gi-soup-0.2.50.12: GI/Soup/Objects/ContentSniffer.hs
{- |
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.Objects.ContentSniffer
(
-- * Exported types
ContentSniffer(..) ,
ContentSnifferK ,
toContentSniffer ,
noContentSniffer ,
-- * Methods
-- ** contentSnifferGetBufferSize
contentSnifferGetBufferSize ,
-- ** contentSnifferNew
contentSnifferNew ,
-- ** contentSnifferSniff
contentSnifferSniff ,
) where
import Prelude ()
import Data.GI.Base.ShortPrelude
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import GI.Soup.Types
import GI.Soup.Callbacks
import qualified GI.GObject as GObject
newtype ContentSniffer = ContentSniffer (ForeignPtr ContentSniffer)
foreign import ccall "soup_content_sniffer_get_type"
c_soup_content_sniffer_get_type :: IO GType
type instance ParentTypes ContentSniffer = ContentSnifferParentTypes
type ContentSnifferParentTypes = '[GObject.Object, SessionFeature]
instance GObject ContentSniffer where
gobjectIsInitiallyUnowned _ = False
gobjectType _ = c_soup_content_sniffer_get_type
class GObject o => ContentSnifferK o
instance (GObject o, IsDescendantOf ContentSniffer o) => ContentSnifferK o
toContentSniffer :: ContentSnifferK o => o -> IO ContentSniffer
toContentSniffer = unsafeCastTo ContentSniffer
noContentSniffer :: Maybe ContentSniffer
noContentSniffer = Nothing
type instance AttributeList ContentSniffer = ContentSnifferAttributeList
type ContentSnifferAttributeList = ('[ ] :: [(Symbol, *)])
type instance SignalList ContentSniffer = ContentSnifferSignalList
type ContentSnifferSignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])
-- method ContentSniffer::new
-- method type : Constructor
-- Args : []
-- Lengths : []
-- hInArgs : []
-- returnType : TInterface "Soup" "ContentSniffer"
-- throws : False
-- Skip return : False
foreign import ccall "soup_content_sniffer_new" soup_content_sniffer_new ::
IO (Ptr ContentSniffer)
contentSnifferNew ::
(MonadIO m) =>
m ContentSniffer
contentSnifferNew = liftIO $ do
result <- soup_content_sniffer_new
checkUnexpectedReturnNULL "soup_content_sniffer_new" result
result' <- (wrapObject ContentSniffer) result
return result'
-- method ContentSniffer::get_buffer_size
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Soup" "ContentSniffer", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Soup" "ContentSniffer", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUInt64
-- throws : False
-- Skip return : False
foreign import ccall "soup_content_sniffer_get_buffer_size" soup_content_sniffer_get_buffer_size ::
Ptr ContentSniffer -> -- _obj : TInterface "Soup" "ContentSniffer"
IO Word64
contentSnifferGetBufferSize ::
(MonadIO m, ContentSnifferK a) =>
a -> -- _obj
m Word64
contentSnifferGetBufferSize _obj = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
result <- soup_content_sniffer_get_buffer_size _obj'
touchManagedPtr _obj
return result
-- method ContentSniffer::sniff
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Soup" "ContentSniffer", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "msg", argType = TInterface "Soup" "Message", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "buffer", argType = TInterface "Soup" "Buffer", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "params", argType = TGHash (TBasicType TUTF8) (TBasicType TUTF8), direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Soup" "ContentSniffer", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "msg", argType = TInterface "Soup" "Message", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "buffer", argType = TInterface "Soup" "Buffer", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False
foreign import ccall "soup_content_sniffer_sniff" soup_content_sniffer_sniff ::
Ptr ContentSniffer -> -- _obj : TInterface "Soup" "ContentSniffer"
Ptr Message -> -- msg : TInterface "Soup" "Message"
Ptr Buffer -> -- buffer : TInterface "Soup" "Buffer"
Ptr (Ptr (GHashTable CString CString)) -> -- params : TGHash (TBasicType TUTF8) (TBasicType TUTF8)
IO CString
contentSnifferSniff ::
(MonadIO m, ContentSnifferK a, MessageK b) =>
a -> -- _obj
b -> -- msg
Buffer -> -- buffer
m (T.Text,(Map.Map T.Text T.Text))
contentSnifferSniff _obj msg buffer = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
let msg' = unsafeManagedPtrCastPtr msg
let buffer' = unsafeManagedPtrGetPtr buffer
params <- allocMem :: IO (Ptr (Ptr (GHashTable CString CString)))
result <- soup_content_sniffer_sniff _obj' msg' buffer' params
checkUnexpectedReturnNULL "soup_content_sniffer_sniff" result
result' <- cstringToText result
freeMem result
params' <- peek params
params'' <- unpackGHashTable params'
let params''' = mapFirst cstringUnpackPtr params''
params'''' <- mapFirstA cstringToText params'''
let params''''' = mapSecond cstringUnpackPtr params''''
params'''''' <- mapSecondA cstringToText params'''''
let params''''''' = Map.fromList params''''''
unrefGHashTable params'
touchManagedPtr _obj
touchManagedPtr msg
touchManagedPtr buffer
freeMem params
return (result', params''''''')