5 import dbus.mainloop.glib
9 DBUS_PROPERTIES = 'org.freedesktop.DBus.Properties'
12 class AutoAcceptCall(object):
15 self._sessionBus = dbus.SessionBus()
19 self._sessionBus.add_signal_receiver(
22 "org.freedesktop.Telepathy.Connection",
27 def _on_new_channel(self, channelObjectPath, channelType, handleType, handle, supressHandler):
28 if channelType != telepathy.interfaces.CHANNEL_TYPE_STREAMED_MEDIA:
31 serviceName = channelObjectPath.rsplit("/", 1)[0][1:].replace("/", ".")
32 self._chan = telepathy.client.Channel(serviceName, channelObjectPath)
34 # @bug Unsure why this isn't working
35 self._chan[DBUS_PROPERTIES].Get(
36 telepathy.interfaces.CHANNEL_INTERFACE_GROUP,
37 'LocalPendingMembers',
38 reply_handler = self._on_got_pending_members,
39 error_handler = self._on_nothing,
42 self._chan[telepathy.interfaces.CHANNEL_INTERFACE_GROUP].GetLocalPendingMembersWithInfo(
43 reply_handler = self._on_got_pending_members,
44 error_handler = self._on_nothing,
47 def _on_got_pending_members(self, pendings):
48 for pendingHandle, instigatorHandle, reason, message in pendings:
49 print pendingHandle, instigatorHandle, reason, message
51 # @bug does not distinguish between inbound and outbound channels
52 # @bug does not distinguish between who the call is from for use for TOR auto-pickup
53 pendingHandles = [pendingWithInfo[0] for pendingWithInfo in pendings]
54 self._chan[telepathy.interfaces.CHANNEL_INTERFACE_GROUP].AddMembers(
55 reply_handler = self._on_members_added,
56 error_handler = self._on_nothing,
59 def _on_members_added(self):
60 print "Should be picked up now"
62 def _on_nothing(*args):
66 if __name__ == "__main__":
67 l = dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
68 autoaccept = AutoAcceptCall()
70 gobject.threads_init()
71 gobject.idle_add(autoaccept.start)
73 mainloop = gobject.MainLoop(is_running=True)