Show
Ignore:
Timestamp:
08/10/05 17:59:55 (3 years ago)
Author:
dkirov
Message:

proper disconnect routines

Files:
1 modified

Legend:

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

    r2922 r2942  
    524524                except: # this bytestream result is not what we need 
    525525                        pass 
    526                 if streamhost is None:  
    527                         # proxy approves the activate query 
    528                         raise common.xmpp.NodeProcessed 
    529                 jid = streamhost.getAttr('jid') 
    530526                id = real_id[3:] 
    531527                if self.files_props.has_key(id): 
     
    533529                else: 
    534530                        raise common.xmpp.NodeProcessed 
    535                         file_props['type'] 
     531                if streamhost is None:  
     532                        # proxy approves the activate query 
     533                        if real_id[:3] == 'au_': 
     534                                id = real_id[3:] 
     535                                if not file_props.has_key('streamhost-used') or \ 
     536                                        file_props['streamhost-used'] is False: 
     537                                        raise common.xmpp.NodeProcessed 
     538                                if not file_props.has_key('proxyhosts'): 
     539                                        raise common.xmpp.NodeProcessed 
     540                                for host in file_props['proxyhosts']: 
     541                                        if host['initiator'] == frm and \ 
     542                                        str(query.getAttr('sid')) == file_props['sid']: 
     543                                                gajim.socks5queue.activate_proxy(host['idx']) 
     544                                                break 
     545                        raise common.xmpp.NodeProcessed 
     546                jid = streamhost.getAttr('jid') 
    536547                if file_props.has_key('streamhost-used') and \ 
    537548                        file_props['streamhost-used'] is True: 
     
    570581                raise common.xmpp.NodeProcessed 
    571582         
     583        def remove_all_transfers(self): 
     584                ''' stops and removes all active connections from the socks5 pool ''' 
     585                for file_props in self.files_props.values(): 
     586                        self.remove_transfer(file_props, remove_from_list = False) 
     587                del(self.files_props) 
     588                self.files_props = {} 
     589         
     590        def remove_transfer(self, file_props, remove_from_list = True): 
     591                if file_props.has_key('hash'): 
     592                        gajim.socks5queue.remove_sender(file_props['hash']) 
     593                 
     594                if file_props.has_key('streamhosts'): 
     595                        for host in file_props['streamhosts']: 
     596                                if host['idx'] > 0: 
     597                                        gajim.socks5queue.remove_receiver(host['idx']) 
     598                                        gajim.socks5queue.remove_sender(host['idx']) 
     599                sid = file_props['sid'] 
     600                gajim.socks5queue.remove_file_props(self.name, sid) 
     601                 
     602                if remove_from_list: 
     603                        if self.files_props.has_key('sid'): 
     604                                del(self.files_props['sid']) 
     605                                 
     606        def disconnect_transfer(self, file_props): 
     607                if file_props.has_key('hash'): 
     608                        gajim.socks5queue.remove_sender(file_props['hash']) 
     609                 
     610                if file_props.has_key('streamhosts'): 
     611                        for host in file_props['streamhosts']: 
     612                                if host['idx'] > 0: 
     613                                        gajim.socks5queue.remove_receiver(host['idx']) 
     614                                        gajim.socks5queue.remove_sender(host['idx']) 
     615                         
    572616        def proxy_auth_ok(self, proxy): 
    573617                '''cb, called after authentication to proxy server ''' 
     
    13851429                                if msg: 
    13861430                                        p.setStatus(msg) 
     1431                                self.remove_all_transfers() 
    13871432                                if self.connection: 
    13881433                                        self.connection.send(p)