mirror of
https://github.com/ModOrganizer2/modorganizer-plugin_python.git
synced 2026-07-27 14:03:33 -07:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e158038cfc | ||
|
|
d4c424911a | ||
|
|
b9c2a18f86 | ||
|
|
224627515a | ||
|
|
6d99b33c61 | ||
|
|
f231c9a025 |
@@ -1,52 +0,0 @@
|
|||||||
%Import QtCore/QtCoremod.sip
|
|
||||||
%Import QtGui/QtGuimod.sip
|
|
||||||
|
|
||||||
|
|
||||||
namespace MOBase
|
|
||||||
{
|
|
||||||
|
|
||||||
class ModRepositoryFileInfo
|
|
||||||
{
|
|
||||||
|
|
||||||
%TypeHeaderCode
|
|
||||||
#include <imodrepositorybridge.h>
|
|
||||||
%End
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
ModRepositoryFileInfo();
|
|
||||||
ModRepositoryFileInfo(const QString &data);
|
|
||||||
~ModRepositoryFileInfo();
|
|
||||||
|
|
||||||
QString toString() const;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class IModRepositoryBridge : QObject
|
|
||||||
{
|
|
||||||
|
|
||||||
%TypeHeaderCode
|
|
||||||
#include <imodrepositorybridge.h>
|
|
||||||
%End
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void requestDescription(int modID, QVariant userData) = 0;
|
|
||||||
virtual void requestFiles(int modID, QVariant userData) = 0;
|
|
||||||
virtual void requestFileInfo(int modID, int fileID, QVariant userData) = 0;
|
|
||||||
virtual void requestDownloadURL(int modID, int fileID, QVariant userData) = 0;
|
|
||||||
virtual void requestToggleEndorsement(int modID, bool endorse, QVariant userData) = 0;
|
|
||||||
|
|
||||||
signals:
|
|
||||||
|
|
||||||
void descriptionAvailable(int modID, QVariant userData, QVariant resultData);
|
|
||||||
void filesAvailable(int modID, QVariant userData, const QList<MOBase::ModRepositoryFileInfo> &resultData);
|
|
||||||
void fileInfoAvailable(int modID, int fileID, QVariant userData, QVariant resultData);
|
|
||||||
void downloadURLsAvailable(int modID, int fileID, QVariant userData, QVariant resultData);
|
|
||||||
void endorsementToggled(int modID, QVariant userData, QVariant resultData);
|
|
||||||
void requestFailed(int modID, QVariant userData, const QString &errorMessage);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#include "resource.h"
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
IDR_LOADER_DLL BINARY MOVEABLE PURE "..\\..\\pythonRunner\\debug\\pythonRunner.dll"
|
||||||
|
#else // _DEBUG
|
||||||
|
IDR_LOADER_DLL BINARY MOVEABLE PURE "..\\..\\pythonRunner\\release\\pythonRunner.dll"
|
||||||
|
#endif // _DEBUG
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
%Module interfaces
|
|
||||||
|
|
||||||
%Include INexusBridge.sip
|
|
||||||
+12
-24
@@ -14,7 +14,6 @@ contains(QT_VERSION, "^5.*") {
|
|||||||
|
|
||||||
CONFIG += plugins
|
CONFIG += plugins
|
||||||
CONFIG += dll
|
CONFIG += dll
|
||||||
CONFIG += warn_on
|
|
||||||
|
|
||||||
CONFIG(release, debug|release) {
|
CONFIG(release, debug|release) {
|
||||||
QMAKE_CXXFLAGS += /Zi
|
QMAKE_CXXFLAGS += /Zi
|
||||||
@@ -23,39 +22,28 @@ CONFIG(release, debug|release) {
|
|||||||
|
|
||||||
DEFINES += PROXYPYTHON_LIBRARY
|
DEFINES += PROXYPYTHON_LIBRARY
|
||||||
|
|
||||||
INCLUDEPATH += "$(BOOSTPATH)" "$$(PYTHONPATH)/include" "$$(PYTHONPATH)/Lib/site-packages/PyQt4/include"
|
SOURCES += proxypython.cpp
|
||||||
# INCLUDEPATH += "$$(SIPPATH)/siplib"
|
|
||||||
|
|
||||||
SOURCES += proxypython.cpp \
|
|
||||||
proxypluginwrappers.cpp \
|
|
||||||
error.cpp \
|
|
||||||
gilock.cpp
|
|
||||||
|
|
||||||
HEADERS += proxypython.h \
|
HEADERS += proxypython.h \
|
||||||
proxypluginwrappers.h \
|
resource.h
|
||||||
uibasewrappers.h \
|
|
||||||
error.h \
|
|
||||||
gilock.h
|
|
||||||
|
|
||||||
LIBS += -L"$$(PYTHONPATH)/libs" -L"$(BOOSTPATH)/stage/lib" -lpython27
|
OTHER_FILES += \
|
||||||
|
proxypython.json \
|
||||||
|
embedrunner.rc
|
||||||
|
|
||||||
|
RC_FILE += \
|
||||||
|
embedrunner.rc
|
||||||
|
|
||||||
include(../plugin_template.pri)
|
include(../plugin_template.pri)
|
||||||
|
|
||||||
OTHER_FILES += \
|
INCLUDEPATH += "../../pythonRunner"
|
||||||
INexusBridge.sip \
|
|
||||||
interfaces.sip \
|
|
||||||
setup.py \
|
|
||||||
setup.cfg \
|
|
||||||
proxypython.json
|
|
||||||
|
|
||||||
WINPWD = $$PWD
|
WINPWD = $$PWD
|
||||||
WINPWD ~= s,/,$$QMAKE_DIR_SEP,g
|
WINPWD ~= s,/,$$QMAKE_DIR_SEP,g
|
||||||
|
|
||||||
|
|
||||||
SIPPATH=""
|
//QMAKE_POST_LINK += SET VS90COMNTOOLS=%VS100COMNTOOLS% $$escape_expand(\\n)
|
||||||
|
|
||||||
QMAKE_POST_LINK += SET VS90COMNTOOLS=%VS100COMNTOOLS% $$escape_expand(\\n)
|
|
||||||
|
|
||||||
QMAKE_POST_LINK += copy $$(PYTHONPATH)\\lib\\site-packages\\sip.pyd $$quote($$DSTDIR)\\plugins\\data\\ $$escape_expand(\\n)
|
QMAKE_POST_LINK += copy $$(PYTHONPATH)\\lib\\site-packages\\sip.pyd $$quote($$DSTDIR)\\plugins\\data\\ $$escape_expand(\\n)
|
||||||
QMAKE_POST_LINK += copy $$(PYTHONPATH)\\lib\\site-packages\\PyQt4\\QtCore.pyd $$quote($$DSTDIR)\\plugins\\data\\ $$escape_expand(\\n)
|
QMAKE_POST_LINK += copy $$(PYTHONPATH)\\lib\\site-packages\\PyQt4\\QtCore.pyd $$quote($$DSTDIR)\\plugins\\data\\PyQt4\\ $$escape_expand(\\n)
|
||||||
QMAKE_POST_LINK += copy $$(PYTHONPATH)\\lib\\site-packages\\PyQt4\\QtGui.pyd $$quote($$DSTDIR)\\plugins\\data\\ $$escape_expand(\\n)
|
QMAKE_POST_LINK += copy $$(PYTHONPATH)\\lib\\site-packages\\PyQt4\\QtGui.pyd $$quote($$DSTDIR)\\plugins\\data\\PyQt4\\ $$escape_expand(\\n)
|
||||||
|
|||||||
+164
-675
File diff suppressed because it is too large
Load Diff
+20
-15
@@ -6,10 +6,7 @@
|
|||||||
#include <iplugindiagnose.h>
|
#include <iplugindiagnose.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
#include <pythonrunner.h>
|
||||||
#ifndef Q_MOC_RUN
|
|
||||||
#include <boost/python.hpp>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
class ProxyPython : public QObject, MOBase::IPluginProxy, MOBase::IPluginDiagnose
|
class ProxyPython : public QObject, MOBase::IPluginProxy, MOBase::IPluginDiagnose
|
||||||
@@ -22,6 +19,7 @@ class ProxyPython : public QObject, MOBase::IPluginProxy, MOBase::IPluginDiagnos
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
ProxyPython();
|
ProxyPython();
|
||||||
|
~ProxyPython();
|
||||||
|
|
||||||
virtual bool init(MOBase::IOrganizer *moInfo);
|
virtual bool init(MOBase::IOrganizer *moInfo);
|
||||||
virtual QString name() const;
|
virtual QString name() const;
|
||||||
@@ -50,20 +48,27 @@ public: // IPluginDiagnose
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool initPython();
|
|
||||||
bool isPythonInstalled() const;
|
|
||||||
bool isPythonVersionSupported() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
const MOBase::IOrganizer *m_MOInfo;
|
|
||||||
|
|
||||||
std::map<QString, boost::python::object> m_PythonObjects;
|
|
||||||
|
|
||||||
static const unsigned int PROBLEM_PYTHONMISSING = 1;
|
static const unsigned int PROBLEM_PYTHONMISSING = 1;
|
||||||
static const unsigned int PROBLEM_PYTHONWRONGVERSION = 2;
|
static const unsigned int PROBLEM_PYTHONWRONGVERSION = 2;
|
||||||
|
static const unsigned int PROBLEM_WRONGPYTHONPATH = 3;
|
||||||
|
static const unsigned int PROBLEM_INITFAIL = 4;
|
||||||
|
static const unsigned int PROBLEM_PYTHONDETECTION = 5;
|
||||||
static const char *s_DownloadPythonURL;
|
static const char *s_DownloadPythonURL;
|
||||||
char *m_PythonHome;
|
|
||||||
|
MOBase::IOrganizer *m_MOInfo;
|
||||||
|
QString m_TempRunnerFile;
|
||||||
|
HMODULE m_RunnerLib;
|
||||||
|
IPythonRunner *m_Runner;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
FAIL_NONE,
|
||||||
|
FAIL_NOTINIT,
|
||||||
|
FAIL_MISSINGDEPENDENCIES,
|
||||||
|
FAIL_INITFAIL,
|
||||||
|
FAIL_WRONGPYTHONPATH,
|
||||||
|
FAIL_PYTHONDETECTION,
|
||||||
|
FAIL_OTHER
|
||||||
|
} m_LoadFailure;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#ifndef RESOURCE_H
|
||||||
|
#define RESOURCE_H
|
||||||
|
|
||||||
|
#define IDR_LOADER_DLL 100
|
||||||
|
|
||||||
|
#endif // RESOURCE_H
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
[build_ext]
|
|
||||||
sip-opts = -e -g -I $$(PYTHONPATH)/Lib/site-packages/PyQt4/sip/PyQt4
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
from distutils.core import setup, Extension
|
|
||||||
import sipdistutils
|
|
||||||
import os, sys
|
|
||||||
|
|
||||||
path = os.path.dirname(sys.argv[0])
|
|
||||||
if len(path) > 0:
|
|
||||||
os.chdir(path)
|
|
||||||
os.environ['PATH'] += r";C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC"
|
|
||||||
print(os.environ['PATH'])
|
|
||||||
|
|
||||||
os.environ['VS90COMNTOOLS'] = os.environ['VS100COMNTOOLS']
|
|
||||||
|
|
||||||
setup(
|
|
||||||
name = 'interfaces',
|
|
||||||
versione = '1.0',
|
|
||||||
ext_modules=[
|
|
||||||
Extension("interfaces", [ "interfaces.sip" ],
|
|
||||||
include_dirs=[ r"C:\QtSDK\Desktop\Qt\4.8.4\include",
|
|
||||||
r"C:\QtSDK\Desktop\Qt\4.8.4\include\QtCore",
|
|
||||||
path + r"\..\..\uibase" ],
|
|
||||||
library_dirs=[ r"C:\QtSDK\Desktop\Qt\4.8.4\lib" ],
|
|
||||||
libraries=[ "QtCore4" ]
|
|
||||||
),
|
|
||||||
],
|
|
||||||
|
|
||||||
cmdclass = {'build_ext': sipdistutils.build_ext}
|
|
||||||
)
|
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
#include "utility.h"
|
|
||||||
#include <boost/python.hpp>
|
#include <boost/python.hpp>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <utility.h>
|
#include <utility.h>
|
||||||
@@ -0,0 +1,213 @@
|
|||||||
|
#include "proxypluginwrappers.h"
|
||||||
|
#include <boost/python.hpp>
|
||||||
|
#include <utility.h>
|
||||||
|
#include "error.h"
|
||||||
|
#include "gilock.h"
|
||||||
|
|
||||||
|
namespace bpy = boost::python;
|
||||||
|
|
||||||
|
using namespace MOBase;
|
||||||
|
|
||||||
|
|
||||||
|
#define PYCATCH catch (const bpy::error_already_set &) { reportPythonError(); throw MyException("unhandled exception"); }\
|
||||||
|
catch (...) { throw MyException("An unknown exception was thrown in python code"); }
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////
|
||||||
|
/// IPluginTool Wrapper
|
||||||
|
|
||||||
|
|
||||||
|
bool IPluginToolWrapper::init(MOBase::IOrganizer *moInfo)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return this->get_override("init")(bpy::ptr(moInfo));
|
||||||
|
} PYCATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString IPluginToolWrapper::name() const
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return this->get_override("name")();
|
||||||
|
} PYCATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString IPluginToolWrapper::author() const
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return this->get_override("author")();
|
||||||
|
} PYCATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString IPluginToolWrapper::description() const
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return this->get_override("description")();
|
||||||
|
} PYCATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
MOBase::VersionInfo IPluginToolWrapper::version() const
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return this->get_override("version")();
|
||||||
|
} PYCATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IPluginToolWrapper::isActive() const
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return this->get_override("isActive")();
|
||||||
|
} PYCATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<MOBase::PluginSetting> IPluginToolWrapper::settings() const
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return this->get_override("settings")();
|
||||||
|
} PYCATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString IPluginToolWrapper::displayName() const
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return this->get_override("displayName")();
|
||||||
|
} PYCATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString IPluginToolWrapper::tooltip() const
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return this->get_override("tooltip")();
|
||||||
|
} PYCATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
QIcon IPluginToolWrapper::icon() const
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return this->get_override("icon")();
|
||||||
|
} 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 {
|
||||||
|
return this->get_override("init")(bpy::ptr(moInfo));
|
||||||
|
} PYCATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString IPluginInstallerCustomWrapper::name() const
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return this->get_override("name")();
|
||||||
|
} PYCATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString IPluginInstallerCustomWrapper::author() const
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return this->get_override("author")();
|
||||||
|
} PYCATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString IPluginInstallerCustomWrapper::description() const
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return this->get_override("description")();
|
||||||
|
} 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 {
|
||||||
|
return this->get_override("settings")();
|
||||||
|
} PYCATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int IPluginInstallerCustomWrapper::priority() const
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return this->get_override("priority")();
|
||||||
|
} PYCATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IPluginInstallerCustomWrapper::isManualInstaller() const
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return this->get_override("isManualInstaller")();
|
||||||
|
} PYCATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IPluginInstallerCustomWrapper::isArchiveSupported(const DirectoryTree &tree) const
|
||||||
|
{
|
||||||
|
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 {
|
||||||
|
return this->get_override("supportedExtensions")();
|
||||||
|
} 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
#ifndef PROXYPLUGINWRAPPERS_H
|
||||||
|
#define PROXYPLUGINWRAPPERS_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <iplugintool.h>
|
||||||
|
#include <iplugininstallersimple.h>
|
||||||
|
#include <iplugininstallercustom.h>
|
||||||
|
#include <iplugindiagnose.h>
|
||||||
|
|
||||||
|
#ifndef Q_MOC_RUN
|
||||||
|
#include <boost/python.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
class IPluginWrapper : public boost::python::wrapper<MOBase::IPlugin>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual bool init(MOBase::IOrganizer *moInfo);
|
||||||
|
virtual QString name() const;
|
||||||
|
virtual QString author() const;
|
||||||
|
virtual QString description() const;
|
||||||
|
virtual MOBase::VersionInfo version() const;
|
||||||
|
virtual bool isActive() const;
|
||||||
|
virtual QList<MOBase::PluginSetting> settings() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class IPluginToolWrapper: public MOBase::IPluginTool, public boost::python::wrapper<MOBase::IPluginTool>
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginTool)
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual bool init(MOBase::IOrganizer *moInfo);
|
||||||
|
virtual QString name() const;
|
||||||
|
virtual QString author() const;
|
||||||
|
virtual QString description() const;
|
||||||
|
virtual MOBase::VersionInfo version() const;
|
||||||
|
virtual bool isActive() const;
|
||||||
|
virtual QList<MOBase::PluginSetting> settings() const;
|
||||||
|
|
||||||
|
virtual QString displayName() const;
|
||||||
|
virtual QString tooltip() const;
|
||||||
|
virtual QIcon icon() const;
|
||||||
|
virtual void setParentWidget(QWidget *parent);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
virtual void display() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class IPluginInstallerCustomWrapper: public MOBase::IPluginInstallerCustom, public boost::python::wrapper<MOBase::IPluginInstallerCustom>
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginInstaller MOBase::IPluginInstallerCustom)
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual bool init(MOBase::IOrganizer *moInfo);
|
||||||
|
virtual QString name() const;
|
||||||
|
virtual QString author() const;
|
||||||
|
virtual QString description() const;
|
||||||
|
virtual MOBase::VersionInfo version() const;
|
||||||
|
virtual bool isActive() const;
|
||||||
|
virtual QList<MOBase::PluginSetting> settings() const;
|
||||||
|
|
||||||
|
virtual unsigned int priority() const;
|
||||||
|
virtual bool isManualInstaller() const;
|
||||||
|
virtual bool isArchiveSupported(const MOBase::DirectoryTree &tree) const;
|
||||||
|
virtual bool isArchiveSupported(const QString &archiveName) const;
|
||||||
|
virtual std::set<QString> supportedExtensions() const;
|
||||||
|
virtual EInstallResult install(MOBase::GuessedValue<QString> &modName, const QString &archiveName,
|
||||||
|
const QString &version, int modID);
|
||||||
|
virtual void setParentWidget(QWidget *parent);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // PROXYPLUGINWRAPPERS_H
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
#-------------------------------------------------
|
||||||
|
#
|
||||||
|
# Project created by QtCreator 2013-09-01T15:55:01
|
||||||
|
#
|
||||||
|
#-------------------------------------------------
|
||||||
|
|
||||||
|
TARGET = pythonRunner
|
||||||
|
TEMPLATE = lib
|
||||||
|
|
||||||
|
CONFIG += dll
|
||||||
|
CONFIG += warn_on
|
||||||
|
|
||||||
|
DEFINES += PYTHONRUNNER_LIBRARY
|
||||||
|
|
||||||
|
SOURCES += pythonrunner.cpp \
|
||||||
|
gilock.cpp \
|
||||||
|
error.cpp \
|
||||||
|
pythonpluginwrapper.cpp \
|
||||||
|
proxypluginwrappers.cpp
|
||||||
|
|
||||||
|
HEADERS += pythonrunner.h \
|
||||||
|
gilock.h \
|
||||||
|
error.h \
|
||||||
|
uibasewrappers.h \
|
||||||
|
pythonpluginwrapper.h \
|
||||||
|
proxypluginwrappers.h
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CONFIG(debug, debug|release) {
|
||||||
|
LIBS += -L$$OUT_PWD/../uibase/debug
|
||||||
|
} else {
|
||||||
|
LIBS += -L$$OUT_PWD/../uibase/release
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
INCLUDEPATH += "$(BOOSTPATH)" "$$(PYTHONPATH)/include" "$$(PYTHONPATH)/Lib/site-packages/PyQt4/include"
|
||||||
|
LIBS += -L"$$(PYTHONPATH)/libs" -L"$(BOOSTPATH)/stage/lib"
|
||||||
|
LIBS += -lpython27
|
||||||
|
|
||||||
|
INCLUDEPATH += ../uibase
|
||||||
|
LIBS += -luibase
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
#include "pythonpluginwrapper.h"
|
||||||
|
|
||||||
|
|
||||||
|
using boost::python::extract;
|
||||||
|
using boost::python::handle_exception;
|
||||||
|
|
||||||
|
|
||||||
|
PythonPluginWrapper::PythonPluginWrapper(const boost::python::object &initFunction,
|
||||||
|
const boost::python::object &nameFunction,
|
||||||
|
const boost::python::object &authorFunction,
|
||||||
|
const boost::python::object &descriptionFunction,
|
||||||
|
const boost::python::object &versionFunction,
|
||||||
|
const boost::python::object &isActiveFunction,
|
||||||
|
const boost::python::object &settingsFunction)
|
||||||
|
: m_InitFunction(initFunction)
|
||||||
|
, m_NameFunction(nameFunction)
|
||||||
|
, m_AuthorFunction(authorFunction)
|
||||||
|
, m_DescriptionFunction(descriptionFunction)
|
||||||
|
, m_VersionFunction(versionFunction)
|
||||||
|
, m_IsActiveFunction(isActiveFunction)
|
||||||
|
, m_SettingsFunction(settingsFunction)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PythonPluginWrapper::reportPythonError() const
|
||||||
|
{
|
||||||
|
if (PyErr_Occurred()) {
|
||||||
|
PyErr_Print();
|
||||||
|
} else {
|
||||||
|
qCritical("An unexpected C++ exception was thrown in python code");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool PythonPluginWrapper::init(MOBase::IOrganizer *moInfo)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return boost::python::extract<bool>(m_InitFunction(boost::python::ptr(moInfo)));
|
||||||
|
} catch (const boost::python::error_already_set&) {
|
||||||
|
reportPythonError();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString PythonPluginWrapper::name() const
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return boost::python::extract<QString>(m_NameFunction());
|
||||||
|
} catch (const boost::python::error_already_set&) {
|
||||||
|
reportPythonError();
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString PythonPluginWrapper::author() const
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return boost::python::extract<QString>(m_AuthorFunction());
|
||||||
|
} catch (const boost::python::error_already_set&) {
|
||||||
|
reportPythonError();
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString PythonPluginWrapper::description() const
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return boost::python::extract<QString>(m_DescriptionFunction());
|
||||||
|
} catch (const boost::python::error_already_set&) {
|
||||||
|
reportPythonError();
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MOBase::VersionInfo PythonPluginWrapper::version() const
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return boost::python::extract<MOBase::VersionInfo>(m_VersionFunction());
|
||||||
|
} catch (const boost::python::error_already_set&) {
|
||||||
|
reportPythonError();
|
||||||
|
return MOBase::VersionInfo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PythonPluginWrapper::isActive() const
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return boost::python::extract<bool>(m_IsActiveFunction());
|
||||||
|
} catch (const boost::python::error_already_set&) {
|
||||||
|
reportPythonError();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<MOBase::PluginSetting> PythonPluginWrapper::settings() const
|
||||||
|
{
|
||||||
|
QList<MOBase::PluginSetting> result;
|
||||||
|
try {
|
||||||
|
boost::python::object l = m_SettingsFunction();
|
||||||
|
if (!l.is_none()) {
|
||||||
|
// boost::python::list l = extract<boost::python::list>(temp);
|
||||||
|
for (int i = 0; i < boost::python::len(l); ++i) {
|
||||||
|
result.append(extract<MOBase::PluginSetting>(l[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (const boost::python::error_already_set&) {
|
||||||
|
reportPythonError();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
#ifndef PYTHONPLUGINWRAPPER_H
|
||||||
|
#define PYTHONPLUGINWRAPPER_H
|
||||||
|
|
||||||
|
#include <iplugin.h>
|
||||||
|
#ifndef Q_MOC_RUN
|
||||||
|
#include <boost/python.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class PythonPluginWrapper : public virtual MOBase::IPlugin
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
PythonPluginWrapper(const boost::python::object &initFunction,
|
||||||
|
const boost::python::object &nameFunction,
|
||||||
|
const boost::python::object &authorFunction,
|
||||||
|
const boost::python::object &descriptionFunction,
|
||||||
|
const boost::python::object &versionFunction,
|
||||||
|
const boost::python::object &isActiveFunction,
|
||||||
|
const boost::python::object &settingsFunction);
|
||||||
|
|
||||||
|
virtual bool init(MOBase::IOrganizer *moInfo);
|
||||||
|
virtual QString name() const;
|
||||||
|
virtual QString author() const;
|
||||||
|
virtual QString description() const;
|
||||||
|
virtual MOBase::VersionInfo version() const;
|
||||||
|
virtual bool isActive() const;
|
||||||
|
virtual QList<MOBase::PluginSetting> settings() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void reportPythonError() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
boost::python::object m_InitFunction;
|
||||||
|
boost::python::object m_NameFunction;
|
||||||
|
boost::python::object m_AuthorFunction;
|
||||||
|
boost::python::object m_DescriptionFunction;
|
||||||
|
boost::python::object m_VersionFunction;
|
||||||
|
boost::python::object m_IsActiveFunction;
|
||||||
|
boost::python::object m_SettingsFunction;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PYTHONPLUGINWRAPPER_H
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,29 @@
|
|||||||
|
#ifndef PYTHONRUNNER_H
|
||||||
|
#define PYTHONRUNNER_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QObject>
|
||||||
|
#include <map>
|
||||||
|
#include <dllimport.h>
|
||||||
|
#include <imoinfo.h>
|
||||||
|
|
||||||
|
|
||||||
|
class IPythonRunner {
|
||||||
|
public:
|
||||||
|
virtual QObject *instantiate(const QString &pluginName) = 0;
|
||||||
|
virtual bool isPythonInstalled() const = 0;
|
||||||
|
virtual bool isPythonVersionSupported() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef PYTHONRUNNER_LIBRARY
|
||||||
|
#define PYDLLEXPORT Q_DECL_EXPORT
|
||||||
|
#else // PYTHONRUNNER_LIBRARY
|
||||||
|
#define PYDLLEXPORT Q_DECL_IMPORT
|
||||||
|
#endif // PYTHONRUNNER_LIBRARY
|
||||||
|
|
||||||
|
extern "C" PYDLLEXPORT IPythonRunner *CreatePythonRunner(const MOBase::IOrganizer *moInfo, const QString &pythonDir);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // PYTHONRUNNER_H
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user