core: added sessionGetInfos bridge method to retrieve various data on current profile session + client.started keep start time

This commit is contained in:
Goffi 2017-01-05 22:22:13 +01:00
commit 50194cde01
2 changed files with 40 additions and 2 deletions

View file

@ -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)

View file

@ -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