add bool type plugin 42/68242/1
authorMyoungJune Park <mj2004.park@samsung.com>
Tue, 19 Jan 2016 09:20:53 +0000 (18:20 +0900)
committerMyoungJune Park <mj2004.park@samsung.com>
Tue, 3 May 2016 06:28:31 +0000 (15:28 +0900)
Change-Id: I66faf4fb7a549f2842cbf7bac0b8696d423b2215
Signed-off-by: MyoungJune Park <mj2004.park@samsung.com>
plugin_model/config_header.xsl
plugin_model/config_impl.xsl
plugin_model/config_manager.c
plugin_model/config_manager.h
plugin_model/config_system_table.h
plugin_model/config_table.c
plugin_model/config_table.h
plugin_model/config_table.xml
plugin_model/plugin_hello/CMakeLists.txt
plugin_model/plugin_hello/hellobool_plugin.c [new file with mode: 0644]
plugin_model/plugin_model.h

index 73c1bd2..90dd507 100644 (file)
@@ -24,10 +24,18 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  * limitations under the License.
  *
  */
+#ifndef bool
+typedef int bool;
+#ifndef true
+#define true 1
+#endif
+#ifndef false
+#define false 0
+#endif
+#endif
 <xsl:apply-templates select="configlists/config"></xsl:apply-templates>
 </xsl:template>
 
-
 <xsl:template match="config">
 char* <xsl:value-of select="./@name"/>_plugin_path();<xsl:text>&#xa;</xsl:text>
 <xsl:apply-templates select="plugin/function"></xsl:apply-templates>
