Optionally return error message from wxSecretStore::IsOk()
This allows to give at least some explanation about why the secrets can't be stored to the user, e.g. they could search for a message such as The name org.freedesktop.secrets was not provided by any .service files to find out that gnome-keyring package needs to be installed on their system. Note that this change means that under Unix an attempt to connect to the secret service is now made when wxSecretStore is constructed and not just when it's used for the first time, as before.
This commit is contained in:
@@ -166,14 +166,16 @@ public:
|
||||
Example of storing credentials using this class:
|
||||
@code
|
||||
wxSecretStore store = wxSecretStore::GetDefault();
|
||||
if ( store.IsOk() )
|
||||
wxString errmsg;
|
||||
if ( store.IsOk(&errmsg) )
|
||||
{
|
||||
if ( !store.Save("MyApp/MyService", username, password) )
|
||||
wxLogWarning("Failed to save credentials to the system secret store.");
|
||||
}
|
||||
else
|
||||
{
|
||||
wxLogWarning("This system doesn't support storing passwords securely.");
|
||||
wxLogWarning("This system doesn't support storing passwords securely "
|
||||
"(%s).", errmsg);
|
||||
}
|
||||
@endcode
|
||||
|
||||
@@ -205,9 +207,13 @@ public:
|
||||
static wxSecretStore GetDefault();
|
||||
|
||||
/**
|
||||
Check if this object is valid.
|
||||
Check if this object can actually be used.
|
||||
|
||||
@param errmsg If not @NULL, this parameter is filled with a
|
||||
user-readable error message explaining why the secret store can't
|
||||
be used (this argument is new since wxWidgets 3.1.4)
|
||||
*/
|
||||
bool IsOk() const;
|
||||
bool IsOk(wxString* errmsg = NULL) const;
|
||||
|
||||
/**
|
||||
Store a username/password combination.
|
||||
|
Reference in New Issue
Block a user