Rework encryption enabling logic + UI

This commit is contained in:
fiaxh 2019-08-02 03:15:12 +02:00
parent 9ee9661bf3
commit 08a5088c16
18 changed files with 481 additions and 201 deletions

View file

@ -25,7 +25,7 @@ public interface EncryptionListEntry : Object {
public abstract Entities.Encryption encryption { get; } public abstract Entities.Encryption encryption { get; }
public abstract string name { get; } public abstract string name { get; }
public abstract bool can_encrypt(Conversation conversation); public abstract void encryption_activated(Entities.Conversation conversation, Plugins.SetInputFieldStatus callback);
} }
public abstract class AccountSettingsEntry : Object { public abstract class AccountSettingsEntry : Object {
@ -123,4 +123,29 @@ public interface NotificationCollection : Object {
public signal void remove_meta_notification(MetaConversationNotification item); public signal void remove_meta_notification(MetaConversationNotification item);
} }
public delegate void SetInputFieldStatus(InputFieldStatus field_status);
public class InputFieldStatus : Object {
public enum MessageType {
NONE,
INFO,
WARNING,
ERROR
}
public enum InputState {
NORMAL,
DISABLED,
NO_SEND
}
public string? message;
public MessageType message_type;
public InputState input_state;
public InputFieldStatus(string? message, MessageType message_type, InputState input_state) {
this.message = message;
this.message_type = message_type;
this.input_state = input_state;
}
}
} }

View file

@ -80,6 +80,17 @@ SOURCES
src/main.vala src/main.vala
src/ui/application.vala src/ui/application.vala
src/ui/avatar_generator.vala
src/ui/avatar_image.vala
src/ui/chat_input_controller.vala
src/ui/conversation_list_titlebar.vala
src/ui/conversation_list_titlebar_csd.vala
src/ui/global_search.vala
src/ui/notifications.vala
src/ui/settings_dialog.vala
src/ui/unified_window.vala
src/ui/unified_window_controller.vala
src/ui/add_conversation/add_conference_dialog.vala src/ui/add_conversation/add_conference_dialog.vala
src/ui/add_conversation/add_contact_dialog.vala src/ui/add_conversation/add_contact_dialog.vala
src/ui/add_conversation/add_groupchat_dialog.vala src/ui/add_conversation/add_groupchat_dialog.vala
@ -89,22 +100,21 @@ SOURCES
src/ui/add_conversation/roster_list.vala src/ui/add_conversation/roster_list.vala
src/ui/add_conversation/select_contact_dialog.vala src/ui/add_conversation/select_contact_dialog.vala
src/ui/add_conversation/select_jid_fragment.vala src/ui/add_conversation/select_jid_fragment.vala
src/ui/avatar_generator.vala
src/ui/avatar_image.vala
src/ui/chat_input/edit_history.vala src/ui/chat_input/edit_history.vala
src/ui/chat_input/encryption_button.vala src/ui/chat_input/encryption_button.vala
src/ui/chat_input/occupants_tab_completer.vala src/ui/chat_input/occupants_tab_completer.vala
src/ui/chat_input/smiley_converter.vala src/ui/chat_input/smiley_converter.vala
src/ui/chat_input/view.vala src/ui/chat_input/view.vala
src/ui/contact_details/blocking_provider.vala src/ui/contact_details/blocking_provider.vala
src/ui/contact_details/settings_provider.vala src/ui/contact_details/settings_provider.vala
src/ui/contact_details/dialog.vala src/ui/contact_details/dialog.vala
src/ui/contact_details/muc_config_form_provider.vala src/ui/contact_details/muc_config_form_provider.vala
src/ui/conversation_list_titlebar.vala
src/ui/conversation_list_titlebar_csd.vala
src/ui/global_search.vala
src/ui/conversation_selector/conversation_selector_row.vala src/ui/conversation_selector/conversation_selector_row.vala
src/ui/conversation_selector/conversation_selector.vala src/ui/conversation_selector/conversation_selector.vala
src/ui/conversation_summary/chat_state_populator.vala src/ui/conversation_summary/chat_state_populator.vala
src/ui/conversation_summary/content_item_widget_factory.vala src/ui/conversation_summary/content_item_widget_factory.vala
src/ui/conversation_summary/content_populator.vala src/ui/conversation_summary/content_populator.vala
@ -113,20 +123,20 @@ SOURCES
src/ui/conversation_summary/date_separator_populator.vala src/ui/conversation_summary/date_separator_populator.vala
src/ui/conversation_summary/file_widget.vala src/ui/conversation_summary/file_widget.vala
src/ui/conversation_summary/subscription_notification.vala src/ui/conversation_summary/subscription_notification.vala
src/ui/conversation_titlebar/menu_entry.vala src/ui/conversation_titlebar/menu_entry.vala
src/ui/conversation_titlebar/occupants_entry.vala src/ui/conversation_titlebar/occupants_entry.vala
src/ui/conversation_titlebar/search_entry.vala src/ui/conversation_titlebar/search_entry.vala
src/ui/conversation_titlebar/conversation_titlebar.vala src/ui/conversation_titlebar/conversation_titlebar.vala
src/ui/manage_accounts/account_row.vala src/ui/manage_accounts/account_row.vala
src/ui/manage_accounts/add_account_dialog.vala src/ui/manage_accounts/add_account_dialog.vala
src/ui/manage_accounts/dialog.vala src/ui/manage_accounts/dialog.vala
src/ui/notifications.vala
src/ui/occupant_menu/list.vala src/ui/occupant_menu/list.vala
src/ui/occupant_menu/list_row.vala src/ui/occupant_menu/list_row.vala
src/ui/occupant_menu/view.vala src/ui/occupant_menu/view.vala
src/ui/settings_dialog.vala
src/ui/unified_window.vala
src/ui/unified_window_controller.vala
src/ui/util/accounts_combo_box.vala src/ui/util/accounts_combo_box.vala
src/ui/util/data_forms.vala src/ui/util/data_forms.vala
src/ui/util/helper.vala src/ui/util/helper.vala

View file

