![]() |
![]() |
![]() |
Libsecret Library Reference Manual | ![]() |
---|---|---|---|---|
Top | Description |
#include <secret/secret.h> SecretSchema; enum SecretSchemaFlags; SecretSchemaAttribute; enum SecretSchemaAttributeType; SecretSchema * secret_schema_new (const gchar *name
,SecretSchemaFlags flags
,GHashTable *attributes
); SecretSchema * secret_schema_ref (SecretSchema *schema
); void secret_schema_unref (SecretSchema *schema
);
Each password is associated with a set of attributes. Attribute values can be either strings, integers or booleans.
The names and types of allowed attributes for a given password are defined with a schema.
Additional schemas can be defined via the SecretSchema
structure like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
/* in a header: */ const SecretSchema * example_get_schema (void) G_GNUC_CONST; #define EXAMPLE_SCHEMA example_get_schema () /* in a .c file: */ const SecretSchema * example_get_schema (void) { static const SecretSchema the_schema = { "org.example.Password", SECRET_SCHEMA_NONE, { { "number", SECRET_SCHEMA_ATTRIBUTE_INTEGER }, { "string", SECRET_SCHEMA_ATTRIBUTE_STRING }, { "even", SECRET_SCHEMA_ATTRIBUTE_BOOLEAN }, { "NULL", 0 }, } }; return &the_schema; } |
typedef struct { const gchar *name; SecretSchemaFlags flags; SecretSchemaAttribute attributes[32]; } SecretSchema;
Represents a set of attributes that are stored with an item. These schemas are used for interoperability between various services storing the same types of items.
Each schema has a name like "org.gnome.keyring.NetworkPassword", and defines a set of attributes, and types (string, integer, boolean) for those attributes.
Attributes are stored as strings in the Secret Service, and the attribute types simply define standard ways to store integer and boolean values as strings.
Schemas are handled entirely on the client side by this library. The name of the schema is automatically stored as an attribute on the item.
Normally when looking up passwords only those with matching schema names are
returned. If the schema flags
contain the SECRET_SCHEMA_DONT_MATCH_NAME
flag,
then lookups will not check that the schema name matches that on the item, only
the schema's attributes are matched. This is useful when you are looking up items
that are not stored by the libsecret library. Other libraries such as libgnome-keyring
don't store the schema name.
const gchar * |
the dotted name of the schema |
SecretSchemaFlags |
flags for the schema |
SecretSchemaAttribute |
the attribute names and types of those attributes |
Stability Level: Stable
typedef enum { SECRET_SCHEMA_NONE = 0, SECRET_SCHEMA_DONT_MATCH_NAME = 1 << 1 } SecretSchemaFlags;
Flags for a SecretSchema definition.
typedef struct { const gchar* name; SecretSchemaAttributeType type; } SecretSchemaAttribute;
An attribute in a SecretSchema.
const gchar * |
name of the attribute |
the type of the attribute |
typedef enum { SECRET_SCHEMA_ATTRIBUTE_STRING = 0, SECRET_SCHEMA_ATTRIBUTE_INTEGER = 1, SECRET_SCHEMA_ATTRIBUTE_BOOLEAN = 2, } SecretSchemaAttributeType;
The type of an attribute in a SecretSchema. Attributes are stored as strings in the Secret Service, and the attribute types simply define standard ways to store integer and boolean values as strings.
SecretSchema * secret_schema_new (const gchar *name
,SecretSchemaFlags flags
,GHashTable *attributes
);
Using this function is not normally necessary from C code. This is useful for constructing SecretSchema structures in bindings.
A schema represents a set of attributes that are stored with an item. These schemas are used for interoperability between various services storing the same types of items.
Each schema has an name
like "org.gnome.keyring.NetworkPassword", and
defines a set of attributes names, and types (string, integer, boolean) for
those attributes.
Each key in the attributes
table should be a attribute name strings, and
the values in the table should be integers from the SecretSchemaAttributeType
enumeration, representing the attribute type for each attribute name.
Normally when looking up passwords only those with matching schema names are
returned. If the schema flags
contain the SECRET_SCHEMA_DONT_MATCH_NAME
flag,
then lookups will not check that the schema name matches that on the item, only
the schema's attributes are matched. This is useful when you are looking up items
that are not stored by the libsecret library. Other libraries such as libgnome-keyring
don't store the schema name.
|
the dotted name of the schema |
|
the flags for the schema |
|
the attribute names and types of those attributes. [element-type utf8 Secret.SchemaAttributeType] |
Returns : |
the new schema, which should be unreferenced with
secret_schema_unref() when done. [transfer full]
|
SecretSchema * secret_schema_ref (SecretSchema *schema
);
Adds a reference to the SecretSchema.
It is not normally necessary to call this function from C code, and is
mainly present for the sake of bindings. If the schema
was statically
allocated, then this function will copy the schema.
|
the schema to reference |
Returns : |
the referenced schema, which should be later
unreferenced with secret_schema_unref() . [transfer full]
|
void secret_schema_unref (SecretSchema *schema
);
Releases a reference to the SecretSchema. If the last reference is released then the schema will be freed.
It is not normally necessary to call this function from C code, and is
mainly present for the sake of bindings. It is an error to call this for
a schema
that was statically allocated.
|
the schema to reference |