Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2007-06-07 16:55:02 (GMT)
committer Simon McVittie <simon.mcvittie@collabora.co.uk>2007-06-07 16:55:02 (GMT)
commit56cc9c2a95b761af3d04c27e758774016e2948eb (patch)
treeee4d161792707f3eb963e8468d24204d3eca9320
parent22978c638d44ef5cf0fdbcaaf9ee93f004ea94dc (diff)
activity, server_plugin: separate success and error callbacks for join
-rw-r--r--src/activity.py22
-rw-r--r--src/server_plugin.py41
2 files changed, 36 insertions, 27 deletions
diff --git a/src/activity.py b/src/activity.py
index 472cc8b..706c2b3 100644
--- a/src/activity.py
+++ b/src/activity.py
@@ -500,7 +500,7 @@ class Activity(ExportedGObject):
return True
- def _joined_cb(self, tp, activity_id, room_handle, text_channel, exc):
+ def _joined_cb(self, tp, activity_id, room_handle, text_channel):
"""XXX - not documented yet
"""
assert activity_id == self.props.id
@@ -508,17 +508,24 @@ class Activity(ExportedGObject):
self._room = room_handle
verb = self._join_is_sharing and 'Share' or 'Join'
- if exc:
- _logger.debug("%s of activity %s failed: %s" % (verb, self._id,
- exc))
- self._join_err_cb(exc)
- else:
+
+ try:
self._handle_share_join(tp, text_channel)
if self._join_is_sharing:
self.send_properties()
self._ps.owner.add_activity(self)
self._join_cb(dbus.ObjectPath(self._object_path))
_logger.debug("%s of activity %s succeeded" % (verb, self._id))
+ except Exception, e:
+ self._join_failed_cb(e)
+
+ self._join_cb = None
+ self._join_err_cb = None
+
+ def _join_failed_cb(self, e):
+ verb = self._join_is_sharing and 'Share' or 'Join'
+ _logger.debug("%s of activity %s failed: %s" % (verb, self._id, e))
+ self._join_err_cb(e)
self._join_cb = None
self._join_err_cb = None
@@ -551,7 +558,8 @@ class Activity(ExportedGObject):
self._join_err_cb = async_err_cb
self._join_is_sharing = sharing
- self._tp.join_activity(self.props.id, self._joined_cb)
+ self._tp.join_activity(self.props.id, self._joined_cb,
+ self._join_failed_cb)
_logger.debug("triggered share/join attempt on activity %s", self._id)
def get_channels(self):
diff --git a/src/server_plugin.py b/src/server_plugin.py
index 914315c..30b33b2 100644
--- a/src/server_plugin.py
+++ b/src/server_plugin.py
@@ -473,13 +473,13 @@ class ServerPlugin(gobject.GObject):
self._set_self_activities()
def _join_activity_channel_props_set_cb(self, activity_id, handle,
- channel, callback):
+ channel, callback, err_cb):
self.emit_joined_activity(activity_id, handle)
- callback(self, activity_id, handle, channel, None)
+ callback(self, activity_id, handle, channel)
def _join_activity_channel_props_listed_cb(self, activity_id,
handle, channel, callback,
- props, prop_specs):
+ err_cb, props, prop_specs):
props_to_set = []
for ident, name, sig, flags in prop_specs:
@@ -494,16 +494,16 @@ class ServerPlugin(gobject.GObject):
if props_to_set:
channel[PROPERTIES_INTERFACE].SetProperties(props_to_set,
reply_handler=lambda: self._join_activity_channel_props_set_cb(
- activity_id, handle, channel, callback),
+ activity_id, handle, channel, callback, err_cb),
error_handler=lambda e: self._join_error_cb(
- activity_id, callback,
+ activity_id, callback, err_cb,
'SetProperties(%r)' % props_to_set, e))
else:
self._join_activity_channel_props_set_cb(activity_id,
- handle, channel, callback)
+ handle, channel, callback, err_cb)
def _join_activity_create_channel_cb(self, activity_id, handle,
- callback, chan_path):
+ callback, err_cb, chan_path):
channel = Channel(self._conn.service_name, chan_path)
props = {
'anonymous': False, # otherwise buddy resolution breaks
@@ -514,11 +514,12 @@ class ServerPlugin(gobject.GObject):
}
channel[PROPERTIES_INTERFACE].ListProperties(
reply_handler=lambda prop_specs: self._join_activity_channel_props_listed_cb(
- activity_id, handle, channel, callback, props, prop_specs),
+ activity_id, handle, channel, callback, err_cb, props,
+ prop_specs),
error_handler=lambda e: self._join_error_cb(
- activity_id, callback, 'ListProperties', e))
+ activity_id, callback, err_cb, 'ListProperties', e))
- def _join_activity_get_channel_cb(self, activity_id, callback,
+ def _join_activity_get_channel_cb(self, activity_id, callback, err_cb,
handles):
if not self._activities.has_key(activity_id):
self._activities[activity_id] = handles[0]
@@ -526,24 +527,24 @@ class ServerPlugin(gobject.GObject):
if (activity_id, handles[0]) in self._joined_activities:
e = RuntimeError("Already joined activity %s" % activity_id)
_logger.debug('%s', e)
- callback(self, activity_id, handles[0], None, e)
+ err_cb(e)
return
self._conn[CONN_INTERFACE].RequestChannel(CHANNEL_TYPE_TEXT,
HANDLE_TYPE_ROOM, handles[0], True,
reply_handler=lambda *args: self._join_activity_create_channel_cb(
- activity_id, handles[0], callback, *args),
+ activity_id, handles[0], callback, err_cb, *args),
error_handler=lambda e: self._join_error_cb(activity_id,
- callback, 'RequestChannel(TEXT, ROOM, %r, True)' % handles[0],
+ callback, err_cb, 'RequestChannel(TEXT, ROOM, %r, True)' % handles[0],
e))
- def _join_error_cb(self, activity_id, callback, where, err):
+ def _join_error_cb(self, activity_id, callback, err_cb, where, err):
e = Exception("Error joining/sharing activity %s: (%s): %s"
% (activity_id, where, err))
_logger.debug('%s', e)
- callback(self, activity_id, 0, None, e)
+ err_cb(e)
- def join_activity(self, activity_id, callback):
+ def join_activity(self, activity_id, callback, err_cb):
"""Share activity with the network, or join an activity on the
network (or locally)
@@ -554,7 +555,7 @@ class ServerPlugin(gobject.GObject):
activity ID: str
activity room handle: int or long
channel: telepathy.client.Channel, or None on failure
- error: None, or Exception on failure
+ err_cb -- callback to be called on failure, with one Exception argument
Asks the Telepathy server to create a "conference" channel
for the activity or return a handle to an already created
@@ -567,12 +568,12 @@ class ServerPlugin(gobject.GObject):
self._conn[CONN_INTERFACE].RequestHandles(HANDLE_TYPE_ROOM,
[room_jid],
reply_handler=lambda *args: self._join_activity_get_channel_cb(
- activity_id, callback, *args),
+ activity_id, callback, err_cb, *args),
error_handler=lambda e: self._join_error_cb(activity_id,
- callback, 'RequestHandles([%u])' % room_jid,
+ callback, err_cb, 'RequestHandles([%u])' % room_jid,
e))
else:
- self._join_activity_get_channel_cb(activity_id, callback,
+ self._join_activity_get_channel_cb(activity_id, callback, err_cb,
[handle])
def _ignore_success_cb(self):