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

-- * Exported types
    NetworkResponse(..)                     ,
    NetworkResponseK                        ,
    toNetworkResponse                       ,
    noNetworkResponse                       ,


 -- * Methods
-- ** networkResponseGetMessage
    networkResponseGetMessage               ,


-- ** networkResponseGetSuggestedFilename
    networkResponseGetSuggestedFilename     ,


-- ** networkResponseGetUri
    networkResponseGetUri                   ,


-- ** networkResponseNew
    networkResponseNew                      ,


-- ** networkResponseSetUri
    networkResponseSetUri                   ,




 -- * Properties
-- ** Message
    NetworkResponseMessagePropertyInfo      ,
    constructNetworkResponseMessage         ,
    getNetworkResponseMessage               ,


-- ** SuggestedFilename
    NetworkResponseSuggestedFilenamePropertyInfo,
    getNetworkResponseSuggestedFilename     ,


-- ** Uri
    NetworkResponseUriPropertyInfo          ,
    constructNetworkResponseUri             ,
    getNetworkResponseUri                   ,
    setNetworkResponseUri                   ,




    ) 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.GObject as GObject
import qualified GI.Soup as Soup

newtype NetworkResponse = NetworkResponse (ForeignPtr NetworkResponse)
foreign import ccall "webkit_network_response_get_type"
    c_webkit_network_response_get_type :: IO GType

type instance ParentTypes NetworkResponse = NetworkResponseParentTypes
type NetworkResponseParentTypes = '[GObject.Object]

instance GObject NetworkResponse where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_webkit_network_response_get_type
    

class GObject o => NetworkResponseK o
instance (GObject o, IsDescendantOf NetworkResponse o) => NetworkResponseK o

toNetworkResponse :: NetworkResponseK o => o -> IO NetworkResponse
toNetworkResponse = unsafeCastTo NetworkResponse

noNetworkResponse :: Maybe NetworkResponse
noNetworkResponse = Nothing

-- VVV Prop "message"
   -- Type: TInterface "Soup" "Message"
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]

getNetworkResponseMessage :: (MonadIO m, NetworkResponseK o) => o -> m Soup.Message
getNetworkResponseMessage obj = liftIO $ getObjectPropertyObject obj "message" Soup.Message

constructNetworkResponseMessage :: (Soup.MessageK a) => a -> IO ([Char], GValue)
constructNetworkResponseMessage val = constructObjectPropertyObject "message" val

data NetworkResponseMessagePropertyInfo
instance AttrInfo NetworkResponseMessagePropertyInfo where
    type AttrAllowedOps NetworkResponseMessagePropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint NetworkResponseMessagePropertyInfo = Soup.MessageK
    type AttrBaseTypeConstraint NetworkResponseMessagePropertyInfo = NetworkResponseK
    type AttrGetType NetworkResponseMessagePropertyInfo = Soup.Message
    type AttrLabel NetworkResponseMessagePropertyInfo = "NetworkResponse::message"
    attrGet _ = getNetworkResponseMessage
    attrSet _ = undefined
    attrConstruct _ = constructNetworkResponseMessage

-- VVV Prop "suggested-filename"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable]

getNetworkResponseSuggestedFilename :: (MonadIO m, NetworkResponseK o) => o -> m T.Text
getNetworkResponseSuggestedFilename obj = liftIO $ getObjectPropertyString obj "suggested-filename"

data NetworkResponseSuggestedFilenamePropertyInfo
instance AttrInfo NetworkResponseSuggestedFilenamePropertyInfo where
    type AttrAllowedOps NetworkResponseSuggestedFilenamePropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint NetworkResponseSuggestedFilenamePropertyInfo = (~) ()
    type AttrBaseTypeConstraint NetworkResponseSuggestedFilenamePropertyInfo = NetworkResponseK
    type AttrGetType NetworkResponseSuggestedFilenamePropertyInfo = T.Text
    type AttrLabel NetworkResponseSuggestedFilenamePropertyInfo = "NetworkResponse::suggested-filename"
    attrGet _ = getNetworkResponseSuggestedFilename
    attrSet _ = undefined
    attrConstruct _ = undefined

