gi-secret
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellNone
LanguageHaskell2010

GI.Secret.Structs.Schema

Description

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 GHashTable with string keys and values. Even for values that defined as an integer or boolean in the schema, the attribute values in the GHashTable 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 [structschema] structure like this:

c code

// 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;
}
Synopsis

Exported types

newtype Schema Source #

Memory-managed wrapper type.

Constructors

Schema (ManagedPtr Schema) 

Instances

Instances details
Eq Schema Source # 
Instance details

Defined in GI.Secret.Structs.Schema

Methods

(==) :: Schema -> Schema -> Bool #

(/=) :: Schema -> Schema -> Bool #

GBoxed Schema Source # 
Instance details

Defined in GI.Secret.Structs.Schema

ManagedPtrNewtype Schema Source # 
Instance details

Defined in GI.Secret.Structs.Schema

TypedObject Schema Source # 
Instance details

Defined in GI.Secret.Structs.Schema

Methods

glibType :: IO GType #

HasParentTypes Schema Source # 
Instance details

Defined in GI.Secret.Structs.Schema

tag ~ 'AttrSet => Constructible Schema tag Source # 
Instance details

Defined in GI.Secret.Structs.Schema

Methods

new :: MonadIO m => (ManagedPtr Schema -> Schema) -> [AttrOp Schema tag] -> m Schema #

HasAttributeList Schema Source # 
Instance details

Defined in GI.Secret.Structs.Schema

(info ~ ResolveSchemaMethod t Schema, OverloadedMethod info Schema p, HasField t Schema p) => HasField (t :: Symbol) Schema p Source # 
Instance details

Defined in GI.Secret.Structs.Schema

Methods

getField :: Schema -> p #

(signature ~ m Schema, MonadIO m) => OverloadedMethod SchemaRefMethodInfo Schema signature Source # 
Instance details

Defined in GI.Secret.Structs.Schema

Methods

overloadedMethod :: Schema -> signature

(signature ~ m (), MonadIO m) => OverloadedMethod SchemaUnrefMethodInfo Schema signature Source # 
Instance details

Defined in GI.Secret.Structs.Schema

Methods

overloadedMethod :: Schema -> signature

OverloadedMethodInfo SchemaRefMethodInfo Schema Source # 
Instance details

Defined in GI.Secret.Structs.Schema

Methods

overloadedMethodInfo :: Maybe ResolvedSymbolInfo

OverloadedMethodInfo SchemaUnrefMethodInfo Schema Source # 
Instance details

Defined in GI.Secret.Structs.Schema

Methods

overloadedMethodInfo :: Maybe ResolvedSymbolInfo

(info ~ ResolveSchemaMethod t Schema, OverloadedMethodInfo info Schema) => IsLabel t (MethodProxy info Schema) Source # 
Instance details

Defined in GI.Secret.Structs.Schema

Methods

fromLabel :: MethodProxy info Schema #

(info ~ ResolveSchemaMethod t Schema, OverloadedMethod info Schema p) => IsLabel t (Schema -> p) Source # 
Instance details

Defined in GI.Secret.Structs.Schema

Methods

fromLabel :: Schema -> p #

IsGValue (Maybe Schema) Source #

Convert Schema to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.Secret.Structs.Schema

type AttributeList Schema Source # 
Instance details

Defined in GI.Secret.Structs.Schema

type AttributeList Schema
type ParentTypes Schema Source # 
Instance details

Defined in GI.Secret.Structs.Schema

type ParentTypes Schema = '[] :: [Type]

newZeroSchema :: MonadIO m => m Schema Source #

Construct a Schema struct initialized to zero.

Methods

Click to display all available methods, including inherited ones

Expand

Methods

ref, unref.

Getters

None.

Setters

None.

type family ResolveSchemaMethod (t :: Symbol) o where ... Source #

Equations

ResolveSchemaMethod "ref" o = SchemaRefMethodInfo 
ResolveSchemaMethod "unref" o = SchemaUnrefMethodInfo 
ResolveSchemaMethod l o = MethodResolutionFailed l o :: Type 

ref

data SchemaRefMethodInfo Source #

Instances

Instances details
(signature ~ m Schema, MonadIO m) => OverloadedMethod SchemaRefMethodInfo Schema signature Source # 
Instance details

Defined in GI.Secret.Structs.Schema

Methods

overloadedMethod :: Schema -> signature

OverloadedMethodInfo SchemaRefMethodInfo Schema Source # 
Instance details

Defined in GI.Secret.Structs.Schema

Methods

overloadedMethodInfo :: Maybe ResolvedSymbolInfo

schemaRef Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Schema

schema: the schema to reference

-> m Schema

Returns: the referenced schema, which should be later unreferenced with [methodschema.unref]

Adds a reference to the Schema.

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.

unref

data SchemaUnrefMethodInfo Source #

Instances

Instances details
(signature ~ m (), MonadIO m) => OverloadedMethod SchemaUnrefMethodInfo Schema signature Source # 
Instance details

Defined in GI.Secret.Structs.Schema

Methods

overloadedMethod :: Schema -> signature

OverloadedMethodInfo SchemaUnrefMethodInfo Schema Source # 
Instance details

Defined in GI.Secret.Structs.Schema

Methods

overloadedMethodInfo :: Maybe ResolvedSymbolInfo

schemaUnref Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Schema

schema: the schema to reference

-> m () 

Releases a reference to the 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 schema that was statically allocated.

Properties

flags

flags for the schema

getSchemaFlags :: MonadIO m => Schema -> m [SchemaFlags] Source #

Get the value of the “flags” field. When overloading is enabled, this is equivalent to

get schema #flags

schema_flags :: AttrLabelProxy "flags" Source #

setSchemaFlags :: MonadIO m => Schema -> [SchemaFlags] -> m () Source #

Set the value of the “flags” field. When overloading is enabled, this is equivalent to

set schema [ #flags := value ]

name

the dotted name of the schema

clearSchemaName :: MonadIO m => Schema -> m () Source #

Set the value of the “name” field to Nothing. When overloading is enabled, this is equivalent to

clear #name

getSchemaName :: MonadIO m => Schema -> m (Maybe Text) Source #

Get the value of the “name” field. When overloading is enabled, this is equivalent to

get schema #name

schema_name :: AttrLabelProxy "name" Source #

setSchemaName :: MonadIO m => Schema -> CString -> m () Source #

Set the value of the “name” field. When overloading is enabled, this is equivalent to

set schema [ #name := value ]