Visually mark OMEMO messages from a trusted device as trusted

This commit is contained in:
fiaxh 2020-03-28 14:46:51 +01:00
parent c029da49bc
commit 1016529c36
8 changed files with 53 additions and 18 deletions

View file

@ -26,6 +26,7 @@ public interface EncryptionListEntry : Object {
public abstract string name { get; } public abstract string name { get; }
public abstract void encryption_activated(Entities.Conversation conversation, Plugins.SetInputFieldStatus callback); public abstract void encryption_activated(Entities.Conversation conversation, Plugins.SetInputFieldStatus callback);
public abstract Object? get_encryption_icon(Entities.Conversation conversation, ContentItem content_item);
} }
public abstract class AccountSettingsEntry : Object { public abstract class AccountSettingsEntry : Object {

View file

@ -18,6 +18,7 @@ set(RESOURCE_LIST
icons/dino-double-tick-symbolic.svg icons/dino-double-tick-symbolic.svg
icons/dino-emoticon-symbolic.svg icons/dino-emoticon-symbolic.svg
icons/dino-qr-code-symbolic.svg icons/dino-qr-code-symbolic.svg
icons/dino-security-high-symbolic.svg
icons/dino-party-popper-symbolic.svg icons/dino-party-popper-symbolic.svg
icons/dino-status-away.svg icons/dino-status-away.svg
icons/dino-status-chat.svg icons/dino-status-chat.svg

View file

@ -42,15 +42,5 @@
</style> </style>
</object> </object>
</child> </child>
<child>
<object class="GtkImage" id="encryption_image">
<property name="opacity">0.4</property>
</object>
</child>
<child>
<object class="GtkImage" id="received_image">
<property name="opacity">0.4</property>
</object>
</child>
</template> </template>
</interface> </interface>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.1" viewBox="0 0 16 12" xmlns="http://www.w3.org/2000/svg">
<path d="m2.9174 0v5.9297c0 1.7552 1.269 3.13 2.399 4.1415a15.807 15.807 0 0 0 2.2533 1.6705l0.4371 0.25836 0.43371-0.2626s1.1182-0.67768 2.2448-1.6959c1.1266-1.0199 2.3973-2.3803 2.3973-4.1118v-5.9297zm1.6942 1.6942h6.7768v4.2355c0 0.77933-0.8471 1.9593-1.8382 2.8547-0.7734 0.69886-1.2512 0.97755-1.5553 1.1741-0.30326-0.19144-0.77764-0.45997-1.5485-1.1504-0.98772-0.88352-1.8348-2.0483-1.8348-2.8784z" color="#bebebe" fill="#474747" font-family="sans-serif" font-weight="400" overflow="visible" stroke-width=".8471" style="font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;isolation:auto;mix-blend-mode:normal;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none" white-space="normal"/>
<path d="m5.8658 3.0501v2.8457c0 0.25398 0.53712 1.1674 1.3118 1.8675 0.40906 0.36994 0.5236 0.41262 0.8224 0.62249 0.29879-0.20916 0.41333-0.25255 0.8224-0.62249 0.77544-0.70003 1.3118-1.6135 1.3118-1.8675v-2.8457z" color="#bebebe" fill="#474747" overflow="visible" stroke-width=".71142"/>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -62,7 +62,6 @@ class ChatStatePopulator : Plugins.ConversationItemPopulator, Plugins.Conversati
} }
private class MetaChatStateItem : Plugins.MetaConversationItem { private class MetaChatStateItem : Plugins.MetaConversationItem {
public override bool dim { get; set; default=true; }
public override DateTime sort_time { get; set; default=new DateTime.now_utc().add_years(10); } public override DateTime sort_time { get; set; default=new DateTime.now_utc().add_years(10); }
public override bool can_merge { get; set; default=false; } public override bool can_merge { get; set; default=false; }

View file

@ -88,8 +88,8 @@ public class ItemMetaDataHeader : Box {
[GtkChild] public Label name_label; [GtkChild] public Label name_label;
[GtkChild] public Label dot_label; [GtkChild] public Label dot_label;
[GtkChild] public Label time_label; [GtkChild] public Label time_label;
[GtkChild] public Image encryption_image; public Image received_image = new Image() { opacity=0.4 };
[GtkChild] public Image received_image; public Image? encryption_image = null;
public static IconSize ICON_SIZE_HEADER = Gtk.icon_size_register("im.dino.Dino.HEADER_ICON", 17, 12); public static IconSize ICON_SIZE_HEADER = Gtk.icon_size_register("im.dino.Dino.HEADER_ICON", 17, 12);
@ -106,9 +106,23 @@ public class ItemMetaDataHeader : Box {
update_name_label(); update_name_label();
name_label.style_updated.connect(update_name_label); name_label.style_updated.connect(update_name_label);
if (item.encryption != Encryption.NONE) {
encryption_image.visible = true; Application app = GLib.Application.get_default() as Application;
encryption_image.set_from_icon_name("dino-changes-prevent-symbolic", ICON_SIZE_HEADER);
ContentMetaItem ci = item as ContentMetaItem;
if (ci != null) {
foreach(var e in app.plugin_registry.encryption_list_entries) {
if (e.encryption == item.encryption) {
Object? w = e.get_encryption_icon(conversation, ci.content_item);
if (w != null) {
this.add(w as Widget);
} else {
Image image = new Image.from_icon_name("dino-changes-prevent-symbolic", ICON_SIZE_HEADER) { opacity=0.4, visible = true };
this.add(image);
}
break;
}
}
} }
if (item.display_time != null) { if (item.display_time != null) {
update_time(); update_time();
@ -143,11 +157,9 @@ public class ItemMetaDataHeader : Box {
received_image.visible = true; received_image.visible = true;
received_image.set_from_icon_name("dialog-warning-symbolic", ICON_SIZE_HEADER); received_image.set_from_icon_name("dialog-warning-symbolic", ICON_SIZE_HEADER);
Util.force_error_color(received_image); Util.force_error_color(received_image);
Util.force_error_color(encryption_image);
Util.force_error_color(time_label); Util.force_error_color(time_label);
string error_text = _("Unable to send message"); string error_text = _("Unable to send message");
received_image.tooltip_text = error_text; received_image.tooltip_text = error_text;
encryption_image.tooltip_text = error_text;
time_label.tooltip_text = error_text; time_label.tooltip_text = error_text;
return; return;
} else if (item.mark != Message.Marked.READ) { } else if (item.mark != Message.Marked.READ) {

View file

@ -1,12 +1,16 @@
using Gtk;
using Qlite;
using Xmpp; using Xmpp;
namespace Dino.Plugins.Omemo { namespace Dino.Plugins.Omemo {
public class EncryptionListEntry : Plugins.EncryptionListEntry, Object { public class EncryptionListEntry : Plugins.EncryptionListEntry, Object {
private Plugin plugin; private Plugin plugin;
private Database db;
public EncryptionListEntry(Plugin plugin) { public EncryptionListEntry(Plugin plugin) {
this.plugin = plugin; this.plugin = plugin;
this.db = plugin.db;
} }
public Entities.Encryption encryption { get { public Entities.Encryption encryption { get {
@ -17,6 +21,22 @@ public class EncryptionListEntry : Plugins.EncryptionListEntry, Object {
return "OMEMO"; return "OMEMO";
}} }}
public static IconSize ICON_SIZE_HEADER = Gtk.icon_size_register("im.dino.Dino.HEADER_ICON2", 17, 12);
public Object? get_encryption_icon(Entities.Conversation conversation, ContentItem content_item) {
if (content_item.encryption != encryption) return null;
RowOption row = db.content_item_meta.select( { db.identity_meta.trust_level } ).with(db.content_item_meta.content_item_id, "=", content_item.id)
.join_on(db.identity_meta, @"$(db.identity_meta.address_name)=$(db.content_item_meta.address_name) AND $(db.identity_meta.device_id)=$(db.content_item_meta.device_id)")
.single().row();
if (row.is_present() && (TrustLevel) row[db.identity_meta.trust_level] == TrustLevel.VERIFIED) {
return new Image.from_icon_name("dino-security-high-symbolic", ICON_SIZE_HEADER) { opacity=0.4, visible = true };
}
return null;
}
public void encryption_activated(Entities.Conversation conversation, Plugins.SetInputFieldStatus input_status_callback) { public void encryption_activated(Entities.Conversation conversation, Plugins.SetInputFieldStatus input_status_callback) {
encryption_activated_async.begin(conversation, input_status_callback); encryption_activated_async.begin(conversation, input_status_callback);
} }

View file

@ -1,4 +1,5 @@
using Gee; using Gee;
using Gtk;
using Dino.Entities; using Dino.Entities;
using Xmpp; using Xmpp;
@ -23,6 +24,12 @@ private class EncryptionListEntry : Plugins.EncryptionListEntry, Object {
return "OpenPGP"; return "OpenPGP";
}} }}
public static IconSize ICON_SIZE_HEADER = Gtk.icon_size_register("im.dino.Dino.HEADER_ICON3", 17, 12);
public Object? get_encryption_icon(Entities.Conversation conversation, ContentItem content_item) {
return null;
}
public void encryption_activated(Entities.Conversation conversation, Plugins.SetInputFieldStatus input_status_callback) { public void encryption_activated(Entities.Conversation conversation, Plugins.SetInputFieldStatus input_status_callback) {
try { try {
GPGHelper.get_public_key(db.get_account_key(conversation.account) ?? ""); GPGHelper.get_public_key(db.get_account_key(conversation.account) ?? "");