diff --git a/CMakeLists.txt b/CMakeLists.txt index ee9fa54..c306ef9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,7 @@ include(GNUInstallDirs) ####################################################################### option(WITH_KDE "Try to build with KDE support if availibe" ON) +option(WITH_FRONTENDS "Build frontends currently only useful if WITH_SNORE_DEAMON=ON" OFF) option(WITH_FREEDESKTOP_FRONTEND "Build the freedesktop frontend" OFF) option(WITH_GROWL_BACKEND "Build the Growl backend" ON) option(WITH_SNORE_DEAMON "Build the Snore deamon, which redirects notifications" OFF) @@ -23,7 +24,9 @@ if(WITH_KDE) find_package(KDE4) endif() - +if(WITH_SNORE_DEAMON) + set(WITH_FRONTENDS ON) +endif() if(KDE4_FOUND) add_definitions(-DHAVE_KDE ${KDE4_DEFINITIONS} -D_UNICODE) @@ -53,9 +56,13 @@ endif(DOXYGEN_FOUND) set(LIBSNORE_PLUGIN_PATH ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libsnore) set(SNORE_PLUGIN_INSTALL_PATH LIBRARY DESTINATION ${LIBSNORE_PLUGIN_PATH}) -add_definitions(-DLIBSNORE_PLUGIN_PATH="${LIBSNORE_PLUGIN_PATH}" -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}") +add_definitions(-DLIBSNORE_PLUGIN_PATH="${LIBSNORE_PLUGIN_PATH}") message(STATUS "Installing plugins to ${LIBSNORE_PLUGIN_PATH}") +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + + add_subdirectory(data) add_subdirectory(share) add_subdirectory(src) diff --git a/src/core/plugins/plugincontainer.cpp b/src/core/plugins/plugincontainer.cpp index e5596e2..8ba6fef 100644 --- a/src/core/plugins/plugincontainer.cpp +++ b/src/core/plugins/plugincontainer.cpp @@ -28,6 +28,7 @@ #include #include #include +#include using namespace Snore; @@ -38,7 +39,7 @@ PluginContainer::PluginContainer(QString fileName, QString pluginName, SnorePlug m_pluginFile(fileName), m_pluginName(pluginName), m_pluginType(type), - m_loader(SnoreCorePrivate::pluginDir().absoluteFilePath(file())) + m_loader(pluginDir().absoluteFilePath(file())) { } @@ -101,13 +102,19 @@ const QStringList &PluginContainer::types() void PluginContainer::updatePluginCache() { snoreDebug( SNORE_DEBUG ) << "Updating plugin cache"; - - s_pluginCache.clear(); cache().remove(""); +#if defined(Q_OS_LINUX) + const QString extensions = "so"; +#elif defined(Q_OS_WIN) + const QString extensions = "dll"; +#elif defined(Q_OS_MAC) + const QString extensions = "dylib"; +#endif + foreach(const QString &type,PluginContainer::types()) { - foreach (const QFileInfo &file, SnoreCorePrivate::pluginDir().entryInfoList(QStringList(QString("libsnore_%1_*").arg(type.toLower())), QDir::Files, QDir::Name | QDir::IgnoreCase )) + foreach (const QFileInfo &file, pluginDir().entryInfoList(QStringList(QString("libsnore_%1_*.%2").arg(type.toLower(), extensions)), QDir::Files, QDir::Name | QDir::IgnoreCase )) { snoreDebug( SNORE_DEBUG ) << "adding" << file.absoluteFilePath(); QPluginLoader loader(file.absoluteFilePath()); @@ -131,7 +138,7 @@ void PluginContainer::updatePluginCache() } cache().setValue("version",Version::revision()); cache().setValue("buildtime",Version::buildTime()); - cache().setValue("pluginPath",SnoreCorePrivate::pluginDir().absolutePath()); + cache().setValue("pluginPath",pluginDir().absolutePath()); QList plugins = pluginCache(SnorePlugin::ALL).values(); cache().beginWriteArray("plugins"); for(int i=0;i< plugins.size();++i) @@ -148,7 +155,6 @@ const QHash PluginContainer::pluginCache(SnorePlugin { if(s_pluginCache.isEmpty()) { - QString version = cache().value("version").toString(); QString buildTime = cache().value("buildtime").toString(); int size = cache().beginReadArray("plugins"); @@ -187,3 +193,30 @@ const QHash PluginContainer::pluginCache(SnorePlugin } return out; } + +const QDir PluginContainer::pluginDir() +{ + static QString path; + if(path.isNull()) + { + const QString appDir = qApp->applicationDirPath(); + QStringList list; + list << QString("%1/../lib/libsnore").arg(appDir) + << QString("%1/../lib64/libsnore").arg(appDir) + << QString("%1/libsnore").arg(appDir) + << QString("%1/").arg(appDir) + << QLatin1String(LIBSNORE_PLUGIN_PATH); + foreach(const QString &p, list) + { + if(QDir(p).exists()) + { + path = p; + break; + } + } + snoreDebug( SNORE_INFO ) << "PluginPath is :" << path; + } + return QDir(path); +} + + diff --git a/src/core/plugins/plugincontainer.h b/src/core/plugins/plugincontainer.h index 34f3c69..3798f54 100644 --- a/src/core/plugins/plugincontainer.h +++ b/src/core/plugins/plugincontainer.h @@ -54,6 +54,7 @@ public: private: void static updatePluginCache(); + static const QDir pluginDir(); static QHash > s_pluginCache; static inline QSettings &cache() @@ -62,7 +63,7 @@ private: if(_cache == NULL) { _cache = new QSettings("SnoreNotify","libsnore"); - _cache->beginGroup( SnoreCorePrivate::computeHash(SnoreCorePrivate::pluginDir().absolutePath().toLatin1())); + _cache->beginGroup( SnoreCorePrivate::computeHash(pluginDir().absolutePath().toLatin1())); } return *_cache; } diff --git a/src/core/snore_p.cpp b/src/core/snore_p.cpp index 2507a01..16d4946 100644 --- a/src/core/snore_p.cpp +++ b/src/core/snore_p.cpp @@ -25,8 +25,6 @@ #include "plugins/snorefrontend.h" #include "notification/notification_p.h" -#include - using namespace Snore; @@ -41,17 +39,6 @@ QString const SnoreCorePrivate::snoreTMP() return tmp; } -const QDir &SnoreCorePrivate::pluginDir() -{ - static QDir path(QString("%1/../%2/libsnore").arg(qApp->applicationDirPath(), CMAKE_INSTALL_LIBDIR)); - if(!path.exists()) - { - path = QDir(LIBSNORE_PLUGIN_PATH); - } - return path; -} - - SnoreCorePrivate::SnoreCorePrivate(QSystemTrayIcon *trayIcon): m_trayIcon(trayIcon), m_defaultApp("SnoreNotify",Icon(":/root/snore.png")) diff --git a/src/core/snore_p.h b/src/core/snore_p.h index bc385de..91b124b 100644 --- a/src/core/snore_p.h +++ b/src/core/snore_p.h @@ -37,7 +37,6 @@ class SNORE_EXPORT SnoreCorePrivate : public QObject public: static const QString snoreTMP(); - static const QDir &pluginDir(); static inline QString computeHash(const QByteArray &data) { return QCryptographicHash::hash(data,QCryptographicHash::Md5).toHex(); diff --git a/src/plugins/frontends/CMakeLists.txt b/src/plugins/frontends/CMakeLists.txt index 58356f7..aff78dc 100644 --- a/src/plugins/frontends/CMakeLists.txt +++ b/src/plugins/frontends/CMakeLists.txt @@ -1,3 +1,4 @@ -add_subdirectory(freedesktop) -add_subdirectory(snarlnetwork) - +if(WITH_FRONTENDS) + add_subdirectory(freedesktop) + add_subdirectory(snarlnetwork) +endif()