{- |
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.CookieJarText
    (

-- * Exported types
    CookieJarText(..)                       ,
    IsCookieJarText                         ,
    toCookieJarText                         ,
    noCookieJarText                         ,


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

    cookieJarTextNew                        ,




 -- * Properties
-- ** filename #attr:filename#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
    CookieJarTextFilenamePropertyInfo       ,
#endif
    constructCookieJarTextFilename          ,
#if ENABLE_OVERLOADING
    cookieJarTextFilename                   ,
#endif
    getCookieJarTextFilename                ,




    ) 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 CookieJarText = CookieJarText (ManagedPtr CookieJarText)
foreign import ccall "soup_cookie_jar_text_get_type"
    c_soup_cookie_jar_text_get_type :: IO GType

instance GObject CookieJarText where
    gobjectType = c_soup_cookie_jar_text_get_type


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

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

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

-- | A convenience alias for `Nothing` :: `Maybe` `CookieJarText`.
noCookieJarText :: Maybe CookieJarText
noCookieJarText = Nothing

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

instance (info ~ ResolveCookieJarTextMethod t CookieJarText, O.MethodInfo info CookieJarText p) => OL.IsLabel t (CookieJarText -> 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' cookieJarText #filename
@
-}
getCookieJarTextFilename :: (MonadIO m, IsCookieJarText o) => o -> m (Maybe T.Text)
getCookieJarTextFilename 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`.
-}
constructCookieJarTextFilename :: (IsCookieJarText o) => T.Text -> IO (GValueConstruct o)
constructCookieJarTextFilename val = B.Properties.constructObjectPropertyString "filename" (Just val)

#if ENABLE_OVERLOADING
data CookieJarTextFilenamePropertyInfo
instance AttrInfo CookieJarTextFilenamePropertyInfo where
    type AttrAllowedOps CookieJarTextFilenamePropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint CookieJarTextFilenamePropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint CookieJarTextFilenamePropertyInfo = IsCookieJarText
    type AttrGetType CookieJarTextFilenamePropertyInfo = (Maybe T.Text)
    type AttrLabel CookieJarTextFilenamePropertyInfo = "filename"
    type AttrOrigin CookieJarTextFilenamePropertyInfo = CookieJarText
    attrGet _ = getCookieJarTextFilename
    attrSet _ = undefined
    attrConstruct _ = constructCookieJarTextFilename
    attrClear _ = undefined
#endif

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

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

#endif

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

#endif

-- method CookieJarText::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", 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 = "CookieJarText"}))
-- throws : False
-- Skip return : False

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

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

/@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.26/
-}
cookieJarTextNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@filename@/: the filename to read to\/write from -}
    -> Bool
    {- ^ /@readOnly@/: 'True' if /@filename@/ is read-only -}
    -> m CookieJarText
    {- ^ __Returns:__ the new 'GI.Soup.Objects.CookieJar.CookieJar' -}
cookieJarTextNew filename readOnly = liftIO $ do
    filename' <- textToCString filename
    let readOnly' = (fromIntegral . fromEnum) readOnly
    result <- soup_cookie_jar_text_new filename' readOnly'
    checkUnexpectedReturnNULL "cookieJarTextNew" result
    result' <- (wrapObject CookieJarText) result
    freeMem filename'
    return result'

#if ENABLE_OVERLOADING
#endif