From a7aa5130f821252c17ffc5725e4240553248ad17 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Thu, 16 May 2019 20:41:41 +0200 Subject: OMEMO code cleanup: Move TrustLevel out of Database --- plugins/omemo/src/ui/contact_details_dialog.vala | 34 ++++++++++++------------ plugins/omemo/src/ui/manage_key_dialog.vala | 14 +++++----- 2 files changed, 24 insertions(+), 24 deletions(-) (limited to 'plugins/omemo/src/ui') diff --git a/plugins/omemo/src/ui/contact_details_dialog.vala b/plugins/omemo/src/ui/contact_details_dialog.vala index 6899acf6..eee06f0f 100644 --- a/plugins/omemo/src/ui/contact_details_dialog.vala +++ b/plugins/omemo/src/ui/contact_details_dialog.vala @@ -91,7 +91,7 @@ public class ContactDetailsDialog : Gtk.Dialog { if(own && device[plugin.db.identity_meta.device_id] == own_id) { continue; } - add_fingerprint(device, (Database.IdentityMetaTable.TrustLevel) device[plugin.db.identity_meta.trust_level]); + add_fingerprint(device, (TrustLevel) device[plugin.db.identity_meta.trust_level]); } auto_accept_switch.set_active(plugin.db.trust.get_blind_trust(identity_id, jid.bare_jid.to_string())); @@ -103,8 +103,8 @@ public class ContactDetailsDialog : Gtk.Dialog { new_keys_container.visible = false; foreach (Row device in plugin.db.identity_meta.get_new_devices(identity_id, jid.to_string())) { - plugin.trust_manager.set_device_trust(account, jid, device[plugin.db.identity_meta.device_id], Database.IdentityMetaTable.TrustLevel.TRUSTED); - add_fingerprint(device, Database.IdentityMetaTable.TrustLevel.TRUSTED); + plugin.trust_manager.set_device_trust(account, jid, device[plugin.db.identity_meta.device_id], TrustLevel.TRUSTED); + add_fingerprint(device, TrustLevel.TRUSTED); } } @@ -121,17 +121,17 @@ public class ContactDetailsDialog : Gtk.Dialog { private void set_row(int trust, bool now_active, Image img, Label status_lbl, Label lbl, ListBoxRow lbr){ switch(trust) { - case Database.IdentityMetaTable.TrustLevel.TRUSTED: + case TrustLevel.TRUSTED: img.icon_name = "emblem-ok-symbolic"; status_lbl.set_markup("%s".printf(_("Accepted"))); lbl.get_style_context().remove_class("dim-label"); break; - case Database.IdentityMetaTable.TrustLevel.UNTRUSTED: + case TrustLevel.UNTRUSTED: img.icon_name = "action-unavailable-symbolic"; status_lbl.set_markup("%s".printf(_("Rejected"))); lbl.get_style_context().add_class("dim-label"); break; - case Database.IdentityMetaTable.TrustLevel.VERIFIED: + case TrustLevel.VERIFIED: img.icon_name = "security-high-symbolic"; status_lbl.set_markup("%s".printf(_("Verified"))); lbl.get_style_context().remove_class("dim-label"); @@ -145,7 +145,7 @@ public class ContactDetailsDialog : Gtk.Dialog { } } - private void add_fingerprint(Row device, Database.IdentityMetaTable.TrustLevel trust) { + private void add_fingerprint(Row device, TrustLevel trust) { keys_container.visible = true; ListBoxRow lbr = new ListBoxRow() { visible = true, activatable = true, hexpand = true }; @@ -188,14 +188,14 @@ public class ContactDetailsDialog : Gtk.Dialog { private void update_device(int response, Row device){ switch (response) { - case Database.IdentityMetaTable.TrustLevel.TRUSTED: - plugin.trust_manager.set_device_trust(account, jid, device[plugin.db.identity_meta.device_id], Database.IdentityMetaTable.TrustLevel.TRUSTED); + case TrustLevel.TRUSTED: + plugin.trust_manager.set_device_trust(account, jid, device[plugin.db.identity_meta.device_id], TrustLevel.TRUSTED); break; - case Database.IdentityMetaTable.TrustLevel.UNTRUSTED: - plugin.trust_manager.set_device_trust(account, jid, device[plugin.db.identity_meta.device_id], Database.IdentityMetaTable.TrustLevel.UNTRUSTED); + case TrustLevel.UNTRUSTED: + plugin.trust_manager.set_device_trust(account, jid, device[plugin.db.identity_meta.device_id], TrustLevel.UNTRUSTED); break; - case Database.IdentityMetaTable.TrustLevel.VERIFIED: - plugin.trust_manager.set_device_trust(account, jid, device[plugin.db.identity_meta.device_id], Database.IdentityMetaTable.TrustLevel.VERIFIED); + case TrustLevel.VERIFIED: + plugin.trust_manager.set_device_trust(account, jid, device[plugin.db.identity_meta.device_id], TrustLevel.VERIFIED); plugin.trust_manager.set_blind_trust(account, jid, false); auto_accept_switch.set_active(false); break; @@ -219,15 +219,15 @@ public class ContactDetailsDialog : Gtk.Dialog { no_button.get_style_context().add_class("destructive-action"); yes_button.clicked.connect(() => { - plugin.trust_manager.set_device_trust(account, jid, device[plugin.db.identity_meta.device_id], Database.IdentityMetaTable.TrustLevel.TRUSTED); - add_fingerprint(device, Database.IdentityMetaTable.TrustLevel.TRUSTED); + plugin.trust_manager.set_device_trust(account, jid, device[plugin.db.identity_meta.device_id], TrustLevel.TRUSTED); + add_fingerprint(device, TrustLevel.TRUSTED); new_keys_listbox.remove(lbr); if (new_keys_listbox.get_children().length() < 1) new_keys_container.visible = false; }); no_button.clicked.connect(() => { - plugin.trust_manager.set_device_trust(account, jid, device[plugin.db.identity_meta.device_id], Database.IdentityMetaTable.TrustLevel.UNTRUSTED); - add_fingerprint(device, Database.IdentityMetaTable.TrustLevel.UNTRUSTED); + plugin.trust_manager.set_device_trust(account, jid, device[plugin.db.identity_meta.device_id], TrustLevel.UNTRUSTED); + add_fingerprint(device, TrustLevel.UNTRUSTED); new_keys_listbox.remove(lbr); if (new_keys_listbox.get_children().length() < 1) new_keys_container.visible = false; }); diff --git a/plugins/omemo/src/ui/manage_key_dialog.vala b/plugins/omemo/src/ui/manage_key_dialog.vala index 87d43de8..51dcbad0 100644 --- a/plugins/omemo/src/ui/manage_key_dialog.vala +++ b/plugins/omemo/src/ui/manage_key_dialog.vala @@ -50,7 +50,7 @@ public class ManageKeyDialog : Gtk.Dialog { manage_stack.set_visible_child_name("confirm"); ok_button.sensitive = true; return_to_main = false; - current_response = Database.IdentityMetaTable.TrustLevel.VERIFIED; + current_response = TrustLevel.VERIFIED; }); verify_no_button.clicked.connect(() => { @@ -115,17 +115,17 @@ public class ManageKeyDialog : Gtk.Dialog { ListBoxRow accept_row = new ListBoxRow() {visible = true }; accept_row.add(make_action_box(_("Accept key"), _("Start accepting this key during communication with its associated contact"))); - switch((Database.IdentityMetaTable.TrustLevel) device[db.identity_meta.trust_level]) { - case Database.IdentityMetaTable.TrustLevel.TRUSTED: + switch((TrustLevel) device[db.identity_meta.trust_level]) { + case TrustLevel.TRUSTED: main_desc_label.set_markup(_("This key is currently %s.").printf(""+_("accepted")+"")+" "+_("This means it can be used by %s to receive and send messages.").printf(@"$(device[db.identity_meta.address_name])")); main_action_list.add(verify_row); main_action_list.add(reject_row); break; - case Database.IdentityMetaTable.TrustLevel.VERIFIED: + case TrustLevel.VERIFIED: main_desc_label.set_markup(_("This key is currently %s.").printf(""+_("verified")+"")+" "+_("This means it can be used by %s to receive and send messages.") + " " + _("Additionally it has been verified to match the key on the contact's device.").printf(@"$(device[db.identity_meta.address_name])")); main_action_list.add(reject_row); break; - case Database.IdentityMetaTable.TrustLevel.UNTRUSTED: + case TrustLevel.UNTRUSTED: main_desc_label.set_markup(_("This key is currently %s.").printf(""+_("rejected")+"")+" "+_("This means it cannot be used by %s to receive messages, and any messages sent by it will be ignored.").printf(@"$(device[db.identity_meta.address_name])")); main_action_list.add(accept_row); break; @@ -142,7 +142,7 @@ public class ManageKeyDialog : Gtk.Dialog { manage_stack.set_visible_child_name("confirm"); ok_button.sensitive = true; return_to_main = true; - current_response = Database.IdentityMetaTable.TrustLevel.UNTRUSTED; + current_response = TrustLevel.UNTRUSTED; } else if (row == accept_row) { confirm_image.set_from_icon_name("emblem-ok-symbolic", IconSize.DIALOG); confirm_title_label.label = _("Accept key"); @@ -150,7 +150,7 @@ public class ManageKeyDialog : Gtk.Dialog { manage_stack.set_visible_child_name("confirm"); ok_button.sensitive = true; return_to_main = true; - current_response = Database.IdentityMetaTable.TrustLevel.TRUSTED; + current_response = TrustLevel.TRUSTED; } cancel_button.label = _("Back"); }); -- cgit v1.2.3-70-g09d2