@@ -77,6 +85,28 @@ int <xsl:value-of select="../../@name"/>_<xsl:value-of select="./@type"/>(char*
 </xsl:choose>
 <!-- end choose INT -->
        </xsl:when>
+       <xsl:when test="../../@type='bool'">
+<!-- begin choose INT-->
+<xsl:choose>
+        <xsl:when test="./@type='init'">
+int <xsl:value-of select="../../@name"/>_<xsl:value-of select="./@type"/>();<xsl:text>&#xa;</xsl:text>
+               </xsl:when>
+
+        <xsl:when test="./@type='destroy'">
+int <xsl:value-of select="../../@name"/>_<xsl:value-of select="./@type"/>();<xsl:text>&#xa;</xsl:text>
+               </xsl:when>
+
+        <xsl:when test="./@type='get'">
+bool <xsl:value-of select="../../@name"/>_<xsl:value-of select="./@type"/>(char* key);<xsl:text>&#xa;</xsl:text>
+               </xsl:when>
+
+        <xsl:when test="./@type='set'">
+int <xsl:value-of select="../../@name"/>_<xsl:value-of select="./@type"/>(char* key, bool value);<xsl:text>&#xa;</xsl:text>
+               </xsl:when>
+</xsl:choose>
+<!-- end choose INT -->
+       </xsl:when>
+
 </xsl:choose>
 
 </xsl:template>
index 3e12bab..3f4c482 100644 (file)
@@ -125,8 +125,51 @@ int <xsl:value-of select="../../@name"/>_<xsl:value-of select="./@type"/>(char*
                </xsl:when>
 </xsl:choose>
 <!-- end choose INT -->
+       </xsl:when>
+       <xsl:when test="../../@type='bool'">
+<!-- begin choose INT-->
+<xsl:choose>
+        <xsl:when test="./@type='init'">
+int <xsl:value-of select="../../@name"/>_<xsl:value-of select="./@type"/>()<xsl:text>&#xa;</xsl:text>
+{
+       return 0;
+}
+               </xsl:when>
+
+        <xsl:when test="./@type='destroy'">
+int <xsl:value-of select="../../@name"/>_<xsl:value-of select="./@type"/>()<xsl:text>&#xa;</xsl:text>
+{
+       return 0;
+}
+               </xsl:when>
+
+        <xsl:when test="./@type='get'">
+bool <xsl:value-of select="../../@name"/>_<xsl:value-of select="./@type"/>(char* key)<xsl:text>&#xa;</xsl:text>
+{
+       PluginTizenConfig* (*fn)(int *);
+       fn = config_manager(<xsl:value-of select="../../@name"/>_plugin_path(), "<xsl:value-of select="../@name"/>");
+       bool val = config_manager_get_bool(fn, key);
+       config_manager_close();
+       return val;
+}
+               </xsl:when>
+
+        <xsl:when test="./@type='set'">
+int <xsl:value-of select="../../@name"/>_<xsl:value-of select="./@type"/>(char* key, bool value)<xsl:text>&#xa;</xsl:text>
+{
+       PluginTizenConfig* (*fn)(int *);
+       fn = config_manager(<xsl:value-of select="../../@name"/>_plugin_path(), "<xsl:value-of select="../@name"/>");
+       config_manager_set_bool(fn, key, value);
+       config_manager_close();
+       return 0;
+}
+               </xsl:when>
+</xsl:choose>
+<!-- end choose INT -->
 
        </xsl:when>
+
+
 </xsl:choose>
 
 
index f1d8b02..77ae3e7 100644 (file)
@@ -68,7 +68,6 @@ int config_manager_set_int(PluginTizenConfig* (*fn)(),char* key, int value)
        return 0;
 }
 
-#if 0
 bool config_manager_get_bool(PluginTizenConfig* (*fn)(),char* key)
 {
        PluginTizenConfig* pt_table = (*fn)();
@@ -88,7 +87,6 @@ int config_manager_set_bool(PluginTizenConfig* (*fn)(),char* key, bool value)
 
        return 0;
 }
-#endif
 
 void config_manager_close()
 {
index f366498..40f96ad 100644 (file)
@@ -7,8 +7,6 @@
 extern "C" {
 #endif
 
-//PluginTizenConfig* (*fn)(int *);
-
 // config_manager
 PluginTizenConfig* (*config_manager(char* plugin_path, char* plugin_id))();
 
@@ -24,8 +22,12 @@ int config_manager_get_int(PluginTizenConfig* (*fn)(int *), char* key);
 // plugin_manager_set
 int config_manager_set_int(PluginTizenConfig* (*fn)(int *), char* key, int value);
 
+// plugin_manager_get
+bool config_manager_get_bool(PluginTizenConfig* (*fn)(int *), char* key);
+
+// plugin_manager_set
+int config_manager_set_bool(PluginTizenConfig* (*fn)(int *), char* key, bool value);
 
-// plugin_manager_close
 void config_manager_close();
 
 #ifdef __cplusplus
index b416b62..fd7cb59 100644 (file)
  * limitations under the License.
  *
  */
+#ifndef bool
+typedef int bool;
+#ifndef true
+#define true 1
+#endif
+#ifndef false
+#define false 0
+#endif
+#endif
 char* airplane_mode_on_plugin_path();
 char* airplane_mode_on_get(char* key);
 int airplane_mode_on_set(char* key, char* value);
index 28a0ebf..4b82f74 100644 (file)
@@ -50,6 +50,28 @@ char* get_simple_text_get(char* key)
        return val;
 }
                
+char* get_bool_version_plugin_path()
+{
+       return "/usr/lib/libhelloworld_plugin.so";
+}
+bool get_bool_version_get(char* key)
+{
+       PluginTizenConfig* (*fn)(int *);
+       fn = config_manager(get_bool_version_plugin_path(), "get_plugin_hellobool_object");
+       bool val = config_manager_get_bool(fn, key);
+       config_manager_close();
+       return val;
+}
+               
+int get_bool_version_set(char* key, bool value)
+{
+       PluginTizenConfig* (*fn)(int *);
+       fn = config_manager(get_bool_version_plugin_path(), "get_plugin_hellobool_object");
+       config_manager_set_bool(fn, key, value);
+       config_manager_close();
+       return 0;
+}
+               
 char* get_int_version_plugin_path()
 {
        return "/usr/lib/libhelloworld_plugin.so";
index cbe9b24..169258f 100644 (file)
  * limitations under the License.
  *
  */
+#ifndef bool
+typedef int bool;
+#ifndef true
+#define true 1
+#endif
+#ifndef false
+#define false 0
+#endif
+#endif
 char* get_complex_string_plugin_path();
 char* get_complex_string_get(char* key);
 char* get_simple_text_plugin_path();
 char* get_simple_text_get(char* key);
+char* get_bool_version_plugin_path();
+bool get_bool_version_get(char* key);
+int get_bool_version_set(char* key, bool value);
 char* get_int_version_plugin_path();
 int get_int_version_get(char* key);
 int get_int_version_set(char* key, int value);
index 8ca901e..11ea4b0 100644 (file)
                <desc>simple text example</desc>
        </config>
 
+       <config name="get_bool_version" type="bool">
+               <plugin name="get_plugin_hellobool_object" path="/usr/lib/libhelloworld_plugin.so">
+                       <function type="get"/>
+                       <function type="set"/>
+               </plugin>
+               <desc>get_bool_version</desc>
+       </config>
+
        <config name="get_int_version" type="int">
                <plugin name="get_plugin_helloint_object" path="/usr/lib/libhelloworld_plugin.so">
                        <function type="get"/>
                        <function type="set"/>
                </plugin>
-               <desc>ini plugin example</desc>
+               <desc>get_int_version</desc>
        </config>
 
-
        <config name="get_sw_version" type="string">
                <plugin name="get_plugin_ini_object" path="/usr/lib/libplugin2.so">
                <!--<plugin name="get_plugin_helloworld_object" path="/usr/lib/libhelloworld_plugin.so">-->
index 48bf707..fffdd32 100644 (file)
@@ -12,7 +12,7 @@ ENDFOREACH(flag)
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Werror-implicit-function-declaration")
 SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
 
-ADD_LIBRARY(helloworld_plugin SHARED helloworld_plugin.c helloint_plugin.c)
+ADD_LIBRARY(helloworld_plugin SHARED helloworld_plugin.c helloint_plugin.c hellobool_plugin.c)
 SET(PLUGIN1_VERSION_MAJOR 1)
 SET(PLUGIN1_VERSION_MINOR 1)
 SET(PLUGIN1_VERSION_PATCH 0)
diff --git a/plugin_model/plugin_hello/hellobool_plugin.c b/plugin_model/plugin_hello/hellobool_plugin.c
new file mode 100644 (file)
index 0000000..0267c32
--- /dev/null
@@ -0,0 +1,38 @@
+#include <stdio.h>
+#include <plugin1.h>
+
+static int hellobool_init()
+{
+       printf("hellobool_init \n");
+       return 0;
+}
+
+static bool hellobool_get_config(char* key)
+{
+       printf("hellobool_get_config : %s \n", key);
+       return true;
+}
+
+static int hellobool_set_config(char* key, bool value)
+{
+       printf("hellobool_set_config key : %s, value : %d \n", key, value);
+       return 0;
+}
+
+static int hellobool_destroy()
+{
+       printf("hellobool_destroy \n");
+       return 0;
+}
+
+static PluginTizenConfig config = {
+       .init = hellobool_init,
+       .get_config_bool = hellobool_get_config,
+       .set_config_bool = hellobool_set_config,
+       .destroy = hellobool_destroy
+};
+
+PluginTizenConfig* get_plugin_hellobool_object()
+{
+       return &config;
+}
index 49850bb..1677e90 100644 (file)
@@ -5,6 +5,16 @@
 extern "C" {
 #endif
 
+#ifndef bool
+typedef int bool;
+#ifndef true
+#define true 1
+#endif
+#ifndef false
+#define false 0
+#endif
+#endif
+
 typedef struct _tagPluginTizenConfig
 {
        int (*init)(void);
@@ -15,6 +25,10 @@ typedef struct _tagPluginTizenConfig
        int (*get_config_int)(char * key);
        int (*set_config_int)(char * key, int value);
 
+       // int type
+       bool (*get_config_bool)(char * key);
+       int (*set_config_bool)(char * key, bool value);
+
        int (*destroy)(void);
 } PluginTizenConfig;