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-13 16:08:15 (GMT)
committer Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>2008-02-13 16:08:15 (GMT)
commit7295d3dc9d36fdd8b5b567fad6b57519a5b86719 (patch)
tree24053d7d156a338821eadd3261e8a43ea33cf4f2
parent32252890131ad7a01b0cc891168cc1a469da9a06 (diff)
parent42dfdb27f761c23904ece7d61db1d6c2150edab8 (diff)
Merge commit 'origin/master' into 6299
-rw-r--r--configure.ac2
-rw-r--r--src/buddy.py19
-rw-r--r--src/pstest.py4
-rw-r--r--src/server_plugin.py41
4 files changed, 25 insertions, 41 deletions
diff --git a/configure.ac b/configure.ac
index 82bc99b..ecd354f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([Sugar Presence Service],[0.79.0],[],[sugar-presence-service])
+AC_INIT([Sugar Presence Service],[0.79.1],[],[sugar-presence-service])
AC_PREREQ([2.59])
diff --git a/src/buddy.py b/src/buddy.py
index d828064..84da0a7 100644
--- a/src/buddy.py
+++ b/src/buddy.py
@@ -660,7 +660,6 @@ class GenericOwner(Buddy):
self._ps = ps
self._server = kwargs.pop("server", None)
self._key_hash = kwargs.pop("key_hash", None)
- self._registered = kwargs.pop("registered", False)
#: Telepathy plugin -> dict { activity ID -> room handle }
self._activities_by_connection = {}
@@ -912,10 +911,6 @@ class GenericOwner(Buddy):
props = {_PROP_IP4_ADDRESS: address}
self.set_properties(props)
- def get_registered(self):
- """Retrieve whether owner has registered with presence server"""
- return self._registered
-
def get_server(self):
"""Retrieve XMPP server hostname (used by the server plugin)"""
return self._server
@@ -926,10 +921,6 @@ class GenericOwner(Buddy):
"""
return self._key_hash
- def set_registered(self, registered):
- """Customisation point: handle the registration of the owner"""
- raise RuntimeError("Subclasses must implement")
-
def update_avatar(self, tp, new_avatar_token, icon=None, mime_type=None):
# This should never get called because Owner avatar changes are
# driven by the Sugar shell, but just in case:
@@ -963,7 +954,6 @@ class ShellOwner(GenericOwner):
profile = get_profile()
server = profile.jabber_server
- registered = profile.jabber_registered
key_hash = profile.privkey_hash
key = profile.pubkey
nick = profile.nick_name
@@ -977,7 +967,7 @@ class ShellOwner(GenericOwner):
GenericOwner.__init__(self, ps, bus,
'keyid/' + psutils.pubkey_to_keyid(key),
key=key, nick=nick, color=color, icon=icon, server=server,
- key_hash=key_hash, registered=registered)
+ key_hash=key_hash)
# Ask to get notifications on Owner object property changes in the
# shell. If it's not currently running, no problem - we'll get the
@@ -994,13 +984,6 @@ class ShellOwner(GenericOwner):
# we already know our own nick, color, key
self._awaiting = None
- def set_registered(self, value):
- """Handle notification that we have been registered"""
- if value:
- profile = get_profile()
- profile.jabber_registered = True
- profile.save()
-
def _icon_changed_cb(self, icon):
"""Handle icon change, set property to generate event"""
icon = str(icon)
diff --git a/src/pstest.py b/src/pstest.py
index b3c8183..e7a0fa4 100644
--- a/src/pstest.py
+++ b/src/pstest.py
@@ -110,10 +110,6 @@ class TestOwner(GenericOwner):
if self._change_timeout == 0:
self._change_timeout = gobject.timeout_add(10000, self._update_something)
- def set_registered(self, value):
- if value:
- self._registered = True
-
def _load_config(self):
if not os.path.exists(self._cfg_file):
return (None, None, False)
diff --git a/src/server_plugin.py b/src/server_plugin.py
index 0a7ef71..8d0a4f0 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)