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
aae1a0a9
Commit
aae1a0a9
authored
Aug 15, 2022
by
Tijmen de Mes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable decryption of incoming sip messages
parent
b36cd04f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
7 deletions
+53
-7
chatwindow.py
blink/chatwindow.py
+11
-1
messages.py
blink/messages.py
+42
-6
No files found.
blink/chatwindow.py
View file @
aae1a0a9
...
...
@@ -1610,6 +1610,7 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
notification_center
.
add_observer
(
self
,
name
=
'BlinkMessageHistoryLoadDidSucceed'
)
notification_center
.
add_observer
(
self
,
name
=
'BlinkMessageHistoryLoadDidFail'
)
notification_center
.
add_observer
(
self
,
name
=
'BlinkMessageHistoryLastContactsDidSucceed'
)
notification_center
.
add_observer
(
self
,
name
=
'PGPMessageDidNotDecrypt'
)
# self.splitter.splitterMoved.connect(self._SH_SplitterMoved) # check this and decide on what size to have in the window (see Notes) -Dan
...
...
@@ -2367,6 +2368,7 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
sender
=
ChatSender
(
message
.
sender
.
display_name
or
session
.
name
,
uri
,
session
.
icon
.
filename
)
if
session
.
chat_widget
.
history_loaded
:
session
.
chat_widget
.
add_message
(
ChatMessage
(
content
,
sender
,
'incoming'
,
id
=
message
.
id
))
session
.
chat_widget
.
update_message_encryption
(
message
.
id
,
message
.
is_secure
)
else
:
self
.
render_after_load
.
append
(
ChatMessage
(
content
,
sender
,
'incoming'
,
id
=
message
.
id
))
...
...
@@ -2414,6 +2416,13 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
session
.
chat_widget
.
add_message
(
ChatStatus
(
f
'Delivery failed: {notification.data.data.code} - {notification.data.data.reason}'
))
session
.
chat_widget
.
update_message_status
(
id
=
notification
.
data
.
id
,
status
=
'failed'
)
def
_NH_PGPMessageDidNotDecrypt
(
self
,
notification
):
blink_session
=
notification
.
sender
session
=
blink_session
.
items
.
chat
if
session
is
None
:
return
session
.
chat_widget
.
add_message
(
ChatStatus
(
f
'Decryption failed: {notification.data.data.error}'
))
def
_NH_BlinkMessageHistoryLoadDidSucceed
(
self
,
notification
):
blink_session
=
notification
.
sender
session
=
blink_session
.
items
.
chat
...
...
@@ -2463,7 +2472,8 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
MessageManager
()
.
send_imdn_message
(
blink_session
,
message
.
message_id
,
message
.
timestamp
,
'displayed'
)
else
:
self
.
pending_displayed_notifications
.
setdefault
(
blink_session
,
[])
.
append
((
message
.
message_id
,
message
.
timestamp
))
if
'OpenPGP'
in
message
.
encryption_type
:
session
.
chat_widget
.
update_message_encryption
(
message
.
message_id
,
True
)
session
.
chat_widget
.
history_loaded
=
True
while
len
(
self
.
render_after_load
)
>
0
:
...
...
blink/messages.py
View file @
aae1a0a9
...
...
@@ -498,6 +498,8 @@ class MessageManager(object, metaclass=Singleton):
notification_center
.
add_observer
(
self
,
name
=
'BlinkSessionNewOutgoing'
)
notification_center
.
add_observer
(
self
,
name
=
'BlinkSessionWasDeleted'
)
notification_center
.
add_observer
(
self
,
name
=
'PGPKeysDidGenerate'
)
notification_center
.
add_observer
(
self
,
name
=
'PGPMessageDidNotDecrypt'
)
notification_center
.
add_observer
(
self
,
name
=
'PGPMessageDidDecrypt'
)
def
_add_contact_to_messages_group
(
self
,
session
):
# Maybe this needs to be placed in Contacts? -- Tijmen
if
not
session
.
account
.
sms
.
add_unknown_contacts
:
...
...
@@ -569,6 +571,17 @@ class MessageManager(object, metaclass=Singleton):
return
True
return
False
def
_handle_incoming_message
(
self
,
message
,
session
):
notification_center
=
NotificationCenter
()
notification_center
.
post_notification
(
'BlinkMessageIsParsed'
,
sender
=
session
,
data
=
message
)
if
message
is
not
None
and
'positive-delivery'
in
message
.
disposition
:
print
(
"-- Should send delivered imdn"
)
self
.
send_imdn_message
(
session
,
message
.
id
,
message
.
timestamp
,
'delivered'
)
self
.
_add_contact_to_messages_group
(
session
)
notification_center
.
post_notification
(
'BlinkGotMessage'
,
sender
=
session
,
data
=
message
)
def
_send_message
(
self
,
outgoing_message
):
self
.
_outgoing_message_queue
.
append
(
outgoing_message
)
self
.
_send_outgoing_messages
()
...
...
@@ -720,6 +733,14 @@ class MessageManager(object, metaclass=Singleton):
return
else
:
blink_session
=
session_manager
.
create_session
(
contact
,
contact_uri
,
[
StreamDescription
(
'messages'
)],
account
=
account
,
connect
=
False
)
else
:
if
blink_session
.
fake_streams
.
get
(
'messages'
)
is
None
:
stream
=
StreamDescription
(
'messages'
)
blink_session
.
fake_streams
.
extend
([
stream
.
create_stream
()])
blink_session
.
_delete_when_done
=
False
if
account
.
sms
.
enable_pgp
and
account
.
sms
.
private_key
is
not
None
and
os
.
path
.
exists
(
account
.
sms
.
private_key
.
normalized
):
blink_session
.
fake_streams
.
get
(
'messages'
)
.
enable_pgp
()
notification_center
.
post_notification
(
'BlinkSessionWillAddStream'
,
sender
=
blink_session
,
data
=
NotificationData
(
stream
=
stream
))
if
content_type
.
lower
()
in
[
'text/pgp-public-key'
,
'text/pgp-private-key'
]:
notification_center
.
post_notification
(
'PGPKeysShouldReload'
,
sender
=
blink_session
)
...
...
@@ -751,14 +772,13 @@ class MessageManager(object, metaclass=Singleton):
return
message
=
BlinkMessage
(
body
,
content_type
,
sender
,
timestamp
=
timestamp
,
id
=
message_id
,
disposition
=
disposition
)
notification_center
.
post_notification
(
'BlinkMessageIsParsed'
,
sender
=
blink_session
,
data
=
message
)
if
disposition
is
not
None
and
'positive-delivery'
in
disposition
:
# print("-- Should send delivered imdn")
self
.
send_imdn_message
(
blink_session
,
message_id
,
timestamp
,
'delivered'
)
if
encryption
==
'OpenPGP'
:
if
blink_session
.
fake_streams
.
get
(
'messages'
)
.
can_decrypt
:
blink_session
.
fake_streams
.
get
(
'messages'
)
.
decrypt
(
message
)
return
self
.
_add_contact_to_messages_group
(
blink_session
)
notification_center
.
post_notification
(
'BlinkGotMessage'
,
sender
=
blink_session
,
data
=
message
)
self
.
_handle_incoming_message
(
message
,
blink_session
)
else
:
# TODO handle replicated messages
pass
...
...
@@ -801,6 +821,22 @@ class MessageManager(object, metaclass=Singleton):
outgoing_message
=
OutgoingMessage
(
session
.
account
,
session
.
contact
,
str
(
notification
.
data
.
public_key
),
'text/pgp-public-key'
,
session
=
session
)
self
.
_send_message
(
outgoing_message
)
def
_NH_PGPMessageDidDecrypt
(
self
,
notification
):
if
not
isinstance
(
notification
.
data
.
message
,
BlinkMessage
):
return
session
=
notification
.
sender
notification
.
data
.
message
.
is_secure
=
True
notification_center
=
NotificationCenter
()
notification_center
.
post_notification
(
'BlinkMessageDidDecrypt'
,
sender
=
session
,
data
=
NotificationData
(
message
=
notification
.
data
.
message
))
self
.
_handle_incoming_message
(
notification
.
data
.
message
,
session
)
def
_NH_PGPMessageDidNotDecrypt
(
self
,
notification
):
session
=
notification
.
sender
data
=
notification
.
data
.
message
self
.
send_imdn_message
(
session
,
data
.
message_id
,
data
.
timestamp
,
'error'
)
def
export_private_key
(
self
,
account
):
if
account
is
None
:
...
...
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