Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2008-02-04 12:29:46 (GMT)
committer Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>2008-02-04 12:29:46 (GMT)
commit74a042d7339dede1dcbd15dff40fffd2ca18879b (patch)
treeac86ff3f9558631527e1508cc454cd14b4579ccf
parent81cfc38857a7bcbbe8680e2acf88859ff880caf9 (diff)
try opportunistic registration if authentication fails (#6295)
-rw-r--r--src/server_plugin.py27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/server_plugin.py b/src/server_plugin.py
index 9ebc8d9..514f949 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 authentification 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,17 +304,17 @@ 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 authentification problem. If the connection fails because of an
+ authentification error that's probably because the account isn't
+ registered yet on the server. So we try to register it."""
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
+ reason == CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED and
+ not self._account['register']):
+ _logger.debug('Authentification failed. Try to register the account')
+ self._account['register'] = True
self._stop()
self._init_connection()
return