diff options
| author | Simeon Simeonov | 2018-03-08 15:01:45 +0100 |
|---|---|---|
| committer | Simeon Simeonov | 2018-03-08 15:01:45 +0100 |
| commit | 57944f6147f077ccf4d84b9d2659f4e8645e8858 (patch) | |
| tree | b5a4f7af257058fb602d36590568ffd06681f6cd /src | |
| parent | 9bcc1f9650eb2d9dff7a78c632dcc14dfcfac9ee (diff) | |
Reastructure master password functionality
Diffstat (limited to 'src')
| -rw-r--r-- | src/inputdialog.c | 38 | ||||
| -rw-r--r-- | src/inputdialog.h | 3 | ||||
| -rw-r--r-- | src/main.c | 2 |
3 files changed, 42 insertions, 1 deletions
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) | |||
| 156 | return pass; | 156 | return pass; |
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | gchar *input_dialog_query_master_password(void) | ||
| 160 | { | ||
| 161 | return input_dialog_with_invisible(_("Input password"), | ||
| 162 | _("Master password"), | ||
| 163 | NULL); | ||
| 164 | } | ||
| 165 | |||
| 166 | gchar *input_dialog_set_new_password(guint max_attempts) | ||
| 167 | { | ||
| 168 | guint cnt; | ||
| 169 | gchar *pass1, *pass2; | ||
| 170 | |||
| 171 | if (max_attempts < 1) | ||
| 172 | return NULL; | ||
| 173 | |||
| 174 | for (cnt = 0; cnt < max_attempts; ++cnt) { | ||
| 175 | pass1 = input_dialog_with_invisible( | ||
| 176 | _("Input password"), | ||
| 177 | _("New password"), | ||
| 178 | NULL); | ||
| 179 | pass2 = input_dialog_with_invisible( | ||
| 180 | _("Input password"), | ||
| 181 | _("Confirm new password"), | ||
| 182 | NULL); | ||
| 183 | if (strcmp(pass1, pass2) == 0) { | ||
| 184 | /* TODO: clear before free? */ | ||
| 185 | g_free(pass2); | ||
| 186 | break; | ||
| 187 | } | ||
| 188 | /* TODO: clear before free? */ | ||
| 189 | g_free(pass2); | ||
| 190 | g_free(pass1); | ||
| 191 | pass1 = NULL; | ||
| 192 | } | ||
| 193 | |||
| 194 | return pass1; | ||
| 195 | } | ||
| 196 | |||
| 159 | gchar *input_dialog_with_filesel(const gchar *title, const gchar *message, | 197 | gchar *input_dialog_with_filesel(const gchar *title, const gchar *message, |
| 160 | const gchar *default_string, | 198 | const gchar *default_string, |
| 161 | GtkFileChooserAction action) | 199 | 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, | |||
| 36 | gboolean case_sensitive); | 36 | gboolean case_sensitive); |
| 37 | gchar *input_dialog_query_password (const gchar *server, | 37 | gchar *input_dialog_query_password (const gchar *server, |
| 38 | const gchar *user); | 38 | const gchar *user); |
| 39 | 39 | gchar *input_dialog_query_master_password(void); | |
| 40 | gchar *input_dialog_set_new_password(guint max_attempts); | ||
| 40 | gchar *input_dialog_with_filesel (const gchar *title, | 41 | gchar *input_dialog_with_filesel (const gchar *title, |
| 41 | const gchar *message, | 42 | const gchar *message, |
| 42 | const gchar *default_string, | 43 | const gchar *default_string, |
| @@ -265,9 +265,11 @@ int main(int argc, char *argv[]) | |||
| 265 | set_ui_update_func(gtkut_events_flush); | 265 | set_ui_update_func(gtkut_events_flush); |
| 266 | set_progress_func(main_window_progress_show); | 266 | set_progress_func(main_window_progress_show); |
| 267 | set_input_query_password_func(input_dialog_query_password); | 267 | set_input_query_password_func(input_dialog_query_password); |
| 268 | set_input_set_new_password_func(input_dialog_set_new_password); | ||
| 268 | #if USE_SSL | 269 | #if USE_SSL |
| 269 | ssl_init(); | 270 | ssl_init(); |
| 270 | ssl_set_verify_func(ssl_manager_verify_cert); | 271 | ssl_set_verify_func(ssl_manager_verify_cert); |
| 272 | set_input_query_master_password_func(input_dialog_query_master_password); | ||
| 271 | #endif | 273 | #endif |
| 272 | 274 | ||
| 273 | CHDIR_EXIT_IF_FAIL(get_home_dir(), 1); | 275 | CHDIR_EXIT_IF_FAIL(get_home_dir(), 1); |
