Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vmj-qt
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
vmj-qt
Commits
dc3e1fef
Commit
dc3e1fef
authored
Jan 23, 2015
by
Dan Pascu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for specifying the transfer_id for file transfers
parent
d33e5d28
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
8 deletions
+15
-8
sessions.py
blink/sessions.py
+15
-8
No files found.
blink/sessions.py
View file @
dc3e1fef
...
...
@@ -10,6 +10,7 @@ import os
import
re
import
string
import
sys
import
uuid
from
abc
import
ABCMeta
,
abstractproperty
from
collections
import
defaultdict
,
deque
...
...
@@ -3375,6 +3376,9 @@ ScreenSharingStream.ViewerHandler = EmbeddedVNCViewerHandler
# File transfers
#
class
RandomID
:
__metaclass__
=
MarkerType
class
FileSizeFormatter
(
object
):
boundaries
=
[(
1024
,
'
%
d bytes'
,
1
),
(
10
*
1024
,
'
%.2
f KB'
,
1024.0
),
(
1024
*
1024
,
'
%.1
f KB'
,
1024.0
),
...
...
@@ -3405,6 +3409,7 @@ class FileTransfer(object):
tmp_file_suffix
=
'.download'
def
__init__
(
self
):
self
.
id
=
None
self
.
direction
=
None
self
.
state
=
None
...
...
@@ -3423,12 +3428,13 @@ class FileTransfer(object):
self
.
_reason
=
None
def
__getstate__
(
self
):
state
=
dict
(
direction
=
self
.
direction
,
state
=
self
.
state
,
filename
=
self
.
filename
,
_error
=
self
.
_error
,
_finished
=
self
.
_finished
,
_reason
=
self
.
_reason
)
state
=
dict
(
id
=
self
.
id
,
direction
=
self
.
direction
,
state
=
self
.
state
,
filename
=
self
.
filename
,
_error
=
self
.
_error
,
_finished
=
self
.
_finished
,
_reason
=
self
.
_reason
)
return
(
self
.
account
.
id
,
self
.
contact
.
name
,
self
.
contact_uri
.
uri
,
state
)
def
__setstate__
(
self
,
state
):
from
blink.contacts
import
URIUtils
account_id
,
contact_name
,
contact_uri
,
state
=
state
self
.
__init__
()
self
.
__dict__
.
update
(
state
)
account_manager
=
AccountManager
()
try
:
...
...
@@ -3441,14 +3447,13 @@ class FileTransfer(object):
self
.
_uri
=
self
.
_normalize_uri
(
contact_uri
)
else
:
self
.
_local_hash
=
hashlib
.
sha1
()
self
.
sip_session
=
None
self
.
stream
=
None
self
.
_file_selector
=
None
def
init_incoming
(
self
,
contact
,
contact_uri
,
session
,
stream
):
assert
self
.
state
is
None
self
.
direction
=
'incoming'
self
.
id
=
stream
.
transfer_id
self
.
account
=
session
.
account
self
.
contact
=
contact
self
.
contact_uri
=
contact_uri
...
...
@@ -3473,10 +3478,12 @@ class FileTransfer(object):
notification_center
.
post_notification
(
'FileTransferNewIncoming'
,
sender
=
self
)
self
.
sip_session
.
accept
([
self
.
stream
])
def
init_outgoing
(
self
,
account
,
contact
,
contact_uri
,
filename
):
def
init_outgoing
(
self
,
account
,
contact
,
contact_uri
,
filename
,
transfer_id
=
RandomID
):
assert
self
.
state
is
None
self
.
direction
=
'outgoing'
self
.
id
=
transfer_id
if
transfer_id
is
not
RandomID
else
str
(
uuid
.
uuid4
())
self
.
account
=
account
self
.
contact
=
contact
self
.
contact_uri
=
contact_uri
...
...
@@ -3716,7 +3723,7 @@ class FileTransfer(object):
self
.
sip_session
=
Session
(
self
.
account
)
registry
=
MediaStreamRegistry
()
cls
=
registry
.
get
(
'file-transfer'
)
self
.
stream
=
cls
(
self
.
_file_selector
,
'sendonly'
)
self
.
stream
=
cls
(
self
.
_file_selector
,
'sendonly'
,
transfer_id
=
self
.
id
)
self
.
sip_session
.
connect
(
ToHeader
(
self
.
_uri
),
routes
,
[
self
.
stream
])
def
_NH_DNSLookupDidFail
(
self
,
notification
):
...
...
@@ -5210,7 +5217,7 @@ class SessionManager(object):
return
session
def
send_file
(
self
,
contact
,
contact_uri
,
filename
,
account
=
None
):
def
send_file
(
self
,
contact
,
contact_uri
,
filename
,
transfer_id
=
RandomID
,
account
=
None
):
if
account
is
None
:
if
contact
.
type
==
'bonjour'
:
account
=
BonjourAccount
()
...
...
@@ -5221,7 +5228,7 @@ class SessionManager(object):
transfer
=
FileTransfer
()
self
.
file_transfers
.
append
(
transfer
)
transfer
.
init_outgoing
(
account
,
contact
,
contact_uri
,
filename
)
transfer
.
init_outgoing
(
account
,
contact
,
contact_uri
,
filename
,
transfer_id
)
transfer
.
connect
()
return
transfer
...
...
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