Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Weblate
gajim
Commits
930c71cc
Commit
930c71cc
authored
13 years ago
by
zimio
Browse files
Options
Downloads
Patches
Plain Diff
complete IBB jingle support, fixes #6998
parent
f3b09203
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/common/jingle_ft.py
+26
-10
26 additions, 10 deletions
src/common/jingle_ft.py
src/common/jingle_transport.py
+6
-5
6 additions, 5 deletions
src/common/jingle_transport.py
with
32 additions
and
15 deletions
src/common/jingle_ft.py
+
26
−
10
View file @
930c71cc
...
...
@@ -22,7 +22,7 @@ Handles Jingle File Transfer (XEP 0234)
import
gajim
import
xmpp
from
jingle_content
import
contents
,
JingleContent
from
jingle_transport
import
JingleTransportICEUDP
,
JingleTransportSocks5
from
jingle_transport
import
JingleTransportICEUDP
,
JingleTransportSocks5
,
JingleTransportIBB
,
TransportType
from
common
import
helpers
from
common.socks5
import
Socks5ReceiverClient
,
Socks5SenderClient
from
common.connection_handlers_events
import
FileRequestReceivedEvent
...
...
@@ -61,7 +61,7 @@ class JingleFileTransfer(JingleContent):
self
.
callbacks
[
'
session-terminate
'
]
+=
[
self
.
__on_session_terminate
]
self
.
callbacks
[
'
transport-accept
'
]
+=
[
self
.
__on_transport_accept
]
self
.
callbacks
[
'
transport-replace
'
]
+=
[
self
.
__on_transport_replace
]
self
.
callbacks
[
'
session-accept-sent
'
]
+=
[
self
.
_
listen_host
]
self
.
callbacks
[
'
session-accept-sent
'
]
+=
[
self
.
_
_transport_setup
]
# fallback transport method
self
.
callbacks
[
'
transport-reject
'
]
+=
[
self
.
__on_transport_reject
]
self
.
callbacks
[
'
transport-info
'
]
+=
[
self
.
__on_transport_info
]
...
...
@@ -119,10 +119,7 @@ class JingleFileTransfer(JingleContent):
response
.
delChild
(
response
.
getQuery
())
con
.
connection
.
send
(
response
)
# We send the file
con
.
files_props
[
self
.
file_props
[
'
sid
'
]]
=
self
.
file_props
fp
=
open
(
self
.
file_props
[
'
file-name
'
],
'
r
'
)
con
.
OpenStream
(
self
.
transport
.
sid
,
self
.
session
.
peerjid
,
fp
,
blocksize
=
4096
)
self
.
__start_IBB_transfer
(
con
)
raise
xmpp
.
NodeProcessed
self
.
file_props
[
'
streamhosts
'
]
=
self
.
transport
.
remote_candidates
...
...
@@ -142,11 +139,14 @@ class JingleFileTransfer(JingleContent):
fingerprint
=
None
if
self
.
use_security
:
fingerprint
=
'
client
'
gajim
.
socks5queue
.
connect_to_hosts
(
self
.
session
.
connection
.
name
,
if
self
.
transport
.
type
==
TransportType
.
SOCKS5
:
gajim
.
socks5queue
.
connect_to_hosts
(
self
.
session
.
connection
.
name
,
self
.
file_props
[
'
sid
'
],
self
.
send_candidate_used
,
self
.
_on_connect_error
,
fingerprint
=
fingerprint
,
receiving
=
False
)
elif
self
.
transport
.
type
==
TransportType
.
IBB
:
self
.
state
=
STATE_TRANSFERING
self
.
__start_IBB_transfer
(
self
.
session
.
connection
)
raise
xmpp
.
NodeProcessed
def
__on_session_terminate
(
self
,
stanza
,
content
,
error
,
action
):
...
...
@@ -224,6 +224,7 @@ class JingleFileTransfer(JingleContent):
self
.
file_props
# Listen on configured port for file transfer
self
.
_listen_host
()
elif
not
self
.
weinitiate
and
self
.
state
==
STATE_NOT_STARTED
:
# session-accept iq-result
if
not
self
.
negotiated
:
...
...
@@ -254,6 +255,22 @@ class JingleFileTransfer(JingleContent):
return
# initiate transfer
self
.
start_transfer
()
def
__start_IBB_transfer
(
self
,
con
):
con
.
files_props
[
self
.
file_props
[
'
sid
'
]]
=
self
.
file_props
fp
=
open
(
self
.
file_props
[
'
file-name
'
],
'
r
'
)
con
.
OpenStream
(
self
.
transport
.
sid
,
self
.
session
.
peerjid
,
fp
,
blocksize
=
4096
)
def
__transport_setup
(
self
,
stanza
=
None
,
content
=
None
,
error
=
None
,
action
=
None
):
# Sets up a few transport specific things for the file transfer
if
self
.
transport
.
type
==
TransportType
.
SOCKS5
:
self
.
_listen_host
()
if
self
.
transport
.
type
==
TransportType
.
IBB
:
self
.
state
=
STATE_TRANSFERING
def
send_candidate_used
(
self
,
streamhost
):
"""
...
...
@@ -328,8 +345,7 @@ class JingleFileTransfer(JingleContent):
# callback from socsk5queue.start_listener
self
.
file_props
[
'
hash
'
]
=
hash_id
def
_listen_host
(
self
,
stanza
=
None
,
content
=
None
,
error
=
None
,
action
=
None
):
def
_listen_host
(
self
):
receiver
=
self
.
file_props
[
'
receiver
'
]
sender
=
self
.
file_props
[
'
sender
'
]
...
...
This diff is collapsed.
Click to expand it.
src/common/jingle_transport.py
+
6
−
5
View file @
930c71cc
...
...
@@ -36,8 +36,9 @@ class TransportType(object):
"""
Possible types of a JingleTransport
"""
datagram
=
1
streaming
=
2
ICEUDP
=
1
SOCKS5
=
2
IBB
=
3
class
JingleTransport
(
object
):
...
...
@@ -98,7 +99,7 @@ class JingleTransportSocks5(JingleTransport):
Note: Don
'
t forget to call set_file_props after initialization
"""
def
__init__
(
self
,
node
=
None
):
JingleTransport
.
__init__
(
self
,
TransportType
.
streaming
)
JingleTransport
.
__init__
(
self
,
TransportType
.
SOCKS5
)
self
.
connection
=
None
self
.
remote_candidates
=
[]
self
.
sid
=
None
...
...
@@ -300,7 +301,7 @@ class JingleTransportIBB(JingleTransport):
def
__init__
(
self
,
node
=
None
,
block_sz
=
None
):
JingleTransport
.
__init__
(
self
,
TransportType
.
streaming
)
JingleTransport
.
__init__
(
self
,
TransportType
.
IBB
)
if
block_sz
:
self
.
block_sz
=
block_sz
...
...
@@ -328,7 +329,7 @@ except Exception:
class
JingleTransportICEUDP
(
JingleTransport
):
def
__init__
(
self
,
node
):
JingleTransport
.
__init__
(
self
,
TransportType
.
datagram
)
JingleTransport
.
__init__
(
self
,
TransportType
.
ICEUDP
)
def
make_candidate
(
self
,
candidate
):
types
=
{
farsight
.
CANDIDATE_TYPE_HOST
:
'
host
'
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment