diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2007-08-30 10:01:03 (GMT) |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2007-08-30 10:01:03 (GMT) |
commit | 31a044e763ba3e6f5b82b3d86f88be25357f8b80 (patch) | |
tree | 79ee96fe3ba657bfa4c5ed2af40f74fe46a5692d /src/presenceservice.py | |
parent | 3fa97df4214cda1daa2a343da40ea9b523d4f89c (diff) |
Move NotFoundError to psutils; add NotJoinedError and WrongConnectionError.
Make BUDDY_PATH public too.
Diffstat (limited to 'src/presenceservice.py')
-rw-r--r-- | src/presenceservice.py | 59 |
1 files changed, 20 insertions, 39 deletions
diff --git a/src/presenceservice.py b/src/presenceservice.py index cc1b063..13f1342 100644 --- a/src/presenceservice.py +++ b/src/presenceservice.py @@ -23,7 +23,6 @@ from weakref import WeakValueDictionary import dbus import dbus.service import gobject -from dbus.exceptions import DBusException from dbus.gobject_service import ExportedGObject from dbus.mainloop.glib import DBusGMainLoop from telepathy.client import ManagerRegistry, Connection @@ -37,25 +36,19 @@ from sugar import util from server_plugin import ServerPlugin from linklocal_plugin import LinkLocalPlugin -from buddy import Buddy, ShellOwner +from buddy import Buddy, ShellOwner, BUDDY_PATH from activity import Activity -from psutils import pubkey_to_keyid +from psutils import pubkey_to_keyid, NotFoundError, PRESENCE_INTERFACE CONN_INTERFACE_BUDDY_INFO = 'org.laptop.Telepathy.BuddyInfo' CONN_INTERFACE_ACTIVITY_PROPERTIES = 'org.laptop.Telepathy.ActivityProperties' _PRESENCE_SERVICE = "org.laptop.Sugar.Presence" -_PRESENCE_INTERFACE = "org.laptop.Sugar.Presence" _PRESENCE_PATH = "/org/laptop/Sugar/Presence" _logger = logging.getLogger('s-p-s.presenceservice') -class NotFoundError(DBusException): - def __init__(self, msg): - DBusException.__init__(self, msg) - self._dbus_error_name = _PRESENCE_INTERFACE + '.NotFound' - class PresenceService(ExportedGObject): __gtype_name__ = "PresenceService" @@ -545,31 +538,31 @@ class PresenceService(ExportedGObject): self.PrivateInvitation(str(conn.service_name), conn.object_path, chan_path) - @dbus.service.signal(_PRESENCE_INTERFACE, signature="o") + @dbus.service.signal(PRESENCE_INTERFACE, signature="o") def ActivityAppeared(self, activity): pass - @dbus.service.signal(_PRESENCE_INTERFACE, signature="o") + @dbus.service.signal(PRESENCE_INTERFACE, signature="o") def ActivityDisappeared(self, activity): pass - @dbus.service.signal(_PRESENCE_INTERFACE, signature="o") + @dbus.service.signal(PRESENCE_INTERFACE, signature="o") def BuddyAppeared(self, buddy): pass - @dbus.service.signal(_PRESENCE_INTERFACE, signature="o") + @dbus.service.signal(PRESENCE_INTERFACE, signature="o") def BuddyDisappeared(self, buddy): pass - @dbus.service.signal(_PRESENCE_INTERFACE, signature="o") + @dbus.service.signal(PRESENCE_INTERFACE, signature="o") def ActivityInvitation(self, activity): pass - @dbus.service.signal(_PRESENCE_INTERFACE, signature="soo") + @dbus.service.signal(PRESENCE_INTERFACE, signature="soo") def PrivateInvitation(self, bus_name, connection, channel): pass - @dbus.service.method(_PRESENCE_INTERFACE, in_signature='', + @dbus.service.method(PRESENCE_INTERFACE, in_signature='', out_signature="ao") def GetActivities(self): ret = [] @@ -578,7 +571,7 @@ class PresenceService(ExportedGObject): ret.append(act.object_path()) return ret - @dbus.service.method(_PRESENCE_INTERFACE, in_signature="s", + @dbus.service.method(PRESENCE_INTERFACE, in_signature="s", out_signature="o") def GetActivityById(self, actid): act = self._activities_by_id.get(actid, None) @@ -586,7 +579,7 @@ class PresenceService(ExportedGObject): raise NotFoundError("The activity was not found.") return act.object_path() - @dbus.service.method(_PRESENCE_INTERFACE, in_signature='', + @dbus.service.method(PRESENCE_INTERFACE, in_signature='', out_signature="ao") def GetBuddies(self): # in the presence of an out_signature, dbus-python will convert @@ -603,7 +596,7 @@ class PresenceService(ExportedGObject): ret.add(buddy) return ret - @dbus.service.method(_PRESENCE_INTERFACE, + @dbus.service.method(PRESENCE_INTERFACE, in_signature="ay", out_signature="o", byte_arrays=True) def GetBuddyByPublicKey(self, key): @@ -618,7 +611,7 @@ class PresenceService(ExportedGObject): return buddy.object_path() raise NotFoundError("The buddy was not found.") - @dbus.service.method(_PRESENCE_INTERFACE, in_signature='sou', + @dbus.service.method(PRESENCE_INTERFACE, in_signature='sou', out_signature='o') def GetBuddyByTelepathyHandle(self, tp_conn_name, tp_conn_path, handle): """Get the buddy corresponding to a Telepathy handle. @@ -696,7 +689,7 @@ class PresenceService(ExportedGObject): handle_to_buddy[handle] = buddy return ret - @dbus.service.method(_PRESENCE_INTERFACE, + @dbus.service.method(PRESENCE_INTERFACE, in_signature='', out_signature="o") def GetOwner(self): if not self._owner: @@ -704,35 +697,23 @@ class PresenceService(ExportedGObject): else: return self._owner.object_path() - @dbus.service.method(_PRESENCE_INTERFACE, in_signature="sssa{sv}", + @dbus.service.method(PRESENCE_INTERFACE, in_signature="sssa{sv}", out_signature="o", async_callbacks=('async_cb', 'async_err_cb')) def ShareActivity(self, actid, atype, name, properties, async_cb, async_err_cb): - _logger.warning('ShareActivity deprecated, use AdvertiseActivity') - self._share_activity(actid, atype, name, properties, False, - async_cb, async_err_cb) - - @dbus.service.method(_PRESENCE_INTERFACE, in_signature="sssa{sv}", - out_signature="o", async_callbacks=('async_cb', 'async_err_cb')) - def AdvertiseActivity(self, actid, atype, name, properties, async_cb, - async_err_cb): + # FIXME: this makes all activities start off public. + # Once mutable properties have landed in sugar.presence, we should + # change the default to private=True. self._share_activity(actid, atype, name, properties, False, async_cb, async_err_cb) - @dbus.service.method(_PRESENCE_INTERFACE, in_signature="sssa{sv}", - out_signature="o", async_callbacks=('async_cb', 'async_err_cb')) - def InviteActivity(self, actid, atype, name, properties, async_cb, - async_err_cb): - self._share_activity(actid, atype, name, properties, True, - async_cb, async_err_cb) - def _get_preferred_plugin(self): for tp in self._plugins: if tp in self._connected_plugins: return tp return None - @dbus.service.method(_PRESENCE_INTERFACE, + @dbus.service.method(PRESENCE_INTERFACE, in_signature='', out_signature="so") def GetPreferredConnection(self): tp = self._get_preferred_plugin() @@ -745,7 +726,7 @@ class PresenceService(ExportedGObject): for tp in self._handles_buddies: tp.cleanup() - def _share_activity(self, actid, atype, name, properties, private, + def _share_activity(self, actid, atype, name, properties, private, async_cb, async_err_cb): """Create the shared Activity. |