diff options
author | Benoit Lagarde <blagarde@centricsoftware.com> | 2023-01-04 22:30:19 +0300 |
---|---|---|
committer | Benoit Lagarde <blagarde@centricsoftware.com> | 2023-01-04 22:30:19 +0300 |
commit | c55ab9b94500aadbc6270c059554266c7b8b981e (patch) | |
tree | b85bd4f00c7ec9c24b8105eb19630ed55c06c35b | |
parent | 4f58b706a8c6c53c83b8409c09539b33e9ecb247 (diff) |
Added ability to view passwords in the clear.
This feature could be made Active/Inactive in Preference > Security
-rw-r--r-- | data/ui/remmina_preferences.glade | 41 | ||||
-rw-r--r-- | src/remmina_file_editor.c | 816 | ||||
-rw-r--r-- | src/remmina_pref.c | 8 | ||||
-rw-r--r-- | src/remmina_pref.h | 1 | ||||
-rw-r--r-- | src/remmina_pref_dialog.c | 5 | ||||
-rw-r--r-- | src/remmina_pref_dialog.h | 1 |
6 files changed, 511 insertions, 361 deletions
diff --git a/data/ui/remmina_preferences.glade b/data/ui/remmina_preferences.glade index 71fe2ef60..5b4f0aba7 100644 --- a/data/ui/remmina_preferences.glade +++ b/data/ui/remmina_preferences.glade @@ -1702,6 +1702,21 @@ It changes the background colour of connection names in the Remmina connection t </packing> </child> <child> + <object class="GtkLabel" id="label_security_lock_view_passwords"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="tooltip-text" translatable="yes">Enter your Remmina password to view passwords</property> + <property name="halign">start</property> + <property name="valign">center</property> + <property name="margin-start">18</property> + <property name="label" translatable="yes" comments="“Require to view passwords” is “Require the Remmina password before to connect”, the Remmina password is the Master/Principal Password, that is used to protect Remmina from unauthorized use.">Require to view passwords</property> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">4</property> + </packing> + </child> + <child> <object class="GtkSwitch" id="switch_security_lock_connect"> <property name="visible">True</property> <property name="can-focus">True</property> @@ -1729,6 +1744,20 @@ It changes the background colour of connection names in the Remmina connection t <property name="top-attach">3</property> </packing> </child> + <child> + <object class="GtkSwitch" id="switch_security_lock_view_passwords"> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="halign">start</property> + <property name="valign">center</property> + <property name="margin-start">6</property> + <property name="margin-end">18</property> + </object> + <packing> + <property name="left-attach">1</property> + <property name="top-attach">4</property> + </packing> + </child> <child> <object class="GtkLabel"> <property name="visible">True</property> @@ -1740,7 +1769,7 @@ It changes the background colour of connection names in the Remmina connection t </object> <packing> <property name="left-attach">0</property> - <property name="top-attach">4</property> + <property name="top-attach">5</property> </packing> </child> <child> @@ -1763,7 +1792,7 @@ Except the "Weak" method, all the others are recommended, "Keystore" is the defa </object> <packing> <property name="left-attach">1</property> - <property name="top-attach">4</property> + <property name="top-attach">5</property> </packing> </child> <child> @@ -1778,7 +1807,7 @@ Except the "Weak" method, all the others are recommended, "Keystore" is the defa </object> <packing> <property name="left-attach">0</property> - <property name="top-attach">5</property> + <property name="top-attach">6</property> </packing> </child> <child> @@ -1792,7 +1821,7 @@ Except the "Weak" method, all the others are recommended, "Keystore" is the defa </object> <packing> <property name="left-attach">1</property> - <property name="top-attach">5</property> + <property name="top-attach">6</property> </packing> </child> <child> @@ -1808,7 +1837,7 @@ Except the "Weak" method, all the others are recommended, "Keystore" is the defa </object> <packing> <property name="left-attach">0</property> - <property name="top-attach">6</property> + <property name="top-attach">7</property> </packing> </child> <child> @@ -1822,7 +1851,7 @@ Except the "Weak" method, all the others are recommended, "Keystore" is the defa </object> <packing> <property name="left-attach">1</property> - <property name="top-attach">6</property> + <property name="top-attach">7</property> </packing> </child> </object> diff --git a/src/remmina_file_editor.c b/src/remmina_file_editor.c index 494358768..29344e955 100644 --- a/src/remmina_file_editor.c +++ b/src/remmina_file_editor.c @@ -55,84 +55,86 @@ #include "remmina_unlock.h" #include "remmina_widget_pool.h" + G_DEFINE_TYPE(RemminaFileEditor, remmina_file_editor, GTK_TYPE_DIALOG) static const gchar *server_tips = N_("<big>" - "Supported formats\n" - "• server\n" - "• server[:port]\n" - "VNC additional formats\n" - "• ID:repeater ID number\n" - "• unix:///path/socket.sock" - "</big>"); + "Supported formats\n" + "• server\n" + "• server[:port]\n" + "VNC additional formats\n" + "• ID:repeater ID number\n" + "• unix:///path/socket.sock" + "</big>"); static const gchar *cmd_tips = N_("<big>" - "• command in PATH args %h\n" - "• /path/to/foo -options %h %u\n" - "• %h is substituted with the server name\n" - "• %t is substituted with the SSH server name\n" - "• %u is substituted with the username\n" - "• %U is substituted with the SSH username\n" - "• %p is substituted with Remmina profile name\n" - "• %g is substituted with Remmina profile group name\n" - "• %d is substituted with local date and time in ISO 8601 format\n" - "Do not run in background if you want the command to be executed before connecting.\n" - "</big>"); + "• command in PATH args %h\n" + "• /path/to/foo -options %h %u\n" + "• %h is substituted with the server name\n" + "• %t is substituted with the SSH server name\n" + "• %u is substituted with the username\n" + "• %U is substituted with the SSH username\n" + "• %p is substituted with Remmina profile name\n" + "• %g is substituted with Remmina profile group name\n" + "• %d is substituted with local date and time in ISO 8601 format\n" + "Do not run in background if you want the command to be executed before connecting.\n" + "</big>"); #ifdef HAVE_LIBSSH static const gchar *server_tips2 = N_("<big>" - "Supported formats\n" - "• server\n" - "• server[:port]\n" - "• username@server[:port] (SSH protocol only)" - "</big>"); + "Supported formats\n" + "• server\n" + "• server[:port]\n" + "• username@server[:port] (SSH protocol only)" + "</big>"); #endif -struct _RemminaFileEditorPriv { - RemminaFile * remmina_file; - RemminaProtocolPlugin * plugin; - const gchar * avahi_service_type; - - GtkWidget * name_entry; - GtkWidget * labels_entry; - GtkWidget * group_combo; - GtkWidget * protocol_combo; - GtkWidget * save_button; - - GtkWidget * config_box; - GtkWidget * config_scrollable; - GtkWidget * config_viewport; - GtkWidget * config_container; - - GtkWidget * server_combo; - GtkWidget * resolution_iws_radio; - GtkWidget * resolution_auto_radio; - GtkWidget * resolution_custom_radio; - GtkWidget * resolution_custom_combo; - GtkWidget * keymap_combo; - - GtkWidget * behavior_autostart_check; - GtkWidget * behavior_precommand_entry; - GtkWidget * behavior_postcommand_entry; - GtkWidget * behavior_lock_check; - - GtkWidget * ssh_tunnel_enabled_check; - GtkWidget * ssh_tunnel_loopback_check; - GtkWidget * ssh_tunnel_server_default_radio; - GtkWidget * ssh_tunnel_server_custom_radio; - GtkWidget * ssh_tunnel_server_entry; - GtkWidget * ssh_tunnel_auth_agent_radio; - GtkWidget * ssh_tunnel_auth_password_radio; - GtkWidget * ssh_tunnel_auth_password; - GtkWidget * ssh_tunnel_passphrase; - GtkWidget * ssh_tunnel_auth_publickey_radio; - GtkWidget * ssh_tunnel_auth_auto_publickey_radio; - GtkWidget * ssh_tunnel_auth_combo; - GtkWidget * ssh_tunnel_username_entry; - GtkWidget * ssh_tunnel_privatekey_chooser; - GtkWidget * ssh_tunnel_certfile_chooser; - - GHashTable * setting_widgets; +struct _RemminaFileEditorPriv +{ + RemminaFile *remmina_file; + RemminaProtocolPlugin *plugin; + const gchar *avahi_service_type; + + GtkWidget *name_entry; + GtkWidget *labels_entry; + GtkWidget *group_combo; + GtkWidget *protocol_combo; + GtkWidget *save_button; + + GtkWidget *config_box; + GtkWidget *config_scrollable; + GtkWidget *config_viewport; + GtkWidget *config_container; + + GtkWidget *server_combo; + GtkWidget *resolution_iws_radio; + GtkWidget *resolution_auto_radio; + GtkWidget *resolution_custom_radio; + GtkWidget *resolution_custom_combo; + GtkWidget *keymap_combo; + + GtkWidget *behavior_autostart_check; + GtkWidget *behavior_precommand_entry; + GtkWidget *behavior_postcommand_entry; + GtkWidget *behavior_lock_check; + + GtkWidget *ssh_tunnel_enabled_check; + GtkWidget *ssh_tunnel_loopback_check; + GtkWidget *ssh_tunnel_server_default_radio; + GtkWidget *ssh_tunnel_server_custom_radio; + GtkWidget *ssh_tunnel_server_entry; + GtkWidget *ssh_tunnel_auth_agent_radio; + GtkWidget *ssh_tunnel_auth_password_radio; + GtkWidget *ssh_tunnel_auth_password; + GtkWidget *ssh_tunnel_passphrase; + GtkWidget *ssh_tunnel_auth_publickey_radio; + GtkWidget *ssh_tunnel_auth_auto_publickey_radio; + GtkWidget *ssh_tunnel_auth_combo; + GtkWidget *ssh_tunnel_username_entry; + GtkWidget *ssh_tunnel_privatekey_chooser; + GtkWidget *ssh_tunnel_certfile_chooser; + + GHashTable *setting_widgets; }; static void remmina_file_editor_class_init(RemminaFileEditorClass *klass) @@ -156,16 +158,20 @@ static void remmina_file_editor_class_init(RemminaFileEditorClass *klass) * TODO: Responsive text size and line wrap. */ static void remmina_file_editor_show_validation_error_popup(RemminaFileEditor *gfe, - GtkWidget *failed_widget, - GError *err) { - if (!err) { + GtkWidget *failed_widget, + GError *err) +{ + if (!err) + { err = NULL; // g_set_error doesn't like overwriting errors. g_set_error(&err, 1, 1, _("Input is invalid.")); } - if(!gfe || !failed_widget) { + if (!gfe || !failed_widget) + { g_critical("(%s): Parameters RemminaFileEditor 'gfe' or " - "GtkWidget* 'failed_widget' are 'NULL'!", __func__); + "GtkWidget* 'failed_widget' are 'NULL'!", + __func__); return; } @@ -175,7 +181,7 @@ static void remmina_file_editor_show_validation_error_popup(RemminaFileEditor *g GtkWidget *err_label = gtk_label_new(""); GtkWidget *alert_icon = NULL; GtkWindow *err_window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); - GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); + GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); GdkWindow *window = gtk_widget_get_window(failed_widget); GtkAllocation allocation; @@ -210,7 +216,7 @@ static void remmina_file_editor_show_validation_error_popup(RemminaFileEditor *g gtk_label_set_markup(GTK_LABEL(err_label), markup); alert_icon = gtk_image_new_from_icon_name("dialog-warning-symbolic", - GTK_ICON_SIZE_DND); + GTK_ICON_SIZE_DND); // Fill icon and label into a box. gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(alert_icon), FALSE, FALSE, 0); @@ -223,10 +229,10 @@ static void remmina_file_editor_show_validation_error_popup(RemminaFileEditor *g gtk_widget_show_all(GTK_WIDGET(err_window)); // Mouse click and focus-loss will delete the err_window. - g_signal_connect(G_OBJECT (err_window), "focus-out-event", - G_CALLBACK(gtk_window_close), NULL); - g_signal_connect(G_OBJECT (err_window), "button-press-event", - G_CALLBACK(gtk_window_close), NULL); + g_signal_connect(G_OBJECT(err_window), "focus-out-event", + G_CALLBACK(gtk_window_close), NULL); + g_signal_connect(G_OBJECT(err_window), "button-press-event", + G_CALLBACK(gtk_window_close), NULL); } #ifdef HAVE_LIBAVAHI_UI @@ -238,27 +244,31 @@ static void remmina_file_editor_browse_avahi(GtkWidget *button, RemminaFileEdito gchar *host; dialog = aui_service_dialog_new(_("Choose a Remote Desktop Server"), - GTK_WINDOW(gfe), - _("_Cancel"), GTK_RESPONSE_CANCEL, - _("_OK"), GTK_RESPONSE_ACCEPT, - NULL); + GTK_WINDOW(gfe), + _("_Cancel"), GTK_RESPONSE_CANCEL, + _("_OK"), GTK_RESPONSE_ACCEPT, + NULL); gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(gfe)); aui_service_dialog_set_resolve_service(AUI_SERVICE_DIALOG(dialog), TRUE); aui_service_dialog_set_resolve_host_name(AUI_SERVICE_DIALOG(dialog), TRUE); aui_service_dialog_set_browse_service_types(AUI_SERVICE_DIALOG(dialog), - gfe->priv->avahi_service_type, NULL); + gfe->priv->avahi_service_type, NULL); - if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { + if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) + { host = g_strdup_printf("[%s]:%i", - aui_service_dialog_get_host_name(AUI_SERVICE_DIALOG(dialog)), - aui_service_dialog_get_port(AUI_SERVICE_DIALOG(dialog))); - } else { + aui_service_dialog_get_host_name(AUI_SERVICE_DIALOG(dialog)), + aui_service_dialog_get_port(AUI_SERVICE_DIALOG(dialog))); + } + else + { host = NULL; } gtk_widget_destroy(dialog); - if (host) { + if (host) + { gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(gfe->priv->server_combo))), host); g_free(host); } @@ -275,7 +285,8 @@ static void remmina_file_editor_on_realize(GtkWidget *widget, gpointer user_data defaultwidget = gfe->priv->server_combo; - if (defaultwidget) { + if (defaultwidget) + { if (GTK_IS_EDITABLE(defaultwidget)) gtk_editable_select_region(GTK_EDITABLE(defaultwidget), 0, -1); gtk_widget_grab_focus(defaultwidget); @@ -305,7 +316,7 @@ static void remmina_file_editor_create_notebook_container(RemminaFileEditor *gfe gfe->priv->config_scrollable = gtk_scrolled_window_new(NULL, NULL); gtk_container_set_border_width(GTK_CONTAINER(gfe->priv->config_scrollable), 2); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(gfe->priv->config_scrollable), - GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); + GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); gtk_widget_show(gfe->priv->config_scrollable); gtk_container_add(GTK_CONTAINER(gfe->priv->config_viewport), gfe->priv->config_container); @@ -319,7 +330,7 @@ static void remmina_file_editor_create_notebook_container(RemminaFileEditor *gfe } static GtkWidget *remmina_file_editor_create_notebook_tab(RemminaFileEditor *gfe, - const gchar *stock_id, const gchar *label, gint rows, gint cols) + const gchar *stock_id, const gchar *label, gint rows, gint cols) { TRACE_CALL(__func__); GtkWidget *tablabel; @@ -358,14 +369,13 @@ static void remmina_file_editor_ssh_tunnel_server_custom_radio_on_toggled(GtkTog { TRACE_CALL(__func__); gtk_widget_set_sensitive(GTK_WIDGET(gfe->priv->ssh_tunnel_server_entry), - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gfe->priv->ssh_tunnel_enabled_check)) && - (gfe->priv->ssh_tunnel_server_custom_radio == NULL || - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gfe->priv->ssh_tunnel_server_custom_radio))) - ); + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gfe->priv->ssh_tunnel_enabled_check)) && + (gfe->priv->ssh_tunnel_server_custom_radio == NULL || + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gfe->priv->ssh_tunnel_server_custom_radio)))); } static void remmina_file_editor_ssh_tunnel_enabled_check_on_toggled(GtkToggleButton *togglebutton, - RemminaFileEditor *gfe, RemminaProtocolSSHSetting ssh_setting) + RemminaFileEditor *gfe, RemminaProtocolSSHSetting ssh_setting) { TRACE_CALL(__func__); RemminaFileEditorPriv *priv = gfe->priv; @@ -374,7 +384,8 @@ static void remmina_file_editor_ssh_tunnel_enabled_check_on_toggled(GtkToggleBut const gchar *cp; const gchar *s = NULL; - if (gfe->priv->ssh_tunnel_enabled_check) { + if (gfe->priv->ssh_tunnel_enabled_check) + { enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gfe->priv->ssh_tunnel_enabled_check)); if (gfe->priv->ssh_tunnel_loopback_check) gtk_widget_set_sensitive(GTK_WIDGET(gfe->priv->ssh_tunnel_loopback_check), enabled); @@ -384,7 +395,7 @@ static void remmina_file_editor_ssh_tunnel_enabled_check_on_toggled(GtkToggleBut gtk_widget_set_sensitive(GTK_WIDGET(gfe->priv->ssh_tunnel_server_custom_radio), enabled); remmina_file_editor_ssh_tunnel_server_custom_radio_on_toggled(NULL, gfe); p = remmina_public_combo_get_active_text(GTK_COMBO_BOX(priv->protocol_combo)); - //if (!(g_strcmp0(p, "SFTP") == 0 || g_strcmp0(p, "SSH") == 0)) { + // if (!(g_strcmp0(p, "SFTP") == 0 || g_strcmp0(p, "SSH") == 0)) { gtk_widget_set_sensitive(GTK_WIDGET(gfe->priv->ssh_tunnel_username_entry), enabled); gtk_widget_set_sensitive(GTK_WIDGET(gfe->priv->ssh_tunnel_auth_password), enabled); gtk_widget_set_sensitive(GTK_WIDGET(gfe->priv->ssh_tunnel_auth_combo), enabled); @@ -393,7 +404,7 @@ static void remmina_file_editor_ssh_tunnel_enabled_check_on_toggled(GtkToggleBut //} g_free(p); } - //remmina_file_editor_ssh_tunnel_auth_publickey_radio_on_toggled(NULL, gfe); + // remmina_file_editor_ssh_tunnel_auth_publickey_radio_on_toggled(NULL, gfe); s = remmina_file_get_string(gfe->priv->remmina_file, "ssh_tunnel_privatekey"); if (s) gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(gfe->priv->ssh_tunnel_privatekey_chooser), s); @@ -402,19 +413,24 @@ static void remmina_file_editor_ssh_tunnel_enabled_check_on_toggled(GtkToggleBut gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(gfe->priv->ssh_tunnel_certfile_chooser), s); if (gfe->priv->ssh_tunnel_username_entry) - if (enabled && gtk_entry_get_text(GTK_ENTRY(gfe->priv->ssh_tunnel_username_entry)) [0] == '\0') { + if (enabled && gtk_entry_get_text(GTK_ENTRY(gfe->priv->ssh_tunnel_username_entry))[0] == '\0') + { cp = remmina_file_get_string(priv->remmina_file, "ssh_tunnel_username"); gtk_entry_set_text(GTK_ENTRY(gfe->priv->ssh_tunnel_username_entry), cp ? cp : ""); } - if (gfe->priv->ssh_tunnel_auth_password) { - if (enabled && gtk_entry_get_text(GTK_ENTRY(gfe->priv->ssh_tunnel_auth_password)) [0] == '\0') { + if (gfe->priv->ssh_tunnel_auth_password) + { + if (enabled && gtk_entry_get_text(GTK_ENTRY(gfe->priv->ssh_tunnel_auth_password))[0] == '\0') + { cp = remmina_file_get_string(priv->remmina_file, "ssh_tunnel_password"); gtk_entry_set_text(GTK_ENTRY(gfe->priv->ssh_tunnel_auth_password), cp ? cp : ""); } } - if (gfe->priv->ssh_tunnel_passphrase) { - if (enabled && gtk_entry_get_text(GTK_ENTRY(gfe->priv->ssh_tunnel_passphrase)) [0] == '\0') { + if (gfe->priv->ssh_tunnel_passphrase) + { + if (enabled && gtk_entry_get_text(GTK_ENTRY(gfe->priv->ssh_tunnel_passphrase))[0] == '\0') + { cp = remmina_file_get_string(priv->remmina_file, "ssh_tunnel_passphrase"); gtk_entry_set_text(GTK_ENTRY(gfe->priv->ssh_tunnel_passphrase), cp ? cp : ""); } @@ -424,7 +440,7 @@ static void remmina_file_editor_ssh_tunnel_enabled_check_on_toggled(GtkToggleBut #endif static void remmina_file_editor_create_server(RemminaFileEditor *gfe, const RemminaProtocolSetting *setting, GtkWidget *grid, - gint row) + gint row) { TRACE_CALL(__func__); RemminaProtocolPlugin *plugin = gfe->priv->plugin; @@ -450,7 +466,8 @@ static void remmina_file_editor_create_server(RemminaFileEditor *gfe, const Remm g_free(s); #ifdef HAVE_LIBAVAHI_UI - if (setting->opt1) { + if (setting->opt1) + { gfe->priv->avahi_service_type = (const gchar *)setting->opt1; hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); @@ -466,16 +483,38 @@ static void remmina_file_editor_create_server(RemminaFileEditor *gfe, const Remm g_signal_connect(G_OBJECT(widget), "clicked", G_CALLBACK(remmina_file_editor_browse_avahi), gfe); gtk_grid_attach(GTK_GRID(grid), hbox, 1, row, 1, 1); - } else + } + else #endif { gtk_grid_attach(GTK_GRID(grid), widget, 1, row, 1, 1); } } +static void remmina_file_toggle_password_view(GtkWidget *widget, gpointer data) { + GtkWindow *mainwindow; + gboolean visible = gtk_entry_get_visibility(GTK_ENTRY(widget)); + mainwindow = remmina_main_get_window(); + if (remmina_pref_get_boolean("use_primary_password") + && remmina_pref_get_boolean("lock_view_passwords") + && remmina_unlock_new(mainwindow) == 0) + return; + + if (visible) { + gtk_entry_set_visibility(GTK_ENTRY(widget), FALSE); + gtk_entry_set_icon_from_icon_name(GTK_ENTRY(widget), + GTK_ENTRY_ICON_SECONDARY, + "view-reveal-symbolic.symbolic"); + } else { + gtk_entry_set_visibility(GTK_ENTRY(widget), TRUE); + gtk_entry_set_icon_from_icon_name(GTK_ENTRY(widget), + GTK_ENTRY_ICON_SECONDARY, + "view-conceal-symbolic.symbolic"); + } +} static GtkWidget *remmina_file_editor_create_password(RemminaFileEditor *gfe, GtkWidget *grid, - gint row, gint col, const gchar *label, const gchar *value, - gchar* setting_name) + gint row, gint col, const gchar *label, const gchar *value, + gchar *setting_name) { TRACE_CALL(__func__); GtkWidget *widget; @@ -503,6 +542,15 @@ static GtkWidget *remmina_file_editor_create_password(RemminaFileEditor *gfe, Gt if (value) gtk_entry_set_text(GTK_ENTRY(widget), value); + /* Password view Toogle*/ + if (setting_name) + { + gtk_entry_set_icon_from_icon_name(GTK_ENTRY(widget), + GTK_ENTRY_ICON_SECONDARY, + "view-reveal-symbolic.symbolic"); + gtk_entry_set_icon_activatable(GTK_ENTRY(widget), GTK_ENTRY_ICON_SECONDARY, TRUE); + g_signal_connect(widget, "icon-press", G_CALLBACK(remmina_file_toggle_password_view), NULL); + } return widget; } @@ -511,11 +559,10 @@ static void remmina_file_editor_update_resolution(GtkWidget *widget, RemminaFile TRACE_CALL(__func__); gchar *res_str; res_str = g_strdup_printf("%dx%d", - remmina_file_get_int(gfe->priv->remmina_file, "resolution_width", 0), - remmina_file_get_int(gfe->priv->remmina_file, "resolution_height", 0) - ); + remmina_file_get_int(gfe->priv->remmina_file, "resolution_width", 0), + remmina_file_get_int(gfe->priv->remmina_file, "resolution_height", 0)); remmina_public_load_combo_text_d(gfe->priv->resolution_custom_combo, remmina_pref.resolutions, - res_str, NULL); + res_str, NULL); g_free(res_str); } @@ -536,7 +583,7 @@ static void remmina_file_editor_browse_resolution(GtkWidget *button, RemminaFile } static void remmina_file_editor_create_resolution(RemminaFileEditor *gfe, const RemminaProtocolSetting *setting, - GtkWidget *grid, gint row) + GtkWidget *grid, gint row) { TRACE_CALL(__func__); GtkWidget *widget; @@ -551,7 +598,8 @@ static void remmina_file_editor_create_resolution(RemminaFileEditor *gfe, const /* If resolution_mode is non-existent (-1), then we try to calculate it * as we did before having resolution_mode */ - if (res_mode == RES_INVALID) { + if (res_mode == RES_INVALID) + { if (resolution_w <= 0 || resolution_h <= 0) res_mode = RES_USE_INITIAL_WINDOW_SIZE; else @@ -600,7 +648,7 @@ static void remmina_file_editor_create_resolution(RemminaFileEditor *gfe, const g_signal_connect(G_OBJECT(widget), "clicked", G_CALLBACK(remmina_file_editor_browse_resolution), gfe); g_signal_connect(G_OBJECT(gfe->priv->resolution_custom_radio), "toggled", - G_CALLBACK(remmina_file_editor_button_on_toggled), gfe->priv->resolution_custom_combo); + G_CALLBACK(remmina_file_editor_button_on_toggled), gfe->priv->resolution_custom_combo); if (res_mode == RES_USE_CUSTOM) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gfe->priv->resolution_custom_radio), TRUE); @@ -615,8 +663,8 @@ static void remmina_file_editor_create_resolution(RemminaFileEditor *gfe, const } static GtkWidget *remmina_file_editor_create_text2(RemminaFileEditor *gfe, GtkWidget *grid, - gint row, gint col, const gchar *label, const gchar *value, gint left, - gint right, gchar* setting_name) + gint row, gint col, const gchar *label, const gchar *value, gint left, + gint right, gchar *setting_name) { TRACE_CALL(__func__); GtkWidget *widget; @@ -649,8 +697,8 @@ static GtkWidget *remmina_file_editor_create_text2(RemminaFileEditor *gfe, GtkWi } static GtkWidget *remmina_file_editor_create_text(RemminaFileEditor *gfe, GtkWidget *grid, - gint row, gint col, const gchar *label, const gchar *value, - gchar* setting_name) + gint row, gint col, const gchar *label, const gchar *value, + gchar *setting_name) { TRACE_CALL(__func__); return remmina_file_editor_create_text2(gfe, grid, row, col, label, value, 0, 40, @@ -658,8 +706,8 @@ static GtkWidget *remmina_file_editor_create_text(RemminaFileEditor *gfe, GtkWid } static GtkWidget *remmina_file_editor_create_textarea(RemminaFileEditor *gfe, GtkWidget *grid, - gint row, gint col, const gchar *label, const gchar *value, - gchar* setting_name) + gint row, gint col, const gchar *label, const gchar *value, + gchar *setting_name) { TRACE_CALL(__func__); GtkWidget *widget; @@ -668,31 +716,32 @@ static GtkWidget *remmina_file_editor_create_textarea(RemminaFileEditor *gfe, Gt GtkTextIter start; widget = gtk_text_view_new(); - view = GTK_TEXT_VIEW (widget); - gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD); - gtk_text_view_set_top_margin (GTK_TEXT_VIEW (view), 20); - gtk_text_view_set_bottom_margin (GTK_TEXT_VIEW (view), 20); - gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 20); - gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 20); + view = GTK_TEXT_VIEW(widget); + gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(view), GTK_WRAP_WORD); + gtk_text_view_set_top_margin(GTK_TEXT_VIEW(view), 20); + gtk_text_view_set_bottom_margin(GTK_TEXT_VIEW(view), 20); + gtk_text_view_set_left_margin(GTK_TEXT_VIEW(view), 20); + gtk_text_view_set_right_margin(GTK_TEXT_VIEW(view), 20); gtk_text_view_set_monospace(view, TRUE); if (setting_name) gtk_widget_set_name(widget, setting_name); - if (value) { - buffer = gtk_text_view_get_buffer (view); - gtk_text_buffer_set_text (buffer, value, -1); - gtk_text_buffer_get_start_iter (buffer, &start); + if (value) + { + buffer = gtk_text_view_get_buffer(view); + gtk_text_buffer_set_text(buffer, value, -1); + gtk_text_buffer_get_start_iter(buffer, &start); gtk_text_buffer_place_cursor(buffer, &start); } gtk_widget_show(widget); gtk_widget_set_hexpand(widget, TRUE); - gtk_widget_set_size_request (GTK_WIDGET(view), 320, 300); + gtk_widget_set_size_request(GTK_WIDGET(view), 320, 300); gtk_grid_attach(GTK_GRID(grid), widget, 0, row, 1, 1); return widget; } static GtkWidget *remmina_file_editor_create_select(RemminaFileEditor *gfe, GtkWidget *grid, - gint row, gint col, const gchar *label, const gpointer *list, - const gchar *value, gchar* setting_name) + gint row, gint col, const gchar *label, const gpointer *list, + const gchar *value, gchar *setting_name) { TRACE_CALL(__func__); GtkWidget *widget; @@ -713,8 +762,8 @@ static GtkWidget *remmina_file_editor_create_select(RemminaFileEditor *gfe, GtkW } static GtkWidget *remmina_file_editor_create_combo(RemminaFileEditor *gfe, GtkWidget *grid, - gint row, gint col, const gchar *label, const gchar *list, - const gchar *value, gchar* setting_name) + gint row, gint col, const gchar *label, const gchar *list, + const gchar *value, gchar *setting_name) { TRACE_CALL(__func__); GtkWidget *widget; @@ -736,8 +785,8 @@ static GtkWidget *remmina_file_editor_create_combo(RemminaFileEditor *gfe, GtkWi } static GtkWidget *remmina_file_editor_create_check(RemminaFileEditor *gfe, GtkWidget *grid, - gint row, gint top, const gchar *label, gboolean value, - gchar* setting_name) + gint row, gint top, const gchar *label, gboolean value, + gchar *setting_name) { TRACE_CALL(__func__); GtkWidget *widget; @@ -764,7 +813,7 @@ static GtkWidget *remmina_file_editor_create_check(RemminaFileEditor *gfe, GtkWi */ static GtkWidget * remmina_file_editor_create_chooser(RemminaFileEditor *gfe, GtkWidget *grid, gint row, gint col, const gchar *label, - const gchar *value, gint type, gchar* setting_name) + const gchar *value, gint type, gchar *setting_name) { TRACE_CALL(__func__); GtkWidget *check; @@ -802,33 +851,37 @@ remmina_file_editor_create_chooser(RemminaFileEditor *gfe, GtkWidget *grid, gint // used to filter out invalid characters for REMMINA_PROTOCOL_SETTING_TYPE_INT void remmina_file_editor_int_setting_filter(GtkEditable *editable, const gchar *text, - gint length, gint *position, gpointer data) + gint length, gint *position, gpointer data) { - for (int i = 0; i < length; i++) { - if (!isdigit(text[i]) && text[i] != '-') { - g_signal_stop_emission_by_name(G_OBJECT(editable), "insert-text"); - return; - } - } + for (int i = 0; i < length; i++) + { + if (!isdigit(text[i]) && text[i] != '-') + { + g_signal_stop_emission_by_name(G_OBJECT(editable), "insert-text"); + return; + } + } } // used to filter out invalid characters for REMMINA_PROTOCOL_SETTING_TYPE_DOUBLE // '.' and ',' can't be used interchangeably! It depends on the language setting // of the user. void remmina_file_editor_double_setting_filter(GtkEditable *editable, const gchar *text, - gint length, gint *position, gpointer data) + gint length, gint *position, gpointer data) { - for (int i = 0; i < length; i++) { - if (!isdigit(text[i]) && text[i] != '-' && text[i] != '.' && text[i] != ',') { - g_signal_stop_emission_by_name(G_OBJECT(editable), "insert-text"); - return; - } - } + for (int i = 0; i < length; i++) + { + if (!isdigit(text[i]) && text[i] != '-' && text[i] != '.' && text[i] != ',') + { + g_signal_stop_emission_by_name(G_OBJECT(editable), "insert-text"); + return; + } + } } static GtkWidget *remmina_file_editor_create_int(RemminaFileEditor *gfe, GtkWidget *grid, - gint row, gint col, const gchar *label, const gint value, - gint left, gint right, gchar* setting_name) + gint row, gint col, const gchar *label, const gint value, + gint left, gint right, gchar *setting_name) { TRACE_CALL(__func__); GtkWidget *widget; @@ -856,7 +909,7 @@ static GtkWidget *remmina_file_editor_create_int(RemminaFileEditor *gfe, GtkWidg // Convert int to str. int length = snprintf(NULL, 0, "%d", value) + 1; // +1 '\0' byte - char* str = malloc(length); + char *str = malloc(length); snprintf(str, length, "%d", value); gtk_entry_set_text(GTK_ENTRY(widget), str); @@ -869,9 +922,9 @@ static GtkWidget *remmina_file_editor_create_int(RemminaFileEditor *gfe, GtkWidg } static GtkWidget *remmina_file_editor_create_double(RemminaFileEditor *gfe, - GtkWidget *grid, gint row, gint col, - const gchar *label, gdouble value, gint left, - gint right, gchar* setting_name) + GtkWidget *grid, gint row, gint col, + const gchar *label, gdouble value, gint left, + gint right, gchar *setting_name) { TRACE_CALL(__func__); GtkWidget *widget; @@ -899,7 +952,7 @@ static GtkWidget *remmina_file_editor_create_double(RemminaFileEditor *gfe, // Convert double to str. int length = snprintf(NULL, 0, "%.8g", value) + 1; // +1 '\0' byte - char* str = malloc(length); + char *str = malloc(length); snprintf(str, length, "%f", value); gtk_entry_set_text(GTK_ENTRY(widget), str); @@ -912,11 +965,12 @@ static GtkWidget *remmina_file_editor_create_double(RemminaFileEditor *gfe, } gdouble remmina_file_get_double(RemminaFile *remminafile, - const gchar *setting, - gfloat default_value); + const gchar *setting, + gfloat default_value); + static void remmina_file_editor_create_settings(RemminaFileEditor *gfe, GtkWidget *grid, - const RemminaProtocolSetting *settings) + const RemminaProtocolSetting *settings) { TRACE_CALL(__func__); RemminaFileEditorPriv *priv = gfe->priv; @@ -927,18 +981,20 @@ static void remmina_file_editor_create_settings(RemminaFileEditor *gfe, GtkWidge gchar *setting_name; const gchar *escaped; - while (settings->type != REMMINA_PROTOCOL_SETTING_TYPE_END) { + while (settings->type != REMMINA_PROTOCOL_SETTING_TYPE_END) + { setting_name = (gchar *)(remmina_plugin_manager_get_canonical_setting_name(settings)); - switch (settings->type) { + switch (settings->type) + { case REMMINA_PROTOCOL_SETTING_TYPE_SERVER: remmina_file_editor_create_server(gfe, settings, grid, grid_row); break; case REMMINA_PROTOCOL_SETTING_TYPE_PASSWORD: widget = remmina_file_editor_create_password(gfe, grid, grid_row, 0, - g_dgettext(priv->plugin->domain, settings->label), - remmina_file_get_string(priv->remmina_file, setting_name), - setting_name); + g_dgettext(priv->plugin->domain, settings->label), + remmina_file_get_string(priv->remmina_file, setting_name), + setting_name); g_hash_table_insert(priv->setting_widgets, setting_name, widget); grid_row++; break; @@ -951,19 +1007,19 @@ static void remmina_file_editor_create_settings(RemminaFileEditor *gfe, GtkWidge case REMMINA_PROTOCOL_SETTING_TYPE_KEYMAP: strarr = remmina_pref_keymap_groups(); priv->keymap_combo = remmina_file_editor_create_select(gfe, grid, - grid_row + 1, 0, - _("Keyboard mapping"), (const gpointer *)strarr, - remmina_file_get_string(priv->remmina_file, "keymap"), - setting_name); + grid_row + 1, 0, + _("Keyboard mapping"), (const gpointer *)strarr, + remmina_file_get_string(priv->remmina_file, "keymap"), + setting_name); g_strfreev(strarr); grid_row++; break; case REMMINA_PROTOCOL_SETTING_TYPE_TEXT: widget = remmina_file_editor_create_text(gfe, grid, grid_row, 0, - g_dgettext(priv->plugin->domain, settings->label), - remmina_file_get_string(priv->remmina_file, setting_name), - setting_name); + g_dgettext(priv->plugin->domain, settings->label), + remmina_file_get_string(priv->remmina_file, setting_name), + setting_name); g_hash_table_insert(priv->setting_widgets, setting_name, widget); if (settings->opt2) gtk_widget_set_tooltip_text(widget, _((const gchar *)settings->opt2)); @@ -972,20 +1028,20 @@ static void remmina_file_editor_create_settings(RemminaFileEditor *gfe, GtkWidge case REMMINA_PROTOCOL_SETTING_TYPE_TEXTAREA: escaped = remmina_file_get_string(priv->remmina_file, setting_name); - escaped = g_uri_unescape_string (escaped, NULL); + escaped = g_uri_unescape_string(escaped, NULL); widget = remmina_file_editor_create_textarea(gfe, grid, grid_row, 0, - g_dgettext(priv->plugin->domain, settings->label), escaped, - setting_name); + g_dgettext(priv->plugin->domain, settings->label), escaped, + setting_name); g_hash_table_insert(priv->setting_widgets, setting_name, widget); grid_row++; break; case REMMINA_PROTOCOL_SETTING_TYPE_SELECT: widget = remmina_file_editor_create_select(gfe, grid, grid_row, 0, - g_dgettext(priv->plugin->domain, settings->label), - (const gpointer *)settings->opt1, - remmina_file_get_string(priv->remmina_file, setting_name), - setting_name); + g_dgettext(priv->plugin->domain, settings->label), + (const gpointer *)settings->opt1, + remmina_file_get_string(priv->remmina_file, setting_name), + setting_name); g_hash_table_insert(priv->setting_widgets, setting_name, widget); if (settings->opt2) gtk_widget_set_tooltip_text(widget, _((const gchar *)settings->opt2)); @@ -993,10 +1049,10 @@ static void remmina_file_editor_create_settings(RemminaFileEditor *gfe, GtkWidge case REMMINA_PROTOCOL_SETTING_TYPE_COMBO: widget = remmina_file_editor_create_combo(gfe, grid, grid_row, 0, - g_dgettext(priv->plugin->domain, settings->label), - (const gchar *)settings->opt1, - remmina_file_get_string(priv->remmina_file, setting_name), - setting_name); + g_dgettext(priv->plugin->domain, settings->label), + (const gchar *)settings->opt1, + remmina_file_get_string(priv->remmina_file, setting_name), + setting_name); g_hash_table_insert(priv->setting_widgets, setting_name, widget); if (settings->opt2) gtk_widget_set_tooltip_text(widget, _((const gchar *)settings->opt2)); @@ -1004,9 +1060,9 @@ static void remmina_file_editor_create_settings(RemminaFileEditor *gfe, GtkWidge case REMMINA_PROTOCOL_SETTING_TYPE_CHECK: widget = remmina_file_editor_create_check(gfe, grid, grid_row, grid_column, - g_dgettext(priv->plugin->domain, settings->label), - remmina_file_get_int(priv->remmina_file, setting_name, FALSE), - setting_name); + g_dgettext(priv->plugin->domain, settings->label), + remmina_file_get_int(priv->remmina_file, setting_name, FALSE), + setting_name); g_hash_table_insert(priv->setting_widgets, setting_name, widget); if (settings->opt2) gtk_widget_set_tooltip_text(widget, _((const gchar *)settings->opt2)); @@ -1014,9 +1070,9 @@ static void remmina_file_editor_create_settings(RemminaFileEditor *gfe, GtkWidge case REMMINA_PROTOCOL_SETTING_TYPE_FILE: widget = remmina_file_editor_create_chooser(gfe, grid, grid_row, 0, - g_dgettext(priv->plugin->domain, settings->label), - remmina_file_get_string(priv->remmina_file, setting_name), - GTK_FILE_CHOOSER_ACTION_OPEN, setting_name); + g_dgettext(priv->plugin->domain, settings->label), + remmina_file_get_string(priv->remmina_file, setting_name), + GTK_FILE_CHOOSER_ACTION_OPEN, setting_name); g_hash_table_insert(priv->setting_widgets, setting_name, widget); if (settings->opt2) gtk_widget_set_tooltip_text(widget, _((const gchar *)settings->opt2)); @@ -1024,19 +1080,19 @@ static void remmina_file_editor_create_settings(RemminaFileEditor *gfe, GtkWidge case REMMINA_PROTOCOL_SETTING_TYPE_FOLDER: widget = remmina_file_editor_create_chooser(gfe, grid, grid_row, 0, - g_dgettext(priv->plugin->domain, settings->label), - remmina_file_get_string(priv->remmina_file, setting_name), - GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, - setting_name); + g_dgettext(priv->plugin->domain, settings->label), + remmina_file_get_string(priv->remmina_file, setting_name), + GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, + setting_name); g_hash_table_insert(priv->setting_widgets, setting_name, widget); if (settings->opt2) gtk_widget_set_tooltip_text(widget, _((const gchar *)settings->opt2)); break; case REMMINA_PROTOCOL_SETTING_TYPE_INT: widget = remmina_file_editor_create_int(gfe, grid, grid_row, 0, - g_dgettext(priv->plugin->domain, settings->label), - remmina_file_get_int(priv->remmina_file, setting_name, 0), - 0, 40, setting_name); + g_dgettext(priv->plugin->domain, settings->label), + remmina_file_get_int(priv->remmina_file, setting_name, 0), + 0, 40, setting_name); g_hash_table_insert(priv->setting_widgets, setting_name, widget); if (settings->opt2) gtk_widget_set_tooltip_text(widget, _((const gchar *)settings->opt2)); @@ -1044,9 +1100,9 @@ static void remmina_file_editor_create_settings(RemminaFileEditor *gfe, GtkWidge break; case REMMINA_PROTOCOL_SETTING_TYPE_DOUBLE: widget = remmina_file_editor_create_double(gfe, grid, grid_row, 0, - g_dgettext(priv->plugin->domain, settings->label), - remmina_file_get_double(priv->remmina_file,setting_name, 0.0f), - 0, 40, setting_name); + g_dgettext(priv->plugin->domain, settings->label), + remmina_file_get_double(priv->remmina_file, setting_name, 0.0f), + 0, 40, setting_name); g_hash_table_insert(priv->setting_widgets, setting_name, widget); if (settings->opt2) gtk_widget_set_tooltip_text(widget, _((const gchar *)settings->opt2)); @@ -1062,7 +1118,8 @@ static void remmina_file_editor_create_settings(RemminaFileEditor *gfe, GtkWidge /* Add a new settings row and move to the first column * if the setting doesn’t want the compactness * or we already have two columns */ - if (!settings->compact || grid_column > 1) { + if (!settings->compact || grid_column > 1) + { grid_row++; grid_column = 0; } @@ -1079,7 +1136,7 @@ static void remmina_file_editor_create_behavior_tab(RemminaFileEditor *gfe) const gchar *cs; /* The Behavior tab (implementation) */ - grid = remmina_file_editor_create_notebook_tab(gfe, NULL, _("Behavior"), 20, 2); + grid = remmina_file_editor_create_notebook_tab(gfe, NULL, _("Behavior"), 20, 2); /* Execute Command frame */ remmina_public_create_group(GTK_GRID(grid), _("Execute a Command"), 0, 1, 2); @@ -1103,26 +1160,25 @@ static void remmina_file_editor_create_behavior_tab(RemminaFileEditor *gfe) /* Autostart profile option */ priv->behavior_autostart_check = remmina_file_editor_create_check(gfe, grid, 6, 1, _("Auto-start this profile"), - remmina_file_get_int(priv->remmina_file, "enable-autostart", FALSE), "enable-autostart"); + remmina_file_get_int(priv->remmina_file, "enable-autostart", FALSE), "enable-autostart"); /* Startup frame */ remmina_public_create_group(GTK_GRID(grid), _("Connection profile security"), 8, 1, 2); /* Autostart profile option */ priv->behavior_lock_check = remmina_file_editor_create_check(gfe, grid, 10, 1, _("Require password to connect or edit the profile"), - remmina_file_get_int(priv->remmina_file, "profile-lock", FALSE), "profile-lock"); + remmina_file_get_int(priv->remmina_file, "profile-lock", FALSE), "profile-lock"); } #ifdef HAVE_LIBSSH static gpointer ssh_tunnel_auth_list[] = -{ - "0", N_("Password"), - "1", N_("SSH identity file"), - "2", N_("SSH agent"), - "3", N_("Public key (automatic)"), - "4", N_("Kerberos (GSSAPI)"), - NULL -}; + { + "0", N_("Password"), + "1", N_("SSH identity file"), + "2", N_("SSH agent"), + "3", N_("Public key (automatic)"), + "4", N_("Kerberos (GSSAPI)"), + NULL}; #endif static void remmina_file_editor_create_ssh_tunnel_tab(RemminaFileEditor *gfe, RemminaProtocolSSHSetting ssh_setting) @@ -1137,16 +1193,17 @@ static void remmina_file_editor_create_ssh_tunnel_tab(RemminaFileEditor *gfe, Re gchar *p; gint row = 0; - if (ssh_setting == REMMINA_PROTOCOL_SSH_SETTING_NONE) return; + if (ssh_setting == REMMINA_PROTOCOL_SSH_SETTING_NONE) + return; /* The SSH tab (implementation) */ grid = remmina_file_editor_create_notebook_tab(gfe, NULL, - _("SSH Tunnel"), 9, 3); + _("SSH Tunnel"), 9, 3); widget = gtk_toggle_button_new_with_label(_("Enable SSH tunnel")); gtk_widget_set_halign(widget, GTK_ALIGN_START); gtk_grid_attach(GTK_GRID(grid), widget, 0, row, 1, 1); g_signal_connect(G_OBJECT(widget), "toggled", - G_CALLBACK(remmina_file_editor_ssh_tunnel_enabled_check_on_toggled), gfe); + G_CALLBACK(remmina_file_editor_ssh_tunnel_enabled_check_on_toggled), gfe); priv->ssh_tunnel_enabled_check = widget; widget = gtk_check_button_new_with_label(_("Tunnel via loopback address")); @@ -1157,7 +1214,8 @@ static void remmina_file_editor_create_ssh_tunnel_tab(RemminaFileEditor *gfe, Re row++; /* SSH Server group */ - switch (ssh_setting) { + switch (ssh_setting) + { case REMMINA_PROTOCOL_SSH_SETTING_TUNNEL: s = g_strdup_printf(_("Same server at port %i"), DEFAULT_SSH_PORT); widget = gtk_radio_button_new_with_label(NULL, s); @@ -1171,7 +1229,7 @@ static void remmina_file_editor_create_ssh_tunnel_tab(RemminaFileEditor *gfe, Re GTK_RADIO_BUTTON(priv->ssh_tunnel_server_default_radio), _("Custom")); gtk_grid_attach(GTK_GRID(grid), widget, 0, row, 1, 1); g_signal_connect(G_OBJECT(widget), "toggled", - G_CALLBACK(remmina_file_editor_ssh_tunnel_server_custom_radio_on_toggled), gfe); + G_CALLBACK(remmina_file_editor_ssh_tunnel_server_custom_radio_on_toggled), gfe); priv->ssh_tunnel_server_custom_radio = widget; widget = gtk_entry_new(); @@ -1188,7 +1246,7 @@ static void remmina_file_editor_create_ssh_tunnel_tab(RemminaFileEditor *gfe, Re priv->ssh_tunnel_server_custom_radio = NULL; priv->ssh_tunnel_server_entry = remmina_file_editor_create_text(gfe, grid, 1, 0, - _("Server"), NULL, "ssh_reverse_tunnel_server"); + _("Server"), NULL, "ssh_reverse_tunnel_server"); gtk_widget_set_tooltip_markup(priv->ssh_tunnel_server_entry, _(server_tips)); // 2 row++; @@ -1207,9 +1265,10 @@ static void remmina_file_editor_create_ssh_tunnel_tab(RemminaFileEditor *gfe, Re /* This is not used? */ p = remmina_public_combo_get_active_text(GTK_COMBO_BOX(priv->protocol_combo)); - if (ssh_setting == REMMINA_PROTOCOL_SSH_SETTING_SFTP) { + if (ssh_setting == REMMINA_PROTOCOL_SSH_SETTING_SFTP) + { widget = remmina_file_editor_create_text(gfe, grid, row, 1, - _("Start-up path"), NULL, "start-up-path"); + _("Start-up path"), NULL, "start-up-path"); cs = remmina_file_get_string(priv->remmina_file, "execpath"); gtk_entry_set_text(GTK_ENTRY(widget), cs ? cs : ""); g_hash_table_insert(priv->setting_widgets, "execpath", widget); @@ -1220,40 +1279,41 @@ static void remmina_file_editor_create_ssh_tunnel_tab(RemminaFileEditor *gfe, Re /* SSH Authentication frame */ remmina_public_create_group(GTK_GRID(grid), _("SSH Authentication"), row, 6, 1); // 5 - row +=2; + row += 2; priv->ssh_tunnel_auth_combo = remmina_file_editor_create_select(gfe, grid, row, 0, - _("Authentication type"), - (const gpointer *)ssh_tunnel_auth_list, - remmina_file_get_string(priv->remmina_file, "ssh_tunnel_auth"), "ssh_tunnel_auth"); + _("Authentication type"), + (const gpointer *)ssh_tunnel_auth_list, + remmina_file_get_string(priv->remmina_file, "ssh_tunnel_auth"), "ssh_tunnel_auth"); row++; if (ssh_setting == REMMINA_PROTOCOL_SSH_SETTING_TUNNEL || - ssh_setting == REMMINA_PROTOCOL_SSH_SETTING_REVERSE_TUNNEL) { + ssh_setting == REMMINA_PROTOCOL_SSH_SETTING_REVERSE_TUNNEL) + { priv->ssh_tunnel_username_entry = remmina_file_editor_create_text(gfe, grid, row, 0, - _("Username"), NULL, "ssh_tunnel_username"); + _("Username"), NULL, "ssh_tunnel_username"); // 5 row++; } - widget= remmina_file_editor_create_password(gfe, grid, row, 0, - _("Password"), - remmina_file_get_string(priv->remmina_file, "ssh_tunnel_password"), - "ssh_tunnel_password"); + widget = remmina_file_editor_create_password(gfe, grid, row, 0, + _("Password"), + remmina_file_get_string(priv->remmina_file, "ssh_tunnel_password"), + "ssh_tunnel_password"); priv->ssh_tunnel_auth_password = widget; row++; priv->ssh_tunnel_privatekey_chooser = remmina_file_editor_create_chooser(gfe, grid, row, 0, - _("SSH private key file"), - remmina_file_get_string(priv->remmina_file, "ssh_tunnel_privatekey"), - GTK_FILE_CHOOSER_ACTION_OPEN, "ssh_tunnel_privatekey"); + _("SSH private key file"), + remmina_file_get_string(priv->remmina_file, "ssh_tunnel_privatekey"), + GTK_FILE_CHOOSER_ACTION_OPEN, "ssh_tunnel_privatekey"); row++; priv->ssh_tunnel_certfile_chooser = remmina_file_editor_create_chooser(gfe, grid, row, 0, - _("SSH certificate file"), - remmina_file_get_string(priv->remmina_file, "ssh_tunnel_certfile"), - GTK_FILE_CHOOSER_ACTION_OPEN, "ssh_tunnel_certfile"); + _("SSH certificate file"), + remmina_file_get_string(priv->remmina_file, "ssh_tunnel_certfile"), + GTK_FILE_CHOOSER_ACTION_OPEN, "ssh_tunnel_certfile"); row++; widget = gtk_label_new(_("Password to unlock private key")); @@ -1268,23 +1328,25 @@ static void remmina_file_editor_create_ssh_tunnel_tab(RemminaFileEditor *gfe, Re /* Set the values */ cs = remmina_file_get_string(priv->remmina_file, "ssh_tunnel_server"); - if (ssh_setting == REMMINA_PROTOCOL_SSH_SETTING_TUNNEL) { + if (ssh_setting == REMMINA_PROTOCOL_SSH_SETTING_TUNNEL) + { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->ssh_tunnel_enabled_check), - remmina_file_get_int(priv->remmina_file, "ssh_tunnel_enabled", FALSE)); + remmina_file_get_int(priv->remmina_file, "ssh_tunnel_enabled", FALSE)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->ssh_tunnel_loopback_check), - remmina_file_get_int(priv->remmina_file, "ssh_tunnel_loopback", FALSE)); + remmina_file_get_int(priv->remmina_file, "ssh_tunnel_loopback", FALSE)); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cs ? - priv->ssh_tunnel_server_custom_radio : priv->ssh_tunnel_server_default_radio), TRUE); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cs ? priv->ssh_tunnel_server_custom_radio : priv->ssh_tunnel_server_default_radio), TRUE); gtk_entry_set_text(GTK_ENTRY(priv->ssh_tunnel_server_entry), - cs ? cs : ""); - } else if (ssh_setting == REMMINA_PROTOCOL_SSH_SETTING_REVERSE_TUNNEL) { + cs ? cs : ""); + } + else if (ssh_setting == REMMINA_PROTOCOL_SSH_SETTING_REVERSE_TUNNEL) + { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->ssh_tunnel_enabled_check), - remmina_file_get_int(priv->remmina_file, "ssh_tunnel_enabled", FALSE)); + remmina_file_get_int(priv->remmina_file, "ssh_tunnel_enabled", FALSE)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->ssh_tunnel_loopback_check), - remmina_file_get_int(priv->remmina_file, "ssh_tunnel_loopback", FALSE)); + remmina_file_get_int(priv->remmina_file, "ssh_tunnel_loopback", FALSE)); gtk_entry_set_text(GTK_ENTRY(priv->ssh_tunnel_server_entry), - cs ? cs : ""); + cs ? cs : ""); } remmina_file_editor_ssh_tunnel_enabled_check_on_toggled(NULL, gfe, ssh_setting); @@ -1300,21 +1362,22 @@ static void remmina_file_editor_create_all_settings(RemminaFileEditor *gfe) GtkWidget *grid; static const RemminaProtocolSetting notes_settings[] = - { - { REMMINA_PROTOCOL_SETTING_TYPE_TEXTAREA, "notes_text", NULL, FALSE, NULL, NULL }, - { REMMINA_PROTOCOL_SETTING_TYPE_END, NULL, NULL, FALSE, NULL, NULL } - }; + { + {REMMINA_PROTOCOL_SETTING_TYPE_TEXTAREA, "notes_text", NULL, FALSE, NULL, NULL}, + {REMMINA_PROTOCOL_SETTING_TYPE_END, NULL, NULL, FALSE, NULL, NULL}}; remmina_file_editor_create_notebook_container(gfe); /* The Basic tab */ - if (priv->plugin->basic_settings) { + if (priv->plugin->basic_settings) + { grid = remmina_file_editor_create_notebook_tab(gfe, NULL, _("Basic"), 20, 2); remmina_file_editor_create_settings(gfe, grid, priv->plugin->basic_settings); } /* The Advanced tab */ - if (priv->plugin->advanced_settings) { + if (priv->plugin->advanced_settings) + { grid = remmina_file_editor_create_notebook_tab(gfe, NULL, _("Advanced"), 20, 2); remmina_file_editor_create_settings(gfe, grid, priv->plugin->advanced_settings); } @@ -1336,7 +1399,8 @@ static void remmina_file_editor_protocol_combo_on_changed(GtkComboBox *combo, Re RemminaFileEditorPriv *priv = gfe->priv; gchar *protocol; - if (priv->config_container) { + if (priv->config_container) + { gtk_widget_destroy(priv->config_container); priv->config_container = NULL; gtk_widget_destroy(priv->config_viewport); @@ -1366,9 +1430,10 @@ static void remmina_file_editor_protocol_combo_on_changed(GtkComboBox *combo, Re g_hash_table_remove_all(priv->setting_widgets); protocol = remmina_public_combo_get_active_text(combo); - if (protocol) { + if (protocol) + { priv->plugin = (RemminaProtocolPlugin *)remmina_plugin_manager_get_plugin(REMMINA_PLUGIN_TYPE_PROTOCOL, - protocol); + protocol); g_free(protocol); remmina_file_editor_create_all_settings(gfe); } @@ -1382,11 +1447,9 @@ static void remmina_file_editor_save_behavior_tab(RemminaFileEditor *gfe) remmina_file_set_string(priv->remmina_file, "precommand", gtk_entry_get_text(GTK_ENTRY(priv->behavior_precommand_entry))); remmina_file_set_string(priv->remmina_file, "postcommand", gtk_entry_get_text(GTK_ENTRY(priv->behavior_postcommand_entry))); - gboolean autostart_enabled = (priv->behavior_autostart_check ? - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->behavior_autostart_check)) : FALSE); + gboolean autostart_enabled = (priv->behavior_autostart_check ? gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->behavior_autostart_check)) : FALSE); remmina_file_set_int(priv->remmina_file, "enable-autostart", autostart_enabled); - gboolean lock_enabled = (priv->behavior_lock_check ? - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->behavior_lock_check)) : FALSE); + gboolean lock_enabled = (priv->behavior_lock_check ? gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->behavior_lock_check)) : FALSE); remmina_file_set_int(priv->remmina_file, "profile-lock", lock_enabled); } @@ -1397,45 +1460,35 @@ static void remmina_file_editor_save_ssh_tunnel_tab(RemminaFileEditor *gfe) gboolean ssh_tunnel_enabled; int ssh_tunnel_auth; - ssh_tunnel_enabled = (priv->ssh_tunnel_enabled_check ? - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->ssh_tunnel_enabled_check)) : FALSE); + ssh_tunnel_enabled = (priv->ssh_tunnel_enabled_check ? gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->ssh_tunnel_enabled_check)) : FALSE); remmina_file_set_int(priv->remmina_file, - "ssh_tunnel_loopback", - (priv->ssh_tunnel_loopback_check ? - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->ssh_tunnel_loopback_check)) : - FALSE)); + "ssh_tunnel_loopback", + (priv->ssh_tunnel_loopback_check ? gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->ssh_tunnel_loopback_check)) : FALSE)); remmina_file_set_int(priv->remmina_file, "ssh_tunnel_enabled", ssh_tunnel_enabled); remmina_file_set_string(priv->remmina_file, "ssh_tunnel_auth", - remmina_public_combo_get_active_text(GTK_COMBO_BOX(priv->ssh_tunnel_auth_combo))); + remmina_public_combo_get_active_text(GTK_COMBO_BOX(priv->ssh_tunnel_auth_combo))); remmina_file_set_string(priv->remmina_file, "ssh_tunnel_username", - (ssh_tunnel_enabled ? gtk_entry_get_text(GTK_ENTRY(priv->ssh_tunnel_username_entry)) : NULL)); + (ssh_tunnel_enabled ? gtk_entry_get_text(GTK_ENTRY(priv->ssh_tunnel_username_entry)) : NULL)); remmina_file_set_string( priv->remmina_file, "ssh_tunnel_server", - (ssh_tunnel_enabled && priv->ssh_tunnel_server_entry - && (priv->ssh_tunnel_server_custom_radio == NULL - || gtk_toggle_button_get_active( - GTK_TOGGLE_BUTTON(priv->ssh_tunnel_server_custom_radio))) ? - gtk_entry_get_text(GTK_ENTRY(priv->ssh_tunnel_server_entry)) : NULL)); + (ssh_tunnel_enabled && priv->ssh_tunnel_server_entry && (priv->ssh_tunnel_server_custom_radio == NULL || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->ssh_tunnel_server_custom_radio))) ? gtk_entry_get_text(GTK_ENTRY(priv->ssh_tunnel_server_entry)) : NULL)); - ssh_tunnel_auth = gtk_combo_box_get_active (GTK_COMBO_BOX(priv->ssh_tunnel_auth_combo)); + ssh_tunnel_auth = gtk_combo_box_get_active(GTK_COMBO_BOX(priv->ssh_tunnel_auth_combo)); remmina_file_set_int( priv->remmina_file, "ssh_tunnel_auth", - ssh_tunnel_auth - ); + ssh_tunnel_auth); remmina_file_set_string( priv->remmina_file, "ssh_tunnel_privatekey", - (priv->ssh_tunnel_privatekey_chooser ? - gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(priv->ssh_tunnel_privatekey_chooser)) : NULL)); + (priv->ssh_tunnel_privatekey_chooser ? gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(priv->ssh_tunnel_privatekey_chooser)) : NULL)); remmina_file_set_string( priv->remmina_file, "ssh_tunnel_certfile", - (priv->ssh_tunnel_certfile_chooser ? - gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(priv->ssh_tunnel_certfile_chooser)) : NULL)); + (priv->ssh_tunnel_certfile_chooser ? gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(priv->ssh_tunnel_certfile_chooser)) : NULL)); remmina_file_set_string( priv->remmina_file, @@ -1445,29 +1498,34 @@ static void remmina_file_editor_save_ssh_tunnel_tab(RemminaFileEditor *gfe) remmina_file_set_string( priv->remmina_file, "ssh_tunnel_passphrase", - (ssh_tunnel_enabled && (ssh_tunnel_auth == SSH_AUTH_PUBLICKEY || ssh_tunnel_auth == SSH_AUTH_AUTO_PUBLICKEY)) ? - gtk_entry_get_text(GTK_ENTRY(priv->ssh_tunnel_passphrase)) : NULL); + (ssh_tunnel_enabled && (ssh_tunnel_auth == SSH_AUTH_PUBLICKEY || ssh_tunnel_auth == SSH_AUTH_AUTO_PUBLICKEY)) ? gtk_entry_get_text(GTK_ENTRY(priv->ssh_tunnel_passphrase)) : NULL); } static gboolean remmina_file_editor_validate_settings(RemminaFileEditor *gfe, - gchar* setting_name_to_validate, - gconstpointer value, + gchar *setting_name_to_validate, + gconstpointer value, GError **err) { - if (!setting_name_to_validate || !value || !gfe) { - if (!setting_name_to_validate) { + if (!setting_name_to_validate || !value || !gfe) + { + if (!setting_name_to_validate) + { g_critical(_("(%s: %i): Can't validate setting '%s' since 'value' or 'gfe' " - "are NULL!"), __func__, __LINE__, setting_name_to_validate); - } else { + "are NULL!"), + __func__, __LINE__, setting_name_to_validate); + } + else + { g_critical(_("(%s: %i): Can't validate user input since " "'setting_name_to_validate', 'value' or 'gfe' are NULL!"), __func__, __LINE__); } - g_set_error (err, 1, 1, _("Internal error.")); + g_set_error(err, 1, 1, _("Internal error.")); return FALSE; } - if (strcmp(setting_name_to_validate, "notes_text") == 0) { + if (strcmp(setting_name_to_validate, "notes_text") == 0) + { // Not a plugin setting. Bail out early. return TRUE; } @@ -1478,15 +1536,21 @@ static gboolean remmina_file_editor_validate_settings(RemminaFileEditor *gfe, protocol_plugin = priv->plugin; setting_iter = protocol_plugin->basic_settings; - if (setting_iter) { + if (setting_iter) + { // gboolean found = FALSE; - while (setting_iter->type != REMMINA_PROTOCOL_SETTING_TYPE_END) { - if (setting_iter->name == NULL) { + while (setting_iter->type != REMMINA_PROTOCOL_SETTING_TYPE_END) + { + if (setting_iter->name == NULL) + { g_error("Internal error: a setting name in protocol plugin %s is " "null. Please fix RemminaProtocolSetting struct content.", protocol_plugin->name); - } else if ((gchar*) setting_name_to_validate){ - if (strcmp((gchar*) setting_name_to_validate, setting_iter->name) == 0) { + } + else if ((gchar *)setting_name_to_validate) + { + if (strcmp((gchar *)setting_name_to_validate, setting_iter->name) == 0) + { // found = TRUE; gpointer validator_data = setting_iter->validator_data; @@ -1497,15 +1561,16 @@ static gboolean remmina_file_editor_validate_settings(RemminaFileEditor *gfe, GError *err_ret = NULL; g_debug("Checking setting '%s' for validation.", setting_iter->name); - if (validator != NULL) { + if (validator != NULL) + { // Looks weird but it calls the setting's validator // function using setting_name_to_validate, value and // validator_data as parameters and it returns a GError*. - err_ret = ((GError* (*)(gpointer, gconstpointer, gpointer))validator) - (setting_name_to_validate, value, validator_data); + err_ret = ((GError * (*)(gpointer, gconstpointer, gpointer)) validator)(setting_name_to_validate, value, validator_data); } - if (err_ret) { + if (err_ret) + { g_debug("it has a validator function and it had an error!"); // pass err (returned value) to function caller. *err = err_ret; @@ -1527,7 +1592,7 @@ static gboolean remmina_file_editor_validate_settings(RemminaFileEditor *gfe, return TRUE; } -static GError* remmina_file_editor_update_settings(RemminaFileEditor *gfe, +static GError *remmina_file_editor_update_settings(RemminaFileEditor *gfe, GtkWidget **failed_widget) { TRACE_CALL(__func__); @@ -1543,18 +1608,22 @@ static GError* remmina_file_editor_update_settings(RemminaFileEditor *gfe, *failed_widget = NULL; g_hash_table_iter_init(&iter, priv->setting_widgets); - while (g_hash_table_iter_next(&iter, &key, &widget)) { + while (g_hash_table_iter_next(&iter, &key, &widget)) + { // We don't want to save or validate grayed-out settings. - if (!gtk_widget_get_sensitive(GTK_WIDGET(widget))) { + if (!gtk_widget_get_sensitive(GTK_WIDGET(widget))) + { g_debug("Grayed-out setting-widget '%s' will not be saved.", gtk_widget_get_name(widget)); continue; } - if (GTK_IS_ENTRY(widget)) { + if (GTK_IS_ENTRY(widget)) + { const gchar *value = gtk_entry_get_text(GTK_ENTRY(widget)); - if (!remmina_file_editor_validate_settings(gfe, (gchar*) key, value, &err)) { + if (!remmina_file_editor_validate_settings(gfe, (gchar *)key, value, &err)) + { // Error while validating! // err should be set now. *failed_widget = widget; @@ -1562,14 +1631,17 @@ static GError* remmina_file_editor_update_settings(RemminaFileEditor *gfe, } remmina_file_set_string(priv->remmina_file, (gchar *)key, value); - } else if (GTK_IS_TEXT_VIEW(widget)) { + } + else if (GTK_IS_TEXT_VIEW(widget)) + { buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget)); - gtk_text_buffer_get_start_iter (buffer, &start); - gtk_text_buffer_get_end_iter (buffer, &end); + gtk_text_buffer_get_start_iter(buffer, &start); + gtk_text_buffer_get_end_iter(buffer, &end); unescaped = gtk_text_buffer_get_text(buffer, &start, &end, FALSE); - escaped = g_uri_escape_string (unescaped, NULL, TRUE); + escaped = g_uri_escape_string(unescaped, NULL, TRUE); - if (!remmina_file_editor_validate_settings(gfe, (gchar*) key, escaped, &err)) { + if (!remmina_file_editor_validate_settings(gfe, (gchar *)key, escaped, &err)) + { // Error while validating! // err should be set now. *failed_widget = widget; @@ -1578,10 +1650,13 @@ static GError* remmina_file_editor_update_settings(RemminaFileEditor *gfe, remmina_file_set_string(priv->remmina_file, (gchar *)key, escaped); g_free(escaped); - } else if (GTK_IS_COMBO_BOX(widget)) { + } + else if (GTK_IS_COMBO_BOX(widget)) + { gchar *value = remmina_public_combo_get_active_text(GTK_COMBO_BOX(widget)); - if (!remmina_file_editor_validate_settings(gfe, (gchar*) key, value, &err)) { + if (!remmina_file_editor_validate_settings(gfe, (gchar *)key, value, &err)) + { // Error while validating! // err should be set now. *failed_widget = widget; @@ -1589,12 +1664,13 @@ static GError* remmina_file_editor_update_settings(RemminaFileEditor *gfe, } remmina_file_set_string(priv->remmina_file, (gchar *)key, value); - } else if (GTK_IS_FILE_CHOOSER(widget)) { - gchar *value = gtk_widget_get_sensitive(GTK_WIDGET(widget)) ? - gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget)) : - NULL; + } + else if (GTK_IS_FILE_CHOOSER(widget)) + { + gchar *value = gtk_widget_get_sensitive(GTK_WIDGET(widget)) ? gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget)) : NULL; - if (!remmina_file_editor_validate_settings(gfe, (gchar*) key, value, &err)) { + if (!remmina_file_editor_validate_settings(gfe, (gchar *)key, value, &err)) + { // Error while validating! // err should be set now. g_free(value); @@ -1602,12 +1678,15 @@ static GError* remmina_file_editor_update_settings(RemminaFileEditor *gfe, break; } - remmina_file_set_string(priv->remmina_file, (gchar *)key, value); + remmina_file_set_string(priv->remmina_file, (gchar *)key, value); g_free(value); - } else if (GTK_IS_TOGGLE_BUTTON(widget)) { + } + else if (GTK_IS_TOGGLE_BUTTON(widget)) + { gboolean value = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); - if (!remmina_file_editor_validate_settings(gfe, (gchar*) key, &value, &err)) { + if (!remmina_file_editor_validate_settings(gfe, (gchar *)key, &value, &err)) + { // Error while validating! // err should be set now. *failed_widget = widget; @@ -1618,14 +1697,15 @@ static GError* remmina_file_editor_update_settings(RemminaFileEditor *gfe, } } - if (err) { + if (err) + { return err; } return NULL; } -static GError* remmina_file_editor_update(RemminaFileEditor *gfe, +static GError *remmina_file_editor_update(RemminaFileEditor *gfe, GtkWidget **failed_widget) { TRACE_CALL(__func__); @@ -1640,24 +1720,30 @@ static GError* remmina_file_editor_update(RemminaFileEditor *gfe, remmina_file_set_string(priv->remmina_file, "labels", gtk_entry_get_text(GTK_ENTRY(priv->labels_entry))); remmina_file_set_string(priv->remmina_file, "group", - (priv->group_combo ? remmina_public_combo_get_active_text(GTK_COMBO_BOX(priv->group_combo)) : NULL)); + (priv->group_combo ? remmina_public_combo_get_active_text(GTK_COMBO_BOX(priv->group_combo)) : NULL)); remmina_file_set_string(priv->remmina_file, "protocol", - remmina_public_combo_get_active_text(GTK_COMBO_BOX(priv->protocol_combo))); + remmina_public_combo_get_active_text(GTK_COMBO_BOX(priv->protocol_combo))); remmina_file_set_string(priv->remmina_file, "server", - (priv->server_combo ? remmina_public_combo_get_active_text(GTK_COMBO_BOX(priv->server_combo)) : NULL)); + (priv->server_combo ? remmina_public_combo_get_active_text(GTK_COMBO_BOX(priv->server_combo)) : NULL)); - if (priv->resolution_auto_radio) { - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->resolution_auto_radio))) { + if (priv->resolution_auto_radio) + { + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->resolution_auto_radio))) + { /* Resolution is set to auto (which means: Use client fullscreen resolution, aka use client resolution) */ res_w = res_h = 0; res_mode = RES_USE_CLIENT; - } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->resolution_iws_radio))) { + } + else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->resolution_iws_radio))) + { /* Resolution is set to initial window size */ res_w = res_h = 0; res_mode = RES_USE_INITIAL_WINDOW_SIZE; - } else { + } + else + { /* Resolution is set to a value from the list */ custom_resolution = remmina_public_combo_get_active_text(GTK_COMBO_BOX(priv->resolution_custom_combo)); if (remmina_public_split_resolution_string(custom_resolution, &res_w, &res_h)) @@ -1673,7 +1759,7 @@ static GError* remmina_file_editor_update(RemminaFileEditor *gfe, if (priv->keymap_combo) remmina_file_set_string(priv->remmina_file, "keymap", - remmina_public_combo_get_active_text(GTK_COMBO_BOX(priv->keymap_combo))); + remmina_public_combo_get_active_text(GTK_COMBO_BOX(priv->keymap_combo))); remmina_file_editor_save_behavior_tab(gfe); remmina_file_editor_save_ssh_tunnel_tab(gfe); @@ -1688,7 +1774,8 @@ static void remmina_file_editor_on_default(GtkWidget *button, RemminaFileEditor GtkWidget *failed_widget = NULL; GError *err = remmina_file_editor_update(gfe, &failed_widget); - if (err) { + if (err) + { g_warning(_("Couldn't validate user input. %s"), err->message); remmina_file_editor_show_validation_error_popup(gfe, failed_widget, err); return; @@ -1724,7 +1811,8 @@ static void remmina_file_editor_on_save(GtkWidget *button, RemminaFileEditor *gf GtkWidget *failed_widget = NULL; GError *err = remmina_file_editor_update(gfe, &failed_widget); - if (err) { + if (err) + { g_warning(_("Couldn't validate user input. %s"), err->message); remmina_file_editor_show_validation_error_popup(gfe, failed_widget, err); return; @@ -1745,7 +1833,8 @@ static void remmina_file_editor_on_connect(GtkWidget *button, RemminaFileEditor GtkWidget *failed_widget = NULL; GError *err = remmina_file_editor_update(gfe, &failed_widget); - if (err) { + if (err) + { g_warning(_("Couldn't validate user input. %s"), err->message); remmina_file_editor_show_validation_error_popup(gfe, failed_widget, err); return; @@ -1768,7 +1857,8 @@ static void remmina_file_editor_on_save_connect(GtkWidget *button, RemminaFileEd GtkWidget *failed_widget = NULL; GError *err = remmina_file_editor_update(gfe, &failed_widget); - if (err) { + if (err) + { g_warning(_("Couldn't validate user input. %s"), err->message); remmina_file_editor_show_validation_error_popup(gfe, failed_widget, err); return; @@ -1850,7 +1940,7 @@ static gboolean remmina_file_editor_iterate_protocol(gchar *protocol, RemminaPlu gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, 0, protocol, 1, g_dgettext(plugin->domain, plugin->description), 2, - ((RemminaProtocolPlugin *)plugin)->icon_name, -1); + ((RemminaProtocolPlugin *)plugin)->icon_name, -1); if (first || g_strcmp0(protocol, remmina_file_get_string(gfe->priv->remmina_file, "protocol")) == 0) gtk_combo_box_set_active_iter(GTK_COMBO_BOX(gfe->priv->protocol_combo), &iter); @@ -1874,11 +1964,14 @@ static void remmina_file_editor_entry_on_changed(GtkEditable *editable, RemminaF RemminaFileEditorPriv *priv; priv = gfe->priv; - if (remmina_file_get_filename(priv->remmina_file) == NULL) { + if (remmina_file_get_filename(priv->remmina_file) == NULL) + { remmina_file_generate_filename(priv->remmina_file); /* TODO: Probably to be removed */ remmina_file_editor_check_profile(gfe); - } else { + } + else + { remmina_file_delete(remmina_file_get_filename(priv->remmina_file)); remmina_file_generate_filename(priv->remmina_file); remmina_file_editor_check_profile(gfe); @@ -1891,15 +1984,17 @@ void remmina_file_editor_file_save(RemminaFileEditor *gfe) RemminaFileEditorPriv *priv; priv = gfe->priv; - if (remmina_file_get_filename(priv->remmina_file) == NULL) { + if (remmina_file_get_filename(priv->remmina_file) == NULL) + { remmina_file_generate_filename(priv->remmina_file); - } else { + } + else + { remmina_file_delete(remmina_file_get_filename(priv->remmina_file)); remmina_file_generate_filename(priv->remmina_file); } } - GtkWidget *remmina_file_editor_new_from_file(RemminaFile *remminafile) { TRACE_CALL(__func__); @@ -1927,7 +2022,7 @@ GtkWidget *remmina_file_editor_new_from_file(RemminaFile *remminafile) gtk_container_set_border_width(GTK_CONTAINER(grid), 8); gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(gfe))), grid, FALSE, FALSE, 2); - //remmina_public_create_group(GTK_GRID(grid), _("Profile"), 0, 4, 3); + // remmina_public_create_group(GTK_GRID(grid), _("Profile"), 0, 4, 3); gboolean profile_file_exists = (remmina_file_get_filename(remminafile) != NULL); @@ -1945,13 +2040,16 @@ GtkWidget *remmina_file_editor_new_from_file(RemminaFile *remminafile) gtk_entry_set_max_length(GTK_ENTRY(widget), 100); priv->name_entry = widget; - if (!profile_file_exists) { + if (!profile_file_exists) + { gtk_entry_set_text(GTK_ENTRY(widget), _("Quick Connect")); #if GTK_CHECK_VERSION(3, 16, 0) gtk_entry_grab_focus_without_selecting(GTK_ENTRY(widget)); #endif g_signal_connect(G_OBJECT(widget), "changed", G_CALLBACK(remmina_file_editor_entry_on_changed), gfe); - } else { + } + else + { cs = remmina_file_get_string(remminafile, "name"); gtk_entry_set_text(GTK_ENTRY(widget), cs ? cs : ""); } @@ -1988,13 +2086,16 @@ GtkWidget *remmina_file_editor_new_from_file(RemminaFile *remminafile) gtk_entry_set_max_length(GTK_ENTRY(widget), 255); priv->labels_entry = widget; - if (!profile_file_exists) { + if (!profile_file_exists) + { gtk_widget_set_tooltip_text(widget, _("Label1,Label2")); #if GTK_CHECK_VERSION(3, 16, 0) gtk_entry_grab_focus_without_selecting(GTK_ENTRY(widget)); #endif g_signal_connect(G_OBJECT(widget), "changed", G_CALLBACK(remmina_file_editor_entry_on_changed), gfe); - } else { + } + else + { cs = remmina_file_get_string(remminafile, "labels"); gtk_entry_set_text(GTK_ENTRY(widget), cs ? cs : ""); } @@ -2057,11 +2158,14 @@ GtkWidget *remmina_file_editor_new_copy(const gchar *filename) remminafile = remmina_file_copy(filename); - if (remminafile) { + if (remminafile) + { return remmina_file_editor_new_from_file(remminafile); - } else { + } + else + { dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, - _("Could not find the file “%s”."), filename); + _("Could not find the file “%s”."), filename); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); return NULL; @@ -2074,14 +2178,16 @@ GtkWidget *remmina_file_editor_new_from_filename(const gchar *filename) RemminaFile *remminafile; remminafile = remmina_file_manager_load_file(filename); - if (remminafile) { - if (remmina_file_get_int (remminafile, "profile-lock", FALSE) - && remmina_unlock_new(remmina_main_get_window()) == 0) + if (remminafile) + { + if (remmina_file_get_int(remminafile, "profile-lock", FALSE) && remmina_unlock_new(remmina_main_get_window()) == 0) return NULL; return remmina_file_editor_new_from_file(remminafile); - } else { + } + else + { GtkWidget *dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, - _("Could not find the file “%s”."), filename); + _("Could not find the file “%s”."), filename); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); return NULL; diff --git a/src/remmina_pref.c b/src/remmina_pref.c index a56bffa25..701b81b4e 100644 --- a/src/remmina_pref.c +++ b/src/remmina_pref.c @@ -319,6 +319,12 @@ void remmina_pref_init(void) else remmina_pref.lock_edit = FALSE; + + if (g_key_file_has_key(gkeyfile, "remmina_pref", "lock_view_passwords", NULL)) + remmina_pref.lock_view_passwords = g_key_file_get_boolean(gkeyfile, "remmina_pref", "lock_view_passwords", NULL); + else + remmina_pref.lock_view_passwords = FALSE; + if (g_key_file_has_key(gkeyfile, "remmina_pref", "enc_mode", NULL)) remmina_pref.enc_mode = g_key_file_get_integer(gkeyfile, "remmina_pref", "enc_mode", NULL); else @@ -802,12 +808,14 @@ gboolean remmina_pref_save(void) g_key_file_set_string(gkeyfile, "remmina_pref", "unlock_password", remmina_pref.unlock_password); g_key_file_set_boolean(gkeyfile, "remmina_pref", "lock_connect", remmina_pref.lock_connect); g_key_file_set_boolean(gkeyfile, "remmina_pref", "lock_edit", remmina_pref.lock_edit); + g_key_file_set_boolean(gkeyfile, "remmina_pref", "lock_view_passwords", remmina_pref.lock_view_passwords); #else g_key_file_set_boolean(gkeyfile, "remmina_pref", "use_primary_password", FALSE); g_key_file_set_integer(gkeyfile, "remmina_pref", "unlock_timeout", 0); g_key_file_set_string(gkeyfile, "remmina_pref", "unlock_password", g_strdup("")); g_key_file_set_boolean(gkeyfile, "remmina_pref", "lock_connect", FALSE); g_key_file_set_boolean(gkeyfile, "remmina_pref", "lock_edit", FALSE); + g_key_file_set_boolean(gkeyfile, "remmina_pref", "lock_view_passwords", FALSE); #endif g_key_file_set_integer(gkeyfile, "remmina_pref", "enc_mode", remmina_pref.enc_mode); g_key_file_set_boolean(gkeyfile, "remmina_pref", "audit", remmina_pref.audit); diff --git a/src/remmina_pref.h b/src/remmina_pref.h index 5a82a7b40..a59da3c09 100644 --- a/src/remmina_pref.h +++ b/src/remmina_pref.h @@ -192,6 +192,7 @@ typedef struct _RemminaPref { gint unlock_timeout; gboolean lock_connect; gboolean lock_edit; + gboolean lock_view_passwords; gint enc_mode; gboolean audit; gboolean trust_all; diff --git a/src/remmina_pref_dialog.c b/src/remmina_pref_dialog.c index fa2edebd8..ad51a11b6 100644 --- a/src/remmina_pref_dialog.c +++ b/src/remmina_pref_dialog.c @@ -180,6 +180,7 @@ void remmina_prefdiag_on_use_password_activated(GtkSwitch *sw, gpointer user_dat unlock_password = g_strdup(remmina_pref_get_value("unlock_password")); gtk_widget_set_sensitive (GTK_WIDGET(remmina_pref_dialog->switch_security_lock_connect), TRUE); gtk_widget_set_sensitive (GTK_WIDGET(remmina_pref_dialog->switch_security_lock_edit), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET(remmina_pref_dialog->switch_security_lock_view_passwords), TRUE); //REMMINA_DEBUG ("Password from preferences is: %s", unlock_password); if (unlock_password == NULL || unlock_password[0] == '\0') { if (remmina_passwd (GTK_WINDOW(remmina_pref_dialog->dialog), &unlock_password)) { @@ -196,6 +197,7 @@ void remmina_prefdiag_on_use_password_activated(GtkSwitch *sw, gpointer user_dat //REMMINA_DEBUG ("use_password deactivated"); gtk_widget_set_sensitive (GTK_WIDGET(remmina_pref_dialog->switch_security_lock_connect), FALSE); gtk_widget_set_sensitive (GTK_WIDGET(remmina_pref_dialog->switch_security_lock_edit), FALSE); + gtk_widget_set_sensitive (GTK_WIDGET(remmina_pref_dialog->switch_security_lock_view_passwords), FALSE); remmina_pref.unlock_password = ""; remmina_pref_set_value("unlock_password", ""); } @@ -235,6 +237,7 @@ void remmina_pref_on_dialog_destroy(GtkWidget *widget, gpointer user_data) remmina_pref.use_primary_password = gtk_switch_get_active(GTK_SWITCH(remmina_pref_dialog->switch_security_use_primary_password)); remmina_pref.lock_connect = gtk_switch_get_active(GTK_SWITCH(remmina_pref_dialog->switch_security_lock_connect)); remmina_pref.lock_edit = gtk_switch_get_active(GTK_SWITCH(remmina_pref_dialog->switch_security_lock_edit)); + remmina_pref.lock_view_passwords = gtk_switch_get_active(GTK_SWITCH(remmina_pref_dialog->switch_security_lock_view_passwords)); remmina_pref.enc_mode = gtk_combo_box_get_active(remmina_pref_dialog->comboboxtext_security_enc_method); remmina_pref.audit = gtk_switch_get_active(GTK_SWITCH(remmina_pref_dialog->switch_security_audit)); remmina_pref.trust_all = gtk_switch_get_active(GTK_SWITCH(remmina_pref_dialog->switch_security_trust_all)); @@ -467,6 +470,7 @@ static void remmina_pref_dialog_init(void) gtk_widget_set_sensitive(GTK_WIDGET(remmina_pref_dialog->switch_security_use_primary_password), TRUE); gtk_switch_set_active(GTK_SWITCH(remmina_pref_dialog->switch_security_lock_connect), remmina_pref.lock_connect); gtk_switch_set_active(GTK_SWITCH(remmina_pref_dialog->switch_security_lock_edit), remmina_pref.lock_edit); + gtk_switch_set_active(GTK_SWITCH(remmina_pref_dialog->switch_security_lock_view_passwords), remmina_pref.lock_view_passwords); gtk_widget_set_sensitive(GTK_WIDGET(remmina_pref_dialog->unlock_timeout), TRUE); #else gtk_switch_set_active(GTK_SWITCH(remmina_pref_dialog->switch_security_use_primary_password), FALSE); @@ -711,6 +715,7 @@ GtkWidget *remmina_pref_dialog_new(gint default_tab, GtkWindow *parent) remmina_pref_dialog->unlock_timeout = GTK_ENTRY(GET_OBJECT("unlock_timeout")); remmina_pref_dialog->switch_security_lock_connect = GTK_SWITCH(GET_OBJECT("switch_security_lock_connect")); remmina_pref_dialog->switch_security_lock_edit = GTK_SWITCH(GET_OBJECT("switch_security_lock_edit")); + remmina_pref_dialog->switch_security_lock_view_passwords = GTK_SWITCH(GET_OBJECT("switch_security_lock_view_passwords")); remmina_pref_dialog->comboboxtext_security_enc_method = GTK_COMBO_BOX(GET_OBJECT("comboboxtext_security_enc_method")); remmina_pref_dialog->switch_security_audit = GTK_SWITCH(GET_OBJECT("switch_security_audit")); diff --git a/src/remmina_pref_dialog.h b/src/remmina_pref_dialog.h index 4ddd08c98..a0c01d432 100644 --- a/src/remmina_pref_dialog.h +++ b/src/remmina_pref_dialog.h @@ -62,6 +62,7 @@ typedef struct _RemminaPrefDialog { GtkEntry * unlock_timeout; GtkSwitch * switch_security_lock_connect; GtkSwitch * switch_security_lock_edit; + GtkSwitch * switch_security_lock_view_passwords; GtkSwitch * switch_security_audit; GtkSwitch * switch_security_trust_all; GtkCheckButton * checkbutton_options_save_settings; |