#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.Soup.Objects.Cache
(
Cache(..) ,
IsCache ,
toCache ,
noCache ,
#if ENABLE_OVERLOADING
CacheClearMethodInfo ,
#endif
cacheClear ,
#if ENABLE_OVERLOADING
CacheDumpMethodInfo ,
#endif
cacheDump ,
#if ENABLE_OVERLOADING
CacheFlushMethodInfo ,
#endif
cacheFlush ,
#if ENABLE_OVERLOADING
CacheGetMaxSizeMethodInfo ,
#endif
cacheGetMaxSize ,
#if ENABLE_OVERLOADING
CacheLoadMethodInfo ,
#endif
cacheLoad ,
cacheNew ,
#if ENABLE_OVERLOADING
CacheSetMaxSizeMethodInfo ,
#endif
cacheSetMaxSize ,
#if ENABLE_OVERLOADING
CacheCacheDirPropertyInfo ,
#endif
#if ENABLE_OVERLOADING
cacheCacheDir ,
#endif
constructCacheCacheDir ,
getCacheCacheDir ,
#if ENABLE_OVERLOADING
CacheCacheTypePropertyInfo ,
#endif
#if ENABLE_OVERLOADING
cacheCacheType ,
#endif
constructCacheCacheType ,
getCacheCacheType ,
) 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.Enums as Soup.Enums
import {-# SOURCE #-} qualified GI.Soup.Interfaces.SessionFeature as Soup.SessionFeature
newtype Cache = Cache (ManagedPtr Cache)
foreign import ccall "soup_cache_get_type"
c_soup_cache_get_type :: IO GType
instance GObject Cache where
gobjectType = c_soup_cache_get_type
class (GObject o, O.IsDescendantOf Cache o) => IsCache o
instance (GObject o, O.IsDescendantOf Cache o) => IsCache o
instance O.HasParentTypes Cache
type instance O.ParentTypes Cache = '[GObject.Object.Object, Soup.SessionFeature.SessionFeature]
toCache :: (MonadIO m, IsCache o) => o -> m Cache
toCache = liftIO . unsafeCastTo Cache
noCache :: Maybe Cache
noCache = Nothing
#if ENABLE_OVERLOADING
type family ResolveCacheMethod (t :: Symbol) (o :: *) :: * where
ResolveCacheMethod "addFeature" o = Soup.SessionFeature.SessionFeatureAddFeatureMethodInfo
ResolveCacheMethod "attach" o = Soup.SessionFeature.SessionFeatureAttachMethodInfo
ResolveCacheMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolveCacheMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolveCacheMethod "clear" o = CacheClearMethodInfo
ResolveCacheMethod "detach" o = Soup.SessionFeature.SessionFeatureDetachMethodInfo
ResolveCacheMethod "dump" o = CacheDumpMethodInfo
ResolveCacheMethod "flush" o = CacheFlushMethodInfo
ResolveCacheMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolveCacheMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolveCacheMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolveCacheMethod "hasFeature" o = Soup.SessionFeature.SessionFeatureHasFeatureMethodInfo
ResolveCacheMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolveCacheMethod "load" o = CacheLoadMethodInfo
ResolveCacheMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolveCacheMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolveCacheMethod "ref" o = GObject.Object.ObjectRefMethodInfo
ResolveCacheMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolveCacheMethod "removeFeature" o = Soup.SessionFeature.SessionFeatureRemoveFeatureMethodInfo
ResolveCacheMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolveCacheMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolveCacheMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolveCacheMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolveCacheMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
ResolveCacheMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolveCacheMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolveCacheMethod "getMaxSize" o = CacheGetMaxSizeMethodInfo
ResolveCacheMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolveCacheMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolveCacheMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolveCacheMethod "setMaxSize" o = CacheSetMaxSizeMethodInfo
ResolveCacheMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolveCacheMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveCacheMethod t Cache, O.MethodInfo info Cache p) => OL.IsLabel t (Cache -> 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
getCacheCacheDir :: (MonadIO m, IsCache o) => o -> m (Maybe T.Text)
getCacheCacheDir obj = liftIO $ B.Properties.getObjectPropertyString obj "cache-dir"
constructCacheCacheDir :: (IsCache o) => T.Text -> IO (GValueConstruct o)
constructCacheCacheDir val = B.Properties.constructObjectPropertyString "cache-dir" (Just val)
#if ENABLE_OVERLOADING
data CacheCacheDirPropertyInfo
instance AttrInfo CacheCacheDirPropertyInfo where
type AttrAllowedOps CacheCacheDirPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
type AttrSetTypeConstraint CacheCacheDirPropertyInfo = (~) T.Text
type AttrBaseTypeConstraint CacheCacheDirPropertyInfo = IsCache
type AttrGetType CacheCacheDirPropertyInfo = (Maybe T.Text)
type AttrLabel CacheCacheDirPropertyInfo = "cache-dir"
type AttrOrigin CacheCacheDirPropertyInfo = Cache
attrGet _ = getCacheCacheDir
attrSet _ = undefined
attrConstruct _ = constructCacheCacheDir
attrClear _ = undefined
#endif
getCacheCacheType :: (MonadIO m, IsCache o) => o -> m Soup.Enums.CacheType
getCacheCacheType obj = liftIO $ B.Properties.getObjectPropertyEnum obj "cache-type"
constructCacheCacheType :: (IsCache o) => Soup.Enums.CacheType -> IO (GValueConstruct o)
constructCacheCacheType val = B.Properties.constructObjectPropertyEnum "cache-type" val
#if ENABLE_OVERLOADING
data CacheCacheTypePropertyInfo
instance AttrInfo CacheCacheTypePropertyInfo where
type AttrAllowedOps CacheCacheTypePropertyInfo = '[ 'AttrConstruct, 'AttrGet]
type AttrSetTypeConstraint CacheCacheTypePropertyInfo = (~) Soup.Enums.CacheType
type AttrBaseTypeConstraint CacheCacheTypePropertyInfo = IsCache
type AttrGetType CacheCacheTypePropertyInfo = Soup.Enums.CacheType
type AttrLabel CacheCacheTypePropertyInfo = "cache-type"
type AttrOrigin CacheCacheTypePropertyInfo = Cache
attrGet _ = getCacheCacheType
attrSet _ = undefined
attrConstruct _ = constructCacheCacheType
attrClear _ = undefined
#endif
#if ENABLE_OVERLOADING
instance O.HasAttributeList Cache
type instance O.AttributeList Cache = CacheAttributeList
type CacheAttributeList = ('[ '("cacheDir", CacheCacheDirPropertyInfo), '("cacheType", CacheCacheTypePropertyInfo)] :: [(Symbol, *)])
#endif
#if ENABLE_OVERLOADING
cacheCacheDir :: AttrLabelProxy "cacheDir"
cacheCacheDir = AttrLabelProxy
cacheCacheType :: AttrLabelProxy "cacheType"
cacheCacheType = AttrLabelProxy
#endif
#if ENABLE_OVERLOADING
type instance O.SignalList Cache = CacheSignalList
type CacheSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])
#endif
foreign import ccall "soup_cache_new" soup_cache_new ::
CString ->
CUInt ->
IO (Ptr Cache)
cacheNew ::
(B.CallStack.HasCallStack, MonadIO m) =>
Maybe (T.Text)
-> Soup.Enums.CacheType
-> m Cache
cacheNew cacheDir cacheType = liftIO $ do
maybeCacheDir <- case cacheDir of
Nothing -> return nullPtr
Just jCacheDir -> do
jCacheDir' <- textToCString jCacheDir
return jCacheDir'
let cacheType' = (fromIntegral . fromEnum) cacheType
result <- soup_cache_new maybeCacheDir cacheType'
checkUnexpectedReturnNULL "cacheNew" result
result' <- (wrapObject Cache) result
freeMem maybeCacheDir
return result'
#if ENABLE_OVERLOADING
#endif
foreign import ccall "soup_cache_clear" soup_cache_clear ::
Ptr Cache ->
IO ()
cacheClear ::
(B.CallStack.HasCallStack, MonadIO m, IsCache a) =>
a
-> m ()
cacheClear cache = liftIO $ do
cache' <- unsafeManagedPtrCastPtr cache
soup_cache_clear cache'
touchManagedPtr cache
return ()
#if ENABLE_OVERLOADING
data CacheClearMethodInfo
instance (signature ~ (m ()), MonadIO m, IsCache a) => O.MethodInfo CacheClearMethodInfo a signature where
overloadedMethod _ = cacheClear
#endif
foreign import ccall "soup_cache_dump" soup_cache_dump ::
Ptr Cache ->
IO ()
cacheDump ::
(B.CallStack.HasCallStack, MonadIO m, IsCache a) =>
a
-> m ()
cacheDump cache = liftIO $ do
cache' <- unsafeManagedPtrCastPtr cache
soup_cache_dump cache'
touchManagedPtr cache
return ()
#if ENABLE_OVERLOADING
data CacheDumpMethodInfo
instance (signature ~ (m ()), MonadIO m, IsCache a) => O.MethodInfo CacheDumpMethodInfo a signature where
overloadedMethod _ = cacheDump
#endif
foreign import ccall "soup_cache_flush" soup_cache_flush ::
Ptr Cache ->
IO ()
cacheFlush ::
(B.CallStack.HasCallStack, MonadIO m, IsCache a) =>
a
-> m ()
cacheFlush cache = liftIO $ do
cache' <- unsafeManagedPtrCastPtr cache
soup_cache_flush cache'
touchManagedPtr cache
return ()
#if ENABLE_OVERLOADING
data CacheFlushMethodInfo
instance (signature ~ (m ()), MonadIO m, IsCache a) => O.MethodInfo CacheFlushMethodInfo a signature where
overloadedMethod _ = cacheFlush
#endif
foreign import ccall "soup_cache_get_max_size" soup_cache_get_max_size ::
Ptr Cache ->
IO Word32
cacheGetMaxSize ::
(B.CallStack.HasCallStack, MonadIO m, IsCache a) =>
a
-> m Word32
cacheGetMaxSize cache = liftIO $ do
cache' <- unsafeManagedPtrCastPtr cache
result <- soup_cache_get_max_size cache'
touchManagedPtr cache
return result
#if ENABLE_OVERLOADING
data CacheGetMaxSizeMethodInfo
instance (signature ~ (m Word32), MonadIO m, IsCache a) => O.MethodInfo CacheGetMaxSizeMethodInfo a signature where
overloadedMethod _ = cacheGetMaxSize
#endif
foreign import ccall "soup_cache_load" soup_cache_load ::
Ptr Cache ->
IO ()
cacheLoad ::
(B.CallStack.HasCallStack, MonadIO m, IsCache a) =>
a
-> m ()
cacheLoad cache = liftIO $ do
cache' <- unsafeManagedPtrCastPtr cache
soup_cache_load cache'
touchManagedPtr cache
return ()
#if ENABLE_OVERLOADING
data CacheLoadMethodInfo
instance (signature ~ (m ()), MonadIO m, IsCache a) => O.MethodInfo CacheLoadMethodInfo a signature where
overloadedMethod _ = cacheLoad
#endif
foreign import ccall "soup_cache_set_max_size" soup_cache_set_max_size ::
Ptr Cache ->
Word32 ->
IO ()
cacheSetMaxSize ::
(B.CallStack.HasCallStack, MonadIO m, IsCache a) =>
a
-> Word32
-> m ()
cacheSetMaxSize cache maxSize = liftIO $ do
cache' <- unsafeManagedPtrCastPtr cache
soup_cache_set_max_size cache' maxSize
touchManagedPtr cache
return ()
#if ENABLE_OVERLOADING
data CacheSetMaxSizeMethodInfo
instance (signature ~ (Word32 -> m ()), MonadIO m, IsCache a) => O.MethodInfo CacheSetMaxSizeMethodInfo a signature where
overloadedMethod _ = cacheSetMaxSize
#endif