summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/stdinstance/CMakeLists.txt49
-rw-r--r--plugins/stdinstance/stdinstance.cpp54
-rw-r--r--plugins/stdinstance/stdinstance.h36
-rw-r--r--plugins/stdinstance/stdinstance.json8
-rw-r--r--plugins/stdinstance/stdinstancetype.cpp58
-rw-r--r--plugins/stdinstance/stdinstancetype.h42
6 files changed, 247 insertions, 0 deletions
diff --git a/plugins/stdinstance/CMakeLists.txt b/plugins/stdinstance/CMakeLists.txt
new file mode 100644
index 00000000..0bb466ec
--- /dev/null
+++ b/plugins/stdinstance/CMakeLists.txt
@@ -0,0 +1,49 @@
+project(stdinstance)
+
+ADD_DEFINITIONS(-DQT_PLUGIN)
+
+# Find Qt
+find_package(Qt5Core REQUIRED)
+find_package(Qt5Network REQUIRED)
+
+# Include Qt headers.
+include_directories(${Qt5Base_INCLUDE_DIRS})
+include_directories(${Qt5Network_INCLUDE_DIRS})
+
+# Include the Java library.
+include_directories(${CMAKE_SOURCE_DIR}/java)
+
+# Include utils library headers.
+include_directories(${CMAKE_SOURCE_DIR}/libutil/include)
+
+# Include settings library headers.
+include_directories(${CMAKE_SOURCE_DIR}/libsettings/include)
+
+# Include instance library headers.
+include_directories(${CMAKE_SOURCE_DIR}libinstance/include)
+
+SET(STDINST_HEADERS
+stdinstancetype.h
+stdinstance.h
+)
+
+SET(STDINST_SOURCES
+stdinstancetype.cpp
+stdinstance.cpp
+)
+
+add_library(stdinstance SHARED ${STDINST_SOURCES} ${STDINST_HEADERS})
+
+set_target_properties(stdinstance PROPERTIES PREFIX "")
+set_target_properties(stdinstance PROPERTIES RUNTIME_OUTPUT_DIRECTORY "..")
+
+qt5_use_modules(stdinstance Core Network)
+target_link_libraries(stdinstance
+quazip
+patchlib
+
+# Link the util, settings, and instance libraries.
+libmmcutil
+libmmcsettings
+libmmcinst
+)
diff --git a/plugins/stdinstance/stdinstance.cpp b/plugins/stdinstance/stdinstance.cpp
new file mode 100644
index 00000000..12d86bbc
--- /dev/null
+++ b/plugins/stdinstance/stdinstance.cpp
@@ -0,0 +1,54 @@
+/* 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 "stdinstance.h"
+
+#include <QFileInfo>
+
+#include <javautils.h>
+
+StdInstance::StdInstance(const QString &rootDir, QObject *parent) :
+ Instance(rootDir, parent)
+{
+
+}
+
+bool StdInstance::shouldUpdateCurrentVersion()
+{
+ QFileInfo jar(mcJar());
+ return jar.lastModified().toUTC().toMSecsSinceEpoch() != lastVersionUpdate();
+}
+
+void StdInstance::updateCurrentVersion(bool keepCurrent)
+{
+ QFileInfo jar(mcJar());
+
+ if(!jar.exists())
+ {
+ setLastVersionUpdate(0);
+ setCurrentVersion("Unknown");
+ return;
+ }
+
+ qint64 time = jar.lastModified().toUTC().toMSecsSinceEpoch();
+
+ setLastVersionUpdate(time);
+ if (!keepCurrent)
+ {
+ // TODO: Implement GetMinecraftJarVersion function.
+ QString newVersion = "Unknown";//javautils::GetMinecraftJarVersion(jar.absoluteFilePath());
+ setCurrentVersion(newVersion);
+ }
+}
diff --git a/plugins/stdinstance/stdinstance.h b/plugins/stdinstance/stdinstance.h
new file mode 100644
index 00000000..d812a9b0
--- /dev/null
+++ b/plugins/stdinstance/stdinstance.h
@@ -0,0 +1,36 @@
+/* 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.
+ */
+
+#ifndef STDINSTANCE_H
+#define STDINSTANCE_H
+
+#include <instance.h>
+
+class StdInstance : public Instance
+{
+ Q_OBJECT
+public:
+ explicit StdInstance(const QString &rootDir, QObject *parent = 0);
+
+ virtual bool shouldUpdateCurrentVersion();
+
+ virtual void updateCurrentVersion(bool keepCurrent);
+
+ ////// TIMESTAMPS //////
+ virtual qint64 lastVersionUpdate() { return getField("lastVersionUpdate", 0).value<qint64>(); }
+ virtual void setLastVersionUpdate(qint64 val) { setField("lastVersionUpdate", val); }
+};
+
+#endif // STDINSTANCE_H
diff --git a/plugins/stdinstance/stdinstance.json b/plugins/stdinstance/stdinstance.json
new file mode 100644
index 00000000..704f0b73
--- /dev/null
+++ b/plugins/stdinstance/stdinstance.json
@@ -0,0 +1,8 @@
+{
+ "api": "MultiMC5-API-1",
+
+ "name": "Standard Instance Plugin",
+ "summary": "A plugin that provides standard Minecraft instances.",
+ "description": "This is a built-in plugin that provides the standard Minecraft instance.",
+ "version": "0.1"
+}
diff --git a/plugins/stdinstance/stdinstancetype.cpp b/plugins/stdinstance/stdinstancetype.cpp
new file mode 100644
index 00000000..5a3a6649
--- /dev/null
+++ b/plugins/stdinstance/stdinstancetype.cpp
@@ -0,0 +1,58 @@
+/* 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 "stdinstancetype.h"
+
+#include <QDir>
+#include <QFileInfo>
+
+#include "stdinstance.h"
+
+StdInstanceType::StdInstanceType(QObject *parent) :
+ QObject(parent)
+{
+
+}
+
+InstanceLoader::InstTypeError StdInstanceType::createInstance(Instance *&inst,
+ const QString &instDir) const
+{
+ QFileInfo rootDir(instDir);
+
+ if (!rootDir.exists() && !QDir().mkdir(rootDir.path()))
+ {
+ return InstanceLoader::CantCreateDir;
+ }
+
+ StdInstance *stdInst = new StdInstance(instDir);
+
+ // TODO: Verify that the instance is valid.
+
+ inst = stdInst;
+
+ return InstanceLoader::NoError;
+}
+
+InstanceLoader::InstTypeError StdInstanceType::loadInstance(Instance *&inst,
+ const QString &instDir) const
+{
+ StdInstance *stdInst = new StdInstance(instDir);
+
+ // TODO: Verify that the instance is valid.
+
+ inst = stdInst;
+
+ return InstanceLoader::NoError;
+}
diff --git a/plugins/stdinstance/stdinstancetype.h b/plugins/stdinstance/stdinstancetype.h
new file mode 100644
index 00000000..b8382a97
--- /dev/null
+++ b/plugins/stdinstance/stdinstancetype.h
@@ -0,0 +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.
+ */
+
+#ifndef STDINSTANCETYPE_H
+#define STDINSTANCETYPE_H
+
+#include <instancetypeinterface.h>
+
+#define StdInstanceType_IID "net.forkk.MultiMC.StdInstanceType/0.1"
+
+class StdInstanceType : public QObject, InstanceTypeInterface
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID StdInstanceType_IID FILE "stdinstance.json")
+ Q_INTERFACES(InstanceTypeInterface)
+public:
+ explicit StdInstanceType(QObject *parent = 0);
+
+ virtual QString typeID() const { return "net.forkk.MultiMC.StdInstance"; }
+
+ virtual QString displayName() const { return "Standard Instance"; }
+
+ virtual QString description() const { return "A standard Minecraft instance."; }
+
+ virtual InstanceLoader::InstTypeError createInstance(Instance *&inst, const QString &instDir) const;
+
+ virtual InstanceLoader::InstTypeError loadInstance(Instance *&inst, const QString &instDir) const;
+};
+
+#endif // STDINSTANCETYPE_H