30 "org.kicad.kicad", SECRET_SCHEMA_NONE,
32 {
"service", SECRET_SCHEMA_ATTRIBUTE_STRING },
33 {
"key", SECRET_SCHEMA_ATTRIBUTE_STRING },
34 {
nullptr, SECRET_SCHEMA_ATTRIBUTE_STRING }
38 bool StoreSecret(
const wxString& aService,
const wxString& aKey,
const wxString& aSecret )
40 GError* error =
nullptr;
41 wxString display = aService +
":" + aKey;
44 wxScopedCharBuffer utf8Display = display.utf8_str();
45 wxScopedCharBuffer utf8Secret = aSecret.utf8_str();
46 wxScopedCharBuffer utf8Service = aService.utf8_str();
47 wxScopedCharBuffer utf8Key = aKey.utf8_str();
49 secret_password_store_sync( &
schema,
50 SECRET_COLLECTION_DEFAULT,
55 "service", utf8Service.data(),
56 "key", utf8Key.data(),
61 g_error_free( error );
68 bool GetSecret(
const wxString& aService,
const wxString& aKey, wxString& aSecret )
70 GError* error =
nullptr;
71 wxScopedCharBuffer utf8Service = aService.utf8_str();
72 wxScopedCharBuffer utf8Key = aKey.utf8_str();
73 gchar* secret = secret_password_lookup_sync( &
schema,
76 "service", utf8Service.data(),
77 "key", utf8Key.data(),
82 g_error_free( error );
90 aSecret = wxString::FromUTF8( secret );
98 GError* error =
nullptr;
99 wxScopedCharBuffer utf8Service = aService.utf8_str();
100 wxScopedCharBuffer utf8Key = aKey.utf8_str();
101 GHashTable* attributes = secret_attributes_build( &
schema,
102 "service", utf8Service.data(),
103 "key", utf8Key.data(),
107 GList* items = secret_service_search_sync(
nullptr, &
schema, attributes,
108 static_cast<SecretSearchFlags
>( SECRET_SEARCH_ALL
109 | SECRET_SEARCH_LOAD_SECRETS ),
111 g_hash_table_unref( attributes );
115 g_error_free( error );
121 for( GList* it = items; it && !found; it = it->next )
123 SecretItem* item = SECRET_ITEM( it->data );
125 if( secret_item_get_locked( item ) )
128 if( SecretValue* value = secret_item_get_secret( item ) )
130 if(
const gchar*
text = secret_value_get_text( value ) )
132 aSecret = wxString::FromUTF8(
text );
136 secret_value_unref( value );
140 g_list_free_full( items, g_object_unref );