6 class TheOneRingPresence(object):
11 ONLINE: telepathy.constants.CONNECTION_PRESENCE_TYPE_AVAILABLE,
12 BUSY: telepathy.constants.CONNECTION_PRESENCE_TYPE_BUSY,
16 class ButterflySimplePresence(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})
25 def GetPresences(self, contacts):
27 @todo Figure out how to know when its self and get whether busy or not
29 @return {ContactHandle: (Status, Presence Type, Message)}
32 for handleId in contacts:
33 handle = self.handle(telepathy.HANDLE_TYPE_CONTACT, handleId)
35 presence = TheOneRingPresence.BUSY
37 presenceType = TheOneRingPresence.TO_PRESENCE_TYPE[presence]
39 presences[handle] = (presenceType, presence, personalMessage)
42 def SetPresence(self, status, message):
44 raise telepathy.errors.InvalidArgument
46 if status == TheOneRingPresence.ONLINE:
47 self._conn.mark_dnd(True)
48 elif status == TheOneRingPresence.BUSY:
49 self._conn.mark_dnd(False)
51 raise telepathy.errors.InvalidArgument
52 logging.info("Setting Presence to '%s'" % status)
55 def _get_statuses(self):
57 Property mapping presence statuses available to the corresponding presence types
59 @returns {Name: (Telepathy Type, May Set On Self, Can Have Message)}
62 TheOneRingPresence.ONLINE: (
63 telepathy.CONNECTION_PRESENCE_TYPE_AVAILABLE,
66 TheOneRingPresence.BUSY: (
67 telepathy.CONNECTION_PRESENCE_TYPE_AWAY,