Show
Ignore:
Timestamp:
06/21/08 21:12:47 (5 months ago)
Author:
bct
Message:

moved session negotiation handling from gajim.py to session.py

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/common/connection_handlers.py

    r9817 r9829  
    12191219                self.sessions = {} 
    12201220 
    1221         def _FeatureNegCB(self, con, stanza, session): 
    1222                 gajim.log.debug('FeatureNegCB') 
    1223                 feature = stanza.getTag(name='feature', namespace=common.xmpp.NS_FEATURE) 
    1224                 form = common.xmpp.DataForm(node=feature.getTag('x')) 
    1225  
    1226                 if form['FORM_TYPE'] == 'urn:xmpp:ssn': 
    1227                         self.dispatch('SESSION_NEG', (stanza.getFrom(), session, form)) 
    1228                 else: 
    1229                         reply = stanza.buildReply() 
    1230                         reply.setType('error') 
    1231  
    1232                         reply.addChild(feature) 
    1233                         reply.addChild(node=common.xmpp.ErrorNode('service-unavailable', typ='cancel')) 
    1234  
    1235                         con.send(reply) 
    1236  
    1237                 raise common.xmpp.NodeProcessed 
    1238  
    1239         def _InitE2ECB(self, con, stanza, session): 
    1240                 gajim.log.debug('InitE2ECB') 
    1241                 init = stanza.getTag(name='init', namespace=common.xmpp.NS_ESESSION_INIT) 
    1242                 form = common.xmpp.DataForm(node=init.getTag('x')) 
    1243  
    1244                 self.dispatch('SESSION_NEG', (stanza.getFrom(), session, form)) 
    1245  
    1246                 raise common.xmpp.NodeProcessed 
    1247  
    12481221        def get_or_create_session(self, jid, thread_id): 
    12491222                '''returns an existing session between this connection and 'jid', returns a new one if none exist.''' 
     
    17181691                if msg.getTag('feature', namespace=common.xmpp.NS_FEATURE): 
    17191692                        if gajim.HAVE_PYCRYPTO: 
    1720                                 self._FeatureNegCB(con, msg, session) 
    1721                         return 
     1693                                feature = msg.getTag(name='feature', namespace=common.xmpp.NS_FEATURE) 
     1694                                form = common.xmpp.DataForm(node=feature.getTag('x')) 
     1695 
     1696                                if form['FORM_TYPE'] == 'urn:xmpp:ssn': 
     1697                                        session.handle_negotiation(form) 
     1698                                else: 
     1699                                        reply = msg.buildReply() 
     1700                                        reply.setType('error') 
     1701 
     1702                                        reply.addChild(feature) 
     1703                                        err = common.xmpp.ErrorNode('service-unavailable', typ='cancel') 
     1704                                        reply.addChild(node=err) 
     1705 
     1706                                        con.send(reply) 
     1707 
     1708                                raise common.xmpp.NodeProcessed 
     1709 
     1710                        return 
     1711 
    17221712                if msg.getTag('init', namespace=common.xmpp.NS_ESESSION_INIT): 
    1723                         self._InitE2ECB(con, msg, session) 
     1713                        init = msg.getTag(name='init', namespace=common.xmpp.NS_ESESSION_INIT) 
     1714                        form = common.xmpp.DataForm(node=init.getTag('x')) 
     1715 
     1716                        session.handle_negotiation(form) 
     1717 
     1718                        raise common.xmpp.NodeProcessed 
    17241719 
    17251720                tim = msg.getTimestamp()