-- | 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


-- ** 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 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

-- 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
--           , 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
    Ptr CChar
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
nullPtr
        Just Text
jPassword -> do
            Ptr CChar
jPassword' <- Text -> IO (Ptr CChar)
textToCString Text
jPassword
            Ptr CChar -> IO (Ptr CChar)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
jPassword'
    Ptr CChar -> IO ()
secret_password_wipe Ptr CChar
maybePassword
    Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
maybePassword
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
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
--           , 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
--           , 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
--           , 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
--           , 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
--           , 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
--           , 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
    Ptr Schema
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
nullPtr
        Just Schema
jSchema -> do
            Ptr Schema
jSchema' <- Schema -> IO (Ptr Schema)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Schema
jSchema
            Ptr Schema -> IO (Ptr Schema)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Schema
jSchema'
    let attributes' :: [(Text, Text)]
attributes' = Map Text Text -> [(Text, Text)]
forall k a. Map k a -> [(k, a)]
Map.toList Map Text Text
attributes
    [(Ptr CChar, Text)]
attributes'' <- (Text -> IO (Ptr CChar))
-> [(Text, Text)] -> IO [(Ptr CChar, Text)]
forall (f :: * -> *) a c b.
Applicative f =>
(a -> f c) -> [(a, b)] -> f [(c, b)]
mapFirstA Text -> IO (Ptr CChar)
textToCString [(Text, Text)]
attributes'
    [(Ptr CChar, Ptr CChar)]
attributes''' <- (Text -> IO (Ptr CChar))
-> [(Ptr CChar, Text)] -> IO [(Ptr CChar, Ptr CChar)]
forall (f :: * -> *) b c a.
Applicative f =>
(b -> f c) -> [(a, b)] -> f [(a, c)]
mapSecondA Text -> IO (Ptr CChar)
textToCString [(Ptr CChar, Text)]
attributes''
    let attributes'''' :: [(PtrWrapped (Ptr CChar), Ptr CChar)]
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''''' :: [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
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''''
    Ptr (GHashTable (Ptr CChar) (Ptr CChar))
