send session-accept for file request
This commit is contained in:
parent
dcab602b75
commit
d16ee652c6
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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')
|
||||
|
|
Loading…
Reference in New Issue