-
Notifications
You must be signed in to change notification settings - Fork 16
/
ivlefetcher.h
89 lines (77 loc) · 2.09 KB
/
ivlefetcher.h
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
* Main class to interate with IVLE
* By Yao Yujian
*/
#ifndef IVLEFETCHER_H
#define IVLEFETCHER_H
#include <QObject>
#include <QtXml/QDomDocument>
#include <QtNetwork>
#include <QFile>
#include <QJsonDocument>
#include <QWebPage>
#include <QWebFrame>
#include "downloader.h"
#include "lapi.h"
#include "externalpageparser.h"
enum fetchingState{
gettingUserInfo,
gottenUserInfo,
gettingFileList,
gottenFileList,
gettingWebbinInfo,
gottenWebbinInfo,
downloading,
remainingChange,
complete,
networkError,
invalidToken
};
enum fetchingError{
wrongUsername
};
class IVLEFetcher : public QObject
{
Q_OBJECT
public:
explicit IVLEFetcher(QString, ExternalPageParser*, QString, double, QObject *parent = 0);
QString username();
void setMaxFileSize(double);
void setIgnoreUploadable(bool);
void setExtraDownloads(const QVariantMap&);
int remainingFiles();
signals:
void statusUpdate(fetchingState);
void tokenUpdated(const QString& token);
void error(fetchingError);
void fileDownloaded(const QString &filename);
void gotUnreadAnnouncements(QVariantList);
public slots:
void setDirectory(const QString&);
void setToken(const QString&);
void start();
private:
void buildDirectoriesAndDownloadList();
QVariantMap mergeFileSystems(const QVariantMap&, const QVariantMap&);
QVariantMap mergeFiles(const QVariantMap&, const QVariantMap&);
void processAnnouncements(QVariantList);
QVariantMap toDownload;
QVariantMap cleanFileSystem(const QVariantMap&);
QVariantMap jsonToFolder(const QVariantMap&);
void exploreFolder(QDir&, const QVariantMap&);
QString token;
QDir path;
QString _username;
QVariantMap courses;
QVariantMap extras;
int numOfFiles;
double maxFileSize;
bool ignoreUploadable;
//set parents of downloader and replies to this so that we can easily terminate a downloading session.
QObject *session;
QTimer *timer;
// url: (course name, folder (can be .), exec)
Lapi* api;
ExternalPageParser* parser;
};
#endif // IVLEFETCHER_H