aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libdino/src/service/blocking_manager.vala15
-rw-r--r--main/data/conversation_details.ui24
-rw-r--r--main/src/ui/conversation_details.vala12
-rw-r--r--main/src/view_model/conversation_details.vala5
-rw-r--r--main/src/windows/conversation_details.vala21
5 files changed, 65 insertions, 12 deletions
diff --git a/libdino/src/service/blocking_manager.vala b/libdino/src/service/blocking_manager.vala
index aa07f990..1c125aac 100644
--- a/libdino/src/service/blocking_manager.vala
+++ b/libdino/src/service/blocking_manager.vala
@@ -20,19 +20,22 @@ public class BlockingManager : StreamInteractionModule, Object {
this.stream_interactor = stream_interactor;
}
- public bool is_blocked(Account account, Jid jid) {
+ public bool is_blocked(Account account, Jid jid, bool domainblock = false) {
XmppStream stream = stream_interactor.get_stream(account);
- return stream != null && stream.get_module(Xmpp.Xep.BlockingCommand.Module.IDENTITY).is_blocked(stream, jid.to_string());
+ string jid_str = domainblock ? jid.domainpart.to_string () : jid.to_string();
+ return stream != null && stream.get_module(Xmpp.Xep.BlockingCommand.Module.IDENTITY).is_blocked(stream, jid_str);
}
- public void block(Account account, Jid jid) {
+ public void block(Account account, Jid jid, bool domainblock = false) {
XmppStream stream = stream_interactor.get_stream(account);
- stream.get_module(Xmpp.Xep.BlockingCommand.Module.IDENTITY).block(stream, { jid.to_string() });
+ string jid_str = domainblock ? jid.domainpart.to_string () : jid.to_string();
+ stream.get_module(Xmpp.Xep.BlockingCommand.Module.IDENTITY).block(stream, { jid_str });
}
- public void unblock(Account account, Jid jid) {
+ public void unblock(Account account, Jid jid, bool domainblock = false) {
XmppStream stream = stream_interactor.get_stream(account);
- stream.get_module(Xmpp.Xep.BlockingCommand.Module.IDENTITY).unblock(stream, { jid.to_string() });
+ string jid_str = domainblock ? jid.domainpart.to_string () : jid.to_string();
+ stream.get_module(Xmpp.Xep.BlockingCommand.Module.IDENTITY).unblock(stream, { jid_str });
}
public bool is_supported(Account account) {
diff --git a/main/data/conversation_details.ui b/main/data/conversation_details.ui
index 4229d875..bef06007 100644
--- a/main/data/conversation_details.ui
+++ b/main/data/conversation_details.ui
@@ -122,7 +122,8 @@
</object>
</child>
<child>
- <object class="GtkButton" id="block_button">
+ <object class="AdwSplitButton" id="block_button">
+ <property name="menu_model">block_menu_model</property>
<property name="visible" bind-source="model" bind-property="show-blocked" bind-flags="sync-create"/>
<child>
<object class="AdwButtonContent" id="block_button_content">
@@ -132,6 +133,17 @@
</child>
</object>
</child>
+ <child>
+ <object class="GtkButton" id="block_domain_button">
+ <property name="visible" bind-source="model" bind-property="show-blocked" bind-flags="sync-create"/>
+ <child>
+ <object class="AdwButtonContent" id="block_domain_button_content">
+ <property name="icon-name">dino-block-symbolic</property>
+ <property name="label">Domain blocked</property>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
</child>
</object>
@@ -203,4 +215,12 @@
</item>
</section>
</menu>
-</interface> \ No newline at end of file
+ <menu id="block_menu_model">
+ <section>
+ <item>
+ <attribute name="label">Block domain</attribute>
+ <attribute name="action">domain.on</attribute>
+ </item>
+ </section>
+ </menu>
+</interface>
diff --git a/main/src/ui/conversation_details.vala b/main/src/ui/conversation_details.vala
index 1c82f105..7a00c786 100644
--- a/main/src/ui/conversation_details.vala
+++ b/main/src/ui/conversation_details.vala
@@ -10,6 +10,7 @@ namespace Dino.Ui.ConversationDetails {
model.conversation = conversation;
model.display_name = stream_interactor.get_module(ContactModels.IDENTITY).get_display_name_model(conversation);
model.blocked = stream_interactor.get_module(BlockingManager.IDENTITY).is_blocked(model.conversation.account, model.conversation.counterpart);
+ model.domain_blocked = stream_interactor.get_module(BlockingManager.IDENTITY).is_blocked(model.conversation.account, model.conversation.counterpart, true);
if (conversation.type_ == Conversation.Type.GROUPCHAT) {
stream_interactor.get_module(MucManager.IDENTITY).get_config_form.begin(conversation.account, conversation.counterpart, (_, res) => {
@@ -58,6 +59,7 @@ namespace Dino.Ui.ConversationDetails {
return true;
});
model.bind_property("blocked", view_model, "blocked", BindingFlags.SYNC_CREATE);
+ model.bind_property("domain_blocked", view_model, "domain_blocked", BindingFlags.SYNC_CREATE);
model.bind_property("data-form", view_model, "room-configuration-rows", BindingFlags.SYNC_CREATE, (_, from, ref to) => {
var data_form = (DataForms.DataForm) from;
if (data_form == null) return true;
@@ -85,6 +87,14 @@ namespace Dino.Ui.ConversationDetails {
}
view_model.blocked = !view_model.blocked;
});
+ view_model.domain_block_changed.connect(() => {
+ if (view_model.domain_blocked) {
+ stream_interactor.get_module(BlockingManager.IDENTITY).unblock(model.conversation.account, model.conversation.counterpart, true);
+ } else {
+ stream_interactor.get_module(BlockingManager.IDENTITY).block(model.conversation.account, model.conversation.counterpart, true);
+ }
+ view_model.domain_blocked = !view_model.domain_blocked;
+ });
view_model.notification_changed.connect((setting) => {
switch (setting) {
case ON:
@@ -189,4 +199,4 @@ namespace Dino.Ui.ConversationDetails {
break;
}
}
-} \ No newline at end of file
+}
diff --git a/main/src/view_model/conversation_details.vala b/main/src/view_model/conversation_details.vala
index 15bf7535..cf765da6 100644
--- a/main/src/view_model/conversation_details.vala
+++ b/main/src/view_model/conversation_details.vala
@@ -7,6 +7,7 @@ using Gtk;
public class Dino.Ui.ViewModel.ConversationDetails : Object {
public signal void pin_changed();
public signal void block_changed();
+ public signal void domain_block_changed();
public signal void notification_flipped();
public signal void notification_changed(NotificationSetting setting);
@@ -32,6 +33,7 @@ public class Dino.Ui.ViewModel.ConversationDetails : Object {
public bool show_blocked { get; set; }
public bool blocked { get; set; }
+ public bool domain_blocked { get; set; }
public GLib.ListStore preferences_rows = new GLib.ListStore(typeof(PreferencesRow.Any));
public GLib.ListStore about_rows = new GLib.ListStore(typeof(PreferencesRow.Any));
@@ -46,4 +48,5 @@ public class Dino.Ui.Model.ConversationDetails : Object {
public DataForms.DataForm? data_form { get; set; }
public string? data_form_bak;
public bool blocked { get; set; }
-} \ No newline at end of file
+ public bool domain_blocked { get; set; }
+}
diff --git a/main/src/windows/conversation_details.vala b/main/src/windows/conversation_details.vala
index 1dac02c7..02463cbc 100644
--- a/main/src/windows/conversation_details.vala
+++ b/main/src/windows/conversation_details.vala
@@ -11,8 +11,10 @@ namespace Dino.Ui.ConversationDetails {
[GtkChild] public unowned Box about_box;
[GtkChild] public unowned Button pin_button;
[GtkChild] public unowned Adw.ButtonContent pin_button_content;
- [GtkChild] public unowned Button block_button;
+ [GtkChild] public unowned Adw.SplitButton block_button;
[GtkChild] public unowned Adw.ButtonContent block_button_content;
+ [GtkChild] public unowned Button block_domain_button;
+ [GtkChild] public unowned Adw.ButtonContent block_domain_button_content;
[GtkChild] public unowned Button notification_button_toggle;
[GtkChild] public unowned Adw.ButtonContent notification_button_toggle_content;
[GtkChild] public unowned MenuButton notification_button_menu;
@@ -27,16 +29,19 @@ namespace Dino.Ui.ConversationDetails {
install_action("notification.off", null, (widget, action_name) => { ((Dialog) widget).model.notification_changed(ViewModel.ConversationDetails.NotificationSetting.OFF); } );
install_action("notification.highlight", null, (widget, action_name) => { ((Dialog) widget).model.notification_changed(ViewModel.ConversationDetails.NotificationSetting.HIGHLIGHT); } );
install_action("notification.default", null, (widget, action_name) => { ((Dialog) widget).model.notification_changed(ViewModel.ConversationDetails.NotificationSetting.DEFAULT); } );
+ install_action("domain.on", null, (widget, action_name) => { ((Dialog) widget).model.domain_block_changed(); } );
}
construct {
pin_button.clicked.connect(() => { model.pin_changed(); });
block_button.clicked.connect(() => { model.block_changed(); });
+ block_domain_button.clicked.connect(() => { model.domain_block_changed(); });
notification_button_toggle.clicked.connect(() => { model.notification_flipped(); });
notification_button_split.clicked.connect(() => { model.notification_flipped(); });
model.notify["pinned"].connect(update_pinned_button);
model.notify["blocked"].connect(update_blocked_button);
+ model.notify["domain-blocked"].connect(update_blocked_button);
model.notify["notification"].connect(update_notification_button);
model.notify["notification"].connect(update_notification_button_state);
model.notify["notification-options"].connect(update_notification_button_visibility);
@@ -66,11 +71,23 @@ namespace Dino.Ui.ConversationDetails {
private void update_blocked_button() {
block_button_content.icon_name = "dino-block-symbolic";
block_button_content.label = model.blocked ? _("Blocked") : _("Block");
+ block_domain_button_content.label = model.domain_blocked ? _("Domain blocked") : _("Block domain");
+ block_domain_button.visible = false;
if (model.blocked) {
+ block_button.visible = true;
+ block_domain_button.visible = false;
block_button.add_css_class("error");
} else {
block_button.remove_css_class("error");
}
+
+ if (model.domain_blocked) {
+ block_domain_button.visible = true;
+ block_button.visible = false;
+ block_domain_button.add_css_class("error");
+ } else {
+ block_button.visible = true;
+ }
}
private void update_notification_button() {
@@ -229,4 +246,4 @@ namespace Dino.Ui.ConversationDetails {
return preference_group;
}
}
-} \ No newline at end of file
+}