Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Bronko
gajim
Commits
e00dad0b
Commit
e00dad0b
authored
Dec 10, 2019
by
Philipp Hörist
Browse files
Bytestream: Simplify event code
parent
294eece2
Changes
2
Hide whitespace changes
Inline
Side-by-side
gajim/common/connection_handlers_events.py
View file @
e00dad0b
...
...
@@ -168,13 +168,6 @@ def generate(self):
self
.
file_props
.
transfered_size
=
[]
return
True
class
FileRequestErrorEvent
(
nec
.
NetworkIncomingEvent
):
name
=
'file-request-error'
def
generate
(
self
):
self
.
jid
=
app
.
get_jid_without_resource
(
self
.
jid
)
return
True
class
FileTransferCompletedEvent
(
nec
.
NetworkIncomingEvent
):
name
=
'file-transfer-completed'
...
...
gajim/common/modules/bytestream.py
View file @
e00dad0b
...
...
@@ -36,8 +36,8 @@
from
gajim.common
import
jingle_xtls
from
gajim.common.file_props
import
FilesProp
from
gajim.common.socks5
import
Socks5SenderClient
from
gajim.common.nec
import
NetworkEvent
from
gajim.common.modules.base
import
BaseModule
from
gajim.common.connection_handlers_events
import
FileRequestErrorEvent
log
=
logging
.
getLogger
(
'gajim.c.m.bytestream'
)
...
...
@@ -218,12 +218,12 @@ def stop_all_active_file_transfers(self, contact):
if
contact
.
get_full_jid
()
==
receiver_jid
:
file_props
.
error
=
-
5
self
.
remove_transfer
(
file_props
)
app
.
nec
.
push_incoming_event
(
FileRequestErrorEvent
(
N
one
,
conn
=
self
.
_con
,
jid
=
contact
.
jid
,
file_props
=
file_props
,
error_msg
=
''
))
app
.
nec
.
push_incoming_event
(
N
etworkEvent
(
'file-request-error'
,
conn
=
self
.
_con
,
jid
=
app
.
get_jid_without_resource
(
contact
.
jid
)
,
file_props
=
file_props
,
error_msg
=
''
))
sender_jid
=
file_props
.
sender
if
contact
.
get_full_jid
()
==
sender_jid
:
file_props
.
error
=
-
3
...
...
@@ -273,12 +273,12 @@ def _send_socks5_info(self, file_props):
self
.
_result_socks5_sid
,
file_props
)
if
not
listener
:
file_props
.
error
=
-
5
app
.
nec
.
push_incoming_event
(
FileRequestErrorEvent
(
N
one
,
conn
=
self
.
_con
,
jid
=
receiver
,
file_props
=
file_props
,
error_msg
=
''
))
app
.
nec
.
push_incoming_event
(
N
etworkEvent
(
'file-request-error'
,
conn
=
self
.
_con
,
jid
=
app
.
get_jid_without_resource
(
receiver
)
,
file_props
=
file_props
,
error_msg
=
''
))
self
.
_connect_error
(
file_props
.
sid
,
error
=
'not-acceptable'
,
error_type
=
'modify'
)
...
...
@@ -524,12 +524,12 @@ def _connect_error(self, sid, error, error_type, msg=None):
if
msg
:
self
.
disconnect_transfer
(
file_props
)
file_props
.
error
=
-
3
app
.
nec
.
push_incoming_event
(
FileRequestErrorEvent
(
N
one
,
conn
=
self
.
_con
,
jid
=
to
,
file_props
=
file_props
,
error_msg
=
msg
))
app
.
nec
.
push_incoming_event
(
N
etworkEvent
(
'file-request-error'
,
conn
=
self
.
_con
,
jid
=
app
.
get_jid_without_resource
(
to
)
,
file_props
=
file_props
,
error_msg
=
msg
))
def
_proxy_auth_ok
(
self
,
proxy
):
"""
...
...
@@ -559,12 +559,12 @@ def _on_bytestream_error(self, _con, iq_obj):
if
not
file_props
:
return
file_props
.
error
=
-
4
app
.
nec
.
push_incoming_event
(
FileRequestErrorEvent
(
N
one
,
conn
=
self
.
_con
,
jid
=
jid
,
file_props
=
file_props
,
error_msg
=
''
))
app
.
nec
.
push_incoming_event
(
N
etworkEvent
(
'file-request-error'
,
conn
=
self
.
_con
,
jid
=
app
.
get_jid_without_resource
(
jid
)
,
file_props
=
file_props
,
error_msg
=
''
))
raise
nbxmpp
.
NodeProcessed
def
_on_bytestream_set
(
self
,
con
,
iq_obj
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment