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 SUBTITLEDOWNLOADENGINE_H
16 #define SUBTITLEDOWNLOADENGINE_H
17 
18 #include <QFile>
19 #include <QFileInfo>
20 #include <QString>
21 #include <QUrl>
22 
23 #include <ctime>
24 
25 #include <Maybe.h>
26 
27 #include "subtitleinfo.h"
28 
29 #include "engines/subtitledownloadenginemetadata.h"
30 
31 class SubtitleDownloadEngine {
32  public:
~SubtitleDownloadEngine()33   virtual ~SubtitleDownloadEngine() {}
34 
35   void setMoviePath(const QString& path);
36   QString moviePath();
37 
38   virtual SubtitleDownloadEngineMetadata meta() const = 0;
39   virtual const char* const* enginePixmapData() const = 0;
40 
41   virtual void clearSubtitlesList();
42   virtual QString checksum(QString filename = "") = 0;
43   virtual bool lookForSubtitles(QString lang) = 0;
44   virtual QList<SubtitleInfo> listSubtitles() = 0;
45   virtual bool download(QUuid id) = 0;
46   virtual bool unpack(QUuid id) = 0;
47   virtual void cleanup() = 0;
48 
49  protected:
50   QString tmpPath;
51 
52   QList<SubtitleInfo> subtitlesList;
53   QString movie;
54   QString subtitles;
55   QString subtitlesTmp;
56   QString checkSum;
57 
58   SubtitleDownloadEngine(const QString& tmpPath);
59 
60   Maybe<SubtitleInfo> resolveById(QUuid id);
61   void updateSubtitleInfo(const SubtitleInfo& si);
62 
63   QString generateTmpFileName() const;
64   QString generateTmpPath() const;
65 
66   friend class QNapi;
67 };
68 
69 #endif
70