core: added sessionGetInfos bridge method to retrieve various data on current profile session + client.started keep start time
This commit is contained in:
parent
fb0aaf2cae
commit
50194cde01
5 changed files with 40 additions and 2 deletions
|
|
@ -644,6 +644,15 @@ class Bridge(BridgeFrontend):
|
|||
kwargs['error_handler'] = error_handler
|
||||
return self.db_core_iface.saveParamsTemplate(filename, **kwargs)
|
||||
|
||||
def sessionInfosGet(self, profile_key, callback=None, errback=None):
|
||||
if callback is None:
|
||||
error_handler = None
|
||||
else:
|
||||
if errback is None:
|
||||
errback = log.error
|
||||
error_handler = lambda err:errback(dbus_to_bridge_exception(err))
|
||||
return self.db_core_iface.sessionInfosGet(profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
|
||||
|
||||
def setParam(self, name, value, category, security_limit=-1, profile_key="@DEFAULT@", callback=None, errback=None):
|
||||
if callback is None:
|
||||
error_handler = None
|
||||
|
|
|
|||
|
|
@ -716,3 +716,15 @@ sig_out=b
|
|||
doc=Load parameters template from xml file
|
||||
doc_param_0=filename: input filename
|
||||
doc_return=boolean (True in case of success)
|
||||
|
||||
[sessionInfosGet]
|
||||
async=
|
||||
type=method
|
||||
category=core
|
||||
sig_in=s
|
||||
sig_out=a{ss}
|
||||
doc=Get various informations on current profile session
|
||||
doc_param_0=%(doc_profile_key)s
|
||||
doc_return=session informations, with at least the following keys:
|
||||
jid: current full jid
|
||||
started: date of creation of the session (Epoch time)
|
||||
|
|
|
|||
|
|
@ -443,6 +443,12 @@ class DbusObject(dbus.service.Object):
|
|||
def saveParamsTemplate(self, filename):
|
||||
return self._callback("saveParamsTemplate", unicode(filename))
|
||||
|
||||
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
|
||||
in_signature='s', out_signature='a{ss}',
|
||||
async_callbacks=('callback', 'errback'))
|
||||
def sessionInfosGet(self, profile_key, callback=None, errback=None):
|
||||
return self._callback("sessionInfosGet", unicode(profile_key), callback=callback, errback=errback)
|
||||
|
||||
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
|
||||
in_signature='sssis', out_signature='',
|
||||
async_callbacks=None)
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ class SAT(service.Service):
|
|||
self.bridge.register_method("discoItems", self.memory.disco._discoItems)
|
||||
self.bridge.register_method("saveParamsTemplate", self.memory.save_xml)
|
||||
self.bridge.register_method("loadParamsTemplate", self.memory.load_xml)
|
||||
self.bridge.register_method("sessionInfosGet", self.getSessionInfos)
|
||||
|
||||
self.memory.initialized.addCallback(self._postMemoryInit)
|
||||
|
||||
|
|
@ -1077,8 +1078,8 @@ class SAT(service.Service):
|
|||
return ret
|
||||
|
||||
def getMenuHelp(self, menu_id, language=''):
|
||||
"""
|
||||
return the help string of the menu
|
||||
"""return the help string of the menu
|
||||
|
||||
@param menu_id: id of the menu (same as callback_id)
|
||||
@param language: language used for translation, or empty string for default
|
||||
@param return: translated help
|
||||
|
|
@ -1092,3 +1093,12 @@ class SAT(service.Service):
|
|||
help_string = _(menu_data['help_string'])
|
||||
languageSwitch()
|
||||
return help_string
|
||||
|
||||
def getSessionInfos(self, profile_key):
|
||||
"""compile interesting data on current profile session"""
|
||||
client = self.getClient(profile_key)
|
||||
data = {
|
||||
"jid": client.jid.full(),
|
||||
"started": unicode(int(client.started)),
|
||||
}
|
||||
return defer.succeed(data)
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ class SatXMPPClient(wokkel_client.XMPPClient):
|
|||
def __init__(self, host_app, profile, user_jid, password, host=None, port=C.XMPP_C2S_PORT, max_retries=C.XMPP_MAX_RETRIES):
|
||||
# XXX: DNS SRV records are checked when the host is not specified.
|
||||
# If no SRV record is found, the host is directly extracted from the JID.
|
||||
self.started = time.time()
|
||||
if sys.platform == "android":
|
||||
# FIXME: temporary hack as SRV is not working on android
|
||||
# TODO: remove this hack and fix SRV
|
||||
|
|
|
|||
Loading…
Reference in a new issue