summaryrefslogtreecommitdiffstats
path: root/logic
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-11-04 02:53:05 +0100
committerPetr Mrázek <peterix@gmail.com>2013-11-04 02:53:05 +0100
commitbb7e8985f6d189de0acac6a1c3033cb16378c1fb (patch)
tree7c2e88c7184a7f5acf5e7a03be5c5f0bf6904113 /logic
parentd6e4fb29713d6ce55b092c0e22412f6121e7f516 (diff)
downloadMultiMC-bb7e8985f6d189de0acac6a1c3033cb16378c1fb.tar
MultiMC-bb7e8985f6d189de0acac6a1c3033cb16378c1fb.tar.gz
MultiMC-bb7e8985f6d189de0acac6a1c3033cb16378c1fb.tar.lz
MultiMC-bb7e8985f6d189de0acac6a1c3033cb16378c1fb.tar.xz
MultiMC-bb7e8985f6d189de0acac6a1c3033cb16378c1fb.zip
Reformat and (slightly) decruft all the things.
Diffstat (limited to 'logic')
-rw-r--r--logic/BaseInstance.cpp140
-rw-r--r--logic/BaseInstance_p.h17
-rw-r--r--logic/BaseUpdate.cpp17
-rw-r--r--logic/BaseUpdate.h13
-rw-r--r--logic/BaseVersion.h9
-rw-r--r--logic/CMakeLists.txt24
-rw-r--r--logic/EnabledItemFilter.cpp27
-rw-r--r--logic/EnabledItemFilter.h18
-rw-r--r--logic/ForgeInstaller.cpp15
-rw-r--r--logic/ForgeInstaller.h19
-rw-r--r--logic/InstanceFactory.cpp31
-rw-r--r--logic/InstanceLauncher.cpp77
-rw-r--r--logic/InstanceLauncher.h26
-rw-r--r--logic/JavaUtils.cpp72
-rw-r--r--logic/JavaUtils.h8
-rw-r--r--logic/LegacyForge.cpp37
-rw-r--r--logic/LegacyForge.h32
-rw-r--r--logic/LegacyInstance.cpp39
-rw-r--r--logic/LegacyInstance.h18
-rw-r--r--logic/LegacyInstance_p.h24
-rw-r--r--logic/LegacyUpdate.cpp17
-rw-r--r--logic/LegacyUpdate.h37
-rw-r--r--logic/MinecraftProcess.h43
-rw-r--r--logic/MinecraftVersion.h30
-rw-r--r--logic/Mod.cpp38
-rw-r--r--logic/Mod.h29
-rw-r--r--logic/ModList.cpp31
-rw-r--r--logic/ModList.h111
-rw-r--r--logic/NagUtils.cpp27
-rw-r--r--logic/NostalgiaInstance.cpp26
-rw-r--r--logic/NostalgiaInstance.h19
-rw-r--r--logic/OneSixAssets.cpp22
-rw-r--r--logic/OneSixAssets.h22
-rw-r--r--logic/OneSixInstance.cpp19
-rw-r--r--logic/OneSixInstance.h19
-rw-r--r--logic/OneSixInstance_p.h27
-rw-r--r--logic/OneSixLibrary.cpp19
-rw-r--r--logic/OneSixLibrary.h36
-rw-r--r--logic/OneSixRule.cpp18
-rw-r--r--logic/OneSixRule.h59
-rw-r--r--logic/OneSixUpdate.cpp1
-rw-r--r--logic/OneSixUpdate.h21
-rw-r--r--logic/OneSixVersion.cpp31
-rw-r--r--logic/OneSixVersion.h17
-rw-r--r--logic/OpSys.cpp35
-rw-r--r--logic/OpSys.h27
-rw-r--r--logic/lists/BaseVersionList.cpp36
-rw-r--r--logic/lists/BaseVersionList.h46
-rw-r--r--logic/lists/ForgeVersionList.cpp2
-rw-r--r--logic/lists/ForgeVersionList.h3
-rw-r--r--logic/lists/IconList.cpp146
-rw-r--r--logic/lists/IconList.h48
-rw-r--r--logic/lists/InstanceList.cpp4
-rw-r--r--logic/lists/InstanceList.h2
-rw-r--r--logic/lists/JavaVersionList.cpp7
-rw-r--r--logic/lists/JavaVersionList.h6
-rw-r--r--logic/lists/LwjglVersionList.cpp2
-rw-r--r--logic/lists/LwjglVersionList.h113
-rw-r--r--logic/lists/MinecraftVersionList.cpp4
-rw-r--r--logic/lists/MinecraftVersionList.h31
-rw-r--r--logic/net/ByteArrayDownload.cpp17
-rw-r--r--logic/net/ByteArrayDownload.h15
-rw-r--r--logic/net/CacheDownload.cpp28
-rw-r--r--logic/net/CacheDownload.h15
-rw-r--r--logic/net/FileDownload.cpp74
-rw-r--r--logic/net/FileDownload.h15
-rw-r--r--logic/net/ForgeXzDownload.cpp44
-rw-r--r--logic/net/ForgeXzDownload.h15
-rw-r--r--logic/net/HttpMetaCache.cpp129
-rw-r--r--logic/net/HttpMetaCache.h15
-rw-r--r--logic/net/LoginTask.cpp29
-rw-r--r--logic/net/LoginTask.h6
-rw-r--r--logic/net/NetAction.h21
-rw-r--r--logic/net/NetJob.cpp21
-rw-r--r--logic/net/NetJob.h20
-rw-r--r--logic/net/S3ListBucket.cpp19
-rw-r--r--logic/net/S3ListBucket.h15
-rw-r--r--logic/tasks/ProgressProvider.h25
-rw-r--r--logic/tasks/Task.cpp12
-rw-r--r--logic/tasks/Task.h22
80 files changed, 1615 insertions, 836 deletions
diff --git a/logic/BaseInstance.cpp b/logic/BaseInstance.cpp
index 6a6b195b..c38f75ef 100644
--- a/logic/BaseInstance.cpp
+++ b/logic/BaseInstance.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
@@ -19,7 +19,7 @@
#include <QFileInfo>
#include <QDir>
-#include <MultiMC.h>
+#include "MultiMC.h"
#include "inisettingsobject.h"
#include "setting.h"
@@ -28,64 +28,74 @@
#include "pathutils.h"
#include "lists/MinecraftVersionList.h"
-
-BaseInstance::BaseInstance( BaseInstancePrivate* d_in,
- const QString& rootDir,
- SettingsObject* settings_obj,
- QObject* parent
- )
-:inst_d(d_in), QObject(parent)
+BaseInstance::BaseInstance(BaseInstancePrivate *d_in, const QString &rootDir,
+ SettingsObject *settings_obj, QObject *parent)
+ : inst_d(d_in), QObject(parent)
{
I_D(BaseInstance);
d->m_settings = settings_obj;
d->m_rootDir = rootDir;
-
+
settings().registerSetting(new Setting("name", "Unnamed Instance"));
settings().registerSetting(new Setting("iconKey", "default"));
settings().registerSetting(new Setting("notes", ""));
settings().registerSetting(new Setting("lastLaunchTime", 0));
-
+
/*
- * custom base jar has no default. it is determined in code... see the accessor methods for it
- *
+ * custom base jar has no default. it is determined in code... see the accessor methods for
+ *it
+ *
* for instances that DO NOT have the CustomBaseJar setting (legacy instances),
* [.]minecraft/bin/mcbackup.jar is the default base jar
*/
settings().registerSetting(new Setting("UseCustomBaseJar", true));
settings().registerSetting(new Setting("CustomBaseJar", ""));
-
+
auto globalSettings = MMC->settings();
-
+
// Java Settings
settings().registerSetting(new Setting("OverrideJava", false));
- settings().registerSetting(new OverrideSetting("JavaPath", globalSettings->getSetting("JavaPath")));
- settings().registerSetting(new OverrideSetting("JvmArgs", globalSettings->getSetting("JvmArgs")));
-
+ settings().registerSetting(
+ new OverrideSetting("JavaPath", globalSettings->getSetting("JavaPath")));
+ settings().registerSetting(
+ new OverrideSetting("JvmArgs", globalSettings->getSetting("JvmArgs")));
+
// Custom Commands
settings().registerSetting(new Setting("OverrideCommands", false));
- settings().registerSetting(new OverrideSetting("PreLaunchCommand", globalSettings->getSetting("PreLaunchCommand")));
- settings().registerSetting(new OverrideSetting("PostExitCommand", globalSettings->getSetting("PostExitCommand")));
-
+ settings().registerSetting(new OverrideSetting(
+ "PreLaunchCommand", globalSettings->getSetting("PreLaunchCommand")));
+ settings().registerSetting(
+ new OverrideSetting("PostExitCommand", globalSettings->getSetting("PostExitCommand")));
+
// Window Size
settings().registerSetting(new Setting("OverrideWindow", false));
- settings().registerSetting(new OverrideSetting("LaunchMaximized", globalSettings->getSetting("LaunchMaximized")));
- settings().registerSetting(new OverrideSetting("MinecraftWinWidth", globalSettings->getSetting("MinecraftWinWidth")));
- settings().registerSetting(new OverrideSetting("MinecraftWinHeight", globalSettings->getSetting("MinecraftWinHeight")));
-
+ settings().registerSetting(
+ new OverrideSetting("LaunchMaximized", globalSettings->getSetting("LaunchMaximized")));
+ settings().registerSetting(new OverrideSetting(
+ "MinecraftWinWidth", globalSettings->getSetting("MinecraftWinWidth")));
+ settings().registerSetting(new OverrideSetting(
+ "MinecraftWinHeight", globalSettings->getSetting("MinecraftWinHeight")));
+
// Memory
settings().registerSetting(new Setting("OverrideMemory", false));
- settings().registerSetting(new OverrideSetting("MinMemAlloc", globalSettings->getSetting("MinMemAlloc")));
- settings().registerSetting(new OverrideSetting("MaxMemAlloc", globalSettings->getSetting("MaxMemAlloc")));
- settings().registerSetting(new OverrideSetting("PermGen", globalSettings->getSetting("PermGen")));
-
+ settings().registerSetting(
+ new OverrideSetting("MinMemAlloc", globalSettings->getSetting("MinMemAlloc")));
+ settings().registerSetting(
+ new OverrideSetting("MaxMemAlloc", globalSettings->getSetting("MaxMemAlloc")));
+ settings().registerSetting(
+ new OverrideSetting("PermGen", globalSettings->getSetting("PermGen")));
+
// Auto login
settings().registerSetting(new Setting("OverrideLogin", false));
- settings().registerSetting(new OverrideSetting("AutoLogin", globalSettings->getSetting("AutoLogin")));
-
+ settings().registerSetting(
+ new OverrideSetting("AutoLogin", globalSettings->getSetting("AutoLogin")));
+
// Console
settings().registerSetting(new Setting("OverrideConsole", false));
- settings().registerSetting(new OverrideSetting("ShowConsole", globalSettings->getSetting("ShowConsole")));
- settings().registerSetting(new OverrideSetting("AutoCloseConsole", globalSettings->getSetting("AutoCloseConsole")));
+ settings().registerSetting(
+ new OverrideSetting("ShowConsole", globalSettings->getSetting("ShowConsole")));
+ settings().registerSetting(new OverrideSetting(
+ "AutoCloseConsole", globalSettings->getSetting("AutoCloseConsole")));
}
void BaseInstance::nuke()
@@ -94,7 +104,6 @@ void BaseInstance::nuke()
emit nuked(this);
}
-
QString BaseInstance::id() const
{
return QFileInfo(instanceRoot()).fileName();
@@ -106,7 +115,6 @@ QString BaseInstance::instanceType() const
return d->m_settings->get("InstanceType").toString();
}
-
QString BaseInstance::instanceRoot() const
{
I_D(BaseInstance);
@@ -117,9 +125,9 @@ QString BaseInstance::minecraftRoot() const
{
QFileInfo mcDir(PathCombine(instanceRoot(), "minecraft"));
QFileInfo dotMCDir(PathCombine(instanceRoot(), ".minecraft"));
-
+
if (dotMCDir.exists() && !mcDir.exists())
- return dotMCDir.filePath();
+ return dotMCDir.filePath();
else
return mcDir.filePath();
}
@@ -147,7 +155,7 @@ QString BaseInstance::baseJar() const
{
I_D(BaseInstance);
bool customJar = d->m_settings->get("UseCustomBaseJar").toBool();
- if(customJar)
+ if (customJar)
{
return customBaseJar();
}
@@ -158,99 +166,97 @@ QString BaseInstance::baseJar() const
QString BaseInstance::customBaseJar() const
{
I_D(BaseInstance);
- QString value = d->m_settings->get ( "CustomBaseJar" ).toString();
- if(value.isNull() || value.isEmpty())
+ QString value = d->m_settings->get("CustomBaseJar").toString();
+ if (value.isNull() || value.isEmpty())
{
return defaultCustomBaseJar();
}
return value;
}
-void BaseInstance::setCustomBaseJar ( QString val )
+void BaseInstance::setCustomBaseJar(QString val)
{
I_D(BaseInstance);
- if(val.isNull() || val.isEmpty() || val == defaultCustomBaseJar())
- d->m_settings->reset ( "CustomBaseJar" );
+ if (val.isNull() || val.isEmpty() || val == defaultCustomBaseJar())
+ d->m_settings->reset("CustomBaseJar");
else
- d->m_settings->set ( "CustomBaseJar", val );
+ d->m_settings->set("CustomBaseJar", val);
}
-void BaseInstance::setShouldUseCustomBaseJar ( bool val )
+void BaseInstance::setShouldUseCustomBaseJar(bool val)
{
I_D(BaseInstance);
- d->m_settings->set ( "UseCustomBaseJar", val );
+ d->m_settings->set("UseCustomBaseJar", val);
}
bool BaseInstance::shouldUseCustomBaseJar() const
{
I_D(BaseInstance);
- return d->m_settings->get ( "UseCustomBaseJar" ).toBool();
+ return d->m_settings->get("UseCustomBaseJar").toBool();
}
-
qint64 BaseInstance::lastLaunch() const
{
I_D(BaseInstance);
- return d->m_settings->get ( "lastLaunchTime" ).value<qint64>();
+ return d->m_settings->get("lastLaunchTime").value<qint64>();
}
-void BaseInstance::setLastLaunch ( qint64 val )
+void BaseInstance::setLastLaunch(qint64 val)
{
I_D(BaseInstance);
- d->m_settings->set ( "lastLaunchTime", val );
- emit propertiesChanged ( this );
+ d->m_settings->set("lastLaunchTime", val);
+ emit propertiesChanged(this);
}
-void BaseInstance::setGroupInitial ( QString val )
+void BaseInstance::setGroupInitial(QString val)
{
I_D(BaseInstance);
d->m_group = val;
- emit propertiesChanged ( this );
+ emit propertiesChanged(this);
}
-void BaseInstance::setGroupPost ( QString val )
+void BaseInstance::setGroupPost(QString val)
{
setGroupInitial(val);
emit groupChanged();
}
-
QString BaseInstance::group() const
{
I_D(BaseInstance);
return d->m_group;
}
-void BaseInstance::setNotes ( QString val )
+void BaseInstance::setNotes(QString val)
{
I_D(BaseInstance);
- d->m_settings->set ( "notes", val );
+ d->m_settings->set("notes", val);
}
QString BaseInstance::notes() const
{
I_D(BaseInstance);
- return d->m_settings->get ( "notes" ).toString();
+ return d->m_settings->get("notes").toString();
}
-void BaseInstance::setIconKey ( QString val )
+void BaseInstance::setIconKey(QString val)
{
I_D(BaseInstance);
- d->m_settings->set ( "iconKey", val );
- emit propertiesChanged ( this );
+ d->m_settings->set("iconKey", val);
+ emit propertiesChanged(this);
}
QString BaseInstance::iconKey() const
{
I_D(BaseInstance);
- return d->m_settings->get ( "iconKey" ).toString();
+ return d->m_settings->get("iconKey").toString();
}
-void BaseInstance::setName ( QString val )
+void BaseInstance::setName(QString val)
{
I_D(BaseInstance);
- d->m_settings->set ( "name", val );
- emit propertiesChanged ( this );
+ d->m_settings->set("name", val);
+ emit propertiesChanged(this);
}
QString BaseInstance::name() const
{
I_D(BaseInstance);
- return d->m_settings->get ( "name" ).toString();
+ return d->m_settings->get("name").toString();
}
diff --git a/logic/BaseInstance_p.h b/logic/BaseInstance_p.h
index 06c0c0ba..06581a34 100644
--- a/logic/BaseInstance_p.h
+++ b/logic/BaseInstance_p.h
@@ -1,10 +1,25 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#pragma once
#include <QString>
#include <settingsobject.h>
class BaseInstance;
-#define I_D(Class) Class##Private * const d = (Class##Private * const) inst_d.get()
+#define I_D(Class) Class##Private *const d = (Class##Private * const)inst_d.get()
struct BaseInstancePrivate
{
diff --git a/logic/BaseUpdate.cpp b/logic/BaseUpdate.cpp
index 02b29d32..5aeb12ef 100644
--- a/logic/BaseUpdate.cpp
+++ b/logic/BaseUpdate.cpp
@@ -1,6 +1,21 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "BaseUpdate.h"
-BaseUpdate::BaseUpdate ( BaseInstance* inst, QObject* parent ) : Task ( parent )
+BaseUpdate::BaseUpdate(BaseInstance *inst, QObject *parent) : Task(parent)
{
m_inst = inst;
}
diff --git a/logic/BaseUpdate.h b/logic/BaseUpdate.h
index 9ada0770..ddeefa97 100644
--- a/logic/BaseUpdate.h
+++ b/logic/BaseUpdate.h
@@ -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
@@ -34,15 +34,14 @@ class BaseUpdate : public Task
Q_OBJECT
public:
explicit BaseUpdate(BaseInstance *inst, QObject *parent = 0);
-
+
virtual void executeTask() = 0;
-protected slots:
- //virtual void error(const QString &msg);
+protected
+slots:
+ // virtual void error(const QString &msg);
void updateDownloadProgress(qint64 current, qint64 total);
-
+
protected:
BaseInstance *m_inst;
};
-
-
diff --git a/logic/BaseVersion.h b/logic/BaseVersion.h
index 01745c46..1864c94c 100644
--- a/logic/BaseVersion.h
+++ b/logic/BaseVersion.h
@@ -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
@@ -14,6 +14,7 @@
*/
#pragma once
+
#include <memory>
/*!
@@ -26,13 +27,13 @@ struct BaseVersion
* This should be unique within the version list or shenanigans will occur.
*/
virtual QString descriptor() = 0;
-
+
/*!
* The name of this version as it is displayed to the user.
* For example: "1.5.1"
*/
virtual QString name() = 0;
-
+
/*!
* This should return a string that describes
* the kind of version this is (Stable, Beta, Snapshot, whatever)
@@ -42,4 +43,4 @@ struct BaseVersion
typedef std::shared_ptr<BaseVersion> BaseVersionPtr;
-Q_DECLARE_METATYPE( BaseVersionPtr ) \ No newline at end of file
+Q_DECLARE_METATYPE(BaseVersionPtr) \ No newline at end of file
diff --git a/logic/CMakeLists.txt b/logic/CMakeLists.txt
deleted file mode 100644
index b1eacced..00000000
--- a/logic/CMakeLists.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-project(libMultiMC)
-
-set(CMAKE_AUTOMOC ON)
-
-# Find Qt
-find_package(Qt5Core REQUIRED)
-find_package(Qt5Network REQUIRED)
-find_package(Qt5Xml REQUIRED)
-
-# Include Qt headers.
-include_directories(${Qt5Base_INCLUDE_DIRS})
-include_directories(${Qt5Network_INCLUDE_DIRS})
-
-# Include utility library.
-include_directories(${CMAKE_SOURCE_DIR}/libutil/include)
-
-# Include settings library.
-include_directories(${CMAKE_SOURCE_DIR}/libsettings/include)
-
-SET(LIBINST_HEADERS
-
-)
-
-
diff --git a/logic/EnabledItemFilter.cpp b/logic/EnabledItemFilter.cpp
index 6ecd0271..c252a0ad 100644
--- a/logic/EnabledItemFilter.cpp
+++ b/logic/EnabledItemFilter.cpp
@@ -1,9 +1,22 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "EnabledItemFilter.h"
-EnabledItemFilter::EnabledItemFilter(QObject* parent)
- :QSortFilterProxyModel(parent)
+EnabledItemFilter::EnabledItemFilter(QObject *parent) : QSortFilterProxyModel(parent)
{
-
}
void EnabledItemFilter::setActive(bool active)
@@ -14,17 +27,17 @@ void EnabledItemFilter::setActive(bool active)
bool EnabledItemFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{
- if(!m_active)
+ if (!m_active)
return true;
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
- if(sourceModel()->flags(index) & Qt::ItemIsEnabled)
+ if (sourceModel()->flags(index) & Qt::ItemIsEnabled)
{
return true;
}
return false;
}
-bool EnabledItemFilter::lessThan(const QModelIndex& left, const QModelIndex& right) const
+bool EnabledItemFilter::lessThan(const QModelIndex &left, const QModelIndex &right) const
{
- return QSortFilterProxyModel::lessThan(left, right);
+ return QSortFilterProxyModel::lessThan(left, right);
}
diff --git a/logic/EnabledItemFilter.h b/logic/EnabledItemFilter.h
index cb6d4041..bf5e1e85 100644
--- a/logic/EnabledItemFilter.h
+++ b/logic/EnabledItemFilter.h
@@ -1,3 +1,18 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#pragma once
#include <QSortFilterProxyModel>
@@ -7,10 +22,11 @@ class EnabledItemFilter : public QSortFilterProxyModel
public:
EnabledItemFilter(QObject *parent = 0);
void setActive(bool active);
-
+
protected:
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
+
private:
bool m_active = false;
}; \ No newline at end of file
diff --git a/logic/ForgeInstaller.cpp b/logic/ForgeInstaller.cpp
index a946dd44..8d4c5b41 100644
--- a/logic/ForgeInstaller.cpp
+++ b/logic/ForgeInstaller.cpp
@@ -1,3 +1,18 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "ForgeInstaller.h"
#include "OneSixVersion.h"
#include "OneSixLibrary.h"
diff --git a/logic/ForgeInstaller.h b/logic/ForgeInstaller.h
index f6f22a2a..0b9f9c77 100644
--- a/logic/ForgeInstaller.h
+++ b/logic/ForgeInstaller.h
@@ -1,3 +1,18 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#pragma once
#include <QString>
#include <memory>
@@ -19,7 +34,3 @@ private:
QString realVersionId;
QString m_universal_url;
};
-
-
-
-
diff --git a/logic/InstanceFactory.cpp b/logic/InstanceFactory.cpp
index e64d22ca..e1f1f202 100644
--- a/logic/InstanceFactory.cpp
+++ b/logic/InstanceFactory.cpp
@@ -30,7 +30,7 @@
#include <setting.h>
#include "pathutils.h"
-#include <logger/QsLog.h>
+#include "logger/QsLog.h"
InstanceFactory InstanceFactory::loader;
@@ -129,19 +129,20 @@ InstanceFactory::InstCreateError InstanceFactory::copyInstance(BaseInstance *&ne
return InstanceFactory::CantCreateDir;
}
auto error = loadInstance(newInstance, instDir);
- switch(error)
+ switch (error)
{
- case NoLoadError:
- return NoCreateError;
- case UnknownLoadError:
- {
- rootDir.removeRecursively();
- return UnknownCreateError;
- }
- case NotAnInstance:
- {
- rootDir.removeRecursively();
- return CantCreateDir;
- }
- };
+ case NoLoadError:
+ return NoCreateError;
+ case UnknownLoadError:
+ {
+ rootDir.removeRecursively();
+ return UnknownCreateError;
+ }
+ case NotAnInstance:
+ {
+ rootDir.removeRecursively();
+ return CantCreateDir;
+ }
+ }
+ ;
}
diff --git a/logic/InstanceLauncher.cpp b/logic/InstanceLauncher.cpp
index 720052a3..9f78e55b 100644
--- a/logic/InstanceLauncher.cpp
+++ b/logic/InstanceLauncher.cpp
@@ -1,18 +1,34 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <iostream>
+
#include "InstanceLauncher.h"
#include "MultiMC.h"
-#include <iostream>
-#include "gui/logindialog.h"
-#include "gui/ProgressDialog.h"
-#include "gui/consolewindow.h"
+#include "gui/ConsoleWindow.h"
+#include "gui/dialogs/LoginDialog.h"
+#include "gui/dialogs/ProgressDialog.h"
+
#include "logic/net/LoginTask.h"
#include "logic/MinecraftProcess.h"
-#include "lists/InstanceList.h"
-
+#include "logic/lists/InstanceList.h"
-InstanceLauncher::InstanceLauncher ( QString instId )
- :QObject(), instId ( instId )
-{}
+InstanceLauncher::InstanceLauncher(QString instId) : QObject(), instId(instId)
+{
+}
void InstanceLauncher::onTerminated()
{
@@ -22,53 +38,56 @@ void InstanceLauncher::onTerminated()
void InstanceLauncher::onLoginComplete()
{
- LoginTask * task = ( LoginTask * ) QObject::sender();
+ LoginTask *task = (LoginTask *)QObject::sender();
auto result = task->getResult();
auto instance = MMC->instances()->getInstanceById(instId);
- proc = instance->prepareForLaunch ( result );
- if ( !proc )
+ proc = instance->prepareForLaunch(result);
+ if (!proc)
{
- //FIXME: report error
+ // FIXME: report error
return;
}
console = new ConsoleWindow(proc);
console->show();
- connect ( proc, SIGNAL ( ended() ), SLOT ( onTerminated() ) );
- connect ( proc, SIGNAL ( log ( QString,MessageLevel::Enum ) ), console, SLOT ( write ( QString,MessageLevel::Enum ) ) );
+ connect(proc, SIGNAL(ended()), SLOT(onTerminated()));
+ connect(proc, SIGNAL(log(QString, MessageLevel::Enum)), console,
+ SLOT(write(QString, MessageLevel::Enum)));
proc->launch();
}
-void InstanceLauncher::doLogin ( const QString& errorMsg )
+void InstanceLauncher::doLogin(const QString &errorMsg)
{
- LoginDialog* loginDlg = new LoginDialog ( nullptr, errorMsg );
+ LoginDialog *loginDlg = new LoginDialog(nullptr, errorMsg);
loginDlg->exec();
- if ( loginDlg->result() == QDialog::Accepted )
+ if (loginDlg->result() == QDialog::Accepted)
{
- UserInfo uInfo {loginDlg->getUsername(), loginDlg->getPassword() };
+ UserInfo uInfo{loginDlg->getUsername(), loginDlg->getPassword()};
- ProgressDialog* tDialog = new ProgressDialog ( nullptr );
- LoginTask* loginTask = new LoginTask ( uInfo, tDialog );
- connect ( loginTask, SIGNAL ( succeeded() ),SLOT ( onLoginComplete() ), Qt::QueuedConnection );
- connect ( loginTask, SIGNAL ( failed ( QString ) ),SLOT ( doLogin ( QString ) ), Qt::QueuedConnection );
- tDialog->exec ( loginTask );
+ ProgressDialog *tDialog = new ProgressDialog(nullptr);
+ LoginTask *loginTask = new LoginTask(uInfo, tDialog);
+ connect(loginTask, SIGNAL(succeeded()), SLOT(onLoginComplete()), Qt::QueuedConnection);
+ connect(loginTask, SIGNAL(failed(QString)), SLOT(doLogin(QString)),
+ Qt::QueuedConnection);
+ tDialog->exec(loginTask);
}
- //onLoginComplete(LoginResponse("Offline","Offline", 1));
+ // onLoginComplete(LoginResponse("Offline","Offline", 1));
}
int InstanceLauncher::launch()
{
- std::cout << "Launching Instance '" << qPrintable ( instId ) << "'" << std::endl;
+ std::cout << "Launching Instance '" << qPrintable(instId) << "'" << std::endl;
auto instance = MMC->instances()->getInstanceById(instId);
- if ( !instance )
+ if (!instance)
{
- std::cout << "Could not find instance requested. note that you have to specify the ID, not the NAME" << std::endl;
+ std::cout << "Could not find instance requested. note that you have to specify the ID, "
+ "not the NAME" << std::endl;
return 1;
}
std::cout << "Logging in..." << std::endl;
- doLogin ( "" );
+ doLogin("");
return MMC->exec();
}
diff --git a/logic/InstanceLauncher.h b/logic/InstanceLauncher.h
index de93e3d7..107c069f 100644
--- a/logic/InstanceLauncher.h
+++ b/logic/InstanceLauncher.h
@@ -1,3 +1,18 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#pragma once
#include <QObject>
@@ -9,20 +24,21 @@ class ConsoleWindow;
class InstanceLauncher : public QObject
{
Q_OBJECT
-
+
private:
QString instId;
MinecraftProcess *proc;
ConsoleWindow *console;
-
+
public:
InstanceLauncher(QString instId);
-
-private slots:
+
+private
+slots:
void onTerminated();
void onLoginComplete();
void doLogin(const QString &errorMsg);
-
+
public:
int launch();
};
diff --git a/logic/JavaUtils.cpp b/logic/JavaUtils.cpp
index 8e9c984f..61d0231a 100644
--- a/logic/JavaUtils.cpp
+++ b/logic/JavaUtils.cpp
@@ -13,21 +13,22 @@
* limitations under the License.
*/
-#include "JavaUtils.h"
-#include "pathutils.h"
-#include "MultiMC.h"
-
#include <QStringList>
#include <QString>
#include <QDir>
#include <QMessageBox>
-#include <logger/QsLog.h>
-#include <gui/versionselectdialog.h>
+
#include <setting.h>
+#include <pathutils.h>
+
+#include "MultiMC.h"
+
+#include "JavaUtils.h"
+#include "logger/QsLog.h"
+#include "gui/dialogs/VersionSelectDialog.h"
JavaUtils::JavaUtils()
{
-
}
JavaVersionPtr JavaUtils::GetDefaultJava()
@@ -48,20 +49,24 @@ QList<JavaVersionPtr> JavaUtils::FindJavaFromRegistryKey(DWORD keyType, QString
QList<JavaVersionPtr> javas;
QString archType = "unknown";
- if(keyType == KEY_WOW64_64KEY) archType = "64";
- else if(keyType == KEY_WOW64_32KEY) archType = "32";
+ if (keyType == KEY_WOW64_64KEY)
+ archType = "64";
+ else if (keyType == KEY_WOW64_32KEY)
+ archType = "32";
HKEY jreKey;
- if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, keyName.toStdString().c_str(), 0, KEY_READ | keyType | KEY_ENUMERATE_SUB_KEYS, &jreKey) == ERROR_SUCCESS)
+ if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, keyName.toStdString().c_str(), 0,
+ KEY_READ | keyType | KEY_ENUMERATE_SUB_KEYS, &jreKey) == ERROR_SUCCESS)
{
// Read the current type version from the registry.
// This will be used to find any key that contains the JavaHome value.
char *value = new char[0];
DWORD valueSz = 0;
- if (RegQueryValueExA(jreKey, "CurrentVersion", NULL, NULL, (BYTE*)value, &valueSz) == ERROR_MORE_DATA)
+ if (RegQueryValueExA(jreKey, "CurrentVersion", NULL, NULL, (BYTE *)value, &valueSz) ==
+ ERROR_MORE_DATA)
{
value = new char[valueSz];
- RegQueryValueExA(jreKey, "CurrentVersion", NULL, NULL, (BYTE*)value, &valueSz);
+ RegQueryValueExA(jreKey, "CurrentVersion", NULL, NULL, (BYTE *)value, &valueSz);
}
QString recommended = value;
@@ -70,37 +75,43 @@ QList<JavaVersionPtr> JavaUtils::FindJavaFromRegistryKey(DWORD keyType, QString
DWORD subKeyNameSize, numSubKeys, retCode;
// Get the number of subkeys
- RegQueryInfoKey(jreKey, NULL, NULL, NULL, &numSubKeys, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ RegQueryInfoKey(jreKey, NULL, NULL, NULL, &numSubKeys, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL);
// Iterate until RegEnumKeyEx fails
- if(numSubKeys > 0)
+ if (numSubKeys > 0)
{
- for(int i = 0; i < numSubKeys; i++)
+ for (int i = 0; i < numSubKeys; i++)
{
subKeyNameSize = 255;
- retCode = RegEnumKeyEx(jreKey, i, subKeyName, &subKeyNameSize, NULL, NULL, NULL, NULL);
- if(retCode == ERROR_SUCCESS)
+ retCode = RegEnumKeyEx(jreKey, i, subKeyName, &subKeyNameSize, NULL, NULL, NULL,
+ NULL);
+ if (retCode == ERROR_SUCCESS)
{
// Now open the registry key for the version that we just got.
QString newKeyName = keyName + "\\" + subKeyName;
HKEY newKey;
- if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, newKeyName.toStdString().c_str(), 0, KEY_READ | KEY_WOW64_64KEY, &newKey) == ERROR_SUCCESS)
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, newKeyName.toStdString().c_str(), 0,
+ KEY_READ | KEY_WOW64_64KEY, &newKey) == ERROR_SUCCESS)
{
// Read the JavaHome value to find where Java is installed.
value = new char[0];
valueSz = 0;
- if (RegQueryValueEx(newKey, "JavaHome", NULL, NULL, (BYTE*)value, &valueSz) == ERROR_MORE_DATA)
+ if (RegQueryValueEx(newKey, "JavaHome", NULL, NULL, (BYTE *)value,
+ &valueSz) == ERROR_MORE_DATA)
{
value = new char[valueSz];
- RegQueryValueEx(newKey, "JavaHome", NULL, NULL, (BYTE*)value, &valueSz);
+ RegQueryValueEx(newKey, "JavaHome", NULL, NULL, (BYTE *)value,
+ &valueSz);
// Now, we construct the version object and add it to the list.
JavaVersionPtr javaVersion(new JavaVersion());
javaVersion->id = subKeyName;
javaVersion->arch = archType;
- javaVersion->path = QDir(PathCombine(value, "bin")).absoluteFilePath("java.exe");
+ javaVersion->path =
+ QDir(PathCombine(value, "bin")).absoluteFilePath("java.exe");
javaVersion->recommended = (recommended == subKeyName);
javas.append(javaVersion);
}
@@ -121,17 +132,21 @@ QList<JavaVersionPtr> JavaUtils::FindJavaPaths()
{
QList<JavaVersionPtr> javas;
- QList<JavaVersionPtr> JRE64s = this->FindJavaFromRegistryKey(KEY_WOW64_64KEY, "SOFTWARE\\JavaSoft\\Java Runtime Environment");
- QList<JavaVersionPtr> JDK64s = this->FindJavaFromRegistryKey(KEY_WOW64_64KEY, "SOFTWARE\\JavaSoft\\Java Development Kit");
- QList<JavaVersionPtr> JRE32s = this->FindJavaFromRegistryKey(KEY_WOW64_32KEY, "SOFTWARE\\JavaSoft\\Java Runtime Environment");
- QList<JavaVersionPtr> JDK32s = this->FindJavaFromRegistryKey(KEY_WOW64_32KEY, "SOFTWARE\\JavaSoft\\Java Development Kit");
+ QList<JavaVersionPtr> JRE64s = this->FindJavaFromRegistryKey(
+ KEY_WOW64_64KEY, "SOFTWARE\\JavaSoft\\Java Runtime Environment");
+ QList<JavaVersionPtr> JDK64s = this->FindJavaFromRegistryKey(
+ KEY_WOW64_64KEY, "SOFTWARE\\JavaSoft\\Java Development Kit");
+ QList<JavaVersionPtr> JRE32s = this->FindJavaFromRegistryKey(
+ KEY_WOW64_32KEY, "SOFTWARE\\JavaSoft\\Java Runtime Environment");
+ QList<JavaVersionPtr> JDK32s = this->FindJavaFromRegistryKey(
+ KEY_WOW64_32KEY, "SOFTWARE\\JavaSoft\\Java Development Kit");
javas.append(JRE64s);
javas.append(JDK64s);
javas.append(JRE32s);
javas.append(JDK32s);
- if(javas.size() <= 0)
+ if (javas.size() <= 0)
{
QLOG_WARN() << "Failed to find Java in the Windows registry - defaulting to \"java\"";
javas.append(this->GetDefaultJava());
@@ -140,10 +155,11 @@ QList<JavaVersionPtr> JavaUtils::FindJavaPaths()
QLOG_INFO() << "Found the following Java installations (64 -> 32, JRE -> JDK): ";
- for(auto &java : javas)
+ for (auto &java : javas)
{
QString sRec;
- if(java->recommended) sRec = "(Recommended)";
+ if (java->recommended)
+ sRec = "(Recommended)";
QLOG_INFO() << java->id << java->arch << " at " << java->path << sRec;
}
diff --git a/logic/JavaUtils.h b/logic/JavaUtils.h
index e4f777d0..8d7550d0 100644
--- a/logic/JavaUtils.h
+++ b/logic/JavaUtils.h
@@ -17,11 +17,13 @@
#include <QStringList>
#include <QWidget>
-#include <logic/lists/JavaVersionList.h>
-#include "osutils.h"
+
+#include <osutils.h>
+
+#include "logic/lists/JavaVersionList.h"
#if WINDOWS
- #include <windows.h>
+#include <windows.h>
#endif
class JavaUtils
diff --git a/logic/LegacyForge.cpp b/logic/LegacyForge.cpp
index adcf487c..94212ae4 100644
--- a/logic/LegacyForge.cpp
+++ b/logic/LegacyForge.cpp
@@ -1,26 +1,25 @@
-//
-// Copyright 2012 MultiMC Contributors
-//
-// 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
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#include "LegacyForge.h"
-MinecraftForge::MinecraftForge ( const QString& file ) : Mod ( file )
+MinecraftForge::MinecraftForge(const QString &file) : Mod(file)
{
-
}
-bool MinecraftForge::FixVersionIfNeeded ( QString newVersion )
+
+bool MinecraftForge::FixVersionIfNeeded(QString newVersion)
{/*
wxString reportedVersion = GetModVersion();
if(reportedVersion == "..." || reportedVersion.empty())
@@ -40,7 +39,7 @@ bool MinecraftForge::FixVersionIfNeeded ( QString newVersion )
// release last entry
in.reset();
outzip.PutNextEntry("forgeversion.properties");
-
+
wxStringTokenizer tokenizer(newVersion,".");
wxString verFile;
verFile << wxString("forge.major.number=") << tokenizer.GetNextToken() << "\n";
diff --git a/logic/LegacyForge.h b/logic/LegacyForge.h
index 00a054b8..f4165ffa 100644
--- a/logic/LegacyForge.h
+++ b/logic/LegacyForge.h
@@ -1,25 +1,25 @@
-//
-// Copyright 2012 MultiMC Contributors
-//
-// 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
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#pragma once
+
#include "Mod.h"
class MinecraftForge : public Mod
{
public:
- MinecraftForge ( const QString& file );
+ MinecraftForge(const QString &file);
bool FixVersionIfNeeded(QString newVersion);
};
diff --git a/logic/LegacyInstance.cpp b/logic/LegacyInstance.cpp
index 2fd18693..9a91b839 100644
--- a/logic/LegacyInstance.cpp
+++ b/logic/LegacyInstance.cpp
@@ -1,16 +1,35 @@
-#include "LegacyInstance.h"
-#include "LegacyInstance_p.h"
-#include "MinecraftProcess.h"
-#include "LegacyUpdate.h"
-#include "lists/IconList.h"
-#include <setting.h>
-#include <pathutils.h>
-#include <cmdutils.h>
-#include "gui/LegacyModEditDialog.h"
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include <QFileInfo>
#include <QDir>
#include <QImage>
-#include <MultiMC.h>
+#include <setting.h>
+#include <pathutils.h>
+#include <cmdutils.h>
+
+#include "MultiMC.h"
+
+#include "LegacyInstance.h"
+#include "LegacyInstance_p.h"
+
+#include "logic/MinecraftProcess.h"
+#include "logic/LegacyUpdate.h"
+#include "logic/lists/IconList.h"
+
+#include "gui/dialogs/LegacyModEditDialog.h"
#define LAUNCHER_FILE "MultiMCLauncher.jar"
diff --git a/logic/LegacyInstance.h b/logic/LegacyInstance.h
index 8bf334f6..8a8d4b91 100644
--- a/logic/LegacyInstance.h
+++ b/logic/LegacyInstance.h
@@ -1,3 +1,18 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#pragma once
#include "BaseInstance.h"
@@ -58,7 +73,8 @@ public:
virtual bool versionIsCustom() override
{
return false;
- };
+ }
+ ;
virtual bool shouldUpdate() const;
virtual void setShouldUpdate(bool val);
diff --git a/logic/LegacyInstance_p.h b/logic/LegacyInstance_p.h
index 0809b8d2..ed97ccd3 100644
--- a/logic/LegacyInstance_p.h
+++ b/logic/LegacyInstance_p.h
@@ -1,16 +1,30 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#pragma once
#include <QString>
#include <settingsobject.h>
+#include <memory>
+
#include "BaseInstance_p.h"
#include "ModList.h"
-#include <QSharedPointer>
-
-class ModList;
-struct LegacyInstancePrivate: public BaseInstancePrivate
+struct LegacyInstancePrivate : public BaseInstancePrivate
{
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 5120b241..9533f8ff 100644
--- a/logic/LegacyUpdate.cpp
+++ b/logic/LegacyUpdate.cpp
@@ -1,3 +1,18 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "LegacyUpdate.h"
#include "lists/LwjglVersionList.h"
#include "lists/MinecraftVersionList.h"
@@ -9,7 +24,7 @@
#include <quazip.h>
#include <quazipfile.h>
#include <JlCompress.h>
-#include <logger/QsLog.h>
+#include "logger/QsLog.h"
LegacyUpdate::LegacyUpdate(BaseInstance *inst, QObject *parent) : BaseUpdate(inst, parent)
{
diff --git a/logic/LegacyUpdate.h b/logic/LegacyUpdate.h
index 69560f55..b30fa0b3 100644
--- a/logic/LegacyUpdate.h
+++ b/logic/LegacyUpdate.h
@@ -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
@@ -19,9 +19,9 @@
#include <QList>
#include <QUrl>
-#include "net/NetJob.h"
-#include "tasks/Task.h"
-#include "BaseUpdate.h"
+#include "logic/net/NetJob.h"
+#include "logic/tasks/Task.h"
+#include "logic/BaseUpdate.h"
class MinecraftVersion;
class BaseInstance;
@@ -34,39 +34,42 @@ class LegacyUpdate : public BaseUpdate
public:
explicit LegacyUpdate(BaseInstance *inst, QObject *parent = 0);
virtual void executeTask();
-
-private slots:
+
+private
+slots:
void lwjglStart();
- void lwjglFinished( QNetworkReply* );
+ void lwjglFinished(QNetworkReply *);
void lwjglFailed();
-
+
void jarStart();
void jarFinished();
void jarFailed();
-
+
void extractLwjgl();
-
+
void ModTheJar();
+
private:
enum MetainfAction
{
- KeepMetainf, // the META-INF folder will be added from the merged jar
+ KeepMetainf, // the META-INF folder will be added from the merged jar
IgnoreMetainf // the META-INF from the merged jar will be ignored
};
- bool MergeZipFiles(QuaZip *into, QFileInfo from, QSet<QString>& contained, MetainfAction metainf);
+ bool MergeZipFiles(QuaZip *into, QFileInfo from, QSet<QString> &contained,
+ MetainfAction metainf);
+
private:
-
+
std::shared_ptr<QNetworkReply> m_reply;
-
+
// target version, determined during this task
// MinecraftVersion *targetVersion;
QString lwjglURL;
QString lwjglVersion;
-
+
QString lwjglTargetPath;
QString lwjglNativesPath;
+
private:
NetJobPtr legacyDownloadJob;
};
-
-
diff --git a/logic/MinecraftProcess.h b/logic/MinecraftProcess.h
index 812559d5..ad887c5b 100644
--- a/logic/MinecraftProcess.h
+++ b/logic/MinecraftProcess.h
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
#pragma once
#include <QProcess>
@@ -24,15 +25,17 @@
* @brief the MessageLevel Enum
* defines what level a message is
*/
-namespace MessageLevel {
-enum Enum {
- MultiMC, /**< MultiMC Messages */
- Debug, /**< Debug Messages */
- Info, /**< Info Messages */
- Message, /**< Standard Messages */
- Warning, /**< Warnings */
- Error, /**< Errors */
- Fatal /**< Fatal Errors */
+namespace MessageLevel
+{
+enum Enum
+{
+ MultiMC, /**< MultiMC Messages */
+ Debug, /**< Debug Messages */
+ Info, /**< Info Messages */
+ Message, /**< Standard Messages */
+ Warning, /**< Warnings */
+ Error, /**< Errors */
+ Fatal /**< Fatal Errors */
};
}
@@ -56,25 +59,29 @@ public:
void launch();
void setMinecraftWorkdir(QString path);
-
+
void setMinecraftArguments(QStringList args);
-
+
void killMinecraft();
-
- inline void setLogin(QString user, QString sid) { username = user; sessionID = sid; }
-
+
+ inline void setLogin(QString user, QString sid)
+ {
+ username = user;
+ sessionID = sid;
+ }
+
signals:
/**
* @brief emitted when mc has finished and the PostLaunchCommand was run
*/
- void ended(BaseInstance*);
+ void ended(BaseInstance *);
/**
* @brief emitted when we want to log something
* @param text the text to log
* @param level the level to log at
*/
- void log(QString text, MessageLevel::Enum level=MessageLevel::MultiMC);
+ void log(QString text, MessageLevel::Enum level = MessageLevel::MultiMC);
protected:
BaseInstance *m_instance;
@@ -83,10 +90,12 @@ protected:
QString m_out_leftover;
QProcess m_prepostlaunchprocess;
-protected slots:
+protected
+slots:
void finish(int, QProcess::ExitStatus status);
void on_stdErr();
void on_stdOut();
+
private:
bool killed;
MessageLevel::Enum getLevel(const QString &message, MessageLevel::Enum defaultLevel);
diff --git a/logic/MinecraftVersion.h b/logic/MinecraftVersion.h
index 53c2f5ef..504381a8 100644
--- a/logic/MinecraftVersion.h
+++ b/logic/MinecraftVersion.h
@@ -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
@@ -25,10 +25,10 @@ struct MinecraftVersion : public BaseVersion
* This is primarily used for sorting versions in a list.
*/
qint64 timestamp;
-
+
/// The URL that this version will be downloaded from. maybe.
QString download_url;
-
+
/// This version's type. Used internally to identify what kind of version this is.
enum VersionType
{
@@ -36,31 +36,31 @@ struct MinecraftVersion : public BaseVersion
Legacy,
Nostalgia
} type;
-
+
/// is this the latest version?
bool is_latest = false;
-
+
/// is this a snapshot?
bool is_snapshot = false;
-
+
QString m_name;
-
+
QString m_descriptor;
-
- virtual QString descriptor()
+
+ virtual QString descriptor()
{
return m_descriptor;
}
-
- virtual QString name()
+
+ virtual QString name()
{
return m_name;
}
-
+
virtual QString typeString() const
{
QStringList pre_final;
- if(is_latest == true)
+ if (is_latest == true)
{
pre_final.append("Latest");
}
@@ -75,12 +75,12 @@ struct MinecraftVersion : public BaseVersion
case Nostalgia:
pre_final.append("Nostalgia");
break;
-
+
default:
pre_final.append(QString("Type(%1)").arg(type));
break;
}
- if(is_snapshot == true)
+ if (is_snapshot == true)
{
pre_final.append("Snapshot");
}
diff --git a/logic/Mod.cpp b/logic/Mod.cpp
index c45e3ad2..f9647eea 100644
--- a/logic/Mod.cpp
+++ b/logic/Mod.cpp
@@ -1,18 +1,17 @@
-//
-// Copyright 2012 MultiMC Contributors
-//
-// 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
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#include <QDir>
#include <QString>
@@ -26,7 +25,7 @@
#include "Mod.h"
#include <pathutils.h>
#include <inifile.h>
-#include <logger/QsLog.h>
+#include "logger/QsLog.h"
Mod::Mod(const QFileInfo &file)
{
@@ -121,11 +120,12 @@ void Mod::ReadMCModInfo(QByteArray contents)
m_homeurl = firstObj.value("url").toString();
m_description = firstObj.value("description").toString();
QJsonArray authors = firstObj.value("authors").toArray();
- if(authors.size() == 0) m_authors = "";
- else if(authors.size() >= 1)
+ if (authors.size() == 0)
+ m_authors = "";
+ else if (authors.size() >= 1)
{
m_authors = authors.at(0).toString();
- for(int i = 1; i < authors.size(); i++)
+ for (int i = 1; i < authors.size(); i++)
{
m_authors += ", " + authors.at(i).toString();
}
diff --git a/logic/Mod.h b/logic/Mod.h
index f3aaf18b..ca362a9d 100644
--- a/logic/Mod.h
+++ b/logic/Mod.h
@@ -1,18 +1,17 @@
-//
-// Copyright 2012 MultiMC Contributors
-//
-// 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
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#pragma once
#include <QFileInfo>
diff --git a/logic/ModList.cpp b/logic/ModList.cpp
index 236f0db6..8ec73955 100644
--- a/logic/ModList.cpp
+++ b/logic/ModList.cpp
@@ -1,18 +1,17 @@
-//
-// Copyright 2013 MultiMC Contributors
-//
-// 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
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#include "ModList.h"
#include "LegacyInstance.h"
@@ -21,7 +20,7 @@
#include <QUrl>
#include <QUuid>
#include <QFileSystemWatcher>
-#include <logger/QsLog.h>
+#include "logger/QsLog.h"
ModList::ModList(const QString &dir, const QString &list_file)
: QAbstractListModel(), m_dir(dir), m_list_file(list_file)
diff --git a/logic/ModList.h b/logic/ModList.h
index e99b6c82..803a5429 100644
--- a/logic/ModList.h
+++ b/logic/ModList.h
@@ -1,22 +1,29 @@
-//
-// Copyright 2013 MultiMC Contributors
-//
-// 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
-//
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#pragma once
-class LegacyInstance;
-class BaseInstance;
#include <QList>
#include <QString>
#include <QDir>
#include <QAbstractListModel>
-#include "Mod.h"
+#include "logic/Mod.h"
+
+class LegacyInstance;
+class BaseInstance;
class QFileSystemWatcher;
/**
@@ -27,91 +34,105 @@ class ModList : public QAbstractListModel
{
Q_OBJECT
public:
- ModList(const QString& dir, const QString& list_file = QString());
+ ModList(const QString &dir, const QString &list_file = QString());
- virtual QVariant data ( const QModelIndex& index, int role = Qt::DisplayRole ) const;
- virtual int rowCount ( const QModelIndex& parent = QModelIndex() ) const
+ virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ virtual int rowCount(const QModelIndex &parent = QModelIndex()) const
{
return size();
- };
- virtual QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
- virtual int columnCount ( const QModelIndex& parent ) const;
-
- size_t size() const { return mods.size(); };
- bool empty() const { return size() == 0; }
- Mod& operator[](size_t index) { return mods[index]; };
-
+ }
+ ;
+ virtual QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+ virtual int columnCount(const QModelIndex &parent) const;
+
+ size_t size() const
+ {
+ return mods.size();
+ }
+ ;
+ bool empty() const
+ {
+ return size() == 0;
+ }
+ Mod &operator[](size_t index)
+ {
+ return mods[index];
+ }
+ ;
+
/// Reloads the mod list and returns true if the list changed.
virtual bool update();
/**
* Adds the given mod to the list at the given index - if the list supports custom ordering
*/
- virtual bool installMod(const QFileInfo& filename, int index = 0);
+ virtual bool installMod(const QFileInfo &filename, int index = 0);
/// Deletes the mod at the given index.
virtual bool deleteMod(int index);
-
+
/// Deletes all the selected mods
- virtual bool deleteMods( int first, int last );
-
+ virtual bool deleteMods(int first, int last);
+
/**
* move the mod at index to the position N
* 0 is the beginning of the list, length() is the end of the list.
*/
virtual bool moveModTo(int from, int to);
-
+
/**
* move the mod at index one position upwards
*/
virtual bool moveModUp(int from);
- virtual bool moveModsUp( int first, int last );
-
+ virtual bool moveModsUp(int first, int last);
+
/**
* move the mod at index one position downwards
*/
virtual bool moveModDown(int from);
- virtual bool moveModsDown( int first, int last );
-
+ virtual bool moveModsDown(int first, int last);
+
/// flags, mostly to support drag&drop
- virtual Qt::ItemFlags flags(const QModelIndex& index) const;
+ virtual Qt::ItemFlags flags(const QModelIndex &index) const;
/// get data for drag action
- virtual QMimeData* mimeData(const QModelIndexList& indexes) const;
+ virtual QMimeData *mimeData(const QModelIndexList &indexes) const;
/// get the supported mime types
virtual QStringList mimeTypes() const;
/// process data from drop action
- virtual bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent);
+ virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column,
+ const QModelIndex &parent);
/// what drag actions do we support?
virtual Qt::DropActions supportedDragActions() const;
-
+
/// what drop actions do we support?
virtual Qt::DropActions supportedDropActions() const;
-
+
void startWatching();
void stopWatching();
-
+
virtual bool isValid();
-
+
QDir dir()
{
return m_dir;
}
+
private:
QStringList readListFile();
bool saveListFile();
-private slots:
+private
+slots:
void directoryChanged(QString path);
-
+
signals:
void changed();
+
protected:
- QFileSystemWatcher * m_watcher;
+ QFileSystemWatcher *m_watcher;
bool is_watching;
QDir m_dir;
QString m_list_file;
QString m_list_id;
QList<Mod> mods;
};
-
-
-
diff --git a/logic/NagUtils.cpp b/logic/NagUtils.cpp
index ccabf71f..6f81b3c7 100644
--- a/logic/NagUtils.cpp
+++ b/logic/NagUtils.cpp
@@ -13,25 +13,26 @@
* limitations under the License.
*/
-#include "NagUtils.h"
-#include "gui/CustomMessageBox.h"
+#include "logic/NagUtils.h"
+#include "gui/dialogs/CustomMessageBox.h"
namespace NagUtils
{
void checkJVMArgs(QString jvmargs, QWidget *parent)
{
- if(jvmargs.contains("-XX:PermSize=") || jvmargs.contains(QRegExp("-Xm[sx]")))
+ if (jvmargs.contains("-XX:PermSize=") || jvmargs.contains(QRegExp("-Xm[sx]")))
{
- CustomMessageBox::selectable(parent, parent->tr("JVM arguments warning"),
- parent->tr("You tried to manually set a JVM memory option (using "
- " \"-XX:PermSize\", \"-Xmx\" or \"-Xms\") - there"
- " are dedicated boxes for these in the settings (Java"
- " tab, in the Memory group at the top).\n"
- "Your manual settings will be overridden by the"
- " dedicated options.\n"
- "This message will be displayed until you remove them"
- " from the JVM arguments."),
- QMessageBox::Warning)->exec();
+ CustomMessageBox::selectable(
+ parent, parent->tr("JVM arguments warning"),
+ parent->tr("You tried to manually set a JVM memory option (using "
+ " \"-XX:PermSize\", \"-Xmx\" or \"-Xms\") - there"
+ " are dedicated boxes for these in the settings (Java"
+ " tab, in the Memory group at the top).\n"
+ "Your manual settings will be overridden by the"
+ " dedicated options.\n"
+ "This message will be displayed until you remove them"
+ " from the JVM arguments."),
+ QMessageBox::Warning)->exec();
}
}
}
diff --git a/logic/NostalgiaInstance.cpp b/logic/NostalgiaInstance.cpp
index efd8f46b..2e23ee71 100644
--- a/logic/NostalgiaInstance.cpp
+++ b/logic/NostalgiaInstance.cpp
@@ -1,9 +1,24 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "NostalgiaInstance.h"
-NostalgiaInstance::NostalgiaInstance ( const QString& rootDir, SettingsObject* settings, QObject* parent )
- : OneSixInstance ( rootDir, settings, parent )
+NostalgiaInstance::NostalgiaInstance(const QString &rootDir, SettingsObject *settings,
+ QObject *parent)
+ : OneSixInstance(rootDir, settings, parent)
{
-
}
QString NostalgiaInstance::getStatusbarDescription()
@@ -15,8 +30,3 @@ bool NostalgiaInstance::menuActionEnabled(QString action_name) const
{
return false;
}
-
-/*
-ADD MORE
- IF REQUIRED
-*/
diff --git a/logic/NostalgiaInstance.h b/logic/NostalgiaInstance.h
index 64eb7a81..a26f7f0a 100644
--- a/logic/NostalgiaInstance.h
+++ b/logic/NostalgiaInstance.h
@@ -1,3 +1,18 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#pragma once
#include "OneSixInstance.h"
@@ -6,8 +21,8 @@ class NostalgiaInstance : public OneSixInstance
{
Q_OBJECT
public:
- explicit NostalgiaInstance(const QString &rootDir, SettingsObject * settings, QObject *parent = 0);
+ explicit NostalgiaInstance(const QString &rootDir, SettingsObject *settings,
+ QObject *parent = 0);
virtual QString getStatusbarDescription();
virtual bool menuActionEnabled(QString action_name) const;
};
-
diff --git a/logic/OneSixAssets.cpp b/logic/OneSixAssets.cpp
index 500385ad..dbc42262 100644
--- a/logic/OneSixAssets.cpp
+++ b/logic/OneSixAssets.cpp
@@ -1,5 +1,20 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include <QString>
-#include <logger/QsLog.h>
+#include "logger/QsLog.h"
#include <QtXml/QtXml>
#include "OneSixAssets.h"
#include "net/NetJob.h"
@@ -70,7 +85,7 @@ void OneSixAssets::S3BucketFinished()
auto metacache = MMC->metacache();
- for (auto object: objectList)
+ for (auto object : objectList)
{
// Filter folder keys (zero size)
if (object.size == 0)
@@ -99,8 +114,7 @@ void OneSixAssets::S3BucketFinished()
void OneSixAssets::start()
{
auto job = new NetJob("Assets index");
- job->addNetAction(
- S3ListBucket::make(QUrl("http://s3.amazonaws.com/Minecraft.Resources/")));
+ job->addNetAction(S3ListBucket::make(QUrl("http://s3.amazonaws.com/Minecraft.Resources/")));
connect(job, SIGNAL(succeeded()), SLOT(S3BucketFinished()));
connect(job, SIGNAL(failed()), SIGNAL(failed()));
emit indexStarted();
diff --git a/logic/OneSixAssets.h b/logic/OneSixAssets.h
index 72e8a843..948068b8 100644
--- a/logic/OneSixAssets.h
+++ b/logic/OneSixAssets.h
@@ -1,3 +1,18 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#pragma once
#include "net/NetJob.h"
@@ -14,13 +29,16 @@ signals:
void filesStarted();
void filesProgress(int, int, int);
-public slots:
+public
+slots:
void S3BucketFinished();
void downloadFinished();
+
public:
void start();
+
private:
- ThreadedDeleter * deleter;
+ ThreadedDeleter *deleter;
QStringList nuke_whitelist;
NetJobPtr index_job;
NetJobPtr files_job;
diff --git a/logic/OneSixInstance.cpp b/logic/OneSixInstance.cpp
index 7539d8e5..5c93236b 100644
--- a/logic/OneSixInstance.cpp
+++ b/logic/OneSixInstance.cpp
@@ -1,3 +1,18 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "OneSixInstance.h"
#include "OneSixInstance_p.h"
#include "OneSixUpdate.h"
@@ -8,8 +23,8 @@
#include <pathutils.h>
#include <cmdutils.h>
#include <JlCompress.h>
-#include <gui/OneSixModEditDialog.h>
-#include <logger/QsLog.h>
+#include "gui/dialogs/OneSixModEditDialog.h"
+#include "logger/QsLog.h"
OneSixInstance::OneSixInstance(const QString &rootDir, SettingsObject *setting_obj,
QObject *parent)
diff --git a/logic/OneSixInstance.h b/logic/OneSixInstance.h
index d2276afc..2d02b605 100644
--- a/logic/OneSixInstance.h
+++ b/logic/OneSixInstance.h
@@ -1,7 +1,24 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#pragma once
-#include "BaseInstance.h"
#include <QStringList>
+
+#include "BaseInstance.h"
+
class OneSixVersion;
class BaseUpdate;
class ModList;
diff --git a/logic/OneSixInstance_p.h b/logic/OneSixInstance_p.h
index 06737b6f..6b7ea431 100644
--- a/logic/OneSixInstance_p.h
+++ b/logic/OneSixInstance_p.h
@@ -1,11 +1,28 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#pragma once
-#include "BaseInstance_p.h"
-#include "OneSixVersion.h"
-#include "OneSixLibrary.h"
-#include "ModList.h"
+#include <memory>
+
+#include "logic/BaseInstance_p.h"
+#include "logic/OneSixVersion.h"
+#include "logic/OneSixLibrary.h"
+#include "logic/ModList.h"
-struct OneSixInstancePrivate: public BaseInstancePrivate
+struct OneSixInstancePrivate : public BaseInstancePrivate
{
std::shared_ptr<OneSixVersion> version;
std::shared_ptr<ModList> loader_mod_list;
diff --git a/logic/OneSixLibrary.cpp b/logic/OneSixLibrary.cpp
index 9c1caaa7..df04a0c7 100644
--- a/logic/OneSixLibrary.cpp
+++ b/logic/OneSixLibrary.cpp
@@ -1,7 +1,24 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <QJsonArray>
+
#include "OneSixLibrary.h"
#include "OneSixRule.h"
#include "OpSys.h"
-#include <QJsonArray>
+
void OneSixLibrary::finalize()
{
QStringList parts = m_name.split(':');
diff --git a/logic/OneSixLibrary.h b/logic/OneSixLibrary.h
index 5e58ef89..3a772420 100644
--- a/logic/OneSixLibrary.h
+++ b/logic/OneSixLibrary.h
@@ -1,9 +1,26 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#pragma once
+
#include <QString>
#include <QStringList>
#include <QMap>
-#include <memory>
#include <QJsonObject>
+#include <memory>
+
#include "OpSys.h"
class Rule;
@@ -14,7 +31,7 @@ private:
// basic values used internally (so far)
QString m_name;
QString m_base_url = "http://s3.amazonaws.com/Minecraft.Download/libraries/";
- QList<std::shared_ptr<Rule> > m_rules;
+ QList<std::shared_ptr<Rule>> m_rules;
// custom values
/// absolute URL. takes precedence over m_download_path, if defined
@@ -39,25 +56,26 @@ private:
bool m_is_native = false;
/// native suffixes per OS
QMap<OpSys, QString> m_native_suffixes;
+
public:
QStringList extract_excludes;
-
+
public:
/// Constructor
OneSixLibrary(QString name)
{
m_name = name;
}
-
+
QJsonObject toJson();
-
+
/**
* finalize the library, processing the input values into derived values and state
- *
+ *
* This SHALL be called after all the values are parsed or after any further change.
*/
void finalize();
-
+
/// Set the library composite name
void setName(QString name);
/// get a decent-looking name
@@ -77,13 +95,13 @@ public:
}
/// Set the url base for downloads
void setBaseUrl(QString base_url);
-
+
/// Call this to mark the library as 'native' (it's a zip archive with DLLs)
void setIsNative();
/// Attach a name suffix to the specified OS native
void addNative(OpSys os, QString suffix);
/// Set the load rules
- void setRules(QList<std::shared_ptr<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 cb64c9ba..d35be720 100644
--- a/logic/OneSixRule.cpp
+++ b/logic/OneSixRule.cpp
@@ -1,7 +1,23 @@
-#include "OneSixRule.h"
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include <QJsonObject>
#include <QJsonArray>
+#include "OneSixRule.h"
+
QList<std::shared_ptr<Rule>> rulesFromJsonV4(QJsonObject &objectWithRules)
{
QList<std::shared_ptr<Rule>> rules;
diff --git a/logic/OneSixRule.h b/logic/OneSixRule.h
index 6be01f1b..9cd1a226 100644
--- a/logic/OneSixRule.h
+++ b/logic/OneSixRule.h
@@ -1,7 +1,24 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#pragma once
+
#include <QString>
#include <QSharedPointer>
-#include "OneSixLibrary.h"
+
+#include "logic/OneSixLibrary.h"
enum RuleAction
{
@@ -17,19 +34,22 @@ class Rule
{
protected:
RuleAction m_result;
- virtual bool applies(OneSixLibrary * parent) = 0;
+ virtual bool applies(OneSixLibrary *parent) = 0;
+
public:
- Rule(RuleAction result)
- :m_result(result) {}
- virtual ~Rule(){};
+ Rule(RuleAction result) : m_result(result)
+ {
+ }
+ virtual ~Rule() {};
virtual QJsonObject toJson() = 0;
- RuleAction apply(OneSixLibrary * parent)
+ RuleAction apply(OneSixLibrary *parent)
{
- if(applies(parent))
+ if (applies(parent))
return m_result;
else
return Defer;
- };
+ }
+ ;
};
class OsRule : public Rule
@@ -39,34 +59,41 @@ private:
OpSys m_system;
// the OS version regexp
QString m_version_regexp;
+
protected:
- virtual bool applies ( OneSixLibrary* )
+ virtual bool applies(OneSixLibrary *)
{
return (m_system == currentSystem);
}
OsRule(RuleAction result, OpSys system, QString version_regexp)
- : Rule(result), m_system(system), m_version_regexp(version_regexp) {}
+ : Rule(result), m_system(system), m_version_regexp(version_regexp)
+ {
+ }
+
public:
virtual QJsonObject toJson();
- static std::shared_ptr<OsRule> create(RuleAction result, OpSys system, QString version_regexp)
+ static std::shared_ptr<OsRule> create(RuleAction result, OpSys system,
+ QString version_regexp)
{
- return std::shared_ptr<OsRule> (new OsRule(result, system, version_regexp));
+ return std::shared_ptr<OsRule>(new OsRule(result, system, version_regexp));
}
};
class ImplicitRule : public Rule
{
protected:
- virtual bool applies ( OneSixLibrary* )
+ virtual bool applies(OneSixLibrary *)
{
return true;
}
- ImplicitRule(RuleAction result)
- : Rule(result) {}
+ ImplicitRule(RuleAction result) : Rule(result)
+ {
+ }
+
public:
virtual QJsonObject toJson();
static std::shared_ptr<ImplicitRule> create(RuleAction result)
{
- return std::shared_ptr<ImplicitRule> (new ImplicitRule(result));
+ return std::shared_ptr<ImplicitRule>(new ImplicitRule(result));
}
};
diff --git a/logic/OneSixUpdate.cpp b/logic/OneSixUpdate.cpp
index 5c421fbf..2d8a167c 100644
--- a/logic/OneSixUpdate.cpp
+++ b/logic/OneSixUpdate.cpp
@@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
#include "MultiMC.h"
#include "OneSixUpdate.h"
diff --git a/logic/OneSixUpdate.h b/logic/OneSixUpdate.h
index 7c6fce1b..e5f553c7 100644
--- a/logic/OneSixUpdate.h
+++ b/logic/OneSixUpdate.h
@@ -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
@@ -18,10 +18,10 @@
#include <QObject>
#include <QList>
#include <QUrl>
-#include "net/NetJob.h"
-#include "tasks/Task.h"
-#include "BaseUpdate.h"
+#include "logic/net/NetJob.h"
+#include "logic/tasks/Task.h"
+#include "logic/BaseUpdate.h"
class MinecraftVersion;
class BaseInstance;
@@ -32,22 +32,21 @@ class OneSixUpdate : public BaseUpdate
public:
explicit OneSixUpdate(BaseInstance *inst, QObject *parent = 0);
virtual void executeTask();
-
-private slots:
+
+private
+slots:
void versionFileStart();
void versionFileFinished();
void versionFileFailed();
-
+
void jarlibStart();
void jarlibFinished();
void jarlibFailed();
-
+
private:
NetJobPtr specificVersionDownloadJob;
NetJobPtr jarlibDownloadJob;
-
+
// target version, determined during this task
std::shared_ptr<MinecraftVersion> targetVersion;
};
-
-
diff --git a/logic/OneSixVersion.cpp b/logic/OneSixVersion.cpp
index 51958389..01bf41f4 100644
--- a/logic/OneSixVersion.cpp
+++ b/logic/OneSixVersion.cpp
@@ -1,9 +1,24 @@
-#include "OneSixVersion.h"
-#include "OneSixLibrary.h"
-#include "OneSixRule.h"
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "logic/OneSixVersion.h"
+#include "logic/OneSixLibrary.h"
+#include "logic/OneSixRule.h"
std::shared_ptr<OneSixVersion> fromJsonV4(QJsonObject root,
- std::shared_ptr<OneSixVersion> fullVersion)
+ std::shared_ptr<OneSixVersion> fullVersion)
{
fullVersion->id = root.value("id").toString();
@@ -82,7 +97,7 @@ std::shared_ptr<OneSixVersion> fromJsonV4(QJsonObject root,
{
library->setAbsoluteUrl(urlAbsVal.toString());
}
- else if(urlAbsuVal.isString())
+ else if (urlAbsuVal.isString())
{
library->setAbsoluteUrl(urlAbsuVal.toString());
}
@@ -167,7 +182,7 @@ std::shared_ptr<OneSixVersion> OneSixVersion::fromFile(QString filepath)
}
QJsonObject root = jsonDoc.object();
auto version = fromJson(root);
- if(version)
+ if (version)
version->original_file = filepath;
return version;
}
@@ -192,11 +207,11 @@ bool OneSixVersion::toOriginalFile()
// screw processArguments
root.insert("releaseTime", releaseTime);
QJsonArray libarray;
- for(const auto & lib: libraries)
+ for (const auto &lib : libraries)
{
libarray.append(lib->toJson());
}
- if(libarray.count())
+ if (libarray.count())
root.insert("libraries", libarray);
QJsonDocument doc(root);
file.write(doc.toJson());
diff --git a/logic/OneSixVersion.h b/logic/OneSixVersion.h
index 3529138c..5718dafe 100644
--- a/logic/OneSixVersion.h
+++ b/logic/OneSixVersion.h
@@ -1,3 +1,18 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#pragma once
#include <QtCore>
#include <memory>
@@ -86,6 +101,4 @@ public:
}
*/
// QList<Rule> rules;
-
-
};
diff --git a/logic/OpSys.cpp b/logic/OpSys.cpp
index f101fd08..e001b7f3 100644
--- a/logic/OpSys.cpp
+++ b/logic/OpSys.cpp
@@ -1,23 +1,42 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "OpSys.h"
OpSys OpSys_fromString(QString name)
{
- if(name == "linux")
+ if (name == "linux")
return Os_Linux;
- if(name == "windows")
+ if (name == "windows")
return Os_Windows;
- if(name == "osx")
+ if (name == "osx")
return Os_OSX;
return Os_Other;
}
QString OpSys_toString(OpSys name)
{
- switch(name)
+ switch (name)
{
- case Os_Linux: return "linux";
- case Os_OSX: return "osx";
- case Os_Windows: return "windows";
- default: return "other";
+ case Os_Linux:
+ return "linux";
+ case Os_OSX:
+ return "osx";
+ case Os_Windows:
+ return "windows";
+ default:
+ return "other";
}
} \ No newline at end of file
diff --git a/logic/OpSys.h b/logic/OpSys.h
index aaa2eb65..363c87d7 100644
--- a/logic/OpSys.h
+++ b/logic/OpSys.h
@@ -1,3 +1,18 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#pragma once
#include <QString>
enum OpSys
@@ -12,11 +27,11 @@ OpSys OpSys_fromString(QString);
QString OpSys_toString(OpSys);
#ifdef Q_OS_WIN32
- #define currentSystem Os_Windows
+#define currentSystem Os_Windows
+#else
+#ifdef Q_OS_MAC
+#define currentSystem Os_OSX
#else
- #ifdef Q_OS_MAC
- #define currentSystem Os_OSX
- #else
- #define currentSystem Os_Linux
- #endif
+#define currentSystem Os_Linux
+#endif
#endif \ No newline at end of file
diff --git a/logic/lists/BaseVersionList.cpp b/logic/lists/BaseVersionList.cpp
index 61da5eeb..6e2c5282 100644
--- a/logic/lists/BaseVersionList.cpp
+++ b/logic/lists/BaseVersionList.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
@@ -16,12 +16,11 @@
#include "logic/lists/BaseVersionList.h"
#include "logic/BaseVersion.h"
-BaseVersionList::BaseVersionList(QObject *parent) :
- QAbstractListModel(parent)
+BaseVersionList::BaseVersionList(QObject *parent) : QAbstractListModel(parent)
{
}
-BaseVersionPtr BaseVersionList::findVersion( const QString& descriptor )
+BaseVersionPtr BaseVersionList::findVersion(const QString &descriptor)
{
for (int i = 0; i < count(); i++)
{
@@ -43,13 +42,12 @@ QVariant BaseVersionList::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
-
+
if (index.row() > count())
return QVariant();
-
-
+
BaseVersionPtr version = at(index.row());
-
+
switch (role)
{
case Qt::DisplayRole:
@@ -57,20 +55,20 @@ QVariant BaseVersionList::data(const QModelIndex &index, int role) const
{
case NameColumn:
return version->name();
-
+
case TypeColumn:
return version->typeString();
-
+
default:
return QVariant();
}
-
+
case Qt::ToolTipRole:
return version->descriptor();
-
+
case VersionPointerRole:
return qVariantFromValue(version);
-
+
default:
return QVariant();
}
@@ -85,27 +83,27 @@ QVariant BaseVersionList::headerData(int section, Qt::Orientation orientation, i
{
case NameColumn:
return "Name";
-
+
case TypeColumn:
return "Type";
-
+
default:
return QVariant();
}
-
+
case Qt::ToolTipRole:
switch (section)
{
case NameColumn:
return "The name of the version.";
-
+
case TypeColumn:
return "The version's type.";
-
+
default:
return QVariant();
}
-
+
default:
return QVariant();
}
diff --git a/logic/lists/BaseVersionList.h b/logic/lists/BaseVersionList.h
index d37431ed..5ac9369b 100644
--- a/logic/lists/BaseVersionList.h
+++ b/logic/lists/BaseVersionList.h
@@ -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
@@ -25,12 +25,12 @@
class Task;
/*!
- * \brief Class that each instance type's version list derives from.
- * Version lists are the lists that keep track of the available game versions
- * for that instance. This list will not be loaded on startup. It will be loaded
+ * \brief Class that each instance type's version list derives from.
+ * Version lists are the lists that keep track of the available game versions
+ * for that instance. This list will not be loaded on startup. It will be loaded
* when the list's load function is called. Before using the version list, you
* should check to see if it has been loaded yet and if not, load the list.
- *
+ *
* Note that this class also inherits from QAbstractListModel. Methods from that
* class determine how this version list shows up in a list view. Said methods
* all have a default implementation, but they can be overridden by plugins to
@@ -44,21 +44,21 @@ public:
{
VersionPointerRole = 0x34B1CB48
};
-
+
enum VListColumns
{
// First column - Name
NameColumn = 0,
-
+
// Second column - Type
TypeColumn,
-
+
// Third column - Timestamp
TimeColumn
};
-
+
explicit BaseVersionList(QObject *parent = 0);
-
+
/*!
* \brief Gets a task that will reload the version list.
* Simply execute the task to load the list.
@@ -66,24 +66,23 @@ public:
* \return A pointer to a task that reloads the version list.
*/
virtual Task *getLoadTask() = 0;
-
- //! Checks whether or not the list is loaded. If this returns false, the list should be loaded.
+
+ //! Checks whether or not the list is loaded. If this returns false, the list should be
+ //loaded.
virtual bool isLoaded() = 0;
-
+
//! Gets the version at the given index.
virtual const BaseVersionPtr at(int i) const = 0;
-
+
//! Returns the number of versions in the list.
virtual int count() const = 0;
-
-
+
//////// List Model Functions ////////
virtual QVariant data(const QModelIndex &index, int role) const;
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const;
virtual int rowCount(const QModelIndex &parent) const;
virtual int columnCount(const QModelIndex &parent) const;
-
-
+
/*!
* \brief Finds a version by its descriptor.
* \param The descriptor of the version to find.
@@ -91,20 +90,21 @@ public:
* one doesn't exist.
*/
virtual BaseVersionPtr findVersion(const QString &descriptor);
-
+
/*!
* \brief Gets the latest stable version of this instance type.
* This is the version that will be selected by default.
* By default, this is simply the first version in the list.
*/
virtual BaseVersionPtr getLatestStable() const;
-
+
/*!
* Sorts the version list.
*/
virtual void sort() = 0;
-
-protected slots:
+
+protected
+slots:
/*!
* Updates this list with the given list of versions.
* This is done by copying each version in the given list and inserting it
@@ -117,5 +117,5 @@ protected slots:
* then copies the versions and sets their parents correctly.
* \param versions List of versions whose parents should be set.
*/
- virtual void updateListData(QList<BaseVersionPtr > versions) = 0;
+ virtual void updateListData(QList<BaseVersionPtr> versions) = 0;
};
diff --git a/logic/lists/ForgeVersionList.cpp b/logic/lists/ForgeVersionList.cpp
index 27f567cd..b5e421af 100644
--- a/logic/lists/ForgeVersionList.cpp
+++ b/logic/lists/ForgeVersionList.cpp
@@ -21,7 +21,7 @@
#include <QtXml>
#include <QRegExp>
-#include <logger/QsLog.h>
+#include "logger/QsLog.h"
#define JSON_URL "http://files.minecraftforge.net/minecraftforge/json"
diff --git a/logic/lists/ForgeVersionList.h b/logic/lists/ForgeVersionList.h
index 52593f94..0d10e1f3 100644
--- a/logic/lists/ForgeVersionList.h
+++ b/logic/lists/ForgeVersionList.h
@@ -75,8 +75,7 @@ public:
virtual BaseVersionPtr getLatestStable() const;
virtual QVariant data(const QModelIndex &index, int role) const;
- virtual QVariant headerData(int section, Qt::Orientation orientation,
- int role) const;
+ virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const;
virtual int columnCount(const QModelIndex &parent) const;
protected:
diff --git a/logic/lists/IconList.cpp b/logic/lists/IconList.cpp
index 6988d02f..ecfb8c3c 100644
--- a/logic/lists/IconList.cpp
+++ b/logic/lists/IconList.cpp
@@ -1,3 +1,18 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "IconList.h"
#include <pathutils.h>
#include <QMap>
@@ -27,22 +42,21 @@ public:
}
};
-
IconList::IconList() : QAbstractListModel(), d(new Private())
{
QDir instance_icons(":/icons/instances/");
auto file_info_list = instance_icons.entryInfoList(QDir::Files, QDir::Name);
- for(auto file_info: file_info_list)
+ for (auto file_info : file_info_list)
{
QString key = file_info.baseName();
addIcon(key, key, file_info.absoluteFilePath(), true);
}
-
+
// FIXME: get from settings
ensureFolderPathExists("icons");
QDir user_icons("icons");
file_info_list = user_icons.entryInfoList(QDir::Files, QDir::Name);
- for(auto file_info: file_info_list)
+ for (auto file_info : file_info_list)
{
QString filename = file_info.absoluteFilePath();
QString key = file_info.baseName();
@@ -67,16 +81,17 @@ Qt::DropActions IconList::supportedDropActions() const
return Qt::CopyAction;
}
-bool IconList::dropMimeData ( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent )
+bool IconList::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column,
+ const QModelIndex &parent)
{
if (action == Qt::IgnoreAction)
- return true;
+ return true;
// check if the action is supported
if (!data || !(action & supportedDropActions()))
return false;
// files dropped from outside?
- if(data->hasUrls())
+ if (data->hasUrls())
{
/*
bool was_watching = is_watching;
@@ -85,10 +100,10 @@ bool IconList::dropMimeData ( const QMimeData* data, Qt::DropAction action, int
*/
auto urls = data->urls();
QStringList iconFiles;
- for(auto url: urls)
+ for (auto url : urls)
{
// only local files may be dropped...
- if(!url.isLocalFile())
+ if (!url.isLocalFile())
continue;
iconFiles += url.toLocalFile();
}
@@ -102,73 +117,73 @@ bool IconList::dropMimeData ( const QMimeData* data, Qt::DropAction action, int
return false;
}
-Qt::ItemFlags IconList::flags ( const QModelIndex& index ) const
+Qt::ItemFlags IconList::flags(const QModelIndex &index) const
{
- Qt::ItemFlags defaultFlags = QAbstractListModel::flags ( index );
+ Qt::ItemFlags defaultFlags = QAbstractListModel::flags(index);
if (index.isValid())
return Qt::ItemIsDropEnabled | defaultFlags;
else
return Qt::ItemIsDropEnabled | defaultFlags;
}
-QVariant IconList::data ( const QModelIndex& index, int role ) const
+QVariant IconList::data(const QModelIndex &index, int role) const
{
- if(!index.isValid())
+ if (!index.isValid())
return QVariant();
-
+
int row = index.row();
-
- if(row < 0 || row >= d->icons.size())
+
+ if (row < 0 || row >= d->icons.size())
return QVariant();
-
- switch(role)
+
+ switch (role)
{
- case Qt::DecorationRole:
- return d->icons[row].icon;
- case Qt::DisplayRole:
- return d->icons[row].name;
- case Qt::UserRole:
- return d->icons[row].key;
- default:
- return QVariant();
+ case Qt::DecorationRole:
+ return d->icons[row].icon;
+ case Qt::DisplayRole:
+ return d->icons[row].name;
+ case Qt::UserRole:
+ return d->icons[row].key;
+ default:
+ return QVariant();
}
}
-int IconList::rowCount ( const QModelIndex& parent ) const
+int IconList::rowCount(const QModelIndex &parent) const
{
return d->icons.size();
}
-void IconList::installIcons ( QStringList iconFiles )
+void IconList::installIcons(QStringList iconFiles)
{
- for(QString file: iconFiles)
+ for (QString file : iconFiles)
{
QFileInfo fileinfo(file);
- if(!fileinfo.isReadable() || !fileinfo.isFile())
+ if (!fileinfo.isReadable() || !fileinfo.isFile())
continue;
QString target = PathCombine("icons", fileinfo.fileName());
-
+
QString suffix = fileinfo.suffix();
- if(suffix != "jpeg" && suffix != "png" && suffix != "jpg")
+ if (suffix != "jpeg" && suffix != "png" && suffix != "jpg")
continue;
-
- if(!QFile::copy(file, target))
+
+ if (!QFile::copy(file, target))
continue;
-
+
QString key = fileinfo.baseName();
addIcon(key, key, target);
}
}
-bool IconList::deleteIcon ( QString key )
+bool IconList::deleteIcon(QString key)
{
int iconIdx = getIconIndex(key);
- if(iconIdx == -1)
+ if (iconIdx == -1)
return false;
- auto & iconEntry = d->icons[iconIdx];
- if(iconEntry.is_builtin)
+ auto &iconEntry = d->icons[iconIdx];
+ if (iconEntry.is_builtin)
return false;
- if(QFile::remove(iconEntry.filename))
+ if (QFile::remove(iconEntry.filename))
{
beginRemoveRows(QModelIndex(), iconIdx, iconIdx);
d->icons.remove(iconIdx);
@@ -178,35 +193,36 @@ bool IconList::deleteIcon ( QString key )
return true;
}
-bool IconList::addIcon ( QString key, QString name, QString path, bool is_builtin )
+bool IconList::addIcon(QString key, QString name, QString path, bool is_builtin)
{
auto iter = d->index.find(key);
- if(iter != d->index.end())
+ if (iter != d->index.end())
{
- if(d->icons[*iter].is_builtin)
+ if (d->icons[*iter].is_builtin)
return false;
-
+
QIcon icon(path);
- if(icon.isNull())
+ if (icon.isNull())
return false;
-
- auto & oldOne = d->icons[*iter];
-
- if(!QFile::remove(oldOne.filename))
+
+ auto &oldOne = d->icons[*iter];
+
+ if (!QFile::remove(oldOne.filename))
return false;
// replace the icon
oldOne = {key, name, icon, is_builtin, path};
- dataChanged(index(*iter),index(*iter));
+ dataChanged(index(*iter), index(*iter));
return true;
}
else
{
QIcon icon(path);
- if(icon.isNull()) return false;
-
+ if (icon.isNull())
+ return false;
+
// add a new icon
- beginInsertRows(QModelIndex(), d->icons.size(),d->icons.size());
+ beginInsertRows(QModelIndex(), d->icons.size(), d->icons.size());
d->icons.push_back({key, name, icon, is_builtin, path});
d->index[key] = d->icons.size() - 1;
endInsertRows();
@@ -218,39 +234,37 @@ void IconList::reindex()
{
d->index.clear();
int i = 0;
- for(auto& iter: d->icons)
+ for (auto &iter : d->icons)
{
d->index[iter.key] = i;
i++;
}
}
-
-QIcon IconList::getIcon ( QString key )
+QIcon IconList::getIcon(QString key)
{
int icon_index = getIconIndex(key);
- if(icon_index != -1)
+ if (icon_index != -1)
return d->icons[icon_index].icon;
-
+
// Fallback for icons that don't exist.
icon_index = getIconIndex("infinity");
-
- if(icon_index != -1)
+
+ if (icon_index != -1)
return d->icons[icon_index].icon;
return QIcon();
}
-int IconList::getIconIndex ( QString key )
+int IconList::getIconIndex(QString key)
{
- if(key == "default")
+ if (key == "default")
key = "infinity";
-
+
auto iter = d->index.find(key);
- if(iter != d->index.end())
+ if (iter != d->index.end())
return *iter;
-
-
+
return -1;
}
diff --git a/logic/lists/IconList.h b/logic/lists/IconList.h
index cad80cdf..40ad043b 100644
--- a/logic/lists/IconList.h
+++ b/logic/lists/IconList.h
@@ -1,3 +1,18 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#pragma once
#include <QMutex>
@@ -11,28 +26,29 @@ class IconList : public QAbstractListModel
public:
IconList();
virtual ~IconList();
-
- QIcon getIcon ( QString key );
- int getIconIndex ( QString key );
-
- virtual QVariant data ( const QModelIndex& index, int role = Qt::DisplayRole ) const;
- virtual int rowCount ( const QModelIndex& parent = QModelIndex() ) const;
-
+
+ QIcon getIcon(QString key);
+ int getIconIndex(QString key);
+
+ virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
+
bool addIcon(QString key, QString name, QString path, bool is_builtin = false);
bool deleteIcon(QString key);
-
+
virtual QStringList mimeTypes() const;
virtual Qt::DropActions supportedDropActions() const;
- virtual bool dropMimeData ( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent );
- virtual Qt::ItemFlags flags ( const QModelIndex& index ) const;
-
- void installIcons ( QStringList iconFiles );
-
+ virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column,
+ const QModelIndex &parent);
+ virtual Qt::ItemFlags flags(const QModelIndex &index) const;
+
+ void installIcons(QStringList iconFiles);
+
private:
// hide copy constructor
- IconList ( const IconList & ) = delete;
+ IconList(const IconList &) = delete;
// hide assign op
- IconList& operator= ( const IconList & ) = delete;
+ IconList &operator=(const IconList &) = delete;
void reindex();
- Private* d;
+ Private *d;
};
diff --git a/logic/lists/InstanceList.cpp b/logic/lists/InstanceList.cpp
index b42d7b7a..4446ff22 100644
--- a/logic/lists/InstanceList.cpp
+++ b/logic/lists/InstanceList.cpp
@@ -29,7 +29,7 @@
#include "logic/lists/IconList.h"
#include "logic/BaseInstance.h"
#include "logic/InstanceFactory.h"
-#include <logger/QsLog.h>
+#include "logger/QsLog.h"
const static int GROUP_FILE_FORMAT_VERSION = 1;
@@ -423,7 +423,7 @@ bool InstanceProxyModel::subSortLessThan(const QModelIndex &left,
BaseInstance *pdataLeft = static_cast<BaseInstance *>(left.internalPointer());
BaseInstance *pdataRight = static_cast<BaseInstance *>(right.internalPointer());
QString sortMode = MMC->settings()->get("InstSortMode").toString();
- if(sortMode == "LastLaunch")
+ if (sortMode == "LastLaunch")
{
return pdataLeft->lastLaunch() > pdataRight->lastLaunch();
}
diff --git a/logic/lists/InstanceList.h b/logic/lists/InstanceList.h
index 3cde6bf5..c3e3561d 100644
--- a/logic/lists/InstanceList.h
+++ b/logic/lists/InstanceList.h
@@ -98,7 +98,7 @@ signals:
public
slots:
- void on_InstFolderChanged(const Setting & setting, QVariant value);
+ void on_InstFolderChanged(const Setting &setting, QVariant value);
private
slots:
diff --git a/logic/lists/JavaVersionList.cpp b/logic/lists/JavaVersionList.cpp
index 5389c4cc..3dc1969b 100644
--- a/logic/lists/JavaVersionList.cpp
+++ b/logic/lists/JavaVersionList.cpp
@@ -20,7 +20,7 @@
#include <QtXml>
#include <QRegExp>
-#include <logger/QsLog.h>
+#include "logger/QsLog.h"
#include <logic/JavaUtils.h>
JavaVersionList::JavaVersionList(QObject *parent) : BaseVersionList(parent)
@@ -32,7 +32,6 @@ Task *JavaVersionList::getLoadTask()
return new JavaListLoadTask(this);
}
-
const BaseVersionPtr JavaVersionList::at(int i) const
{
return m_vlist.at(i);
@@ -187,11 +186,11 @@ void JavaListLoadTask::executeTask()
QList<JavaVersionPtr> javas = ju.FindJavaPaths();
QList<BaseVersionPtr> javas_bvp;
- for(int i = 0; i < javas.length(); i++)
+ for (int i = 0; i < javas.length(); i++)
{
BaseVersionPtr java = std::dynamic_pointer_cast<BaseVersion>(javas.at(i));
- if(java)
+ if (java)
{
javas_bvp.append(java);
}
diff --git a/logic/lists/JavaVersionList.h b/logic/lists/JavaVersionList.h
index 23bccfe4..4826ca0c 100644
--- a/logic/lists/JavaVersionList.h
+++ b/logic/lists/JavaVersionList.h
@@ -64,11 +64,11 @@ public:
virtual BaseVersionPtr getTopRecommended() const;
virtual QVariant data(const QModelIndex &index, int role) const;
- virtual QVariant headerData(int section, Qt::Orientation orientation,
- int role) const;
+ virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const;
virtual int columnCount(const QModelIndex &parent) const;
-public slots:
+public
+slots:
virtual void updateListData(QList<BaseVersionPtr> versions);
protected:
diff --git a/logic/lists/LwjglVersionList.cpp b/logic/lists/LwjglVersionList.cpp
index 6bf401ec..3333e86c 100644
--- a/logic/lists/LwjglVersionList.cpp
+++ b/logic/lists/LwjglVersionList.cpp
@@ -20,7 +20,7 @@
#include <QtXml>
#include <QRegExp>
-#include <logger/QsLog.h>
+#include "logger/QsLog.h"
#define RSS_URL "http://sourceforge.net/api/file/index/project-id/58488/mtime/desc/rss"
diff --git a/logic/lists/LwjglVersionList.h b/logic/lists/LwjglVersionList.h
index 99712292..fa57e8eb 100644
--- a/logic/lists/LwjglVersionList.h
+++ b/logic/lists/LwjglVersionList.h
@@ -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
@@ -28,20 +28,30 @@ typedef std::shared_ptr<LWJGLVersion> PtrLWJGLVersion;
class LWJGLVersion : public QObject
{
Q_OBJECT
-
- LWJGLVersion(const QString &name, const QString &url, QObject *parent = 0) :
- QObject(parent), m_name(name), m_url(url) { }
+
+ LWJGLVersion(const QString &name, const QString &url, QObject *parent = 0)
+ : QObject(parent), m_name(name), m_url(url)
+ {
+ }
+
public:
-
+
static PtrLWJGLVersion Create(const QString &name, const QString &url, QObject *parent = 0)
{
return PtrLWJGLVersion(new LWJGLVersion(name, url, parent));
- };
-
- QString name() const { return m_name; }
-
- QString url() const { return m_url; }
-
+ }
+ ;
+
+ QString name() const
+ {
+ return m_name;
+ }
+
+ QString url() const
+ {
+ return m_url;
+ }
+
protected:
QString m_name;
QString m_url;
@@ -52,64 +62,87 @@ class LWJGLVersionList : public QAbstractListModel
Q_OBJECT
public:
explicit LWJGLVersionList(QObject *parent = 0);
-
- bool isLoaded() { return m_vlist.length() > 0; }
-
+
+ bool isLoaded()
+ {
+ return m_vlist.length() > 0;
+ }
+
const PtrLWJGLVersion getVersion(const QString &versionName);
- PtrLWJGLVersion at(int index) { return m_vlist[index]; }
- const PtrLWJGLVersion at(int index) const { return m_vlist[index]; }
-
- int count() const { return m_vlist.length(); }
-
+ PtrLWJGLVersion at(int index)
+ {
+ return m_vlist[index];
+ }
+ const PtrLWJGLVersion at(int index) const
+ {
+ return m_vlist[index];
+ }
+
+ int count() const
+ {
+ return m_vlist.length();
+ }
+
virtual QVariant data(const QModelIndex &index, int role) const;
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const;
- virtual int rowCount(const QModelIndex &parent) const { return count(); }
+ virtual int rowCount(const QModelIndex &parent) const
+ {
+ return count();
+ }
virtual int columnCount(const QModelIndex &parent) const;
-
+
virtual bool isLoading() const;
- virtual bool errored() const { return m_errored; }
-
- virtual QString lastErrorMsg() const { return m_lastErrorMsg; }
-
-public slots:
+ virtual bool errored() const
+ {
+ return m_errored;
+ }
+
+ virtual QString lastErrorMsg() const
+ {
+ return m_lastErrorMsg;
+ }
+
+public
+slots:
/*!
* Loads the version list.
* This is done asynchronously. On success, the loadListFinished() signal will
- * be emitted. The list model will be reset as well, resulting in the modelReset()
- * signal being emitted. Note that the model will be reset before loadListFinished() is emitted.
+ * be emitted. The list model will be reset as well, resulting in the modelReset()
+ * signal being emitted. Note that the model will be reset before loadListFinished() is
+ * emitted.
* If loading the list failed, the loadListFailed(QString msg),
* signal will be emitted.
*/
virtual void loadList();
-
+
signals:
/*!
* Emitted when the list either starts or finishes loading.
* \param loading Whether or not the list is loading.
*/
void loadingStateUpdated(bool loading);
-
+
void loadListFinished();
-
+
void loadListFailed(QString msg);
-
+
private:
QList<PtrLWJGLVersion> m_vlist;
-
+
QNetworkReply *m_netReply;
QNetworkReply *reply;
-
+
bool m_loading;
bool m_errored;
QString m_lastErrorMsg;
-
+
void failed(QString msg);
-
+
void finished();
-
+
void setLoading(bool loading);
-
-private slots:
+
+private
+slots:
virtual void netRequestComplete();
};
-
diff --git a/logic/lists/MinecraftVersionList.cpp b/logic/lists/MinecraftVersionList.cpp
index dd26714a..2a9c0d3b 100644
--- a/logic/lists/MinecraftVersionList.cpp
+++ b/logic/lists/MinecraftVersionList.cpp
@@ -1,4 +1,4 @@
-/* Copyright 2013 Andrew Okin
+/* Copyright 2013 MultiMC Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
*/
#include "MinecraftVersionList.h"
-#include <MultiMC.h>
+#include "MultiMC.h"
#include <QtXml>
diff --git a/logic/lists/MinecraftVersionList.h b/logic/lists/MinecraftVersionList.h
index ed68efbb..90b1ae86 100644
--- a/logic/lists/MinecraftVersionList.h
+++ b/logic/lists/MinecraftVersionList.h
@@ -1,9 +1,9 @@
-/* Copyright 2013 Andrew Okin
+/* Copyright 2013 MultiMC Contributors
*
* 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
@@ -32,43 +32,44 @@ class MinecraftVersionList : public BaseVersionList
Q_OBJECT
public:
friend class MCVListLoadTask;
-
+
explicit MinecraftVersionList(QObject *parent = 0);
-
+
virtual Task *getLoadTask();
virtual bool isLoaded();
virtual const BaseVersionPtr at(int i) const;
virtual int count() const;
virtual void sort();
-
+
virtual BaseVersionPtr getLatestStable() const;
-
+
protected:
QList<BaseVersionPtr> m_vlist;
-
+
bool m_loaded = false;
-
-protected slots:
+
+protected
+slots:
virtual void updateListData(QList<BaseVersionPtr> versions);
};
class MCVListLoadTask : public Task
{
Q_OBJECT
-
+
public:
explicit MCVListLoadTask(MinecraftVersionList *vlist);
~MCVListLoadTask();
-
+
virtual void executeTask();
-
-protected slots:
+
+protected
+slots:
void list_downloaded();
-
+
protected:
QNetworkReply *vlistReply;
MinecraftVersionList *m_list;
MinecraftVersion *m_currentStable;
QSet<QString> legacyWhitelist;
};
-
diff --git a/logic/net/ByteArrayDownload.cpp b/logic/net/ByteArrayDownload.cpp
index 25e6d51a..af5af8e9 100644
--- a/logic/net/ByteArrayDownload.cpp
+++ b/logic/net/ByteArrayDownload.cpp
@@ -1,6 +1,21 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "ByteArrayDownload.h"
#include "MultiMC.h"
-#include <logger/QsLog.h>
+#include "logger/QsLog.h"
ByteArrayDownload::ByteArrayDownload(QUrl url) : NetAction()
{
diff --git a/logic/net/ByteArrayDownload.h b/logic/net/ByteArrayDownload.h
index fc32dc04..0d90abc2 100644
--- a/logic/net/ByteArrayDownload.h
+++ b/logic/net/ByteArrayDownload.h
@@ -1,3 +1,18 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#pragma once
#include "NetAction.h"
diff --git a/logic/net/CacheDownload.cpp b/logic/net/CacheDownload.cpp
index f8769576..4fe4e68e 100644
--- a/logic/net/CacheDownload.cpp
+++ b/logic/net/CacheDownload.cpp
@@ -1,3 +1,18 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "MultiMC.h"
#include "CacheDownload.h"
#include <pathutils.h>
@@ -5,7 +20,7 @@
#include <QCryptographicHash>
#include <QFileInfo>
#include <QDateTime>
-#include <logger/QsLog.h>
+#include "logger/QsLog.h"
CacheDownload::CacheDownload(QUrl url, MetaEntryPtr entry)
: NetAction(), md5sum(QCryptographicHash::Md5)
@@ -33,12 +48,13 @@ void CacheDownload::start()
}
QLOG_INFO() << "Downloading " << m_url.toString();
QNetworkRequest request(m_url);
- if(m_entry->remote_changed_timestamp.size())
- request.setRawHeader(QString("If-Modified-Since").toLatin1(), m_entry->remote_changed_timestamp.toLatin1());
- if(m_entry->etag.size())
+ if (m_entry->remote_changed_timestamp.size())
+ request.setRawHeader(QString("If-Modified-Since").toLatin1(),
+ m_entry->remote_changed_timestamp.toLatin1());
+ if (m_entry->etag.size())
request.setRawHeader(QString("If-None-Match").toLatin1(), m_entry->etag.toLatin1());
- request.setHeader(QNetworkRequest::UserAgentHeader,"MultiMC/5.0 (Cached)");
+ request.setHeader(QNetworkRequest::UserAgentHeader, "MultiMC/5.0 (Cached)");
auto worker = MMC->qnam();
QNetworkReply *rep = worker->get(request);
@@ -91,7 +107,7 @@ void CacheDownload::downloadFinished()
QFileInfo output_file_info(m_target_path);
m_entry->etag = m_reply->rawHeader("ETag").constData();
- if(m_reply->hasRawHeader("Last-Modified"))
+ if (m_reply->hasRawHeader("Last-Modified"))
{
m_entry->remote_changed_timestamp = m_reply->rawHeader("Last-Modified").constData();
}
diff --git a/logic/net/CacheDownload.h b/logic/net/CacheDownload.h
index 1e70874c..2b9a5dd8 100644
--- a/logic/net/CacheDownload.h
+++ b/logic/net/CacheDownload.h
@@ -1,3 +1,18 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#pragma once
#include "NetAction.h"
diff --git a/logic/net/FileDownload.cpp b/logic/net/FileDownload.cpp
index eefdd4da..6b2aa66f 100644
--- a/logic/net/FileDownload.cpp
+++ b/logic/net/FileDownload.cpp
@@ -1,12 +1,25 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "MultiMC.h"
#include "FileDownload.h"
#include <pathutils.h>
#include <QCryptographicHash>
-#include <logger/QsLog.h>
-
+#include "logger/QsLog.h"
-FileDownload::FileDownload ( QUrl url, QString target_path )
- :NetAction()
+FileDownload::FileDownload(QUrl url, QString target_path) : NetAction()
{
m_url = url;
m_target_path = target_path;
@@ -18,15 +31,18 @@ FileDownload::FileDownload ( QUrl url, QString target_path )
void FileDownload::start()
{
QString filename = m_target_path;
- m_output_file.setFileName ( filename );
+ m_output_file.setFileName(filename);
// if there already is a file and md5 checking is in effect and it can be opened
- if ( m_output_file.exists() && m_output_file.open ( QIODevice::ReadOnly ) )
+ if (m_output_file.exists() && m_output_file.open(QIODevice::ReadOnly))
{
// check the md5 against the expected one
- QString hash = QCryptographicHash::hash ( m_output_file.readAll(), QCryptographicHash::Md5 ).toHex().constData();
+ QString hash =
+ QCryptographicHash::hash(m_output_file.readAll(), QCryptographicHash::Md5)
+ .toHex()
+ .constData();
m_output_file.close();
// skip this file if they match
- if ( m_check_md5 && hash == m_expected_md5 )
+ if (m_check_md5 && hash == m_expected_md5)
{
QLOG_INFO() << "Skipping " << m_url.toString() << ": md5 match.";
emit succeeded(index_within_job);
@@ -37,33 +53,35 @@ void FileDownload::start()
m_expected_md5 = hash;
}
}
- if(!ensureFilePathExists(filename))
+ if (!ensureFilePathExists(filename))
{
emit failed(index_within_job);
return;
}
-
+
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)");
-
+ QNetworkRequest request(m_url);
+ request.setRawHeader(QString("If-None-Match").toLatin1(), m_expected_md5.toLatin1());
+ request.setHeader(QNetworkRequest::UserAgentHeader, "MultiMC/5.0 (Uncached)");
+
auto worker = MMC->qnam();
- QNetworkReply * rep = worker->get ( request );
-
- 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 ) ) );
- connect ( rep, SIGNAL ( readyRead() ), SLOT ( downloadReadyRead() ) );
+ QNetworkReply *rep = worker->get(request);
+
+ 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)));
+ connect(rep, SIGNAL(readyRead()), SLOT(downloadReadyRead()));
}
-void FileDownload::downloadProgress ( qint64 bytesReceived, qint64 bytesTotal )
+void FileDownload::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
{
- emit progress (index_within_job, bytesReceived, bytesTotal );
+ emit progress(index_within_job, bytesReceived, bytesTotal);
}
-void FileDownload::downloadError ( QNetworkReply::NetworkError error )
+void FileDownload::downloadError(QNetworkReply::NetworkError error)
{
// error happened during download.
// TODO: log the reason why
@@ -73,7 +91,7 @@ void FileDownload::downloadError ( QNetworkReply::NetworkError error )
void FileDownload::downloadFinished()
{
// if the download succeeded
- if ( m_status != Job_Failed )
+ if (m_status != Job_Failed)
{
// nothing went wrong...
m_status = Job_Finished;
@@ -95,9 +113,9 @@ void FileDownload::downloadFinished()
void FileDownload::downloadReadyRead()
{
- if(!m_opened_for_saving)
+ if (!m_opened_for_saving)
{
- if ( !m_output_file.open ( QIODevice::WriteOnly ) )
+ if (!m_output_file.open(QIODevice::WriteOnly))
{
/*
* Can't open the file... the job failed
@@ -108,5 +126,5 @@ void FileDownload::downloadReadyRead()
}
m_opened_for_saving = true;
}
- m_output_file.write ( m_reply->readAll() );
+ m_output_file.write(m_reply->readAll());
}
diff --git a/logic/net/FileDownload.h b/logic/net/FileDownload.h
index 5f72587f..31e0259c 100644
--- a/logic/net/FileDownload.h
+++ b/logic/net/FileDownload.h
@@ -1,3 +1,18 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#pragma once
#include "NetAction.h"
diff --git a/logic/net/ForgeXzDownload.cpp b/logic/net/ForgeXzDownload.cpp
index 20279d99..6c9d7a60 100644
--- a/logic/net/ForgeXzDownload.cpp
+++ b/logic/net/ForgeXzDownload.cpp
@@ -1,3 +1,18 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "MultiMC.h"
#include "ForgeXzDownload.h"
#include <pathutils.h>
@@ -5,10 +20,9 @@
#include <QCryptographicHash>
#include <QFileInfo>
#include <QDateTime>
-#include <logger/QsLog.h>
+#include "logger/QsLog.h"
-ForgeXzDownload::ForgeXzDownload(QUrl url, MetaEntryPtr entry)
- : NetAction()
+ForgeXzDownload::ForgeXzDownload(QUrl url, MetaEntryPtr entry) : NetAction()
{
QString urlstr = url.toString();
urlstr.append(".pack.xz");
@@ -35,7 +49,7 @@ void ForgeXzDownload::start()
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)");
+ request.setHeader(QNetworkRequest::UserAgentHeader, "MultiMC/5.0 (Cached)");
auto worker = MMC->qnam();
QNetworkReply *rep = worker->get(request);
@@ -96,7 +110,7 @@ void ForgeXzDownload::downloadFinished()
void ForgeXzDownload::downloadReadyRead()
{
-
+
if (!m_opened_for_saving)
{
if (!m_pack200_xz_file.open())
@@ -154,7 +168,7 @@ void ForgeXzDownload::decompressAndInstall()
{
if (b.in_pos == b.in_size)
{
- b.in_size = m_pack200_xz_file.read((char*)in, sizeof(in));
+ b.in_size = m_pack200_xz_file.read((char *)in, sizeof(in));
b.in_pos = 0;
}
@@ -162,7 +176,7 @@ void ForgeXzDownload::decompressAndInstall()
if (b.out_pos == sizeof(out))
{
- if (pack200_file.write((char*)out, b.out_pos) != b.out_pos)
+ if (pack200_file.write((char *)out, b.out_pos) != b.out_pos)
{
// msg = "Write error\n";
xz_dec_end(s);
@@ -182,7 +196,7 @@ void ForgeXzDownload::decompressAndInstall()
continue;
}
- if (pack200_file.write((char*)out, b.out_pos) != b.out_pos )
+ if (pack200_file.write((char *)out, b.out_pos) != b.out_pos)
{
// write error
pack200_file.close();
@@ -236,7 +250,7 @@ void ForgeXzDownload::decompressAndInstall()
}
}
}
-
+
// revert pack200
pack200_file.close();
QString pack_name = pack200_file.fileName();
@@ -244,16 +258,16 @@ void ForgeXzDownload::decompressAndInstall()
{
unpack_200(pack_name.toStdString(), m_target_path.toStdString());
}
- catch(std::runtime_error & err)
+ catch (std::runtime_error &err)
{
QLOG_ERROR() << "Error unpacking " << pack_name.toUtf8() << " : " << err.what();
QFile f(m_target_path);
- if(f.exists())
+ if (f.exists())
f.remove();
emit failed(index_within_job);
return;
}
-
+
QFile jar_file(m_target_path);
if (!jar_file.open(QIODevice::ReadOnly))
@@ -263,10 +277,10 @@ void ForgeXzDownload::decompressAndInstall()
return;
}
m_entry->md5sum = QCryptographicHash::hash(jar_file.readAll(), QCryptographicHash::Md5)
- .toHex()
- .constData();
+ .toHex()
+ .constData();
jar_file.close();
-
+
QFileInfo output_file_info(m_target_path);
m_entry->etag = m_reply->rawHeader("ETag").constData();
m_entry->local_changed_timestamp =
diff --git a/logic/net/ForgeXzDownload.h b/logic/net/ForgeXzDownload.h
index 0b73711e..9f1bb029 100644
--- a/logic/net/ForgeXzDownload.h
+++ b/logic/net/ForgeXzDownload.h
@@ -1,3 +1,18 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#pragma once
#include "NetAction.h"
diff --git a/logic/net/HttpMetaCache.cpp b/logic/net/HttpMetaCache.cpp
index 5ba5b98d..29007951 100644
--- a/logic/net/HttpMetaCache.cpp
+++ b/logic/net/HttpMetaCache.cpp
@@ -1,3 +1,18 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "MultiMC.h"
#include "HttpMetaCache.h"
#include <pathutils.h>
@@ -9,7 +24,7 @@
#include <QDateTime>
#include <QCryptographicHash>
-#include <logger/QsLog.h>
+#include "logger/QsLog.h"
#include <QJsonDocument>
#include <QJsonArray>
@@ -20,14 +35,12 @@ QString MetaEntry::getFullPath()
return PathCombine(MMC->metacache()->getBasePath(base), path);
}
-
-HttpMetaCache::HttpMetaCache(QString path)
- :QObject()
+HttpMetaCache::HttpMetaCache(QString path) : QObject()
{
m_index_file = path;
saveBatchingTimer.setSingleShot(true);
saveBatchingTimer.setTimerType(Qt::VeryCoarseTimer);
- connect(&saveBatchingTimer,SIGNAL(timeout()),SLOT(SaveNow()));
+ connect(&saveBatchingTimer, SIGNAL(timeout()), SLOT(SaveNow()));
}
HttpMetaCache::~HttpMetaCache()
@@ -36,58 +49,61 @@ HttpMetaCache::~HttpMetaCache()
SaveNow();
}
-MetaEntryPtr HttpMetaCache::getEntry ( QString base, QString resource_path )
+MetaEntryPtr HttpMetaCache::getEntry(QString base, QString resource_path)
{
// no base. no base path. can't store
- if(!m_entries.contains(base))
+ if (!m_entries.contains(base))
{
// TODO: log problem
return MetaEntryPtr();
}
- EntryMap & map = m_entries[base];
- if(map.entry_list.contains(resource_path))
+ EntryMap &map = m_entries[base];
+ if (map.entry_list.contains(resource_path))
{
return map.entry_list[resource_path];
}
return MetaEntryPtr();
}
-MetaEntryPtr HttpMetaCache::resolveEntry ( QString base, QString resource_path, QString expected_etag )
+MetaEntryPtr HttpMetaCache::resolveEntry(QString base, QString resource_path,
+ QString expected_etag)
{
auto entry = getEntry(base, resource_path);
// it's not present? generate a default stale entry
- if(!entry)
+ if (!entry)
{
return staleEntry(base, resource_path);
}
-
- auto & selected_base = m_entries[base];
+
+ auto &selected_base = m_entries[base];
QString real_path = PathCombine(selected_base.base_path, resource_path);
QFileInfo finfo(real_path);
-
+
// is the file really there? if not -> stale
- if(!finfo.isFile() || !finfo.isReadable())
+ if (!finfo.isFile() || !finfo.isReadable())
{
// if the file doesn't exist, we disown the entry
selected_base.entry_list.remove(resource_path);
return staleEntry(base, resource_path);
}
-
- if(!expected_etag.isEmpty() && expected_etag != entry->etag)
+
+ if (!expected_etag.isEmpty() && expected_etag != entry->etag)
{
// if the etag doesn't match expected, we disown the entry
selected_base.entry_list.remove(resource_path);
return staleEntry(base, resource_path);
}
-
+
// if the file changed, check md5sum
qint64 file_last_changed = finfo.lastModified().toUTC().toMSecsSinceEpoch();
- if(file_last_changed != entry->local_changed_timestamp)
+ if (file_last_changed != entry->local_changed_timestamp)
{
QFile input(real_path);
input.open(QIODevice::ReadOnly);
- QString md5sum = QCryptographicHash::hash(input.readAll(), QCryptographicHash::Md5).toHex().constData();
- if(entry->md5sum != md5sum)
+ QString md5sum = QCryptographicHash::hash(input.readAll(), QCryptographicHash::Md5)
+ .toHex()
+ .constData();
+ if (entry->md5sum != md5sum)
{
selected_base.entry_list.remove(resource_path);
return staleEntry(base, resource_path);
@@ -101,14 +117,15 @@ MetaEntryPtr HttpMetaCache::resolveEntry ( QString base, QString resource_path,
return entry;
}
-bool HttpMetaCache::updateEntry ( MetaEntryPtr stale_entry )
+bool HttpMetaCache::updateEntry(MetaEntryPtr stale_entry)
{
- if(!m_entries.contains(stale_entry->base))
+ if (!m_entries.contains(stale_entry->base))
{
- QLOG_ERROR() << "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)
+ if (stale_entry->stale)
{
QLOG_ERROR() << "Cannot add stale entry: " << stale_entry->getFullPath().toLocal8Bit();
return false;
@@ -127,10 +144,10 @@ MetaEntryPtr HttpMetaCache::staleEntry(QString base, QString resource_path)
return MetaEntryPtr(foo);
}
-void HttpMetaCache::addBase ( QString base, QString base_root )
+void HttpMetaCache::addBase(QString base, QString base_root)
{
// TODO: report error
- if(m_entries.contains(base))
+ if (m_entries.contains(base))
return;
// TODO: check if the base path is valid
EntryMap foo;
@@ -138,57 +155,57 @@ void HttpMetaCache::addBase ( QString base, QString base_root )
m_entries[base] = foo;
}
-QString HttpMetaCache::getBasePath ( QString base )
+QString HttpMetaCache::getBasePath(QString base)
{
- if(m_entries.contains(base))
+ if (m_entries.contains(base))
{
return m_entries[base].base_path;
}
return QString();
}
-
void HttpMetaCache::Load()
{
QFile index(m_index_file);
- if(!index.open(QIODevice::ReadOnly))
+ if (!index.open(QIODevice::ReadOnly))
return;
-
+
QJsonDocument json = QJsonDocument::fromJson(index.readAll());
- if(!json.isObject())
+ if (!json.isObject())
return;
auto root = json.object();
// check file version first
- auto version_val =root.value("version");
- if(!version_val.isString())
+ auto version_val = root.value("version");
+ if (!version_val.isString())
return;
- if(version_val.toString() != "1")
+ if (version_val.toString() != "1")
return;
-
+
// read the entry array
- auto entries_val =root.value("entries");
- if(!entries_val.isArray())
+ auto entries_val = root.value("entries");
+ if (!entries_val.isArray())
return;
QJsonArray array = entries_val.toArray();
- for(auto element: array)
+ for (auto element : array)
{
- if(!element.isObject())
+ if (!element.isObject())
return;
auto element_obj = element.toObject();
QString base = element_obj.value("base").toString();
- if(!m_entries.contains(base))
+ if (!m_entries.contains(base))
continue;
- auto & entrymap = m_entries[base];
+ auto &entrymap = m_entries[base];
auto foo = new MetaEntry;
foo->base = base;
QString path = foo->path = element_obj.value("path").toString();
foo->md5sum = element_obj.value("md5sum").toString();
foo->etag = element_obj.value("etag").toString();
foo->local_changed_timestamp = element_obj.value("last_changed_timestamp").toDouble();
- foo->remote_changed_timestamp = element_obj.value("remote_changed_timestamp").toString();
+ foo->remote_changed_timestamp =
+ element_obj.value("remote_changed_timestamp").toString();
// presumed innocent until closer examination
foo->stale = false;
- entrymap.entry_list[path] = MetaEntryPtr( foo );
+ entrymap.entry_list[path] = MetaEntryPtr(foo);
}
}
@@ -202,33 +219,35 @@ void HttpMetaCache::SaveEventually()
void HttpMetaCache::SaveNow()
{
QSaveFile tfile(m_index_file);
- if(!tfile.open(QIODevice::WriteOnly | QIODevice::Truncate))
+ if (!tfile.open(QIODevice::WriteOnly | QIODevice::Truncate))
return;
QJsonObject toplevel;
- toplevel.insert("version",QJsonValue(QString("1")));
+ toplevel.insert("version", QJsonValue(QString("1")));
QJsonArray entriesArr;
- for(auto group : m_entries)
+ for (auto group : m_entries)
{
- for(auto entry : group.entry_list)
+ for (auto entry : group.entry_list)
{
QJsonObject entryObj;
entryObj.insert("base", QJsonValue(entry->base));
entryObj.insert("path", QJsonValue(entry->path));
entryObj.insert("md5sum", QJsonValue(entry->md5sum));
entryObj.insert("etag", QJsonValue(entry->etag));
- entryObj.insert("last_changed_timestamp", QJsonValue(double(entry->local_changed_timestamp)));
- if(!entry->remote_changed_timestamp.isEmpty())
- entryObj.insert("remote_changed_timestamp", QJsonValue(entry->remote_changed_timestamp));
+ entryObj.insert("last_changed_timestamp",
+ QJsonValue(double(entry->local_changed_timestamp)));
+ if (!entry->remote_changed_timestamp.isEmpty())
+ entryObj.insert("remote_changed_timestamp",
+ QJsonValue(entry->remote_changed_timestamp));
entriesArr.append(entryObj);
}
}
- toplevel.insert("entries",entriesArr);
+ toplevel.insert("entries", entriesArr);
QJsonDocument doc(toplevel);
QByteArray jsonData = doc.toJson();
qint64 result = tfile.write(jsonData);
- if(result == -1)
+ if (result == -1)
return;
- if(result != jsonData.size())
+ if (result != jsonData.size())
return;
tfile.commit();
}
diff --git a/logic/net/HttpMetaCache.h b/logic/net/HttpMetaCache.h
index 557d9298..e91d2684 100644
--- a/logic/net/HttpMetaCache.h
+++ b/logic/net/HttpMetaCache.h
@@ -1,3 +1,18 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#pragma once
#include <QString>
#include <QSharedPointer>
diff --git a/logic/net/LoginTask.cpp b/logic/net/LoginTask.cpp
index 5717aa9f..4a789bb4 100644
--- a/logic/net/LoginTask.cpp
+++ b/logic/net/LoginTask.cpp
@@ -100,7 +100,9 @@ void LoginTask::processYggdrasilReply(QNetworkReply *reply)
processReply(reply, &LoginTask::parseYggdrasilReply, &LoginTask::parseYggdrasilError);
}
-void LoginTask::processReply(QNetworkReply *reply, std::function<void (LoginTask*, QByteArray)> parser, std::function<QString (LoginTask*, QNetworkReply*)> errorHandler)
+void LoginTask::processReply(QNetworkReply *reply,
+ std::function<void(LoginTask *, QByteArray)> parser,
+ std::function<QString(LoginTask *, QNetworkReply *)> errorHandler)
{
if (netReply != reply)
return;
@@ -147,7 +149,7 @@ QString LoginTask::parseLegacyError(QNetworkReply *reply)
case 503:
return tr("The login servers are currently unavailable. Check "
- "http://help.mojang.com/ for more info.");
+ "http://help.mojang.com/ for more info.");
default:
QLOG_DEBUG() << "Login failed with QNetworkReply code:" << reply->error();
@@ -161,7 +163,8 @@ QString LoginTask::parseYggdrasilError(QNetworkReply *reply)
QJsonParseError jsonError;
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError);
- // If there are JSON errors fall back to using the legacy error handling using HTTP status codes
+ // If there are JSON errors fall back to using the legacy error handling using HTTP status
+ // codes
if (jsonError.error != QJsonParseError::NoError)
{
return parseLegacyError(reply);
@@ -174,10 +177,10 @@ QString LoginTask::parseYggdrasilError(QNetworkReply *reply)
QJsonObject root = jsonDoc.object();
- //QString error = root.value("error").toString();
+ // QString error = root.value("error").toString();
QString errorMessage = root.value("errorMessage").toString();
- if(errorMessage.isEmpty())
+ if (errorMessage.isEmpty())
{
return parseLegacyError(reply);
}
@@ -230,14 +233,14 @@ void LoginTask::yggdrasilLogin()
"accessToken": "random access token", // hexadecimal
"clientToken": "client identifier", // identical to the one received
"availableProfiles": [ // only present if the agent field was received
- {
- "id": "profile identifier", // hexadecimal
- "name": "player name"
- }
+ {
+ "id": "profile identifier", // hexadecimal
+ "name": "player name"
+ }
],
"selectedProfile": { // only present if the agent field was received
- "id": "profile identifier",
- "name": "player name"
+ "id": "profile identifier",
+ "name": "player name"
}
}
*/
@@ -264,7 +267,7 @@ void LoginTask::parseYggdrasilReply(QByteArray data)
QString playerID;
QString playerName;
auto selectedProfile = root.value("selectedProfile");
- if(selectedProfile.isObject())
+ if (selectedProfile.isObject())
{
auto selectedProfileO = selectedProfile.toObject();
playerID = selectedProfileO.value("id").toString();
@@ -281,7 +284,7 @@ void LoginTask::parseYggdrasilReply(QByteArray data)
QString client_id;
};
*/
-
+
result = {uInfo.username, sessionID, playerName, playerID, accessToken};
emitSucceeded();
}
diff --git a/logic/net/LoginTask.h b/logic/net/LoginTask.h
index aa925999..26ac0808 100644
--- a/logic/net/LoginTask.h
+++ b/logic/net/LoginTask.h
@@ -45,7 +45,8 @@ public:
return result;
}
-protected slots:
+protected
+slots:
void legacyLogin();
void processLegacyReply(QNetworkReply *reply);
void parseLegacyReply(QByteArray data);
@@ -56,7 +57,8 @@ protected slots:
void parseYggdrasilReply(QByteArray data);
QString parseYggdrasilError(QNetworkReply *reply);
- void processReply(QNetworkReply *reply, std::function<void(LoginTask*, QByteArray)>, std::function<QString(LoginTask*, QNetworkReply*)>);
+ void processReply(QNetworkReply *reply, std::function<void(LoginTask *, QByteArray)>,
+ std::function<QString(LoginTask *, QNetworkReply *)>);
protected:
void executeTask();
diff --git a/logic/net/NetAction.h b/logic/net/NetAction.h
index b7c922f5..c96d8f8f 100644
--- a/logic/net/NetAction.h
+++ b/logic/net/NetAction.h
@@ -1,3 +1,18 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#pragma once
#include <QObject>
@@ -42,12 +57,14 @@ signals:
void succeeded(int index);
void failed(int index);
-protected slots:
+protected
+slots:
virtual void downloadProgress(qint64 bytesReceived, qint64 bytesTotal) = 0;
virtual void downloadError(QNetworkReply::NetworkError error) = 0;
virtual void downloadFinished() = 0;
virtual void downloadReadyRead() = 0;
-public slots:
+public
+slots:
virtual void start() = 0;
};
diff --git a/logic/net/NetJob.cpp b/logic/net/NetJob.cpp
index c7ca4409..21c6d3f7 100644
--- a/logic/net/NetJob.cpp
+++ b/logic/net/NetJob.cpp
@@ -1,3 +1,18 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "NetJob.h"
#include "pathutils.h"
#include "MultiMC.h"
@@ -5,7 +20,7 @@
#include "ByteArrayDownload.h"
#include "CacheDownload.h"
-#include <logger/QsLog.h>
+#include "logger/QsLog.h"
void NetJob::partSucceeded(int index)
{
@@ -15,7 +30,7 @@ void NetJob::partSucceeded(int index)
num_succeeded++;
QLOG_INFO() << m_job_name.toLocal8Bit() << "progress:" << num_succeeded << "/"
- << downloads.size();
+ << downloads.size();
emit filesProgress(num_succeeded, num_failed, downloads.size());
if (num_failed + num_succeeded == downloads.size())
@@ -50,7 +65,7 @@ void NetJob::partFailed(int index)
else
{
QLOG_ERROR() << "Part" << index << "failed, restarting (" << downloads[index]->m_url
- << ")";
+ << ")";
// restart the job
slot.failures++;
downloads[index]->start();
diff --git a/logic/net/NetJob.h b/logic/net/NetJob.h
index 01d12e60..c5c0d00c 100644
--- a/logic/net/NetJob.h
+++ b/logic/net/NetJob.h
@@ -1,3 +1,18 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#pragma once
#include <QtNetwork>
#include <QLabel>
@@ -18,10 +33,9 @@ class NetJob : public ProgressProvider
public:
explicit NetJob(QString job_name) : ProgressProvider(), m_job_name(job_name) {};
- template <typename T>
- bool addNetAction(T action)
+ template <typename T> bool addNetAction(T action)
{
- NetActionPtr base = std::static_pointer_cast<NetAction>(action);
+ NetActionPtr base = std::static_pointer_cast<NetAction>(action);
base->index_within_job = downloads.size();
downloads.append(action);
parts_progress.append(part_info());
diff --git a/logic/net/S3ListBucket.cpp b/logic/net/S3ListBucket.cpp
index 643c3224..89dff951 100644
--- a/logic/net/S3ListBucket.cpp
+++ b/logic/net/S3ListBucket.cpp
@@ -1,6 +1,21 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "S3ListBucket.h"
#include "MultiMC.h"
-#include <logger/QsLog.h>
+#include "logger/QsLog.h"
#include <QUrlQuery>
#include <qxmlstream.h>
#include <QDomDocument>
@@ -123,7 +138,7 @@ void S3ListBucket::processValidReply()
emit failed(index_within_job);
return;
}
- if(is_truncated)
+ if (is_truncated)
{
current_marker = objects.last().Key;
bytesSoFar += m_reply->size();
diff --git a/logic/net/S3ListBucket.h b/logic/net/S3ListBucket.h
index f054532d..e7c5e05c 100644
--- a/logic/net/S3ListBucket.h
+++ b/logic/net/S3ListBucket.h
@@ -1,3 +1,18 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#pragma once
#include "NetAction.h"
diff --git a/logic/tasks/ProgressProvider.h b/logic/tasks/ProgressProvider.h
index e158eb54..f6f2906a 100644
--- a/logic/tasks/ProgressProvider.h
+++ b/logic/tasks/ProgressProvider.h
@@ -1,20 +1,41 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * 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
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#pragma once
+
#include <QObject>
+
class ProgressProvider : public QObject
{
Q_OBJECT
protected:
- explicit ProgressProvider(QObject* parent = 0): QObject(parent){}
+ explicit ProgressProvider(QObject *parent = 0) : QObject(parent)
+ {
+ }
signals:
void started();
void progress(qint64 current, qint64 total);
void succeeded();
void failed(QString reason);
void status(QString status);
+
public:
virtual QString getStatus() const = 0;
virtual void getProgress(qint64 &current, qint64 &total) = 0;
virtual bool isRunning() const = 0;
-public slots:
+public
+slots:
virtual void start() = 0;
};
diff --git a/logic/tasks/Task.cpp b/logic/tasks/Task.cpp
index 2f137c55..47214723 100644
--- a/logic/tasks/Task.cpp
+++ b/logic/tasks/Task.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
@@ -14,12 +14,10 @@
*/
#include "Task.h"
-#include <logger/QsLog.h>
+#include "logger/QsLog.h"
-Task::Task(QObject *parent) :
- ProgressProvider(parent)
+Task::Task(QObject *parent) : ProgressProvider(parent)
{
-
}
QString Task::getStatus() const
@@ -39,13 +37,12 @@ void Task::setProgress(int new_progress)
emit progress(new_progress, 100);
}
-void Task::getProgress(qint64& current, qint64& total)
+void Task::getProgress(qint64 &current, qint64 &total)
{
current = m_progress;
total = 100;
}
-
void Task::start()
{
m_running = true;
@@ -66,7 +63,6 @@ void Task::emitSucceeded()
emit succeeded();
}
-
bool Task::isRunning() const
{
return m_running;
diff --git a/logic/tasks/Task.h b/logic/tasks/Task.h
index cfe71c51..980b2af8 100644
--- a/logic/tasks/Task.h
+++ b/logic/tasks/Task.h
@@ -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
@@ -24,24 +24,26 @@ class Task : public ProgressProvider
Q_OBJECT
public:
explicit Task(QObject *parent = 0);
-
+
virtual QString getStatus() const;
- virtual void getProgress(qint64& current, qint64& total);
+ virtual void getProgress(qint64 &current, qint64 &total);
virtual bool isRunning() const;
-
-public slots:
+
+public
+slots:
virtual void start();
-
+
protected:
virtual void executeTask() = 0;
-
+
virtual void emitSucceeded();
virtual void emitFailed(QString reason);
-protected slots:
- void setStatus(const QString& status);
+protected
+slots:
+ void setStatus(const QString &status);
void setProgress(int progress);
-
+
protected:
QString m_status;
int m_progress = 0;