diff --git a/daemon/configure.ac b/daemon/configure.ac index 304ab694b6e5a25205db4d51049f22f861f97d8b..f3915c46c3fd41db43dbaaf4b0af737bafb48646 100644 --- a/daemon/configure.ac +++ b/daemon/configure.ac @@ -50,8 +50,6 @@ AC_CONFIG_FILES([src/Makefile \ src/audio/codecs/Makefile \ src/config/Makefile \ src/dbus/Makefile \ - src/plug-in/Makefile \ - src/plug-in/test/Makefile \ src/hooks/Makefile \ src/history/Makefile]) diff --git a/daemon/src/Makefile.am b/daemon/src/Makefile.am index 2779f6efdf91e2ed08825a9ff9f23f2d6597e5bd..62e5c191c14142dfb01d0d938b249888b94da05b 100644 --- a/daemon/src/Makefile.am +++ b/daemon/src/Makefile.am @@ -5,7 +5,7 @@ libexec_PROGRAMS = sflphoned # all: indent -SUBDIRS = dbus audio config plug-in hooks history sip iax im +SUBDIRS = dbus audio config hooks history sip iax im sflphoned_SOURCES = main.cpp @@ -58,7 +58,6 @@ libsflphone_la_LIBADD = \ ./audio/libaudio.la \ ./dbus/libdbus.la \ ./config/libconfig.la \ - ./plug-in/libplugin.la \ ./hooks/libhooks.la \ ./history/libhistory.la diff --git a/daemon/src/plug-in/Makefile.am b/daemon/src/plug-in/Makefile.am deleted file mode 100644 index be2aa0731b061da2fb33a3545a18e7f8e8d08156..0000000000000000000000000000000000000000 --- a/daemon/src/plug-in/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -include ../../globals.mak - -SUBDIRS=test - -noinst_LTLIBRARIES = libplugin.la - -libplugin_la_SOURCES = \ - pluginmanager.cpp \ - librarymanager.cpp \ - pluginmanager.h librarymanager.h plugin.h - -libplugin_la_CXXFLAGS = -I $(top_srcdir)/src/plug-in diff --git a/daemon/src/plug-in/librarymanager.cpp b/daemon/src/plug-in/librarymanager.cpp deleted file mode 100644 index 4a391c343f1fd014c2fda7c722dde617c925b509..0000000000000000000000000000000000000000 --- a/daemon/src/plug-in/librarymanager.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010, 2011 Savoir-Faire Linux Inc. - * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Additional permission under GNU GPL version 3 section 7: - * - * If you modify this program, or any covered work, by linking or - * combining it with the OpenSSL project's OpenSSL library (or a - * modified version of that library), containing parts covered by the - * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. - * grants you additional permission to convey the resulting work. - * Corresponding Source for a non-source form of such a combination - * shall include the source code for the parts of OpenSSL used as well - * as that of the covered work. - */ - - -#include "librarymanager.h" - -LibraryManager::LibraryManager(const std::string &filename) - : _filename(filename), _handlePtr(NULL) -{ - _handlePtr = loadLibrary(filename); -} - -LibraryManager::~LibraryManager(void) -{ - unloadLibrary(); -} - -LibraryManager::LibraryHandle LibraryManager::loadLibrary(const std::string &filename) -{ - LibraryHandle pluginHandlePtr = NULL; - const char *error; - - _debug("Loading dynamic library %s", filename.c_str()); - - /* Load the library */ - pluginHandlePtr = dlopen(filename.c_str(), RTLD_LAZY); - - if (!pluginHandlePtr) { - error = dlerror(); - _debug("Error while opening plug-in: %s", error); - return NULL; - } - - dlerror(); - - return pluginHandlePtr; -} - -int LibraryManager::unloadLibrary() -{ - if (_handlePtr == NULL) - return 1; - - _debug("Unloading dynamic library ..."); - - dlclose(_handlePtr); - - if (dlerror()) { - _debug("Error unloading the library : %s...", dlerror()); - return 1; - } - - return 0; -} - -int LibraryManager::resolveSymbol(const std::string &symbol, SymbolHandle *symbolPtr) -{ - SymbolHandle sy = 0; - - if (_handlePtr) { - try { - sy = dlsym(_handlePtr, symbol.c_str()); - - if (sy != NULL) { - *symbolPtr = sy; - return 0; - } - } catch (...) {} - - throw LibraryManagerException(_filename, symbol, LibraryManagerException::symbolNotFound); - } else - return 1; -} - - -/************************************************************************************************/ - -LibraryManagerException::LibraryManagerException(const std::string &libraryName, const std::string &details, Reason reason) : - std::runtime_error(""), _reason(reason), _details("") - -{ - if (_reason == loadingFailed) - _details = "Error when loading " + libraryName + "" + details; - else - _details = "Error when resolving symbol " + details + " in " + libraryName; -} - -const char* LibraryManagerException::what() const throw() -{ - return _details.c_str(); -} diff --git a/daemon/src/plug-in/librarymanager.h b/daemon/src/plug-in/librarymanager.h deleted file mode 100644 index 5f750428fa30bfda519c00aab3109dbadc45413a..0000000000000000000000000000000000000000 --- a/daemon/src/plug-in/librarymanager.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010, 2011 Savoir-Faire Linux Inc. - * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Additional permission under GNU GPL version 3 section 7: - * - * If you modify this program, or any covered work, by linking or - * combining it with the OpenSSL project's OpenSSL library (or a - * modified version of that library), containing parts covered by the - * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. - * grants you additional permission to convey the resulting work. - * Corresponding Source for a non-source form of such a combination - * shall include the source code for the parts of OpenSSL used as well - * as that of the covered work. - */ - -#ifndef LIBRARY_MANAGER_H -#define LIBRARY_MANAGER_H - -#include "dlfcn.h" -#include <stdexcept> - -#include "global.h" - -class LibraryManager { - - public: - typedef void* LibraryHandle; - typedef void* SymbolHandle; - - LibraryManager(const std::string &filename); - ~LibraryManager(void); - - int resolveSymbol(const std::string &symbol, SymbolHandle *ptr); - - int unloadLibrary(void); - - protected: - LibraryHandle loadLibrary(const std::string &filename); - - private: - std::string _filename; - LibraryHandle _handlePtr; -}; - -class LibraryManagerException : public std::runtime_error { - - public: - - typedef enum Reason { - loadingFailed = 0, - symbolNotFound - } Reason; - - LibraryManagerException(const std::string &libraryName, const std::string &details, Reason reason); - ~LibraryManagerException(void) throw() {} - - Reason getReason(void) const { - return _reason; - } - - const char* what() const throw(); - - private: - Reason _reason; - std::string _details; -}; - -#endif // LIBRARY_MANAGER_H diff --git a/daemon/src/plug-in/plugin.h b/daemon/src/plug-in/plugin.h deleted file mode 100644 index 6fefa9f62e05b83697a45b5891d337d9a6428376..0000000000000000000000000000000000000000 --- a/daemon/src/plug-in/plugin.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010, 2011 Savoir-Faire Linux Inc. - * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Additional permission under GNU GPL version 3 section 7: - * - * If you modify this program, or any covered work, by linking or - * combining it with the OpenSSL project's OpenSSL library (or a - * modified version of that library), containing parts covered by the - * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. - * grants you additional permission to convey the resulting work. - * Corresponding Source for a non-source form of such a combination - * shall include the source code for the parts of OpenSSL used as well - * as that of the covered work. - */ - - -#ifndef PLUGIN_H -#define PLUGIN_H - -#include "global.h" - -#include "pluginmanager.h" - -/* - * @file plugin.h - * @brief Define a plugin object - */ - -class Plugin { - - public: - Plugin(const std::string &name) { - _name = name; - } - - virtual ~Plugin() {} - - std::string getPluginName(void) const { - return _name; - } - - /** - * Return the minimal core version required so that the plugin could work - * @return int The version required - */ - virtual int initFunc(PluginInfo **info) = 0; - - private: - Plugin &operator = (const Plugin &plugin); - - std::string _name; -}; - -typedef Plugin* createFunc(void); - -typedef void destroyFunc(Plugin*); - -#endif //PLUGIN_H - diff --git a/daemon/src/plug-in/pluginmanager.cpp b/daemon/src/plug-in/pluginmanager.cpp deleted file mode 100644 index a9c624e074ac8ccaa97d04a200eb6ea8bcbdf1c0..0000000000000000000000000000000000000000 --- a/daemon/src/plug-in/pluginmanager.cpp +++ /dev/null @@ -1,270 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010, 2011 Savoir-Faire Linux Inc. - * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Additional permission under GNU GPL version 3 section 7: - * - * If you modify this program, or any covered work, by linking or - * combining it with the OpenSSL project's OpenSSL library (or a - * modified version of that library), containing parts covered by the - * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. - * grants you additional permission to convey the resulting work. - * Corresponding Source for a non-source form of such a combination - * shall include the source code for the parts of OpenSSL used as well - * as that of the covered work. - */ - -#include <dirent.h> -#include <dlfcn.h> - -#include "pluginmanager.h" - -PluginManager* PluginManager::_instance = 0; - -PluginManager* -PluginManager::instance() -{ - if (!_instance) { - return new PluginManager(); - } - - return _instance; -} - -PluginManager::PluginManager() - :_loadedPlugins() -{ - _instance = this; -} - -PluginManager::~PluginManager() -{ - _instance = 0; -} - -namespace { -bool hasSharedExtension(const std::string &fn) -{ - size_t dot_position = fn.rfind("."); - return (dot_position != std::string::npos and - fn.substr(dot_position) == ".so"); -} -} - -int -PluginManager::loadPlugins(const std::string &path) -{ - std::string pluginDir, current; - DIR *dir; - dirent *dirStruct; - LibraryManager *library; - Plugin *plugin; - - const std::string pDir = ".."; - const std::string cDir = "."; - - /* The directory in which plugins are dropped. Default: /usr/lib/sflphone/plugins/ */ - if (path.empty()) - pluginDir = std::string(PLUGINS_DIR).append("/"); - else - pluginDir = path; - - _debug("Loading plugins from %s...", pluginDir.c_str()); - - dir = opendir(pluginDir.c_str()); - /* Test if the directory exists or is readable */ - - if (!dir) - return 1; - - /* Read the directory */ - while ((dirStruct=readdir(dir))) { - /* Get the name of the current item in the directory */ - current = dirStruct->d_name; - - /* Test if the current item is not the parent or the current directory and that it ends with .so*/ - if (current == pDir || current == cDir || !hasSharedExtension(current)) - continue; - - - /* Load the dynamic library */ - library = loadDynamicLibrary(pluginDir + current); - - /* Instanciate the plugin object */ - - if (instanciatePlugin(library, &plugin) != 0) { - _debug("Error instanciating the plugin ..."); - closedir(dir); - return 1; - } - - /* Regitering the current plugin */ - if (registerPlugin(plugin, library) != 0) { - _debug("Error registering the plugin ..."); - closedir(dir); - return 1; - } - } - - /* Close the directory */ - closedir(dir); - - return 0; -} - -int -PluginManager::unloadPlugins(void) -{ - PluginInfo *info; - - if (_loadedPlugins.empty()) return 0; - - /* Use an iterator on the loaded plugins map */ - pluginMap::iterator iter; - - iter = _loadedPlugins.begin(); - - while (iter != _loadedPlugins.end()) { - info = iter->second; - - if (deletePlugin(info) != 0) { - _debug("Error deleting the plugin ... "); - return 1; - } - - unloadDynamicLibrary(info->_libraryPtr); - - if (unregisterPlugin(info) != 0) { - _debug("Error unregistering the plugin ... "); - return 1; - } - - iter++; - } - - return 0; -} - -bool -PluginManager::isPluginLoaded(const std::string &name) -{ - if (_loadedPlugins.empty()) return false; - - /* Use an iterator on the loaded plugins map */ - pluginMap::iterator iter; - - iter = _loadedPlugins.find(name); - - /* Returns map::end if the specified key has not been found */ - if (iter==_loadedPlugins.end()) - return false; - - /* Returns the plugin pointer */ - return true; -} - - -LibraryManager* -PluginManager::loadDynamicLibrary(const std::string& filename) -{ - /* Load the library through the library manager */ - return new LibraryManager(filename); -} - -int -PluginManager::unloadDynamicLibrary(LibraryManager *libraryPtr) -{ - _debug("Unloading dynamic library ..."); - /* Close it */ - return libraryPtr->unloadLibrary(); -} - -int -PluginManager::instanciatePlugin(LibraryManager *libraryPtr, Plugin **plugin) -{ - createFunc *createPlugin; - LibraryManager::SymbolHandle symbol; - - if (libraryPtr->resolveSymbol("createPlugin", &symbol) != 0) - return 1; - - createPlugin = (createFunc*) symbol; - - *plugin = createPlugin(); - - return 0; -} - -int -PluginManager::deletePlugin(PluginInfo *plugin) -{ - destroyFunc *destroyPlugin; - LibraryManager::SymbolHandle symbol; - - if (plugin->_libraryPtr->resolveSymbol("destroyPlugin", &symbol) != 0) - return 1; - - destroyPlugin = (destroyFunc*) symbol; - - /* Call it */ - destroyPlugin(plugin->_plugin); - - return 0; -} - -int -PluginManager::registerPlugin(Plugin *plugin, LibraryManager *library) -{ - std::string key; - PluginInfo *p_info; - - if (plugin==0) - return 1; - - p_info = new PluginInfo(); - - /* Retrieve information from the plugin */ - plugin->initFunc(&p_info); - - key = p_info->_name; - - //p_info->_plugin = plugin; - p_info->_libraryPtr = library; - - /* Add the data in the loaded plugin map */ - _loadedPlugins[ key ] = p_info; - - return 0; -} - -int -PluginManager::unregisterPlugin(PluginInfo *plugin) -{ - pluginMap::iterator iter; - std::string key; - - key = plugin->_name; - - if (!isPluginLoaded(key)) - return 1; - - iter = _loadedPlugins.find(key); - - _loadedPlugins.erase(iter); - - return 0; -} diff --git a/daemon/src/plug-in/pluginmanager.h b/daemon/src/plug-in/pluginmanager.h deleted file mode 100644 index e48ab3e7c61eecdef2fe8df5385396fc32048a38..0000000000000000000000000000000000000000 --- a/daemon/src/plug-in/pluginmanager.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010, 2011 Savoir-Faire Linux Inc. - * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Additional permission under GNU GPL version 3 section 7: - * - * If you modify this program, or any covered work, by linking or - * combining it with the OpenSSL project's OpenSSL library (or a - * modified version of that library), containing parts covered by the - * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. - * grants you additional permission to convey the resulting work. - * Corresponding Source for a non-source form of such a combination - * shall include the source code for the parts of OpenSSL used as well - * as that of the covered work. - */ - -#ifndef PLUGIN_MANAGER_H -#define PLUGIN_MANAGER_H - -/* - * @file pluginmanager.h - * @brief Base class of the plugin manager - */ - -#include "librarymanager.h" -#include "global.h" - -#include <map> -#include <string> -#include <vector> - -class Plugin; - -typedef struct PluginInfo { - std::string _name; - LibraryManager *_libraryPtr; - Plugin *_plugin; - int _major_version; - int _minor_version; -} PluginInfo; - -#include "plugin.h" - -class PluginManager { - public: - /** - * Destructor - */ - ~PluginManager(); - - /** - * Returns the unique instance of the plugin manager - */ - static PluginManager* instance(); - - /** - * Load all the plugins found in a specific directory - * @param path The absolute path to the directory - * @return int The number of items loaded - */ - int loadPlugins(const std::string &path = ""); - - int unloadPlugins(void); - - int instanciatePlugin(LibraryManager* libraryPtr, Plugin** plugin); - - /** - * Check if a plugin has been already loaded - * @param name The name of the plugin looked for - * @return bool The pointer on the plugin or NULL if not found - */ - bool isPluginLoaded(const std::string &name); - - int registerPlugin(Plugin *plugin, LibraryManager *library); - - int unregisterPlugin(PluginInfo *plugin); - - int deletePlugin(PluginInfo *plugin); - - /** - * Load a unix dynamic/shared library - * @param filename The path to the dynamic/shared library - * @return LibraryManager* A pointer on the library - */ - LibraryManager* loadDynamicLibrary(const std::string &filename); - - /** - * Unload a unix dynamic/shared library - * @param LibraryManager* The pointer on the loaded library - */ - int unloadDynamicLibrary(LibraryManager* libraryPtr); - - private: - /** - * Default constructor - */ - PluginManager(); - - /* Map of plugins associated by their string name */ - typedef std::map<std::string, PluginInfo*> pluginMap; - pluginMap _loadedPlugins; - - /* The unique static instance */ - static PluginManager* _instance; - -}; - -#endif //PLUGIN_MANAGER_H diff --git a/daemon/src/plug-in/test/Makefile.am b/daemon/src/plug-in/test/Makefile.am deleted file mode 100644 index 089aa35a82f58b1f037bdbc5b04741c01ec23709..0000000000000000000000000000000000000000 --- a/daemon/src/plug-in/test/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ -include $(top_srcdir)/globals.mak - -PLUGIN_LIB = libplugintest.so -libplugintest_so_SOURCES = pluginTest.cpp -LLIBS=$(top_builddir)/src/plug-in/libplugin.la -libplugintest_so_CXXFLAGS = -fPIC -g -Wall -I $(top_srcdir)/src/plug-in -libplugintest_so_LDFLAGS = --shared -lc -INSTALL_PLUGIN_RULE = install-libplugintest_so - -check_PROGRAMS = libplugintest.so - -install-exec-local: install-libplugintest_so -uninstall-local: uninstall-libplugintest_so - -install-libplugintest_so: libplugintest.so - mkdir -p $(sflplugindir) - $(INSTALL_PROGRAM) libplugintest.so $(sflplugindir) - -uninstall-libplugintest_so: - rm -f $(sflplugindir)/libplugintest.so diff --git a/daemon/src/plug-in/test/pluginTest.cpp b/daemon/src/plug-in/test/pluginTest.cpp deleted file mode 100644 index 5f0190206feee5e7bc2fad2b665f14bed9c44fe9..0000000000000000000000000000000000000000 --- a/daemon/src/plug-in/test/pluginTest.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010 Savoir-Faire Linux Inc. - * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Additional permission under GNU GPL version 3 section 7: - * - * If you modify this program, or any covered work, by linking or - * combining it with the OpenSSL project's OpenSSL library (or a - * modified version of that library), containing parts covered by the - * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. - * grants you additional permission to convey the resulting work. - * Corresponding Source for a non-source form of such a combination - * shall include the source code for the parts of OpenSSL used as well - * as that of the covered work. - */ - -#include "plugin.h" - -#define MAJOR_VERSION 1 -#define MINOR_VERSION 0 - -class PluginTest : public Plugin { - - public: - PluginTest(const std::string &name) - :Plugin(name) { - } - - virtual int initFunc(PluginInfo **info) { - - (*info)->_plugin = this; - (*info)->_major_version = MAJOR_VERSION; - (*info)->_minor_version = MINOR_VERSION; - (*info)->_name = getPluginName(); - - return 0; - } -}; - -extern "C" Plugin* createPlugin(void) -{ - return new PluginTest("mytest"); -} - -extern "C" void destroyPlugin(Plugin *p) -{ - delete p; -} diff --git a/daemon/test/Makefile.am b/daemon/test/Makefile.am index cf38aaf032e5dc756260df0757e7726b8f54ef0e..c9fdba31d6b031192cf35e66d45242a6e47a781e 100644 --- a/daemon/test/Makefile.am +++ b/daemon/test/Makefile.am @@ -1,8 +1,6 @@ include ../globals.mak -TESTS_ENVIRONMENT = CODECS_PATH="$(top_builddir)/src/audio/codecs" \ - FAKE_PLUGIN_DIR="$(top_builddir)/src/plug-in/test/" \ - FAKE_PLUGIN_NAME="$(top_builddir)/src/plug-in/test/libplugintest.so" +TESTS_ENVIRONMENT = CODECS_PATH="$(top_builddir)/src/audio/codecs" check_PROGRAMS = test TESTS = run_tests.sh @@ -26,8 +24,6 @@ test_SOURCES = \ historytest.cpp \ numbercleanertest.h \ numbercleanertest.cpp \ - pluginmanagertest.h \ - pluginmanagertest.cpp \ rtptest.h \ rtptest.cpp \ sdesnegotiatortest.h \ @@ -53,7 +49,6 @@ test_SOURCES = \ instantmessagingtest.h \ mainbuffertest.h \ numbercleanertest.h \ - pluginmanagertest.h \ ringtonetest.h \ rtptest.h \ sdesnegotiatortest.h \ diff --git a/daemon/test/pluginmanagertest.cpp b/daemon/test/pluginmanagertest.cpp deleted file mode 100644 index ab9ac46e46b0bb5fac441f6b8915ed7bb3367768..0000000000000000000000000000000000000000 --- a/daemon/test/pluginmanagertest.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010 Savoir-Faire Linux Inc. - * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Additional permission under GNU GPL version 3 section 7: - * - * If you modify this program, or any covered work, by linking or - * combining it with the OpenSSL project's OpenSSL library (or a - * modified version of that library), containing parts covered by the - * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. - * grants you additional permission to convey the resulting work. - * Corresponding Source for a non-source form of such a combination - * shall include the source code for the parts of OpenSSL used as well - * as that of the covered work. - */ - -#include <stdio.h> -#include <sstream> -#include <dlfcn.h> - -#include "pluginmanagertest.h" - -using std::cout; -using std::endl; - -#define FAKE_PLUGIN_DESC "mytest" - - -void PluginManagerTest::setUp() -{ - FAKE_PLUGIN_DIR = std::string(getenv("FAKE_PLUGIN_DIR")); - FAKE_PLUGIN_NAME = std::string(getenv("FAKE_PLUGIN_NAME")); - // Instanciate the plugin manager singleton - _pm = PluginManager::instance(); - library = 0; - plugin = 0; -} - -void PluginManagerTest::testLoadDynamicLibrary() -{ - _debug("-------------------- PluginManagerTest::testLoadDynamicLibrary --------------------\n"); - - CPPUNIT_ASSERT(_pm->loadDynamicLibrary(FAKE_PLUGIN_NAME) != NULL); -} - -void PluginManagerTest::testUnloadDynamicLibrary() -{ - _debug("-------------------- PluginManagerTest::testUnloadDynamicLibrary --------------------\n"); - - library = _pm->loadDynamicLibrary(FAKE_PLUGIN_NAME); - CPPUNIT_ASSERT(library != NULL); - CPPUNIT_ASSERT(_pm->unloadDynamicLibrary(library) == 0); -} - -void PluginManagerTest::testInstanciatePlugin() -{ - _debug("-------------------- PluginManagerTest::testInstanciatePlugin --------------------\n"); - - library = _pm->loadDynamicLibrary(FAKE_PLUGIN_NAME); - CPPUNIT_ASSERT(library != NULL); - CPPUNIT_ASSERT(_pm->instanciatePlugin(library, &plugin) == 0); - CPPUNIT_ASSERT(plugin!=NULL); -} - -void PluginManagerTest::testInitPlugin() -{ - _debug("-------------------- PluginManagerTest::testInitPlugin --------------------\n"); - - library = _pm->loadDynamicLibrary(FAKE_PLUGIN_NAME); - CPPUNIT_ASSERT(library != NULL); - CPPUNIT_ASSERT(_pm->instanciatePlugin(library, &plugin) == 0); - CPPUNIT_ASSERT(plugin!=NULL); - CPPUNIT_ASSERT(plugin->getPluginName() == FAKE_PLUGIN_DESC); -} - -void PluginManagerTest::testRegisterPlugin() -{ - _debug("-------------------- PluginManagerTest::testRegisterPlugin --------------------\n"); - - library = _pm->loadDynamicLibrary(FAKE_PLUGIN_NAME); - CPPUNIT_ASSERT(library != NULL); - CPPUNIT_ASSERT(_pm->instanciatePlugin(library, &plugin) == 0); - CPPUNIT_ASSERT(_pm->isPluginLoaded(FAKE_PLUGIN_DESC) == false); - CPPUNIT_ASSERT(_pm->registerPlugin(plugin, library) == 0); - CPPUNIT_ASSERT(_pm->isPluginLoaded(FAKE_PLUGIN_DESC) == true); -} - -void PluginManagerTest::testLoadPlugins() -{ - _debug("-------------------- PluginManagerTest::testLoadPlugins --------------------\n"); - - try { - CPPUNIT_ASSERT(_pm->loadPlugins(FAKE_PLUGIN_DIR) == 0); - CPPUNIT_ASSERT(_pm->isPluginLoaded(FAKE_PLUGIN_DESC) == true); - } catch (LibraryManagerException &e) { - - } -} - -void PluginManagerTest::testUnloadPlugins() -{ - _debug("-------------------- PluginManagerTest::testUnloadPlugins --------------------\n"); - - try { - - CPPUNIT_ASSERT(_pm->loadPlugins(FAKE_PLUGIN_DIR) == 0); - CPPUNIT_ASSERT(_pm->isPluginLoaded(FAKE_PLUGIN_DESC) == true); - CPPUNIT_ASSERT(_pm->unloadPlugins() == 0); - CPPUNIT_ASSERT(_pm->isPluginLoaded(FAKE_PLUGIN_DESC) == false); - } catch (LibraryManagerException &e) { - - } -} - -void PluginManagerTest::tearDown() -{ - // Delete the plugin manager object - delete _pm; - _pm=0; - - delete plugin; - plugin = 0; - - delete library; - library = 0; -} diff --git a/daemon/test/pluginmanagertest.h b/daemon/test/pluginmanagertest.h deleted file mode 100644 index 2d2975d8b140a1c59ea0ec6ee469136e9e156e28..0000000000000000000000000000000000000000 --- a/daemon/test/pluginmanagertest.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010 Savoir-Faire Linux Inc. - * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Additional permission under GNU GPL version 3 section 7: - * - * If you modify this program, or any covered work, by linking or - * combining it with the OpenSSL project's OpenSSL library (or a - * modified version of that library), containing parts covered by the - * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. - * grants you additional permission to convey the resulting work. - * Corresponding Source for a non-source form of such a combination - * shall include the source code for the parts of OpenSSL used as well - * as that of the covered work. - */ - -// Cppunit import -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCaller.h> -#include <cppunit/TestCase.h> -#include <cppunit/TestSuite.h> - -#include <assert.h> - -// Application import -#include "plug-in/pluginmanager.h" -#include "plug-in/librarymanager.h" -#include "plug-in/plugin.h" - -/* - * @file pluginManagerTest.cpp - * @brief Regroups unitary tests related to the plugin manager. - */ - -#ifndef _PLUGINMANAGER_TEST_ -#define _PLUGINMANAGER_TEST_ - -class PluginManagerTest : public CppUnit::TestCase { - - /** - * Use cppunit library macros to add unit test the factory - */ - CPPUNIT_TEST_SUITE(PluginManagerTest); - CPPUNIT_TEST(testLoadDynamicLibrary); - CPPUNIT_TEST(testUnloadDynamicLibrary); - CPPUNIT_TEST(testInstanciatePlugin); - CPPUNIT_TEST(testInitPlugin); - CPPUNIT_TEST(testRegisterPlugin); - CPPUNIT_TEST(testLoadPlugins); - CPPUNIT_TEST(testUnloadPlugins); - CPPUNIT_TEST_SUITE_END(); - - public: - PluginManagerTest() : CppUnit::TestCase("Plugin Manager Tests") - , _pm(0) - , library(0) - , plugin(0) - {} - - /* - * Code factoring - Common resources can be initialized here. - * This method is called by unitcpp before each test - */ - void setUp(); - - /* - * Code factoring - Common resources can be released here. - * This method is called by unitcpp after each test - */ - void tearDown(); - - void testLoadDynamicLibrary(); - - void testUnloadDynamicLibrary(); - - void testInstanciatePlugin(); - - void testInitPlugin(); - - void testRegisterPlugin(); - - void testLoadPlugins(); - - void testUnloadPlugins(); - - private: - std::string FAKE_PLUGIN_DIR; - std::string FAKE_PLUGIN_NAME; - PluginManager *_pm; - LibraryManager *library; - Plugin *plugin; -}; - -/* Register our test module */ -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(PluginManagerTest, "PluginManagerTest"); -CPPUNIT_TEST_SUITE_REGISTRATION(PluginManagerTest); - -#endif diff --git a/daemon/test/run_tests.sh b/daemon/test/run_tests.sh index 69649f1ffa2b93c9eb95c886d580851b9d29e420..85a3a785019821bd50704031b3a63feea6dad5a6 100755 --- a/daemon/test/run_tests.sh +++ b/daemon/test/run_tests.sh @@ -1,2 +1,2 @@ #!/bin/bash -CODECS_PATH="../src/audio/codecs" FAKE_PLUGIN_DIR="../src/plug-in/test/" FAKE_PLUGIN_NAME="../src/plug-in/test/libplugintest.so" exec ./test --xml +CODECS_PATH="../src/audio/codecs" exec ./test --xml