{- |
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.Objects.CookieJarDB
    (

-- * Exported types
    CookieJarDB(..)                         ,
    IsCookieJarDB                           ,
    toCookieJarDB                           ,
    noCookieJarDB                           ,


 -- * Methods
-- ** new #method:new#

    cookieJarDBNew                          ,




 -- * Properties
-- ** filename #attr:filename#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
    CookieJarDBFilenamePropertyInfo         ,
#endif
    constructCookieJarDBFilename            ,
#if ENABLE_OVERLOADING
    cookieJarDBFilename                     ,
#endif
    getCookieJarDBFilename                  ,




    ) 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.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Soup.Interfaces.SessionFeature as Soup.SessionFeature
import {-# SOURCE #-} qualified GI.Soup.Objects.CookieJar as Soup.CookieJar

-- | Memory-managed wrapper type.
newtype CookieJarDB = CookieJarDB (ManagedPtr CookieJarDB)
foreign import ccall "soup_cookie_jar_db_get_type"
    c_soup_cookie_jar_db_get_type :: IO GType

instance GObject CookieJarDB where
    gobjectType = c_soup_cookie_jar_db_get_type


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

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

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

-- | A convenience alias for `Nothing` :: `Maybe` `CookieJarDB`.
noCookieJarDB :: Maybe CookieJarDB
noCookieJarDB = Nothing

#if ENABLE_OVERLOADING
type family ResolveCookieJarDBMethod (t :: Symbol) (o :: *) :: * where
    ResolveCookieJarDBMethod "addCookie" o = Soup.CookieJar.CookieJarAddCookieMethodInfo
    ResolveCookieJarDBMethod "addCookieWithFirstParty" o = Soup.CookieJar.CookieJarAddCookieWithFirstPartyMethodInfo
    ResolveCookieJarDBMethod "addFeature" o = Soup.SessionFeature.SessionFeatureAddFeatureMethodInfo
    ResolveCookieJarDBMethod "allCookies" o = Soup.CookieJar.CookieJarAllCookiesMethodInfo
    ResolveCookieJarDBMethod "attach" o = Soup.SessionFeature.SessionFeatureAttachMethodInfo
    ResolveCookieJarDBMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveCookieJarDBMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveCookieJarDBMethod "deleteCookie" o = Soup.CookieJar.CookieJarDeleteCookieMethodInfo
    ResolveCookieJarDBMethod "detach" o = Soup.SessionFeature.SessionFeatureDetachMethodInfo
    ResolveCookieJarDBMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveCookieJarDBMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveCookieJarDBMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveCookieJarDBMethod "hasFeature" o = Soup.SessionFeature.SessionFeatureHasFeatureMethodInfo
    ResolveCookieJarDBMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveCookieJarDBMethod "isPersistent" o = Soup.CookieJar.CookieJarIsPersistentMethodInfo
    ResolveCookieJarDBMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveCookieJarDBMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveCookieJarDBMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveCookieJarDBMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveCookieJarDBMethod "removeFeature" o = Soup.SessionFeature.SessionFeatureRemoveFeatureMethodInfo
    ResolveCookieJarDBMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveCookieJarDBMethod "save" o = Soup.CookieJar.CookieJarSaveMethodInfo
    ResolveCookieJarDBMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveCookieJarDBMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveCookieJarDBMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveCookieJarDBMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveCookieJarDBMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveCookieJarDBMethod "getAcceptPolicy" o = Soup.CookieJar.CookieJarGetAcceptPolicyMethodInfo
    ResolveCookieJarDBMethod "getCookieList" o = Soup.CookieJar.CookieJarGetCookieListMethodInfo
    ResolveCookieJarDBMethod "getCookies" o = Soup.CookieJar.CookieJarGetCookiesMethodInfo
    ResolveCookieJarDBMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveCookieJarDBMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveCookieJarDBMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveCookieJarDBMethod "setAcceptPolicy" o = Soup.CookieJar.CookieJarSetAcceptPolicyMethodInfo
    ResolveCookieJarDBMethod "setCookie" o = Soup.CookieJar.CookieJarSetCookieMethodInfo
    ResolveCookieJarDBMethod "setCookieWithFirstParty" o = Soup.CookieJar.CookieJarSetCookieWithFirstPartyMethodInfo
    ResolveCookieJarDBMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveCookieJarDBMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveCookieJarDBMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveCookieJarDBMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveCookieJarDBMethod t CookieJarDB, O.MethodInfo info CookieJarDB p) => OL.IsLabel t (CookieJarDB -> 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

-- VVV Prop "filename"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

{- |
Get the value of the “@filename@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' cookieJarDB #filename
@
-}
getCookieJarDBFilename :: (MonadIO m, IsCookieJarDB o) => o -> m (Maybe T.Text)
getCookieJarDBFilename obj = liftIO $ B.Properties.getObjectPropertyString obj "filename"

{- |
Construct a `GValueConstruct` with valid value for the “@filename@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructCookieJarDBFilename :: (IsCookieJarDB o) => T.Text -> IO (GValueConstruct o)
constructCookieJarDBFilename val = B.Properties.constructObjectPropertyString "filename" (Just val)

#if ENABLE_OVERLOADING
data CookieJarDBFilenamePropertyInfo
instance AttrInfo CookieJarDBFilenamePropertyInfo where
    type AttrAllowedOps CookieJarDBFilenamePropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint CookieJarDBFilenamePropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint CookieJarDBFilenamePropertyInfo = IsCookieJarDB
    type AttrGetType CookieJarDBFilenamePropertyInfo = (Maybe T.Text)
    type AttrLabel CookieJarDBFilenamePropertyInfo = "filename"
    type AttrOrigin CookieJarDBFilenamePropertyInfo = CookieJarDB
    attrGet _ = getCookieJarDBFilename
    attrSet _ = undefined
    attrConstruct _ = constructCookieJarDBFilename
    attrClear _ = undefined
#endif

#if ENABLE_OVERLOADING
instance O.HasAttributeList CookieJarDB
type instance O.AttributeList CookieJarDB = CookieJarDBAttributeList
type CookieJarDBAttributeList = ('[ '("acceptPolicy", Soup.CookieJar.CookieJarAcceptPolicyPropertyInfo), '("filename", CookieJarDBFilenamePropertyInfo), '("readOnly", Soup.CookieJar.CookieJarReadOnlyPropertyInfo)] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
cookieJarDBFilename :: AttrLabelProxy "filename"
cookieJarDBFilename = AttrLabelProxy

#endif

#if ENABLE_OVERLOADING
type instance O.SignalList CookieJarDB = CookieJarDBSignalList
type CookieJarDBSignalList = ('[ '("changed", Soup.CookieJar.CookieJarChangedSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method CookieJarDB::new
-- method type : Constructor
-- Args : [Arg {argCName = "filename", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the filename to read to/write from, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "read_only", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "%TRUE if @filename is read-only", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Soup", name = "CookieJarDB"}))
-- throws : False
-- Skip return : False

foreign import ccall "soup_cookie_jar_db_new" soup_cookie_jar_db_new ::
    CString ->                              -- filename : TBasicType TUTF8
    CInt ->                                 -- read_only : TBasicType TBoolean
    IO (Ptr CookieJarDB)

{- |
Creates a 'GI.Soup.Objects.CookieJarDB.CookieJarDB'.

/@filename@/ will be read in at startup to create an initial set of
cookies. If /@readOnly@/ is 'False', then the non-session cookies will
be written to /@filename@/ when the \'changed\' signal is emitted from
the jar. (If /@readOnly@/ is 'True', then the cookie jar will only be
used for this session, and changes made to it will be lost when the
jar is destroyed.)

/Since: 2.42/
-}
cookieJarDBNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@filename@/: the filename to read to\/write from, or 'Nothing' -}
    -> Bool
    {- ^ /@readOnly@/: 'True' if /@filename@/ is read-only -}
    -> m CookieJarDB
    {- ^ __Returns:__ the new 'GI.Soup.Objects.CookieJar.CookieJar' -}
cookieJarDBNew filename readOnly = liftIO $ do
    filename' <- textToCString filename
    let readOnly' = (fromIntegral . fromEnum) readOnly
    result <- soup_cookie_jar_db_new filename' readOnly'
    checkUnexpectedReturnNULL "cookieJarDBNew" result
    result' <- (wrapObject CookieJarDB) result
    freeMem filename'
    return result'

#if ENABLE_OVERLOADING
#endif