diff frontends/src/bridge/DBus.py @ 1072:d123d61976c8

bridge (D-Bus): frontend side now use a 120 s timeout for async calls
author Goffi <goffi@goffi.org>
date Sun, 15 Jun 2014 00:18:28 +0200
parents 95758ef3faa8
children f094583732de
line wrap: on
line diff
--- a/frontends/src/bridge/DBus.py	Sat Jun 14 17:26:22 2014 +0200
+++ b/frontends/src/bridge/DBus.py	Sun Jun 15 00:18:28 2014 +0200
@@ -32,6 +32,7 @@
 const_OBJ_PATH = '/org/goffi/SAT/bridge'
 const_CORE_SUFFIX = ".core"
 const_PLUGIN_SUFFIX = ".plugin"
+const_TIMEOUT = 120
 
 
 def dbus_to_bridge_exception(dbus_e):
@@ -100,6 +101,7 @@
                 method = getattr(self.db_plugin_iface, name)
 
                 if async:
+                    kwargs['timeout'] = const_TIMEOUT
                     kwargs['reply_handler'] = _callback
                     kwargs['error_handler'] = lambda err: _errback(dbus_to_bridge_exception(err))
 
@@ -110,16 +112,16 @@
         return self.db_core_iface.addContact(entity_jid, profile_key)
 
     def asyncConnect(self, profile_key="@DEFAULT@", password='', callback=None, errback=None):
-        return self.db_core_iface.asyncConnect(profile_key, password, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err)))
+        return self.db_core_iface.asyncConnect(profile_key, password, timeout=const_TIMEOUT, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err)))
 
     def asyncCreateProfile(self, profile, password='', callback=None, errback=None):
-        return self.db_core_iface.asyncCreateProfile(profile, password, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err)))
+        return self.db_core_iface.asyncCreateProfile(profile, password, timeout=const_TIMEOUT, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err)))
 
     def asyncDeleteProfile(self, profile, callback=None, errback=None):
-        return self.db_core_iface.asyncDeleteProfile(profile, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err)))
+        return self.db_core_iface.asyncDeleteProfile(profile, timeout=const_TIMEOUT, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err)))
 
     def asyncGetParamA(self, name, category, attribute="value", security_limit=-1, profile_key="@DEFAULT@", callback=None, errback=None):
-        return unicode(self.db_core_iface.asyncGetParamA(name, category, attribute, security_limit, profile_key, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err))))
+        return unicode(self.db_core_iface.asyncGetParamA(name, category, attribute, security_limit, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err))))
 
     def confirmationAnswer(self, id, accepted, data, profile):
         return self.db_core_iface.confirmationAnswer(id, accepted, data, profile)
@@ -128,10 +130,10 @@
         return self.db_core_iface.delContact(entity_jid, profile_key)
 
     def discoInfos(self, entity_jid, profile_key, callback=None, errback=None):
-        return self.db_core_iface.discoInfos(entity_jid, profile_key, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err)))
+        return self.db_core_iface.discoInfos(entity_jid, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err)))
 
     def discoItems(self, entity_jid, profile_key, callback=None, errback=None):
-        return self.db_core_iface.discoItems(entity_jid, profile_key, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err)))
+        return self.db_core_iface.discoItems(entity_jid, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err)))
 
     def disconnect(self, profile_key="@DEFAULT@"):
         return self.db_core_iface.disconnect(profile_key)
@@ -149,7 +151,7 @@
         return self.db_core_iface.getEntityData(jid, keys, profile)
 
     def getHistory(self, from_jid, to_jid, limit, between=True, profile="@NONE@", callback=None, errback=None):
-        return self.db_core_iface.getHistory(from_jid, to_jid, limit, between, profile, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err)))
+        return self.db_core_iface.getHistory(from_jid, to_jid, limit, between, profile, timeout=const_TIMEOUT, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err)))
 
     def getLastResource(self, contact_jid, profile_key="@DEFAULT@"):
         return unicode(self.db_core_iface.getLastResource(contact_jid, profile_key))
@@ -164,16 +166,16 @@
         return unicode(self.db_core_iface.getParamA(name, category, attribute, profile_key))
 
     def getParams(self, security_limit=-1, app='', profile_key="@DEFAULT@", callback=None, errback=None):
-        return unicode(self.db_core_iface.getParams(security_limit, app, profile_key, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err))))
+        return unicode(self.db_core_iface.getParams(security_limit, app, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err))))
 
     def getParamsCategories(self, ):
         return self.db_core_iface.getParamsCategories()
 
     def getParamsForCategory(self, category, security_limit=-1, app='', profile_key="@DEFAULT@", callback=None, errback=None):
-        return unicode(self.db_core_iface.getParamsForCategory(category, security_limit, app, profile_key, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err))))
+        return unicode(self.db_core_iface.getParamsForCategory(category, security_limit, app, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err))))
 
     def getParamsUI(self, security_limit=-1, app='', profile_key="@DEFAULT@", callback=None, errback=None):
-        return unicode(self.db_core_iface.getParamsUI(security_limit, app, profile_key, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err))))
+        return unicode(self.db_core_iface.getParamsUI(security_limit, app, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err))))
 
     def getPresenceStatuses(self, profile_key="@DEFAULT@"):
         return self.db_core_iface.getPresenceStatuses(profile_key)
@@ -188,7 +190,7 @@
         return self.db_core_iface.getProgress(id, profile)
 
     def getReady(self, callback=None, errback=None):
-        return self.db_core_iface.getReady(reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err)))
+        return self.db_core_iface.getReady(timeout=const_TIMEOUT, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err)))
 
     def getVersion(self, ):
         return unicode(self.db_core_iface.getVersion())
@@ -203,7 +205,7 @@
         return self.db_core_iface.isConnected(profile_key)
 
     def launchAction(self, callback_id, data, profile_key="@DEFAULT@", callback=None, errback=None):
-        return self.db_core_iface.launchAction(callback_id, data, profile_key, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err)))
+        return self.db_core_iface.launchAction(callback_id, data, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err)))
 
     def loadParamsTemplate(self, filename):
         return self.db_core_iface.loadParamsTemplate(filename)
@@ -215,7 +217,7 @@
         return self.db_core_iface.saveParamsTemplate(filename)
 
     def sendMessage(self, to_jid, message, subject='', mess_type="auto", extra={}, profile_key="@NONE@", callback=None, errback=None):
-        return self.db_core_iface.sendMessage(to_jid, message, subject, mess_type, extra, profile_key, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err)))
+        return self.db_core_iface.sendMessage(to_jid, message, subject, mess_type, extra, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err)))
 
     def setParam(self, name, value, category, security_limit=-1, profile_key="@DEFAULT@"):
         return self.db_core_iface.setParam(name, value, category, security_limit, profile_key)