module GI.WebKit2.Objects.Download
(
Download(..) ,
DownloadK ,
toDownload ,
noDownload ,
downloadCancel ,
downloadGetAllowOverwrite ,
downloadGetDestination ,
downloadGetElapsedTime ,
downloadGetEstimatedProgress ,
downloadGetReceivedDataLength ,
downloadGetRequest ,
downloadGetResponse ,
downloadGetWebView ,
downloadSetAllowOverwrite ,
downloadSetDestination ,
DownloadAllowOverwritePropertyInfo ,
constructDownloadAllowOverwrite ,
getDownloadAllowOverwrite ,
setDownloadAllowOverwrite ,
DownloadDestinationPropertyInfo ,
getDownloadDestination ,
DownloadEstimatedProgressPropertyInfo ,
getDownloadEstimatedProgress ,
DownloadResponsePropertyInfo ,
getDownloadResponse ,
DownloadCreatedDestinationCallback ,
DownloadCreatedDestinationCallbackC ,
DownloadCreatedDestinationSignalInfo ,
afterDownloadCreatedDestination ,
downloadCreatedDestinationCallbackWrapper,
downloadCreatedDestinationClosure ,
mkDownloadCreatedDestinationCallback ,
noDownloadCreatedDestinationCallback ,
onDownloadCreatedDestination ,
DownloadDecideDestinationCallback ,
DownloadDecideDestinationCallbackC ,
DownloadDecideDestinationSignalInfo ,
afterDownloadDecideDestination ,
downloadDecideDestinationCallbackWrapper,
downloadDecideDestinationClosure ,
mkDownloadDecideDestinationCallback ,
noDownloadDecideDestinationCallback ,
onDownloadDecideDestination ,
DownloadFailedCallback ,
DownloadFailedCallbackC ,
DownloadFailedSignalInfo ,
afterDownloadFailed ,
downloadFailedCallbackWrapper ,
downloadFailedClosure ,
mkDownloadFailedCallback ,
noDownloadFailedCallback ,
onDownloadFailed ,
DownloadFinishedCallback ,
DownloadFinishedCallbackC ,
DownloadFinishedSignalInfo ,
afterDownloadFinished ,
downloadFinishedCallbackWrapper ,
downloadFinishedClosure ,
mkDownloadFinishedCallback ,
noDownloadFinishedCallback ,
onDownloadFinished ,
DownloadReceivedDataCallback ,
DownloadReceivedDataCallbackC ,
DownloadReceivedDataSignalInfo ,
afterDownloadReceivedData ,
downloadReceivedDataCallbackWrapper ,
downloadReceivedDataClosure ,
mkDownloadReceivedDataCallback ,
noDownloadReceivedDataCallback ,
onDownloadReceivedData ,
) 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.WebKit2.Types
import GI.WebKit2.Callbacks
import qualified GI.GObject as GObject
newtype Download = Download (ForeignPtr Download)
foreign import ccall "webkit_download_get_type"
c_webkit_download_get_type :: IO GType
type instance ParentTypes Download = DownloadParentTypes
type DownloadParentTypes = '[GObject.Object]
instance GObject Download where
gobjectIsInitiallyUnowned _ = False
gobjectType _ = c_webkit_download_get_type
class GObject o => DownloadK o
instance (GObject o, IsDescendantOf Download o) => DownloadK o
toDownload :: DownloadK o => o -> IO Download
toDownload = unsafeCastTo Download
noDownload :: Maybe Download
noDownload = Nothing
type DownloadCreatedDestinationCallback =
T.Text ->
IO ()
noDownloadCreatedDestinationCallback :: Maybe DownloadCreatedDestinationCallback
noDownloadCreatedDestinationCallback = Nothing
type DownloadCreatedDestinationCallbackC =
Ptr () ->
CString ->
Ptr () ->
IO ()
foreign import ccall "wrapper"
mkDownloadCreatedDestinationCallback :: DownloadCreatedDestinationCallbackC -> IO (FunPtr DownloadCreatedDestinationCallbackC)
downloadCreatedDestinationClosure :: DownloadCreatedDestinationCallback -> IO Closure
downloadCreatedDestinationClosure cb = newCClosure =<< mkDownloadCreatedDestinationCallback wrapped
where wrapped = downloadCreatedDestinationCallbackWrapper cb
downloadCreatedDestinationCallbackWrapper ::
DownloadCreatedDestinationCallback ->
Ptr () ->
CString ->
Ptr () ->
IO ()
downloadCreatedDestinationCallbackWrapper _cb _ destination _ = do
destination' <- cstringToText destination
_cb destination'
onDownloadCreatedDestination :: (GObject a, MonadIO m) => a -> DownloadCreatedDestinationCallback -> m SignalHandlerId
onDownloadCreatedDestination obj cb = liftIO $ connectDownloadCreatedDestination obj cb SignalConnectBefore
afterDownloadCreatedDestination :: (GObject a, MonadIO m) => a -> DownloadCreatedDestinationCallback -> m SignalHandlerId
afterDownloadCreatedDestination obj cb = connectDownloadCreatedDestination obj cb SignalConnectAfter
connectDownloadCreatedDestination :: (GObject a, MonadIO m) =>
a -> DownloadCreatedDestinationCallback -> SignalConnectMode -> m SignalHandlerId
connectDownloadCreatedDestination obj cb after = liftIO $ do
cb' <- mkDownloadCreatedDestinationCallback (downloadCreatedDestinationCallbackWrapper cb)
connectSignalFunPtr obj "created-destination" cb' after
type DownloadDecideDestinationCallback =
T.Text ->
IO Bool
noDownloadDecideDestinationCallback :: Maybe DownloadDecideDestinationCallback
noDownloadDecideDestinationCallback = Nothing
type DownloadDecideDestinationCallbackC =
Ptr () ->
CString ->
Ptr () ->
IO CInt
foreign import ccall "wrapper"
mkDownloadDecideDestinationCallback :: DownloadDecideDestinationCallbackC -> IO (FunPtr DownloadDecideDestinationCallbackC)
downloadDecideDestinationClosure :: DownloadDecideDestinationCallback -> IO Closure
downloadDecideDestinationClosure cb = newCClosure =<< mkDownloadDecideDestinationCallback wrapped
where wrapped = downloadDecideDestinationCallbackWrapper cb
downloadDecideDestinationCallbackWrapper ::
DownloadDecideDestinationCallback ->
Ptr () ->
CString ->
Ptr () ->
IO CInt
downloadDecideDestinationCallbackWrapper _cb _ suggested_filename _ = do
suggested_filename' <- cstringToText suggested_filename
result <- _cb suggested_filename'
let result' = (fromIntegral . fromEnum) result
return result'
onDownloadDecideDestination :: (GObject a, MonadIO m) => a -> DownloadDecideDestinationCallback -> m SignalHandlerId
onDownloadDecideDestination obj cb = liftIO $ connectDownloadDecideDestination obj cb SignalConnectBefore
afterDownloadDecideDestination :: (GObject a, MonadIO m) => a -> DownloadDecideDestinationCallback -> m SignalHandlerId
afterDownloadDecideDestination obj cb = connectDownloadDecideDestination obj cb SignalConnectAfter
connectDownloadDecideDestination :: (GObject a, MonadIO m) =>
a -> DownloadDecideDestinationCallback -> SignalConnectMode -> m SignalHandlerId
connectDownloadDecideDestination obj cb after = liftIO $ do
cb' <- mkDownloadDecideDestinationCallback (downloadDecideDestinationCallbackWrapper cb)
connectSignalFunPtr obj "decide-destination" cb' after
type DownloadFailedCallback =
Ptr () ->
IO ()
noDownloadFailedCallback :: Maybe DownloadFailedCallback
noDownloadFailedCallback = Nothing
type DownloadFailedCallbackC =
Ptr () ->
Ptr () ->
Ptr () ->
IO ()
foreign import ccall "wrapper"
mkDownloadFailedCallback :: DownloadFailedCallbackC -> IO (FunPtr DownloadFailedCallbackC)
downloadFailedClosure :: DownloadFailedCallback -> IO Closure
downloadFailedClosure cb = newCClosure =<< mkDownloadFailedCallback wrapped
where wrapped = downloadFailedCallbackWrapper cb
downloadFailedCallbackWrapper ::
DownloadFailedCallback ->
Ptr () ->
Ptr () ->
Ptr () ->
IO ()
downloadFailedCallbackWrapper _cb _ error_ _ = do
_cb error_
onDownloadFailed :: (GObject a, MonadIO m) => a -> DownloadFailedCallback -> m SignalHandlerId
onDownloadFailed obj cb = liftIO $ connectDownloadFailed obj cb SignalConnectBefore
afterDownloadFailed :: (GObject a, MonadIO m) => a -> DownloadFailedCallback -> m SignalHandlerId
afterDownloadFailed obj cb = connectDownloadFailed obj cb SignalConnectAfter
connectDownloadFailed :: (GObject a, MonadIO m) =>
a -> DownloadFailedCallback -> SignalConnectMode -> m SignalHandlerId
connectDownloadFailed obj cb after = liftIO $ do
cb' <- mkDownloadFailedCallback (downloadFailedCallbackWrapper cb)
connectSignalFunPtr obj "failed" cb' after
type DownloadFinishedCallback =
IO ()
noDownloadFinishedCallback :: Maybe DownloadFinishedCallback
noDownloadFinishedCallback = Nothing
type DownloadFinishedCallbackC =
Ptr () ->
Ptr () ->
IO ()
foreign import ccall "wrapper"
mkDownloadFinishedCallback :: DownloadFinishedCallbackC -> IO (FunPtr DownloadFinishedCallbackC)
downloadFinishedClosure :: DownloadFinishedCallback -> IO Closure
downloadFinishedClosure cb = newCClosure =<< mkDownloadFinishedCallback wrapped
where wrapped = downloadFinishedCallbackWrapper cb
downloadFinishedCallbackWrapper ::
DownloadFinishedCallback ->
Ptr () ->
Ptr () ->
IO ()
downloadFinishedCallbackWrapper _cb _ _ = do
_cb
onDownloadFinished :: (GObject a, MonadIO m) => a -> DownloadFinishedCallback -> m SignalHandlerId
onDownloadFinished obj cb = liftIO $ connectDownloadFinished obj cb SignalConnectBefore
afterDownloadFinished :: (GObject a, MonadIO m) => a -> DownloadFinishedCallback -> m SignalHandlerId
afterDownloadFinished obj cb = connectDownloadFinished obj cb SignalConnectAfter
connectDownloadFinished :: (GObject a, MonadIO m) =>
a -> DownloadFinishedCallback -> SignalConnectMode -> m SignalHandlerId
connectDownloadFinished obj cb after = liftIO $ do
cb' <- mkDownloadFinishedCallback (downloadFinishedCallbackWrapper cb)
connectSignalFunPtr obj "finished" cb' after
type DownloadReceivedDataCallback =
Word64 ->
IO ()
noDownloadReceivedDataCallback :: Maybe DownloadReceivedDataCallback
noDownloadReceivedDataCallback = Nothing
type DownloadReceivedDataCallbackC =
Ptr () ->
Word64 ->
Ptr () ->
IO ()
foreign import ccall "wrapper"
mkDownloadReceivedDataCallback :: DownloadReceivedDataCallbackC -> IO (FunPtr DownloadReceivedDataCallbackC)
downloadReceivedDataClosure :: DownloadReceivedDataCallback -> IO Closure
downloadReceivedDataClosure cb = newCClosure =<< mkDownloadReceivedDataCallback wrapped
where wrapped = downloadReceivedDataCallbackWrapper cb
downloadReceivedDataCallbackWrapper ::
DownloadReceivedDataCallback ->
Ptr () ->
Word64 ->
Ptr () ->
IO ()
downloadReceivedDataCallbackWrapper _cb _ data_length _ = do
_cb data_length
onDownloadReceivedData :: (GObject a, MonadIO m) => a -> DownloadReceivedDataCallback -> m SignalHandlerId
onDownloadReceivedData obj cb = liftIO $ connectDownloadReceivedData obj cb SignalConnectBefore
afterDownloadReceivedData :: (GObject a, MonadIO m) => a -> DownloadReceivedDataCallback -> m SignalHandlerId
afterDownloadReceivedData obj cb = connectDownloadReceivedData obj cb SignalConnectAfter
connectDownloadReceivedData :: (GObject a, MonadIO m) =>
a -> DownloadReceivedDataCallback -> SignalConnectMode -> m SignalHandlerId
connectDownloadReceivedData obj cb after = liftIO $ do
cb' <- mkDownloadReceivedDataCallback (downloadReceivedDataCallbackWrapper cb)
connectSignalFunPtr obj "received-data" cb' after
getDownloadAllowOverwrite :: (MonadIO m, DownloadK o) => o -> m Bool
getDownloadAllowOverwrite obj = liftIO $ getObjectPropertyBool obj "allow-overwrite"
setDownloadAllowOverwrite :: (MonadIO m, DownloadK o) => o -> Bool -> m ()
setDownloadAllowOverwrite obj val = liftIO $ setObjectPropertyBool obj "allow-overwrite" val
constructDownloadAllowOverwrite :: Bool -> IO ([Char], GValue)
constructDownloadAllowOverwrite val = constructObjectPropertyBool "allow-overwrite" val
data DownloadAllowOverwritePropertyInfo
instance AttrInfo DownloadAllowOverwritePropertyInfo where
type AttrAllowedOps DownloadAllowOverwritePropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
type AttrSetTypeConstraint DownloadAllowOverwritePropertyInfo = (~) Bool
type AttrBaseTypeConstraint DownloadAllowOverwritePropertyInfo = DownloadK
type AttrGetType DownloadAllowOverwritePropertyInfo = Bool
type AttrLabel DownloadAllowOverwritePropertyInfo = "Download::allow-overwrite"
attrGet _ = getDownloadAllowOverwrite
attrSet _ = setDownloadAllowOverwrite
attrConstruct _ = constructDownloadAllowOverwrite
getDownloadDestination :: (MonadIO m, DownloadK o) => o -> m T.Text
getDownloadDestination obj = liftIO $ getObjectPropertyString obj "destination"
data DownloadDestinationPropertyInfo
instance AttrInfo DownloadDestinationPropertyInfo where
type AttrAllowedOps DownloadDestinationPropertyInfo = '[ 'AttrGet]
type AttrSetTypeConstraint DownloadDestinationPropertyInfo = (~) ()
type AttrBaseTypeConstraint DownloadDestinationPropertyInfo = DownloadK
type AttrGetType DownloadDestinationPropertyInfo = T.Text
type AttrLabel DownloadDestinationPropertyInfo = "Download::destination"
attrGet _ = getDownloadDestination
attrSet _ = undefined
attrConstruct _ = undefined
getDownloadEstimatedProgress :: (MonadIO m, DownloadK o) => o -> m Double
getDownloadEstimatedProgress obj = liftIO $ getObjectPropertyDouble obj "estimated-progress"
data DownloadEstimatedProgressPropertyInfo
instance AttrInfo DownloadEstimatedProgressPropertyInfo where
type AttrAllowedOps DownloadEstimatedProgressPropertyInfo = '[ 'AttrGet]
type AttrSetTypeConstraint DownloadEstimatedProgressPropertyInfo = (~) ()
type AttrBaseTypeConstraint DownloadEstimatedProgressPropertyInfo = DownloadK
type AttrGetType DownloadEstimatedProgressPropertyInfo = Double
type AttrLabel DownloadEstimatedProgressPropertyInfo = "Download::estimated-progress"
attrGet _ = getDownloadEstimatedProgress
attrSet _ = undefined
attrConstruct _ = undefined
getDownloadResponse :: (MonadIO m, DownloadK o) => o -> m URIResponse
getDownloadResponse obj = liftIO $ getObjectPropertyObject obj "response" URIResponse
data DownloadResponsePropertyInfo
instance AttrInfo DownloadResponsePropertyInfo where
type AttrAllowedOps DownloadResponsePropertyInfo = '[ 'AttrGet]
type AttrSetTypeConstraint DownloadResponsePropertyInfo = (~) ()
type AttrBaseTypeConstraint DownloadResponsePropertyInfo = DownloadK
type AttrGetType DownloadResponsePropertyInfo = URIResponse
type AttrLabel DownloadResponsePropertyInfo = "Download::response"
attrGet _ = getDownloadResponse
attrSet _ = undefined
attrConstruct _ = undefined
type instance AttributeList Download = DownloadAttributeList
type DownloadAttributeList = ('[ '("allow-overwrite", DownloadAllowOverwritePropertyInfo), '("destination", DownloadDestinationPropertyInfo), '("estimated-progress", DownloadEstimatedProgressPropertyInfo), '("response", DownloadResponsePropertyInfo)] :: [(Symbol, *)])
data DownloadCreatedDestinationSignalInfo
instance SignalInfo DownloadCreatedDestinationSignalInfo where
type HaskellCallbackType DownloadCreatedDestinationSignalInfo = DownloadCreatedDestinationCallback
connectSignal _ = connectDownloadCreatedDestination
data DownloadDecideDestinationSignalInfo
instance SignalInfo DownloadDecideDestinationSignalInfo where
type HaskellCallbackType DownloadDecideDestinationSignalInfo = DownloadDecideDestinationCallback
connectSignal _ = connectDownloadDecideDestination
data DownloadFailedSignalInfo
instance SignalInfo DownloadFailedSignalInfo where
type HaskellCallbackType DownloadFailedSignalInfo = DownloadFailedCallback
connectSignal _ = connectDownloadFailed
data DownloadFinishedSignalInfo
instance SignalInfo DownloadFinishedSignalInfo where
type HaskellCallbackType DownloadFinishedSignalInfo = DownloadFinishedCallback
connectSignal _ = connectDownloadFinished
data DownloadReceivedDataSignalInfo
instance SignalInfo DownloadReceivedDataSignalInfo where
type HaskellCallbackType DownloadReceivedDataSignalInfo = DownloadReceivedDataCallback
connectSignal _ = connectDownloadReceivedData
type instance SignalList Download = DownloadSignalList
type DownloadSignalList = ('[ '("created-destination", DownloadCreatedDestinationSignalInfo), '("decide-destination", DownloadDecideDestinationSignalInfo), '("failed", DownloadFailedSignalInfo), '("finished", DownloadFinishedSignalInfo), '("notify", GObject.ObjectNotifySignalInfo), '("received-data", DownloadReceivedDataSignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])
foreign import ccall "webkit_download_cancel" webkit_download_cancel ::
Ptr Download ->
IO ()
downloadCancel ::
(MonadIO m, DownloadK a) =>
a ->
m ()
downloadCancel _obj = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
webkit_download_cancel _obj'
touchManagedPtr _obj
return ()
foreign import ccall "webkit_download_get_allow_overwrite" webkit_download_get_allow_overwrite ::
Ptr Download ->
IO CInt
downloadGetAllowOverwrite ::
(MonadIO m, DownloadK a) =>
a ->
m Bool
downloadGetAllowOverwrite _obj = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
result <- webkit_download_get_allow_overwrite _obj'
let result' = (/= 0) result
touchManagedPtr _obj
return result'
foreign import ccall "webkit_download_get_destination" webkit_download_get_destination ::
Ptr Download ->
IO CString
downloadGetDestination ::
(MonadIO m, DownloadK a) =>
a ->
m T.Text
downloadGetDestination _obj = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
result <- webkit_download_get_destination _obj'
checkUnexpectedReturnNULL "webkit_download_get_destination" result
result' <- cstringToText result
touchManagedPtr _obj
return result'
foreign import ccall "webkit_download_get_elapsed_time" webkit_download_get_elapsed_time ::
Ptr Download ->
IO CDouble
downloadGetElapsedTime ::
(MonadIO m, DownloadK a) =>
a ->
m Double
downloadGetElapsedTime _obj = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
result <- webkit_download_get_elapsed_time _obj'
let result' = realToFrac result
touchManagedPtr _obj
return result'
foreign import ccall "webkit_download_get_estimated_progress" webkit_download_get_estimated_progress ::
Ptr Download ->
IO CDouble
downloadGetEstimatedProgress ::
(MonadIO m, DownloadK a) =>
a ->
m Double
downloadGetEstimatedProgress _obj = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
result <- webkit_download_get_estimated_progress _obj'
let result' = realToFrac result
touchManagedPtr _obj
return result'
foreign import ccall "webkit_download_get_received_data_length" webkit_download_get_received_data_length ::
Ptr Download ->
IO Word64
downloadGetReceivedDataLength ::
(MonadIO m, DownloadK a) =>
a ->
m Word64
downloadGetReceivedDataLength _obj = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
result <- webkit_download_get_received_data_length _obj'
touchManagedPtr _obj
return result
foreign import ccall "webkit_download_get_request" webkit_download_get_request ::
Ptr Download ->
IO (Ptr URIRequest)
downloadGetRequest ::
(MonadIO m, DownloadK a) =>
a ->
m URIRequest
downloadGetRequest _obj = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
result <- webkit_download_get_request _obj'
checkUnexpectedReturnNULL "webkit_download_get_request" result
result' <- (newObject URIRequest) result
touchManagedPtr _obj
return result'
foreign import ccall "webkit_download_get_response" webkit_download_get_response ::
Ptr Download ->
IO (Ptr URIResponse)
downloadGetResponse ::
(MonadIO m, DownloadK a) =>
a ->
m URIResponse
downloadGetResponse _obj = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
result <- webkit_download_get_response _obj'
checkUnexpectedReturnNULL "webkit_download_get_response" result
result' <- (newObject URIResponse) result
touchManagedPtr _obj
return result'
foreign import ccall "webkit_download_get_web_view" webkit_download_get_web_view ::
Ptr Download ->
IO (Ptr WebView)
downloadGetWebView ::
(MonadIO m, DownloadK a) =>
a ->
m WebView
downloadGetWebView _obj = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
result <- webkit_download_get_web_view _obj'
checkUnexpectedReturnNULL "webkit_download_get_web_view" result
result' <- (newObject WebView) result
touchManagedPtr _obj
return result'
foreign import ccall "webkit_download_set_allow_overwrite" webkit_download_set_allow_overwrite ::
Ptr Download ->
CInt ->
IO ()
downloadSetAllowOverwrite ::
(MonadIO m, DownloadK a) =>
a ->
Bool ->
m ()
downloadSetAllowOverwrite _obj allowed = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
let allowed' = (fromIntegral . fromEnum) allowed
webkit_download_set_allow_overwrite _obj' allowed'
touchManagedPtr _obj
return ()
foreign import ccall "webkit_download_set_destination" webkit_download_set_destination ::
Ptr Download ->
CString ->
IO ()
downloadSetDestination ::
(MonadIO m, DownloadK a) =>
a ->
T.Text ->
m ()
downloadSetDestination _obj uri = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
uri' <- textToCString uri
webkit_download_set_destination _obj' uri'
touchManagedPtr _obj
freeMem uri'
return ()