Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar/presence/presenceservice.py
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2007-05-03 03:25:15 (GMT)
committer Dan Williams <dcbw@redhat.com>2007-05-03 03:25:15 (GMT)
commit7774073276de007dbf02c4f36aeeef3d56151bff (patch)
treed3dc6435490f05523159df3e1ec2f5f99d75c3da /sugar/presence/presenceservice.py
parent46d97015e61d9969840f1b36980b80af18e38ac1 (diff)
Make joining asynchronous on the activity side
Diffstat (limited to 'sugar/presence/presenceservice.py')
-rw-r--r--sugar/presence/presenceservice.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/sugar/presence/presenceservice.py b/sugar/presence/presenceservice.py
index 4044c4e..f93c831 100644
--- a/sugar/presence/presenceservice.py
+++ b/sugar/presence/presenceservice.py
@@ -160,6 +160,11 @@ class PresenceService(gobject.GObject):
elif object_path.startswith(self._PS_ACTIVITY_OP):
obj = activity.Activity(self._bus, self._new_object,
self._del_object, object_path)
+ try:
+ # Pre-fill the activity's ID
+ foo = obj.props.id
+ except dbus.exceptions.DBusException, err:
+ pass
else:
raise RuntimeError("Unknown object type")
self._objcache[object_path] = obj
@@ -322,7 +327,9 @@ class PresenceService(gobject.GObject):
def _share_activity_cb(self, activity, op):
"""Notify with GObject event of successful sharing of activity"""
- self.emit("activity-shared", True, self._new_object(op), None)
+ psact = self._new_object(op)
+ psact._joined = True
+ self.emit("activity-shared", True, psact, None)
def _share_activity_error_cb(self, activity, err):
"""Notify with GObject event of unsuccessful sharing of activity"""
@@ -343,6 +350,14 @@ class PresenceService(gobject.GObject):
returns None
"""
actid = activity.get_id()
+
+ # Ensure the activity is not already shared/joined
+ for obj in self._objcache.values():
+ if not isinstance(object, activity.Activity):
+ continue
+ if obj.props.id == actid or obj.props.joined:
+ raise RuntimeError("Activity %s is already shared." % actid)
+
atype = activity.get_service_name()
name = activity.props.title
self._ps.ShareActivity(actid, atype, name, properties,