diff --git a/configure.ac b/configure.ac index 3cb974e0f6ecae9ae549ade4553542e7093bbe43..3fc535bcb9d9a0fe59321928b90cffa7e6a1d6b6 100644 --- a/configure.ac +++ b/configure.ac @@ -38,7 +38,8 @@ AC_CONFIG_FILES([src/Makefile \ src/config/Makefile \ src/dbus/Makefile \ src/zeroconf/Makefile \ - src/plug-in/Makefile]) + src/plug-in/Makefile \ + src/plug-in/test/Makefile]) dnl Unitary test section AC_CONFIG_FILES([test/Makefile]) diff --git a/src/plug-in/Makefile.am b/src/plug-in/Makefile.am index 53bf6b050cba69da07a0f8fd60b2f4b52c8f41d6..3e386fcc6e6aa1da0a4cbbd2ab4108979513d6a4 100644 --- a/src/plug-in/Makefile.am +++ b/src/plug-in/Makefile.am @@ -2,7 +2,8 @@ include ../../globals.mak noinst_LTLIBRARIES = libplugin.la +noinst_HEADERS=plugin_api.h + libplugin_la_SOURCES = \ - pluginmanager.cpp \ - plugin.h + pluginmanager.cpp diff --git a/src/plug-in/plugin_api.h b/src/plug-in/plugin_api.h new file mode 100644 index 0000000000000000000000000000000000000000..66f078b5cb02dbbd655b9370e05fe0e096215749 --- /dev/null +++ b/src/plug-in/plugin_api.h @@ -0,0 +1,65 @@ +#ifndef PLUGIN_API_H +#define PLUGIN_API_H + +#include <string> + +#include "global.h" + +/* + * @file plugin_api.h + * @brief Define a plugin object + */ + +#ifdef __cplusplus +extern "C" { +#endif + + namespace sflphone { + + class PluginManager; + + typedef struct PluginApi_Version{ + int version; + int revision; + } + + typedef struct Register_Params{ + PluginApi_Version plugin_version; + create_t create_func; + destroy_t destroy_func; + }Register_Params; + + class PluginApi { + + public: + PluginApi( const std::string &name ); + //Plugin( const Plugin &plugin ); + virtual ~PluginApi() {} + + public: + /** + * Return the minimal core version required so that the plugin could work + * @return int The version required + */ + virtual int getCoreVersion() const = 0; + + /** + * Register the plugin to the plugin manager + */ + virtual void registerPlugin( PluginManager & ) = 0; + + private: + PluginApi &operator =(const PluginApi &plugin); + + }; + + typedef Plugin* create_t( void* ); + typedef int destroy_t( Plugin* ); + } + +#ifdef __cplusplus +} +#endif + +#endif //PLUGIN_API_H + diff --git a/src/plug-in/test/Makefile.am b/src/plug-in/test/Makefile.am new file mode 100644 index 0000000000000000000000000000000000000000..f52231a05acf7593b76ab730f5838cef2c3fb728 --- /dev/null +++ b/src/plug-in/test/Makefile.am @@ -0,0 +1,21 @@ +include $(top_srcdir)/globals.mak + +PLUGIN_LIB = libplugintest.so +libplugintest_so_SOURCES = pluginTest.cpp +libplugintest_so_CXXFLAGS = -fPIC -g -Wall +libplugintest_so_LDFLAGS = --shared -lc +INSTALL_PLUGIN_RULE = install-libplugintest_so + +noinst_PROGRAMS = libplugintest.so + +noinst_HEADERS = plugin_api.h + +install-exec-local: install-libplugintest_so +uninstall-local: uninstall-libplugintest_so + +install-libplugintest_so: libplugintest.so + mkdir -p $(sflpluginsdir) + $(INSTALL_PROGRAM) libplugintest.so $(sflpluginsdir) + +uninstall-libplugintest_so: + rm -f $(sflpluginsdir)/libplugintest.so diff --git a/src/plug-in/test/pluginTest.cpp b/src/plug-in/test/pluginTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2e467dbe1babdff773d46d4adff4a041d37cd2fa --- /dev/null +++ b/src/plug-in/test/pluginTest.cpp @@ -0,0 +1,15 @@ +#include "../plugin_api.h" + +class PluginTest : public Plugin { + public: + PluginTest():Plugin(){ + } +}; + +extern "C" Plugin* create_t( void * ){ + return new PluginTest(); +} + +extern "C" void* destroy_t( Plugin *p ){ + delete p; +}