From d91dfd6d9117a24b21e81f03c123fce6e92d277a Mon Sep 17 00:00:00 2001
From: Emmanuel Milou <manu@manu-eeepc.(none)>
Date: Mon, 26 Jan 2009 23:38:46 -0500
Subject: [PATCH] Continue plugin API definition

---
 configure.ac                    |  3 +-
 src/plug-in/Makefile.am         |  5 ++-
 src/plug-in/plugin_api.h        | 65 +++++++++++++++++++++++++++++++++
 src/plug-in/test/Makefile.am    | 21 +++++++++++
 src/plug-in/test/pluginTest.cpp | 15 ++++++++
 5 files changed, 106 insertions(+), 3 deletions(-)
 create mode 100644 src/plug-in/plugin_api.h
 create mode 100644 src/plug-in/test/Makefile.am
 create mode 100644 src/plug-in/test/pluginTest.cpp

diff --git a/configure.ac b/configure.ac
index 3cb974e0f6..3fc535bcb9 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 53bf6b050c..3e386fcc6e 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 0000000000..66f078b5cb
--- /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 0000000000..f52231a05a
--- /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 0000000000..2e467dbe1b
--- /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;
+}
-- 
GitLab