Ticket #644: jep70.2.patch

File jep70.2.patch, 3.6 KB (added by asterix, 5 years ago)

new patch for JEP 70

  • common/xmpp/protocol.py

     
    7070NS_FILE         ='http://jabber.org/protocol/si/profile/file-transfer' # JEP-0096 
    7171NS_FEATURE      ='http://jabber.org/protocol/feature-neg' 
    7272NS_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' 
     73NS_DISCO        ='http://jabber.org/protocol/disco#info' # JEP-0095 
     74NS_STREAM       ='http://affinix.com/jabber/stream' 
     75NS_HTTP_AUTH    ='http://jabber.org/protocol/http-auth'         # JEP-0070 
    7576 
    7677xmpp_stream_error_conditions=""" 
    7778bad-format --  --  -- The entity has sent XML that cannot be processed. 
  • common/connection.py

     
    127127                        'GC_SUBJECT': [], 'GC_CONFIG': [], 'BAD_PASSPHRASE': [], 
    128128                        'ROSTER_INFO': [], 'ERROR_ANSWER': [], 'BOOKMARKS': [], 'CON_TYPE': [], 
    129129                        'FILE_REQUEST': [], 'FILE_RCV_COMPLETED': [], 'FILE_PROGRESS': [], 
    130                         'STANZA_ARRIVED': [] 
     130                        'STANZA_ARRIVED': [], 'HTTP_AUTH': [] 
    131131                        } 
    132132                self.name = name 
    133133                self.connected = 0 # offline 
     
    859859                        #Preferences data 
    860860                        #http://www.jabber.org/jeps/jep-0049.html 
    861861                        #TODO: implement this 
    862                         pass  
     862                        pass 
     863         
     864        def _HttpAuthCB(self, con, iq_obj): 
     865                opt = gajim.config.get('http_auth') 
     866                iq = None 
     867                if opt == 'yes': 
     868                        iq = iq_obj.buildReply('result') 
     869                elif opt == 'no': 
     870                        iq = iq_obj.buildReply('error') 
     871                        iq.setError('not-authorized', 401) 
     872                else: 
     873                        method = iq_obj.getTagAttr('confirm', 'method') 
     874                        url = iq_obj.getTagAttr('confirm', 'url') 
     875                        self.dispatch('HTTP_AUTH', (method, url, iq_obj)); 
     876                if iq: 
     877                        con.send(iq) 
     878                raise common.xmpp.NodeProcessed 
    863879 
    864880        def _ErrorCB(self, con, iq_obj): 
    865881                errmsg = iq_obj.getError() 
     
    9891005                        common.xmpp.NS_ROSTER) 
    9901006                con.RegisterHandler('iq', self._PrivateCB, 'result', 
    9911007                        common.xmpp.NS_PRIVATE) 
     1008                con.RegisterHandler('iq', self._HttpAuthCB, 'get', 
     1009                        common.xmpp.NS_HTTP_AUTH) 
    9921010                con.RegisterHandler('iq', self._ErrorCB, 'error') 
    9931011                con.RegisterHandler('iq', self._StanzaArrivedCB) 
    9941012                con.RegisterHandler('presence', self._StanzaArrivedCB) 
  • common/config.py

     
    154154                        # try for 2 minutes before giving up (aka. timeout after those seconds) 
    155155                        'try_connecting_for_foo_secs': [ opt_int, 60 ], 
    156156                        'max_stanza_per_sec': [ opt_int, 5], 
     157                        'http_auth': [opt_str, 'ask'], # yes, no, ask 
    157158                }, {}), 
    158159                'statusmsg': ({ 
    159160                        'message': [ opt_str, '' ], 
  • gajim.py

     
    197197                #('INFORMATION', account, (title_text, section_text)) 
    198198                dialogs.InformationDialog(data[0], data[1]).get_response() 
    199199 
     200        def handle_event_http_auth(self, account, data): 
     201                #('HTTP_AUTH', account, (method, url, iq_obj)) 
     202                dialog = dialogs.ConfirmationDialog(_('HTTP (%s) Authorization for %s') \ 
     203                        % (array[0], array[1]), _('Do you accept this request?')) 
     204                if dialog.get_response() == gtk.RESPONSE_OK: 
     205                        answer = 'yes' 
     206                else: 
     207                        answer = 'no' 
     208                gajim.connections[account].build_http_auth_answer(data[2], answer) 
     209 
    200210        def handle_event_error_answer(self, account, array): 
    201211                id, jid_from, errmsg, errcode = array 
    202212                if str(errcode) in ['403', '406'] and id: