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
a8946797
Commit
a8946797
authored
Sep 22, 2022
by
Tijmen de Mes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle OTR message sessions
parent
4d87b4ee
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
12 deletions
+57
-12
chatwindow.py
blink/chatwindow.py
+5
-1
messages.py
blink/messages.py
+24
-1
sessions.py
blink/sessions.py
+28
-10
No files found.
blink/chatwindow.py
View file @
a8946797
...
@@ -964,8 +964,12 @@ class ChatWidget(base_class, ui_class):
...
@@ -964,8 +964,12 @@ class ChatWidget(base_class, ui_class):
self
.
add_message
(
ChatMessage
(
content
,
sender
,
'outgoing'
,
id
=
id
))
self
.
add_message
(
ChatMessage
(
content
,
sender
,
'outgoing'
,
id
=
id
))
def
_SH_ChatInputLockReleased
(
self
,
lock_type
):
def
_SH_ChatInputLockReleased
(
self
,
lock_type
):
blink_session
=
self
.
session
.
blink_session
if
lock_type
is
EncryptionLock
:
if
lock_type
is
EncryptionLock
:
if
blink_session
.
chat_type
is
not
None
:
self
.
session
.
chat_stream
.
encryption
.
stop
()
self
.
session
.
chat_stream
.
encryption
.
stop
()
else
:
blink_session
.
fake_streams
.
get
(
'messages'
)
.
encryption
.
stop
()
def
_SH_ComposingTimerTimeout
(
self
):
def
_SH_ComposingTimerTimeout
(
self
):
self
.
composing_timer
.
stop
()
self
.
composing_timer
.
stop
()
...
...
blink/messages.py
View file @
a8946797
...
@@ -374,7 +374,16 @@ class OutgoingMessage(object):
...
@@ -374,7 +374,16 @@ class OutgoingMessage(object):
stream
=
self
.
session
.
fake_streams
.
get
(
'messages'
)
stream
=
self
.
session
.
fake_streams
.
get
(
'messages'
)
if
self
.
content_type
.
lower
()
not
in
self
.
__disabled_imdn_content_types__
:
if
self
.
content_type
.
lower
()
not
in
self
.
__disabled_imdn_content_types__
:
if
self
.
account
.
sms
.
enable_pgp
and
stream
.
can_encrypt
:
if
self
.
account
.
sms
.
enable_pgp
and
stream
.
can_encrypt
:
content
=
stream
.
encrypt
(
self
.
content
)
try
:
content
=
stream
.
encrypt
(
self
.
content
,
self
.
content_type
)
except
Exception
as
e
:
notification_center
.
post_notification
(
'BlinkMessageDidFail'
,
sender
=
self
.
session
,
data
=
NotificationData
(
data
=
NotificationData
(
code
=
''
,
reason
=
f
"Encryption error {e}"
),
id
=
self
.
id
))
return
self
.
is_secure
=
True
self
.
is_secure
=
True
content
=
content
if
isinstance
(
content
,
bytes
)
else
content
.
encode
()
content
=
content
if
isinstance
(
content
,
bytes
)
else
content
.
encode
()
additional_sip_headers
=
[]
additional_sip_headers
=
[]
...
@@ -1113,6 +1122,20 @@ class MessageManager(object, metaclass=Singleton):
...
@@ -1113,6 +1122,20 @@ class MessageManager(object, metaclass=Singleton):
if
not
content_type
.
lower
()
.
startswith
(
'text'
):
if
not
content_type
.
lower
()
.
startswith
(
'text'
):
return
return
if
encryption
is
None
and
not
x_replicated_message
:
otr
=
blink_session
.
fake_streams
.
get
(
'messages'
)
.
check_otr
(
message
)
if
otr
is
not
None
:
message
=
otr
else
:
return
if
message
.
content
.
startswith
(
"?OTR:"
)
and
x_replicated_message
:
log
.
warning
(
'Incoming message skipped, OTR encrypted, it should be handled [BUG]'
)
return
if
message
.
content
.
startswith
(
"?OTRv3?"
)
and
x_replicated_message
:
return
if
x_replicated_message
or
account
is
not
blink_session
.
account
:
if
x_replicated_message
or
account
is
not
blink_session
.
account
:
history_message_data
=
NotificationData
(
remote_uri
=
contact
.
uri
.
uri
,
history_message_data
=
NotificationData
(
remote_uri
=
contact
.
uri
.
uri
,
message
=
message
,
message
=
message
,
...
...
blink/sessions.py
View file @
a8946797
...
@@ -1279,6 +1279,8 @@ class SMPVerificationHandler(object):
...
@@ -1279,6 +1279,8 @@ class SMPVerificationHandler(object):
"""@type blink_session: BlinkSession"""
"""@type blink_session: BlinkSession"""
self
.
blink_session
=
blink_session
self
.
blink_session
=
blink_session
self
.
chat_stream
=
self
.
blink_session
.
streams
.
get
(
'chat'
)
self
.
chat_stream
=
self
.
blink_session
.
streams
.
get
(
'chat'
)
if
self
.
chat_stream
is
None
:
self
.
chat_stream
=
self
.
blink_session
.
fake_streams
.
get
(
'messages'
)
self
.
delay
=
0
if
self
.
chat_stream
.
encryption
.
key_fingerprint
>
self
.
chat_stream
.
encryption
.
peer_fingerprint
else
1
self
.
delay
=
0
if
self
.
chat_stream
.
encryption
.
key_fingerprint
>
self
.
chat_stream
.
encryption
.
peer_fingerprint
else
1
self
.
tries
=
5
self
.
tries
=
5
...
@@ -1297,11 +1299,17 @@ class SMPVerificationHandler(object):
...
@@ -1297,11 +1299,17 @@ class SMPVerificationHandler(object):
self
.
chat_stream
=
Null
self
.
chat_stream
=
Null
def
_do_smp
(
self
):
def
_do_smp
(
self
):
if
isinstance
(
self
.
chat_stream
,
MessageStream
):
if
self
.
blink_session
.
info
.
streams
.
messages
.
smp_status
in
(
SMPVerification
.
InProgress
,
SMPVerification
.
Succeeded
,
SMPVerification
.
Failed
):
return
# Set SMP succeeded for message streams until it is implemented in all other clients
self
.
blink_session
.
info
.
streams
.
messages
.
smp_status
=
SMPVerification
.
Succeeded
else
:
if
self
.
blink_session
.
info
.
streams
.
chat
.
smp_status
in
(
SMPVerification
.
InProgress
,
SMPVerification
.
Succeeded
,
SMPVerification
.
Failed
):
if
self
.
blink_session
.
info
.
streams
.
chat
.
smp_status
in
(
SMPVerification
.
InProgress
,
SMPVerification
.
Succeeded
,
SMPVerification
.
Failed
):
return
return
audio_stream
=
self
.
audio_stream
audio_stream
=
self
.
audio_stream
if
audio_stream
.
encryption
.
active
and
audio_stream
.
encryption
.
type
==
'ZRTP'
and
audio_stream
.
encryption
.
zrtp
.
verified
:
if
audio_stream
.
encryption
.
active
and
audio_stream
.
encryption
.
type
==
'ZRTP'
and
audio_stream
.
encryption
.
zrtp
.
verified
:
self
.
chat_stream
.
encryption
.
smp_verify
(
audio_stream
.
encryption
.
zrtp
.
sas
.
encode
()
,
question
=
self
.
question
)
self
.
chat_stream
.
encryption
.
smp_verify
(
audio_stream
.
encryption
.
zrtp
.
sas
,
question
=
self
.
question
)
@
run_in_gui_thread
@
run_in_gui_thread
def
handle_notification
(
self
,
notification
):
def
handle_notification
(
self
,
notification
):
...
@@ -1314,8 +1322,13 @@ class SMPVerificationHandler(object):
...
@@ -1314,8 +1322,13 @@ class SMPVerificationHandler(object):
call_later
(
0
,
self
.
_do_smp
)
call_later
(
0
,
self
.
_do_smp
)
def
_NH_ChatStreamSMPVerificationDidStart
(
self
,
notification
):
def
_NH_ChatStreamSMPVerificationDidStart
(
self
,
notification
):
if
isinstance
(
self
.
chat_stream
,
MessageStream
):
stream_info
=
self
.
blink_session
.
info
.
streams
.
messages
else
:
stream_info
=
self
.
blink_session
.
info
.
streams
.
chat
if
notification
.
data
.
originator
==
'local'
:
if
notification
.
data
.
originator
==
'local'
:
s
elf
.
blink_session
.
info
.
streams
.
chat
.
smp_status
=
SMPVerification
.
InProgress
s
tream_info
.
smp_status
=
SMPVerification
.
InProgress
notification
.
center
.
post_notification
(
'BlinkSessionInfoUpdated'
,
sender
=
self
.
blink_session
,
data
=
NotificationData
(
elements
=
{
'media'
}))
notification
.
center
.
post_notification
(
'BlinkSessionInfoUpdated'
,
sender
=
self
.
blink_session
,
data
=
NotificationData
(
elements
=
{
'media'
}))
return
return
if
self
.
blink_session
.
info
.
streams
.
chat
.
smp_status
is
SMPVerification
.
Failed
or
notification
.
data
.
question
!=
self
.
question
:
if
self
.
blink_session
.
info
.
streams
.
chat
.
smp_status
is
SMPVerification
.
Failed
or
notification
.
data
.
question
!=
self
.
question
:
...
@@ -1324,22 +1337,27 @@ class SMPVerificationHandler(object):
...
@@ -1324,22 +1337,27 @@ class SMPVerificationHandler(object):
audio_stream
=
self
.
audio_stream
audio_stream
=
self
.
audio_stream
if
audio_stream
.
encryption
.
active
and
audio_stream
.
encryption
.
type
==
'ZRTP'
and
audio_stream
.
encryption
.
zrtp
.
sas
is
not
None
:
if
audio_stream
.
encryption
.
active
and
audio_stream
.
encryption
.
type
==
'ZRTP'
and
audio_stream
.
encryption
.
zrtp
.
sas
is
not
None
:
self
.
chat_stream
.
encryption
.
smp_answer
(
audio_stream
.
encryption
.
zrtp
.
sas
)
self
.
chat_stream
.
encryption
.
smp_answer
(
audio_stream
.
encryption
.
zrtp
.
sas
)
if
s
elf
.
blink_session
.
info
.
streams
.
chat
.
smp_status
not
in
(
SMPVerification
.
Succeeded
,
SMPVerification
.
Failed
):
if
s
tream_info
.
smp_status
not
in
(
SMPVerification
.
Succeeded
,
SMPVerification
.
Failed
):
s
elf
.
blink_session
.
info
.
streams
.
chat
.
smp_status
=
SMPVerification
.
InProgress
s
tream_info
.
smp_status
=
SMPVerification
.
InProgress
notification
.
center
.
post_notification
(
'BlinkSessionInfoUpdated'
,
sender
=
self
.
blink_session
,
data
=
NotificationData
(
elements
=
{
'media'
}))
notification
.
center
.
post_notification
(
'BlinkSessionInfoUpdated'
,
sender
=
self
.
blink_session
,
data
=
NotificationData
(
elements
=
{
'media'
}))
else
:
else
:
self
.
chat_stream
.
encryption
.
smp_abort
()
self
.
chat_stream
.
encryption
.
smp_abort
()
def
_NH_ChatStreamSMPVerificationDidEnd
(
self
,
notification
):
def
_NH_ChatStreamSMPVerificationDidEnd
(
self
,
notification
):
if
self
.
blink_session
.
info
.
streams
.
chat
.
smp_status
in
(
SMPVerification
.
Succeeded
,
SMPVerification
.
Failed
):
if
isinstance
(
self
.
chat_stream
,
MessageStream
):
stream_info
=
self
.
blink_session
.
info
.
streams
.
messages
else
:
stream_info
=
self
.
blink_session
.
info
.
streams
.
chat
if
stream_info
.
chat
.
smp_status
in
(
SMPVerification
.
Succeeded
,
SMPVerification
.
Failed
):
return
return
if
notification
.
data
.
status
==
SMPStatus
.
Success
:
if
notification
.
data
.
status
==
SMPStatus
.
Success
:
if
notification
.
data
.
same_secrets
:
if
notification
.
data
.
same_secrets
:
s
elf
.
blink_session
.
info
.
streams
.
chat
.
smp_status
=
SMPVerification
.
Succeeded
if
self
.
blink_session
.
info
.
streams
.
audio
.
zrtp_verified
else
SMPVerification
.
Unavailable
s
tream_info
.
smp_status
=
SMPVerification
.
Succeeded
if
self
.
blink_session
.
info
.
streams
.
audio
.
zrtp_verified
else
SMPVerification
.
Unavailable
else
:
else
:
s
elf
.
blink_session
.
info
.
streams
.
chat
.
smp_status
=
SMPVerification
.
Failed
s
tream_info
.
smp_status
=
SMPVerification
.
Failed
else
:
else
:
s
elf
.
blink_session
.
info
.
streams
.
chat
.
smp_status
=
SMPVerification
.
Unavailable
s
tream_info
.
smp_status
=
SMPVerification
.
Unavailable
if
notification
.
data
.
status
is
SMPStatus
.
ProtocolError
and
notification
.
data
.
reason
==
'startup collision'
:
if
notification
.
data
.
status
is
SMPStatus
.
ProtocolError
and
notification
.
data
.
reason
==
'startup collision'
:
self
.
tries
-=
1
self
.
tries
-=
1
self
.
delay
*=
2
self
.
delay
*=
2
...
...
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