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
e05fb8e6
Commit
e05fb8e6
authored
Feb 02, 2016
by
Dan Pascu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplified updating ringtones on session state changes
parent
c2e721f3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
52 deletions
+28
-52
sessions.py
blink/sessions.py
+28
-52
No files found.
blink/sessions.py
View file @
e05fb8e6
...
...
@@ -5152,6 +5152,17 @@ class RingtoneDescriptor(object):
raise
AttributeError
(
"Attribute cannot be deleted"
)
class
RequestList
(
list
):
def
__getitem__
(
self
,
key
):
if
isinstance
(
key
,
(
int
,
long
)):
return
super
(
RequestList
,
self
)
.
__getitem__
(
key
)
elif
isinstance
(
key
,
tuple
):
session
,
item_type
=
key
return
[
item
for
item
in
self
if
item
.
session
is
session
and
isinstance
(
item
,
item_type
)]
else
:
return
[
item
for
item
in
self
if
item
.
session
is
key
]
class
SessionManager
(
object
):
__metaclass__
=
Singleton
...
...
@@ -5166,8 +5177,8 @@ class SessionManager(object):
def
__init__
(
self
):
self
.
sessions
=
[]
self
.
incoming_requests
=
[]
self
.
file_transfers
=
[]
self
.
incoming_requests
=
RequestList
()
self
.
last_dialed_uri
=
None
self
.
send_file_directory
=
Path
(
'~'
)
.
normalized
self
.
active_session
=
None
...
...
@@ -5186,17 +5197,12 @@ class SessionManager(object):
notification_center
=
NotificationCenter
()
notification_center
.
add_observer
(
self
,
name
=
'SIPSessionNewIncoming'
)
notification_center
.
add_observer
(
self
,
name
=
'SIPSessionDidEnd'
)
notification_center
.
add_observer
(
self
,
name
=
'SIPSessionDidFail'
)
notification_center
.
add_observer
(
self
,
name
=
'SIPSessionProposalRejected'
)
notification_center
.
add_observer
(
self
,
name
=
'SIPSessionHadProposalFailure'
)
notification_center
.
add_observer
(
self
,
name
=
'BlinkFileTransferDidChangeState'
)
notification_center
.
add_observer
(
self
,
name
=
'BlinkFileTransferDidEnd'
)
notification_center
.
add_observer
(
self
,
name
=
'BlinkFileTransferWillRetry'
)
notification_center
.
add_observer
(
self
,
name
=
'BlinkSessionNewIncoming'
)
notification_center
.
add_observer
(
self
,
name
=
'BlinkSessionDidReinitializeForIncoming'
)
notification_center
.
add_observer
(
self
,
name
=
'BlinkSessionDidEnd'
)
notification_center
.
add_observer
(
self
,
name
=
'BlinkSessionWasDeleted'
)
notification_center
.
add_observer
(
self
,
name
=
'BlinkSessionDidChangeState'
)
...
...
@@ -5447,48 +5453,27 @@ class SessionManager(object):
self
.
update_ringtone
()
def
_NH_SIPSessionDidFail
(
self
,
notification
):
try
:
incoming_request
=
next
(
incoming_request
for
incoming_request
in
self
.
incoming_requests
if
incoming_request
.
session
is
notification
.
sender
)
except
StopIteration
:
return
incoming_request
.
dialog
.
hide
()
self
.
incoming_requests
.
remove
(
incoming_request
)
self
.
update_ringtone
()
def
_NH_SIPSessionDidEnd
(
self
,
notification
):
try
:
incoming_request
=
next
(
incoming_request
for
incoming_request
in
self
.
incoming_requests
if
incoming_request
.
session
is
notification
.
sender
)
except
StopIteration
:
return
incoming_request
.
dialog
.
hide
()
self
.
incoming_requests
.
remove
(
incoming_request
)
# Ringtone is updated in BlinkSessionDidEnd
def
_NH_SIPSessionProposalRejected
(
self
,
notification
):
try
:
incoming_request
=
next
(
incoming_request
for
incoming_request
in
self
.
incoming_requests
if
incoming_request
.
session
is
notification
.
sender
)
except
StopIteration
:
return
incoming_request
.
dialog
.
hide
()
self
.
incoming_requests
.
remove
(
incoming_request
)
self
.
update_ringtone
()
def
_NH_SIPSessionHadProposalFailure
(
self
,
notification
):
try
:
incoming_request
=
next
(
incoming_request
for
incoming_request
in
self
.
incoming_requests
if
incoming_request
.
session
is
notification
.
sender
)
except
StopIteration
:
return
incoming_request
.
dialog
.
hide
()
self
.
incoming_requests
.
remove
(
incoming_request
)
self
.
update_ringtone
()
if
notification
.
sender
.
direction
==
'incoming'
:
for
incoming_request
in
self
.
incoming_requests
[
notification
.
sender
]:
incoming_request
.
dialog
.
hide
()
self
.
incoming_requests
.
remove
(
incoming_request
)
self
.
update_ringtone
()
def
_NH_BlinkSessionDidChangeState
(
self
,
notification
):
new_state
=
notification
.
data
.
new_state
if
new_state
==
'connected/received_proposal'
:
self
.
_process_remote_proposal
(
notification
.
sender
)
if
new_state
in
(
'connecting/ringing'
,
'connecting/early_media'
,
'connected/*'
):
self
.
update_ringtone
()
if
new_state
==
'connected'
:
for
request
in
self
.
incoming_requests
[
notification
.
sender
.
sip_session
,
IncomingRequest
]:
request
.
dialog
.
hide
()
self
.
incoming_requests
.
remove
(
request
)
elif
new_state
==
'ending'
:
for
request
in
self
.
incoming_requests
[
notification
.
sender
.
sip_session
]:
request
.
dialog
.
hide
()
self
.
incoming_requests
.
remove
(
request
)
if
new_state
in
(
'connecting/ringing'
,
'connecting/early_media'
,
'connected/*'
,
'ending'
):
self
.
update_ringtone
()
if
new_state
==
'ending'
:
notification
.
sender
.
_play_hangup_tone
=
notification
.
data
.
old_state
in
(
'connecting/*'
,
'connected/*'
)
and
notification
.
sender
.
streams
.
types
.
intersection
({
'audio'
,
'video'
})
def
_NH_BlinkSessionDidChangeHoldState
(
self
,
notification
):
...
...
@@ -5498,12 +5483,6 @@ class SessionManager(object):
player
.
start
()
self
.
update_ringtone
()
def
_NH_BlinkSessionNewIncoming
(
self
,
notification
):
self
.
update_ringtone
()
def
_NH_BlinkSessionDidReinitializeForIncoming
(
self
,
notification
):
self
.
update_ringtone
()
def
_NH_BlinkSessionDidRemoveStream
(
self
,
notification
):
if
notification
.
data
.
stream
.
type
in
(
'audio'
,
'video'
)
and
not
self
.
_hangup_tone_timer
.
isActive
():
self
.
_hangup_tone_timer
.
start
()
...
...
@@ -5512,7 +5491,6 @@ class SessionManager(object):
player
.
start
()
def
_NH_BlinkSessionDidEnd
(
self
,
notification
):
self
.
update_ringtone
()
if
notification
.
sender
.
_play_hangup_tone
and
not
self
.
_hangup_tone_timer
.
isActive
():
self
.
_hangup_tone_timer
.
start
()
player
=
WavePlayer
(
SIPApplication
.
voice_audio_bridge
.
mixer
,
Resources
.
get
(
'sounds/hangup_tone.wav'
),
volume
=
30
)
...
...
@@ -5553,16 +5531,14 @@ class SessionManager(object):
def
_NH_BlinkFileTransferDidChangeState
(
self
,
notification
):
new_state
=
notification
.
data
.
new_state
if
new_state
in
(
'connecting/ringing'
,
'connected'
):
if
new_state
in
(
'connecting/ringing'
,
'connected'
,
'ending'
):
self
.
update_ringtone
()
def
_NH_BlinkFileTransferWillRetry
(
self
,
notification
):
self
.
file_transfers
.
append
(
notification
.
sender
)
self
.
update_ringtone
()
def
_NH_BlinkFileTransferDidEnd
(
self
,
notification
):
self
.
file_transfers
.
remove
(
notification
.
sender
)
self
.
update_ringtone
()
if
not
notification
.
data
.
error
and
not
self
.
_filetransfer_tone_timer
.
isActive
():
self
.
_filetransfer_tone_timer
.
start
()
player
=
WavePlayer
(
SIPApplication
.
voice_audio_bridge
.
mixer
,
Resources
.
get
(
'sounds/file_transfer.wav'
),
volume
=
30
)
...
...
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