refactoring
This commit is contained in:
parent
3d39c36c18
commit
4f6687e868
3 changed files with 8 additions and 13 deletions
|
@ -2002,10 +2002,8 @@ class FileRequestReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
|
|||
file_tag = desc.getTag('request').getTag('file')
|
||||
h = file_tag.getTag('hash')
|
||||
n = file_tag.getTag('name')
|
||||
if h:
|
||||
file_info = self.conn.get_file_info(hash_=h)
|
||||
elif n:
|
||||
file_info = self.conn.get_file_info(name=n)
|
||||
pjid = gajim.get_jid_without_resource(self.fjid)
|
||||
file_info = self.conn.get_file_info(pjid, hash_=h, name=n)
|
||||
self.file_props.file_name = file_info['file-name']
|
||||
self.file_props.sender = self.conn._ft_get_our_jid()
|
||||
self.file_props.receiver = self.fjid
|
||||
|
|
|
@ -194,15 +194,15 @@ class ConnectionJingle(object):
|
|||
# to be requested again.
|
||||
self.files.append(file_)
|
||||
|
||||
def get_file_info(self, hash_=None, name=None):
|
||||
def get_file_info(self, peerjid, hash_=None, name=None):
|
||||
if hash_:
|
||||
for f in self.files: # DEBUG
|
||||
#if f['hash'] == '1294809248109223':
|
||||
if f['hash'] == hash_:
|
||||
if f['hash'] == hash_ and f['peerjid'] == peerjid:
|
||||
return f
|
||||
elif name:
|
||||
for f in self.files:
|
||||
if f['name'] == name:
|
||||
if f['name'] == name and f['peerjid'] == peerjid:
|
||||
return f
|
||||
|
||||
def get_jingle_session(self, jid, sid=None, media=None):
|
||||
|
|
|
@ -521,15 +521,12 @@ class JingleSession(object):
|
|||
self.request = True
|
||||
h = request.getTag('file').getTag('hash')
|
||||
n = request.getTag('file').getTag('name')
|
||||
if h:
|
||||
file_info = self.connection.get_file_info(hash_=h)
|
||||
elif n:
|
||||
file_info = self.connection.get_file_info(name=n)
|
||||
pjid = gajim.get_jid_without_resource(self.peerjid)
|
||||
if not file_info or file_info['peerjid'] != pjid:
|
||||
file_info = self.connection.get_file_info(pjid, h, n)
|
||||
if not file_info:
|
||||
log.warning('The peer ' + pjid + \
|
||||
' is requesting a ' + \
|
||||
'file that we dont have or' + \
|
||||
'file that we dont have or ' + \
|
||||
'it is not allowed to request')
|
||||
self.decline_session()
|
||||
raise xmpp.NodeProcessed
|
||||
|
|
Loading…
Add table
Reference in a new issue