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:03:09 (GMT)
committer Simon McVittie <simon.mcvittie@collabora.co.uk>2007-06-07 16:03:09 (GMT)
commitfd199a6602a81bca2aad5358642fb98e44a01690 (patch)
tree1b5c78ddf87e26f59ec37fa7e87b9273d20dab31
parente03146eaa6677b2ad7d951502844439a9242586c (diff)
Pass room handle to Activity constructor if the Activity was found on the network
-rw-r--r--src/activity.py6
-rw-r--r--src/presenceservice.py16
-rw-r--r--src/server_plugin.py7
3 files changed, 16 insertions, 13 deletions
diff --git a/src/activity.py b/src/activity.py
index 91efbba..8e8d6ce 100644
--- a/src/activity.py
+++ b/src/activity.py
@@ -81,7 +81,7 @@ class Activity(ExportedGObject):
_RESERVED_PROPNAMES = __gproperties__.keys()
- def __init__(self, bus, object_id, ps, tp, **kwargs):
+ def __init__(self, bus, object_id, ps, tp, room, **kwargs):
"""Initializes the activity and sets its properties to default values.
:Parameters:
@@ -93,6 +93,9 @@ class Activity(ExportedGObject):
The presence service
`tp` : server plugin
The server plugin object (stands for "telepathy plugin")
+ `room` : int or long
+ The handle (of type HANDLE_TYPE_ROOM) of the activity on
+ the server plugin
:Keywords:
`id` : str
The globally unique activity ID (required)
@@ -126,6 +129,7 @@ class Activity(ExportedGObject):
# the telepathy client
self._tp = tp
+ self._room = room
self._self_handle = None
self._text_channel = None
self._text_channel_group_flags = 0
diff --git a/src/presenceservice.py b/src/presenceservice.py
index 6d8b881..70759ff 100644
--- a/src/presenceservice.py
+++ b/src/presenceservice.py
@@ -219,10 +219,10 @@ class PresenceService(ExportedGObject):
_logger.debug("Buddy %s properties updated: %s", buddy.props.nick,
properties.keys())
- def _new_activity(self, activity_id, tp):
+ def _new_activity(self, activity_id, tp, room):
try:
objid = self._get_next_object_id()
- activity = Activity(self._session_bus, objid, self, tp,
+ activity = Activity(self._session_bus, objid, self, tp, room,
id=activity_id)
except Exception:
# FIXME: catching bare Exception considered harmful
@@ -242,10 +242,7 @@ class PresenceService(ExportedGObject):
del self._activities[activity.props.id]
def _buddy_activities_changed(self, tp, contact_handle, activities):
- acts = []
- for act in activities:
- acts.append(str(act))
- _logger.debug("Handle %s activities changed: %s", contact_handle, acts)
+ _logger.debug("Handle %s activities changed: %s", contact_handle, activities)
buddies = self._handles_buddies[tp]
buddy = buddies.get(contact_handle)
@@ -260,7 +257,7 @@ class PresenceService(ExportedGObject):
for activity in buddy.get_joined_activities():
old_activities.add(activity.props.id)
- new_activities = set(activities)
+ new_activities = set(activities.iterkeys())
activities_joined = new_activities - old_activities
for act in activities_joined:
@@ -268,7 +265,7 @@ class PresenceService(ExportedGObject):
activity = self._activities.get(act)
if activity is None:
# new activity, can fail
- activity = self._new_activity(act, tp)
+ activity = self._new_activity(act, tp, activities[act])
if activity is not None:
activity.buddy_apparently_joined(buddy)
@@ -473,7 +470,8 @@ class PresenceService(ExportedGObject):
# FIXME check which tp client we should use to share the activity
color = self._owner.props.color
activity = Activity(self._session_bus, objid, self,
- self._server_plugin, id=actid, type=atype,
+ self._server_plugin, 0,
+ id=actid, type=atype,
name=name, color=color, local=True)
activity.connect("validity-changed",
self._activity_validity_changed_cb)
diff --git a/src/server_plugin.py b/src/server_plugin.py
index acaceb7..e92894f 100644
--- a/src/server_plugin.py
+++ b/src/server_plugin.py
@@ -135,7 +135,7 @@ class ServerPlugin(gobject.GObject):
# OLPC activities changed
# args:
# contact handle: int
- # activity IDs: list of str
+ # activities: dict {activity_id: str => room: int or long}
(gobject.SIGNAL_RUN_FIRST, None, [object, object]),
'activity-invitation':
# We were invited to join an activity
@@ -995,10 +995,11 @@ class ServerPlugin(gobject.GObject):
not self._online_contacts[handle]):
return
+ activities_dict = {}
for act_id, act_handle in activities:
self._activities[act_id] = act_handle
- activities_id = map(lambda x: x[0], activities)
- self.emit("buddy-activities-changed", handle, activities_id)
+ activities_dict[act_id] = act_handle
+ self.emit("buddy-activities-changed", handle, activities_dict)
def _buddy_current_activity_changed_cb(self, handle, activity, channel):
"""Handle update of given user (handle)'s current activity"""