#include <mythdownloadmanager.h>
Public Member Functions | |
| MythDownloadManager () | |
| Constructor for MythDownloadManager. | |
| ~MythDownloadManager () | |
| Destructor for MythDownloadManager. | |
| void | run (void) |
| Runs a loop to process incoming download requests and triggers download events to be processed. | |
| void | setRunThread (void) |
| QThread * | getQueueThread (void) |
| bool | isRunning (void) |
| void | preCache (const QString &url) |
| Downloads a URL but doesn't store the resulting data anywhere. | |
| void | queueDownload (const QString &url, const QString &dest, QObject *caller, const bool reload=false) |
| Adds a url to the download queue. | |
| void | queueDownload (QNetworkRequest *req, QByteArray *data, QObject *caller) |
| Downloads a QNetworkRequest via the QNetworkAccessManager. | |
| bool | download (const QString &url, const QString &dest, const bool reload=false) |
| Downloads a URL to a file in blocking mode. | |
| bool | download (const QString &url, QByteArray *data, const bool reload=false) |
| Downloads a URI to a QByteArray in blocking mode. | |
| QNetworkReply * | download (const QString &url, const bool reload=false) |
| Downloads a URI to a QByteArray in blocking mode. | |
| bool | download (QNetworkRequest *req, QByteArray *data) |
| Downloads a QNetworkRequest via the QNetworkAccessManager. | |
| bool | downloadAuth (const QString &url, const QString &dest, const bool reload=false, AuthCallback authCallback=NULL, void *authArg=NULL, const QByteArray *header=NULL, const QByteArray *headerVal=NULL) |
| Downloads a URL to a file in blocking mode. | |
| void | queuePost (const QString &url, QByteArray *data, QObject *caller) |
| Queues a post to a URL via the QNetworkAccessManager. | |
| void | queuePost (QNetworkRequest *req, QByteArray *data, QObject *caller) |
| Queues a post to a URL via the QNetworkAccessManager. | |
| bool | post (const QString &url, QByteArray *data) |
| Posts data to a url via the QNetworkAccessManager. | |
| bool | post (QNetworkRequest *req, QByteArray *data) |
| Posts a QNetworkRequest via the QNetworkAccessManager. | |
| bool | postAuth (const QString &url, QByteArray *data, AuthCallback authCallback, void *authArg, const QByteArray *header=NULL, const QByteArray *headerVal=NULL) |
| Posts data to a url via the QNetworkAccessManager. | |
| void | cancelDownload (const QString &url) |
| Cancel a queued or current download. | |
| void | removeListener (QObject *caller) |
| Disconnects the specified caller from any existing MythDownloadInfo instances. | |
| QDateTime | GetLastModified (const QString &url) |
| Gets the Last Modified timestamp for a URI. | |
| void | loadCookieJar (const QString &filename) |
| Loads the cookie jar from a cookie file. | |
| void | saveCookieJar (const QString &filename) |
| Saves the cookie jar to a cookie file. | |
| void | setCookieJar (QNetworkCookieJar *cookieJar) |
| QNetworkCookieJar * | copyCookieJar (void) |
| Copy from one cookie jar to another. | |
| void | refreshCookieJar (QNetworkCookieJar *jar) |
| Refresh the temporary cookie jar from another cookie jar. | |
| void | updateCookieJar (void) |
| Update the cookie jar from the temporary cookie jar. | |
| QString | getHeader (const QUrl &url, const QString &header) |
| QString | getHeader (const QNetworkCacheMetaData &cacheData, const QString &header) |
| Gets the value of an HTTP header from the cache. | |
Private Slots | |
| void | downloadFinished (QNetworkReply *reply) |
| Slot to process download finished events. | |
| void | authCallback (QNetworkReply *reply, QAuthenticator *authenticator) |
| Signal handler for authentication requests. | |
| void | downloadError (QNetworkReply::NetworkError errorCode) |
| Slot to process download error events. | |
| void | downloadProgress (qint64 bytesReceived, qint64 bytesTotal) |
| Slot to process download update events. | |
Private Member Functions | |
| void | downloadFinished (MythDownloadInfo *dlInfo) |
| Callback to process download finished events. | |
| void | queueItem (const QString &url, QNetworkRequest *req, const QString &dest, QByteArray *data, QObject *caller, const MRequestType reqType=kRequestGet, const bool reload=false) |
| Adds a request to the download queue. | |
| bool | processItem (const QString &url, QNetworkRequest *req, const QString &dest, QByteArray *data, const MRequestType reqType=kRequestGet, const bool reload=false, AuthCallback authCallback=NULL, void *authArg=NULL, const QByteArray *header=NULL, const QByteArray *headerVal=NULL) |
| Processes a network request immediately and waits for a response. | |
| void | downloadRemoteFile (MythDownloadInfo *dlInfo) |
| Triggers a myth:// URI download in the background via RemoteFile. | |
| void | downloadQNetworkRequest (MythDownloadInfo *dlInfo) |
| Downloads a QNetworkRequest via the QNetworkAccessManager. | |
| bool | downloadNow (MythDownloadInfo *dlInfo, bool deleteInfo=true) |
| Download helper for download() blocking methods. | |
| QUrl | redirectUrl (const QUrl &possibleRedirectUrl, const QUrl &oldRedirectUrl) const |
| Checks whether we were redirected to the given URL. | |
| bool | saveFile (const QString &outFile, const QByteArray &data, const bool append=false) |
| Saves a QByteArray of data to a given filename. | |
| void | updateCookieJar (QNetworkCookieJar *jar) |
Private Attributes | |
| QNetworkAccessManager * | m_manager |
| QNetworkDiskCache * | m_diskCache |
| QNetworkProxy * | m_proxy |
| QWaitCondition | m_queueWaitCond |
| QMutex | m_queueWaitLock |
| QMutex * | m_infoLock |
| QMap< QString, MythDownloadInfo * > | m_downloadInfos |
| QMap< QNetworkReply *, MythDownloadInfo * > | m_downloadReplies |
| QList< MythDownloadInfo * > | m_downloadQueue |
| QThread * | m_queueThread |
| bool | m_runThread |
| bool | m_isRunning |
| QNetworkCookieJar * | m_inCookieJar |
| QMutex | m_cookieLock |
Friends | |
| class | RemoteFileDownloadThread |
Definition at line 31 of file mythdownloadmanager.h.
| MythDownloadManager::MythDownloadManager | ( | ) |
Constructor for MythDownloadManager.
Instantiates a QNetworkAccessManager and QNetworkDiskCache.
Definition at line 193 of file mythdownloadmanager.cpp.
| MythDownloadManager::~MythDownloadManager | ( | ) |
Destructor for MythDownloadManager.
Definition at line 208 of file mythdownloadmanager.cpp.
| void MythDownloadManager::run | ( | void | ) | [virtual] |
Runs a loop to process incoming download requests and triggers download events to be processed.
Reimplemented from MThread.
Definition at line 224 of file mythdownloadmanager.cpp.
| void MythDownloadManager::setRunThread | ( | void | ) | [inline] |
Definition at line 41 of file mythdownloadmanager.h.
Referenced by GetMythDownloadManager().
| QThread* MythDownloadManager::getQueueThread | ( | void | ) | [inline] |
Definition at line 42 of file mythdownloadmanager.h.
Referenced by GetMythDownloadManager().
| bool MythDownloadManager::isRunning | ( | void | ) | [inline] |
Definition at line 43 of file mythdownloadmanager.h.
Referenced by GetMythDownloadManager().
| void MythDownloadManager::preCache | ( | const QString & | url | ) |
Downloads a URL but doesn't store the resulting data anywhere.
| url | URI to download. |
Definition at line 398 of file mythdownloadmanager.cpp.
| void MythDownloadManager::queueDownload | ( | const QString & | url, | |
| const QString & | dest, | |||
| QObject * | caller, | |||
| const bool | reload = false | |||
| ) |
Adds a url to the download queue.
| url | URI to download. | |
| dest | Destination filename. | |
| caller | QObject to receive event notifications. | |
| reload | Whether to force reloading of the URL or not |
Definition at line 410 of file mythdownloadmanager.cpp.
Referenced by ThemeChooser::customEvent(), MythWebView::doDownload(), MainServer::HandleDownloadFile(), FileServerHandler::HandleDownloadFile(), ThemeChooser::Load(), and ThemeChooser::saveAndReload().
| void MythDownloadManager::queueDownload | ( | QNetworkRequest * | req, | |
| QByteArray * | data, | |||
| QObject * | caller | |||
| ) |
Downloads a QNetworkRequest via the QNetworkAccessManager.
| req | Network request to GET | |
| data | Location to store download data | |
| caller | QObject of caller for event notification |
Definition at line 426 of file mythdownloadmanager.cpp.
| bool MythDownloadManager::download | ( | const QString & | url, | |
| const QString & | dest, | |||
| const bool | reload = false | |||
| ) |
Downloads a URL to a file in blocking mode.
| url | URI to download. | |
| dest | Destination filename. | |
| reload | Whether to force reloading of the URL or not |
Definition at line 443 of file mythdownloadmanager.cpp.
Referenced by downloadURL(), Metadata::getAlbumArtFile(), ChannelData::handleChannels(), ThemeChooser::Load(), MythUIHelper::LoadScaleImage(), MythImageReader::MythImageReader(), ThemeInfo::parseThemeInfo(), MetadataImageDownload::run(), and HouseKeeper::UpdateThemeChooserInfoCache().
| bool MythDownloadManager::download | ( | const QString & | url, | |
| QByteArray * | data, | |||
| const bool | reload = false | |||
| ) |
Downloads a URI to a QByteArray in blocking mode.
| url | URI to download. | |
| data | Pointer to destination QByteArray. | |
| reload | Whether to force reloading of the URL or not |
Definition at line 455 of file mythdownloadmanager.cpp.
| QNetworkReply * MythDownloadManager::download | ( | const QString & | url, | |
| const bool | reload = false | |||
| ) |
Downloads a URI to a QByteArray in blocking mode.
| url | URI to download. | |
| reload | Whether to force reloading of the URL or not |
Definition at line 467 of file mythdownloadmanager.cpp.
| bool MythDownloadManager::download | ( | QNetworkRequest * | req, | |
| QByteArray * | data | |||
| ) |
Downloads a QNetworkRequest via the QNetworkAccessManager.
| req | Information on the network request | |
| data | Location to store download data |
Definition at line 498 of file mythdownloadmanager.cpp.
| bool MythDownloadManager::downloadAuth | ( | const QString & | url, | |
| const QString & | dest, | |||
| const bool | reload = false, |
|||
| AuthCallback | authCallback = NULL, |
|||
| void * | authArg = NULL, |
|||
| const QByteArray * | header = NULL, |
|||
| const QByteArray * | headerVal = NULL | |||
| ) |
Downloads a URL to a file in blocking mode.
| url | URI to download. | |
| dest | Destination filename. | |
| reload | Whether to force reloading of the URL or not | |
| authCallback | AuthCallback function for use with authentication | |
| authArg | Opaque argument for callback function | |
| header | Optional HTTP header to add to the request | |
| headerVal | Value for the optional HTTP header to add to the request |
Definition at line 515 of file mythdownloadmanager.cpp.
| void MythDownloadManager::queuePost | ( | const QString & | url, | |
| QByteArray * | data, | |||
| QObject * | caller | |||
| ) |
Queues a post to a URL via the QNetworkAccessManager.
| url | URL to post to | |
| data | Location holding post and response data | |
| caller | QObject of caller for event notification |
Definition at line 529 of file mythdownloadmanager.cpp.
| void MythDownloadManager::queuePost | ( | QNetworkRequest * | req, | |
| QByteArray * | data, | |||
| QObject * | caller | |||
| ) |
Queues a post to a URL via the QNetworkAccessManager.
| req | QNetworkRequest to post | |
| data | Location holding post and response data | |
| caller | QObject of caller for event notification |
Definition at line 550 of file mythdownloadmanager.cpp.
| bool MythDownloadManager::post | ( | const QString & | url, | |
| QByteArray * | data | |||
| ) |
Posts data to a url via the QNetworkAccessManager.
| url | URL to post to | |
| data | Location holding post and response data |
Definition at line 572 of file mythdownloadmanager.cpp.
Referenced by DataDirectProcessor::Post().
| bool MythDownloadManager::post | ( | QNetworkRequest * | req, | |
| QByteArray * | data | |||
| ) |
Posts a QNetworkRequest via the QNetworkAccessManager.
| req | Information on the network request | |
| data | Location holding post and response data |
Definition at line 591 of file mythdownloadmanager.cpp.
| bool MythDownloadManager::postAuth | ( | const QString & | url, | |
| QByteArray * | data, | |||
| AuthCallback | authCallback, | |||
| void * | authArg, | |||
| const QByteArray * | header = NULL, |
|||
| const QByteArray * | headerVal = NULL | |||
| ) |
Posts data to a url via the QNetworkAccessManager.
| url | URL to post to | |
| data | Location holding post and response data | |
| authCallback | AuthCallback function for authentication | |
| authArg | Opaque argument for callback function | |
| header | Optional HTTP header to add to the request | |
| headerVal | Value for the optional HTTP header to add to the request |
Definition at line 615 of file mythdownloadmanager.cpp.
Referenced by DataDirectProcessor::DDPost(), and DataDirectProcessor::GrabNextSuggestedTime().
| void MythDownloadManager::cancelDownload | ( | const QString & | url | ) |
Cancel a queued or current download.
| url | for download to cancel |
Definition at line 843 of file mythdownloadmanager.cpp.
| void MythDownloadManager::removeListener | ( | QObject * | caller | ) |
Disconnects the specified caller from any existing MythDownloadInfo instances.
| caller | QObject listener to remove |
Definition at line 888 of file mythdownloadmanager.cpp.
| QDateTime MythDownloadManager::GetLastModified | ( | const QString & | url | ) |
Gets the Last Modified timestamp for a URI.
| url | URI to test. |
Definition at line 1286 of file mythdownloadmanager.cpp.
Referenced by MythUIHelper::LoadCacheImage().
| void MythDownloadManager::loadCookieJar | ( | const QString & | filename | ) |
Loads the cookie jar from a cookie file.
| filename | Filename of the cookie file to read. |
Definition at line 1374 of file mythdownloadmanager.cpp.
Referenced by DataDirectProcessor::Post().
| void MythDownloadManager::saveCookieJar | ( | const QString & | filename | ) |
Saves the cookie jar to a cookie file.
| filename | Filename of the cookie file to write. |
Definition at line 1386 of file mythdownloadmanager.cpp.
Referenced by DataDirectProcessor::Post().
| void MythDownloadManager::setCookieJar | ( | QNetworkCookieJar * | cookieJar | ) |
Definition at line 1397 of file mythdownloadmanager.cpp.
| QNetworkCookieJar * MythDownloadManager::copyCookieJar | ( | void | ) |
Copy from one cookie jar to another.
Definition at line 1406 of file mythdownloadmanager.cpp.
| void MythDownloadManager::refreshCookieJar | ( | QNetworkCookieJar * | jar | ) |
Refresh the temporary cookie jar from another cookie jar.
| jar | other cookie jar to update from |
Definition at line 1422 of file mythdownloadmanager.cpp.
Referenced by DestroyNetworkAccessManager().
| void MythDownloadManager::updateCookieJar | ( | void | ) |
Update the cookie jar from the temporary cookie jar.
Definition at line 1438 of file mythdownloadmanager.cpp.
Referenced by run().
| QString MythDownloadManager::getHeader | ( | const QUrl & | url, | |
| const QString & | header | |||
| ) |
Definition at line 1450 of file mythdownloadmanager.cpp.
Referenced by downloadFinished(), downloadQNetworkRequest(), and GetLastModified().
| QString MythDownloadManager::getHeader | ( | const QNetworkCacheMetaData & | cacheData, | |
| const QString & | header | |||
| ) |
Gets the value of an HTTP header from the cache.
| cacheData | The cache data to search through | |
| header | Which HTTP header to get the value of |
Definition at line 1467 of file mythdownloadmanager.cpp.
| void MythDownloadManager::downloadFinished | ( | QNetworkReply * | reply | ) | [private, slot] |
Slot to process download finished events.
| reply | QNetworkReply for completed download. |
Definition at line 963 of file mythdownloadmanager.cpp.
Referenced by run(), and RemoteFileDownloadThread::run().
| void MythDownloadManager::authCallback | ( | QNetworkReply * | reply, | |
| QAuthenticator * | authenticator | |||
| ) | [private, slot] |
Signal handler for authentication requests.
| reply | Response from the remote server | |
| authenticator | To fill in with authentication details |
Definition at line 759 of file mythdownloadmanager.cpp.
Referenced by downloadQNetworkRequest().
| void MythDownloadManager::downloadError | ( | QNetworkReply::NetworkError | errorCode | ) | [private, slot] |
Slot to process download error events.
| errorCode | error code |
Definition at line 921 of file mythdownloadmanager.cpp.
Referenced by downloadFinished(), and downloadQNetworkRequest().
| void MythDownloadManager::downloadProgress | ( | qint64 | bytesReceived, | |
| qint64 | bytesTotal | |||
| ) | [private, slot] |
Slot to process download update events.
| bytesReceived | Bytes received so far | |
| bytesTotal | Bytes total for the download, -1 if the total is unknown |
Definition at line 1170 of file mythdownloadmanager.cpp.
Referenced by downloadFinished(), and downloadQNetworkRequest().
| void MythDownloadManager::downloadFinished | ( | MythDownloadInfo * | dlInfo | ) | [private] |
Callback to process download finished events.
| dlInfo | MythDownloadInfo for completed download. |
Definition at line 986 of file mythdownloadmanager.cpp.
| void MythDownloadManager::queueItem | ( | const QString & | url, | |
| QNetworkRequest * | req, | |||
| const QString & | dest, | |||
| QByteArray * | data, | |||
| QObject * | caller, | |||
| const MRequestType | reqType = kRequestGet, |
|||
| const bool | reload = false | |||
| ) | [private] |
Adds a request to the download queue.
| url | URI to download. | |
| req | QNetworkRequest to queue | |
| dest | Destination filename. | |
| data | Location of data for request | |
| caller | QObject to receive event notifications. | |
| reqType | Issue a POST/GET/HEAD request | |
| reload | Force reloading of the URL |
Definition at line 335 of file mythdownloadmanager.cpp.
Referenced by preCache(), queueDownload(), and queuePost().
| bool MythDownloadManager::processItem | ( | const QString & | url, | |
| QNetworkRequest * | req, | |||
| const QString & | dest, | |||
| QByteArray * | data, | |||
| const MRequestType | reqType = kRequestGet, |
|||
| const bool | reload = false, |
|||
| AuthCallback | authCallback = NULL, |
|||
| void * | authArg = NULL, |
|||
| const QByteArray * | header = NULL, |
|||
| const QByteArray * | headerVal = NULL | |||
| ) | [private] |
Processes a network request immediately and waits for a response.
| url | URI to download. | |
| req | QNetworkRequest to queue | |
| dest | Destination filename. | |
| data | Location of data for request | |
| reqType | Issue a POST/GET/HEAD request | |
| reload | Force reloading of the URL | |
| authCallback | AuthCallback function for authentication | |
| authArg | Opaque argument for callback function | |
| header | Optional HTTP header to add to the request | |
| headerVal | Value for the optional HTTP header to add to the request |
Definition at line 370 of file mythdownloadmanager.cpp.
Referenced by download(), downloadAuth(), post(), and postAuth().
| void MythDownloadManager::downloadRemoteFile | ( | MythDownloadInfo * | dlInfo | ) | [private] |
Triggers a myth:// URI download in the background via RemoteFile.
| dlInfo | MythDownloadInfo information for download |
Definition at line 636 of file mythdownloadmanager.cpp.
Referenced by run().
| void MythDownloadManager::downloadQNetworkRequest | ( | MythDownloadInfo * | dlInfo | ) | [private] |
Downloads a QNetworkRequest via the QNetworkAccessManager.
| dlInfo | MythDownloadInfo information for download |
Definition at line 646 of file mythdownloadmanager.cpp.
Referenced by run().
| bool MythDownloadManager::downloadNow | ( | MythDownloadInfo * | dlInfo, | |
| bool | deleteInfo = true | |||
| ) | [private] |
Download helper for download() blocking methods.
| dlInfo | Information on URI to download. | |
| deleteInfo | Flag to indicate whether to delete the provided MythDownloadInfo instance when done. |
Definition at line 783 of file mythdownloadmanager.cpp.
Referenced by download(), GetLastModified(), and processItem().
| QUrl MythDownloadManager::redirectUrl | ( | const QUrl & | possibleRedirectUrl, | |
| const QUrl & | oldRedirectUrl | |||
| ) | const [private] |
Checks whether we were redirected to the given URL.
| possibleRedirectUrl | Possible Redirect URL | |
| oldRedirectUrl | Old Redirect URL |
Definition at line 948 of file mythdownloadmanager.cpp.
Referenced by downloadFinished().
| bool MythDownloadManager::saveFile | ( | const QString & | outFile, | |
| const QByteArray & | data, | |||
| const bool | append = false | |||
| ) | [private] |
Saves a QByteArray of data to a given filename.
Any parent directories are created automatically.
| outFile | Filename to save to. | |
| data | Data to save. | |
| append | Append data to output file instead of overwriting. |
Definition at line 1230 of file mythdownloadmanager.cpp.
Referenced by downloadFinished(), and downloadProgress().
| void MythDownloadManager::updateCookieJar | ( | QNetworkCookieJar * | jar | ) | [private] |
friend class RemoteFileDownloadThread [friend] |
Definition at line 150 of file mythdownloadmanager.h.
Referenced by downloadRemoteFile().
QNetworkAccessManager* MythDownloadManager::m_manager [private] |
Definition at line 130 of file mythdownloadmanager.h.
Referenced by copyCookieJar(), downloadFinished(), downloadQNetworkRequest(), getHeader(), GetLastModified(), loadCookieJar(), run(), saveCookieJar(), setCookieJar(), and updateCookieJar().
QNetworkDiskCache* MythDownloadManager::m_diskCache [private] |
Definition at line 131 of file mythdownloadmanager.h.
Referenced by run().
QNetworkProxy* MythDownloadManager::m_proxy [private] |
Definition at line 132 of file mythdownloadmanager.h.
Referenced by run().
QWaitCondition MythDownloadManager::m_queueWaitCond [private] |
Definition at line 134 of file mythdownloadmanager.h.
Referenced by downloadFinished(), downloadNow(), queueItem(), refreshCookieJar(), run(), and ~MythDownloadManager().
QMutex MythDownloadManager::m_queueWaitLock [private] |
Definition at line 135 of file mythdownloadmanager.h.
Referenced by downloadNow(), refreshCookieJar(), and run().
QMutex* MythDownloadManager::m_infoLock [private] |
Definition at line 137 of file mythdownloadmanager.h.
Referenced by cancelDownload(), downloadError(), downloadFinished(), downloadNow(), downloadProgress(), downloadQNetworkRequest(), getHeader(), GetLastModified(), queueItem(), removeListener(), run(), and ~MythDownloadManager().
QMap<QString, MythDownloadInfo*> MythDownloadManager::m_downloadInfos [private] |
Definition at line 138 of file mythdownloadmanager.h.
Referenced by cancelDownload(), downloadFinished(), removeListener(), and run().
QMap<QNetworkReply*, MythDownloadInfo*> MythDownloadManager::m_downloadReplies [private] |
Definition at line 139 of file mythdownloadmanager.h.
Referenced by authCallback(), cancelDownload(), downloadError(), downloadFinished(), downloadProgress(), and downloadQNetworkRequest().
QList<MythDownloadInfo*> MythDownloadManager::m_downloadQueue [private] |
Definition at line 140 of file mythdownloadmanager.h.
Referenced by cancelDownload(), downloadNow(), queueItem(), removeListener(), and run().
QThread* MythDownloadManager::m_queueThread [private] |
Definition at line 142 of file mythdownloadmanager.h.
Referenced by run().
bool MythDownloadManager::m_runThread [private] |
Definition at line 144 of file mythdownloadmanager.h.
Referenced by run(), and ~MythDownloadManager().
bool MythDownloadManager::m_isRunning [private] |
Definition at line 145 of file mythdownloadmanager.h.
Referenced by run().
QNetworkCookieJar* MythDownloadManager::m_inCookieJar [private] |
Definition at line 147 of file mythdownloadmanager.h.
Referenced by refreshCookieJar(), run(), updateCookieJar(), and ~MythDownloadManager().
QMutex MythDownloadManager::m_cookieLock [private] |
Definition at line 148 of file mythdownloadmanager.h.
Referenced by copyCookieJar(), loadCookieJar(), refreshCookieJar(), run(), saveCookieJar(), setCookieJar(), and updateCookieJar().
1.6.3