Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu.vizoso@collabora.co.uk>2010-07-20 09:40:17 (GMT)
committer Tomeu Vizoso <tomeu.vizoso@collabora.co.uk>2010-08-20 13:02:27 (GMT)
commit9c7b4cf708048653694ed97acc79fafacd90d6c3 (patch)
treebba672310cdc8ca62596f0643e56aad724be3b0e
parentb9d2a313709469398228d82a72a03a93a66e6dcb (diff)
Announce the local current activity
-rw-r--r--src/jarabe/model/buddy.py22
-rw-r--r--src/jarabe/model/neighborhood.py61
2 files changed, 62 insertions, 21 deletions
diff --git a/src/jarabe/model/buddy.py b/src/jarabe/model/buddy.py
index 3bcf790..25ca857 100644
--- a/src/jarabe/model/buddy.py
+++ b/src/jarabe/model/buddy.py
@@ -114,6 +114,7 @@ class OwnerBuddyModel(BaseBuddyModel):
self.connect('notify::nick', self.__property_changed_cb)
self.connect('notify::color', self.__property_changed_cb)
+ self.connect('notify::current-activity', self.__current_activity_changed_cb)
logging.info('KILL_PS should set the properties before the connection'
'is connected, if possible')
@@ -125,6 +126,25 @@ class OwnerBuddyModel(BaseBuddyModel):
def __property_changed_cb(self, pspec):
self._sync_properties()
+ def __current_activity_changed_cb(self, pspec):
+ conn_watcher = connection_watcher.get_instance()
+ for connection in conn_watcher.get_connections():
+ if self.props.current_activity is not None:
+ activity_id = self.props.current_activity.activity_id
+ room_handle = self.props.current_activity.room_handle
+ else:
+ activity_id = ''
+ room_handle = 0
+
+ connection[CONNECTION_INTERFACE_BUDDY_INFO].SetCurrentProperty(
+ activity_id,
+ room_handle,
+ reply_handler=self.__set_current_activity_cb,
+ error_handler=self.__error_handler_cb)
+
+ def __set_current_activity_cb(self):
+ logging.debug('__set_current_activity_cb')
+
def _sync_properties(self):
conn_watcher = connection_watcher.get_instance()
for connection in conn_watcher.get_connections():
@@ -162,8 +182,8 @@ class OwnerBuddyModel(BaseBuddyModel):
_owner_instance = None
def get_owner_instance():
+ global _owner_instance
if _owner_instance is None:
- global _owner_instance
_owner_instance = OwnerBuddyModel()
return _owner_instance
diff --git a/src/jarabe/model/neighborhood.py b/src/jarabe/model/neighborhood.py
index cb6b810..ab6330b 100644
--- a/src/jarabe/model/neighborhood.py
+++ b/src/jarabe/model/neighborhood.py
@@ -175,33 +175,45 @@ class _Account(gobject.GObject):
def __connection_ready_cb(self, connection):
logging.debug('__connection_ready_cb %r', connection)
- connection[CONNECTION_INTERFACE_ALIASING].connect_to_signal(
- 'AliasesChanged', self.__aliases_changed_cb)
+ connection[PROPERTIES_IFACE].Get(CONNECTION,
+ 'SelfHandle',
+ reply_handler=self.__get_self_handle_cb,
+ error_handler=self.__error_handler_cb)
+
+ def __get_self_handle_cb(self, self_handle):
+ self._self_handle = self_handle
- connection[CONNECTION_INTERFACE_SIMPLE_PRESENCE].connect_to_signal(
- 'PresencesChanged', self.__presences_changed_cb)
+ connection = self._connection[CONNECTION_INTERFACE_ALIASING]
+ connection.connect_to_signal('AliasesChanged',
+ self.__aliases_changed_cb)
- if CONNECTION_INTERFACE_BUDDY_INFO in connection:
- connection[CONNECTION_INTERFACE_BUDDY_INFO].connect_to_signal(
- 'PropertiesChanged', self.__buddy_info_updated_cb,
- byte_arrays=True)
+ connection = self._connection[CONNECTION_INTERFACE_SIMPLE_PRESENCE]
+ connection.connect_to_signal('PresencesChanged',
+ self.__presences_changed_cb)
- connection[CONNECTION_INTERFACE_BUDDY_INFO].connect_to_signal(
- 'ActivitiesChanged', self.__buddy_activities_changed_cb)
+ if CONNECTION_INTERFACE_BUDDY_INFO in self._connection:
+ connection = self._connection[CONNECTION_INTERFACE_BUDDY_INFO]
+ connection.connect_to_signal('PropertiesChanged',
+ self.__buddy_info_updated_cb,
+ byte_arrays=True)
- connection[CONNECTION_INTERFACE_BUDDY_INFO].connect_to_signal(
- 'CurrentActivityChanged', self.__current_activity_changed_cb)
+ connection.connect_to_signal('ActivitiesChanged',
+ self.__buddy_activities_changed_cb)
+
+ connection.connect_to_signal('CurrentActivityChanged',
+ self.__current_activity_changed_cb)
else:
logging.warning('Connection %s does not support OLPC buddy '
- 'properties', connection.object_path)
+ 'properties', self._connection.object_path)
- if CONNECTION_INTERFACE_ACTIVITY_PROPERTIES in connection:
- connection[CONNECTION_INTERFACE_ACTIVITY_PROPERTIES].connect_to_signal(
+ if CONNECTION_INTERFACE_ACTIVITY_PROPERTIES in self._connection:
+ connection = self._connection[CONNECTION_INTERFACE_ACTIVITY_PROPERTIES]
+ connection.connect_to_signal(
'ActivityPropertiesChanged',
self.__activity_properties_changed_cb)
else:
logging.warning('Connection %s does not support OLPC activity '
- 'properties', connection.object_path)
+ 'properties', self._connection.object_path)
for target_id in 'subscribe', 'publish':
properties = {
@@ -209,12 +221,12 @@ class _Account(gobject.GObject):
CHANNEL + '.TargetHandleType': HANDLE_TYPE_LIST,
CHANNEL + '.TargetID': target_id,
}
+ properties = dbus.Dictionary(properties, signature='sv')
+ connection = self._connection[CONNECTION_INTERFACE_REQUESTS]
is_ours, channel_path, properties = \
- connection[CONNECTION_INTERFACE_REQUESTS].EnsureChannel(
- dbus.Dictionary(properties, signature='sv'))
- print is_ours, channel_path
+ connection.EnsureChannel(properties)
- channel = Channel(connection.service_name, channel_path)
+ channel = Channel(self._connection.service_name, channel_path)
channel[CHANNEL_INTERFACE_GROUP].connect_to_signal(
'MembersChanged', self.__members_changed_cb)
@@ -316,6 +328,15 @@ class _Account(gobject.GObject):
properties)
else:
logging.debug('__activity_properties_changed_cb unknown activity')
+ # We don't get ActivitiesChanged for the owner of the connection,
+ # so we query for its activities in order to find out.
+ if CONNECTION_INTERFACE_BUDDY_INFO in self._connection:
+ handle = self._self_handle
+ connection = self._connection[CONNECTION_INTERFACE_BUDDY_INFO]
+ connection.GetActivities(
+ handle,
+ reply_handler=partial(self.__got_activities_cb, handle),
+ error_handler=self.__error_handler_cb)
def __members_changed_cb(self, message, added, removed, local_pending,
remote_pending, actor, reason):