Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/server_plugin.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/server_plugin.py')
-rw-r--r--src/server_plugin.py41
1 files changed, 23 insertions, 18 deletions
diff --git a/src/server_plugin.py b/src/server_plugin.py
index 9ebc8d9..4a32042 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_NAME_IN_USE)
+ CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED)
import sugar.profile
# Presence Service local modules
@@ -76,7 +76,10 @@ class ServerPlugin(TelepathyPlugin):
self._stop()
def _get_account_info(self):
- """Retrieve connection manager parameters for this account
+ """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.
"""
server = self._owner.get_server()
khash = psutils.pubkey_to_keyid(self._owner.props.key)
@@ -85,7 +88,7 @@ class ServerPlugin(TelepathyPlugin):
'account': "%s@%s" % (khash, server),
'fallback-conference-server': "conference.%s" % server,
'password': self._owner.get_key_hash(),
- 'register': not self._owner.get_registered(),
+ 'register': False,
'port': dbus.UInt32(5223),
'old-ssl': True,
'ignore-ssl-errors': True,
@@ -234,10 +237,6 @@ 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
@@ -305,20 +304,26 @@ class ServerPlugin(TelepathyPlugin):
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)."""
+ 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."""
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
+ 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
TelepathyPlugin._handle_connection_status_change(self, status, reason)