aboutsummaryrefslogtreecommitdiff
path: root/plugins/omemo/src/ui
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2021-05-03 13:17:17 +0200
committerfiaxh <git@lightrise.org>2021-05-11 12:52:00 +0200
commit90f9ecf62b2ebfef14de2874e7942552409632bf (patch)
treec9cd6da902ee89ab9cfcc435c2e98680e2ec3c50 /plugins/omemo/src/ui
parent8044b546d0ac15d34a3e6499b9c0d55d3d8f9c94 (diff)
downloaddino-90f9ecf62b2ebfef14de2874e7942552409632bf.tar.gz
dino-90f9ecf62b2ebfef14de2874e7942552409632bf.zip
Calls: Indicate whether OMEMO key is verified
Diffstat (limited to 'plugins/omemo/src/ui')
-rw-r--r--plugins/omemo/src/ui/call_encryption_entry.vala57
1 files changed, 57 insertions, 0 deletions
diff --git a/plugins/omemo/src/ui/call_encryption_entry.vala b/plugins/omemo/src/ui/call_encryption_entry.vala
new file mode 100644
index 00000000..69b7b686
--- /dev/null
+++ b/plugins/omemo/src/ui/call_encryption_entry.vala
@@ -0,0 +1,57 @@
+using Dino.Entities;
+using Gtk;
+using Qlite;
+using Xmpp;
+
+namespace Dino.Plugins.Omemo {
+
+ public class CallEncryptionEntry : Plugins.CallEncryptionEntry, Object {
+ private Database db;
+
+ public CallEncryptionEntry(Database db) {
+ this.db = db;
+ }
+
+ public Plugins.CallEncryptionWidget? get_widget(Account account, Xmpp.Xep.Jingle.ContentEncryption encryption) {
+ DtlsSrtpVerificationDraft.OmemoContentEncryption? omemo_encryption = encryption as DtlsSrtpVerificationDraft.OmemoContentEncryption;
+ if (omemo_encryption == null) return null;
+
+ int identity_id = db.identity.get_id(account.id);
+ Row? device = db.identity_meta.get_device(identity_id, omemo_encryption.jid.to_string(), omemo_encryption.sid);
+ if (device == null) return null;
+ TrustLevel trust = (TrustLevel) device[db.identity_meta.trust_level];
+
+ return new CallEncryptionWidget(trust);
+ }
+ }
+
+ public class CallEncryptionWidget : Plugins.CallEncryptionWidget, Object {
+
+ string? title = null;
+ string? icon = null;
+ bool should_show_keys = false;
+
+ public CallEncryptionWidget(TrustLevel trust) {
+ if (trust == TrustLevel.VERIFIED) {
+ title = "This call is <b>encrypted and verified</b> with OMEMO.";
+ icon = "dino-security-high-symbolic";
+ should_show_keys = false;
+ } else {
+ title = "This call is encrypted with OMEMO.";
+ should_show_keys = true;
+ }
+ }
+
+ public string? get_title() {
+ return title;
+ }
+
+ public string? get_icon_name() {
+ return icon;
+ }
+
+ public bool show_keys() {
+ return should_show_keys;
+ }
+ }
+}