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()
42 raise NotImplementedError("Abstract property called")
44 @gtk_toolbox.log_exception(_moduleLogger)
45 def GetPresences(self, contacts):
47 @todo Figure out how to know when its self and get whether busy or not
49 @return {ContactHandle: (Status, Presence Type, Message)}
52 for handleId in contacts:
53 handle = self.handle(telepathy.HANDLE_TYPE_CONTACT, handleId)
55 presence = TheOneRingPresence.BUSY
57 presenceType = TheOneRingPresence.TO_PRESENCE_TYPE[presence]
59 presences[handle] = (presenceType, presence, personalMessage)
62 @gtk_toolbox.log_exception(_moduleLogger)
63 def SetPresence(self, status, message):
65 raise telepathy.errors.InvalidArgument("Messages aren't supported")
67 if status == TheOneRingPresence.ONLINE:
68 self.gvoice_backend.mark_dnd(True)
69 elif status == TheOneRingPresence.BUSY:
70 raise telepathy.errors.NotAvailable("DnD support not yet added to TheOneRing")
71 self.gvoice_backend.mark_dnd(False)
73 raise telepathy.errors.InvalidArgument("Unsupported status: %r" % status)
74 _moduleLogger.info("Setting Presence to '%s'" % status)
77 def _get_statuses(self):
79 Property mapping presence statuses available to the corresponding presence types
81 @returns {Name: (Telepathy Type, May Set On Self, Can Have Message)}
84 TheOneRingPresence.ONLINE: (
85 telepathy.CONNECTION_PRESENCE_TYPE_AVAILABLE,
88 TheOneRingPresence.BUSY: (
89 telepathy.CONNECTION_PRESENCE_TYPE_AWAY,