get right info in file_props when we receive a request for a file

This commit is contained in:
Jefry Lagrange 2012-09-02 12:59:55 -04:00
parent e0adaa8a87
commit 88194e02bc
5 changed files with 14 additions and 6 deletions

View File

@ -1996,8 +1996,13 @@ class FileRequestReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
desc = self.jingle_content.getTag('description') desc = self.jingle_content.getTag('description')
if desc.getTag('offer'): if desc.getTag('offer'):
file_tag = desc.getTag('offer').getTag('file') file_tag = desc.getTag('offer').getTag('file')
self.file_props.sender = self.fjid
self.file_props.receiver = self.conn._ft_get_our_jid()
else: else:
file_tag = desc.getTag('request').getTag('file') file_tag = desc.getTag('request').getTag('file')
self.file_props.sender = self.conn._ft_get_our_jid()
self.file_props.receiver = self.fjid
self.file_props.type_ = 's'
for child in file_tag.getChildren(): for child in file_tag.getChildren():
name = child.getName() name = child.getName()
val = child.getData() val = child.getData()
@ -2050,12 +2055,12 @@ class FileRequestReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
mime_type = si.getAttr('mime-type') mime_type = si.getAttr('mime-type')
if mime_type is not None: if mime_type is not None:
self.file_props.mime_type = mime_type self.file_props.mime_type = mime_type
self.file_props.sender = self.fjid self.file_props.sender = self.fjid
self.file_props.receiver = self.conn._ft_get_our_jid()
self.file_props.request_id = self.id_ self.file_props.request_id = self.id_
file_desc_tag = file_tag.getTag('desc') file_desc_tag = file_tag.getTag('desc')
if file_desc_tag is not None: if file_desc_tag is not None:
self.file_props.desc = file_desc_tag.getData() self.file_props.desc = file_desc_tag.getData()
self.file_props.receiver = self.conn._ft_get_our_jid()
self.file_props.transfered_size = [] self.file_props.transfered_size = []
return True return True

View File

@ -195,6 +195,7 @@ class JingleContent(object):
h = self._calcHash() h = self._calcHash()
file_tag.addChild(node=h) file_tag.addChild(node=h)
file_info = {'name' : self.file_props.name, file_info = {'name' : self.file_props.name,
'file-name' : self.file_props.file_name,
'hash' : self.file_props.hash_, 'hash' : self.file_props.hash_,
'size' : self.file_props.size, 'size' : self.file_props.size,
'date' : self.file_props.date 'date' : self.file_props.date

View File

@ -128,6 +128,7 @@ class JingleFileTransfer(JingleContent):
checksum.setNamespace(xmpp.NS_JINGLE_FILE_TRANSFER) checksum.setNamespace(xmpp.NS_JINGLE_FILE_TRANSFER)
self.session.__session_info(checksum ) self.session.__session_info(checksum )
file_info = {'name' : self.file_props.name, file_info = {'name' : self.file_props.name,
'file-name' : self.file_props.file_name,
'hash' : self.file_props.hash_, 'hash' : self.file_props.hash_,
'size' : self.file_props.size, 'size' : self.file_props.size,
'date' : self.file_props.date 'date' : self.file_props.date

View File

@ -522,8 +522,11 @@ class JingleSession(object):
file_info = self.connection.get_files_info(hash_=h) file_info = self.connection.get_files_info(hash_=h)
elif n: elif n:
file_info = self.connection.get_files_info(name=n) file_info = self.connection.get_files_info(name=n)
if not file_info: if file_info:
# Send 404 error? file_props = FilesProp.getFileProp(self.connection.name,
self.sid)
file_props.file_name = file_info['file-name']
else:
log.warning('The peer ' + self.peerjid + \ log.warning('The peer ' + self.peerjid + \
' is requesting a ' + \ ' is requesting a ' + \
'file that we dont have') 'file that we dont have')

View File

@ -32,7 +32,6 @@ import socket
import base64 import base64
import gobject import gobject
import time import time
import pdb
from common import xmpp from common import xmpp
from common import gajim from common import gajim
@ -838,7 +837,6 @@ class ConnectionIBBytestream(ConnectionBytestream):
Send next portion of data if it is time to do it. Used internally. Send next portion of data if it is time to do it. Used internally.
""" """
log.debug('SendHandler called') log.debug('SendHandler called')
#pdb.set_trace()
for file_props in FilesProp.getAllFileProp(): for file_props in FilesProp.getAllFileProp():
if not file_props.direction: if not file_props.direction:
# it's socks5 bytestream # it's socks5 bytestream