2013-09-01 18:36:43 +02:00
|
|
|
#include "proxypluginwrappers.h"
|
|
|
|
|
#include <utility.h>
|
|
|
|
|
#include "error.h"
|
|
|
|
|
#include "gilock.h"
|
2015-11-08 23:15:55 +00:00
|
|
|
#include <QWidget>
|
2013-09-01 18:36:43 +02:00
|
|
|
|
2016-11-27 16:54:19 +02:00
|
|
|
namespace boost
|
|
|
|
|
{
|
|
|
|
|
// See bug https://connect.microsoft.com/VisualStudio/Feedback/Details/2852624
|
|
|
|
|
template<> const volatile MOBase::IOrganizer* get_pointer(const volatile MOBase::IOrganizer* p) { return p; }
|
|
|
|
|
template<> const volatile MOBase::IModInterface* get_pointer(const volatile MOBase::IModInterface* p) { return p; }
|
|
|
|
|
template<> const volatile MOBase::IPluginGame* get_pointer(const volatile MOBase::IPluginGame* p) { return p; }
|
|
|
|
|
template<> const volatile MOBase::IProfile* get_pointer(const volatile MOBase::IProfile* p) { return p; }
|
|
|
|
|
template<> const volatile MOBase::IModList* get_pointer(const volatile MOBase::IModList* p) { return p; }
|
|
|
|
|
template<> const volatile MOBase::IPluginList* get_pointer(const volatile MOBase::IPluginList* p) { return p; }
|
|
|
|
|
template<> const volatile MOBase::IDownloadManager* get_pointer(const volatile MOBase::IDownloadManager* p) { return p; }
|
|
|
|
|
template<> const volatile MOBase::IModRepositoryBridge* get_pointer(const volatile MOBase::IModRepositoryBridge* p) { return p; }
|
|
|
|
|
}
|
2013-09-01 18:36:43 +02:00
|
|
|
|
|
|
|
|
using namespace MOBase;
|
|
|
|
|
|
2016-11-27 16:54:19 +02:00
|
|
|
#define PYCATCH catch (const boost::python::error_already_set &) { reportPythonError(); throw MyException("unhandled exception"); }\
|
2013-09-01 18:36:43 +02:00
|
|
|
catch (...) { throw MyException("An unknown exception was thrown in python code"); }
|
|
|
|
|
|
|
|
|
|
|
2016-01-10 19:50:19 +01:00
|
|
|
/////////////////////////////
|
|
|
|
|
/// IPlugin Wrapper
|
|
|
|
|
bool IPluginWrapper::init(MOBase::IOrganizer *moInfo)
|
|
|
|
|
{
|
|
|
|
|
try {
|
2016-11-27 16:54:19 +02:00
|
|
|
return this->get_override("init")(boost::python::ptr(moInfo));
|
2016-01-10 19:50:19 +01:00
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString IPluginWrapper::name() const
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
return this->get_override("name")().as<QString>();
|
|
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString IPluginWrapper::author() const
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
return this->get_override("author")().as<QString>();
|
|
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString IPluginWrapper::description() const
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
return this->get_override("description")().as<QString>();
|
|
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MOBase::VersionInfo IPluginWrapper::version() const
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
return this->get_override("version")().as<MOBase::VersionInfo>();
|
|
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool IPluginWrapper::isActive() const
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
return this->get_override("isActive")().as<bool>();
|
|
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<MOBase::PluginSetting> IPluginWrapper::settings() const
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
return this->get_override("settings")().as<QList<MOBase::PluginSetting>>();
|
|
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
/// end IPlugin Wrapper
|
2013-09-01 18:36:43 +02:00
|
|
|
/////////////////////////////
|
|
|
|
|
/// IPluginTool Wrapper
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool IPluginToolWrapper::init(MOBase::IOrganizer *moInfo)
|
|
|
|
|
{
|
|
|
|
|
try {
|
2016-11-27 16:54:19 +02:00
|
|
|
return this->get_override("init")(boost::python::ptr(moInfo));
|
2013-09-01 18:36:43 +02:00
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString IPluginToolWrapper::name() const
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-11-09 14:01:48 +01:00
|
|
|
return this->get_override("name")().as<QString>();
|
2013-09-01 18:36:43 +02:00
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString IPluginToolWrapper::author() const
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-11-09 14:01:48 +01:00
|
|
|
return this->get_override("author")().as<QString>();
|
2013-09-01 18:36:43 +02:00
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString IPluginToolWrapper::description() const
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-11-09 14:01:48 +01:00
|
|
|
return this->get_override("description")().as<QString>();
|
2013-09-01 18:36:43 +02:00
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MOBase::VersionInfo IPluginToolWrapper::version() const
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-11-09 14:01:48 +01:00
|
|
|
return this->get_override("version")().as<MOBase::VersionInfo>();
|
2013-09-01 18:36:43 +02:00
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool IPluginToolWrapper::isActive() const
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-11-09 14:01:48 +01:00
|
|
|
return this->get_override("isActive")().as<bool>();
|
2013-09-01 18:36:43 +02:00
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<MOBase::PluginSetting> IPluginToolWrapper::settings() const
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-11-09 14:01:48 +01:00
|
|
|
return this->get_override("settings")().as<QList<MOBase::PluginSetting>>();
|
2013-09-01 18:36:43 +02:00
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString IPluginToolWrapper::displayName() const
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-11-09 14:01:48 +01:00
|
|
|
return this->get_override("displayName")().as<QString>();
|
2013-09-01 18:36:43 +02:00
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString IPluginToolWrapper::tooltip() const
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-11-09 14:01:48 +01:00
|
|
|
return this->get_override("tooltip")().as<QString>();
|
2013-09-01 18:36:43 +02:00
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QIcon IPluginToolWrapper::icon() const
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-11-09 14:01:48 +01:00
|
|
|
return this->get_override("icon")().as<QIcon>();
|
2013-09-01 18:36:43 +02:00
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IPluginToolWrapper::setParentWidget(QWidget *parent)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
this->get_override("setParentWidget")(parent);
|
|
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IPluginToolWrapper::display() const
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
GILock lock;
|
|
|
|
|
|
|
|
|
|
this->get_override("display")();
|
|
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// end IPluginTool Wrapper
|
|
|
|
|
/////////////////////////////////////
|
|
|
|
|
/// IPluginInstallerCustom Wrapper
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool IPluginInstallerCustomWrapper::init(MOBase::IOrganizer *moInfo)
|
|
|
|
|
{
|
|
|
|
|
try {
|
2016-11-27 16:54:19 +02:00
|
|
|
return this->get_override("init")(boost::python::ptr(moInfo));
|
2013-09-01 18:36:43 +02:00
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString IPluginInstallerCustomWrapper::name() const
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-11-09 14:01:48 +01:00
|
|
|
return this->get_override("name")().as<QString>();
|
2013-09-01 18:36:43 +02:00
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString IPluginInstallerCustomWrapper::author() const
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-11-09 14:01:48 +01:00
|
|
|
return this->get_override("author")().as<QString>();
|
2013-09-01 18:36:43 +02:00
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString IPluginInstallerCustomWrapper::description() const
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-11-09 14:01:48 +01:00
|
|
|
return this->get_override("description")().as<QString>();
|
2013-09-01 18:36:43 +02:00
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MOBase::VersionInfo IPluginInstallerCustomWrapper::version() const
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
return this->get_override("version")();
|
|
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool IPluginInstallerCustomWrapper::isActive() const
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
return this->get_override("isActive")();
|
|
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<MOBase::PluginSetting> IPluginInstallerCustomWrapper::settings() const
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-11-09 14:01:48 +01:00
|
|
|
return this->get_override("settings")().as<QList<MOBase::PluginSetting>>();
|
2013-09-01 18:36:43 +02:00
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned int IPluginInstallerCustomWrapper::priority() const
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
return this->get_override("priority")();
|
|
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool IPluginInstallerCustomWrapper::isManualInstaller() const
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
return this->get_override("isManualInstaller")();
|
|
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-16 23:04:03 +02:00
|
|
|
bool IPluginInstallerCustomWrapper::isArchiveSupported(const DirectoryTree &) const
|
2013-09-01 18:36:43 +02:00
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
//return this->get_override("isArchiveSupported")(tree);
|
|
|
|
|
return false;
|
|
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool IPluginInstallerCustomWrapper::isArchiveSupported(const QString &archiveName) const
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
return this->get_override("isArchiveSupported")(archiveName);
|
|
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::set<QString> IPluginInstallerCustomWrapper::supportedExtensions() const
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-11-09 14:01:48 +01:00
|
|
|
return this->get_override("supportedExtensions")().as<std::set<QString>>();
|
2013-09-01 18:36:43 +02:00
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IPluginInstaller::EInstallResult IPluginInstallerCustomWrapper::install(GuessedValue<QString> &modName, const QString &archiveName,
|
|
|
|
|
const QString &version, int modID)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
return this->get_override("install")(modName, archiveName, version, modID);
|
|
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void IPluginInstallerCustomWrapper::setParentWidget(QWidget *parent)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
this->get_override("setParentWidget")(parent);
|
|
|
|
|
} PYCATCH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|