comparison 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
comparison
equal deleted inserted replaced
2088:c02f96756d5c 2089:0931b5a6213c
32 from sat.core import exceptions 32 from sat.core import exceptions
33 from zope.interface import implements 33 from zope.interface import implements
34 import time 34 import time
35 import calendar 35 import calendar
36 import uuid 36 import uuid
37 import sys
37 38
38 39
39 class SatXMPPClient(wokkel_client.XMPPClient): 40 class SatXMPPClient(wokkel_client.XMPPClient):
40 implements(iwokkel.IDisco) 41 implements(iwokkel.IDisco)
41 42
42 def __init__(self, host_app, profile, user_jid, password, host=None, port=C.XMPP_C2S_PORT, max_retries=C.XMPP_MAX_RETRIES): 43 def __init__(self, host_app, profile, user_jid, password, host=None, port=C.XMPP_C2S_PORT, max_retries=C.XMPP_MAX_RETRIES):
43 # XXX: DNS SRV records are checked when the host is not specified. 44 # XXX: DNS SRV records are checked when the host is not specified.
44 # If no SRV record is found, the host is directly extracted from the JID. 45 # If no SRV record is found, the host is directly extracted from the JID.
46 if sys.platform == "android":
47 # FIXME: temporary hack as SRV is not working on android
48 # TODO: remove this hack and fix SRV
49 log.info(u"FIXME: Android hack, ignoring SRV")
50 host = user_jid.host
51 hosts_map = host_app.memory.getConfig("android", "hosts_dict", {})
52 if host in hosts_map:
53 log.info(u"using {host_to_use} for host {host_ori} as requested in config".format(
54 host_ori = host,
55 host_to_use = hosts_map[host]))
56 host = hosts_map[host]
45 wokkel_client.XMPPClient.__init__(self, user_jid, password, host or None, port or C.XMPP_C2S_PORT) 57 wokkel_client.XMPPClient.__init__(self, user_jid, password, host or None, port or C.XMPP_C2S_PORT)
46 self.factory.clientConnectionLost = self.connectionLost 58 self.factory.clientConnectionLost = self.connectionLost
47 self.factory.maxRetries = max_retries 59 self.factory.maxRetries = max_retries
48 self.__connected = False 60 self.__connected = False
49 self.profile = profile 61 self.profile = profile