1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef ONLINESYNCTHREAD_H
#define ONLINESYNCTHREAD_H
#include <QList>
#include <QWaitCondition>
#include <QThread>
#include "onlinetracker.h"
#include "onlinetvshowdatabase.h"
#include "onlinedropurl.h"
#include <QDebug>
class BaseConfig;
class OnlineSync : public QThread
{
Q_OBJECT
public:
OnlineSync(const Library& library);
void init(const BaseConfig& config);
void addShowToFetch(TvShow* show);
void addShowToUpdate(TvShow* show);
void handleDropUrl(TvShow* show, const QUrl url);
bool handleApiRequest(QHttpRequest *req, QHttpResponse *resp);
void run();
signals:
void trackersFinished();
void databasesFinished();
void allFinished();
private slots:
void checkIfAllFinished();
private:
void startThreadIfNotRunning();
bool requiresFetch(const TvShow* show, const QString dbIdentifier);
bool fetchShow(TvShow* show, const Library& library);
bool updateShow(TvShow* show);
void updateTrackers();
void fetchDatabases();
bool shouldQuit;
std::set<TvShow*> unhandledFetch;
std::set<TvShow*> unhandledUpdate;
const Library& library;
QWaitCondition waitCondition;
QList<OnlineCredentials*> credentials;
QList<OnlineTracker*> trackers;
QList<OnlineTvShowDatabase::Client*> databases;
QList<OnlineDropUrl*> dropUrls;
static QDebug log();
static QDebug err();
};
#endif // ONLINESYNCTHREAD_H