From 8944029128e3d0f9e32b61e00e880d92fceabb31 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Tue, 5 Sep 2017 23:53:18 +0200 Subject: Move encryption menu into ChatInput, PGP support for MUCs --- plugins/openpgp/src/encryption_list_entry.vala | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'plugins/openpgp/src/encryption_list_entry.vala') diff --git a/plugins/openpgp/src/encryption_list_entry.vala b/plugins/openpgp/src/encryption_list_entry.vala index 584e065b..e0a11865 100644 --- a/plugins/openpgp/src/encryption_list_entry.vala +++ b/plugins/openpgp/src/encryption_list_entry.vala @@ -1,3 +1,5 @@ +using Gee; + using Dino.Entities; namespace Dino.Plugins.OpenPgp { @@ -19,8 +21,23 @@ private class EncryptionListEntry : Plugins.EncryptionListEntry, Object { }} public bool can_encrypt(Entities.Conversation conversation) { - string? key_id = stream_interactor.get_module(Manager.IDENTITY).get_key_id(conversation.account, conversation.counterpart); - return key_id != null && GPGHelper.get_keylist(key_id).size > 0; + if (conversation.type_ == Conversation.Type.CHAT) { + string? key_id = stream_interactor.get_module(Manager.IDENTITY).get_key_id(conversation.account, conversation.counterpart); + return key_id != null && GPGHelper.get_keylist(key_id).size > 0; + } else if (conversation.type_ == Conversation.Type.GROUPCHAT) { + Gee.List muc_jids = new Gee.ArrayList(); + Gee.List? occupants = stream_interactor.get_module(MucManager.IDENTITY).get_occupants(conversation.counterpart, conversation.account); + if (occupants != null) muc_jids.add_all(occupants); + Gee.List? offline_members = stream_interactor.get_module(MucManager.IDENTITY).get_offline_members(conversation.counterpart, conversation.account); + if (occupants != null) muc_jids.add_all(offline_members); + + foreach (Jid jid in muc_jids) { + string? key_id = stream_interactor.get_module(Manager.IDENTITY).get_key_id(conversation.account, jid); + if (key_id == null) return false; + } + return true; + } + return false; } } -- cgit v1.2.3-70-g09d2