mirror of
https://github.com/QuasarApp/qca.git
synced 2025-04-26 11:34:32 +00:00
added new functiion pluginPaths
Retrieve plugin paths. It consists of: 1. QCA_PLUGIN_PATH environment if set. 2. QCoreApplication::libraryPaths() . 3. Directory where plugins were installed. QCA_PLUGIN_PATH is paths list like PATH or QT_PLUGIN_PATH. It uses system path separator. ";" on Windows and ":" on Unix. Also qcatool now uses this function.
This commit is contained in:
parent
192243d4bd
commit
4b8e2214cd
@ -89,10 +89,6 @@ else(QCA_SUFFIX)
|
||||
set(QCA_PC_NAME qca2.pc)
|
||||
endif(QCA_SUFFIX)
|
||||
|
||||
if(DEVELOPER_MODE)
|
||||
add_definitions(-DDEVELOPER_MODE -DQCA_PLUGIN_PATH="${CMAKE_BINARY_DIR}/lib/${QCA_LIB_NAME}")
|
||||
endif(DEVELOPER_MODE)
|
||||
|
||||
set(QCA_LIB_VERSION_STRING "${QCA_LIB_MAJOR_VERSION}.${QCA_LIB_MINOR_VERSION}.${QCA_LIB_PATCH_VERSION}")
|
||||
|
||||
configure_file("include/QtCrypto/qca_version.h.in" "${CMAKE_BINARY_DIR}/qca_version.h")
|
||||
@ -222,6 +218,12 @@ else()
|
||||
set(QCA_PREFIX_INSTALL_DIR "")
|
||||
endif()
|
||||
|
||||
if(DEVELOPER_MODE)
|
||||
add_definitions(-DDEVELOPER_MODE -DQCA_PLUGIN_PATH="${CMAKE_BINARY_DIR}/lib/${QCA_LIB_NAME}")
|
||||
else()
|
||||
add_definitions(-DQCA_PLUGIN_PATH="${QCA_PREFIX_INSTALL_DIR}${QCA_PLUGINS_INSTALL_DIR}")
|
||||
endif(DEVELOPER_MODE)
|
||||
|
||||
if (APPLE)
|
||||
find_package(Carbon REQUIRED)
|
||||
set(CMAKE_INSTALL_NAME_DIR ${QCA_LIBRARY_INSTALL_DIR})
|
||||
|
@ -369,6 +369,19 @@ QCA_EXPORT Provider *findProvider(const QString &name);
|
||||
*/
|
||||
QCA_EXPORT Provider *defaultProvider();
|
||||
|
||||
/**
|
||||
Retrieve plugin paths. It consists of:
|
||||
1. QCA_PLUGIN_PATH environment if set.
|
||||
2. \c %QCoreApplication::libraryPaths() .
|
||||
3. Directory where plugins were installed.
|
||||
|
||||
QCA_PLUGIN_PATH is paths list like PATH or QT_PLUGIN_PATH.
|
||||
It uses system path separator. \";\" on Windows and \":\" on Unix.
|
||||
|
||||
This function was introduced in %QCA 2.1.
|
||||
*/
|
||||
QCA_EXPORT QStringList pluginPaths();
|
||||
|
||||
/**
|
||||
Scan for new plugins
|
||||
*/
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include <QSettings>
|
||||
#include <QVariantMap>
|
||||
#include <QWaitCondition>
|
||||
#include <QDir>
|
||||
|
||||
#ifdef Q_OS_UNIX
|
||||
# include <unistd.h>
|
||||
@ -452,6 +453,37 @@ Provider *defaultProvider()
|
||||
return global->manager->find("default");
|
||||
}
|
||||
|
||||
QStringList pluginPaths()
|
||||
{
|
||||
QStringList paths;
|
||||
#ifndef DEVELOPER_MODE
|
||||
const QString qcaPluginPath = qgetenv("QCA_PLUGIN_PATH");
|
||||
if (!qcaPluginPath.isEmpty())
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
QLatin1Char pathSep(';');
|
||||
#else
|
||||
QLatin1Char pathSep(':');
|
||||
#endif
|
||||
foreach (const QString &path, qcaPluginPath.split(pathSep))
|
||||
{
|
||||
QString canonicalPath = QDir(path).canonicalPath();
|
||||
if (!canonicalPath.isEmpty())
|
||||
paths << canonicalPath;
|
||||
}
|
||||
|
||||
}
|
||||
paths += QCoreApplication::libraryPaths();
|
||||
#endif
|
||||
// In developer mode load plugins only from buildtree.
|
||||
// In regular mode QCA_PLUGIN_PATH is path where plugins was installed
|
||||
paths << QDir(QCA_PLUGIN_PATH).canonicalPath();
|
||||
#ifndef DEVELOPER_MODE
|
||||
paths.removeDuplicates();
|
||||
#endif
|
||||
return paths;
|
||||
}
|
||||
|
||||
void scanForPlugins()
|
||||
{
|
||||
if(!global_check_load())
|
||||
|
@ -366,14 +366,7 @@ void ProviderManager::scan()
|
||||
if(qgetenv("QCA_NO_PLUGINS") == "1")
|
||||
return;
|
||||
|
||||
// check plugin files
|
||||
#ifdef DEVELOPER_MODE
|
||||
// Load plugins only from buildtree
|
||||
QStringList dirs;
|
||||
dirs << QCA_PLUGIN_PATH;
|
||||
#else
|
||||
const QStringList dirs = QCoreApplication::libraryPaths();
|
||||
#endif
|
||||
const QStringList dirs = pluginPaths();
|
||||
if(dirs.isEmpty())
|
||||
logDebug("No Qt Library Paths");
|
||||
for(QStringList::ConstIterator it = dirs.begin(); it != dirs.end(); ++it)
|
||||
|
@ -2881,14 +2881,7 @@ int main(int argc, char **argv)
|
||||
// show plugins
|
||||
if(args[0] == "plugins")
|
||||
{
|
||||
#ifdef DEVELOPER_MODE
|
||||
printf("QCA build tree path:\n");
|
||||
QStringList paths;
|
||||
paths << QCA_PLUGIN_PATH;
|
||||
#else
|
||||
printf("Qt Library Paths:\n");
|
||||
QStringList paths = QCoreApplication::libraryPaths();
|
||||
#endif
|
||||
QStringList paths = QCA::pluginPaths();
|
||||
if(!paths.isEmpty())
|
||||
{
|
||||
for(int n = 0; n < paths.count(); ++n)
|
||||
|
Loading…
x
Reference in New Issue
Block a user