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

module GI.Soup.Interfaces.PasswordManager
    ( 

-- * Exported types
    PasswordManager(..)                     ,
    noPasswordManager                       ,
    IsPasswordManager                       ,
    toPasswordManager                       ,


 -- * Methods
-- ** getPasswordsAsync #method:getPasswordsAsync#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    PasswordManagerGetPasswordsAsyncMethodInfo,
#endif
    passwordManagerGetPasswordsAsync        ,


-- ** getPasswordsSync #method:getPasswordsSync#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    PasswordManagerGetPasswordsSyncMethodInfo,
#endif
    passwordManagerGetPasswordsSync         ,




    ) where

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

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import qualified GI.GLib.Structs.MainContext as GLib.MainContext
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import qualified GI.Soup.Callbacks as Soup.Callbacks
import {-# SOURCE #-} qualified GI.Soup.Interfaces.SessionFeature as Soup.SessionFeature
import {-# SOURCE #-} qualified GI.Soup.Objects.Auth as Soup.Auth
import {-# SOURCE #-} qualified GI.Soup.Objects.Message as Soup.Message

-- interface PasswordManager 
newtype PasswordManager = PasswordManager (ManagedPtr PasswordManager)
noPasswordManager :: Maybe PasswordManager
noPasswordManager = Nothing

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
type instance O.SignalList PasswordManager = PasswordManagerSignalList
type PasswordManagerSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

foreign import ccall "soup_password_manager_get_type"
    c_soup_password_manager_get_type :: IO GType

instance GObject PasswordManager where
    gobjectType _ = c_soup_password_manager_get_type
    

class GObject o => IsPasswordManager o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError PasswordManager a) =>
    IsPasswordManager a
#endif
instance IsPasswordManager PasswordManager
instance Soup.SessionFeature.IsSessionFeature PasswordManager
instance GObject.Object.IsObject PasswordManager

toPasswordManager :: (MonadIO m, IsPasswordManager o) => o -> m PasswordManager
toPasswordManager = liftIO . unsafeCastTo PasswordManager

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
instance O.HasAttributeList PasswordManager
type instance O.AttributeList PasswordManager = PasswordManagerAttributeList
type PasswordManagerAttributeList = ('[ ] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
type family ResolvePasswordManagerMethod (t :: Symbol) (o :: *) :: * where
    ResolvePasswordManagerMethod "addFeature" o = Soup.SessionFeature.SessionFeatureAddFeatureMethodInfo
    ResolvePasswordManagerMethod "attach" o = Soup.SessionFeature.SessionFeatureAttachMethodInfo
    ResolvePasswordManagerMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolvePasswordManagerMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolvePasswordManagerMethod "detach" o = Soup.SessionFeature.SessionFeatureDetachMethodInfo
    ResolvePasswordManagerMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolvePasswordManagerMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolvePasswordManagerMethod "hasFeature" o = Soup.SessionFeature.SessionFeatureHasFeatureMethodInfo
    ResolvePasswordManagerMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolvePasswordManagerMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolvePasswordManagerMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolvePasswordManagerMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolvePasswordManagerMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolvePasswordManagerMethod "removeFeature" o = Soup.SessionFeature.SessionFeatureRemoveFeatureMethodInfo
    ResolvePasswordManagerMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolvePasswordManagerMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolvePasswordManagerMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolvePasswordManagerMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolvePasswordManagerMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolvePasswordManagerMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolvePasswordManagerMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolvePasswordManagerMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolvePasswordManagerMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolvePasswordManagerMethod "getPasswordsAsync" o = PasswordManagerGetPasswordsAsyncMethodInfo
    ResolvePasswordManagerMethod "getPasswordsSync" o = PasswordManagerGetPasswordsSyncMethodInfo
    ResolvePasswordManagerMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolvePasswordManagerMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolvePasswordManagerMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolvePasswordManagerMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolvePasswordManagerMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolvePasswordManagerMethod t PasswordManager, O.MethodInfo info PasswordManager p) => O.IsLabelProxy t (PasswordManager -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolvePasswordManagerMethod t PasswordManager, O.MethodInfo info PasswordManager p) => O.IsLabel t (PasswordManager -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
#endif

#endif

-- method PasswordManager::get_passwords_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "password_manager", argType = TInterface (Name {namespace = "Soup", name = "PasswordManager"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msg", argType = TInterface (Name {namespace = "Soup", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "auth", argType = TInterface (Name {namespace = "Soup", name = "Auth"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "retrying", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "async_context", argType = TInterface (Name {namespace = "GLib", name = "MainContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, 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 = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Soup", name = "PasswordManagerCallback"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, 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 = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_password_manager_get_passwords_async" soup_password_manager_get_passwords_async :: 
    Ptr PasswordManager ->                  -- password_manager : TInterface (Name {namespace = "Soup", name = "PasswordManager"})
    Ptr Soup.Message.Message ->             -- msg : TInterface (Name {namespace = "Soup", name = "Message"})
    Ptr Soup.Auth.Auth ->                   -- auth : TInterface (Name {namespace = "Soup", name = "Auth"})
    CInt ->                                 -- retrying : TBasicType TBoolean
    Ptr GLib.MainContext.MainContext ->     -- async_context : TInterface (Name {namespace = "GLib", name = "MainContext"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Soup.Callbacks.C_PasswordManagerCallback -> -- callback : TInterface (Name {namespace = "Soup", name = "PasswordManagerCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
/No description available in the introspection data./
-}
passwordManagerGetPasswordsAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsPasswordManager a, Soup.Message.IsMessage b, Soup.Auth.IsAuth c, Gio.Cancellable.IsCancellable d) =>
    a
    -> b
    -> c
    -> Bool
    -> GLib.MainContext.MainContext
    -> Maybe (d)
    -> Soup.Callbacks.PasswordManagerCallback
    -> m ()
passwordManagerGetPasswordsAsync passwordManager msg auth retrying asyncContext cancellable callback = liftIO $ do
    passwordManager' <- unsafeManagedPtrCastPtr passwordManager
    msg' <- unsafeManagedPtrCastPtr msg
    auth' <- unsafeManagedPtrCastPtr auth
    let retrying' = (fromIntegral . fromEnum) retrying
    asyncContext' <- unsafeManagedPtrGetPtr asyncContext
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Soup.Callbacks.C_PasswordManagerCallback))
    callback' <- Soup.Callbacks.mk_PasswordManagerCallback (Soup.Callbacks.wrap_PasswordManagerCallback (Just ptrcallback) (Soup.Callbacks.drop_closures_PasswordManagerCallback callback))
    poke ptrcallback callback'
    let userData = nullPtr
    soup_password_manager_get_passwords_async passwordManager' msg' auth' retrying' asyncContext' maybeCancellable callback' userData
    touchManagedPtr passwordManager
    touchManagedPtr msg
    touchManagedPtr auth
    touchManagedPtr asyncContext
    whenJust cancellable touchManagedPtr
    return ()

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data PasswordManagerGetPasswordsAsyncMethodInfo
instance (signature ~ (b -> c -> Bool -> GLib.MainContext.MainContext -> Maybe (d) -> Soup.Callbacks.PasswordManagerCallback -> m ()), MonadIO m, IsPasswordManager a, Soup.Message.IsMessage b, Soup.Auth.IsAuth c, Gio.Cancellable.IsCancellable d) => O.MethodInfo PasswordManagerGetPasswordsAsyncMethodInfo a signature where
    overloadedMethod _ = passwordManagerGetPasswordsAsync

#endif

-- method PasswordManager::get_passwords_sync
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "password_manager", argType = TInterface (Name {namespace = "Soup", name = "PasswordManager"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msg", argType = TInterface (Name {namespace = "Soup", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "auth", argType = TInterface (Name {namespace = "Soup", name = "Auth"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, 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 = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_password_manager_get_passwords_sync" soup_password_manager_get_passwords_sync :: 
    Ptr PasswordManager ->                  -- password_manager : TInterface (Name {namespace = "Soup", name = "PasswordManager"})
    Ptr Soup.Message.Message ->             -- msg : TInterface (Name {namespace = "Soup", name = "Message"})
    Ptr Soup.Auth.Auth ->                   -- auth : TInterface (Name {namespace = "Soup", name = "Auth"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    IO ()

{- |
/No description available in the introspection data./
-}
passwordManagerGetPasswordsSync ::
    (B.CallStack.HasCallStack, MonadIO m, IsPasswordManager a, Soup.Message.IsMessage b, Soup.Auth.IsAuth c, Gio.Cancellable.IsCancellable d) =>
    a
    -> b
    -> c
    -> Maybe (d)
    -> m ()
passwordManagerGetPasswordsSync passwordManager msg auth cancellable = liftIO $ do
    passwordManager' <- unsafeManagedPtrCastPtr passwordManager
    msg' <- unsafeManagedPtrCastPtr msg
    auth' <- unsafeManagedPtrCastPtr auth
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    soup_password_manager_get_passwords_sync passwordManager' msg' auth' maybeCancellable
    touchManagedPtr passwordManager
    touchManagedPtr msg
    touchManagedPtr auth
    whenJust cancellable touchManagedPtr
    return ()

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data PasswordManagerGetPasswordsSyncMethodInfo
instance (signature ~ (b -> c -> Maybe (d) -> m ()), MonadIO m, IsPasswordManager a, Soup.Message.IsMessage b, Soup.Auth.IsAuth c, Gio.Cancellable.IsCancellable d) => O.MethodInfo PasswordManagerGetPasswordsSyncMethodInfo a signature where
    overloadedMethod _ = passwordManagerGetPasswordsSync

#endif