From 57944f6147f077ccf4d84b9d2659f4e8645e8858 Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Thu, 8 Mar 2018 15:01:45 +0100 Subject: Reastructure master password functionality --- src/inputdialog.c | 38 ++++++++++++++++++++++++++++++++++++++ src/inputdialog.h | 3 ++- src/main.c | 2 ++ 3 files changed, 42 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/inputdialog.c b/src/inputdialog.c index a601085..d17b852 100644 --- a/src/inputdialog.c +++ b/src/inputdialog.c @@ -156,6 +156,44 @@ gchar *input_dialog_query_password(const gchar *server, const gchar *user) return pass; } +gchar *input_dialog_query_master_password(void) +{ + return input_dialog_with_invisible(_("Input password"), + _("Master password"), + NULL); +} + +gchar *input_dialog_set_new_password(guint max_attempts) +{ + guint cnt; + gchar *pass1, *pass2; + + if (max_attempts < 1) + return NULL; + + for (cnt = 0; cnt < max_attempts; ++cnt) { + pass1 = input_dialog_with_invisible( + _("Input password"), + _("New password"), + NULL); + pass2 = input_dialog_with_invisible( + _("Input password"), + _("Confirm new password"), + NULL); + if (strcmp(pass1, pass2) == 0) { + /* TODO: clear before free? */ + g_free(pass2); + break; + } + /* TODO: clear before free? */ + g_free(pass2); + g_free(pass1); + pass1 = NULL; + } + + return pass1; +} + gchar *input_dialog_with_filesel(const gchar *title, const gchar *message, const gchar *default_string, GtkFileChooserAction action) diff --git a/src/inputdialog.h b/src/inputdialog.h index 02bdda3..5364d1a 100644 --- a/src/inputdialog.h +++ b/src/inputdialog.h @@ -36,7 +36,8 @@ gchar *input_dialog_combo (const gchar *title, gboolean case_sensitive); gchar *input_dialog_query_password (const gchar *server, const gchar *user); - +gchar *input_dialog_query_master_password(void); +gchar *input_dialog_set_new_password(guint max_attempts); gchar *input_dialog_with_filesel (const gchar *title, const gchar *message, const gchar *default_string, diff --git a/src/main.c b/src/main.c index 77d8192..be8ea54 100644 --- a/src/main.c +++ b/src/main.c @@ -265,9 +265,11 @@ int main(int argc, char *argv[]) set_ui_update_func(gtkut_events_flush); set_progress_func(main_window_progress_show); set_input_query_password_func(input_dialog_query_password); + set_input_set_new_password_func(input_dialog_set_new_password); #if USE_SSL ssl_init(); ssl_set_verify_func(ssl_manager_verify_cert); + set_input_query_master_password_func(input_dialog_query_master_password); #endif CHDIR_EXIT_IF_FAIL(get_home_dir(), 1); -- cgit v1.3