mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 12:29:19 -08:00
115 lines
5.2 KiB
Diff
115 lines
5.2 KiB
Diff
From cee5e27b157081a3ce55869bd5f649560a6127ea Mon Sep 17 00:00:00 2001
|
|
From: lumi <lumi@pew.im>
|
|
Date: Thu, 17 Oct 2019 16:43:40 +0200
|
|
Subject: [PATCH] add an option to enable omemo by default in new conversations
|
|
|
|
---
|
|
libdino/src/entity/settings.vala | 10 ++++++++++
|
|
libdino/src/service/conversation_manager.vala | 5 +++++
|
|
main/data/settings_dialog.ui | 12 ++++++++++++
|
|
main/src/ui/settings_dialog.vala | 3 +++
|
|
4 files changed, 30 insertions(+)
|
|
|
|
diff --git a/libdino/src/entity/settings.vala b/libdino/src/entity/settings.vala
|
|
index bf1ebed..f9cd734 100644
|
|
--- a/libdino/src/entity/settings.vala
|
|
+++ b/libdino/src/entity/settings.vala
|
|
@@ -11,6 +11,7 @@ public class Settings : Object {
|
|
send_marker_ = col_to_bool_or_default("send_marker", true);
|
|
notifications_ = col_to_bool_or_default("notifications", true);
|
|
convert_utf8_smileys_ = col_to_bool_or_default("convert_utf8_smileys", true);
|
|
+ omemo_default_ = col_to_bool_or_default("omemo_default", false);
|
|
}
|
|
|
|
private bool col_to_bool_or_default(string key, bool def) {
|
|
@@ -53,6 +54,15 @@ public class Settings : Object {
|
|
convert_utf8_smileys_ = value;
|
|
}
|
|
}
|
|
+
|
|
+ private bool omemo_default_;
|
|
+ public bool omemo_default {
|
|
+ get { return omemo_default_; }
|
|
+ set {
|
|
+ db.settings.insert().or("REPLACE").value(db.settings.key, "omemo_default").value(db.settings.value, value.to_string()).perform();
|
|
+ omemo_default_ = value;
|
|
+ }
|
|
+ }
|
|
}
|
|
|
|
}
|
|
diff --git a/libdino/src/service/conversation_manager.vala b/libdino/src/service/conversation_manager.vala
|
|
index c473ea7..e980e08 100644
|
|
--- a/libdino/src/service/conversation_manager.vala
|
|
+++ b/libdino/src/service/conversation_manager.vala
|
|
@@ -8,6 +8,8 @@ public class ConversationManager : StreamInteractionModule, Object {
|
|
public static ModuleIdentity<ConversationManager> IDENTITY = new ModuleIdentity<ConversationManager>("conversation_manager");
|
|
public string id { get { return IDENTITY.id; } }
|
|
|
|
+ private Dino.Entities.Settings settings = Dino.Application.get_default().settings;
|
|
+
|
|
public signal void conversation_activated(Conversation conversation);
|
|
public signal void conversation_deactivated(Conversation conversation);
|
|
|
|
@@ -46,6 +48,9 @@ public class ConversationManager : StreamInteractionModule, Object {
|
|
|
|
// Create a new converation
|
|
Conversation conversation = new Conversation(jid, account, type);
|
|
+ if (settings.omemo_default) {
|
|
+ conversation.encryption = Encryption.OMEMO;
|
|
+ }
|
|
add_conversation(conversation);
|
|
conversation.persist(db);
|
|
return conversation;
|
|
diff --git a/main/data/settings_dialog.ui b/main/data/settings_dialog.ui
|
|
index c76f347..23ee7b8 100644
|
|
--- a/main/data/settings_dialog.ui
|
|
+++ b/main/data/settings_dialog.ui
|
|
@@ -65,6 +65,18 @@
|
|
<property name="height">1</property>
|
|
</packing>
|
|
</child>
|
|
+ <child>
|
|
+ <object class="GtkCheckButton" id="omemo_default_checkbutton">
|
|
+ <property name="label" translatable="yes">Enable OMEMO by default</property>
|
|
+ <property name="visible">True</property>
|
|
+ </object>
|
|
+ <packing>
|
|
+ <property name="left_attach">0</property>
|
|
+ <property name="top_attach">4</property>
|
|
+ <property name="width">1</property>
|
|
+ <property name="height">1</property>
|
|
+ </packing>
|
|
+ </child>
|
|
</object>
|
|
</child>
|
|
</object>
|
|
diff --git a/main/src/ui/settings_dialog.vala b/main/src/ui/settings_dialog.vala
|
|
index 68c711d..6401a2d 100644
|
|
--- a/main/src/ui/settings_dialog.vala
|
|
+++ b/main/src/ui/settings_dialog.vala
|
|
@@ -9,6 +9,7 @@ class SettingsDialog : Dialog {
|
|
[GtkChild] private CheckButton marker_checkbutton;
|
|
[GtkChild] private CheckButton notification_checkbutton;
|
|
[GtkChild] private CheckButton emoji_checkbutton;
|
|
+ [GtkChild] private CheckButton omemo_default_checkbutton;
|
|
|
|
Dino.Entities.Settings settings = Dino.Application.get_default().settings;
|
|
|
|
@@ -19,11 +20,13 @@ class SettingsDialog : Dialog {
|
|
marker_checkbutton.active = settings.send_marker;
|
|
notification_checkbutton.active = settings.notifications;
|
|
emoji_checkbutton.active = settings.convert_utf8_smileys;
|
|
+ omemo_default_checkbutton.active = settings.omemo_default;
|
|
|
|
typing_checkbutton.toggled.connect(() => { settings.send_typing = typing_checkbutton.active; } );
|
|
marker_checkbutton.toggled.connect(() => { settings.send_marker = marker_checkbutton.active; } );
|
|
notification_checkbutton.toggled.connect(() => { settings.notifications = notification_checkbutton.active; } );
|
|
emoji_checkbutton.toggled.connect(() => { settings.convert_utf8_smileys = emoji_checkbutton.active; });
|
|
+ omemo_default_checkbutton.toggled.connect(() => { settings.omemo_default = omemo_default_checkbutton.active; });
|
|
}
|
|
}
|
|
|
|
--
|
|
2.23.0
|
|
|