|
KiCad PCB EDA Suite
|
#include <core/kicad_algo.h>#include <json_common.h>#include <algorithm>#include <set>#include <database/database_lib_settings.h>#include <kiplatform/secrets.h>#include <settings/json_settings_internals.h>#include <settings/parameters.h>#include <string_utils.h>#include <wildcards_and_files_ext.h>#include <wx/filename.h>Go to the source code of this file.
Functions | |
| template<typename T> | |
| static void | patchKey (nlohmann::json &aObj, const std::string &aKey, const T &aValue, const T &aParsed, bool aRequired) |
| Writes aValue to aObj[aKey] only if it differs from aParsed, the value the raw key was read as. | |
| static void | normalizeScalarParents (JSON_SETTINGS_INTERNALS &aInternals) |
| Nested params cannot store into a non-object parent, so replace a malformed one before storing. | |
| std::unique_ptr< DATABASE_LIB_SETTINGS > | LoadDatabaseLibSettingsReadOnly (const wxString &aPath, bool *aLoaded) |
| Loads a database library settings file without allowing the load itself (e.g. | |
| wxString | DefaultDatabaseLibFileName (const wxString &aLibName) |
| static wxString | passwordService (const DATABASE_SOURCE &aSource) |
| DATABASE_SECRET_LOOKUP | DefaultDatabaseSecretLookup () |
| The lookup used when none is injected, which must never prompt to unlock the keyring. | |
| bool | IsNoPromptSecretLookup (const DATABASE_SECRET_LOOKUP &aLookup) |
| static bool | hasKeyringLogin (const DATABASE_SOURCE &aSource) |
| bool | GetDatabasePassword (const DATABASE_SOURCE &aSource, std::string &aPassword, const DATABASE_SECRET_LOOKUP &aLookup) |
| DSN passwords that are not saved in the (often shared) library file live in the system keyring, keyed by DSN and user name so every library on the same login shares one entry. | |
| void | ResolveDatabasePassword (DATABASE_SOURCE &aSource, const DATABASE_SECRET_LOOKUP &aLookup) |
| Fills in the source password from the keyring, but only when the library file did not supply one. | |
| bool | StoreDatabasePassword (const DATABASE_SOURCE &aSource, const std::string &aPassword) |
| Stores the password for the source's DSN login in the system keyring, or removes the entry when the password is empty. | |
Variables | |
| const int | dblibSchemaVersion = 1 |
| static constexpr const char * | c_scalarParents [] = { "/source", "/cache" } |
| Objects that hold scalar settings rather than library tables. | |
| wxString DefaultDatabaseLibFileName | ( | const wxString & | aLibName | ) |
Definition at line 431 of file database_lib_settings.cpp.
References name, and ReplaceIllegalFileNameChars().
Referenced by DIALOG_DATABASE_LIB_SETTINGS::chooseSavePath().
| DATABASE_SECRET_LOOKUP DefaultDatabaseSecretLookup | ( | ) |
The lookup used when none is injected, which must never prompt to unlock the keyring.
Definition at line 451 of file database_lib_settings.cpp.
References KIPLATFORM::SECRETS::GetSecretNoPrompt().
Referenced by GetDatabasePassword().
| bool GetDatabasePassword | ( | const DATABASE_SOURCE & | aSource, |
| std::string & | aPassword, | ||
| const DATABASE_SECRET_LOOKUP & | aLookup = nullptr ) |
DSN passwords that are not saved in the (often shared) library file live in the system keyring, keyed by DSN and user name so every library on the same login shares one entry.
| aLookup | replaces the system keyring when set, for tests. |
Definition at line 474 of file database_lib_settings.cpp.
References DefaultDatabaseSecretLookup(), hasKeyringLogin(), passwordService(), and DATABASE_SOURCE::username.
Referenced by ResolveDatabasePassword(), and DIALOG_DATABASE_LIB_SETTINGS::TransferDataToWindow().
|
static |
Definition at line 467 of file database_lib_settings.cpp.
References DATABASE_SOURCE::connection_string, DATABASE_SOURCE::dsn, and DATABASE_SOURCE::username.
Referenced by GetDatabasePassword(), and StoreDatabasePassword().
| bool IsNoPromptSecretLookup | ( | const DATABASE_SECRET_LOOKUP & | aLookup | ) |
Definition at line 457 of file database_lib_settings.cpp.
References KIPLATFORM::SECRETS::GetSecretNoPrompt().
| std::unique_ptr< DATABASE_LIB_SETTINGS > LoadDatabaseLibSettingsReadOnly | ( | const wxString & | aPath, |
| bool * | aLoaded = nullptr ) |
Loads a database library settings file without allowing the load itself (e.g.
a schema migration) to write back to disk. Callers must SetReadOnly( false ) around an explicit save.
| aLoaded | is set to false when the file exists but could not be read; saving such settings would replace the file with defaults |
Definition at line 411 of file database_lib_settings.cpp.
References FILEEXT::DatabaseLibraryFileExtension, and path.
Referenced by BOOST_AUTO_TEST_CASE().
|
static |
Nested params cannot store into a non-object parent, so replace a malformed one before storing.
Definition at line 316 of file database_lib_settings.cpp.
References c_scalarParents.
Referenced by DATABASE_LIB_SETTINGS::Store().
|
static |
Definition at line 445 of file database_lib_settings.cpp.
References DATABASE_SOURCE::dsn.
Referenced by GetDatabasePassword(), and StoreDatabasePassword().
|
static |
Writes aValue to aObj[aKey] only if it differs from aParsed, the value the raw key was read as.
An unchanged key keeps its raw form (or stays absent) unless it is required and missing.
Definition at line 76 of file database_lib_settings.cpp.
References T.
Referenced by DATABASE_LIB_SETTINGS::fieldToJson(), and DATABASE_LIB_SETTINGS::tableToJson().
| void ResolveDatabasePassword | ( | DATABASE_SOURCE & | aSource, |
| const DATABASE_SECRET_LOOKUP & | aLookup ) |
Fills in the source password from the keyring, but only when the library file did not supply one.
Definition at line 491 of file database_lib_settings.cpp.
References GetDatabasePassword(), and DATABASE_SOURCE::password.
Referenced by DATABASE_LIB_SETTINGS::ResolvePassword().
| bool StoreDatabasePassword | ( | const DATABASE_SOURCE & | aSource, |
| const std::string & | aPassword ) |
Stores the password for the source's DSN login in the system keyring, or removes the entry when the password is empty.
Definition at line 498 of file database_lib_settings.cpp.
References KIPLATFORM::SECRETS::DeleteSecret(), hasKeyringLogin(), passwordService(), KIPLATFORM::SECRETS::StoreSecret(), and DATABASE_SOURCE::username.
Referenced by DIALOG_DATABASE_LIB_SETTINGS::TransferDataFromWindow().
|
staticconstexpr |
Objects that hold scalar settings rather than library tables.
Definition at line 312 of file database_lib_settings.cpp.
Referenced by normalizeScalarParents(), and DATABASE_LIB_SETTINGS::Store().
| const int dblibSchemaVersion = 1 |
Definition at line 36 of file database_lib_settings.cpp.
Referenced by DATABASE_LIB_SETTINGS::DATABASE_LIB_SETTINGS().