Doomseeker
   
  • Doomseeker
  • Wadseeker
  • Download
  • Tracker
  • Git
  • Docs
  • Main Page
  • Classes
  • Files
  • File List

src/wadseeker/wadseeker.h

00001 //------------------------------------------------------------------------------
00002 // wadseeker.h
00003 //------------------------------------------------------------------------------
00004 //
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 //
00010 // This library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00018 // 02110-1301  USA
00019 //
00020 //------------------------------------------------------------------------------
00021 // Copyright (C) 2009 "Zalewa" <zalewapl@gmail.com>
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     // The following slots are used to pickup progress from the WWW object.
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 
   
Doomseeker © 2009-2024 The Doomseeker Team