Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBert Freudenberg <bert@ubuntu.(none)>2007-06-20 09:52:29 (GMT)
committer Bert Freudenberg <bert@ubuntu.(none)>2007-06-20 09:52:29 (GMT)
commitbd86aee0d4ab8a989ae19a7959e65d563228709a (patch)
treea1896ffc226d80571d2f9bd9bef1a17ca6bf82e2
parent9283a5cc806c0c00bb822679a97ef527c3a8bc1b (diff)
use activity_id in service name
- construct service name from activity id instead of X window id - cleanup unused declarations in activityfactory.py - remove obsolete _dbus_name_owner_changed_cb() - see http://dev.laptop.org/ticket/1767 - cleared by marcopg
-rw-r--r--shell/model/homemodel.py27
-rw-r--r--sugar/activity/activityfactory.py4
-rw-r--r--sugar/activity/activityservice.py17
3 files changed, 11 insertions, 37 deletions
diff --git a/shell/model/homemodel.py b/shell/model/homemodel.py
index 7eb4b46..6a2d45f 100644
--- a/shell/model/homemodel.py
+++ b/shell/model/homemodel.py
@@ -71,12 +71,6 @@ class HomeModel(gobject.GObject):
screen.connect('active-window-changed',
self._active_window_changed_cb)
- bus = dbus.SessionBus()
- bus.add_signal_receiver(self._dbus_name_owner_changed_cb,
- 'NameOwnerChanged',
- 'org.freedesktop.DBus',
- 'org.freedesktop.DBus')
-
def get_current_activity(self):
return self._current_activity
@@ -111,7 +105,7 @@ class HomeModel(gobject.GObject):
activity = HomeActivity(bundle, activity_id)
self._add_activity(activity)
- service = self._get_activity_service(window.get_xid())
+ service = self._get_activity_service(activity_id)
activity.set_service(service)
activity.set_window(window)
@@ -125,19 +119,6 @@ class HomeModel(gobject.GObject):
self.emit('active-activity-changed', None)
self._notify_activity_activation(self._current_activity, None)
- def _dbus_name_owner_changed_cb(self, name, old, new):
- """Detect new activity instances on the DBus"""
- if name.startswith(_SERVICE_NAME) and new and not old:
- try:
- xid = int(name[len(_SERVICE_NAME):])
- activity = self._get_activity_by_xid(xid)
- if activity and not activity.get_service():
- service = self._get_activity_service(xid)
- activity.set_service(service)
- except ValueError:
- logging.error('Invalid activity service name, '
- 'cannot extract the xid')
-
def _get_activity_by_xid(self, xid):
for activity in self._activities:
if activity.get_xid() == xid:
@@ -185,12 +166,12 @@ class HomeModel(gobject.GObject):
self.emit('active-activity-changed', self._current_activity)
- def _get_activity_service(self, xid):
+ def _get_activity_service(self, activity_id):
bus = dbus.SessionBus()
try:
service = dbus.Interface(
- bus.get_object(_SERVICE_NAME + '%d' % xid,
- _SERVICE_PATH + "/%s" % xid),
+ bus.get_object(_SERVICE_NAME + activity_id,
+ _SERVICE_PATH + "/" + activity_id),
_SERVICE_INTERFACE)
except dbus.DBusException:
service = None
diff --git a/sugar/activity/activityfactory.py b/sugar/activity/activityfactory.py
index 809a74d..2cdf9a1 100644
--- a/sugar/activity/activityfactory.py
+++ b/sugar/activity/activityfactory.py
@@ -26,10 +26,6 @@ from sugar.presence import presenceservice
from sugar.activity.activityhandle import ActivityHandle
from sugar import util
-_ACTIVITY_SERVICE_NAME = "org.laptop.Activity"
-_ACTIVITY_SERVICE_PATH = "/org/laptop/Activity"
-_ACTIVITY_INTERFACE = "org.laptop.Activity"
-
_ACTIVITY_FACTORY_INTERFACE = "org.laptop.ActivityFactory"
def create_activity_id():
diff --git a/sugar/activity/activityservice.py b/sugar/activity/activityservice.py
index f456581..3251177 100644
--- a/sugar/activity/activityservice.py
+++ b/sugar/activity/activityservice.py
@@ -33,24 +33,21 @@ class ActivityService(dbus.service.Object):
def __init__(self, activity):
"""Initialise the service for the given activity
- activity -- sugar.activity.activity.Activity instance,
- must have already bound it's window (i.e. it must
- have already initialised to the point of having
- the X window available).
+ activity -- sugar.activity.activity.Activity instance
- Creates dbus services that use the xid of the activity's
- root window as discriminants among all active services
+ Creates dbus services that use the instance's activity_id
+ as discriminants among all active services
of this type. That is, the services are all available
- as names/paths derived from the xid for the window.
+ as names/paths derived from the instance's activity_id.
The various methods exposed on dbus are just forwarded
to the client Activity object's equally-named methods.
"""
activity.realize()
- xid = activity.window.xid
- service_name = _ACTIVITY_SERVICE_NAME + '%d' % xid
- object_path = _ACTIVITY_SERVICE_PATH + "/%s" % xid
+ activity_id = activity.get_id()
+ service_name = _ACTIVITY_SERVICE_NAME + activity_id
+ object_path = _ACTIVITY_SERVICE_PATH + "/" + activity_id
bus = dbus.SessionBus()
bus_name = dbus.service.BusName(service_name, bus=bus)