aboutsummaryrefslogtreecommitdiff
path: root/plugins/openpgp/src/contact_details_provider.vala
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-08-14 13:48:43 +0200
committerfiaxh <git@mx.ax.lt>2017-08-14 22:38:17 +0200
commit3ddc53e683b9cdacff7184f3aa805b431edebcdb (patch)
tree5d9a3ed994ae9193789c7115c294aa9866930074 /plugins/openpgp/src/contact_details_provider.vala
parentb0264b3e0034ddd9ea76d0e13bb4c3c709ba3b3e (diff)
downloaddino-3ddc53e683b9cdacff7184f3aa805b431edebcdb.tar.gz
dino-3ddc53e683b9cdacff7184f3aa805b431edebcdb.zip
openpgp: contact details provider (fingerprint), colored fingerprints, fix shown availability
Diffstat (limited to 'plugins/openpgp/src/contact_details_provider.vala')
-rw-r--r--plugins/openpgp/src/contact_details_provider.vala34
1 files changed, 34 insertions, 0 deletions
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<GPG.Key> 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);
+ }
+ }
+ }
+ }
+}
+
+}