mirror of
https://github.com/UltimMC/Launcher.git
synced 2025-12-23 20:12:34 +00:00
NOISSUE Modrinth exporter: lookup all hashes in one request
This commit is contained in:
55
launcher/modplatform/modrinth/ModrinthHashLookupRequest.h
Normal file
55
launcher/modplatform/modrinth/ModrinthHashLookupRequest.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2023 arthomnix
|
||||
*
|
||||
* This source is subject to the Microsoft Public License (MS-PL).
|
||||
* Please see the COPYING.md file for more information.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QJsonObject>
|
||||
#include "net/NetAction.h"
|
||||
|
||||
namespace Modrinth
|
||||
{
|
||||
|
||||
struct HashLookupData
|
||||
{
|
||||
QFileInfo fileInfo;
|
||||
QString hash;
|
||||
};
|
||||
|
||||
struct HashLookupResponseData
|
||||
{
|
||||
QFileInfo fileInfo;
|
||||
bool found;
|
||||
QJsonObject fileJson;
|
||||
};
|
||||
|
||||
class HashLookupRequest : public NetAction
|
||||
{
|
||||
public:
|
||||
using Ptr = shared_qobject_ptr<HashLookupRequest>;
|
||||
|
||||
explicit HashLookupRequest(QList<HashLookupData> hashes, QList<HashLookupResponseData> *output);
|
||||
static Ptr make(QList<HashLookupData> hashes, QList<HashLookupResponseData> *output) {
|
||||
return Ptr(new HashLookupRequest(hashes, output));
|
||||
}
|
||||
|
||||
protected slots:
|
||||
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal) override;
|
||||
void downloadError(QNetworkReply::NetworkError error) override;
|
||||
void downloadFinished() override;
|
||||
void downloadReadyRead() override {}
|
||||
|
||||
public slots:
|
||||
void startImpl() override;
|
||||
|
||||
private:
|
||||
QList<HashLookupData> m_hashes;
|
||||
std::shared_ptr<QList<HashLookupResponseData>> m_output;
|
||||
bool finished = true;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user