summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt113
-rw-r--r--data/plugin/instancetypeplugin.h41
-rw-r--r--data/plugin/pluginmanager.cpp81
-rw-r--r--data/plugin/pluginmanager.h17
-rw-r--r--gui/mainwindow.cpp16
-rw-r--r--gui/mainwindow.h2
-rw-r--r--gui/settingsdialog.cpp2
-rw-r--r--libinstance/CMakeLists.txt50
-rw-r--r--libinstance/include/instance.h (renamed from data/inst/instance.h)14
-rw-r--r--libinstance/include/instancelist.h (renamed from data/inst/instancelist.h)6
-rw-r--r--libinstance/include/instanceloader.h (renamed from data/inst/instanceloader.h)28
-rw-r--r--libinstance/include/instancetypeinterface.h (renamed from data/inst/instancetype.h)13
-rw-r--r--libinstance/include/instversion.h (renamed from data/version/instversion.h)4
-rw-r--r--libinstance/include/instversionlist.h (renamed from data/version/instversionlist.h)4
-rw-r--r--libinstance/include/libinstance_config.h (renamed from util/osutils.cpp)18
-rw-r--r--libinstance/src/instance.cpp (renamed from data/inst/instance.cpp)10
-rw-r--r--libinstance/src/instancelist.cpp (renamed from data/inst/instancelist.cpp)32
-rw-r--r--libinstance/src/instanceloader.cpp (renamed from data/inst/instanceloader.cpp)25
-rw-r--r--libinstance/src/instversion.cpp (renamed from data/version/instversion.cpp)4
-rw-r--r--libinstance/src/instversionlist.cpp (renamed from data/version/instversionlist.cpp)2
-rw-r--r--libsettings/CMakeLists.txt30
-rw-r--r--libsettings/include/appsettings.h (renamed from data/appsettings.h)21
-rw-r--r--libsettings/include/libsettings_config.h27
-rw-r--r--libsettings/src/appsettings.cpp (renamed from data/appsettings.cpp)2
-rw-r--r--libutil/CMakeLists.txt38
-rw-r--r--libutil/include/apputils.h (renamed from util/apputils.h)0
-rw-r--r--libutil/include/inifile.h (renamed from data/inifile.h)4
-rw-r--r--libutil/include/libutil_config.h (renamed from plugins/stdinstance/stdinstplugin.cpp)18
-rw-r--r--libutil/include/osutils.h (renamed from util/osutils.h)3
-rw-r--r--libutil/include/pathutils.h (renamed from util/pathutils.h)8
-rw-r--r--libutil/include/siglist.h (renamed from data/siglist.h)0
-rw-r--r--libutil/include/siglist_impl.h (renamed from data/siglist_impl.h)0
-rw-r--r--libutil/src/inifile.cpp (renamed from data/inifile.cpp)2
-rw-r--r--libutil/src/osutils.cpp (renamed from data/inst/instancetype.cpp)8
-rw-r--r--libutil/src/pathutils.cpp (renamed from util/pathutils.cpp)2
-rw-r--r--main.cpp4
-rw-r--r--plugins/stdinstance/CMakeLists.txt28
-rw-r--r--plugins/stdinstance/stdinstance.cpp5
-rw-r--r--plugins/stdinstance/stdinstance.h2
-rw-r--r--plugins/stdinstance/stdinstance.json9
-rw-r--r--plugins/stdinstance/stdinstancetype.cpp2
-rw-r--r--plugins/stdinstance/stdinstancetype.h8
-rw-r--r--plugins/stdinstance/stdinstplugin.h33
43 files changed, 420 insertions, 316 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5e8f7a90..eea4ded5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,6 +4,7 @@ project(MultiMC)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
+SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
#### Check for machine endianness ####
INCLUDE(TestBigEndian)
@@ -32,9 +33,22 @@ add_subdirectory(quazip)
add_subdirectory(patchlib)
include_directories(patchlib)
-# add the java launcher
+# Add the java launcher
add_subdirectory(launcher)
+
+# Add the util library.
+add_subdirectory(libutil)
+include_directories(${LIBMMCUTIL_INCLUDE_DIR})
+
+# Add the settings library.
+add_subdirectory(libsettings)
+include_directories(${LIBMMCSETTINGS_INCLUDE_DIR})
+
+# Add the instance library.
+add_subdirectory(libinstance)
+include_directories(${LIBMMCINST_INCLUDE_DIR})
+
# Add the stdinstance plugin.
add_subdirectory(plugins/stdinstance)
@@ -97,43 +111,6 @@ message(STATUS "Job URL: ${MultiMC_JOB_URL}")
configure_file("${PROJECT_SOURCE_DIR}/config.h.in"
"${PROJECT_BINARY_DIR}/config.h")
-
-SET(MULTIMC_SOURCES
-main.cpp
-
-data/appsettings.cpp
-data/inifile.cpp
-data/version.cpp
-data/userinfo.cpp
-data/loginresponse.cpp
-
-data/inst/instanceloader.cpp
-data/inst/instancetype.cpp
-data/inst/instance.cpp
-data/inst/instancelist.cpp
-
-data/plugin/pluginmanager.cpp
-
-data/version/instversion.cpp
-data/version/instversionlist.cpp
-
-gui/mainwindow.cpp
-gui/modeditwindow.cpp
-gui/settingsdialog.cpp
-gui/newinstancedialog.cpp
-gui/logindialog.cpp
-gui/taskdialog.cpp
-
-util/pathutils.cpp
-util/osutils.cpp
-
-java/javautils.cpp
-java/annotations.cpp
-
-tasks/task.cpp
-tasks/logintask.cpp
-)
-
SET(MULTIMC_HEADERS
gui/mainwindow.h
gui/modeditwindow.h
@@ -142,28 +119,11 @@ gui/newinstancedialog.h
gui/logindialog.h
gui/taskdialog.h
-data/appsettings.h
-data/inifile.h
data/version.h
data/userinfo.h
data/loginresponse.h
-data/siglist.h
-data/siglist_impl.h
-
-data/inst/instanceloader.h
-data/inst/instancetype.h
-data/inst/instance.h
-data/inst/instancelist.h
data/plugin/pluginmanager.h
-data/plugin/instancetypeplugin.h
-
-data/version/instversion.h
-data/version/instversionlist.h
-
-util/apputils.h
-util/pathutils.h
-util/osutils.h
multimc_pragma.h
@@ -179,6 +139,29 @@ tasks/task.h
tasks/logintask.h
)
+SET(MULTIMC_SOURCES
+main.cpp
+
+data/version.cpp
+data/userinfo.cpp
+data/loginresponse.cpp
+
+data/plugin/pluginmanager.cpp
+
+gui/mainwindow.cpp
+gui/modeditwindow.cpp
+gui/settingsdialog.cpp
+gui/newinstancedialog.cpp
+gui/logindialog.cpp
+gui/taskdialog.cpp
+
+java/javautils.cpp
+java/annotations.cpp
+
+tasks/task.cpp
+tasks/logintask.cpp
+)
+
SET(MULTIMC5_UIS
gui/mainwindow.ui
gui/modeditwindow.ui
@@ -214,8 +197,10 @@ QT5_ADD_RESOURCES(MULTIMC_QRC multimc.qrc)
add_executable(MultiMC MACOSX_BUNDLE WIN32 ${MULTIMC_SOURCES} ${MULTIMC_HEADERS} ${MULTIMC_UI} ${MULTIMC_QRC})
qt5_use_modules(MultiMC Widgets Network)
-target_link_libraries(MultiMC quazip patchlib stdinstance ${MultiMC_LINK_ADDITIONAL_LIBS})
-add_dependencies(MultiMC MultiMCLauncher)
+target_link_libraries(MultiMC quazip patchlib
+libmmcutil libmmcsettings libmmcinst
+${MultiMC_LINK_ADDITIONAL_LIBS})
+add_dependencies(MultiMC MultiMCLauncher libmmcutil libmmcsettings libmmcinst)
################ Dirs ################
@@ -225,9 +210,9 @@ SET(QTCONF_DEST_DIR bin)
SET(APPS "\${CMAKE_INSTALL_PREFIX}/bin/MultiMC")
IF(WIN32)
- #SET(PLUGIN_DEST_DIR .)
- #SET(QTCONF_DEST_DIR .)
- SET(APPS "\${CMAKE_INSTALL_PREFIX}/bin/MultiMC.exe")
+ SET(PLUGIN_DEST_DIR .)
+ SET(QTCONF_DEST_DIR .)
+ SET(APPS "\${CMAKE_INSTALL_PREFIX}/MultiMC.exe")
ENDIF()
IF(APPLE)
SET(PLUGIN_DEST_DIR MultiMC.app/Contents/MacOS)
@@ -255,7 +240,7 @@ ENDIF(APPLE)
IF(WIN32)
INSTALL(TARGETS MultiMC
BUNDLE DESTINATION . COMPONENT Runtime
- RUNTIME DESTINATION bin COMPONENT Runtime
+ RUNTIME DESTINATION . COMPONENT Runtime
)
ENDIF()
IF(UNIX)
@@ -287,7 +272,11 @@ INSTALL(CODE "
# Dirs to look for dependencies.
-SET(DIRS ${QT_LIBRARY_DIRS})
+SET(DIRS "${QT_LIBRARY_DIRS}
+${CMAKE_BINARY_DIR}/libutil
+${CMAKE_BINARY_DIR}/libsettings
+${CMAKE_BINARY_DIR}/libinstance")
+message(STATUS "${DIRS}")
INSTALL(CODE "
file(GLOB_RECURSE QTPLUGINS
diff --git a/data/plugin/instancetypeplugin.h b/data/plugin/instancetypeplugin.h
deleted file mode 100644
index 8e3febdb..00000000
--- a/data/plugin/instancetypeplugin.h
+++ /dev/null
@@ -1,41 +0,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.
- */
-
-#ifndef INSTANCETYPEPLUGIN_H
-#define INSTANCETYPEPLUGIN_H
-
-#include <QList>
-
-#include "data/inst/instancetype.h"
-
-/*!
- * \brief Interface for plugins that want to provide custom instance types.
- */
-class InstanceTypePlugin
-{
-public:
- /*!
- * \brief Gets a QList containing the instance types that this plugin provides.
- * These instance types are then registered with the InstanceLoader.
- * The InstanceType objects should \e not be deleted by the plugin. Once they
- * are registered, they belong to the InstanceLoader.
- * \return A QList containing this plugin's instance types.
- */
- virtual QList<InstanceType *> getInstanceTypes() = 0;
-};
-
-Q_DECLARE_INTERFACE(InstanceTypePlugin, "net.forkk.MultiMC.InstanceTypePlugin/0.1")
-
-#endif // INSTANCETYPEPLUGIN_H
diff --git a/data/plugin/pluginmanager.cpp b/data/plugin/pluginmanager.cpp
index cd33b285..2f066293 100644
--- a/data/plugin/pluginmanager.cpp
+++ b/data/plugin/pluginmanager.cpp
@@ -18,10 +18,17 @@
#include <QDir>
#include <QDirIterator>
#include <QFileInfo>
+#include <QVariant>
+
+#include <QJsonObject>
#include <QtPlugin>
-#include "data/plugin/instancetypeplugin.h"
+#include "instancetypeinterface.h"
+
+// MultiMC's API version. This must match the "api" field in each plugin's
+// metadata or MultiMC won't consider them valid MultiMC plugin.
+#define MMC_API_VERSION "MultiMC5-API-1"
PluginManager PluginManager::manager;
@@ -33,8 +40,16 @@ PluginManager::PluginManager() :
bool PluginManager::loadPlugins(QString pluginDir)
{
+ // Delete the loaded plugins and clear the list.
+ for (int i = 0; i < m_plugins.count(); i++)
+ {
+ delete m_plugins[i];
+ }
m_plugins.clear();
+ qDebug(QString("Loading plugins from directory: %1").
+ arg(pluginDir).toUtf8());
+
QDir dir(pluginDir);
QDirIterator iter(dir);
@@ -44,53 +59,47 @@ bool PluginManager::loadPlugins(QString pluginDir)
if (pluginFile.exists() && pluginFile.isFile())
{
- QPluginLoader pluginLoader(pluginFile.absoluteFilePath());
- pluginLoader.load();
- QObject *plugin = pluginLoader.instance();
- if (plugin)
- {
- qDebug(QString("Loaded plugin %1.").
- arg(pluginFile.baseName()).toUtf8());
- m_plugins.push_back(plugin);
- }
- else
+ qDebug(QString("Attempting to load plugin: %1").
+ arg(pluginFile.canonicalFilePath()).toUtf8());
+
+ QPluginLoader *pluginLoader = new QPluginLoader(pluginFile.absoluteFilePath());
+
+ QJsonObject pluginInfo = pluginLoader->metaData();
+ QJsonObject pluginMetadata = pluginInfo.value("MetaData").toObject();
+
+ if (pluginMetadata.value("api").toString("") != MMC_API_VERSION)
{
- qWarning(QString("Error loading plugin %1. Not a valid plugin.").
- arg(pluginFile.baseName()).toUtf8());
+ // If "api" is not specified, it's not a MultiMC plugin.
+ qDebug(QString("Not loading plugin %1. Not a valid MultiMC plugin. "
+ "API: %2").
+ arg(pluginFile.canonicalFilePath(), pluginMetadata.value("api").toString("")).toUtf8());
+ continue;
}
+
+ qDebug(QString("Loaded plugin: %1").
+ arg(pluginInfo.value("IID").toString()).toUtf8());
+ m_plugins.push_back(pluginLoader);
}
}
return true;
}
-bool PluginManager::initInstanceTypes()
+QPluginLoader *PluginManager::getPlugin(int index)
+{
+ return m_plugins[index];
+}
+
+void PluginManager::initInstanceTypes()
{
for (int i = 0; i < m_plugins.count(); i++)
{
- InstanceTypePlugin *plugin = qobject_cast<InstanceTypePlugin *>(m_plugins[i]);
- if (plugin)
+ InstanceTypeInterface *instType = qobject_cast<InstanceTypeInterface *>(m_plugins[i]->instance());
+
+ if (instType)
{
- QList<InstanceType *> instanceTypes = plugin->getInstanceTypes();
-
- for (int i = 0; i < instanceTypes.count(); i++)
- {
- InstanceLoader::InstTypeError error =
- InstanceLoader::loader.registerInstanceType(instanceTypes[i]);
- switch (error)
- {
- case InstanceLoader::TypeIDExists:
- qWarning(QString("Instance type %1 already registered.").
- arg(instanceTypes[i]->typeID()).toUtf8());
- }
- }
+ // TODO: Handle errors
+ InstanceLoader::get().registerInstanceType(instType);
}
}
-
- return true;
-}
-
-QObject *PluginManager::getPlugin(int index)
-{
- return m_plugins[index];
}
diff --git a/data/plugin/pluginmanager.h b/data/plugin/pluginmanager.h
index 8e2dba0d..b93fd6d2 100644
--- a/data/plugin/pluginmanager.h
+++ b/data/plugin/pluginmanager.h
@@ -42,12 +42,6 @@ public:
bool loadPlugins(QString pluginDir);
/*!
- * \brief Initializes the instance type plugins.
- * \return True if successful. False on failure.
- */
- bool initInstanceTypes();
-
- /*!
* \brief Checks how many plugins are loaded.
* \return The number of plugins.
*/
@@ -58,12 +52,19 @@ public:
* \param index The index of the plugin to get.
* \return The plugin at the given index.
*/
- QObject *getPlugin(int index);
+ QPluginLoader *getPlugin(int index);
+
+ /*!
+ * \brief Initializes and registers all the instance types.
+ * This is done by going through the plugin list and registering all of the
+ * plugins that derive from the InstanceTypeInterface with the InstanceLoader.
+ */
+ void initInstanceTypes();
private:
PluginManager();
- QList<QObject *> m_plugins;
+ QList<QPluginLoader *> m_plugins;
static PluginManager manager;
};
diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp
index d19d69dc..19ff2108 100644
--- a/gui/mainwindow.cpp
+++ b/gui/mainwindow.cpp
@@ -21,20 +21,25 @@
#include <QDesktopServices>
#include <QUrl>
+#include <QFileInfo>
-#include "util/osutils.h"
+#include "osutils.h"
#include "gui/settingsdialog.h"
#include "gui/newinstancedialog.h"
#include "gui/logindialog.h"
#include "gui/taskdialog.h"
-#include "data/inst/instancelist.h"
-#include "data/appsettings.h"
+#include "instancelist.h"
+#include "appsettings.h"
#include "data/version.h"
#include "tasks/logintask.h"
+// Opens the given file in the default application.
+// TODO: Move this somewhere.
+void openInDefaultProgram(QString filename);
+
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
@@ -156,3 +161,8 @@ void MainWindow::onLoginComplete(LoginResponse response)
QString("Logged in as %1 with session ID %2.").
arg(response.getUsername(), response.getSessionID()));
}
+
+void openInDefaultProgram(QString filename)
+{
+ QDesktopServices::openUrl("file:///" + QFileInfo(filename).absolutePath());
+}
diff --git a/gui/mainwindow.h b/gui/mainwindow.h
index d286bd0e..591d0632 100644
--- a/gui/mainwindow.h
+++ b/gui/mainwindow.h
@@ -18,7 +18,7 @@
#include <QMainWindow>
-#include "data/inst/instancelist.h"
+#include "instancelist.h"
#include "data/loginresponse.h"
namespace Ui
diff --git a/gui/settingsdialog.cpp b/gui/settingsdialog.cpp
index ab4d18ee..b3c42380 100644
--- a/gui/settingsdialog.cpp
+++ b/gui/settingsdialog.cpp
@@ -16,7 +16,7 @@
#include "settingsdialog.h"
#include "ui_settingsdialog.h"
-#include "data/appsettings.h"
+#include "appsettings.h"
#include <QFileDialog>
#include <QMessageBox>
diff --git a/libinstance/CMakeLists.txt b/libinstance/CMakeLists.txt
index 503bda75..d0a9aa08 100644
--- a/libinstance/CMakeLists.txt
+++ b/libinstance/CMakeLists.txt
@@ -1,31 +1,47 @@
-project(stdinstance)
+project(libmmcinst)
-ADD_DEFINITIONS(-DQT_PLUGIN)
+set(CMAKE_AUTOMOC ON)
# Find Qt
find_package(Qt5Core REQUIRED)
-find_package(Qt5Network REQUIRED)
# Include Qt headers.
include_directories(${Qt5Base_INCLUDE_DIRS})
include_directories(${Qt5Network_INCLUDE_DIRS})
-# Include MultiMC's headers.
-include_directories(../../)
+# Include utility library.
+include_directories(${CMAKE_SOURCE_DIR}/libutil/include)
-SET(STDINST_HEADERS
-stdinstplugin.h
-stdinstancetype.h
-stdinstance.h
+# Include utility library.
+include_directories(${CMAKE_SOURCE_DIR}/libsettings/include)
+
+SET(LIBINST_HEADERS
+include/libinstance_config.h
+
+include/instancetypeinterface.h
+
+include/instance.h
+include/instancelist.h
+include/instanceloader.h
+
+include/instversion.h
+include/instversionlist.h
)
-SET(STDINST_SOURCES
-stdinstplugin.cpp
-stdinstancetype.cpp
-stdinstance.cpp
+SET(LIBINST_SOURCES
+src/instance.cpp
+src/instancelist.cpp
+src/instanceloader.cpp
+
+src/instversion.cpp
+src/instversionlist.cpp
)
-add_library(stdinstance SHARED ${STDINST_SOURCES} ${STDINST_HEADERS})
-set_target_properties(stdinstance PROPERTIES PREFIX "")
-qt5_use_modules(stdinstance Core Network)
-target_link_libraries(stdinstance quazip patchlib)
+# Set the include dir path.
+SET(LIBMMCINST_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include" PARENT_SCOPE)
+
+add_definitions(-DLIBMMCINST_LIBRARY)
+
+add_library(libmmcinst SHARED ${LIBINST_SOURCES} ${LIBINST_HEADERS})
+qt5_use_modules(libmmcinst Core)
+target_link_libraries(libmmcinst libmmcutil libmmcsettings)
diff --git a/data/inst/instance.h b/libinstance/include/instance.h
index 035704b9..7b3c001d 100644
--- a/data/inst/instance.h
+++ b/libinstance/include/instance.h
@@ -19,8 +19,10 @@
#include <QObject>
#include <QDateTime>
-#include "data/appsettings.h"
-#include "data/inifile.h"
+#include "appsettings.h"
+#include "inifile.h"
+
+#include "libinstance_config.h"
#define DEFINE_OVERRIDDEN_SETTING_ADVANCED(funcName, cfgEntryName, typeName) \
typeName get ## funcName() const { return getField(cfgEntryName, settings->get ## funcName()).value<typeName>(); }
@@ -38,7 +40,7 @@ class InstanceList;
* To create a new instance type, create a new class inheriting from this class
* and implement the pure virtual functions.
*/
-class Instance : public SettingsBase
+class LIBMMCINST_EXPORT Instance : public SettingsBase
{
Q_OBJECT
public:
@@ -62,13 +64,13 @@ public:
*
* \return The instance's ID.
*/
- virtual QString id();
+ virtual QString id() const;
/*!
* \brief Gets the path to the instance's root directory.
* \return The path to the instance's root directory.
*/
- virtual QString rootDir();
+ virtual QString rootDir() const;
/*!
* \brief Gets the instance list that this instance is a part of.
@@ -76,7 +78,7 @@ public:
* (the parent is not an InstanceList).
* \return A pointer to the InstanceList containing this instance.
*/
- virtual InstanceList *instList();
+ virtual InstanceList *instList() const;
//////// FIELDS AND SETTINGS ////////
diff --git a/data/inst/instancelist.h b/libinstance/include/instancelist.h
index c43c4cc0..f6be815c 100644
--- a/data/inst/instancelist.h
+++ b/libinstance/include/instancelist.h
@@ -20,11 +20,13 @@
#include <QSharedPointer>
-#include "data/siglist.h"
+#include "siglist.h"
+
+#include "libinstance_config.h"
class Instance;
-class InstanceList : public QObject, public SigList<QSharedPointer<Instance>>
+class LIBMMCINST_EXPORT InstanceList : public QObject, public SigList<QSharedPointer<Instance>>
{
Q_OBJECT
public:
diff --git a/data/inst/instanceloader.h b/libinstance/include/instanceloader.h
index 60c4e998..39696639 100644
--- a/data/inst/instanceloader.h
+++ b/libinstance/include/instanceloader.h
@@ -20,21 +20,26 @@
#include <QMap>
#include <QList>
-class InstanceType;
+#include "libinstance_config.h"
+
+class InstanceTypeInterface;
class Instance;
-typedef QList<const InstanceType *> InstTypeList;
+typedef QList<const InstanceTypeInterface *> InstTypeList;
/*!
* \brief The InstanceLoader is a singleton that manages all of the instance types and handles loading and creating instances.
* Instance types are registered with the instance loader through its registerInstType() function.
* Creating instances is done through the InstanceLoader's createInstance() function. This function takes
*/
-class InstanceLoader : public QObject
+class LIBMMCINST_EXPORT InstanceLoader : public QObject
{
Q_OBJECT
public:
- static InstanceLoader loader;
+ /*!
+ * \brief Gets a reference to the instance loader.
+ */
+ static InstanceLoader &get() { return loader; }
/*!
* \brief Error codes returned by functions in the InstanceLoader and InstanceType classes.
@@ -62,15 +67,12 @@ public:
/*!
* \brief Registers the given InstanceType with the instance loader.
- * This causes the instance loader to take ownership of the given
- * instance type (meaning the instance type's parent will be set to
- * the instance loader).
*
* \param type The InstanceType to register.
* \return An InstTypeError error code.
* - TypeIDExists if the given type's is already registered to another instance type.
*/
- InstTypeError registerInstanceType(InstanceType *type);
+ InstTypeError registerInstanceType(InstanceTypeInterface *type);
/*!
* \brief Creates an instance with the given type and stores it in inst.
@@ -82,7 +84,7 @@ public:
* - TypeNotRegistered if the given type is not registered with the InstanceLoader.
* - InstExists if the given instance directory is already an instance.
*/
- InstTypeError createInstance(Instance *inst, const InstanceType *type, const QString &instDir);
+ InstTypeError createInstance(Instance *inst, const InstanceTypeInterface *type, const QString &instDir);
/*!
* \brief Loads an instance from the given directory.
@@ -95,7 +97,7 @@ public:
* - NotAnInstance if the given instance directory isn't a valid instance.
* - WrongInstType if the given instance directory's type isn't the same as the given type.
*/
- InstTypeError loadInstance(Instance *inst, const InstanceType *type, const QString &instDir);
+ InstTypeError loadInstance(Instance *inst, const InstanceTypeInterface *type, const QString &instDir);
/*!
* \brief Loads an instance from the given directory.
@@ -115,7 +117,7 @@ public:
* \param id The ID of the type to find.
* \return The type with the given ID. NULL if none were found.
*/
- const InstanceType *findType(const QString &id);
+ const InstanceTypeInterface *findType(const QString &id);
/*!
* \brief Gets a list of the registered instance types.
@@ -127,7 +129,9 @@ public:
private:
InstanceLoader();
- QMap<QString, InstanceType *> m_typeMap;
+ QMap<QString, InstanceTypeInterface *> m_typeMap;
+
+ static InstanceLoader loader;
};
#endif // INSTANCELOADER_H
diff --git a/data/inst/instancetype.h b/libinstance/include/instancetypeinterface.h
index bd22a17c..a061b9d2 100644
--- a/data/inst/instancetype.h
+++ b/libinstance/include/instancetypeinterface.h
@@ -20,20 +20,21 @@
#include "instanceloader.h"
+//! The InstanceTypeInterface's interface ID.
+#define InstanceTypeInterface_IID "net.forkk.MultiMC.InstanceTypeInterface/0.1"
+
/*!
- * \brief The InstanceType class is a base class for all instance types.
+ * \brief The InstanceType class is an interface for all instance types.
+ * InstanceTypes are usually provided by plugins.
* It handles loading and creating instances of a certain type. There should be
* one of these for each type of instance and they should be registered with the
* InstanceLoader.
* To create an instance, the InstanceLoader calls the type's createInstance()
* function. Loading is done through the loadInstance() function.
*/
-class InstanceType : public QObject
+class InstanceTypeInterface
{
- Q_OBJECT
public:
- explicit InstanceType(QObject *parent = 0);
-
friend class InstanceLoader;
/*!
@@ -80,4 +81,6 @@ protected:
virtual InstanceLoader::InstTypeError loadInstance(Instance *inst, const QString &instDir) const = 0;
};
+Q_DECLARE_INTERFACE(InstanceTypeInterface, InstanceTypeInterface_IID)
+
#endif // INSTANCETYPE_H
diff --git a/data/version/instversion.h b/libinstance/include/instversion.h
index 361563fd..c505c5a3 100644
--- a/data/version/instversion.h
+++ b/libinstance/include/instversion.h
@@ -18,9 +18,11 @@
#include <QObject>
+#include "libinstance_config.h"
+
class InstVersionList;
-class InstVersion : public QObject
+class LIBMMCINST_EXPORT InstVersion : public QObject
{
Q_OBJECT
public:
diff --git a/data/version/instversionlist.h b/libinstance/include/instversionlist.h
index f79bc1b0..2cd9ed1e 100644
--- a/data/version/instversionlist.h
+++ b/libinstance/include/instversionlist.h
@@ -18,13 +18,15 @@
#include <QObject>
+#include "libinstance_config.h"
+
class InstVersion;
// 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.
-class InstVersionList : public QObject
+class LIBMMCINST_EXPORT InstVersionList : public QObject
{
Q_OBJECT
public:
diff --git a/util/osutils.cpp b/libinstance/include/libinstance_config.h
index 6b095518..2e6dc884 100644
--- a/util/osutils.cpp
+++ b/libinstance/include/libinstance_config.h
@@ -13,13 +13,15 @@
* limitations under the License.
*/
-#include "osutils.h"
+//#ifndef LIBINSTANCE_CONFIG_H
+//#define LIBINSTANCE_CONFIG_H
-#include <QDesktopServices>
-#include <QUrl>
-#include <QFileInfo>
+#include <QtCore/QtGlobal>
-void openInDefaultProgram(QString filename)
-{
- QDesktopServices::openUrl("file:///" + QFileInfo(filename).absolutePath());
-}
+#ifdef LIBMMCINST_LIBRARY
+# define LIBMMCINST_EXPORT Q_DECL_EXPORT
+#else
+# define LIBMMCINST_EXPORT Q_DECL_IMPORT
+#endif
+
+//#endif // LIBINSTANCE_CONFIG_H
diff --git a/data/inst/instance.cpp b/libinstance/src/instance.cpp
index 5db0be20..c79c0213 100644
--- a/data/inst/instance.cpp
+++ b/libinstance/src/instance.cpp
@@ -13,11 +13,11 @@
* limitations under the License.
*/
-#include "instance.h"
+#include "include/instance.h"
#include <QFileInfo>
-#include "util/pathutils.h"
+#include "pathutils.h"
Instance::Instance(const QString &rootDir, QObject *parent) :
SettingsBase(parent)
@@ -26,17 +26,17 @@ Instance::Instance(const QString &rootDir, QObject *parent) :
config.loadFile(PathCombine(rootDir, "instance.cfg"));
}
-QString Instance::id()
+QString Instance::id() const
{
return QFileInfo(rootDir()).baseName();
}
-QString Instance::rootDir()
+QString Instance::rootDir() const
{
return m_rootDir;
}
-InstanceList *Instance::instList()
+InstanceList *Instance::instList() const
{
if (parent()->inherits("InstanceList"))
return (InstanceList *)parent();
diff --git a/data/inst/instancelist.cpp b/libinstance/src/instancelist.cpp
index cbb89f05..15f79d05 100644
--- a/data/inst/instancelist.cpp
+++ b/libinstance/src/instancelist.cpp
@@ -13,18 +13,18 @@
* limitations under the License.
*/
-#include "instancelist.h"
+#include "include/instancelist.h"
-#include "data/siglist_impl.h"
+#include "siglist_impl.h"
#include <QDir>
#include <QFile>
#include <QDirIterator>
-#include "instance.h"
-#include "instanceloader.h"
+#include "include/instance.h"
+#include "include/instanceloader.h"
-#include "util/pathutils.h"
+#include "pathutils.h"
InstanceList::InstanceList(const QString &instDir, QObject *parent) :
@@ -44,16 +44,11 @@ InstanceList::InstListError InstanceList::loadList()
if (QFileInfo(PathCombine(subDir, "instance.cfg")).exists())
{
QSharedPointer<Instance> inst;
- InstanceLoader::InstTypeError error = InstanceLoader::loader.
+ InstanceLoader::InstTypeError error = InstanceLoader::get().
loadInstance(inst.data(), subDir);
- if (inst.data() && error == InstanceLoader::NoError)
- {
- qDebug(QString("Loaded instance %1").arg(inst->name()).toUtf8());
- inst->setParent(this);
- append(QSharedPointer<Instance>(inst));
- }
- else if (error != InstanceLoader::NotAnInstance)
+ if (error != InstanceLoader::NoError &&
+ error != InstanceLoader::NotAnInstance)
{
QString errorMsg = QString("Failed to load instance %1: ").
arg(QFileInfo(subDir).baseName()).toUtf8();
@@ -63,6 +58,11 @@ InstanceList::InstListError InstanceList::loadList()
case InstanceLoader::TypeNotRegistered:
errorMsg += "Instance type not found.";
break;
+
+ default:
+ errorMsg += QString("Unknown instance loader error %1").
+ arg(error);
+ break;
}
qDebug(errorMsg.toUtf8());
}
@@ -71,6 +71,12 @@ InstanceList::InstListError InstanceList::loadList()
qDebug(QString("Error loading instance %1. Instance loader returned null.").
arg(QFileInfo(subDir).baseName()).toUtf8());
}
+ else
+ {
+ qDebug(QString("Loaded instance %1").arg(inst->name()).toUtf8());
+ inst->setParent(this);
+ append(QSharedPointer<Instance>(inst));
+ }
}
}
diff --git a/data/inst/instanceloader.cpp b/libinstance/src/instanceloader.cpp
index e80a0e9e..eff9d56e 100644
--- a/data/inst/instanceloader.cpp
+++ b/libinstance/src/instanceloader.cpp
@@ -13,15 +13,15 @@
* limitations under the License.
*/
-#include "instanceloader.h"
+#include "include/instanceloader.h"
#include <QFileInfo>
-#include "instancetype.h"
+#include "include/instancetypeinterface.h"
-#include "data/inifile.h"
+#include "inifile.h"
-#include "util/pathutils.h"
+#include "pathutils.h"
InstanceLoader InstanceLoader::loader;
@@ -32,22 +32,25 @@ InstanceLoader::InstanceLoader() :
}
-InstanceLoader::InstTypeError InstanceLoader::registerInstanceType(InstanceType *type)
+InstanceLoader::InstTypeError InstanceLoader::registerInstanceType(InstanceTypeInterface *type)
{
// Check to see if the type ID exists.
if (m_typeMap.contains(type->typeID()))
return TypeIDExists;
// Set the parent to this.
- type->setParent(this);
+ // ((QObject *)type)->setParent(this);
// Add it to the map.
m_typeMap.insert(type->typeID(), type);
+
+ qDebug(QString("Registered instance type %1.").
+ arg(type->typeID()).toUtf8());
return NoError;
}
InstanceLoader::InstTypeError InstanceLoader::createInstance(Instance *inst,
- const InstanceType *type,
+ const InstanceTypeInterface *type,
const QString &instDir)
{
// Check if the type is registered.
@@ -59,7 +62,7 @@ InstanceLoader::InstTypeError InstanceLoader::createInstance(Instance *inst,
}
InstanceLoader::InstTypeError InstanceLoader::loadInstance(Instance *inst,
- const InstanceType *type,
+ const InstanceTypeInterface *type,
const QString &instDir)
{
// Check if the type is registered.
@@ -79,13 +82,13 @@ InstanceLoader::InstTypeError InstanceLoader::loadInstance(Instance *inst,
INIFile ini;
ini.loadFile(instConfig.path());
- QString typeName = ini.get("type", "StdInstance").toString();
- const InstanceType *type = findType(typeName);
+ QString typeName = ini.get("type", "net.forkk.MultiMC.StdInstance").toString();
+ const InstanceTypeInterface *type = findType(typeName);
return loadInstance(inst, type, instDir);
}
-const InstanceType *InstanceLoader::findType(const QString &id)
+const InstanceTypeInterface *InstanceLoader::findType(const QString &id)
{
if (!m_typeMap.contains(id))
return NULL;
diff --git a/data/version/instversion.cpp b/libinstance/src/instversion.cpp
index 1493153a..cedb61df 100644
--- a/data/version/instversion.cpp
+++ b/libinstance/src/instversion.cpp
@@ -13,8 +13,8 @@
* limitations under the License.
*/
-#include "instversion.h"
-#include "instversionlist.h"
+#include "include/instversion.h"
+#include "include/instversionlist.h"
InstVersion::InstVersion(InstVersionList *parent) :
QObject(parent)
diff --git a/data/version/instversionlist.cpp b/libinstance/src/instversionlist.cpp
index ab57f94c..e171cfa5 100644
--- a/data/version/instversionlist.cpp
+++ b/libinstance/src/instversionlist.cpp
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-#include "instversionlist.h"
+#include "include/instversionlist.h"
InstVersionList::InstVersionList() :
QObject(NULL)
diff --git a/libsettings/CMakeLists.txt b/libsettings/CMakeLists.txt
new file mode 100644
index 00000000..2cf72365
--- /dev/null
+++ b/libsettings/CMakeLists.txt
@@ -0,0 +1,30 @@
+project(libmmcsettings)
+
+# Find Qt
+find_package(Qt5Core REQUIRED)
+
+# Include Qt headers.
+include_directories(${Qt5Base_INCLUDE_DIRS})
+include_directories(${Qt5Network_INCLUDE_DIRS})
+
+# Include utils library headers.
+include_directories(${CMAKE_SOURCE_DIR}/libutil/include)
+
+SET(LIBSETTINGS_HEADERS
+include/libsettings_config.h
+
+include/appsettings.h
+)
+
+SET(LIBSETTINGS_SOURCES
+src/appsettings.cpp
+)
+
+# Set the include dir path.
+SET(LIBMMCSETTINGS_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include" PARENT_SCOPE)
+
+add_definitions(-DLIBMMCSETTINGS_LIBRARY)
+
+add_library(libmmcsettings SHARED ${LIBSETTINGS_SOURCES} ${LIBSETTINGS_HEADERS})
+qt5_use_modules(libmmcsettings Core)
+target_link_libraries(libmmcsettings libmmcutil)
diff --git a/data/appsettings.h b/libsettings/include/appsettings.h
index 8a786db0..79515618 100644
--- a/data/appsettings.h
+++ b/libsettings/include/appsettings.h
@@ -18,11 +18,13 @@
#include <QObject>
#include <QSettings>
-#include <QColor>
+//#include <QColor>
#include <QPoint>
-#include "util/apputils.h"
-#include "util/osutils.h"
+#include <apputils.h>
+#include <osutils.h>
+
+#include "libsettings_config.h"
#if WINDOWS
#define JPATHKEY "JavaPathWindows"
@@ -40,7 +42,7 @@
DEFINE_SETTING_ADVANCED(name, STR_VAL(name), valType, defVal)
-class SettingsBase : public QObject
+class LIBMMCSETTINGS_EXPORT SettingsBase : public QObject
{
Q_OBJECT
public:
@@ -64,9 +66,10 @@ public:
DEFINE_SETTING(InstanceToolbarPosition, QPoint, QPoint())
// Console Colors
- DEFINE_SETTING(SysMessageColor, QColor, QColor(Qt::blue))
- DEFINE_SETTING(StdOutColor, QColor, QColor(Qt::black))
- DEFINE_SETTING(StdErrColor, QColor, QColor(Qt::red))
+ // Currently commented out because QColor is a part of QtGUI
+// DEFINE_SETTING(SysMessageColor, QColor, QColor(Qt::blue))
+// DEFINE_SETTING(StdOutColor, QColor, QColor(Qt::black))
+// DEFINE_SETTING(StdErrColor, QColor, QColor(Qt::red))
// Window Size
DEFINE_SETTING(LaunchCompatMode, bool, false)
@@ -93,7 +96,7 @@ public:
virtual void setValue(const QString& name, QVariant val) = 0;
};
-class AppSettings : public SettingsBase
+class LIBMMCSETTINGS_EXPORT AppSettings : public SettingsBase
{
Q_OBJECT
public:
@@ -111,6 +114,6 @@ protected:
#undef DEFINE_SETTING_ADVANCED
#undef DEFINE_SETTING
-extern AppSettings* settings;
+LIBMMCSETTINGS_EXPORT extern AppSettings* settings;
#endif // APPSETTINGS_H
diff --git a/libsettings/include/libsettings_config.h b/libsettings/include/libsettings_config.h
new file mode 100644
index 00000000..05df5bfa
--- /dev/null
+++ b/libsettings/include/libsettings_config.h
@@ -0,0 +1,27 @@
+/* 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 LIBINSTANCE_CONFIG_H
+#define LIBINSTANCE_CONFIG_H
+
+#include <QtCore/QtGlobal>
+
+#ifdef LIBMMCSETTINGS_LIBRARY
+# define LIBMMCSETTINGS_EXPORT Q_DECL_EXPORT
+#else
+# define LIBMMCSETTINGS_EXPORT Q_DECL_IMPORT
+#endif
+
+#endif // LIBINSTANCE_CONFIG_H
diff --git a/data/appsettings.cpp b/libsettings/src/appsettings.cpp
index 1d9c4312..8fe9b8ad 100644
--- a/data/appsettings.cpp
+++ b/libsettings/src/appsettings.cpp
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-#include "appsettings.h"
+#include "include/appsettings.h"
AppSettings* settings;
diff --git a/libutil/CMakeLists.txt b/libutil/CMakeLists.txt
new file mode 100644
index 00000000..b6eadf50
--- /dev/null
+++ b/libutil/CMakeLists.txt
@@ -0,0 +1,38 @@
+project(libmmcutil)
+
+# Find Qt
+find_package(Qt5Core REQUIRED)
+
+# Include Qt headers.
+include_directories(${Qt5Base_INCLUDE_DIRS})
+include_directories(${Qt5Network_INCLUDE_DIRS})
+
+SET(LIBUTIL_HEADERS
+include/libutil_config.h
+
+include/apputils.h
+
+include/pathutils.h
+include/osutils.h
+
+include/inifile.h
+
+include/siglist.h
+include/siglist_impl.h
+)
+
+SET(LIBUTIL_SOURCES
+src/pathutils.cpp
+src/osutils.cpp
+
+src/inifile.cpp
+)
+
+# Set the include dir path.
+SET(LIBMMCUTIL_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include" PARENT_SCOPE)
+
+add_definitions(-DLIBMMCUTIL_LIBRARY)
+
+add_library(libmmcutil SHARED ${LIBUTIL_SOURCES} ${LIBUTIL_HEADERS})
+qt5_use_modules(libmmcutil Core)
+target_link_libraries(libmmcutil)
diff --git a/util/apputils.h b/libutil/include/apputils.h
index a64adc50..a64adc50 100644
--- a/util/apputils.h
+++ b/libutil/include/apputils.h
diff --git a/data/inifile.h b/libutil/include/inifile.h
index 75783859..1280c7e3 100644
--- a/data/inifile.h
+++ b/libutil/include/inifile.h
@@ -20,8 +20,10 @@
#include <QString>
#include <QVariant>
+#include "libutil_config.h"
+
// Sectionless INI parser (for instance config files)
-class INIFile : public QMap<QString, QVariant>
+class LIBMMCUTIL_EXPORT INIFile : public QMap<QString, QVariant>
{
public:
explicit INIFile();
diff --git a/plugins/stdinstance/stdinstplugin.cpp b/libutil/include/libutil_config.h
index 98e12ae0..41766184 100644
--- a/plugins/stdinstance/stdinstplugin.cpp
+++ b/libutil/include/libutil_config.h
@@ -13,15 +13,15 @@
* limitations under the License.
*/
-#include "stdinstplugin.h"
+#ifndef LIBUTIL_CONFIG_H
+#define LIBUTIL_CONFIG_H
-#include <QtPlugin>
+#include <QtCore/QtGlobal>
-#include "stdinstancetype.h"
+#ifdef LIBMMCUTIL_LIBRARY
+# define LIBMMCUTIL_EXPORT Q_DECL_EXPORT
+#else
+# define LIBMMCUTIL_EXPORT Q_DECL_IMPORT
+#endif
-QList<InstanceType *> StdInstPlugin::getInstanceTypes()
-{
- QList<InstanceType *> types;
- types.push_back(new StdInstanceType(this));
- return types;
-}
+#endif // LIBUTIL_CONFIG_H
diff --git a/util/osutils.h b/libutil/include/osutils.h
index f779ea2d..c5d4bb61 100644
--- a/util/osutils.h
+++ b/libutil/include/osutils.h
@@ -26,7 +26,4 @@
#define LINUX 1
#endif
-// Opens the given file in the default application.
-void openInDefaultProgram(QString filename);
-
#endif // OSUTILS_H
diff --git a/util/pathutils.h b/libutil/include/pathutils.h
index 1922e3a0..d5f106ef 100644
--- a/util/pathutils.h
+++ b/libutil/include/pathutils.h
@@ -18,9 +18,11 @@
#include <QString>
-QString PathCombine(QString path1, QString path2);
-QString PathCombine(QString path1, QString path2, QString path3);
+#include "libutil_config.h"
-QString AbsolutePath(QString path);
+LIBMMCUTIL_EXPORT QString PathCombine(QString path1, QString path2);
+LIBMMCUTIL_EXPORT QString PathCombine(QString path1, QString path2, QString path3);
+
+LIBMMCUTIL_EXPORT QString AbsolutePath(QString path);
#endif // PATHUTILS_H
diff --git a/data/siglist.h b/libutil/include/siglist.h
index b6432b6e..b6432b6e 100644
--- a/data/siglist.h
+++ b/libutil/include/siglist.h
diff --git a/data/siglist_impl.h b/libutil/include/siglist_impl.h
index 16ddd9b0..16ddd9b0 100644
--- a/data/siglist_impl.h
+++ b/libutil/include/siglist_impl.h
diff --git a/data/inifile.cpp b/libutil/src/inifile.cpp
index 2d68caf6..43545a4a 100644
--- a/data/inifile.cpp
+++ b/libutil/src/inifile.cpp
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-#include "inifile.h"
+#include "include/inifile.h"
#include <QFile>
#include <QTextStream>
diff --git a/data/inst/instancetype.cpp b/libutil/src/osutils.cpp
index 4f27542d..9a85d1e5 100644
--- a/data/inst/instancetype.cpp
+++ b/libutil/src/osutils.cpp
@@ -13,9 +13,7 @@
* limitations under the License.
*/
-#include "instancetype.h"
+#include "include/osutils.h"
-InstanceType::InstanceType(QObject *parent) :
- QObject(parent)
-{
-}
+#include <QUrl>
+#include <QFileInfo>
diff --git a/util/pathutils.cpp b/libutil/src/pathutils.cpp
index 8610b80d..8e91bf31 100644
--- a/util/pathutils.cpp
+++ b/libutil/src/pathutils.cpp
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-#include "pathutils.h"
+#include "include/pathutils.h"
#include <QFileInfo>
#include <QDir>
diff --git a/main.cpp b/main.cpp
index 29c11e87..b78774a8 100644
--- a/main.cpp
+++ b/main.cpp
@@ -17,12 +17,12 @@
#include "gui/mainwindow.h"
#include <QApplication>
-#include "data/appsettings.h"
+#include "appsettings.h"
#include "data/loginresponse.h"
#include "data/plugin/pluginmanager.h"
-#include "util/pathutils.h"
+#include "pathutils.h"
int main(int argc, char *argv[])
{
diff --git a/plugins/stdinstance/CMakeLists.txt b/plugins/stdinstance/CMakeLists.txt
index 503bda75..0bb466ec 100644
--- a/plugins/stdinstance/CMakeLists.txt
+++ b/plugins/stdinstance/CMakeLists.txt
@@ -10,22 +10,40 @@ find_package(Qt5Network REQUIRED)
include_directories(${Qt5Base_INCLUDE_DIRS})
include_directories(${Qt5Network_INCLUDE_DIRS})
-# Include MultiMC's headers.
-include_directories(../../)
+# 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
-stdinstplugin.h
stdinstancetype.h
stdinstance.h
)
SET(STDINST_SOURCES
-stdinstplugin.cpp
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)
+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
index 19490965..12d86bbc 100644
--- a/plugins/stdinstance/stdinstance.cpp
+++ b/plugins/stdinstance/stdinstance.cpp
@@ -17,7 +17,7 @@
#include <QFileInfo>
-#include <java/javautils.h>
+#include <javautils.h>
StdInstance::StdInstance(const QString &rootDir, QObject *parent) :
Instance(rootDir, parent)
@@ -47,7 +47,8 @@ void StdInstance::updateCurrentVersion(bool keepCurrent)
setLastVersionUpdate(time);
if (!keepCurrent)
{
- QString newVersion = javautils::GetMinecraftJarVersion(jar.absoluteFilePath());
+ // 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
index 17c03f15..d812a9b0 100644
--- a/plugins/stdinstance/stdinstance.h
+++ b/plugins/stdinstance/stdinstance.h
@@ -16,7 +16,7 @@
#ifndef STDINSTANCE_H
#define STDINSTANCE_H
-#include <data/inst/instance.h>
+#include <instance.h>
class StdInstance : public Instance
{
diff --git a/plugins/stdinstance/stdinstance.json b/plugins/stdinstance/stdinstance.json
index 0967ef42..704f0b73 100644
--- a/plugins/stdinstance/stdinstance.json
+++ b/plugins/stdinstance/stdinstance.json
@@ -1 +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
index 3e9e00a0..9b7aa994 100644
--- a/plugins/stdinstance/stdinstancetype.cpp
+++ b/plugins/stdinstance/stdinstancetype.cpp
@@ -16,7 +16,7 @@
#include "stdinstancetype.h"
StdInstanceType::StdInstanceType(QObject *parent) :
- InstanceType(parent)
+ QObject(parent)
{
}
diff --git a/plugins/stdinstance/stdinstancetype.h b/plugins/stdinstance/stdinstancetype.h
index 9516aa80..4f659ba7 100644
--- a/plugins/stdinstance/stdinstancetype.h
+++ b/plugins/stdinstance/stdinstancetype.h
@@ -16,11 +16,15 @@
#ifndef STDINSTANCETYPE_H
#define STDINSTANCETYPE_H
-#include <data/inst/instancetype.h>
+#include <instancetypeinterface.h>
-class StdInstanceType : public InstanceType
+#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);
diff --git a/plugins/stdinstance/stdinstplugin.h b/plugins/stdinstance/stdinstplugin.h
deleted file mode 100644
index f44409bd..00000000
--- a/plugins/stdinstance/stdinstplugin.h
+++ /dev/null
@@ -1,33 +0,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.
- */
-
-#ifndef STDINSTPLUGIN_H
-#define STDINSTPLUGIN_H
-
-#include <QObject>
-
-#include <data/plugin/instancetypeplugin.h>
-
-class StdInstPlugin : public QObject, InstanceTypePlugin
-{
- Q_OBJECT
- Q_INTERFACES(InstanceTypePlugin)
- Q_PLUGIN_METADATA(IID "net.forkk.MultiMC.Plugins.StdInstance")
-
-public:
- virtual QList<InstanceType *> getInstanceTypes();
-};
-
-#endif // STDINSTPLUGIN_H