From 3ddc53e683b9cdacff7184f3aa805b431edebcdb Mon Sep 17 00:00:00 2001 From: fiaxh Date: Mon, 14 Aug 2017 13:48:43 +0200 Subject: openpgp: contact details provider (fingerprint), colored fingerprints, fix shown availability --- plugins/openpgp/src/contact_details_provider.vala | 34 +++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 plugins/openpgp/src/contact_details_provider.vala (limited to 'plugins/openpgp/src/contact_details_provider.vala') diff --git a/plugins/openpgp/src/contact_details_provider.vala b/plugins/openpgp/src/contact_details_provider.vala new file mode 100644 index 00000000..39b6de2c --- /dev/null +++ b/plugins/openpgp/src/contact_details_provider.vala @@ -0,0 +1,34 @@ +using Gtk; + +using Dino.Entities; + +namespace Dino.Plugins.OpenPgp { + +public class ContactDetailsProvider : Plugins.ContactDetailsProvider { + public override string id { get { return "pgp_info"; } } + + private StreamInteractor stream_interactor; + + public ContactDetailsProvider(StreamInteractor stream_interactor) { + this.stream_interactor = stream_interactor; + } + + public override void populate(Conversation conversation, Plugins.ContactDetails contact_details) { + if (conversation.type_ == Conversation.Type.CHAT) { + string? key_id = stream_interactor.get_module(Manager.IDENTITY).get_key_id(conversation.account, conversation.counterpart); + if (key_id != null) { + Gee.List keys = GPGHelper.get_keylist(key_id); + if (keys.size > 0) { + Label label = new Label(markup_colorize_id(keys[0].fpr, true)) { use_markup=true, justify=Justification.RIGHT, visible=true }; + contact_details.add(_("Encryption"), _("OpenPGP"), "", label); + } else { + string s = _("Key not in keychain") + "\n" + markup_colorize_id(key_id, false); + Label label = new Label(s) { use_markup=true, justify=Justification.RIGHT, visible=true }; + contact_details.add(_("Encryption"), _("OpenPGP"), "", label); + } + } + } + } +} + +} -- cgit v1.2.3-70-g09d2