diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2007-05-25 10:39:45 (GMT) |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2007-05-25 10:39:45 (GMT) |
commit | 7b0d65a21147388790dc6e490d8735d93759762e (patch) | |
tree | f07f39016ac2d87b41180943f60b343cf7ba4346 /services | |
parent | eafd338d093ef78752466a88c14a87e4c9e864b4 (diff) | |
parent | c1346a530301a420eb30918f45dc18b142fa1589 (diff) |
Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar
Diffstat (limited to 'services')
-rw-r--r-- | services/presence/server_plugin.py | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/services/presence/server_plugin.py b/services/presence/server_plugin.py index e6fd395..f0d988c 100644 --- a/services/presence/server_plugin.py +++ b/services/presence/server_plugin.py @@ -58,6 +58,7 @@ _OBJ_PATH_PREFIX = "/org/freedesktop/Telepathy/Connection/gabble/jabber/" _logger = logging.getLogger('s-p-s.server_plugin') +_RECONNECT_TIMEOUT = 5000 def _buddy_icon_save_cb(buf, data): data[0] += buf @@ -349,6 +350,9 @@ class ServerPlugin(gobject.GObject): _logger.debug('Connect() succeeded') def connect_error(e): _logger.debug('Connect() failed: %s', e) + if not self._reconnect_id: + self._reconnect_id = gobject.timeout_add(_RECONNECT_TIMEOUT, + self._reconnect_cb) self._conn[CONN_INTERFACE].Connect(reply_handler=connect_reply, error_handler=connect_error) @@ -648,15 +652,9 @@ class ServerPlugin(gobject.GObject): return handle return None - def _start_helper(self): - """Helper so start() doesn't have to return False""" - self.start() - return False - def _reconnect_cb(self): - """Schedule a reconnection attempt""" - gobject.idle_add(self._start_helper) - self._reconnect_id = 0 + """Attempt to reconnect to the server""" + self.start() return False def _handle_connection_status_change(self, status, reason): @@ -684,8 +682,8 @@ class ServerPlugin(gobject.GObject): # If disconnected and no network connection, do nothing here # and let the IP4AddressMonitor address-changed signal handle # reconnection - if self._ip4am.props.address: - self._reconnect_id = gobject.timeout_add(5000, + if self._ip4am.props.address and not self._reconnect_id: + self._reconnect_id = gobject.timeout_add(_RECONNECT_TIMEOUT, self._reconnect_cb) self.emit('status', self._conn_status, int(reason)) |