cleaneup plugin loading and install path...

This commit is contained in:
Patrick von Reth 2014-01-22 17:49:54 +01:00
parent a64f6ebe71
commit b9f94f5e7d
21 changed files with 65 additions and 73 deletions

View File

@ -91,7 +91,7 @@ const QStringList &PluginContainer::types()
QMetaEnum e = SnorePlugin::staticMetaObject.enumerator(SnorePlugin::staticMetaObject.indexOfEnumerator("PluginType"));
for(int i=0;i<e.keyCount();++i)
{
out << QString::fromLatin1(e.key(i)).toLower();
out << QString::fromLatin1(e.key(i));
}
}
return out;
@ -107,25 +107,24 @@ void PluginContainer::updatePluginCache()
foreach(const QString &type,PluginContainer::types())
{
QDir plPath(SnoreCorePrivate::pluginDir().absoluteFilePath(type));
snoreDebug( SNORE_DEBUG ) << "Searching for plugins in" << plPath.path();
foreach (QString fileName, plPath.entryList(QDir::Files))
foreach (const QFileInfo &file, SnoreCorePrivate::pluginDir().entryInfoList(QStringList(QString("libsnore_%1_*").arg(type.toLower())), QDir::Files, QDir::Name | QDir::IgnoreCase ))
{
QString filepath(plPath.absoluteFilePath(fileName));
snoreDebug( SNORE_DEBUG ) << "adding" << filepath;
QPluginLoader loader(filepath);
snoreDebug( SNORE_DEBUG ) << "adding" << file.absoluteFilePath();
QPluginLoader loader(file.absoluteFilePath());
QObject *plugin = loader.instance();
if (plugin == NULL) {
snoreDebug( SNORE_DEBUG ) << "Failed loading plugin: " << filepath << loader.errorString();
if (plugin == NULL)
{
snoreDebug( SNORE_WARNING ) << "Failed loading plugin: " << file.absoluteFilePath() << loader.errorString();
continue;
}
SnorePlugin *sp = qobject_cast<SnorePlugin*>(plugin);
if(sp == NULL){
snoreDebug( SNORE_DEBUG ) << "Error:" << fileName << " is not a Snore plugin" ;
if(sp == NULL)
{
snoreDebug( SNORE_WARNING ) << "Error:" << file.absoluteFilePath() << " is not a Snore plugin" ;
loader.unload();
continue;
}
PluginContainer *info = new PluginContainer( SnoreCorePrivate::pluginDir().relativeFilePath(filepath),sp->name(),PluginContainer::typeFromString(type));
PluginContainer *info = new PluginContainer(file.fileName(), sp->name() ,PluginContainer::typeFromString(type));
s_pluginCache[info->type()].insert(info->name(),info);
snoreDebug( SNORE_DEBUG ) << "added" << info->name() << "to cache";
}

View File

@ -87,7 +87,7 @@ QDebug operator <<(QDebug debug, const Snore::SnorePlugin::PluginTypes &flags)
debug.nospace() << "PluginTypes(";
bool needSeparator = false;
int key;
for (uint i = 0; i < e.keyCount(); ++i)
for (int i = 0; i < e.keyCount(); ++i)
{
key = e.value(i);
if (flags.testFlag((SnorePlugin::PluginType)key))

View File

@ -30,7 +30,8 @@
using namespace Snore;
QString const SnoreCorePrivate::snoreTMP(){
QString const SnoreCorePrivate::snoreTMP()
{
static QString tmp;
if(tmp.isNull())
{
@ -40,7 +41,8 @@ QString const SnoreCorePrivate::snoreTMP(){
return tmp;
}
const QDir &SnoreCorePrivate::pluginDir(){
const QDir &SnoreCorePrivate::pluginDir()
{
static QDir path(QString("%1/../%2/libsnore").arg(qApp->applicationDirPath(), CMAKE_INSTALL_LIBDIR));
if(!path.exists())
{

View File

@ -1,5 +1,3 @@
set(SNORE_BACKEND_INSTALL_PATH ${SNORE_PLUGIN_INSTALL_PATH}/backend)
add_subdirectory(freedesktop)
add_subdirectory(snarl)
add_subdirectory(growl)

View File

@ -12,6 +12,6 @@ if(QT_QTDBUS_FOUND AND NOT WITH_FREEDESKTOP_FRONTEND AND UNIX AND NOT APPLE)
add_library(freedesktop_backend MODULE ${FREEDESKTOP_NOTIFICATION_SRC} )
target_link_libraries(freedesktop_backend snorecore ${QT_QTGUI_LIBRARY} ${QT_QTDBUS_LIBRARY} )
install(TARGETS freedesktop_backend ${SNORE_BACKEND_INSTALL_PATH})
install(TARGETS libsnore_backend_freedesktop ${SNORE_PLUGIN_INSTALL_PATH})
endif(QT_QTDBUS_FOUND AND NOT WITH_FREEDESKTOP_FRONTEND AND UNIX AND NOT APPLE)

View File

@ -13,7 +13,7 @@
using namespace Snore;
Q_EXPORT_PLUGIN2 ( freedesktopnotificationbackend,FreedesktopBackend )
Q_EXPORT_PLUGIN2 ( libsnore_backend_freedesktop,FreedesktopBackend )
FreedesktopBackend::FreedesktopBackend () :

View File

@ -1,37 +1,37 @@
if( WITH_GROWL_BACKEND )
if(CRYPTOPP_LIBRARIES AND Boost_SYSTEM_LIBRARY)
message( STATUS "Found Boost and Cryptopp, adding libgrowl backend" )
if(CRYPTOPP_LIBRARIES AND Boost_SYSTEM_LIBRARY)
message( STATUS "Found Boost and Cryptopp, adding libgrowl backend" )
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
endif(CMAKE_COMPILER_IS_GNUCXX)
set( GROWL__SRC
set( GROWL__SRC
growl.cpp
)
)
add_library(growl MODULE ${GROWL__SRC} )
target_link_libraries(growl snorecore ${QT_QTCORE_LIBRARY} ${CRYPTOPP_LIBRARIES} ${Boost_SYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY})
add_library(libsnore_backend_growl MODULE ${GROWL__SRC} )
target_link_libraries(libsnore_backend_growl snorecore ${QT_QTCORE_LIBRARY} ${CRYPTOPP_LIBRARIES} ${Boost_SYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY})
if(MINGW)
#fiexes a multiple defenition error with static boost
SET_TARGET_PROPERTIES(growl PROPERTIES LINK_FLAGS -Wl,--allow-multiple-definition COMPILE_FLAGS
SET_TARGET_PROPERTIES(libsnore_backend_growl PROPERTIES LINK_FLAGS -Wl,--allow-multiple-definition COMPILE_FLAGS
"-Wno-undef -Wno-unused-parameter -Wno-unknown-pragmas -Wno-unused-local-typedefs -Wno-missing-field-initializers -Wno-strict-aliasing -Wno-reorder -Wno-unused-variable -Wno-unused-function" )
endif(MINGW)
if(WIN32)
target_link_libraries(growl wsock32 ws2_32)
target_link_libraries(libsnore_backend_growl wsock32 ws2_32)
endif(WIN32)
if(UNIX)
target_link_libraries(growl pthread)
target_link_libraries(libsnore_backend_growl pthread)
endif(UNIX)
install(TARGETS growl ${SNORE_BACKEND_INSTALL_PATH})
else(CRYPTOPP_LIBRARIES AND Boost_SYSTEM_LIBRARY)
if(NOT CRYPTOPP_LIBRARIES)
message(STATUS "Cant build the growl backend because the dependency Cryptopp is missing")
endif(NOT CRYPTOPP_LIBRARIES)
if(NOT Boost_SYSTEM_LIBRARY)
message(STATUS "Cant build the growl backend because the dependency BOOST_SYSTEM is missing")
endif(NOT Boost_SYSTEM_LIBRARY)
endif(CRYPTOPP_LIBRARIES AND Boost_SYSTEM_LIBRARY)
install(TARGETS libsnore_backend_growl ${SNORE_PLUGIN_INSTALL_PATH})
else(CRYPTOPP_LIBRARIES AND Boost_SYSTEM_LIBRARY)
if(NOT CRYPTOPP_LIBRARIES)
message(STATUS "Cant build the growl backend because the dependency Cryptopp is missing")
endif(NOT CRYPTOPP_LIBRARIES)
if(NOT Boost_SYSTEM_LIBRARY)
message(STATUS "Cant build the growl backend because the dependency BOOST_SYSTEM is missing")
endif(NOT Boost_SYSTEM_LIBRARY)
endif(CRYPTOPP_LIBRARIES AND Boost_SYSTEM_LIBRARY)
endif( WITH_GROWL_BACKEND )

View File

@ -28,7 +28,7 @@
using namespace Snore;
Q_EXPORT_PLUGIN2(growl,Growl)
Q_EXPORT_PLUGIN2(libsnore_backend_growl,Growl)
Growl *Growl::s_instance = NULL;

View File

@ -7,12 +7,12 @@ if(WIN32)
SnarlInterface.cpp
snarl.cpp
)
add_library(snarl MODULE ${SNARL_SRC} )
target_link_libraries(snarl snorecore ${QT_QTCORE_LIBRARY} )
add_library(libsnore_backend_snarl MODULE ${SNARL_SRC} )
target_link_libraries(libsnore_backend_snarl snorecore ${QT_QTCORE_LIBRARY} )
if(MINGW)
set_target_properties(snarl PROPERTIES COMPILE_FLAGS "-Wno-conversion-null -Wno-unused")
set_target_properties(libsnore_backend_snarl PROPERTIES COMPILE_FLAGS "-Wno-conversion-null -Wno-unused")
endif(MINGW)
install(TARGETS snarl ${SNORE_BACKEND_INSTALL_PATH})
install(TARGETS libsnore_backend_snarl ${SNORE_PLUGIN_INSTALL_PATH})
endif(WIN32)

View File

@ -38,7 +38,7 @@
using namespace Snore;
using namespace Snarl::V42;
Q_EXPORT_PLUGIN2(snarl,SnarlBackend)
Q_EXPORT_PLUGIN2(libsnore_backend_snarl,SnarlBackend)
class SnarlBackend::SnarlWidget:public QWidget
{

View File

@ -4,9 +4,9 @@ if(WIN32)
set( TOASTER_SRC
snoretoast.cpp
)
add_library(snoretoast MODULE ${TOASTER_SRC} )
target_link_libraries(snoretoast snorecore ${QT_QTCORE_LIBRARY} )
add_library(libsnore_backend_snoretoast MODULE ${TOASTER_SRC} )
target_link_libraries(libsnore_backend_snoretoast snorecore ${QT_QTCORE_LIBRARY} )
install(TARGETS snoretoast ${SNORE_BACKEND_INSTALL_PATH})
install(TARGETS libsnore_backend_snoretoast ${SNORE_PLUGIN_INSTALL_PATH})
endif(WIN32)

View File

@ -13,7 +13,7 @@
using namespace Snore;
Q_EXPORT_PLUGIN2(snoretoast,SnoreToast)
Q_EXPORT_PLUGIN2(libsnore_backend_snoretoast,SnoreToast)
SnoreToast::SnoreToast():

View File

@ -1,7 +1,7 @@
set( trayicon_SRC
trayiconnotifer.cpp
)
add_library(trayicon MODULE ${trayicon_SRC} )
target_link_libraries(trayicon snorecore ${QT_QTCORE_LIBRARY} )
add_library(libsnore_backend_trayicon MODULE ${trayicon_SRC} )
target_link_libraries(libsnore_backend_trayicon snorecore ${QT_QTCORE_LIBRARY} )
install(TARGETS trayicon ${SNORE_BACKEND_INSTALL_PATH})
install(TARGETS libsnore_backend_trayicon ${SNORE_PLUGIN_INSTALL_PATH})

View File

@ -9,7 +9,7 @@
#include <QDebug>
using namespace Snore;
Q_EXPORT_PLUGIN2(trayicon,TrayIconNotifer)
Q_EXPORT_PLUGIN2(libsnore_backend_trayicon,TrayIconNotifer)
TrayIconNotifer::TrayIconNotifer () :
SnoreBackend ( "SystemTray",true,false ),

View File

@ -1,6 +1,3 @@
set(SNORE_FRONTEND_INSTALL_PATH ${SNORE_PLUGIN_INSTALL_PATH}/frontend)
add_subdirectory(freedesktop)
add_subdirectory(snarlnetwork)

View File

@ -2,32 +2,34 @@ if(QT_QTDBUS_FOUND AND WITH_FREEDESKTOP_FRONTEND)
message(STATUS "Adding freedesktop notification frontend")
set( FREEDESKTOP_NOTIFICATION_FRONTEND_SRC
freedesktopnotificationfrontend.cpp
freedesktopnotificationfrontend.cpp
../../backends/freedesktop/fredesktopnotification.cpp
)
)
qt4_add_dbus_adaptor( FREEDESKTOP_NOTIFICATION_FRONTEND_SRC org.freedesktop.Notifications.xml freedesktopnotificationfrontend.h FreedesktopFrontend)
add_library(freedesktop MODULE ${FREEDESKTOP_NOTIFICATION_FRONTEND_SRC} )
target_link_libraries(freedesktop snorecore ${QT_QTDBUS_LIBRARY} ${QT_QTGUI_LIBRARY} )
add_library(libsnore_frontend_freedesktop MODULE ${FREEDESKTOP_NOTIFICATION_FRONTEND_SRC} )
target_link_libraries(libsnore_frontend_freedesktop snorecore ${QT_QTDBUS_LIBRARY} ${QT_QTGUI_LIBRARY} )
if(KDE4_FOUND)
target_link_libraries(freedesktop ${KDE4_KDEUI_LIBRARY})
target_link_libraries(libsnore_frontend_freedesktop ${KDE4_KDEUI_LIBRARY})
endif(KDE4_FOUND)
#install the dbus interface
if(WITH_SNORE_DEAMON)
if(WIN32)
set(SNORE_LOCATION ../bin/snorenotify)
else(WIN32)
set(SNORE_LOCATION ${CMAKE_INSTALL_PREFIX}/bin/snorenotify)
endif(WIN32)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/org.freedesktop.Notifications.service.cmake ${CMAKE_CURRENT_BINARY_DIR}/org.freedesktop.Notifications.service)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/org.freedesktop.Notifications.service.cmake ${CMAKE_CURRENT_BINARY_DIR}/org.freedesktop.Notifications.service)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.freedesktop.Notifications.service
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.freedesktop.Notifications.service
DESTINATION share/dbus-1/services/)
endif(WITH_SNORE_DEAMON)
install(TARGETS freedesktop ${SNORE_FRONTEND_INSTALL_PATH})
install(TARGETS libsnore_frontend_freedesktop ${SNORE_PLUGIN_INSTALL_PATH})
endif(QT_QTDBUS_FOUND AND WITH_FREEDESKTOP_FRONTEND)

View File

@ -34,7 +34,7 @@
#endif
using namespace Snore;
Q_EXPORT_PLUGIN2(freedesktop,FreedesktopFrontend)
Q_EXPORT_PLUGIN2(libsnore_frontend_freedesktop,FreedesktopFrontend)
FreedesktopFrontend::FreedesktopFrontend():
SnoreFrontend("Freedesktop")

View File

@ -1,9 +1,8 @@
#deprecated
set( SNARL_NETWORK_SRC
snarlnetwork.cpp
parser.cpp
)
add_library(snarlnetwork MODULE ${SNARL_NETWORK_SRC} )
target_link_libraries(snarlnetwork snorecore ${QT_QTNETWORK_LIBRARY} )
add_library(libsnore_frontend_snarlnetwork MODULE ${SNARL_NETWORK_SRC} )
target_link_libraries(libsnore_frontend_snarlnetwork snorecore ${QT_QTNETWORK_LIBRARY} )
install(TARGETS snarlnetwork ${SNORE_FRONTEND_INSTALL_PATH})
install(TARGETS libsnore_frontend_snarlnetwork ${SNORE_PLUGIN_INSTALL_PATH})

View File

@ -27,7 +27,7 @@
#include <iostream>
using namespace Snore;
Q_EXPORT_PLUGIN2(snalnetwork,SnarlNetworkFrontend)
Q_EXPORT_PLUGIN2(libsnore_frontend_snarlnetwork,SnarlNetworkFrontend)
SnarlNetworkFrontend::SnarlNetworkFrontend():

View File

@ -1,3 +0,0 @@
set(SNORE_PLUGINS_INSTALL_PATH ${SNORE_PLUGIN_INSTALL_PATH}/plugin)

View File

@ -1,2 +0,0 @@
set(SNORE_SECONDARY_BACKEND_INSTALL_PATH ${SNORE_PLUGIN_INSTALL_PATH}/secondary_backend)