8 _moduleLogger = logging.getLogger("simple_presence")
11 class TheOneRingPresence(object):
16 ONLINE: telepathy.constants.CONNECTION_PRESENCE_TYPE_AVAILABLE,
17 BUSY: telepathy.constants.CONNECTION_PRESENCE_TYPE_BUSY,
21 class SimplePresenceMixin(telepathy.server.ConnectionInterfaceSimplePresence):
24 telepathy.server.ConnectionInterfaceSimplePresence.__init__(self)
26 dbus_interface = 'org.freedesktop.Telepathy.Connection.Interface.SimplePresence'
28 self._implement_property_get(dbus_interface, {'Statuses' : self._get_statuses})
35 raise NotImplementedError()
37 @gtk_toolbox.log_exception(_moduleLogger)
38 def GetPresences(self, contacts):
40 @todo Figure out how to know when its self and get whether busy or not
42 @return {ContactHandle: (Status, Presence Type, Message)}
45 for handleId in contacts:
46 handle = self.handle(telepathy.HANDLE_TYPE_CONTACT, handleId)
48 presence = TheOneRingPresence.BUSY
50 presenceType = TheOneRingPresence.TO_PRESENCE_TYPE[presence]
52 presences[handle] = (presenceType, presence, personalMessage)
55 @gtk_toolbox.log_exception(_moduleLogger)
56 def SetPresence(self, status, message):
58 raise telepathy.errors.InvalidArgument
60 if status == TheOneRingPresence.ONLINE:
61 self.gvoice_backend.mark_dnd(True)
62 elif status == TheOneRingPresence.BUSY:
63 self.gvoice_backend.mark_dnd(False)
65 raise telepathy.errors.InvalidArgument
66 _moduleLogger.info("Setting Presence to '%s'" % status)
69 def _get_statuses(self):
71 Property mapping presence statuses available to the corresponding presence types
73 @returns {Name: (Telepathy Type, May Set On Self, Can Have Message)}
76 TheOneRingPresence.ONLINE: (
77 telepathy.CONNECTION_PRESENCE_TYPE_AVAILABLE,
80 TheOneRingPresence.BUSY: (
81 telepathy.CONNECTION_PRESENCE_TYPE_AWAY,