Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar/presence
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
parent46d97015e61d9969840f1b36980b80af18e38ac1 (diff)
Make joining asynchronous on the activity side
Diffstat (limited to 'sugar/presence')
-rw-r--r--sugar/presence/activity.py24
-rw-r--r--sugar/presence/presenceservice.py17
2 files changed, 32 insertions, 9 deletions
diff --git a/sugar/presence/activity.py b/sugar/presence/activity.py
index 31638ac..3681f91 100644
--- a/sugar/presence/activity.py
+++ b/sugar/presence/activity.py
@@ -36,10 +36,12 @@ class Activity(gobject.GObject):
__gsignals__ = {
'buddy-joined': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
([gobject.TYPE_PYOBJECT])),
- 'buddy-left': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
+ 'buddy-left': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
([gobject.TYPE_PYOBJECT])),
- 'new-channel': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
- ([gobject.TYPE_PYOBJECT]))
+ 'new-channel': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
+ ([gobject.TYPE_PYOBJECT])),
+ 'joined': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
+ ([gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT]))
}
__gproperties__ = {
@@ -137,15 +139,22 @@ class Activity(gobject.GObject):
buddies.append(self._ps_new_object(item))
return buddies
+ def _join_cb(self):
+ self._joined = True
+ self.emit("joined", True, None)
+
+ def _join_error_cb(self, err):
+ self.emit("joined", False, str(err))
+
def join(self):
"""Join this activity
XXX if these are all activities, can I join my own activity?
"""
if self._joined:
+ self.emit("joined", True, None)
return
- self._activity.Join()
- self._joined = True
+ self._activity.Join(reply_handler=self._join_cb, error_handler=self._join_error_cb)
def get_channels(self):
"""Retrieve communications channel descriptions for the activity
@@ -157,7 +166,6 @@ class Activity(gobject.GObject):
(bus_name, connection, channels) = self._activity.GetChannels()
return bus_name, connection, channels
- def owner_has_joined(self):
- """Retrieve whether the owner of the activity is active within it"""
+ def leave(self):
# FIXME
- return False
+ self._joined = False
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,