aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2020-06-10 23:40:00 +0200
committerfiaxh <git@lightrise.org>2020-06-10 23:40:00 +0200
commit0beb592c5a6a2767e11a892bdb5ac9bcc5283c38 (patch)
treebea2894d322472292590ec126dc1b52543a10a7e /plugins
parent50c55c7f55aff6622d242bdcf2b58d5f7956f28e (diff)
downloaddino-0beb592c5a6a2767e11a892bdb5ac9bcc5283c38.tar.gz
dino-0beb592c5a6a2767e11a892bdb5ac9bcc5283c38.zip
Use sqlite UPSERT
Diffstat (limited to 'plugins')
-rw-r--r--plugins/omemo/src/logic/manager.vala4
-rw-r--r--plugins/omemo/src/logic/pre_key_store.vala6
-rw-r--r--plugins/omemo/src/logic/session_store.vala8
-rw-r--r--plugins/omemo/src/logic/signed_pre_key_store.vala6
-rw-r--r--plugins/openpgp/CMakeLists.txt2
-rw-r--r--plugins/openpgp/src/database.vala8
6 files changed, 17 insertions, 17 deletions
diff --git a/plugins/omemo/src/logic/manager.vala b/plugins/omemo/src/logic/manager.vala
index 4bb85d59..e561bd90 100644
--- a/plugins/omemo/src/logic/manager.vala
+++ b/plugins/omemo/src/logic/manager.vala
@@ -352,8 +352,8 @@ public class Manager : StreamInteractionModule, Object {
store.identity_key_store.identity_key_private = new Bytes(key_pair.private.serialize());
store.identity_key_store.identity_key_public = new Bytes(key_pair.public.serialize());
- identity_id = (int) db.identity.insert().or("REPLACE")
- .value(db.identity.account_id, account.id)
+ identity_id = (int) db.identity.upsert()
+ .value(db.identity.account_id, account.id, true)
.value(db.identity.device_id, (int) store.local_registration_id)
.value(db.identity.identity_key_private_base64, Base64.encode(store.identity_key_store.identity_key_private.get_data()))
.value(db.identity.identity_key_public_base64, Base64.encode(store.identity_key_store.identity_key_public.get_data()))
diff --git a/plugins/omemo/src/logic/pre_key_store.vala b/plugins/omemo/src/logic/pre_key_store.vala
index 716fd32f..27e5c01d 100644
--- a/plugins/omemo/src/logic/pre_key_store.vala
+++ b/plugins/omemo/src/logic/pre_key_store.vala
@@ -27,9 +27,9 @@ private class BackedPreKeyStore : SimplePreKeyStore {
}
public void on_pre_key_stored(PreKeyStore.Key key) {
- db.pre_key.insert().or("REPLACE")
- .value(db.pre_key.identity_id, identity_id)
- .value(db.pre_key.pre_key_id, (int) key.key_id)
+ db.pre_key.upsert()
+ .value(db.pre_key.identity_id, identity_id, true)
+ .value(db.pre_key.pre_key_id, (int) key.key_id, true)
.value(db.pre_key.record_base64, Base64.encode(key.record))
.perform();
}
diff --git a/plugins/omemo/src/logic/session_store.vala b/plugins/omemo/src/logic/session_store.vala
index 654591d1..2c7ef642 100644
--- a/plugins/omemo/src/logic/session_store.vala
+++ b/plugins/omemo/src/logic/session_store.vala
@@ -29,10 +29,10 @@ private class BackedSessionStore : SimpleSessionStore {
}
public void on_session_stored(SessionStore.Session session) {
- db.session.insert().or("REPLACE")
- .value(db.session.identity_id, identity_id)
- .value(db.session.address_name, session.name)
- .value(db.session.device_id, session.device_id)
+ db.session.upsert()
+ .value(db.session.identity_id, identity_id, true)
+ .value(db.session.address_name, session.name, true)
+ .value(db.session.device_id, session.device_id, true)
.value(db.session.record_base64, Base64.encode(session.record))
.perform();
}
diff --git a/plugins/omemo/src/logic/signed_pre_key_store.vala b/plugins/omemo/src/logic/signed_pre_key_store.vala
index 8ff54a93..08f115c9 100644
--- a/plugins/omemo/src/logic/signed_pre_key_store.vala
+++ b/plugins/omemo/src/logic/signed_pre_key_store.vala
@@ -27,9 +27,9 @@ private class BackedSignedPreKeyStore : SimpleSignedPreKeyStore {
}
public void on_signed_pre_key_stored(SignedPreKeyStore.Key key) {
- db.signed_pre_key.insert().or("REPLACE")
- .value(db.signed_pre_key.identity_id, identity_id)
- .value(db.signed_pre_key.signed_pre_key_id, (int) key.key_id)
+ db.signed_pre_key.upsert()
+ .value(db.signed_pre_key.identity_id, identity_id, true)
+ .value(db.signed_pre_key.signed_pre_key_id, (int) key.key_id, true)
.value(db.signed_pre_key.record_base64, Base64.encode(key.record))
.perform();
}
diff --git a/plugins/openpgp/CMakeLists.txt b/plugins/openpgp/CMakeLists.txt
index 3f7c1974..769d517d 100644
--- a/plugins/openpgp/CMakeLists.txt
+++ b/plugins/openpgp/CMakeLists.txt
@@ -6,7 +6,7 @@ gettext_compile(${GETTEXT_PACKAGE} SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/po TAR
find_packages(OPENPGP_PACKAGES REQUIRED
Gee
- GLib>=2.38
+ GLib
GModule
GObject
GTK3
diff --git a/plugins/openpgp/src/database.vala b/plugins/openpgp/src/database.vala
index 52005651..2bda06af 100644
--- a/plugins/openpgp/src/database.vala
+++ b/plugins/openpgp/src/database.vala
@@ -39,8 +39,8 @@ public class Database : Qlite.Database {
}
public void set_contact_key(Jid jid, string key) {
- contact_key_table.insert().or("REPLACE")
- .value(contact_key_table.jid, jid.to_string())
+ contact_key_table.upsert()
+ .value(contact_key_table.jid, jid.to_string(), true)
.value(contact_key_table.key, key)
.perform();
}
@@ -51,8 +51,8 @@ public class Database : Qlite.Database {
}
public void set_account_key(Account account, string key) {
- account_setting_table.insert().or("REPLACE")
- .value(account_setting_table.account_id, account.id)
+ account_setting_table.upsert()
+ .value(account_setting_table.account_id, account.id, true)
.value(account_setting_table.key, key)
.perform();
}