| 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 OPENSUBTITLESDOWNLOADENGINE_H |
| 16 | #define OPENSUBTITLESDOWNLOADENGINE_H |
| 17 | |
| 18 | #include "config/engineconfig.h" |
| 19 | #include "engines/subtitledownloadengine.h" |
| 20 | #include "utils/p7zipdecoder.h" |
| 21 | #include "utils/syncxmlrpc.h" |
| 22 | |
| 23 | class OpenSubtitlesDownloadEngine : public SubtitleDownloadEngine { |
| 24 | public: |
| 25 | OpenSubtitlesDownloadEngine( |
| 26 | const QString& tmpPath, const EngineConfig& config, |
| 27 | const QSharedPointer<const P7ZipDecoder>& p7zipDecoder, |
| 28 | const QString& qnapiDisplayableVersion, const QString& language); |
| 29 | ~OpenSubtitlesDownloadEngine(); |
| 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 | private: |
| 45 | EngineConfig engineConfig; |
| 46 | QSharedPointer<const P7ZipDecoder> p7zipDecoder; |
| 47 | QString qnapiDisplayableVersion; |
| 48 | QString language; |
| 49 | SyncXmlRpc rpc; |
| 50 | |
| 51 | quint64 fileSize; |
| 52 | QString subFileName, token; |
| 53 | |
| 54 | // sprawdza czy dana instancja klasy jest zalogowana na sewerze |
| 55 | bool isLogged() { return !token.isEmpty(); } |
| 56 | // loguje na serwer OpenSubtitles |
| 57 | bool login(); |
| 58 | // wylogowuje z serwera |
| 59 | void logout(); |
| 60 | }; |
| 61 | |
| 62 | #endif |