S3 bucket listing support and network code refactors.

* Adds support for listing all objects in an S3 bucket.
* Renames a bunch of network related classes (Download->Action)
* Net actions now have static constructors
This commit is contained in:
Petr Mrázek
2013-10-26 19:55:48 +02:00
parent c467ebf132
commit 9233477295
27 changed files with 405 additions and 243 deletions

View File

@ -14,7 +14,7 @@
*/
#include "ForgeVersionList.h"
#include <logic/net/DownloadJob.h>
#include <logic/net/NetJob.h>
#include "MultiMC.h"
#include <QtNetwork>
@ -159,14 +159,14 @@ ForgeListLoadTask::ForgeListLoadTask(ForgeVersionList *vlist) : Task()
void ForgeListLoadTask::executeTask()
{
auto job = new DownloadJob("Version index");
auto job = new NetJob("Version index");
// we do not care if the version is stale or not.
auto forgeListEntry = MMC->metacache()->resolveEntry("minecraftforge", "list.json");
// verify by poking the server.
forgeListEntry->stale = true;
job->addCacheDownload(QUrl(JSON_URL), forgeListEntry);
job->addNetAction(CacheDownload::make(QUrl(JSON_URL), forgeListEntry));
listJob.reset(job);
connect(listJob.get(), SIGNAL(succeeded()), SLOT(list_downloaded()));
connect(listJob.get(), SIGNAL(failed()), SLOT(list_failed()));
@ -178,7 +178,7 @@ void ForgeListLoadTask::list_failed()
{
auto DlJob = listJob->first();
auto reply = DlJob->m_reply;
if(reply)
if (reply)
{
QLOG_ERROR() << "Getting forge version list failed: " << reply->errorString();
}
@ -193,7 +193,7 @@ void ForgeListLoadTask::list_downloaded()
auto DlJob = listJob->first();
auto filename = std::dynamic_pointer_cast<CacheDownload>(DlJob)->m_target_path;
QFile listFile(filename);
if(!listFile.open(QIODevice::ReadOnly))
if (!listFile.open(QIODevice::ReadOnly))
return;
data = listFile.readAll();
DlJob.reset();
@ -202,7 +202,6 @@ void ForgeListLoadTask::list_downloaded()
QJsonParseError jsonError;
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError);
if (jsonError.error != QJsonParseError::NoError)
{
emitFailed("Error parsing version list JSON:" + jsonError.errorString());

View File

@ -23,7 +23,7 @@
#include <QNetworkReply>
#include "BaseVersionList.h"
#include "logic/tasks/Task.h"
#include "logic/net/DownloadJob.h"
#include "logic/net/NetJob.h"
class ForgeVersion;
typedef std::shared_ptr<ForgeVersion> ForgeVersionPtr;
@ -104,6 +104,6 @@ slots:
void list_failed();
protected:
DownloadJobPtr listJob;
NetJobPtr listJob;
ForgeVersionList *m_list;
};