diff options
author | fiaxh <git@lightrise.org> | 2019-08-02 03:15:12 +0200 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2019-08-02 19:20:04 +0200 |
commit | 08a5088c16ae0bd69adc42ac6489adde3a9ad13f (patch) | |
tree | d68d0600e320e662876ffecdd8d8b00c20e4c5a4 /plugins/omemo/src/logic/manager.vala | |
parent | 9ee9661bf3616603d9d92590fa1556840fe18970 (diff) | |
download | dino-08a5088c16ae0bd69adc42ac6489adde3a9ad13f.tar.gz dino-08a5088c16ae0bd69adc42ac6489adde3a9ad13f.zip |
Rework encryption enabling logic + UI
Diffstat (limited to 'plugins/omemo/src/logic/manager.vala')
-rw-r--r-- | plugins/omemo/src/logic/manager.vala | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/plugins/omemo/src/logic/manager.vala b/plugins/omemo/src/logic/manager.vala index b8862ab8..3fe41a35 100644 --- a/plugins/omemo/src/logic/manager.vala +++ b/plugins/omemo/src/logic/manager.vala @@ -149,7 +149,7 @@ public class Manager : StreamInteractionModule, Object { } if (state.waiting_other_devicelists > 0 && message.counterpart != null) { foreach(Jid jid in get_occupants(((!)message.counterpart).bare_jid, conversation.account)) { - module.request_user_devicelist((!)stream, jid); + module.request_user_devicelist.begin((!)stream, jid); } } } @@ -161,7 +161,7 @@ public class Manager : StreamInteractionModule, Object { XmppStream? stream = stream_interactor.get_stream(account); if(stream == null) return; - stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).request_user_devicelist((!)stream, jid); + stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).request_user_devicelist.begin((!)stream, jid); } private void on_account_added(Account account) { @@ -171,7 +171,7 @@ public class Manager : StreamInteractionModule, Object { } private void on_stream_negotiated(Account account, XmppStream stream) { - stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).request_user_devicelist(stream, account.bare_jid); + stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).request_user_devicelist.begin(stream, account.bare_jid); } private void on_device_list_loaded(Account account, Jid jid, ArrayList<int32> device_list) { @@ -352,7 +352,7 @@ public class Manager : StreamInteractionModule, Object { if (stream == null) return; StreamModule? module = ((!)stream).get_module(StreamModule.IDENTITY); if(module == null) return; - module.request_user_devicelist(stream, account.bare_jid); + module.request_user_devicelist.begin(stream, account.bare_jid); } } @@ -376,6 +376,27 @@ public class Manager : StreamInteractionModule, Object { return trust_manager.is_known_address(conversation.account, conversation.counterpart.bare_jid); } + public async bool ensure_get_keys_for_conversation(Conversation conversation) { + if (stream_interactor.get_module(MucManager.IDENTITY).is_private_room(conversation.account, conversation.counterpart)) { + foreach (Jid offline_member in stream_interactor.get_module(MucManager.IDENTITY).get_offline_members(conversation.counterpart, conversation.account)) { + bool ok = yield ensure_get_keys_for_jid(conversation.account, offline_member); + if (!ok) { + return false; + } + } + return true; + } + + return yield ensure_get_keys_for_jid(conversation.account, conversation.counterpart.bare_jid); + } + + public async bool ensure_get_keys_for_jid(Account account, Jid jid) { + if (trust_manager.is_known_address(account, jid)) return true; + XmppStream? stream = stream_interactor.get_stream(account); + var device_list = yield stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).request_user_devicelist((!)stream, jid); + return device_list.size > 0; + } + public static void start(StreamInteractor stream_interactor, Database db, TrustManager trust_manager) { Manager m = new Manager(stream_interactor, db, trust_manager); stream_interactor.add_module(m); |