{- |
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.WebKit2.Structs.MimeInfo
    ( 

-- * Exported types
    MimeInfo(..)                            ,
    noMimeInfo                              ,


 -- * Methods
-- ** getDescription #method:getDescription#
    MimeInfoGetDescriptionMethodInfo        ,
    mimeInfoGetDescription                  ,


-- ** getExtensions #method:getExtensions#
    MimeInfoGetExtensionsMethodInfo         ,
    mimeInfoGetExtensions                   ,


-- ** getMimeType #method:getMimeType#
    MimeInfoGetMimeTypeMethodInfo           ,
    mimeInfoGetMimeType                     ,


-- ** ref #method:ref#
    MimeInfoRefMethodInfo                   ,
    mimeInfoRef                             ,


-- ** unref #method:unref#
    MimeInfoUnrefMethodInfo                 ,
    mimeInfoUnref                           ,




    ) 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.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
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


newtype MimeInfo = MimeInfo (ManagedPtr MimeInfo)
foreign import ccall "webkit_mime_info_get_type" c_webkit_mime_info_get_type :: 
    IO GType

instance BoxedObject MimeInfo where
    boxedType _ = c_webkit_mime_info_get_type

noMimeInfo :: Maybe MimeInfo
noMimeInfo = Nothing


instance O.HasAttributeList MimeInfo
type instance O.AttributeList MimeInfo = MimeInfoAttributeList
type MimeInfoAttributeList = ('[ ] :: [(Symbol, *)])

-- method MimeInfo::get_description
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "info", argType = TInterface (Name {namespace = "WebKit2", name = "MimeInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitMimeInfo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "webkit_mime_info_get_description" webkit_mime_info_get_description :: 
    Ptr MimeInfo ->                         -- info : TInterface (Name {namespace = "WebKit2", name = "MimeInfo"})
    IO CString

{- |
/No description available in the introspection data./
-}
mimeInfoGetDescription ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    MimeInfo
    {- ^ /@info@/: a 'GI.WebKit2.Structs.MimeInfo.MimeInfo' -}
    -> m T.Text
    {- ^ __Returns:__ the description of the MIME type of /@info@/ -}
mimeInfoGetDescription info = liftIO $ do
    info' <- unsafeManagedPtrGetPtr info
    result <- webkit_mime_info_get_description info'
    checkUnexpectedReturnNULL "mimeInfoGetDescription" result
    result' <- cstringToText result
    touchManagedPtr info
    return result'

data MimeInfoGetDescriptionMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo MimeInfoGetDescriptionMethodInfo MimeInfo signature where
    overloadedMethod _ = mimeInfoGetDescription

-- method MimeInfo::get_extensions
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "info", argType = TInterface (Name {namespace = "WebKit2", name = "MimeInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitMimeInfo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TCArray True (-1) (-1) (TBasicType TUTF8))
-- throws : False
-- Skip return : False

foreign import ccall "webkit_mime_info_get_extensions" webkit_mime_info_get_extensions :: 
    Ptr MimeInfo ->                         -- info : TInterface (Name {namespace = "WebKit2", name = "MimeInfo"})
    IO (Ptr CString)

{- |
Get the list of file extensions associated to the
MIME type of /@info@/
-}
mimeInfoGetExtensions ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    MimeInfo
    {- ^ /@info@/: a 'GI.WebKit2.Structs.MimeInfo.MimeInfo' -}
    -> m [T.Text]
    {- ^ __Returns:__ a
    'Nothing'-terminated array of strings -}
mimeInfoGetExtensions info = liftIO $ do
    info' <- unsafeManagedPtrGetPtr info
    result <- webkit_mime_info_get_extensions info'
    checkUnexpectedReturnNULL "mimeInfoGetExtensions" result
    result' <- unpackZeroTerminatedUTF8CArray result
    touchManagedPtr info
    return result'

data MimeInfoGetExtensionsMethodInfo
instance (signature ~ (m [T.Text]), MonadIO m) => O.MethodInfo MimeInfoGetExtensionsMethodInfo MimeInfo signature where
    overloadedMethod _ = mimeInfoGetExtensions

-- method MimeInfo::get_mime_type
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "info", argType = TInterface (Name {namespace = "WebKit2", name = "MimeInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitMimeInfo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "webkit_mime_info_get_mime_type" webkit_mime_info_get_mime_type :: 
    Ptr MimeInfo ->                         -- info : TInterface (Name {namespace = "WebKit2", name = "MimeInfo"})
    IO CString

{- |
/No description available in the introspection data./
-}
mimeInfoGetMimeType ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    MimeInfo
    {- ^ /@info@/: a 'GI.WebKit2.Structs.MimeInfo.MimeInfo' -}
    -> m T.Text
    {- ^ __Returns:__ the MIME type of /@info@/ -}
mimeInfoGetMimeType info = liftIO $ do
    info' <- unsafeManagedPtrGetPtr info
    result <- webkit_mime_info_get_mime_type info'
    checkUnexpectedReturnNULL "mimeInfoGetMimeType" result
    result' <- cstringToText result
    touchManagedPtr info
    return result'

data MimeInfoGetMimeTypeMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo MimeInfoGetMimeTypeMethodInfo MimeInfo signature where
    overloadedMethod _ = mimeInfoGetMimeType

-- method MimeInfo::ref
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "info", argType = TInterface (Name {namespace = "WebKit2", name = "MimeInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitMimeInfo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "WebKit2", name = "MimeInfo"}))
-- throws : False
-- Skip return : False

foreign import ccall "webkit_mime_info_ref" webkit_mime_info_ref :: 
    Ptr MimeInfo ->                         -- info : TInterface (Name {namespace = "WebKit2", name = "MimeInfo"})
    IO (Ptr MimeInfo)

{- |
Atomically increments the reference count of /@info@/ by one. This
function is MT-safe and may be called from any thread.
-}
mimeInfoRef ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    MimeInfo
    {- ^ /@info@/: a 'GI.WebKit2.Structs.MimeInfo.MimeInfo' -}
    -> m MimeInfo
    {- ^ __Returns:__ The passed in 'GI.WebKit2.Structs.MimeInfo.MimeInfo' -}
mimeInfoRef info = liftIO $ do
    info' <- unsafeManagedPtrGetPtr info
    result <- webkit_mime_info_ref info'
    checkUnexpectedReturnNULL "mimeInfoRef" result
    result' <- (wrapBoxed MimeInfo) result
    touchManagedPtr info
    return result'

data MimeInfoRefMethodInfo
instance (signature ~ (m MimeInfo), MonadIO m) => O.MethodInfo MimeInfoRefMethodInfo MimeInfo signature where
    overloadedMethod _ = mimeInfoRef

-- method MimeInfo::unref
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "info", argType = TInterface (Name {namespace = "WebKit2", name = "MimeInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitMimeInfo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "webkit_mime_info_unref" webkit_mime_info_unref :: 
    Ptr MimeInfo ->                         -- info : TInterface (Name {namespace = "WebKit2", name = "MimeInfo"})
    IO ()

{- |
Atomically decrements the reference count of /@info@/ by one. If the
reference count drops to 0, all memory allocated by the 'GI.WebKit2.Structs.MimeInfo.MimeInfo' is
released. This function is MT-safe and may be called from any
thread.
-}
mimeInfoUnref ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    MimeInfo
    {- ^ /@info@/: a 'GI.WebKit2.Structs.MimeInfo.MimeInfo' -}
    -> m ()
mimeInfoUnref info = liftIO $ do
    info' <- unsafeManagedPtrGetPtr info
    webkit_mime_info_unref info'
    touchManagedPtr info
    return ()

data MimeInfoUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo MimeInfoUnrefMethodInfo MimeInfo signature where
    overloadedMethod _ = mimeInfoUnref

type family ResolveMimeInfoMethod (t :: Symbol) (o :: *) :: * where
    ResolveMimeInfoMethod "ref" o = MimeInfoRefMethodInfo
    ResolveMimeInfoMethod "unref" o = MimeInfoUnrefMethodInfo
    ResolveMimeInfoMethod "getDescription" o = MimeInfoGetDescriptionMethodInfo
    ResolveMimeInfoMethod "getExtensions" o = MimeInfoGetExtensionsMethodInfo
    ResolveMimeInfoMethod "getMimeType" o = MimeInfoGetMimeTypeMethodInfo
    ResolveMimeInfoMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveMimeInfoMethod t MimeInfo, O.MethodInfo info MimeInfo p) => O.IsLabelProxy t (MimeInfo -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveMimeInfoMethod t MimeInfo, O.MethodInfo info MimeInfo p) => O.IsLabel t (MimeInfo -> p) where
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif