module Graphics.UI.Gtk.WebKit.WebResource (
WebResource,
WebResourceClass,
webResourceNew,
webResourceGetData,
webResourceGetEncoding,
webResourceGetFrameName,
webResourceGetMimeType,
webResourceGetUri,
) where
import Control.Monad (liftM)
import Data.ByteString (ByteString, useAsCStringLen)
import System.Glib.FFI
import System.Glib.UTFString
import System.Glib.GList
import System.Glib.GString
import System.Glib.GError
import Graphics.UI.Gtk.Gdk.Events
import Graphics.UI.Gtk.Abstract.Object (makeNewObject)
import Graphics.UI.Gtk.WebKit.Types
import System.Glib.GObject
webResourceNew :: GlibString string => ByteString -> string -> string -> string -> string -> IO WebResource
webResourceNew resData uri mimeType encoding frameName =
useAsCStringLen resData $ \(dataPtr, size) ->
withUTFString uri $ \uriPtr ->
withUTFString mimeType $ \mimePtr ->
withUTFString encoding $ \encodingPtr ->
withUTFString frameName $ \framePtr ->
wrapNewGObject mkWebResource $
webkit_web_resource_new dataPtr (fromIntegral size) uriPtr mimePtr encodingPtr framePtr
webResourceGetData :: WebResourceClass self => self -> IO (Maybe ByteString)
webResourceGetData wr =
(\(WebResource arg1) -> withForeignPtr arg1 $ \argPtr1 ->webkit_web_resource_get_data argPtr1) (toWebResource wr) >>= readGStringByteString
webResourceGetEncoding ::
(WebResourceClass self, GlibString string) => self
-> IO (Maybe string)
webResourceGetEncoding wr =
(\(WebResource arg1) -> withForeignPtr arg1 $ \argPtr1 ->webkit_web_resource_get_encoding argPtr1) (toWebResource wr) >>= maybePeek peekUTFString
webResourceGetFrameName ::
(WebResourceClass self, GlibString string) => self
-> IO (Maybe string)
webResourceGetFrameName wr =
(\(WebResource arg1) -> withForeignPtr arg1 $ \argPtr1 ->webkit_web_resource_get_frame_name argPtr1) (toWebResource wr) >>= maybePeek peekUTFString
webResourceGetMimeType ::
(WebResourceClass self, GlibString string) => self
-> IO (Maybe string)
webResourceGetMimeType wr =
(\(WebResource arg1) -> withForeignPtr arg1 $ \argPtr1 ->webkit_web_resource_get_mime_type argPtr1) (toWebResource wr) >>= maybePeek peekUTFString
webResourceGetUri ::
(WebResourceClass self, GlibString string) => self
-> IO string
webResourceGetUri wr =
(\(WebResource arg1) -> withForeignPtr arg1 $ \argPtr1 ->webkit_web_resource_get_uri argPtr1) (toWebResource wr) >>= peekUTFString
foreign import ccall safe "webkit_web_resource_new"
webkit_web_resource_new :: ((Ptr CChar) -> (CLong -> ((Ptr CChar) -> ((Ptr CChar) -> ((Ptr CChar) -> ((Ptr CChar) -> (IO (Ptr WebResource))))))))
foreign import ccall safe "webkit_web_resource_get_data"
webkit_web_resource_get_data :: ((Ptr WebResource) -> (IO (Ptr ())))
foreign import ccall safe "webkit_web_resource_get_encoding"
webkit_web_resource_get_encoding :: ((Ptr WebResource) -> (IO (Ptr CChar)))
foreign import ccall safe "webkit_web_resource_get_frame_name"
webkit_web_resource_get_frame_name :: ((Ptr WebResource) -> (IO (Ptr CChar)))
foreign import ccall safe "webkit_web_resource_get_mime_type"
webkit_web_resource_get_mime_type :: ((Ptr WebResource) -> (IO (Ptr CChar)))
foreign import ccall safe "webkit_web_resource_get_uri"
webkit_web_resource_get_uri :: ((Ptr WebResource) -> (IO (Ptr CChar)))