Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
e00dad0b
by Philipp Hörist at 2019-12-10T22:12:48Z
-
1b1ca88c
by Philipp Hörist at 2019-12-10T22:18:10Z
3 changed files:
- gajim/common/connection_handlers_events.py
- gajim/common/modules/bytestream.py
- gajim/gui_interface.py
Changes:
| ... | ... | @@ -168,21 +168,6 @@ class FileRequestReceivedEvent(nec.NetworkIncomingEvent): |
| 168 | 168 |
self.file_props.transfered_size = []
|
| 169 | 169 |
return True
|
| 170 | 170 |
|
| 171 |
-class FileRequestErrorEvent(nec.NetworkIncomingEvent):
|
|
| 172 |
- name = 'file-request-error'
|
|
| 173 |
- |
|
| 174 |
- def generate(self):
|
|
| 175 |
- self.jid = app.get_jid_without_resource(self.jid)
|
|
| 176 |
- return True
|
|
| 177 |
- |
|
| 178 |
-class FileTransferCompletedEvent(nec.NetworkIncomingEvent):
|
|
| 179 |
- name = 'file-transfer-completed'
|
|
| 180 |
- |
|
| 181 |
- def generate(self):
|
|
| 182 |
- jid = str(self.file_props.receiver)
|
|
| 183 |
- self.jid = app.get_jid_without_resource(jid)
|
|
| 184 |
- return True
|
|
| 185 |
- |
|
| 186 | 171 |
class NotificationEvent(nec.NetworkIncomingEvent):
|
| 187 | 172 |
name = 'notification'
|
| 188 | 173 |
base_network_events = ['decrypted-message-received',
|
| ... | ... | @@ -36,8 +36,8 @@ from gajim.common import helpers |
| 36 | 36 |
from gajim.common import jingle_xtls
|
| 37 | 37 |
from gajim.common.file_props import FilesProp
|
| 38 | 38 |
from gajim.common.socks5 import Socks5SenderClient
|
| 39 |
+from gajim.common.nec import NetworkEvent
|
|
| 39 | 40 |
from gajim.common.modules.base import BaseModule
|
| 40 |
-from gajim.common.connection_handlers_events import FileRequestErrorEvent
|
|
| 41 | 41 |
|
| 42 | 42 |
|
| 43 | 43 |
log = logging.getLogger('gajim.c.m.bytestream')
|
| ... | ... | @@ -218,12 +218,12 @@ class Bytestream(BaseModule): |
| 218 | 218 |
if contact.get_full_jid() == receiver_jid:
|
| 219 | 219 |
file_props.error = -5
|
| 220 | 220 |
self.remove_transfer(file_props)
|
| 221 |
- app.nec.push_incoming_event(FileRequestErrorEvent(
|
|
| 222 |
- None,
|
|
| 223 |
- conn=self._con,
|
|
| 224 |
- jid=contact.jid,
|
|
| 225 |
- file_props=file_props,
|
|
| 226 |
- error_msg=''))
|
|
| 221 |
+ app.nec.push_incoming_event(
|
|
| 222 |
+ NetworkEvent('file-request-error',
|
|
| 223 |
+ conn=self._con,
|
|
| 224 |
+ jid=app.get_jid_without_resource(contact.jid),
|
|
| 225 |
+ file_props=file_props,
|
|
| 226 |
+ error_msg=''))
|
|
| 227 | 227 |
sender_jid = file_props.sender
|
| 228 | 228 |
if contact.get_full_jid() == sender_jid:
|
| 229 | 229 |
file_props.error = -3
|
| ... | ... | @@ -273,12 +273,12 @@ class Bytestream(BaseModule): |
| 273 | 273 |
self._result_socks5_sid, file_props)
|
| 274 | 274 |
if not listener:
|
| 275 | 275 |
file_props.error = -5
|
| 276 |
- app.nec.push_incoming_event(FileRequestErrorEvent(
|
|
| 277 |
- None,
|
|
| 278 |
- conn=self._con,
|
|
| 279 |
- jid=receiver,
|
|
| 280 |
- file_props=file_props,
|
|
| 281 |
- error_msg=''))
|
|
| 276 |
+ app.nec.push_incoming_event(
|
|
| 277 |
+ NetworkEvent('file-request-error',
|
|
| 278 |
+ conn=self._con,
|
|
| 279 |
+ jid=app.get_jid_without_resource(receiver),
|
|
| 280 |
+ file_props=file_props,
|
|
| 281 |
+ error_msg=''))
|
|
| 282 | 282 |
self._connect_error(file_props.sid,
|
| 283 | 283 |
error='not-acceptable',
|
| 284 | 284 |
error_type='modify')
|
| ... | ... | @@ -524,12 +524,12 @@ class Bytestream(BaseModule): |
| 524 | 524 |
if msg:
|
| 525 | 525 |
self.disconnect_transfer(file_props)
|
| 526 | 526 |
file_props.error = -3
|
| 527 |
- app.nec.push_incoming_event(FileRequestErrorEvent(
|
|
| 528 |
- None,
|
|
| 529 |
- conn=self._con,
|
|
| 530 |
- jid=to,
|
|
| 531 |
- file_props=file_props,
|
|
| 532 |
- error_msg=msg))
|
|
| 527 |
+ app.nec.push_incoming_event(
|
|
| 528 |
+ NetworkEvent('file-request-error',
|
|
| 529 |
+ conn=self._con,
|
|
| 530 |
+ jid=app.get_jid_without_resource(to),
|
|
| 531 |
+ file_props=file_props,
|
|
| 532 |
+ error_msg=msg))
|
|
| 533 | 533 |
|
| 534 | 534 |
def _proxy_auth_ok(self, proxy):
|
| 535 | 535 |
"""
|
| ... | ... | @@ -559,12 +559,12 @@ class Bytestream(BaseModule): |
| 559 | 559 |
if not file_props:
|
| 560 | 560 |
return
|
| 561 | 561 |
file_props.error = -4
|
| 562 |
- app.nec.push_incoming_event(FileRequestErrorEvent(
|
|
| 563 |
- None,
|
|
| 564 |
- conn=self._con,
|
|
| 565 |
- jid=jid,
|
|
| 566 |
- file_props=file_props,
|
|
| 567 |
- error_msg=''))
|
|
| 562 |
+ app.nec.push_incoming_event(
|
|
| 563 |
+ NetworkEvent('file-request-error',
|
|
| 564 |
+ conn=self._con,
|
|
| 565 |
+ jid=app.get_jid_without_resource(jid),
|
|
| 566 |
+ file_props=file_props,
|
|
| 567 |
+ error_msg=''))
|
|
| 568 | 568 |
raise nbxmpp.NodeProcessed
|
| 569 | 569 |
|
| 570 | 570 |
def _on_bytestream_set(self, con, iq_obj):
|
| ... | ... | @@ -77,8 +77,7 @@ from gajim.common import logging_helpers |
| 77 | 77 |
from gajim.common.structs import MUCData
|
| 78 | 78 |
from gajim.common.nec import NetworkEvent
|
| 79 | 79 |
from gajim.common.i18n import _
|
| 80 |
-from gajim.common.connection_handlers_events import (
|
|
| 81 |
- OurShowEvent, FileTransferCompletedEvent)
|
|
| 80 |
+from gajim.common.connection_handlers_events import OurShowEvent
|
|
| 82 | 81 |
|
| 83 | 82 |
from gajim.common.modules.httpupload import HTTPUploadProgressEvent
|
| 84 | 83 |
from gajim.common.connection import Connection
|
| ... | ... | @@ -637,8 +636,12 @@ class Interface: |
| 637 | 636 |
if file_props.error == 0:
|
| 638 | 637 |
ft.set_progress(
|
| 639 | 638 |
file_props.type_, file_props.sid, file_props.received_len)
|
| 639 |
+ jid = app.get_jid_without_resource(str(file_props.receiver))
|
|
| 640 | 640 |
app.nec.push_incoming_event(
|
| 641 |
- FileTransferCompletedEvent(None, file_props=file_props))
|
|
| 641 |
+ NetworkEvent('file-transfer-completed',
|
|
| 642 |
+ file_props=file_props,
|
|
| 643 |
+ jid=jid))
|
|
| 644 |
+ |
|
| 642 | 645 |
else:
|
| 643 | 646 |
ft.set_status(file_props, 'stop')
|
| 644 | 647 |
if not file_props.completed and (file_props.stalled or
|