Yann Leboulanger pushed to branch gajim_0.16 at gajim / gajim
Commits:
470c0e86 by Andrey Gursky at 2016-12-15T23:52:38+01:00
finish jingle file transfer session for files without hash
- - - - -
efc9c5b5 by Andrey Gursky at 2016-12-16T00:33:59+01:00
finish jingle file transfer session if file couldn't be verified
- - - - -
8cd423fa by Andrey Gursky at 2016-12-16T01:36:17+01:00
add event for jingle session initiation if we're initiator
- - - - -
005451ca by Yann Leboulanger at 2016-12-16T21:23:13+01:00
Merge branch 'file_transfer_related' into 'gajim_0.16'
Correctly end jingle session when file transfer doesn't terminate correctly
See merge request !5
- - - - -
3 changed files:
- src/common/connection_handlers_events.py
- src/common/jingle_ft.py
- src/gui_interface.py
Changes:
=====================================
src/common/connection_handlers_events.py
=====================================
--- a/src/common/connection_handlers_events.py
+++ b/src/common/connection_handlers_events.py
@@ -1657,6 +1657,20 @@ class AnonymousAuthEvent(nec.NetworkIncomingEvent):
name = 'anonymous-auth'
base_network_events = []
+class JingleSessionInitiateSendingEvent(nec.NetworkOutgoingEvent, HelperEvent):
+ name = 'jingle-session-initiate-sending'
+ base_network_events = []
+
+ def init(self):
+ self.jingle_content = None
+ self.FT_content = None
+
+ def generate(self):
+ self.get_id()
+ self.fjid = self.conn._ft_get_from(self.stanza)
+ self.jid = gajim.get_jid_without_resource(self.fjid)
+ return True
+
class JingleRequestReceivedEvent(nec.NetworkIncomingEvent):
name = 'jingle-request-received'
base_network_events = []
=====================================
src/common/jingle_ft.py
=====================================
--- a/src/common/jingle_ft.py
+++ b/src/common/jingle_ft.py
@@ -31,7 +31,8 @@ from common.jingle_ftstates import StateCandReceived,
JingleTransportSocks5, \
from common.jingle_transport import TransportType
from jingle_content import contents, JingleContent
from common import helpers
-from common.connection_handlers_events import FileRequestReceivedEvent
+from common.connection_handlers_events import FileRequestReceivedEvent, \
+ JingleSessionInitiateSendingEvent
import threading
import logging
@@ -140,7 +141,10 @@ class JingleFileTransfer(JingleContent):
self.session.accept_session()
def __on_session_initiate_sent(self, stanza, content, error, action):
- pass
+ log.debug("Jingle FT session initiate sending")
+ gajim.nec.push_outgoing_event(JingleSessionInitiateSendingEvent(None,
+ conn=self.session.connection, stanza=stanza,
jingle_content=content,
+ FT_content=self))
def __send_hash(self):
# Send hash in a session info
=====================================
src/gui_interface.py
=====================================
--- a/src/gui_interface.py
+++ b/src/gui_interface.py
@@ -970,32 +970,32 @@ class Interface:
session = gajim.connections[account].get_jingle_session(jid=None,
sid=file_props.sid)
ft_win = self.instances['file_transfers']
- if not file_props.hash_:
- # We disn't get the hash, sender probably don't support that
- jid = unicode(file_props.sender)
- self.popup_ft_result(account, jid, file_props)
- ft_win.set_status(file_props, 'ok')
h = Hashes()
+ hash_ = None
try:
file_ = open(file_props.file_name, 'rb')
+ hash_ = h.calculateHash(file_props.algo, file_)
+ file_.close()
except:
- return
- hash_ = h.calculateHash(file_props.algo, file_)
- file_.close()
+ pass
# If the hash we received and the hash of the file are the same,
# then the file is not corrupt
jid = unicode(file_props.sender)
- if file_props.hash_ == hash_:
+ if hash_ and file_props.hash_ == hash_:
gobject.idle_add(self.popup_ft_result, account, jid, file_props)
gobject.idle_add(ft_win.set_status, file_props, 'ok')
+ # End jingle session
+ if session:
+ session.end_session()
else:
# wrong hash, we need to get the file again!
file_props.error = -10
gobject.idle_add(self.popup_ft_result, account, jid, file_props)
gobject.idle_add(ft_win.set_status, file_props, 'hash_error')
- # End jingle session
- if session:
- session.end_session()
+ # End jingle session
+ # TODO: send media-error
+ if session:
+ session.end_session()
def handle_event_file_rcv_completed(self, account, file_props):
ft = self.instances['file_transfers']
@@ -1009,14 +1009,25 @@ class Interface:
if file_props.stalled or file_props.paused:
return
- if file_props.type_ == 'r' and file_props.hash_: # we receive a file
+ if file_props.type_ == 'r': # we receive a file
gajim.socks5queue.remove_receiver(file_props.sid, True, True)
- # we compare hashes
if file_props.session_type == 'jingle':
- # Compare hashes in a new thread
- self.hashThread = Thread(target=self.__compare_hashes,
- args=(account, file_props))
- self.hashThread.start()
+ if file_props.hash_:
+ # We compare hashes in a new thread
+ self.hashThread = Thread(target=self.__compare_hashes,
+ args=(account, file_props))
+ self.hashThread.start()
+ else:
+ # We disn't get the hash, sender probably don't support
that
+ jid = unicode(file_props.sender)
+ self.popup_ft_result(account, jid, file_props)
+ ft.set_status(file_props, 'ok')
+ session =
gajim.connections[account].get_jingle_session(jid=None,
+ sid=file_props.sid)
+ # End jingle session
+ # TODO: only if there are no other parallel downloads in
this session
+ if session:
+ session.end_session()
else: # we send a file
jid = unicode(file_props.receiver)
gajim.socks5queue.remove_sender(file_props.sid, True, True)
View it on GitLab:
https://dev.gajim.org/gajim/gajim/compare/6d866b14248a0c9d2fbde72d19a733d71412e4d1...005451ca95d88bc181e76bda7bc4f5c4c86ffac8
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits