Reducing not-helpful traces
[theonering] / src / simple_presence.py
index 7cad575..bda9fed 100644 (file)
@@ -2,12 +2,13 @@ import logging
 
 import telepathy
 
-import gtk_toolbox
+import util.misc as misc_utils
+import tp
 import handle
 import gvoice.state_machine as state_machine
 
 
-_moduleLogger = logging.getLogger("simple_presence")
+_moduleLogger = logging.getLogger(__name__)
 
 
 class TheOneRingPresence(object):
@@ -38,7 +39,7 @@ class TheOneRingPresence(object):
                """
                raise NotImplementedError("Abstract function called")
 
-       def handle(self, handleType, handleId):
+       def get_handle_by_id(self, handleType, handleId):
                """
                @abstract
                """
@@ -50,9 +51,9 @@ class TheOneRingPresence(object):
                """
                presences = {}
                for handleId in contactIds:
-                       h = self.handle(telepathy.HANDLE_TYPE_CONTACT, handleId)
+                       h = self.get_handle_by_id(telepathy.HANDLE_TYPE_CONTACT, handleId)
                        if isinstance(h, handle.ConnectionHandle):
-                               isDnd = self.session.backend.is_dnd()
+                               isDnd = self.session.is_dnd()
                                if isDnd:
                                        presence = TheOneRingPresence.HIDDEN
                                else:
@@ -65,7 +66,7 @@ class TheOneRingPresence(object):
                                                raise telepathy.errors.InvalidArgument("Unsupported state on the state machine: %s" % state)
                                presenceType = TheOneRingPresence.TO_PRESENCE_TYPE[presence]
                        else:
-                               presence = TheOneRingPresence.ONLINE
+                               presence = TheOneRingPresence.AWAY
                                presenceType = TheOneRingPresence.TO_PRESENCE_TYPE[presence]
 
                        presences[h] = (presenceType, presence)
@@ -73,12 +74,12 @@ class TheOneRingPresence(object):
 
        def set_presence(self, status):
                if status == self.ONLINE:
-                       self.session.backend.set_dnd(False)
+                       self.session.set_dnd(False)
                        self.session.stateMachine.set_state(state_machine.StateMachine.STATE_ACTIVE)
                elif status == self.AWAY:
                        self.session.stateMachine.set_state(state_machine.StateMachine.STATE_IDLE)
                elif status == self.HIDDEN:
-                       self.session.backend.set_dnd(True)
+                       self.session.set_dnd(True)
                elif status == self.OFFLINE:
                        self.Disconnect()
                else:
@@ -86,18 +87,18 @@ class TheOneRingPresence(object):
                _moduleLogger.info("Setting Presence to '%s'" % status)
 
 
-class SimplePresenceMixin(telepathy.server.ConnectionInterfaceSimplePresence, TheOneRingPresence):
+class SimplePresenceMixin(tp.ConnectionInterfaceSimplePresence, TheOneRingPresence):
 
        def __init__(self):
-               telepathy.server.ConnectionInterfaceSimplePresence.__init__(self)
+               tp.ConnectionInterfaceSimplePresence.__init__(self)
                TheOneRingPresence.__init__(self)
 
                self._implement_property_get(
-                       telepathy.server.CONNECTION_INTERFACE_SIMPLE_PRESENCE,
+                       tp.CONNECTION_INTERFACE_SIMPLE_PRESENCE,
                        {'Statuses' : self._get_statuses}
                )
 
-       @gtk_toolbox.log_exception(_moduleLogger)
+       @misc_utils.log_exception(_moduleLogger)
        def GetPresences(self, contacts):
                """
                @return {ContactHandle: (Status, Presence Type, Message)}
@@ -108,7 +109,7 @@ class SimplePresenceMixin(telepathy.server.ConnectionInterfaceSimplePresence, Th
                        for (h, (presenceType, presence)) in self.get_presences(contacts).iteritems()
                )
 
-       @gtk_toolbox.log_exception(_moduleLogger)
+       @misc_utils.log_exception(_moduleLogger)
        def SetPresence(self, status, message):
                if message:
                        raise telepathy.errors.InvalidArgument("Messages aren't supported")