-- VVV Prop "uri"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable]

getNetworkResponseUri :: (MonadIO m, NetworkResponseK o) => o -> m T.Text
getNetworkResponseUri obj = liftIO $ getObjectPropertyString obj "uri"

setNetworkResponseUri :: (MonadIO m, NetworkResponseK o) => o -> T.Text -> m ()
setNetworkResponseUri obj val = liftIO $ setObjectPropertyString obj "uri" val

constructNetworkResponseUri :: T.Text -> IO ([Char], GValue)
constructNetworkResponseUri val = constructObjectPropertyString "uri" val

data NetworkResponseUriPropertyInfo
instance AttrInfo NetworkResponseUriPropertyInfo where
    type AttrAllowedOps NetworkResponseUriPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint NetworkResponseUriPropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint NetworkResponseUriPropertyInfo = NetworkResponseK
    type AttrGetType NetworkResponseUriPropertyInfo = T.Text
    type AttrLabel NetworkResponseUriPropertyInfo = "NetworkResponse::uri"
    attrGet _ = getNetworkResponseUri
    attrSet _ = setNetworkResponseUri
    attrConstruct _ = constructNetworkResponseUri

type instance AttributeList NetworkResponse = NetworkResponseAttributeList
type NetworkResponseAttributeList = ('[ '("message", NetworkResponseMessagePropertyInfo), '("suggested-filename", NetworkResponseSuggestedFilenamePropertyInfo), '("uri", NetworkResponseUriPropertyInfo)] :: [(Symbol, *)])

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

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

foreign import ccall "webkit_network_response_new" webkit_network_response_new :: 
    CString ->                              -- uri : TBasicType TUTF8
    IO (Ptr NetworkResponse)


networkResponseNew ::
    (MonadIO m) =>
    T.Text ->                               -- uri
    m NetworkResponse
networkResponseNew uri = liftIO $ do
    uri' <- textToCString uri
    result <- webkit_network_response_new uri'
    checkUnexpectedReturnNULL "webkit_network_response_new" result
    result' <- (wrapObject NetworkResponse) result
    freeMem uri'
    return result'

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

foreign import ccall "webkit_network_response_get_message" webkit_network_response_get_message :: 
    Ptr NetworkResponse ->                  -- _obj : TInterface "WebKit" "NetworkResponse"
    IO (Ptr Soup.Message)


networkResponseGetMessage ::
    (MonadIO m, NetworkResponseK a) =>
    a ->                                    -- _obj
    m Soup.Message
networkResponseGetMessage _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_network_response_get_message _obj'
    checkUnexpectedReturnNULL "webkit_network_response_get_message" result
    result' <- (newObject Soup.Message) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "webkit_network_response_get_suggested_filename" webkit_network_response_get_suggested_filename :: 
    Ptr NetworkResponse ->                  -- _obj : TInterface "WebKit" "NetworkResponse"
    IO CString


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

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

foreign import ccall "webkit_network_response_get_uri" webkit_network_response_get_uri :: 
    Ptr NetworkResponse ->                  -- _obj : TInterface "WebKit" "NetworkResponse"
    IO CString


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

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

foreign import ccall "webkit_network_response_set_uri" webkit_network_response_set_uri :: 
    Ptr NetworkResponse ->                  -- _obj : TInterface "WebKit" "NetworkResponse"
    CString ->                              -- uri : TBasicType TUTF8
    IO ()


networkResponseSetUri ::
    (MonadIO m, NetworkResponseK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- uri
    m ()
networkResponseSetUri _obj uri = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    uri' <- textToCString uri
    webkit_network_response_set_uri _obj' uri'
    touchManagedPtr _obj
    freeMem uri'
    return ()