Fix OMEMO plugin for latest changes

This commit is contained in:
Marvin W 2017-03-12 00:25:47 +01:00
parent d5ea5172a7
commit 766af21d87
No known key found for this signature in database
GPG key ID: 072E9235DB996F2A

View file

@ -256,7 +256,7 @@ public class Module : XmppStreamModule {
public void start_session_with(XmppStream stream, string bare_jid, int device_id) {
print(@"Asking for bundle from $bare_jid/$device_id\n");
stream.get_module(Pubsub.Module.IDENTITY).request(stream, bare_jid, @"$NODE_BUNDLES:$device_id", new OtherBundleResponseListener(store, device_id));
stream.get_module(Pubsub.Module.IDENTITY).request(stream, bare_jid, @"$NODE_BUNDLES:$device_id", on_other_bundle_result, Tuple.create(store, device_id));
}
public void ignore_device(string jid, int32 device_id) {
@ -276,16 +276,11 @@ public class Module : XmppStreamModule {
}
}
private class OtherBundleResponseListener : Pubsub.RequestResponseListener, Object {
private Store store;
private int device_id;
private static void on_other_bundle_result(XmppStream stream, string jid, string? id, StanzaNode? node, Object? storage) {
Tuple<Store, int> tuple = (Tuple<Store, int>)storage;
Store store = tuple.a;
int device_id = tuple.b;
public OtherBundleResponseListener(Store store, int device_id) {
this.store = store;
this.device_id = device_id;
}
public void on_result(XmppStream stream, string jid, string? id, StanzaNode? node) {
bool fail = false;
if (node == null) {
// Device not registered, shouldn't exist
@ -325,20 +320,13 @@ public class Module : XmppStreamModule {
get_module(stream).ignore_device(jid, device_id);
}
}
}
public void publish_bundles_if_needed(XmppStream stream, string jid) {
stream.get_module(Pubsub.Module.IDENTITY).request(stream, jid, @"$NODE_BUNDLES:$(store.local_registration_id)", new SelfBundleResponseListener(store));
stream.get_module(Pubsub.Module.IDENTITY).request(stream, jid, @"$NODE_BUNDLES:$(store.local_registration_id)", on_self_bundle_result, store);
}
private class SelfBundleResponseListener : Pubsub.RequestResponseListener, Object {
private Store store;
public SelfBundleResponseListener(Store store) {
this.store = store;
}
public void on_result(XmppStream stream, string jid, string? id, StanzaNode? node) {
private static void on_self_bundle_result(XmppStream stream, string jid, string? id, StanzaNode? node, Object? storage) {
Store store = (Store)storage;
Map<int, ECPublicKey> keys = new HashMap<int, ECPublicKey>();
ECPublicKey identity_key = null;
IdentityKeyPair identity_key_pair = null;
@ -400,7 +388,6 @@ public class Module : XmppStreamModule {
publish_bundles(stream, signed_pre_key_record, identity_key_pair, pre_key_records, (int32) store.local_registration_id);
}
}
}
public static void publish_bundles(XmppStream stream, SignedPreKeyRecord signed_pre_key_record, IdentityKeyPair identity_key_pair, Set<PreKeyRecord> pre_key_records, int32 device_id) {
ECKeyPair tmp;