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 #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 WADSEEKER_API 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         void                abort();
00192 
00197         bool                areAllFilesFound() const;
00198 
00202         const QStringList&  filesNotFound() const;
00203 
00210         void                seekWads(const QStringList& wads);
00211 
00218         void                setCustomSite(const QUrl& url);
00219 
00226         void                setPrimarySites(const QStringList& lst);
00227 
00233         void                setPrimarySitesToDefault();
00234 
00239         void                setTargetDirectory(const QString& dir);
00240 
00251         void                setUseIdgames(bool use, bool highPriority = false, QString archiveURL = defaultIdgamesUrl());
00252 
00257         QString             targetDirectory() const;
00258 
00259 
00260 
00261     signals:
00266         void aborted();
00267 
00274         void allDone();
00275 
00282         void downloadProgress(int done, int total);
00283 
00290         void message(const QString& msg, Wadseeker::MessageType type);
00291 
00292     protected:
00300         static QStringList  wantedFilenames(const QString& wad, QString& zip);
00301 
00302     protected slots:
00307         void            messageSlot(const QString& msg, int type);
00308 
00315         void            wwwAborted();
00316 
00317     private:
00318         int             iNextWad;
00319         QString         currentWad;
00320         QStringList     notFound;
00321         QStringList     seekedWads;
00322         QString         targetDir;
00323         WWWSeeker       *www;
00324 
00325         void    nextWad();
00326 
00327     // The following slots are used to pickup progress from the WWW object.
00328     private slots:
00329         void            downloadProgressSlot(int done, int total);
00330         void            fileDone(QByteArray& data, const QString& filename);
00331         void            wadFail();
00332 };
00333 
00334 #endif
00335 
   
Doomseeker © 2009-2024 The Doomseeker Team