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
This commit is contained in:
parent
9283a5cc80
commit
bd86aee0d4
@ -71,12 +71,6 @@ class HomeModel(gobject.GObject):
|
|||||||
screen.connect('active-window-changed',
|
screen.connect('active-window-changed',
|
||||||
self._active_window_changed_cb)
|
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):
|
def get_current_activity(self):
|
||||||
return self._current_activity
|
return self._current_activity
|
||||||
|
|
||||||
@ -111,7 +105,7 @@ class HomeModel(gobject.GObject):
|
|||||||
activity = HomeActivity(bundle, activity_id)
|
activity = HomeActivity(bundle, activity_id)
|
||||||
self._add_activity(activity)
|
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_service(service)
|
||||||
activity.set_window(window)
|
activity.set_window(window)
|
||||||
|
|
||||||
@ -125,19 +119,6 @@ class HomeModel(gobject.GObject):
|
|||||||
self.emit('active-activity-changed', None)
|
self.emit('active-activity-changed', None)
|
||||||
self._notify_activity_activation(self._current_activity, 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):
|
def _get_activity_by_xid(self, xid):
|
||||||
for activity in self._activities:
|
for activity in self._activities:
|
||||||
if activity.get_xid() == xid:
|
if activity.get_xid() == xid:
|
||||||
@ -185,12 +166,12 @@ class HomeModel(gobject.GObject):
|
|||||||
|
|
||||||
self.emit('active-activity-changed', self._current_activity)
|
self.emit('active-activity-changed', self._current_activity)
|
||||||
|
|
||||||
def _get_activity_service(self, xid):
|
def _get_activity_service(self, activity_id):
|
||||||
bus = dbus.SessionBus()
|
bus = dbus.SessionBus()
|
||||||
try:
|
try:
|
||||||
service = dbus.Interface(
|
service = dbus.Interface(
|
||||||
bus.get_object(_SERVICE_NAME + '%d' % xid,
|
bus.get_object(_SERVICE_NAME + activity_id,
|
||||||
_SERVICE_PATH + "/%s" % xid),
|
_SERVICE_PATH + "/" + activity_id),
|
||||||
_SERVICE_INTERFACE)
|
_SERVICE_INTERFACE)
|
||||||
except dbus.DBusException:
|
except dbus.DBusException:
|
||||||
service = None
|
service = None
|
||||||
|
@ -26,10 +26,6 @@ from sugar.presence import presenceservice
|
|||||||
from sugar.activity.activityhandle import ActivityHandle
|
from sugar.activity.activityhandle import ActivityHandle
|
||||||
from sugar import util
|
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"
|
_ACTIVITY_FACTORY_INTERFACE = "org.laptop.ActivityFactory"
|
||||||
|
|
||||||
def create_activity_id():
|
def create_activity_id():
|
||||||
|
@ -33,24 +33,21 @@ class ActivityService(dbus.service.Object):
|
|||||||
def __init__(self, activity):
|
def __init__(self, activity):
|
||||||
"""Initialise the service for the given activity
|
"""Initialise the service for the given activity
|
||||||
|
|
||||||
activity -- sugar.activity.activity.Activity instance,
|
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).
|
|
||||||
|
|
||||||
Creates dbus services that use the xid of the activity's
|
Creates dbus services that use the instance's activity_id
|
||||||
root window as discriminants among all active services
|
as discriminants among all active services
|
||||||
of this type. That is, the services are all available
|
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
|
The various methods exposed on dbus are just forwarded
|
||||||
to the client Activity object's equally-named methods.
|
to the client Activity object's equally-named methods.
|
||||||
"""
|
"""
|
||||||
activity.realize()
|
activity.realize()
|
||||||
|
|
||||||
xid = activity.window.xid
|
activity_id = activity.get_id()
|
||||||
service_name = _ACTIVITY_SERVICE_NAME + '%d' % xid
|
service_name = _ACTIVITY_SERVICE_NAME + activity_id
|
||||||
object_path = _ACTIVITY_SERVICE_PATH + "/%s" % xid
|
object_path = _ACTIVITY_SERVICE_PATH + "/" + activity_id
|
||||||
|
|
||||||
bus = dbus.SessionBus()
|
bus = dbus.SessionBus()
|
||||||
bus_name = dbus.service.BusName(service_name, bus=bus)
|
bus_name = dbus.service.BusName(service_name, bus=bus)
|
||||||
|
Loading…
Reference in New Issue
Block a user