Ticket #142: ps-0001--142-D-Bus-method-to-restart-the-server_plugin.patch

File ps-0001--142-D-Bus-method-to-restart-the-server_plugin.patch, 3.5 KB (added by morgs, 15 years ago)

sugar-presence-service patch

  • src/buddy.py

    From ccd2656a216023b7d1aeef2a61bdcb77ddca037a Mon Sep 17 00:00:00 2001
    From: Morgan Collett <morgan.collett@gmail.com>
    Date: Fri, 19 Dec 2008 14:21:34 +0200
    Subject: [PATCH] #142: D-Bus method to restart the server_plugin.
    
    Changes to ShellOwner and GenericOwner to reread the server from gconf on the fly.
    ---
     src/buddy.py            |    9 ++++-----
     src/presenceservice.py  |   12 ++++++++++++
     src/telepathy_plugin.py |    2 ++
     3 files changed, 18 insertions(+), 5 deletions(-)
    
    diff --git a/src/buddy.py b/src/buddy.py
    index 3e8788d..68061c6 100644
    a b class GenericOwner(Buddy): 
    655655        calls Buddy.__init__
    656656        """
    657657        self._ps = ps
    658         self._server = kwargs.pop("server", None)
    659658        self._key_hash = kwargs.pop("key_hash", None)
    660659
    661660        #: Telepathy plugin -> dict { activity ID -> room handle }
    class GenericOwner(Buddy): 
    910909
    911910    def get_server(self):
    912911        """Retrieve XMPP server hostname (used by the server plugin)"""
    913         return self._server
     912        client = gconf.client_get_default()   
     913        server = client.get_string("/desktop/sugar/collaboration/jabber_server")
     914        return server
    914915
    915916    def get_key_hash(self):
    916917        """Retrieve the user's private-key hash (used by the server plugin
    class ShellOwner(GenericOwner): 
    951952        client = gconf.client_get_default()   
    952953        profile = get_profile()
    953954
    954         server = client.get_string("/desktop/sugar/collaboration/jabber_server")
    955955        key_hash = profile.privkey_hash
    956956        key = profile.pubkey
    957957
    class ShellOwner(GenericOwner): 
    965965
    966966        GenericOwner.__init__(self, ps, bus,
    967967                'keyid/' + psutils.pubkey_to_keyid(key),
    968                 key=key, nick=nick, color=color, icon=icon, server=server,
    969                 key_hash=key_hash)
     968                key=key, nick=nick, color=color, icon=icon, key_hash=key_hash)
    970969
    971970        # Ask to get notifications on Owner object property changes in the
    972971        # shell. If it's not currently running, no problem - we'll get the
  • src/presenceservice.py

    diff --git a/src/presenceservice.py b/src/presenceservice.py
    index e68bded..84c3cc2 100644
    a b class PresenceService(ExportedGObject): 
    857857        if self._server_plugin is not None:
    858858            self._server_plugin.sync_friends(keys)
    859859
     860    @dbus.service.method(PRESENCE_INTERFACE, in_signature="",
     861            out_signature="")
     862    def RestartServerConnection(self):
     863        """Stop and restart the server_plugin.
     864       
     865        This allows changing jabber servers without restarting Sugar.
     866        """
     867        if self._server_plugin:
     868            if self._server_plugin.status == CONNECTION_STATUS_CONNECTED:
     869                self._server_plugin.cleanup()
     870                self._server_plugin.start()
     871
    860872def main(test_num=0, randomize=False):
    861873    loop = gobject.MainLoop()
    862874    DBusGMainLoop(set_as_default=True)
  • src/telepathy_plugin.py

    diff --git a/src/telepathy_plugin.py b/src/telepathy_plugin.py
    index 982f7cc..5aca07e 100644
    a b class TelepathyPlugin(gobject.GObject): 
    591591
    592592        # Only init connection if we have a valid IP address
    593593        if self._could_connect():
     594            # Reread account info in case the server changed
     595            self._account = self._get_account_info()
    594596            self._init_connection()
    595597        else:
    596598            _logger.debug('%r: Postponing connection', self)