#pragma once #include "Manifest.h" #include "State.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace gpt4all { namespace download { class HashFile : public QObject { public: HashFile() : QObject(nullptr) {} void hashAndInstall(const QString &expected, QCryptographicHash::Algorithm algo, QFile *temp, const QString &file, QNetworkReply *reply); }; class Download : public QObject { public: static Download *instance(); Q_INVOKABLE void driveFetchAndInstall(); Q_INVOKABLE void downloadManifest(); Q_INVOKABLE void downloadInstaller(); Q_INVOKABLE void cancelDownload(); Q_INVOKABLE void installInstaller(QString &expected, QFile *temp, QNetworkReply *installerResponse); private Q_SLOTS: void handleSslErrors(QNetworkReply *reply, const QList &errors); void handleErrorOccurred(QNetworkReply::NetworkError code); void handleInstallerDownloadFinished(); void handleReadyRead(); private: explicit Download(); ~Download(); QNetworkReply * downloadInMemory(QUrl &url); QNetworkReply * downloadLargeFile(QUrl &url); QIODevice * handleManifestRequestResponse(QNetworkReply * reply); gpt4all::manifest::ManifestFile *manifest; QNetworkAccessManager m_networkManager; QMap download_tracking; HashFile *saver; QDateTime m_startTime; QString platform_ext; QFile *downloadPath; friend class Downloader; }; } }