@ -3,15 +3,15 @@
<requires lib="gtk+" version="3.22"/> <requires lib="gtk+" version="3.22"/>
<template class="DinoUiChatInputView"> <template class="DinoUiChatInputView">
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="orientation">horizontal</property> <property name="orientation">vertical</property>
<property name="visible">True</property> <property name="visible">True</property>
<style> <style>
<class name="dino-chatinput"/> <class name="dino-chatinput"/>
</style> </style>
<child> <child>
<object class="GtkFrame" id="frame"> <object class="GtkFrame" id="frame">
<property name="margin">12</property> <property name="margin_start">14</property>
<property name="margin_top">0</property> <property name="margin_end">14</property>
<property name="visible">True</property> <property name="visible">True</property>
<child> <child>
<object class="GtkBox" id="outer_box"> <object class="GtkBox" id="outer_box">
@ -65,5 +65,20 @@
</child> </child>
</object> </object>
</child> </child>
<child>
<object class="GtkLabel" id="chat_input_status">
<property name="xalign">0</property>
<property name="margin_bottom">3</property>
<property name="margin_start">14</property>
<property name="margin_end">14</property>
<property name="visible">True</property>
<attributes>
<attribute name="scale" value="0.8"/>
</attributes>
<style>
<class name="chat-input-status"/>
</style>
</object>
</child>
</template> </template>
</interface> </interface>

View file

