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

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 #ifdef Q_OS_WIN32
00032 #ifdef WADSEEKER_API_EXPORT
00033 #define WADSEEKER_API   __declspec(dllexport)
00034 #else
00035 #define WADSEEKER_API   __declspec(dllimport)
00036 #endif
00037 #else
00038 #define WADSEEKER_API
00039 #endif
00040 
00041 class WWW;
00042 
00083 class WADSEEKER_API Wadseeker : public QObject
00084 {
00085     Q_OBJECT
00086 
00087     public:
00100         enum MessageType
00101         {
00102             Notice          = 0,
00103             Error           = 1,
00104             CriticalError   = 2
00105         };
00106 
00110         static const QString    author();
00111 
00116         static const QString defaultSites[];
00122         static const QString iwadNames[];
00123 
00129         static QStringList      defaultSitesListEncoded();
00130 
00131 
00135         static const QString    description();
00136 
00143         static bool             isIwad(const QString& wad);
00144 
00148         static const QString    version();
00149 
00153         static const QString    yearSpan();
00154 
00158         Wadseeker();
00162         ~Wadseeker();
00163 
00168         void                abort();
00169 
00174         bool                areAllFilesFound() const;
00175 
00179         const QStringList&  filesNotFound() const;
00180 
00187         void                seekWads(const QStringList& wads);
00188 
00195         void                setCustomSite(const QUrl& url);
00196 
00203         void                setPrimarySites(const QStringList& lst);
00204 
00210         void                setPrimarySitesToDefault();
00211 
00216         void                setTargetDirectory(const QString& dir);
00217 
00222         QString             targetDirectory() const;
00223 
00224 
00225 
00226     signals:
00231         void aborted();
00232 
00239         void allDone();
00240 
00247         void downloadProgress(int done, int total);
00248 
00255         void message(const QString& msg, Wadseeker::MessageType type);
00256 
00257     protected:
00264         static QStringList  wantedFilenames(const QString& wad);
00265 
00266     protected slots:
00271         void            messageSlot(const QString& msg,
00272                                     Wadseeker::MessageType type);
00273 
00274     private:
00275         int             iNextWad;
00276         QString         currentWad;
00277         QStringList     notFound;
00278         QStringList     seekedWads;
00279         QString         targetDir;
00280         WWW             *www;
00281 
00282         void    nextWad();
00283 
00284     // The following slots are used to pickup progress from the WWW object.
00285     private slots:
00286         void            downloadProgressSlot(int done, int total);
00287         void            fileDone(QByteArray& data, const QString& filename);
00288         void            wadFail();
00289 };
00290 
00291 #endif
00292 
   
Doomseeker © 2009-2024 The Doomseeker Team