Mercurial > libervia-backend
diff src/core/xmpp.py @ 2089:0931b5a6213c
core, quick_frontends: android compatibility hacks:
a couple of hacks have been used so backend can be launched on android using kivy
- config file (sat.conf) is been read on a specific dir, using a detection of Cagou domains in constants.py
- fixed crash when using sys.stdout.isatty in log_config.py
- Q&D fix for logging encoding issue on android
- when android is detected, the path/pattern to load plugins is modified
- SRV is not working at the moment on android. If the platform is detected, the host is used directly with default port. A hosts_dir configuration can be used in [android] section to map a specific ip to a host
- getRepositoryData in tools/utils return constant string on android. Proper repository data need to be copied during package building.
- [quick app] more robust failure handling on asyncConnect error
- [quick chat] default to utf-8 when getlocale doesn't return the actual locale.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 04 Dec 2016 18:16:48 +0100 |
parents | 046449cc2bff |
children | ad88808591ef |
line wrap: on
line diff
--- a/src/core/xmpp.py Sun Dec 04 18:16:37 2016 +0100 +++ b/src/core/xmpp.py Sun Dec 04 18:16:48 2016 +0100 @@ -34,6 +34,7 @@ import time import calendar import uuid +import sys class SatXMPPClient(wokkel_client.XMPPClient): @@ -42,6 +43,17 @@ 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. + if sys.platform == "android": + # FIXME: temporary hack as SRV is not working on android + # TODO: remove this hack and fix SRV + log.info(u"FIXME: Android hack, ignoring SRV") + host = user_jid.host + hosts_map = host_app.memory.getConfig("android", "hosts_dict", {}) + if host in hosts_map: + log.info(u"using {host_to_use} for host {host_ori} as requested in config".format( + host_ori = host, + host_to_use = hosts_map[host])) + host = hosts_map[host] wokkel_client.XMPPClient.__init__(self, user_jid, password, host or None, port or C.XMPP_C2S_PORT) self.factory.clientConnectionLost = self.connectionLost self.factory.maxRetries = max_retries