Make joining asynchronous on the activity side

This commit is contained in:
Dan Williams
2007-05-02 23:25:15 -04:00
parent 46d97015e6
commit 7774073276
4 changed files with 76 additions and 40 deletions
+16 -8
View File
@@ -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
+16 -1
View File
@@ -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,