{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc)
-}

#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
       && !defined(__HADDOCK_VERSION__))

module GI.Secret.Enums
    (

 -- * Enumerations
-- ** Error #enum:Error#

    Error(..)                               ,


-- ** SchemaAttributeType #enum:SchemaAttributeType#

    SchemaAttributeType(..)                 ,


-- ** SchemaType #enum:SchemaType#

    SchemaType(..)                          ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL


-- Enum SchemaType
{- |
Different types of schemas for storing secrets, intended for use with
'GI.Secret.Functions.getSchema'.

/Since: 0.18.6/
-}
data SchemaType =
      SchemaTypeNote
    {- ^
    Personal passwords; see @/SECRET_SCHEMA_NOTE/@
    -}
    | SchemaTypeCompatNetwork
    {- ^
    Network passwords from older
       libgnome-keyring storage; see @/SECRET_SCHEMA_COMPAT_NETWORK/@
    -}
    | AnotherSchemaType Int
    -- ^ Catch-all for unknown values
    deriving (Show, Eq)

instance P.Enum SchemaType where
    fromEnum SchemaTypeNote = 0
    fromEnum SchemaTypeCompatNetwork = 1
    fromEnum (AnotherSchemaType k) = k

    toEnum 0 = SchemaTypeNote
    toEnum 1 = SchemaTypeCompatNetwork
    toEnum k = AnotherSchemaType k

instance P.Ord SchemaType where
    compare a b = P.compare (P.fromEnum a) (P.fromEnum b)

-- Enum SchemaAttributeType
{- |
The type of an attribute in a 'GI.Secret.Structs.Schema.Schema'. 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.
-}
data SchemaAttributeType =
      SchemaAttributeTypeString
    {- ^
    a utf-8 string attribute
    -}
    | SchemaAttributeTypeInteger
    {- ^
    an integer attribute, stored as a decimal
    -}
    | SchemaAttributeTypeBoolean
    {- ^
    a boolean attribute, stored as \'true\' or \'false\'
    -}
    | AnotherSchemaAttributeType Int
    -- ^ Catch-all for unknown values
    deriving (Show, Eq)

instance P.Enum SchemaAttributeType where
    fromEnum SchemaAttributeTypeString = 0
    fromEnum SchemaAttributeTypeInteger = 1
    fromEnum SchemaAttributeTypeBoolean = 2
    fromEnum (AnotherSchemaAttributeType k) = k

    toEnum 0 = SchemaAttributeTypeString
    toEnum 1 = SchemaAttributeTypeInteger
    toEnum 2 = SchemaAttributeTypeBoolean
    toEnum k = AnotherSchemaAttributeType k

instance P.Ord SchemaAttributeType where
    compare a b = P.compare (P.fromEnum a) (P.fromEnum b)

-- Enum Error
{- |
/No description available in the introspection data./
-}
data Error =
      ErrorProtocol
    {- ^
    /No description available in the introspection data./
    -}
    | ErrorIsLocked
    {- ^
    /No description available in the introspection data./
    -}
    | ErrorNoSuchObject
    {- ^
    /No description available in the introspection data./
    -}
    | ErrorAlreadyExists
    {- ^
    /No description available in the introspection data./
    -}
    | AnotherError Int
    -- ^ Catch-all for unknown values
    deriving (Show, Eq)

instance P.Enum Error where
    fromEnum ErrorProtocol = 1
    fromEnum ErrorIsLocked = 2
    fromEnum ErrorNoSuchObject = 3
    fromEnum ErrorAlreadyExists = 4
    fromEnum (AnotherError k) = k

    toEnum 1 = ErrorProtocol
    toEnum 2 = ErrorIsLocked
    toEnum 3 = ErrorNoSuchObject
    toEnum 4 = ErrorAlreadyExists
    toEnum k = AnotherError k

instance P.Ord Error where
    compare a b = P.compare (P.fromEnum a) (P.fromEnum b)