[RigoDaemon] expose daemon API version to Rigo

This commit is contained in:
Fabio Erculiani
2012-03-24 19:53:08 +01:00
parent f2f58e8616
commit a3d82ff44f
3 changed files with 43 additions and 0 deletions
+12
View File
@@ -219,6 +219,8 @@ class RigoDaemonService(dbus.service.Object):
BUS_NAME = DbusConfig.BUS_NAME
OBJECT_PATH = DbusConfig.OBJECT_PATH
API_VERSION = 0
"""
RigoDaemon is the dbus service Object in charge of executing
privileged tasks, like repository updates, package installation
@@ -676,6 +678,16 @@ class RigoDaemonService(dbus.service.Object):
return self._acquired_exclusive
@dbus.service.method(BUS_NAME, in_signature='',
out_signature='i')
def api(self):
"""
Return RigoDaemon API version.
"""
write_output("api called", debug=True)
return RigoDaemonService.API_VERSION
@dbus.service.method(BUS_NAME, in_signature='',
out_signature='')
def pong(self):
@@ -33,6 +33,10 @@
<arg name="status" type="b" direction="out"/>
</method>
<method name="api">
<arg name="version" type="i" direction="out"/>
</method>
<method name="pong"/>
</interface>
</node>
+27
View File
@@ -179,6 +179,7 @@ class RigoServiceController(GObject.Object):
_PROCESSING_APPLICATION_SIGNAL = "processing_application"
_APPLICATION_PROCESSED_SIGNAL = "application_processed"
_APPLICATIONS_MANAGED_SIGNAL = "applications_managed"
_SUPPORTED_APIS = [0]
def __init__(self, rigo_app, activity_rwsem, auth,
entropy_client, entropy_ws):
@@ -328,6 +329,12 @@ class RigoServiceController(GObject.Object):
"""
return self._local_transactions
def supported_apis(self):
"""
Return a list of supported RigoDaemon APIs.
"""
return RigoServiceController._SUPPORTED_APIS
@property
def repositories_lock(self):
"""
@@ -874,6 +881,14 @@ class RigoServiceController(GObject.Object):
self._entropy_bus,
dbus_interface=self.DBUS_INTERFACE).exclusive()
def api(self):
"""
Return RigoDaemon API version
"""
return dbus.Interface(
self._entropy_bus,
dbus_interface=self.DBUS_INTERFACE).api()
def _release_local_resources(self, clear_avc=True):
"""
Release all the local resources (like repositories)
@@ -2465,6 +2480,18 @@ class Rigo(Gtk.Application):
Gtk.main_quit()
return
supported_apis = self._service.supported_apis()
daemon_api = self._service.api()
if daemon_api not in supported_apis:
self._show_ok_dialog(
None,
escape_markup(_("Rigo")),
escape_markup(
_("API mismatch, please update Rigo and RigoDaemon")))
entropy.tools.kill_threads()
Gtk.main_quit()
return
acquired = not self._entropy.wait_resources(
max_lock_count=1,
shared=True)