aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libdino/src/entity/conversation.vala10
-rw-r--r--libdino/src/entity/settings.vala78
-rw-r--r--libdino/src/service/notification_events.vala27
-rw-r--r--main/data/preferences_window/general_preferences_page.ui47
-rw-r--r--main/src/view_model/preferences_dialog.vala9
-rw-r--r--main/src/windows/preferences_window/general_preferences_page.vala24
6 files changed, 180 insertions, 15 deletions
diff --git a/libdino/src/entity/conversation.vala b/libdino/src/entity/conversation.vala
index 40943132..e6991973 100644
--- a/libdino/src/entity/conversation.vala
+++ b/libdino/src/entity/conversation.vala
@@ -115,12 +115,20 @@ public class Conversation : Object {
}
public NotifySetting get_notification_setting(StreamInteractor stream_interactor) {
- return notify_setting != NotifySetting.DEFAULT ? notify_setting : get_notification_default_setting(stream_interactor);
+ return get_notification_setting_for(stream_interactor, Application.get_default().settings.notifications);
+ }
+
+ public NotifySetting get_notification_setting_for(StreamInteractor stream_interactor, bool notifications_enabled) {
+ if (!notifications_enabled) return NotifySetting.OFF;
+ return notify_setting != NotifySetting.DEFAULT ? notify_setting : get_notification_default_setting_for(stream_interactor);
}
public NotifySetting get_notification_default_setting(StreamInteractor stream_interactor) {
if (!Application.get_default().settings.notifications) return NotifySetting.OFF;
+ return get_notification_default_setting_for(stream_interactor);
+ }
+ private NotifySetting get_notification_default_setting_for(StreamInteractor stream_interactor) {
if (type_ == Type.GROUPCHAT) {
if (stream_interactor.get_module(MucManager.IDENTITY).is_private_room(this.account, this.counterpart)) {
return NotifySetting.ON;
diff --git a/libdino/src/entity/settings.vala b/libdino/src/entity/settings.vala
index 1b533667..8a3eb2fe 100644
--- a/libdino/src/entity/settings.vala
+++ b/libdino/src/entity/settings.vala
@@ -13,6 +13,12 @@ public class Settings : Object {
send_marker_ = col_to_bool_or_default("send_marker", true);
share_time_ = col_to_bool_or_default("share_time", true);
notifications_ = col_to_bool_or_default("notifications", true);
+ notifications_files_ = col_to_bool_or_default("notifications_files", notifications_);
+ notifications_calls_ = col_to_bool_or_default("notifications_calls", true);
+ notifications_subscription_requests_ = col_to_bool_or_default("notifications_subscription_requests", true);
+ notifications_group_chat_invitations_ = col_to_bool_or_default("notifications_group_chat_invitations", true);
+ notifications_permission_requests_ = col_to_bool_or_default("notifications_permission_requests", true);
+ notifications_connection_errors_ = col_to_bool_or_default("notifications_connection_errors", true);
convert_utf8_smileys_ = col_to_bool_or_default("convert_utf8_smileys", true);
check_spelling = col_to_bool_or_default("check_spelling", true);
}
@@ -70,6 +76,78 @@ public class Settings : Object {
}
}
+ private bool notifications_files_;
+ public bool notifications_files {
+ get { return notifications_files_; }
+ set {
+ db.settings.upsert()
+ .value(db.settings.key, "notifications_files", true)
+ .value(db.settings.value, value.to_string())
+ .perform();
+ notifications_files_ = value;
+ }
+ }
+
+ private bool notifications_calls_;
+ public bool notifications_calls {
+ get { return notifications_calls_; }
+ set {
+ db.settings.upsert()
+ .value(db.settings.key, "notifications_calls", true)
+ .value(db.settings.value, value.to_string())
+ .perform();
+ notifications_calls_ = value;
+ }
+ }
+
+ private bool notifications_subscription_requests_;
+ public bool notifications_subscription_requests {
+ get { return notifications_subscription_requests_; }
+ set {
+ db.settings.upsert()
+ .value(db.settings.key, "notifications_subscription_requests", true)
+ .value(db.settings.value, value.to_string())
+ .perform();
+ notifications_subscription_requests_ = value;
+ }
+ }
+
+ private bool notifications_group_chat_invitations_;
+ public bool notifications_group_chat_invitations {
+ get { return notifications_group_chat_invitations_; }
+ set {
+ db.settings.upsert()
+ .value(db.settings.key, "notifications_group_chat_invitations", true)
+ .value(db.settings.value, value.to_string())
+ .perform();
+ notifications_group_chat_invitations_ = value;
+ }
+ }
+
+ private bool notifications_permission_requests_;
+ public bool notifications_permission_requests {
+ get { return notifications_permission_requests_; }
+ set {
+ db.settings.upsert()
+ .value(db.settings.key, "notifications_permission_requests", true)
+ .value(db.settings.value, value.to_string())
+ .perform();
+ notifications_permission_requests_ = value;
+ }
+ }
+
+ private bool notifications_connection_errors_;
+ public bool notifications_connection_errors {
+ get { return notifications_connection_errors_; }
+ set {
+ db.settings.upsert()
+ .value(db.settings.key, "notifications_connection_errors", true)
+ .value(db.settings.value, value.to_string())
+ .perform();
+ notifications_connection_errors_ = value;
+ }
+ }
+
private bool convert_utf8_smileys_;
public bool convert_utf8_smileys {
get { return convert_utf8_smileys_; }
diff --git a/libdino/src/service/notification_events.vala b/libdino/src/service/notification_events.vala
index 1830bab4..d22d54a4 100644
--- a/libdino/src/service/notification_events.vala
+++ b/libdino/src/service/notification_events.vala
@@ -53,9 +53,6 @@ public class NotificationEvents : StreamInteractionModule, Object {
if (item.id == conversation.read_up_to_item) return;
if (stream_interactor.get_module(ChatInteraction.IDENTITY).is_active_focus()) return;
- Conversation.NotifySetting notify = conversation.get_notification_setting(stream_interactor);
- if (notify == Conversation.NotifySetting.OFF) return;
-
string conversation_display_name = get_conversation_display_name(stream_interactor, conversation, null);
string? participant_display_name = null;
if (conversation.type_ == Conversation.Type.GROUPCHAT) {
@@ -64,13 +61,16 @@ public class NotificationEvents : StreamInteractionModule, Object {
switch (item.type_) {
case MessageItem.TYPE:
+ Conversation.NotifySetting message_notify = conversation.get_notification_setting(stream_interactor);
+ if (message_notify == Conversation.NotifySetting.OFF) return;
+
Message message = ((MessageItem) item).message;
if (message.direction == Message.DIRECTION_SENT) return;
DateTime? message_time = message.time;
if (message_time != null && message_time.compare(new DateTime.now_utc().add_seconds(-MESSAGE_NOTIFICATION_MAX_AGE_SECONDS)) < 0) return;
- if (notify == Conversation.NotifySetting.HIGHLIGHT) {
+ if (message_notify == Conversation.NotifySetting.HIGHLIGHT) {
Jid? nick = stream_interactor.get_module(MucManager.IDENTITY).get_own_jid(conversation.counterpart, conversation.account);
if (nick == null) return;
@@ -79,21 +79,25 @@ public class NotificationEvents : StreamInteractionModule, Object {
}
notify_content_item(item, conversation);
- if (notify != Conversation.NotifySetting.OFF) {
+ if (message_notify != Conversation.NotifySetting.OFF) {
NotificationProvider notifier = yield notifier.wait_async();
yield notifier.notify_message(message, conversation, conversation_display_name, participant_display_name);
}
break;
case FileItem.TYPE:
+ Conversation.NotifySetting file_notify = conversation.get_notification_setting_for(
+ stream_interactor, Application.get_default().settings.notifications_files);
+ if (file_notify == Conversation.NotifySetting.OFF) return;
+
FileTransfer file_transfer = ((FileItem) item).file_transfer;
bool is_image = file_transfer.content_type != null && file_transfer.content_type.is_image();
// Don't notify on file transfers in a groupchat set to "mention only"
- if (notify == Conversation.NotifySetting.HIGHLIGHT) return;
+ if (file_notify == Conversation.NotifySetting.HIGHLIGHT) return;
if (file_transfer.direction == FileTransfer.DIRECTION_SENT) return;
notify_content_item(item, conversation);
- if (notify != Conversation.NotifySetting.OFF) {
+ if (file_notify != Conversation.NotifySetting.OFF) {
NotificationProvider notifier = yield notifier.wait_async();
yield notifier.notify_file(file_transfer, conversation, is_image, conversation_display_name, participant_display_name);
}
@@ -105,6 +109,8 @@ public class NotificationEvents : StreamInteractionModule, Object {
}
private async void on_voice_request_received(Account account, Jid room_jid, Jid from_jid, string nick) {
+ if (!Application.get_default().settings.notifications_permission_requests) return;
+
Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation(room_jid, account, Conversation.Type.GROUPCHAT);
if (conversation == null) return;
@@ -113,6 +119,8 @@ public class NotificationEvents : StreamInteractionModule, Object {
}
private async void on_received_subscription_request(Jid jid, Account account) {
+ if (!Application.get_default().settings.notifications_subscription_requests) return;
+
Conversation conversation = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(jid, account, Conversation.Type.CHAT);
if (stream_interactor.get_module(ChatInteraction.IDENTITY).is_active_focus(conversation)) return;
@@ -121,6 +129,7 @@ public class NotificationEvents : StreamInteractionModule, Object {
}
private async void on_call_incoming(Call call, CallState call_state, Conversation conversation, bool video, bool multiparty) {
+ if (!Application.get_default().settings.notifications_calls) return;
if (!stream_interactor.get_module(Calls.IDENTITY).can_we_do_calls(call.account)) return;
string conversation_display_name = get_conversation_display_name(stream_interactor, conversation, null);
@@ -134,6 +143,8 @@ public class NotificationEvents : StreamInteractionModule, Object {
}
private async void on_invite_received(Account account, Jid room_jid, Jid from_jid, string? password, string? reason) {
+ if (!Application.get_default().settings.notifications_group_chat_invitations) return;
+
string inviter_display_name;
if (room_jid.equals_bare(from_jid)) {
Conversation conversation = new Conversation(room_jid, account, Conversation.Type.GROUPCHAT);
@@ -147,6 +158,8 @@ public class NotificationEvents : StreamInteractionModule, Object {
}
private async void on_connection_error(Account account, ConnectionManager.ConnectionError error) {
+ if (!Application.get_default().settings.notifications_connection_errors) return;
+
NotificationProvider notifier = yield notifier.wait_async();
yield notifier.notify_connection_error(account, error);
}
diff --git a/main/data/preferences_window/general_preferences_page.ui b/main/data/preferences_window/general_preferences_page.ui
index ca240511..50efd425 100644
--- a/main/data/preferences_window/general_preferences_page.ui
+++ b/main/data/preferences_window/general_preferences_page.ui
@@ -27,13 +27,56 @@
</child>
<child>
<object class="AdwPreferencesGroup">
+ <property name="title" translatable="yes">Notifications</property>
<child>
- <object class="AdwSwitchRow" id="notification_row">
- <property name="title" translatable="yes">_Notifications</property>
+ <object class="AdwSwitchRow" id="notification_messages_row">
+ <property name="title" translatable="yes">_Messages</property>
<property name="subtitle" translatable="yes">Notify when a new message arrives</property>
<property name="use-underline">True</property>
</object>
</child>
+ <child>
+ <object class="AdwSwitchRow" id="notification_files_row">
+ <property name="title" translatable="yes">_Files</property>
+ <property name="subtitle" translatable="yes">Notify when a new file arrives</property>
+ <property name="use-underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="AdwSwitchRow" id="notification_calls_row">
+ <property name="title" translatable="yes">_Calls</property>
+ <property name="subtitle" translatable="yes">Notify about incoming calls</property>
+ <property name="use-underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="AdwSwitchRow" id="notification_subscription_requests_row">
+ <property name="title" translatable="yes">_Subscription Requests</property>
+ <property name="subtitle" translatable="yes">Notify when someone wants to add you as a contact</property>
+ <property name="use-underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="AdwSwitchRow" id="notification_group_chat_invitations_row">
+ <property name="title" translatable="yes">_Group Chat Invitations</property>
+ <property name="subtitle" translatable="yes">Notify when someone invites you to a group chat</property>
+ <property name="use-underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="AdwSwitchRow" id="notification_permission_requests_row">
+ <property name="title" translatable="yes">_Permission Requests</property>
+ <property name="subtitle" translatable="yes">Notify when someone requests permission to write in a group chat</property>
+ <property name="use-underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="AdwSwitchRow" id="notification_connection_errors_row">
+ <property name="title" translatable="yes">Connection _Errors</property>
+ <property name="subtitle" translatable="yes">Notify when an account cannot connect</property>
+ <property name="use-underline">True</property>
+ </object>
+ </child>
</object>
</child>
<child>
diff --git a/main/src/view_model/preferences_dialog.vala b/main/src/view_model/preferences_dialog.vala
index 20e11ae3..5b5412f8 100644
--- a/main/src/view_model/preferences_dialog.vala
+++ b/main/src/view_model/preferences_dialog.vala
@@ -110,7 +110,13 @@ public class Dino.Ui.ViewModel.PreferencesDialog : Object {
settings.bind_property("send-typing", general_page, "send-typing", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
settings.bind_property("send-marker", general_page, "send-marker", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
settings.bind_property("share-time", general_page, "share-time", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
- settings.bind_property("notifications", general_page, "notifications", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
+ settings.bind_property("notifications", general_page, "notifications-messages", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
+ settings.bind_property("notifications-files", general_page, "notifications-files", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
+ settings.bind_property("notifications-calls", general_page, "notifications-calls", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
+ settings.bind_property("notifications-subscription-requests", general_page, "notifications-subscription-requests", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
+ settings.bind_property("notifications-group-chat-invitations", general_page, "notifications-group-chat-invitations", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
+ settings.bind_property("notifications-permission-requests", general_page, "notifications-permission-requests", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
+ settings.bind_property("notifications-connection-errors", general_page, "notifications-connection-errors", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
settings.bind_property("convert-utf8-smileys", general_page, "convert-emojis", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
}
}
@@ -127,4 +133,3 @@ public class Dino.Ui.ViewModel.ChangePasswordDialog : Object {
return res;
}
}
-
diff --git a/main/src/windows/preferences_window/general_preferences_page.vala b/main/src/windows/preferences_window/general_preferences_page.vala
index 0dcf2118..81906643 100644
--- a/main/src/windows/preferences_window/general_preferences_page.vala
+++ b/main/src/windows/preferences_window/general_preferences_page.vala
@@ -4,7 +4,13 @@ public class Dino.Ui.ViewModel.GeneralPreferencesPage : Object {
public bool send_typing { get; set; }
public bool send_marker { get; set; }
public bool share_time { get; set; }
- public bool notifications { get; set; }
+ public bool notifications_messages { get; set; }
+ public bool notifications_files { get; set; }
+ public bool notifications_calls { get; set; }
+ public bool notifications_subscription_requests { get; set; }
+ public bool notifications_group_chat_invitations { get; set; }
+ public bool notifications_permission_requests { get; set; }
+ public bool notifications_connection_errors { get; set; }
public bool convert_emojis { get; set; }
}
@@ -13,7 +19,13 @@ public class Dino.Ui.GeneralPreferencesPage : Adw.PreferencesPage {
[GtkChild] private unowned Adw.SwitchRow typing_row;
[GtkChild] private unowned Adw.SwitchRow marker_row;
[GtkChild] private unowned Adw.SwitchRow time_row;
- [GtkChild] private unowned Adw.SwitchRow notification_row;
+ [GtkChild] private unowned Adw.SwitchRow notification_messages_row;
+ [GtkChild] private unowned Adw.SwitchRow notification_files_row;
+ [GtkChild] private unowned Adw.SwitchRow notification_calls_row;
+ [GtkChild] private unowned Adw.SwitchRow notification_subscription_requests_row;
+ [GtkChild] private unowned Adw.SwitchRow notification_group_chat_invitations_row;
+ [GtkChild] private unowned Adw.SwitchRow notification_permission_requests_row;
+ [GtkChild] private unowned Adw.SwitchRow notification_connection_errors_row;
[GtkChild] private unowned Adw.SwitchRow emoji_row;
public ViewModel.GeneralPreferencesPage model { get; set; default = new ViewModel.GeneralPreferencesPage(); }
@@ -32,7 +44,13 @@ public class Dino.Ui.GeneralPreferencesPage : Adw.PreferencesPage {
model.bind_property("send-typing", typing_row, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL),
model.bind_property("send-marker", marker_row, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL),
model.bind_property("share-time", time_row, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL),
- model.bind_property("notifications", notification_row, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL),
+ model.bind_property("notifications-messages", notification_messages_row, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL),
+ model.bind_property("notifications-files", notification_files_row, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL),
+ model.bind_property("notifications-calls", notification_calls_row, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL),
+ model.bind_property("notifications-subscription-requests", notification_subscription_requests_row, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL),
+ model.bind_property("notifications-group-chat-invitations", notification_group_chat_invitations_row, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL),
+ model.bind_property("notifications-permission-requests", notification_permission_requests_row, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL),
+ model.bind_property("notifications-connection-errors", notification_connection_errors_row, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL),
model.bind_property("convert-emojis", emoji_row, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL)
};
} else {