mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
PyFalkon: Fix C linkage issues
BUG: 413093 FIXED-IN: 3.1.1
This commit is contained in:
parent
1363b848a5
commit
bfb9420cbb
@ -220,11 +220,12 @@ void Plugins::loadAvailablePlugins()
|
|||||||
|
|
||||||
// PythonPlugin
|
// PythonPlugin
|
||||||
if (m_pythonPlugin) {
|
if (m_pythonPlugin) {
|
||||||
auto f = (QVector<Plugin>(*)()) m_pythonPlugin->resolve("pyfalkon_load_available_plugins");
|
auto f = (void(*)(QVector<Plugin>*)) m_pythonPlugin->resolve("pyfalkon_load_available_plugins");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
qWarning() << "Failed to resolve" << "pyfalkon_load_available_plugins";
|
qWarning() << "Failed to resolve" << "pyfalkon_load_available_plugins";
|
||||||
} else {
|
} else {
|
||||||
const auto plugins = f();
|
QVector<Plugin> plugins;
|
||||||
|
f(&plugins);
|
||||||
for (const auto &plugin : plugins) {
|
for (const auto &plugin : plugins) {
|
||||||
registerAvailablePlugin(plugin);
|
registerAvailablePlugin(plugin);
|
||||||
}
|
}
|
||||||
@ -382,13 +383,15 @@ Plugins::Plugin Plugins::loadPythonPlugin(const QString &name)
|
|||||||
return Plugin();
|
return Plugin();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto f = (Plugin(*)(const QString &)) m_pythonPlugin->resolve("pyfalkon_load_plugin");
|
auto f = (bool(*)(const QString &,Plugin*)) m_pythonPlugin->resolve("pyfalkon_load_plugin");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
qWarning() << "Failed to resolve" << "pyfalkon_load_plugin";
|
qWarning() << "Failed to resolve" << "pyfalkon_load_plugin";
|
||||||
return Plugin();
|
return Plugin();
|
||||||
}
|
}
|
||||||
|
|
||||||
return f(name);
|
Plugin plugin;
|
||||||
|
f(name, &plugin);
|
||||||
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Plugins::initPlugin(PluginInterface::InitState state, Plugin *plugin)
|
bool Plugins::initPlugin(PluginInterface::InitState state, Plugin *plugin)
|
||||||
|
@ -91,7 +91,7 @@ void pyfalkon_register_plugin(PluginInterface *plugin)
|
|||||||
pluginInterface = plugin;
|
pluginInterface = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
Plugins::Plugin pyfalkon_load_plugin(const QString &name)
|
bool pyfalkon_load_plugin(const QString &name, Plugins::Plugin *out)
|
||||||
{
|
{
|
||||||
QString fullPath;
|
QString fullPath;
|
||||||
if (QFileInfo(name).isAbsolute()) {
|
if (QFileInfo(name).isAbsolute()) {
|
||||||
@ -100,15 +100,14 @@ Plugins::Plugin pyfalkon_load_plugin(const QString &name)
|
|||||||
fullPath = DataPaths::locate(DataPaths::Plugins, QSL("python/") + name);
|
fullPath = DataPaths::locate(DataPaths::Plugins, QSL("python/") + name);
|
||||||
if (fullPath.isEmpty()) {
|
if (fullPath.isEmpty()) {
|
||||||
qWarning() << "Plugin" << name << "not found";
|
qWarning() << "Plugin" << name << "not found";
|
||||||
return Plugins::Plugin();
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Plugins::Plugin plugin;
|
out->type = Plugins::Plugin::PythonPlugin;
|
||||||
plugin.type = Plugins::Plugin::PythonPlugin;
|
out->pluginId = QSL("python:%1").arg(QFileInfo(name).fileName());
|
||||||
plugin.pluginId = QSL("python:%1").arg(QFileInfo(name).fileName());
|
out->pluginSpec = Plugins::createSpec(DesktopFile(fullPath + QSL("/metadata.desktop")));
|
||||||
plugin.pluginSpec = Plugins::createSpec(DesktopFile(fullPath + QSL("/metadata.desktop")));
|
return true;
|
||||||
return plugin;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void pyfalkon_init_plugin(Plugins::Plugin *plugin)
|
void pyfalkon_init_plugin(Plugins::Plugin *plugin)
|
||||||
@ -143,24 +142,21 @@ void pyfalkon_init_plugin(Plugins::Plugin *plugin)
|
|||||||
plugin->data = QVariant::fromValue(static_cast<void*>(module));
|
plugin->data = QVariant::fromValue(static_cast<void*>(module));
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<Plugins::Plugin> pyfalkon_load_available_plugins()
|
void pyfalkon_load_available_plugins(QVector<Plugins::Plugin> *out)
|
||||||
{
|
{
|
||||||
QVector<Plugins::Plugin> plugins;
|
|
||||||
|
|
||||||
const QStringList dirs = script_paths();
|
const QStringList dirs = script_paths();
|
||||||
for (const QString &dir : dirs) {
|
for (const QString &dir : dirs) {
|
||||||
const auto modules = QDir(dir).entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
|
const auto modules = QDir(dir).entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||||
for (const QFileInfo &info : modules) {
|
for (const QFileInfo &info : modules) {
|
||||||
Plugins::Plugin plugin = pyfalkon_load_plugin(info.absoluteFilePath());
|
Plugins::Plugin plugin;
|
||||||
|
pyfalkon_load_plugin(info.absoluteFilePath(), &plugin);
|
||||||
if (plugin.pluginSpec.name.isEmpty()) {
|
if (plugin.pluginSpec.name.isEmpty()) {
|
||||||
qWarning() << "Invalid plugin spec of" << info.absoluteFilePath() << "plugin";
|
qWarning() << "Invalid plugin spec of" << info.absoluteFilePath() << "plugin";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
plugins.append(plugin);
|
out->append(plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return plugins;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pyfalkon_run_script(const QByteArray &script)
|
bool pyfalkon_run_script(const QByteArray &script)
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
|
|
||||||
void pyfalkon_register_plugin(PluginInterface *plugin);
|
void pyfalkon_register_plugin(PluginInterface *plugin);
|
||||||
|
|
||||||
extern "C" Q_DECL_EXPORT Plugins::Plugin pyfalkon_load_plugin(const QString &name);
|
extern "C" Q_DECL_EXPORT bool pyfalkon_load_plugin(const QString &name, Plugins::Plugin *out);
|
||||||
extern "C" Q_DECL_EXPORT void pyfalkon_init_plugin(Plugins::Plugin *plugin);
|
extern "C" Q_DECL_EXPORT void pyfalkon_init_plugin(Plugins::Plugin *plugin);
|
||||||
extern "C" Q_DECL_EXPORT QVector<Plugins::Plugin> pyfalkon_load_available_plugins();
|
extern "C" Q_DECL_EXPORT void pyfalkon_load_available_plugins(QVector<Plugins::Plugin> *out);
|
||||||
|
|
||||||
extern "C" Q_DECL_EXPORT bool pyfalkon_run_script(const QByteArray &script);
|
extern "C" Q_DECL_EXPORT bool pyfalkon_run_script(const QByteArray &script);
|
||||||
|
Loading…
Reference in New Issue
Block a user