make file_props use session sid as the default sid
This commit is contained in:
		
							parent
							
								
									ce1bdb7b63
								
							
						
					
					
						commit
						5bec8c7a09
					
				
					 7 changed files with 16 additions and 17 deletions
				
			
		| 
						 | 
				
			
			@ -1981,11 +1981,9 @@ class FileRequestReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
 | 
			
		|||
                    self.FT_content.session.ourjid)
 | 
			
		||||
                self.FT_content.transport.set_connection(
 | 
			
		||||
                    self.FT_content.session.connection)
 | 
			
		||||
            sid = self.FT_content.transport.sid
 | 
			
		||||
            sid = unicode(self.stanza.getTag('jingle').getAttr('sid'))
 | 
			
		||||
            self.file_props = FilesProp.getNewFileProp(self.conn.name, sid)
 | 
			
		||||
            self.file_props.session_sid = unicode(
 | 
			
		||||
                                self.stanza.getTag('jingle').getAttr('sid')
 | 
			
		||||
                                                 )
 | 
			
		||||
            self.file_props.transport_sid = self.FT_content.transport.sid
 | 
			
		||||
            self.FT_content.file_props = self.file_props
 | 
			
		||||
            self.FT_content.transport.set_file_props(self.file_props)
 | 
			
		||||
            if self.file_props.streamhosts:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -123,6 +123,7 @@ class FileProp(object):
 | 
			
		|||
        self.tt_account = None
 | 
			
		||||
        self.size = None
 | 
			
		||||
        self._sid = sid
 | 
			
		||||
        self.transport_sid = None
 | 
			
		||||
        self.account = account
 | 
			
		||||
        self.mime_type = None
 | 
			
		||||
        self.algo = None
 | 
			
		||||
| 
						 | 
				
			
			@ -130,7 +131,6 @@ class FileProp(object):
 | 
			
		|||
        self.syn_id = None
 | 
			
		||||
        self.seq = None
 | 
			
		||||
        self.hash_ = None
 | 
			
		||||
        self.session_sid = None
 | 
			
		||||
        self.fd = None
 | 
			
		||||
        self.startexmpp = None
 | 
			
		||||
        self.session_type = None
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -76,8 +76,9 @@ class JingleFileTransfer(JingleContent):
 | 
			
		|||
            self.file_props.sender = session.ourjid
 | 
			
		||||
            self.file_props.receiver = session.peerjid
 | 
			
		||||
            self.file_props.session_type = 'jingle'
 | 
			
		||||
            self.file_props.session_sid = session.sid
 | 
			
		||||
            self.file_props.sid = session.sid
 | 
			
		||||
            self.file_props.transfered_size = []
 | 
			
		||||
            self.file_props.transport_sid = self.transport.sid
 | 
			
		||||
        log.info("FT request: %s" % file_props)
 | 
			
		||||
        if transport is None:
 | 
			
		||||
            self.transport = JingleTransportSocks5()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -250,7 +250,7 @@ class JingleTransportSocks5(JingleTransport):
 | 
			
		|||
 | 
			
		||||
    def get_content(self):
 | 
			
		||||
        sesn = self.connection.get_jingle_session(self.ourjid,
 | 
			
		||||
            self.file_props.session_sid)
 | 
			
		||||
            self.file_props.sid)
 | 
			
		||||
        for content in sesn.contents.values():
 | 
			
		||||
            if content.transport == self:
 | 
			
		||||
                return content
 | 
			
		||||
| 
						 | 
				
			
			@ -261,7 +261,7 @@ class JingleTransportSocks5(JingleTransport):
 | 
			
		|||
        if not self.connection:
 | 
			
		||||
            return
 | 
			
		||||
        sesn = self.connection.get_jingle_session(self.ourjid,
 | 
			
		||||
            self.file_props.session_sid)
 | 
			
		||||
            self.file_props.sid)
 | 
			
		||||
        if sesn is None:
 | 
			
		||||
            return
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -143,12 +143,12 @@ class ConnectionBytestream:
 | 
			
		|||
        log.info("send_file_approval: jingle session accept")
 | 
			
		||||
        if file_props.session_type == 'jingle':
 | 
			
		||||
            session = self.get_jingle_session(file_props.sender,
 | 
			
		||||
                file_props.session_sid)
 | 
			
		||||
                file_props.sid)
 | 
			
		||||
            if not session:
 | 
			
		||||
                return
 | 
			
		||||
            content = None
 | 
			
		||||
            for c in session.contents.values():
 | 
			
		||||
                if c.transport.sid == file_props.sid:
 | 
			
		||||
                if c.transport.sid == file_props.transport_sid:
 | 
			
		||||
                    content = c
 | 
			
		||||
                    break
 | 
			
		||||
            if not content:
 | 
			
		||||
