diff options
author | Guillaume Desmottes <cassidy@cass-wks.(none)> | 2007-07-25 15:29:03 (GMT) |
---|---|---|
committer | Guillaume Desmottes <cassidy@cass-wks.(none)> | 2007-07-25 15:29:03 (GMT) |
commit | 27626680395ac8bba95d36bc40160666578b8039 (patch) | |
tree | 4009cd3af1d07be29367539bd8cb33216e3843e9 /src | |
parent | c12024a8172b9aa6d50e9ed15dde98baa84e79ff (diff) |
Try to connect without the register flag if we received the "name in use" error (#2062)
Diffstat (limited to 'src')
-rw-r--r-- | src/server_plugin.py | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/server_plugin.py b/src/server_plugin.py index 9ba0376..75eadb2 100644 --- a/src/server_plugin.py +++ b/src/server_plugin.py @@ -28,7 +28,8 @@ from telepathy.interfaces import (CONN_MGR_INTERFACE, CONN_INTERFACE, CHANNEL_INTERFACE_GROUP) from telepathy.constants import (HANDLE_TYPE_CONTACT, CONNECTION_STATUS_CONNECTED, CONNECTION_STATUS_DISCONNECTED, - CHANNEL_GROUP_FLAG_CHANNEL_SPECIFIC_HANDLES) + CHANNEL_GROUP_FLAG_CHANNEL_SPECIFIC_HANDLES, + CONNECTION_STATUS_REASON_NAME_IN_USE) # Presence Service local modules import psutils @@ -229,7 +230,7 @@ class ServerPlugin(TelepathyPlugin): return ret def _connected_cb(self): - if self._account['register']: + if not self._owner.get_registered(): # we successfully register this account self._owner.set_registered(True) @@ -270,3 +271,22 @@ class ServerPlugin(TelepathyPlugin): if added: self._subscribe_channel[CHANNEL_INTERFACE_GROUP].AddMembers( added, '') + + def _handle_connection_status_change(self, status, reason): + """Override TelepathyPlugin implementation to manage connection errors + 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 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) |