X-Git-Url: http://git.maemo.org/git/?p=theonering;a=blobdiff_plain;f=src%2Fsimple_presence.py;h=29deb887c06f7664547299e02ef65e72ef95f641;hp=44e5c50bac66c50609d6102c6ce021882717c58b;hb=5dfd64ee4ce4d38f44cddd566dafa59e6139cad7;hpb=51beca2c54c6a5a5e8dd92f5df0d81fd67406a97 diff --git a/src/simple_presence.py b/src/simple_presence.py index 44e5c50..29deb88 100644 --- a/src/simple_presence.py +++ b/src/simple_presence.py @@ -2,6 +2,11 @@ import logging import telepathy +import gtk_toolbox + + +_moduleLogger = logging.getLogger("simple_presence") + class TheOneRingPresence(object): ONLINE = 'available' @@ -13,7 +18,7 @@ class TheOneRingPresence(object): } -class ButterflySimplePresence(telepathy.server.ConnectionInterfaceSimplePresence): +class SimplePresenceMixin(telepathy.server.ConnectionInterfaceSimplePresence): def __init__(self): telepathy.server.ConnectionInterfaceSimplePresence.__init__(self) @@ -22,6 +27,21 @@ class ButterflySimplePresence(telepathy.server.ConnectionInterfaceSimplePresence self._implement_property_get(dbus_interface, {'Statuses' : self._get_statuses}) + @property + def session(self): + """ + @abstract + """ + raise NotImplementedError() + + @property + def handle(self): + """ + @abstract + """ + raise NotImplementedError("Abstract property called") + + @gtk_toolbox.log_exception(_moduleLogger) def GetPresences(self, contacts): """ @todo Figure out how to know when its self and get whether busy or not @@ -39,17 +59,19 @@ class ButterflySimplePresence(telepathy.server.ConnectionInterfaceSimplePresence presences[handle] = (presenceType, presence, personalMessage) return presences + @gtk_toolbox.log_exception(_moduleLogger) def SetPresence(self, status, message): if message: - raise telepathy.errors.InvalidArgument + raise telepathy.errors.InvalidArgument("Messages aren't supported") if status == TheOneRingPresence.ONLINE: - self._conn.mark_dnd(True) + self.gvoice_backend.mark_dnd(True) elif status == TheOneRingPresence.BUSY: - self._conn.mark_dnd(False) + raise telepathy.errors.NotAvailable("DnD support not yet added to TheOneRing") + self.gvoice_backend.mark_dnd(False) else: - raise telepathy.errors.InvalidArgument - logging.info("Setting Presence to '%s'" % status) + raise telepathy.errors.InvalidArgument("Unsupported status: %r" % status) + _moduleLogger.info("Setting Presence to '%s'" % status) def _get_statuses(self):