{-# LINE 2 "./Graphics/UI/Gtk/WebKit/Download.chs" #-}-- -*-haskell-*-------------------------------------------------------------------------------- Module : Graphics.UI.Gtk.WebKit.Download-- Author : Cjacker Huang-- Copyright : (c) 2009 Cjacker Huang <jzhuang@redflag-1 .com>-- Copyright : (c) 2010 Andy Stewart <lazycat.manatee@gmail.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)---- Object used to communicate with the application when downloading-----------------------------------------------------------------------------moduleGraphics.UI.Gtk.WebKit.Download(-- * TypesDownload,-- * EnumsDownloadError(..),DownloadStatus(..),-- * ConstructorsdownloadNew,-- * MethodsdownloadStart,downloadCancel,downloadGetUri,downloadGetNetworkRequest,downloadGetSuggestedFilename,downloadGetDestinationUri,downloadGetProgress,downloadGetElapsedTime,downloadGetTotalSize,downloadGetCurrentSize,downloadGetStatus,downloadSetDestinationUri,-- * AttributescurrentSize,destinationUri,networkRequest,networkResponse,progress,status,suggestedFilename,totalSize,-- * SignalsdownloadError,)whereimportControl.Monad(liftM)importSystem.Glib.FFIimportSystem.Glib.UTFStringimportSystem.Glib.GListimportSystem.Glib.GErrorimportSystem.Glib.AttributesimportSystem.Glib.PropertiesimportGraphics.UI.Gtk.Gdk.EventsimportGraphics.UI.Gtk.Abstract.Object(makeNewObject)importGraphics.UI.Gtk.WebKit.Types{-# LINE 78 "./Graphics/UI/Gtk/WebKit/Download.chs" #-}importGraphics.UI.Gtk.WebKit.Signals{-# LINE 79 "./Graphics/UI/Gtk/WebKit/Download.chs" #-}importSystem.Glib.GObject{-# LINE 80 "./Graphics/UI/Gtk/WebKit/Download.chs" #-}{-# LINE 82 "./Graphics/UI/Gtk/WebKit/Download.chs" #-}-- * EnumsdataDownloadError=DownloadErrorCancelledByUser|DownloadErrorDestination|DownloadErrorNetworkderiving(Enum){-# LINE 86 "./Graphics/UI/Gtk/WebKit/Download.chs" #-}dataDownloadStatus=DownloadStatusError|DownloadStatusCreated|DownloadStatusStarted|DownloadStatusCancelled|DownloadStatusFinishedinstanceEnumDownloadStatuswherefromEnumDownloadStatusError=(-1)fromEnumDownloadStatusCreated=0fromEnumDownloadStatusStarted=1fromEnumDownloadStatusCancelled=2fromEnumDownloadStatusFinished=3toEnum(-1)=DownloadStatusErrortoEnum0=DownloadStatusCreatedtoEnum1=DownloadStatusStartedtoEnum2=DownloadStatusCancelledtoEnum3=DownloadStatusFinishedtoEnumunmatched=error("DownloadStatus.toEnum: Cannot match "++showunmatched)succDownloadStatusError=DownloadStatusCreatedsuccDownloadStatusCreated=DownloadStatusStartedsuccDownloadStatusStarted=DownloadStatusCancelledsuccDownloadStatusCancelled=DownloadStatusFinishedsucc_=undefinedpredDownloadStatusCreated=DownloadStatusErrorpredDownloadStatusStarted=DownloadStatusCreatedpredDownloadStatusCancelled=DownloadStatusStartedpredDownloadStatusFinished=DownloadStatusCancelledpred_=undefinedenumFromToxy|fromEnumx==fromEnumy=[y]|otherwise=x:enumFromTo(succx)yenumFromx=enumFromToxDownloadStatusFinishedenumFromThen__=error"Enum DownloadStatus: enumFromThen not implemented"enumFromThenTo___=error"Enum DownloadStatus: enumFromThenTo not implemented"{-# LINE 87 "./Graphics/UI/Gtk/WebKit/Download.chs" #-}-------------------- Constructors-- | Create a new 'Download' instance for the given 'NetworkRequest'---- Object used to communicate with the application when downloading.downloadNew::NetworkRequestClassrequest=>request->IODownloaddownloadNewnr=makeNewGObjectmkDownload$(\(NetworkRequestarg1)->withForeignPtrarg1$\argPtr1->webkit_download_newargPtr1)(toNetworkRequestnr)-- | Initiates the 'Download'.---- Notice that you must have set the destination-uri property before-- calling this function.downloadStart::DownloadClassself=>self->IO()downloadStartdl=(\(Downloadarg1)->withForeignPtrarg1$\argPtr1->webkit_download_startargPtr1)(toDownloaddl)-- | Cancels the 'Download'.downloadCancel::DownloadClassself=>self->IO()downloadCanceldl=(\(Downloadarg1)->withForeignPtrarg1$\argPtr1->webkit_download_cancelargPtr1)(toDownloaddl)-- | Retrieves the URI from 'Download' which is being downloaded.downloadGetUri::DownloadClassself=>self->IO(MaybeString)-- ^ the uri or @Nothing@ in case of faileddownloadGetUridl=(\(Downloadarg1)->withForeignPtrarg1$\argPtr1->webkit_download_get_uriargPtr1)(toDownloaddl)>>=maybePeekpeekCString-- | Retrieves the 'NetworkRequest' that backs the download process.downloadGetNetworkRequest::DownloadClassself=>self->IONetworkRequestdownloadGetNetworkRequestdl=makeNewGObjectmkNetworkRequest$(\(Downloadarg1)->withForeignPtrarg1$\argPtr1->webkit_download_get_network_requestargPtr1)(toDownloaddl)-- | Retrieves the filename that was suggested by the server,-- or the one derived from the URI.downloadGetSuggestedFilename::DownloadClassself=>self->IO(MaybeString)-- ^ the suggested filename or @Nothing@ in case of faileddownloadGetSuggestedFilenamedl=(\(Downloadarg1)->withForeignPtrarg1$\argPtr1->webkit_download_get_suggested_filenameargPtr1)(toDownloaddl)>>=maybePeekpeekCString-- | Obtains the URI to which the downloaded file will be written.---- It is set by Application before call 'downloadStart'downloadGetDestinationUri::DownloadClassself=>self->IO(MaybeString)downloadGetDestinationUridl=(\(Downloadarg1)->withForeignPtrarg1$\argPtr1->webkit_download_get_destination_uriargPtr1)(toDownloaddl)>>=maybePeekpeekCString-- | Defines the URI that should be used to save the downloaded file to.downloadSetDestinationUri::DownloadClassself=>self->String-- ^ @destination_uri@ - the destination URI->IO()downloadSetDestinationUridldest=withCStringdest$\destPtr->(\(Downloadarg1)arg2->withForeignPtrarg1$\argPtr1->webkit_download_set_destination_uriargPtr1arg2)(toDownloaddl)destPtr-- |Determines the current progress of the 'Download'downloadGetProgress::DownloadClassself=>self->IODouble-- ^ a 'Double' ranging from 0.0 to 1.0downloadGetProgressdl=liftMrealToFrac$(\(Downloadarg1)->withForeignPtrarg1$\argPtr1->webkit_download_get_progressargPtr1)(toDownloaddl)-- |Return elapsed time for the 'Download' in seconds.-- includeing any fractional part.---- If the 'Download' is finished, had an error or was cancelled,-- this is the time between its start and the event.downloadGetElapsedTime::DownloadClassself=>self->IODouble-- ^ seconds since the 'Download' was started.downloadGetElapsedTimedl=liftMrealToFrac$(\(Downloadarg1)->withForeignPtrarg1$\argPtr1->webkit_download_get_elapsed_timeargPtr1)(toDownloaddl)-- |Returns the excepted total size of the download.---- This is expected because the server may provide incorrect or missing-- Content-Length.---- Notice that this may grow over time.downloadGetTotalSize::DownloadClassself=>self->IOInt-- ^ the expected total size of the downloaded file.downloadGetTotalSizedl=liftMfromIntegral$(\(Downloadarg1)->withForeignPtrarg1$\argPtr1->webkit_download_get_total_sizeargPtr1)(toDownloaddl)-- | Returns the current already downleaded sizedownloadGetCurrentSize::DownloadClassself=>self->IOInt-- ^ the already downloaded size.downloadGetCurrentSizedl=liftMfromIntegral$(\(Downloadarg1)->withForeignPtrarg1$\argPtr1->webkit_download_get_current_sizeargPtr1)(toDownloaddl)-- | Obtains the current status of the 'Download' as 'DownloadStatus'downloadGetStatus::DownloadClassself=>self->IODownloadStatus-- ^ the current 'DownloadStatus'downloadGetStatusdl=liftM(toEnum.fromIntegral)$(\(Downloadarg1)->withForeignPtrarg1$\argPtr1->webkit_download_get_statusargPtr1)(toDownloaddl)-- * Attibutes-- | The length of the data already downloaded---- Default value: 0---- * Since 1.1.2--currentSize::DownloadClassself=>ReadAttrselfIntcurrentSize=readAttrdownloadGetCurrentSize-- | The URI of the save location for this download.---- Default value: \"\"---- * Since 1.1.2destinationUri::DownloadClassself=>Attrself(MaybeString)destinationUri=newAttrFromMaybeStringProperty"destination-uri"-- | The NetworkRequest instance associated with the download.---- * Since 1.1.2networkRequest::DownloadClassself=>AttrselfNetworkRequestnetworkRequest=newAttrFromObjectProperty"network-request"webkit_network_request_get_type{-# LINE 228 "./Graphics/UI/Gtk/WebKit/Download.chs" #-}-- | The NetworkResponse instance associated with the download.---- * Since 1.1.16networkResponse::DownloadClassself=>AttrselfNetworkResponsenetworkResponse=newAttrFromObjectProperty"network-response"webkit_network_response_get_type{-# LINE 236 "./Graphics/UI/Gtk/WebKit/Download.chs" #-}-- | Determines the current progress of the download.-- Notice that, although the progress changes are reported as soon as possible,-- the emission of the notify signal for this property is throttled, for the benefit of download managers.-- If you care about every update, use 'Download' : currentSize.---- Allowed values: [0,1]---- Default value: 1---- * Since 1.1.2progress::DownloadClassself=>ReadAttrselfDoubleprogress=readAttrdownloadGetProgress-- | Determines the current status of the download.---- Default value: 'DownloadStatusCreated'---- * Since 1.1.2status::DownloadClassself=>ReadAttrselfDownloadStatusstatus=readAttrdownloadGetStatus-- | The file name suggested as default when saving---- Default value: \"\"---- * Since 1.1.2suggestedFilename::DownloadClassself=>ReadAttrself(MaybeString)suggestedFilename=readAttrdownloadGetSuggestedFilename-- | The total size of the file---- Default value: 0---- * Since 1.1.2totalSize::DownloadClassself=>ReadAttrselfInttotalSize=readAttrdownloadGetTotalSize-- * Signals-- | Emitted when download is interrupted either by user action or by network errors,-- errorDetail will take any value of 'DownloadError'.---- 'download': the object on which the signal is emitted-- 'errorCode': the corresponding error code-- 'errorDetail': detailed error code for the error, see 'DownloadError'-- 'reason': a string describing the error---- Since 1.1.2downloadError::DownloadClassself=>Signalself(Int->Int->String->IOBool)downloadError=Signal(connect_INT_INT_STRING__BOOL"error")foreignimportccallsafe"webkit_download_new"webkit_download_new::((PtrNetworkRequest)->(IO(PtrDownload)))foreignimportccallsafe"webkit_download_start"webkit_download_start::((PtrDownload)->(IO()))foreignimportccallsafe"webkit_download_cancel"webkit_download_cancel::((PtrDownload)->(IO()))foreignimportccallsafe"webkit_download_get_uri"webkit_download_get_uri::((PtrDownload)->(IO(PtrCChar)))foreignimportccallsafe"webkit_download_get_network_request"webkit_download_get_network_request::((PtrDownload)->(IO(PtrNetworkRequest)))foreignimportccallsafe"webkit_download_get_suggested_filename"webkit_download_get_suggested_filename::((PtrDownload)->(IO(PtrCChar)))foreignimportccallsafe"webkit_download_get_destination_uri"webkit_download_get_destination_uri::((PtrDownload)->(IO(PtrCChar)))foreignimportccallsafe"webkit_download_set_destination_uri"webkit_download_set_destination_uri::((PtrDownload)->((PtrCChar)->(IO())))foreignimportccallsafe"webkit_download_get_progress"webkit_download_get_progress::((PtrDownload)->(IOCDouble))foreignimportccallsafe"webkit_download_get_elapsed_time"webkit_download_get_elapsed_time::((PtrDownload)->(IOCDouble))foreignimportccallsafe"webkit_download_get_total_size"webkit_download_get_total_size::((PtrDownload)->(IOCULLong))foreignimportccallsafe"webkit_download_get_current_size"webkit_download_get_current_size::((PtrDownload)->(IOCULLong))foreignimportccallsafe"webkit_download_get_status"webkit_download_get_status::((PtrDownload)->(IOCInt))foreignimportccallsafe"webkit_network_request_get_type"webkit_network_request_get_type::CUIntforeignimportccallsafe"webkit_network_response_get_type"webkit_network_response_get_type::CUInt