mirror of
https://gitlab.gnome.org/GNOME/libsecret.git
synced 2024-12-22 04:38:55 +00:00
lib/schemas: Add secret_get_schema() accessor for SECRET_SCHEMA_*s
The SECRET_SCHEMA_* extern structs are not introspectable; add a new accessor function which takes an enum and returns a struct, which is introspectable. Mark the old extern structs as (skip), but don’t deprecate them because they’re still useful from C (if unconventional). Signed-off-by: Philip Withnall <withnall@endlessm.com> https://bugzilla.gnome.org/show_bug.cgi?id=697681
This commit is contained in:
parent
d3ac1c1834
commit
b738c9f787
@ -150,6 +150,8 @@ secret_schema_new
|
||||
secret_schema_newv
|
||||
secret_schema_ref
|
||||
secret_schema_unref
|
||||
SecretSchemaType
|
||||
secret_get_schema
|
||||
<SUBSECTION Standard>
|
||||
secret_schema_get_type
|
||||
secret_schema_attribute_get_type
|
||||
|
@ -15,9 +15,10 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "secret-schema.h"
|
||||
#include "secret-schemas.h"
|
||||
|
||||
/**
|
||||
* SECRET_SCHEMA_NOTE:
|
||||
* SECRET_SCHEMA_NOTE: (skip)
|
||||
*
|
||||
* A predefined schema for personal passwords stored by the user in the
|
||||
* password manager. This schema has no attributes, and the items are not
|
||||
@ -39,7 +40,7 @@ static const SecretSchema note_schema = {
|
||||
const SecretSchema * SECRET_SCHEMA_NOTE = ¬e_schema;
|
||||
|
||||
/**
|
||||
* SECRET_SCHEMA_COMPAT_NETWORK:
|
||||
* SECRET_SCHEMA_COMPAT_NETWORK: (skip)
|
||||
*
|
||||
* A predefined schema that is compatible with items stored via the
|
||||
* libgnome-keyring 'network password' functions. This is meant to be used by
|
||||
@ -85,3 +86,28 @@ static const SecretSchema network_schema = {
|
||||
};
|
||||
|
||||
const SecretSchema * SECRET_SCHEMA_COMPAT_NETWORK = &network_schema;
|
||||
|
||||
/**
|
||||
* secret_get_schema:
|
||||
* @type: type of schema to get
|
||||
*
|
||||
* Get a secret storage schema of the given @type.
|
||||
*
|
||||
* C code may access the schemas (such as %SECRET_SCHEMA_NOTE) directly, but
|
||||
* language bindings cannot, and must use this accessor.
|
||||
*
|
||||
* Returns: (transfer none): schema type
|
||||
* Since: 0.18.6
|
||||
*/
|
||||
const SecretSchema *
|
||||
secret_get_schema (SecretSchemaType type)
|
||||
{
|
||||
switch (type) {
|
||||
case SECRET_SCHEMA_TYPE_NOTE:
|
||||
return SECRET_SCHEMA_NOTE;
|
||||
case SECRET_SCHEMA_TYPE_COMPAT_NETWORK:
|
||||
return SECRET_SCHEMA_COMPAT_NETWORK;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,25 @@ extern const SecretSchema * SECRET_SCHEMA_NOTE;
|
||||
|
||||
extern const SecretSchema * SECRET_SCHEMA_COMPAT_NETWORK;
|
||||
|
||||
/**
|
||||
* SecretSchemaType:
|
||||
* @SECRET_SCHEMA_TYPE_NOTE: Personal passwords; see %SECRET_SCHEMA_NOTE
|
||||
* @SECRET_SCHEMA_TYPE_COMPAT_NETWORK: Network passwords from older
|
||||
* libgnome-keyring storage; see %SECRET_SCHEMA_COMPAT_NETWORK
|
||||
*
|
||||
* Different types of schemas for storing secrets, intended for use with
|
||||
* secret_get_schema().
|
||||
*
|
||||
* Since: 0.18.6
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SECRET_SCHEMA_TYPE_NOTE,
|
||||
SECRET_SCHEMA_TYPE_COMPAT_NETWORK,
|
||||
} SecretSchemaType;
|
||||
|
||||
const SecretSchema *secret_get_schema (SecretSchemaType type);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __SECRET_SCHEMAS_H___ */
|
||||
|
Loading…
Reference in New Issue
Block a user