Database migration and code cleanup
This commit is contained in:
parent
0bcdae34a5
commit
2a8352c543
|
@ -20,11 +20,12 @@ public class ContactDetailsDialog : Gtk.Dialog {
|
||||||
|
|
||||||
|
|
||||||
private void set_device_trust(Row device, bool trust) {
|
private void set_device_trust(Row device, bool trust) {
|
||||||
|
Database.IdentityMetaTable.TrustLevel trust_level = trust ? Database.IdentityMetaTable.TrustLevel.TRUSTED : Database.IdentityMetaTable.TrustLevel.UNTRUSTED;
|
||||||
plugin.db.identity_meta.update()
|
plugin.db.identity_meta.update()
|
||||||
.with(plugin.db.identity_meta.identity_id, "=", account.id)
|
.with(plugin.db.identity_meta.identity_id, "=", account.id)
|
||||||
.with(plugin.db.identity_meta.address_name, "=", device[plugin.db.identity_meta.address_name])
|
.with(plugin.db.identity_meta.address_name, "=", device[plugin.db.identity_meta.address_name])
|
||||||
.with(plugin.db.identity_meta.device_id, "=", device[plugin.db.identity_meta.device_id])
|
.with(plugin.db.identity_meta.device_id, "=", device[plugin.db.identity_meta.device_id])
|
||||||
.set(plugin.db.identity_meta.trusted_identity, trust).perform();
|
.set(plugin.db.identity_meta.trusted_identity, trust_level).perform();
|
||||||
|
|
||||||
if(!trust) {
|
if(!trust) {
|
||||||
plugin.app.stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).untrust_device(jid, device[plugin.db.identity_meta.device_id]);
|
plugin.app.stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).untrust_device(jid, device[plugin.db.identity_meta.device_id]);
|
||||||
|
@ -33,11 +34,12 @@ public class ContactDetailsDialog : Gtk.Dialog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void add_fingerprint(Row device, int row, bool trust) {
|
private void add_fingerprint(Row device, int row, Database.IdentityMetaTable.TrustLevel trust) {
|
||||||
string res = fingerprint_markup(fingerprint_from_base64(device[plugin.db.identity_meta.identity_key_public_base64]));
|
string res = fingerprint_markup(fingerprint_from_base64(device[plugin.db.identity_meta.identity_key_public_base64]));
|
||||||
Label lbl = new Label(res)
|
Label lbl = new Label(res)
|
||||||
{ use_markup=true, justify=Justification.RIGHT, visible=true, margin = 8, halign = Align.START, valign = Align.CENTER };
|
{ use_markup=true, justify=Justification.RIGHT, visible=true, margin = 8, halign = Align.START, valign = Align.CENTER };
|
||||||
Switch tgl = new Switch() {visible = true, halign = Align.END, valign = Align.CENTER, margin = 8, hexpand = true, active = trust };
|
//TODO: handle display of verified devices
|
||||||
|
Switch tgl = new Switch() {visible = true, halign = Align.END, valign = Align.CENTER, margin = 8, hexpand = true, active = (trust == Database.IdentityMetaTable.TrustLevel.TRUSTED) };
|
||||||
tgl.state_set.connect((active) => {
|
tgl.state_set.connect((active) => {
|
||||||
set_device_trust(device, active);
|
set_device_trust(device, active);
|
||||||
|
|
||||||
|
@ -55,17 +57,17 @@ public class ContactDetailsDialog : Gtk.Dialog {
|
||||||
this.jid = jid;
|
this.jid = jid;
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (Row device in plugin.db.identity_meta.with_address(jid.to_string()).without_null(plugin.db.identity_meta.trusted_identity).with(plugin.db.identity_meta.identity_id, "=", account.id)) {
|
foreach (Row device in plugin.db.identity_meta.with_address(jid.to_string()).with(plugin.db.identity_meta.trusted_identity, "!=", Database.IdentityMetaTable.TrustLevel.UNKNOWN).with(plugin.db.identity_meta.identity_id, "=", account.id)) {
|
||||||
if(device[plugin.db.identity_meta.identity_key_public_base64] == null)
|
if(device[plugin.db.identity_meta.identity_key_public_base64] == null)
|
||||||
continue;
|
continue;
|
||||||
add_fingerprint(device, i, device[plugin.db.identity_meta.trusted_identity]);
|
add_fingerprint(device, i, (Database.IdentityMetaTable.TrustLevel) device[plugin.db.identity_meta.trusted_identity]);
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int j = 0;
|
int j = 0;
|
||||||
foreach (Row device in plugin.db.identity_meta.with_address(jid.to_string()).with_null(plugin.db.identity_meta.trusted_identity).with(plugin.db.identity_meta.identity_id, "=", account.id)) {
|
foreach (Row device in plugin.db.identity_meta.with_address(jid.to_string()).with(plugin.db.identity_meta.trusted_identity, "=", Database.IdentityMetaTable.TrustLevel.UNKNOWN).with(plugin.db.identity_meta.identity_id, "=", account.id)) {
|
||||||
if(device[plugin.db.identity_meta.identity_key_public_base64] == null)
|
if(device[plugin.db.identity_meta.identity_key_public_base64] == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -85,7 +87,7 @@ public class ContactDetailsDialog : Gtk.Dialog {
|
||||||
fingerprints_prompt.remove(lbl);
|
fingerprints_prompt.remove(lbl);
|
||||||
j--;
|
j--;
|
||||||
|
|
||||||
add_fingerprint(device, i, true);
|
add_fingerprint(device, i, Database.IdentityMetaTable.TrustLevel.TRUSTED);
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
if(j == 0)
|
if(j == 0)
|
||||||
|
@ -102,7 +104,7 @@ public class ContactDetailsDialog : Gtk.Dialog {
|
||||||
fingerprints_prompt.remove(lbl);
|
fingerprints_prompt.remove(lbl);
|
||||||
j--;
|
j--;
|
||||||
|
|
||||||
add_fingerprint(device, i, false);
|
add_fingerprint(device, i, Database.IdentityMetaTable.TrustLevel.UNTRUSTED);
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
if(j == 0)
|
if(j == 0)
|
||||||
|
|
|
@ -6,14 +6,27 @@ using Dino.Entities;
|
||||||
namespace Dino.Plugins.Omemo {
|
namespace Dino.Plugins.Omemo {
|
||||||
|
|
||||||
public class Database : Qlite.Database {
|
public class Database : Qlite.Database {
|
||||||
private const int VERSION = 1;
|
private const int VERSION = 2;
|
||||||
|
|
||||||
public class IdentityMetaTable : Table {
|
public class IdentityMetaTable : Table {
|
||||||
public Column<int> identity_id = new Column.Integer("identity_id") { not_null = true };
|
public enum TrustLevel {
|
||||||
|
VERIFIED,
|
||||||
|
TRUSTED,
|
||||||
|
UNTRUSTED,
|
||||||
|
UNKNOWN;
|
||||||
|
|
||||||
|
public string to_string() {
|
||||||
|
int val = this;
|
||||||
|
return val.to_string();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Default to provide backwards compatability
|
||||||
|
public Column<int> identity_id = new Column.Integer("identity_id") { not_null = true, min_version = 2, default = "-1" };
|
||||||
public Column<string> address_name = new Column.Text("address_name") { not_null = true };
|
public Column<string> address_name = new Column.Text("address_name") { not_null = true };
|
||||||
public Column<int> device_id = new Column.Integer("device_id") { not_null = true };
|
public Column<int> device_id = new Column.Integer("device_id") { not_null = true };
|
||||||
public Column<string?> identity_key_public_base64 = new Column.Text("identity_key_public_base64");
|
public Column<string?> identity_key_public_base64 = new Column.Text("identity_key_public_base64");
|
||||||
public Column<bool> trusted_identity = new Column.BoolInt("trusted_identity");
|
public Column<int> trusted_identity = new Column.Integer("trusted_identity") { not_null = true, default = TrustLevel.UNKNOWN.to_string() };
|
||||||
public Column<bool> now_active = new Column.BoolInt("now_active") { default = "1" };
|
public Column<bool> now_active = new Column.BoolInt("now_active") { default = "1" };
|
||||||
public Column<long> last_active = new Column.Long("last_active");
|
public Column<long> last_active = new Column.Long("last_active");
|
||||||
|
|
||||||
|
@ -41,16 +54,14 @@ public class Database : Qlite.Database {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int64 insert_device_bundle(int32 identity_id, string address_name, int device_id, Bundle bundle, bool? trust) {
|
public int64 insert_device_bundle(int32 identity_id, string address_name, int device_id, Bundle bundle, TrustLevel trust) {
|
||||||
if (bundle == null || bundle.identity_key == null) return -1;
|
if (bundle == null || bundle.identity_key == null) return -1;
|
||||||
UpsertBuilder query = upsert()
|
return upsert()
|
||||||
.value(this.identity_id, identity_id, true)
|
.value(this.identity_id, identity_id, true)
|
||||||
.value(this.address_name, address_name, true)
|
.value(this.address_name, address_name, true)
|
||||||
.value(this.device_id, device_id, true)
|
.value(this.device_id, device_id, true)
|
||||||
.value(this.identity_key_public_base64, Base64.encode(bundle.identity_key.serialize()));
|
.value(this.identity_key_public_base64, Base64.encode(bundle.identity_key.serialize()))
|
||||||
if(trust != null)
|
.value(this.trusted_identity, trust).perform();
|
||||||
query.value(this.trusted_identity, trust);
|
|
||||||
return query.perform();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -121,10 +121,10 @@ public class Manager : StreamInteractionModule, Object {
|
||||||
if (Plugin.DEBUG) print(@"OMEMO: message will be delayed: $state\n");
|
if (Plugin.DEBUG) print(@"OMEMO: message will be delayed: $state\n");
|
||||||
|
|
||||||
if (state.waiting_own_sessions > 0) {
|
if (state.waiting_own_sessions > 0) {
|
||||||
module.start_sessions_with((!)stream, conversation.account.bare_jid);
|
module.fetch_bundles((!)stream, conversation.account.bare_jid);
|
||||||
}
|
}
|
||||||
if (state.waiting_other_sessions > 0 && message.counterpart != null) {
|
if (state.waiting_other_sessions > 0 && message.counterpart != null) {
|
||||||
module.start_sessions_with((!)stream, ((!)message.counterpart).bare_jid);
|
module.fetch_bundles((!)stream, ((!)message.counterpart).bare_jid);
|
||||||
}
|
}
|
||||||
if (state.waiting_other_devicelist && message.counterpart != null) {
|
if (state.waiting_other_devicelist && message.counterpart != null) {
|
||||||
module.request_user_devicelist((!)stream, ((!)message.counterpart).bare_jid);
|
module.request_user_devicelist((!)stream, ((!)message.counterpart).bare_jid);
|
||||||
|
@ -138,40 +138,12 @@ public class Manager : StreamInteractionModule, Object {
|
||||||
stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).store_created.connect((store) => on_store_created(account, store));
|
stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).store_created.connect((store) => on_store_created(account, store));
|
||||||
stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).device_list_loaded.connect((jid) => on_device_list_loaded(account, jid));
|
stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).device_list_loaded.connect((jid) => on_device_list_loaded(account, jid));
|
||||||
stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).bundle_fetched.connect((jid, device_id, bundle) => on_bundle_fetched(account, jid, device_id, bundle));
|
stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).bundle_fetched.connect((jid, device_id, bundle) => on_bundle_fetched(account, jid, device_id, bundle));
|
||||||
stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).session_started.connect((jid, device_id) => on_session_started(account, jid, false));
|
|
||||||
stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).session_start_failed.connect((jid, device_id) => on_session_started(account, jid, true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void on_stream_negotiated(Account account, XmppStream stream) {
|
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(stream, account.bare_jid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void on_session_started(Account account, Jid jid, bool failed) {
|
|
||||||
if (Plugin.DEBUG) print(@"OMEMO: session start between $(account.bare_jid) and $jid $(failed ? "failed" : "successful")\n");
|
|
||||||
HashSet<Entities.Message> send_now = new HashSet<Entities.Message>();
|
|
||||||
lock (message_states) {
|
|
||||||
foreach (Entities.Message msg in message_states.keys) {
|
|
||||||
if (!msg.account.equals(account)) continue;
|
|
||||||
MessageState state = message_states[msg];
|
|
||||||
if (account.bare_jid.equals(jid)) {
|
|
||||||
state.waiting_own_sessions--;
|
|
||||||
} else if (msg.counterpart != null && msg.counterpart.equals_bare(jid)) {
|
|
||||||
state.waiting_other_sessions--;
|
|
||||||
}
|
|
||||||
if (state.should_retry_now()) {
|
|
||||||
send_now.add(msg);
|
|
||||||
state.active_send_attempt = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach (Entities.Message msg in send_now) {
|
|
||||||
if (msg.counterpart == null) continue;
|
|
||||||
Entities.Conversation? conv = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation((!)msg.counterpart, account);
|
|
||||||
if (conv == null) continue;
|
|
||||||
stream_interactor.get_module(MessageProcessor.IDENTITY).send_xmpp_message(msg, (!)conv, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void on_device_list_loaded(Account account, Jid jid) {
|
private void on_device_list_loaded(Account account, Jid jid) {
|
||||||
if (Plugin.DEBUG) print(@"OMEMO: received device list for $(account.bare_jid) from $jid\n");
|
if (Plugin.DEBUG) print(@"OMEMO: received device list for $(account.bare_jid) from $jid\n");
|
||||||
HashSet<Entities.Message> send_now = new HashSet<Entities.Message>();
|
HashSet<Entities.Message> send_now = new HashSet<Entities.Message>();
|
||||||
|
@ -231,30 +203,21 @@ public class Manager : StreamInteractionModule, Object {
|
||||||
.with(db.identity_meta.identity_key_public_base64, "=", Base64.encode(bundle.identity_key.serialize()))
|
.with(db.identity_meta.identity_key_public_base64, "=", Base64.encode(bundle.identity_key.serialize()))
|
||||||
.count() > 0);
|
.count() > 0);
|
||||||
|
|
||||||
bool? trusted = null;
|
Database.IdentityMetaTable.TrustLevel trusted = Database.IdentityMetaTable.TrustLevel.UNKNOWN;
|
||||||
foreach(Row row in db.identity_meta.with_address(jid.bare_jid.to_string())
|
foreach(Row row in db.identity_meta.with_address(jid.bare_jid.to_string())
|
||||||
.with(db.identity_meta.identity_id, "=", account.id)
|
.with(db.identity_meta.identity_id, "=", account.id)
|
||||||
.with(db.identity_meta.device_id, "=", device_id)) {
|
.with(db.identity_meta.device_id, "=", device_id)) {
|
||||||
trusted = row[db.identity_meta.trusted_identity];
|
trusted = (Database.IdentityMetaTable.TrustLevel) row[db.identity_meta.trusted_identity];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(db.identity_meta.with_address(jid.bare_jid.to_string())
|
|
||||||
.with(db.identity_meta.identity_id, "=", account.id)
|
|
||||||
.with(db.identity_meta.device_id, "=", device_id)
|
|
||||||
.with_null(db.identity_meta.trusted_identity).count() > 0)
|
|
||||||
trusted = null;
|
|
||||||
|
|
||||||
if(untrust)
|
if(untrust)
|
||||||
trusted = null;
|
trusted = Database.IdentityMetaTable.TrustLevel.UNKNOWN;
|
||||||
else if (blind_trust && trusted == null)
|
else if (blind_trust && trusted == Database.IdentityMetaTable.TrustLevel.UNKNOWN)
|
||||||
trusted = true;
|
trusted = Database.IdentityMetaTable.TrustLevel.TRUSTED;
|
||||||
|
|
||||||
db.identity_meta.insert_device_bundle(account.id, jid.bare_jid.to_string(), device_id, bundle, trusted);
|
db.identity_meta.insert_device_bundle(account.id, jid.bare_jid.to_string(), device_id, bundle, trusted);
|
||||||
|
|
||||||
if(trusted == null)
|
|
||||||
trusted = false;
|
|
||||||
|
|
||||||
XmppStream? stream = stream_interactor.get_stream(account);
|
XmppStream? stream = stream_interactor.get_stream(account);
|
||||||
if(stream == null) return;
|
if(stream == null) return;
|
||||||
StreamModule? module = ((!)stream).get_module(StreamModule.IDENTITY);
|
StreamModule? module = ((!)stream).get_module(StreamModule.IDENTITY);
|
||||||
|
@ -268,11 +231,11 @@ public class Manager : StreamInteractionModule, Object {
|
||||||
if (!msg.account.equals(account)) continue;
|
if (!msg.account.equals(account)) continue;
|
||||||
MessageState state = message_states[msg];
|
MessageState state = message_states[msg];
|
||||||
|
|
||||||
if (trusted != true) {
|
if (trusted != Database.IdentityMetaTable.TrustLevel.TRUSTED && trusted != Database.IdentityMetaTable.TrustLevel.VERIFIED) {
|
||||||
module.untrust_device(jid, device_id);
|
module.untrust_device(jid, device_id);
|
||||||
} else {
|
} else {
|
||||||
if(account.bare_jid.equals(jid) || (msg.counterpart != null && msg.counterpart.equals_bare(jid)))
|
if(account.bare_jid.equals(jid) || (msg.counterpart != null && msg.counterpart.equals_bare(jid)))
|
||||||
session_created = module.create_session_if_needed(stream, jid, device_id, bundle);
|
session_created = module.start_session(stream, jid, device_id, bundle);
|
||||||
}
|
}
|
||||||
if (account.bare_jid.equals(jid) && session_created) {
|
if (account.bare_jid.equals(jid) && session_created) {
|
||||||
state.waiting_own_sessions--;
|
state.waiting_own_sessions--;
|
||||||
|
|
|
@ -26,8 +26,6 @@ public class StreamModule : XmppStreamModule {
|
||||||
public signal void store_created(Store store);
|
public signal void store_created(Store store);
|
||||||
public signal void device_list_loaded(Jid jid);
|
public signal void device_list_loaded(Jid jid);
|
||||||
public signal void bundle_fetched(Jid jid, int device_id, Bundle bundle);
|
public signal void bundle_fetched(Jid jid, int device_id, Bundle bundle);
|
||||||
public signal void session_started(Jid jid, int device_id);
|
|
||||||
public signal void session_start_failed(Jid jid, int device_id);
|
|
||||||
|
|
||||||
public EncryptState encrypt(MessageStanza message, Jid self_jid) {
|
public EncryptState encrypt(MessageStanza message, Jid self_jid) {
|
||||||
EncryptState status = new EncryptState();
|
EncryptState status = new EncryptState();
|
||||||
|
@ -181,7 +179,7 @@ public class StreamModule : XmppStreamModule {
|
||||||
device_list_loaded(jid);
|
device_list_loaded(jid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start_sessions_with(XmppStream stream, Jid jid) {
|
public void fetch_bundles(XmppStream stream, Jid jid) {
|
||||||
if (!device_lists.has_key(jid)) {
|
if (!device_lists.has_key(jid)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -191,7 +189,7 @@ public class StreamModule : XmppStreamModule {
|
||||||
address.device_id = device_id;
|
address.device_id = device_id;
|
||||||
try {
|
try {
|
||||||
if (!store.contains_session(address)) {
|
if (!store.contains_session(address)) {
|
||||||
start_session_with(stream, jid, device_id);
|
fetch_bundle(stream, jid, device_id);
|
||||||
}
|
}
|
||||||
} catch (Error e) {
|
} catch (Error e) {
|
||||||
// Ignore
|
// Ignore
|
||||||
|
@ -201,21 +199,11 @@ public class StreamModule : XmppStreamModule {
|
||||||
address.device_id = 0;
|
address.device_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start_session_with(XmppStream stream, Jid jid, int device_id) {
|
|
||||||
if (active_bundle_requests.add(jid.bare_jid.to_string() + @":$device_id")) {
|
|
||||||
if (Plugin.DEBUG) print(@"OMEMO: Asking for bundle from $(jid.bare_jid.to_string()):$device_id\n");
|
|
||||||
stream.get_module(Pubsub.Module.IDENTITY).request(stream, jid.bare_jid, @"$NODE_BUNDLES:$device_id", (stream, jid, id, node) => {
|
|
||||||
on_other_bundle_result(stream, jid, device_id, id, node);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void fetch_bundle(XmppStream stream, Jid jid, int device_id) {
|
public void fetch_bundle(XmppStream stream, Jid jid, int device_id) {
|
||||||
if (active_bundle_requests.add(jid.bare_jid.to_string() + @":$device_id")) {
|
if (active_bundle_requests.add(jid.bare_jid.to_string() + @":$device_id")) {
|
||||||
if (Plugin.DEBUG) print(@"OMEMO: Asking for bundle from $(jid.bare_jid.to_string()):$device_id\n");
|
if (Plugin.DEBUG) print(@"OMEMO: Asking for bundle from $(jid.bare_jid.to_string()):$device_id\n");
|
||||||
stream.get_module(Pubsub.Module.IDENTITY).request(stream, jid.bare_jid, @"$NODE_BUNDLES:$device_id", (stream, jid, id, node) => {
|
stream.get_module(Pubsub.Module.IDENTITY).request(stream, jid.bare_jid, @"$NODE_BUNDLES:$device_id", (stream, jid, id, node) => {
|
||||||
stream.get_module(IDENTITY).active_bundle_requests.remove(jid.bare_jid.to_string() + @":$device_id");
|
on_other_bundle_result(stream, jid, device_id, id, node);
|
||||||
bundle_fetched(jid, device_id, new Bundle(node));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -240,7 +228,6 @@ public class StreamModule : XmppStreamModule {
|
||||||
}
|
}
|
||||||
ignored_devices[jid].add(device_id);
|
ignored_devices[jid].add(device_id);
|
||||||
}
|
}
|
||||||
//session_start_failed(jid, device_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool is_ignored_device(Jid jid, int32 device_id) {
|
public bool is_ignored_device(Jid jid, int32 device_id) {
|
||||||
|
@ -261,7 +248,7 @@ public class StreamModule : XmppStreamModule {
|
||||||
stream.get_module(IDENTITY).active_bundle_requests.remove(jid.bare_jid.to_string() + @":$device_id");
|
stream.get_module(IDENTITY).active_bundle_requests.remove(jid.bare_jid.to_string() + @":$device_id");
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool create_session_if_needed(XmppStream stream, Jid jid, int32 device_id, Bundle bundle) {
|
public bool start_session(XmppStream stream, Jid jid, int32 device_id, Bundle bundle) {
|
||||||
bool fail = false;
|
bool fail = false;
|
||||||
int32 signed_pre_key_id = bundle.signed_pre_key_id;
|
int32 signed_pre_key_id = bundle.signed_pre_key_id;
|
||||||
ECPublicKey? signed_pre_key = bundle.signed_pre_key;
|
ECPublicKey? signed_pre_key = bundle.signed_pre_key;
|
||||||
|
@ -285,7 +272,6 @@ public class StreamModule : XmppStreamModule {
|
||||||
}
|
}
|
||||||
SessionBuilder builder = store.create_session_builder(address);
|
SessionBuilder builder = store.create_session_builder(address);
|
||||||
builder.process_pre_key_bundle(create_pre_key_bundle(device_id, device_id, pre_key_id, pre_key, signed_pre_key_id, signed_pre_key, signed_pre_key_signature, identity_key));
|
builder.process_pre_key_bundle(create_pre_key_bundle(device_id, device_id, pre_key_id, pre_key, signed_pre_key_id, signed_pre_key, signed_pre_key_signature, identity_key));
|
||||||
//stream.get_module(IDENTITY).session_started(jid, device_id);
|
|
||||||
} catch (Error e) {
|
} catch (Error e) {
|
||||||
fail = true;
|
fail = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,10 +95,12 @@ public class Table {
|
||||||
public void create_table_at_version(long version) {
|
public void create_table_at_version(long version) {
|
||||||
ensure_init();
|
ensure_init();
|
||||||
string sql = @"CREATE TABLE IF NOT EXISTS $name (";
|
string sql = @"CREATE TABLE IF NOT EXISTS $name (";
|
||||||
|
bool first = true;
|
||||||
for (int i = 0; i < columns.length; i++) {
|
for (int i = 0; i < columns.length; i++) {
|
||||||
Column c = columns[i];
|
Column c = columns[i];
|
||||||
if (c.min_version <= version && c.max_version >= version) {
|
if (c.min_version <= version && c.max_version >= version) {
|
||||||
sql += @"$(i > 0 ? "," : "") $c";
|
sql += @"$(!first ? "," : "") $c";
|
||||||
|
first = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sql += @"$constraints)";
|
sql += @"$constraints)";
|
||||||
|
|
Loading…
Reference in a new issue