Fix handling of binary secrets in wxSecretStore with wxGTK

Use correct content type when creating binary secrets to prevent
libsecret from munging them.

Also update the sample to show more functionality.

Closes #24351.

Closes #24352.
This commit is contained in:
Martin Corino 2024-02-26 09:39:43 +01:00 committed by Vadim Zeitlin
parent 6e7bbfd17c
commit 8a027b98d1
5 changed files with 154 additions and 34 deletions

View file

@ -40,7 +40,7 @@ public:
// Creates a secret value from the given data.
wxSecretValue(size_t size, const void *data)
: m_impl(NewImpl(size, data))
: m_impl(NewImpl(size, data, "application/octet-stream"))
{
}
@ -48,7 +48,7 @@ public:
explicit wxSecretValue(const wxString& secret)
{
const wxScopedCharBuffer buf(secret.utf8_str());
m_impl = NewImpl(buf.length(), buf.data());
m_impl = NewImpl(buf.length(), buf.data(), "text/plain");
}
wxSecretValue(const wxSecretValue& other);
@ -90,7 +90,8 @@ public:
private:
// This method is implemented in platform-specific code and must return a
// new heap-allocated object initialized with the given data.
static wxSecretValueImpl* NewImpl(size_t size, const void *data);
static wxSecretValueImpl*
NewImpl(size_t size, const void *data, const char* contentType);
// This ctor is only used by wxSecretStore and takes ownership of the
// provided existing impl pointer.