2017-03-12 01:28:23 +00:00
|
|
|
using Gtk;
|
|
|
|
using Dino.Entities;
|
|
|
|
|
|
|
|
namespace Dino.Plugins.Omemo {
|
|
|
|
|
|
|
|
public class AccountSettingWidget : Plugins.AccountSettingsWidget, Box {
|
|
|
|
private Plugin plugin;
|
|
|
|
private Label fingerprint;
|
|
|
|
private Account account;
|
|
|
|
|
|
|
|
public AccountSettingWidget(Plugin plugin) {
|
|
|
|
this.plugin = plugin;
|
|
|
|
|
|
|
|
fingerprint = new Label("...");
|
|
|
|
fingerprint.xalign = 0;
|
|
|
|
Border border = new Button().get_style_context().get_padding(StateFlags.NORMAL);
|
|
|
|
fingerprint.set_padding(border.left + 1, border.top + 1);
|
|
|
|
fingerprint.visible = true;
|
|
|
|
pack_start(fingerprint);
|
|
|
|
|
|
|
|
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(() => { activated(); });
|
|
|
|
pack_start(btn, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void set_account(Account account) {
|
|
|
|
this.account = account;
|
|
|
|
try {
|
2017-03-12 18:33:31 +00:00
|
|
|
Qlite.Row? row = plugin.db.identity.row_with(plugin.db.identity.account_id, account.id).inner;
|
2017-03-12 01:28:23 +00:00
|
|
|
if (row == null) {
|
2017-04-07 09:09:47 +00:00
|
|
|
fingerprint.set_markup("%s\n<span font='8'>%s</span>".printf(_("Own fingerprint"), _("Will be generated on first connect")));
|
2017-03-12 01:28:23 +00:00
|
|
|
} else {
|
2017-04-18 15:55:20 +00:00
|
|
|
uint8[] arr = Base64.decode(((!)row)[plugin.db.identity.identity_key_public_base64]);
|
2017-03-12 01:28:23 +00:00
|
|
|
arr = arr[1:arr.length];
|
|
|
|
string res = "";
|
|
|
|
foreach (uint8 i in arr) {
|
|
|
|
string s = i.to_string("%x");
|
|
|
|
if (s.length == 1) s = "0" + s;
|
|
|
|
res = res + s;
|
|
|
|
if ((res.length % 9) == 8) {
|
|
|
|
if (res.length == 35) {
|
|
|
|
res += "\n";
|
|
|
|
} else {
|
|
|
|
res += " ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-04-07 09:09:47 +00:00
|
|
|
fingerprint.set_markup("%s\n<span font_family='monospace' font='8'>%s</span>".printf(_("Own fingerprint"), res));
|
2017-03-12 01:28:23 +00:00
|
|
|
}
|
|
|
|
} catch (Qlite.DatabaseError e) {
|
2017-04-07 09:09:47 +00:00
|
|
|
fingerprint.set_markup("%s\n<span font='8'>%s</span>".printf(_("Own fingerprint"), _("Database error")));
|
2017-03-12 01:28:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void deactivate() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|