Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell/shellservice.py
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2007-03-09 03:17:33 (GMT)
committer Dan Williams <dcbw@redhat.com>2007-03-09 03:17:33 (GMT)
commit8dc201bc5f166a84a50535252d35e8f9586813e4 (patch)
treeacaf5b7d0172dad33117405573dad65c067c4f6f /shell/shellservice.py
parent5210231e8fc9845f46ccdb57164b50a56ecdc02b (diff)
Expose owner details through the Shell's DBus service
For security, we need the PresenceService to listen for changes to the owner's attributes, like changed color, nickname, icon, and current activity, rather than having D-Bus API in the PS itself that any process could call. So, the shell provides signals when these attributes change, which the PS listens to and pushes out over the network accordingly.
Diffstat (limited to 'shell/shellservice.py')
-rw-r--r--shell/shellservice.py46
1 files changed, 43 insertions, 3 deletions
diff --git a/shell/shellservice.py b/shell/shellservice.py
index c31e501..7cf60f0 100644
--- a/shell/shellservice.py
+++ b/shell/shellservice.py
@@ -4,18 +4,58 @@ from sugar.activity import bundleregistry
_DBUS_SERVICE = "org.laptop.Shell"
_DBUS_INTERFACE = "org.laptop.Shell"
+_DBUS_OWNER_INTERFACE = "org.laptop.Shell.Owner"
_DBUS_PATH = "/org/laptop/Shell"
class ShellService(dbus.service.Object):
- def __init__(self, shellModel):
- self._shellModel = shellModel
+ def __init__(self, shell_model):
+ self._shell_model = shell_model
+
+ self._owner = self._shell_model.get_owner()
+ self._owner.connect('nick-changed', self._owner_nick_changed_cb)
+ self._owner.connect('icon-changed', self._owner_icon_changed_cb)
+ self._owner.connect('color-changed', self._owner_color_changed_cb)
+
+ self._home_model = self._shell_model.get_home()
+ self._home_model.connect('active-activity-changed', self._cur_activity_changed_cb)
bus = dbus.SessionBus()
bus_name = dbus.service.BusName(_DBUS_SERVICE, bus=bus)
dbus.service.Object.__init__(self, bus_name, _DBUS_PATH)
-
+
@dbus.service.method(_DBUS_INTERFACE, in_signature="s", out_signature="b")
def add_bundle(self, bundle_path):
registry = bundleregistry.get_registry()
return registry.add_bundle(bundle_path)
+
+ @dbus.service.signal(_DBUS_OWNER_INTERFACE, signature="s")
+ def ColorChanged(self, color):
+ pass
+
+ def _owner_color_changed_cb(self, new_color):
+ self.ColorChanged(new_color.to_string())
+
+ @dbus.service.signal(_DBUS_OWNER_INTERFACE, signature="s")
+ def NickChanged(self, nick):
+ pass
+
+ def _owner_nick_changed_cb(self, new_nick):
+ self.NickChanged(new_nick)
+
+ @dbus.service.signal(_DBUS_OWNER_INTERFACE, signature="ay")
+ def IconChanged(self, icon_data):
+ pass
+
+ def _owner_icon_changed_cb(self, new_icon):
+ self.IconChanged(dbus.ByteArray(new_icon))
+
+ @dbus.service.signal(_DBUS_OWNER_INTERFACE, signature="s")
+ def CurrentActivityChanged(self, activity_id):
+ pass
+
+ def _cur_activity_changed_cb(self, owner, new_activity):
+ new_id = ""
+ if new_activity:
+ new_id = new_activity.get_id()
+ self.CurrentActivityChanged(new_id)