diff options
author | Jonas Smedegaard <dr@jones.dk> | 2008-03-08 20:19:58 (GMT) |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2008-03-08 20:19:58 (GMT) |
commit | 95253f88614ec74a3b3af3feede9f86a7f64c920 (patch) | |
tree | 5b6346f88a0bad63bce04c4156d399c9d3245916 /src/server_plugin.py | |
parent | 08b95a75bd515a209d838957b5fdd5e9e2ac06cf (diff) |
Imported Upstream version 0.79.0upstream/0.79.0
Diffstat (limited to 'src/server_plugin.py')
-rw-r--r-- | src/server_plugin.py | 47 |
1 files changed, 21 insertions, 26 deletions
diff --git a/src/server_plugin.py b/src/server_plugin.py index f862ce4..9ebc8d9 100644 --- a/src/server_plugin.py +++ b/src/server_plugin.py @@ -32,7 +32,7 @@ from telepathy.interfaces import (CONN_MGR_INTERFACE, CONN_INTERFACE, from telepathy.constants import (HANDLE_TYPE_CONTACT, HANDLE_TYPE_GROUP, CONNECTION_STATUS_CONNECTED, CONNECTION_STATUS_DISCONNECTED, CHANNEL_GROUP_FLAG_CHANNEL_SPECIFIC_HANDLES, - CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED) + CONNECTION_STATUS_REASON_NAME_IN_USE) import sugar.profile # Presence Service local modules @@ -62,24 +62,21 @@ class ServerPlugin(TelepathyPlugin): self._friends_channel = None - def _ip4_address_changed_cb(self, ip4am, address, iface): - TelepathyPlugin._ip4_address_changed_cb(self, ip4am, address, iface) + def _ip4_address_changed_cb(self, ip4am, address): + TelepathyPlugin._ip4_address_changed_cb(self, ip4am, address) if address: _logger.debug("::: valid IP4 address, conn_status %s" % self._conn_status) # this is a no-op if starting would be inappropriate right now if self._conn_status != CONNECTION_STATUS_CONNECTED: - self.emit('want-to-connect') + self.start() else: _logger.debug("::: invalid IP4 address, will disconnect") self._stop() def _get_account_info(self): - """Retrieve connection manager parameters for this account. - We first try to connect without the register flag. If the connection - fails because of an authentication error we'll try to register - the account. + """Retrieve connection manager parameters for this account """ server = self._owner.get_server() khash = psutils.pubkey_to_keyid(self._owner.props.key) @@ -88,7 +85,7 @@ class ServerPlugin(TelepathyPlugin): 'account': "%s@%s" % (khash, server), 'fallback-conference-server': "conference.%s" % server, 'password': self._owner.get_key_hash(), - 'register': False, + 'register': not self._owner.get_registered(), 'port': dbus.UInt32(5223), 'old-ssl': True, 'ignore-ssl-errors': True, @@ -237,6 +234,10 @@ class ServerPlugin(TelepathyPlugin): return ret def _connected_cb(self): + if not self._owner.get_registered(): + # we successfully register this account + self._owner.set_registered(True) + TelepathyPlugin._connected_cb(self) # request Friends group channel @@ -304,26 +305,20 @@ class ServerPlugin(TelepathyPlugin): def _handle_connection_status_change(self, status, reason): """Override TelepathyPlugin implementation to manage connection errors - due to authentication problem. If the connection fails because of an - authentication error that's probably because the account isn't - registered yet on the server. So we try to register it. - If it fails because any other reason we unset the register flag so futur - connection attempts won't try to register until we got a new - authentication error. This should properly handle the "XO having to use - different jabber servers" use case.""" + due to registration problem. So, if for any reason the registered flag + was not set in the config file but the account was registered, we don't + fail to connect (see ticket #2062).""" if status == self._conn_status: return - if status == CONNECTION_STATUS_DISCONNECTED: - if reason == CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED and \ - not self._account['register']: - _logger.debug('Authentication failed. Trying to register the account') - self._account['register'] = True - self._stop() - self._init_connection() - return - else: - self._account['register'] = False + if (status == CONNECTION_STATUS_DISCONNECTED and + reason == CONNECTION_STATUS_REASON_NAME_IN_USE and + self._account['register']): + _logger.debug('This account is already registered. Connect to it') + self._account['register'] = False + self._stop() + self._init_connection() + return TelepathyPlugin._handle_connection_status_change(self, status, reason) |