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

-- * Exported types
    WebDataSource(..)                       ,
    WebDataSourceK                          ,
    toWebDataSource                         ,
    noWebDataSource                         ,


 -- * Methods
-- ** webDataSourceGetData
    webDataSourceGetData                    ,


-- ** webDataSourceGetEncoding
    webDataSourceGetEncoding                ,


-- ** webDataSourceGetInitialRequest
    webDataSourceGetInitialRequest          ,


-- ** webDataSourceGetMainResource
    webDataSourceGetMainResource            ,


-- ** webDataSourceGetRequest
    webDataSourceGetRequest                 ,


-- ** webDataSourceGetSubresources
    webDataSourceGetSubresources            ,


-- ** webDataSourceGetUnreachableUri
    webDataSourceGetUnreachableUri          ,


-- ** webDataSourceGetWebFrame
    webDataSourceGetWebFrame                ,


-- ** webDataSourceIsLoading
    webDataSourceIsLoading                  ,


-- ** webDataSourceNew
    webDataSourceNew                        ,


-- ** webDataSourceNewWithRequest
    webDataSourceNewWithRequest             ,




    ) 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.WebKit.Types
import GI.WebKit.Callbacks
import qualified GI.GLib as GLib
import qualified GI.GObject as GObject

newtype WebDataSource = WebDataSource (ForeignPtr WebDataSource)
foreign import ccall "webkit_web_data_source_get_type"
    c_webkit_web_data_source_get_type :: IO GType

type instance ParentTypes WebDataSource = WebDataSourceParentTypes
type WebDataSourceParentTypes = '[GObject.Object]

instance GObject WebDataSource where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_webkit_web_data_source_get_type
    

class GObject o => WebDataSourceK o
instance (GObject o, IsDescendantOf WebDataSource o) => WebDataSourceK o

toWebDataSource :: WebDataSourceK o => o -> IO WebDataSource
toWebDataSource = unsafeCastTo WebDataSource

noWebDataSource :: Maybe WebDataSource
noWebDataSource = Nothing

