Enable key management for own keys
This commit is contained in:
parent
f3c82094cd
commit
acbc5710d0
|
@ -12,7 +12,6 @@ find_packages(OMEMO_PACKAGES REQUIRED
|
||||||
)
|
)
|
||||||
|
|
||||||
set(RESOURCE_LIST
|
set(RESOURCE_LIST
|
||||||
account_settings_dialog.ui
|
|
||||||
contact_details_dialog.ui
|
contact_details_dialog.ui
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -28,7 +27,6 @@ compile_gresources(
|
||||||
|
|
||||||
vala_precompile(OMEMO_VALA_C
|
vala_precompile(OMEMO_VALA_C
|
||||||
SOURCES
|
SOURCES
|
||||||
src/account_settings_dialog.vala
|
|
||||||
src/account_settings_entry.vala
|
src/account_settings_entry.vala
|
||||||
src/account_settings_widget.vala
|
src/account_settings_widget.vala
|
||||||
src/bundle.vala
|
src/bundle.vala
|
||||||
|
|
|
@ -1,124 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<interface>
|
|
||||||
<template class="DinoPluginsOmemoAccountSettingsDialog">
|
|
||||||
<property name="modal">True</property>
|
|
||||||
<property name="title" translatable="yes">OMEMO Keys</property>
|
|
||||||
<child internal-child="vbox">
|
|
||||||
<object class="GtkBox">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="margin-left">40</property>
|
|
||||||
<property name="margin-right">40</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkBox">
|
|
||||||
<property name="margin-top">12</property>
|
|
||||||
<property name="orientation">horizontal</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="label" translatable="yes">Own fingerprint</property>
|
|
||||||
<property name="xalign">0</property>
|
|
||||||
<property name="yalign">1</property>
|
|
||||||
<property name="hexpand">True</property>
|
|
||||||
<property name="margin-bottom">2</property>
|
|
||||||
<attributes>
|
|
||||||
<attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
|
|
||||||
</attributes>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="copy_button">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<style>
|
|
||||||
<class name="flat"/>
|
|
||||||
</style>
|
|
||||||
<signal name="clicked" handler="copy_button_clicked"/>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImage">
|
|
||||||
<property name="icon-name">edit-copy-symbolic</property>
|
|
||||||
<property name="icon-size">1</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<!--<child>
|
|
||||||
<object class="GtkButton" id="qr_button">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="sensitive">False</property>
|
|
||||||
<style>
|
|
||||||
<class name="flat"/>
|
|
||||||
</style>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImage">
|
|
||||||
<property name="icon-name">camera-photo-symbolic</property>
|
|
||||||
<property name="icon-size">1</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>-->
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkFrame">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkListBox">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="selection-mode">none</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel" id="own_fingerprint">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="margin">8</property>
|
|
||||||
<property name="label">...</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel">
|
|
||||||
<property name="margin-top">12</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="xalign">0</property>
|
|
||||||
<property name="label" translatable="yes">Other devices</property>
|
|
||||||
<property name="margin-bottom">2</property>
|
|
||||||
<attributes>
|
|
||||||
<attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
|
|
||||||
</attributes>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkFrame">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="margin-bottom">18</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkScrolledWindow">
|
|
||||||
<property name="hscrollbar_policy">never</property>
|
|
||||||
<property name="vscrollbar_policy">never</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkListBox" id="other_list">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="selection-mode">none</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="margin">8</property>
|
|
||||||
<property name="label" translatable="yes">- None -</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</template>
|
|
||||||
</interface>
|
|
|
@ -9,6 +9,46 @@
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="margin-left">40</property>
|
<property name="margin-left">40</property>
|
||||||
<property name="margin-right">40</property>
|
<property name="margin-right">40</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox" id="own_fingerprint_label">
|
||||||
|
<property name="margin-top">12</property>
|
||||||
|
<property name="orientation">horizontal</property>
|
||||||
|
<property name="visible">False</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="label" translatable="yes">Own fingerprint</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="yalign">1</property>
|
||||||
|
<property name="hexpand">True</property>
|
||||||
|
<property name="margin-bottom">2</property>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
|
||||||
|
</attributes>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkFrame" id="own_fingerprint_container">
|
||||||
|
<property name="visible">False</property>
|
||||||
|
<property name="margin-bottom">18</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkScrolledWindow">
|
||||||
|
<property name="hscrollbar_policy">never</property>
|
||||||
|
<property name="vscrollbar_policy">automatic</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="propagate_natural_height">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkGrid" id="own_fingerprint">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="vexpand">True</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkBox">
|
||||||
<property name="margin-top">12</property>
|
<property name="margin-top">12</property>
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
using Gtk;
|
|
||||||
using Qlite;
|
|
||||||
using Dino.Entities;
|
|
||||||
|
|
||||||
namespace Dino.Plugins.Omemo {
|
|
||||||
|
|
||||||
[GtkTemplate (ui = "/im/dino/Dino/omemo/account_settings_dialog.ui")]
|
|
||||||
public class AccountSettingsDialog : Gtk.Dialog {
|
|
||||||
|
|
||||||
private Plugin plugin;
|
|
||||||
private Account account;
|
|
||||||
private string fingerprint;
|
|
||||||
|
|
||||||
[GtkChild] private Label own_fingerprint;
|
|
||||||
[GtkChild] private ListBox other_list;
|
|
||||||
|
|
||||||
public AccountSettingsDialog(Plugin plugin, Account account) {
|
|
||||||
Object(use_header_bar : 1);
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.account = account;
|
|
||||||
|
|
||||||
string own_b64 = plugin.db.identity.row_with(plugin.db.identity.account_id, account.id)[plugin.db.identity.identity_key_public_base64];
|
|
||||||
fingerprint = fingerprint_from_base64(own_b64);
|
|
||||||
own_fingerprint.set_markup(fingerprint_markup(fingerprint));
|
|
||||||
|
|
||||||
int own_id = plugin.db.identity.row_with(plugin.db.identity.account_id, account.id)[plugin.db.identity.device_id];
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
foreach (Row row in plugin.db.identity_meta.with_address(account.id, account.bare_jid.to_string())) {
|
|
||||||
if (row[plugin.db.identity_meta.device_id] == own_id) continue;
|
|
||||||
if (i == 0) {
|
|
||||||
other_list.foreach((widget) => { widget.destroy(); });
|
|
||||||
}
|
|
||||||
string? other_b64 = row[plugin.db.identity_meta.identity_key_public_base64];
|
|
||||||
Label lbl = new Label(other_b64 != null ? fingerprint_markup(fingerprint_from_base64(other_b64)) : _("Unknown device (0x%.8x)").printf(row[plugin.db.identity_meta.device_id])) { use_markup = true, visible = true, margin = 8, selectable=true };
|
|
||||||
if (row[plugin.db.identity_meta.now_active] && other_b64 != null) {
|
|
||||||
other_list.insert(lbl, 0);
|
|
||||||
} else {
|
|
||||||
lbl.sensitive = false;
|
|
||||||
other_list.insert(lbl, i);
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[GtkCallback]
|
|
||||||
public void copy_button_clicked() {
|
|
||||||
Clipboard.get_default(get_display()).set_text(fingerprint, fingerprint.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -27,7 +27,7 @@ public class AccountSettingWidget : Plugins.AccountSettingsWidget, Box {
|
||||||
btn.valign = Align.CENTER;
|
btn.valign = Align.CENTER;
|
||||||
btn.clicked.connect(() => {
|
btn.clicked.connect(() => {
|
||||||
activated();
|
activated();
|
||||||
AccountSettingsDialog dialog = new AccountSettingsDialog(plugin, account);
|
ContactDetailsDialog dialog = new ContactDetailsDialog(plugin, account, account.bare_jid);
|
||||||
dialog.set_transient_for((Window) get_toplevel());
|
dialog.set_transient_for((Window) get_toplevel());
|
||||||
dialog.present();
|
dialog.present();
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,10 +12,15 @@ public class ContactDetailsDialog : Gtk.Dialog {
|
||||||
private Plugin plugin;
|
private Plugin plugin;
|
||||||
private Account account;
|
private Account account;
|
||||||
private Jid jid;
|
private Jid jid;
|
||||||
|
private bool own = false;
|
||||||
|
private int own_id = 0;
|
||||||
|
|
||||||
private Gee.List<Widget> toggles;
|
private Gee.List<Widget> toggles;
|
||||||
|
|
||||||
[GtkChild] private Grid fingerprints;
|
[GtkChild] private Grid fingerprints;
|
||||||
|
[GtkChild] private Box own_fingerprint_label;
|
||||||
|
[GtkChild] private Frame own_fingerprint_container;
|
||||||
|
[GtkChild] private Grid own_fingerprint;
|
||||||
[GtkChild] private Box fingerprints_prompt_label;
|
[GtkChild] private Box fingerprints_prompt_label;
|
||||||
[GtkChild] private Frame fingerprints_prompt_container;
|
[GtkChild] private Frame fingerprints_prompt_container;
|
||||||
[GtkChild] private Grid fingerprints_prompt;
|
[GtkChild] private Grid fingerprints_prompt;
|
||||||
|
@ -33,12 +38,14 @@ public class ContactDetailsDialog : Gtk.Dialog {
|
||||||
.with(plugin.db.identity_meta.device_id, "=", device[plugin.db.identity_meta.device_id])
|
.with(plugin.db.identity_meta.device_id, "=", device[plugin.db.identity_meta.device_id])
|
||||||
.set(plugin.db.identity_meta.trust_level, trust_level).perform();
|
.set(plugin.db.identity_meta.trust_level, trust_level).perform();
|
||||||
|
|
||||||
|
if (!own) {
|
||||||
if(!trust) {
|
if(!trust) {
|
||||||
plugin.app.stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).untrust_device(jid, device[plugin.db.identity_meta.device_id]);
|
plugin.app.stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).untrust_device(jid, device[plugin.db.identity_meta.device_id]);
|
||||||
} else {
|
} else {
|
||||||
plugin.app.stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).trust_device(jid, device[plugin.db.identity_meta.device_id]);
|
plugin.app.stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).trust_device(jid, device[plugin.db.identity_meta.device_id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void add_fingerprint(Row device, int row, Database.IdentityMetaTable.TrustLevel trust) {
|
private void add_fingerprint(Row device, int row, Database.IdentityMetaTable.TrustLevel trust) {
|
||||||
string res = fingerprint_markup(fingerprint_from_base64(device[plugin.db.identity_meta.identity_key_public_base64]));
|
string res = fingerprint_markup(fingerprint_from_base64(device[plugin.db.identity_meta.identity_key_public_base64]));
|
||||||
|
@ -65,11 +72,34 @@ public class ContactDetailsDialog : Gtk.Dialog {
|
||||||
|
|
||||||
toggles = new ArrayList<Widget>();
|
toggles = new ArrayList<Widget>();
|
||||||
|
|
||||||
|
if(jid.equals(account.bare_jid)) {
|
||||||
|
own = true;
|
||||||
|
own_id = plugin.db.identity.row_with(plugin.db.identity.account_id, account.id)[plugin.db.identity.device_id];
|
||||||
|
own_fingerprint_label.visible = true;
|
||||||
|
own_fingerprint_container.visible = true;
|
||||||
|
string own_b64 = plugin.db.identity.row_with(plugin.db.identity.account_id, account.id)[plugin.db.identity.identity_key_public_base64];
|
||||||
|
string fingerprint = fingerprint_from_base64(own_b64);
|
||||||
|
Label lbl = new Label(fingerprint_markup(fingerprint))
|
||||||
|
{ use_markup=true, justify=Justification.RIGHT, visible=true, margin = 8, halign = Align.START };
|
||||||
|
|
||||||
|
Box box = new Box(Gtk.Orientation.HORIZONTAL, 0) { visible = true, valign = Align.CENTER, hexpand = true, margin = 8 };
|
||||||
|
|
||||||
|
Button copy = new Button() { visible = true, valign = Align.CENTER, halign = Align.END, hexpand = false };
|
||||||
|
copy.image = new Image.from_icon_name("edit-copy-symbolic", IconSize.BUTTON);
|
||||||
|
copy.clicked.connect(() => {Clipboard.get_default(get_display()).set_text(fingerprint, fingerprint.length);});
|
||||||
|
box.pack_start(lbl);
|
||||||
|
box.pack_end(copy);
|
||||||
|
own_fingerprint.attach(box, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (Row device in plugin.db.identity_meta.with_address(account.id, jid.to_string()).with(plugin.db.identity_meta.trust_level, "!=", Database.IdentityMetaTable.TrustLevel.UNKNOWN).with(plugin.db.identity_meta.trust_level, "!=", Database.IdentityMetaTable.TrustLevel.VERIFIED)) {
|
foreach (Row device in plugin.db.identity_meta.with_address(account.id, jid.to_string()).with(plugin.db.identity_meta.trust_level, "!=", Database.IdentityMetaTable.TrustLevel.UNKNOWN).with(plugin.db.identity_meta.trust_level, "!=", Database.IdentityMetaTable.TrustLevel.VERIFIED)) {
|
||||||
if (device[plugin.db.identity_meta.identity_key_public_base64] == null) {
|
if (device[plugin.db.identity_meta.identity_key_public_base64] == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if(own && device[plugin.db.identity_meta.device_id] == own_id) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
add_fingerprint(device, i, (Database.IdentityMetaTable.TrustLevel) device[plugin.db.identity_meta.trust_level]);
|
add_fingerprint(device, i, (Database.IdentityMetaTable.TrustLevel) device[plugin.db.identity_meta.trust_level]);
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
|
@ -81,6 +111,9 @@ public class ContactDetailsDialog : Gtk.Dialog {
|
||||||
if (device[plugin.db.identity_meta.identity_key_public_base64] == null) {
|
if (device[plugin.db.identity_meta.identity_key_public_base64] == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if(own && device[plugin.db.identity_meta.device_id] == own_id) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
string res = fingerprint_markup(fingerprint_from_base64(device[plugin.db.identity_meta.identity_key_public_base64]));
|
string res = fingerprint_markup(fingerprint_from_base64(device[plugin.db.identity_meta.identity_key_public_base64]));
|
||||||
Label lbl = new Label(res)
|
Label lbl = new Label(res)
|
||||||
|
@ -143,6 +176,9 @@ public class ContactDetailsDialog : Gtk.Dialog {
|
||||||
|
|
||||||
int k = 0;
|
int k = 0;
|
||||||
foreach (Row device in plugin.db.identity_meta.with_address(account.id, jid.to_string()).without_null(plugin.db.identity_meta.identity_key_public_base64).with(plugin.db.identity_meta.trust_level, "=", Database.IdentityMetaTable.TrustLevel.VERIFIED)) {
|
foreach (Row device in plugin.db.identity_meta.with_address(account.id, jid.to_string()).without_null(plugin.db.identity_meta.identity_key_public_base64).with(plugin.db.identity_meta.trust_level, "=", Database.IdentityMetaTable.TrustLevel.VERIFIED)) {
|
||||||
|
if(own && device[plugin.db.identity_meta.device_id] == own_id) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
string res = fingerprint_markup(fingerprint_from_base64(device[plugin.db.identity_meta.identity_key_public_base64]));
|
string res = fingerprint_markup(fingerprint_from_base64(device[plugin.db.identity_meta.identity_key_public_base64]));
|
||||||
Label lbl = new Label(res)
|
Label lbl = new Label(res)
|
||||||
{ use_markup=true, justify=Justification.RIGHT, visible=true, margin = 8, halign = Align.START };
|
{ use_markup=true, justify=Justification.RIGHT, visible=true, margin = 8, halign = Align.START };
|
||||||
|
|
|
@ -98,6 +98,15 @@ public class Manager : StreamInteractionModule, Object {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
StreamModule module = (!)module_;
|
StreamModule module = (!)module_;
|
||||||
|
|
||||||
|
foreach (Row row in db.identity_meta.with_address(conversation.account.id, conversation.account.bare_jid.to_string())){
|
||||||
|
if(row[db.identity_meta.trust_level] == Database.IdentityMetaTable.TrustLevel.TRUSTED || row[db.identity_meta.trust_level] == Database.IdentityMetaTable.TrustLevel.VERIFIED){
|
||||||
|
module.trust_device(conversation.account.bare_jid, row[db.identity_meta.device_id]);
|
||||||
|
} else {
|
||||||
|
module.untrust_device(conversation.account.bare_jid, row[db.identity_meta.device_id]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
EncryptState enc_state = module.encrypt(message_stanza, conversation.account.bare_jid);
|
EncryptState enc_state = module.encrypt(message_stanza, conversation.account.bare_jid);
|
||||||
MessageState state;
|
MessageState state;
|
||||||
lock (message_states) {
|
lock (message_states) {
|
||||||
|
|
Loading…
Reference in a new issue