Ticket #1151: presenceservice.patch

File presenceservice.patch, 3.4 KB (added by dsd, 15 years ago)

presence service patch

  • telepathy_plugin.py

    old new  
    154154        self._ip4am_sigid = self._ip4am.connect('address-changed',
    155155                self._ip4_address_changed_cb)
    156156
     157    def reload_account_info(self):
     158        self._account = self._get_account_info()
     159
    157160    @property
    158161    def status(self):
    159162        """Return the Telepathy connection status."""
  • presenceservice.py

    old new  
    5656        # Overridden by TestPresenceService
    5757        return ShellOwner(self, self._session_bus)
    5858
     59    def _setup_tp(self, tp):
     60        self._handles_buddies[tp] = {}
     61        self._activities_by_handle[tp] = {}
     62
     63        tp.connect('status', self._tp_status_cb)
     64        tp.connect('contacts-online', self._contacts_online)
     65        tp.connect('contacts-offline', self._contacts_offline)
     66        tp.connect('activity-invitation',
     67                                    self._activity_invitation)
     68        tp.connect('private-invitation',
     69                                    self._private_invitation)
     70        tp.connect('want-to-connect', self._want_to_connect)
     71
    5972    def __init__(self):
    6073        self._next_object_id = 0
    6174
     
    115128        self._connected_plugins = set()
    116129
    117130        for tp in self._plugins:
    118             self._handles_buddies[tp] = {}
    119             self._activities_by_handle[tp] = {}
    120 
    121             tp.connect('status', self._tp_status_cb)
    122             tp.connect('contacts-online', self._contacts_online)
    123             tp.connect('contacts-offline', self._contacts_offline)
    124             tp.connect('activity-invitation',
    125                                         self._activity_invitation)
    126             tp.connect('private-invitation',
    127                                         self._private_invitation)
    128             tp.connect('want-to-connect', self._want_to_connect)
     131            self._setup_tp(tp)
    129132            tp.start()
    130133
    131134        self._contacts_online_queue = []
     
    271274            for match in matches:
    272275                match.remove()
    273276
     277    @dbus.service.method(PRESENCE_INTERFACE, in_signature="",
     278            out_signature="")
     279    def RetryConnections(self):
     280        """Reload configuration and retry connections on all managers."""
     281        self._owner.reload_config()
     282        if self._server_plugin is None:
     283            server = self._owner.get_server()
     284            if server and len(server):
     285                tp = ServerPlugin(self._registry, self._owner)
     286                self._setup_tp(tp)
     287                self._server_plugin = tp
     288                self._plugins.append(self._server_plugin)
     289
     290        for tp in self._plugins:
     291            tp.reload_account_info()
     292            tp.start()
     293
    274294    def get_buddy_by_path(self, path):
    275295        """Get the Buddy object corresponding to an object-path, or None.
    276296
  • buddy.py

    old new  
    984984        # we already know our own nick, color, key
    985985        self._awaiting = None
    986986
     987    def reload_config(self):
     988        profile = get_profile()
     989        profile.reload()
     990        self._server = profile.jabber_server
     991
    987992    def _icon_changed_cb(self, icon):
    988993        """Handle icon change, set property to generate event"""
    989994        icon = str(icon)