diff options
author | John (J5) Palmieri <johnp@redhat.com> | 2007-08-27 19:51:55 (GMT) |
---|---|---|
committer | John (J5) Palmieri <johnp@redhat.com> | 2007-08-27 19:51:55 (GMT) |
commit | f5f95f4d7b84f5fe09499c6c4d75d1a06e1bbcb6 (patch) | |
tree | 9f8bf94d05c550d0a2ef4d533e8be814e6fe668d /sugar/presence | |
parent | c06d63948794cce11e5b59e98f2ec2122a433972 (diff) | |
parent | 7fcc23b4c8c36b28f2e17904c1a64244fdd553b6 (diff) |
Merge branch 'master' of git+ssh://j5@dev.laptop.org/git/sugar
Diffstat (limited to 'sugar/presence')
-rw-r--r-- | sugar/presence/activity.py | 7 | ||||
-rw-r--r-- | sugar/presence/presenceservice.py | 34 |
2 files changed, 30 insertions, 11 deletions
diff --git a/sugar/presence/activity.py b/sugar/presence/activity.py index 2df8793..bdfc74f 100644 --- a/sugar/presence/activity.py +++ b/sugar/presence/activity.py @@ -167,16 +167,17 @@ class Activity(gobject.GObject): return bus_name, connection, channels def _leave_cb(self): - # XXX Is this the right thing to do? + """Callback for async action of leaving shared activity.""" self.emit("joined", False, "left activity") def _leave_error_cb(self, err): - # XXX We are closing down anyway + """Callback for error in async leaving of shared activity. + + XXX Add logging!""" pass def leave(self): """Leave this shared activity""" - # FIXME self._joined = False self._activity.Leave(reply_handler=self._leave_cb, error_handler=self._leave_error_cb) diff --git a/sugar/presence/presenceservice.py b/sugar/presence/presenceservice.py index 7b64b20..c8e23db 100644 --- a/sugar/presence/presenceservice.py +++ b/sugar/presence/presenceservice.py @@ -421,7 +421,11 @@ class PresenceService(gobject.GObject): return self._new_object(owner_op) def _share_activity_cb(self, activity, op): - """Notify with GObject event of successful sharing of activity""" + """Notify with GObject event of successful sharing of activity + + op -- full dbus path of the new object, must be + prefixed with either of _PS_BUDDY_OP or _PS_ACTIVITY_OP + """ psact = self._new_object(op) psact._joined = True self.emit("activity-shared", True, psact, None) @@ -431,10 +435,10 @@ class PresenceService(gobject.GObject): _logger.debug("Error sharing activity %s: %s" % (activity.get_id(), err)) self.emit("activity-shared", False, None, err) - def share_activity(self, activity, properties={}): - """Ask presence service to ask the activity to share itself + def share_activity(self, activity, properties={}, private=True): + """Ask presence service to ask the activity to share itself publicly. - Uses the ShareActivity method on the service to ask for the + Uses the AdvertiseActivity method on the service to ask for the sharing of the given activity. Arranges to emit activity-shared event with: @@ -445,19 +449,33 @@ class PresenceService(gobject.GObject): returns None """ actid = activity.get_id() + _logger.debug('XXXX in share_activity') # Ensure the activity is not already shared/joined for obj in self._objcache.values(): if not isinstance(object, Activity): continue if obj.props.id == actid or obj.props.joined: - raise RuntimeError("Activity %s is already shared." % actid) + raise RuntimeError("Activity %s is already shared." % + actid) atype = activity.get_service_name() name = activity.props.title - self._ps.ShareActivity(actid, atype, name, properties, - reply_handler=lambda *args: self._share_activity_cb(activity, *args), - error_handler=lambda *args: self._share_activity_error_cb(activity, *args)) + if private: + _logger.debug('XXXX private, so calling InviteActivity') + self._ps.InviteActivity(actid, atype, name, properties, + reply_handler=lambda *args: \ + self._share_activity_cb(activity, *args), + error_handler=lambda *args: \ + self._share_activity_error_cb(activity, *args)) + else: + # FIXME: Test, then make this AdvertiseActivity: + _logger.debug('XXXX not private, so calling ShareActivity') + self._ps.ShareActivity(actid, atype, name, properties, + reply_handler=lambda *args: \ + self._share_activity_cb(activity, *args), + error_handler=lambda *args: \ + self._share_activity_error_cb(activity, *args)) def get_preferred_connection(self): """Gets the preferred telepathy connection object that an activity |