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
b025d709
Commit
b025d709
authored
Feb 07, 2021
by
Adrian Georgescu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Session fixes
parent
944cdf89
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
28 deletions
+53
-28
chatwindow.py
blink/chatwindow.py
+5
-4
contacts.py
blink/contacts.py
+9
-8
history.py
blink/history.py
+12
-5
sessions.py
blink/sessions.py
+27
-11
No files found.
blink/chatwindow.py
View file @
b025d709
...
...
@@ -2210,7 +2210,7 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
if
message
.
content_type
.
startswith
(
'image/'
):
content
=
'''<img src="data:{};base64,{}" class="scaled-to-fit" />'''
.
format
(
message
.
content_type
,
message
.
content
.
decode
(
'base64'
)
.
rstrip
())
elif
message
.
content_type
.
startswith
(
'text/'
):
content
=
message
.
content
.
decode
()
content
=
message
.
content
content
=
HtmlProcessor
.
autolink
(
content
if
message
.
content_type
==
'text/html'
else
QTextDocument
(
content
)
.
toHtml
())
else
:
return
...
...
@@ -2410,6 +2410,7 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
self
.
close
()
self
.
no_sessions_label
.
show
()
elif
not
self
.
session_list
.
isVisibleTo
(
self
):
if
self
.
session_list
.
animation
:
self
.
session_list
.
animation
.
setDirection
(
QPropertyAnimation
.
Forward
)
self
.
session_list
.
animation
.
setStartValue
(
self
.
session_widget
.
geometry
())
self
.
session_list
.
animation
.
setEndValue
(
self
.
session_panel
.
rect
())
...
...
blink/contacts.py
View file @
b025d709
...
...
@@ -1301,8 +1301,8 @@ class Contact(object):
@
property
def
info
(
self
):
try
:
return
self
.
note
or
(
'@'
+
self
.
uri
.
uri
.
host
if
self
.
type
==
'bonjour'
else
self
.
uri
.
uri
)
except
AttributeError
:
return
self
.
note
or
(
self
.
uri
.
uri
.
split
(
'@'
)[
1
]
if
self
.
type
==
'bonjour'
else
self
.
uri
.
uri
)
except
(
AttributeError
,
TypeError
)
:
return
''
@
property
...
...
@@ -4684,11 +4684,11 @@ class URIUtils(object):
@
classmethod
def
is_number
(
cls
,
token
):
return
cls
.
number_re
.
match
(
token
.
decode
()
)
is
not
None
return
cls
.
number_re
.
match
(
token
)
is
not
None
@
classmethod
def
trim_number
(
cls
,
token
):
return
cls
.
number_trim_re
.
sub
(
''
,
token
.
decode
())
.
encode
(
)
return
cls
.
number_trim_re
.
sub
(
''
,
token
)
@
classmethod
def
find_contact
(
cls
,
uri
,
display_name
=
None
,
exact
=
True
):
...
...
@@ -4701,8 +4701,9 @@ class URIUtils(object):
if
not
uri
.
startswith
((
'sip:'
,
'sips:'
)):
uri
=
'sip:'
+
uri
uri
=
SIPURI
.
parse
(
str
(
uri
)
.
translate
(
translation_table
))
if
cls
.
is_number
(
uri
.
user
):
uri
.
user
=
cls
.
trim_number
(
uri
.
user
)
if
cls
.
is_number
(
uri
.
user
.
decode
()):
uri
.
user
=
cls
.
trim_number
(
uri
.
user
.
decode
())
.
encode
()
is_number
=
True
else
:
is_number
=
False
...
...
@@ -4714,7 +4715,7 @@ class URIUtils(object):
return
contact
,
contact_uri
if
not
exact
and
is_number
:
number
=
uri
.
user
.
lstrip
(
'0'
)
number
=
uri
.
user
.
decode
()
.
lstrip
(
'0'
)
counter
=
count
()
matched_numbers
=
[]
for
contact
in
(
contact
for
contact
in
contact_model
.
iter_contacts
()
if
contact
.
group
.
virtual
):
...
...
@@ -4732,7 +4733,7 @@ class URIUtils(object):
if
matched_numbers
:
return
matched_numbers
[
0
][
2
:]
# ratio, index, contact, uri
display_name
=
display_name
or
"
%
s@
%
s"
%
(
uri
.
user
,
uri
.
host
)
display_name
=
display_name
or
"
%
s@
%
s"
%
(
uri
.
user
.
decode
(),
uri
.
host
.
decode
()
)
contact
=
Contact
(
DummyContact
(
display_name
,
[
DummyContactURI
(
str
(
uri
)
.
partition
(
':'
)[
2
],
default
=
True
)]),
None
)
return
contact
,
contact
.
uri
...
...
blink/history.py
View file @
b025d709
...
...
@@ -19,6 +19,7 @@ from sipsimple.util import ISOTimestamp
from
blink.resources
import
ApplicationData
,
Resources
from
blink.util
import
run_in_gui_thread
import
traceback
__all__
=
[
'HistoryManager'
]
...
...
@@ -31,10 +32,11 @@ class HistoryManager(object, metaclass=Singleton):
def
__init__
(
self
):
try
:
data
=
pickle
.
load
(
open
(
ApplicationData
.
get
(
'calls_history'
)))
data
=
pickle
.
load
(
open
(
ApplicationData
.
get
(
'calls_history'
)
,
"rb"
))
if
not
isinstance
(
data
,
list
)
or
not
all
(
isinstance
(
item
,
HistoryEntry
)
and
item
.
text
and
isinstance
(
item
.
call_time
,
ISOTimestamp
)
for
item
in
data
):
raise
ValueError
(
"invalid save data"
)
except
Exception
:
except
Exception
as
e
:
traceback
.
print_exc
()
self
.
calls
=
[]
else
:
self
.
calls
=
data
[
-
self
.
history_size
:]
...
...
@@ -66,6 +68,7 @@ class HistoryManager(object, metaclass=Singleton):
return
session
=
notification
.
sender
entry
=
HistoryEntry
.
from_session
(
session
)
if
session
.
direction
==
'incoming'
:
if
notification
.
data
.
code
!=
487
or
notification
.
data
.
failure_reason
!=
'Call completed elsewhere'
:
entry
.
failed
=
True
...
...
@@ -184,7 +187,13 @@ class HistoryEntry(object):
duration
=
session
.
end_time
-
session
.
start_time
else
:
duration
=
None
remote_uri
=
'
%
s@
%
s'
%
(
session
.
remote_identity
.
uri
.
user
,
session
.
remote_identity
.
uri
.
host
)
user
=
session
.
remote_identity
.
uri
.
user
domain
=
session
.
remote_identity
.
uri
.
host
user
=
user
.
decode
()
if
isinstance
(
user
,
bytes
)
else
user
domain
=
domain
.
decode
()
if
isinstance
(
domain
,
bytes
)
else
domain
remote_uri
=
'
%
s@
%
s'
%
(
user
,
domain
)
match
=
cls
.
phone_number_re
.
match
(
remote_uri
)
if
match
:
remote_uri
=
match
.
group
(
'number'
)
...
...
@@ -195,5 +204,3 @@ class HistoryEntry(object):
else
:
display_name
=
contact
.
name
return
cls
(
session
.
direction
,
display_name
,
remote_uri
,
str
(
session
.
account
.
id
),
call_time
,
duration
)
blink/sessions.py
View file @
b025d709
...
...
@@ -497,6 +497,7 @@ class BlinkSession(BlinkSessionBase):
self
.
_sibling
=
None
self
.
_smp_handler
=
Null
self
.
routes
=
None
def
_get_state
(
self
):
return
self
.
__dict__
[
'state'
]
...
...
@@ -713,7 +714,7 @@ class BlinkSession(BlinkSessionBase):
self
.
stream_descriptions
=
None
self
.
state
=
'
connect
ing'
self
.
state
=
'
initializ
ing'
notification_center
.
post_notification
(
'BlinkSessionConnectionProgress'
,
sender
=
self
,
data
=
NotificationData
(
stage
=
'connecting'
))
def
connect
(
self
):
...
...
@@ -737,6 +738,7 @@ class BlinkSession(BlinkSessionBase):
uri
=
self
.
uri
else
:
uri
=
self
.
uri
self
.
lookup
=
DNSLookup
()
notification_center
.
add_observer
(
self
,
sender
=
self
.
lookup
)
self
.
lookup
.
lookup_sip_proxy
(
uri
,
settings
.
sip
.
transport_list
)
...
...
@@ -912,13 +914,14 @@ class BlinkSession(BlinkSessionBase):
uri
=
'sip:'
+
uri
uri
=
SIPURI
.
parse
(
str
(
uri
)
.
translate
(
translation_table
))
if
URIUtils
.
is_number
(
uri
.
user
):
u
ri
.
user
=
URIUtils
.
trim_number
(
uri
.
user
)
if
URIUtils
.
is_number
(
uri
.
user
.
decode
()
):
u
ser
=
URIUtils
.
trim_number
(
uri
.
user
.
decode
()
)
if
isinstance
(
self
.
account
,
Account
):
if
self
.
account
.
pstn
.
idd_prefix
is
not
None
:
u
ri
.
user
=
re
.
sub
(
r'^\+'
,
self
.
account
.
pstn
.
idd_prefix
,
uri
.
user
)
u
ser
=
re
.
sub
(
r'^\+'
,
self
.
account
.
pstn
.
idd_prefix
,
user
)
if
self
.
account
.
pstn
.
prefix
is
not
None
:
uri
.
user
=
self
.
account
.
pstn
.
prefix
+
uri
.
user
user
=
self
.
account
.
pstn
.
prefix
+
user
uri
.
user
=
user
.
encode
()
return
uri
def
_sync_chat_peer_name
(
self
):
...
...
@@ -943,9 +946,13 @@ class BlinkSession(BlinkSessionBase):
if
notification
.
sender
is
self
.
lookup
:
routes
=
notification
.
data
.
result
if
routes
:
self
.
routes
=
routes
self
.
state
=
'connection/dns_lookup_succeeded'
self
.
info
.
update
(
self
)
self
.
sip_session
=
Session
(
self
.
account
)
self
.
sip_session
.
connect
(
ToHeader
(
self
.
uri
),
routes
,
list
(
self
.
streams
))
else
:
self
.
routes
=
None
self
.
_terminate
(
reason
=
'Destination not found'
,
error
=
True
)
def
_NH_DNSLookupDidFail
(
self
,
notification
):
...
...
@@ -1659,7 +1666,7 @@ class AudioSessionWidget(base_class, ui_class):
session
.
zrtp_widget
.
hide
()
session
.
zrtp_widget
.
peer_name
=
stream_info
.
zrtp_peer_name
session
.
zrtp_widget
.
peer_verified
=
stream_info
.
zrtp_verified
session
.
zrtp_widget
.
sas
=
stream_info
.
zrtp_sas
.
decode
()
session
.
zrtp_widget
.
sas
=
stream_info
.
zrtp_sas
session
.
zrtp_widget
.
setGeometry
(
rect
)
session
.
zrtp_widget
.
show
()
session
.
zrtp_widget
.
peer_name_value
.
setFocus
(
Qt
.
OtherFocusReason
)
...
...
@@ -2083,11 +2090,15 @@ class AudioSessionItem(object):
def
_NH_BlinkSessionConnectionProgress
(
self
,
notification
):
stage
=
notification
.
data
.
stage
if
stage
==
'dns_lookup'
:
if
stage
==
'initializing'
:
self
.
status
=
Status
(
'Initializing...'
)
elif
stage
==
'connecting/dns_lookup'
:
self
.
status
=
Status
(
'Looking up destination...'
)
elif
stage
==
'connecting'
:
elif
stage
==
'connecting'
and
self
.
blink_session
.
routes
:
self
.
tls
=
self
.
blink_session
.
transport
==
'tls'
self
.
status
=
Status
(
'Connecting...'
)
uri
=
self
.
blink_session
.
routes
[
0
]
.
uri
destination
=
'
%
s:
%
s'
%
(
self
.
blink_session
.
transport
,
uri
.
host
.
decode
())
self
.
status
=
Status
(
'Trying
%
s'
%
destination
)
elif
stage
==
'ringing'
:
self
.
status
=
Status
(
'Ringing...'
)
elif
stage
==
'starting'
:
...
...
@@ -2677,7 +2688,7 @@ class AudioSessionListView(QListView):
def
keyPressEvent
(
self
,
event
):
char
=
event
.
text
()
.
upper
()
if
char
and
char
in
string
.
digits
+
string
.
uppercase
+
'#*'
:
if
char
and
char
in
string
.
digits
+
string
.
ascii_uppercase
+
'#*'
:
digit_map
=
{
'2'
:
'ABC'
,
'3'
:
'DEF'
,
'4'
:
'GHI'
,
'5'
:
'JKL'
,
'6'
:
'MNO'
,
'7'
:
'PQRS'
,
'8'
:
'TUV'
,
'9'
:
'WXYZ'
}
letter_map
=
{
letter
:
digit
for
digit
,
letter_group
in
digit_map
.
items
()
for
letter
in
letter_group
}
for
session
in
(
s
for
s
in
self
.
model
()
.
sessions
if
s
.
active
):
...
...
@@ -3150,10 +3161,12 @@ class ChatSessionItem(object):
elif
data
.
state
==
'idle'
:
self
.
remote_composing
=
False
self
.
remote_composing_timer
.
stop
()
self
.
widget
.
update_content
(
self
)
def
_SH_RemoteComposingTimerTimeout
(
self
):
self
.
remote_composing_timer
.
stop
()
self
.
remote_composing
=
False
self
.
widget
.
update_content
(
self
)
def
handle_notification
(
self
,
notification
):
handler
=
getattr
(
self
,
'_NH_
%
s'
%
notification
.
name
,
Null
)
...
...
@@ -4036,10 +4049,13 @@ class BlinkFileTransfer(BlinkSessionBase):
notification
.
center
.
remove_observer
(
self
,
sender
=
notification
.
sender
)
if
self
.
state
in
(
'ending'
,
'ended'
):
return
self
.
state
=
'connecting'
routes
=
notification
.
data
.
result
if
not
routes
:
self
.
_terminate
(
failure_reason
=
'Destination not found'
)
self
.
routes
=
None
return
self
.
routes
=
routes
self
.
sip_session
=
Session
(
self
.
account
)
self
.
stream
=
MediaStreamRegistry
.
FileTransferStream
(
self
.
file_selector
,
'sendonly'
,
transfer_id
=
self
.
id
)
self
.
handler
=
self
.
stream
.
handler
...
...
@@ -4052,7 +4068,7 @@ class BlinkFileTransfer(BlinkSessionBase):
self
.
_terminate
(
failure_reason
=
'DNS Lookup failed'
)
def
_NH_SIPSessionNewOutgoing
(
self
,
notification
):
self
.
state
=
'
connect
ing'
self
.
state
=
'
initializ
ing'
def
_NH_SIPSessionGotProvisionalResponse
(
self
,
notification
):
if
notification
.
data
.
code
==
180
:
...
...
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