6 class TheOneRingPresence(object):
11 ONLINE: telepathy.constants.CONNECTION_PRESENCE_TYPE_AVAILABLE,
12 BUSY: telepathy.constants.CONNECTION_PRESENCE_TYPE_BUSY,
16 class SimplePresenceMixin(telepathy.server.ConnectionInterfaceSimplePresence):
19 telepathy.server.ConnectionInterfaceSimplePresence.__init__(self)
21 dbus_interface = 'org.freedesktop.Telepathy.Connection.Interface.SimplePresence'
23 self._implement_property_get(dbus_interface, {'Statuses' : self._get_statuses})
26 def gvoice_backend(self):
30 raise NotImplementedError()
32 def GetPresences(self, contacts):
34 @todo Figure out how to know when its self and get whether busy or not
36 @return {ContactHandle: (Status, Presence Type, Message)}
39 for handleId in contacts:
40 handle = self.handle(telepathy.HANDLE_TYPE_CONTACT, handleId)
42 presence = TheOneRingPresence.BUSY
44 presenceType = TheOneRingPresence.TO_PRESENCE_TYPE[presence]
46 presences[handle] = (presenceType, presence, personalMessage)
49 def SetPresence(self, status, message):
51 raise telepathy.errors.InvalidArgument
53 if status == TheOneRingPresence.ONLINE:
54 self.gvoice_backend.mark_dnd(True)
55 elif status == TheOneRingPresence.BUSY:
56 self.gvoice_backend.mark_dnd(False)
58 raise telepathy.errors.InvalidArgument
59 logging.info("Setting Presence to '%s'" % status)
62 def _get_statuses(self):
64 Property mapping presence statuses available to the corresponding presence types
66 @returns {Name: (Telepathy Type, May Set On Self, Can Have Message)}
69 TheOneRingPresence.ONLINE: (
70 telepathy.CONNECTION_PRESENCE_TYPE_AVAILABLE,
73 TheOneRingPresence.BUSY: (
74 telepathy.CONNECTION_PRESENCE_TYPE_AWAY,