Show modal dialog to select default encryption if unknown
This commit is contained in:
parent
366a49a820
commit
302e770a98
|
@ -33,7 +33,7 @@ public class Conversation : Object {
|
|||
}
|
||||
}
|
||||
}
|
||||
public Encryption encryption { get; set; default = Encryption.NONE; }
|
||||
public Encryption encryption { get; set; default = Encryption.UNKNOWN; }
|
||||
public Message? read_up_to { get; set; }
|
||||
public int read_up_to_item { get; set; default=-1; }
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@ set(RESOURCE_LIST
|
|||
conversation_list_titlebar_csd.ui
|
||||
conversation_row.ui
|
||||
conversation_view.ui
|
||||
default_encryption_dialog.ui
|
||||
file_default_widget.ui
|
||||
file_send_overlay.ui
|
||||
emojichooser.ui
|
||||
|
|
|
@ -0,0 +1,125 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.22.2 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.6"/>
|
||||
<object class="GtkDialog" id="dialog">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="modal">True</property>
|
||||
<property name="default_width">320</property>
|
||||
<property name="default_height">260</property>
|
||||
<property name="type_hint">dialog</property>
|
||||
<child type="titlebar">
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkBox">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkButtonBox">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="layout_style">end</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="accept_button">
|
||||
<property name="label" translatable="yes">OK</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="default_encryption_warning_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xpad">10</property>
|
||||
<property name="ypad">10</property>
|
||||
<property name="label" translatable="yes">No default end-to-end encryption method has been previously selected for this conversation. XMPP defines some XEP for end-to-end encryption that Dino supports.
|
||||
|
||||
It is strongly recommended that one of the following end-to-end encryption methods below is selected before sending a message.
|
||||
|
||||
TAKE INTO ACCOUNT UNENCRYPTED CONVERSATIONS COULD BE READ BY THIRD PARTIES.
|
||||
|
||||
These settings can be later changed from the Settings menu.</property>
|
||||
<property name="wrap">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="omemo">
|
||||
<property name="label" translatable="yes">OMEMO (XEP-0384)</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="active">True</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="openpgp">
|
||||
<property name="label" translatable="yes">OpenPGP (XEP-0027)</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="active">True</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<property name="group">omemo</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="none">
|
||||
<property name="label" translatable="yes">Unencrypted (not recommended)</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="active">True</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<property name="group">omemo</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
|
@ -110,6 +110,67 @@ public class ConversationViewController : Object {
|
|||
((Gtk.Window)view.get_toplevel()).add_accel_group(accel_group);
|
||||
}
|
||||
|
||||
private void update_conversation_encryption(Conversation? conversation) {
|
||||
if (conversation == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool visible = false;
|
||||
|
||||
// FIXME duplicate logic from encryption_button.vala
|
||||
switch (conversation.type_) {
|
||||
case Conversation.Type.CHAT:
|
||||
visible = true;
|
||||
break;
|
||||
case Conversation.Type.GROUPCHAT_PM:
|
||||
visible = false;
|
||||
break;
|
||||
case Conversation.Type.GROUPCHAT:
|
||||
visible = stream_interactor.get_module(MucManager.IDENTITY).is_private_room(conversation.account, conversation.counterpart);
|
||||
break;
|
||||
}
|
||||
|
||||
if (visible && conversation.encryption == UNKNOWN) {
|
||||
Dino.Entities.Settings settings = Dino.Application.get_default().settings;
|
||||
|
||||
if (settings.default_encryption == UNKNOWN) {
|
||||
var selection_dialog_builder = new Builder.from_resource("/im/dino/Dino/default_encryption_dialog.ui");
|
||||
var selection_dialog = selection_dialog_builder.get_object("dialog") as Dialog;
|
||||
var omemo_radio = selection_dialog_builder.get_object("omemo") as RadioButton;
|
||||
var openpgp_radio = selection_dialog_builder.get_object("openpgp") as RadioButton;
|
||||
var none_radio = selection_dialog_builder.get_object("none") as RadioButton;
|
||||
var accept_button = selection_dialog_builder.get_object("accept_button") as Button;
|
||||
Encryption selected_default = UNKNOWN;
|
||||
|
||||
accept_button.clicked.connect(() => {
|
||||
if (omemo_radio.active) {selected_default = OMEMO;}
|
||||
else if (openpgp_radio.active) {selected_default = PGP;}
|
||||
else if (none_radio.active) {selected_default = NONE;}
|
||||
|
||||
selection_dialog.response(selected_default);
|
||||
selection_dialog.close();
|
||||
});
|
||||
|
||||
selection_dialog.run();
|
||||
conversation.encryption = selected_default;
|
||||
|
||||
if (selected_default != NONE) {
|
||||
settings.default_encryption = selected_default;
|
||||
}
|
||||
else {
|
||||
// Set conversation as unencrypted, but keep
|
||||
// default encryption setting as undecided.
|
||||
}
|
||||
}
|
||||
else {
|
||||
conversation.encryption = settings.default_encryption;
|
||||
}
|
||||
}
|
||||
else if (!visible) {
|
||||
conversation.encryption = Encryption.NONE;
|
||||
}
|
||||
}
|
||||
|
||||
public void select_conversation(Conversation? conversation, bool default_initialize_conversation) {
|
||||
if (this.conversation != null) {
|
||||
conversation.notify["encryption"].disconnect(update_file_upload_status);
|
||||
|
@ -120,6 +181,8 @@ public class ConversationViewController : Object {
|
|||
|
||||
this.conversation = conversation;
|
||||
|
||||
update_conversation_encryption(conversation);
|
||||
|
||||
conversation.notify["encryption"].connect(update_file_upload_status);
|
||||
|
||||
chat_input_controller.set_conversation(conversation);
|
||||
|
|
Loading…
Reference in New Issue