2017-05-13 15:48:13 +00:00
|
|
|
using Gtk;
|
2018-06-11 06:11:04 +00:00
|
|
|
using Gee;
|
2017-05-13 15:48:13 +00:00
|
|
|
using Qlite;
|
|
|
|
using Dino.Entities;
|
|
|
|
|
|
|
|
namespace Dino.Plugins.Omemo {
|
|
|
|
|
|
|
|
public class ContactDetailsProvider : Plugins.ContactDetailsProvider, Object {
|
|
|
|
public string id { get { return "omemo_info"; } }
|
|
|
|
|
|
|
|
private Plugin plugin;
|
|
|
|
|
|
|
|
public ContactDetailsProvider(Plugin plugin) {
|
|
|
|
this.plugin = plugin;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void populate(Conversation conversation, Plugins.ContactDetails contact_details, WidgetType type) {
|
|
|
|
if (conversation.type_ == Conversation.Type.CHAT && type == WidgetType.GTK) {
|
2018-06-11 06:11:04 +00:00
|
|
|
|
2017-05-13 15:48:13 +00:00
|
|
|
int i = 0;
|
|
|
|
foreach (Row row in plugin.db.identity_meta.with_address(conversation.counterpart.to_string())) {
|
|
|
|
if (row[plugin.db.identity_meta.identity_key_public_base64] != null) {
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
2018-06-11 06:11:04 +00:00
|
|
|
|
2017-05-13 15:48:13 +00:00
|
|
|
if (i > 0) {
|
2018-06-11 06:11:04 +00:00
|
|
|
Button btn = new Button();
|
|
|
|
btn.image = new Image.from_icon_name("view-list-symbolic", IconSize.BUTTON);
|
|
|
|
btn.relief = ReliefStyle.NONE;
|
|
|
|
btn.visible = true;
|
|
|
|
btn.valign = Align.CENTER;
|
|
|
|
btn.clicked.connect(() => {
|
|
|
|
btn.activate();
|
|
|
|
ContactDetailsDialog dialog = new ContactDetailsDialog(plugin, conversation.account, conversation.counterpart);
|
|
|
|
dialog.set_transient_for((Window) btn.get_toplevel());
|
|
|
|
dialog.present();
|
|
|
|
});
|
|
|
|
|
|
|
|
contact_details.add(_("Encryption"), "OMEMO", n("%d OMEMO device", "%d OMEMO devices", i).printf(i), btn);
|
2017-05-13 15:48:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|