send transport info, start "send_file" after receiving transport-info.
TODO: implement file transfer complete callback, various session management code for abnormal FT interactions.
This commit is contained in:
parent
d0adcb1a05
commit
14fe189b00
|
@ -117,7 +117,6 @@ class JingleFileTransfer(JingleContent):
|
||||||
|
|
||||||
def __on_session_accept(self, stanza, content, error, action):
|
def __on_session_accept(self, stanza, content, error, action):
|
||||||
log.info("__on_session_accept")
|
log.info("__on_session_accept")
|
||||||
gajim.socks5queue.send_file(self.file_props, self.session.ourjid)
|
|
||||||
|
|
||||||
def __on_session_terminate(self, stanza, content, error, action):
|
def __on_session_terminate(self, stanza, content, error, action):
|
||||||
log.info("__on_session_terminate")
|
log.info("__on_session_terminate")
|
||||||
|
@ -133,6 +132,7 @@ class JingleFileTransfer(JingleContent):
|
||||||
|
|
||||||
def __on_transport_info(self, stanza, content, error, action):
|
def __on_transport_info(self, stanza, content, error, action):
|
||||||
log.info("__on_transport_info")
|
log.info("__on_transport_info")
|
||||||
|
gajim.socks5queue.send_file(self.file_props, self.session.ourjid)
|
||||||
|
|
||||||
def __on_iq_result(self, stanza, content, error, action):
|
def __on_iq_result(self, stanza, content, error, action):
|
||||||
log.info("__on_iq_result")
|
log.info("__on_iq_result")
|
||||||
|
@ -152,6 +152,38 @@ class JingleFileTransfer(JingleContent):
|
||||||
if not listener:
|
if not listener:
|
||||||
return
|
return
|
||||||
# send error message, notify the user
|
# send error message, notify the user
|
||||||
|
else: # session-accept iq-result
|
||||||
|
if not gajim.socks5queue.get_file_props(self.session.ourjid, self.file_props['sid']):
|
||||||
|
gajim.socks5queue.add_file_props(self.session.ourjid, self.file_props)
|
||||||
|
gajim.socks5queue.connect_to_hosts(self.session.ourjid, self.file_props['sid'],
|
||||||
|
self.send_candidate_used, self._on_connect_error)
|
||||||
|
|
||||||
|
def send_candidate_used(self, streamhost):
|
||||||
|
"""
|
||||||
|
send candidate-used stanza
|
||||||
|
"""
|
||||||
|
log.info("send_candidate_used")
|
||||||
|
if streamhost is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
content = xmpp.Node('content')
|
||||||
|
content.setAttr('creator', 'initiator')
|
||||||
|
content.setAttr('name', 'file')
|
||||||
|
|
||||||
|
transport = xmpp.Node('transport')
|
||||||
|
transport.setAttr('xmlns', xmpp.NS_JINGLE_BYTESTREAM)
|
||||||
|
|
||||||
|
candidateused = xmpp.Node('candidate-used')
|
||||||
|
candidateused.setAttr('cid', streamhost['cid'])
|
||||||
|
|
||||||
|
transport.addChild(node=candidateused)
|
||||||
|
content.addChild(node=transport)
|
||||||
|
|
||||||
|
self.session.send_transport_info(content)
|
||||||
|
|
||||||
|
def _on_connect_error(self, to, _id, sid, code=404):
|
||||||
|
log.info("connect error, sid=" + sid)
|
||||||
|
return
|
||||||
|
|
||||||
def _fill_content(self, content):
|
def _fill_content(self, content):
|
||||||
description_node = xmpp.simplexml.Node(tag=xmpp.NS_JINGLE_FILE_TRANSFER + ' description')
|
description_node = xmpp.simplexml.Node(tag=xmpp.NS_JINGLE_FILE_TRANSFER + ' description')
|
||||||
|
|
|
@ -123,7 +123,8 @@ class JingleTransportSocks5(JingleTransport):
|
||||||
'state': 0,
|
'state': 0,
|
||||||
'target': self.ourjid,
|
'target': self.ourjid,
|
||||||
'host': candidate['host'],
|
'host': candidate['host'],
|
||||||
'port': candidate['port']
|
'port': candidate['port'],
|
||||||
|
'cid': candidate['cid']
|
||||||
}
|
}
|
||||||
candidates.append(cand)
|
candidates.append(cand)
|
||||||
|
|
||||||
|
|
|
@ -143,12 +143,6 @@ class ConnectionBytestream:
|
||||||
if not session.accepted:
|
if not session.accepted:
|
||||||
session.approve_session()
|
session.approve_session()
|
||||||
session.approve_content('file')
|
session.approve_content('file')
|
||||||
|
|
||||||
if not gajim.socks5queue.get_file_props(session.ourjid, sid):
|
|
||||||
gajim.socks5queue.add_file_props(session.ourjid, file_props)
|
|
||||||
gajim.socks5queue.connect_to_hosts(session.ourjid, sid,
|
|
||||||
lambda streamhost: log.info("connected to" + str(streamhost)),
|
|
||||||
lambda a, b, c, d: log.info("connect error!" + a + b + c + d))
|
|
||||||
return
|
return
|
||||||
|
|
||||||
iq = xmpp.Iq(to=unicode(file_props['sender']), typ='result')
|
iq = xmpp.Iq(to=unicode(file_props['sender']), typ='result')
|
||||||
|
|
Loading…
Reference in New Issue