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
45fa9dbe
Commit
45fa9dbe
authored
Apr 22, 2022
by
Tijmen de Mes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved message code
parent
adb683e8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
40 deletions
+40
-40
chatwindow.py
blink/chatwindow.py
+40
-40
No files found.
blink/chatwindow.py
View file @
45fa9dbe
...
...
@@ -2272,15 +2272,15 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
def
_NH_ChatSessionItemDidChange
(
self
,
notification
):
self
.
_update_widgets_for_session
()
def
_NH_
ChatStream
GotMessage
(
self
,
notification
):
blink_session
=
notification
.
sender
.
blink_session
def
_NH_GotMessage
(
self
,
notification
):
blink_session
=
notification
.
sender
session
=
blink_session
.
items
.
chat
message
=
notification
.
data
if
session
is
None
:
return
message
=
notification
.
data
.
message
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/'
):
...
...
@@ -2289,7 +2289,11 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
else
:
return
try
:
uri
=
'
%
s@
%
s'
%
(
message
.
sender
.
uri
.
user
.
decode
(),
message
.
sender
.
uri
.
host
.
decode
())
except
AttributeError
:
uri
=
'
%
s@
%
s'
%
(
message
.
sender
.
uri
.
user
,
message
.
sender
.
uri
.
host
)
account_manager
=
AccountManager
()
if
account_manager
.
has_account
(
uri
):
account
=
account_manager
.
get_account
(
uri
)
...
...
@@ -2300,11 +2304,7 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
else
:
sender
=
ChatSender
(
message
.
sender
.
display_name
or
session
.
name
,
uri
,
session
.
icon
.
filename
)
is_status_message
=
any
(
h
.
name
==
'Message-Type'
and
h
.
value
==
'status'
and
h
.
namespace
==
'urn:ag-projects:xml:ns:cpim'
for
h
in
message
.
additional_headers
)
if
is_status_message
:
session
.
chat_widget
.
add_message
(
ChatStatus
(
content
))
else
:
session
.
chat_widget
.
add_message
(
ChatMessage
(
content
,
sender
,
'incoming'
))
session
.
chat_widget
.
add_message
(
ChatMessage
(
content
,
sender
,
'incoming'
,
id
=
message
.
id
))
session
.
remote_composing
=
False
settings
=
SIPSimpleSettings
()
...
...
@@ -2313,15 +2313,37 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
SIPApplication
.
alert_audio_bridge
.
add
(
player
)
player
.
start
()
def
_NH_
Go
tMessage
(
self
,
notification
):
def
_NH_
DidAccep
tMessage
(
self
,
notification
):
blink_session
=
notification
.
sender
session
=
blink_session
.
items
.
chat
if
session
is
None
:
return
session
.
chat_widget
.
update_message_status
(
id
=
notification
.
data
.
id
,
status
=
'accepted'
)
message
=
notification
.
data
def
_NH_DidNotDeliverMessage
(
self
,
notification
):
blink_session
=
notification
.
sender
session
=
blink_session
.
items
.
chat
if
session
is
None
:
return
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_GotComposingIndication
(
self
,
notification
):
session
=
notification
.
sender
.
items
.
chat
if
session
is
None
:
return
session
.
update_composing_indication
(
notification
.
data
)
def
_NH_ChatStreamGotMessage
(
self
,
notification
):
blink_session
=
notification
.
sender
.
blink_session
session
=
blink_session
.
items
.
chat
if
session
is
None
:
return
message
=
notification
.
data
.
message
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/'
):
...
...
@@ -2330,11 +2352,7 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
else
:
return
try
:
uri
=
'
%
s@
%
s'
%
(
message
.
sender
.
uri
.
user
.
decode
(),
message
.
sender
.
uri
.
host
.
decode
())
except
AttributeError
:
uri
=
'
%
s@
%
s'
%
(
message
.
sender
.
uri
.
user
,
message
.
sender
.
uri
.
host
)
account_manager
=
AccountManager
()
if
account_manager
.
has_account
(
uri
):
account
=
account_manager
.
get_account
(
uri
)
...
...
@@ -2345,7 +2363,11 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
else
:
sender
=
ChatSender
(
message
.
sender
.
display_name
or
session
.
name
,
uri
,
session
.
icon
.
filename
)
session
.
chat_widget
.
add_message
(
ChatMessage
(
content
,
sender
,
'incoming'
,
id
=
message
.
id
))
is_status_message
=
any
(
h
.
name
==
'Message-Type'
and
h
.
value
==
'status'
and
h
.
namespace
==
'urn:ag-projects:xml:ns:cpim'
for
h
in
message
.
additional_headers
)
if
is_status_message
:
session
.
chat_widget
.
add_message
(
ChatStatus
(
content
))
else
:
session
.
chat_widget
.
add_message
(
ChatMessage
(
content
,
sender
,
'incoming'
))
session
.
remote_composing
=
False
settings
=
SIPSimpleSettings
()
...
...
@@ -2354,28 +2376,6 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
SIPApplication
.
alert_audio_bridge
.
add
(
player
)
player
.
start
()
def
_NH_DidAcceptMessage
(
self
,
notification
):
blink_session
=
notification
.
sender
session
=
blink_session
.
items
.
chat
if
session
is
None
:
return
session
.
chat_widget
.
update_message_status
(
id
=
notification
.
data
.
id
,
status
=
'accepted'
)
def
_NH_DidNotDeliverMessage
(
self
,
notification
):
blink_session
=
notification
.
sender
session
=
blink_session
.
items
.
chat
if
session
is
None
:
return
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_GotComposingIndication
(
self
,
notification
):
session
=
notification
.
sender
.
items
.
chat
if
session
is
None
:
return
session
.
update_composing_indication
(
notification
.
data
)
def
_NH_ChatStreamGotComposingIndication
(
self
,
notification
):
session
=
notification
.
sender
.
blink_session
.
items
.
chat
if
session
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