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

module GI.Secret.Flags
    ( 

-- * Exported types
    ServiceFlags(..)                        ,
    SearchFlags(..)                         ,
    SchemaFlags(..)                         ,
    ItemFlags(..)                           ,
    ItemCreateFlags(..)                     ,
    CollectionFlags(..)                     ,
    CollectionCreateFlags(..)               ,


    ) 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.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
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


-- Flags ServiceFlags
{- |
Flags which determine which parts of the 'GI.Secret.Objects.Service.Service' proxy are initialized
during a 'GI.Secret.Objects.Service.serviceGet' or 'GI.Secret.Objects.Service.serviceOpen' operation.
-}
data ServiceFlags = 
      ServiceFlagsNone
    {- ^
    no flags for initializing the 'GI.Secret.Objects.Service.Service'
    -}
    | ServiceFlagsOpenSession
    {- ^
    establish a session for transfer of secrets
                                  while initializing the 'GI.Secret.Objects.Service.Service'
    -}
    | ServiceFlagsLoadCollections
    {- ^
    load collections while initializing the
                                      'GI.Secret.Objects.Service.Service'
    -}
    | AnotherServiceFlags Int
    -- ^ Catch-all for unknown values
    deriving (Show, Eq)

instance P.Enum ServiceFlags where
    fromEnum ServiceFlagsNone = 0
    fromEnum ServiceFlagsOpenSession = 2
    fromEnum ServiceFlagsLoadCollections = 4
    fromEnum (AnotherServiceFlags k) = k

    toEnum 0 = ServiceFlagsNone
    toEnum 2 = ServiceFlagsOpenSession
    toEnum 4 = ServiceFlagsLoadCollections
    toEnum k = AnotherServiceFlags k

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

instance IsGFlag ServiceFlags

-- Flags SearchFlags
{- |
Various flags to be used with 'GI.Secret.Objects.Service.serviceSearch' and 'GI.Secret.Objects.Service.serviceSearchSync'.
-}
data SearchFlags = 
      SearchFlagsNone
    {- ^
    no flags
    -}
    | SearchFlagsAll
    {- ^
    all the items matching the search will be returned, instead of just the first one
    -}
    | SearchFlagsUnlock
    {- ^
    unlock locked items while searching
    -}
    | SearchFlagsLoadSecrets
    {- ^
    while searching load secrets for items that are not locked
    -}
    | AnotherSearchFlags Int
    -- ^ Catch-all for unknown values
    deriving (Show, Eq)

instance P.Enum SearchFlags where
    fromEnum SearchFlagsNone = 0
    fromEnum SearchFlagsAll = 2
    fromEnum SearchFlagsUnlock = 4
    fromEnum SearchFlagsLoadSecrets = 8
    fromEnum (AnotherSearchFlags k) = k

    toEnum 0 = SearchFlagsNone
    toEnum 2 = SearchFlagsAll
    toEnum 4 = SearchFlagsUnlock
    toEnum 8 = SearchFlagsLoadSecrets
    toEnum k = AnotherSearchFlags k

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

instance IsGFlag SearchFlags

-- Flags SchemaFlags
{- |
Flags for a 'GI.Secret.Structs.Schema.Schema' definition.
-}
data SchemaFlags = 
      SchemaFlagsNone
    {- ^
    no flags for the schema
    -}
    | SchemaFlagsDontMatchName
    {- ^
    don\'t match the schema name when looking up or
                                    removing passwords
    -}
    | AnotherSchemaFlags Int
    -- ^ Catch-all for unknown values
    deriving (Show, Eq)

instance P.Enum SchemaFlags where
    fromEnum SchemaFlagsNone = 0
    fromEnum SchemaFlagsDontMatchName = 2
    fromEnum (AnotherSchemaFlags k) = k

    toEnum 0 = SchemaFlagsNone
    toEnum 2 = SchemaFlagsDontMatchName
    toEnum k = AnotherSchemaFlags k

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

instance IsGFlag SchemaFlags

-- Flags ItemFlags
{- |
Flags which determine which parts of the 'GI.Secret.Objects.Item.Item' proxy are initialized.
-}
data ItemFlags = 
      ItemFlagsNone
    {- ^
    no flags
    -}
    | ItemFlagsLoadSecret
    {- ^
    a secret has been (or should be) loaded for 'GI.Secret.Objects.Item.Item'
    -}
    | AnotherItemFlags Int
    -- ^ Catch-all for unknown values
    deriving (Show, Eq)

instance P.Enum ItemFlags where
    fromEnum ItemFlagsNone = 0
    fromEnum ItemFlagsLoadSecret = 2
    fromEnum (AnotherItemFlags k) = k

    toEnum 0 = ItemFlagsNone
    toEnum 2 = ItemFlagsLoadSecret
    toEnum k = AnotherItemFlags k

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

instance IsGFlag ItemFlags

-- Flags ItemCreateFlags
{- |
Flags for 'GI.Secret.Objects.Item.itemCreate'.
-}
data ItemCreateFlags = 
      ItemCreateFlagsNone
    {- ^
    no flags
    -}
    | ItemCreateFlagsReplace
    {- ^
    replace an item with the same attributes.
    -}
    | AnotherItemCreateFlags Int
    -- ^ Catch-all for unknown values
    deriving (Show, Eq)

instance P.Enum ItemCreateFlags where
    fromEnum ItemCreateFlagsNone = 0
    fromEnum ItemCreateFlagsReplace = 2
    fromEnum (AnotherItemCreateFlags k) = k

    toEnum 0 = ItemCreateFlagsNone
    toEnum 2 = ItemCreateFlagsReplace
    toEnum k = AnotherItemCreateFlags k

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

instance IsGFlag ItemCreateFlags

-- Flags CollectionFlags
{- |
Flags which determine which parts of the 'GI.Secret.Objects.Collection.Collection' proxy are initialized.
-}
data CollectionFlags = 
      CollectionFlagsNone
    {- ^
    no flags
    -}
    | CollectionFlagsLoadItems
    {- ^
    items have or should be loaded
    -}
    | AnotherCollectionFlags Int
    -- ^ Catch-all for unknown values
    deriving (Show, Eq)

instance P.Enum CollectionFlags where
    fromEnum CollectionFlagsNone = 0
    fromEnum CollectionFlagsLoadItems = 2
    fromEnum (AnotherCollectionFlags k) = k

    toEnum 0 = CollectionFlagsNone
    toEnum 2 = CollectionFlagsLoadItems
    toEnum k = AnotherCollectionFlags k

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

instance IsGFlag CollectionFlags

-- Flags CollectionCreateFlags
{- |
Flags for 'GI.Secret.Objects.Collection.collectionCreate'.
-}
data CollectionCreateFlags = 
      CollectionCreateFlagsCollectionCreateNone
    {- ^
    no flags
    -}
    | AnotherCollectionCreateFlags Int
    -- ^ Catch-all for unknown values
    deriving (Show, Eq)

instance P.Enum CollectionCreateFlags where
    fromEnum CollectionCreateFlagsCollectionCreateNone = 0
    fromEnum (AnotherCollectionCreateFlags k) = k

    toEnum 0 = CollectionCreateFlagsCollectionCreateNone
    toEnum k = AnotherCollectionCreateFlags k

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

instance IsGFlag CollectionCreateFlags