From: MyoungJune Park Date: Tue, 19 Jan 2016 09:20:53 +0000 (+0900) Subject: add bool type plugin X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F42%2F68242%2F1;p=platform%2Fframework%2Fnative%2Ftizen-config-fw.git add bool type plugin Change-Id: I66faf4fb7a549f2842cbf7bac0b8696d423b2215 Signed-off-by: MyoungJune Park --- diff --git a/plugin_model/config_header.xsl b/plugin_model/config_header.xsl index 73c1bd2..90dd507 100644 --- a/plugin_model/config_header.xsl +++ b/plugin_model/config_header.xsl @@ -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 - char* _plugin_path(); @@ -77,6 +85,28 @@ int _(char* + + + + +int _(); + + + +int _(); + + + +bool _(char* key); + + + +int _(char* key, bool value); + + + + + diff --git a/plugin_model/config_impl.xsl b/plugin_model/config_impl.xsl index 3e12bab..3f4c482 100644 --- a/plugin_model/config_impl.xsl +++ b/plugin_model/config_impl.xsl @@ -125,8 +125,51 @@ int _(char* + + + + + +int _() +{ + return 0; +} + + + +int _() +{ + return 0; +} + + + +bool _(char* key) +{ + PluginTizenConfig* (*fn)(int *); + fn = config_manager(_plugin_path(), ""); + bool val = config_manager_get_bool(fn, key); + config_manager_close(); + return val; +} + + + +int _(char* key, bool value) +{ + PluginTizenConfig* (*fn)(int *); + fn = config_manager(_plugin_path(), ""); + config_manager_set_bool(fn, key, value); + config_manager_close(); + return 0; +} + + + + + diff --git a/plugin_model/config_manager.c b/plugin_model/config_manager.c index f1d8b02..77ae3e7 100644 --- a/plugin_model/config_manager.c +++ b/plugin_model/config_manager.c @@ -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() { diff --git a/plugin_model/config_manager.h b/plugin_model/config_manager.h index f366498..40f96ad 100644 --- a/plugin_model/config_manager.h +++ b/plugin_model/config_manager.h @@ -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 diff --git a/plugin_model/config_system_table.h b/plugin_model/config_system_table.h index b416b62..fd7cb59 100644 --- a/plugin_model/config_system_table.h +++ b/plugin_model/config_system_table.h @@ -18,6 +18,15 @@ * 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); diff --git a/plugin_model/config_table.c b/plugin_model/config_table.c index 28a0ebf..4b82f74 100644 --- a/plugin_model/config_table.c +++ b/plugin_model/config_table.c @@ -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"; diff --git a/plugin_model/config_table.h b/plugin_model/config_table.h index cbe9b24..169258f 100644 --- a/plugin_model/config_table.h +++ b/plugin_model/config_table.h @@ -18,10 +18,22 @@ * 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); diff --git a/plugin_model/config_table.xml b/plugin_model/config_table.xml index 8ca901e..11ea4b0 100644 --- a/plugin_model/config_table.xml +++ b/plugin_model/config_table.xml @@ -16,15 +16,22 @@ simple text example + + + + + + get_bool_version + + - ini plugin example + get_int_version - diff --git a/plugin_model/plugin_hello/CMakeLists.txt b/plugin_model/plugin_hello/CMakeLists.txt index 48bf707..fffdd32 100644 --- a/plugin_model/plugin_hello/CMakeLists.txt +++ b/plugin_model/plugin_hello/CMakeLists.txt @@ -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 index 0000000..0267c32 --- /dev/null +++ b/plugin_model/plugin_hello/hellobool_plugin.c @@ -0,0 +1,38 @@ +#include +#include + +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; +} diff --git a/plugin_model/plugin_model.h b/plugin_model/plugin_model.h index 49850bb..1677e90 100644 --- a/plugin_model/plugin_model.h +++ b/plugin_model/plugin_model.h @@ -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;