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 Morgan Collett <morgan.collett@gmail.com>2008-02-12 14:21:10 (GMT)
commit210eb6412317e7e4387bbe4caf5231d6e7d30f0a (patch)
tree484a7e43ab335f05e703a9b7e0ba0ee51e02cb63
parent2b62954d76443c7544521b06ca00061741fea71e (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