diff --git a/libdino/src/entity/conversation.vala b/libdino/src/entity/conversation.vala
index a1e0081d..9535cdd0 100644
--- a/libdino/src/entity/conversation.vala
+++ b/libdino/src/entity/conversation.vala
@@ -35,7 +35,7 @@ public class Conversation : Object {
}
}
}
- public Encryption encryption { get; set; default = Encryption.NONE; }
+ public Encryption encryption { get; set; default = Encryption.UNKNOWN; }
public Message? read_up_to { get; set; }
public int read_up_to_item { get; set; default=-1; }
diff --git a/libdino/src/entity/encryption.vala b/libdino/src/entity/encryption.vala
index ab5a0ae0..6868def4 100644
--- a/libdino/src/entity/encryption.vala
+++ b/libdino/src/entity/encryption.vala
@@ -11,6 +11,27 @@ namespace Dino.Entities {
public bool is_some() {
return this != NONE;
}
+
+ 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 0b09e9b9..dbad9650 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.UNKNOWN);
}
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_; }
@@ -79,6 +86,20 @@ 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;
+ }
+ }
+
}
}
diff --git a/main/data/settings_dialog.ui b/main/data/settings_dialog.ui
index a8b24135..44f3e81f 100644
--- a/main/data/settings_dialog.ui
+++ b/main/data/settings_dialog.ui
@@ -7,6 +7,49 @@
False