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 #define WADSEEKER_CONNECT_TIMEOUT_SECONDS_DEFAULT 30
00032 #define WADSEEKER_DOWNLOAD_TIMEOUT_SECONDS_DEFAULT 120
00033
00034 #ifdef Q_OS_WIN32
00035 #ifdef WADSEEKER_API_EXPORT
00036 #define WADSEEKER_API __declspec(dllexport)
00037 #else
00038 #define WADSEEKER_API __declspec(dllimport)
00039 #endif
00040 #else
00041 #define WADSEEKER_API
00042 #endif
00043
00044 class WWWSeeker;
00045
00086 class WADSEEKER_API Wadseeker : public QObject
00087 {
00088 Q_OBJECT
00089
00090 public:
00103 enum MessageType
00104 {
00105 Notice = 0,
00106 Error = 1,
00107 CriticalError = 2
00108 };
00109
00114 static const QString defaultSites[];
00121 static const QString iwadNames[];
00122
00126 static const QString author();
00127
00131 static const QString defaultIdgamesUrl();
00132
00138 static QStringList defaultSitesListEncoded();
00139
00140
00144 static const QString description();
00145
00152 static bool isIwad(const QString& wad);
00153
00159 static void setTimeConnectTimeout(int seconds);
00160
00166 static void setTimeDownloadTimeout(int seconds);
00167
00171 static const QString version();
00172
00176 static const QString yearSpan();
00177
00181 Wadseeker();
00185 ~Wadseeker();
00186
00191 bool areAllFilesFound() const;
00192
00196 const QStringList& filesNotFound() const;
00197
00204 void seekWads(const QStringList& wads);
00205
00212 void setCustomSite(const QUrl& url);
00213
00220 void setPrimarySites(const QStringList& lst);
00221
00227 void setPrimarySitesToDefault();
00228
00233 void setTargetDirectory(const QString& dir);
00234
00245 void setUseIdgames(bool use, bool highPriority = false, QString archiveURL = defaultIdgamesUrl());
00246
00251 QString targetDirectory() const;
00252
00253 public slots:
00258 void abort();
00259
00263 void skipSite();
00264
00265 signals:
00270 void aborted();
00271
00278 void allDone();
00279
00286 void downloadProgress(int done, int total);
00287
00294 void message(const QString& msg, Wadseeker::MessageType type);
00295
00296 protected:
00304 static QStringList wantedFilenames(const QString& wad, QString& zip);
00305
00306 protected slots:
00311 void messageSlot(const QString& msg, int type);
00312
00319 void wwwAborted();
00320
00321 private:
00322 int iNextWad;
00323 QString currentWad;
00324 QStringList notFound;
00325 QStringList seekedWads;
00326 QString targetDir;
00327 WWWSeeker *www;
00328
00329 void nextWad();
00330
00331
00332 private slots:
00333 void downloadProgressSlot(int done, int total);
00334 void fileDone(QByteArray& data, const QString& filename);
00335 void wadFail();
00336 };
00337
00338 #endif
00339