From 1351084b0cd16c5bb92d5689da3f11ada3c7cee6 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Wed, 13 Feb 2008 16:46:15 +0000 Subject: add a want-to-connect signal to tp plugin so presenceservice.py can accept or decline the request according to its policy --- diff --git a/src/presenceservice.py b/src/presenceservice.py index 02a5ba4..0c51f61 100644 --- a/src/presenceservice.py +++ b/src/presenceservice.py @@ -125,6 +125,7 @@ class PresenceService(ExportedGObject): self._activity_invitation) tp.connect('private-invitation', self._private_invitation) + tp.connect('want-to-connect', self._want_to_connect) tp.start() self._contacts_online_queue = [] @@ -572,6 +573,19 @@ class PresenceService(ExportedGObject): self.PrivateInvitation(str(conn.service_name), conn.object_path, chan_path) + def _want_to_connect(self, plugin): + if plugin == self._ll_plugin: + # Link-local plugin can connect only if the Server plugin isn't + # connected + if not self._server_plugin or \ + self._server_plugin.status != CONNECTION_STATUS_CONNECTED: + plugin.start() + + elif plugin == self._server_plugin: + # Server plugin can always try to connect + plugin.start() + + @dbus.service.signal(PRESENCE_INTERFACE, signature="o") def ActivityAppeared(self, activity): pass diff --git a/src/telepathy_plugin.py b/src/telepathy_plugin.py index 0fb4b05..b4581d8 100644 --- a/src/telepathy_plugin.py +++ b/src/telepathy_plugin.py @@ -75,6 +75,10 @@ class TelepathyPlugin(gobject.GObject): # args: # channel object path (gobject.SIGNAL_RUN_FIRST, None, [object]), + 'want-to-connect': + # The TelepathyPlugin wants to connect. presenceservice.py will + # call the start() method if that's OK with its policy. + (gobject.SIGNAL_RUN_FIRST, None, []), } _RECONNECT_INITIAL_TIMEOUT = 5000 # 5 seconds -- cgit v0.9.1