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 17:14:52 (GMT)
committer Simon McVittie <simon.mcvittie@collabora.co.uk>2007-06-07 17:14:52 (GMT)
commita72d2d738eee97b40843c600e710b5a055613626 (patch)
tree5bc83268d562f0cbe54134d03db37ed7e771abfe
parent14fb0f1464c672120c5f1e624b5e1b6ec9840f03 (diff)
activity, server_plugin: move responsibility for actually setting room properties to Activity
-rw-r--r--src/activity.py30
-rw-r--r--src/server_plugin.py29
2 files changed, 31 insertions, 28 deletions
diff --git a/src/activity.py b/src/activity.py
index 897700a..0f1dc51 100644
--- a/src/activity.py
+++ b/src/activity.py
@@ -22,8 +22,10 @@ from dbus.gobject_service import ExportedGObject
from sugar import util
import logging
-from telepathy.constants import CHANNEL_GROUP_FLAG_CHANNEL_SPECIFIC_HANDLES
-from telepathy.interfaces import (CHANNEL_INTERFACE, CHANNEL_INTERFACE_GROUP)
+from telepathy.constants import (CHANNEL_GROUP_FLAG_CHANNEL_SPECIFIC_HANDLES,
+ PROPERTY_FLAG_WRITE)
+from telepathy.interfaces import (CHANNEL_INTERFACE, CHANNEL_INTERFACE_GROUP,
+ PROPERTIES_INTERFACE)
_ACTIVITY_PATH = "/org/laptop/Sugar/Presence/Activities/"
_ACTIVITY_INTERFACE = "org.laptop.Sugar.Presence.Activity"
@@ -532,6 +534,28 @@ class Activity(ExportedGObject):
self._join_cb = None
self._join_err_cb = None
+ def _join_activity_channel_props_listed_cb(self, tp, activity_id,
+ handle, channel, props,
+ prop_specs):
+
+ props_to_set = []
+ for ident, name, sig, flags in prop_specs:
+ value = props.pop(name, None)
+ if value is not None:
+ if flags & PROPERTY_FLAG_WRITE:
+ props_to_set.append((ident, value))
+ # FIXME: else error, but only if we're creating the room?
+ # FIXME: if props is nonempty, then we want to set props that aren't
+ # supported here - raise an error?
+
+ if props_to_set:
+ channel[PROPERTIES_INTERFACE].SetProperties(props_to_set,
+ reply_handler=lambda: self._joined_cb(tp, activity_id, handle,
+ channel),
+ error_handler=self._join_failed_cb)
+ else:
+ self._joined_cb(tp, activity_id, handle, channel)
+
def join(self, async_cb, async_err_cb, sharing):
"""Local method for the local user to attempt to join the activity.
@@ -560,7 +584,7 @@ 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._join_activity_channel_props_listed_cb,
self._join_failed_cb)
_logger.debug("triggered share/join attempt on activity %s", self._id)
diff --git a/src/server_plugin.py b/src/server_plugin.py
index 98293cc..75ba58d 100644
--- a/src/server_plugin.py
+++ b/src/server_plugin.py
@@ -472,28 +472,6 @@ class ServerPlugin(gobject.GObject):
self._joined_activities.append((activity_id, room))
self._set_self_activities()
- def _join_activity_channel_props_listed_cb(self, activity_id,
- handle, channel, callback,
- err_cb, props, prop_specs):
-
- props_to_set = []
- for ident, name, sig, flags in prop_specs:
- value = props.pop(name, None)
- if value is not None:
- if flags & PROPERTY_FLAG_WRITE:
- props_to_set.append((ident, value))
- # FIXME: else error, but only if we're creating the room?
- # FIXME: if props is nonempty, then we want to set props that aren't
- # supported here - raise an error?
-
- if props_to_set:
- channel[PROPERTIES_INTERFACE].SetProperties(props_to_set,
- reply_handler=lambda: callback(self, activity_id, handle,
- channel)
- error_handler=err_cb)
- else:
- callback(self, activity_id, handle, channel)
-
def _join_activity_create_channel_cb(self, activity_id, handle,
callback, err_cb, chan_path):
channel = Channel(self._conn.service_name, chan_path)
@@ -505,9 +483,8 @@ class ServerPlugin(gobject.GObject):
'private': False, # XXX: should be True unless public
}
channel[PROPERTIES_INTERFACE].ListProperties(
- reply_handler=lambda prop_specs: self._join_activity_channel_props_listed_cb(
- activity_id, handle, channel, callback, err_cb, props,
- prop_specs),
+ reply_handler=lambda prop_specs: callback(self,
+ activity_id, handle, channel, props, prop_specs),
error_handler=err_cb)
def _join_activity_get_channel_cb(self, activity_id, callback, err_cb,
@@ -538,6 +515,8 @@ class ServerPlugin(gobject.GObject):
activity ID: str
activity room handle: int or long
channel: telepathy.client.Channel, or None on failure
+ props: properties we want to set on the channel
+ prop_specs: property specifications
err_cb -- callback to be called on failure, with one Exception argument
Asks the Telepathy server to create a "conference" channel