| 1 | /***************************************************************************** |
| 2 | ** QNapi |
| 3 | ** Copyright (C) 2008-2017 Piotr KrzemiĆski <[email protected]> |
| 4 | ** |
| 5 | ** This program is free software; you can redistribute it and/or modify |
| 6 | ** it under the terms of the GNU General Public License as published by |
| 7 | ** the Free Software Foundation; either version 2 of the License, or |
| 8 | ** (at your option) any later version. |
| 9 | ** |
| 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
| 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
| 12 | ** |
| 13 | *****************************************************************************/ |
| 14 | |
| 15 | #ifndef NAPIPROJEKTDOWNLOADENGINE_H |
| 16 | #define NAPIPROJEKTDOWNLOADENGINE_H |
| 17 | |
| 18 | #include "config/engineconfig.h" |
| 19 | #include "engines/subtitledownloadengine.h" |
| 20 | #include "utils/p7zipdecoder.h" |
| 21 | |
| 22 | #include <QSharedPointer> |
| 23 | |
| 24 | class NapiProjektDownloadEngine : public SubtitleDownloadEngine { |
| 25 | public: |
| 26 | NapiProjektDownloadEngine( |
| 27 | const QString& tmpPath, const EngineConfig& config, |
| 28 | const QSharedPointer<const P7ZipDecoder>& p7zipDecoder); |
| 29 | ~NapiProjektDownloadEngine(); |
| 30 | |
| 31 | static SubtitleDownloadEngineMetadata metadata; |
| 32 | static const char* const pixmapData[]; |
| 33 | |
| 34 | SubtitleDownloadEngineMetadata meta() const; |
| 35 | const char* const* enginePixmapData() const; |
| 36 | |
| 37 | QString checksum(QString filename = ""); |
| 38 | bool lookForSubtitles(QString lang); |
| 39 | QList<SubtitleInfo> listSubtitles(); |
| 40 | bool download(QUuid id); |
| 41 | bool unpack(QUuid id); |
| 42 | void cleanup(); |
| 43 | |
| 44 | static bool checkUser(const QString& nick, const QString& pass); |
| 45 | |
| 46 | private: |
| 47 | EngineConfig engineConfig; |
| 48 | QSharedPointer<const P7ZipDecoder> p7zipDecoder; |
| 49 | |
| 50 | QString checksum(QString filename, bool limit10M); |
| 51 | Maybe<QString> downloadByLangAndChecksum(QString lang, |
| 52 | QString checksum) const; |
| 53 | QString npFDigest(const QString& input) const; |
| 54 | QString npLangWrapper(QString lang) const; |
| 55 | QString napiOS() const; |
| 56 | }; |
| 57 | |
| 58 | #endif |