|
KiCad PCB EDA Suite
|
#include <core/kicad_algo.h>#include <json_common.h>#include <algorithm>#include <cctype>#include <map>#include <set>#include <boost/algorithm/string.hpp>#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 | |
| static std::map< std::string, std::string > | parseConnectionString (const std::string &aConnectionString) |
| Splits a connection string into lower-case keys and values for display. | |
| static bool | holdsAssignment (const std::string &aText) |
| A shown value holding '=' has swallowed another key's assignment, possibly a credential. | |
| 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) |
| std::string | DatabasePathForStorage (const wxString &aPath, const wxString &aBaseDir) |
| wxString | DatabasePathFromInput (const wxString &aInput, const wxString &aBaseDir) |
| 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. | |
| std::string DatabasePathForStorage | ( | const wxString & | aPath, |
| const wxString & | aBaseDir ) |
Definition at line 661 of file database_lib_settings.cpp.
Referenced by DIALOG_DATABASE_LIB_SETTINGS::storeSource().
| wxString DatabasePathFromInput | ( | const wxString & | aInput, |
| const wxString & | aBaseDir ) |
Definition at line 702 of file database_lib_settings.cpp.
References source.
Referenced by DIALOG_DATABASE_LIB_SETTINGS::OnBrowseFile(), and DIALOG_DATABASE_LIB_SETTINGS::OnFileTextChanged().
| wxString DefaultDatabaseLibFileName | ( | const wxString & | aLibName | ) |
Definition at line 647 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 734 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 758 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 750 of file database_lib_settings.cpp.
References DATABASE_SOURCE::connection_string, DATABASE_SOURCE::dsn, ODBC, DATABASE_SOURCE::type, and DATABASE_SOURCE::username.
Referenced by GetDatabasePassword(), and StoreDatabasePassword().
|
static |
A shown value holding '=' has swallowed another key's assignment, possibly a credential.
Definition at line 171 of file database_lib_settings.cpp.
Referenced by DATABASE_SOURCE::Describe().
| bool IsNoPromptSecretLookup | ( | const DATABASE_SECRET_LOOKUP & | aLookup | ) |
Definition at line 740 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 628 of file database_lib_settings.cpp.
References 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 516 of file database_lib_settings.cpp.
References c_scalarParents.
Referenced by DATABASE_LIB_SETTINGS::Store().
|
static |
Splits a connection string into lower-case keys and values for display.
We skip anything else that doesn't match the grammar
string := { segment ';' } segment segment := blank | key '=' value value := '{' text '}' blank | plain a doubled '}' inside braces is a literal brace plain := text with none of = { } " '
Definition at line 84 of file database_lib_settings.cpp.
References end.
Referenced by DATABASE_SOURCE::Describe().
|
static |
Definition at line 728 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 235 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 775 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 782 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 512 of file database_lib_settings.cpp.
Referenced by normalizeScalarParents(), and DATABASE_LIB_SETTINGS::Store().
| const int dblibSchemaVersion = 1 |
Definition at line 40 of file database_lib_settings.cpp.
Referenced by DATABASE_LIB_SETTINGS::DATABASE_LIB_SETTINGS().