diff options
author | Eduardo Lima (Etrunko) <eduardo.lima@intel.com> | 2014-10-23 12:10:05 -0200 |
---|---|---|
committer | Eduardo Lima (Etrunko) <eduardo.lima@intel.com> | 2014-10-27 18:47:22 -0200 |
commit | f1482b7f354a462bcad36ef64625f67aac900b3d (patch) | |
tree | 7f8fd54aa713a6dc6d8c37223f87d37a99b583a6 | |
parent | 7b75c61b1fc2a8d49e10c141fdc255f83ef8da94 (diff) | |
download | weekeyboard-f1482b7f354a462bcad36ef64625f67aac900b3d.tar.gz weekeyboard-f1482b7f354a462bcad36ef64625f67aac900b3d.tar.bz2 weekeyboard-f1482b7f354a462bcad36ef64625f67aac900b3d.zip |
Accessor for string_list keys
Change-Id: Ie6c692829bcd05a409e7102e8b9f3e87b94d79d6
Signed-off-by: Eduardo Lima (Etrunko) <eduardo.lima@intel.com>
-rw-r--r-- | src/wkb-ibus-config-eet.c | 16 | ||||
-rw-r--r-- | src/wkb-ibus-config-eet.h | 1 | ||||
-rw-r--r-- | src/wkb-ibus-config-key.c | 16 | ||||
-rw-r--r-- | src/wkb-ibus-config-key.h | 1 | ||||
-rw-r--r-- | src/wkb-ibus-config.c | 9 | ||||
-rw-r--r-- | src/wkb-ibus-config.h | 2 |
6 files changed, 45 insertions, 0 deletions
diff --git a/src/wkb-ibus-config-eet.c b/src/wkb-ibus-config-eet.c index ed0f8e9..87d50bd 100644 --- a/src/wkb-ibus-config-eet.c +++ b/src/wkb-ibus-config-eet.c @@ -881,6 +881,22 @@ wkb_ibus_config_eet_get_value_string(struct wkb_ibus_config_eet *config_eet, con return wkb_config_key_get_string(key); } +char ** +wkb_ibus_config_eet_get_value_string_list(struct wkb_ibus_config_eet *config_eet, const char *section, const char *name) +{ + struct wkb_config_key *key; + + if (!(key = _config_section_find_key(config_eet->ibus_config, section, name))) + { + ERR("Config key with id '%s' not found", name); + return NULL; + } + + DBG("Found key: section = <%s> name = <%s>", section, name); + + return wkb_config_key_get_string_list(key); +} + Eina_Bool wkb_ibus_config_eet_get_values(struct wkb_ibus_config_eet *config_eet, const char *section, Eldbus_Message_Iter *reply) { diff --git a/src/wkb-ibus-config-eet.h b/src/wkb-ibus-config-eet.h index 1d10905..e47a138 100644 --- a/src/wkb-ibus-config-eet.h +++ b/src/wkb-ibus-config-eet.h @@ -42,6 +42,7 @@ void wkb_ibus_config_eet_shutdown(void); int wkb_ibus_config_eet_get_value_int(struct wkb_ibus_config_eet *config_eet, const char *section, const char *name); Eina_Bool wkb_ibus_config_eet_get_value_bool(struct wkb_ibus_config_eet *config_eet, const char *section, const char *name); const char *wkb_ibus_config_eet_get_value_string(struct wkb_ibus_config_eet *config_eet, const char *section, const char *name); +char **wkb_ibus_config_eet_get_value_string_list(struct wkb_ibus_config_eet *config_eet, const char *section, const char *name); #ifdef __cplusplus } #endif diff --git a/src/wkb-ibus-config-key.c b/src/wkb-ibus-config-key.c index 94c3a8d..e44ce0a 100644 --- a/src/wkb-ibus-config-key.c +++ b/src/wkb-ibus-config-key.c @@ -292,3 +292,19 @@ wkb_config_key_get_string(struct wkb_config_key* key) return *((const char **) key->field); } +char ** +wkb_config_key_get_string_list(struct wkb_config_key *key) +{ + Eina_List *node, **list = (Eina_List **) key->field; + char *str, **ret; + int i = 0; + + assert(!strcmp(key->signature, "as")); + + ret = calloc(eina_list_count(*list) + 1, sizeof(char *)); + EINA_LIST_FOREACH(*list, node, str) + ret[i++] = str; + + return ret; +} + diff --git a/src/wkb-ibus-config-key.h b/src/wkb-ibus-config-key.h index fc8352a..f76f8aa 100644 --- a/src/wkb-ibus-config-key.h +++ b/src/wkb-ibus-config-key.h @@ -41,6 +41,7 @@ Eina_Bool wkb_config_key_get(struct wkb_config_key *key, Eldbus_Message_Iter *re int wkb_config_key_get_int(struct wkb_config_key* key); Eina_Bool wkb_config_key_get_bool(struct wkb_config_key* key); const char *wkb_config_key_get_string(struct wkb_config_key* key); +char **wkb_config_key_get_string_list(struct wkb_config_key *key); #ifdef __cplusplus } diff --git a/src/wkb-ibus-config.c b/src/wkb-ibus-config.c index 408abea..cf155c1 100644 --- a/src/wkb-ibus-config.c +++ b/src/wkb-ibus-config.c @@ -70,6 +70,15 @@ wkb_ibus_config_get_value_string(const char *section, const char *name) return wkb_ibus_config_eet_get_value_string(_conf_eet, section, name); } +char ** +wkb_ibus_config_get_value_string_list(const char *section, const char *name) +{ + if (!_conf_eet) + return NULL; + + return wkb_ibus_config_eet_get_value_string_list(_conf_eet, section, name); +} + static Eldbus_Message * _config_set_value(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg) { diff --git a/src/wkb-ibus-config.h b/src/wkb-ibus-config.h index c329c37..0c7fc78 100644 --- a/src/wkb-ibus-config.h +++ b/src/wkb-ibus-config.h @@ -1,5 +1,6 @@ /* * Copyright © 2014 Jaguar Landrover + * Copyright © 2014 Intel Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +28,7 @@ extern "C" { int wkb_ibus_config_get_value_int(const char *section, const char *name); Eina_Bool wkb_ibus_config_get_value_bool(const char *section, const char *name); const char *wkb_ibus_config_get_value_string(const char *section, const char *name); +char **wkb_ibus_config_get_value_string_list(const char *section, const char *name); #ifdef __cplusplus } |