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
206fca38
Commit
206fca38
authored
Jun 27, 2023
by
Tijmen de Mes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for pull filetransfers
parent
7cd3ce78
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
0 deletions
+42
-0
sessions.py
blink/sessions.py
+42
-0
No files found.
blink/sessions.py
View file @
206fca38
...
@@ -26,6 +26,7 @@ from application.notification import IObserver, NotificationCenter, Notification
...
@@ -26,6 +26,7 @@ from application.notification import IObserver, NotificationCenter, Notification
from
application.python
import
Null
,
limit
from
application.python
import
Null
,
limit
from
application.python.types
import
MarkerType
,
Singleton
from
application.python.types
import
MarkerType
,
Singleton
from
application.python.weakref
import
weakobjectmap
,
defaultweakobjectmap
from
application.python.weakref
import
weakobjectmap
,
defaultweakobjectmap
from
application.system
import
makedirs
from
eventlib.proc
import
spawn
from
eventlib.proc
import
spawn
from
zope.interface
import
implementer
from
zope.interface
import
implementer
...
@@ -3924,6 +3925,8 @@ class BlinkFileTransfer(BlinkSessionBase):
...
@@ -3924,6 +3925,8 @@ class BlinkFileTransfer(BlinkSessionBase):
self
.
file_selector
=
None
self
.
file_selector
=
None
self
.
handler
=
None
self
.
handler
=
None
self
.
transfer_type
=
'push'
self
.
conference_file
=
True
# used for outgoing transfers
# used for outgoing transfers
self
.
_uri
=
None
self
.
_uri
=
None
...
@@ -4000,6 +4003,28 @@ class BlinkFileTransfer(BlinkSessionBase):
...
@@ -4000,6 +4003,28 @@ class BlinkFileTransfer(BlinkSessionBase):
notification_center
=
NotificationCenter
()
notification_center
=
NotificationCenter
()
notification_center
.
post_notification
(
'BlinkFileTransferNewOutgoing'
,
self
)
notification_center
.
post_notification
(
'BlinkFileTransferNewOutgoing'
,
self
)
def
init_outgoing_pull
(
self
,
account
,
contact
,
contact_uri
,
filename
,
hash
,
transfer_id
=
RandomID
,
conference_file
=
True
):
assert
self
.
state
is
None
self
.
transfer_type
=
'pull'
self
.
direction
=
'outgoing'
self
.
conference_file
=
conference_file
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
self
.
_uri
=
self
.
_normalize_uri
(
contact_uri
.
uri
)
self
.
file_selector
=
FileSelector
(
name
=
os
.
path
.
basename
(
filename
),
hash
=
hash
)
self
.
state
=
'initialized'
notification_center
=
NotificationCenter
()
notification_center
.
post_notification
(
'BlinkFileTransferNewOutgoing'
,
self
)
def
connect
(
self
):
def
connect
(
self
):
assert
self
.
direction
==
'outgoing'
and
self
.
state
in
(
'initialized'
,
'ended'
)
assert
self
.
direction
==
'outgoing'
and
self
.
state
in
(
'initialized'
,
'ended'
)
...
@@ -4149,6 +4174,9 @@ class BlinkFileTransfer(BlinkSessionBase):
...
@@ -4149,6 +4174,9 @@ class BlinkFileTransfer(BlinkSessionBase):
self
.
routes
=
routes
self
.
routes
=
routes
self
.
sip_session
=
Session
(
self
.
account
)
self
.
sip_session
=
Session
(
self
.
account
)
self
.
stream
=
MediaStreamRegistry
.
FileTransferStream
(
self
.
file_selector
,
'sendonly'
,
transfer_id
=
self
.
id
)
self
.
stream
=
MediaStreamRegistry
.
FileTransferStream
(
self
.
file_selector
,
'sendonly'
,
transfer_id
=
self
.
id
)
if
self
.
transfer_type
==
'pull'
:
self
.
stream
=
MediaStreamRegistry
.
FileTransferStream
(
self
.
file_selector
,
'recvonly'
,
transfer_id
=
self
.
id
)
self
.
handler
=
self
.
stream
.
handler
self
.
handler
=
self
.
stream
.
handler
self
.
sip_session
.
connect
(
ToHeader
(
self
.
_uri
),
routes
,
[
self
.
stream
])
self
.
sip_session
.
connect
(
ToHeader
(
self
.
_uri
),
routes
,
[
self
.
stream
])
...
@@ -5768,6 +5796,20 @@ class SessionManager(object, metaclass=Singleton):
...
@@ -5768,6 +5796,20 @@ class SessionManager(object, metaclass=Singleton):
transfer
.
connect
()
transfer
.
connect
()
return
transfer
return
transfer
def
get_file
(
self
,
contact
,
contact_uri
,
filename
,
hash
,
transfer_id
=
RandomID
,
account
=
None
,
conference_file
=
True
):
if
account
is
None
:
if
contact
.
type
==
'bonjour'
:
account
=
BonjourAccount
()
else
:
account
=
AccountManager
()
.
default_account
self
.
send_file_directory
=
os
.
path
.
dirname
(
filename
)
transfer
=
BlinkFileTransfer
()
transfer
.
init_outgoing_pull
(
account
,
contact
,
contact_uri
,
filename
,
hash
,
transfer_id
,
conference_file
)
transfer
.
connect
()
return
transfer
def
update_ringtone
(
self
):
def
update_ringtone
(
self
):
# Outgoing ringtone
# Outgoing ringtone
outgoing_sessions_or_proposals
=
[
session
for
session
in
self
.
sessions
if
session
.
state
==
'connecting/ringing'
and
session
.
direction
==
'outgoing'
or
session
.
state
==
'connected/sent_proposal'
]
outgoing_sessions_or_proposals
=
[
session
for
session
in
self
.
sessions
if
session
.
state
==
'connecting/ringing'
and
session
.
direction
==
'outgoing'
or
session
.
state
==
'connected/sent_proposal'
]
...
...
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