# HG changeset patch # User Olaf Wintermann # Date 1730131332 -3600 # Node ID 3f987dde3be25709fafbe4afd3346c555fdf8dcc # Parent eee1f3092844fdb86b06b5fcdd54b24a5feb3dc4 implement creation of new secret stores diff -r eee1f3092844 -r 3f987dde3be2 application/settings.c --- 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); } diff -r eee1f3092844 -r 3f987dde3be2 application/settings.h --- a/application/settings.h Mon Oct 28 16:47:59 2024 +0100 +++ b/application/settings.h Mon Oct 28 17:02:12 2024 +0100 @@ -42,7 +42,6 @@ DavConfig *config; PwdStore *pwdstore; - DavBool config_saved; UiList *repos; /*