wadseeker.h
1 //------------------------------------------------------------------------------
2 // wadseeker.h
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2009 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #ifndef WADSEEKER_H
24 #define WADSEEKER_H
25 
26 #include <QList>
27 #include <QObject>
28 #include <QString>
29 #include <QStringList>
30 #include <QUrl>
31 
32 #include "dptr.h"
33 #include "entities/waddownloadinfo.h"
34 #include "wadseekerexportinfo.h"
35 #include "wadseekermessagetype.h"
36 
37 class ModSet;
38 class ModFile;
39 
183 class WADSEEKER_API Wadseeker : public QObject
184 {
185  Q_OBJECT
186 
187 public:
193  static const QString defaultSites[];
194 
204  static const QString forbiddenWads[];
205 
209  static const QString defaultIdgamesUrl();
210 
218  static QStringList defaultSitesListEncoded();
219 
223  static ModSet filterAllowedOnlyWads(const ModSet &wads);
227  static ModSet filterForbiddenOnlyWads(const ModSet &wads);
228 
236  static bool isForbiddenWad(const ModFile &wad);
237 
241  Wadseeker();
242 
246  ~Wadseeker() override;
247 
254  bool isDownloadingFile(const ModFile &file) const;
255 
265  bool isWorking() const;
266 
280  void setCustomSite(const QString &url);
281 
290  void setCustomSites(const QStringList &urls);
291 
300  void setIdgamesEnabled(bool bEnabled);
301 
309  void setIdgamesUrl(QString archiveURL);
310 
319  void setMaximumConcurrentDownloads(unsigned max);
320 
329  void setMaximumConcurrentSeeks(unsigned max);
330 
339  void setPrimarySites(const QStringList &urlList);
340 
353  void setPrimarySitesToDefault();
354 
365  void setTargetDirectory(const QString &dir);
366 
378  void setWadArchiveEnabled(bool enabled);
379 
395  void skipFileCurrentUrl(const QString &fileName);
396 
406  void skipService(const QString &service);
407 
418  void skipSiteSeek(const QUrl &url);
419 
447  bool startSeek(const ModSet &wads);
448 
459  QString targetDirectory() const;
460 
461 public slots:
469  void abort();
470 
471 signals:
480  void allDone(bool bSuccess);
481 
494  void fileDownloadFinished(const ModFile &filename);
495 
510  void fileDownloadProgress(const ModFile &filename, qint64 done, qint64 total);
511 
520  void fileDownloadStarted(const ModFile &filename, const QUrl &url);
521 
530  void fileInstalled(const ModFile &filename);
531 
540  void message(const QString &msg, WadseekerLib::MessageType type);
541 
551  void seekStarted(const ModSet &filenames);
552 
565  void serviceStarted(const QString &name);
566 
575  void serviceFinished(const QString &name);
576 
580  void siteFinished(const QUrl &site);
581 
585  void siteProgress(const QUrl &site, qint64 bytes, qint64 total);
586 
590  void siteRedirect(const QUrl &oldUrl, const QUrl &newUrl);
591 
595  void siteStarted(const QUrl &site);
596 
597 private:
598  DPtr<Wadseeker> d;
599 };
600 
601 #endif