attributes'''''' <- GHashFunc (Ptr CChar)
-> GEqualFunc (Ptr CChar)
-> Maybe (GDestroyNotify (Ptr CChar))
-> Maybe (GDestroyNotify (Ptr CChar))
-> [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
-> IO (Ptr (GHashTable (Ptr CChar) (Ptr CChar)))
forall a b.
GHashFunc a
-> GEqualFunc a
-> Maybe (GDestroyNotify a)
-> Maybe (GDestroyNotify b)
-> [(PtrWrapped a, PtrWrapped b)]
-> IO (Ptr (GHashTable a b))
packGHashTable GHashFunc (Ptr CChar)
gStrHash GEqualFunc (Ptr CChar)
gStrEqual (GDestroyNotify (Ptr CChar) -> Maybe (GDestroyNotify (Ptr CChar))
forall a. a -> Maybe a
Just GDestroyNotify (Ptr CChar)
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free) (GDestroyNotify (Ptr CChar) -> Maybe (GDestroyNotify (Ptr CChar))
forall a. a -> Maybe a
Just GDestroyNotify (Ptr CChar)
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free) [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
attributes'''''
    Ptr CChar
maybeCollection <- case Maybe Text
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
nullPtr
        Just Text
jCollection -> do
            Ptr CChar
jCollection' <- Text -> IO (Ptr CChar)
textToCString Text
jCollection
            Ptr CChar -> IO (Ptr CChar)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
jCollection'
    Ptr CChar
label' <- Text -> IO (Ptr CChar)
textToCString Text
label
    Ptr CChar
password' <- Text -> IO (Ptr CChar)
textToCString Text
password
    Ptr Cancellable
maybeCancellable <- case Maybe a
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
nullPtr
        Just a
jCancellable -> do
            Ptr Cancellable
jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Schema
-> Ptr (GHashTable (Ptr CChar) (Ptr CChar))
-> Ptr CChar
-> Ptr CChar
-> Ptr CChar
-> Ptr Cancellable
-> Ptr (Ptr GError)
-> IO CInt
secret_password_storev_sync Ptr Schema
maybeSchema Ptr (GHashTable (Ptr CChar) (Ptr CChar))
attributes'''''' Ptr CChar
maybeCollection Ptr CChar
label' Ptr CChar
password' Ptr Cancellable
maybeCancellable
        Maybe Schema -> (Schema -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe Schema
schema Schema -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        Maybe a -> (a -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe a
cancellable a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        Ptr (GHashTable (Ptr CChar) (Ptr CChar)) -> IO ()
forall a b. Ptr (GHashTable a b) -> IO ()
unrefGHashTable Ptr (GHashTable (Ptr CChar) (Ptr CChar))
attributes''''''
        Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
maybeCollection
        Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
label'
        Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
password'
        () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        Ptr (GHashTable (Ptr CChar) (Ptr CChar)) -> IO ()
forall a b. Ptr (GHashTable a b) -> IO ()
unrefGHashTable Ptr (GHashTable (Ptr CChar) (Ptr CChar))
attributes''''''
        Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
maybeCollection
        Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
label'
        Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
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
--           , 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
    Ptr AsyncResult
result_' <- a -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
result_
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr AsyncResult -> Ptr (Ptr GError) -> IO CInt
secret_password_store_finish Ptr AsyncResult
result_'
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
result_
        () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
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
--           , 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
--           , 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
--           , 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
--           , 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
--           , 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
--           , 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
    Ptr Schema
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
nullPtr
        Just Schema
jSchema -> do
            Ptr Schema
jSchema' <- Schema -> IO (Ptr Schema)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Schema
jSchema
            Ptr Schema -> IO (Ptr Schema)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Schema
jSchema'
    let attributes' :: [(Text, Text)]
attributes' = Map Text Text -> [(Text, Text)]
forall k a. Map k a -> [(k, a)]
Map.toList Map Text Text
attributes
    [(Ptr CChar, Text)]
attributes'' <- (Text -> IO (Ptr CChar))
-> [(Text, Text)] -> IO [(Ptr CChar, Text)]
forall (f :: * -> *) a c b.
Applicative f =>
(a -> f c) -> [(a, b)] -> f [(c, b)]
mapFirstA Text -> IO (Ptr CChar)
textToCString [(Text, Text)]
attributes'
    [(Ptr CChar, Ptr CChar)]
attributes''' <- (Text -> IO (Ptr CChar))
-> [(Ptr CChar, Text)] -> IO [(Ptr CChar, Ptr CChar)]
forall (f :: * -> *) b c a.
Applicative f =>
(b -> f c) -> [(a, b)] -> f [(a, c)]
mapSecondA Text -> IO (Ptr CChar)
textToCString [(Ptr CChar, Text)]
attributes''
    let attributes'''' :: [(PtrWrapped (Ptr CChar), Ptr CChar)]
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''''' :: [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
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''''
    Ptr (GHashTable (Ptr CChar) (Ptr CChar))
attributes'''''' <- GHashFunc (Ptr CChar)
-> GEqualFunc (Ptr CChar)
-> Maybe (GDestroyNotify (Ptr CChar))
-> Maybe (GDestroyNotify (Ptr CChar))
-> [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
-> IO (Ptr (GHashTable (Ptr CChar) (Ptr CChar)))
forall a b.
GHashFunc a
-> GEqualFunc a
-> Maybe (GDestroyNotify a)
-> Maybe (GDestroyNotify b)
-> [(PtrWrapped a, PtrWrapped b)]
-> IO (Ptr (GHashTable a b))
packGHashTable GHashFunc (Ptr CChar)
gStrHash GEqualFunc (Ptr CChar)
gStrEqual (GDestroyNotify (Ptr CChar) -> Maybe (GDestroyNotify (Ptr CChar))
forall a. a -> Maybe a
Just GDestroyNotify (Ptr CChar)
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free) (GDestroyNotify (Ptr CChar) -> Maybe (GDestroyNotify (Ptr CChar))
forall a. a -> Maybe a
Just GDestroyNotify (Ptr CChar)
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free) [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
attributes'''''
    Ptr CChar
maybeCollection <- case Maybe Text
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
nullPtr
        Just Text
jCollection -> do
            Ptr CChar
jCollection' <- Text -> IO (Ptr CChar)
textToCString Text
jCollection
            Ptr CChar -> IO (Ptr CChar)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
jCollection'
    Ptr CChar
label' <- Text -> IO (Ptr CChar)
textToCString Text
label
    Ptr Value
value' <- Value -> IO (Ptr Value)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Value
value
    Ptr Cancellable
maybeCancellable <- case Maybe a
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
nullPtr
        Just a
jCancellable -> do
            Ptr Cancellable
jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Schema
-> Ptr (GHashTable (Ptr CChar) (Ptr CChar))
-> Ptr CChar
-> Ptr CChar
-> Ptr Value
-> Ptr Cancellable
-> Ptr (Ptr GError)
-> IO CInt
secret_password_storev_binary_sync Ptr Schema
maybeSchema Ptr (GHashTable (Ptr CChar) (Ptr CChar))
attributes'''''' Ptr CChar
maybeCollection Ptr CChar
label' Ptr Value
value' Ptr Cancellable
maybeCancellable
        Maybe Schema -> (Schema -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe Schema
schema Schema -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        Value -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Value
value
        Maybe a -> (a -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe a
cancellable a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        Ptr (GHashTable (Ptr CChar) (Ptr CChar)) -> IO ()
forall a b. Ptr (GHashTable a b) -> IO ()
unrefGHashTable Ptr (GHashTable (Ptr CChar) (Ptr CChar))
attributes''''''
        Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
maybeCollection
        Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
label'
        () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        Ptr (GHashTable (Ptr CChar) (Ptr CChar)) -> IO ()
forall a b. Ptr (GHashTable a b) -> IO ()
unrefGHashTable Ptr (GHashTable (Ptr CChar) (Ptr CChar))
attributes''''''
        Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
maybeCollection
        Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
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
--           , 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
--           , 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
--           , 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
--           , 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
--           , 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
--           , 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
--           , 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
--           , 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
    Ptr Schema
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
nullPtr
        Just Schema
jSchema -> do
            Ptr Schema
jSchema' <- Schema -> IO (Ptr Schema)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Schema
jSchema
            Ptr Schema -> IO (Ptr Schema)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Schema
jSchema'
    let attributes' :: [(Text, Text)]
attributes' = Map Text Text -> [(Text, Text)]
forall k a. Map k a -> [(k, a)]
Map.toList Map Text Text
attributes
    [(Ptr CChar, Text)]
attributes'' <- (Text -> IO (Ptr CChar))
-> [(Text, Text)] -> IO [(Ptr CChar, Text)]
forall (f :: * -> *) a c b.
Applicative f =>
(a -> f c) -> [(a, b)] -> f [(c, b)]
mapFirstA Text -> IO (Ptr CChar)
textToCString [(Text, Text)]
attributes'
    [(Ptr CChar, Ptr CChar)]
attributes''' <- (Text -> IO (Ptr CChar))
-> [(Ptr CChar, Text)] -> IO [(Ptr CChar, Ptr CChar)]
forall (f :: * -> *) b c a.
Applicative f =>
(b -> f c) -> [(a, b)] -> f [(a, c)]
mapSecondA Text -> IO (Ptr CChar)
textToCString [(Ptr CChar, Text)]
attributes''
    let attributes'''' :: [(PtrWrapped (Ptr CChar), Ptr CChar)]
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''''' :: [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
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''''
    Ptr (GHashTable (Ptr CChar) (Ptr CChar))
attributes'''''' <- GHashFunc (Ptr CChar)
-> GEqualFunc (Ptr CChar)
-> Maybe (GDestroyNotify (Ptr CChar))
-> Maybe (GDestroyNotify (Ptr CChar))
-> [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
-> IO (Ptr (GHashTable (Ptr CChar) (Ptr CChar)))
forall a b.
GHashFunc a
-> GEqualFunc a
-> Maybe (GDestroyNotify a)
-> Maybe (GDestroyNotify b)
-> [(PtrWrapped a, PtrWrapped b)]
-> IO (Ptr (GHashTable a b))
packGHashTable GHashFunc (Ptr CChar)
gStrHash GEqualFunc (Ptr CChar)
gStrEqual (GDestroyNotify (Ptr CChar) -> Maybe (GDestroyNotify (Ptr CChar))
forall a. a -> Maybe a
Just GDestroyNotify (Ptr CChar)
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free) (GDestroyNotify (Ptr CChar) -> Maybe (GDestroyNotify (Ptr CChar))
forall a. a -> Maybe a
Just GDestroyNotify (Ptr CChar)
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free) [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
attributes'''''
    Ptr CChar
maybeCollection <- case Maybe Text
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
nullPtr
        Just Text
jCollection -> do
            Ptr CChar
jCollection' <- Text -> IO (Ptr CChar)
textToCString Text
jCollection
            Ptr CChar -> IO (Ptr CChar)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
jCollection'
    Ptr CChar
label' <- Text -> IO (Ptr CChar)
textToCString Text
label
    Ptr Value
value' <- Value -> IO (Ptr Value)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Value
value
    Ptr Cancellable
maybeCancellable <- case Maybe a
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
nullPtr
        Just a
jCancellable -> do
            Ptr Cancellable
jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
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 (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just AsyncReadyCallback
jCallback -> do
            Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) AsyncReadyCallback
jCallback)
            Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
            FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr Schema
-> Ptr (GHashTable (Ptr CChar) (Ptr CChar))
-> Ptr CChar
-> Ptr CChar
-> Ptr Value
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> IO ()
secret_password_storev_binary Ptr Schema
maybeSchema Ptr (GHashTable (Ptr CChar) (Ptr CChar))
attributes'''''' Ptr CChar
maybeCollection Ptr CChar
label' Ptr Value
value' Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
    Maybe Schema -> (Schema -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe Schema
schema Schema -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    Value -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Value
value
    Maybe a -> (a -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe a
cancellable a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
maybeCollection
    Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
label'
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
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
--           , 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
--           , 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
--           , 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
--           , 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
--           , 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
--           , 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
--           , 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
--           , 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
    Ptr Schema
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
nullPtr
        Just Schema
jSchema -> do
            Ptr Schema
jSchema' <- Schema -> IO (Ptr Schema)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Schema
jSchema
            Ptr Schema -> IO (Ptr Schema)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Schema
jSchema'
    let attributes' :: [(Text, Text)]
attributes' = Map Text Text -> [(Text, Text)]
forall k a. Map k a -> [(k, a)]
Map.toList Map Text Text
attributes
    [(Ptr CChar, Text)]
attributes'' <- (Text -> IO (Ptr CChar))
-> [(Text, Text)] -> IO [(Ptr CChar, Text)]
forall (f :: * -> *) a c b.
Applicative f =>
(a -> f c) -> [(a, b)] -> f [(c, b)]
mapFirstA Text -> IO (Ptr CChar)
textToCString [(Text, Text)]
attributes'
    [(Ptr CChar, Ptr CChar)]
attributes''' <- (Text -> IO (Ptr CChar))
-> [(Ptr CChar, Text)] -> IO [(Ptr CChar, Ptr CChar)]
forall (f :: * -> *) b c a.
Applicative f =>
(b -> f c) -> [(a, b)] -> f [(a, c)]
mapSecondA Text -> IO (Ptr CChar)
textToCString [(Ptr CChar, Text)]
attributes''
    let attributes'''' :: [(PtrWrapped (Ptr CChar), Ptr CChar)]
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''''' :: [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
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''''
    Ptr (GHashTable (Ptr CChar) (Ptr CChar))
attributes'''''' <- GHashFunc (Ptr CChar)
-> GEqualFunc (Ptr CChar)
-> Maybe (GDestroyNotify (Ptr CChar))
-> Maybe (GDestroyNotify (Ptr CChar))
-> [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
-> IO (Ptr (GHashTable (Ptr CChar) (Ptr CChar)))
forall a b.
GHashFunc a
-> GEqualFunc a
-> Maybe (GDestroyNotify a)
-> Maybe (GDestroyNotify b)
-> [(PtrWrapped a, PtrWrapped b)]
-> IO (Ptr (GHashTable a b))
packGHashTable GHashFunc (Ptr CChar)
gStrHash GEqualFunc (Ptr CChar)
gStrEqual (GDestroyNotify (Ptr CChar) -> Maybe (GDestroyNotify (Ptr CChar))
forall a. a -> Maybe a
Just GDestroyNotify (Ptr CChar)
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free) (GDestroyNotify (Ptr CChar) -> Maybe (GDestroyNotify (Ptr CChar))
forall a. a -> Maybe a
Just GDestroyNotify (Ptr CChar)
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free) [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
attributes'''''
    Ptr CChar
maybeCollection <- case Maybe Text
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
nullPtr
        Just Text
jCollection -> do
            Ptr CChar
jCollection' <- Text -> IO (Ptr CChar)
textToCString Text
jCollection
            Ptr CChar -> IO (Ptr CChar)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
jCollection'
    Ptr CChar
label' <- Text -> IO (Ptr CChar)
textToCString Text
label
    Ptr CChar
password' <- Text -> IO (Ptr CChar)
textToCString Text
password
    Ptr Cancellable
maybeCancellable <- case Maybe a
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
nullPtr
        Just a
jCancellable -> do
            Ptr Cancellable
jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
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 (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just AsyncReadyCallback
jCallback -> do
            Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) AsyncReadyCallback
jCallback)
            Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
            FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr Schema
-> Ptr (GHashTable (Ptr CChar) (Ptr CChar))
-> Ptr CChar
-> Ptr CChar
-> Ptr CChar
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> IO ()
secret_password_storev Ptr Schema
maybeSchema Ptr (GHashTable (Ptr CChar) (Ptr CChar))
attributes'''''' Ptr CChar
maybeCollection Ptr CChar
label' Ptr CChar
password' Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
    Maybe Schema -> (Schema -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe Schema
schema Schema -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    Maybe a -> (a -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe a
cancellable a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
maybeCollection
    Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
label'
    Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
password'
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
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
--           , 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
--           , 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
--           , 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
--           , 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
    Ptr Schema
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
nullPtr
        Just Schema
jSchema -> do
            Ptr Schema
jSchema' <- Schema -> IO (Ptr Schema)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Schema
jSchema
            Ptr Schema -> IO (Ptr Schema)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Schema
jSchema'
    let attributes' :: [(Text, Text)]
attributes' = Map Text Text -> [(Text, Text)]
forall k a. Map k a -> [(k, a)]
Map.toList Map Text Text
attributes
    [(Ptr CChar, Text)]
attributes'' <- (Text -> IO (Ptr CChar))
-> [(Text, Text)] -> IO [(Ptr CChar, Text)]
forall (f :: * -> *) a c b.
Applicative f =>
(a -> f c) -> [(a, b)] -> f [(c, b)]
mapFirstA Text -> IO (Ptr CChar)
textToCString [(Text, Text)]
attributes'
    [(Ptr CChar, Ptr CChar)]
attributes''' <- (Text -> IO (Ptr CChar))
-> [(Ptr CChar, Text)] -> IO [(Ptr CChar, Ptr CChar)]
forall (f :: * -> *) b c a.
Applicative f =>
(b -> f c) -> [(a, b)] -> f [(a, c)]
mapSecondA Text -> IO (Ptr CChar)
textToCString [(Ptr CChar, Text)]
attributes''
    let attributes'''' :: [(PtrWrapped (Ptr CChar), Ptr CChar)]
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''''' :: [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
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''''
    Ptr (GHashTable (Ptr CChar) (Ptr CChar))
attributes'''''' <- GHashFunc (Ptr CChar)
-> GEqualFunc (Ptr CChar)
-> Maybe (GDestroyNotify (Ptr CChar))
-> Maybe (GDestroyNotify (Ptr CChar))
-> [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
-> IO (Ptr (GHashTable (Ptr CChar) (Ptr CChar)))
forall a b.
GHashFunc a
-> GEqualFunc a
-> Maybe (GDestroyNotify a)
-> Maybe (GDestroyNotify b)
-> [(PtrWrapped a, PtrWrapped b)]
-> IO (Ptr (GHashTable a b))
packGHashTable GHashFunc (Ptr CChar)
gStrHash GEqualFunc (Ptr CChar)
gStrEqual (GDestroyNotify (Ptr CChar) -> Maybe (GDestroyNotify (Ptr CChar))
forall a. a -> Maybe a
Just GDestroyNotify (Ptr CChar)
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free) (GDestroyNotify (Ptr CChar) -> Maybe (GDestroyNotify (Ptr CChar))
forall a. a -> Maybe a
Just GDestroyNotify (Ptr CChar)
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free) [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
attributes'''''
    let flags' :: CUInt
flags' = [SearchFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [SearchFlags]
flags
    Ptr Cancellable
maybeCancellable <- case Maybe a
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
nullPtr
        Just a
jCancellable -> do
            Ptr Cancellable
jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    IO [Retrievable] -> IO () -> IO [Retrievable]
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr (GList (Ptr Retrievable))
result <- (Ptr (Ptr GError) -> IO (Ptr (GList (Ptr Retrievable))))
-> IO (Ptr (GList (Ptr Retrievable)))
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr (GList (Ptr Retrievable))))
 -> IO (Ptr (GList (Ptr Retrievable))))
-> (Ptr (Ptr GError) -> IO (Ptr (GList (Ptr Retrievable))))
-> IO (Ptr (GList (Ptr Retrievable)))
forall a b. (a -> b) -> a -> b
$ Ptr Schema
-> Ptr (GHashTable (Ptr CChar) (Ptr CChar))
-> CUInt
-> Ptr Cancellable
-> Ptr (Ptr GError)
-> IO (Ptr (GList (Ptr Retrievable)))
secret_password_searchv_sync Ptr Schema
maybeSchema Ptr (GHashTable (Ptr CChar) (Ptr CChar))
attributes'''''' CUInt
flags' Ptr Cancellable
maybeCancellable
        [Ptr Retrievable]
result' <- Ptr (GList (Ptr Retrievable)) -> IO [Ptr Retrievable]
forall a. Ptr (GList (Ptr a)) -> IO [Ptr a]
unpackGList Ptr (GList (Ptr Retrievable))
result
        [Retrievable]
result'' <- (Ptr Retrievable -> IO Retrievable)
-> [Ptr Retrievable] -> IO [Retrievable]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ((ManagedPtr Retrievable -> Retrievable)
-> Ptr Retrievable -> IO Retrievable
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Retrievable -> Retrievable
Secret.Retrievable.Retrievable) [Ptr Retrievable]
result'
        Ptr (GList (Ptr Retrievable)) -> IO ()
forall a. Ptr (GList a) -> IO ()
g_list_free Ptr (GList (Ptr Retrievable))
result
        Maybe Schema -> (Schema -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe Schema
schema Schema -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        Maybe a -> (a -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe a
cancellable a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        Ptr (GHashTable (Ptr CChar) (Ptr CChar)) -> IO ()
forall a b. Ptr (GHashTable a b) -> IO ()
unrefGHashTable Ptr (GHashTable (Ptr CChar) (Ptr CChar))
attributes''''''
        [Retrievable] -> IO [Retrievable]
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return [Retrievable]
result''
     ) (do
        Ptr (GHashTable (Ptr CChar) (Ptr CChar)) -> IO ()
forall a b. Ptr (GHashTable a b) -> IO ()
unrefGHashTable Ptr (GHashTable (Ptr CChar) (Ptr CChar))
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
--           , 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
    Ptr AsyncResult
result_' <- a -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
result_
    IO [Retrievable] -> IO () -> IO [Retrievable]
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr (GList (Ptr Retrievable))
result <- (Ptr (Ptr GError) -> IO (Ptr (GList (Ptr Retrievable))))
-> IO (Ptr (GList (Ptr Retrievable)))
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr (GList (Ptr Retrievable))))
 -> IO (Ptr (GList (Ptr Retrievable))))
-> (Ptr (Ptr GError) -> IO (Ptr (GList (Ptr Retrievable))))
-> IO (Ptr (GList (Ptr Retrievable)))
forall a b. (a -> b) -> a -> b
$ Ptr AsyncResult
-> Ptr (Ptr GError) -> IO (Ptr (GList (Ptr Retrievable)))
secret_password_search_finish Ptr AsyncResult
result_'
        [Ptr Retrievable]
result' <- Ptr (GList (Ptr Retrievable)) -> IO [Ptr Retrievable]
forall a. Ptr (GList (Ptr a)) -> IO [Ptr a]
unpackGList Ptr (GList (Ptr Retrievable))
result
        [Retrievable]
result'' <- (Ptr Retrievable -> IO Retrievable)
-> [Ptr Retrievable] -> IO [Retrievable]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ((ManagedPtr Retrievable -> Retrievable)
-> Ptr Retrievable -> IO Retrievable
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Retrievable -> Retrievable
Secret.Retrievable.Retrievable) [Ptr Retrievable]
result'
        Ptr (GList (Ptr Retrievable)) -> IO ()
forall a. Ptr (GList a) -> IO ()
g_list_free Ptr (GList (Ptr Retrievable))
result
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
result_
        [Retrievable] -> IO [Retrievable]
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return [Retrievable]
result''
     ) (do
        () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
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
--           , 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
--           , 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
--           , 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
--           , 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
--           , 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
--           , 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
    Ptr Schema
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
nullPtr
        Just Schema
jSchema -> do
            Ptr Schema
jSchema' <- Schema -> IO (Ptr Schema)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Schema
jSchema
            Ptr Schema -> IO (Ptr Schema)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Schema
jSchema'
    let attributes' :: [(Text, Text)]
attributes' = Map Text Text -> [(Text, Text)]
forall k a. Map k a -> [(k, a)]
Map.toList Map Text Text
attributes
    [(Ptr CChar, Text)]
attributes'' <- (Text -> IO (Ptr CChar))
-> [(Text, Text)] -> IO [(Ptr CChar, Text)]
forall (f :: * -> *) a c b.
Applicative f =>
(a -> f c) -> [(a, b)] -> f [(c, b)]
mapFirstA Text -> IO (Ptr CChar)
textToCString [(Text, Text)]
attributes'
    [(Ptr CChar, Ptr CChar)]
attributes''' <- (Text -> IO (Ptr CChar))
-> [(Ptr CChar, Text)] -> IO [(Ptr CChar, Ptr CChar)]
forall (f :: * -> *) b c a.
Applicative f =>
(b -> f c) -> [(a, b)] -> f [(a, c)]
mapSecondA Text -> IO (Ptr CChar)
textToCString [(Ptr CChar, Text)]
attributes''
    let attributes'''' :: [(PtrWrapped (Ptr CChar), Ptr CChar)]
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''''' :: [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
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''''
    Ptr (GHashTable (Ptr CChar) (Ptr CChar))
attributes'''''' <- GHashFunc (Ptr CChar)
-> GEqualFunc (Ptr CChar)
-> Maybe (GDestroyNotify (Ptr CChar))
-> Maybe (GDestroyNotify (Ptr CChar))
-> [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
-> IO (Ptr (GHashTable (Ptr CChar) (Ptr CChar)))
forall a b.
GHashFunc a
-> GEqualFunc a
-> Maybe (GDestroyNotify a)
-> Maybe (GDestroyNotify b)
-> [(PtrWrapped a, PtrWrapped b)]
-> IO (Ptr (GHashTable a b))
packGHashTable GHashFunc (Ptr CChar)
gStrHash GEqualFunc (Ptr CChar)
gStrEqual (GDestroyNotify (Ptr CChar) -> Maybe (GDestroyNotify (Ptr CChar))
forall a. a -> Maybe a
Just GDestroyNotify (Ptr CChar)
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free) (GDestroyNotify (Ptr CChar) -> Maybe (GDestroyNotify (Ptr CChar))
forall a. a -> Maybe a
Just GDestroyNotify (Ptr CChar)
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free) [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
attributes'''''
    let flags' :: CUInt
flags' = [SearchFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [SearchFlags]
flags
    Ptr Cancellable
maybeCancellable <- case Maybe a
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
nullPtr
        Just a
jCancellable -> do
            Ptr Cancellable
jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
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 (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just AsyncReadyCallback
jCallback -> do
            Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) AsyncReadyCallback
jCallback)
            Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
            FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr Schema
-> Ptr (GHashTable (Ptr CChar) (Ptr CChar))
-> CUInt
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> IO ()
secret_password_searchv Ptr Schema
maybeSchema Ptr (GHashTable (Ptr CChar) (Ptr CChar))
attributes'''''' CUInt
flags' Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
    Maybe Schema -> (Schema -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe Schema
schema Schema -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    Maybe a -> (a -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe a
cancellable a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
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
--           , 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
--           , 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
--           , 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 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 Text
passwordLookupSync Maybe Schema
schema Map Text Text
attributes Maybe a
cancellable = 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
    Ptr Schema
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
nullPtr
        Just Schema
jSchema -> do
            Ptr Schema
jSchema' <- Schema -> IO (Ptr Schema)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Schema
jSchema
            Ptr Schema -> IO (Ptr Schema)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Schema
jSchema'
    let attributes' :: [(Text, Text)]
attributes' = Map Text Text -> [(Text, Text)]
forall k a. Map k a -> [(k, a)]
Map.toList Map Text Text
attributes
    [(Ptr CChar, Text)]
attributes'' <- (Text -> IO (Ptr CChar))
-> [(Text, Text)] -> IO [(Ptr CChar, Text)]
forall (f :: * -> *) a c b.
Applicative f =>
(a -> f c) -> [(a, b)] -> f [(c, b)]
mapFirstA Text -> IO (Ptr CChar)
textToCString [(Text, Text)]
attributes'
    [(Ptr CChar, Ptr CChar)]
attributes''' <- (Text -> IO (Ptr CChar))
-> [(Ptr CChar, Text)] -> IO [(Ptr CChar, Ptr CChar)]
forall (f :: * -> *) b c a.
Applicative f =>
(b -> f c) -> [(a, b)] -> f [(a, c)]
mapSecondA Text -> IO (Ptr CChar)
textToCString [(Ptr CChar, Text)]
attributes''
    let attributes'''' :: [(PtrWrapped (Ptr CChar), Ptr CChar)]
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''''' :: [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
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''''
    Ptr (GHashTable (Ptr CChar) (Ptr CChar))
attributes'''''' <- GHashFunc (Ptr CChar)
-> GEqualFunc (Ptr CChar)
-> Maybe (GDestroyNotify (Ptr CChar))
-> Maybe (GDestroyNotify (Ptr CChar))
-> [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
-> IO (Ptr (GHashTable (Ptr CChar) (Ptr CChar)))
forall a b.
GHashFunc a
-> GEqualFunc a
-> Maybe (GDestroyNotify a)
-> Maybe (GDestroyNotify b)
-> [(PtrWrapped a, PtrWrapped b)]
-> IO (Ptr (GHashTable a b))
packGHashTable GHashFunc (Ptr CChar)
gStrHash GEqualFunc (Ptr CChar)
gStrEqual (GDestroyNotify (Ptr CChar) -> Maybe (GDestroyNotify (Ptr CChar))
forall a. a -> Maybe a
Just GDestroyNotify (Ptr CChar)
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free) (GDestroyNotify (Ptr CChar) -> Maybe (GDestroyNotify (Ptr CChar))
forall a. a -> Maybe a
Just GDestroyNotify (Ptr CChar)
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free) [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
attributes'''''
    Ptr Cancellable
maybeCancellable <- case Maybe a
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
nullPtr
        Just a
jCancellable -> do
            Ptr Cancellable
jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    IO Text -> IO () -> IO Text
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr CChar
result <- (Ptr (Ptr GError) -> IO (Ptr CChar)) -> IO (Ptr CChar)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr CChar)) -> IO (Ptr CChar))
-> (Ptr (Ptr GError) -> IO (Ptr CChar)) -> IO (Ptr CChar)
forall a b. (a -> b) -> a -> b
$ Ptr Schema
-> Ptr (GHashTable (Ptr CChar) (Ptr CChar))
-> Ptr Cancellable
-> Ptr (Ptr GError)
-> IO (Ptr CChar)
secret_password_lookupv_sync Ptr Schema
maybeSchema Ptr (GHashTable (Ptr CChar) (Ptr CChar))
attributes'''''' Ptr Cancellable
maybeCancellable
        Text -> Ptr CChar -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"passwordLookupSync" Ptr CChar
result
        Text
result' <- HasCallStack => Ptr CChar -> IO Text
Ptr CChar -> IO Text
cstringToText Ptr CChar
result
        Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
result
        Maybe Schema -> (Schema -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe Schema
schema Schema -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        Maybe a -> (a -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe a
cancellable a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        Ptr (GHashTable (Ptr CChar) (Ptr CChar)) -> IO ()
forall a b. Ptr (GHashTable a b) -> IO ()
unrefGHashTable Ptr (GHashTable (Ptr CChar) (Ptr CChar))
attributes''''''
        Text -> IO Text
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
     ) (do
        Ptr (GHashTable (Ptr CChar) (Ptr CChar)) -> IO ()
forall a b. Ptr (GHashTable a b) -> IO ()
unrefGHashTable Ptr (GHashTable (Ptr CChar) (Ptr CChar))
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
--           , 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
    Ptr AsyncResult
result_' <- a -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
result_
    IO Text -> IO () -> IO Text
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr CChar
result <- (Ptr (Ptr GError) -> IO (Ptr CChar)) -> IO (Ptr CChar)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr CChar)) -> IO (Ptr CChar))
-> (Ptr (Ptr GError) -> IO (Ptr CChar)) -> IO (Ptr CChar)
forall a b. (a -> b) -> a -> b
$ Ptr AsyncResult -> Ptr (Ptr GError) -> IO (Ptr CChar)
secret_password_lookup_finish Ptr AsyncResult
result_'
        Text -> Ptr CChar -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"passwordLookupFinish" Ptr CChar
result
        Text
result' <- HasCallStack => Ptr CChar -> IO Text
Ptr CChar -> IO Text
cstringToText Ptr CChar
result
        Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
result
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
result_
        Text -> IO Text
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
     ) (do
        () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
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
--           , 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
--           , 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
--           , 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
--           , 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
--           , 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
    Ptr Schema
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
nullPtr
        Just Schema
jSchema -> do
            Ptr Schema
jSchema' <- Schema -> IO (Ptr Schema)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Schema
jSchema
            Ptr Schema -> IO (Ptr Schema)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Schema
jSchema'
    let attributes' :: [(Text, Text)]
attributes' = Map Text Text -> [(Text, Text)]
forall k a. Map k a -> [(k, a)]
Map.toList Map Text Text
attributes
    [(Ptr CChar, Text)]
attributes'' <- (Text -> IO (Ptr CChar))
-> [(Text, Text)] -> IO [(Ptr CChar, Text)]
forall (f :: * -> *) a c b.
Applicative f =>
(a -> f c) -> [(a, b)] -> f [(c, b)]
mapFirstA Text -> IO (Ptr CChar)
textToCString [(Text, Text)]
attributes'
    [(Ptr CChar, Ptr CChar)]
attributes''' <- (Text -> IO (Ptr CChar))
-> [(Ptr CChar, Text)] -> IO [(Ptr CChar, Ptr CChar)]
forall (f :: * -> *) b c a.
Applicative f =>
(b -> f c) -> [(a, b)] -> f [(a, c)]
mapSecondA Text -> IO (Ptr CChar)
textToCString [(Ptr CChar, Text)]
attributes''
    let attributes'''' :: [(PtrWrapped (Ptr CChar), Ptr CChar)]
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''''' :: [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
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''''
    Ptr (GHashTable (Ptr CChar) (Ptr CChar))
attributes'''''' <- GHashFunc (Ptr CChar)
-> GEqualFunc (Ptr CChar)
-> Maybe (GDestroyNotify (Ptr CChar))
-> Maybe (GDestroyNotify (Ptr CChar))
-> [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
-> IO (Ptr (GHashTable (Ptr CChar) (Ptr CChar)))
forall a b.
GHashFunc a
-> GEqualFunc a
-> Maybe (GDestroyNotify a)
-> Maybe (GDestroyNotify b)
-> [(PtrWrapped a, PtrWrapped b)]
-> IO (Ptr (GHashTable a b))
packGHashTable GHashFunc (Ptr CChar)
gStrHash GEqualFunc (Ptr CChar)
gStrEqual (GDestroyNotify (Ptr CChar) -> Maybe (GDestroyNotify (Ptr CChar))
forall a. a -> Maybe a
Just GDestroyNotify (Ptr CChar)
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free) (GDestroyNotify (Ptr CChar) -> Maybe (GDestroyNotify (Ptr CChar))
forall a. a -> Maybe a
Just GDestroyNotify (Ptr CChar)
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free) [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
attributes'''''
    Ptr Cancellable
maybeCancellable <- case Maybe a
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
nullPtr
        Just a
jCancellable -> do
            Ptr Cancellable
jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
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 (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just AsyncReadyCallback
jCallback -> do
            Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) AsyncReadyCallback
jCallback)
            Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
            FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr Schema
-> Ptr (GHashTable (Ptr CChar) (Ptr CChar))
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> IO ()
secret_password_lookupv Ptr Schema
maybeSchema Ptr (GHashTable (Ptr CChar) (Ptr CChar))
attributes'''''' Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
    Maybe Schema -> (Schema -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe Schema
schema Schema -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    Maybe a -> (a -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe a
cancellable a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
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
--           , 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
--           , 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
--           , 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
    Ptr Schema
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
nullPtr
        Just Schema
jSchema -> do
            Ptr Schema
jSchema' <- Schema -> IO (Ptr Schema)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Schema
jSchema
            Ptr Schema -> IO (Ptr Schema)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Schema
jSchema'
    let attributes' :: [(Text, Text)]
attributes' = Map Text Text -> [(Text, Text)]
forall k a. Map k a -> [(k, a)]
Map.toList Map Text Text
attributes
    [(Ptr CChar, Text)]
attributes'' <- (Text -> IO (Ptr CChar))
-> [(Text, Text)] -> IO [(Ptr CChar, Text)]
forall (f :: * -> *) a c b.
Applicative f =>
(a -> f c) -> [(a, b)] -> f [(c, b)]
mapFirstA Text -> IO (Ptr CChar)
textToCString [(Text, Text)]
attributes'
    [(Ptr CChar, Ptr CChar)]
attributes''' <- (Text -> IO (Ptr CChar))
-> [(Ptr CChar, Text)] -> IO [(Ptr CChar, Ptr CChar)]
forall (f :: * -> *) b c a.
Applicative f =>
(b -> f c) -> [(a, b)] -> f [(a, c)]
mapSecondA Text -> IO (Ptr CChar)
textToCString [(Ptr CChar, Text)]
attributes''
    let attributes'''' :: [(PtrWrapped (Ptr CChar), Ptr CChar)]
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''''' :: [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
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''''
    Ptr (GHashTable (Ptr CChar) (Ptr CChar))
attributes'''''' <- GHashFunc (Ptr CChar)
-> GEqualFunc (Ptr CChar)
-> Maybe (GDestroyNotify (Ptr CChar))
-> Maybe (GDestroyNotify (Ptr CChar))
-> [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
-> IO (Ptr (GHashTable (Ptr CChar) (Ptr CChar)))
forall a b.
GHashFunc a
-> GEqualFunc a
-> Maybe (GDestroyNotify a)
-> Maybe (GDestroyNotify b)
-> [(PtrWrapped a, PtrWrapped b)]
-> IO (Ptr (GHashTable a b))
packGHashTable GHashFunc (Ptr CChar)
gStrHash GEqualFunc (Ptr CChar)
gStrEqual (GDestroyNotify (Ptr CChar) -> Maybe (GDestroyNotify (Ptr CChar))
forall a. a -> Maybe a
Just GDestroyNotify (Ptr CChar)
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free) (GDestroyNotify (Ptr CChar) -> Maybe (GDestroyNotify (Ptr CChar))
forall a. a -> Maybe a
Just GDestroyNotify (Ptr CChar)
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free) [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
attributes'''''
    Ptr Cancellable
maybeCancellable <- case Maybe a
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
nullPtr
        Just a
jCancellable -> do
            Ptr Cancellable
jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Schema
-> Ptr (GHashTable (Ptr CChar) (Ptr CChar))
-> Ptr Cancellable
-> Ptr (Ptr GError)
-> IO CInt
secret_password_clearv_sync Ptr Schema
maybeSchema Ptr (GHashTable (Ptr CChar) (Ptr CChar))
attributes'''''' Ptr Cancellable
maybeCancellable
        Maybe Schema -> (Schema -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe Schema
schema Schema -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        Maybe a -> (a -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe a
cancellable a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        Ptr (GHashTable (Ptr CChar) (Ptr CChar)) -> IO ()
forall a b. Ptr (GHashTable a b) -> IO ()
unrefGHashTable Ptr (GHashTable (Ptr CChar) (Ptr CChar))
attributes''''''
        () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        Ptr (GHashTable (Ptr CChar) (Ptr CChar)) -> IO ()
forall a b. Ptr (GHashTable a b) -> IO ()
unrefGHashTable Ptr (GHashTable (Ptr CChar) (Ptr CChar))
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
--           , 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
    Ptr AsyncResult
result_' <- a -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
result_
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr AsyncResult -> Ptr (Ptr GError) -> IO CInt
secret_password_clear_finish Ptr AsyncResult
result_'
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
result_
        () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
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
--           , 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
--           , 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
--           , 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
--           , 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
--           , 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
    Ptr Schema
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
nullPtr
        Just Schema
jSchema -> do
            Ptr Schema
jSchema' <- Schema -> IO (Ptr Schema)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Schema
jSchema
            Ptr Schema -> IO (Ptr Schema)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Schema
jSchema'
    let attributes' :: [(Text, Text)]
attributes' = Map Text Text -> [(Text, Text)]
forall k a. Map k a -> [(k, a)]
Map.toList Map Text Text
attributes
    [(Ptr CChar, Text)]
attributes'' <- (Text -> IO (Ptr CChar))
-> [(Text, Text)] -> IO [(Ptr CChar, Text)]
forall (f :: * -> *) a c b.
Applicative f =>
(a -> f c) -> [(a, b)] -> f [(c, b)]
mapFirstA Text -> IO (Ptr CChar)
textToCString [(Text, Text)]
attributes'
    [(Ptr CChar, Ptr CChar)]
attributes''' <- (Text -> IO (Ptr CChar))
-> [(Ptr CChar, Text)] -> IO [(Ptr CChar, Ptr CChar)]
forall (f :: * -> *) b c a.
Applicative f =>
(b -> f c) -> [(a, b)] -> f [(a, c)]
mapSecondA Text -> IO (Ptr CChar)
textToCString [(Ptr CChar, Text)]
attributes''
    let attributes'''' :: [(PtrWrapped (Ptr CChar), Ptr CChar)]
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''''' :: [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
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''''
    Ptr (GHashTable (Ptr CChar) (Ptr CChar))
attributes'''''' <- GHashFunc (Ptr CChar)
-> GEqualFunc (Ptr CChar)
-> Maybe (GDestroyNotify (Ptr CChar))
-> Maybe (GDestroyNotify (Ptr CChar))
-> [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
-> IO (Ptr (GHashTable (Ptr CChar) (Ptr CChar)))
forall a b.
GHashFunc a
-> GEqualFunc a
-> Maybe (GDestroyNotify a)
-> Maybe (GDestroyNotify b)
-> [(PtrWrapped a, PtrWrapped b)]
-> IO (Ptr (GHashTable a b))
packGHashTable GHashFunc (Ptr CChar)
gStrHash GEqualFunc (Ptr CChar)
gStrEqual (GDestroyNotify (Ptr CChar) -> Maybe (GDestroyNotify (Ptr CChar))
forall a. a -> Maybe a
Just GDestroyNotify (Ptr CChar)
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free) (GDestroyNotify (Ptr CChar) -> Maybe (GDestroyNotify (Ptr CChar))
forall a. a -> Maybe a
Just GDestroyNotify (Ptr CChar)
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free) [(PtrWrapped (Ptr CChar), PtrWrapped (Ptr CChar))]
attributes'''''
    Ptr Cancellable
maybeCancellable <- case Maybe a
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
nullPtr
        Just a
jCancellable -> do
            Ptr Cancellable
jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
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 (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just AsyncReadyCallback
jCallback -> do
            Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) AsyncReadyCallback
jCallback)
            Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
            FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr Schema
-> Ptr (GHashTable (Ptr CChar) (Ptr CChar))
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> IO ()
secret_password_clearv Ptr Schema
maybeSchema Ptr (GHashTable (Ptr CChar) (Ptr CChar))
attributes'''''' Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
    Maybe Schema -> (Schema -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe Schema
schema Schema -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    Maybe a -> (a -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe a
cancellable a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
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
--           , 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_
    Ptr Schema
result <- CUInt -> IO (Ptr Schema)
secret_get_schema CUInt
type_'
    Text -> Ptr Schema -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"getSchema" Ptr Schema
result
    Schema
result' <- ((ManagedPtr Schema -> Schema) -> Ptr Schema -> IO Schema
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr Schema -> Schema
Secret.Schema.Schema) Ptr Schema
result
    Schema -> IO Schema
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Schema
result'