00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __WADSEEKER_H_
00024 #define __WADSEEKER_H_
00025
00026 #include <QList>
00027 #include <QString>
00028 #include <QStringList>
00029 #include <QUrl>
00030
00031 #include "entities/waddownloadinfo.h"
00032 #include "wadseekerexportinfo.h"
00033 #include "wadseekermessagetype.h"
00034
00035 #define WADSEEKER_CONNECT_TIMEOUT_SECONDS_DEFAULT 30
00036 #define WADSEEKER_DOWNLOAD_TIMEOUT_SECONDS_DEFAULT 120
00037
00038 class Idgames;
00039 class WadRetriever;
00040 class WWWSeeker;
00041
00082 class WADSEEKER_API Wadseeker : public QObject
00083 {
00084 Q_OBJECT
00085
00086 public:
00092 static const QString defaultSites[];
00093
00101 static const QString forbiddenWads[];
00102
00106 static const QString defaultIdgamesUrl();
00107
00113 static QStringList defaultSitesListEncoded();
00114
00124 static bool isForbiddenWad(const QString& wad);
00125
00129 Wadseeker();
00130
00134 ~Wadseeker();
00135
00142 bool isDownloadingFile(const QString& file) const;
00143
00153 bool isWorking() const;
00154
00165 void setCustomSite(const QUrl& url);
00166
00173 void setIdgamesEnabled(bool bEnabled);
00174
00178 void setIdgamesUrl(QString archiveURL);
00179
00188 void setMaximumConcurrentDownloads(unsigned max);
00189
00198 void setMaximumConcurrentSeeks(unsigned max);
00199
00210 void setPrimarySites(const QStringList& urlList);
00211
00218 void setPrimarySitesToDefault();
00219
00229 void setTargetDirectory(const QString& dir);
00230
00243 void skipFileCurrentUrl(const QString& fileName);
00244
00256 void skipSiteSeek(const QUrl& url);
00257
00267 bool startSeek(const QStringList& wads);
00268
00275 QString targetDirectory() const;
00276
00277 public slots:
00282 void abort();
00283
00284 signals:
00293 void allDone(bool bSuccess);
00294
00307 void fileDownloadFinished(const QString& filename);
00308
00324 void fileDownloadProgress(const QString& filename, qint64 done, qint64 total);
00325
00334 void fileDownloadStarted(const QString& filename, const QUrl& url);
00335
00344 void fileInstalled(const QString& filename);
00345
00353 void message(const QString& msg, WadseekerLib::MessageType type);
00354
00363 void seekStarted(const QStringList& filenames);
00364
00368 void siteFinished(const QUrl& site);
00369
00373 void siteProgress(const QUrl& site, qint64 bytes, qint64 total);
00374
00378 void siteRedirect(const QUrl& oldUrl, const QUrl& newUrl);
00379
00383 void siteStarted(const QUrl& site);
00384
00385 private:
00386 class SeekParameters
00387 {
00388 public:
00389 bool bIdgamesEnabled;
00390 QUrl customSiteUrl;
00391 QString idgamesUrl;
00392 unsigned maxConcurrentDownloads;
00393 unsigned maxConcurrentSeeks;
00394 QString saveDirectoryPath;
00395 QStringList seekedWads;
00396 QStringList sitesUrls;
00397
00398 SeekParameters();
00399 };
00400
00401 class PrivData
00402 {
00403 public:
00404 bool bIsAborting;
00405
00418 QList<Idgames* > idgamesClients;
00419
00420 SeekParameters seekParameters;
00421
00427 SeekParameters* seekParametersForCurrentSeek;
00428
00429 WadRetriever* wadRetriever;
00430 WWWSeeker* wwwSeeker;
00431 };
00432
00433 PrivData d;
00434
00435 void cleanUpAfterFinish();
00436 bool isAllFinished() const;
00437
00441 void prepareSeekObjects();
00442
00443 void setupIdgamesClients(const QList<WadDownloadInfo>& wadDownloadInfoList);
00444 void setupSitesUrls();
00445
00446
00447 void startNextIdgamesClient();
00448
00449 private slots:
00450 void fileLinkFound(const QString& filename, const QUrl& url);
00451 void idgamesClientFinished(Idgames* pEmitter);
00452 void wadRetrieverDownloadFinished(WadDownloadInfo wadDownloadInfo);
00453 void wadRetrieverDownloadProgress(WadDownloadInfo wadDownloadInfo, qint64 current, qint64 total);
00454 void wadRetrieverDownloadStarted(WadDownloadInfo wadDownloadInfo, const QUrl& url);
00455 void wadRetrieverFinished();
00456 void wadRetrieverMessage(const QString& message, WadseekerLib::MessageType type);
00457 void wadRetrieverWadInstalled(WadDownloadInfo wadDownloadInfo);
00458 void wwwSeekerAttachmentDownloaded(const QString& name, const QByteArray& data);
00459 void wwwSeekerFinished();
00460 };
00461
00462 #endif
00463