-
Notifications
You must be signed in to change notification settings - Fork 3
/
fastdownloader_p.h
84 lines (72 loc) · 2.63 KB
/
fastdownloader_p.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
/****************************************************************************
**
** Copyright (C) 2019 Ömer Göktaş
** Contact: omergoktas.com
**
** This file is part of the FastDownloader library.
**
** The FastDownloader is free software: you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public License
** version 3 as published by the Free Software Foundation.
**
** The FastDownloader is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with the FastDownloader. If not, see
** <https://www.gnu.org/licenses/>.
**
****************************************************************************/
#ifndef FASTDOWNLOADER_P_H
#define FASTDOWNLOADER_P_H
#include "fastdownloader.h"
#include <private/qobject_p.h>
class FastDownloaderPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(FastDownloader)
struct Connection
{
int id = 0;
qint64 head = 0;
qint64 pos = 0;
qint64 bytesReceived = 0;
qint64 bytesTotal = 0;
QNetworkReply* reply = nullptr;
};
public:
FastDownloaderPrivate();
int generateUniqueId() const;
bool downloadCompleted() const;
bool connectionExists(int id) const;
bool nextPortionAvailable() const;
qint64 nextPortionPosition() const;
qint64 untargetedDataSize() const;
Connection* connectionFor(int id) const;
Connection* connectionFor(const QObject* sender) const;
QList<Connection> createFakeCopyForActiveConnections() const;
void free();
void reset();
void startSimultaneousDownloading();
void deleteConnection(Connection* connection);
void createConnection(const QUrl& url, qint64 begin = -1, qint64 end = -1);
static qint64 testContentLength(const Connection* connection);
static bool testSimultaneousDownload(const Connection* connection);
QScopedPointer<QNetworkAccessManager> manager;
bool running;
bool resolved;
bool simultaneousDownloadPossible;
QUrl resolvedUrl;
qint64 contentLength;
qint64 totalBytesReceived;
QNetworkReply::NetworkError error;
QList<Connection*> connections;
void _q_finished();
void _q_readyRead();
void _q_redirected(const QUrl& url);
void _q_error(QNetworkReply::NetworkError code);
void _q_sslErrors(const QList<QSslError>& errors);
void _q_downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
};
#endif // FASTDOWNLOADER_P_H