parse transport, construct streamhosts
This commit is contained in:
		
							parent
							
								
									2b745570ec
								
							
						
					
					
						commit
						2203755734
					
				
					 3 changed files with 29 additions and 8 deletions
				
			
		| 
						 | 
				
			
			@ -98,6 +98,13 @@ class JingleFileTransfer(JingleContent):
 | 
			
		|||
            self.transport = JingleTransportSocks5()
 | 
			
		||||
            self.transport.set_our_jid(self.session.ourjid)
 | 
			
		||||
        self.transport.set_file_props(self.file_props)
 | 
			
		||||
        if self.file_props.has_key("streamhosts"):
 | 
			
		||||
            self.file_props['streamhosts'].extend(self.transport.remote_candidates)
 | 
			
		||||
        else:
 | 
			
		||||
            self.file_props['streamhosts'] = self.transport.remote_candidates
 | 
			
		||||
        for host in self.file_props['streamhosts']:
 | 
			
		||||
            host['initiator'] = self.session.initiator
 | 
			
		||||
            host['target'] = self.session.responder
 | 
			
		||||
        log.info("FT request: %s" % file_props)
 | 
			
		||||
 | 
			
		||||
        self.session.connection.dispatch('FILE_REQUEST', (jid, file_props))
 | 
			
		||||
| 
						 | 
				
			
			@ -106,27 +113,22 @@ class JingleFileTransfer(JingleContent):
 | 
			
		|||
 | 
			
		||||
    def __on_session_accept(self, stanza, content, error, action):
 | 
			
		||||
        log.info("__on_session_accept")
 | 
			
		||||
        pass
 | 
			
		||||
        gajim.socks5queue.send_file(self.file_props, self.session.ourjid)
 | 
			
		||||
 | 
			
		||||
    def __on_session_terminate(self, stanza, content, error, action):
 | 
			
		||||
        log.info("__on_session_terminate")
 | 
			
		||||
        pass
 | 
			
		||||
 | 
			
		||||
    def __on_transport_accept(self, stanza, content, error, action):
 | 
			
		||||
        log.info("__on_transport_accept")
 | 
			
		||||
        pass
 | 
			
		||||
 | 
			
		||||
    def __on_transport_replace(self, stanza, content, error, action):
 | 
			
		||||
        log.info("__on_transport_replace")
 | 
			
		||||
        pass
 | 
			
		||||
    
 | 
			
		||||
    def __on_transport_reject(self, stanza, content, error, action):
 | 
			
		||||
        log.info("__on_transport_reject")
 | 
			
		||||
        pass
 | 
			
		||||
 | 
			
		||||
    def __on_transport_info(self, stanza, content, error, action):
 | 
			
		||||
        log.info("__on_transport_info")
 | 
			
		||||
        pass
 | 
			
		||||
 | 
			
		||||
    def _fill_content(self, content):
 | 
			
		||||
        description_node = xmpp.simplexml.Node(tag=xmpp.NS_JINGLE_FILE_TRANSFER + ' description')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -85,6 +85,7 @@ class JingleTransportSocks5(JingleTransport):
 | 
			
		|||
    """
 | 
			
		||||
    def __init__(self):
 | 
			
		||||
        JingleTransport.__init__(self, TransportType.streaming)
 | 
			
		||||
        self.remote_candidates = []
 | 
			
		||||
 | 
			
		||||
    def set_file_props(self, file_props):
 | 
			
		||||
        self.file_props = file_props
 | 
			
		||||
| 
						 | 
				
			
			@ -116,7 +117,20 @@ class JingleTransportSocks5(JingleTransport):
 | 
			
		|||
        return transport
 | 
			
		||||
 | 
			
		||||
    def parse_transport_stanza(self, transport):
 | 
			
		||||
        pass
 | 
			
		||||
        candidates = []
 | 
			
		||||
        for candidate in transport.iterTags('candidate'):
 | 
			
		||||
            cand = {
 | 
			
		||||
                'state': 0,
 | 
			
		||||
                'target': self.ourjid,
 | 
			
		||||
                'host': candidate['host'],
 | 
			
		||||
                'port': candidate['port']
 | 
			
		||||
            }
 | 
			
		||||
            candidates.append(cand)
 | 
			
		||||
            
 | 
			
		||||
            # we need this when we construct file_props on session-initiation
 | 
			
		||||
        self.remote_candidates = candidates
 | 
			
		||||
        return candidates
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
    def _add_local_ips_as_candidates(self):
 | 
			
		||||
        local_ip_cand = []
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -137,12 +137,17 @@ class ConnectionBytestream:
 | 
			
		|||
                return
 | 
			
		||||
            jid = gajim.get_jid_without_resource(file_props['sender'])
 | 
			
		||||
            resource = gajim.get_resource_from_jid(file_props['sender'])
 | 
			
		||||
            
 | 
			
		||||
            sid = file_props['sid']
 | 
			
		||||
            gajim.socks5queue.add_file_props(session.ourjid, file_props)
 | 
			
		||||
            
 | 
			
		||||
            if not session.accepted:
 | 
			
		||||
                session.approve_session()
 | 
			
		||||
                session.approve_content('file')
 | 
			
		||||
                
 | 
			
		||||
        if not gajim.socks5queue.get_file_props(session.ourjid, sid):
 | 
			
		||||
            gajim.socks5queue.add_file_props(session.ourjid, file_props)
 | 
			
		||||
        gajim.socks5queue.connect_to_hosts(session.ourjid, sid,
 | 
			
		||||
            None, None)
 | 
			
		||||
        return
 | 
			
		||||
 | 
			
		||||
        iq = xmpp.Iq(to=unicode(file_props['sender']), typ='result')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue