Secret.Schema

Fields

Name

Type

Access

Description

attributes

[Secret.SchemaAttribute]

r/w

the attribute names and types of those attributes

flags

Secret.SchemaFlags

r/w

flags for the schema

name

str

r/w

the dotted name of the schema

reserved

int

r

reserved1

object

r

reserved2

object

r

reserved3

object

r

reserved4

object

r

reserved5

object

r

reserved6

object

r

reserved7

object

r

Methods

class

new (name, flags, attribute_names_and_types)

ref ()

unref ()

Details

class Secret.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 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. Attributes are represented in libsecret via a [struct`GLib`.HashTable] with string keys and values. Even for values that defined as an integer or boolean in the schema, the attribute values in the [struct`GLib`.HashTable] are strings. Boolean values are stored as the strings ‘true’ and ‘false’. Integer values are stored in decimal, with a preceding negative sign for negative integers.

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.

Additional schemas can be defined via the [struct`Schema`] structure like this:

```c // in a header:

const Secret.Schema * example_get_schema (void) G_GNUC_CONST;

#define EXAMPLE_SCHEMA example_get_schema ()

// in a .c file

const Secret.Schema * example_get_schema (void) { static const Secret.Schema the_schema = { “org.example.Password”, Secret.SchemaFlags.NONE, { { “number”, Secret.SchemaAttributeType.INTEGER }, { “string”, Secret.SchemaAttributeType.STRING }, { “even”, Secret.SchemaAttributeType.BOOLEAN }, { None, 0 }, } }; return &the_schema; } ```

classmethod new(name, flags, attribute_names_and_types)
Parameters:
Returns:

the new schema, which should be unreferenced with [method`Schema`.unref] when done

Return type:

Secret.Schema

Using this function is not normally necessary from C code. This is useful for constructing Secret.Schema 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 [enum`SchemaAttributeType`] 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.SchemaFlags.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.

ref()
Returns:

the referenced schema, which should be later unreferenced with [method`Schema`.unref]

Return type:

Secret.Schema

Adds a reference to the Secret.Schema.

It is not normally necessary to call this function from C code, and is mainly present for the sake of bindings. If the self was statically allocated, then this function will copy the schema.

unref()

Releases a reference to the Secret.Schema.

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 self that was statically allocated.