Add section id to struct wkb_config_key
authorEduardo Lima (Etrunko) <eduardo.lima@intel.com>
Wed, 22 Oct 2014 18:26:44 +0000 (16:26 -0200)
committerEduardo Lima (Etrunko) <eduardo.lima@intel.com>
Mon, 27 Oct 2014 20:47:24 +0000 (18:47 -0200)
Also make it available via accessor functions

Change-Id: Ie7642ffe80279923b3fa775723157e6ae438c167
Signed-off-by: Eduardo Lima (Etrunko) <eduardo.lima@intel.com>
src/wkb-ibus-config-eet.c
src/wkb-ibus-config-key.c
src/wkb-ibus-config-key.h

index eee3b3c4d3e1d40c1ca5e65f35173f69be8d8900..4f455cf70f6a66b3f1dabaaa2b89300d3c1f631c 100644 (file)
@@ -175,7 +175,7 @@ end:
 #define _config_section_add_key(_section, _section_id, _key_type, _field) \
    do { \
         struct _config_ ## _section_id *__conf = (struct _config_ ## _section_id *) _section; \
-        struct wkb_config_key *__key = wkb_config_key_ ## _key_type(#_field, &__conf->_field); \
+        struct wkb_config_key *__key = wkb_config_key_ ## _key_type(#_field, _section->id, &__conf->_field); \
         _section->keys = eina_list_append(_section->keys, __key); \
    } while (0)
 
index e44ce0a02b738c7c77d1040f03f80752eef571aa..1429c867e88566b23919e44a921720b74dd309ae 100644 (file)
@@ -32,6 +32,7 @@ typedef Eina_Bool (*key_get_cb) (struct wkb_config_key *, Eldbus_Message_Iter *)
 struct wkb_config_key
 {
    const char *id;
+   const char *section;
    const char *signature;
    void *field; /* pointer to the actual struct field */
 
@@ -41,10 +42,11 @@ struct wkb_config_key
 };
 
 static struct wkb_config_key *
-_key_new(const char *id, const char *signature, void *field, key_free_cb free_cb, key_set_cb set_cb, key_get_cb get_cb)
+_key_new(const char *id, const char *section, const char *signature, void *field, key_free_cb free_cb, key_set_cb set_cb, key_get_cb get_cb)
 {
    struct wkb_config_key *key = calloc(1, sizeof(*key));
    key->id = eina_stringshare_add(id);
+   key->section = eina_stringshare_add(section);
    key->signature = eina_stringshare_add(signature);
    key->field = field;
    key->free = free_cb;
@@ -189,27 +191,27 @@ _key_string_list_get(struct wkb_config_key *key, Eldbus_Message_Iter *reply)
  * PUBLIC FUNCTIONS
  */
 struct wkb_config_key *
-wkb_config_key_int(const char *id, void *field)
+wkb_config_key_int(const char *id, const char *section, void *field)
 {
-   return _key_new(id, "i", field, NULL, _key_int_set, _key_int_get);
+   return _key_new(id, section, "i", field, NULL, _key_int_set, _key_int_get);
 }
 
 struct wkb_config_key *
-wkb_config_key_bool(const char *id, void *field)
+wkb_config_key_bool(const char *id, const char *section, void *field)
 {
-   return _key_new(id, "b", field, NULL, _key_bool_set, _key_bool_get);
+   return _key_new(id, section, "b", field, NULL, _key_bool_set, _key_bool_get);
 }
 
 struct wkb_config_key *
-wkb_config_key_string(const char *id, void *field)
+wkb_config_key_string(const char *id, const char *section, void *field)
 {
-   return _key_new(id, "s", field, (key_free_cb) _key_string_free, _key_string_set, _key_string_get);
+   return _key_new(id, section, "s", field, (key_free_cb) _key_string_free, _key_string_set, _key_string_get);
 }
 
 struct wkb_config_key *
-wkb_config_key_string_list(const char *id, void *field)
+wkb_config_key_string_list(const char *id, const char *section, void *field)
 {
-   return _key_new(id, "as", field, (key_free_cb) _key_string_list_free, _key_string_list_set, _key_string_list_get);
+   return _key_new(id, section, "as", field, (key_free_cb) _key_string_list_free, _key_string_list_set, _key_string_list_get);
 }
 
 void
@@ -219,6 +221,7 @@ wkb_config_key_free(struct wkb_config_key *key)
       key->free(key->field);
 
    eina_stringshare_del(key->id);
+   eina_stringshare_del(key->section);
    eina_stringshare_del(key->signature);
    free(key);
 }
@@ -229,6 +232,12 @@ wkb_config_key_id(struct wkb_config_key *key)
    return key->id;
 }
 
+const char *
+wkb_config_key_section(struct wkb_config_key *key)
+{
+   return key->section;
+}
+
 const char *
 wkb_config_key_signature(struct wkb_config_key *key)
 {
index f76f8aa1dec644f11f330f6146ba3d6cc69ac34b..5706667992d01c326080f1c40effbe0ebf3b4965 100644 (file)
@@ -27,13 +27,14 @@ extern "C" {
 
 struct wkb_config_key;
 
-struct wkb_config_key *wkb_config_key_int(const char *id, void *field);
-struct wkb_config_key *wkb_config_key_bool(const char *id, void *field);
-struct wkb_config_key *wkb_config_key_string(const char *id, void *field);
-struct wkb_config_key *wkb_config_key_string_list(const char *id, void *field);
+struct wkb_config_key *wkb_config_key_int(const char *id, const char *section, void *field);
+struct wkb_config_key *wkb_config_key_bool(const char *id, const char *section, void *field);
+struct wkb_config_key *wkb_config_key_string(const char *id, const char *section, void *field);
+struct wkb_config_key *wkb_config_key_string_list(const char *id, const char *section, void *field);
 
 void wkb_config_key_free(struct wkb_config_key *key);
 const char *wkb_config_key_id(struct wkb_config_key *key);
+const char *wkb_config_key_section(struct wkb_config_key *key);
 const char *wkb_config_key_signature(struct wkb_config_key *key);
 Eina_Bool wkb_config_key_set(struct wkb_config_key * key, Eldbus_Message_Iter *iter);
 Eina_Bool wkb_config_key_get(struct wkb_config_key *key, Eldbus_Message_Iter *reply);