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

/No description available in the introspection data./
-}

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

module GI.Soup.Interfaces.PasswordManager
    (

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


 -- * Methods
-- ** getPasswordsAsync #method:getPasswordsAsync#

#if ENABLE_OVERLOADING
    PasswordManagerGetPasswordsAsyncMethodInfo,
#endif
    passwordManagerGetPasswordsAsync        ,


-- ** getPasswordsSync #method:getPasswordsSync#

#if ENABLE_OVERLOADING
    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.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL

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 
-- | Memory-managed wrapper type.
newtype PasswordManager = PasswordManager (ManagedPtr PasswordManager)
-- | A convenience alias for `Nothing` :: `Maybe` `PasswordManager`.
noPasswordManager :: Maybe PasswordManager
noPasswordManager = Nothing

#if ENABLE_OVERLOADING
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


-- | Type class for types which can be safely cast to `PasswordManager`, for instance with `toPasswordManager`.
class (GObject o, O.IsDescendantOf PasswordManager o) => IsPasswordManager o
instance (GObject o, O.IsDescendantOf PasswordManager o) => IsPasswordManager o

instance O.HasParentTypes PasswordManager
type instance O.ParentTypes PasswordManager = '[Soup.SessionFeature.SessionFeature, GObject.Object.Object]

-- | Cast to `PasswordManager`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toPasswordManager :: (MonadIO m, IsPasswordManager o) => o -> m PasswordManager
toPasswordManager = liftIO . unsafeCastTo PasswordManager

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

#if ENABLE_OVERLOADING
#endif

#if ENABLE_OVERLOADING
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 "getv" o = GObject.Object.ObjectGetvMethodInfo
    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 "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) => OL.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

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