-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria

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

module GI.Secret.Functions
    ( 

 -- * Methods


-- ** attributesValidate #method:attributesValidate#

    attributesValidate                      ,


-- ** getSchema #method:getSchema#

    getSchema                               ,


-- ** passwordClear #method:passwordClear#

    passwordClear                           ,


-- ** passwordClearFinish #method:passwordClearFinish#

    passwordClearFinish                     ,


-- ** passwordClearSync #method:passwordClearSync#

    passwordClearSync                       ,


-- ** passwordLookup #method:passwordLookup#

    passwordLookup                          ,


-- ** passwordLookupFinish #method:passwordLookupFinish#

    passwordLookupFinish                    ,


-- ** passwordLookupSync #method:passwordLookupSync#

    passwordLookupSync                      ,


-- ** passwordSearch #method:passwordSearch#

    passwordSearch                          ,


-- ** passwordSearchFinish #method:passwordSearchFinish#

    passwordSearchFinish                    ,


-- ** passwordSearchSync #method:passwordSearchSync#

    passwordSearchSync                      ,


-- ** passwordStore #method:passwordStore#

    passwordStore                           ,


-- ** passwordStoreBinary #method:passwordStoreBinary#

    passwordStoreBinary                     ,


-- ** passwordStoreBinarySync #method:passwordStoreBinarySync#

    passwordStoreBinarySync                 ,


-- ** passwordStoreFinish #method:passwordStoreFinish#

    passwordStoreFinish                     ,


-- ** passwordStoreSync #method:passwordStoreSync#

    passwordStoreSync                       ,


-- ** passwordWipe #method:passwordWipe#

    passwordWipe                            ,




    ) 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.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
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.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
import qualified Data.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.Kind as DK
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
import qualified GHC.Records as R
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT

-- Workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/23392
#if MIN_VERSION_base(4,18,0)
import qualified GI.GLib.Callbacks as GLib.Callbacks
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Callbacks as Gio.Callbacks
import qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import {-# SOURCE #-} qualified GI.Secret.Enums as Secret.Enums
import {-# SOURCE #-} qualified GI.Secret.Flags as Secret.Flags
import {-# SOURCE #-} qualified GI.Secret.Interfaces.Retrievable as Secret.Retrievable
import {-# SOURCE #-} qualified GI.Secret.Structs.Schema as Secret.Schema
import {-# SOURCE #-} qualified GI.Secret.Structs.Value as Secret.Value

#else
import qualified GI.Gio.Callbacks as Gio.Callbacks
import qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import {-# SOURCE #-} qualified GI.Secret.Enums as Secret.Enums
import {-# SOURCE #-} qualified GI.Secret.Flags as Secret.Flags
import {-# SOURCE #-} qualified GI.Secret.Interfaces.Retrievable as Secret.Retrievable
import {-# SOURCE #-} qualified GI.Secret.Structs.Schema as Secret.Schema
import {-# SOURCE #-} qualified GI.Secret.Structs.Value as Secret.Value

#endif

-- function password_wipe
-- Args: [ Arg
--           { argCName = "password"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "password to clear" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "secret_password_wipe" secret_password_wipe :: 
    CString ->                              -- password : TBasicType TUTF8
    IO ()

-- | Clear the memory used by a password.
passwordWipe ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (T.Text)
    -- ^ /@password@/: password to clear
    -> m ()
passwordWipe :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Maybe Text -> m ()
passwordWipe Maybe Text
password = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    maybePassword <- case Maybe Text
password of
        Maybe Text
Nothing -> Ptr CChar -> IO (Ptr CChar)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
forall a. Ptr a
FP.nullPtr
        Just Text
jPassword -> do
            jPassword' <- Text -> IO (Ptr CChar)
textToCString Text
jPassword
            return jPassword'
    secret_password_wipe maybePassword
    freeMem maybePassword
    return ()


-- function password_store_sync
-- Args: [ Arg
--           { argCName = "schema"
--           , argType =
--               TInterface Name { namespace = "Secret" , name = "Schema" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the schema for attributes"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "attributes"
--           , argType = TGHash (TBasicType TUTF8) (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the attribute keys and values"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "collection"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "a collection alias, or D-Bus object path of the\n  collection where to store the secret"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "label"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "label for the secret"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "password"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the null-terminated password to store"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "cancellable"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "Cancellable" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "optional cancellation object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "secret_password_storev_sync" secret_password_storev_sync :: 
    Ptr Secret.Schema.Schema ->             -- schema : TInterface (Name {namespace = "Secret", name = "Schema"})
    Ptr (GHashTable CString CString) ->     -- attributes : TGHash (TBasicType TUTF8) (TBasicType TUTF8)
    CString ->                              -- collection : TBasicType TUTF8
    CString ->                              -- label : TBasicType TUTF8
    CString ->                              -- password : TBasicType TUTF8
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

-- | Store a password in the secret service.
-- 
-- The /@attributes@/ should be a set of key and value string pairs.
-- 
-- If the attributes match a secret item already stored in the collection, then
-- the item will be updated with these new values.
-- 
-- If /@collection@/ is 'P.Nothing', then the default collection will be
-- used. Use [const/@cOLLECTIONSESSION@/] to store the password in the session
-- collection, which doesn\'t get stored across login sessions.
-- 
-- This method may block indefinitely and should not be used in user interface
-- threads.
passwordStoreSync ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.Cancellable.IsCancellable a) =>
    Maybe (Secret.Schema.Schema)
    -- ^ /@schema@/: the schema for attributes
    -> Map.Map T.Text T.Text
    -- ^ /@attributes@/: the attribute keys and values
    -> Maybe (T.Text)
    -- ^ /@collection@/: a collection alias, or D-Bus object path of the
    --   collection where to store the secret
    -> T.Text
    -- ^ /@label@/: label for the secret
    -> T.Text
    -- ^ /@password@/: the null-terminated password to store
    -> Maybe (a)
    -- ^ /@cancellable@/: optional cancellation object
    -> m ()
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
passwordStoreSync :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsCancellable a) =>
Maybe Schema
-> Map Text Text -> Maybe Text -> Text -> Text -> Maybe a -> m ()
passwordStoreSync Maybe Schema
schema Map Text Text
attributes Maybe Text
collection Text
label Text
password Maybe a
cancellable = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    maybeSchema <- case Maybe Schema
schema of
        Maybe Schema
Nothing -> Ptr Schema -> IO (Ptr Schema)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Schema
forall a. Ptr a
FP.nullPtr
        Just Schema
jSchema -> do
            jSchema' <- Schema -> IO (Ptr Schema)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Schema
jSchema
            return jSchema'
    let attributes' = Map Text Text -> [(Text, Text)]
forall k a. Map k a -> [(k, a)]
Map.toList Map Text Text
attributes
    attributes'' <- mapFirstA textToCString attributes'
    attributes''' <- mapSecondA textToCString attributes''
    let attributes'''' = (Ptr CChar -> PtrWrapped (Ptr CChar))
-> [(Ptr CChar, Ptr CChar)]
-> [(PtrWrapped (Ptr CChar), Ptr CChar)]
forall a c b. (a -> c) -> [(a, b)] -> [(c, b)]
mapFirst Ptr CChar -> PtrWrapped (Ptr CChar)
B.GHT.cstringPackPtr [(Ptr CChar, Ptr CChar)]
attributes'''
    let attributes''''' = (Ptr CChar -> PtrWrapped (Ptr CChar))
-> [(PtrWrapped (Ptr CChar), Ptr CChar)]
-> [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
forall b c a. (b -> c) -> [(a, b)] -> [(a, c)]
mapSecond Ptr CChar -> PtrWrapped (Ptr CChar)
B.GHT.cstringPackPtr [(PtrWrapped (Ptr CChar), Ptr CChar)]
attributes''''
    attributes'''''' <- packGHashTable gStrHash gStrEqual (Just ptr_to_g_free) (Just ptr_to_g_free) attributes'''''
    maybeCollection <- case collection of
        Maybe Text
Nothing -> Ptr CChar -> IO (Ptr CChar)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
forall a. Ptr a
FP.nullPtr
        Just Text
jCollection -> do
            jCollection' <- Text -> IO (Ptr CChar)
textToCString Text
jCollection
            return jCollection'
    label' <- textToCString label
    password' <- textToCString password
    maybeCancellable <- case cancellable of
        Maybe a
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
FP.nullPtr
        Just a
jCancellable -> do
            jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ secret_password_storev_sync maybeSchema attributes'''''' maybeCollection label' password' maybeCancellable
        whenJust schema touchManagedPtr
        whenJust cancellable touchManagedPtr
        unrefGHashTable attributes''''''
        freeMem maybeCollection
        freeMem label'
        freeMem password'
        return ()
     ) (do
        unrefGHashTable attributes''''''
        freeMem maybeCollection
        freeMem label'
        freeMem password'
     )


-- function password_store_finish
-- Args: [ Arg
--           { argCName = "result"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "AsyncResult" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the asynchronous result passed to the callback"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "secret_password_store_finish" secret_password_store_finish :: 
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

-- | Finish asynchronous operation to store a password in the secret service.
passwordStoreFinish ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.AsyncResult.IsAsyncResult a) =>
    a
    -- ^ /@result@/: the asynchronous result passed to the callback
    -> m ()
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
passwordStoreFinish :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsAsyncResult a) =>
a -> m ()
passwordStoreFinish a
result_ = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    result_' <- a -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
result_
    onException (do
        _ <- propagateGError $ secret_password_store_finish result_'
        touchManagedPtr result_
        return ()
     ) (do
        return ()
     )


-- function password_store_binary_sync
-- Args: [ Arg
--           { argCName = "schema"
--           , argType =
--               TInterface Name { namespace = "Secret" , name = "Schema" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the schema for attributes"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "attributes"
--           , argType = TGHash (TBasicType TUTF8) (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the attribute keys and values"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "collection"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "a collection alias, or D-Bus object path of the\n  collection where to store the secret"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "label"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "label for the secret"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "value"
--           , argType =
--               TInterface Name { namespace = "Secret" , name = "Value" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a [struct@Value]" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "cancellable"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "Cancellable" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "optional cancellation object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "secret_password_storev_binary_sync" secret_password_storev_binary_sync :: 
    Ptr Secret.Schema.Schema ->             -- schema : TInterface (Name {namespace = "Secret", name = "Schema"})
    Ptr (GHashTable CString CString) ->     -- attributes : TGHash (TBasicType TUTF8) (TBasicType TUTF8)
    CString ->                              -- collection : TBasicType TUTF8
    CString ->                              -- label : TBasicType TUTF8
    Ptr Secret.Value.Value ->               -- value : TInterface (Name {namespace = "Secret", name = "Value"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

-- | Store a password in the secret service.
-- 
-- This is similar to [func/@passwordStorevSync@/], but takes a [struct/@value@/] as
-- the argument instead of a null-terminated passwords.
-- 
-- This method may block indefinitely and should not be used in user interface
-- threads.
-- 
-- /Since: 0.19.0/
passwordStoreBinarySync ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.Cancellable.IsCancellable a) =>
    Maybe (Secret.Schema.Schema)
    -- ^ /@schema@/: the schema for attributes
    -> Map.Map T.Text T.Text
    -- ^ /@attributes@/: the attribute keys and values
    -> Maybe (T.Text)
    -- ^ /@collection@/: a collection alias, or D-Bus object path of the
    --   collection where to store the secret
    -> T.Text
    -- ^ /@label@/: label for the secret
    -> Secret.Value.Value
    -- ^ /@value@/: a [struct/@value@/]
    -> Maybe (a)
    -- ^ /@cancellable@/: optional cancellation object
    -> m ()
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
passwordStoreBinarySync :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsCancellable a) =>
Maybe Schema
-> Map Text Text -> Maybe Text -> Text -> Value -> Maybe a -> m ()
passwordStoreBinarySync Maybe Schema
schema Map Text Text
attributes Maybe Text
collection Text
label Value
value Maybe a
cancellable = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    maybeSchema <- case Maybe Schema
schema of
        Maybe Schema
Nothing -> Ptr Schema -> IO (Ptr Schema)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Schema
forall a. Ptr a
FP.nullPtr
        Just Schema
jSchema -> do
            jSchema' <- Schema -> IO (Ptr Schema)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Schema
jSchema
            return jSchema'
    let attributes' = Map Text Text -> [(Text, Text)]
forall k a. Map k a -> [(k, a)]
Map.toList Map Text Text
attributes
    attributes'' <- mapFirstA textToCString attributes'
    attributes''' <- mapSecondA textToCString attributes''
    let attributes'''' = (Ptr CChar -> PtrWrapped (Ptr CChar))
-> [(Ptr CChar, Ptr CChar)]
-> [(PtrWrapped (Ptr CChar), Ptr CChar)]
forall a c b. (a -> c) -> [(a, b)] -> [(c, b)]
mapFirst Ptr CChar -> PtrWrapped (Ptr CChar)
B.GHT.cstringPackPtr [(Ptr CChar, Ptr CChar)]
attributes'''
    let attributes''''' = (Ptr CChar -> PtrWrapped (Ptr CChar))
-> [(PtrWrapped (Ptr CChar), Ptr CChar)]
-> [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
forall b c a. (b -> c) -> [(a, b)] -> [(a, c)]
mapSecond Ptr CChar -> PtrWrapped (Ptr CChar)
B.GHT.cstringPackPtr [(PtrWrapped (Ptr CChar), Ptr CChar)]
attributes''''
    attributes'''''' <- packGHashTable gStrHash gStrEqual (Just ptr_to_g_free) (Just ptr_to_g_free) attributes'''''
    maybeCollection <- case collection of
        Maybe Text
Nothing -> Ptr CChar -> IO (Ptr CChar)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
forall a. Ptr a
FP.nullPtr
        Just Text
jCollection -> do
            jCollection' <- Text -> IO (Ptr CChar)
textToCString Text
jCollection
            return jCollection'
    label' <- textToCString label
    value' <- unsafeManagedPtrGetPtr value
    maybeCancellable <- case cancellable of
        Maybe a
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
FP.nullPtr
        Just a
jCancellable -> do
            jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ secret_password_storev_binary_sync maybeSchema attributes'''''' maybeCollection label' value' maybeCancellable
        whenJust schema touchManagedPtr
        touchManagedPtr value
        whenJust cancellable touchManagedPtr
        unrefGHashTable attributes''''''
        freeMem maybeCollection
        freeMem label'
        return ()
     ) (do
        unrefGHashTable attributes''''''
        freeMem maybeCollection
        freeMem label'
     )


-- function password_store_binary
-- Args: [ Arg
--           { argCName = "schema"
--           , argType =
--               TInterface Name { namespace = "Secret" , name = "Schema" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the schema for attributes"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "attributes"
--           , argType = TGHash (TBasicType TUTF8) (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the attribute keys and values"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "collection"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "a collection alias, or D-Bus object path of the\n  collection where to store the secret"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "label"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "label for the secret"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "value"
--           , argType =
--               TInterface Name { namespace = "Secret" , name = "Value" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a [struct@Value]" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "cancellable"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "Cancellable" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "optional cancellation object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "callback"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "AsyncReadyCallback" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "called when the operation completes"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeAsync
--           , argClosure = 7
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "user_data"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "data to be passed to the callback"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "secret_password_storev_binary" secret_password_storev_binary :: 
    Ptr Secret.Schema.Schema ->             -- schema : TInterface (Name {namespace = "Secret", name = "Schema"})
    Ptr (GHashTable CString CString) ->     -- attributes : TGHash (TBasicType TUTF8) (TBasicType TUTF8)
    CString ->                              -- collection : TBasicType TUTF8
    CString ->                              -- label : TBasicType TUTF8
    Ptr Secret.Value.Value ->               -- value : TInterface (Name {namespace = "Secret", name = "Value"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

-- | Store a password in the secret service.
-- 
-- This is similar to [func/@passwordStorev@/], but takes a
-- [struct/@value@/] as the argument instead of a null-terminated password.
-- 
-- This method will return immediately and complete asynchronously.
-- 
-- /Since: 0.19.0/
passwordStoreBinary ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.Cancellable.IsCancellable a) =>
    Maybe (Secret.Schema.Schema)
    -- ^ /@schema@/: the schema for attributes
    -> Map.Map T.Text T.Text
    -- ^ /@attributes@/: the attribute keys and values
    -> Maybe (T.Text)
    -- ^ /@collection@/: a collection alias, or D-Bus object path of the
    --   collection where to store the secret
    -> T.Text
    -- ^ /@label@/: label for the secret
    -> Secret.Value.Value
    -- ^ /@value@/: a [struct/@value@/]
    -> Maybe (a)
    -- ^ /@cancellable@/: optional cancellation object
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    -- ^ /@callback@/: called when the operation completes
    -> m ()
passwordStoreBinary :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsCancellable a) =>
Maybe Schema
-> Map Text Text
-> Maybe Text
-> Text
-> Value
-> Maybe a
-> Maybe AsyncReadyCallback
-> m ()
passwordStoreBinary Maybe Schema
schema Map Text Text
attributes Maybe Text
collection Text
label Value
value Maybe a
cancellable Maybe AsyncReadyCallback
callback = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    maybeSchema <- case Maybe Schema
schema of
        Maybe Schema
Nothing -> Ptr Schema -> IO (Ptr Schema)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Schema
forall a. Ptr a
FP.nullPtr
        Just Schema
jSchema -> do
            jSchema' <- Schema -> IO (Ptr Schema)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Schema
jSchema
            return jSchema'
    let attributes' = Map Text Text -> [(Text, Text)]
forall k a. Map k a -> [(k, a)]
Map.toList Map Text Text
attributes
    attributes'' <- mapFirstA textToCString attributes'
    attributes''' <- mapSecondA textToCString attributes''
    let attributes'''' = (Ptr CChar -> PtrWrapped (Ptr CChar))
-> [(Ptr CChar, Ptr CChar)]
-> [(PtrWrapped (Ptr CChar), Ptr CChar)]
forall a c b. (a -> c) -> [(a, b)] -> [(c, b)]
mapFirst Ptr CChar -> PtrWrapped (Ptr CChar)
B.GHT.cstringPackPtr [(Ptr CChar, Ptr CChar)]
attributes'''
    let attributes''''' = (Ptr CChar -> PtrWrapped (Ptr CChar))
-> [(PtrWrapped (Ptr CChar), Ptr CChar)]
-> [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
forall b c a. (b -> c) -> [(a, b)] -> [(a, c)]
mapSecond Ptr CChar -> PtrWrapped (Ptr CChar)
B.GHT.cstringPackPtr [(PtrWrapped (Ptr CChar), Ptr CChar)]
attributes''''
    attributes'''''' <- packGHashTable gStrHash gStrEqual (Just ptr_to_g_free) (Just ptr_to_g_free) attributes'''''
    maybeCollection <- case collection of
        Maybe Text
Nothing -> Ptr CChar -> IO (Ptr CChar)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
forall a. Ptr a
FP.nullPtr
        Just Text
jCollection -> do
            jCollection' <- Text -> IO (Ptr CChar)
textToCString Text
jCollection
            return jCollection'
    label' <- textToCString label
    value' <- unsafeManagedPtrGetPtr value
    maybeCancellable <- case cancellable of
        Maybe a
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
FP.nullPtr
        Just a
jCancellable -> do
            jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
            return jCancellable'
    maybeCallback <- case callback of
        Maybe AsyncReadyCallback
Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
forall a. FunPtr a
FP.nullFunPtr
        Just AsyncReadyCallback
jCallback -> do
            ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = Ptr a
forall a. Ptr a
nullPtr
    secret_password_storev_binary maybeSchema attributes'''''' maybeCollection label' value' maybeCancellable maybeCallback userData
    whenJust schema touchManagedPtr
    touchManagedPtr value
    whenJust cancellable touchManagedPtr
    freeMem maybeCollection
    freeMem label'
    return ()


-- function password_store
-- Args: [ Arg
--           { argCName = "schema"
--           , argType =
--               TInterface Name { namespace = "Secret" , name = "Schema" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the schema for attributes"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "attributes"
--           , argType = TGHash (TBasicType TUTF8) (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the attribute keys and values"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "collection"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "a collection alias, or D-Bus object path of the\n  collection where to store the secret"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "label"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "label for the secret"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "password"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the null-terminated password to store"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "cancellable"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "Cancellable" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "optional cancellation object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "callback"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "AsyncReadyCallback" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "called when the operation completes"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeAsync
--           , argClosure = 7
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "user_data"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "data to be passed to the callback"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "secret_password_storev" secret_password_storev :: 
    Ptr Secret.Schema.Schema ->             -- schema : TInterface (Name {namespace = "Secret", name = "Schema"})
    Ptr (GHashTable CString CString) ->     -- attributes : TGHash (TBasicType TUTF8) (TBasicType TUTF8)
    CString ->                              -- collection : TBasicType TUTF8
    CString ->                              -- label : TBasicType TUTF8
    CString ->                              -- password : TBasicType TUTF8
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

-- | Store a password in the secret service.
-- 
-- The /@attributes@/ should be a set of key and value string pairs.
-- 
-- If the attributes match a secret item already stored in the collection, then
-- the item will be updated with these new values.
-- 
-- If /@collection@/ is 'P.Nothing', then the default collection will be
-- used. Use [const/@cOLLECTIONSESSION@/] to store the password in the session
-- collection, which doesn\'t get stored across login sessions.
-- 
-- This method will return immediately and complete asynchronously.
passwordStore ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.Cancellable.IsCancellable a) =>
    Maybe (Secret.Schema.Schema)
    -- ^ /@schema@/: the schema for attributes
    -> Map.Map T.Text T.Text
    -- ^ /@attributes@/: the attribute keys and values
    -> Maybe (T.Text)
    -- ^ /@collection@/: a collection alias, or D-Bus object path of the
    --   collection where to store the secret
    -> T.Text
    -- ^ /@label@/: label for the secret
    -> T.Text
    -- ^ /@password@/: the null-terminated password to store
    -> Maybe (a)
    -- ^ /@cancellable@/: optional cancellation object
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    -- ^ /@callback@/: called when the operation completes
    -> m ()
passwordStore :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsCancellable a) =>
Maybe Schema
-> Map Text Text
-> Maybe Text
-> Text
-> Text
-> Maybe a
-> Maybe AsyncReadyCallback
-> m ()
passwordStore Maybe Schema
schema Map Text Text
attributes Maybe Text
collection Text
label Text
password Maybe a
cancellable Maybe AsyncReadyCallback
callback = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    maybeSchema <- case Maybe Schema
schema of
        Maybe Schema
Nothing -> Ptr Schema -> IO (Ptr Schema)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Schema
forall a. Ptr a
FP.nullPtr
        Just Schema
jSchema -> do
            jSchema' <- Schema -> IO (Ptr Schema)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Schema
jSchema
            return jSchema'
    let attributes' = Map Text Text -> [(Text, Text)]
forall k a. Map k a -> [(k, a)]
Map.toList Map Text Text
attributes
    attributes'' <- mapFirstA textToCString attributes'
    attributes''' <- mapSecondA textToCString attributes''
    let attributes'''' = (Ptr CChar -> PtrWrapped (Ptr CChar))
-> [(Ptr CChar, Ptr CChar)]
-> [(PtrWrapped (Ptr CChar), Ptr CChar)]
forall a c b. (a -> c) -> [(a, b)] -> [(c, b)]
mapFirst Ptr CChar -> PtrWrapped (Ptr CChar)
B.GHT.cstringPackPtr [(Ptr CChar, Ptr CChar)]
attributes'''
    let attributes''''' = (Ptr CChar -> PtrWrapped (Ptr CChar))
-> [(PtrWrapped (Ptr CChar), Ptr CChar)]
-> [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
forall b c a. (b -> c) -> [(a, b)] -> [(a, c)]
mapSecond Ptr CChar -> PtrWrapped (Ptr CChar)
B.GHT.cstringPackPtr [(PtrWrapped (Ptr CChar), Ptr CChar)]
attributes''''
    attributes'''''' <- packGHashTable gStrHash gStrEqual (Just ptr_to_g_free) (Just ptr_to_g_free) attributes'''''
    maybeCollection <- case collection of
        Maybe Text
Nothing -> Ptr CChar -> IO (Ptr CChar)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
forall a. Ptr a
FP.nullPtr
        Just Text
jCollection -> do
            jCollection' <- Text -> IO (Ptr CChar)
textToCString Text
jCollection
            return jCollection'
    label' <- textToCString label
    password' <- textToCString password
    maybeCancellable <- case cancellable of
        Maybe a
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
FP.nullPtr
        Just a
jCancellable -> do
            jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
            return jCancellable'
    maybeCallback <- case callback of
        Maybe AsyncReadyCallback
Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
forall a. FunPtr a
FP.nullFunPtr
        Just AsyncReadyCallback
jCallback -> do
            ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = Ptr a
forall a. Ptr a
nullPtr
    secret_password_storev maybeSchema attributes'''''' maybeCollection label' password' maybeCancellable maybeCallback userData
    whenJust schema touchManagedPtr
    whenJust cancellable touchManagedPtr
    freeMem maybeCollection
    freeMem label'
    freeMem password'
    return ()


-- function password_search_sync
-- Args: [ Arg
--           { argCName = "schema"
--           , argType =
--               TInterface Name { namespace = "Secret" , name = "Schema" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the schema for attributes"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "attributes"
--           , argType = TGHash (TBasicType TUTF8) (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the attribute keys and values"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "flags"
--           , argType =
--               TInterface Name { namespace = "Secret" , name = "SearchFlags" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "search option flags"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "cancellable"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "Cancellable" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "optional cancellation object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TGList
--                  (TInterface Name { namespace = "Secret" , name = "Retrievable" }))
-- throws : True
-- Skip return : False

foreign import ccall "secret_password_searchv_sync" secret_password_searchv_sync :: 
    Ptr Secret.Schema.Schema ->             -- schema : TInterface (Name {namespace = "Secret", name = "Schema"})
    Ptr (GHashTable CString CString) ->     -- attributes : TGHash (TBasicType TUTF8) (TBasicType TUTF8)
    CUInt ->                                -- flags : TInterface (Name {namespace = "Secret", name = "SearchFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr (GList (Ptr Secret.Retrievable.Retrievable)))

-- | Search for items in the secret service.
-- 
-- The /@attributes@/ should be a set of key and value string pairs.
-- 
-- If no secret is found then 'P.Nothing' is returned.
-- 
-- This method may block indefinitely and should not be used in user interface
-- threads.
-- 
-- /Since: 0.19.0/
passwordSearchSync ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.Cancellable.IsCancellable a) =>
    Maybe (Secret.Schema.Schema)
    -- ^ /@schema@/: the schema for attributes
    -> Map.Map T.Text T.Text
    -- ^ /@attributes@/: the attribute keys and values
    -> [Secret.Flags.SearchFlags]
    -- ^ /@flags@/: search option flags
    -> Maybe (a)
    -- ^ /@cancellable@/: optional cancellation object
    -> m [Secret.Retrievable.Retrievable]
    -- ^ __Returns:__ a list of
    --   [iface/@retrievable@/] containing attributes of the matched items /(Can throw 'Data.GI.Base.GError.GError')/
passwordSearchSync :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsCancellable a) =>
Maybe Schema
-> Map Text Text -> [SearchFlags] -> Maybe a -> m [Retrievable]
passwordSearchSync Maybe Schema
schema Map Text Text
attributes [SearchFlags]
flags Maybe a
cancellable = IO [Retrievable] -> m [Retrievable]
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Retrievable] -> m [Retrievable])
-> IO [Retrievable] -> m [Retrievable]
forall a b. (a -> b) -> a -> b
$ do
    maybeSchema <- case Maybe Schema
schema of
        Maybe Schema
Nothing -> Ptr Schema -> IO (Ptr Schema)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Schema
forall a. Ptr a
FP.nullPtr
        Just Schema
jSchema -> do
            jSchema' <- Schema -> IO (Ptr Schema)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Schema
jSchema
            return jSchema'
    let attributes' = Map Text Text -> [(Text, Text)]
forall k a. Map k a -> [(k, a)]
Map.toList Map Text Text
attributes
    attributes'' <- mapFirstA textToCString attributes'
    attributes''' <- mapSecondA textToCString attributes''
    let attributes'''' = (Ptr CChar -> PtrWrapped (Ptr CChar))
-> [(Ptr CChar, Ptr CChar)]
-> [(PtrWrapped (Ptr CChar), Ptr CChar)]
forall a c b. (a -> c) -> [(a, b)] -> [(c, b)]
mapFirst Ptr CChar -> PtrWrapped (Ptr CChar)
B.GHT.cstringPackPtr [(Ptr CChar, Ptr CChar)]
attributes'''
    let attributes''''' = (Ptr CChar -> PtrWrapped (Ptr CChar))
-> [(PtrWrapped (Ptr CChar), Ptr CChar)]
-> [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
forall b c a. (b -> c) -> [(a, b)] -> [(a, c)]
mapSecond Ptr CChar -> PtrWrapped (Ptr CChar)
B.GHT.cstringPackPtr [(PtrWrapped (Ptr CChar), Ptr CChar)]
attributes''''
    attributes'''''' <- packGHashTable gStrHash gStrEqual (Just ptr_to_g_free) (Just ptr_to_g_free) attributes'''''
    let flags' = [SearchFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [SearchFlags]
flags
    maybeCancellable <- case cancellable of
        Maybe a
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
FP.nullPtr
        Just a
jCancellable -> do
            jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ secret_password_searchv_sync maybeSchema attributes'''''' flags' maybeCancellable
        result' <- unpackGList result
        result'' <- mapM (wrapObject Secret.Retrievable.Retrievable) result'
        g_list_free result
        whenJust schema touchManagedPtr
        whenJust cancellable touchManagedPtr
        unrefGHashTable attributes''''''
        return result''
     ) (do
        unrefGHashTable attributes''''''
     )


-- function password_search_finish
-- Args: [ Arg
--           { argCName = "result"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "AsyncResult" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the asynchronous result passed to the callback"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TGList
--                  (TInterface Name { namespace = "Secret" , name = "Retrievable" }))
-- throws : True
-- Skip return : False

foreign import ccall "secret_password_search_finish" secret_password_search_finish :: 
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr (GList (Ptr Secret.Retrievable.Retrievable)))

-- | Finish an asynchronous operation to search for items in the secret service.
-- 
-- /Since: 0.19.0/
passwordSearchFinish ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.AsyncResult.IsAsyncResult a) =>
    a
    -- ^ /@result@/: the asynchronous result passed to the callback
    -> m [Secret.Retrievable.Retrievable]
    -- ^ __Returns:__ a list of
    --   [iface/@retrievable@/] containing attributes of the matched items /(Can throw 'Data.GI.Base.GError.GError')/
passwordSearchFinish :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsAsyncResult a) =>
a -> m [Retrievable]
passwordSearchFinish a
result_ = IO [Retrievable] -> m [Retrievable]
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Retrievable] -> m [Retrievable])
-> IO [Retrievable] -> m [Retrievable]
forall a b. (a -> b) -> a -> b
$ do
    result_' <- a -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
result_
    onException (do
        result <- propagateGError $ secret_password_search_finish result_'
        result' <- unpackGList result
        result'' <- mapM (wrapObject Secret.Retrievable.Retrievable) result'
        g_list_free result
        touchManagedPtr result_
        return result''
     ) (do
        return ()
     )


-- function password_search
-- Args: [ Arg
--           { argCName = "schema"
--           , argType =
--               TInterface Name { namespace = "Secret" , name = "Schema" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the schema for attributes"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "attributes"
--           , argType = TGHash (TBasicType TUTF8) (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the attribute keys and values"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "flags"
--           , argType =
--               TInterface Name { namespace = "Secret" , name = "SearchFlags" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "search option flags"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "cancellable"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "Cancellable" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "optional cancellation object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "callback"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "AsyncReadyCallback" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "called when the operation completes"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeAsync
--           , argClosure = 5
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "user_data"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "data to be passed to the callback"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "secret_password_searchv" secret_password_searchv :: 
    Ptr Secret.Schema.Schema ->             -- schema : TInterface (Name {namespace = "Secret", name = "Schema"})
    Ptr (GHashTable CString CString) ->     -- attributes : TGHash (TBasicType TUTF8) (TBasicType TUTF8)
    CUInt ->                                -- flags : TInterface (Name {namespace = "Secret", name = "SearchFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

-- | Search for items in the secret service.
-- 
-- The /@attributes@/ should be a set of key and value string pairs.
-- 
-- This method will return immediately and complete asynchronously.
-- 
-- /Since: 0.19.0/
passwordSearch ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.Cancellable.IsCancellable a) =>
    Maybe (Secret.Schema.Schema)
    -- ^ /@schema@/: the schema for attributes
    -> Map.Map T.Text T.Text
    -- ^ /@attributes@/: the attribute keys and values
    -> [Secret.Flags.SearchFlags]
    -- ^ /@flags@/: search option flags
    -> Maybe (a)
    -- ^ /@cancellable@/: optional cancellation object
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    -- ^ /@callback@/: called when the operation completes
    -> m ()
passwordSearch :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsCancellable a) =>
Maybe Schema
-> Map Text Text
-> [SearchFlags]
-> Maybe a
-> Maybe AsyncReadyCallback
-> m ()
passwordSearch Maybe Schema
schema Map Text Text
attributes [SearchFlags]
flags Maybe a
cancellable Maybe AsyncReadyCallback
callback = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    maybeSchema <- case Maybe Schema
schema of
        Maybe Schema
Nothing -> Ptr Schema -> IO (Ptr Schema)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Schema
forall a. Ptr a
FP.nullPtr
        Just Schema
jSchema -> do
            jSchema' <- Schema -> IO (Ptr Schema)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Schema
jSchema
            return jSchema'
    let attributes' = Map Text Text -> [(Text, Text)]
forall k a. Map k a -> [(k, a)]
Map.toList Map Text Text
attributes
    attributes'' <- mapFirstA textToCString attributes'
    attributes''' <- mapSecondA textToCString attributes''
    let attributes'''' = (Ptr CChar -> PtrWrapped (Ptr CChar))
-> [(Ptr CChar, Ptr CChar)]
-> [(PtrWrapped (Ptr CChar), Ptr CChar)]
forall a c b. (a -> c) -> [(a, b)] -> [(c, b)]
mapFirst Ptr CChar -> PtrWrapped (Ptr CChar)
B.GHT.cstringPackPtr [(Ptr CChar, Ptr CChar)]
attributes'''
    let attributes''''' = (Ptr CChar -> PtrWrapped (Ptr CChar))
-> [(PtrWrapped (Ptr CChar), Ptr CChar)]
-> [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
forall b c a. (b -> c) -> [(a, b)] -> [(a, c)]
mapSecond Ptr CChar -> PtrWrapped (Ptr CChar)
B.GHT.cstringPackPtr [(PtrWrapped (Ptr CChar), Ptr CChar)]
attributes''''
    attributes'''''' <- packGHashTable gStrHash gStrEqual (Just ptr_to_g_free) (Just ptr_to_g_free) attributes'''''
    let flags' = [SearchFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [SearchFlags]
flags
    maybeCancellable <- case cancellable of
        Maybe a
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
FP.nullPtr
        Just a
jCancellable -> do
            jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
            return jCancellable'
    maybeCallback <- case callback of
        Maybe AsyncReadyCallback
Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
forall a. FunPtr a
FP.nullFunPtr
        Just AsyncReadyCallback
jCallback -> do
            ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = Ptr a
forall a. Ptr a
nullPtr
    secret_password_searchv maybeSchema attributes'''''' flags' maybeCancellable maybeCallback userData
    whenJust schema touchManagedPtr
    whenJust cancellable touchManagedPtr
    return ()


-- function password_lookup_sync
-- Args: [ Arg
--           { argCName = "schema"
--           , argType =
--               TInterface Name { namespace = "Secret" , name = "Schema" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the schema for attributes"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "attributes"
--           , argType = TGHash (TBasicType TUTF8) (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the attribute keys and values"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "cancellable"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "Cancellable" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "optional cancellation object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : True
-- Skip return : False

foreign import ccall "secret_password_lookupv_sync" secret_password_lookupv_sync :: 
    Ptr Secret.Schema.Schema ->             -- schema : TInterface (Name {namespace = "Secret", name = "Schema"})
    Ptr (GHashTable CString CString) ->     -- attributes : TGHash (TBasicType TUTF8) (TBasicType TUTF8)
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CString

-- | Lookup a password in the secret service.
-- 
-- The /@attributes@/ should be a set of key and value string pairs.
-- 
-- If no secret is found then 'P.Nothing' is returned.
-- 
-- This method may block indefinitely and should not be used in user interface
-- threads.
passwordLookupSync ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.Cancellable.IsCancellable a) =>
    Maybe (Secret.Schema.Schema)
    -- ^ /@schema@/: the schema for attributes
    -> Map.Map T.Text T.Text
    -- ^ /@attributes@/: the attribute keys and values
    -> Maybe (a)
    -- ^ /@cancellable@/: optional cancellation object
    -> m (Maybe T.Text)
    -- ^ __Returns:__ a new password string which should be freed with
    --   [func/@passwordFree@/] or may be freed with 'GI.GLib.Functions.free' when done /(Can throw 'Data.GI.Base.GError.GError')/
passwordLookupSync :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsCancellable a) =>
Maybe Schema -> Map Text Text -> Maybe a -> m (Maybe Text)
passwordLookupSync Maybe Schema
schema Map Text Text
attributes Maybe a
cancellable = IO (Maybe Text) -> m (Maybe Text)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    maybeSchema <- case Maybe Schema
schema of
        Maybe Schema
Nothing -> Ptr Schema -> IO (Ptr Schema)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Schema
forall a. Ptr a
FP.nullPtr
        Just Schema
jSchema -> do
            jSchema' <- Schema -> IO (Ptr Schema)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Schema
jSchema
            return jSchema'
    let attributes' = Map Text Text -> [(Text, Text)]
forall k a. Map k a -> [(k, a)]
Map.toList Map Text Text
attributes
    attributes'' <- mapFirstA textToCString attributes'
    attributes''' <- mapSecondA textToCString attributes''
    let attributes'''' = (Ptr CChar -> PtrWrapped (Ptr CChar))
-> [(Ptr CChar, Ptr CChar)]
-> [(PtrWrapped (Ptr CChar), Ptr CChar)]
forall a c b. (a -> c) -> [(a, b)] -> [(c, b)]
mapFirst Ptr CChar -> PtrWrapped (Ptr CChar)
B.GHT.cstringPackPtr [(Ptr CChar, Ptr CChar)]
attributes'''
    let attributes''''' = (Ptr CChar -> PtrWrapped (Ptr CChar))
-> [(PtrWrapped (Ptr CChar), Ptr CChar)]
-> [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
forall b c a. (b -> c) -> [(a, b)] -> [(a, c)]
mapSecond Ptr CChar -> PtrWrapped (Ptr CChar)
B.GHT.cstringPackPtr [(PtrWrapped (Ptr CChar), Ptr CChar)]
attributes''''
    attributes'''''' <- packGHashTable gStrHash gStrEqual (Just ptr_to_g_free) (Just ptr_to_g_free) attributes'''''
    maybeCancellable <- case cancellable of
        Maybe a
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
FP.nullPtr
        Just a
jCancellable -> do
            jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ secret_password_lookupv_sync maybeSchema attributes'''''' maybeCancellable
        maybeResult <- convertIfNonNull result $ \Ptr CChar
result' -> do
            result'' <- HasCallStack => Ptr CChar -> IO Text
Ptr CChar -> IO Text
cstringToText Ptr CChar
result'
            freeMem result'
            return result''
        whenJust schema touchManagedPtr
        whenJust cancellable touchManagedPtr
        unrefGHashTable attributes''''''
        return maybeResult
     ) (do
        unrefGHashTable attributes''''''
     )


-- function password_lookup_finish
-- Args: [ Arg
--           { argCName = "result"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "AsyncResult" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the asynchronous result passed to the callback"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : True
-- Skip return : False

foreign import ccall "secret_password_lookup_finish" secret_password_lookup_finish :: 
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CString

-- | Finish an asynchronous operation to lookup a password in the secret service.
passwordLookupFinish ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.AsyncResult.IsAsyncResult a) =>
    a
    -- ^ /@result@/: the asynchronous result passed to the callback
    -> m T.Text
    -- ^ __Returns:__ a new password string which should be freed with
    --   [func/@passwordFree@/] or may be freed with 'GI.GLib.Functions.free' when done /(Can throw 'Data.GI.Base.GError.GError')/
passwordLookupFinish :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsAsyncResult a) =>
a -> m Text
passwordLookupFinish a
result_ = IO Text -> m Text
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    result_' <- a -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
result_
    onException (do
        result <- propagateGError $ secret_password_lookup_finish result_'
        checkUnexpectedReturnNULL "passwordLookupFinish" result
        result' <- cstringToText result
        freeMem result
        touchManagedPtr result_
        return result'
     ) (do
        return ()
     )


-- function password_lookup
-- Args: [ Arg
--           { argCName = "schema"
--           , argType =
--               TInterface Name { namespace = "Secret" , name = "Schema" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the schema for attributes"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "attributes"
--           , argType = TGHash (TBasicType TUTF8) (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the attribute keys and values"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "cancellable"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "Cancellable" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "optional cancellation object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "callback"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "AsyncReadyCallback" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "called when the operation completes"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeAsync
--           , argClosure = 4
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "user_data"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "data to be passed to the callback"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "secret_password_lookupv" secret_password_lookupv :: 
    Ptr Secret.Schema.Schema ->             -- schema : TInterface (Name {namespace = "Secret", name = "Schema"})
    Ptr (GHashTable CString CString) ->     -- attributes : TGHash (TBasicType TUTF8) (TBasicType TUTF8)
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

-- | Lookup a password in the secret service.
-- 
-- The /@attributes@/ should be a set of key and value string pairs.
-- 
-- If no secret is found then 'P.Nothing' is returned.
-- 
-- This method will return immediately and complete asynchronously.
passwordLookup ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.Cancellable.IsCancellable a) =>
    Maybe (Secret.Schema.Schema)
    -- ^ /@schema@/: the schema for attributes
    -> Map.Map T.Text T.Text
    -- ^ /@attributes@/: the attribute keys and values
    -> Maybe (a)
    -- ^ /@cancellable@/: optional cancellation object
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    -- ^ /@callback@/: called when the operation completes
    -> m ()
passwordLookup :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsCancellable a) =>
Maybe Schema
-> Map Text Text -> Maybe a -> Maybe AsyncReadyCallback -> m ()
passwordLookup Maybe Schema
schema Map Text Text
attributes Maybe a
cancellable Maybe AsyncReadyCallback
callback = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    maybeSchema <- case Maybe Schema
schema of
        Maybe Schema
Nothing -> Ptr Schema -> IO (Ptr Schema)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Schema
forall a. Ptr a
FP.nullPtr
        Just Schema
jSchema -> do
            jSchema' <- Schema -> IO (Ptr Schema)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Schema
jSchema
            return jSchema'
    let attributes' = Map Text Text -> [(Text, Text)]
forall k a. Map k a -> [(k, a)]
Map.toList Map Text Text
attributes
    attributes'' <- mapFirstA textToCString attributes'
    attributes''' <- mapSecondA textToCString attributes''
    let attributes'''' = (Ptr CChar -> PtrWrapped (Ptr CChar))
-> [(Ptr CChar, Ptr CChar)]
-> [(PtrWrapped (Ptr CChar), Ptr CChar)]
forall a c b. (a -> c) -> [(a, b)] -> [(c, b)]
mapFirst Ptr CChar -> PtrWrapped (Ptr CChar)
B.GHT.cstringPackPtr [(Ptr CChar, Ptr CChar)]
attributes'''
    let attributes''''' = (Ptr CChar -> PtrWrapped (Ptr CChar))
-> [(PtrWrapped (Ptr CChar), Ptr CChar)]
-> [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
forall b c a. (b -> c) -> [(a, b)] -> [(a, c)]
mapSecond Ptr CChar -> PtrWrapped (Ptr CChar)
B.GHT.cstringPackPtr [(PtrWrapped (Ptr CChar), Ptr CChar)]
attributes''''
    attributes'''''' <- packGHashTable gStrHash gStrEqual (Just ptr_to_g_free) (Just ptr_to_g_free) attributes'''''
    maybeCancellable <- case cancellable of
        Maybe a
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
FP.nullPtr
        Just a
jCancellable -> do
            jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
            return jCancellable'
    maybeCallback <- case callback of
        Maybe AsyncReadyCallback
Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
forall a. FunPtr a
FP.nullFunPtr
        Just AsyncReadyCallback
jCallback -> do
            ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = Ptr a
forall a. Ptr a
nullPtr
    secret_password_lookupv maybeSchema attributes'''''' maybeCancellable maybeCallback userData
    whenJust schema touchManagedPtr
    whenJust cancellable touchManagedPtr
    return ()


-- function password_clear_sync
-- Args: [ Arg
--           { argCName = "schema"
--           , argType =
--               TInterface Name { namespace = "Secret" , name = "Schema" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the schema for the attributes"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "attributes"
--           , argType = TGHash (TBasicType TUTF8) (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the attribute keys and values"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "cancellable"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "Cancellable" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "optional cancellation object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "secret_password_clearv_sync" secret_password_clearv_sync :: 
    Ptr Secret.Schema.Schema ->             -- schema : TInterface (Name {namespace = "Secret", name = "Schema"})
    Ptr (GHashTable CString CString) ->     -- attributes : TGHash (TBasicType TUTF8) (TBasicType TUTF8)
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

-- | Remove unlocked matching passwords from the secret service.
-- 
-- The /@attributes@/ should be a set of key and value string pairs.
-- 
-- All unlocked items that match the attributes will be deleted.
-- 
-- This method may block indefinitely and should not be used in user interface
-- threads.
passwordClearSync ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.Cancellable.IsCancellable a) =>
    Maybe (Secret.Schema.Schema)
    -- ^ /@schema@/: the schema for the attributes
    -> Map.Map T.Text T.Text
    -- ^ /@attributes@/: the attribute keys and values
    -> Maybe (a)
    -- ^ /@cancellable@/: optional cancellation object
    -> m ()
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
passwordClearSync :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsCancellable a) =>
Maybe Schema -> Map Text Text -> Maybe a -> m ()
passwordClearSync Maybe Schema
schema Map Text Text
attributes Maybe a
cancellable = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    maybeSchema <- case Maybe Schema
schema of
        Maybe Schema
Nothing -> Ptr Schema -> IO (Ptr Schema)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Schema
forall a. Ptr a
FP.nullPtr
        Just Schema
jSchema -> do
            jSchema' <- Schema -> IO (Ptr Schema)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Schema
jSchema
            return jSchema'
    let attributes' = Map Text Text -> [(Text, Text)]
forall k a. Map k a -> [(k, a)]
Map.toList Map Text Text
attributes
    attributes'' <- mapFirstA textToCString attributes'
    attributes''' <- mapSecondA textToCString attributes''
    let attributes'''' = (Ptr CChar -> PtrWrapped (Ptr CChar))
-> [(Ptr CChar, Ptr CChar)]
-> [(PtrWrapped (Ptr CChar), Ptr CChar)]
forall a c b. (a -> c) -> [(a, b)] -> [(c, b)]
mapFirst Ptr CChar -> PtrWrapped (Ptr CChar)
B.GHT.cstringPackPtr [(Ptr CChar, Ptr CChar)]
attributes'''
    let attributes''''' = (Ptr CChar -> PtrWrapped (Ptr CChar))
-> [(PtrWrapped (Ptr CChar), Ptr CChar)]
-> [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
forall b c a. (b -> c) -> [(a, b)] -> [(a, c)]
mapSecond Ptr CChar -> PtrWrapped (Ptr CChar)
B.GHT.cstringPackPtr [(PtrWrapped (Ptr CChar), Ptr CChar)]
attributes''''
    attributes'''''' <- packGHashTable gStrHash gStrEqual (Just ptr_to_g_free) (Just ptr_to_g_free) attributes'''''
    maybeCancellable <- case cancellable of
        Maybe a
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
FP.nullPtr
        Just a
jCancellable -> do
            jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ secret_password_clearv_sync maybeSchema attributes'''''' maybeCancellable
        whenJust schema touchManagedPtr
        whenJust cancellable touchManagedPtr
        unrefGHashTable attributes''''''
        return ()
     ) (do
        unrefGHashTable attributes''''''
     )


-- function password_clear_finish
-- Args: [ Arg
--           { argCName = "result"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "AsyncResult" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the asynchronous result passed to the callback"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "secret_password_clear_finish" secret_password_clear_finish :: 
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

-- | Finish an asynchronous operation to remove passwords from the secret
-- service.
passwordClearFinish ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.AsyncResult.IsAsyncResult a) =>
    a
    -- ^ /@result@/: the asynchronous result passed to the callback
    -> m ()
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
passwordClearFinish :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsAsyncResult a) =>
a -> m ()
passwordClearFinish a
result_ = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    result_' <- a -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
result_
    onException (do
        _ <- propagateGError $ secret_password_clear_finish result_'
        touchManagedPtr result_
        return ()
     ) (do
        return ()
     )


-- function password_clear
-- Args: [ Arg
--           { argCName = "schema"
--           , argType =
--               TInterface Name { namespace = "Secret" , name = "Schema" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the schema for the attributes"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "attributes"
--           , argType = TGHash (TBasicType TUTF8) (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the attribute keys and values"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "cancellable"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "Cancellable" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "optional cancellation object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "callback"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "AsyncReadyCallback" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "called when the operation completes"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeAsync
--           , argClosure = 4
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "user_data"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "data to be passed to the callback"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "secret_password_clearv" secret_password_clearv :: 
    Ptr Secret.Schema.Schema ->             -- schema : TInterface (Name {namespace = "Secret", name = "Schema"})
    Ptr (GHashTable CString CString) ->     -- attributes : TGHash (TBasicType TUTF8) (TBasicType TUTF8)
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

-- | Remove unlocked matching passwords from the secret service.
-- 
-- The /@attributes@/ should be a set of key and value string pairs.
-- 
-- All unlocked items that match the attributes will be deleted.
-- 
-- This method will return immediately and complete asynchronously.
passwordClear ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.Cancellable.IsCancellable a) =>
    Maybe (Secret.Schema.Schema)
    -- ^ /@schema@/: the schema for the attributes
    -> Map.Map T.Text T.Text
    -- ^ /@attributes@/: the attribute keys and values
    -> Maybe (a)
    -- ^ /@cancellable@/: optional cancellation object
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    -- ^ /@callback@/: called when the operation completes
    -> m ()
passwordClear :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsCancellable a) =>
Maybe Schema
-> Map Text Text -> Maybe a -> Maybe AsyncReadyCallback -> m ()
passwordClear Maybe Schema
schema Map Text Text
attributes Maybe a
cancellable Maybe AsyncReadyCallback
callback = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    maybeSchema <- case Maybe Schema
schema of
        Maybe Schema
Nothing -> Ptr Schema -> IO (Ptr Schema)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Schema
forall a. Ptr a
FP.nullPtr
        Just Schema
jSchema -> do
            jSchema' <- Schema -> IO (Ptr Schema)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Schema
jSchema
            return jSchema'
    let attributes' = Map Text Text -> [(Text, Text)]
forall k a. Map k a -> [(k, a)]
Map.toList Map Text Text
attributes
    attributes'' <- mapFirstA textToCString attributes'
    attributes''' <- mapSecondA textToCString attributes''
    let attributes'''' = (Ptr CChar -> PtrWrapped (Ptr CChar))
-> [(Ptr CChar, Ptr CChar)]
-> [(PtrWrapped (Ptr CChar), Ptr CChar)]
forall a c b. (a -> c) -> [(a, b)] -> [(c, b)]
mapFirst Ptr CChar -> PtrWrapped (Ptr CChar)
B.GHT.cstringPackPtr [(Ptr CChar, Ptr CChar)]
attributes'''
    let attributes''''' = (Ptr CChar -> PtrWrapped (Ptr CChar))
-> [(PtrWrapped (Ptr CChar), Ptr CChar)]
-> [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
forall b c a. (b -> c) -> [(a, b)] -> [(a, c)]
mapSecond Ptr CChar -> PtrWrapped (Ptr CChar)
B.GHT.cstringPackPtr [(PtrWrapped (Ptr CChar), Ptr CChar)]
attributes''''
    attributes'''''' <- packGHashTable gStrHash gStrEqual (Just ptr_to_g_free) (Just ptr_to_g_free) attributes'''''
    maybeCancellable <- case cancellable of
        Maybe a
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
FP.nullPtr
        Just a
jCancellable -> do
            jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
            return jCancellable'
    maybeCallback <- case callback of
        Maybe AsyncReadyCallback
Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
forall a. FunPtr a
FP.nullFunPtr
        Just AsyncReadyCallback
jCallback -> do
            ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = Ptr a
forall a. Ptr a
nullPtr
    secret_password_clearv maybeSchema attributes'''''' maybeCancellable maybeCallback userData
    whenJust schema touchManagedPtr
    whenJust cancellable touchManagedPtr
    return ()


-- function get_schema
-- Args: [ Arg
--           { argCName = "type"
--           , argType =
--               TInterface Name { namespace = "Secret" , name = "SchemaType" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "type of schema to get"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Secret" , name = "Schema" })
-- throws : False
-- Skip return : False

foreign import ccall "secret_get_schema" secret_get_schema :: 
    CUInt ->                                -- type : TInterface (Name {namespace = "Secret", name = "SchemaType"})
    IO (Ptr Secret.Schema.Schema)

-- | Get a secret storage schema of the given /@type@/.
-- 
-- C code may access the schemas (such as @/SECRET_SCHEMA_NOTE/@) directly, but
-- language bindings cannot, and must use this accessor.
-- 
-- /Since: 0.18.6/
getSchema ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Secret.Enums.SchemaType
    -- ^ /@type@/: type of schema to get
    -> m Secret.Schema.Schema
    -- ^ __Returns:__ schema type
getSchema :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
SchemaType -> m Schema
getSchema SchemaType
type_ = IO Schema -> m Schema
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Schema -> m Schema) -> IO Schema -> m Schema
forall a b. (a -> b) -> a -> b
$ do
    let type_' :: CUInt
type_' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (SchemaType -> Int) -> SchemaType -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SchemaType -> Int
forall a. Enum a => a -> Int
fromEnum) SchemaType
type_
    result <- CUInt -> IO (Ptr Schema)
secret_get_schema CUInt
type_'
    checkUnexpectedReturnNULL "getSchema" result
    result' <- (newBoxed Secret.Schema.Schema) result
    return result'


-- function attributes_validate
-- Args: [ Arg
--           { argCName = "schema"
--           , argType =
--               TInterface Name { namespace = "Secret" , name = "Schema" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the schema for the attributes"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "attributes"
--           , argType = TGHash (TBasicType TPtr) (TBasicType TPtr)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the attributes to be validated"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "secret_attributes_validate" secret_attributes_validate :: 
    Ptr Secret.Schema.Schema ->             -- schema : TInterface (Name {namespace = "Secret", name = "Schema"})
    Ptr (GHashTable (Ptr ()) (Ptr ())) ->   -- attributes : TGHash (TBasicType TPtr) (TBasicType TPtr)
    Ptr (Ptr GError) ->                     -- error
    IO CInt

-- | Check if attributes are valid according to the provided schema.
-- 
-- Verifies schema name if available, attribute names and parsing
-- of attribute values.
attributesValidate ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Secret.Schema.Schema
    -- ^ /@schema@/: the schema for the attributes
    -> Map.Map (Ptr ()) (Ptr ())
    -- ^ /@attributes@/: the attributes to be validated
    -> m ()
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
attributesValidate :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Schema -> Map (Ptr ()) (Ptr ()) -> m ()
attributesValidate Schema
schema Map (Ptr ()) (Ptr ())
attributes = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    schema' <- Schema -> IO (Ptr Schema)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Schema
schema
    let attributes' = Map (Ptr ()) (Ptr ()) -> [(Ptr (), Ptr ())]
forall k a. Map k a -> [(k, a)]
Map.toList Map (Ptr ()) (Ptr ())
attributes
    let attributes'' = (Ptr () -> PtrWrapped (Ptr ()))
-> [(Ptr (), Ptr ())] -> [(PtrWrapped (Ptr ()), Ptr ())]
forall a c b. (a -> c) -> [(a, b)] -> [(c, b)]
mapFirst Ptr () -> PtrWrapped (Ptr ())
forall a. Ptr a -> PtrWrapped (Ptr a)
B.GHT.ptrPackPtr [(Ptr (), Ptr ())]
attributes'
    let attributes''' = (Ptr () -> PtrWrapped (Ptr ()))
-> [(PtrWrapped (Ptr ()), Ptr ())]
-> [(PtrWrapped (Ptr ()), PtrWrapped (Ptr ()))]
forall b c a. (b -> c) -> [(a, b)] -> [(a, c)]
mapSecond Ptr () -> PtrWrapped (Ptr ())
forall a. Ptr a -> PtrWrapped (Ptr a)
B.GHT.ptrPackPtr [(PtrWrapped (Ptr ()), Ptr ())]
attributes''
    attributes'''' <- packGHashTable gDirectHash gDirectEqual Nothing Nothing attributes'''
    onException (do
        _ <- propagateGError $ secret_attributes_validate schema' attributes''''
        touchManagedPtr schema
        unrefGHashTable attributes''''
        return ()
     ) (do
        unrefGHashTable attributes''''
     )