Ticket #644: jep70.patch
| File jep70.patch, 9.3 KB (added by travis@…, 5 years ago) |
|---|
-
launch.sh
1 1 cd src 2 ./gajim.py $@2 ./gajim.py --verbose $@ -
src/common/xmpp/protocol.py
70 70 NS_FILE ='http://jabber.org/protocol/si/profile/file-transfer' # JEP-0096 71 71 NS_FEATURE ='http://jabber.org/protocol/feature-neg' 72 72 NS_BYTESTREAM ='http://jabber.org/protocol/bytestreams' # JEP-0065 73 NS_DISCO ='http://jabber.org/protocol/disco#info' # JEP-0095 74 NS_STREAM ='http://affinix.com/jabber/stream' 73 NS_DISCO ='http://jabber.org/protocol/disco#info' # JEP-0095 74 NS_STREAM ='http://affinix.com/jabber/stream' 75 NS_HTTP_AUTH ='http://jabber.org/protocol/http-auth' # JEP-0070 75 76 76 77 xmpp_stream_error_conditions=""" 77 78 bad-format -- -- -- The entity has sent XML that cannot be processed. … … 324 325 if tag.getName()<>'text': return tag.getName() 325 326 return errtag.getData() 326 327 def getErrorCode(self): 327 """ Return the error code. Obsolet te. """328 """ Return the error code. Obsolete. """ 328 329 return self.getTagAttr('error','code') 329 330 def setError(self,error,code=None): 330 """ Set the error code. Obsolet te. Use error-conditions instead. """331 """ Set the error code. Obsolete. Use error-conditions instead. """ 331 332 if code: 332 333 if str(code) in _errorcodes.keys(): error=ErrorNode(_errorcodes[str(code)],text=error) 333 334 else: error=ErrorNode(ERR_UNDEFINED_CONDITION,code=code,typ='cancel',text=error) … … 449 450 450 451 class Iq(Protocol): 451 452 """ XMPP Iq object - get/set dialog mechanism. """ 452 def __init__(self, typ=None, queryNS=None, attrs={}, to=None, frm=None, payload=[], xmlns=NS_CLIENT, node=None): 453 def __init__(self, typ=None, queryNS=None, attrs={}, to=None, frm=None, 454 payload=[], xmlns=NS_CLIENT, node=None, iq_child='query'): 453 455 """ Create Iq object. You can specify type, query namespace 454 any additional attributes, recipient of the iq, sender of the iq, any additional payload (f.e. jabber:x:data node) and namespace in one go. 455 Alternatively you can pass in the other XML object as the 'node' parameted to replicate it as an iq. """ 456 Protocol.__init__(self, 'iq', to=to, typ=typ, attrs=attrs, frm=frm, xmlns=xmlns, node=node) 456 any additional attributes, recipient of the iq, sender of the iq, 457 any additional payload (f.e. jabber:x:data node) and namespace in 458 one go. Alternatively you can pass in the other XML object as the 459 'node' parameted to replicate it as an iq. Many protocols 460 have an inner child named 'query' for the Iq payload, but this is 461 not required. To allow for newer protocols the name of this child 462 can be specified to override the default value 'query'.""" 463 Protocol.__init__(self, 'iq', to=to, typ=typ, attrs=attrs, frm=frm, 464 xmlns=xmlns, node=node) 465 self.iq_child = iq_child or 'query' 457 466 if payload: self.setQueryPayload(payload) 458 467 if queryNS: self.setQueryNS(queryNS) 468 def setIqChildName(self, iq_child): 469 self.iq_child = iq_child or 'query'; 459 470 def getQueryNS(self): 460 """ Return the namespace of the 'query'child element."""461 tag=self.getTag( 'query')471 """ Return the namespace of the iq child element.""" 472 tag=self.getTag(self.iq_child) 462 473 if tag: return tag.getNamespace() 463 474 def getQuerynode(self): 464 """ Return the 'node' attribute value of the 'query'child element."""465 return self.getTagAttr( 'query','node')475 """ Return the 'node' attribute value of the iq child element.""" 476 return self.getTagAttr(self.iq_child,'node') 466 477 def getQueryPayload(self): 467 """ Return the 'query'child element payload."""468 tag=self.getTag( 'query')478 """ Return the iq child element payload.""" 479 tag=self.getTag(self.iq_child) 469 480 if tag: return tag.getPayload() 470 481 def getQueryChildren(self): 471 """ Return the 'query'child element child nodes."""472 tag=self.getTag( 'query')482 """ Return the iq child element child nodes.""" 483 tag=self.getTag(self.iq_child) 473 484 if tag: return tag.getChildren() 474 485 def setQueryNS(self,namespace): 475 """ Set the namespace of the 'query'child element."""476 self.setTag( 'query').setNamespace(namespace)486 """ Set the namespace of the iq child element.""" 487 self.setTag(self.iq_child).setNamespace(namespace) 477 488 def setQueryPayload(self,payload): 478 """ Set the 'query'child element payload."""479 self.setTag( 'query').setPayload(payload)489 """ Set the iq child element payload.""" 490 self.setTag(self.iq_child).setPayload(payload) 480 491 def setQuerynode(self,node): 481 """ Set the 'node' attribute value of the 'query'child element."""482 self.setTagAttr( 'query','node',node)492 """ Set the 'node' attribute value of the iq child element.""" 493 self.setTagAttr(self.iq_child,'node',node) 483 494 def buildReply(self,typ): 484 495 """ Builds and returns another Iq object of specified type. 485 The to, from and query child node of new Iq are pre-set as reply to this Iq. """ 496 The to, from and child node of new Iq are pre-set as reply 497 to this Iq. """ 486 498 iq=Iq(typ,to=self.getFrom(),frm=self.getTo(),attrs={'id':self.getID()}) 487 if self.getTag( 'query'): iq.setQueryNS(self.getQueryNS())499 if self.getTag(self.iq_child): iq.setQueryNS(self.getQueryNS()) 488 500 return iq 489 501 490 502 class ErrorNode(Node): -
src/common/connection.py
127 127 'GC_SUBJECT': [], 'GC_CONFIG': [], 'BAD_PASSPHRASE': [], 128 128 'ROSTER_INFO': [], 'ERROR_ANSWER': [], 'BOOKMARKS': [], 'CON_TYPE': [], 129 129 'FILE_REQUEST': [], 'FILE_RCV_COMPLETED': [], 'FILE_PROGRESS': [], 130 'STANZA_ARRIVED': [] 130 'STANZA_ARRIVED': [], 'HTTP_AUTH': [] 131 131 } 132 132 self.name = name 133 133 self.connected = 0 # offline … … 861 861 #TODO: implement this 862 862 pass 863 863 864 def _HttpAuthCB(self, con, iq_obj): 865 self.dispatch('HTTP_AUTH', (con, iq_obj)); 866 raise common.xmpp.NodeProcessed 867 864 868 def _ErrorCB(self, con, iq_obj): 865 869 errmsg = iq_obj.getError() 866 870 errcode = iq_obj.getErrorCode() … … 988 992 common.xmpp.NS_ROSTER) 989 993 con.RegisterHandler('iq', self._PrivateCB, 'result', 990 994 common.xmpp.NS_PRIVATE) 995 con.RegisterHandler('iq', self._HttpAuthCB, 'get', 996 common.xmpp.NS_HTTP_AUTH) 991 997 con.RegisterHandler('iq', self._ErrorCB, 'error') 992 998 con.RegisterHandler('iq', self._StanzaArrivedCB) 993 999 con.RegisterHandler('presence', self._StanzaArrivedCB) -
src/common/config.py
122 122 'confirm_close_muc': [opt_bool, True], # confirm closing MUC window 123 123 'notify_on_file_complete': [opt_bool, True], # notif. on file complete 124 124 'file_transfers_port': [opt_int, 28011], # port, used for file transfers 125 'http_auth': [opt_str, 'ask'], # yes, no, ask 125 126 } 126 127 127 128 __options_per_key = { -
src/gajim.py
197 197 #('INFORMATION', account, (title_text, section_text)) 198 198 dialogs.InformationDialog(data[0], data[1]).get_response() 199 199 200 def handle_http_auth(self, unused, data): 201 #('HTTP_AUTH', account, (connection, iq)) 202 con = data[0] 203 iq = data[1] 204 opt = gajim.config.get('http_auth') 205 if opt == 'yes': 206 iq = iq.buildReply('result') 207 elif opt == 'no': 208 iq = iq.buildReply('error') 209 iq.setError('not-authorized', 401); 210 else: 211 method = iq.getTagAttr('confirm', 'method') 212 url = iq.getTagAttr('confirm', 'url') 213 dialog = dialogs.ConfirmationDialog(\ 214 _('HTTP (%s) Authorization for %s') % (method, url), 215 _('Accept this request?')) 216 if dialog.get_response() == gtk.RESPONSE_OK: 217 iq = iq.buildReply('result'); 218 else: 219 iq = iq.buildReply('error'); 220 iq.setError('not-authorized', 401); 221 con.send(iq); 222 200 223 def handle_event_error_answer(self, account, array): 201 224 id, jid_from, errmsg, errcode = array 202 225 if str(errcode) in ['403', '406'] and id: … … 932 955 con.register_handler('CON_TYPE', self.handle_event_con_type) 933 956 con.register_handler('FILE_REQUEST', self.handle_event_file_request) 934 957 con.register_handler('STANZA_ARRIVED', self.handle_event_stanza_arrived) 958 con.register_handler('HTTP_AUTH', self.handle_http_auth) 935 959 936 960 def process_connections(self): 937 961 try:
