import simple_presence
+_moduleLogger = logging.getLogger("connection")
+
+
class TheOneRingConnection(telepathy.server.Connection, simple_presence.SimplePresenceMixin):
MANDATORY_PARAMETERS = {
self.set_self_handle(handle.create_handle(self, 'connection'))
- logging.info("Connection to the account %s created" % account)
+ _moduleLogger.info("Connection to the account %s created" % account)
except Exception, e:
- logging.exception("Failed to create Connection")
+ _moduleLogger.exception("Failed to create Connection")
raise
@property
"""
For org.freedesktop.telepathy.Connection
"""
+ self.StatusChanged(
+ telepathy.CONNECTION_STATUS_CONNECTING,
+ telepathy.CONNECTION_STATUS_REASON_REQUESTED
+ )
try:
self._backend.login(*self._credentials)
+ except gv_backend.NetworkError:
self.StatusChanged(
- telepathy.CONNECTION_STATUS_CONNECTED,
- telepathy.CONNECTION_STATUS_REASON_REQUESTED
+ telepathy.CONNECTION_STATUS_DISCONNECTED,
+ telepathy.CONNECTION_STATUS_REASON_NETWORK_ERROR
)
- logging.info("Connected")
except Exception:
self.StatusChanged(
telepathy.CONNECTION_STATUS_DISCONNECTED,
telepathy.CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED
)
- logging.exception("Connecting Failed")
+ else:
+ self.StatusChanged(
+ telepathy.CONNECTION_STATUS_CONNECTED,
+ telepathy.CONNECTION_STATUS_REASON_REQUESTED
+ )
def Disconnect(self):
"""
"""
try:
self._backend.logout()
- logging.info("Disconnected")
+ _moduleLogger.info("Disconnected")
except Exception:
- logging.exception("Disconnecting Failed")
+ _moduleLogger.exception("Disconnecting Failed")
+ self.StatusChanged(
+ telepathy.CONNECTION_STATUS_DISCONNECTED,
+ telepathy.CONNECTION_STATUS_REASON_REQUESTED
+ )
def RequestChannel(self, type, handleType, handleId, suppressHandler):
"""