{-# LINE 2 "./Graphics/UI/Gtk/WebKit/NetworkRequest.chs" #-}
-- -*-haskell-*-
-----------------------------------------------------------------------------
-- Module : Graphics.UI.Gtk.WebKit.NetworkRequest
-- Author : Cjacker Huang
-- Copyright : (c) 2009 Cjacker Huang <jzhuang@redflag-1 .com>
--
-- This library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
-- License as published by the Free Software Foundation; either
-- version 2.1 of the License, or (at your option) any later version.
--
-- This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- Lesser General Public License for more details.
--
-- |
-- Maintainer : gtk2hs-users@lists.sourceforge.net
-- Stability : provisional
-- Portability : portable (depends on GHC)
--
-- The target of a navigation request
-----------------------------------------------------------------------------

module Graphics.UI.Gtk.WebKit.NetworkRequest (
-- * Types
  NetworkRequest,
  NetworkRequestClass,

-- * Constructors
  networkRequestNew,

-- * Methods
  networkRequestSetUri,
  networkRequestGetUri,
) where

import Control.Monad (liftM)

import System.Glib.FFI
import System.Glib.UTFString
import System.Glib.GList
import System.Glib.GError
import Graphics.UI.Gtk.Gdk.Events

import Graphics.UI.Gtk.Abstract.Object (makeNewObject)
import Graphics.UI.Gtk.WebKit.Types
{-# LINE 49 "./Graphics/UI/Gtk/WebKit/NetworkRequest.chs" #-}
import System.Glib.GObject
{-# LINE 50 "./Graphics/UI/Gtk/WebKit/NetworkRequest.chs" #-}


{-# LINE 52 "./Graphics/UI/Gtk/WebKit/NetworkRequest.chs" #-}

------------------
-- Constructors



-- | Create a new NetworkRequest with the given @uri@.
--
-- It is used whenever WebKit wants to provide information
-- about a request that will be sent, or has been sent.
networkRequestNew ::
    String -- ^ @uri@ - the uri of the request
 -> IO NetworkRequest
networkRequestNew uri =
    withCString uri $ \uriPtr ->
      constructNewGObject mkNetworkRequest $
        webkit_network_request_new uriPtr


-- | Set the URI of 'NetworkRequest'.
--
networkRequestSetUri ::
    NetworkRequestClass self => self
 -> String -- ^ @uri@ - the uri will be set to the request.
 -> IO()
networkRequestSetUri networkrequest uri =
    withCString uri $ \uriPtr ->
      (\(NetworkRequest arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->webkit_network_request_set_uri argPtr1 arg2)
{-# LINE 80 "./Graphics/UI/Gtk/WebKit/NetworkRequest.chs" #-}
        (toNetworkRequest networkrequest)
        uriPtr


-- | Return the uri of 'NetworkRequest'.
networkRequestGetUri ::
    NetworkRequestClass self => self
 -> IO (Maybe String) -- ^ the URI or @Nothing@ in case failed.
networkRequestGetUri networkrequest =
    (\(NetworkRequest arg1) -> withForeignPtr arg1 $ \argPtr1 ->webkit_network_request_get_uri argPtr1)
{-# LINE 90 "./Graphics/UI/Gtk/WebKit/NetworkRequest.chs" #-}
      (toNetworkRequest networkrequest) >>=
      maybePeek peekCString

foreign import ccall safe "webkit_network_request_new"
  webkit_network_request_new :: ((Ptr CChar) -> (IO (Ptr NetworkRequest)))

foreign import ccall safe "webkit_network_request_set_uri"
  webkit_network_request_set_uri :: ((Ptr NetworkRequest) -> ((Ptr CChar) -> (IO ())))

foreign import ccall safe "webkit_network_request_get_uri"
  webkit_network_request_get_uri :: ((Ptr NetworkRequest) -> (IO (Ptr CChar)))