Attachments you submit will be routed for moderation. If you have an account, please log in first.

Ticket #2296: 0001-Set-param-register-to-False-after-a-RegistrationExis.patch

File 0001-Set-param-register-to-False-after-a-RegistrationExis.patch, 2.4 KB (added by tomeu, 3 years ago)
  • src/jarabe/model/neighborhood.py

    From 885d118b31651bf381b40f6bf10cbd8b28cdc915 Mon Sep 17 00:00:00 2001
    From: Tomeu Vizoso <tomeu.vizoso@collabora.co.uk>
    Date: Mon, 6 Sep 2010 17:48:08 +0200
    Subject: [PATCH] Set param-register to False after a RegistrationExists error #2296
    
    ---
     src/jarabe/model/neighborhood.py |   23 ++++++++++++++++++++++-
     1 files changed, 22 insertions(+), 1 deletions(-)
    
    diff --git a/src/jarabe/model/neighborhood.py b/src/jarabe/model/neighborhood.py
    index 3e89855..9ec6322 100644
    a b  
    199199        logging.debug('_Account.__got_connection_cb %r', connection_path) 
    200200 
    201201        if connection_path == '/': 
    202             # Account has no connection, wait until it has one. 
     202            self._check_registration_error() 
    203203            return 
    204204 
    205205        self._prepare_connection(connection_path) 
    206206 
     207    def _check_registration_error(self): 
     208        """ 
     209        See if a previous connection attempt failed and we need to unset 
     210        the register flag. 
     211        """ 
     212        bus = dbus.Bus() 
     213        obj = bus.get_object(ACCOUNT_MANAGER_SERVICE, self.object_path) 
     214        obj.Get(ACCOUNT, 'ConnectionError', 
     215                reply_handler=self.__got_connection_error_cb, 
     216                error_handler=partial(self.__error_handler_cb, 
     217                                      'Account.GetConnectionError')) 
     218 
     219    def __got_connection_error_cb(self, error): 
     220        logging.debug('_Account.__got_connection_error_cb %r', error) 
     221        if error == 'org.freedesktop.Telepathy.Error.RegistrationExists': 
     222            bus = dbus.Bus() 
     223            obj = bus.get_object(ACCOUNT_MANAGER_SERVICE, self.object_path) 
     224            obj.UpdateParameters({'register': False}, [], 
     225                                 dbus_interface=ACCOUNT) 
     226 
    207227    def __account_property_changed_cb(self, properties): 
    208228        logging.debug('_Account.__account_property_changed_cb %r %r %r', 
    209229                      self.object_path, properties.get('Connection', None), 
     
    211231        if 'Connection' not in properties: 
    212232            return 
    213233        if properties['Connection'] == '/': 
     234            self._check_registration_error() 
    214235            self._connection = None 
    215236        elif self._connection is None: 
    216237            self._prepare_connection(properties['Connection'])