diff options
author | Marvin W <git@larma.de> | 2017-05-13 17:48:13 +0200 |
---|---|---|
committer | Marvin W <git@larma.de> | 2017-08-27 14:52:18 +0200 |
commit | 9840774a87b9d15523ecc04ee4c157270e9abfe5 (patch) | |
tree | e3183522c19cabc787ec969d67a35208cd9c61de /plugins/omemo/src/stream_module.vala | |
parent | ad033beea82a4ba20da71220966b80d5f674428f (diff) | |
download | dino-9840774a87b9d15523ecc04ee4c157270e9abfe5.tar.gz dino-9840774a87b9d15523ecc04ee4c157270e9abfe5.zip |
omemo: store and display identity keys of all devices
Diffstat (limited to 'plugins/omemo/src/stream_module.vala')
-rw-r--r-- | plugins/omemo/src/stream_module.vala | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/plugins/omemo/src/stream_module.vala b/plugins/omemo/src/stream_module.vala index 00cddd0a..46bc0ecf 100644 --- a/plugins/omemo/src/stream_module.vala +++ b/plugins/omemo/src/stream_module.vala @@ -24,6 +24,7 @@ public class StreamModule : XmppStreamModule { public signal void store_created(Store store); public signal void device_list_loaded(string jid); + public signal void bundle_fetched(string jid, int device_id, Bundle bundle); public signal void session_started(string jid, int device_id); public signal void session_start_failed(string jid, int device_id); @@ -183,11 +184,11 @@ public class StreamModule : XmppStreamModule { public void request_user_devicelist(XmppStream stream, string jid) { if (active_devicelist_requests.add(jid)) { if (Plugin.DEBUG) print(@"OMEMO: requesting device list for $jid\n"); - stream.get_module(Pubsub.Module.IDENTITY).request(stream, jid, NODE_DEVICELIST, (stream, jid, id, node) => on_devicelist(stream, jid, id ?? "", node)); + stream.get_module(Pubsub.Module.IDENTITY).request(stream, jid, NODE_DEVICELIST, (stream, jid, id, node) => on_devicelist(stream, jid, id, node)); } } - public void on_devicelist(XmppStream stream, string jid, string id, StanzaNode? node_) { + public void on_devicelist(XmppStream stream, string jid, string? id, StanzaNode? node_) { StanzaNode node = node_ ?? new StanzaNode.build("list", NS_URI).add_self_xmlns(); string? my_jid = stream.get_flag(Bind.Flag.IDENTITY).my_jid; if (my_jid == null) return; @@ -219,7 +220,6 @@ public class StreamModule : XmppStreamModule { public void start_sessions_with(XmppStream stream, string bare_jid) { if (!device_lists.has_key(bare_jid)) { - // TODO: manually request a device list return; } Address address = new Address(bare_jid, 0); @@ -247,6 +247,23 @@ public class StreamModule : XmppStreamModule { } } + public void fetch_bundle(XmppStream stream, string bare_jid, int device_id) { + if (active_bundle_requests.add(bare_jid + @":$device_id")) { + if (Plugin.DEBUG) print(@"OMEMO: Asking for bundle from $bare_jid:$device_id\n"); + stream.get_module(Pubsub.Module.IDENTITY).request(stream, bare_jid, @"$NODE_BUNDLES:$device_id", (stream, jid, id, node) => { + bundle_fetched(jid, device_id, new Bundle(node)); + }); + } + } + + public ArrayList<int32> get_device_list(string jid) { + if (is_known_address(jid)) { + return device_lists[jid]; + } else { + return new ArrayList<int32>(); + } + } + public bool is_known_address(string name) { return device_lists.has_key(name); } @@ -276,6 +293,7 @@ public class StreamModule : XmppStreamModule { fail = true; } else { Bundle bundle = new Bundle(node); + bundle_fetched(jid, device_id, bundle); int32 signed_pre_key_id = bundle.signed_pre_key_id; ECPublicKey? signed_pre_key = bundle.signed_pre_key; uint8[] signed_pre_key_signature = bundle.signed_pre_key_signature; |