mirror of
https://github.com/ModOrganizer2/modorganizer-plugin_python.git
synced 2026-07-27 14:03:33 -07:00
Compare commits
76
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d8f49b3906 | ||
|
|
25d9ad16c2 | ||
|
|
a5901d7975 | ||
|
|
a7b81418a5 | ||
|
|
560e1ce0c7 | ||
|
|
6edbec745d | ||
|
|
d6edcf4fa0 | ||
|
|
50a725a1b4 | ||
|
|
a1fdb54471 | ||
|
|
e602014dda | ||
|
|
90df417a8c | ||
|
|
cb9a7fcd2d | ||
|
|
9d2264aff8 | ||
|
|
0aeeb9365f | ||
|
|
3967d64437 | ||
|
|
a7e881869e | ||
|
|
3f66d206e8 | ||
|
|
9d48b75388 | ||
|
|
841b923751 | ||
|
|
23fd430605 | ||
|
|
1a89e42c0f | ||
|
|
42afc90c8d | ||
|
|
9b989e9f97 | ||
|
|
c7203bf9de | ||
|
|
a7d626c83c | ||
|
|
bbea63e7af | ||
|
|
9f607a5fcb | ||
|
|
b7edde6fa0 | ||
|
|
589325d91b | ||
|
|
994018a491 | ||
|
|
868ab93a1f | ||
|
|
7c8fafc196 | ||
|
|
dec620b5b7 | ||
|
|
29c66c621d | ||
|
|
5da6a9d3bd | ||
|
|
7b5f01b49d | ||
|
|
573be8c6b5 | ||
|
|
a738cef190 | ||
|
|
2c661da2da | ||
|
|
2bf3ba0984 | ||
|
|
fa09fd7635 | ||
|
|
b76c4a1869 | ||
|
|
84fe2b0307 | ||
|
|
e7e686c361 | ||
|
|
ae8b6a39b0 | ||
|
|
2dc9463951 | ||
|
|
1d4a4b485d | ||
|
|
d5838c7560 | ||
|
|
9cbf374166 | ||
|
|
f71bfff0e6 | ||
|
|
8aa2ab4eac | ||
|
|
46a0ce9e38 | ||
|
|
15e635741c | ||
|
|
f56c605479 | ||
|
|
617c76e9f8 | ||
|
|
96081888f1 | ||
|
|
af5958b0af | ||
|
|
b33293e49a | ||
|
|
dc3b60e578 | ||
|
|
d591bc017a | ||
|
|
aad5864192 | ||
|
|
7deee938d3 | ||
|
|
5d51b2bcc6 | ||
|
|
0566a968e8 | ||
|
|
14fc674d72 | ||
|
|
b7cbdaad1e | ||
|
|
25cdcdd2fe | ||
|
|
f06a6d4e55 | ||
|
|
ceab36e5f0 | ||
|
|
e158038cfc | ||
|
|
d4c424911a | ||
|
|
fee774db45 | ||
|
|
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,32 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
Import('qt_env')
|
||||||
|
|
||||||
|
env = qt_env.Clone()
|
||||||
|
|
||||||
|
env.AppendUnique(CPPDEFINES = [
|
||||||
|
'PROXYPYTHON_LIBRARY',
|
||||||
|
# suppress a few warnings caused by boost vs vc++ paranoia
|
||||||
|
'_SCL_SECURE_NO_WARNINGS'
|
||||||
|
])
|
||||||
|
|
||||||
|
env.AppendUnique(CPPPATH = [
|
||||||
|
'${BOOSTPATH}',
|
||||||
|
'..\\..\\pythonRunner'
|
||||||
|
])
|
||||||
|
|
||||||
|
env.AppendUnique(LIBS = 'shell32')
|
||||||
|
|
||||||
|
runner = env.File(os.path.join('..', '..', 'pythonRunner', 'pythonRunner.dll'))
|
||||||
|
|
||||||
|
runner_env = env.Clone()
|
||||||
|
runner_env.AppendUnique(CPPDEFINES = 'SCONS_BUILD')
|
||||||
|
runner_env.AppendUnique(CPPPATH = runner.dir)
|
||||||
|
|
||||||
|
# There's a whole load of unused C++ files in here.
|
||||||
|
lib = env.SharedLibrary('proxyPython', [ 'proxypython.cpp' ])
|
||||||
|
|
||||||
|
env.InstallModule(lib)
|
||||||
|
|
||||||
|
res = env['QT_USED_MODULES']
|
||||||
|
Return('res')
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#include "resource.h"
|
||||||
|
|
||||||
|
#ifdef SCONS_BUILD
|
||||||
|
IDR_LOADER_DLL BINARY MOVEABLE PURE pythonRunner.dll
|
||||||
|
#else
|
||||||
|
#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
|
||||||
|
#endif
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
%Module interfaces
|
|
||||||
|
|
||||||
%Include INexusBridge.sip
|
|
||||||
+15
-28
@@ -8,13 +8,10 @@
|
|||||||
TARGET = proxyPython
|
TARGET = proxyPython
|
||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
|
|
||||||
contains(QT_VERSION, "^5.*") {
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||||
QT += widgets
|
|
||||||
}
|
|
||||||
|
|
||||||
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 +20,29 @@ CONFIG(release, debug|release) {
|
|||||||
|
|
||||||
DEFINES += PROXYPYTHON_LIBRARY
|
DEFINES += PROXYPYTHON_LIBRARY
|
||||||
|
|
||||||
INCLUDEPATH += "$(BOOSTPATH)" "$$(PYTHONPATH)/include" "$$(PYTHONPATH)/Lib/site-packages/PyQt4/include"
|
# suppress a few warnings caused by boost vs vc++ paranoia
|
||||||
# INCLUDEPATH += "$$(SIPPATH)/siplib"
|
DEFINES += _SCL_SECURE_NO_WARNINGS
|
||||||
|
|
||||||
SOURCES += proxypython.cpp \
|
|
||||||
proxypluginwrappers.cpp \
|
|
||||||
error.cpp \
|
|
||||||
gilock.cpp
|
|
||||||
|
|
||||||
|
SOURCES += proxypython.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 \
|
||||||
|
SConscript
|
||||||
|
|
||||||
|
RC_FILE +=
|
||||||
|
|
||||||
include(../plugin_template.pri)
|
include(../plugin_template.pri)
|
||||||
|
|
||||||
OTHER_FILES += \
|
INCLUDEPATH += "../../pythonRunner" "$${BOOSTPATH}"
|
||||||
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
|
||||||
|
|
||||||
|
#QMAKE_POST_LINK += SET VS90COMNTOOLS=%VS100COMNTOOLS% $$escape_expand(\\n)
|
||||||
|
|
||||||
SIPPATH=""
|
|
||||||
|
|
||||||
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\\PyQt4\\QtCore.pyd $$quote($$DSTDIR)\\plugins\\data\\PyQt4\\ $$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\\QtGui.pyd $$quote($$DSTDIR)\\plugins\\data\\PyQt4\\ $$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\\QtGui.pyd $$quote($$DSTDIR)\\plugins\\data\\ $$escape_expand(\\n)
|
|
||||||
|
|||||||
+208
-671
File diff suppressed because it is too large
Load Diff
+42
-16
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2013 Sebastian Herbord. All rights reserved.
|
||||||
|
|
||||||
|
This file is part of python proxy plugin for MO
|
||||||
|
|
||||||
|
python proxy plugin is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Python proxy plugin is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with python proxy plugin. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef PROXYPYTHON_H
|
#ifndef PROXYPYTHON_H
|
||||||
#define PROXYPYTHON_H
|
#define PROXYPYTHON_H
|
||||||
|
|
||||||
@@ -6,13 +25,10 @@
|
|||||||
#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, public MOBase::IPluginProxy, public MOBase::IPluginDiagnose
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginProxy MOBase::IPluginDiagnose)
|
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginProxy MOBase::IPluginDiagnose)
|
||||||
@@ -22,6 +38,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 +67,29 @@ 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 unsigned int PROBLEM_SEMICOLON = 6;
|
||||||
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_SEMICOLON,
|
||||||
|
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,159 +0,0 @@
|
|||||||
#ifndef UIBASEWRAPPERS_H
|
|
||||||
#define UIBASEWRAPPERS_H
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef Q_MOC_RUN
|
|
||||||
#include <boost/python.hpp>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
#include <imoinfo.h>
|
|
||||||
#include <igameinfo.h>
|
|
||||||
#include <imodrepositorybridge.h>
|
|
||||||
#include "error.h"
|
|
||||||
#include "gilock.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern MOBase::IOrganizer *s_Organizer;
|
|
||||||
|
|
||||||
using MOBase::ModRepositoryFileInfo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Wrapper class for the bridge to a mod repository. Awkward: This may be
|
|
||||||
* unnecessary but I didn't manage to figure out how to correctly connect python
|
|
||||||
* code to C++ signals
|
|
||||||
*/
|
|
||||||
class ModRepositoryBridgeWrapper : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
|
|
||||||
ModRepositoryBridgeWrapper()
|
|
||||||
: m_Wrapped(s_Organizer->createNexusBridge())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
ModRepositoryBridgeWrapper(MOBase::IModRepositoryBridge *wrapped)
|
|
||||||
: m_Wrapped(wrapped)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
~ModRepositoryBridgeWrapper()
|
|
||||||
{
|
|
||||||
delete m_Wrapped;
|
|
||||||
}
|
|
||||||
|
|
||||||
void requestDescription(int modID, QVariant userData)
|
|
||||||
{ m_Wrapped->requestDescription(modID, userData); }
|
|
||||||
void requestFiles(int modID, QVariant userData)
|
|
||||||
{ m_Wrapped->requestFiles(modID, userData); }
|
|
||||||
void requestFileInfo(int modID, int fileID, QVariant userData)
|
|
||||||
{ m_Wrapped->requestFileInfo(modID, fileID, userData); }
|
|
||||||
void requestDownloadURL(int modID, int fileID, QVariant userData)
|
|
||||||
{ m_Wrapped->requestDownloadURL(modID, fileID, userData); }
|
|
||||||
void requestToggleEndorsement(int modID, bool endorse, QVariant userData)
|
|
||||||
{ m_Wrapped->requestToggleEndorsement(modID, endorse, userData); }
|
|
||||||
|
|
||||||
void onFilesAvailable(boost::python::object callback) {
|
|
||||||
m_FilesAvailableHandler = callback;
|
|
||||||
connect(m_Wrapped, SIGNAL(filesAvailable(int,QVariant,const QList<ModRepositoryFileInfo>&)),
|
|
||||||
this, SLOT(filesAvailable(int,QVariant,const QList<ModRepositoryFileInfo>&)),
|
|
||||||
Qt::UniqueConnection);
|
|
||||||
}
|
|
||||||
|
|
||||||
void onRequestFailed(boost::python::object callback) {
|
|
||||||
m_FailedHandler = callback;
|
|
||||||
connect(m_Wrapped, SIGNAL(requestFailed(int,QVariant,QString)),
|
|
||||||
this, SLOT(requestFailed(int,QVariant,QString)),
|
|
||||||
Qt::UniqueConnection);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
Q_DISABLE_COPY(ModRepositoryBridgeWrapper)
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
|
|
||||||
void filesAvailable(int modID, QVariant userData, const QList<ModRepositoryFileInfo> &resultData)
|
|
||||||
{
|
|
||||||
if (m_FilesAvailableHandler.is_none()) {
|
|
||||||
qCritical("no handler connected");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// try {
|
|
||||||
GILock lock;
|
|
||||||
m_FilesAvailableHandler(modID, userData, resultData);
|
|
||||||
// } catch (const boost::python::error_already_set&) {
|
|
||||||
// qDebug("error");
|
|
||||||
//reportPythonError();
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
void requestFailed(int modID, QVariant userData, const QString &errorMessage)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
GILock lock;
|
|
||||||
m_FailedHandler(modID, userData, errorMessage);
|
|
||||||
} catch (const boost::python::error_already_set&) {
|
|
||||||
reportPythonError();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
MOBase::IModRepositoryBridge *m_Wrapped;
|
|
||||||
boost::python::object m_FilesAvailableHandler;
|
|
||||||
boost::python::object m_FailedHandler;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
struct IOrganizerWrapper: MOBase::IOrganizer, boost::python::wrapper<MOBase::IOrganizer>
|
|
||||||
{
|
|
||||||
virtual MOBase::IGameInfo &gameInfo() const {
|
|
||||||
MOBase::IGameInfo *result = this->get_override("gameInfo")();
|
|
||||||
return *result;
|
|
||||||
}
|
|
||||||
virtual MOBase::IModRepositoryBridge *createNexusBridge() const {
|
|
||||||
return this->get_override("createNexusBridge")();
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
static ModRepositoryBridgeWrapper newNexusBridge(IOrganizerWrapper *self) {
|
|
||||||
return ModRepositoryBridgeWrapper(self->createNexusBridge());
|
|
||||||
}*/
|
|
||||||
|
|
||||||
virtual QString profileName() const { return this->get_override("profileName")(); }
|
|
||||||
virtual QString profilePath() const { return this->get_override("profilePath")(); }
|
|
||||||
virtual QString downloadsPath() const { return this->get_override("downloadsPath")(); }
|
|
||||||
virtual MOBase::VersionInfo appVersion() const { return this->get_override("appVersion")(); }
|
|
||||||
virtual MOBase::IModInterface *getMod(const QString &name) { return this->get_override("getMod")(name); }
|
|
||||||
virtual MOBase::IModInterface *createMod(MOBase::GuessedValue<QString> &name) { return this->get_override("createMod")(name); }
|
|
||||||
virtual bool removeMod(MOBase::IModInterface *mod) { return this->get_override("removeMod")(mod); }
|
|
||||||
virtual void modDataChanged(MOBase::IModInterface *mod) { this->get_override("modDataChanged")(mod); }
|
|
||||||
virtual QVariant pluginSetting(const QString &pluginName, const QString &key) const { return this->get_override("pluginSetting")(pluginName, key); }
|
|
||||||
virtual QString pluginDataPath() const { return this->get_override("pluginDataPath")(); }
|
|
||||||
virtual void installMod(const QString &fileName) { this->get_override("installMod")(fileName); }
|
|
||||||
virtual MOBase::IDownloadManager *downloadManager() { return this->get_override("downloadManager")(); }
|
|
||||||
virtual QString resolvePath(const QString &fileName) const { return this->get_override("resolvePath")(fileName); }
|
|
||||||
};
|
|
||||||
|
|
||||||
struct IDownloadManagerWrapper: MOBase::IDownloadManager, boost::python::wrapper<MOBase::IDownloadManager>
|
|
||||||
{
|
|
||||||
virtual int startDownloadURLs(const QStringList &urls) { return this->get_override("downloadURLs")(urls); }
|
|
||||||
virtual int startDownloadNexusFile(int modID, int fileID) { return this->get_override("downloadNexusFile")(modID, fileID); }
|
|
||||||
virtual QString downloadPath(int id) { return this->get_override("downloadPath")(id); }
|
|
||||||
private:
|
|
||||||
boost::python::object m_DownloadCompleteHandler;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct IGameInfoWrapper: MOBase::IGameInfo, boost::python::wrapper<MOBase::IGameInfo>
|
|
||||||
{
|
|
||||||
virtual Type type() const { return this->get_override("type")(); }
|
|
||||||
virtual QString path() const { return this->get_override("path")(); }
|
|
||||||
virtual QString binaryName() const { return this->get_override("binaryName")(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif // UIBASEWRAPPERS_H
|
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
Import('qt_env')
|
||||||
|
|
||||||
|
env = qt_env.Clone()
|
||||||
|
|
||||||
|
env.EnableQtModules('Core', 'Gui')
|
||||||
|
|
||||||
|
env.AppendUnique(CPPDEFINES = 'PYTHONRUNNER_LIBRARY')
|
||||||
|
|
||||||
|
# suppress a few warnings caused by boost vs vc++ paranoia
|
||||||
|
# NB HAVE_ROUND causes a warning because it's defined in pythonrunner.cpp
|
||||||
|
env.AppendUnique(CPPDEFINES = [
|
||||||
|
'_SCL_SECURE_NO_WARNINGS',
|
||||||
|
'HAVE_ROUND'
|
||||||
|
])
|
||||||
|
|
||||||
|
# QMAKE_CXXFLAGS += /Zi
|
||||||
|
# QMAKE_LFLAGS += /DEBUG
|
||||||
|
|
||||||
|
env.RequireLibraries('uibase')
|
||||||
|
|
||||||
|
# AppendUnique appears not to work with QT4
|
||||||
|
env['CPPPATH'] += [
|
||||||
|
'${BOOSTPATH}',
|
||||||
|
'${PYTHONPATH}\\include',
|
||||||
|
]
|
||||||
|
|
||||||
|
env.AppendUnique(LIBS = [
|
||||||
|
'python27', # Could be done better
|
||||||
|
])
|
||||||
|
|
||||||
|
env.AppendUnique(LIBPATH = [
|
||||||
|
'${PYTHONPATH}/libs', # Could be done better
|
||||||
|
])
|
||||||
|
|
||||||
|
# We have to 'persuade' moc to generate certain other targets and inject them
|
||||||
|
# into the list of cpps
|
||||||
|
targets = env.AddExtraMoc(env.Glob('*.h'))
|
||||||
|
|
||||||
|
# pythontoolwrapper doesnt compile and isn't in the project file
|
||||||
|
cpp_files = [
|
||||||
|
x for x in Glob('*.cpp') if x.name != 'pythontoolwrapper.cpp'
|
||||||
|
]
|
||||||
|
|
||||||
|
lib = env.SharedLibrary('pythonRunner', cpp_files + targets)
|
||||||
|
|
||||||
|
env.InstallModule(lib, 'plugins/data')
|
||||||
|
|
||||||
|
# However...
|
||||||
|
# we do need boost-python and pythonvv.dll and pythonvv.zip (though the last
|
||||||
|
# isn't needed to just bring up the module)
|
||||||
|
#env.Pseudo('install')
|
||||||
|
#env.Depends('install',
|
||||||
|
# (env.Install('${INSTALL_PATH}', 'pyCfg.py'),
|
||||||
|
# env.Install(os.path.join('${INSTALL_PATH}', 'data'),
|
||||||
|
# ( ui, rc, 'settings.json' )),
|
||||||
|
# ))
|
||||||
|
|
||||||
|
res = env['QT_USED_MODULES']
|
||||||
|
Return('res')
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "utility.h"
|
#ifndef Q_MOC_RUN
|
||||||
#include <boost/python.hpp>
|
#include <boost/python.hpp>
|
||||||
|
#endif
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <utility.h>
|
#include <utility.h>
|
||||||
|
|
||||||
@@ -0,0 +1,212 @@
|
|||||||
|
#include "proxypluginwrappers.h"
|
||||||
|
#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")().as<QString>();
|
||||||
|
} PYCATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString IPluginToolWrapper::author() const
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return this->get_override("author")().as<QString>();
|
||||||
|
} PYCATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString IPluginToolWrapper::description() const
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return this->get_override("description")().as<QString>();
|
||||||
|
} PYCATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
MOBase::VersionInfo IPluginToolWrapper::version() const
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return this->get_override("version")().as<MOBase::VersionInfo>();
|
||||||
|
} PYCATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IPluginToolWrapper::isActive() const
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return this->get_override("isActive")().as<bool>();
|
||||||
|
} PYCATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<MOBase::PluginSetting> IPluginToolWrapper::settings() const
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return this->get_override("settings")().as<QList<MOBase::PluginSetting>>();
|
||||||
|
} PYCATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString IPluginToolWrapper::displayName() const
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return this->get_override("displayName")().as<QString>();
|
||||||
|
} PYCATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString IPluginToolWrapper::tooltip() const
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return this->get_override("tooltip")().as<QString>();
|
||||||
|
} PYCATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
QIcon IPluginToolWrapper::icon() const
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return this->get_override("icon")().as<QIcon>();
|
||||||
|
} 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")().as<QString>();
|
||||||
|
} PYCATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString IPluginInstallerCustomWrapper::author() const
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return this->get_override("author")().as<QString>();
|
||||||
|
} PYCATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString IPluginInstallerCustomWrapper::description() const
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return this->get_override("description")().as<QString>();
|
||||||
|
} 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")().as<QList<MOBase::PluginSetting>>();
|
||||||
|
} 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 &) 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")().as<std::set<QString>>();
|
||||||
|
} 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,79 @@
|
|||||||
|
#ifndef PROXYPLUGINWRAPPERS_H
|
||||||
|
#define PROXYPLUGINWRAPPERS_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <iplugintool.h>
|
||||||
|
#include <iplugininstallersimple.h>
|
||||||
|
#include <iplugininstallercustom.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,64 @@
|
|||||||
|
#-------------------------------------------------
|
||||||
|
#
|
||||||
|
# Project created by QtCreator 2013-09-01T15:55:01
|
||||||
|
#
|
||||||
|
#-------------------------------------------------
|
||||||
|
|
||||||
|
TARGET = pythonRunner
|
||||||
|
TEMPLATE = lib
|
||||||
|
|
||||||
|
CONFIG += dll
|
||||||
|
CONFIG += warn_on
|
||||||
|
|
||||||
|
DEFINES += PYTHONRUNNER_LIBRARY
|
||||||
|
|
||||||
|
# suppress a few warnings caused by boost vs vc++ paranoia
|
||||||
|
DEFINES += _SCL_SECURE_NO_WARNINGS HAVE_ROUND NOMINMAX
|
||||||
|
|
||||||
|
|
||||||
|
!include(../LocalPaths.pri) {
|
||||||
|
message("paths to required libraries need to be set up in LocalPaths.pri")
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
msvc:QMAKE_CXXFLAGS += /Zi
|
||||||
|
msvc:QMAKE_LFLAGS += /DEBUG
|
||||||
|
}
|
||||||
|
|
||||||
|
INCLUDEPATH += "$${BOOSTPATH}" "$${PYTHONPATH}/include" "$${PYTHONPATH}/Lib/site-packages/PyQt5/include" ../uibase
|
||||||
|
LIBS += -L"$${PYTHONPATH}/libs" -L"$${BOOSTPATH}/stage/lib"
|
||||||
|
LIBS += -lpython27
|
||||||
|
LIBS += -luibase
|
||||||
|
|
||||||
|
CONFIG(debug, debug|release) {
|
||||||
|
SRCDIR = $$OUT_PWD/debug
|
||||||
|
DSTDIR = $$PWD/../../outputd
|
||||||
|
} else {
|
||||||
|
SRCDIR = $$OUT_PWD/release
|
||||||
|
DSTDIR = $$PWD/../../output
|
||||||
|
}
|
||||||
|
|
||||||
|
SRCDIR ~= s,/,$$QMAKE_DIR_SEP,g
|
||||||
|
DSTDIR ~= s,/,$$QMAKE_DIR_SEP,g
|
||||||
|
|
||||||
|
QMAKE_POST_LINK += xcopy /y /s /i $$quote($$SRCDIR\\$${TARGET}*.dll) $$quote($$DSTDIR)\\plugins\\data $$escape_expand(\\n)
|
||||||
|
QMAKE_POST_LINK += xcopy /y /I $$quote($$SRCDIR\\$${TARGET}*.pdb) $$quote($$DSTDIR)\\plugins $$escape_expand(\\n)
|
||||||
|
|
||||||
|
OTHER_FILES += \
|
||||||
|
SConscript
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
#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()) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user