diff --git a/libdino/src/application.vala b/libdino/src/application.vala index d307c746..7b19a9e9 100644 --- a/libdino/src/application.vala +++ b/libdino/src/application.vala @@ -40,6 +40,7 @@ public interface Dino.Application : GLib.Application { ContentItemStore.start(stream_interactor, db); NotificationEvents.start(stream_interactor); SearchProcessor.start(stream_interactor, db); + Register.start(stream_interactor, db); create_actions(); @@ -110,11 +111,11 @@ public interface Dino.Application : GLib.Application { } protected void add_connection(Account account) { - stream_interactor.connect(account); + stream_interactor.connect_account(account); } protected void remove_connection(Account account) { - stream_interactor.disconnect(account); + stream_interactor.disconnect_account(account); } private void restore() { diff --git a/libdino/src/entity/account.vala b/libdino/src/entity/account.vala index 111fbf08..f7257b5a 100644 --- a/libdino/src/entity/account.vala +++ b/libdino/src/entity/account.vala @@ -44,6 +44,8 @@ public class Account : Object { } public void persist(Database db) { + if (id > 0) return; + this.db = db; id = (int) db.account.insert() .value(db.account.bare_jid, bare_jid.to_string()) diff --git a/libdino/src/service/connection_manager.vala b/libdino/src/service/connection_manager.vala index 2abbc9cb..6a7964a0 100644 --- a/libdino/src/service/connection_manager.vala +++ b/libdino/src/service/connection_manager.vala @@ -5,7 +5,7 @@ using Dino.Entities; namespace Dino { -public class ConnectionManager { +public class ConnectionManager : Object { public signal void stream_opened(Account account, XmppStream stream); public signal void connection_state_changed(Account account, ConnectionState state); @@ -133,7 +133,7 @@ public class ConnectionManager { connections[account].stream.get_module(Presence.Module.IDENTITY).send_presence(connections[account].stream, presence); } - public void disconnect(Account account) { + public void disconnect_account(Account account) { if (connections.has_key(account)) { make_offline(account); try { diff --git a/libdino/src/service/registration.vala b/libdino/src/service/registration.vala index 32d8b04b..8cac355e 100644 --- a/libdino/src/service/registration.vala +++ b/libdino/src/service/registration.vala @@ -5,12 +5,96 @@ using Dino.Entities; namespace Dino { -public class Register { +public class Register : StreamInteractionModule, Object{ + public static ModuleIdentity IDENTITY = new ModuleIdentity("registration"); + public string id { get { return IDENTITY.id; } } + + private StreamInteractor stream_interactor; + private Database db; + + public static void start(StreamInteractor stream_interactor, Database db) { + Register m = new Register(stream_interactor, db); + stream_interactor.add_module(m); + } + + private Register(StreamInteractor stream_interactor, Database db) { + this.stream_interactor = stream_interactor; + this.db = db; + } + + public async ConnectionManager.ConnectionError.Source? add_check_account(Account account) { + SourceFunc callback = add_check_account.callback; + ConnectionManager.ConnectionError.Source? ret = null; + + ulong handler_id_connected = stream_interactor.stream_negotiated.connect((connected_account, stream) => { + if (connected_account.equals(account)) { + account.persist(db); + account.enabled = true; + Idle.add((owned)callback); + } + }); + ulong handler_id_error = stream_interactor.connection_manager.connection_error.connect((connected_account, error) => { + if (connected_account.equals(account)) { + ret = error.source; + } + stream_interactor.disconnect_account(account); + Idle.add((owned)callback); + }); + + stream_interactor.connect_account(account); + yield; + stream_interactor.disconnect(handler_id_connected); + stream_interactor.connection_manager.disconnect(handler_id_error); + + return ret; + } + + public class ServerAvailabilityReturn { + public bool available { get; set; } + public TlsCertificateFlags? error_flags { get; set; } + } + + public static async ServerAvailabilityReturn check_server_availability(Jid jid) { + XmppStream stream = new XmppStream(); + stream.add_module(new Tls.Module()); + stream.add_module(new Iq.Module()); + stream.add_module(new Xep.SrvRecordsTls.Module()); + + ServerAvailabilityReturn ret = new ServerAvailabilityReturn() { available=false }; + SourceFunc callback = check_server_availability.callback; + stream.stream_negotiated.connect(() => { + if (callback != null) { + ret.available = true; + Idle.add((owned)callback); + } + }); + stream.get_module(Tls.Module.IDENTITY).invalid_certificate.connect((peer_cert, errors) => { + if (callback != null) { + + ret.error_flags = errors; + Idle.add((owned)callback); + } + }); + Timeout.add_seconds(5, () => { + if (callback != null) { + Idle.add((owned)callback); + } + return false; + }); + + stream.connect.begin(jid.domainpart); + yield; + try { + stream.disconnect(); + } catch (Error e) {} + return ret; + } public static async Xep.InBandRegistration.Form get_registration_form(Jid jid) { XmppStream stream = new XmppStream(); stream.add_module(new Tls.Module()); stream.add_module(new Iq.Module()); + stream.add_module(new Xep.SrvRecordsTls.Module()); stream.add_module(new Xep.InBandRegistration.Module()); stream.connect.begin(jid.bare_jid.to_string()); diff --git a/libdino/src/service/stream_interactor.vala b/libdino/src/service/stream_interactor.vala index d9f3f0ec..55ab8984 100644 --- a/libdino/src/service/stream_interactor.vala +++ b/libdino/src/service/stream_interactor.vala @@ -5,7 +5,7 @@ using Dino.Entities; namespace Dino { -public class StreamInteractor { +public class StreamInteractor : Object { public signal void account_added(Account account); public signal void account_removed(Account account); @@ -23,14 +23,14 @@ public class StreamInteractor { connection_manager.stream_opened.connect(on_stream_opened); } - public void connect(Account account) { + public void connect_account(Account account) { module_manager.initialize(account); account_added(account); connection_manager.connect(account); } - public void disconnect(Account account) { - connection_manager.disconnect(account); + public void disconnect_account(Account account) { + connection_manager.disconnect_account(account); account_removed(account); } diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 65d547c6..d21d10ed 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -15,6 +15,7 @@ set(RESOURCE_LIST icons/dino-changes-prevent-symbolic.svg icons/dino-double-tick-symbolic.svg icons/dino-qr-code-symbolic.svg + icons/dino-party-popper-symbolic.svg icons/dino-status-away.svg icons/dino-status-chat.svg icons/dino-status-dnd.svg diff --git a/main/data/icons/dino-party-popper-symbolic.svg b/main/data/icons/dino-party-popper-symbolic.svg new file mode 100644 index 00000000..084d6f1b --- /dev/null +++ b/main/data/icons/dino-party-popper-symbolic.svg @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/main/data/manage_accounts/add_account_dialog.ui b/main/data/manage_accounts/add_account_dialog.ui index 52f91481..bdf0837b 100644 --- a/main/data/manage_accounts/add_account_dialog.ui +++ b/main/data/manage_accounts/add_account_dialog.ui @@ -19,16 +19,16 @@ True True - + vertical 20 50 50 + 20 True Sign in - 10 True @@ -57,6 +57,156 @@ True + + + 0 + 7 + True + + + + + + + + + + horizontal + True + + + Create account + True + + + start + + + + + False + True + True + + + + True + + + Next + True + + + label + + + + + True + True + + + spinner + + + + + + + + end + + + + + + + login_jid + + + + + vertical + 30 + 20 + 50 + 50 + 20 + True + + + True + channel-insecure-symbolic + 4 + 72 + 10 + + + + + + Could not establish a secure connection + True + + + + + + + + fill + True + True + True + True + + + + + horizontal + True + + + Back + True + + + start + + + + + + + tls_error + + + + + vertical + 20 + 50 + 50 + 20 + True + + + Sign in + True + + + + + + + + vertical + True Password @@ -79,8 +229,7 @@ - - Local alias + 0 7 True @@ -89,24 +238,34 @@ - - - True - True - 200 - True - - + + + + + + + + + + + + + + + + + + + horizontal - 20 True - - Create account + + Back True @@ -114,14 +273,38 @@ - - True - Save + False + True True + + + True + + + Connect + True + + + label + + + + + True + True + + + spinner + + + + + end @@ -131,7 +314,7 @@ - login + login_password @@ -335,6 +518,79 @@ form + + + 50 + 5 + 5 + vertical + 10 + center + True + + + True + dino-party-popper-symbolic + 4 + 72 + 10 + + + + + + All set up! + 0.5 + 0.5 + True + + + + + + + + + + True + 5 + 0.5 + 0.5 + True + True + + + + + + horizontal + center + 20 + True + + + True + Finish + True + + + + + + + + success + + diff --git a/main/data/unified_window_placeholder.ui b/main/data/unified_window_placeholder.ui index 429c95c6..a16d98d4 100644 --- a/main/data/unified_window_placeholder.ui +++ b/main/data/unified_window_placeholder.ui @@ -22,6 +22,18 @@ + + + 0.5 + 0.5 + + + + + + 0.5 @@ -54,4 +66,4 @@ - \ No newline at end of file + diff --git a/main/src/ui/application.vala b/main/src/ui/application.vala index 86a4e288..c34752a2 100644 --- a/main/src/ui/application.vala +++ b/main/src/ui/application.vala @@ -29,7 +29,7 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application { activate.connect(() => { if (window == null) { create_set_app_menu(); - window = new UnifiedWindow(this, stream_interactor); + window = new UnifiedWindow(this, stream_interactor, db); notifications = new Notifications(stream_interactor, window); notifications.start(); notifications.conversation_selected.connect((conversation) => window.on_conversation_selected(conversation)); diff --git a/main/src/ui/manage_accounts/add_account_dialog.vala b/main/src/ui/manage_accounts/add_account_dialog.vala index f9ab794e..97a8e924 100644 --- a/main/src/ui/manage_accounts/add_account_dialog.vala +++ b/main/src/ui/manage_accounts/add_account_dialog.vala @@ -1,5 +1,6 @@ using Gee; using Gtk; +using Pango; using Dino.Entities; using Xmpp; @@ -16,13 +17,28 @@ public class AddAccountDialog : Gtk.Dialog { [GtkChild] private Revealer notification_revealer; [GtkChild] private Label notification_label; - // Sign in - [GtkChild] private Box sign_in_box; + // Sign in - JID + [GtkChild] private Box sign_in_jid_box; + [GtkChild] private Label sign_in_jid_error_label; [GtkChild] private Entry jid_entry; - [GtkChild] private Entry alias_entry; + [GtkChild] private Stack sign_in_jid_continue_stack; + [GtkChild] private Button sign_in_jid_continue_button; + [GtkChild] private Button sign_in_jid_serverlist_button; + + // Sign in - TLS error + [GtkChild] private Box sign_in_tls_box; + [GtkChild] private Label sign_in_tls_label; + [GtkChild] private Stack sign_in_password_continue_stack; + [GtkChild] private Button sign_in_tls_back_button; + + // Sign in - Password + [GtkChild] private Box sign_in_password_box; + [GtkChild] private Label sign_in_password_title; + [GtkChild] private Label sign_in_password_error_label; + [GtkChild] private Entry password_entry; - [GtkChild] private Button sign_in_continue; - [GtkChild] private Button serverlist_button; + [GtkChild] private Button sign_in_password_continue_button; + [GtkChild] private Button sign_in_password_back_button; // Select Server [GtkChild] private Box create_account_box; @@ -41,24 +57,41 @@ public class AddAccountDialog : Gtk.Dialog { [GtkChild] private Stack register_form_continue_stack; [GtkChild] private Button register_form_continue; + // Success + [GtkChild] private Box success_box; + [GtkChild] private Label success_description; + [GtkChild] private Button success_continue_button; + private static string[] server_list = new string[]{ "5222.de", "jabber.fr", "movim.eu", "yax.im" }; + + private StreamInteractor stream_interactor; private HashMap list_box_jids = new HashMap(); private Jid? server_jid = null; private Xep.InBandRegistration.Form? form = null; public AddAccountDialog(StreamInteractor stream_interactor) { + this.stream_interactor = stream_interactor; this.title = _("Add Account"); - // Sign in + // Sign in - Jid + Util.force_error_color(sign_in_jid_error_label); jid_entry.changed.connect(on_jid_entry_changed); - jid_entry.focus_out_event.connect(on_jid_entry_focus_out_event); - sign_in_continue.clicked.connect(on_sign_in_continue_clicked); - serverlist_button.clicked.connect(show_select_server); + sign_in_jid_continue_button.clicked.connect(on_sign_in_jid_continue_button_clicked); + sign_in_jid_serverlist_button.clicked.connect(show_select_server); + + // Sign in - TLS error + sign_in_tls_back_button.clicked.connect(show_sign_in_jid); + + // Sign in - Password + Util.force_error_color(sign_in_password_error_label); + password_entry.changed.connect(() => { sign_in_password_continue_button.set_sensitive(password_entry.text.length > 0); }); + sign_in_password_continue_button.clicked.connect(on_sign_in_password_continue_button_clicked); + sign_in_password_back_button.clicked.connect(show_sign_in_jid); // Select Server server_entry.changed.connect(() => { @@ -66,7 +99,7 @@ public class AddAccountDialog : Gtk.Dialog { select_server_continue.sensitive = jid != null && jid.localpart == null && jid.resourcepart == null; }); select_server_continue.clicked.connect(on_select_server_continue); - login_button.clicked.connect(show_sign_in); + login_button.clicked.connect(show_sign_in_jid); foreach (string server in server_list) { ListBoxRow list_box_row = new ListBoxRow() { visible=true }; @@ -79,16 +112,49 @@ public class AddAccountDialog : Gtk.Dialog { register_form_continue.clicked.connect(on_register_form_continue_clicked); register_form_back.clicked.connect(show_select_server); - show_sign_in(); + // Success + success_continue_button.clicked.connect(() => close()); + + show_sign_in_jid(); } - private void show_sign_in() { - sign_in_box.visible = true; - stack.visible_child_name = "login"; + private void show_sign_in_jid() { + sign_in_jid_box.visible = true; + stack.visible_child_name = "login_jid"; + sign_in_tls_box.visible = false; + sign_in_password_box.visible = false; create_account_box.visible = false; register_box.visible = false; - set_default(sign_in_continue); - animate_window_resize(sign_in_box); + success_box.visible = false; + set_default(sign_in_jid_continue_button); + + sign_in_jid_error_label.label = ""; + animate_window_resize(sign_in_jid_box); + } + + private void show_tls_error() { + sign_in_tls_box.visible = true; + stack.visible_child_name = "tls_error"; + sign_in_jid_box.visible = false; + sign_in_password_box.visible = false; + create_account_box.visible = false; + register_box.visible = false; + success_box.visible = false; + } + + private void show_sign_in_password() { + sign_in_password_box.visible = true; + stack.visible_child_name = "login_password"; + sign_in_jid_box.visible = false; + sign_in_tls_box.visible = false; + create_account_box.visible = false; + register_box.visible = false; + success_box.visible = false; + set_default(sign_in_password_continue_button); + + sign_in_password_error_label.label = ""; + sign_in_password_title.label = _("Sign in to %s").printf(jid_entry.text); + animate_window_resize(sign_in_password_box); } private void show_select_server() { @@ -102,8 +168,10 @@ public class AddAccountDialog : Gtk.Dialog { create_account_box.visible = true; stack.visible_child_name = "server"; - sign_in_box.visible = false; + sign_in_jid_box.visible = false; + sign_in_tls_box.visible = false; register_box.visible = false; + success_box.visible = false; animate_window_resize(create_account_box); } @@ -111,40 +179,88 @@ public class AddAccountDialog : Gtk.Dialog { private void show_register_form() { register_box.visible = true; stack.visible_child_name = "form"; - sign_in_box.visible = false; + sign_in_jid_box.visible = false; + sign_in_tls_box.visible = false; + sign_in_password_box.visible = false; create_account_box.visible = false; + success_box.visible = false; set_default(register_form_continue); animate_window_resize(register_box); } + private void show_success() { + success_box.visible = true; + stack.visible_child_name = "success"; + sign_in_jid_box.visible = false; + sign_in_tls_box.visible = false; + sign_in_password_box.visible = false; + create_account_box.visible = false; + register_box.visible = false; + success_description.label = _("You can now start using %s").printf("" + Markup.escape_text(jid_entry.text) + ""); + + set_default(success_continue_button); + } + private void on_jid_entry_changed() { Jid? jid = Jid.parse(jid_entry.text); if (jid != null && jid.localpart != null && jid.resourcepart == null) { - sign_in_continue.set_sensitive(true); + sign_in_jid_continue_button.set_sensitive(true); jid_entry.secondary_icon_name = null; } else { - sign_in_continue.set_sensitive(false); + sign_in_jid_continue_button.set_sensitive(false); } } - private bool on_jid_entry_focus_out_event() { - Jid? jid = Jid.parse(jid_entry.text); - if (jid == null || jid.localpart == null || jid.resourcepart != null) { - jid_entry.secondary_icon_name = "dialog-warning-symbolic"; - jid_entry.set_icon_tooltip_text(EntryIconPosition.SECONDARY, _("JID should be of the form “user@example.com”")); + private async void on_sign_in_jid_continue_button_clicked() { + Jid jid = new Jid(jid_entry.get_text()); + sign_in_jid_continue_stack.visible_child_name = "spinner"; + Register.ServerAvailabilityReturn server_status = yield stream_interactor.get_module(Register.IDENTITY).check_server_availability(jid); + sign_in_jid_continue_stack.visible_child_name = "label"; + if (server_status.available) { + show_sign_in_password(); } else { - jid_entry.secondary_icon_name = null; + if (server_status.error_flags != null) { + string error_desc = "The server could not prove that it is %s.".printf("" + jid.domainpart + ""); + if (TlsCertificateFlags.UNKNOWN_CA in server_status.error_flags) { + error_desc += " " + "Its security certificate is not trusted by your computer's operating system."; + } else if (TlsCertificateFlags.BAD_IDENTITY in server_status.error_flags) { + error_desc += " " + "Its security certificate is issued to another domain."; + } else if (TlsCertificateFlags.NOT_ACTIVATED in server_status.error_flags) { + error_desc += " " + "Its security certificate will only become valid in the future."; + } else if (TlsCertificateFlags.EXPIRED in server_status.error_flags) { + error_desc += " " + "Its security certificate is expired."; + } + sign_in_tls_label.label = error_desc; + show_tls_error(); + } else { + sign_in_jid_error_label.label = _("Could not connect to %s").printf(jid.domainpart); + } } - return false; } - private void on_sign_in_continue_clicked() { + private async void on_sign_in_password_continue_button_clicked() { Jid jid = new Jid(jid_entry.get_text()); string password = password_entry.get_text(); - string alias = alias_entry.get_text(); - store_account(jid, password, alias); - close(); + Account account = new Account(jid, null, password, null); + + sign_in_password_continue_stack.visible_child_name = "spinner"; + ConnectionManager.ConnectionError.Source? error = yield stream_interactor.get_module(Register.IDENTITY).add_check_account(account); + sign_in_password_continue_stack.visible_child_name = "label"; + + if (error != null) { + switch (error) { + case ConnectionManager.ConnectionError.Source.SASL: + sign_in_password_error_label.label = _("Wrong username or password"); + break; + default: + sign_in_password_error_label.label = "Something went wrong"; + break; + } + } else { + show_success(); + added(account); + } } private void on_select_server_continue() { @@ -209,7 +325,7 @@ public class AddAccountDialog : Gtk.Dialog { try { AppInfo.launch_default_for_uri(form.oob, null); } catch (Error e) { } - show_sign_in(); + show_sign_in_jid(); return; } @@ -227,18 +343,14 @@ public class AddAccountDialog : Gtk.Dialog { case "password": password = field.get_value_string(); break; } } - store_account(new Jid(username + "@" + server_jid.domainpart), password, ""); - close(); + Account account = new Account(new Jid(username + "@" + server_jid.domainpart), null, password, null); + show_success(); + added(account); } else { display_notification(error); } } - private void store_account(Jid jid, string password, string? alias) { - Account account = new Account(jid, null, password, alias); - added(account); - } - private void display_notification(string text) { notification_label.label = text; notification_revealer.set_reveal_child(true); diff --git a/main/src/ui/unified_window.vala b/main/src/ui/unified_window.vala index 61a22085..21a535ea 100644 --- a/main/src/ui/unified_window.vala +++ b/main/src/ui/unified_window.vala @@ -8,6 +8,7 @@ namespace Dino.Ui { public class UnifiedWindow : Gtk.Window { + private WelcomePlceholder welcome_placeholder = new WelcomePlceholder() { visible=true }; private NoAccountsPlaceholder accounts_placeholder = new NoAccountsPlaceholder() { visible=true }; private NoConversationsPlaceholder conversations_placeholder = new NoConversationsPlaceholder() { visible=true }; private ChatInput.View chat_input; @@ -28,11 +29,13 @@ public class UnifiedWindow : Gtk.Window { private StreamInteractor stream_interactor; private Conversation? conversation; private Application app; + private Database db; - public UnifiedWindow(Application application, StreamInteractor stream_interactor) { + public UnifiedWindow(Application application, StreamInteractor stream_interactor, Database db) { Object(application : application); - this.stream_interactor = stream_interactor; this.app = application; + this.stream_interactor = stream_interactor; + this.db = db; restore_window_size(); @@ -92,6 +95,11 @@ public class UnifiedWindow : Gtk.Window { stream_interactor.account_removed.connect((account) => { check_stack(); }); stream_interactor.get_module(ConversationManager.IDENTITY).conversation_activated.connect(() => check_stack()); stream_interactor.get_module(ConversationManager.IDENTITY).conversation_deactivated.connect(() => check_stack()); + welcome_placeholder.primary_button.clicked.connect(() => { + ManageAccounts.AddAccountDialog dialog = new ManageAccounts.AddAccountDialog(stream_interactor); + dialog.set_transient_for(app.get_active_window()); + dialog.present(); + }); accounts_placeholder.primary_button.clicked.connect(() => { get_application().activate_action("accounts", null); }); conversations_placeholder.primary_button.clicked.connect(() => { get_application().activate_action("add_chat", null); }); conversations_placeholder.secondary_button.clicked.connect(() => { get_application().activate_action("add_conference", null); }); @@ -173,6 +181,7 @@ public class UnifiedWindow : Gtk.Window { private void setup_stack() { stack.add_named(paned, "main"); + stack.add_named(welcome_placeholder, "welcome_placeholder"); stack.add_named(accounts_placeholder, "accounts_placeholder"); stack.add_named(conversations_placeholder, "conversations_placeholder"); add(stack); @@ -181,8 +190,13 @@ public class UnifiedWindow : Gtk.Window { private void check_stack(bool know_exists = false) { ArrayList accounts = stream_interactor.get_accounts(); if (!know_exists && accounts.size == 0) { - stack.set_visible_child_name("accounts_placeholder"); - set_titlebar(placeholder_headerbar); + if (db.get_accounts().size == 0) { + stack.set_visible_child_name("welcome_placeholder"); + set_titlebar(placeholder_headerbar); + } else { + stack.set_visible_child_name("accounts_placeholder"); + set_titlebar(placeholder_headerbar); + } } else if (stream_interactor.get_module(ConversationManager.IDENTITY).get_active_conversations().size == 0) { stack.set_visible_child_name("conversations_placeholder"); set_titlebar(placeholder_headerbar); @@ -228,25 +242,40 @@ public class UnifiedWindow : Gtk.Window { } } +public class WelcomePlceholder : UnifiedWindowPlaceholder { + public WelcomePlceholder() { + title_label.label = _("Welcome to Dino!"); + label.label = _("Communicate happieness."); + primary_button.label = _("Setup account"); + title_label.visible = true; + secondary_button.visible = false; + } +} + public class NoAccountsPlaceholder : UnifiedWindowPlaceholder { public NoAccountsPlaceholder() { - label.label = _("No active accounts"); + title_label.label = _("No active accounts"); primary_button.label = _("Manage accounts"); + title_label.visible = true; + label.visible = false; secondary_button.visible = false; } } public class NoConversationsPlaceholder : UnifiedWindowPlaceholder { public NoConversationsPlaceholder() { - label.label = _("No active conversations"); + title_label.label = _("No active conversations"); primary_button.label = _("Start Conversation"); secondary_button.label = _("Join Channel"); + title_label.visible = true; + label.visible = false; secondary_button.visible = true; } } [GtkTemplate (ui = "/im/dino/Dino/unified_window_placeholder.ui")] public class UnifiedWindowPlaceholder : Box { + [GtkChild] public Label title_label; [GtkChild] public Label label; [GtkChild] public Button primary_button; [GtkChild] public Button secondary_button; diff --git a/main/src/ui/util/helper.vala b/main/src/ui/util/helper.vala index e51b8344..049b2d07 100644 --- a/main/src/ui/util/helper.vala +++ b/main/src/ui/util/helper.vala @@ -70,7 +70,7 @@ public static string get_display_name(StreamInteractor stream_interactor, Jid ji } else { if (jid.equals_bare(account.bare_jid)) { if (account.alias == null || account.alias == "") { - return account.bare_jid.to_string(); + return _("Me"); } else { return account.alias; } diff --git a/xmpp-vala/src/module/tls.vala b/xmpp-vala/src/module/tls.vala index f2d58d32..c3afc4b3 100644 --- a/xmpp-vala/src/module/tls.vala +++ b/xmpp-vala/src/module/tls.vala @@ -58,7 +58,7 @@ namespace Xmpp.Tls { } } - public static bool on_invalid_certificate(TlsCertificate peer_cert, TlsCertificateFlags errors) { + public bool on_invalid_certificate(TlsCertificate peer_cert, TlsCertificateFlags errors) { string error_str = ""; foreach (var f in new TlsCertificateFlags[]{TlsCertificateFlags.UNKNOWN_CA, TlsCertificateFlags.BAD_IDENTITY, TlsCertificateFlags.NOT_ACTIVATED, TlsCertificateFlags.EXPIRED, TlsCertificateFlags.REVOKED, @@ -68,6 +68,7 @@ namespace Xmpp.Tls { } } warning(@"Tls Certificate Errors: $(error_str)"); + invalid_certificate(peer_cert, errors); return false; } diff --git a/xmpp-vala/src/module/xep/0368_srv_records_tls.vala b/xmpp-vala/src/module/xep/0368_srv_records_tls.vala index 87c8e433..a40d0bb5 100644 --- a/xmpp-vala/src/module/xep/0368_srv_records_tls.vala +++ b/xmpp-vala/src/module/xep/0368_srv_records_tls.vala @@ -38,7 +38,7 @@ public class TlsConnectionProvider : ConnectionProvider { try { IOStream? io_stream = yield client.connect_to_host_async(srv_target.get_hostname(), srv_target.get_port()); TlsConnection tls_connection = TlsClientConnection.new(io_stream, new NetworkAddress(stream.remote_name.to_string(), srv_target.get_port())); - tls_connection.accept_certificate.connect(Tls.Module.on_invalid_certificate); + tls_connection.accept_certificate.connect(stream.get_module(Tls.Module.IDENTITY).on_invalid_certificate); stream.add_flag(new Tls.Flag() { finished=true }); return tls_connection; } catch (Error e) {