diff options
Diffstat (limited to 'plugins/omemo/src')
-rw-r--r-- | plugins/omemo/src/file_transfer/file_decryptor.vala | 2 | ||||
-rw-r--r-- | plugins/omemo/src/logic/manager.vala | 36 | ||||
-rw-r--r-- | plugins/omemo/src/protocol/stream_module.vala | 8 |
3 files changed, 20 insertions, 26 deletions
diff --git a/plugins/omemo/src/file_transfer/file_decryptor.vala b/plugins/omemo/src/file_transfer/file_decryptor.vala index dcb65301..6998fef2 100644 --- a/plugins/omemo/src/file_transfer/file_decryptor.vala +++ b/plugins/omemo/src/file_transfer/file_decryptor.vala @@ -15,7 +15,7 @@ public class OmemoFileDecryptor : FileDecryptor, Object { public FileReceiveData prepare_get_meta_info(Conversation conversation, FileTransfer file_transfer, FileReceiveData receive_data) { HttpFileReceiveData? http_receive_data = receive_data as HttpFileReceiveData; if (http_receive_data == null) assert(false); -// if ((receive_data as OmemoHttpFileReceiveData) != null) return receive_data; + if ((receive_data as OmemoHttpFileReceiveData) != null) return receive_data; var omemo_http_receive_data = new OmemoHttpFileReceiveData(); omemo_http_receive_data.url = aesgcm_to_https_link(http_receive_data.url); diff --git a/plugins/omemo/src/logic/manager.vala b/plugins/omemo/src/logic/manager.vala index 3fe41a35..a71dfd9d 100644 --- a/plugins/omemo/src/logic/manager.vala +++ b/plugins/omemo/src/logic/manager.vala @@ -71,6 +71,13 @@ public class Manager : StreamInteractionModule, Object { stream_interactor.get_module(RosterManager.IDENTITY).mutual_subscription.connect(on_mutual_subscription); } + public void clear_device_list(Account account) { + XmppStream? stream = stream_interactor.get_stream(account); + if (stream == null) return; + + stream.get_module(StreamModule.IDENTITY).clear_device_list(stream); + } + private Gee.List<Jid> get_occupants(Jid jid, Account account){ Gee.List<Jid> occupants = new ArrayList<Jid>(Jid.equals_bare_func); if(!stream_interactor.get_module(MucManager.IDENTITY).is_groupchat(jid, account)){ @@ -234,7 +241,7 @@ public class Manager : StreamInteractionModule, Object { } - public void on_bundle_fetched(Account account, Jid jid, int32 device_id, Bundle bundle) { + private void on_bundle_fetched(Account account, Jid jid, int32 device_id, Bundle bundle) { int identity_id = db.identity.get_id(account.id); if (identity_id < 0) return; @@ -356,26 +363,6 @@ public class Manager : StreamInteractionModule, Object { } } - - public bool can_encrypt(Entities.Conversation conversation) { - if (stream_interactor.get_module(MucManager.IDENTITY).is_public_room(conversation.account, conversation.counterpart)){ - debug("Can't enable OMEMO for %s: Room not members-only or non-anonymous", conversation.counterpart.to_string()); - return false; - } - - if (stream_interactor.get_module(MucManager.IDENTITY).is_private_room(conversation.account, conversation.counterpart)){ - foreach(Jid jid in stream_interactor.get_module(MucManager.IDENTITY).get_offline_members(conversation.counterpart, conversation.account)) { - if (!trust_manager.is_known_address(conversation.account, jid.bare_jid)) { - debug("Can't enable OMEMO for %s: missing keys for %s", conversation.counterpart.to_string(), jid.bare_jid.to_string()); - return false; - } - } - return true; - } - - 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)) { @@ -393,8 +380,11 @@ public class Manager : StreamInteractionModule, Object { 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; + if (stream != null) { + var device_list = yield stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).request_user_devicelist(stream, jid); + return device_list.size > 0; + } + return true; // TODO wait for stream? } public static void start(StreamInteractor stream_interactor, Database db, TrustManager trust_manager) { diff --git a/plugins/omemo/src/protocol/stream_module.vala b/plugins/omemo/src/protocol/stream_module.vala index 258ff8c0..824098ba 100644 --- a/plugins/omemo/src/protocol/stream_module.vala +++ b/plugins/omemo/src/protocol/stream_module.vala @@ -74,7 +74,7 @@ public class StreamModule : XmppStreamModule { if (!am_on_devicelist) { debug("Not on device list, adding id"); node.put_node(new StanzaNode.build("device", NS_URI).put_attribute("id", store.local_registration_id.to_string())); - stream.get_module(Pubsub.Module.IDENTITY).publish(stream, jid, NODE_DEVICELIST, NODE_DEVICELIST, id, node); + stream.get_module(Pubsub.Module.IDENTITY).publish(stream, jid, NODE_DEVICELIST, id, node, Xmpp.Xep.Pubsub.ACCESS_MODEL_OPEN); } publish_bundles_if_needed(stream, jid); } @@ -130,6 +130,10 @@ public class StreamModule : XmppStreamModule { } } + public void clear_device_list(XmppStream stream) { + stream.get_module(Pubsub.Module.IDENTITY).delete_node(stream, null, NODE_DEVICELIST); + } + private void on_other_bundle_result(XmppStream stream, Jid jid, int device_id, string? id, StanzaNode? node) { if (node == null) { // Device not registered, shouldn't exist @@ -276,7 +280,7 @@ public class StreamModule : XmppStreamModule { } bundle.put_node(prekeys); - stream.get_module(Pubsub.Module.IDENTITY).publish(stream, null, @"$NODE_BUNDLES:$device_id", @"$NODE_BUNDLES:$device_id", "1", bundle); + stream.get_module(Pubsub.Module.IDENTITY).publish(stream, null, @"$NODE_BUNDLES:$device_id", "1", bundle, Xmpp.Xep.Pubsub.ACCESS_MODEL_OPEN); } public override string get_ns() { |