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
0fa9886b
Commit
0fa9886b
authored
Jun 08, 2022
by
Tijmen de Mes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added option to add 'unknown' contacts to the messages group in the contact list
parent
515fb1dc
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
100 additions
and
47 deletions
+100
-47
account.py
blink/configuration/account.py
+1
-0
messages.py
blink/messages.py
+38
-0
preferences.py
blink/preferences.py
+7
-0
preferences.ui
resources/preferences.ui
+54
-47
No files found.
blink/configuration/account.py
View file @
0fa9886b
...
...
@@ -65,6 +65,7 @@ class SMSSettings(SettingsGroup):
use_cpim
=
Setting
(
type
=
bool
,
default
=
True
)
enable_iscomposing
=
Setting
(
type
=
bool
,
default
=
True
)
enable_imdn
=
Setting
(
type
=
bool
,
default
=
True
)
add_unknown_contacts
=
Setting
(
type
=
bool
,
default
=
True
)
class
SoundSettings
(
SettingsGroup
):
...
...
blink/messages.py
View file @
0fa9886b
...
...
@@ -7,6 +7,8 @@ from application.python.types import Singleton
from
zope.interface
import
implementer
from
sipsimple.account
import
Account
,
AccountManager
from
sipsimple.addressbook
import
AddressbookManager
,
Group
,
Contact
,
ContactURI
from
sipsimple.configuration
import
DuplicateIDError
from
sipsimple.configuration.settings
import
SIPSimpleSettings
from
sipsimple.core
import
SIPURI
,
FromHeader
,
ToHeader
,
Message
,
RouteHeader
from
sipsimple.lookup
import
DNSLookup
...
...
@@ -157,12 +159,44 @@ class OutgoingMessage(object):
@
implementer
(
IObserver
)
class
MessageManager
(
object
,
metaclass
=
Singleton
):
__ignored_content_types__
=
{
IsComposingDocument
.
content_type
,
IMDNDocument
.
content_type
,
'text/pgp-public-key'
,
'text/pgp-private-key'
}
def
__init__
(
self
):
self
.
sessions
=
[]
notification_center
=
NotificationCenter
()
notification_center
.
add_observer
(
self
,
name
=
'SIPEngineGotMessage'
)
notification_center
.
add_observer
(
self
,
name
=
'BlinkSessionWasCreated'
)
def
_add_contact_to_messages_group
(
self
,
session
):
# Maybe this be places in Contacts? -- Tijmen
if
not
session
.
account
.
sms
.
add_unknown_contacts
:
return
if
session
.
contact
.
type
not
in
[
'dummy'
,
'unknown'
]:
return
print
(
'Adding contact'
)
group_id
=
'_messages'
try
:
group
=
next
((
group
for
group
in
AddressbookManager
()
.
get_groups
()
if
group
.
id
==
group_id
))
except
StopIteration
:
try
:
group
=
Group
(
id
=
group_id
)
except
DuplicateIDError
as
e
:
return
else
:
group
.
name
=
'Messages'
group
.
position
=
0
group
.
expanded
=
True
contact
=
Contact
()
contact
.
name
=
session
.
contact
.
name
contact
.
preferred_media
=
session
.
contact
.
preferred_media
contact
.
uris
=
[
ContactURI
(
uri
=
uri
.
uri
,
type
=
uri
.
type
)
for
uri
in
session
.
contact
.
uris
]
contact
.
save
()
group
.
contacts
.
add
(
contact
)
group
.
save
()
@
run_in_gui_thread
def
handle_notification
(
self
,
notification
):
handler
=
getattr
(
self
,
'_NH_
%
s'
%
notification
.
name
,
Null
)
...
...
@@ -256,6 +290,7 @@ class MessageManager(object, metaclass=Singleton):
# print("-- Should send delivered imdn")
self
.
send_imdn_message
(
blink_session
,
message_id
,
timestamp
,
'delivered'
)
self
.
_add_contact_to_messages_group
(
blink_session
)
notification_center
.
post_notification
(
'BlinkGotMessage'
,
sender
=
blink_session
,
data
=
message
)
else
:
# TODO handle replicated messages
...
...
@@ -301,6 +336,9 @@ class MessageManager(object, metaclass=Singleton):
outgoing_message
=
OutgoingMessage
(
account
,
contact
,
content
,
content_type
,
recipients
,
courtesy_recipients
,
subject
,
timestamp
,
required
,
additional_headers
,
id
)
outgoing_message
.
send
(
blink_session
)
if
content_type
.
lower
()
not
in
self
.
__ignored_content_types__
:
self
.
_add_contact_to_messages_group
(
blink_session
)
def
create_message_session
(
self
,
uri
):
from
blink.contacts
import
URIUtils
contact
,
contact_uri
=
URIUtils
.
find_contact
(
uri
)
...
...
blink/preferences.py
View file @
0fa9886b
...
...
@@ -260,6 +260,7 @@ class PreferencesWindow(base_class, ui_class, metaclass=QSingleton):
self
.
message_cpim_enabled_button
.
clicked
.
connect
(
self
.
_SH_EnableMessageCPIMButtonClicked
)
self
.
message_iscomposing_enabled_button
.
clicked
.
connect
(
self
.
_SH_EnableMessageIsComposingButtonClicked
)
self
.
message_imdn_enabled_button
.
clicked
.
connect
(
self
.
_SH_EnableMessageIMDNButtonClicked
)
self
.
message_add_unknown_contacts_button
.
clicked
.
connect
(
self
.
_SH_AddUnknownContactsButtonClicked
)
# Audio devices
self
.
audio_alert_device_button
.
activated
[
int
]
.
connect
(
self
.
_SH_AudioAlertDeviceButtonActivated
)
...
...
@@ -833,6 +834,7 @@ class PreferencesWindow(base_class, ui_class, metaclass=QSingleton):
self
.
message_iscomposing_enabled_button
.
setChecked
(
account
.
sms
.
enable_iscomposing
)
self
.
message_imdn_enabled_button
.
setEnabled
(
account
.
sms
.
use_cpim
)
self
.
message_imdn_enabled_button
.
setChecked
(
account
.
sms
.
enable_imdn
)
self
.
message_add_unknown_contacts_button
.
setChecked
(
account
.
sms
.
add_unknown_contacts
)
if
account
is
not
bonjour_account
:
self
.
account_auto_answer
.
setText
(
'Auto answer from allowed contacts'
)
...
...
@@ -1435,6 +1437,11 @@ class PreferencesWindow(base_class, ui_class, metaclass=QSingleton):
account
.
sms
.
enable_imdn
=
checked
account
.
save
()
def
_SH_AddUnknownContactsButtonClicked
(
self
,
checked
):
account
=
self
.
selected_account
account
.
sms
.
add_unknown_contacts
=
checked
account
.
save
()
# Audio devices signal handlers
def
_SH_AudioAlertDeviceButtonActivated
(
self
,
index
):
device
=
self
.
audio_alert_device_button
.
itemData
(
index
)
...
...
resources/preferences.ui
View file @
0fa9886b
...
...
@@ -1257,6 +1257,19 @@
<property
name=
"spacing"
>
<number>
5
</number>
</property>
<item
row=
"5"
column=
"0"
>
<spacer
name=
"verticalSpacer"
>
<property
name=
"orientation"
>
<enum>
Qt::Vertical
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
20
</width>
<height>
20
</height>
</size>
</property>
</spacer>
</item>
<item
row=
"0"
column=
"0"
>
<widget
class=
"QWidget"
name=
"message_widget"
native=
"true"
>
<property
name=
"minimumSize"
>
...
...
@@ -1278,10 +1291,13 @@
<property
name=
"bottomMargin"
>
<number>
0
</number>
</property>
<item
row=
"5"
column=
"1"
>
<widget
class=
"QCheckBox"
name=
"message_iscomposing_enabled_button"
>
<item
row=
"10"
column=
"1"
>
<widget
class=
"QLabel"
name=
"label_4"
>
<property
name=
"enabled"
>
<bool>
false
</bool>
</property>
<property
name=
"text"
>
<string>
Enable Is-Composing
</string>
<string>
If you turn off IMDN you won't be able to see receipts from other people
</string>
</property>
</widget>
</item>
...
...
@@ -1292,26 +1308,24 @@
</property>
</widget>
</item>
<item
row=
"1"
column=
"1"
>
<widget
class=
"QLabel"
name=
"message_label"
>
<property
name=
"font"
>
<font>
<weight>
75
</weight>
<bold>
true
</bold>
</font>
</property>
<item
row=
"4"
column=
"1"
>
<widget
class=
"QCheckBox"
name=
"message_cpim_enabled_button"
>
<property
name=
"text"
>
<string>
When sending messages
</string>
<string>
Use CPIM envelope
</string>
</property>
<property
name=
"scaledContents"
>
<bool>
false
</bool>
</widget>
</item>
<item
row=
"9"
column=
"1"
>
<widget
class=
"QCheckBox"
name=
"message_imdn_enabled_button"
>
<property
name=
"text"
>
<string>
Enable IMDN (Read receipts)
</string>
</property>
</widget>
</item>
<item
row=
"
4
"
column=
"1"
>
<widget
class=
"QCheckBox"
name=
"message_
cpim
_enabled_button"
>
<item
row=
"
5
"
column=
"1"
>
<widget
class=
"QCheckBox"
name=
"message_
iscomposing
_enabled_button"
>
<property
name=
"text"
>
<string>
Use CPIM envelope
</string>
<string>
Enable Is-Composing
</string>
</property>
</widget>
</item>
...
...
@@ -1328,44 +1342,37 @@
</property>
</widget>
</item>
<item
row=
"8"
column=
"1"
>
<widget
class=
"Line"
name=
"line_4"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
<item
row=
"1"
column=
"1"
>
<widget
class=
"QLabel"
name=
"message_label"
>
<property
name=
"font"
>
<font>
<weight>
75
</weight>
<bold>
true
</bold>
</font>
</property>
<property
name=
"text"
>
<string>
When sending messages
</string>
</property>
<property
name=
"scaledContents"
>
<bool>
false
</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item
row=
"1"
column=
"0"
>
<widget
class=
"QCheckBox"
name=
"message_imdn_enabled_button"
>
<item
row=
"11"
column=
"1"
>
<widget
class=
"QCheckBox"
name=
"message_add_unknown_contacts_button"
>
<property
name=
"text"
>
<string>
Enable IMDN (Read receipts)
</string>
<string>
Add unknown contacts to 'Messages' group in your contacts
</string>
</property>
</widget>
</item>
<item
row=
"3"
column=
"0
"
>
<spacer
name=
"verticalSpacer
"
>
<item
row=
"8"
column=
"1
"
>
<widget
class=
"Line"
name=
"line_4
"
>
<property
name=
"orientation"
>
<enum>
Qt::Vertical
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
20
</width>
<height>
20
</height>
</size>
<enum>
Qt::Horizontal
</enum>
</property>
</spacer
>
</widget
>
</item>
<item
row=
"2"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label_4"
>
<property
name=
"enabled"
>
<bool>
false
</bool>
</property>
<property
name=
"text"
>
<string>
If you turn off IMDN you won't be able to see receipts from other people
</string>
</property>
</layout>
</widget>
</item>
</layout>
...
...
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