comparison sat/plugins/plugin_xep_0184.py @ 3028:ab2696e34d29

Python 3 port: /!\ this is a huge commit /!\ starting from this commit, SàT is needs Python 3.6+ /!\ SàT maybe be instable or some feature may not work anymore, this will improve with time This patch port backend, bridge and frontends to Python 3. Roughly this has been done this way: - 2to3 tools has been applied (with python 3.7) - all references to python2 have been replaced with python3 (notably shebangs) - fixed files not handled by 2to3 (notably the shell script) - several manual fixes - fixed issues reported by Python 3 that where not handled in Python 2 - replaced "async" with "async_" when needed (it's a reserved word from Python 3.7) - replaced zope's "implements" with @implementer decorator - temporary hack to handle data pickled in database, as str or bytes may be returned, to be checked later - fixed hash comparison for password - removed some code which is not needed anymore with Python 3 - deactivated some code which needs to be checked (notably certificate validation) - tested with jp, fixed reported issues until some basic commands worked - ported Primitivus (after porting dependencies like urwid satext) - more manual fixes
author Goffi <goffi@goffi.org>
date Tue, 13 Aug 2019 19:08:41 +0200
parents 56f94936df1e
children 95befc85e816
comparison
equal deleted inserted replaced
3027:ff5bcb12ae60 3028:ab2696e34d29
24 from twisted.words.xish import domish 24 from twisted.words.xish import domish
25 25
26 log = getLogger(__name__) 26 log = getLogger(__name__)
27 27
28 from wokkel import disco, iwokkel 28 from wokkel import disco, iwokkel
29 from zope.interface import implements 29 from zope.interface import implementer
30 30
31 try: 31 try:
32 from twisted.words.protocols.xmlstream import XMPPHandler 32 from twisted.words.protocols.xmlstream import XMPPHandler
33 except ImportError: 33 except ImportError:
34 from wokkel.subprotocols import XMPPHandler 34 from wokkel.subprotocols import XMPPHandler
161 def onMessageDeliveryReceiptsReceived(self, msg_elt, client): 161 def onMessageDeliveryReceiptsReceived(self, msg_elt, client):
162 """This method is called on message delivery receipts **received** (XEP-0184 #7) 162 """This method is called on message delivery receipts **received** (XEP-0184 #7)
163 @param msg_elt: message element 163 @param msg_elt: message element
164 @param client: %(doc_client)s""" 164 @param client: %(doc_client)s"""
165 msg_elt.handled = True 165 msg_elt.handled = True
166 rcv_elt = msg_elt.elements(NS_MESSAGE_DELIVERY_RECEIPTS, "received").next() 166 rcv_elt = next(msg_elt.elements(NS_MESSAGE_DELIVERY_RECEIPTS, "received"))
167 msg_id = rcv_elt["id"] 167 msg_id = rcv_elt["id"]
168 168
169 try: 169 try:
170 uid = self._dictRequest[msg_id] 170 uid = self._dictRequest[msg_id]
171 del self._dictRequest[msg_id] 171 del self._dictRequest[msg_id]
193 193
194 def _isActif(self, profile): 194 def _isActif(self, profile):
195 return self.host.memory.getParamA(PARAM_NAME, PARAM_KEY, profile_key=profile) 195 return self.host.memory.getParamA(PARAM_NAME, PARAM_KEY, profile_key=profile)
196 196
197 197
198 @implementer(iwokkel.IDisco)
198 class XEP_0184_handler(XMPPHandler): 199 class XEP_0184_handler(XMPPHandler):
199 implements(iwokkel.IDisco)
200 200
201 def __init__(self, plugin_parent, profile): 201 def __init__(self, plugin_parent, profile):
202 self.plugin_parent = plugin_parent 202 self.plugin_parent = plugin_parent
203 self.host = plugin_parent.host 203 self.host = plugin_parent.host
204 self.profile = profile 204 self.profile = profile