From d16ee652c60a2ec1fe05593ecb95c048bdef7eed Mon Sep 17 00:00:00 2001 From: Jefry Lagrange Date: Wed, 5 Sep 2012 19:39:07 -0400 Subject: [PATCH] send session-accept for file request --- src/common/connection_handlers_events.py | 7 +++++++ src/common/jingle_ft.py | 5 +++++ src/common/jingle_session.py | 8 +++----- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/common/connection_handlers_events.py b/src/common/connection_handlers_events.py index 16f5d3418..06bb22c83 100644 --- a/src/common/connection_handlers_events.py +++ b/src/common/connection_handlers_events.py @@ -2000,6 +2000,13 @@ class FileRequestReceivedEvent(nec.NetworkIncomingEvent, HelperEvent): self.file_props.receiver = self.conn._ft_get_our_jid() else: file_tag = desc.getTag('request').getTag('file') + h = file_tag.getTag('hash') + n = file_tag.getTag('name') + if h: + file_info = self.conn.get_files_info(hash_=h) + elif n: + file_info = self.conn.get_files_info(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 self.file_props.type_ = 's' diff --git a/src/common/jingle_ft.py b/src/common/jingle_ft.py index 851a16289..e605e24d3 100644 --- a/src/common/jingle_ft.py +++ b/src/common/jingle_ft.py @@ -47,6 +47,7 @@ STATE_TRANSFERING = 6 class JingleFileTransfer(JingleContent): + def __init__(self, session, transport=None, file_props=None, use_security=False): JingleContent.__init__(self, session, transport) @@ -117,6 +118,10 @@ class JingleFileTransfer(JingleContent): gajim.nec.push_incoming_event(FileRequestReceivedEvent(None, conn=self.session.connection, stanza=stanza, jingle_content=content, FT_content=self)) + if self.session.request: + # accept the request + self.session.approve_content(self.media, self.name) + self.session.accept_session() def __on_session_initiate_sent(self, stanza, content, error, action): pass diff --git a/src/common/jingle_session.py b/src/common/jingle_session.py index 44cab74ed..8b5814d57 100644 --- a/src/common/jingle_session.py +++ b/src/common/jingle_session.py @@ -86,6 +86,7 @@ class JingleSession(object): self.weinitiate = weinitiate # Are we requesting or offering a file? self.werequest = werequest + self.request = False # what state is session in? (one from JingleStates) self.state = JingleStates.ended if not sid: @@ -516,17 +517,14 @@ class JingleSession(object): request = \ jingle.getTag('content').getTag('description').getTag('request') if request: + self.request = True h = request.getTag('file').getTag('hash') n = request.getTag('file').getTag('name') if h: file_info = self.connection.get_files_info(hash_=h) elif n: file_info = self.connection.get_files_info(name=n) - if file_info: - file_props = FilesProp.getFileProp(self.connection.name, - self.sid) - file_props.file_name = file_info['file-name'] - else: + if not file_info: log.warning('The peer ' + self.peerjid + \ ' is requesting a ' + \ 'file that we dont have')