diff options
-rw-r--r-- | data/ui/remmina_preferences.glade | 43 | ||||
-rw-r--r-- | src/remmina_exec.c | 7 | ||||
-rw-r--r-- | src/remmina_main.c | 15 | ||||
-rw-r--r-- | src/remmina_pref.c | 6 | ||||
-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 | ||||
-rw-r--r-- | src/remmina_unlock.c | 36 | ||||
-rw-r--r-- | src/remmina_unlock.h | 12 |
9 files changed, 104 insertions, 22 deletions
diff --git a/data/ui/remmina_preferences.glade b/data/ui/remmina_preferences.glade index 95449081a..a504a7ce1 100644 --- a/data/ui/remmina_preferences.glade +++ b/data/ui/remmina_preferences.glade @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.20.4 +<!-- Generated with glade 3.22.1 Remmina Preferences Dialog - Copyright (C) Antenore Gatta & Giovanni Panozzo 2014-2019 @@ -43,6 +43,9 @@ Author: Antenore Gatta <property name="type_hint">dialog</property> <signal name="close" handler="remmina_pref_dialog_on_close_clicked" swapped="no"/> <signal name="destroy" handler="remmina_pref_on_dialog_destroy" swapped="no"/> + <child> + <placeholder/> + </child> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> <property name="can_focus">False</property> @@ -1364,7 +1367,7 @@ Author: Antenore Gatta <property name="margin_left">18</property> <property name="margin_top">18</property> <property name="margin_bottom">9</property> - <property name="hexpand">True</property> + <property name="hexpand">False</property> <property name="label" translatable="yes">Master password</property> <attributes> <attribute name="weight" value="bold"/> @@ -1416,7 +1419,7 @@ Author: Antenore Gatta <property name="halign">start</property> <property name="margin_left">18</property> <property name="margin_top">9</property> - <property name="hexpand">True</property> + <property name="hexpand">False</property> <property name="label" translatable="yes">File encryption</property> <attributes> <attribute name="weight" value="bold"/> @@ -1424,10 +1427,39 @@ Author: Antenore Gatta </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">2</property> + <property name="top_attach">3</property> <property name="width">3</property> </packing> </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="margin_left">36</property> + <property name="label" translatable="yes">Automatic lock interval</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="unlocked_timeout"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="tooltip_text" translatable="yes">Master password validity in seconds</property> + <property name="halign">start</property> + <property name="width_chars">9</property> + <property name="text" translatable="yes">300</property> + <property name="input_purpose">number</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">2</property> + <property name="width">2</property> + </packing> + </child> </object> <packing> <property name="position">5</property> @@ -2093,8 +2125,5 @@ Author: Antenore Gatta </child> </object> </child> - <child> - <placeholder/> - </child> </object> </interface> diff --git a/src/remmina_exec.c b/src/remmina_exec.c index 0897ca8f4..c0dccc92a 100644 --- a/src/remmina_exec.c +++ b/src/remmina_exec.c @@ -166,12 +166,7 @@ void remmina_exec_command(RemminaCommandType command, const gchar* data) break; case REMMINA_COMMAND_PREF: - if (remmina_pref_get_boolean("use_master_password")) - if (mainwindow) { - GtkDialog *unlock_dialog = remmina_unlock_new(mainwindow); - gtk_dialog_run(unlock_dialog); - gtk_widget_destroy(GTK_WIDGET(unlock_dialog)); - } + remmina_unlock_new(mainwindow); prefdialog = remmina_pref_dialog_get_dialog(); if (prefdialog) { gtk_window_present(GTK_WINDOW(prefdialog)); diff --git a/src/remmina_main.c b/src/remmina_main.c index 900b47c15..6570d08c0 100644 --- a/src/remmina_main.c +++ b/src/remmina_main.c @@ -641,6 +641,8 @@ void remmina_main_on_action_connection_connect(GSimpleAction *action, GVariant * if (!remminamain->priv->selected_filename) return; + remmina_unlock_new(remminamain->window); + remminafile = remmina_file_load(remminamain->priv->selected_filename); if (remminafile == NULL) @@ -658,6 +660,8 @@ void remmina_main_on_action_connection_external_tools(GSimpleAction *action, GVa if (!remminamain->priv->selected_filename) return; + remmina_unlock_new(remminamain->window); + remmina_external_tools_from_filename(remminamain, remminamain->priv->selected_filename); } @@ -688,6 +692,8 @@ void remmina_main_on_action_application_mpchange(GSimpleAction *action, GVariant } } + remmina_unlock_new(remminamain->window); + remmina_mpchange_schedule(TRUE, group, domain, username, ""); if (remminafile != NULL) @@ -700,6 +706,8 @@ void remmina_main_on_action_connection_new(GSimpleAction *action, GVariant *para TRACE_CALL(__func__); GtkWidget *widget; + remmina_unlock_new(remminamain->window); + widget = remmina_file_editor_new(); g_signal_connect(G_OBJECT(widget), "destroy", G_CALLBACK(remmina_main_file_editor_destroy), remminamain); gtk_window_set_transient_for(GTK_WINDOW(widget), remminamain->window); @@ -783,6 +791,7 @@ void remmina_main_on_action_connection_delete(GSimpleAction *action, GVariant *p if (!remminamain->priv->selected_filename) return; + remmina_unlock_new(remminamain->window); dialog = gtk_message_dialog_new(remminamain->window, GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, _("Are you sure to delete '%s'"), remminamain->priv->selected_name); if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_YES) { @@ -799,11 +808,7 @@ void remmina_main_on_action_connection_delete(GSimpleAction *action, GVariant *p void remmina_main_on_action_application_preferences(GSimpleAction *action, GVariant *param, gpointer data) { TRACE_CALL(__func__); - if (remmina_pref_get_boolean("use_master_password")) { - GtkDialog *unlock_dialog = remmina_unlock_new(remminamain->window); - gtk_dialog_run(unlock_dialog); - gtk_widget_destroy(GTK_WIDGET(unlock_dialog)); - } + remmina_unlock_new(remminamain->window); GtkDialog *dialog = remmina_pref_dialog_new(0, remminamain->window); gtk_dialog_run(dialog); gtk_widget_destroy(GTK_WIDGET(dialog)); diff --git a/src/remmina_pref.c b/src/remmina_pref.c index 3be82b6bf..fd4df5890 100644 --- a/src/remmina_pref.c +++ b/src/remmina_pref.c @@ -286,6 +286,11 @@ void remmina_pref_init(void) else remmina_pref.use_master_password = TRUE; + if (g_key_file_has_key(gkeyfile, "remmina_pref", "unlocked_timeout", NULL)) + remmina_pref.unlock_timeout = g_key_file_get_integer(gkeyfile, "remmina_pref", "unlocked_timeout", NULL); + else + remmina_pref.unlock_timeout = 300; + if (g_key_file_has_key(gkeyfile, "remmina_pref", "fullscreen_on_auto", NULL)) remmina_pref.fullscreen_on_auto = g_key_file_get_boolean(gkeyfile, "remmina_pref", "fullscreen_on_auto", NULL); else @@ -677,6 +682,7 @@ gboolean remmina_pref_save(void) g_key_file_set_boolean(gkeyfile, "remmina_pref", "deny_screenshot_clipboard", remmina_pref.deny_screenshot_clipboard); g_key_file_set_boolean(gkeyfile, "remmina_pref", "save_view_mode", remmina_pref.save_view_mode); g_key_file_set_boolean(gkeyfile, "remmina_pref", "use_master_password", remmina_pref.use_master_password); + g_key_file_set_boolean(gkeyfile, "remmina_pref", "unlock_timeout", remmina_pref.unlock_timeout); g_key_file_set_integer(gkeyfile, "remmina_pref", "floating_toolbar_placement", remmina_pref.floating_toolbar_placement); g_key_file_set_integer(gkeyfile, "remmina_pref", "toolbar_placement", remmina_pref.toolbar_placement); g_key_file_set_boolean(gkeyfile, "remmina_pref", "prevent_snap_welcome_message", remmina_pref.prevent_snap_welcome_message); diff --git a/src/remmina_pref.h b/src/remmina_pref.h index 781b92e13..0d5cacf7a 100644 --- a/src/remmina_pref.h +++ b/src/remmina_pref.h @@ -117,6 +117,7 @@ typedef struct _RemminaPref { const gchar *screenshot_name; gboolean save_view_mode; gboolean use_master_password; + gint unlock_timeout; gint default_action; gint scale_quality; gint auto_scroll_step; diff --git a/src/remmina_pref_dialog.c b/src/remmina_pref_dialog.c index 293e999c6..7bbce61a8 100644 --- a/src/remmina_pref_dialog.c +++ b/src/remmina_pref_dialog.c @@ -167,6 +167,7 @@ void remmina_pref_on_dialog_destroy(GtkWidget *widget, gpointer user_data) remmina_pref.deny_screenshot_clipboard = gtk_switch_get_active(GTK_SWITCH(remmina_pref_dialog->switch_options_deny_screenshot_clipboard)); remmina_pref.save_view_mode = gtk_switch_get_active(GTK_SWITCH(remmina_pref_dialog->switch_options_remember_last_view_mode)); remmina_pref.use_master_password = gtk_switch_get_active(GTK_SWITCH(remmina_pref_dialog->switch_security_use_master_password)); + remmina_pref.unlock_timeout = atoi(gtk_entry_get_text(remmina_pref_dialog->unlock_timeout)); remmina_pref.fullscreen_on_auto = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(remmina_pref_dialog->checkbutton_appearance_fullscreen_on_auto)); remmina_pref.always_show_tab = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(remmina_pref_dialog->checkbutton_appearance_show_tabs)); remmina_pref.hide_connection_toolbar = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(remmina_pref_dialog->checkbutton_appearance_hide_toolbar)); @@ -504,6 +505,9 @@ static void remmina_pref_dialog_init(void) g_snprintf(buf, sizeof(buf), "%i", remmina_pref.vte_lines); gtk_entry_set_text(remmina_pref_dialog->entry_scrollback_lines, buf); + g_snprintf(buf, sizeof(buf), "%i", remmina_pref.unlock_timeout); + gtk_entry_set_text(remmina_pref_dialog->unlock_timeout, buf); + gtk_combo_box_set_active(remmina_pref_dialog->comboboxtext_options_double_click, remmina_pref.default_action); gtk_combo_box_set_active(remmina_pref_dialog->comboboxtext_appearance_view_mode, remmina_pref.default_mode); gtk_combo_box_set_active(remmina_pref_dialog->comboboxtext_appearance_tab_interface, remmina_pref.tab_mode); @@ -583,6 +587,7 @@ GtkDialog* remmina_pref_dialog_new(gint default_tab, GtkWindow *parent) remmina_pref_dialog->entry_options_scroll = GTK_ENTRY(GET_OBJECT("entry_options_scroll")); remmina_pref_dialog->entry_options_recent_items = GTK_ENTRY(GET_OBJECT("entry_options_recent_items")); remmina_pref_dialog->button_options_recent_items_clear = GTK_BUTTON(GET_OBJECT("button_options_recent_items_clear")); + remmina_pref_dialog->unlock_timeout = GTK_ENTRY(GET_OBJECT("unlock_timeout")); remmina_pref_dialog->checkbutton_applet_new_connection_on_top = GTK_CHECK_BUTTON(GET_OBJECT("checkbutton_applet_new_connection_on_top")); remmina_pref_dialog->checkbutton_applet_hide_totals = GTK_CHECK_BUTTON(GET_OBJECT("checkbutton_applet_hide_totals")); diff --git a/src/remmina_pref_dialog.h b/src/remmina_pref_dialog.h index f12048fb8..b64ac808e 100644 --- a/src/remmina_pref_dialog.h +++ b/src/remmina_pref_dialog.h @@ -55,6 +55,7 @@ typedef struct _RemminaPrefDialog { GtkSwitch *switch_options_deny_screenshot_clipboard; GtkSwitch *switch_options_remember_last_view_mode; GtkSwitch *switch_security_use_master_password; + GtkEntry *unlock_timeout; GtkCheckButton *checkbutton_options_save_settings; GtkCheckButton *checkbutton_appearance_fullscreen_on_auto; GtkCheckButton *checkbutton_appearance_show_tabs; diff --git a/src/remmina_unlock.c b/src/remmina_unlock.c index 1f0739135..c6edf7585 100644 --- a/src/remmina_unlock.c +++ b/src/remmina_unlock.c @@ -32,22 +32,45 @@ * */ -#ifdef __linux__ #include <gtk/gtk.h> #include <glib/gi18n.h> #include "config.h" +#include "remmina_pref.h" #include "remmina_unlock.h" #include "remmina_public.h" #include "remmina/remmina_trace_calls.h" +#ifdef __linux__ static RemminaUnlockDialog *remmina_unlock_dialog; #define GET_OBJ(object_name) gtk_builder_get_object(remmina_unlock_dialog->builder, object_name) +static void remmina_unlock_timer_init (gpointer user_data) +{ + TRACE_CALL(__func__); + + remmina_unlock_dialog->timer = g_timer_new(); +} + +static void remmina_unlock_timer_reset (gpointer user_data) +{ + TRACE_CALL(__func__); + + g_timer_reset(remmina_unlock_dialog->timer); +} + +static void remmina_unlock_timer_destroy (gpointer user_data) +{ + TRACE_CALL(__func__); + + g_timer_destroy(remmina_unlock_dialog->timer); +} + static void remmina_button_unlock_clicked(GtkButton *btn, gpointer user_data) { TRACE_CALL(__func__); + g_timer_reset(remmina_unlock_dialog->timer); gtk_widget_destroy(GTK_WIDGET(remmina_unlock_dialog->dialog)); remmina_unlock_dialog->dialog = NULL; } @@ -59,13 +82,14 @@ static void remmina_button_unlock_cancel_clicked(GtkButton *btn, gpointer user_d remmina_unlock_dialog->dialog = NULL; } -GtkDialog* remmina_unlock_new(GtkWindow *parent) +void remmina_unlock_new(GtkWindow *parent) { TRACE_CALL(__func__); remmina_unlock_dialog = g_new0(RemminaUnlockDialog, 1); //remmina_unlock_dialog->priv = g_new0(RemminaUnlockDialogPriv, 1); + //if (remmina_unlock_dialog->unlock_init) remmina_unlock_dialog->builder = remmina_public_gtk_builder_new_from_file("remmina_unlock.glade"); remmina_unlock_dialog->dialog = GTK_DIALOG(gtk_builder_get_object(remmina_unlock_dialog->builder, "RemminaUnlockDialog")); if (parent) @@ -83,7 +107,13 @@ GtkDialog* remmina_unlock_new(GtkWindow *parent) /* Connect signals */ gtk_builder_connect_signals(remmina_unlock_dialog->builder, NULL); - return remmina_unlock_dialog->dialog; + if (remmina_pref_get_boolean("use_master_password")) + gtk_dialog_run(remmina_unlock_dialog->dialog); } +#else +void remmina_unlock_new(...) +{ + TRACE_CALL(__func__); +} #endif diff --git a/src/remmina_unlock.h b/src/remmina_unlock.h index 5115aeed6..31b93e20f 100644 --- a/src/remmina_unlock.h +++ b/src/remmina_unlock.h @@ -34,6 +34,7 @@ #pragma once +#ifdef __linux__ typedef struct _RemminaUnlockDialog { GtkBuilder *builder; GtkDialog *dialog; @@ -41,10 +42,19 @@ typedef struct _RemminaUnlockDialog { GtkEntry *entry_unlock; GtkButton *button_unlock; GtkButton *button_unlock_cancel; + + gboolean unlock_init; + GTimer *timer; + } RemminaUnlockDialog; +#endif G_BEGIN_DECLS -GtkDialog* remmina_unlock_new(GtkWindow *parent); +#ifdef __linux__ +void remmina_unlock_new(GtkWindow *parent); +#else +void remmina_unlock_new(...); +#endif G_END_DECLS |