@ -77,6 +77,10 @@ window.dino-main .dino-chatinput frame box {
background: transparent; background: transparent;
} }
window.dino-main button.dino-attach-button {
min-width: 24px; /* Make button the same with as avatars */
}
window.dino-main button.dino-chatinput-button { window.dino-main button.dino-chatinput-button {
border: none; border: none;
background: transparent; background: transparent;
@ -103,3 +107,51 @@ window.dino-main button.dino-chatinput-button:checked {
window.dino-main button.dino-chatinput-button:checked:backdrop { window.dino-main button.dino-chatinput-button:checked:backdrop {
color: alpha(@theme_unfocused_selected_bg_color, 0.8); color: alpha(@theme_unfocused_selected_bg_color, 0.8);
} }
.dino-chatinput textview, .dino-chatinput textview text {
background-color: transparent;
}
/*Chat input warning*/
box.dino-input-warning frame border {
border-color: @warning_color;
}
box.dino-input-warning frame separator {
background-color: @warning_color;
border: none;
}
box.dino-input-warning label {
color: mix(@warning_color, @theme_fg_color, 0.5);
}
/*Chat input error*/
box.dino-input-error frame border {
border-color: @error_color;
}
box.dino-input-error frame separator {
background-color: @error_color;
border: none;
}
box.dino-input-error label {
color: @error_color;
}
@keyframes input-error-highlight {
0% { color: mix(@error_color, @theme_fg_color, 0.3);}
30% { color: @error_color; text-shadow: 0px 0px 2px alpha(@error_color, 0.4); }
100% { color: mix(@error_color, @theme_fg_color, 0.3); }
}
box.dino-input-error label.input-status-highlight-once {
animation-duration: 1s;
animation-timing-function: linear;
animation-iteration-count: 1;
animation-name: input-error-highlight;
}

View file

@ -6,7 +6,7 @@ using Dino.Entities;
namespace Dino.Ui.ChatInput { namespace Dino.Ui.ChatInput {
class EditHistory { public class EditHistory {
private Conversation? conversation; private Conversation? conversation;
private TextView text_input; private TextView text_input;

View file

@ -7,6 +7,8 @@ namespace Dino.Ui {
public class EncryptionButton : MenuButton { public class EncryptionButton : MenuButton {
public signal void encryption_changed(Plugins.EncryptionListEntry? encryption_entry);
private Conversation? conversation; private Conversation? conversation;
private RadioButton? button_unencrypted; private RadioButton? button_unencrypted;
private Map<RadioButton, Plugins.EncryptionListEntry> encryption_radios = new HashMap<RadioButton, Plugins.EncryptionListEntry>(); private Map<RadioButton, Plugins.EncryptionListEntry> encryption_radios = new HashMap<RadioButton, Plugins.EncryptionListEntry>();
@ -25,38 +27,45 @@ public class EncryptionButton : MenuButton {
popover = builder.get_object("menu_encryption") as PopoverMenu; popover = builder.get_object("menu_encryption") as PopoverMenu;
Box encryption_box = builder.get_object("encryption_box") as Box; Box encryption_box = builder.get_object("encryption_box") as Box;
button_unencrypted = builder.get_object("button_unencrypted") as RadioButton; button_unencrypted = builder.get_object("button_unencrypted") as RadioButton;
button_unencrypted.toggled.connect(encryption_changed); button_unencrypted.toggled.connect(encryption_button_toggled);
Application app = GLib.Application.get_default() as Application; Application app = GLib.Application.get_default() as Application;
foreach (var e in app.plugin_registry.encryption_list_entries) { foreach (var e in app.plugin_registry.encryption_list_entries) {
RadioButton btn = new RadioButton.with_label(button_unencrypted.get_group(), e.name); RadioButton btn = new RadioButton.with_label(button_unencrypted.get_group(), e.name);
encryption_radios[btn] = e; encryption_radios[btn] = e;
btn.toggled.connect(encryption_changed); btn.toggled.connect(encryption_button_toggled);
btn.visible = true; btn.visible = true;
encryption_box.pack_end(btn, false); encryption_box.pack_end(btn, false);
} }
clicked.connect(update_encryption_menu_state); clicked.connect(update_encryption_menu_state);
} }
private void encryption_changed() { private void encryption_button_toggled() {
foreach (RadioButton e in encryption_radios.keys) { foreach (RadioButton e in encryption_radios.keys) {
if (e.get_active()) { if (e.get_active()) {
conversation.encryption = encryption_radios[e].encryption; conversation.encryption = encryption_radios[e].encryption;
encryption_changed(encryption_radios[e]);
update_encryption_menu_icon(); update_encryption_menu_icon();
return; return;
} }
} }
// Selected unencrypted
conversation.encryption = Encryption.NONE; conversation.encryption = Encryption.NONE;
update_encryption_menu_icon(); update_encryption_menu_icon();
encryption_changed(null);
} }
private void update_encryption_menu_state() { private void update_encryption_menu_state() {
foreach (RadioButton e in encryption_radios.keys) { foreach (RadioButton e in encryption_radios.keys) {
e.set_sensitive(encryption_radios[e].can_encrypt(conversation)); if (conversation.encryption == encryption_radios[e].encryption) {
if (conversation.encryption == encryption_radios[e].encryption) e.set_active(true); e.set_active(true);
encryption_changed(encryption_radios[e]);
}
} }
if (conversation.encryption == Encryption.NONE) { if (conversation.encryption == Encryption.NONE) {
button_unencrypted.set_active(true); button_unencrypted.set_active(true);
encryption_changed(null);
} }
} }

View file

@ -13,7 +13,7 @@ namespace Dino.Ui.ChatInput {
* - At the start (with ",") and in the middle of a text * - At the start (with ",") and in the middle of a text
* - Backwards tabbing * - Backwards tabbing
*/ */
class OccupantsTabCompletor { public class OccupantsTabCompletor {
private StreamInteractor stream_interactor; private StreamInteractor stream_interactor;
private Conversation? conversation; private Conversation? conversation;

View file

@ -8,7 +8,6 @@ namespace Dino.Ui.ChatInput {
class SmileyConverter { class SmileyConverter {
private StreamInteractor stream_interactor;
private TextView text_input; private TextView text_input;
private static HashMap<string, string> smiley_translations = new HashMap<string, string>(); private static HashMap<string, string> smiley_translations = new HashMap<string, string>();
@ -27,8 +26,7 @@ class SmileyConverter {
smiley_translations[":/"] = "😕"; smiley_translations[":/"] = "😕";
} }
public SmileyConverter(StreamInteractor stream_interactor, TextView text_input) { public SmileyConverter(TextView text_input) {
this.stream_interactor = stream_interactor;
this.text_input = text_input; this.text_input = text_input;
text_input.key_press_event.connect(on_text_input_key_press); text_input.key_press_event.connect(on_text_input_key_press);

View file

@ -10,6 +10,8 @@ namespace Dino.Ui.ChatInput {
[GtkTemplate (ui = "/im/dino/Dino/chat_input.ui")] [GtkTemplate (ui = "/im/dino/Dino/chat_input.ui")]
public class View : Box { public class View : Box {
public signal void send_text(string text);
public string text { public string text {
owned get { return text_input.buffer.text; } owned get { return text_input.buffer.text; }
set { text_input.buffer.text = value; } set { text_input.buffer.text = value; }
@ -20,44 +22,36 @@ public class View : Box {
private HashMap<Conversation, string> entry_cache = new HashMap<Conversation, string>(Conversation.hash_func, Conversation.equals_func); private HashMap<Conversation, string> entry_cache = new HashMap<Conversation, string>(Conversation.hash_func, Conversation.equals_func);
private int vscrollbar_min_height; private int vscrollbar_min_height;
private OccupantsTabCompletor occupants_tab_completor; public OccupantsTabCompletor occupants_tab_completor;
private SmileyConverter smiley_converter; private SmileyConverter smiley_converter;
private EditHistory edit_history; public EditHistory edit_history;
[GtkChild] private Frame frame; [GtkChild] public Frame frame;
[GtkChild] private ScrolledWindow scrolled; [GtkChild] public ScrolledWindow scrolled;
[GtkChild] public TextView text_input; [GtkChild] public TextView text_input;
[GtkChild] private Box outer_box; [GtkChild] public Box outer_box;
[GtkChild] private Button file_button; [GtkChild] public Button file_button;
[GtkChild] private Separator file_separator; [GtkChild] public Separator file_separator;
private EncryptionButton encryption_widget; [GtkChild] public Label chat_input_status;
public EncryptionButton encryption_widget;
public View init(StreamInteractor stream_interactor) { public View init(StreamInteractor stream_interactor) {
this.stream_interactor = stream_interactor; this.stream_interactor = stream_interactor;
occupants_tab_completor = new OccupantsTabCompletor(stream_interactor, text_input); occupants_tab_completor = new OccupantsTabCompletor(stream_interactor, text_input);
smiley_converter = new SmileyConverter(stream_interactor, text_input); smiley_converter = new SmileyConverter(text_input);
edit_history = new EditHistory(text_input, GLib.Application.get_default()); edit_history = new EditHistory(text_input, GLib.Application.get_default());
encryption_widget = new EncryptionButton(stream_interactor) { margin_top=3, valign=Align.START, visible=true }; encryption_widget = new EncryptionButton(stream_interactor) { margin_top=3, valign=Align.START, visible=true };
file_button.clicked.connect(() => { file_button.clicked.connect(() => {
PreviewFileChooserNative chooser = new PreviewFileChooserNative("Select file", get_toplevel() as Gtk.Window, FileChooserAction.OPEN, "Select", "Cancel"); PreviewFileChooserNative chooser = new PreviewFileChooserNative("Select file", get_toplevel() as Gtk.Window, FileChooserAction.OPEN, "Select", "Cancel");
// long max_file_size = stream_interactor.get_module(Manager.IDENTITY).get_max_file_size(conversation.account);
// if (max_file_size != -1) {
// FileFilter filter = new FileFilter();
// filter.add_custom(FileFilterFlags.URI, (filter_info) => {
// File file = File.new_for_uri(filter_info.uri);
// FileInfo file_info = file.query_info("*", FileQueryInfoFlags.NONE);
// return file_info.get_size() <= max_file_size;
// });
// chooser.set_filter(filter);
// }
if (chooser.run() == Gtk.ResponseType.ACCEPT) { if (chooser.run() == Gtk.ResponseType.ACCEPT) {
string uri = chooser.get_filename(); string uri = chooser.get_filename();
stream_interactor.get_module(FileManager.IDENTITY).send_file.begin(uri, conversation); stream_interactor.get_module(FileManager.IDENTITY).send_file.begin(uri, conversation);
} }
}); });
file_button.get_style_context().add_class("dino-attach-button");
scrolled.get_vscrollbar().get_preferred_height(out vscrollbar_min_height, null); scrolled.get_vscrollbar().get_preferred_height(out vscrollbar_min_height, null);
scrolled.vadjustment.notify["upper"].connect_after(on_upper_notify); scrolled.vadjustment.notify["upper"].connect_after(on_upper_notify);
@ -66,18 +60,14 @@ public class View : Box {
outer_box.add(encryption_widget); outer_box.add(encryption_widget);
text_input.key_press_event.connect(on_text_input_key_press); text_input.key_press_event.connect(on_text_input_key_press);
text_input.buffer.changed.connect(on_text_input_changed);
Util.force_css(frame, "* { border-radius: 3px; }"); Util.force_css(frame, "* { border-radius: 3px; }");
stream_interactor.get_module(FileManager.IDENTITY).upload_available.connect(on_upload_available);
return this; return this;
} }
public void initialize_for_conversation(Conversation conversation) { public void initialize_for_conversation(Conversation conversation) {
occupants_tab_completor.initialize_for_conversation(conversation);
edit_history.initialize_for_conversation(conversation);
encryption_widget.set_conversation(conversation);
if (this.conversation != null) entry_cache[this.conversation] = text_input.buffer.text; if (this.conversation != null) entry_cache[this.conversation] = text_input.buffer.text;
this.conversation = conversation; this.conversation = conversation;
@ -86,74 +76,49 @@ public class View : Box {
file_button.visible = upload_available; file_button.visible = upload_available;
file_separator.visible = upload_available; file_separator.visible = upload_available;
text_input.buffer.changed.disconnect(on_text_input_changed);
text_input.buffer.text = ""; text_input.buffer.text = "";
if (entry_cache.has_key(conversation)) { if (entry_cache.has_key(conversation)) {
text_input.buffer.text = entry_cache[conversation]; text_input.buffer.text = entry_cache[conversation];
} }
text_input.buffer.changed.connect(on_text_input_changed);
text_input.grab_focus(); text_input.grab_focus();
} }
private void send_text() { public void set_input_state(Plugins.InputFieldStatus.MessageType message_type) {
string text = text_input.buffer.text; switch (message_type) {
text_input.buffer.text = ""; case Plugins.InputFieldStatus.MessageType.NONE:
if (text.has_prefix("/")) { this.get_style_context().remove_class("dino-input-warning");
string[] token = text.split(" ", 2); this.get_style_context().remove_class("dino-input-error");
switch(token[0]) { break;
case "/me": case Plugins.InputFieldStatus.MessageType.INFO:
// Just send as is. this.get_style_context().remove_class("dino-input-warning");
break; this.get_style_context().remove_class("dino-input-error");
case "/say": break;
if (token.length == 1) return; case Plugins.InputFieldStatus.MessageType.WARNING:
text = token[1]; this.get_style_context().add_class("dino-input-warning");
break; this.get_style_context().remove_class("dino-input-error");
case "/kick": break;
stream_interactor.get_module(MucManager.IDENTITY).kick(conversation.account, conversation.counterpart, token[1]); case Plugins.InputFieldStatus.MessageType.ERROR:
return; this.get_style_context().remove_class("dino-input-warning");
case "/affiliate": this.get_style_context().add_class("dino-input-error");
if (token.length > 1) { break;
string[] user_role = token[1].split(" ", 2);
if (user_role.length == 2) {
stream_interactor.get_module(MucManager.IDENTITY).change_affiliation(conversation.account, conversation.counterpart, user_role[0].strip(), user_role[1].strip());
}
}
return;
case "/nick":
stream_interactor.get_module(MucManager.IDENTITY).change_nick(conversation.account, conversation.counterpart, token[1]);
return;
case "/ping":
Xmpp.XmppStream? stream = stream_interactor.get_stream(conversation.account);
stream.get_module(Xmpp.Xep.Ping.Module.IDENTITY).send_ping(stream, conversation.counterpart.with_resource(token[1]), null);
return;
case "/topic":
stream_interactor.get_module(MucManager.IDENTITY).change_subject(conversation.account, conversation.counterpart, token[1]);
return;
default:
if (token[0].has_prefix("//")) {
text = text.substring(1);
} else {
string cmd_name = token[0].substring(1);
Dino.Application app = GLib.Application.get_default() as Dino.Application;
if (app != null && app.plugin_registry.text_commands.has_key(cmd_name)) {
string? new_text = app.plugin_registry.text_commands[cmd_name].handle_command(token[1], conversation);
if (new_text == null) return;
text = (!)new_text;
}
}
break;
}
} }
stream_interactor.get_module(MessageProcessor.IDENTITY).send_text(text, conversation); }
public void highlight_state_description() {
chat_input_status.get_style_context().add_class("input-status-highlight-once");
Timeout.add_seconds(1, () => {
chat_input_status.get_style_context().remove_class("input-status-highlight-once");
return false;
});
} }
private bool on_text_input_key_press(EventKey event) { private bool on_text_input_key_press(EventKey event) {
if (event.keyval in new uint[]{Key.Return, Key.KP_Enter}) { if (event.keyval in new uint[]{Key.Return, Key.KP_Enter}) {
if ((event.state & ModifierType.SHIFT_MASK) > 0) { if ((event.state & ModifierType.SHIFT_MASK) > 0) {
text_input.buffer.insert_at_cursor("\n", 1); text_input.buffer.insert_at_cursor("\n", 1);
} else if (text_input.buffer.text != ""){ } else if (this.text != "") {
send_text(); send_text(this.text);
edit_history.reset_history(); edit_history.reset_history();
} }
return true; return true;
@ -167,21 +132,6 @@ public class View : Box {
// hack for vscrollbar not requiring space and making textview higher //TODO doesn't resize immediately // hack for vscrollbar not requiring space and making textview higher //TODO doesn't resize immediately
scrolled.get_vscrollbar().visible = (scrolled.vadjustment.upper > scrolled.max_content_height - 2 * vscrollbar_min_height); scrolled.get_vscrollbar().visible = (scrolled.vadjustment.upper > scrolled.max_content_height - 2 * vscrollbar_min_height);
} }
private void on_text_input_changed() {
if (text_input.buffer.text != "") {
stream_interactor.get_module(ChatInteraction.IDENTITY).on_message_entered(conversation);
} else {
stream_interactor.get_module(ChatInteraction.IDENTITY).on_message_cleared(conversation);
}
}
private void on_upload_available(Account account) {
if (conversation != null && conversation.account.equals(account)) {
file_button.visible = true;
file_separator.visible = true;
}
}
} }
} }

View file

@ -0,0 +1,143 @@
using Gee;
using Gdk;
using Gtk;
using Dino.Entities;
namespace Dino.Ui {
public class ChatInputController : Object {
public new string? conversation_display_name { get; set; }
public string? conversation_topic { get; set; }
private Conversation? conversation;
private ChatInput.View chat_input;
private Label status_description_label;
private StreamInteractor stream_interactor;
private Plugins.InputFieldStatus input_field_status;
public ChatInputController(ChatInput.View chat_input, StreamInteractor stream_interactor) {
this.chat_input = chat_input;
this.status_description_label = chat_input.chat_input_status;
this.stream_interactor = stream_interactor;
reset_input_field_status();
chat_input.text_input.buffer.changed.connect(on_text_input_changed);
chat_input.send_text.connect(send_text);
chat_input.encryption_widget.encryption_changed.connect(on_encryption_changed);
stream_interactor.get_module(FileManager.IDENTITY).upload_available.connect(on_upload_available);
}
public void set_conversation(Conversation conversation) {
this.conversation = conversation;
reset_input_field_status();
chat_input.occupants_tab_completor.initialize_for_conversation(conversation);
chat_input.edit_history.initialize_for_conversation(conversation);
chat_input.encryption_widget.set_conversation(conversation);
}
private void on_encryption_changed(Plugins.EncryptionListEntry? encryption_entry) {
reset_input_field_status();
if (encryption_entry == null) return;
encryption_entry.encryption_activated(conversation, set_input_field_status);
}
private void set_input_field_status(Plugins.InputFieldStatus? status) {
input_field_status = status;
chat_input.set_input_state(status.message_type);
status_description_label.label = status.message;
chat_input.file_button.sensitive = status.input_state == Plugins.InputFieldStatus.InputState.NORMAL;
}
private void reset_input_field_status() {
set_input_field_status(new Plugins.InputFieldStatus("", Plugins.InputFieldStatus.MessageType.NONE, Plugins.InputFieldStatus.InputState.NORMAL));
}
private void on_upload_available(Account account) {
if (conversation != null && conversation.account.equals(account)) {
chat_input.file_button.visible = true;
chat_input.file_separator.visible = true;
}
}
private void send_text() {
// Don't do anything if we're in a NO_SEND state. Don't clear the chat input, don't send.
if (input_field_status.input_state == Plugins.InputFieldStatus.InputState.NO_SEND) {
chat_input.highlight_state_description();
return;
}
string text = chat_input.text_input.buffer.text;
chat_input.text_input.buffer.text = "";
if (chat_input.text.has_prefix("/")) {
string[] token = chat_input.text.split(" ", 2);
switch(token[0]) {
case "/me":
// Just send as is.
break;
case "/say":
if (token.length == 1) return;
text = token[1];
break;
case "/kick":
stream_interactor.get_module(MucManager.IDENTITY).kick(conversation.account, conversation.counterpart, token[1]);
return;
case "/affiliate":
if (token.length > 1) {
string[] user_role = token[1].split(" ", 2);
if (user_role.length == 2) {
stream_interactor.get_module(MucManager.IDENTITY).change_affiliation(conversation.account, conversation.counterpart, user_role[0].strip(), user_role[1].strip());
}
}
return;
case "/nick":
stream_interactor.get_module(MucManager.IDENTITY).change_nick(conversation.account, conversation.counterpart, token[1]);
return;
case "/ping":
Xmpp.XmppStream? stream = stream_interactor.get_stream(conversation.account);
stream.get_module(Xmpp.Xep.Ping.Module.IDENTITY).send_ping(stream, conversation.counterpart.with_resource(token[1]), null);
return;
case "/topic":
stream_interactor.get_module(MucManager.IDENTITY).change_subject(conversation.account, conversation.counterpart, token[1]);
return;
default:
if (token[0].has_prefix("//")) {
text = text.substring(1);
} else {
string cmd_name = token[0].substring(1);
Dino.Application app = GLib.Application.get_default() as Dino.Application;
if (app != null && app.plugin_registry.text_commands.has_key(cmd_name)) {
string? new_text = app.plugin_registry.text_commands[cmd_name].handle_command(token[1], conversation);
if (new_text == null) return;
text = (!)new_text;
}
}
break;
}
}
stream_interactor.get_module(MessageProcessor.IDENTITY).send_text(text, conversation);
}
private void on_text_input_changed() {
if (chat_input.text_input.buffer.text != "") {
stream_interactor.get_module(ChatInteraction.IDENTITY).on_message_entered(conversation);
} else {
stream_interactor.get_module(ChatInteraction.IDENTITY).on_message_cleared(conversation);
}
}
}
}

View file

@ -19,6 +19,8 @@ public class UnifiedWindowController : Object {
private SearchMenuEntry search_menu_entry = new SearchMenuEntry(); private SearchMenuEntry search_menu_entry = new SearchMenuEntry();
private ChatInputController chat_input_controller;
public UnifiedWindowController(Application application, StreamInteractor stream_interactor, Database db) { public UnifiedWindowController(Application application, StreamInteractor stream_interactor, Database db) {
this.app = application; this.app = application;
this.stream_interactor = stream_interactor; this.stream_interactor = stream_interactor;
@ -50,6 +52,8 @@ public class UnifiedWindowController : Object {
public void set_window(UnifiedWindow window) { public void set_window(UnifiedWindow window) {
this.window = window; this.window = window;
this.chat_input_controller = new ChatInputController(window.chat_input, stream_interactor);
this.bind_property("conversation-display-name", window, "title"); this.bind_property("conversation-display-name", window, "title");
this.bind_property("conversation-topic", window, "subtitle"); this.bind_property("conversation-topic", window, "subtitle");
search_menu_entry.search_button.bind_property("active", window.search_revealer, "reveal_child"); search_menu_entry.search_button.bind_property("active", window.search_revealer, "reveal_child");
@ -136,6 +140,7 @@ public class UnifiedWindowController : Object {
if (do_reset_search) { if (do_reset_search) {
reset_search_entry(); reset_search_entry();
} }
chat_input_controller.set_conversation(conversation);
window.chat_input.initialize_for_conversation(conversation); window.chat_input.initialize_for_conversation(conversation);
if (default_initialize_conversation) { if (default_initialize_conversation) {
window.conversation_frame.initialize_for_conversation(conversation); window.conversation_frame.initialize_for_conversation(conversation);

View file

@ -22,9 +22,8 @@
* *
*/ */
[CCode (lower_case_cprefix = "gpgme_", cheader_filename = "gpgme.h")] [CCode (lower_case_cprefix = "gpgme_", cheader_filename = "gpgme.h,gpgme_fix.h")]
namespace GPG { namespace GPG {
[CCode (cheader_filename = "gpgme_fix.h")]
public static GLib.RecMutex global_mutex; public static GLib.RecMutex global_mutex;
[CCode (cname = "struct _gpgme_engine_info")] [CCode (cname = "struct _gpgme_engine_info")]

View file

@ -149,7 +149,7 @@ public class Manager : StreamInteractionModule, Object {
} }
if (state.waiting_other_devicelists > 0 && message.counterpart != null) { if (state.waiting_other_devicelists > 0 && message.counterpart != null) {
foreach(Jid jid in get_occupants(((!)message.counterpart).bare_jid, conversation.account)) { foreach(Jid jid in get_occupants(((!)message.counterpart).bare_jid, conversation.account)) {
module.request_user_devicelist((!)stream, jid); module.request_user_devicelist.begin((!)stream, jid);
} }
} }
} }
@ -161,7 +161,7 @@ public class Manager : StreamInteractionModule, Object {
XmppStream? stream = stream_interactor.get_stream(account); XmppStream? stream = stream_interactor.get_stream(account);
if(stream == null) return; if(stream == null) return;
stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).request_user_devicelist((!)stream, jid); stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).request_user_devicelist.begin((!)stream, jid);
} }
private void on_account_added(Account account) { private void on_account_added(Account account) {
@ -171,7 +171,7 @@ public class Manager : StreamInteractionModule, Object {
} }
private void on_stream_negotiated(Account account, XmppStream stream) { private void on_stream_negotiated(Account account, XmppStream stream) {
stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).request_user_devicelist(stream, account.bare_jid); stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).request_user_devicelist.begin(stream, account.bare_jid);
} }
private void on_device_list_loaded(Account account, Jid jid, ArrayList<int32> device_list) { private void on_device_list_loaded(Account account, Jid jid, ArrayList<int32> device_list) {
@ -352,7 +352,7 @@ public class Manager : StreamInteractionModule, Object {
if (stream == null) return; if (stream == null) return;
StreamModule? module = ((!)stream).get_module(StreamModule.IDENTITY); StreamModule? module = ((!)stream).get_module(StreamModule.IDENTITY);
if(module == null) return; if(module == null) return;
module.request_user_devicelist(stream, account.bare_jid); module.request_user_devicelist.begin(stream, account.bare_jid);
} }
} }
@ -376,6 +376,27 @@ public class Manager : StreamInteractionModule, Object {
return trust_manager.is_known_address(conversation.account, conversation.counterpart.bare_jid); return trust_manager.is_known_address(conversation.account, conversation.counterpart.bare_jid);
} }
public async bool ensure_get_keys_for_conversation(Conversation conversation) {
if (stream_interactor.get_module(MucManager.IDENTITY).is_private_room(conversation.account, conversation.counterpart)) {
foreach (Jid offline_member in stream_interactor.get_module(MucManager.IDENTITY).get_offline_members(conversation.counterpart, conversation.account)) {
bool ok = yield ensure_get_keys_for_jid(conversation.account, offline_member);
if (!ok) {
return false;
}
}
return true;
}
return yield ensure_get_keys_for_jid(conversation.account, conversation.counterpart.bare_jid);
}
public async bool ensure_get_keys_for_jid(Account account, Jid jid) {
if (trust_manager.is_known_address(account, jid)) return true;
XmppStream? stream = stream_interactor.get_stream(account);
var device_list = yield stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).request_user_devicelist((!)stream, jid);
return device_list.size > 0;
}
public static void start(StreamInteractor stream_interactor, Database db, TrustManager trust_manager) { public static void start(StreamInteractor stream_interactor, Database db, TrustManager trust_manager) {
Manager m = new Manager(stream_interactor, db, trust_manager); Manager m = new Manager(stream_interactor, db, trust_manager);
stream_interactor.add_module(m); stream_interactor.add_module(m);

View file

@ -269,70 +269,67 @@ public class TrustManager {
if (sid <= 0) return false; if (sid <= 0) return false;
foreach (StanzaNode key_node in header.get_subnodes("key")) { foreach (StanzaNode key_node in header.get_subnodes("key")) {
if (key_node.get_attribute_int("rid") == store.local_registration_id) { if (key_node.get_attribute_int("rid") == store.local_registration_id) {
try {
string? payload = encrypted.get_deep_string_content("payload"); string? payload = encrypted.get_deep_string_content("payload");
string? iv_node = header.get_deep_string_content("iv"); string? iv_node = header.get_deep_string_content("iv");
string? key_node_content = key_node.get_string_content(); string? key_node_content = key_node.get_string_content();
if (payload == null || iv_node == null || key_node_content == null) continue; if (payload == null || iv_node == null || key_node_content == null) continue;
uint8[] key; uint8[] key;
uint8[] ciphertext = Base64.decode((!)payload); uint8[] ciphertext = Base64.decode((!)payload);
uint8[] iv = Base64.decode((!)iv_node); uint8[] iv = Base64.decode((!)iv_node);
Gee.List<Jid> possible_jids = new ArrayList<Jid>(); Gee.List<Jid> possible_jids = new ArrayList<Jid>();
if (conversation.type_ == Conversation.Type.CHAT) { if (conversation.type_ == Conversation.Type.CHAT) {
possible_jids.add(stanza.from); possible_jids.add(stanza.from);
} else {
Jid? real_jid = message.real_jid;
if (real_jid != null) {
possible_jids.add(real_jid);
} else { } else {
Jid? real_jid = message.real_jid; // If we don't know the device name (MUC history w/o MAM), test decryption with all keys with fitting device id
if (real_jid != null) { foreach (Row row in db.identity_meta.get_with_device_id(sid)) {
possible_jids.add(real_jid); possible_jids.add(new Jid(row[db.identity_meta.address_name]));
}
}
}
foreach (Jid possible_jid in possible_jids) {
try {
Address address = new Address(possible_jid.bare_jid.to_string(), header.get_attribute_int("sid"));
if (key_node.get_attribute_bool("prekey")) {
PreKeySignalMessage msg = Plugin.get_context().deserialize_pre_key_signal_message(Base64.decode((!)key_node_content));
SessionCipher cipher = store.create_session_cipher(address);
key = cipher.decrypt_pre_key_signal_message(msg);
} else { } else {
// If we don't know the device name (MUC history w/o MAM), test decryption with all keys with fitting device id SignalMessage msg = Plugin.get_context().deserialize_signal_message(Base64.decode((!)key_node_content));
foreach (Row row in db.identity_meta.get_with_device_id(sid)) { SessionCipher cipher = store.create_session_cipher(address);
possible_jids.add(new Jid(row[db.identity_meta.address_name])); key = cipher.decrypt_signal_message(msg);
}
} }
//address.device_id = 0; // TODO: Hack to have address obj live longer
if (key.length >= 32) {
int authtaglength = key.length - 16;
uint8[] new_ciphertext = new uint8[ciphertext.length + authtaglength];
uint8[] new_key = new uint8[16];
Memory.copy(new_ciphertext, ciphertext, ciphertext.length);
Memory.copy((uint8*)new_ciphertext + ciphertext.length, (uint8*)key + 16, authtaglength);
Memory.copy(new_key, key, 16);
ciphertext = new_ciphertext;
key = new_key;
}
message.body = arr_to_str(aes_decrypt(Cipher.AES_GCM_NOPADDING, key, iv, ciphertext));
message_device_id_map[message] = address.device_id;
message.encryption = Encryption.OMEMO;
flag.decrypted = true;
} catch (Error e) {
continue;
} }
foreach (Jid possible_jid in possible_jids) { // If we figured out which real jid a message comes from due to decryption working, save it
try { if (conversation.type_ == Conversation.Type.GROUPCHAT && message.real_jid == null) {
Address address = new Address(possible_jid.bare_jid.to_string(), header.get_attribute_int("sid")); message.real_jid = possible_jid;
if (key_node.get_attribute_bool("prekey")) {
PreKeySignalMessage msg = Plugin.get_context().deserialize_pre_key_signal_message(Base64.decode((!)key_node_content));
SessionCipher cipher = store.create_session_cipher(address);
key = cipher.decrypt_pre_key_signal_message(msg);
} else {
SignalMessage msg = Plugin.get_context().deserialize_signal_message(Base64.decode((!)key_node_content));
SessionCipher cipher = store.create_session_cipher(address);
key = cipher.decrypt_signal_message(msg);
}
//address.device_id = 0; // TODO: Hack to have address obj live longer
if (key.length >= 32) {
int authtaglength = key.length - 16;
uint8[] new_ciphertext = new uint8[ciphertext.length + authtaglength];
uint8[] new_key = new uint8[16];
Memory.copy(new_ciphertext, ciphertext, ciphertext.length);
Memory.copy((uint8*)new_ciphertext + ciphertext.length, (uint8*)key + 16, authtaglength);
Memory.copy(new_key, key, 16);
ciphertext = new_ciphertext;
key = new_key;
}
message.body = arr_to_str(aes_decrypt(Cipher.AES_GCM_NOPADDING, key, iv, ciphertext));
message_device_id_map[message] = address.device_id;
message.encryption = Encryption.OMEMO;
flag.decrypted = true;
} catch (Error e) {
continue;
}
// If we figured out which real jid a message comes from due to decryption working, save it
if (conversation.type_ == Conversation.Type.GROUPCHAT && message.real_jid == null) {
message.real_jid = possible_jid;
}
break;
} }
} catch (Error e) { break;
warning(@"Signal error while decrypting message: $(e.message)\n");
} }
} }
} }

View file

@ -17,7 +17,7 @@ public class StreamModule : XmppStreamModule {
public Store store { public get; private set; } public Store store { public get; private set; }
private ConcurrentSet<string> active_bundle_requests = new ConcurrentSet<string>(); private ConcurrentSet<string> active_bundle_requests = new ConcurrentSet<string>();
private ConcurrentSet<Jid> active_devicelist_requests = new ConcurrentSet<Jid>(); private HashMap<Jid, Future<ArrayList<int32>>> active_devicelist_requests = new HashMap<Jid, Future<ArrayList<int32>>>(Jid.hash_func, Jid.equals_func);
private Map<Jid, ArrayList<int32>> ignored_devices = new HashMap<Jid, ArrayList<int32>>(Jid.hash_bare_func, Jid.equals_bare_func); private Map<Jid, ArrayList<int32>> ignored_devices = new HashMap<Jid, ArrayList<int32>>(Jid.hash_bare_func, Jid.equals_bare_func);
public signal void store_created(Store store); public signal void store_created(Store store);
@ -29,22 +29,40 @@ public class StreamModule : XmppStreamModule {
this.store = Plugin.get_context().create_store(); this.store = Plugin.get_context().create_store();
store_created(store); store_created(store);
stream.get_module(Pubsub.Module.IDENTITY).add_filtered_notification(stream, NODE_DEVICELIST, (stream, jid, id, node) => on_devicelist(stream, jid, id, node)); stream.get_module(Pubsub.Module.IDENTITY).add_filtered_notification(stream, NODE_DEVICELIST, (stream, jid, id, node) => parse_device_list(stream, jid, id, node));
} }
public override void detach(XmppStream stream) {} public override void detach(XmppStream stream) {}
public void request_user_devicelist(XmppStream stream, Jid jid) { public async ArrayList<int32> request_user_devicelist(XmppStream stream, Jid jid) {
if (active_devicelist_requests.add(jid)) { var future = active_devicelist_requests[jid];
debug("requesting device list for %s", jid.to_string()); if (future == null) {
stream.get_module(Pubsub.Module.IDENTITY).request(stream, jid, NODE_DEVICELIST, (stream, jid, id, node) => on_devicelist(stream, jid, id, node)); var promise = new Promise<ArrayList<int32>?>();
future = promise.future;
active_devicelist_requests[jid] = future;
stream.get_module(Pubsub.Module.IDENTITY).request(stream, jid, NODE_DEVICELIST, (stream, jid, id, node) => {
ArrayList<int32> device_list = parse_device_list(stream, jid, id, node);
promise.set_value(device_list);
active_devicelist_requests.unset(jid);
});
}
try {
ArrayList<int32> device_list = yield future.wait_async();
return device_list;
} catch (FutureError error) {
warning("Future error when waiting for device list: %s", error.message);
return new ArrayList<int32>();
} }
} }
public void on_devicelist(XmppStream stream, Jid jid, string? id, StanzaNode? node_) { public ArrayList<int32> parse_device_list(XmppStream stream, Jid jid, string? id, StanzaNode? node_) {
ArrayList<int32> device_list = new ArrayList<int32>();
StanzaNode node = node_ ?? new StanzaNode.build("list", NS_URI).add_self_xmlns(); StanzaNode node = node_ ?? new StanzaNode.build("list", NS_URI).add_self_xmlns();
Jid? my_jid = stream.get_flag(Bind.Flag.IDENTITY).my_jid; Jid? my_jid = stream.get_flag(Bind.Flag.IDENTITY).my_jid;
if (my_jid == null) return; if (my_jid == null) return device_list;
if (jid.equals_bare(my_jid) && store.local_registration_id != 0) { if (jid.equals_bare(my_jid) && store.local_registration_id != 0) {
bool am_on_devicelist = false; bool am_on_devicelist = false;
foreach (StanzaNode device_node in node.get_subnodes("device")) { foreach (StanzaNode device_node in node.get_subnodes("device")) {
@ -61,12 +79,12 @@ public class StreamModule : XmppStreamModule {
publish_bundles_if_needed(stream, jid); publish_bundles_if_needed(stream, jid);
} }
ArrayList<int32> device_list = new ArrayList<int32>();
foreach (StanzaNode device_node in node.get_subnodes("device")) { foreach (StanzaNode device_node in node.get_subnodes("device")) {
device_list.add(device_node.get_attribute_int("id")); device_list.add(device_node.get_attribute_int("id"));
} }
active_devicelist_requests.remove(jid);
device_list_loaded(jid, device_list); device_list_loaded(jid, device_list);
return device_list;
} }
public void fetch_bundles(XmppStream stream, Jid jid, Gee.List<int32> devices) { public void fetch_bundles(XmppStream stream, Jid jid, Gee.List<int32> devices) {

View file

@ -1,3 +1,5 @@
using Xmpp;
namespace Dino.Plugins.Omemo { namespace Dino.Plugins.Omemo {
public class EncryptionListEntry : Plugins.EncryptionListEntry, Object { public class EncryptionListEntry : Plugins.EncryptionListEntry, Object {
@ -15,9 +17,29 @@ public class EncryptionListEntry : Plugins.EncryptionListEntry, Object {
return "OMEMO"; return "OMEMO";
}} }}
public bool can_encrypt(Entities.Conversation conversation) { public void encryption_activated(Entities.Conversation conversation, Plugins.SetInputFieldStatus input_status_callback) {
return plugin.app.stream_interactor.get_module(Manager.IDENTITY).can_encrypt(conversation); encryption_activated_async.begin(conversation, input_status_callback);
}
public async void encryption_activated_async(Entities.Conversation conversation, Plugins.SetInputFieldStatus input_status_callback) {
MucManager muc_manager = plugin.app.stream_interactor.get_module(MucManager.IDENTITY);
Manager omemo_manager = plugin.app.stream_interactor.get_module(Manager.IDENTITY);
if (muc_manager.is_private_room(conversation.account, conversation.counterpart)) {
foreach (Jid offline_member in muc_manager.get_offline_members(conversation.counterpart, conversation.account)) {
bool ok = yield omemo_manager.ensure_get_keys_for_jid(conversation.account, offline_member);
if (!ok) {
input_status_callback(new Plugins.InputFieldStatus("A member does not support OMEMO: %s".printf(offline_member.to_string()), Plugins.InputFieldStatus.MessageType.ERROR, Plugins.InputFieldStatus.InputState.NO_SEND));
return;
}
}
return;
}
if (!(yield omemo_manager.ensure_get_keys_for_jid(conversation.account, conversation.counterpart.bare_jid))) {
input_status_callback(new Plugins.InputFieldStatus("This contact does not support %s encryption".printf("OMEMO"), Plugins.InputFieldStatus.MessageType.ERROR, Plugins.InputFieldStatus.InputState.NO_SEND));
}
} }
}
} }
}

View file

@ -8,9 +8,11 @@ namespace Dino.Plugins.OpenPgp {
private class EncryptionListEntry : Plugins.EncryptionListEntry, Object { private class EncryptionListEntry : Plugins.EncryptionListEntry, Object {
private StreamInteractor stream_interactor; private StreamInteractor stream_interactor;
private Database db;
public EncryptionListEntry(StreamInteractor stream_interactor) { public EncryptionListEntry(StreamInteractor stream_interactor, Database db) {
this.stream_interactor = stream_interactor; this.stream_interactor = stream_interactor;
this.db = db;
} }
public Entities.Encryption encryption { get { public Entities.Encryption encryption { get {
@ -21,12 +23,25 @@ private class EncryptionListEntry : Plugins.EncryptionListEntry, Object {
return "OpenPGP"; return "OpenPGP";
}} }}
public bool can_encrypt(Entities.Conversation conversation) { public void encryption_activated(Entities.Conversation conversation, Plugins.SetInputFieldStatus input_status_callback) {
try {
GPGHelper.get_public_key(db.get_account_key(conversation.account) ?? "");
} catch (Error e) {
input_status_callback(new Plugins.InputFieldStatus("You didn't configure OpenPGP for this account. You can do that in the Accounts Dialog.", Plugins.InputFieldStatus.MessageType.ERROR, Plugins.InputFieldStatus.InputState.NO_SEND));
return;
}
if (conversation.type_ == Conversation.Type.CHAT) { if (conversation.type_ == Conversation.Type.CHAT) {
string? key_id = stream_interactor.get_module(Manager.IDENTITY).get_key_id(conversation.account, conversation.counterpart); string? key_id = stream_interactor.get_module(Manager.IDENTITY).get_key_id(conversation.account, conversation.counterpart);
if (key_id == null) {
input_status_callback(new Plugins.InputFieldStatus("This contact does not support %s encryption.".printf("OpenPGP"), Plugins.InputFieldStatus.MessageType.ERROR, Plugins.InputFieldStatus.InputState.NO_SEND));
return;
}
try { try {
return key_id != null && GPGHelper.get_keylist(key_id).size > 0; GPGHelper.get_keylist(key_id);
} catch (Error e) { return false; } } catch (Error e) {
input_status_callback(new Plugins.InputFieldStatus("This contact's OpenPGP key is not in your keyring.", Plugins.InputFieldStatus.MessageType.ERROR, Plugins.InputFieldStatus.InputState.NO_SEND));
}
} else if (conversation.type_ == Conversation.Type.GROUPCHAT) { } else if (conversation.type_ == Conversation.Type.GROUPCHAT) {
Gee.List<Jid> muc_jids = new Gee.ArrayList<Jid>(); Gee.List<Jid> muc_jids = new Gee.ArrayList<Jid>();
Gee.List<Jid>? occupants = stream_interactor.get_module(MucManager.IDENTITY).get_occupants(conversation.counterpart, conversation.account); Gee.List<Jid>? occupants = stream_interactor.get_module(MucManager.IDENTITY).get_occupants(conversation.counterpart, conversation.account);
@ -36,11 +51,12 @@ private class EncryptionListEntry : Plugins.EncryptionListEntry, Object {
foreach (Jid jid in muc_jids) { foreach (Jid jid in muc_jids) {
string? key_id = stream_interactor.get_module(Manager.IDENTITY).get_key_id(conversation.account, jid); string? key_id = stream_interactor.get_module(Manager.IDENTITY).get_key_id(conversation.account, jid);
if (key_id == null) return false; if (key_id == null) {
input_status_callback(new Plugins.InputFieldStatus("A member's OpenPGP key is not in your keyring: %s / %s.".printf(jid.to_string(), key_id), Plugins.InputFieldStatus.MessageType.ERROR, Plugins.InputFieldStatus.InputState.NO_SEND));
return;
}
} }
return true;
} }
return false;
} }
} }

View file

@ -19,7 +19,7 @@ public class Plugin : Plugins.RootInterface, Object {
public void registered(Dino.Application app) { public void registered(Dino.Application app) {
this.app = app; this.app = app;
this.db = new Database(Path.build_filename(Application.get_storage_dir(), "pgp.db")); this.db = new Database(Path.build_filename(Application.get_storage_dir(), "pgp.db"));
this.list_entry = new EncryptionListEntry(app.stream_interactor); this.list_entry = new EncryptionListEntry(app.stream_interactor, db);
this.settings_entry = new AccountSettingsEntry(this); this.settings_entry = new AccountSettingsEntry(this);
this.contact_details_provider = new ContactDetailsProvider(app.stream_interactor); this.contact_details_provider = new ContactDetailsProvider(app.stream_interactor);