Mon, 28 Oct 2024 17:02:12 +0100
implement creation of new secret stores
application/settings.c | file | annotate | diff | comparison | revisions | |
application/settings.h | file | annotate | diff | comparison | revisions |
--- a/application/settings.c Mon Oct 28 16:47:59 2024 +0100 +++ b/application/settings.c Mon Oct 28 17:02:12 2024 +0100 @@ -273,10 +273,19 @@ ui_free(ctx, ptr); } +static void secretstore_newmasterpw(UiEvent *event, void *userdata) { + SettingsWindow *settings = event->window; + if(event->intval == 1) { + pwdstore_setpassword(settings->pwdstore, event->eventdata); + set_pwdstore(settings->pwdstore); + pwdstore_save(settings->pwdstore); + settings->pwdstore = NULL; + } + ui_close(event->obj); +} void settings_ok(UiEvent *event, void *userdata) { SettingsWindow *settings = event->window; - settings->config_saved = TRUE; // save any changed settings settings_store_repository(settings); settings_credentials_save(settings); @@ -285,24 +294,29 @@ if(store_config()) { ui_dialog(event->obj, .title = "Error", .content = "Cannot store settings", .closebutton_label = "OK"); } - settings->config = NULL; + application_update_repolist(get_application()); settings->config = NULL; if(settings->credentials_modified) { - set_pwdstore(settings->pwdstore); - pwdstore_save(settings->pwdstore); + if(settings->pwdstore->key) { + set_pwdstore(settings->pwdstore); + pwdstore_save(settings->pwdstore); + } else { + ui_dialog(event->obj, + .title = "Secret Store", + .content = "Master password", + .password = TRUE, + .result = secretstore_newmasterpw, + .button1_label = "Create Secret Store", + .closebutton_label = "Cancel", + .result = secretstore_newmasterpw); + return; + } settings->pwdstore = NULL; } - application_update_repolist(get_application()); ui_close(event->obj); } void settings_close(UiEvent *event, void *userdata) { SettingsWindow *settings = event->window; - if(settings->config_saved) { - // function was called as context closefunc by ui_close - // in settings_ok - // don't free anything - return; - } if(settings->config) { dav_config_free(settings->config); } @@ -312,7 +326,6 @@ } void settings_cancel(UiEvent *event, void *userdata) { - SettingsWindow *settings = event->window; ui_close(event->obj); }