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 "wadseekerexportinfo.h"
00032
00033 #define WADSEEKER_CONNECT_TIMEOUT_SECONDS_DEFAULT 30
00034 #define WADSEEKER_DOWNLOAD_TIMEOUT_SECONDS_DEFAULT 120
00035
00036 class SpeedCalculator;
00037 class WWWSeeker;
00038
00079 class WADSEEKER_API Wadseeker : public QObject
00080 {
00081 Q_OBJECT
00082
00083 public:
00097 enum MessageType
00098 {
00099 Notice = 0,
00100 NoticeImportant = 1,
00101 Error = 2,
00102 CriticalError = 3
00103 };
00104
00109 static const QString defaultSites[];
00116 static const QString forbiddenWads[];
00117
00121 static const QString defaultIdgamesUrl();
00122
00128 static QStringList defaultSitesListEncoded();
00129
00136 static bool isForbiddenWad(const QString& wad);
00137
00143 static void setTimeConnectTimeout(int seconds);
00144
00150 static void setTimeDownloadTimeout(int seconds);
00151
00155 Wadseeker();
00159 ~Wadseeker();
00160
00165 bool areAllFilesFound() const;
00166
00173 float downloadSpeed() const;
00174
00183 float estimatedTimeUntilArrivalOfCurrentFile() const;
00184
00188 const QStringList& filesNotFound() const;
00189
00196 void seekWads(const QStringList& wads);
00197
00204 void setCustomSite(const QUrl& url);
00205
00212 void setPrimarySites(const QStringList& lst);
00213
00219 void setPrimarySitesToDefault();
00220
00225 void setTargetDirectory(const QString& dir);
00226
00237 void setUseIdgames(bool use, bool highPriority = false, QString archiveURL = defaultIdgamesUrl());
00238
00243 QString targetDirectory() const;
00244
00245 public slots:
00250 void abort();
00251
00255 void skipSite();
00256
00257 signals:
00262 void aborted();
00263
00270 void allDone();
00271
00278 void downloadProgress(int done, int total);
00279
00286 void message(const QString& msg, Wadseeker::MessageType type);
00287
00288 protected:
00296 static QStringList wantedFilenames(const QString& wad, QString& zip);
00297
00298 protected slots:
00303 void messageSlot(const QString& msg, int type);
00304
00311 void wwwAborted();
00312
00313 private:
00314 int iNextWad;
00315 QString currentWad;
00316 QStringList notFound;
00317 QStringList seekedWads;
00318 SpeedCalculator* speedCalculator;
00319 QString targetDir;
00320
00321 WWWSeeker* www;
00322
00323 void nextWad();
00324
00325
00326 private slots:
00327 void downloadProgressSlot(int done, int total);
00328 void fileDone(QByteArray& data, const QString& filename);
00329 void wadFail();
00330 };
00331
00332 #endif
00333