1 /***************************************************************************** 2 ** QNapi 3 ** Copyright (C) 2008-2017 Piotr Krzemiński <pio.krzeminski@gmail.com> 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 __QNAPI__H__ 16 #define __QNAPI__H__ 17 18 #include "config/qnapiconfig.h" 19 #include "engines/subtitledownloadengine.h" 20 #include "engines/subtitledownloadenginesregistry.h" 21 #include "subtitleinfo.h" 22 23 #include <Maybe.h> 24 #include <QList> 25 #include <QSharedPointer> 26 #include <QString> 27 #include <QStringList> 28 29 class QNapi { 30 public: 31 QNapi(const QNapiConfig& config, 32 const Maybe<QString>& specificEngine = nothing()); 33 ~QNapi(); 34 35 bool checkP7ZipPath(); 36 bool checkTmpPath(); 37 bool ppEnabled(); 38 39 void setMoviePath(QString path); 40 QString moviePath(); 41 bool checkWritePermissions(); 42 43 void clearSubtitlesList(); 44 void checksum(); 45 bool lookForSubtitles(QString lang, QString engine = ""); 46 bool lookForSubtitles(QStringList languages, QString engine = ""); 47 QList<SubtitleInfo> listSubtitles(); 48 49 bool needToShowList(); 50 int bestIdx(); 51 52 bool download(int i); 53 bool unpack(int i); 54 bool matchSubtitles(); 55 void postProcessSubtitles() const; 56 57 void cleanup(); 58 QString error(); 59 60 QStringList listLoadedEngines() const; 61 62 private: 63 QSharedPointer<SubtitleDownloadEngine> engineByName(QString name) const; 64 65 QString movie; 66 QString errorMsg; 67 QList<QSharedPointer<SubtitleDownloadEngine>> enginesList; 68 QList<SubtitleInfo> subtitlesList; 69 QSharedPointer<SubtitleDownloadEngine> currentEngine; 70 71 // najlepszy indeks napisow 72 int theBestIdx; 73 74 const QSharedPointer<const SubtitleDownloadEnginesRegistry> enginesRegistry; 75 const QNapiConfig config; 76 }; 77 78 #endif // __QNAPI__H__ 79