mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-08-03 03:56:08 -04:00
Support proper plugin finding.
So we don't have to hardcode the location anymore.
This commit is contained in:
parent
7fef3bd701
commit
2a45f57386
7 changed files with 62 additions and 10 deletions
|
@ -23,6 +23,7 @@
|
||||||
#include "autotype/AutoTypePlatformPlugin.h"
|
#include "autotype/AutoTypePlatformPlugin.h"
|
||||||
#include "core/Database.h"
|
#include "core/Database.h"
|
||||||
#include "core/Entry.h"
|
#include "core/Entry.h"
|
||||||
|
#include "core/FilePath.h"
|
||||||
#include "core/Group.h"
|
#include "core/Group.h"
|
||||||
#include "core/ListDeleter.h"
|
#include "core/ListDeleter.h"
|
||||||
#include "core/Tools.h"
|
#include "core/Tools.h"
|
||||||
|
@ -39,10 +40,21 @@ AutoType::AutoType(QObject* parent)
|
||||||
// prevent crash when the plugin has unresolved symbols
|
// prevent crash when the plugin has unresolved symbols
|
||||||
m_pluginLoader->setLoadHints(QLibrary::ResolveAllSymbolsHint);
|
m_pluginLoader->setLoadHints(QLibrary::ResolveAllSymbolsHint);
|
||||||
|
|
||||||
// TODO: scan in proper paths
|
QString pluginPath = filePath()->pluginPath("keepassx-autotype-" + Tools::platform());
|
||||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
|
|
||||||
m_pluginLoader->setFileName(QCoreApplication::applicationDirPath() + "/autotype/x11/libkeepassx-autotype-x11.so");
|
if (!pluginPath.isEmpty()) {
|
||||||
#endif
|
loadPlugin(pluginPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AutoType::~AutoType()
|
||||||
|
{
|
||||||
|
delete m_executor;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AutoType::loadPlugin(const QString& pluginPath)
|
||||||
|
{
|
||||||
|
m_pluginLoader->setFileName(pluginPath);
|
||||||
|
|
||||||
QObject* pluginInstance = m_pluginLoader->instance();
|
QObject* pluginInstance = m_pluginLoader->instance();
|
||||||
if (pluginInstance) {
|
if (pluginInstance) {
|
||||||
|
@ -58,11 +70,6 @@ AutoType::AutoType(QObject* parent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoType::~AutoType()
|
|
||||||
{
|
|
||||||
delete m_executor;
|
|
||||||
}
|
|
||||||
|
|
||||||
AutoType* AutoType::instance()
|
AutoType* AutoType::instance()
|
||||||
{
|
{
|
||||||
if (!m_instance) {
|
if (!m_instance) {
|
||||||
|
|
|
@ -57,6 +57,7 @@ Q_SIGNALS:
|
||||||
private:
|
private:
|
||||||
explicit AutoType(QObject* parent = Q_NULLPTR);
|
explicit AutoType(QObject* parent = Q_NULLPTR);
|
||||||
~AutoType();
|
~AutoType();
|
||||||
|
void loadPlugin(const QString& pluginPath);
|
||||||
bool parseActions(const QString& sequence, const Entry* entry, QList<AutoTypeAction*>& actions);
|
bool parseActions(const QString& sequence, const Entry* entry, QList<AutoTypeAction*>& actions);
|
||||||
QList<AutoTypeAction*> createActionFromTemplate(const QString& tmpl, const Entry* entry);
|
QList<AutoTypeAction*> createActionFromTemplate(const QString& tmpl, const Entry* entry);
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ QImage DatabaseIcons::icon(int index)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QString iconPath = QString("icons/database/").append(m_indexToName[index]);
|
QString iconPath = QString("icons/database/").append(m_indexToName[index]);
|
||||||
QImage icon(filePath()->path(iconPath));
|
QImage icon(filePath()->dataPath(iconPath));
|
||||||
|
|
||||||
m_iconCache[index] = icon;
|
m_iconCache[index] = icon;
|
||||||
return icon;
|
return icon;
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include <QtCore/QCoreApplication>
|
#include <QtCore/QCoreApplication>
|
||||||
#include <QtCore/QDir>
|
#include <QtCore/QDir>
|
||||||
|
#include <QtCore/QLibrary>
|
||||||
|
|
||||||
#include "config-keepassx.h"
|
#include "config-keepassx.h"
|
||||||
|
|
||||||
|
@ -29,6 +30,34 @@ QString FilePath::dataPath(const QString& name)
|
||||||
return m_basePath + name;
|
return m_basePath + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString FilePath::pluginPath(const QString& name)
|
||||||
|
{
|
||||||
|
QStringList pluginPaths;
|
||||||
|
QDir buildDir(QCoreApplication::applicationDirPath() + "/autotype");
|
||||||
|
Q_FOREACH (const QString& dir, buildDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) {
|
||||||
|
pluginPaths << QCoreApplication::applicationDirPath() + "/autotype/" + dir;
|
||||||
|
}
|
||||||
|
pluginPaths << QCoreApplication::applicationDirPath();
|
||||||
|
pluginPaths << QCoreApplication::applicationDirPath() + "/../lib/keepassx";
|
||||||
|
|
||||||
|
QStringList dirFilter;
|
||||||
|
dirFilter << QString("*%1*").arg(name);
|
||||||
|
|
||||||
|
Q_FOREACH (const QString& path, pluginPaths) {
|
||||||
|
QStringList fileCandidates = QDir(path).entryList(dirFilter, QDir::Files);
|
||||||
|
|
||||||
|
Q_FOREACH (const QString& file, fileCandidates) {
|
||||||
|
QString filePath = path + "/" + file;
|
||||||
|
|
||||||
|
if (QLibrary::isLibrary(filePath)) {
|
||||||
|
return filePath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
QIcon FilePath::applicationIcon()
|
QIcon FilePath::applicationIcon()
|
||||||
{
|
{
|
||||||
return icon("apps", "keepassx");
|
return icon("apps", "keepassx");
|
||||||
|
|
|
@ -27,6 +27,7 @@ class FilePath
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString dataPath(const QString& name);
|
QString dataPath(const QString& name);
|
||||||
|
QString pluginPath(const QString& name);
|
||||||
QIcon applicationIcon();
|
QIcon applicationIcon();
|
||||||
QIcon icon(const QString& category, const QString& name, bool fromTheme = true);
|
QIcon icon(const QString& category, const QString& name, bool fromTheme = true);
|
||||||
|
|
||||||
|
|
|
@ -181,4 +181,17 @@ void wait(int ms)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString platform()
|
||||||
|
{
|
||||||
|
#if defined(Q_WS_X11)
|
||||||
|
return "x11";
|
||||||
|
#elif defined(Q_WS_MAC)
|
||||||
|
return "mac";
|
||||||
|
#elif defined(Q_WS_WIN)
|
||||||
|
return "win";
|
||||||
|
#else
|
||||||
|
return QString();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Tools
|
} // namespace Tools
|
||||||
|
|
|
@ -37,6 +37,7 @@ QString imageReaderFilter();
|
||||||
bool isHex(const QByteArray& ba);
|
bool isHex(const QByteArray& ba);
|
||||||
void sleep(int ms);
|
void sleep(int ms);
|
||||||
void wait(int ms);
|
void wait(int ms);
|
||||||
|
QString platform();
|
||||||
|
|
||||||
} // namespace Tools
|
} // namespace Tools
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue