Class Schema
- All Implemented Interfaces:
Proxy
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 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 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 Schema structure like this:
// 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;
}
-
Constructor Summary
ConstructorsConstructorDescriptionSchema(MemorySegment address) Create a Schema proxy instance for the provided memory address.Schema(String name, Set<SchemaFlags> flags, HashTable<String, SchemaAttributeType> attributeNamesAndTypes) Using this function is not normally necessary from C code.Schema(String name, SchemaFlags flags, HashTable<String, SchemaAttributeType> attributeNamesAndTypes) Using this function is not normally necessary from C code. -
Method Summary
Modifier and TypeMethodDescriptionstatic MemoryLayoutThe memory layout of the native struct.static @Nullable TypegetType()Get the GType of the Schema class@Nullable SchemaAttribute @Nullable []Read the value of the fieldattributes.Read the value of the fieldflags.readName()Read the value of the fieldname.ref()Adds a reference to theSecretSchema.voidunref()Releases a reference to theSecretSchema.voidwriteAttributes(@Nullable SchemaAttribute @Nullable [] attributes, Arena _arena) Write a value in the fieldattributes.voidwriteFlags(Set<SchemaFlags> flags) Write a value in the fieldflags.voidWrite a value in the fieldname.Methods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Schema
Create a Schema proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
Schema
public Schema(String name, Set<SchemaFlags> flags, HashTable<String, SchemaAttributeType> attributeNamesAndTypes) Using this function is not normally necessary from C code. This is useful for constructingSecretSchemastructures 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
namelikeorg.gnome.keyring.NetworkPassword, and defines a set of attributes names, and types (string, integer, boolean) for those attributes.Each key in the
attributestable should be a attribute name strings, and the values in the table should be integers from theSchemaAttributeTypeenumeration, representing the attribute type for each attribute name.Normally when looking up passwords only those with matching schema names are returned. If the schema
flagscontain theSchemaFlags.DONT_MATCH_NAMEflag, 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.- Parameters:
name- the dotted name of the schemaflags- the flags for the schemaattributeNamesAndTypes- the attribute names and types of those attributes
-
Schema
public Schema(String name, SchemaFlags flags, HashTable<String, SchemaAttributeType> attributeNamesAndTypes) Using this function is not normally necessary from C code. This is useful for constructingSecretSchemastructures 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
namelikeorg.gnome.keyring.NetworkPassword, and defines a set of attributes names, and types (string, integer, boolean) for those attributes.Each key in the
attributestable should be a attribute name strings, and the values in the table should be integers from theSchemaAttributeTypeenumeration, representing the attribute type for each attribute name.Normally when looking up passwords only those with matching schema names are returned. If the schema
flagscontain theSchemaFlags.DONT_MATCH_NAMEflag, 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.- Parameters:
name- the dotted name of the schemaflags- the flags for the schemaattributeNamesAndTypes- the attribute names and types of those attributes
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
readName
-
writeName
-
readFlags
Read the value of the fieldflags.- Returns:
- The value of the field
flags
-
writeFlags
Write a value in the fieldflags.- Parameters:
flags- The new value for the fieldflags
-
readAttributes
Read the value of the fieldattributes.- Returns:
- The value of the field
attributes
-
writeAttributes
Write a value in the fieldattributes.- Parameters:
attributes- The new value for the fieldattributes
-
ref
Adds a reference to theSecretSchema.It is not normally necessary to call this function from C code, and is mainly present for the sake of bindings. If the this Schema was statically allocated, then this function will copy the schema.
- Returns:
- the referenced schema, which should be later
unreferenced with
unref()
-
unref
public void unref()Releases a reference to theSecretSchema.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 this Schema that was statically allocated.
-