services/presence/server_plugin: Call _handle_connection_status_change with appropriate arguments

Also reduce number of methods by using nested functions for trivial Connect()
reply handlers.
This commit is contained in:
Simon McVittie 2007-05-24 13:04:00 +01:00
parent e13728f347
commit a450a82e59

View File

@ -41,6 +41,7 @@ from telepathy.constants import (HANDLE_TYPE_CONTACT,
CONNECTION_STATUS_CONNECTED, CONNECTION_STATUS_DISCONNECTED, CONNECTION_STATUS_CONNECTED, CONNECTION_STATUS_DISCONNECTED,
CONNECTION_STATUS_CONNECTING, CONNECTION_STATUS_CONNECTING,
CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED, CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED,
CONNECTION_STATUS_REASON_NONE_SPECIFIED,
PROPERTY_FLAG_WRITE) PROPERTY_FLAG_WRITE)
from sugar import util from sugar import util
@ -303,14 +304,6 @@ class ServerPlugin(gobject.GObject):
"""Retrieve our telepathy.client.Connection object""" """Retrieve our telepathy.client.Connection object"""
return self._conn return self._conn
def _connect_reply_cb(self):
"""Handle connection success"""
pass
def _connect_error_cb(self, exception):
"""Handle connection failure"""
_logger.debug("Connect error: %s", exception)
def _init_connection(self): def _init_connection(self):
"""Set up our connection """Set up our connection
@ -350,11 +343,18 @@ class ServerPlugin(gobject.GObject):
self._conn = conn self._conn = conn
status = self._conn[CONN_INTERFACE].GetStatus() status = self._conn[CONN_INTERFACE].GetStatus()
if status == CONNECTION_STATUS_DISCONNECTED: if status == CONNECTION_STATUS_DISCONNECTED:
self._conn[CONN_INTERFACE].Connect( def connect_reply():
reply_handler=self._connect_reply_cb, _logger.debug('Connect() succeeded')
error_handler=self._connect_error_cb) def connect_error(e):
self._handle_connection_status_change(self._conn, status) _logger.debug('Connect() failed: %s', e)
self._conn[CONN_INTERFACE].Connect(reply_handler=connect_reply,
error_handler=connect_error)
self._handle_connection_status_change(status,
CONNECTION_STATUS_REASON_NONE_SPECIFIED)
def _request_list_channel(self, name): def _request_list_channel(self, name):
"""Request a contact-list channel from Telepathy """Request a contact-list channel from Telepathy