type instance AttributeList WebDataSource = WebDataSourceAttributeList
type WebDataSourceAttributeList = ('[ ] :: [(Symbol, *)])

type instance SignalList WebDataSource = WebDataSourceSignalList
type WebDataSourceSignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method WebDataSource::new
-- method type : Constructor
-- Args : []
-- Lengths : []
-- hInArgs : []
-- returnType : TInterface "WebKit" "WebDataSource"
-- throws : False
-- Skip return : False

foreign import ccall "webkit_web_data_source_new" webkit_web_data_source_new :: 
    IO (Ptr WebDataSource)


webDataSourceNew ::
    (MonadIO m) =>
    m WebDataSource
webDataSourceNew  = liftIO $ do
    result <- webkit_web_data_source_new
    checkUnexpectedReturnNULL "webkit_web_data_source_new" result
    result' <- (wrapObject WebDataSource) result
    return result'

-- method WebDataSource::new_with_request
-- method type : Constructor
-- Args : [Arg {argName = "request", argType = TInterface "WebKit" "NetworkRequest", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "request", argType = TInterface "WebKit" "NetworkRequest", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "WebKit" "WebDataSource"
-- throws : False
-- Skip return : False

foreign import ccall "webkit_web_data_source_new_with_request" webkit_web_data_source_new_with_request :: 
    Ptr NetworkRequest ->                   -- request : TInterface "WebKit" "NetworkRequest"
    IO (Ptr WebDataSource)


webDataSourceNewWithRequest ::
    (MonadIO m, NetworkRequestK a) =>
    a ->                                    -- request
    m WebDataSource
webDataSourceNewWithRequest request = liftIO $ do
    let request' = unsafeManagedPtrCastPtr request
    result <- webkit_web_data_source_new_with_request request'
    checkUnexpectedReturnNULL "webkit_web_data_source_new_with_request" result
    result' <- (wrapObject WebDataSource) result
    touchManagedPtr request
    return result'

-- method WebDataSource::get_data
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebDataSource", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebDataSource", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "GLib" "String"
-- throws : False
-- Skip return : False

foreign import ccall "webkit_web_data_source_get_data" webkit_web_data_source_get_data :: 
    Ptr WebDataSource ->                    -- _obj : TInterface "WebKit" "WebDataSource"
    IO (Ptr GLib.String)


webDataSourceGetData ::
    (MonadIO m, WebDataSourceK a) =>
    a ->                                    -- _obj
    m GLib.String
webDataSourceGetData _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_web_data_source_get_data _obj'
    checkUnexpectedReturnNULL "webkit_web_data_source_get_data" result
    result' <- (newBoxed GLib.String) result
    touchManagedPtr _obj
    return result'

-- method WebDataSource::get_encoding
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebDataSource", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebDataSource", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "webkit_web_data_source_get_encoding" webkit_web_data_source_get_encoding :: 
    Ptr WebDataSource ->                    -- _obj : TInterface "WebKit" "WebDataSource"
    IO CString


webDataSourceGetEncoding ::
    (MonadIO m, WebDataSourceK a) =>
    a ->                                    -- _obj
    m T.Text
webDataSourceGetEncoding _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_web_data_source_get_encoding _obj'
    checkUnexpectedReturnNULL "webkit_web_data_source_get_encoding" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

-- method WebDataSource::get_initial_request
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebDataSource", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebDataSource", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "WebKit" "NetworkRequest"
-- throws : False
-- Skip return : False

foreign import ccall "webkit_web_data_source_get_initial_request" webkit_web_data_source_get_initial_request :: 
    Ptr WebDataSource ->                    -- _obj : TInterface "WebKit" "WebDataSource"
    IO (Ptr NetworkRequest)


webDataSourceGetInitialRequest ::
    (MonadIO m, WebDataSourceK a) =>
    a ->                                    -- _obj
    m NetworkRequest
webDataSourceGetInitialRequest _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_web_data_source_get_initial_request _obj'
    checkUnexpectedReturnNULL "webkit_web_data_source_get_initial_request" result
    result' <- (newObject NetworkRequest) result
    touchManagedPtr _obj
    return result'

-- method WebDataSource::get_main_resource
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebDataSource", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebDataSource", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "WebKit" "WebResource"
-- throws : False
-- Skip return : False

foreign import ccall "webkit_web_data_source_get_main_resource" webkit_web_data_source_get_main_resource :: 
    Ptr WebDataSource ->                    -- _obj : TInterface "WebKit" "WebDataSource"
    IO (Ptr WebResource)


webDataSourceGetMainResource ::
    (MonadIO m, WebDataSourceK a) =>
    a ->                                    -- _obj
    m WebResource
webDataSourceGetMainResource _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_web_data_source_get_main_resource _obj'
    checkUnexpectedReturnNULL "webkit_web_data_source_get_main_resource" result
    result' <- (newObject WebResource) result
    touchManagedPtr _obj
    return result'

-- method WebDataSource::get_request
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebDataSource", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebDataSource", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "WebKit" "NetworkRequest"
-- throws : False
-- Skip return : False

foreign import ccall "webkit_web_data_source_get_request" webkit_web_data_source_get_request :: 
    Ptr WebDataSource ->                    -- _obj : TInterface "WebKit" "WebDataSource"
    IO (Ptr NetworkRequest)


webDataSourceGetRequest ::
    (MonadIO m, WebDataSourceK a) =>
    a ->                                    -- _obj
    m NetworkRequest
webDataSourceGetRequest _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_web_data_source_get_request _obj'
    checkUnexpectedReturnNULL "webkit_web_data_source_get_request" result
    result' <- (newObject NetworkRequest) result
    touchManagedPtr _obj
    return result'

-- method WebDataSource::get_subresources
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebDataSource", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebDataSource", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TGList (TInterface "WebKit" "WebResource")
-- throws : False
-- Skip return : False

foreign import ccall "webkit_web_data_source_get_subresources" webkit_web_data_source_get_subresources :: 
    Ptr WebDataSource ->                    -- _obj : TInterface "WebKit" "WebDataSource"
    IO (Ptr (GList (Ptr WebResource)))


webDataSourceGetSubresources ::
    (MonadIO m, WebDataSourceK a) =>
    a ->                                    -- _obj
    m [WebResource]
webDataSourceGetSubresources _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_web_data_source_get_subresources _obj'
    checkUnexpectedReturnNULL "webkit_web_data_source_get_subresources" result
    result' <- unpackGList result
    result'' <- mapM (newObject WebResource) result'
    g_list_free result
    touchManagedPtr _obj
    return result''

-- method WebDataSource::get_unreachable_uri
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebDataSource", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebDataSource", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "webkit_web_data_source_get_unreachable_uri" webkit_web_data_source_get_unreachable_uri :: 
    Ptr WebDataSource ->                    -- _obj : TInterface "WebKit" "WebDataSource"
    IO CString


webDataSourceGetUnreachableUri ::
    (MonadIO m, WebDataSourceK a) =>
    a ->                                    -- _obj
    m T.Text
webDataSourceGetUnreachableUri _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_web_data_source_get_unreachable_uri _obj'
    checkUnexpectedReturnNULL "webkit_web_data_source_get_unreachable_uri" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

-- method WebDataSource::get_web_frame
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebDataSource", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebDataSource", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "WebKit" "WebFrame"
-- throws : False
-- Skip return : False

foreign import ccall "webkit_web_data_source_get_web_frame" webkit_web_data_source_get_web_frame :: 
    Ptr WebDataSource ->                    -- _obj : TInterface "WebKit" "WebDataSource"
    IO (Ptr WebFrame)


webDataSourceGetWebFrame ::
    (MonadIO m, WebDataSourceK a) =>
    a ->                                    -- _obj
    m WebFrame
webDataSourceGetWebFrame _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_web_data_source_get_web_frame _obj'
    checkUnexpectedReturnNULL "webkit_web_data_source_get_web_frame" result
    result' <- (newObject WebFrame) result
    touchManagedPtr _obj
    return result'

-- method WebDataSource::is_loading
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebDataSource", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebDataSource", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "webkit_web_data_source_is_loading" webkit_web_data_source_is_loading :: 
    Ptr WebDataSource ->                    -- _obj : TInterface "WebKit" "WebDataSource"
    IO CInt


webDataSourceIsLoading ::
    (MonadIO m, WebDataSourceK a) =>
    a ->                                    -- _obj
    m Bool
webDataSourceIsLoading _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_web_data_source_is_loading _obj'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'