diff options
author | Morgan Collett <morgan.collett@gmail.com> | 2007-08-22 14:55:08 (GMT) |
---|---|---|
committer | Morgan Collett <morgan.collett@gmail.com> | 2007-08-22 14:55:08 (GMT) |
commit | 4a2ca8b04e971fbc8774a824eb2b66362b757a86 (patch) | |
tree | 7f0101275d5c23e54197bb9dfca229d646c7a7ba | |
parent | e82ee34e2e2c83fb51859f193fe8c2e6f9356da2 (diff) |
PresenceService API Change to support sharing by invitation only
-rw-r--r-- | src/activity.py | 16 | ||||
-rw-r--r-- | src/presenceservice.py | 39 |
2 files changed, 42 insertions, 13 deletions
diff --git a/src/activity.py b/src/activity.py index 5606b98..182d253 100644 --- a/src/activity.py +++ b/src/activity.py @@ -137,6 +137,7 @@ class Activity(ExportedGObject): self._join_cb = None self._join_err_cb = None self._join_is_sharing = False + self._private = True self._leave_cb = None self._leave_err_cb = None @@ -603,11 +604,10 @@ class Activity(ExportedGObject): def _join_activity_channel_props_listed_cb(self, channel, prop_specs): props = { - 'anonymous': False, # otherwise buddy resolution breaks - 'invite-only': False, # XXX: should be True in future - #'name': ... # XXX: set from activity name? - 'persistent': False, # vanish when there are no members - 'private': False, # XXX: should be True unless public + 'anonymous': False, # otherwise buddy resolution breaks + 'invite-only': self._private, + 'persistent': False, # vanish when there are no members + 'private': self._private, } props_to_set = [] for ident, name, sig, flags in prop_specs: @@ -648,13 +648,15 @@ class Activity(ExportedGObject): reply_handler=self._join_activity_create_channel_cb, error_handler=self._join_failed_cb) - def join(self, async_cb, async_err_cb, sharing): + def join(self, async_cb, async_err_cb, sharing, private=True): """Local method for the local user to attempt to join the activity. async_cb -- Callback method to be called with no parameters if join attempt is successful async_err_cb -- Callback method to be called with an Exception parameter if join attempt is unsuccessful + sharing -- bool: True if sharing, False if joining + private -- bool: True if by invitation, False if Advertising The two callbacks are passed to the server_plugin ("tp") object, which in turn passes them back as parameters in a callback to the @@ -676,10 +678,12 @@ class Activity(ExportedGObject): self._join_cb = async_cb self._join_err_cb = async_err_cb self._join_is_sharing = sharing + self._private = private if self._room: # we're probably sharing a local activity. # FIXME: assert that this is the case? + # (try this:) assert self._local self._join_activity_got_handles_cb((self._room,)) else: conn = self._tp.get_connection() diff --git a/src/presenceservice.py b/src/presenceservice.py index bc49488..6859796 100644 --- a/src/presenceservice.py +++ b/src/presenceservice.py @@ -708,7 +708,22 @@ class PresenceService(ExportedGObject): out_signature="o", async_callbacks=('async_cb', 'async_err_cb')) def ShareActivity(self, actid, atype, name, properties, async_cb, async_err_cb): - self._share_activity(actid, atype, name, properties, + _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): + 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): @@ -730,10 +745,20 @@ class PresenceService(ExportedGObject): for tp in self._handles_buddies: tp.cleanup() - def _share_activity(self, actid, atype, name, properties, async_cb, - async_err_cb): + def _share_activity(self, actid, atype, name, private, + async_cb, async_err_cb): + """Create the shared Activity. + + actid -- XXX + atype -- XXX + name -- XXX + private -- bool: True for by-invitation-only sharing, + False for publicly advertised sharing + async_cb -- function: Callback for success + async_err_cb -- function: Callback for failure + """ objid = self._get_next_object_id() - # FIXME: is the preferred Telepathy plugin always the right way to + # XXX: is the preferred Telepathy plugin always the right way to # share the activity? color = self._owner.props.color activity = Activity(self._session_bus, objid, self, @@ -750,7 +775,7 @@ class PresenceService(ExportedGObject): self._activities_by_handle[tp][room] = activity async_cb(activity.object_path()) - activity.join(activity_shared, async_err_cb, True) + activity.join(activity_shared, async_err_cb, True, private) # local activities are valid at creation by definition, but we can't # connect to the activity's validity-changed signal until its already @@ -765,8 +790,8 @@ class PresenceService(ExportedGObject): activity.props.id) else: self.ActivityDisappeared(activity.object_path()) - _logger.debug("Activity disappeared: %s (%s)", activity.props.name, - activity.props.id) + _logger.debug("Activity disappeared: %s (%s)", + activity.props.name, activity.props.id) def _activity_properties_changed(self, tp, act_handle, props): activity = self._activities_by_handle[tp].get(act_handle) |