Add a toggle switch for key management
This commit is contained in:
parent
a3c0c24b7e
commit
20fe944c2d
|
@ -9,6 +9,27 @@
|
||||||
<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">
|
||||||
|
<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="halign">start</property>
|
||||||
|
<property name="hexpand">True</property>
|
||||||
|
<property name="label" translatable="yes">Enable Key Management</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSwitch" id="key_mgmnt">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="halign">end</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="fingerprints_prompt_label">
|
<object class="GtkBox" id="fingerprints_prompt_label">
|
||||||
<property name="margin-top">12</property>
|
<property name="margin-top">12</property>
|
||||||
|
@ -107,7 +128,8 @@
|
||||||
</attributes>
|
</attributes>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<!-- TODO: implement QR code verification !-->
|
||||||
|
<!--<child>
|
||||||
<object class="GtkButton" id="scan_button">
|
<object class="GtkButton" id="scan_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
|
@ -122,7 +144,7 @@
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>!-->
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
|
|
|
@ -13,6 +13,8 @@ public class ContactDetailsDialog : Gtk.Dialog {
|
||||||
private Account account;
|
private Account account;
|
||||||
private Jid jid;
|
private Jid jid;
|
||||||
|
|
||||||
|
private Gee.List<Widget> toggles;
|
||||||
|
|
||||||
[GtkChild] private Grid fingerprints;
|
[GtkChild] private Grid fingerprints;
|
||||||
[GtkChild] private Box fingerprints_prompt_label;
|
[GtkChild] private Box fingerprints_prompt_label;
|
||||||
[GtkChild] private Frame fingerprints_prompt_container;
|
[GtkChild] private Frame fingerprints_prompt_container;
|
||||||
|
@ -20,6 +22,7 @@ public class ContactDetailsDialog : Gtk.Dialog {
|
||||||
[GtkChild] private Box fingerprints_verified_label;
|
[GtkChild] private Box fingerprints_verified_label;
|
||||||
[GtkChild] private Frame fingerprints_verified_container;
|
[GtkChild] private Frame fingerprints_verified_container;
|
||||||
[GtkChild] private Grid fingerprints_verified;
|
[GtkChild] private Grid fingerprints_verified;
|
||||||
|
[GtkChild] private Switch key_mgmnt;
|
||||||
|
|
||||||
|
|
||||||
private void set_device_trust(Row device, bool trust) {
|
private void set_device_trust(Row device, bool trust) {
|
||||||
|
@ -48,6 +51,7 @@ public class ContactDetailsDialog : Gtk.Dialog {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
toggles.add(tgl);
|
||||||
|
|
||||||
fingerprints.attach(lbl, 0, row);
|
fingerprints.attach(lbl, 0, row);
|
||||||
fingerprints.attach(tgl, 1, row);
|
fingerprints.attach(tgl, 1, row);
|
||||||
|
@ -59,6 +63,8 @@ public class ContactDetailsDialog : Gtk.Dialog {
|
||||||
this.account = account;
|
this.account = account;
|
||||||
this.jid = jid;
|
this.jid = jid;
|
||||||
|
|
||||||
|
toggles = new ArrayList<Widget>();
|
||||||
|
|
||||||
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.trusted_identity, "!=", Database.IdentityMetaTable.TrustLevel.UNKNOWN).with(plugin.db.identity_meta.trusted_identity, "!=", Database.IdentityMetaTable.TrustLevel.VERIFIED)) {
|
foreach (Row device in plugin.db.identity_meta.with_address(account.id, jid.to_string()).with(plugin.db.identity_meta.trusted_identity, "!=", Database.IdentityMetaTable.TrustLevel.UNKNOWN).with(plugin.db.identity_meta.trusted_identity, "!=", 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) {
|
||||||
|
@ -90,6 +96,7 @@ public class ContactDetailsDialog : Gtk.Dialog {
|
||||||
|
|
||||||
fingerprints_prompt.remove(box);
|
fingerprints_prompt.remove(box);
|
||||||
fingerprints_prompt.remove(lbl);
|
fingerprints_prompt.remove(lbl);
|
||||||
|
toggles.remove(box);
|
||||||
j--;
|
j--;
|
||||||
|
|
||||||
add_fingerprint(device, i, Database.IdentityMetaTable.TrustLevel.TRUSTED);
|
add_fingerprint(device, i, Database.IdentityMetaTable.TrustLevel.TRUSTED);
|
||||||
|
@ -108,6 +115,7 @@ public class ContactDetailsDialog : Gtk.Dialog {
|
||||||
|
|
||||||
fingerprints_prompt.remove(box);
|
fingerprints_prompt.remove(box);
|
||||||
fingerprints_prompt.remove(lbl);
|
fingerprints_prompt.remove(lbl);
|
||||||
|
toggles.remove(box);
|
||||||
j--;
|
j--;
|
||||||
|
|
||||||
add_fingerprint(device, i, Database.IdentityMetaTable.TrustLevel.UNTRUSTED);
|
add_fingerprint(device, i, Database.IdentityMetaTable.TrustLevel.UNTRUSTED);
|
||||||
|
@ -122,6 +130,7 @@ public class ContactDetailsDialog : Gtk.Dialog {
|
||||||
box.pack_start(no);
|
box.pack_start(no);
|
||||||
|
|
||||||
box.get_style_context().add_class("linked");
|
box.get_style_context().add_class("linked");
|
||||||
|
toggles.add(box);
|
||||||
|
|
||||||
fingerprints_prompt.attach(lbl, 0, j);
|
fingerprints_prompt.attach(lbl, 0, j);
|
||||||
fingerprints_prompt.attach(box, 1, j);
|
fingerprints_prompt.attach(box, 1, j);
|
||||||
|
@ -148,6 +157,7 @@ public class ContactDetailsDialog : Gtk.Dialog {
|
||||||
|
|
||||||
fingerprints_verified.remove(no);
|
fingerprints_verified.remove(no);
|
||||||
fingerprints_verified.remove(lbl);
|
fingerprints_verified.remove(lbl);
|
||||||
|
toggles.remove(no);
|
||||||
k--;
|
k--;
|
||||||
|
|
||||||
add_fingerprint(device, i, Database.IdentityMetaTable.TrustLevel.UNTRUSTED);
|
add_fingerprint(device, i, Database.IdentityMetaTable.TrustLevel.UNTRUSTED);
|
||||||
|
@ -159,6 +169,7 @@ public class ContactDetailsDialog : Gtk.Dialog {
|
||||||
});
|
});
|
||||||
|
|
||||||
box.pack_end(no);
|
box.pack_end(no);
|
||||||
|
toggles.add(no);
|
||||||
|
|
||||||
fingerprints_verified.attach(lbl, 0, k);
|
fingerprints_verified.attach(lbl, 0, k);
|
||||||
fingerprints_verified.attach(box, 1, k);
|
fingerprints_verified.attach(box, 1, k);
|
||||||
|
@ -169,6 +180,22 @@ public class ContactDetailsDialog : Gtk.Dialog {
|
||||||
fingerprints_verified_label.visible = true;
|
fingerprints_verified_label.visible = true;
|
||||||
fingerprints_verified_container.visible = true;
|
fingerprints_verified_container.visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool blind_trust = plugin.db.trust.get_blind_trust(account.id, jid.bare_jid.to_string());
|
||||||
|
key_mgmnt.set_active(!blind_trust);
|
||||||
|
foreach(Widget tgl in toggles){
|
||||||
|
tgl.set_sensitive(!blind_trust);
|
||||||
|
}
|
||||||
|
|
||||||
|
key_mgmnt.state_set.connect((active) => {
|
||||||
|
plugin.db.trust.update().with(plugin.db.trust.identity_id, "=", account.id).with(plugin.db.trust.address_name, "=", jid.bare_jid.to_string()).set(plugin.db.trust.blind_trust, !active).perform();
|
||||||
|
foreach(Widget tgl in toggles){
|
||||||
|
tgl.set_sensitive(active);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,7 +218,6 @@ public class Manager : StreamInteractionModule, Object {
|
||||||
if(module == null) return;
|
if(module == null) return;
|
||||||
|
|
||||||
HashSet<Entities.Message> send_now = new HashSet<Entities.Message>();
|
HashSet<Entities.Message> send_now = new HashSet<Entities.Message>();
|
||||||
bool session_needed = false;
|
|
||||||
lock (message_states) {
|
lock (message_states) {
|
||||||
foreach (Entities.Message msg in message_states.keys) {
|
foreach (Entities.Message msg in message_states.keys) {
|
||||||
bool session_created = true;
|
bool session_created = true;
|
||||||
|
|
Loading…
Reference in a new issue