Krita Source Code Documentation
Loading...
Searching...
No Matches
KisSupporterBundlesFetcher.h
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: GPL-3.0-or-later
3 */
4#ifndef __KISSUPPORTERBUNDLESFETCHER_H_
5#define __KISSUPPORTERBUNDLESFETCHER_H_
6
7#include <QFileInfo>
8#include <QObject>
9#include <QUrl>
10#include <QVector>
11#include <functional>
12
13#include "KisSupporterBundle.h"
14
16class QNetworkReply;
17class QSqlDatabase;
18
19class KisSupporterBundlesFetcher : public QObject
20{
21 Q_OBJECT
22public:
23 explicit KisSupporterBundlesFetcher(QObject *parent = nullptr);
24
25 bool isFetching() const
26 {
27 return m_fetching;
28 }
29
31 {
32 return m_bundles;
33 }
34
35 void fetchIndex();
36
37 QNetworkReply *fetchBundle(const KisSupporterBundle &bundle);
38
39 static bool hasNetworkReplyError(QNetworkReply *reply, QString &outErrorMessage);
40
41Q_SIGNALS:
42 void fetchIndexDone(bool success, const QString &errorMessage);
43
44private:
45 static constexpr char BASE_URL[] = "https://cdn.kde.org/krita/.android-supporters-extra/supporterbundles/";
46
47 void handleCheckTxtFetched(QNetworkReply *reply);
48 bool handleCheckTxtPredefinedFailure(const QString &content);
49
50 bool checkExistingIndexDb(unsigned int expectedVersion, const QString &expectedHash);
51
52 void fetchIndexDb(unsigned int expectedVersion, const QString &expectedHash);
53
54 void handleIndexDbFetched(QNetworkReply *reply, unsigned int expectedVersion, const QString &expectedHash);
55
56 void readIndexDbBundles();
57
58 QNetworkReply *fetch(const QString &path);
59
60 void emitCheckTxtFetchFailed(const QString &errorMessage);
61 void emitIndexDbFetchFailed(const QString &errorMessage);
62 void emitFailure(const QString &errorMessage);
63
64 bool doWithIndexDb(QString &outErrorMessage, const std::function<bool(QSqlDatabase &, QString &)> &block);
65
66 static bool readSqliteUserVersion(const QByteArray &bytes, unsigned int &outVersion);
67
71 bool m_fetching = false;
72};
73
74#endif
Network Access Manager for use with Krita.
void emitIndexDbFetchFailed(const QString &errorMessage)
void emitFailure(const QString &errorMessage)
QNetworkReply * fetch(const QString &path)
bool doWithIndexDb(QString &outErrorMessage, const std::function< bool(QSqlDatabase &, QString &)> &block)
bool checkExistingIndexDb(unsigned int expectedVersion, const QString &expectedHash)
QNetworkReply * fetchBundle(const KisSupporterBundle &bundle)
void emitCheckTxtFetchFailed(const QString &errorMessage)
void handleCheckTxtFetched(QNetworkReply *reply)
void handleIndexDbFetched(QNetworkReply *reply, unsigned int expectedVersion, const QString &expectedHash)
static bool hasNetworkReplyError(QNetworkReply *reply, QString &outErrorMessage)
QVector< KisSupporterBundle > m_bundles
void fetchIndexDone(bool success, const QString &errorMessage)
KisSupporterBundlesFetcher(QObject *parent=nullptr)
void fetchIndexDb(unsigned int expectedVersion, const QString &expectedHash)
const QVector< KisSupporterBundle > & bundles() const
static bool readSqliteUserVersion(const QByteArray &bytes, unsigned int &outVersion)
bool handleCheckTxtPredefinedFailure(const QString &content)