2017-08-14 11:48:43 +00:00
|
|
|
using Gtk;
|
|
|
|
|
|
|
|
using Dino.Entities;
|
|
|
|
|
|
|
|
namespace Dino.Plugins.OpenPgp {
|
|
|
|
|
2017-05-04 20:05:48 +00:00
|
|
|
public class ContactDetailsProvider : Plugins.ContactDetailsProvider, Object {
|
|
|
|
public string id { get { return "pgp_info"; } }
|
2017-08-14 11:48:43 +00:00
|
|
|
|
|
|
|
private StreamInteractor stream_interactor;
|
|
|
|
|
|
|
|
public ContactDetailsProvider(StreamInteractor stream_interactor) {
|
|
|
|
this.stream_interactor = stream_interactor;
|
|
|
|
}
|
|
|
|
|
2017-05-04 20:05:48 +00:00
|
|
|
public void populate(Conversation conversation, Plugins.ContactDetails contact_details, WidgetType type) {
|
|
|
|
if (conversation.type_ == Conversation.Type.CHAT && type == WidgetType.GTK) {
|
2017-08-14 11:48:43 +00:00
|
|
|
string? key_id = stream_interactor.get_module(Manager.IDENTITY).get_key_id(conversation.account, conversation.counterpart);
|
|
|
|
if (key_id != null) {
|
2017-08-24 15:24:22 +00:00
|
|
|
Label label = new Label("") { use_markup=true, justify=Justification.RIGHT, selectable=true, visible=true };
|
2017-10-29 14:15:28 +00:00
|
|
|
Gee.List<GPG.Key>? keys = null;
|
|
|
|
try {
|
|
|
|
keys = GPGHelper.get_keylist(key_id);
|
|
|
|
} catch (Error e) { }
|
|
|
|
if (keys != null && keys.size > 0) {
|
2017-08-24 15:24:22 +00:00
|
|
|
label.label = markup_colorize_id(keys[0].fpr, true);
|
2017-08-14 11:48:43 +00:00
|
|
|
} else {
|
2017-08-24 15:24:22 +00:00
|
|
|
label.label = _("Key not in keychain") + "\n" + markup_colorize_id(key_id, false);
|
2017-08-14 11:48:43 +00:00
|
|
|
}
|
2017-11-18 18:42:22 +00:00
|
|
|
contact_details.add(_("Encryption"), "OpenPGP", "", label);
|
2017-08-14 11:48:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|