aboutsummaryrefslogtreecommitdiff
path: root/plugins/omemo/src/ui
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2019-08-02 03:15:12 +0200
committerfiaxh <git@lightrise.org>2019-08-02 19:20:04 +0200
commit08a5088c16ae0bd69adc42ac6489adde3a9ad13f (patch)
treed68d0600e320e662876ffecdd8d8b00c20e4c5a4 /plugins/omemo/src/ui
parent9ee9661bf3616603d9d92590fa1556840fe18970 (diff)
downloaddino-08a5088c16ae0bd69adc42ac6489adde3a9ad13f.tar.gz
dino-08a5088c16ae0bd69adc42ac6489adde3a9ad13f.zip
Rework encryption enabling logic + UI
Diffstat (limited to 'plugins/omemo/src/ui')
-rw-r--r--plugins/omemo/src/ui/encryption_list_entry.vala28
1 files changed, 25 insertions, 3 deletions
diff --git a/plugins/omemo/src/ui/encryption_list_entry.vala b/plugins/omemo/src/ui/encryption_list_entry.vala
index 2e8905e2..a4891442 100644
--- a/plugins/omemo/src/ui/encryption_list_entry.vala
+++ b/plugins/omemo/src/ui/encryption_list_entry.vala
@@ -1,3 +1,5 @@
+using Xmpp;
+
namespace Dino.Plugins.Omemo {
public class EncryptionListEntry : Plugins.EncryptionListEntry, Object {
@@ -15,9 +17,29 @@ public class EncryptionListEntry : Plugins.EncryptionListEntry, Object {
return "OMEMO";
}}
- public bool can_encrypt(Entities.Conversation conversation) {
- return plugin.app.stream_interactor.get_module(Manager.IDENTITY).can_encrypt(conversation);
+ public void encryption_activated(Entities.Conversation conversation, Plugins.SetInputFieldStatus input_status_callback) {
+ encryption_activated_async.begin(conversation, input_status_callback);
}
-}
+ public async void encryption_activated_async(Entities.Conversation conversation, Plugins.SetInputFieldStatus input_status_callback) {
+ MucManager muc_manager = plugin.app.stream_interactor.get_module(MucManager.IDENTITY);
+ Manager omemo_manager = plugin.app.stream_interactor.get_module(Manager.IDENTITY);
+
+ if (muc_manager.is_private_room(conversation.account, conversation.counterpart)) {
+ foreach (Jid offline_member in muc_manager.get_offline_members(conversation.counterpart, conversation.account)) {
+ bool ok = yield omemo_manager.ensure_get_keys_for_jid(conversation.account, offline_member);
+ if (!ok) {
+ input_status_callback(new Plugins.InputFieldStatus("A member does not support OMEMO: %s".printf(offline_member.to_string()), Plugins.InputFieldStatus.MessageType.ERROR, Plugins.InputFieldStatus.InputState.NO_SEND));
+ return;
+ }
+ }
+ return;
+ }
+
+ if (!(yield omemo_manager.ensure_get_keys_for_jid(conversation.account, conversation.counterpart.bare_jid))) {
+ input_status_callback(new Plugins.InputFieldStatus("This contact does not support %s encryption".printf("OMEMO"), Plugins.InputFieldStatus.MessageType.ERROR, Plugins.InputFieldStatus.InputState.NO_SEND));
+ }
+ }
+
+}
}