diff options
author | Marvin W <git@larma.de> | 2017-05-13 17:48:13 +0200 |
---|---|---|
committer | Marvin W <git@larma.de> | 2017-08-27 14:52:18 +0200 |
commit | 9840774a87b9d15523ecc04ee4c157270e9abfe5 (patch) | |
tree | e3183522c19cabc787ec969d67a35208cd9c61de /plugins/omemo/src/account_settings_dialog.vala | |
parent | ad033beea82a4ba20da71220966b80d5f674428f (diff) | |
download | dino-9840774a87b9d15523ecc04ee4c157270e9abfe5.tar.gz dino-9840774a87b9d15523ecc04ee4c157270e9abfe5.zip |
omemo: store and display identity keys of all devices
Diffstat (limited to 'plugins/omemo/src/account_settings_dialog.vala')
-rw-r--r-- | plugins/omemo/src/account_settings_dialog.vala | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/plugins/omemo/src/account_settings_dialog.vala b/plugins/omemo/src/account_settings_dialog.vala new file mode 100644 index 00000000..373d02aa --- /dev/null +++ b/plugins/omemo/src/account_settings_dialog.vala @@ -0,0 +1,53 @@ +using Gtk; +using Qlite; +using Dino.Entities; + +namespace Dino.Plugins.Omemo { + +[GtkTemplate (ui = "/im/dino/omemo/account_settings_dialog.ui")] +public class AccountSettingsDialog : Gtk.Dialog { + + private Plugin plugin; + private Account account; + private string fingerprint; + + [GtkChild] private Label own_fingerprint; + [GtkChild] private ListBox other_list; + + public AccountSettingsDialog(Plugin plugin, Account account) { + Object(use_header_bar : 1); + this.plugin = plugin; + + string own_b64 = plugin.db.identity.row_with(plugin.db.identity.account_id, account.id)[plugin.db.identity.identity_key_public_base64]; + fingerprint = fingerprint_from_base64(own_b64); + own_fingerprint.set_markup(fingerprint_markup(fingerprint)); + + int own_id = plugin.db.identity.row_with(plugin.db.identity.account_id, account.id)[plugin.db.identity.device_id]; + + int i = 0; + foreach (Row row in plugin.db.identity_meta.with_address(account.bare_jid.to_string())) { + if (row[plugin.db.identity_meta.device_id] == own_id) continue; + if (i == 0) { + other_list.foreach((widget) => { other_list.remove(widget); }); + } + string? other_b64 = row[plugin.db.identity_meta.identity_key_public_base64]; + Label lbl = new Label(other_b64 != null ? fingerprint_markup(fingerprint_from_base64(other_b64)) : _("Unknown device (0x%xd)").printf(row[plugin.db.identity_meta.device_id])) { use_markup = true, visible = true, margin = 8, selectable=true }; + if (row[plugin.db.identity_meta.now_active] && other_b64 != null) { + other_list.insert(lbl, 0); + } else { + lbl.sensitive = false; + other_list.insert(lbl, i); + } + i++; + } + } + + [GtkCallback] + public void copy_button_clicked() { + Clipboard.get_default(get_display()).set_text(fingerprint, fingerprint.length); + } + + +} + +}
\ No newline at end of file |