diff options
| author | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2022-05-15 11:50:26 +0200 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2023-10-05 14:32:07 +0200 |
| commit | 366a49a82073a591c9b06979fd2bbb0c102a9581 (patch) | |
| tree | acf4c8044e618257932af5379443cee920af2eef /libdino/src/entity | |
| parent | cc6d8d5930769e48df8b604622afaae93cdaa8ff (diff) | |
| download | dino-366a49a82073a591c9b06979fd2bbb0c102a9581.tar.gz | |
Set up default encryption settings GUI
Diffstat (limited to 'libdino/src/entity')
| -rw-r--r-- | libdino/src/entity/encryption.vala | 23 | ||||
| -rw-r--r-- | libdino/src/entity/settings.vala | 20 |
2 files changed, 42 insertions, 1 deletions
diff --git a/libdino/src/entity/encryption.vala b/libdino/src/entity/encryption.vala index 193d741b..f6427b02 100644 --- a/libdino/src/entity/encryption.vala +++ b/libdino/src/entity/encryption.vala @@ -6,7 +6,28 @@ public enum Encryption { OMEMO, DTLS_SRTP, SRTP, - UNKNOWN, + UNKNOWN; + + public static Encryption parse(string str) { + switch (str) { + case "DINO_ENTITIES_ENCRYPTION_NONE": + return NONE; + case "DINO_ENTITIES_ENCRYPTION_PGP": + return PGP; + case "DINO_ENTITIES_ENCRYPTION_OMEMO": + return OMEMO; + case "DINO_ENTITIES_ENCRYPTION_DTLS_SRTP": + return DTLS_SRTP; + case "DINO_ENTITIES_ENCRYPTION_SRTP": + return SRTP; + case "DINO_ENTITIES_ENCRYPTION_UNKNOWN": + // Fall through. + default: + break; + } + + return UNKNOWN; + } } }
\ No newline at end of file diff --git a/libdino/src/entity/settings.vala b/libdino/src/entity/settings.vala index 97ea5482..716c5f7d 100644 --- a/libdino/src/entity/settings.vala +++ b/libdino/src/entity/settings.vala @@ -12,6 +12,7 @@ public class Settings : Object { notifications_ = col_to_bool_or_default("notifications", true); convert_utf8_smileys_ = col_to_bool_or_default("convert_utf8_smileys", true); check_spelling = col_to_bool_or_default("check_spelling", true); + default_encryption = col_to_encryption_or_default("default_encryption", Encryption.OMEMO); } private bool col_to_bool_or_default(string key, bool def) { @@ -19,6 +20,12 @@ public class Settings : Object { return val != null ? bool.parse(val) : def; } + private Encryption col_to_encryption_or_default(string key, Encryption def) { + var sval = db.settings.value; + string? val = db.settings.select({sval}).with(db.settings.key, "=", key)[sval]; + return val != null ? Encryption.parse(val) : def; + } + private bool send_typing_; public bool send_typing { get { return send_typing_; } @@ -78,6 +85,19 @@ public class Settings : Object { check_spelling_ = value; } } + + private Encryption default_encryption_; + public Encryption default_encryption { + get { return default_encryption_; } + set { + string valstr = value.to_string(); + db.settings.upsert() + .value(db.settings.key, "default_encryption", true) + .value(db.settings.value, valstr) + .perform(); + default_encryption_ = value; + } + } } } |
