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
=== modified file '_zeitgeist/engine/remote.py'
--- _zeitgeist/engine/remote.py 2009-10-17 14:21:29 +0000
+++ _zeitgeist/engine/remote.py 2009-10-29 19:55:19 +0000
@@ -31,6 +31,10 @@
31SIG_EVENTS = "aa{sv}a{sa{sv}}"31SIG_EVENTS = "aa{sv}a{sa{sv}}"
3232
33class RemoteInterface(SingletonApplication):33class RemoteInterface(SingletonApplication):
34
35 _dbus_properties = {
36 "version": property(lambda self: (0, 3, 0)),
37 }
34 38
35 # Initialization39 # Initialization
36 40
@@ -241,6 +245,29 @@
241 """245 """
242 result = _engine.delete_items(uris)246 result = _engine.delete_items(uris)
243 self.EventsChanged(("deleted", result))247 self.EventsChanged(("deleted", result))
248
249 # Properties interface
250
251 @dbus.service.method(dbus_interface=dbus.PROPERTIES_IFACE,
252 in_signature="ss", out_signature="v")
253 def Get(self, interface_name, property_name):
254 try:
255 return self._dbus_properties[property_name].fget(self)
256 except KeyError, e:
257 raise AttributeError(property_name)
258
259 @dbus.service.method(dbus_interface=dbus.PROPERTIES_IFACE,
260 in_signature="ssv", out_signature="")
261 def Set(self, interface_name, property_name, value):
262 try:
263 prop = self._dbus_properties[property_name].fset(self, value)
264 except (KeyError, TypeError), e:
265 raise AttributeError(property_name)
266
267 @dbus.service.method(dbus_interface=dbus.PROPERTIES_IFACE,
268 in_signature="s", out_signature="a{sv}")
269 def GetAll(self, interface_name):
270 return dict((k, v.fget(self)) for (k,v) in self._dbus_properties.items())
244 271
245 # Signals and signal emitters272 # Signals and signal emitters
246 273
247274
=== modified file 'zeitgeist/dbusutils.py'
--- zeitgeist/dbusutils.py 2009-09-23 11:14:03 +0000
+++ zeitgeist/dbusutils.py 2009-10-29 19:55:19 +0000
@@ -123,14 +123,21 @@
123 def connect_exit(cls, callback):123 def connect_exit(cls, callback):
124 """executes callback when the RemoteInterface exists"""124 """executes callback when the RemoteInterface exists"""
125 bus = cls.get_session_bus()125 bus = cls.get_session_bus()
126 bus_obj = bus.get_object("org.freedesktop.DBus", "/org/freedesktop/DBus")126 bus_obj = bus.get_object(dbus.BUS_DAEMON_IFACE, dbus.BUS_DAEMON_PATH)
127 bus_obj.connect_to_signal(127 bus_obj.connect_to_signal(
128 "NameOwnerChanged",128 "NameOwnerChanged",
129 lambda *args: callback(),129 lambda *args: callback(),
130 dbus_interface="org.freedesktop.DBus",130 dbus_interface=dbus.BUS_DAEMON_IFACE,
131 arg0=cls.INTERFACE_NAME, #only match dying zeitgeist remote interfaces131 arg0=cls.INTERFACE_NAME, #only match dying zeitgeist remote interfaces
132 arg2="", #only match services with no new owner132 arg2="", #only match services with no new owner
133 )133 )
134
135 @classmethod
136 def version(cls):
137 """ get the API version """
138 proxy = cls._get_proxy()
139 return proxy.get_dbus_method("Get", dbus_interface=dbus.PROPERTIES_IFACE)(cls.INTERFACE_NAME, "version")
140
134 141
135 def __init__(self):142 def __init__(self):
136 self.__dict__ = self.__shared_state143 self.__dict__ = self.__shared_state

Subscribers

People subscribed via source and target branches