summaryrefslogtreecommitdiffstats
path: root/logic
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-10-06 01:13:40 +0200
committerPetr Mrázek <peterix@gmail.com>2013-10-06 01:13:40 +0200
commitf83119ce7ec3d11a903901b8eff762d2b0a9f635 (patch)
tree5c30d7b9fff0f9417e7f2cd79d8ad9ea56d7f056 /logic
parenteba9b3d759dbf6e402e91ab897059f1d274aef90 (diff)
downloadMultiMC-f83119ce7ec3d11a903901b8eff762d2b0a9f635.tar
MultiMC-f83119ce7ec3d11a903901b8eff762d2b0a9f635.tar.gz
MultiMC-f83119ce7ec3d11a903901b8eff762d2b0a9f635.tar.lz
MultiMC-f83119ce7ec3d11a903901b8eff762d2b0a9f635.tar.xz
MultiMC-f83119ce7ec3d11a903901b8eff762d2b0a9f635.zip
Added file logger
Diffstat (limited to 'logic')
-rw-r--r--logic/BaseInstance.cpp2
-rw-r--r--logic/BaseInstance.h6
-rw-r--r--logic/BaseInstance_p.h2
-rw-r--r--logic/BaseVersion.h4
-rw-r--r--logic/ForgeInstaller.cpp4
-rw-r--r--logic/ForgeInstaller.h6
-rw-r--r--logic/InstanceFactory.cpp5
-rw-r--r--logic/InstanceLauncher.cpp2
-rw-r--r--logic/LegacyInstance.cpp8
-rw-r--r--logic/LegacyInstance.h8
-rw-r--r--logic/LegacyInstance_p.h8
-rw-r--r--logic/LegacyUpdate.cpp213
-rw-r--r--logic/LegacyUpdate.h2
-rw-r--r--logic/Mod.cpp7
-rw-r--r--logic/ModList.cpp16
-rw-r--r--logic/OneSixAssets.cpp13
-rw-r--r--logic/OneSixInstance.cpp9
-rw-r--r--logic/OneSixInstance.h6
-rw-r--r--logic/OneSixInstance_p.h6
-rw-r--r--logic/OneSixLibrary.cpp2
-rw-r--r--logic/OneSixLibrary.h6
-rw-r--r--logic/OneSixRule.cpp6
-rw-r--r--logic/OneSixRule.h10
-rw-r--r--logic/OneSixUpdate.cpp25
-rw-r--r--logic/OneSixUpdate.h2
-rw-r--r--logic/OneSixVersion.cpp28
-rw-r--r--logic/OneSixVersion.h12
-rw-r--r--logic/lists/ForgeVersionList.cpp20
-rw-r--r--logic/lists/ForgeVersionList.h2
-rw-r--r--logic/lists/InstanceList.cpp218
-rw-r--r--logic/lists/LwjglVersionList.cpp62
-rw-r--r--logic/lists/LwjglVersionList.h6
-rw-r--r--logic/lists/MinecraftVersionList.cpp10
-rw-r--r--logic/net/ByteArrayDownload.cpp13
-rw-r--r--logic/net/ByteArrayDownload.h2
-rw-r--r--logic/net/CacheDownload.cpp10
-rw-r--r--logic/net/CacheDownload.h2
-rw-r--r--logic/net/Download.h18
-rw-r--r--logic/net/DownloadJob.cpp22
-rw-r--r--logic/net/DownloadJob.h2
-rw-r--r--logic/net/FileDownload.cpp12
-rw-r--r--logic/net/FileDownload.h2
-rw-r--r--logic/net/ForgeXzDownload.cpp26
-rw-r--r--logic/net/ForgeXzDownload.h2
-rw-r--r--logic/net/HttpMetaCache.cpp6
-rw-r--r--logic/net/HttpMetaCache.h2
-rw-r--r--logic/net/LoginTask.cpp4
-rw-r--r--logic/tasks/Task.cpp2
48 files changed, 441 insertions, 420 deletions
diff --git a/logic/BaseInstance.cpp b/logic/BaseInstance.cpp
index ec86596a..6a6b195b 100644
--- a/logic/BaseInstance.cpp
+++ b/logic/BaseInstance.cpp
@@ -132,7 +132,7 @@ InstanceList *BaseInstance::instList() const
return NULL;
}
-QSharedPointer<BaseVersionList> BaseInstance::versionList() const
+std::shared_ptr<BaseVersionList> BaseInstance::versionList() const
{
return MMC->minecraftlist();
}
diff --git a/logic/BaseInstance.h b/logic/BaseInstance.h
index 0056327a..e360d3ae 100644
--- a/logic/BaseInstance.h
+++ b/logic/BaseInstance.h
@@ -135,7 +135,7 @@ public:
* \brief Gets a pointer to this instance's version list.
* \return A pointer to the available version list for this instance.
*/
- virtual QSharedPointer<BaseVersionList> versionList() const;
+ virtual std::shared_ptr<BaseVersionList> versionList() const;
/*!
* \brief Gets this instance's settings object.
@@ -179,9 +179,9 @@ signals:
void nuked(BaseInstance * inst);
protected:
- QSharedPointer<BaseInstancePrivate> inst_d;
+ std::shared_ptr<BaseInstancePrivate> inst_d;
};
// pointer for lazy people
-typedef QSharedPointer<BaseInstance> InstancePtr;
+typedef std::shared_ptr<BaseInstance> InstancePtr;
diff --git a/logic/BaseInstance_p.h b/logic/BaseInstance_p.h
index a30916a4..06c0c0ba 100644
--- a/logic/BaseInstance_p.h
+++ b/logic/BaseInstance_p.h
@@ -4,7 +4,7 @@
class BaseInstance;
-#define I_D(Class) Class##Private * const d = (Class##Private * const) inst_d.data()
+#define I_D(Class) Class##Private * const d = (Class##Private * const) inst_d.get()
struct BaseInstancePrivate
{
diff --git a/logic/BaseVersion.h b/logic/BaseVersion.h
index be717fee..01745c46 100644
--- a/logic/BaseVersion.h
+++ b/logic/BaseVersion.h
@@ -14,7 +14,7 @@
*/
#pragma once
-#include <QSharedPointer>
+#include <memory>
/*!
* An abstract base class for versions.
@@ -40,6 +40,6 @@ struct BaseVersion
virtual QString typeString() const = 0;
};
-typedef QSharedPointer<BaseVersion> BaseVersionPtr;
+typedef std::shared_ptr<BaseVersion> BaseVersionPtr;
Q_DECLARE_METATYPE( BaseVersionPtr ) \ No newline at end of file
diff --git a/logic/ForgeInstaller.cpp b/logic/ForgeInstaller.cpp
index 9ae3f1e1..a946dd44 100644
--- a/logic/ForgeInstaller.cpp
+++ b/logic/ForgeInstaller.cpp
@@ -10,7 +10,7 @@
ForgeInstaller::ForgeInstaller(QString filename, QString universal_url)
{
- QSharedPointer<OneSixVersion> newVersion;
+ std::shared_ptr<OneSixVersion> newVersion;
m_universal_url = universal_url;
QuaZip zip(filename);
@@ -88,7 +88,7 @@ ForgeInstaller::ForgeInstaller(QString filename, QString universal_url)
realVersionId = m_forge_version->id = installObj.value("minecraft").toString();
}
-bool ForgeInstaller::apply(QSharedPointer<OneSixVersion> to)
+bool ForgeInstaller::apply(std::shared_ptr<OneSixVersion> to)
{
if (!m_forge_version)
return false;
diff --git a/logic/ForgeInstaller.h b/logic/ForgeInstaller.h
index f4ceaaef..f6f22a2a 100644
--- a/logic/ForgeInstaller.h
+++ b/logic/ForgeInstaller.h
@@ -1,6 +1,6 @@
#pragma once
#include <QString>
-#include <QSharedPointer>
+#include <memory>
class OneSixVersion;
@@ -9,11 +9,11 @@ class ForgeInstaller
public:
ForgeInstaller(QString filename, QString universal_url);
- bool apply(QSharedPointer<OneSixVersion> to);
+ bool apply(std::shared_ptr<OneSixVersion> to);
private:
// the version, read from the installer
- QSharedPointer<OneSixVersion> m_forge_version;
+ std::shared_ptr<OneSixVersion> m_forge_version;
QString internalPath;
QString finalPath;
QString realVersionId;
diff --git a/logic/InstanceFactory.cpp b/logic/InstanceFactory.cpp
index b5832ce5..0da62803 100644
--- a/logic/InstanceFactory.cpp
+++ b/logic/InstanceFactory.cpp
@@ -30,6 +30,7 @@
#include <setting.h>
#include "pathutils.h"
+#include <logger/QsLog.h>
InstanceFactory InstanceFactory::loader;
@@ -72,12 +73,12 @@ InstanceFactory::InstCreateError InstanceFactory::createInstance( BaseInstance*&
{
QDir rootDir(instDir);
- qDebug(instDir.toUtf8());
+ QLOG_DEBUG() << instDir.toUtf8();
if (!rootDir.exists() && !rootDir.mkpath("."))
{
return InstanceFactory::CantCreateDir;
}
- auto mcVer = version.dynamicCast<MinecraftVersion>();
+ auto mcVer = std::dynamic_pointer_cast<MinecraftVersion>(version);
if(!mcVer)
return InstanceFactory::NoSuchVersion;
diff --git a/logic/InstanceLauncher.cpp b/logic/InstanceLauncher.cpp
index 93b87f23..720052a3 100644
--- a/logic/InstanceLauncher.cpp
+++ b/logic/InstanceLauncher.cpp
@@ -61,7 +61,7 @@ int InstanceLauncher::launch()
{
std::cout << "Launching Instance '" << qPrintable ( instId ) << "'" << std::endl;
auto instance = MMC->instances()->getInstanceById(instId);
- if ( instance.isNull() )
+ if ( !instance )
{
std::cout << "Could not find instance requested. note that you have to specify the ID, not the NAME" << std::endl;
return 1;
diff --git a/logic/LegacyInstance.cpp b/logic/LegacyInstance.cpp
index 4f367980..2ffcb075 100644
--- a/logic/LegacyInstance.cpp
+++ b/logic/LegacyInstance.cpp
@@ -92,7 +92,7 @@ void LegacyInstance::cleanupAfterRun()
//FIXME: delete the launcher and icons and whatnot.
}
-QSharedPointer< ModList > LegacyInstance::coreModList()
+std::shared_ptr< ModList > LegacyInstance::coreModList()
{
I_D(LegacyInstance);
if(!d->core_mod_list)
@@ -104,7 +104,7 @@ QSharedPointer< ModList > LegacyInstance::coreModList()
return d->core_mod_list;
}
-QSharedPointer< ModList > LegacyInstance::jarModList()
+std::shared_ptr< ModList > LegacyInstance::jarModList()
{
I_D(LegacyInstance);
if(!d->jar_mod_list)
@@ -124,7 +124,7 @@ void LegacyInstance::jarModsChanged()
}
-QSharedPointer< ModList > LegacyInstance::loaderModList()
+std::shared_ptr< ModList > LegacyInstance::loaderModList()
{
I_D(LegacyInstance);
if(!d->loader_mod_list)
@@ -136,7 +136,7 @@ QSharedPointer< ModList > LegacyInstance::loaderModList()
return d->loader_mod_list;
}
-QSharedPointer< ModList > LegacyInstance::texturePackList()
+std::shared_ptr< ModList > LegacyInstance::texturePackList()
{
I_D(LegacyInstance);
if(!d->texture_pack_list)
diff --git a/logic/LegacyInstance.h b/logic/LegacyInstance.h
index 2eab9035..d7438cca 100644
--- a/logic/LegacyInstance.h
+++ b/logic/LegacyInstance.h
@@ -19,10 +19,10 @@ public:
QString modListFile() const;
////// Mod Lists //////
- QSharedPointer<ModList> jarModList();
- QSharedPointer<ModList> coreModList();
- QSharedPointer<ModList> loaderModList();
- QSharedPointer<ModList> texturePackList();
+ std::shared_ptr<ModList> jarModList();
+ std::shared_ptr<ModList> coreModList();
+ std::shared_ptr<ModList> loaderModList();
+ std::shared_ptr<ModList> texturePackList();
////// Directories //////
QString savesDir() const;
diff --git a/logic/LegacyInstance_p.h b/logic/LegacyInstance_p.h
index d1f417fe..0809b8d2 100644
--- a/logic/LegacyInstance_p.h
+++ b/logic/LegacyInstance_p.h
@@ -9,8 +9,8 @@ class ModList;
struct LegacyInstancePrivate: public BaseInstancePrivate
{
- QSharedPointer<ModList> jar_mod_list;
- QSharedPointer<ModList> core_mod_list;
- QSharedPointer<ModList> loader_mod_list;
- QSharedPointer<ModList> texture_pack_list;
+ std::shared_ptr<ModList> jar_mod_list;
+ std::shared_ptr<ModList> core_mod_list;
+ std::shared_ptr<ModList> loader_mod_list;
+ std::shared_ptr<ModList> texture_pack_list;
}; \ No newline at end of file
diff --git a/logic/LegacyUpdate.cpp b/logic/LegacyUpdate.cpp
index d8e622dd..5f5a2e52 100644
--- a/logic/LegacyUpdate.cpp
+++ b/logic/LegacyUpdate.cpp
@@ -9,9 +9,11 @@
#include <quazip.h>
#include <quazipfile.h>
#include <JlCompress.h>
+#include <logger/QsLog.h>
-
-LegacyUpdate::LegacyUpdate ( BaseInstance* inst, QObject* parent ) : BaseUpdate ( inst, parent ) {}
+LegacyUpdate::LegacyUpdate(BaseInstance *inst, QObject *parent) : BaseUpdate(inst, parent)
+{
+}
void LegacyUpdate::executeTask()
{
@@ -20,35 +22,35 @@ void LegacyUpdate::executeTask()
void LegacyUpdate::lwjglStart()
{
- LegacyInstance * inst = (LegacyInstance *) m_inst;
+ LegacyInstance *inst = (LegacyInstance *)m_inst;
+
+ lwjglVersion = inst->lwjglVersion();
+ lwjglTargetPath = PathCombine("lwjgl", lwjglVersion);
+ lwjglNativesPath = PathCombine(lwjglTargetPath, "natives");
- lwjglVersion = inst->lwjglVersion();
- lwjglTargetPath = PathCombine("lwjgl", lwjglVersion );
- lwjglNativesPath = PathCombine( lwjglTargetPath, "natives");
-
// if the 'done' file exists, we don't have to download this again
QFileInfo doneFile(PathCombine(lwjglTargetPath, "done"));
- if(doneFile.exists())
+ if (doneFile.exists())
{
jarStart();
return;
}
-
+
auto list = MMC->lwjgllist();
- if(!list->isLoaded())
+ if (!list->isLoaded())
{
emitFailed("Too soon! Let the LWJGL list load :)");
return;
}
-
+
setStatus("Downloading new LWJGL.");
auto version = list->getVersion(lwjglVersion);
- if(!version)
+ if (!version)
{
emitFailed("Game update failed: the selected LWJGL version is invalid.");
return;
}
-
+
QString url = version->url();
QUrl realUrl(url);
QString hostname = realUrl.host();
@@ -56,39 +58,42 @@ void LegacyUpdate::lwjglStart()
QNetworkRequest req(realUrl);
req.setRawHeader("Host", hostname.toLatin1());
req.setHeader(QNetworkRequest::UserAgentHeader, "Wget/1.14 (linux-gnu)");
- QNetworkReply * rep = worker->get ( req );
-
- m_reply = QSharedPointer<QNetworkReply> (rep, &QObject::deleteLater);
- connect(rep, SIGNAL(downloadProgress(qint64,qint64)), SIGNAL(progress(qint64,qint64)));
- connect(worker.data(), SIGNAL(finished(QNetworkReply*)), SLOT(lwjglFinished(QNetworkReply*)));
- //connect(rep, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(downloadError(QNetworkReply::NetworkError)));
+ QNetworkReply *rep = worker->get(req);
+
+ m_reply = std::shared_ptr<QNetworkReply>(rep);
+ connect(rep, SIGNAL(downloadProgress(qint64, qint64)), SIGNAL(progress(qint64, qint64)));
+ connect(worker.get(), SIGNAL(finished(QNetworkReply *)),
+ SLOT(lwjglFinished(QNetworkReply *)));
+ // connect(rep, SIGNAL(error(QNetworkReply::NetworkError)),
+ // SLOT(downloadError(QNetworkReply::NetworkError)));
}
-void LegacyUpdate::lwjglFinished(QNetworkReply* reply)
+void LegacyUpdate::lwjglFinished(QNetworkReply *reply)
{
- if(m_reply != reply)
+ if (m_reply.get() != reply)
{
return;
}
- if(reply->error() != QNetworkReply::NoError)
+ if (reply->error() != QNetworkReply::NoError)
{
- emitFailed( "Failed to download: "+
- reply->errorString()+
- "\nSometimes you have to wait a bit if you download many LWJGL versions in a row. YMMV");
+ emitFailed("Failed to download: " + reply->errorString() +
+ "\nSometimes you have to wait a bit if you download many LWJGL versions in "
+ "a row. YMMV");
return;
}
auto worker = MMC->qnam();
- //Here i check if there is a cookie for me in the reply and extract it
- QList<QNetworkCookie> cookies = qvariant_cast<QList<QNetworkCookie>>(reply->header(QNetworkRequest::SetCookieHeader));
- if(cookies.count() != 0)
+ // Here i check if there is a cookie for me in the reply and extract it
+ QList<QNetworkCookie> cookies =
+ qvariant_cast<QList<QNetworkCookie>>(reply->header(QNetworkRequest::SetCookieHeader));
+ if (cookies.count() != 0)
{
- //you must tell which cookie goes with which url
+ // you must tell which cookie goes with which url
worker->cookieJar()->setCookiesFromUrl(cookies, QUrl("sourceforge.net"));
}
- //here you can check for the 302 or whatever other header i need
+ // here you can check for the 302 or whatever other header i need
QVariant newLoc = reply->header(QNetworkRequest::LocationHeader);
- if(newLoc.isValid())
+ if (newLoc.isValid())
{
QString redirectedTo = reply->header(QNetworkRequest::LocationHeader).toString();
QUrl realUrl(redirectedTo);
@@ -96,9 +101,10 @@ void LegacyUpdate::lwjglFinished(QNetworkReply* reply)
QNetworkRequest req(redirectedTo);
req.setRawHeader("Host", hostname.toLatin1());
req.setHeader(QNetworkRequest::UserAgentHeader, "Wget/1.14 (linux-gnu)");
- QNetworkReply * rep = worker->get(req);
- connect(rep, SIGNAL(downloadProgress(qint64,qint64)), SIGNAL(progress(qint64,qint64)));
- m_reply = QSharedPointer<QNetworkReply> (rep, &QObject::deleteLater);
+ QNetworkReply *rep = worker->get(req);
+ connect(rep, SIGNAL(downloadProgress(qint64, qint64)),
+ SIGNAL(progress(qint64, qint64)));
+ m_reply = std::shared_ptr<QNetworkReply>(rep);
return;
}
QFile saveMe("lwjgl.zip");
@@ -114,26 +120,26 @@ void LegacyUpdate::extractLwjgl()
// make sure the directories are there
bool success = ensureFolderPathExists(lwjglNativesPath);
-
- if(!success)
+
+ if (!success)
{
emitFailed("Failed to extract the lwjgl libs - error when creating required folders.");
return;
}
-
+
QuaZip zip("lwjgl.zip");
- if(!zip.open(QuaZip::mdUnzip))
+ if (!zip.open(QuaZip::mdUnzip))
{
emitFailed("Failed to extract the lwjgl libs - not a valid archive.");
return;
}
-
+
// and now we are going to access files inside it
QuaZipFile file(&zip);
- const QString jarNames[] = { "jinput.jar", "lwjgl_util.jar", "lwjgl.jar" };
- for(bool more=zip.goToFirstFile(); more; more=zip.goToNextFile())
+ const QString jarNames[] = {"jinput.jar", "lwjgl_util.jar", "lwjgl.jar"};
+ for (bool more = zip.goToFirstFile(); more; more = zip.goToNextFile())
{
- if(!file.open(QIODevice::ReadOnly))
+ if (!file.open(QIODevice::ReadOnly))
{
zip.close();
emitFailed("Failed to extract the lwjgl libs - error while reading archive.");
@@ -141,7 +147,7 @@ void LegacyUpdate::extractLwjgl()
}
QuaZipFileInfo info;
QString name = file.getActualFileName();
- if(name.endsWith('/'))
+ if (name.endsWith('/'))
{
file.close();
continue;
@@ -156,25 +162,25 @@ void LegacyUpdate::extractLwjgl()
}
}
// Not found? look for the natives
- if(destFileName.isEmpty())
+ if (destFileName.isEmpty())
{
#ifdef Q_OS_WIN32
QString nativesDir = "windows";
#else
- #ifdef Q_OS_MAC
+#ifdef Q_OS_MAC
QString nativesDir = "macosx";
- #else
+#else
QString nativesDir = "linux";
- #endif
+#endif
#endif
if (name.contains(nativesDir))
{
int lastSlash = name.lastIndexOf('/');
int lastBackSlash = name.lastIndexOf('\\');
- if(lastSlash != -1)
- name = name.mid(lastSlash+1);
- else if(lastBackSlash != -1)
- name = name.mid(lastBackSlash+1);
+ if (lastSlash != -1)
+ name = name.mid(lastSlash + 1);
+ else if (lastBackSlash != -1)
+ name = name.mid(lastBackSlash + 1);
destFileName = PathCombine(lwjglNativesPath, name);
}
}
@@ -190,7 +196,7 @@ void LegacyUpdate::extractLwjgl()
file.close(); // do not forget to close!
}
zip.close();
- m_reply.clear();
+ m_reply.reset();
QFile doneFile(PathCombine(lwjglTargetPath, "done"));
doneFile.open(QIODevice::WriteOnly);
doneFile.write("done.");
@@ -204,13 +210,13 @@ void LegacyUpdate::lwjglFailed()
void LegacyUpdate::jarStart()
{
- LegacyInstance * inst = (LegacyInstance *) m_inst;
- if(!inst->shouldUpdate() || inst->shouldUseCustomBaseJar())
+ LegacyInstance *inst = (LegacyInstance *)m_inst;
+ if (!inst->shouldUpdate() || inst->shouldUseCustomBaseJar())
{
ModTheJar();
return;
}
-
+
setStatus("Checking for jar updates...");
// Make directories
QDir binDir(inst->binDir());
@@ -226,13 +232,13 @@ void LegacyUpdate::jarStart()
QString urlstr("http://s3.amazonaws.com/Minecraft.Download/versions/");
QString intended_version_id = inst->intendedVersionId();
urlstr += intended_version_id + "/" + intended_version_id + ".jar";
-
+
auto dljob = new DownloadJob("Minecraft.jar for version " + intended_version_id);
dljob->addFileDownload(QUrl(urlstr), inst->defaultBaseJar());
legacyDownloadJob.reset(dljob);
connect(dljob, SIGNAL(succeeded()), SLOT(jarFinished()));
connect(dljob, SIGNAL(failed()), SLOT(jarFailed()));
- connect(dljob, SIGNAL(progress(qint64,qint64)), SIGNAL(progress(qint64,qint64)));
+ connect(dljob, SIGNAL(progress(qint64, qint64)), SIGNAL(progress(qint64, qint64)));
legacyDownloadJob->start();
}
@@ -248,34 +254,36 @@ void LegacyUpdate::jarFailed()
emitFailed("Failed to download the minecraft jar. Try again later.");
}
-bool LegacyUpdate::MergeZipFiles( QuaZip* into, QFileInfo from, QSet< QString >& contained, MetainfAction metainf )
+bool LegacyUpdate::MergeZipFiles(QuaZip *into, QFileInfo from, QSet<QString> &contained,
+ MetainfAction metainf)
{
setStatus("Installing mods - Adding " + from.fileName());
-
+
QuaZip modZip(from.filePath());
modZip.open(QuaZip::mdUnzip);
-
+
QuaZipFile fileInsideMod(&modZip);
- QuaZipFile zipOutFile( into );
- for(bool more=modZip.goToFirstFile(); more; more=modZip.goToNextFile())
+ QuaZipFile zipOutFile(into);
+ for (bool more = modZip.goToFirstFile(); more; more = modZip.goToNextFile())
{
QString filename = modZip.getCurrentFileName();
- if(filename.contains("META-INF") && metainf == LegacyUpdate::IgnoreMetainf)
+ if (filename.contains("META-INF") && metainf == LegacyUpdate::IgnoreMetainf)
{
- qDebug() << "Skipping META-INF " << filename << " from " << from.fileName();
+ QLOG_INFO() << "Skipping META-INF " << filename << " from " << from.fileName();
continue;
}
- if(contained.contains(filename))
+ if (contained.contains(filename))
{
- qDebug() << "Skipping already contained file " << filename << " from " << from.fileName();
+ QLOG_INFO() << "Skipping already contained file " << filename << " from "
+ << from.fileName();
continue;
}
contained.insert(filename);
- qDebug() << "Adding file " << filename << " from " << from.fileName();
-
- if(!fileInsideMod.open(QIODevice::ReadOnly))
+ QLOG_INFO() << "Adding file " << filename << " from " << from.fileName();
+
+ if (!fileInsideMod.open(QIODevice::ReadOnly))
{
- qDebug() << "Failed to open " << filename << " from " << from.fileName();
+ QLOG_ERROR() << "Failed to open " << filename << " from " << from.fileName();
return false;
}
/*
@@ -286,17 +294,17 @@ bool LegacyUpdate::MergeZipFiles( QuaZip* into, QFileInfo from, QSet< QString >&
/*
info_out.externalAttr = old_info.externalAttr;
*/
- if(!zipOutFile.open(QIODevice::WriteOnly, info_out))
+ if (!zipOutFile.open(QIODevice::WriteOnly, info_out))
{
- qDebug() << "Failed to open " << filename << " in the jar";
+ QLOG_ERROR() << "Failed to open " << filename << " in the jar";
fileInsideMod.close();
return false;
}
- if(!JlCompress::copyData(fileInsideMod, zipOutFile))
+ if (!JlCompress::copyData(fileInsideMod, zipOutFile))
{
zipOutFile.close();
fileInsideMod.close();
- qDebug() << "Failed to copy data of " << filename << " into the jar";
+ QLOG_ERROR() << "Failed to copy data of " << filename << " into the jar";
return false;
}
zipOutFile.close();
@@ -307,34 +315,34 @@ bool LegacyUpdate::MergeZipFiles( QuaZip* into, QFileInfo from, QSet< QString >&
void LegacyUpdate::ModTheJar()
{
- LegacyInstance * inst = (LegacyInstance *) m_inst;
-
- if(!inst->shouldRebuild())
+ LegacyInstance *inst = (LegacyInstance *)m_inst;
+
+ if (!inst->shouldRebuild())
{
emitSucceeded();
return;
}
-
+
// Get the mod list
auto modList = inst->jarModList();
-
- QFileInfo runnableJar (inst->runnableJar());
- QFileInfo baseJar (inst->baseJar());
+
+ QFileInfo runnableJar(inst->runnableJar());
+ QFileInfo baseJar(inst->baseJar());
bool base_is_custom = inst->shouldUseCustomBaseJar();
-
+
// Nothing to do if there are no jar mods to install, no backup and just the mc jar
- if(base_is_custom)
+ if (base_is_custom)
{
// yes, this can happen if the instance only has the runnable jar and not the base jar
// it *could* be assumed that such an instance is vanilla, but that wouldn't be safe
// because that's not something mmc4 guarantees
- if(runnableJar.isFile() && !baseJar.exists() && modList->empty())
+ if (runnableJar.isFile() && !baseJar.exists() && modList->empty())
{
inst->setShouldRebuild(false);
emitSucceeded();
return;
}
-
+
setStatus("Installing mods - backing up minecraft.jar...");
if (!baseJar.exists() && !QFile::copy(runnableJar.filePath(), baseJar.filePath()))
{
@@ -342,24 +350,24 @@ void LegacyUpdate::ModTheJar()
return;
}
}
-
+
if (!baseJar.exists())
{
emitFailed("The base jar " + baseJar.filePath() + " does not exist");
return;
}
-
+
if (runnableJar.exists() && !QFile::remove(runnableJar.filePath()))
{
emitFailed("Failed to delete old minecraft.jar");
return;
}
-
- //TaskStep(); // STEP 1
+
+ // TaskStep(); // STEP 1
setStatus("Installing mods - Opening minecraft.jar");
QuaZip zipOut(runnableJar.filePath());
- if(!zipOut.open(QuaZip::mdCreate))
+ if (!zipOut.open(QuaZip::mdCreate))
{
QFile::remove(runnableJar.filePath());
emitFailed("Failed to open the minecraft.jar for modding");
@@ -376,7 +384,7 @@ void LegacyUpdate::ModTheJar()
auto &mod = modList->operator[](i);
if (mod.type() == Mod::MOD_ZIPFILE)
{
- if(!MergeZipFiles(&zipOut, mod.filename(), addedFiles, LegacyUpdate::KeepMetainf))
+ if (!MergeZipFiles(&zipOut, mod.filename(), addedFiles, LegacyUpdate::KeepMetainf))
{
zipOut.close();
QFile::remove(runnableJar.filePath());
@@ -387,7 +395,8 @@ void LegacyUpdate::ModTheJar()
else if (mod.type() == Mod::MOD_SINGLEFILE)
{
auto filename = mod.filename();
- if(!JlCompress::compressFile(&zipOut, filename.absoluteFilePath(), filename.fileName()))
+ if (!JlCompress::compressFile(&zipOut, filename.absoluteFilePath(),
+ filename.fileName()))
{
zipOut.close();
QFile::remove(runnableJar.filePath());
@@ -395,7 +404,8 @@ void LegacyUpdate::ModTheJar()
return;
}
addedFiles.insert(filename.fileName());
- qDebug() << "Adding file " << filename.fileName() << " from " << filename.absoluteFilePath();
+ QLOG_INFO() << "Adding file " << filename.fileName() << " from "
+ << filename.absoluteFilePath();
}
else if (mod.type() == Mod::MOD_FOLDER)
{
@@ -404,35 +414,36 @@ void LegacyUpdate::ModTheJar()
QDir dir(what_to_zip);
dir.cdUp();
QString parent_dir = dir.absolutePath();
- if(!JlCompress::compressSubDir(&zipOut, what_to_zip, parent_dir, true, addedFiles))
+ if (!JlCompress::compressSubDir(&zipOut, what_to_zip, parent_dir, true, addedFiles))
{
zipOut.close();
QFile::remove(runnableJar.filePath());
emitFailed("Failed to add " + filename.fileName() + " to the jar");
return;
}
- qDebug() << "Adding folder " << filename.fileName() << " from " << filename.absoluteFilePath();
+ QLOG_INFO() << "Adding folder " << filename.fileName() << " from "
+ << filename.absoluteFilePath();
}
}
-
- if(!MergeZipFiles(&zipOut, baseJar, addedFiles, LegacyUpdate::IgnoreMetainf))
+
+ if (!MergeZipFiles(&zipOut, baseJar, addedFiles, LegacyUpdate::IgnoreMetainf))
{
zipOut.close();
QFile::remove(runnableJar.filePath());
emitFailed("Failed to insert minecraft.jar contents.");
return;
}
-
+
// Recompress the jar
zipOut.close();
- if(zipOut.getZipError()!=0)
+ if (zipOut.getZipError() != 0)
{
QFile::remove(runnableJar.filePath());
emitFailed("Failed to finalize minecraft.jar!");
return;
- }
+ }
inst->setShouldRebuild(false);
- //inst->UpdateVersion(true);
+ // inst->UpdateVersion(true);
emitSucceeded();
return;
} \ No newline at end of file
diff --git a/logic/LegacyUpdate.h b/logic/LegacyUpdate.h
index 05c00495..e84ec56a 100644
--- a/logic/LegacyUpdate.h
+++ b/logic/LegacyUpdate.h
@@ -56,7 +56,7 @@ private:
bool MergeZipFiles(QuaZip *into, QFileInfo from, QSet<QString>& contained, MetainfAction metainf);
private:
- QSharedPointer<QNetworkReply> m_reply;
+ std::shared_ptr<QNetworkReply> m_reply;
// target version, determined during this task
// MinecraftVersion *targetVersion;
diff --git a/logic/Mod.cpp b/logic/Mod.cpp
index 38faa760..75e0a3a9 100644
--- a/logic/Mod.cpp
+++ b/logic/Mod.cpp
@@ -20,14 +20,13 @@
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonValue>
-#include <QDebug>
#include <quazip.h>
#include <quazipfile.h>
#include "Mod.h"
#include <pathutils.h>
#include <inifile.h>
-
+#include <logger/QsLog.h>
Mod::Mod( const QFileInfo& file )
{
@@ -134,8 +133,8 @@ void Mod::ReadMCModInfo(QByteArray contents)
int version = val.toDouble();
if(version != 2)
{
- qDebug() << "BAD stuff happened to mod json:";
- qDebug() << contents;
+ QLOG_ERROR() << "BAD stuff happened to mod json:";
+ QLOG_ERROR() << contents;
return;
}
auto arrVal = jsonDoc.object().value("modlist");
diff --git a/logic/ModList.cpp b/logic/ModList.cpp
index 84511e4c..a600afff 100644
--- a/logic/ModList.cpp
+++ b/logic/ModList.cpp
@@ -19,9 +19,9 @@
#include <pathutils.h>
#include <QMimeData>
#include <QUrl>
-#include <QDebug>
#include <QUuid>
#include <QFileSystemWatcher>
+#include <logger/QsLog.h>
ModList::ModList ( const QString& dir, const QString& list_file )
: QAbstractListModel(), m_dir(dir), m_list_file(list_file)
@@ -39,18 +39,18 @@ void ModList::startWatching()
{
is_watching = m_watcher->addPath(m_dir.absolutePath());
if(is_watching)
- qDebug() << "Started watching " << m_dir.absolutePath();
+ QLOG_INFO() << "Started watching " << m_dir.absolutePath();
else
- qDebug() << "Failed to start watching " << m_dir.absolutePath();
+ QLOG_INFO() << "Failed to start watching " << m_dir.absolutePath();
}
void ModList::stopWatching()
{
is_watching = !m_watcher->removePath(m_dir.absolutePath());
if(!is_watching)
- qDebug() << "Stopped watching " << m_dir.absolutePath();
+ QLOG_INFO() << "Stopped watching " << m_dir.absolutePath();
else
- qDebug() << "Failed to stop watching " << m_dir.absolutePath();
+ QLOG_INFO() << "Failed to stop watching " << m_dir.absolutePath();
}
@@ -436,7 +436,7 @@ bool ModList::dropMimeData ( const QMimeData* data, Qt::DropAction action, int r
row = rowCount();
if (column == -1)
column = 0;
- qDebug() << "Drop row: " << row << " column: " << column;
+ QLOG_INFO() << "Drop row: " << row << " column: " << column;
// files dropped from outside?
if(data->hasUrls())
@@ -452,7 +452,7 @@ bool ModList::dropMimeData ( const QMimeData* data, Qt::DropAction action, int r
continue;
QString filename = url.toLocalFile();
installMod(filename, row);
- qDebug() << "installing: " << filename;
+ QLOG_INFO() << "installing: " << filename;
}
if(was_watching)
startWatching();
@@ -466,7 +466,7 @@ bool ModList::dropMimeData ( const QMimeData* data, Qt::DropAction action, int r
return false;
QString remoteId = list[0];
int remoteIndex = list[1].toInt();
- qDebug() << "move: " << sourcestr;
+ QLOG_INFO() << "move: " << sourcestr;
// no moving of things between two lists
if(remoteId != m_list_id)
return false;
diff --git a/logic/OneSixAssets.cpp b/logic/OneSixAssets.cpp
index ca7a5534..6aa0a207 100644
--- a/logic/OneSixAssets.cpp
+++ b/logic/OneSixAssets.cpp
@@ -1,5 +1,5 @@
#include <QString>
-#include <QDebug>
+#include <logger/QsLog.h>
#include <QtXml/QtXml>
#include "OneSixAssets.h"
#include "net/DownloadJob.h"
@@ -21,6 +21,7 @@ class ThreadedDeleter : public QThread
public:
void run()
{
+ QLOG_INFO() << "Cleaning up assets folder...";
QDirIterator iter ( m_base, QDirIterator::Subdirectories );
int base_length = m_base.length();
while ( iter.hasNext() )
@@ -34,12 +35,12 @@ public:
trimmedf.remove ( 0, base_length + 1 );
if ( m_whitelist.contains ( trimmedf ) )
{
- // qDebug() << trimmedf << " gets to live";
+ QLOG_TRACE() << trimmedf << " gets to live";
}
else
{
// DO NOT TOLERATE JUNK
- // qDebug() << trimmedf << " dies";
+ QLOG_TRACE() << trimmedf << " dies";
QFile f ( filename );
f.remove();
}
@@ -67,13 +68,15 @@ void OneSixAssets::fetchXMLFinished()
nuke_whitelist.clear();
auto firstJob = index_job->first();
- QByteArray ba = firstJob.dynamicCast<ByteArrayDownload>()->m_data;
+ QByteArray ba = std::dynamic_pointer_cast<ByteArrayDownload>(firstJob)->m_data;
QString xmlErrorMsg;
QDomDocument doc;
if ( !doc.setContent ( ba, false, &xmlErrorMsg ) )
{
- qDebug() << "Failed to process s3.amazonaws.com/Minecraft.Resources. XML error:" << xmlErrorMsg << ba;
+ QLOG_ERROR() << "Failed to process s3.amazonaws.com/Minecraft.Resources. XML error:" << xmlErrorMsg << ba;
+ emit failed();
+ return;
}
//QRegExp etag_match(".*([a-f0-9]{32}).*");
QDomNodeList contents = doc.elementsByTagName ( "Contents" );
diff --git a/logic/OneSixInstance.cpp b/logic/OneSixInstance.cpp
index 6e39b5b5..c5d546a3 100644
--- a/logic/OneSixInstance.cpp
+++ b/logic/OneSixInstance.cpp
@@ -9,6 +9,7 @@
#include <cmdutils.h>
#include <JlCompress.h>
#include <gui/OneSixModEditDialog.h>
+#include <logger/QsLog.h>
OneSixInstance::OneSixInstance(const QString &rootDir, SettingsObject *setting_obj,
QObject *parent)
@@ -102,7 +103,7 @@ MinecraftProcess *OneSixInstance::prepareForLaunch(LoginResponse response)
for (auto lib : libs_to_extract)
{
QString path = "libraries/" + lib->storagePath();
- qDebug() << "Will extract " << path.toLocal8Bit();
+ QLOG_INFO() << "Will extract " << path.toLocal8Bit();
if (JlCompress::extractWithExceptions(path, natives_dir_raw, lib->extract_excludes)
.isEmpty())
{
@@ -156,7 +157,7 @@ void OneSixInstance::cleanupAfterRun()
dir.removeRecursively();
}
-QSharedPointer<ModList> OneSixInstance::loaderModList()
+std::shared_ptr<ModList> OneSixInstance::loaderModList()
{
I_D(OneSixInstance);
if (!d->loader_mod_list)
@@ -168,7 +169,7 @@ QSharedPointer<ModList> OneSixInstance::loaderModList()
return d->loader_mod_list;
}
-QSharedPointer<ModList> OneSixInstance::resourcePackList()
+std::shared_ptr<ModList> OneSixInstance::resourcePackList()
{
I_D(OneSixInstance);
if (!d->resource_pack_list)
@@ -271,7 +272,7 @@ bool OneSixInstance::reloadFullVersion()
return false;
}
-QSharedPointer<OneSixVersion> OneSixInstance::getFullVersion()
+std::shared_ptr<OneSixVersion> OneSixInstance::getFullVersion()
{
I_D(OneSixInstance);
return d->version;
diff --git a/logic/OneSixInstance.h b/logic/OneSixInstance.h
index 33091188..8f5c22e6 100644
--- a/logic/OneSixInstance.h
+++ b/logic/OneSixInstance.h
@@ -14,8 +14,8 @@ public:
////// Mod Lists //////
- QSharedPointer<ModList> loaderModList();
- QSharedPointer<ModList> resourcePackList();
+ std::shared_ptr<ModList> loaderModList();
+ std::shared_ptr<ModList> resourcePackList();
////// Directories //////
QString resourcePacksDir() const;
@@ -40,7 +40,7 @@ public:
/// reload the full version json file. return true on success!
bool reloadFullVersion();
/// get the current full version info
- QSharedPointer<OneSixVersion> getFullVersion();
+ std::shared_ptr<OneSixVersion> getFullVersion();
/// revert the current custom version back to base
bool revertCustomVersion();
/// customize the current base version
diff --git a/logic/OneSixInstance_p.h b/logic/OneSixInstance_p.h
index 7b1ca82e..06737b6f 100644
--- a/logic/OneSixInstance_p.h
+++ b/logic/OneSixInstance_p.h
@@ -7,7 +7,7 @@
struct OneSixInstancePrivate: public BaseInstancePrivate
{
- QSharedPointer<OneSixVersion> version;
- QSharedPointer<ModList> loader_mod_list;
- QSharedPointer<ModList> resource_pack_list;
+ std::shared_ptr<OneSixVersion> version;
+ std::shared_ptr<ModList> loader_mod_list;
+ std::shared_ptr<ModList> resource_pack_list;
}; \ No newline at end of file
diff --git a/logic/OneSixLibrary.cpp b/logic/OneSixLibrary.cpp
index 63d42646..0643abe3 100644
--- a/logic/OneSixLibrary.cpp
+++ b/logic/OneSixLibrary.cpp
@@ -72,7 +72,7 @@ void OneSixLibrary::addNative(OpSys os, QString suffix)
m_is_native = true;
m_native_suffixes[os] = suffix;
}
-void OneSixLibrary::setRules(QList<QSharedPointer<Rule>> rules)
+void OneSixLibrary::setRules(QList<std::shared_ptr<Rule>> rules)
{
m_rules = rules;
}
diff --git a/logic/OneSixLibrary.h b/logic/OneSixLibrary.h
index 2a16d8e1..a8bcc364 100644
--- a/logic/OneSixLibrary.h
+++ b/logic/OneSixLibrary.h
@@ -2,7 +2,7 @@
#include <QString>
#include <QStringList>
#include <QMap>
-#include <QSharedPointer>
+#include <memory>
#include <QJsonObject>
#include "OpSys.h"
@@ -14,7 +14,7 @@ private:
// basic values used internally (so far)
QString m_name;
QString m_base_url = "https://s3.amazonaws.com/Minecraft.Download/libraries/";
- QList<QSharedPointer<Rule> > m_rules;
+ QList<std::shared_ptr<Rule> > m_rules;
// custom values
/// absolute URL. takes precedence over m_download_path, if defined
@@ -83,7 +83,7 @@ public:
/// Attach a name suffix to the specified OS native
void addNative(OpSys os, QString suffix);
/// Set the load rules
- void setRules(QList<QSharedPointer<Rule> > rules);
+ void setRules(QList<std::shared_ptr<Rule> > rules);
/// Returns true if the library should be loaded (or extracted, in case of natives)
bool isActive();
diff --git a/logic/OneSixRule.cpp b/logic/OneSixRule.cpp
index 545cd641..cb64c9ba 100644
--- a/logic/OneSixRule.cpp
+++ b/logic/OneSixRule.cpp
@@ -2,9 +2,9 @@
#include <QJsonObject>
#include <QJsonArray>
-QList<QSharedPointer<Rule>> rulesFromJsonV4(QJsonObject &objectWithRules)
+QList<std::shared_ptr<Rule>> rulesFromJsonV4(QJsonObject &objectWithRules)
{
- QList<QSharedPointer<Rule>> rules;
+ QList<std::shared_ptr<Rule>> rules;
auto rulesVal = objectWithRules.value("rules");
if (!rulesVal.isArray())
return rules;
@@ -12,7 +12,7 @@ QList<QSharedPointer<Rule>> rulesFromJsonV4(QJsonObject &objectWithRules)
QJsonArray ruleList = rulesVal.toArray();
for (auto ruleVal : ruleList)
{
- QSharedPointer<Rule> rule;
+ std::shared_ptr<Rule> rule;
if (!ruleVal.isObject())
continue;
auto ruleObj = ruleVal.toObject();
diff --git a/logic/OneSixRule.h b/logic/OneSixRule.h
index 23d20ff4..6be01f1b 100644
--- a/logic/OneSixRule.h
+++ b/logic/OneSixRule.h
@@ -11,7 +11,7 @@ enum RuleAction
};
RuleAction RuleAction_fromString(QString);
-QList<QSharedPointer<Rule>> rulesFromJsonV4(QJsonObject &objectWithRules);
+QList<std::shared_ptr<Rule>> rulesFromJsonV4(QJsonObject &objectWithRules);
class Rule
{
@@ -48,9 +48,9 @@ protected:
: Rule(result), m_system(system), m_version_regexp(version_regexp) {}
public:
virtual QJsonObject toJson();
- static QSharedPointer<OsRule> create(RuleAction result, OpSys system, QString version_regexp)
+ static std::shared_ptr<OsRule> create(RuleAction result, OpSys system, QString version_regexp)
{
- return QSharedPointer<OsRule> (new OsRule(result, system, version_regexp));
+ return std::shared_ptr<OsRule> (new OsRule(result, system, version_regexp));
}
};
@@ -65,8 +65,8 @@ protected:
: Rule(result) {}
public:
virtual QJsonObject toJson();
- static QSharedPointer<ImplicitRule> create(RuleAction result)
+ static std::shared_ptr<ImplicitRule> create(RuleAction result)
{
- return QSharedPointer<ImplicitRule> (new ImplicitRule(result));
+ return std::shared_ptr<ImplicitRule> (new ImplicitRule(result));
}
};
diff --git a/logic/OneSixUpdate.cpp b/logic/OneSixUpdate.cpp
index 41d8f599..008995ae 100644
--- a/logic/OneSixUpdate.cpp
+++ b/logic/OneSixUpdate.cpp
@@ -22,8 +22,6 @@
#include <QTextStream>
#include <QDataStream>
-#include <QDebug>
-
#include "BaseInstance.h"
#include "lists/MinecraftVersionList.h"
#include "OneSixVersion.h"
@@ -49,8 +47,8 @@ void OneSixUpdate::executeTask()
}
// Get a pointer to the version object that corresponds to the instance's version.
- targetVersion =
- MMC->minecraftlist()->findVersion(intendedVersion).dynamicCast<MinecraftVersion>();
+ targetVersion = std::dynamic_pointer_cast<MinecraftVersion>(
+ MMC->minecraftlist()->findVersion(intendedVersion));
if (targetVersion == nullptr)
{
// don't do anything if it was invalid
@@ -77,10 +75,9 @@ void OneSixUpdate::versionFileStart()
auto job = new DownloadJob("Version index");
job->addByteArrayDownload(QUrl(urlstr));
specificVersionDownloadJob.reset(job);
- connect(specificVersionDownloadJob.data(), SIGNAL(succeeded()),
- SLOT(versionFileFinished()));
- connect(specificVersionDownloadJob.data(), SIGNAL(failed()), SLOT(versionFileFailed()));
- connect(specificVersionDownloadJob.data(), SIGNAL(progress(qint64, qint64)),
+ connect(specificVersionDownloadJob.get(), SIGNAL(succeeded()), SLOT(versionFileFinished()));
+ connect(specificVersionDownloadJob.get(), SIGNAL(failed()), SLOT(versionFileFailed()));
+ connect(specificVersionDownloadJob.get(), SIGNAL(progress(qint64, qint64)),
SIGNAL(progress(qint64, qint64)));
specificVersionDownloadJob->start();
}
@@ -103,7 +100,7 @@ void OneSixUpdate::versionFileFinished()
emitFailed("Can't open " + version1 + " for writing.");
return;
}
- auto data = DlJob.dynamicCast<ByteArrayDownload>()->m_data;
+ auto data = std::dynamic_pointer_cast<ByteArrayDownload>(DlJob)->m_data;
qint64 actual = 0;
if ((actual = vfile1.write(data)) != data.size())
{
@@ -149,7 +146,7 @@ void OneSixUpdate::jarlibStart()
return;
}
- QSharedPointer<OneSixVersion> version = inst->getFullVersion();
+ std::shared_ptr<OneSixVersion> version = inst->getFullVersion();
// download the right jar, save it in versions/$version/$version.jar
QString urlstr("http://s3.amazonaws.com/Minecraft.Download/versions/");
@@ -171,15 +168,15 @@ void OneSixUpdate::jarlibStart()
auto entry = metacache->resolveEntry("libraries", lib->storagePath());
if (entry->stale)
{
- if(lib->hint() == "forge-pack-xz")
+ if (lib->hint() == "forge-pack-xz")
jarlibDownloadJob->addForgeXzDownload(download_path, entry);
else
jarlibDownloadJob->addCacheDownload(download_path, entry);
}
}
- connect(jarlibDownloadJob.data(), SIGNAL(succeeded()), SLOT(jarlibFinished()));
- connect(jarlibDownloadJob.data(), SIGNAL(failed()), SLOT(jarlibFailed()));
- connect(jarlibDownloadJob.data(), SIGNAL(progress(qint64, qint64)),
+ connect(jarlibDownloadJob.get(), SIGNAL(succeeded()), SLOT(jarlibFinished()));
+ connect(jarlibDownloadJob.get(), SIGNAL(failed()), SLOT(jarlibFailed()));
+ connect(jarlibDownloadJob.get(), SIGNAL(progress(qint64, qint64)),
SIGNAL(progress(qint64, qint64)));
jarlibDownloadJob->start();
diff --git a/logic/OneSixUpdate.h b/logic/OneSixUpdate.h
index 7314a6d1..ed8dcbcd 100644
--- a/logic/OneSixUpdate.h
+++ b/logic/OneSixUpdate.h
@@ -47,7 +47,7 @@ private:
DownloadJobPtr jarlibDownloadJob;
// target version, determined during this task
- QSharedPointer<MinecraftVersion> targetVersion;
+ std::shared_ptr<MinecraftVersion> targetVersion;
};
diff --git a/logic/OneSixVersion.cpp b/logic/OneSixVersion.cpp
index 64a47562..f7efedf9 100644
--- a/logic/OneSixVersion.cpp
+++ b/logic/OneSixVersion.cpp
@@ -2,8 +2,8 @@
#include "OneSixLibrary.h"
#include "OneSixRule.h"
-QSharedPointer<OneSixVersion> fromJsonV4(QJsonObject root,
- QSharedPointer<OneSixVersion> fullVersion)
+std::shared_ptr<OneSixVersion> fromJsonV4(QJsonObject root,
+ std::shared_ptr<OneSixVersion> fullVersion)
{
fullVersion->id = root.value("id").toString();
@@ -64,7 +64,7 @@ QSharedPointer<OneSixVersion> fromJsonV4(QJsonObject root,
auto nameVal = libObj.value("name");
if (!nameVal.isString())
continue;
- QSharedPointer<OneSixLibrary> library(new OneSixLibrary(nameVal.toString()));
+ std::shared_ptr<OneSixLibrary> library(new OneSixLibrary(nameVal.toString()));
auto urlVal = libObj.value("url");
if (urlVal.isString())
@@ -129,9 +129,9 @@ QSharedPointer<OneSixVersion> fromJsonV4(QJsonObject root,
return fullVersion;
}
-QSharedPointer<OneSixVersion> OneSixVersion::fromJson(QJsonObject root)
+std::shared_ptr<OneSixVersion> OneSixVersion::fromJson(QJsonObject root)
{
- QSharedPointer<OneSixVersion> readVersion(new OneSixVersion());
+ std::shared_ptr<OneSixVersion> readVersion(new OneSixVersion());
int launcher_ver = readVersion->minimumLauncherVersion =
root.value("minimumLauncherVersion").toDouble();
@@ -140,16 +140,16 @@ QSharedPointer<OneSixVersion> OneSixVersion::fromJson(QJsonObject root)
return fromJsonV4(root, readVersion);
else
{
- return QSharedPointer<OneSixVersion>();
+ return std::shared_ptr<OneSixVersion>();
}
}
-QSharedPointer<OneSixVersion> OneSixVersion::fromFile(QString filepath)
+std::shared_ptr<OneSixVersion> OneSixVersion::fromFile(QString filepath)
{
QFile file(filepath);
if (!file.open(QIODevice::ReadOnly))
{
- return QSharedPointer<OneSixVersion>();
+ return std::shared_ptr<OneSixVersion>();
}
auto data = file.readAll();
@@ -158,12 +158,12 @@ QSharedPointer<OneSixVersion> OneSixVersion::fromFile(QString filepath)
if (jsonError.error != QJsonParseError::NoError)
{
- return QSharedPointer<OneSixVersion>();
+ return std::shared_ptr<OneSixVersion>();
}
if (!jsonDoc.isObject())
{
- return QSharedPointer<OneSixVersion>();
+ return std::shared_ptr<OneSixVersion>();
}
QJsonObject root = jsonDoc.object();
auto version = fromJson(root);
@@ -202,9 +202,9 @@ bool OneSixVersion::toOriginalFile()
return file.commit();
}
-QList<QSharedPointer<OneSixLibrary>> OneSixVersion::getActiveNormalLibs()
+QList<std::shared_ptr<OneSixLibrary>> OneSixVersion::getActiveNormalLibs()
{
- QList<QSharedPointer<OneSixLibrary>> output;
+ QList<std::shared_ptr<OneSixLibrary>> output;
for (auto lib : libraries)
{
if (lib->isActive() && !lib->isNative())
@@ -215,9 +215,9 @@ QList<QSharedPointer<OneSixLibrary>> OneSixVersion::getActiveNormalLibs()
return output;
}
-QList<QSharedPointer<OneSixLibrary>> OneSixVersion::getActiveNativeLibs()
+QList<std::shared_ptr<OneSixLibrary>> OneSixVersion::getActiveNativeLibs()
{
- QList<QSharedPointer<OneSixLibrary>> output;
+ QList<std::shared_ptr<OneSixLibrary>> output;
for (auto lib : libraries)
{
if (lib->isActive() && lib->isNative())
diff --git a/logic/OneSixVersion.h b/logic/OneSixVersion.h
index 69268ecf..3529138c 100644
--- a/logic/OneSixVersion.h
+++ b/logic/OneSixVersion.h
@@ -1,5 +1,7 @@
#pragma once
#include <QtCore>
+#include <memory>
+
class OneSixLibrary;
class OneSixVersion : public QAbstractListModel
@@ -16,12 +18,12 @@ public:
// serialization/deserialization
public:
bool toOriginalFile();
- static QSharedPointer<OneSixVersion> fromJson(QJsonObject root);
- static QSharedPointer<OneSixVersion> fromFile(QString filepath);
+ static std::shared_ptr<OneSixVersion> fromJson(QJsonObject root);
+ static std::shared_ptr<OneSixVersion> fromFile(QString filepath);
public:
- QList<QSharedPointer<OneSixLibrary>> getActiveNormalLibs();
- QList<QSharedPointer<OneSixLibrary>> getActiveNativeLibs();
+ QList<std::shared_ptr<OneSixLibrary>> getActiveNormalLibs();
+ QList<std::shared_ptr<OneSixLibrary>> getActiveNativeLibs();
// called when something starts/stops messing with the object
// FIXME: these are ugly in every possible way.
void externalUpdateStart();
@@ -62,7 +64,7 @@ public:
QString mainClass;
/// the list of libs - both active and inactive, native and java
- QList<QSharedPointer<OneSixLibrary>> libraries;
+ QList<std::shared_ptr<OneSixLibrary>> libraries;
/*
FIXME: add support for those rules here? Looks like a pile of quick hacks to me though.
diff --git a/logic/lists/ForgeVersionList.cpp b/logic/lists/ForgeVersionList.cpp
index ac1a4ef5..9b698135 100644
--- a/logic/lists/ForgeVersionList.cpp
+++ b/logic/lists/ForgeVersionList.cpp
@@ -18,11 +18,11 @@
#include "MultiMC.h"
#include <QtNetwork>
-
#include <QtXml>
-
#include <QRegExp>
+#include <logger/QsLog.h>
+
#define JSON_URL "http://files.minecraftforge.net/minecraftforge/json"
ForgeVersionList::ForgeVersionList(QObject *parent) : BaseVersionList(parent)
@@ -62,7 +62,7 @@ QVariant ForgeVersionList::data(const QModelIndex &index, int role) const
if (index.row() > count())
return QVariant();
- auto version = m_vlist[index.row()].dynamicCast<ForgeVersion>();
+ auto version = std::dynamic_pointer_cast<ForgeVersion>(m_vlist[index.row()]);
switch (role)
{
case Qt::DisplayRole:
@@ -164,9 +164,9 @@ void ForgeListLoadTask::executeTask()
auto forgeListEntry = MMC->metacache()->resolveEntry("minecraftforge", "list.json");
job->addCacheDownload(QUrl(JSON_URL), forgeListEntry);
listJob.reset(job);
- connect(listJob.data(), SIGNAL(succeeded()), SLOT(list_downloaded()));
- connect(listJob.data(), SIGNAL(failed()), SLOT(list_failed()));
- connect(listJob.data(), SIGNAL(progress(qint64, qint64)), SIGNAL(progress(qint64, qint64)));
+ connect(listJob.get(), SIGNAL(succeeded()), SLOT(list_downloaded()));
+ connect(listJob.get(), SIGNAL(failed()), SLOT(list_failed()));
+ connect(listJob.get(), SIGNAL(progress(qint64, qint64)), SIGNAL(progress(qint64, qint64)));
listJob->start();
}
@@ -176,10 +176,10 @@ void ForgeListLoadTask::list_failed()
auto reply = DlJob->m_reply;
if(reply)
{
- qDebug() << "Getting forge version list failed: " << reply->errorString();
+ QLOG_ERROR() << "Getting forge version list failed: " << reply->errorString();
}
else
- qDebug() << "Getting forge version list failed for reasons unknown.";
+ QLOG_ERROR() << "Getting forge version list failed for reasons unknown.";
}
void ForgeListLoadTask::list_downloaded()
@@ -187,7 +187,7 @@ void ForgeListLoadTask::list_downloaded()
QByteArray data;
{
auto DlJob = listJob->first();
- auto filename = DlJob.dynamicCast<CacheDownload>()->m_target_path;
+ auto filename = std::dynamic_pointer_cast<CacheDownload>(DlJob)->m_target_path;
QFile listFile(filename);
if(!listFile.open(QIODevice::ReadOnly))
return;
@@ -272,7 +272,7 @@ void ForgeListLoadTask::list_downloaded()
if (valid)
{
// Now, we construct the version object and add it to the list.
- QSharedPointer<ForgeVersion> fVersion(new ForgeVersion());
+ std::shared_ptr<ForgeVersion> fVersion(new ForgeVersion());
fVersion->universal_url = url;
fVersion->changelog_url = changelog_url;
fVersion->installer_url = installer_url;
diff --git a/logic/lists/ForgeVersionList.h b/logic/lists/ForgeVersionList.h
index 4abfe9ce..56a207c8 100644
--- a/logic/lists/ForgeVersionList.h
+++ b/logic/lists/ForgeVersionList.h
@@ -26,7 +26,7 @@
#include "logic/net/DownloadJob.h"
class ForgeVersion;
-typedef QSharedPointer<ForgeVersion> ForgeVersionPtr;
+typedef std::shared_ptr<ForgeVersion> ForgeVersionPtr;
struct ForgeVersion : public BaseVersion
{
diff --git a/logic/lists/InstanceList.cpp b/logic/lists/InstanceList.cpp
index b930f781..ac054267 100644
--- a/logic/lists/InstanceList.cpp
+++ b/logic/lists/InstanceList.cpp
@@ -3,7 +3,7 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@@ -29,13 +29,13 @@
#include "logic/lists/IconList.h"
#include "logic/BaseInstance.h"
#include "logic/InstanceFactory.h"
+#include <logger/QsLog.h>
const static int GROUP_FILE_FORMAT_VERSION = 1;
-InstanceList::InstanceList(const QString &instDir, QObject *parent) :
- QAbstractListModel ( parent ), m_instDir("instances")
+InstanceList::InstanceList(const QString &instDir, QObject *parent)
+ : QAbstractListModel(parent), m_instDir("instances")
{
-
}
InstanceList::~InstanceList()
@@ -43,32 +43,32 @@ InstanceList::~InstanceList()
saveGroupList();
}
-int InstanceList::rowCount ( const QModelIndex& parent ) const
+int InstanceList::rowCount(const QModelIndex &parent) const
{
- Q_UNUSED ( parent );
+ Q_UNUSED(parent);
return m_instances.count();
}
-QModelIndex InstanceList::index ( int row, int column, const QModelIndex& parent ) const
+QModelIndex InstanceList::index(int row, int column, const QModelIndex &parent) const
{
- Q_UNUSED ( parent );
- if ( row < 0 || row >= m_instances.size() )
+ Q_UNUSED(parent);
+ if (row < 0 || row >= m_instances.size())
return QModelIndex();
- return createIndex ( row, column, ( void* ) m_instances.at ( row ).data() );
+ return createIndex(row, column, (void *)m_instances.at(row).get());
}
-QVariant InstanceList::data ( const QModelIndex& index, int role ) const
+QVariant InstanceList::data(const QModelIndex &index, int role) const
{
- if ( !index.isValid() )
+ if (!index.isValid())
{
return QVariant();
}
- BaseInstance *pdata = static_cast<BaseInstance*> ( index.internalPointer() );
- switch ( role )
+ BaseInstance *pdata = static_cast<BaseInstance *>(index.internalPointer());
+ switch (role)
{
case InstancePointerRole:
{
- QVariant v = qVariantFromValue((void *) pdata);
+ QVariant v = qVariantFromValue((void *)pdata);
return v;
}
case Qt::DisplayRole:
@@ -96,12 +96,12 @@ QVariant InstanceList::data ( const QModelIndex& index, int role ) const
return QVariant();
}
-Qt::ItemFlags InstanceList::flags ( const QModelIndex& index ) const
+Qt::ItemFlags InstanceList::flags(const QModelIndex &index) const
{
Qt::ItemFlags f;
- if ( index.isValid() )
+ if (index.isValid())
{
- f |= ( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
+ f |= (Qt::ItemIsEnabled | Qt::ItemIsSelectable);
}
return f;
}
@@ -116,23 +116,23 @@ void InstanceList::saveGroupList()
{
QString groupFileName = m_instDir + "/instgroups.json";
QFile groupFile(groupFileName);
-
+
// if you can't open the file, fail
- if (!groupFile.open(QIODevice::WriteOnly| QIODevice::Truncate))
+ if (!groupFile.open(QIODevice::WriteOnly | QIODevice::Truncate))
{
// An error occurred. Ignore it.
- qDebug("Failed to read instance group file.");
+ QLOG_ERROR() << "Failed to read instance group file.";
return;
}
QTextStream out(&groupFile);
- QMap<QString, QSet<QString> > groupMap;
- for(auto instance: m_instances)
+ QMap<QString, QSet<QString>> groupMap;
+ for (auto instance : m_instances)
{
QString id = instance->id();
QString group = instance->group();
- if(group.isEmpty())
+ if (group.isEmpty())
continue;
- if(!groupMap.count(group))
+ if (!groupMap.count(group))
{
QSet<QString> set;
set.insert(id);
@@ -145,109 +145,114 @@ void InstanceList::saveGroupList()
}
}
QJsonObject toplevel;
- toplevel.insert("formatVersion",QJsonValue(QString("1")));
+ toplevel.insert("formatVersion", QJsonValue(QString("1")));
QJsonObject groupsArr;
- for(auto iter = groupMap.begin(); iter != groupMap.end(); iter++)
+ for (auto iter = groupMap.begin(); iter != groupMap.end(); iter++)
{
auto list = iter.value();
auto name = iter.key();
QJsonObject groupObj;
QJsonArray instanceArr;
- groupObj.insert("hidden",QJsonValue(QString("false")));
- for(auto item: list)
+ groupObj.insert("hidden", QJsonValue(QString("false")));
+ for (auto item : list)
{
instanceArr.append(QJsonValue(item));
}
- groupObj.insert("instances",instanceArr);
- groupsArr.insert(name,groupObj);
+ groupObj.insert("instances", instanceArr);
+ groupsArr.insert(name, groupObj);
}
- toplevel.insert("groups",groupsArr);
+ toplevel.insert("groups", groupsArr);
QJsonDocument doc(toplevel);
groupFile.write(doc.toJson());
groupFile.close();
}
-void InstanceList::loadGroupList(QMap<QString, QString> & groupMap)
+void InstanceList::loadGroupList(QMap<QString, QString> &groupMap)
{
QString groupFileName = m_instDir + "/instgroups.json";
-
+
// if there's no group file, fail
- if(!QFileInfo(groupFileName).exists())
+ if (!QFileInfo(groupFileName).exists())
return;
-
+
QFile groupFile(groupFileName);
-
+
// if you can't open the file, fail
if (!groupFile.open(QIODevice::ReadOnly))
{
// An error occurred. Ignore it.
- qDebug("Failed to read instance group file.");
+ QLOG_ERROR() << "Failed to read instance group file.";
return;
}
-
+
QTextStream in(&groupFile);
QString jsonStr = in.readAll();
groupFile.close();
-
+
QJsonParseError error;
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonStr.toUtf8(), &error);
-
+
// if the json was bad, fail
if (error.error != QJsonParseError::NoError)
{
- qWarning(QString("Failed to parse instance group file: %1 at offset %2").
- arg(error.errorString(), QString::number(error.offset)).toUtf8());
+ QLOG_ERROR() << QString("Failed to parse instance group file: %1 at offset %2")
+ .arg(error.errorString(), QString::number(error.offset))
+ .toUtf8();
return;
}
-
+
// if the root of the json wasn't an object, fail
if (!jsonDoc.isObject())
{
qWarning("Invalid group file. Root entry should be an object.");
return;
}
-
+
QJsonObject rootObj = jsonDoc.object();
-
+
// Make sure the format version matches, otherwise fail.
if (rootObj.value("formatVersion").toVariant().toInt() != GROUP_FILE_FORMAT_VERSION)
return;
-
+
// Get the groups. if it's not an object, fail
if (!rootObj.value("groups").isObject())
{
qWarning("Invalid group list JSON: 'groups' should be an object.");
return;
}
-
+
// Iterate through all the groups.
QJsonObject groupMapping = rootObj.value("groups").toObject();
for (QJsonObject::iterator iter = groupMapping.begin(); iter != groupMapping.end(); iter++)
{
QString groupName = iter.key();
-
+
// If not an object, complain and skip to the next one.
if (!iter.value().isObject())
{
qWarning(QString("Group '%1' in the group list should "
- "be an object.").arg(groupName).toUtf8());
+ "be an object.")
+ .arg(groupName)
+ .toUtf8());
continue;
}
-
+
QJsonObject groupObj = iter.value().toObject();
if (!groupObj.value("instances").isArray())
{
qWarning(QString("Group '%1' in the group list is invalid. "
- "It should contain an array "
- "called 'instances'.").arg(groupName).toUtf8());
+ "It should contain an array "
+ "called 'instances'.")
+ .arg(groupName)
+ .toUtf8());
continue;
}
-
+
// Iterate through the list of instances in the group.
QJsonArray instancesArray = groupObj.value("instances").toArray();
-
- for (QJsonArray::iterator iter2 = instancesArray.begin();
- iter2 != instancesArray.end(); iter2++)
+
+ for (QJsonArray::iterator iter2 = instancesArray.begin(); iter2 != instancesArray.end();
+ iter2++)
{
groupMap[(*iter2).toString()] = groupName;
}
@@ -259,9 +264,9 @@ InstanceList::InstListError InstanceList::loadList()
// load the instance groups
QMap<QString, QString> groupMap;
loadGroupList(groupMap);
-
+
beginResetModel();
-
+
m_instances.clear();
QDir dir(m_instDir);
QDirIterator iter(dir);
@@ -270,53 +275,55 @@ InstanceList::InstListError InstanceList::loadList()
QString subDir = iter.next();
if (!QFileInfo(PathCombine(subDir, "instance.cfg")).exists())
continue;
-
+
BaseInstance *instPtr = NULL;
auto &loader = InstanceFactory::get();
auto error = loader.loadInstance(instPtr, subDir);
-
- switch(error)
+
+ switch (error)
{
- case InstanceFactory::NoLoadError:
- break;
- case InstanceFactory::NotAnInstance:
- break;
+ case InstanceFactory::NoLoadError:
+ break;
+ case InstanceFactory::NotAnInstance:
+ break;
}
-
- if (error != InstanceFactory::NoLoadError &&
- error != InstanceFactory::NotAnInstance)
+
+ if (error != InstanceFactory::NoLoadError && error != InstanceFactory::NotAnInstance)
{
- QString errorMsg = QString("Failed to load instance %1: ").
- arg(QFileInfo(subDir).baseName()).toUtf8();
-
+ QString errorMsg = QString("Failed to load instance %1: ")
+ .arg(QFileInfo(subDir).baseName())
+ .toUtf8();
+
switch (error)
{
default:
- errorMsg += QString("Unknown instance loader error %1").
- arg(error);
+ errorMsg += QString("Unknown instance loader error %1").arg(error);
break;
}
- qDebug(errorMsg.toUtf8());
+ QLOG_ERROR() << errorMsg.toUtf8();
}
else if (!instPtr)
{
- qDebug(QString("Error loading instance %1. Instance loader returned null.").
- arg(QFileInfo(subDir).baseName()).toUtf8());
+ QLOG_ERROR() << QString("Error loading instance %1. Instance loader returned null.")
+ .arg(QFileInfo(subDir).baseName())
+ .toUtf8();
}
else
{
- QSharedPointer<BaseInstance> inst(instPtr);
+ std::shared_ptr<BaseInstance> inst(instPtr);
auto iter = groupMap.find(inst->id());
- if(iter != groupMap.end())
+ if (iter != groupMap.end())
{
inst->setGroupInitial((*iter));
}
- qDebug(QString("Loaded instance %1").arg(inst->name()).toUtf8());
+ QLOG_INFO() << QString("Loaded instance %1").arg(inst->name()).toUtf8();
inst->setParent(this);
m_instances.append(inst);
- connect(instPtr, SIGNAL(propertiesChanged(BaseInstance*)),this, SLOT(propertiesChanged(BaseInstance*)));
- connect(instPtr, SIGNAL(groupChanged()),this, SLOT(groupChanged()));
- connect(instPtr, SIGNAL(nuked(BaseInstance*)), this, SLOT(instanceNuked(BaseInstance*)));
+ connect(instPtr, SIGNAL(propertiesChanged(BaseInstance *)), this,
+ SLOT(propertiesChanged(BaseInstance *)));
+ connect(instPtr, SIGNAL(groupChanged()), this, SLOT(groupChanged()));
+ connect(instPtr, SIGNAL(nuked(BaseInstance *)), this,
+ SLOT(instanceNuked(BaseInstance *)));
}
}
endResetModel();
@@ -332,7 +339,8 @@ void InstanceList::clear()
m_instances.clear();
endResetModel();
emit dataIsInvalid();
-};
+}
+;
/// Add an instance. Triggers notifications, returns the new index
int InstanceList::add(InstancePtr t)
@@ -340,9 +348,10 @@ int InstanceList::add(InstancePtr t)
beginInsertRows(QModelIndex(), m_instances.size(), m_instances.size());
m_instances.append(t);
t->setParent(this);
- connect(t.data(), SIGNAL(propertiesChanged(BaseInstance*)),this, SLOT(propertiesChanged(BaseInstance*)));
- connect(t.data(), SIGNAL(groupChanged()),this, SLOT(groupChanged()));
- connect(t.data(), SIGNAL(nuked(BaseInstance*)), this, SLOT(instanceNuked(BaseInstance*)));
+ connect(t.get(), SIGNAL(propertiesChanged(BaseInstance *)), this,
+ SLOT(propertiesChanged(BaseInstance *)));
+ connect(t.get(), SIGNAL(groupChanged()), this, SLOT(groupChanged()));
+ connect(t.get(), SIGNAL(nuked(BaseInstance *)), this, SLOT(instanceNuked(BaseInstance *)));
endInsertRows();
return count() - 1;
}
@@ -351,7 +360,7 @@ InstancePtr InstanceList::getInstanceById(QString instId)
{
QListIterator<InstancePtr> iter(m_instances);
InstancePtr inst;
- while(iter.hasNext())
+ while (iter.hasNext())
{
inst = iter.next();
if (inst->id() == instId)
@@ -363,11 +372,11 @@ InstancePtr InstanceList::getInstanceById(QString instId)
return iter.peekPrevious();
}
-int InstanceList::getInstIndex ( BaseInstance* inst )
+int InstanceList::getInstIndex(BaseInstance *inst)
{
- for(int i = 0; i < m_instances.count(); i++)
+ for (int i = 0; i < m_instances.count(); i++)
{
- if(inst == m_instances[i].data())
+ if (inst == m_instances[i].get())
{
return i;
}
@@ -375,40 +384,39 @@ int InstanceList::getInstIndex ( BaseInstance* inst )
return -1;
}
-
-void InstanceList::instanceNuked ( BaseInstance* inst )
+void InstanceList::instanceNuked(BaseInstance *inst)
{
int i = getInstIndex(inst);
- if(i != -1)
+ if (i != -1)
{
- beginRemoveRows(QModelIndex(),i,i);
+ beginRemoveRows(QModelIndex(), i, i);
m_instances.removeAt(i);
endRemoveRows();
}
}
-
-void InstanceList::propertiesChanged(BaseInstance * inst)
+void InstanceList::propertiesChanged(BaseInstance *inst)
{
int i = getInstIndex(inst);
- if(i != -1)
+ if (i != -1)
{
emit dataChanged(index(i), index(i));
}
}
-InstanceProxyModel::InstanceProxyModel ( QObject *parent )
- : KCategorizedSortFilterProxyModel ( parent )
+InstanceProxyModel::InstanceProxyModel(QObject *parent)
+ : KCategorizedSortFilterProxyModel(parent)
{
// disable since by default we are globally sorting by date:
setCategorizedModel(true);
}
-bool InstanceProxyModel::subSortLessThan (const QModelIndex& left, const QModelIndex& right ) const
+bool InstanceProxyModel::subSortLessThan(const QModelIndex &left,
+ const QModelIndex &right) const
{
- BaseInstance *pdataLeft = static_cast<BaseInstance*> ( left.internalPointer() );
- BaseInstance *pdataRight = static_cast<BaseInstance*> ( right.internalPointer() );
- //kDebug() << *pdataLeft << *pdataRight;
+ BaseInstance *pdataLeft = static_cast<BaseInstance *>(left.internalPointer());
+ BaseInstance *pdataRight = static_cast<BaseInstance *>(right.internalPointer());
+ // kDebug() << *pdataLeft << *pdataRight;
return QString::localeAwareCompare(pdataLeft->name(), pdataRight->name()) < 0;
- //return pdataLeft->name() < pdataRight->name();
+ // return pdataLeft->name() < pdataRight->name();
}
diff --git a/logic/lists/LwjglVersionList.cpp b/logic/lists/LwjglVersionList.cpp
index b3e2dab4..6bf401ec 100644
--- a/logic/lists/LwjglVersionList.cpp
+++ b/logic/lists/LwjglVersionList.cpp
@@ -3,7 +3,7 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@@ -17,15 +17,14 @@
#include "MultiMC.h"
#include <QtNetwork>
-
#include <QtXml>
-
#include <QRegExp>
+#include <logger/QsLog.h>
+
#define RSS_URL "http://sourceforge.net/api/file/index/project-id/58488/mtime/desc/rss"
-LWJGLVersionList::LWJGLVersionList(QObject *parent) :
- QAbstractListModel(parent)
+LWJGLVersionList::LWJGLVersionList(QObject *parent) : QAbstractListModel(parent)
{
setLoading(false);
}
@@ -34,20 +33,20 @@ QVariant LWJGLVersionList::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
-
+
if (index.row() > count())
return QVariant();
-
+
const PtrLWJGLVersion version = at(index.row());
-
+
switch (role)
{
case Qt::DisplayRole:
return version->name();
-
+
case Qt::ToolTipRole:
return version->url();
-
+
default:
return QVariant();
}
@@ -59,10 +58,10 @@ QVariant LWJGLVersionList::headerData(int section, Qt::Orientation orientation,
{
case Qt::DisplayRole:
return "Version";
-
+
case Qt::ToolTipRole:
return "LWJGL version name.";
-
+
default:
return QVariant();
}
@@ -81,7 +80,7 @@ bool LWJGLVersionList::isLoading() const
void LWJGLVersionList::loadList()
{
Q_ASSERT_X(!m_loading, "loadList", "list is already loading (m_loading is true)");
-
+
setLoading(true);
auto worker = MMC->qnam();
reply = worker->get(QNetworkRequest(QUrl(RSS_URL)));
@@ -102,68 +101,68 @@ void LWJGLVersionList::netRequestComplete()
if (reply->error() == QNetworkReply::NoError)
{
QRegExp lwjglRegex("lwjgl-(([0-9]\\.?)+)\\.zip");
- Q_ASSERT_X(lwjglRegex.isValid(), "load LWJGL list",
- "LWJGL regex is invalid");
-
+ Q_ASSERT_X(lwjglRegex.isValid(), "load LWJGL list", "LWJGL regex is invalid");
+
QDomDocument doc;
-
+
QString xmlErrorMsg;
int errorLine;
if (!doc.setContent(reply->readAll(), false, &xmlErrorMsg, &errorLine))
{
- failed("Failed to load LWJGL list. XML error: " + xmlErrorMsg + " at line " + QString::number(errorLine));
+ failed("Failed to load LWJGL list. XML error: " + xmlErrorMsg + " at line " +
+ QString::number(errorLine));
setLoading(false);
return;
}
-
+
QDomNodeList items = doc.elementsByTagName("item");
-
+
QList<PtrLWJGLVersion> tempList;
-
+
for (int i = 0; i < items.length(); i++)
{
Q_ASSERT_X(items.at(i).isElement(), "load LWJGL list",
"XML element isn't an element... wat?");
-
+
QDomElement linkElement = getDomElementByTagName(items.at(i).toElement(), "link");
if (linkElement.isNull())
{
qWarning() << "Link element" << i << "in RSS feed doesn't exist! Skipping.";
continue;
}
-
+
QString link = linkElement.text();
-
+
// Make sure it's a download link.
if (link.endsWith("/download") && link.contains(lwjglRegex))
{
QString name = link.mid(lwjglRegex.indexIn(link) + 6);
// Subtract 4 here to remove the .zip file extension.
name = name.left(lwjglRegex.matchedLength() - 10);
-
+
QUrl url(link);
if (!url.isValid())
{
qWarning() << "LWJGL version URL isn't valid:" << link << "Skipping.";
continue;
}
-
+
tempList.append(LWJGLVersion::Create(name, link));
}
}
-
+
beginResetModel();
m_vlist.swap(tempList);
endResetModel();
-
- qDebug("Loaded LWJGL list.");
+
+ QLOG_INFO() << "Loaded LWJGL list.";
finished();
}
else
{
failed("Failed to load LWJGL list. Network error: " + reply->errorString());
}
-
+
setLoading(false);
reply->deleteLater();
}
@@ -173,13 +172,12 @@ const PtrLWJGLVersion LWJGLVersionList::getVersion(const QString &versionName)
for (int i = 0; i < count(); i++)
{
QString name = at(i)->name();
- if ( name == versionName)
+ if (name == versionName)
return at(i);
}
return PtrLWJGLVersion();
}
-
void LWJGLVersionList::failed(QString msg)
{
qWarning() << msg;
diff --git a/logic/lists/LwjglVersionList.h b/logic/lists/LwjglVersionList.h
index 23e92a1a..99712292 100644
--- a/logic/lists/LwjglVersionList.h
+++ b/logic/lists/LwjglVersionList.h
@@ -17,13 +17,13 @@
#include <QObject>
#include <QAbstractListModel>
-#include <QSharedPointer>
#include <QUrl>
-
#include <QNetworkReply>
+#include <memory>
+
class LWJGLVersion;
-typedef QSharedPointer<LWJGLVersion> PtrLWJGLVersion;
+typedef std::shared_ptr<LWJGLVersion> PtrLWJGLVersion;
class LWJGLVersion : public QObject
{
diff --git a/logic/lists/MinecraftVersionList.cpp b/logic/lists/MinecraftVersionList.cpp
index 35f7251e..36611165 100644
--- a/logic/lists/MinecraftVersionList.cpp
+++ b/logic/lists/MinecraftVersionList.cpp
@@ -16,8 +16,6 @@
#include "MinecraftVersionList.h"
#include <MultiMC.h>
-#include <QDebug>
-
#include <QtXml>
#include <QJsonDocument>
@@ -62,8 +60,8 @@ int MinecraftVersionList::count() const
bool cmpVersions(BaseVersionPtr first, BaseVersionPtr second)
{
- auto left = first.dynamicCast<MinecraftVersion>();
- auto right = second.dynamicCast<MinecraftVersion>();
+ auto left = std::dynamic_pointer_cast<MinecraftVersion>(first);
+ auto right = std::dynamic_pointer_cast<MinecraftVersion>(second);
return left->timestamp > right->timestamp;
}
@@ -78,7 +76,7 @@ BaseVersionPtr MinecraftVersionList::getLatestStable() const
{
for (int i = 0; i < m_vlist.length(); i++)
{
- auto ver = m_vlist.at(i).dynamicCast<MinecraftVersion>();
+ auto ver =std::dynamic_pointer_cast<MinecraftVersion>(m_vlist.at(i));
if (ver->is_latest && !ver->is_snapshot)
{
return m_vlist.at(i);
@@ -272,7 +270,7 @@ void MCVListLoadTask::list_downloaded()
QString dlUrl = QString(MCVLIST_URLBASE) + versionID + "/";
// Now, we construct the version object and add it to the list.
- QSharedPointer<MinecraftVersion> mcVersion(new MinecraftVersion());
+ std::shared_ptr<MinecraftVersion> mcVersion(new MinecraftVersion());
mcVersion->m_name = mcVersion->m_descriptor = versionID;
mcVersion->timestamp = versionTime.toMSecsSinceEpoch();
mcVersion->download_url = dlUrl;
diff --git a/logic/net/ByteArrayDownload.cpp b/logic/net/ByteArrayDownload.cpp
index b7a68c60..ba771eef 100644
--- a/logic/net/ByteArrayDownload.cpp
+++ b/logic/net/ByteArrayDownload.cpp
@@ -1,6 +1,6 @@
#include "ByteArrayDownload.h"
#include "MultiMC.h"
-#include <QDebug>
+#include <logger/QsLog.h>
ByteArrayDownload::ByteArrayDownload(QUrl url) : Download()
{
@@ -10,13 +10,13 @@ ByteArrayDownload::ByteArrayDownload(QUrl url) : Download()
void ByteArrayDownload::start()
{
- qDebug() << "Downloading " << m_url.toString();
+ QLOG_INFO() << "Downloading " << m_url.toString();
QNetworkRequest request(m_url);
request.setHeader(QNetworkRequest::UserAgentHeader, "MultiMC/5.0 (Uncached)");
auto worker = MMC->qnam();
QNetworkReply *rep = worker->get(request);
- m_reply = QSharedPointer<QNetworkReply>(rep, &QObject::deleteLater);
+ m_reply = std::shared_ptr<QNetworkReply>(rep);
connect(rep, SIGNAL(downloadProgress(qint64, qint64)),
SLOT(downloadProgress(qint64, qint64)));
connect(rep, SIGNAL(finished()), SLOT(downloadFinished()));
@@ -33,7 +33,8 @@ void ByteArrayDownload::downloadProgress(qint64 bytesReceived, qint64 bytesTotal
void ByteArrayDownload::downloadError(QNetworkReply::NetworkError error)
{
// error happened during download.
- qDebug() << "URL:" << m_url.toString().toLocal8Bit() << "Network error: " << error;
+ QLOG_ERROR() << "Error getting URL:" << m_url.toString().toLocal8Bit()
+ << "Network error: " << error;
m_status = Job_Failed;
}
@@ -45,14 +46,14 @@ void ByteArrayDownload::downloadFinished()
// nothing went wrong...
m_status = Job_Finished;
m_data = m_reply->readAll();
- m_reply.clear();
+ m_reply.reset();
emit succeeded(index_within_job);
return;
}
// else the download failed
else
{
- m_reply.clear();
+ m_reply.reset();
emit failed(index_within_job);
return;
}
diff --git a/logic/net/ByteArrayDownload.h b/logic/net/ByteArrayDownload.h
index 428b21db..cfc6a8d0 100644
--- a/logic/net/ByteArrayDownload.h
+++ b/logic/net/ByteArrayDownload.h
@@ -21,4 +21,4 @@ protected slots:
void downloadReadyRead();
};
-typedef QSharedPointer<ByteArrayDownload> ByteArrayDownloadPtr;
+typedef std::shared_ptr<ByteArrayDownload> ByteArrayDownloadPtr;
diff --git a/logic/net/CacheDownload.cpp b/logic/net/CacheDownload.cpp
index 9fc1f127..0e653e05 100644
--- a/logic/net/CacheDownload.cpp
+++ b/logic/net/CacheDownload.cpp
@@ -5,7 +5,7 @@
#include <QCryptographicHash>
#include <QFileInfo>
#include <QDateTime>
-#include <QDebug>
+#include <logger/QsLog.h>
CacheDownload::CacheDownload(QUrl url, MetaEntryPtr entry)
: Download(), md5sum(QCryptographicHash::Md5)
@@ -31,7 +31,7 @@ void CacheDownload::start()
emit failed(index_within_job);
return;
}
- qDebug() << "Downloading " << m_url.toString();
+ QLOG_INFO() << "Downloading " << m_url.toString();
QNetworkRequest request(m_url);
request.setRawHeader(QString("If-None-Match").toLatin1(), m_entry->etag.toLatin1());
request.setHeader(QNetworkRequest::UserAgentHeader,"MultiMC/5.0 (Cached)");
@@ -39,7 +39,7 @@ void CacheDownload::start()
auto worker = MMC->qnam();
QNetworkReply *rep = worker->get(request);
- m_reply = QSharedPointer<QNetworkReply>(rep, &QObject::deleteLater);
+ m_reply = std::shared_ptr<QNetworkReply>(rep);
connect(rep, SIGNAL(downloadProgress(qint64, qint64)),
SLOT(downloadProgress(qint64, qint64)));
connect(rep, SIGNAL(finished()), SLOT(downloadFinished()));
@@ -92,7 +92,7 @@ void CacheDownload::downloadFinished()
m_entry->stale = false;
MMC->metacache()->updateEntry(m_entry);
- m_reply.clear();
+ m_reply.reset();
emit succeeded(index_within_job);
return;
}
@@ -101,7 +101,7 @@ void CacheDownload::downloadFinished()
{
m_output_file.close();
m_output_file.remove();
- m_reply.clear();
+ m_reply.reset();
emit failed(index_within_job);
return;
}
diff --git a/logic/net/CacheDownload.h b/logic/net/CacheDownload.h
index f95dabd5..295391b1 100644
--- a/logic/net/CacheDownload.h
+++ b/logic/net/CacheDownload.h
@@ -31,4 +31,4 @@ public slots:
virtual void start();
};
-typedef QSharedPointer<CacheDownload> CacheDownloadPtr;
+typedef std::shared_ptr<CacheDownload> CacheDownloadPtr;
diff --git a/logic/net/Download.h b/logic/net/Download.h
index 91f09dec..ca4bee9f 100644
--- a/logic/net/Download.h
+++ b/logic/net/Download.h
@@ -2,10 +2,9 @@
#include <QObject>
#include <QUrl>
-#include <QSharedPointer>
+#include <memory>
#include <QNetworkReply>
-
enum JobStatus
{
Job_NotStarted,
@@ -18,20 +17,21 @@ class Download : public QObject
{
Q_OBJECT
protected:
- explicit Download(): QObject(0){};
+ explicit Download() : QObject(0) {};
+
public:
virtual ~Download() {};
public:
/// the network reply
- QSharedPointer<QNetworkReply> m_reply;
-
+ std::shared_ptr<QNetworkReply> m_reply;
+
/// source URL
QUrl m_url;
-
+
/// The file's status
JobStatus m_status;
-
+
/// index within the parent job
int index_within_job = 0;
@@ -46,9 +46,9 @@ protected slots:
virtual void downloadError(QNetworkReply::NetworkError error) = 0;
virtual void downloadFinished() = 0;
virtual void downloadReadyRead() = 0;
-
+
public slots:
virtual void start() = 0;
};
-typedef QSharedPointer<Download> DownloadPtr;
+typedef std::shared_ptr<Download> DownloadPtr;
diff --git a/logic/net/DownloadJob.cpp b/logic/net/DownloadJob.cpp
index 03a69555..f6275b7a 100644
--- a/logic/net/DownloadJob.cpp
+++ b/logic/net/DownloadJob.cpp
@@ -5,7 +5,7 @@
#include "ByteArrayDownload.h"
#include "CacheDownload.h"
-#include <QDebug>
+#include <logger/QsLog.h>
ByteArrayDownloadPtr DownloadJob::addByteArrayDownload(QUrl url)
{
@@ -54,18 +54,18 @@ void DownloadJob::partSucceeded(int index)
partProgress(index, slot.total_progress, slot.total_progress);
num_succeeded++;
- qDebug() << m_job_name.toLocal8Bit() << " progress: " << num_succeeded << "/"
+ QLOG_INFO() << m_job_name.toLocal8Bit() << " progress: " << num_succeeded << "/"
<< downloads.size();
if (num_failed + num_succeeded == downloads.size())
{
if (num_failed)
{
- qDebug() << m_job_name.toLocal8Bit() << " failed.";
+ QLOG_ERROR() << m_job_name.toLocal8Bit() << " failed.";
emit failed();
}
else
{
- qDebug() << m_job_name.toLocal8Bit() << " succeeded.";
+ QLOG_INFO() << m_job_name.toLocal8Bit() << " succeeded.";
emit succeeded();
}
}
@@ -76,17 +76,17 @@ void DownloadJob::partFailed(int index)
auto &slot = parts_progress[index];
if (slot.failures == 3)
{
- qDebug() << "Part " << index << " failed 3 times (" << downloads[index]->m_url << ")";
+ QLOG_ERROR() << "Part " << index << " failed 3 times (" << downloads[index]->m_url << ")";
num_failed++;
if (num_failed + num_succeeded == downloads.size())
{
- qDebug() << m_job_name.toLocal8Bit() << " failed.";
+ QLOG_ERROR() << m_job_name.toLocal8Bit() << " failed.";
emit failed();
}
}
else
{
- qDebug() << "Part " << index << " failed, restarting (" << downloads[index]->m_url
+ QLOG_ERROR() << "Part " << index << " failed, restarting (" << downloads[index]->m_url
<< ")";
// restart the job
slot.failures++;
@@ -110,12 +110,12 @@ void DownloadJob::partProgress(int index, qint64 bytesReceived, qint64 bytesTota
void DownloadJob::start()
{
- qDebug() << m_job_name.toLocal8Bit() << " started.";
+ QLOG_INFO() << m_job_name.toLocal8Bit() << " started.";
for (auto iter : downloads)
{
- connect(iter.data(), SIGNAL(succeeded(int)), SLOT(partSucceeded(int)));
- connect(iter.data(), SIGNAL(failed(int)), SLOT(partFailed(int)));
- connect(iter.data(), SIGNAL(progress(int, qint64, qint64)),
+ connect(iter.get(), SIGNAL(succeeded(int)), SLOT(partSucceeded(int)));
+ connect(iter.get(), SIGNAL(failed(int)), SLOT(partFailed(int)));
+ connect(iter.get(), SIGNAL(progress(int, qint64, qint64)),
SLOT(partProgress(int, qint64, qint64)));
iter->start();
}
diff --git a/logic/net/DownloadJob.h b/logic/net/DownloadJob.h
index 8c32950a..91b014ad 100644
--- a/logic/net/DownloadJob.h
+++ b/logic/net/DownloadJob.h
@@ -9,7 +9,7 @@
#include "logic/tasks/ProgressProvider.h"
class DownloadJob;
-typedef QSharedPointer<DownloadJob> DownloadJobPtr;
+typedef std::shared_ptr<DownloadJob> DownloadJobPtr;
/**
* A single file for the downloader/cache to process.
diff --git a/logic/net/FileDownload.cpp b/logic/net/FileDownload.cpp
index 353fd58b..3f38b0fa 100644
--- a/logic/net/FileDownload.cpp
+++ b/logic/net/FileDownload.cpp
@@ -2,7 +2,7 @@
#include "FileDownload.h"
#include <pathutils.h>
#include <QCryptographicHash>
-#include <QDebug>
+#include <logger/QsLog.h>
FileDownload::FileDownload ( QUrl url, QString target_path )
@@ -28,7 +28,7 @@ void FileDownload::start()
// skip this file if they match
if ( m_check_md5 && hash == m_expected_md5 )
{
- qDebug() << "Skipping " << m_url.toString() << ": md5 match.";
+ QLOG_INFO() << "Skipping " << m_url.toString() << ": md5 match.";
emit succeeded(index_within_job);
return;
}
@@ -43,7 +43,7 @@ void FileDownload::start()
return;
}
- qDebug() << "Downloading " << m_url.toString();
+ QLOG_INFO() << "Downloading " << m_url.toString();
QNetworkRequest request ( m_url );
request.setRawHeader(QString("If-None-Match").toLatin1(), m_expected_md5.toLatin1());
request.setHeader(QNetworkRequest::UserAgentHeader,"MultiMC/5.0 (Uncached)");
@@ -51,7 +51,7 @@ void FileDownload::start()
auto worker = MMC->qnam();
QNetworkReply * rep = worker->get ( request );
- m_reply = QSharedPointer<QNetworkReply> ( rep, &QObject::deleteLater );
+ m_reply = std::shared_ptr<QNetworkReply> ( rep );
connect ( rep, SIGNAL ( downloadProgress ( qint64,qint64 ) ), SLOT ( downloadProgress ( qint64,qint64 ) ) );
connect ( rep, SIGNAL ( finished() ), SLOT ( downloadFinished() ) );
connect ( rep, SIGNAL ( error ( QNetworkReply::NetworkError ) ), SLOT ( downloadError ( QNetworkReply::NetworkError ) ) );
@@ -79,7 +79,7 @@ void FileDownload::downloadFinished()
m_status = Job_Finished;
m_output_file.close();
- m_reply.clear();
+ m_reply.reset();
emit succeeded(index_within_job);
return;
}
@@ -87,7 +87,7 @@ void FileDownload::downloadFinished()
else
{
m_output_file.close();
- m_reply.clear();
+ m_reply.reset();
emit failed(index_within_job);
return;
}
diff --git a/logic/net/FileDownload.h b/logic/net/FileDownload.h
index 190bee58..9abb590d 100644
--- a/logic/net/FileDownload.h
+++ b/logic/net/FileDownload.h
@@ -32,4 +32,4 @@ public slots:
virtual void start();
};
-typedef QSharedPointer<FileDownload> FileDownloadPtr;
+typedef std::shared_ptr<FileDownload> FileDownloadPtr;
diff --git a/logic/net/ForgeXzDownload.cpp b/logic/net/ForgeXzDownload.cpp
index 6d66abce..3ec2155b 100644
--- a/logic/net/ForgeXzDownload.cpp
+++ b/logic/net/ForgeXzDownload.cpp
@@ -5,7 +5,7 @@
#include <QCryptographicHash>
#include <QFileInfo>
#include <QDateTime>
-#include <QDebug>
+#include <logger/QsLog.h>
ForgeXzDownload::ForgeXzDownload(QUrl url, MetaEntryPtr entry)
: Download()
@@ -32,7 +32,7 @@ void ForgeXzDownload::start()
emit failed(index_within_job);
return;
}
- qDebug() << "Downloading " << m_url.toString();
+ QLOG_INFO() << "Downloading " << m_url.toString();
QNetworkRequest request(m_url);
request.setRawHeader(QString("If-None-Match").toLatin1(), m_entry->etag.toLatin1());
request.setHeader(QNetworkRequest::UserAgentHeader,"MultiMC/5.0 (Cached)");
@@ -40,7 +40,7 @@ void ForgeXzDownload::start()
auto worker = MMC->qnam();
QNetworkReply *rep = worker->get(request);
- m_reply = QSharedPointer<QNetworkReply>(rep, &QObject::deleteLater);
+ m_reply = std::shared_ptr<QNetworkReply>(rep);
connect(rep, SIGNAL(downloadProgress(qint64, qint64)),
SLOT(downloadProgress(qint64, qint64)));
connect(rep, SIGNAL(finished()), SLOT(downloadFinished()));
@@ -78,7 +78,7 @@ void ForgeXzDownload::downloadFinished()
{
// something bad happened
m_pack200_xz_file.remove();
- m_reply.clear();
+ m_reply.reset();
emit failed(index_within_job);
return;
}
@@ -88,7 +88,7 @@ void ForgeXzDownload::downloadFinished()
{
m_pack200_xz_file.close();
m_pack200_xz_file.remove();
- m_reply.clear();
+ m_reply.reset();
emit failed(index_within_job);
return;
}
@@ -198,38 +198,38 @@ void ForgeXzDownload::decompressAndInstall()
break;
case XZ_MEM_ERROR:
- qDebug() << "Memory allocation failed\n";
+ QLOG_ERROR() << "Memory allocation failed\n";
xz_dec_end(s);
emit failed(index_within_job);
return;
case XZ_MEMLIMIT_ERROR:
- qDebug() << "Memory usage limit reached\n";
+ QLOG_ERROR() << "Memory usage limit reached\n";
xz_dec_end(s);
emit failed(index_within_job);
return;
case XZ_FORMAT_ERROR:
- qDebug() << "Not a .xz file\n";
+ QLOG_ERROR() << "Not a .xz file\n";
xz_dec_end(s);
emit failed(index_within_job);
return;
case XZ_OPTIONS_ERROR:
- qDebug() << "Unsupported options in the .xz headers\n";
+ QLOG_ERROR() << "Unsupported options in the .xz headers\n";
xz_dec_end(s);
emit failed(index_within_job);
return;
case XZ_DATA_ERROR:
case XZ_BUF_ERROR:
- qDebug() << "File is corrupt\n";
+ QLOG_ERROR() << "File is corrupt\n";
xz_dec_end(s);
emit failed(index_within_job);
return;
default:
- qDebug() << "Bug!\n";
+ QLOG_ERROR() << "Bug!\n";
xz_dec_end(s);
emit failed(index_within_job);
return;
@@ -246,7 +246,7 @@ void ForgeXzDownload::decompressAndInstall()
}
catch(std::runtime_error & err)
{
- qDebug() << "Error unpacking " << pack_name.toUtf8() << " : " << err.what();
+ QLOG_ERROR() << "Error unpacking " << pack_name.toUtf8() << " : " << err.what();
QFile f(m_target_path);
if(f.exists())
f.remove();
@@ -274,6 +274,6 @@ void ForgeXzDownload::decompressAndInstall()
m_entry->stale = false;
MMC->metacache()->updateEntry(m_entry);
- m_reply.clear();
+ m_reply.reset();
emit succeeded(index_within_job);
}
diff --git a/logic/net/ForgeXzDownload.h b/logic/net/ForgeXzDownload.h
index 8cb47783..5d677947 100644
--- a/logic/net/ForgeXzDownload.h
+++ b/logic/net/ForgeXzDownload.h
@@ -32,4 +32,4 @@ private:
void decompressAndInstall();
};
-typedef QSharedPointer<ForgeXzDownload> ForgeXzDownloadPtr;
+typedef std::shared_ptr<ForgeXzDownload> ForgeXzDownloadPtr;
diff --git a/logic/net/HttpMetaCache.cpp b/logic/net/HttpMetaCache.cpp
index 46801ab3..9c642a0f 100644
--- a/logic/net/HttpMetaCache.cpp
+++ b/logic/net/HttpMetaCache.cpp
@@ -9,7 +9,7 @@
#include <QDateTime>
#include <QCryptographicHash>
-#include <QDebug>
+#include <logger/QsLog.h>
#include <QJsonDocument>
#include <QJsonArray>
@@ -105,12 +105,12 @@ bool HttpMetaCache::updateEntry ( MetaEntryPtr stale_entry )
{
if(!m_entries.contains(stale_entry->base))
{
- qDebug() << "Cannot add entry with unknown base: " << stale_entry->base.toLocal8Bit();
+ QLOG_ERROR() << "Cannot add entry with unknown base: " << stale_entry->base.toLocal8Bit();
return false;
}
if(stale_entry->stale)
{
- qDebug() << "Cannot add stale entry: " << stale_entry->getFullPath().toLocal8Bit();
+ QLOG_ERROR() << "Cannot add stale entry: " << stale_entry->getFullPath().toLocal8Bit();
return false;
}
m_entries[stale_entry->base].entry_list[stale_entry->path] = stale_entry;
diff --git a/logic/net/HttpMetaCache.h b/logic/net/HttpMetaCache.h
index daf6c43f..8107839e 100644
--- a/logic/net/HttpMetaCache.h
+++ b/logic/net/HttpMetaCache.h
@@ -15,7 +15,7 @@ struct MetaEntry
QString getFullPath();
};
-typedef QSharedPointer<MetaEntry> MetaEntryPtr;
+typedef std::shared_ptr<MetaEntry> MetaEntryPtr;
class HttpMetaCache : public QObject
{
diff --git a/logic/net/LoginTask.cpp b/logic/net/LoginTask.cpp
index 2a45400e..5de8efa9 100644
--- a/logic/net/LoginTask.cpp
+++ b/logic/net/LoginTask.cpp
@@ -40,7 +40,7 @@ void LoginTask::legacyLogin()
{
setStatus(tr("Logging in..."));
auto worker = MMC->qnam();
- connect(worker.data(), SIGNAL(finished(QNetworkReply *)), this,
+ connect(worker.get(), SIGNAL(finished(QNetworkReply *)), this,
SLOT(processLegacyReply(QNetworkReply *)));
QUrl loginURL("https://login.minecraft.net/");
@@ -134,7 +134,7 @@ void LoginTask::yggdrasilLogin()
{
setStatus(tr("Logging in..."));
auto worker = MMC->qnam();
- connect(worker.data(), SIGNAL(finished(QNetworkReply *)), this,
+ connect(worker.get(), SIGNAL(finished(QNetworkReply *)), this,
SLOT(processYggdrasilReply(QNetworkReply *)));
/*
diff --git a/logic/tasks/Task.cpp b/logic/tasks/Task.cpp
index c75bcb8f..2f137c55 100644
--- a/logic/tasks/Task.cpp
+++ b/logic/tasks/Task.cpp
@@ -14,6 +14,7 @@
*/
#include "Task.h"
+#include <logger/QsLog.h>
Task::Task(QObject *parent) :
ProgressProvider(parent)
@@ -55,6 +56,7 @@ void Task::start()
void Task::emitFailed(QString reason)
{
m_running = false;
+ QLOG_ERROR() << "Task failed: " << reason;
emit failed(reason);
}