| 
						 | 
				
			
			@ -193,7 +193,7 @@ class ConnectionBytestream:
 | 
			
		|||
        if not self.connection or self.connected < 2:
 | 
			
		||||
            return
 | 
			
		||||
        if file_props.session_type == 'jingle':
 | 
			
		||||
            jingle = self._sessions[file_props.session_sid]
 | 
			
		||||
            jingle = self._sessions[file_props.sid]
 | 
			
		||||
            jingle.cancel_session()
 | 
			
		||||
            return
 | 
			
		||||
        iq = xmpp.Iq(to=unicode(file_props.sender), typ='error')
 | 
			
		||||
| 
						 | 
				
			
			@ -562,7 +562,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
 | 
			
		|||
        else:
 | 
			
		||||
            to = file_props.sender
 | 
			
		||||
        iq = xmpp.Iq(to=to,     typ='error')
 | 
			
		||||
        iq.setAttr('id', file_props.session_sid)
 | 
			
		||||
        iq.setAttr('id', file_props.sid)
 | 
			
		||||
        err = iq.setTag('error')
 | 
			
		||||
        err.setAttr('code', unicode(code))
 | 
			
		||||
        err.setData(msg)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -257,7 +257,7 @@ class FileTransfersWindow:
 | 
			
		|||
            sid = gajim.connections[account].start_file_transfer(fjid,
 | 
			
		||||
                                                            file_props,
 | 
			
		||||
                                                                True)
 | 
			
		||||
            file_props.sid = sid
 | 
			
		||||
            file_props.transport_sid = sid
 | 
			
		||||
 | 
			
		||||
        if file_props.type_ == 'r':
 | 
			
		||||
            file_name = os.path.basename(file_props.file_name)
 | 
			
		||||
| 
						 | 
				
			
			@ -643,7 +643,8 @@ class FileTransfersWindow:
 | 
			
		|||
            self.model.set(iter_, 0, self.get_icon(status))
 | 
			
		||||
            if transfered_size == full_size:
 | 
			
		||||
                # If we are receiver and this is a jingle session
 | 
			
		||||
                if file_props.type_ == 'r' and  file_props.session_sid:
 | 
			
		||||
                if file_props.type_ == 'r' and  \
 | 
			
		||||
                        file_props.session_type == 'jingle':
 | 
			
		||||
                    # Show that we are computing the hash
 | 
			
		||||
                    self.set_status(file_props, 'computing')
 | 
			
		||||
                else:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -941,7 +941,7 @@ class Interface:
 | 
			
		|||
 | 
			
		||||
    def __compare_hashes(self, account, file_props):
 | 
			
		||||
        session = gajim.connections[account].get_jingle_session(jid=None,
 | 
			
		||||
            sid=file_props.session_sid)
 | 
			
		||||
            sid=file_props.sid)
 | 
			
		||||
        ft_win = self.instances['file_transfers']
 | 
			
		||||
        if not file_props.hash_:
 | 
			
		||||
            # We disn't get the hash, sender probably don't support that
 | 
			
		||||
| 
						 | 
				
			
			@ -981,9 +981,8 @@ class Interface:
 | 
			
		|||
            return
 | 
			
		||||
 | 
			
		||||
        if file_props.type_ == 'r': # we receive a file
 | 
			
		||||
            # If we have a jingle session id, it is a jingle transfer
 | 
			
		||||
            # we compare hashes
 | 
			
		||||
            if file_props.session_sid:
 | 
			
		||||
            if file_props.session_type == 'jingle':
 | 
			
		||||
                # Compare hashes in a new thread
 | 
			
		||||
                self.hashThread = Thread(target=self.__compare_hashes,
 | 
			
		||||
                    args=(account, file_props))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue