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
Hide 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):
...
@@ -65,6 +65,7 @@ class SMSSettings(SettingsGroup):
use_cpim
=
Setting
(
type
=
bool
,
default
=
True
)
use_cpim
=
Setting
(
type
=
bool
,
default
=
True
)
enable_iscomposing
=
Setting
(
type
=
bool
,
default
=
True
)
enable_iscomposing
=
Setting
(
type
=
bool
,
default
=
True
)
enable_imdn
=
Setting
(
type
=
bool
,
default
=
True
)
enable_imdn
=
Setting
(
type
=
bool
,
default
=
True
)
add_unknown_contacts
=
Setting
(
type
=
bool
,
default
=
True
)
class
SoundSettings
(
SettingsGroup
):
class
SoundSettings
(
SettingsGroup
):
...
...
blink/messages.py
View file @
0fa9886b
...
@@ -7,6 +7,8 @@ from application.python.types import Singleton
...
@@ -7,6 +7,8 @@ from application.python.types import Singleton
from
zope.interface
import
implementer
from
zope.interface
import
implementer
from
sipsimple.account
import
Account
,
AccountManager
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.configuration.settings
import
SIPSimpleSettings
from
sipsimple.core
import
SIPURI
,
FromHeader
,
ToHeader
,
Message
,
RouteHeader
from
sipsimple.core
import
SIPURI
,
FromHeader
,
ToHeader
,
Message
,
RouteHeader
from
sipsimple.lookup
import
DNSLookup
from
sipsimple.lookup
import
DNSLookup
...
@@ -157,12 +159,44 @@ class OutgoingMessage(object):
...
@@ -157,12 +159,44 @@ class OutgoingMessage(object):
@
implementer
(
IObserver
)
@
implementer
(
IObserver
)
class
MessageManager
(
object
,
metaclass
=
Singleton
):
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
):
def
__init__
(
self
):
self
.
sessions
=
[]
self
.
sessions
=
[]
notification_center
=
NotificationCenter
()
notification_center
=
NotificationCenter
()
notification_center
.
add_observer
(
self
,
name
=
'SIPEngineGotMessage'
)
notification_center
.
add_observer
(
self
,
name
=
'SIPEngineGotMessage'
)
notification_center
.
add_observer
(
self
,
name
=
'BlinkSessionWasCreated'
)
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
@
run_in_gui_thread
def
handle_notification
(
self
,
notification
):
def
handle_notification
(
self
,
notification
):
handler
=
getattr
(
self
,
'_NH_
%
s'
%
notification
.
name
,
Null
)
handler
=
getattr
(
self
,
'_NH_
%
s'
%
notification
.
name
,
Null
)
...
@@ -256,6 +290,7 @@ class MessageManager(object, metaclass=Singleton):
...
@@ -256,6 +290,7 @@ class MessageManager(object, metaclass=Singleton):
# print("-- Should send delivered imdn")
# print("-- Should send delivered imdn")
self
.
send_imdn_message
(
blink_session
,
message_id
,
timestamp
,
'delivered'
)
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
)
notification_center
.
post_notification
(
'BlinkGotMessage'
,
sender
=
blink_session
,
data
=
message
)
else
:
else
:
# TODO handle replicated messages
# TODO handle replicated messages
...
@@ -301,6 +336,9 @@ class MessageManager(object, metaclass=Singleton):
...
@@ -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
=
OutgoingMessage
(
account
,
contact
,
content
,
content_type
,
recipients
,
courtesy_recipients
,
subject
,
timestamp
,
required
,
additional_headers
,
id
)
outgoing_message
.
send
(
blink_session
)
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
):
def
create_message_session
(
self
,
uri
):
from
blink.contacts
import
URIUtils
from
blink.contacts
import
URIUtils
contact
,
contact_uri
=
URIUtils
.
find_contact
(
uri
)
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):
...
@@ -260,6 +260,7 @@ class PreferencesWindow(base_class, ui_class, metaclass=QSingleton):
self
.
message_cpim_enabled_button
.
clicked
.
connect
(
self
.
_SH_EnableMessageCPIMButtonClicked
)
self
.
message_cpim_enabled_button
.
clicked
.
connect
(
self
.
_SH_EnableMessageCPIMButtonClicked
)
self
.
message_iscomposing_enabled_button
.
clicked
.
connect
(
self
.
_SH_EnableMessageIsComposingButtonClicked
)
self
.
message_iscomposing_enabled_button
.
clicked
.
connect
(
self
.
_SH_EnableMessageIsComposingButtonClicked
)
self
.
message_imdn_enabled_button
.
clicked
.
connect
(
self
.
_SH_EnableMessageIMDNButtonClicked
)
self
.
message_imdn_enabled_button
.
clicked
.
connect
(
self
.
_SH_EnableMessageIMDNButtonClicked
)
self
.
message_add_unknown_contacts_button
.
clicked
.
connect
(
self
.
_SH_AddUnknownContactsButtonClicked
)
# Audio devices
# Audio devices
self
.
audio_alert_device_button
.
activated
[
int
]
.
connect
(
self
.
_SH_AudioAlertDeviceButtonActivated
)
self
.
audio_alert_device_button
.
activated
[
int
]
.
connect
(
self
.
_SH_AudioAlertDeviceButtonActivated
)
...
@@ -833,6 +834,7 @@ class PreferencesWindow(base_class, ui_class, metaclass=QSingleton):
...
@@ -833,6 +834,7 @@ class PreferencesWindow(base_class, ui_class, metaclass=QSingleton):
self
.
message_iscomposing_enabled_button
.
setChecked
(
account
.
sms
.
enable_iscomposing
)
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
.
setEnabled
(
account
.
sms
.
use_cpim
)
self
.
message_imdn_enabled_button
.
setChecked
(
account
.
sms
.
enable_imdn
)
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
:
if
account
is
not
bonjour_account
:
self
.
account_auto_answer
.
setText
(
'Auto answer from allowed contacts'
)
self
.
account_auto_answer
.
setText
(
'Auto answer from allowed contacts'
)
...
@@ -1435,6 +1437,11 @@ class PreferencesWindow(base_class, ui_class, metaclass=QSingleton):
...
@@ -1435,6 +1437,11 @@ class PreferencesWindow(base_class, ui_class, metaclass=QSingleton):
account
.
sms
.
enable_imdn
=
checked
account
.
sms
.
enable_imdn
=
checked
account
.
save
()
account
.
save
()
def
_SH_AddUnknownContactsButtonClicked
(
self
,
checked
):
account
=
self
.
selected_account
account
.
sms
.
add_unknown_contacts
=
checked
account
.
save
()
# Audio devices signal handlers
# Audio devices signal handlers
def
_SH_AudioAlertDeviceButtonActivated
(
self
,
index
):
def
_SH_AudioAlertDeviceButtonActivated
(
self
,
index
):
device
=
self
.
audio_alert_device_button
.
itemData
(
index
)
device
=
self
.
audio_alert_device_button
.
itemData
(
index
)
...
...
resources/preferences.ui
View file @
0fa9886b
...
@@ -1257,6 +1257,19 @@
...
@@ -1257,6 +1257,19 @@
<property
name=
"spacing"
>
<property
name=
"spacing"
>
<number>
5
</number>
<number>
5
</number>
</property>
</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"
>
<item
row=
"0"
column=
"0"
>
<widget
class=
"QWidget"
name=
"message_widget"
native=
"true"
>
<widget
class=
"QWidget"
name=
"message_widget"
native=
"true"
>
<property
name=
"minimumSize"
>
<property
name=
"minimumSize"
>
...
@@ -1278,10 +1291,13 @@
...
@@ -1278,10 +1291,13 @@
<property
name=
"bottomMargin"
>
<property
name=
"bottomMargin"
>
<number>
0
</number>
<number>
0
</number>
</property>
</property>
<item
row=
"5"
column=
"1"
>
<item
row=
"10"
column=
"1"
>
<widget
class=
"QCheckBox"
name=
"message_iscomposing_enabled_button"
>
<widget
class=
"QLabel"
name=
"label_4"
>
<property
name=
"enabled"
>
<bool>
false
</bool>
</property>
<property
name=
"text"
>
<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>
</property>
</widget>
</widget>
</item>
</item>
...
@@ -1292,26 +1308,24 @@
...
@@ -1292,26 +1308,24 @@
</property>
</property>
</widget>
</widget>
</item>
</item>
<item
row=
"1"
column=
"1"
>
<item
row=
"4"
column=
"1"
>
<widget
class=
"QLabel"
name=
"message_label"
>
<widget
class=
"QCheckBox"
name=
"message_cpim_enabled_button"
>
<property
name=
"font"
>
<font>
<weight>
75
</weight>
<bold>
true
</bold>
</font>
</property>
<property
name=
"text"
>
<property
name=
"text"
>
<string>
When sending messages
</string>
<string>
Use CPIM envelope
</string>
</property>
</property>
<property
name=
"scaledContents"
>
</widget>
<bool>
false
</bool>
</item>
<item
row=
"9"
column=
"1"
>
<widget
class=
"QCheckBox"
name=
"message_imdn_enabled_button"
>
<property
name=
"text"
>
<string>
Enable IMDN (Read receipts)
</string>
</property>
</property>
</widget>
</widget>
</item>
</item>
<item
row=
"
4
"
column=
"1"
>
<item
row=
"
5
"
column=
"1"
>
<widget
class=
"QCheckBox"
name=
"message_
cpim
_enabled_button"
>
<widget
class=
"QCheckBox"
name=
"message_
iscomposing
_enabled_button"
>
<property
name=
"text"
>
<property
name=
"text"
>
<string>
Use CPIM envelope
</string>
<string>
Enable Is-Composing
</string>
</property>
</property>
</widget>
</widget>
</item>
</item>
...
@@ -1328,6 +1342,29 @@
...
@@ -1328,6 +1342,29 @@
</property>
</property>
</widget>
</widget>
</item>
</item>
<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>
<item
row=
"11"
column=
"1"
>
<widget
class=
"QCheckBox"
name=
"message_add_unknown_contacts_button"
>
<property
name=
"text"
>
<string>
Add unknown contacts to 'Messages' group in your contacts
</string>
</property>
</widget>
</item>
<item
row=
"8"
column=
"1"
>
<item
row=
"8"
column=
"1"
>
<widget
class=
"Line"
name=
"line_4"
>
<widget
class=
"Line"
name=
"line_4"
>
<property
name=
"orientation"
>
<property
name=
"orientation"
>
...
@@ -1338,36 +1375,6 @@
...
@@ -1338,36 +1375,6 @@
</layout>
</layout>
</widget>
</widget>
</item>
</item>
<item
row=
"1"
column=
"0"
>
<widget
class=
"QCheckBox"
name=
"message_imdn_enabled_button"
>
<property
name=
"text"
>
<string>
Enable IMDN (Read receipts)
</string>
</property>
</widget>
</item>
<item
row=
"3"
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=
"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>
</widget>
</item>
</layout>
</layout>
</widget>
</widget>
<widget
class=
"QWidget"
name=
"advanced_tab"
>
<widget
class=
"QWidget"
name=
"advanced_tab"
>
...
...
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