6 _moduleLogger = logging.getLogger("simple_presence")
9 class TheOneRingPresence(object):
14 ONLINE: telepathy.constants.CONNECTION_PRESENCE_TYPE_AVAILABLE,
15 BUSY: telepathy.constants.CONNECTION_PRESENCE_TYPE_BUSY,
19 class SimplePresenceMixin(telepathy.server.ConnectionInterfaceSimplePresence):
22 telepathy.server.ConnectionInterfaceSimplePresence.__init__(self)
24 dbus_interface = 'org.freedesktop.Telepathy.Connection.Interface.SimplePresence'
26 self._implement_property_get(dbus_interface, {'Statuses' : self._get_statuses})
29 def gvoice_backend(self):
33 raise NotImplementedError()
35 def GetPresences(self, contacts):
37 @todo Figure out how to know when its self and get whether busy or not
39 @return {ContactHandle: (Status, Presence Type, Message)}
42 for handleId in contacts:
43 handle = self.handle(telepathy.HANDLE_TYPE_CONTACT, handleId)
45 presence = TheOneRingPresence.BUSY
47 presenceType = TheOneRingPresence.TO_PRESENCE_TYPE[presence]
49 presences[handle] = (presenceType, presence, personalMessage)
52 def SetPresence(self, status, message):
54 raise telepathy.errors.InvalidArgument
56 if status == TheOneRingPresence.ONLINE:
57 self.gvoice_backend.mark_dnd(True)
58 elif status == TheOneRingPresence.BUSY:
59 self.gvoice_backend.mark_dnd(False)
61 raise telepathy.errors.InvalidArgument
62 _moduleLogger.info("Setting Presence to '%s'" % status)
65 def _get_statuses(self):
67 Property mapping presence statuses available to the corresponding presence types
69 @returns {Name: (Telepathy Type, May Set On Self, Can Have Message)}
72 TheOneRingPresence.ONLINE: (
73 telepathy.CONNECTION_PRESENCE_TYPE_AVAILABLE,
76 TheOneRingPresence.BUSY: (
77 telepathy.CONNECTION_PRESENCE_TYPE_AWAY,