Merge lp:~thekorn/zeitgeist/dbus.properties into lp:zeitgeist/0.1

Proposed by Markus Korn
Status: Merged
Merged at revision: not available
Proposed branch: lp:~thekorn/zeitgeist/dbus.properties
Merge into: lp:zeitgeist/0.1
Diff against target: 72 lines
2 files modified
_zeitgeist/engine/remote.py (+27/-0)
zeitgeist/dbusutils.py (+9/-2)
To merge this branch: bzr merge lp:~thekorn/zeitgeist/dbus.properties
Reviewer Review Type Date Requested Status
Mikkel Kamstrup Erlandsen review, no testing Approve
Siegfried Gevatter Approve
Review via email: mp+14188@code.launchpad.net

Commit message

* Implemented 'org.freedesktop.DBus.Properties' Interface for
  RemoteInterface
* added a 'version' property to RemoteInterface which returns a version
  tuple, right now it looks like (0, 3, 0) (LP: #462890)
* Replaced some hardcoded interface and object_path identifier with the constants of the
  dbus module

To post a comment you must log in.
Revision history for this message
Markus Korn (thekorn) wrote :

* Implemented 'org.freedesktop.DBus.Properties' Interface for
  RemoteInterface
* added a 'version' property to RemoteInterface which returns a version
  tuple, right now it looks like (0, 3, 0) (LP: #462890)
* Replaced some hardcoded interface and object_path identifier with the constants of the
  dbus module

Revision history for this message
Siegfried Gevatter (rainct) wrote :

Looks good.

But didn't Mikkel mention that D-Bus already has some sort of in-build versioning, or did I understand that wrong?

review: Approve
Revision history for this message
Markus Korn (thekorn) wrote :

> Looks good.
>
> But didn't Mikkel mention that D-Bus already has some sort of in-build
> versioning, or did I understand that wrong?

Well, I'm not sure myself, but this is how I understood it should work after reading the DBus spec, the DBus API reference and some sample code, maybe Mikkel can enlighten us.

Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

This was exactly what I meant. Good work Markus.

About the versioning, it was not directly related to this... I just mean that Tracker names its APIs as org.foo.Service1, so that they later can break the API, and use interface name org.foo.Service2, etc.

review: Approve (review, no testing)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '_zeitgeist/engine/remote.py'
2--- _zeitgeist/engine/remote.py 2009-10-17 14:21:29 +0000
3+++ _zeitgeist/engine/remote.py 2009-10-29 19:55:19 +0000
4@@ -31,6 +31,10 @@
5 SIG_EVENTS = "aa{sv}a{sa{sv}}"
6
7 class RemoteInterface(SingletonApplication):
8+
9+ _dbus_properties = {
10+ "version": property(lambda self: (0, 3, 0)),
11+ }
12
13 # Initialization
14
15@@ -241,6 +245,29 @@
16 """
17 result = _engine.delete_items(uris)
18 self.EventsChanged(("deleted", result))
19+
20+ # Properties interface
21+
22+ @dbus.service.method(dbus_interface=dbus.PROPERTIES_IFACE,
23+ in_signature="ss", out_signature="v")
24+ def Get(self, interface_name, property_name):
25+ try:
26+ return self._dbus_properties[property_name].fget(self)
27+ except KeyError, e:
28+ raise AttributeError(property_name)
29+
30+ @dbus.service.method(dbus_interface=dbus.PROPERTIES_IFACE,
31+ in_signature="ssv", out_signature="")
32+ def Set(self, interface_name, property_name, value):
33+ try:
34+ prop = self._dbus_properties[property_name].fset(self, value)
35+ except (KeyError, TypeError), e:
36+ raise AttributeError(property_name)
37+
38+ @dbus.service.method(dbus_interface=dbus.PROPERTIES_IFACE,
39+ in_signature="s", out_signature="a{sv}")
40+ def GetAll(self, interface_name):
41+ return dict((k, v.fget(self)) for (k,v) in self._dbus_properties.items())
42
43 # Signals and signal emitters
44
45
46=== modified file 'zeitgeist/dbusutils.py'
47--- zeitgeist/dbusutils.py 2009-09-23 11:14:03 +0000
48+++ zeitgeist/dbusutils.py 2009-10-29 19:55:19 +0000
49@@ -123,14 +123,21 @@
50 def connect_exit(cls, callback):
51 """executes callback when the RemoteInterface exists"""
52 bus = cls.get_session_bus()
53- bus_obj = bus.get_object("org.freedesktop.DBus", "/org/freedesktop/DBus")
54+ bus_obj = bus.get_object(dbus.BUS_DAEMON_IFACE, dbus.BUS_DAEMON_PATH)
55 bus_obj.connect_to_signal(
56 "NameOwnerChanged",
57 lambda *args: callback(),
58- dbus_interface="org.freedesktop.DBus",
59+ dbus_interface=dbus.BUS_DAEMON_IFACE,
60 arg0=cls.INTERFACE_NAME, #only match dying zeitgeist remote interfaces
61 arg2="", #only match services with no new owner
62 )
63+
64+ @classmethod
65+ def version(cls):
66+ """ get the API version """
67+ proxy = cls._get_proxy()
68+ return proxy.get_dbus_method("Get", dbus_interface=dbus.PROPERTIES_IFACE)(cls.INTERFACE_NAME, "version")
69+
70
71 def __init__(self):
72 self.__dict__ = self.__shared_state

Subscribers

People subscribed via source and target branches