diff options
author | sung.goo.kim <sung.goo.kim@samsung.com> | 2016-05-16 10:21:36 +0900 |
---|---|---|
committer | sung.goo.kim <sung.goo.kim@samsung.com> | 2016-06-02 12:42:56 +0900 |
commit | 2481c74d5868a0ec78afc7359735222e7bc3db74 (patch) | |
tree | 34db5646fb3fdfd837044e7fe06fb07812347610 | |
parent | be2e4f383222b58ce9c7013eda3e5b54486a953e (diff) | |
download | iotcon-2481c74d5868a0ec78afc7359735222e7bc3db74.tar.gz iotcon-2481c74d5868a0ec78afc7359735222e7bc3db74.tar.bz2 iotcon-2481c74d5868a0ec78afc7359735222e7bc3db74.zip |
Modify handle/enum/API name (state->attributes)
Change-Id: I829fdb33020d9f27aa2063cb018e0dc9345bda8a
28 files changed, 742 insertions, 722 deletions
diff --git a/doc/iotcon_doc.h b/doc/iotcon_doc.h index 11d6032..27eeebd 100644 --- a/doc/iotcon_doc.h +++ b/doc/iotcon_doc.h @@ -86,16 +86,16 @@ static void _request_handler(iotcon_resource_h resource, iotcon_request_h reques return; } - ret = iotcon_state_create(&state); + ret = iotcon_attributes_create(&attributes); if (IOTCON_ERROR_NONE != ret) { iotcon_representation_destroy(resp_repr); iotcon_response_destroy(response); return; } - ret = iotcon_state_add_bool(resp_repr, "opened", true); + ret = iotcon_attributes_add_bool(resp_repr, "opened", true); if (IOTCON_ERROR_NONE != ret) { - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(resp_repr); iotcon_response_destroy(response); return; @@ -103,7 +103,7 @@ static void _request_handler(iotcon_resource_h resource, iotcon_request_h reques ret = iotcon_response_set_representation(response, resp_repr); if (IOTCON_ERROR_NONE != ret) { - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(resp_repr); iotcon_response_destroy(response); return; @@ -111,13 +111,13 @@ static void _request_handler(iotcon_resource_h resource, iotcon_request_h reques ret = iotcon_response_send(response); if (IOTCON_ERROR_NONE != ret) { - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(resp_repr); iotcon_response_destroy(response); return; } - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(resp_repr); iotcon_response_destroy(response); } diff --git a/lib/icl-state.c b/lib/icl-attributes.c index 8168baf..3e1c9d1 100644 --- a/lib/icl-state.c +++ b/lib/icl-attributes.c @@ -22,72 +22,72 @@ #include "icl-list.h" #include "icl-value.h" #include "icl-representation.h" -#include "icl-state.h" +#include "icl-attributes.h" -iotcon_state_h icl_state_ref(iotcon_state_h state) +iotcon_attributes_h icl_attributes_ref(iotcon_attributes_h attributes) { - RETV_IF(NULL == state, NULL); - RETV_IF(state->ref_count <= 0, NULL); + RETV_IF(NULL == attributes, NULL); + RETV_IF(attributes->ref_count <= 0, NULL); - state->ref_count++; + attributes->ref_count++; - return state; + return attributes; } -API int iotcon_state_create(iotcon_state_h *ret_state) +API int iotcon_attributes_create(iotcon_attributes_h *ret_attributes) { - iotcon_state_h state; + iotcon_attributes_h attributes; RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED); - RETV_IF(NULL == ret_state, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == ret_attributes, IOTCON_ERROR_INVALID_PARAMETER); - state = calloc(1, sizeof(struct icl_state_s)); - if (NULL == state) { + attributes = calloc(1, sizeof(struct icl_attributes_s)); + if (NULL == attributes) { ERR("calloc() Fail(%d)", errno); return IOTCON_ERROR_OUT_OF_MEMORY; } - state->hash_table = g_hash_table_new_full(g_str_hash, g_str_equal, free, + attributes->hash_table = g_hash_table_new_full(g_str_hash, g_str_equal, free, icl_value_destroy); - state->ref_count = 1; + attributes->ref_count = 1; - *ret_state = state; + *ret_attributes = attributes; return IOTCON_ERROR_NONE; } -API void iotcon_state_destroy(iotcon_state_h state) +API void iotcon_attributes_destroy(iotcon_attributes_h attributes) { - RET_IF(NULL == state); + RET_IF(NULL == attributes); - state->ref_count--; + attributes->ref_count--; - if (0 != state->ref_count) + if (0 != attributes->ref_count) return; - g_hash_table_destroy(state->hash_table); - free(state); + g_hash_table_destroy(attributes->hash_table); + free(attributes); } -API int iotcon_state_remove(iotcon_state_h state, const char *key) +API int iotcon_attributes_remove(iotcon_attributes_h attributes, const char *key) { gboolean ret = FALSE; iotcon_value_h value = NULL; RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED); - RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER); - value = g_hash_table_lookup(state->hash_table, key); + value = g_hash_table_lookup(attributes->hash_table, key); if (NULL == value) { ERR("g_hash_table_lookup(%s) Fail", key); return IOTCON_ERROR_NO_DATA; } - ret = g_hash_table_remove(state->hash_table, key); + ret = g_hash_table_remove(attributes->hash_table, key); if (FALSE == ret) { ERR("g_hash_table_remove(%s) Fail", key); return IOTCON_ERROR_NO_DATA; @@ -97,16 +97,17 @@ API int iotcon_state_remove(iotcon_state_h state, const char *key) } -API int iotcon_state_get_int(iotcon_state_h state, const char *key, int *val) +API int iotcon_attributes_get_int(iotcon_attributes_h attributes, const char *key, + int *val) { iotcon_value_h value; RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED); - RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER); - value = g_hash_table_lookup(state->hash_table, key); + value = g_hash_table_lookup(attributes->hash_table, key); if (NULL == value) { ERR("g_hash_table_lookup() Fail"); return IOTCON_ERROR_NO_DATA; @@ -123,12 +124,13 @@ API int iotcon_state_get_int(iotcon_state_h state, const char *key, int *val) return IOTCON_ERROR_NONE; } -API int iotcon_state_add_int(iotcon_state_h state, const char *key, int val) +API int iotcon_attributes_add_int(iotcon_attributes_h attributes, const char *key, + int val) { iotcon_value_h value; RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED); - RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER); value = icl_value_create_int(val); @@ -137,22 +139,23 @@ API int iotcon_state_add_int(iotcon_state_h state, const char *key, int val) return IOTCON_ERROR_OUT_OF_MEMORY; } - g_hash_table_replace(state->hash_table, ic_utils_strdup(key), value); + g_hash_table_replace(attributes->hash_table, ic_utils_strdup(key), value); return IOTCON_ERROR_NONE; } -API int iotcon_state_get_bool(iotcon_state_h state, const char *key, bool *val) +API int iotcon_attributes_get_bool(iotcon_attributes_h attributes, const char *key, + bool *val) { icl_basic_s *real = NULL; iotcon_value_h value = NULL; RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED); - RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER); - value = g_hash_table_lookup(state->hash_table, key); + value = g_hash_table_lookup(attributes->hash_table, key); if (NULL == value) { ERR("g_hash_table_lookup() Fail"); return IOTCON_ERROR_NO_DATA; @@ -169,12 +172,13 @@ API int iotcon_state_get_bool(iotcon_state_h state, const char *key, bool *val) return IOTCON_ERROR_NONE; } -API int iotcon_state_add_bool(iotcon_state_h state, const char *key, bool val) +API int iotcon_attributes_add_bool(iotcon_attributes_h attributes, const char *key, + bool val) { iotcon_value_h value = NULL; RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED); - RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER); value = icl_value_create_bool(val); @@ -183,22 +187,23 @@ API int iotcon_state_add_bool(iotcon_state_h state, const char *key, bool val) return IOTCON_ERROR_OUT_OF_MEMORY; } - g_hash_table_replace(state->hash_table, ic_utils_strdup(key), value); + g_hash_table_replace(attributes->hash_table, ic_utils_strdup(key), value); return IOTCON_ERROR_NONE; } -API int iotcon_state_get_double(iotcon_state_h state, const char *key, double *val) +API int iotcon_attributes_get_double(iotcon_attributes_h attributes, + const char *key, double *val) { icl_basic_s *real = NULL; iotcon_value_h value = NULL; RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED); - RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER); - value = g_hash_table_lookup(state->hash_table, key); + value = g_hash_table_lookup(attributes->hash_table, key); if (NULL == value) { ERR("g_hash_table_lookup() Fail"); return IOTCON_ERROR_NO_DATA; @@ -215,12 +220,13 @@ API int iotcon_state_get_double(iotcon_state_h state, const char *key, double *v return IOTCON_ERROR_NONE; } -API int iotcon_state_add_double(iotcon_state_h state, const char *key, double val) +API int iotcon_attributes_add_double(iotcon_attributes_h attributes, + const char *key, double val) { iotcon_value_h value = NULL; RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED); - RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER); value = icl_value_create_double(val); @@ -229,22 +235,23 @@ API int iotcon_state_add_double(iotcon_state_h state, const char *key, double va return IOTCON_ERROR_OUT_OF_MEMORY; } - g_hash_table_replace(state->hash_table, ic_utils_strdup(key), value); + g_hash_table_replace(attributes->hash_table, ic_utils_strdup(key), value); return IOTCON_ERROR_NONE; } -API int iotcon_state_get_str(iotcon_state_h state, const char *key, char **val) +API int iotcon_attributes_get_str(iotcon_attributes_h attributes, const char *key, + char **val) { icl_basic_s *real = NULL; iotcon_value_h value = NULL; RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED); - RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER); - value = g_hash_table_lookup(state->hash_table, key); + value = g_hash_table_lookup(attributes->hash_table, key); if (NULL == value) { ERR("g_hash_table_lookup() Fail"); return IOTCON_ERROR_NO_DATA; @@ -261,12 +268,13 @@ API int iotcon_state_get_str(iotcon_state_h state, const char *key, char **val) return IOTCON_ERROR_NONE; } -API int iotcon_state_add_str(iotcon_state_h state, const char *key, char *val) +API int iotcon_attributes_add_str(iotcon_attributes_h attributes, const char *key, + char *val) { iotcon_value_h value = NULL; RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED); - RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER); @@ -276,24 +284,24 @@ API int iotcon_state_add_str(iotcon_state_h state, const char *key, char *val) return IOTCON_ERROR_OUT_OF_MEMORY; } - g_hash_table_replace(state->hash_table, ic_utils_strdup(key), value); + g_hash_table_replace(attributes->hash_table, ic_utils_strdup(key), value); return IOTCON_ERROR_NONE; } -API int iotcon_state_get_byte_str(iotcon_state_h state, const char *key, +API int iotcon_attributes_get_byte_str(iotcon_attributes_h attributes, const char *key, unsigned char **val, int *len) { iotcon_value_h value = NULL; icl_val_byte_str_s *real = NULL; RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED); - RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == len, IOTCON_ERROR_INVALID_PARAMETER); - value = g_hash_table_lookup(state->hash_table, key); + value = g_hash_table_lookup(attributes->hash_table, key); if (NULL == value) { ERR("g_hash_table_lookup() Fail"); return IOTCON_ERROR_NO_DATA; @@ -311,13 +319,13 @@ API int iotcon_state_get_byte_str(iotcon_state_h state, const char *key, return IOTCON_ERROR_NONE; } -API int iotcon_state_add_byte_str(iotcon_state_h state, const char *key, - unsigned char *val, int len) +API int iotcon_attributes_add_byte_str(iotcon_attributes_h attributes, + const char *key, unsigned char *val, int len) { iotcon_value_h value = NULL; RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED); - RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(len <= 0, IOTCON_ERROR_INVALID_PARAMETER); @@ -328,22 +336,23 @@ API int iotcon_state_add_byte_str(iotcon_state_h state, const char *key, return IOTCON_ERROR_OUT_OF_MEMORY; } - g_hash_table_replace(state->hash_table, ic_utils_strdup(key), value); + g_hash_table_replace(attributes->hash_table, ic_utils_strdup(key), value); return IOTCON_ERROR_NONE; } -API int iotcon_state_is_null(iotcon_state_h state, const char *key, bool *is_null) +API int iotcon_attributes_is_null(iotcon_attributes_h attributes, const char *key, + bool *is_null) { icl_basic_s *real = NULL; iotcon_value_h value = NULL; RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED); - RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == is_null, IOTCON_ERROR_INVALID_PARAMETER); - value = (iotcon_value_h) g_hash_table_lookup(state->hash_table, key); + value = (iotcon_value_h) g_hash_table_lookup(attributes->hash_table, key); if (NULL == value) { ERR("g_hash_table_lookup() Fail"); return IOTCON_ERROR_NO_DATA; @@ -355,12 +364,12 @@ API int iotcon_state_is_null(iotcon_state_h state, const char *key, bool *is_nul return IOTCON_ERROR_NONE; } -API int iotcon_state_add_null(iotcon_state_h state, const char *key) +API int iotcon_attributes_add_null(iotcon_attributes_h attributes, const char *key) { iotcon_value_h value = NULL; RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED); - RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER); value = icl_value_create_null(); @@ -369,23 +378,23 @@ API int iotcon_state_add_null(iotcon_state_h state, const char *key) return IOTCON_ERROR_OUT_OF_MEMORY; } - g_hash_table_replace(state->hash_table, ic_utils_strdup(key), value); + g_hash_table_replace(attributes->hash_table, ic_utils_strdup(key), value); return IOTCON_ERROR_NONE; } -API int iotcon_state_get_list(iotcon_state_h state, const char *key, +API int iotcon_attributes_get_list(iotcon_attributes_h attributes, const char *key, iotcon_list_h *list) { iotcon_value_h value = NULL; icl_val_list_s *real = NULL; RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED); - RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER); - value = g_hash_table_lookup(state->hash_table, key); + value = g_hash_table_lookup(attributes->hash_table, key); if (NULL == value) { ERR("g_hash_table_lookup() Fail"); return IOTCON_ERROR_NO_DATA; @@ -402,13 +411,13 @@ API int iotcon_state_get_list(iotcon_state_h state, const char *key, return IOTCON_ERROR_NONE; } -API int iotcon_state_add_list(iotcon_state_h state, const char *key, +API int iotcon_attributes_add_list(iotcon_attributes_h attributes, const char *key, iotcon_list_h list) { iotcon_value_h value = NULL; RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED); - RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER); @@ -419,15 +428,15 @@ API int iotcon_state_add_list(iotcon_state_h state, const char *key, return IOTCON_ERROR_OUT_OF_MEMORY; } - g_hash_table_replace(state->hash_table, ic_utils_strdup(key), value); + g_hash_table_replace(attributes->hash_table, ic_utils_strdup(key), value); return IOTCON_ERROR_NONE; } -API int iotcon_state_get_state(iotcon_state_h src, const char *key, - iotcon_state_h *dest) +API int iotcon_attributes_get_attributes(iotcon_attributes_h src, const char *key, + iotcon_attributes_h *dest) { - icl_val_state_s *real = NULL; + icl_val_attributes_s *real = NULL; iotcon_value_h value = NULL; RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED); @@ -441,49 +450,49 @@ API int iotcon_state_get_state(iotcon_state_h src, const char *key, return IOTCON_ERROR_NO_DATA; } - real = (icl_val_state_s*)value; - if (IOTCON_TYPE_STATE != real->type) { + real = (icl_val_attributes_s*)value; + if (IOTCON_TYPE_ATTRIBUTES != real->type) { ERR("Invalid Type(%d)", real->type); return IOTCON_ERROR_INVALID_TYPE; } - *dest = real->state; + *dest = real->attributes; return IOTCON_ERROR_NONE; } -API int iotcon_state_add_state(iotcon_state_h state, const char *key, - iotcon_state_h val) +API int iotcon_attributes_add_attributes(iotcon_attributes_h attributes, + const char *key, iotcon_attributes_h val) { iotcon_value_h value = NULL; RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED); - RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER); - value = icl_value_create_state(val); + value = icl_value_create_attributes(val); if (NULL == value) { - ERR("icl_value_create_state(%p) Fail", val); + ERR("icl_value_create_attributes(%p) Fail", val); return IOTCON_ERROR_OUT_OF_MEMORY; } - g_hash_table_replace(state->hash_table, ic_utils_strdup(key), value); + g_hash_table_replace(attributes->hash_table, ic_utils_strdup(key), value); return IOTCON_ERROR_NONE; } -API int iotcon_state_get_type(iotcon_state_h state, const char *key, +API int iotcon_attributes_get_type(iotcon_attributes_h attributes, const char *key, iotcon_type_e *type) { iotcon_value_h value = NULL; RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED); - RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == type, IOTCON_ERROR_INVALID_PARAMETER); - value = g_hash_table_lookup(state->hash_table, key); + value = g_hash_table_lookup(attributes->hash_table, key); if (NULL == value) { ERR("g_hash_table_lookup() Fail"); return IOTCON_ERROR_NO_DATA; @@ -493,59 +502,63 @@ API int iotcon_state_get_type(iotcon_state_h state, const char *key, return IOTCON_ERROR_NONE; } -int icl_state_set_value(iotcon_state_h state, const char *key, iotcon_value_h value) +int icl_attributes_set_value(iotcon_attributes_h attributes, const char *key, + iotcon_value_h value) { - RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == value, IOTCON_ERROR_INVALID_PARAMETER); - g_hash_table_replace(state->hash_table, ic_utils_strdup(key), value); + g_hash_table_replace(attributes->hash_table, ic_utils_strdup(key), value); return IOTCON_ERROR_NONE; } -API int iotcon_state_get_keys_count(iotcon_state_h state, unsigned int *count) +API int iotcon_attributes_get_keys_count(iotcon_attributes_h attributes, + unsigned int *count) { RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED); - RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == count, IOTCON_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == state->hash_table, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == attributes->hash_table, IOTCON_ERROR_INVALID_PARAMETER); - *count = g_hash_table_size(state->hash_table); + *count = g_hash_table_size(attributes->hash_table); return IOTCON_ERROR_NONE; } -API int iotcon_state_clone(iotcon_state_h state, iotcon_state_h *state_clone) +API int iotcon_attributes_clone(iotcon_attributes_h attributes, + iotcon_attributes_h *attributes_clone) { int ret; - iotcon_state_h temp = NULL; + iotcon_attributes_h temp = NULL; RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED); - RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == state_clone, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == attributes_clone, IOTCON_ERROR_INVALID_PARAMETER); - if (state->hash_table) { - ret = iotcon_state_create(&temp); + if (attributes->hash_table) { + ret = iotcon_attributes_create(&temp); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_create() Fail(%d)", ret); + ERR("iotcon_attributes_create() Fail(%d)", ret); return ret; } - g_hash_table_foreach(state->hash_table, (GHFunc)icl_state_clone_foreach, temp); + g_hash_table_foreach(attributes->hash_table, (GHFunc)icl_attributes_clone_foreach, + temp); } - *state_clone = temp; + *attributes_clone = temp; return IOTCON_ERROR_NONE; } -void icl_state_clone_foreach(char *key, iotcon_value_h src_val, - iotcon_state_h dest_state) +void icl_attributes_clone_foreach(char *key, iotcon_value_h src_val, + iotcon_attributes_h dest_attributes) { FN_CALL; iotcon_value_h copied_val; @@ -556,23 +569,23 @@ void icl_state_clone_foreach(char *key, iotcon_value_h src_val, return; } - icl_state_set_value(dest_state, key, copied_val); + icl_attributes_set_value(dest_attributes, key, copied_val); } -API int iotcon_state_foreach(iotcon_state_h state, iotcon_state_cb cb, - void *user_data) +API int iotcon_attributes_foreach(iotcon_attributes_h attributes, + iotcon_attributes_cb cb, void *user_data) { GHashTableIter iter; gpointer key; RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED); - RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER); - g_hash_table_iter_init(&iter, state->hash_table); + g_hash_table_iter_init(&iter, attributes->hash_table); while (g_hash_table_iter_next(&iter, &key, NULL)) { - if (IOTCON_FUNC_STOP == cb(state, key, user_data)) + if (IOTCON_FUNC_STOP == cb(attributes, key, user_data)) break; } diff --git a/lib/icl-state.h b/lib/icl-attributes.h index 17c7033..b74f418 100644 --- a/lib/icl-state.h +++ b/lib/icl-attributes.h @@ -13,17 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef __IOT_CONNECTIVITY_LIBRARY_STATE_H__ -#define __IOT_CONNECTIVITY_LIBRARY_STATE_H__ +#ifndef __IOT_CONNECTIVITY_LIBRARY_ATTRIBUTES_H__ +#define __IOT_CONNECTIVITY_LIBRARY_ATTRIBUTES_H__ #include "icl-value.h" #include "icl-representation.h" -int icl_state_set_value(iotcon_state_h state, const char *key, iotcon_value_h value); +int icl_attributes_set_value(iotcon_attributes_h attributes, const char *key, + iotcon_value_h value); -void icl_state_clone_foreach(char *key, iotcon_value_h src_val, - iotcon_state_h dest_state); +void icl_attributes_clone_foreach(char *key, iotcon_value_h src_val, + iotcon_attributes_h dest_attributes); -iotcon_state_h icl_state_ref(iotcon_state_h state); +iotcon_attributes_h icl_attributes_ref(iotcon_attributes_h attributes); -#endif /* __IOT_CONNECTIVITY_LIBRARY_STATE_H__ */ +#endif /* __IOT_CONNECTIVITY_LIBRARY_ATTRIBUTES_H__ */ diff --git a/lib/icl-ioty-ocprocess.c b/lib/icl-ioty-ocprocess.c index dcb8e72..e72c567 100644 --- a/lib/icl-ioty-ocprocess.c +++ b/lib/icl-ioty-ocprocess.c @@ -33,7 +33,7 @@ #include "icl-options.h" #include "icl-representation.h" #include "icl-types.h" -#include "icl-state.h" +#include "icl-attributes.h" #include "icl-lite-resource.h" #include "icl-ioty.h" #include "icl-ioty-types.h" @@ -716,9 +716,9 @@ static int _icl_ioty_ocprocess_lite_resource_get_repr( return ret; } - ret = iotcon_representation_set_state(repr, resource->state); + ret = iotcon_representation_set_attributes(repr, resource->attributes); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_representation_set_state() Fail(%d)", ret); + ERR("iotcon_representation_set_attributes() Fail(%d)", ret); iotcon_representation_destroy(repr); return ret; } @@ -817,15 +817,15 @@ OCEntityHandlerResult icl_ioty_ocprocess_lite_request_cb(OCEntityHandlerFlag fla break; case IOTCON_REQUEST_POST: if (resource->cb) { - if (false == resource->cb(resource, repr->state, resource->cb_data)) { + if (false == resource->cb(resource, repr->attributes, resource->cb_data)) { res->result = IOTCON_RESPONSE_ERROR; g_idle_add(_icl_ioty_ocprocess_lite_resource_response_idle_cb, res); break; } } - iotcon_state_destroy(resource->state); - resource->state = repr->state; - repr->state = NULL; + iotcon_attributes_destroy(resource->attributes); + resource->attributes = repr->attributes; + repr->attributes = NULL; _icl_ioty_ocprocess_lite_resource_get_repr(resource, &(res->repr)); res->result = IOTCON_RESPONSE_OK; g_idle_add(_icl_ioty_ocprocess_lite_resource_response_idle_cb, res); diff --git a/lib/icl-ioty-types.c b/lib/icl-ioty-types.c index d2d8e0b..7d4063b 100644 --- a/lib/icl-ioty-types.c +++ b/lib/icl-ioty-types.c @@ -36,16 +36,16 @@ #include "icl-types.h" #include "icl-ioty-types.h" -struct icl_state_list_s { +struct icl_attributes_list_s { OCRepPayloadPropType type; size_t dimensions[MAX_REP_ARRAY_DEPTH]; GList *list; }; static int _icl_ioty_parse_oic_rep_payload_value(OCRepPayloadValue *val, - iotcon_state_h *state); + iotcon_attributes_h *attributes); static int _icl_ioty_fill_oic_rep_payload_value(OCRepPayload *payload, - iotcon_state_h state); + iotcon_attributes_h attributes); static void _icl_ioty_free_resource_list(iotcon_remote_resource_h *resource_list, int resource_count) @@ -388,29 +388,29 @@ static int _icl_ioty_parse_oic_rep_payload_value_array_attr( } break; case OCREP_PROP_OBJECT: - ret = iotcon_list_create(IOTCON_TYPE_STATE, &l); + ret = iotcon_list_create(IOTCON_TYPE_ATTRIBUTES, &l); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_list_create(IOTCON_TYPE_STATE) Fail(%d)", ret); + ERR("iotcon_list_create(IOTCON_TYPE_ATTRIBUTES) Fail(%d)", ret); return ret; } for (i = 0; i < len; i++) { - iotcon_state_h state; + iotcon_attributes_h attributes; ret = _icl_ioty_parse_oic_rep_payload_value(arr->objArray[index + i]->values, - &state); + &attributes); if (IOTCON_ERROR_NONE != ret) { ERR("_icl_ioty_parse_oic_rep_payload_value(%d)", ret); iotcon_list_destroy(l); return ret; } - ret = iotcon_list_add_state(l, state, -1); + ret = iotcon_list_add_attributes(l, attributes, -1); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_list_add_state() Fail(%d)", ret); - iotcon_state_destroy(state); + ERR("iotcon_list_add_attributes() Fail(%d)", ret); + iotcon_attributes_destroy(attributes); iotcon_list_destroy(l); return ret; } - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); } break; case OCREP_PROP_ARRAY: @@ -477,70 +477,70 @@ static int _icl_ioty_parse_oic_rep_payload_value_array( } static int _icl_ioty_parse_oic_rep_payload_value(OCRepPayloadValue *val, - iotcon_state_h *state) + iotcon_attributes_h *attributes) { int ret, total_len; - iotcon_state_h s; + iotcon_attributes_h s; iotcon_list_h list; - iotcon_state_h s_obj; + iotcon_attributes_h s_obj; RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER); - ret = iotcon_state_create(&s); + ret = iotcon_attributes_create(&s); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_create() Fail(%d)", ret); + ERR("iotcon_attributes_create() Fail(%d)", ret); return ret; } while (val) { switch (val->type) { case OCREP_PROP_INT: - ret = iotcon_state_add_int(s, val->name, val->i); + ret = iotcon_attributes_add_int(s, val->name, val->i); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_add_int() Fail(%d)", ret); - iotcon_state_destroy(s); + ERR("iotcon_attributes_add_int() Fail(%d)", ret); + iotcon_attributes_destroy(s); return ret; } break; case OCREP_PROP_BOOL: - ret = iotcon_state_add_bool(s, val->name, val->b); + ret = iotcon_attributes_add_bool(s, val->name, val->b); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_add_bool() Fail(%d)", ret); - iotcon_state_destroy(s); + ERR("iotcon_attributes_add_bool() Fail(%d)", ret); + iotcon_attributes_destroy(s); return ret; } break; case OCREP_PROP_DOUBLE: - ret = iotcon_state_add_double(s, val->name, val->d); + ret = iotcon_attributes_add_double(s, val->name, val->d); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_add_double() Fail(%d)", ret); - iotcon_state_destroy(s); + ERR("iotcon_attributes_add_double() Fail(%d)", ret); + iotcon_attributes_destroy(s); return ret; } break; case OCREP_PROP_STRING: - ret = iotcon_state_add_str(s, val->name, val->str); + ret = iotcon_attributes_add_str(s, val->name, val->str); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_add_str() Fail(%d)", ret); - iotcon_state_destroy(s); + ERR("iotcon_attributes_add_str() Fail(%d)", ret); + iotcon_attributes_destroy(s); return ret; } break; case OCREP_PROP_BYTE_STRING: - ret = iotcon_state_add_byte_str(s, val->name, val->ocByteStr.bytes, + ret = iotcon_attributes_add_byte_str(s, val->name, val->ocByteStr.bytes, val->ocByteStr.len); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_add_byte_str() Fail(%d)", ret); - iotcon_state_destroy(s); + ERR("iotcon_attributes_add_byte_str() Fail(%d)", ret); + iotcon_attributes_destroy(s); return ret; } break; case OCREP_PROP_NULL: - ret = iotcon_state_add_null(s, val->name); + ret = iotcon_attributes_add_null(s, val->name); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_add_null() Fail(%d)", ret); - iotcon_state_destroy(s); + ERR("iotcon_attributes_add_null() Fail(%d)", ret); + iotcon_attributes_destroy(s); return ret; } break; @@ -550,14 +550,14 @@ static int _icl_ioty_parse_oic_rep_payload_value(OCRepPayloadValue *val, &list); if (IOTCON_ERROR_NONE != ret) { ERR("_icl_ioty_parse_oic_rep_payload_value_array() Fail(%d)", ret); - iotcon_state_destroy(s); + iotcon_attributes_destroy(s); return ret; } - ret = iotcon_state_add_list(s, val->name, list); + ret = iotcon_attributes_add_list(s, val->name, list); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_add_list() Fail(%d)", ret); + ERR("iotcon_attributes_add_list() Fail(%d)", ret); iotcon_list_destroy(list); - iotcon_state_destroy(s); + iotcon_attributes_destroy(s); return ret; } iotcon_list_destroy(list); @@ -566,17 +566,17 @@ static int _icl_ioty_parse_oic_rep_payload_value(OCRepPayloadValue *val, ret = _icl_ioty_parse_oic_rep_payload_value(val->obj->values, &s_obj); if (IOTCON_ERROR_NONE != ret) { ERR("_icl_ioty_parse_oic_rep_payload_value() Fail(%d)", ret); - iotcon_state_destroy(s); + iotcon_attributes_destroy(s); return ret; } - ret = iotcon_state_add_state(s, val->name, s_obj); + ret = iotcon_attributes_add_attributes(s, val->name, s_obj); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_add_state() Fail(%d)", ret); - iotcon_state_destroy(s_obj); - iotcon_state_destroy(s); + ERR("iotcon_attributes_add_attributes() Fail(%d)", ret); + iotcon_attributes_destroy(s_obj); + iotcon_attributes_destroy(s); return ret; } - iotcon_state_destroy(s_obj); + iotcon_attributes_destroy(s_obj); break; default: ERR("Invalid Type(%d)", val->type); @@ -584,7 +584,7 @@ static int _icl_ioty_parse_oic_rep_payload_value(OCRepPayloadValue *val, val = val->next; } - *state = s; + *attributes = s; return IOTCON_ERROR_NONE; } @@ -597,7 +597,7 @@ int icl_ioty_parse_oic_rep_payload(OCRepPayload *payload, bool is_parent, OCRepPayload *child_node; iotcon_resource_interfaces_h ifaces; iotcon_representation_h repr; - iotcon_state_h state = NULL; + iotcon_attributes_h attributes = NULL; iotcon_resource_types_h types = NULL; RETV_IF(NULL == payload, IOTCON_ERROR_INVALID_PARAMETER); @@ -667,22 +667,22 @@ int icl_ioty_parse_oic_rep_payload(OCRepPayload *payload, bool is_parent, } iotcon_resource_interfaces_destroy(ifaces); - /* state */ + /* attributes */ if (payload->values) { - ret = _icl_ioty_parse_oic_rep_payload_value(payload->values, &state); + ret = _icl_ioty_parse_oic_rep_payload_value(payload->values, &attributes); if (IOTCON_ERROR_NONE != ret) { ERR("iotcon_representation_set_resource_types() Fail(%d)", ret); iotcon_representation_destroy(repr); return ret; } - ret = iotcon_representation_set_state(repr, state); + ret = iotcon_representation_set_attributes(repr, attributes); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_representation_set_state() Fail(%d)", ret); - iotcon_state_destroy(state); + ERR("iotcon_representation_set_attributes() Fail(%d)", ret); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(repr); return ret; } - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); } /* children */ @@ -716,7 +716,7 @@ int icl_ioty_parse_oic_rep_payload(OCRepPayload *payload, bool is_parent, } static int _icl_ioty_fill_oic_rep_payload_value_array(OCRepPayload *payload, - const char *key, struct icl_state_list_s *list) + const char *key, struct icl_attributes_list_s *list) { int i, j, len, ret; bool *b_arr; @@ -724,7 +724,7 @@ static int _icl_ioty_fill_oic_rep_payload_value_array(OCRepPayload *payload, char **str_arr; int64_t *i_arr; OCByteString *byte_arr; - struct OCRepPayload **state_arr; + struct OCRepPayload **attributes_arr; GList *node; RETV_IF(NULL == payload, IOTCON_ERROR_INVALID_PARAMETER); @@ -795,29 +795,29 @@ static int _icl_ioty_fill_oic_rep_payload_value_array(OCRepPayload *payload, free(byte_arr); break; case OCREP_PROP_OBJECT: - state_arr = calloc(len, sizeof(struct OCRepPayload *)); - if (NULL == state_arr) { + attributes_arr = calloc(len, sizeof(struct OCRepPayload *)); + if (NULL == attributes_arr) { ERR("calloc() Fail(%d)", errno); return IOTCON_ERROR_OUT_OF_MEMORY; } for (node = list->list, i = 0; node; node = node->next, i++) { - state_arr[i] = OCRepPayloadCreate(); - if (NULL == state_arr[i]) { + attributes_arr[i] = OCRepPayloadCreate(); + if (NULL == attributes_arr[i]) { ERR("OCRepPayloadCreate() Fail"); - free(state_arr); + free(attributes_arr); return ret; } - ret = _icl_ioty_fill_oic_rep_payload_value(state_arr[i], - ((icl_val_state_s*)node->data)->state); + ret = _icl_ioty_fill_oic_rep_payload_value(attributes_arr[i], + ((icl_val_attributes_s*)node->data)->attributes); if (IOTCON_ERROR_NONE != ret) { ERR("_icl_ioty_fill_oic_rep_payload_value() Fail(%d)", ret); for (j = 0; j <= i; j++) - OCRepPayloadDestroy(state_arr[j]); - free(state_arr); + OCRepPayloadDestroy(attributes_arr[j]); + free(attributes_arr); return ret; } } - OCRepPayloadSetPropObjectArrayAsOwner(payload, key, state_arr, list->dimensions); + OCRepPayloadSetPropObjectArrayAsOwner(payload, key, attributes_arr, list->dimensions); break; case OCREP_PROP_ARRAY: case OCREP_PROP_NULL: @@ -829,8 +829,8 @@ static int _icl_ioty_fill_oic_rep_payload_value_array(OCRepPayload *payload, } -static int _icl_ioty_state_list_to_value_list(iotcon_list_h list, - struct icl_state_list_s *value_list, int depth) +static int _icl_ioty_attributes_list_to_value_list(iotcon_list_h list, + struct icl_attributes_list_s *value_list, int depth) { int ret; GList *c; @@ -866,16 +866,17 @@ static int _icl_ioty_state_list_to_value_list(iotcon_list_h list, for (c = list->list; c; c = c->next) value_list->list = g_list_append(value_list->list, c->data); break; - case IOTCON_TYPE_STATE: + case IOTCON_TYPE_ATTRIBUTES: value_list->type = OCREP_PROP_OBJECT; for (c = list->list; c; c = c->next) value_list->list = g_list_append(value_list->list, c->data); break; case IOTCON_TYPE_LIST: for (c = list->list; c; c = c->next) { - ret = _icl_ioty_state_list_to_value_list(((icl_val_list_s *)c->data)->list, value_list, depth + 1); + ret = _icl_ioty_attributes_list_to_value_list(((icl_val_list_s *)c->data)->list, + value_list, depth + 1); if (IOTCON_ERROR_NONE != ret) { - ERR("_icl_ioty_state_list_to_value_list() Fail(%d)", ret); + ERR("_icl_ioty_attributes_list_to_value_list() Fail(%d)", ret); return ret; } } @@ -890,7 +891,7 @@ static int _icl_ioty_state_list_to_value_list(iotcon_list_h list, } static int _icl_ioty_fill_oic_rep_payload_value(OCRepPayload *payload, - iotcon_state_h state) + iotcon_attributes_h attributes) { FN_CALL; int ret; @@ -898,46 +899,46 @@ static int _icl_ioty_fill_oic_rep_payload_value(OCRepPayload *payload, gpointer key, value; OCRepPayload *repr_payload; OCByteString byte_string; - struct icl_value_s *state_value; - struct icl_state_list_s value_list = {0}; + struct icl_value_s *attributes_value; + struct icl_attributes_list_s value_list = {0}; - RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == payload, IOTCON_ERROR_INVALID_PARAMETER); - g_hash_table_iter_init(&iter, state->hash_table); + g_hash_table_iter_init(&iter, attributes->hash_table); while (g_hash_table_iter_next(&iter, &key, &value)) { - state_value = (struct icl_value_s *)value; - if (NULL == state_value) { - ERR("state_value(%s) is NULL", key); + attributes_value = (struct icl_value_s *)value; + if (NULL == attributes_value) { + ERR("attributes_value(%s) is NULL", key); continue; } - switch (state_value->type) { + switch (attributes_value->type) { case IOTCON_TYPE_BOOL: - OCRepPayloadSetPropBool(payload, key, ((icl_basic_s*)state_value)->val.b); + OCRepPayloadSetPropBool(payload, key, ((icl_basic_s*)attributes_value)->val.b); break; case IOTCON_TYPE_INT: - OCRepPayloadSetPropInt(payload, key, ((icl_basic_s*)state_value)->val.i); + OCRepPayloadSetPropInt(payload, key, ((icl_basic_s*)attributes_value)->val.i); break; case IOTCON_TYPE_DOUBLE: - OCRepPayloadSetPropDouble(payload, key, ((icl_basic_s*)state_value)->val.d); + OCRepPayloadSetPropDouble(payload, key, ((icl_basic_s*)attributes_value)->val.d); break; case IOTCON_TYPE_STR: - OCRepPayloadSetPropString(payload, key, ((icl_basic_s*)state_value)->val.s); + OCRepPayloadSetPropString(payload, key, ((icl_basic_s*)attributes_value)->val.s); break; case IOTCON_TYPE_NULL: OCRepPayloadSetNull(payload, key); break; case IOTCON_TYPE_BYTE_STR: - byte_string.bytes = ((icl_val_byte_str_s*)state_value)->s; - byte_string.len = ((icl_val_byte_str_s*)state_value)->len; + byte_string.bytes = ((icl_val_byte_str_s*)attributes_value)->s; + byte_string.len = ((icl_val_byte_str_s*)attributes_value)->len; OCRepPayloadSetPropByteString(payload, key, byte_string); break; case IOTCON_TYPE_LIST: - ret = _icl_ioty_state_list_to_value_list(((icl_val_list_s*)state_value)->list, + ret = _icl_ioty_attributes_list_to_value_list(((icl_val_list_s*)attributes_value)->list, &value_list, 0); if (IOTCON_ERROR_NONE != ret) { - ERR("_icl_ioty_state_list_to_value_list() Fail(%d)", ret); + ERR("_icl_ioty_attributes_list_to_value_list() Fail(%d)", ret); return ret; } ret = _icl_ioty_fill_oic_rep_payload_value_array(payload, key, &value_list); @@ -949,10 +950,10 @@ static int _icl_ioty_fill_oic_rep_payload_value(OCRepPayload *payload, g_list_free(value_list.list); value_list.list = NULL; break; - case IOTCON_TYPE_STATE: + case IOTCON_TYPE_ATTRIBUTES: repr_payload = OCRepPayloadCreate(); ret = _icl_ioty_fill_oic_rep_payload_value(repr_payload, - ((icl_val_state_s*)state_value)->state); + ((icl_val_attributes_s*)attributes_value)->attributes); if (IOTCON_ERROR_NONE != ret) { ERR("_icl_ioty_fill_oic_rep_payload_value() Fail(%d)", ret); OCRepPayloadDestroy(repr_payload); @@ -962,7 +963,7 @@ static int _icl_ioty_fill_oic_rep_payload_value(OCRepPayload *payload, break; case IOTCON_TYPE_NONE: default: - ERR("Invalid Type(%d)", state_value->type); + ERR("Invalid Type(%d)", attributes_value->type); return IOTCON_ERROR_INVALID_PARAMETER; } } @@ -1004,9 +1005,9 @@ int icl_ioty_convert_representation(iotcon_representation_h repr, OCRepPayloadAddResourceType(repr_payload, c->data); } - /* state */ - if (repr->state) { - ret = _icl_ioty_fill_oic_rep_payload_value(repr_payload, repr->state); + /* attributes */ + if (repr->attributes) { + ret = _icl_ioty_fill_oic_rep_payload_value(repr_payload, repr->attributes); if (IOTCON_ERROR_NONE != ret) { ERR("_icl_ioty_fill_oic_rep_payload_value() Fail(%d)", ret); OCRepPayloadDestroy(repr_payload); diff --git a/lib/icl-ioty.c b/lib/icl-ioty.c index cb2468e..a8071ac 100644 --- a/lib/icl-ioty.c +++ b/lib/icl-ioty.c @@ -40,7 +40,7 @@ #include "icl-resource-types.h" #include "icl-response.h" #include "icl-observation.h" -#include "icl-state.h" +#include "icl-attributes.h" #include "icl-lite-resource.h" #include "icl-ioty-ocprocess.h" #include "icl-ioty-types.h" @@ -1608,7 +1608,7 @@ int icl_ioty_resource_destroy(iotcon_resource_h resource) int icl_ioty_lite_resource_create(const char *uri_path, iotcon_resource_types_h res_types, uint8_t policies, - iotcon_state_h state, + iotcon_attributes_h attributes, iotcon_lite_resource_post_request_cb cb, void *user_data, iotcon_lite_resource_h *resource_handle) @@ -1634,8 +1634,9 @@ int icl_ioty_lite_resource_create(const char *uri_path, } resource->uri_path = strdup(uri_path); resource->policies = policies; - resource->state = state; - icl_state_ref(resource->state); + resource->policies = policies; + resource->attributes = attributes; + icl_attributes_ref(resource->attributes); resource->cb = cb; resource->cb_data = user_data; @@ -1715,20 +1716,20 @@ int icl_ioty_lite_resource_notify(iotcon_lite_resource_h resource) return IOTCON_ERROR_NONE; } -int icl_ioty_lite_resource_update_state(iotcon_lite_resource_h resource, - iotcon_state_h state) +int icl_ioty_lite_resource_update_attributes(iotcon_lite_resource_h resource, + iotcon_attributes_h attributes) { int ret; RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER); - if (state) - state = icl_state_ref(state); + if (attributes) + attributes = icl_attributes_ref(attributes); - if (resource->state) - iotcon_state_destroy(resource->state); + if (resource->attributes) + iotcon_attributes_destroy(resource->attributes); - resource->state = state; + resource->attributes = attributes; ret = icl_ioty_lite_resource_notify(resource); if (IOTCON_ERROR_NONE != ret) diff --git a/lib/icl-ioty.h b/lib/icl-ioty.h index 094527a..dd590a5 100644 --- a/lib/icl-ioty.h +++ b/lib/icl-ioty.h @@ -130,13 +130,13 @@ int icl_ioty_resource_destroy(iotcon_resource_h resource); int icl_ioty_lite_resource_create(const char *uri_path, iotcon_resource_types_h res_types, uint8_t policies, - iotcon_state_h state, + iotcon_attributes_h attributes, iotcon_lite_resource_post_request_cb cb, void *user_data, iotcon_lite_resource_h *resource_handle); int icl_ioty_lite_resource_destroy(iotcon_lite_resource_h resource); -int icl_ioty_lite_resource_update_state(iotcon_lite_resource_h resource, - iotcon_state_h state); +int icl_ioty_lite_resource_update_attributes(iotcon_lite_resource_h resource, + iotcon_attributes_h attributes); int icl_ioty_lite_resource_notify(iotcon_lite_resource_h resource); int icl_ioty_response_send(iotcon_response_h response); diff --git a/lib/icl-list.c b/lib/icl-list.c index dd6f6fe..f961e59 100644 --- a/lib/icl-list.c +++ b/lib/icl-list.c @@ -20,7 +20,7 @@ #include "iotcon-types.h" #include "ic-utils.h" #include "icl.h" -#include "icl-state.h" +#include "icl-attributes.h" #include "icl-representation.h" #include "icl-value.h" #include "icl-list.h" @@ -43,7 +43,7 @@ API int iotcon_list_create(iotcon_type_e type, iotcon_list_h *ret_list) RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED); RETV_IF(NULL == ret_list, IOTCON_ERROR_INVALID_PARAMETER); - if (type < IOTCON_TYPE_INT || IOTCON_TYPE_STATE < type) { + if (type < IOTCON_TYPE_INT || IOTCON_TYPE_ATTRIBUTES < type) { ERR("Invalid Type(%d)", type); return IOTCON_ERROR_INVALID_TYPE; } @@ -181,19 +181,19 @@ API int iotcon_list_add_list(iotcon_list_h list, iotcon_list_h val, int pos) } -API int iotcon_list_add_state(iotcon_list_h list, iotcon_state_h val, int pos) +API int iotcon_list_add_attributes(iotcon_list_h list, iotcon_attributes_h val, int pos) { iotcon_value_h value; RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED); RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER); - RETVM_IF(IOTCON_TYPE_STATE != list->type, IOTCON_ERROR_INVALID_TYPE, + RETVM_IF(IOTCON_TYPE_ATTRIBUTES != list->type, IOTCON_ERROR_INVALID_TYPE, "Invalid Type(%d)", list->type); - value = icl_value_create_state(val); + value = icl_value_create_attributes(val); if (NULL == value) { - ERR("icl_value_create_state(%p) Fail", val); + ERR("icl_value_create_attributes(%p) Fail", val); return IOTCON_ERROR_OUT_OF_MEMORY; } @@ -377,16 +377,17 @@ API int iotcon_list_get_nth_list(iotcon_list_h src, int pos, iotcon_list_h *dest } -API int iotcon_list_get_nth_state(iotcon_list_h list, int pos, iotcon_state_h *state) +API int iotcon_list_get_nth_attributes(iotcon_list_h list, int pos, + iotcon_attributes_h *attributes) { int ret; iotcon_value_h value; - iotcon_state_h state_val; + iotcon_attributes_h attributes_val; RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED); RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == list->list, IOTCON_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER); value = g_list_nth_data(list->list, pos); if (NULL == value) { @@ -394,13 +395,13 @@ API int iotcon_list_get_nth_state(iotcon_list_h list, int pos, iotcon_state_h *s return IOTCON_ERROR_NO_DATA; } - ret = icl_value_get_state(value, &state_val); + ret = icl_value_get_attributes(value, &attributes_val); if (IOTCON_ERROR_NONE != ret) { - ERR("icl_value_get_state() Fail(%d)", ret); + ERR("icl_value_get_attributes() Fail(%d)", ret); return IOTCON_ERROR_REPRESENTATION; } - *state = state_val; + *attributes = attributes_val; return IOTCON_ERROR_NONE; } @@ -620,16 +621,16 @@ API int iotcon_list_foreach_list(iotcon_list_h list, iotcon_list_list_cb cb, return IOTCON_ERROR_NONE; } -API int iotcon_list_foreach_state(iotcon_list_h list, iotcon_list_state_cb cb, - void *user_data) +API int iotcon_list_foreach_attributes(iotcon_list_h list, + iotcon_list_attributes_cb cb, void *user_data) { int index = 0; GList *cur = NULL; - icl_val_state_s *real = NULL; + icl_val_attributes_s *real = NULL; RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED); RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER); - RETVM_IF(IOTCON_TYPE_STATE != list->type, IOTCON_ERROR_INVALID_TYPE, + RETVM_IF(IOTCON_TYPE_ATTRIBUTES != list->type, IOTCON_ERROR_INVALID_TYPE, "Invalid Type(%d)", list->type); RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER); @@ -637,7 +638,7 @@ API int iotcon_list_foreach_state(iotcon_list_h list, iotcon_list_state_cb cb, while (cur) { GList *next = cur->next; real = cur->data; - if (IOTCON_FUNC_STOP == cb(index, real->state, user_data)) + if (IOTCON_FUNC_STOP == cb(index, real->attributes, user_data)) break; index++; cur = next; diff --git a/lib/icl-lite-resource.c b/lib/icl-lite-resource.c index 37eb0b9..15f1ced 100644 --- a/lib/icl-lite-resource.c +++ b/lib/icl-lite-resource.c @@ -21,7 +21,7 @@ #include "ic-utils.h" #include "icl.h" #include "icl-representation.h" -#include "icl-state.h" +#include "icl-attributes.h" #include "icl-value.h" #include "icl-list.h" #include "icl-resource.h" @@ -34,7 +34,7 @@ API int iotcon_lite_resource_create(const char *uri_path, iotcon_resource_types_h res_types, uint8_t policies, - iotcon_state_h state, + iotcon_attributes_h attributes, iotcon_lite_resource_post_request_cb cb, void *user_data, iotcon_lite_resource_h *resource_handle) @@ -50,7 +50,7 @@ API int iotcon_lite_resource_create(const char *uri_path, RETV_IF(NULL == res_types, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == resource_handle, IOTCON_ERROR_INVALID_PARAMETER); - ret = icl_ioty_lite_resource_create(uri_path, res_types, policies, state, cb, + ret = icl_ioty_lite_resource_create(uri_path, res_types, policies, attributes, cb, user_data, resource_handle); if (IOTCON_ERROR_NONE != ret) { ERR("icl_ioty_lite_resource_create() Fail(%d)", ret); @@ -80,8 +80,8 @@ API int iotcon_lite_resource_destroy(iotcon_lite_resource_h resource) } -API int iotcon_lite_resource_update_state(iotcon_lite_resource_h resource, - iotcon_state_h state) +API int iotcon_lite_resource_update_attributes(iotcon_lite_resource_h resource, + iotcon_attributes_h attributes) { int ret; @@ -90,9 +90,9 @@ API int iotcon_lite_resource_update_state(iotcon_lite_resource_h resource, IOTCON_ERROR_PERMISSION_DENIED); RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER); - ret = icl_ioty_lite_resource_update_state(resource, state); + ret = icl_ioty_lite_resource_update_attributes(resource, attributes); if (IOTCON_ERROR_NONE != ret) { - ERR("icl_ioty_lite_resource_update_state() Fail(%d)", ret); + ERR("icl_ioty_lite_resource_update_attributes() Fail(%d)", ret); return ret; } @@ -100,14 +100,14 @@ API int iotcon_lite_resource_update_state(iotcon_lite_resource_h resource, } -API int iotcon_lite_resource_get_state(iotcon_lite_resource_h resource, - iotcon_state_h *state) +API int iotcon_lite_resource_get_attributes(iotcon_lite_resource_h resource, + iotcon_attributes_h *attributes) { RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED); RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER); - *state = resource->state; + *attributes = resource->attributes; return IOTCON_ERROR_NONE; } diff --git a/lib/icl-lite-resource.h b/lib/icl-lite-resource.h index 26b4e21..7201958 100644 --- a/lib/icl-lite-resource.h +++ b/lib/icl-lite-resource.h @@ -22,7 +22,7 @@ struct icl_lite_resource { char *uri_path; - iotcon_state_h state; + iotcon_attributes_h attributes; int64_t handle; uint8_t policies; iotcon_lite_resource_post_request_cb cb; diff --git a/lib/icl-representation.c b/lib/icl-representation.c index e57810f..6be07f2 100644 --- a/lib/icl-representation.c +++ b/lib/icl-representation.c @@ -30,12 +30,13 @@ #include "icl-response.h" #include "icl-list.h" #include "icl-value.h" -#include "icl-state.h" +#include "icl-attributes.h" #include "icl-representation.h" -static int _icl_repr_compare_state_value(struct icl_value_s *val1, +static int _icl_repr_compare_attributes_value(struct icl_value_s *val1, struct icl_value_s *val2); -static int _icl_repr_compare_state(iotcon_state_h state1, iotcon_state_h state2); +static int _icl_repr_compare_attributes(iotcon_attributes_h attributes1, + iotcon_attributes_h attributes2); iotcon_representation_h icl_representation_ref(iotcon_representation_h repr) { @@ -93,8 +94,8 @@ API void iotcon_representation_destroy(iotcon_representation_h repr) iotcon_resource_types_destroy(repr->res_types); /* null COULD be allowed */ - if (repr->state) - iotcon_state_destroy(repr->state); + if (repr->attributes) + iotcon_attributes_destroy(repr->attributes); free(repr); } @@ -162,8 +163,8 @@ API int iotcon_representation_set_resource_types(iotcon_representation_h repr, return IOTCON_ERROR_NONE; } -API int iotcon_representation_get_resource_interfaces(iotcon_representation_h repr, - iotcon_resource_interfaces_h *ifaces) +API int iotcon_representation_get_resource_interfaces( + iotcon_representation_h repr, iotcon_resource_interfaces_h *ifaces) { RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED); RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER); @@ -192,32 +193,32 @@ API int iotcon_representation_set_resource_interfaces( return IOTCON_ERROR_NONE; } -API int iotcon_representation_set_state(iotcon_representation_h repr, - iotcon_state_h state) +API int iotcon_representation_set_attributes(iotcon_representation_h repr, + iotcon_attributes_h attributes) { RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED); RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER); - if (state) - state = icl_state_ref(state); + if (attributes) + attributes = icl_attributes_ref(attributes); - if (repr->state) - iotcon_state_destroy(repr->state); + if (repr->attributes) + iotcon_attributes_destroy(repr->attributes); - repr->state = state; + repr->attributes = attributes; return IOTCON_ERROR_NONE; } -API int iotcon_representation_get_state(iotcon_representation_h repr, - iotcon_state_h *state) +API int iotcon_representation_get_attributes(iotcon_representation_h repr, + iotcon_attributes_h *attributes) { RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED); RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER); - *state = repr->state; + *attributes = repr->attributes; return IOTCON_ERROR_NONE; } @@ -371,10 +372,10 @@ API int iotcon_representation_clone(const iotcon_representation_h src, } } - if (src->state) { - ret = iotcon_state_clone(src->state, &cloned_repr->state); + if (src->attributes) { + ret = iotcon_attributes_clone(src->attributes, &cloned_repr->attributes); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_clone() Fail(%d)", ret); + ERR("iotcon_attributes_clone() Fail(%d)", ret); iotcon_representation_destroy(cloned_repr); return ret; } @@ -431,15 +432,15 @@ static int _icl_repr_compare_resource_types(iotcon_resource_types_h types1, return ret ; } -static int _icl_repr_compare_state_value_custom(gconstpointer p1, +static int _icl_repr_compare_attributes_value_custom(gconstpointer p1, gconstpointer p2) { struct icl_value_s *val1 = (struct icl_value_s *)p1; struct icl_value_s *val2 = (struct icl_value_s *)p2; - return _icl_repr_compare_state_value(val1, val2); + return _icl_repr_compare_attributes_value(val1, val2); } -static int _icl_repr_compare_state_list_value(struct icl_list_s *list1, +static int _icl_repr_compare_attributes_list_value(struct icl_list_s *list1, struct icl_list_s *list2) { GList *c; @@ -454,12 +455,12 @@ static int _icl_repr_compare_state_list_value(struct icl_list_s *list1, return !!(list1->list - list2->list); for (c = list1->list; c; c = c->next) - g_list_find_custom(list2->list, c->data, _icl_repr_compare_state_value_custom); + g_list_find_custom(list2->list, c->data, _icl_repr_compare_attributes_value_custom); return IC_EQUAL; } -static int _icl_repr_compare_state_value(struct icl_value_s *val1, +static int _icl_repr_compare_attributes_value(struct icl_value_s *val1, struct icl_value_s *val2) { int i; @@ -498,11 +499,11 @@ static int _icl_repr_compare_state_value(struct icl_value_s *val1, return 1; } break; - case IOTCON_TYPE_STATE: - return _icl_repr_compare_state(((icl_val_state_s *)val1)->state, - ((icl_val_state_s *)val2)->state); + case IOTCON_TYPE_ATTRIBUTES: + return _icl_repr_compare_attributes(((icl_val_attributes_s *)val1)->attributes, + ((icl_val_attributes_s *)val2)->attributes); case IOTCON_TYPE_LIST: - return _icl_repr_compare_state_list_value(((icl_val_list_s*)val1)->list, + return _icl_repr_compare_attributes_list_value(((icl_val_list_s*)val1)->list, ((icl_val_list_s*)val2)->list); case IOTCON_TYPE_NULL: return IC_EQUAL; @@ -514,29 +515,31 @@ static int _icl_repr_compare_state_value(struct icl_value_s *val1, return IC_EQUAL; } -static int _icl_repr_compare_state(iotcon_state_h state1, iotcon_state_h state2) +static int _icl_repr_compare_attributes(iotcon_attributes_h attributes1, + iotcon_attributes_h attributes2) { int ret; gpointer key, value1, value2; GHashTableIter iter; - struct icl_value_s *state_val1, *state_val2; + struct icl_value_s *attributes_val1, *attributes_val2; - if (NULL == state1 || NULL == state2) - return !!(state1 - state2); + if (NULL == attributes1 || NULL == attributes2) + return !!(attributes1 - attributes2); - if (NULL == state1->hash_table || NULL == state2->hash_table) - return !!(IC_POINTER_TO_INT64(state1->hash_table) - - IC_POINTER_TO_INT64(state2->hash_table)); + if (NULL == attributes1->hash_table || NULL == attributes2->hash_table) + return !!(IC_POINTER_TO_INT64(attributes1->hash_table) - + IC_POINTER_TO_INT64(attributes2->hash_table)); - if (g_hash_table_size(state1->hash_table) != g_hash_table_size(state2->hash_table)) + if (g_hash_table_size(attributes1->hash_table) != + g_hash_table_size(attributes1->hash_table)) return 1; - g_hash_table_iter_init(&iter, state1->hash_table); + g_hash_table_iter_init(&iter, attributes1->hash_table); while (g_hash_table_iter_next(&iter, &key, &value1)) { - value2 = g_hash_table_lookup(state2->hash_table, key); - state_val1 = (struct icl_value_s *)value1; - state_val2 = (struct icl_value_s *)value2; - ret = _icl_repr_compare_state_value(state_val1, state_val2); + value2 = g_hash_table_lookup(attributes2->hash_table, key); + attributes_val1 = (struct icl_value_s *)value1; + attributes_val2 = (struct icl_value_s *)value2; + ret = _icl_repr_compare_attributes_value(attributes_val1, attributes_val2); if (IC_EQUAL != ret) return ret; } @@ -605,8 +608,8 @@ int icl_representation_compare(iotcon_representation_h repr1, if (IC_EQUAL != ret) return ret; - /* state */ - ret = _icl_repr_compare_state(repr1->state, repr2->state); + /* attributes */ + ret = _icl_repr_compare_attributes(repr1->attributes, repr2->attributes); if (IC_EQUAL != ret) return ret; diff --git a/lib/icl-representation.h b/lib/icl-representation.h index f881e86..8f2873c 100644 --- a/lib/icl-representation.h +++ b/lib/icl-representation.h @@ -21,7 +21,7 @@ #include "iotcon-types.h" #include "icl-value.h" -struct icl_state_s { +struct icl_attributes_s { int ref_count; GHashTable *hash_table; }; @@ -33,7 +33,7 @@ struct icl_representation_s { GList *children; iotcon_resource_types_h res_types; iotcon_resource_interfaces_h interfaces; - struct icl_state_s *state; + struct icl_attributes_s *attributes; }; iotcon_representation_h icl_representation_ref(iotcon_representation_h repr); diff --git a/lib/icl-value.c b/lib/icl-value.c index 223b091..1922b1b 100644 --- a/lib/icl-value.c +++ b/lib/icl-value.c @@ -23,7 +23,7 @@ #include "icl.h" #include "icl-representation.h" #include "icl-list.h" -#include "icl-state.h" +#include "icl-attributes.h" #include "icl-value.h" static iotcon_value_h _icl_value_create(int type) @@ -44,8 +44,8 @@ static iotcon_value_h _icl_value_create(int type) case IOTCON_TYPE_LIST: ret_val = calloc(1, sizeof(icl_val_list_s)); break; - case IOTCON_TYPE_STATE: - ret_val = calloc(1, sizeof(icl_val_state_s)); + case IOTCON_TYPE_ATTRIBUTES: + ret_val = calloc(1, sizeof(icl_val_attributes_s)); break; default: ERR("Invalid Type(%d)", type); @@ -179,17 +179,17 @@ iotcon_value_h icl_value_create_list(iotcon_list_h val) return (iotcon_value_h)value; } -iotcon_value_h icl_value_create_state(iotcon_state_h val) +iotcon_value_h icl_value_create_attributes(iotcon_attributes_h val) { - icl_val_state_s *value; + icl_val_attributes_s *value; - value = (icl_val_state_s*)_icl_value_create(IOTCON_TYPE_STATE); + value = (icl_val_attributes_s*)_icl_value_create(IOTCON_TYPE_ATTRIBUTES); if (NULL == value) { - ERR("_icl_value_create(state) Fail"); + ERR("_icl_value_create(attributes) Fail"); return NULL; } - value->state = icl_state_ref(val); + value->attributes = icl_attributes_ref(val); return (iotcon_value_h)value; } @@ -275,15 +275,15 @@ int icl_value_get_list(iotcon_value_h value, iotcon_list_h *list) return IOTCON_ERROR_NONE; } -int icl_value_get_state(iotcon_value_h value, iotcon_state_h *state) +int icl_value_get_attributes(iotcon_value_h value, iotcon_attributes_h *attributes) { - icl_val_state_s *real = (icl_val_state_s*)value; + icl_val_attributes_s *real = (icl_val_attributes_s*)value; RETV_IF(NULL == value, IOTCON_ERROR_INVALID_PARAMETER); - RETVM_IF(IOTCON_TYPE_STATE != real->type, IOTCON_ERROR_INVALID_PARAMETER, + RETVM_IF(IOTCON_TYPE_ATTRIBUTES != real->type, IOTCON_ERROR_INVALID_PARAMETER, "Invalid Type(%d)", real->type); - *state = real->state; + *attributes = real->attributes; return IOTCON_ERROR_NONE; } @@ -294,7 +294,7 @@ void icl_value_destroy(gpointer data) int ret; iotcon_value_h value; iotcon_list_h list; - iotcon_state_h state; + iotcon_attributes_h attributes; RET_IF(NULL == data); @@ -320,13 +320,13 @@ void icl_value_destroy(gpointer data) } iotcon_list_destroy(list); break; - case IOTCON_TYPE_STATE: - ret = icl_value_get_state(value, &state); + case IOTCON_TYPE_ATTRIBUTES: + ret = icl_value_get_attributes(value, &attributes); if (IOTCON_ERROR_NONE != ret) { - ERR("icl_value_get_state() Fail(%d)", ret); + ERR("icl_value_get_attributes() Fail(%d)", ret); break; } - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); break; default: ERR("Invalid type(%d)", type); @@ -366,8 +366,8 @@ iotcon_value_h icl_value_clone(iotcon_value_h src) case IOTCON_TYPE_LIST: dest = icl_value_create_list(((icl_val_list_s*)real)->list); break; - case IOTCON_TYPE_STATE: - dest = icl_value_create_state(((icl_val_state_s*)real)->state); + case IOTCON_TYPE_ATTRIBUTES: + dest = icl_value_create_attributes(((icl_val_attributes_s*)real)->attributes); break; default: ERR("Invalid type(%d)", src->type); diff --git a/lib/icl-value.h b/lib/icl-value.h index 48e8d29..cc7c1de 100644 --- a/lib/icl-value.h +++ b/lib/icl-value.h @@ -47,8 +47,8 @@ typedef struct { typedef struct { int type; - struct icl_state_s *state; -} icl_val_state_s; + struct icl_attributes_s *attributes; +} icl_val_attributes_s; /** * @ingroup CAPI_IOT_CONNECTIVITY_REPRESENTATION_MODULE @@ -64,7 +64,7 @@ typedef struct { * #IOTCON_TYPE_NULL\n * #IOTCON_TYPE_BYTE_STR\n * #IOTCON_TYPE_LIST\n - * #IOTCON_TYPE_STATE + * #IOTCON_TYPE_ATTRIBUTES * * @since_tizen 3.0 */ @@ -77,7 +77,7 @@ iotcon_value_h icl_value_create_double(double val); iotcon_value_h icl_value_create_str(const char *val); iotcon_value_h icl_value_create_byte_str(const unsigned char *val, int len); iotcon_value_h icl_value_create_list(iotcon_list_h val); -iotcon_value_h icl_value_create_state(iotcon_state_h val); +iotcon_value_h icl_value_create_attributes(iotcon_attributes_h val); int icl_value_get_int(iotcon_value_h value, int *val); @@ -86,7 +86,7 @@ int icl_value_get_double(iotcon_value_h value, double *val); int icl_value_get_str(iotcon_value_h value, char **val); int icl_value_get_byte_str(iotcon_value_h value, unsigned char **val, int *len); int icl_value_get_list(iotcon_value_h value, iotcon_list_h *list); -int icl_value_get_state(iotcon_value_h value, iotcon_state_h *state); +int icl_value_get_attributes(iotcon_value_h value, iotcon_attributes_h *attributes); void icl_value_destroy(gpointer data); diff --git a/lib/include/iotcon-state.h b/lib/include/iotcon-attributes.h index f46a148..4f61667 100644 --- a/lib/include/iotcon-state.h +++ b/lib/include/iotcon-attributes.h @@ -13,26 +13,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef __IOT_CONNECTIVITY_STRUCT_STATE_H__ -#define __IOT_CONNECTIVITY_STRUCT_STATE_H__ +#ifndef __IOT_CONNECTIVITY_STRUCT_ATTRIBUTES_H__ +#define __IOT_CONNECTIVITY_STRUCT_ATTRIBUTES_H__ #include <iotcon-types.h> /** - * @file iotcon-state.h + * @file iotcon-attributes.h */ /** * @ingroup CAPI_IOT_CONNECTIVITY_COMMON_REPRESENTATION_MODULE - * @defgroup CAPI_IOT_CONNECTIVITY_COMMON_REPRESENTATION_STATE_MODULE State + * @defgroup CAPI_IOT_CONNECTIVITY_COMMON_REPRESENTATION_ATTRIBUTES_MODULE State * - * @brief IoTCon State provides API to manage state. + * @brief IoTCon State provides API to manage attributes. * - * @section CAPI_IOT_CONNECTIVITY_COMMON_REPRESENTATION_STATE_MODULE_HEADER Required Header + * @section CAPI_IOT_CONNECTIVITY_COMMON_REPRESENTATION_ATTRIBUTES_MODULE_HEADER Required Header * \#include <iotcon.h> * - * @section CAPI_IOT_CONNECTIVITY_COMMON_REPRESENTATION_STATE_MODULE_OVERVIEW Overview - * The iotcon state API provides string key based hash table. + * @section CAPI_IOT_CONNECTIVITY_COMMON_REPRESENTATION_ATTRIBUTES_MODULE_OVERVIEW Overview + * The iotcon attributes API provides string key based hash table. * * Example : * @code @@ -51,7 +51,7 @@ static void _request_handler(iotcon_resource_h resource, iotcon_request_h reques if (IOTCON_REQUEST_GET & types) { iotcon_response_h response = NULL; iotcon_representation_h representation = NULL; - iotcon_state_h state = NULL; + iotcon_attributes_h attributes = NULL; ret = iotcon_response_create(request, &response); if (IOTCON_ERROR_NONE != ret) @@ -65,32 +65,32 @@ static void _request_handler(iotcon_resource_h resource, iotcon_request_h reques ... - ret = iotcon_state_create(&state); + ret = iotcon_attributes_create(&attributes); if (IOTCON_ERROR_NONE != ret) { iotcon_representation_destroy(representation); iotcon_response_destroy(resopnse); return; } - ret = iotcon_state_add_bool(state, "power", true); + ret = iotcon_attributes_add_bool(attributes, "power", true); if (IOTCON_ERROR_NONE != ret) { - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(representation); iotcon_response_destroy(resopnse); return; } - ret = iotcon_state_add_int(state, "brightness", 75); + ret = itocon_attributes_add_int(attributes, "brightness", 75); if (IOTCON_ERROR_NONE != ret) { - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(representation); iotcon_response_destroy(resopnse); return; } - ret = iotcon_representation_set_state(representation, state); + ret = iotcon_representation_set_attributes(representation, attributes); if (IOTCON_ERROR_NONE != ret) { - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(representation); iotcon_response_destroy(resopnse); return; @@ -100,7 +100,7 @@ static void _request_handler(iotcon_resource_h resource, iotcon_request_h reques ret = iotcon_response_set_representation(response, representation); if (IOTCON_ERROR_NONE != ret) { - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(representation); iotcon_response_destroy(resopnse); return; @@ -108,13 +108,13 @@ static void _request_handler(iotcon_resource_h resource, iotcon_request_h reques ret = iotcon_response_send(response); if (IOTCON_ERROR_NONE != ret) { - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(representation); iotcon_response_destroy(resopnse); return; } - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(representation); iotcon_response_destroy(resopnse); } @@ -122,7 +122,7 @@ static void _request_handler(iotcon_resource_h resource, iotcon_request_h reques } * @endcode * - * @section CAPI_IOT_CONNECTIVITY_COMMON_REPRESENTATION_STATE_MODULE_FEATURE Related Features + * @section CAPI_IOT_CONNECTIVITY_COMMON_REPRESENTATION_ATTRIBUTES_MODULE_FEATURE Related Features * This API is related with the following features:\n * - http://tizen.org/feature/iot.ocf\n * @@ -138,14 +138,14 @@ static void _request_handler(iotcon_resource_h resource, iotcon_request_h reques */ /** - * @brief Creates a new state handle. + * @brief Creates a new attributes handle. * * @since_tizen 3.0 * - * @remarks You must destroy @a state by calling iotcon_state_destroy() - * if @a state is no longer needed. + * @remarks You must destroy @a attributes by calling iotcon_attributes_destroy() + * if @a attributes is no longer needed. * - * @param[out] state A newly allocated state handle + * @param[out] attributes A newly allocated attributes handle * * @return 0 on success, otherwise a negative error value. * @retval #IOTCON_ERROR_NONE Successful @@ -153,34 +153,34 @@ static void _request_handler(iotcon_resource_h resource, iotcon_request_h reques * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter * - * @see iotcon_state_destroy() + * @see iotcon_attributes_destroy() */ -int iotcon_state_create(iotcon_state_h *state); +int iotcon_attributes_create(iotcon_attributes_h *attributes); /** - * @brief Destroys a state. - * @details Releases a @a state and its internal data. + * @brief Destroys a attributes. + * @details Releases a @a attributes and its internal data. * * @since_tizen 3.0 * - * @param[in] state The state handle to free + * @param[in] attributes The attributes handle to free * * @return void * - * @see iotcon_state_create() + * @see iotcon_attributes_create() */ -void iotcon_state_destroy(iotcon_state_h state); +void iotcon_attributes_destroy(iotcon_attributes_h attributes); /** - * @brief Clones a state handle. + * @brief Clones a attributes handle. * * @since_tizen 3.0 * - * @remarks You must destroy @a state_clone by calling iotcon_state_destroy() - * if @a state_clone is no longer needed. + * @remarks You must destroy @a attributes_clone by calling iotcon_attributes_destroy() + * if @a attributes_clone is no longer needed. * - * @param[in] state The state handle - * @param[out] state_clone The cloned state handle + * @param[in] attributes The attributes handle + * @param[out] attributes_clone The cloned attributes handle * * @return 0 on success, otherwise a negative error value. * @retval #IOTCON_ERROR_NONE Successful @@ -188,18 +188,18 @@ void iotcon_state_destroy(iotcon_state_h state); * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter * - * @see iotcon_state_create() - * @see iotcon_state_destroy() + * @see iotcon_attributes_create() + * @see iotcon_attributes_destroy() */ -int iotcon_state_clone(iotcon_state_h state, iotcon_state_h *state_clone); +int iotcon_attributes_clone(iotcon_attributes_h attributes, iotcon_attributes_h *attributes_clone); /** - * @brief Adds a new key and integer value into the state. + * @brief Adds a new key and integer value into the attributes. * @details If @a key is already exists, current value will be replaced with new @a val. * * @since_tizen 3.0 * - * @param[in] state The state handle + * @param[in] attributes The attributes handle * @param[in] key The key * @param[in] val The value * @@ -209,15 +209,15 @@ int iotcon_state_clone(iotcon_state_h state, iotcon_state_h *state_clone); * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter */ -int iotcon_state_add_int(iotcon_state_h state, const char *key, int val); +int iotcon_attributes_add_int(iotcon_attributes_h attributes, const char *key, int val); /** - * @brief Adds a new key and boolean value into the state. + * @brief Adds a new key and boolean value into the attributes. * @details If @a key is already exists, current value will be replaced with new @a val. * * @since_tizen 3.0 * - * @param[in] state The state handle + * @param[in] attributes The attributes handle * @param[in] key The key * @param[in] val The value * @@ -227,15 +227,15 @@ int iotcon_state_add_int(iotcon_state_h state, const char *key, int val); * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter */ -int iotcon_state_add_bool(iotcon_state_h state, const char *key, bool val); +int iotcon_attributes_add_bool(iotcon_attributes_h attributes, const char *key, bool val); /** - * @brief Adds a new key and double value into the state. + * @brief Adds a new key and double value into the attributes. * @details If @a key is already exists, current value will be replaced with new @a val. * * @since_tizen 3.0 * - * @param[in] state The state handle + * @param[in] attributes The attributes handle * @param[in] key The key * @param[in] val The value * @@ -245,15 +245,15 @@ int iotcon_state_add_bool(iotcon_state_h state, const char *key, bool val); * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter */ -int iotcon_state_add_double(iotcon_state_h state, const char *key, double val); +int iotcon_attributes_add_double(iotcon_attributes_h attributes, const char *key, double val); /** - * @brief Adds a new key and string value into the state. + * @brief Adds a new key and string value into the attributes. * @details If @a key is already exists, current value will be replaced with new @a val. * * @since_tizen 3.0 * - * @param[in] state The state handle + * @param[in] attributes The attributes handle * @param[in] key The key * @param[in] val The value * @@ -263,15 +263,15 @@ int iotcon_state_add_double(iotcon_state_h state, const char *key, double val); * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter */ -int iotcon_state_add_str(iotcon_state_h state, const char *key, char *val); +int iotcon_attributes_add_str(iotcon_attributes_h attributes, const char *key, char *val); /** - * @brief Adds a new key and byte string value into the state. + * @brief Adds a new key and byte string value into the attributes. * @details If @a key is already exists, current value will be replaced with new @a val. * * @since_tizen 3.0 * - * @param[in] state The state handle + * @param[in] attributes The attributes handle * @param[in] key The key * @param[in] val The value * @param[in] len The length of @a val @@ -282,16 +282,16 @@ int iotcon_state_add_str(iotcon_state_h state, const char *key, char *val); * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter */ -int iotcon_state_add_byte_str(iotcon_state_h state, const char *key, unsigned char *val, +int iotcon_attributes_add_byte_str(iotcon_attributes_h attributes, const char *key, unsigned char *val, int len); /** - * @brief Adds a new key and list value into the state. + * @brief Adds a new key and list value into the attributes. * @details If @a key is already exists, current list will be replaced with new @a list. * * @since_tizen 3.0 * - * @param[in] state The state handle + * @param[in] attributes The attributes handle * @param[in] key The key * @param[in] list The value * @@ -301,17 +301,17 @@ int iotcon_state_add_byte_str(iotcon_state_h state, const char *key, unsigned ch * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter */ -int iotcon_state_add_list(iotcon_state_h state, const char *key, iotcon_list_h list); +int iotcon_attributes_add_list(iotcon_attributes_h attributes, const char *key, iotcon_list_h list); /** - * @brief Adds a new key and state value into the state. - * @details If @a key is already exists, current state will be replaced with new @a src. + * @brief Adds a new key and attributes value into the attributes. + * @details If @a key is already exists, current attributes will be replaced with new @a src. * * @since_tizen 3.0 * - * @param[in] dest The state handle + * @param[in] dest The attributes handle * @param[in] key The key - * @param[in] src The state handle to set newly + * @param[in] src The attributes handle to set newly * * @return 0 on success, otherwise a negative error value. * @retval #IOTCON_ERROR_NONE Successful @@ -319,15 +319,15 @@ int iotcon_state_add_list(iotcon_state_h state, const char *key, iotcon_list_h l * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter */ -int iotcon_state_add_state(iotcon_state_h dest, const char *key, iotcon_state_h src); +int iotcon_attributes_add_attributes(iotcon_attributes_h dest, const char *key, iotcon_attributes_h src); /** - * @brief Adds a new key with NULL value into the state. + * @brief Adds a new key with NULL value into the attributes. * @details If @a key is already exists, current value will be replaced with NULL. * * @since_tizen 3.0 * - * @param[in] state The state handle + * @param[in] attributes The attributes handle * @param[in] key The key to be set NULL * * @return 0 on success, otherwise a negative error value. @@ -336,14 +336,14 @@ int iotcon_state_add_state(iotcon_state_h dest, const char *key, iotcon_state_h * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter */ -int iotcon_state_add_null(iotcon_state_h state, const char *key); +int iotcon_attributes_add_null(iotcon_attributes_h attributes, const char *key); /** * @brief Gets the integer value from the given key. * * @since_tizen 3.0 * - * @param[in] state The state handle + * @param[in] attributes The attributes handle * @param[in] key The key * @param[out] val The integer value * @@ -354,14 +354,14 @@ int iotcon_state_add_null(iotcon_state_h state, const char *key); * @retval #IOTCON_ERROR_NO_DATA No data available * @retval #IOTCON_ERROR_INVALID_TYPE Invalid type */ -int iotcon_state_get_int(iotcon_state_h state, const char *key, int *val); +int iotcon_attributes_get_int(iotcon_attributes_h attributes, const char *key, int *val); /** * @brief Gets the boolean value from the given key. * * @since_tizen 3.0 * - * @param[in] state The state handle + * @param[in] attributes The attributes handle * @param[in] key The key * @param[out] val The boolean value * @@ -372,14 +372,14 @@ int iotcon_state_get_int(iotcon_state_h state, const char *key, int *val); * @retval #IOTCON_ERROR_NO_DATA No data available * @retval #IOTCON_ERROR_INVALID_TYPE Invalid type */ -int iotcon_state_get_bool(iotcon_state_h state, const char *key, bool *val); +int iotcon_attributes_get_bool(iotcon_attributes_h attributes, const char *key, bool *val); /** * @brief Gets the double value from the given key. * * @since_tizen 3.0 * - * @param[in] state The state handle + * @param[in] attributes The attributes handle * @param[in] key The key * @param[out] val The double value * @@ -390,7 +390,7 @@ int iotcon_state_get_bool(iotcon_state_h state, const char *key, bool *val); * @retval #IOTCON_ERROR_NO_DATA No data available * @retval #IOTCON_ERROR_INVALID_TYPE Invalid type */ -int iotcon_state_get_double(iotcon_state_h state, const char *key, double *val); +int iotcon_attributes_get_double(iotcon_attributes_h attributes, const char *key, double *val); /** * @brief Gets the string value from the given key. @@ -399,7 +399,7 @@ int iotcon_state_get_double(iotcon_state_h state, const char *key, double *val); * * @remarks @a val must not be released using free(). * - * @param[in] state The state handle + * @param[in] attributes The attributes handle * @param[in] key The key * @param[out] val The string value * @@ -410,7 +410,7 @@ int iotcon_state_get_double(iotcon_state_h state, const char *key, double *val); * @retval #IOTCON_ERROR_NO_DATA No data available * @retval #IOTCON_ERROR_INVALID_TYPE Invalid type */ -int iotcon_state_get_str(iotcon_state_h state, const char *key, char **val); +int iotcon_attributes_get_str(iotcon_attributes_h attributes, const char *key, char **val); /** * @brief Gets the byte string value from the given key. @@ -419,7 +419,7 @@ int iotcon_state_get_str(iotcon_state_h state, const char *key, char **val); * * @remarks @a val must not be released using free(). * - * @param[in] state The state handle + * @param[in] attributes The attributes handle * @param[in] key The key * @param[out] val The byte string value * @param[out] len The length of @a val @@ -431,7 +431,7 @@ int iotcon_state_get_str(iotcon_state_h state, const char *key, char **val); * @retval #IOTCON_ERROR_NO_DATA No data available * @retval #IOTCON_ERROR_INVALID_TYPE Invalid type */ -int iotcon_state_get_byte_str(iotcon_state_h state, const char *key, unsigned char **val, +int iotcon_attributes_get_byte_str(iotcon_attributes_h attributes, const char *key, unsigned char **val, int *len); /** @@ -441,7 +441,7 @@ int iotcon_state_get_byte_str(iotcon_state_h state, const char *key, unsigned ch * * @remarks @a list must not be released using iotcon_list_destroy(). * - * @param[in] state The state handle + * @param[in] attributes The attributes handle * @param[in] key The key * @param[out] list The list value * @@ -452,18 +452,18 @@ int iotcon_state_get_byte_str(iotcon_state_h state, const char *key, unsigned ch * @retval #IOTCON_ERROR_NO_DATA No data available * @retval #IOTCON_ERROR_INVALID_TYPE Invalid type */ -int iotcon_state_get_list(iotcon_state_h state, const char *key, iotcon_list_h *list); +int iotcon_attributes_get_list(iotcon_attributes_h attributes, const char *key, iotcon_list_h *list); /** - * @brief Gets the state value from the given key. + * @brief Gets the attributes value from the given key. * * @since_tizen 3.0 * - * @remarks @a state must not be released using iotcon_state_destroy(). + * @remarks @a attributes must not be released using iotcon_attributes_destroy(). * - * @param[in] src The state handle + * @param[in] src The attributes handle * @param[in] key The key - * @param[out] dest The state value at the key + * @param[out] dest The attributes value at the key * * @return 0 on success, otherwise a negative error value. * @retval #IOTCON_ERROR_NONE Successful @@ -472,14 +472,14 @@ int iotcon_state_get_list(iotcon_state_h state, const char *key, iotcon_list_h * * @retval #IOTCON_ERROR_NO_DATA No data available * @retval #IOTCON_ERROR_INVALID_TYPE Invalid type */ -int iotcon_state_get_state(iotcon_state_h src, const char *key, iotcon_state_h *dest); +int iotcon_attributes_get_attributes(iotcon_attributes_h src, const char *key, iotcon_attributes_h *dest); /** * @brief Checks whether the value of given key is NULL or not. * * @since_tizen 3.0 * - * @param[in] state The state handle + * @param[in] attributes The attributes handle * @param[in] key The key * @param[out] is_null true if the type of the given key is null, otherwise false * @@ -488,14 +488,14 @@ int iotcon_state_get_state(iotcon_state_h src, const char *key, iotcon_state_h * * @retval #IOTCON_ERROR_NOT_SUPPORTED Not supported * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter */ -int iotcon_state_is_null(iotcon_state_h state, const char *key, bool *is_null); +int iotcon_attributes_is_null(iotcon_attributes_h attributes, const char *key, bool *is_null); /** - * @brief Removes the key and its associated value from the state. + * @brief Removes the key and its associated value from the attributes. * * @since_tizen 3.0 * - * @param[in] state The state handle + * @param[in] attributes The attributes handle * @param[in] key The key * * @return 0 on success, otherwise a negative error value. @@ -504,18 +504,18 @@ int iotcon_state_is_null(iotcon_state_h state, const char *key, bool *is_null); * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter * @retval #IOTCON_ERROR_NO_DATA No data available */ -int iotcon_state_remove(iotcon_state_h state, const char *key); +int iotcon_attributes_remove(iotcon_attributes_h attributes, const char *key); /** * @brief Gets the type of a value at the given key. - * @details It gets the data type of value related the @a key in @a state. + * @details It gets the data type of value related the @a key in @a attributes. * The data type could be one of #iotcon_type_e. * * @since_tizen 3.0 * - * @param[in] state The state handle + * @param[in] attributes The attributes handle * @param[in] key The key - * @param[out] type The data type of value related the key in state handle. + * @param[out] type The data type of value related the key in attributes handle. * * @return 0 on success, otherwise a negative error value. * @retval #IOTCON_ERROR_NONE Successful @@ -523,15 +523,15 @@ int iotcon_state_remove(iotcon_state_h state, const char *key); * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter * @retval #IOTCON_ERROR_NO_DATA No data available */ -int iotcon_state_get_type(iotcon_state_h state, const char *key, +int iotcon_attributes_get_type(iotcon_attributes_h attributes, const char *key, iotcon_type_e *type); /** - * @brief Specifies the type of function passed to iotcon_state_foreach(). + * @brief Specifies the type of function passed to iotcon_attributes_foreach(). * * @since_tizen 3.0 * - * @param[in] state The state handle + * @param[in] attributes The attributes handle * @param[in] key The key * @param[in] user_data The user data to pass to the function * @@ -539,19 +539,19 @@ int iotcon_state_get_type(iotcon_state_h state, const char *key, * otherwise false to break out of the loop. #IOTCON_FUNC_CONTINUE and #IOTCON_FUNC_STOP * are more friendly values for the return. * - * @pre iotcon_state_foreach() will invoke this callback function. + * @pre iotcon_attributes_foreach() will invoke this callback function. * - * @see iotcon_state_foreach() + * @see iotcon_attributes_foreach() */ -typedef bool (*iotcon_state_cb)(iotcon_state_h state, const char *key, void *user_data); +typedef bool (*iotcon_attributes_cb)(iotcon_attributes_h attributes, const char *key, void *user_data); /** - * @brief Calls a function for each element of state. - * @details iotcon_state_cb() will be called for each child. + * @brief Calls a function for each element of attributes. + * @details iotcon_attributes_cb() will be called for each child. * * @since_tizen 3.0 * - * @param[in] state The state handle + * @param[in] attributes The attributes handle * @param[in] cb The callback function to invoke * @param[in] user_data The user data to pass to the function * @@ -560,18 +560,18 @@ typedef bool (*iotcon_state_cb)(iotcon_state_h state, const char *key, void *use * @retval #IOTCON_ERROR_NOT_SUPPORTED Not supported * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter * - * @post iotcon_state_cb() will be called for each child. + * @post iotcon_attributes_cb() will be called for each child. * - * @see iotcon_state_cb() + * @see iotcon_attributes_cb() */ -int iotcon_state_foreach(iotcon_state_h state, iotcon_state_cb cb, void *user_data); +int iotcon_attributes_foreach(iotcon_attributes_h attributes, iotcon_attributes_cb cb, void *user_data); /** - * @brief Gets the number of keys in the state. + * @brief Gets the number of keys in the attributes. * * @since_tizen 3.0 * - * @param[in] state The state handle + * @param[in] attributes The attributes handle * @param[out] count The number of keys * * @return 0 on success, otherwise a negative error value. @@ -579,10 +579,10 @@ int iotcon_state_foreach(iotcon_state_h state, iotcon_state_cb cb, void *user_da * @retval #IOTCON_ERROR_NOT_SUPPORTED Not supported * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter */ -int iotcon_state_get_keys_count(iotcon_state_h state, unsigned int *count); +int iotcon_attributes_get_keys_count(iotcon_attributes_h attributes, unsigned int *count); /** * @} */ -#endif /* __IOT_CONNECTIVITY_STRUCT_STATE_H__ */ +#endif /* __IOT_CONNECTIVITY_STRUCT_ATTRIBUTES_H__ */ diff --git a/lib/include/iotcon-constant.h b/lib/include/iotcon-constant.h index da4bc9a..d82d68a 100644 --- a/lib/include/iotcon-constant.h +++ b/lib/include/iotcon-constant.h @@ -198,7 +198,7 @@ typedef enum { IOTCON_TYPE_BYTE_STR, /**< Indicates for representation that have byte string type */ IOTCON_TYPE_NULL, /**< Indicates for representation that have null type */ IOTCON_TYPE_LIST, /**< Indicates for representation that have list type */ - IOTCON_TYPE_STATE, /**< Indicates for representation that have another representation type */ + IOTCON_TYPE_ATTRIBUTES, /**< Indicates for representation that have another representation type */ } iotcon_type_e; /** diff --git a/lib/include/iotcon-list.h b/lib/include/iotcon-list.h index 23a0896..effda3c 100644 --- a/lib/include/iotcon-list.h +++ b/lib/include/iotcon-list.h @@ -23,16 +23,16 @@ */ /** - * @ingroup CAPI_IOT_CONNECTIVITY_COMMON_REPRESENTATION_STATE_MODULE - * @defgroup CAPI_IOT_CONNECTIVITY_COMMON_REPRESENTATION_STATE_LIST_MODULE List + * @ingroup CAPI_IOT_CONNECTIVITY_COMMON_REPRESENTATION_ATTRIBUTES_MODULE + * @defgroup CAPI_IOT_CONNECTIVITY_COMMON_REPRESENTATION_ATTRIBUTES_LIST_MODULE List * * @brief IoTCon List provides API to get data from list and set data to list. * - * @section CAPI_IOT_CONNECTIVITY_COMMON_REPRESENTATION_STATE_LIST_MODULE_HEADER Required Header + * @section CAPI_IOT_CONNECTIVITY_COMMON_REPRESENTATION_ATTRIBUTES_LIST_MODULE_HEADER Required Header * \#include <iotcon.h> * - * @section CAPI_IOT_CONNECTIVITY_COMMON_REPRESENTATION_STATE_LIST_MODULE_OVERVIEW Overview - * The iotcon list API provides list of bool, integer, double, string, byte string, list and state handle. + * @section CAPI_IOT_CONNECTIVITY_COMMON_REPRESENTATION_ATTRIBUTES_LIST_MODULE_OVERVIEW Overview + * The iotcon list API provides list of bool, integer, double, string, byte string, list and attributes handle. * * Example : * @code @@ -49,7 +49,7 @@ static void _request_handler(iotcon_resource_h resource, iotcon_request_h reques if (IOTCON_REQUEST_GET & types) { iotcon_response_h response = NULL; iotcon_representation_h representation = NULL; - iotcon_state_h state = NULL; + iotcon_attributes_h attributes = NULL; iotcon_list_h list = NULL; ret = iotcon_response_create(request, &response); @@ -64,7 +64,7 @@ static void _request_handler(iotcon_resource_h resource, iotcon_request_h reques ... - ret = iotcon_state_create(&state); + ret = iotcon_attributes_create(&attributes); if (IOTCON_ERROR_NONE != ret) { iotcon_representation_destroy(representation); iotcon_response_destroy(resopnse); @@ -73,7 +73,7 @@ static void _request_handler(iotcon_resource_h resource, iotcon_request_h reques ret = iotcon_list_create(IOTCON_TYPE_INT, &list); if (IOTCON_ERROR_NONE != ret) { - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(representation); iotcon_response_destroy(resopnse); return; @@ -82,7 +82,7 @@ static void _request_handler(iotcon_resource_h resource, iotcon_request_h reques ret = iotcon_list_add_int(list, 1); if (IOTCON_ERROR_NONE != ret) { iotcon_list_destroy(list); - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(representation); iotcon_response_destroy(resopnse); return; @@ -91,7 +91,7 @@ static void _request_handler(iotcon_resource_h resource, iotcon_request_h reques ret = iotcon_list_add_int(list, 2); if (IOTCON_ERROR_NONE != ret) { iotcon_list_destroy(list); - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(representation); iotcon_response_destroy(resopnse); return; @@ -100,25 +100,25 @@ static void _request_handler(iotcon_resource_h resource, iotcon_request_h reques ret = iotcon_list_add_int(list, 10); if (IOTCON_ERROR_NONE != ret) { iotcon_list_destroy(list); - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(representation); iotcon_response_destroy(resopnse); return; } - ret = iotcon_state_add_list(state, "ids", list); + ret = itocon_attributes_add_list(attributes, "ids", list); if (IOTCON_ERROR_NONE != ret) { iotcon_list_destroy(list); - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(representation); iotcon_response_destroy(resopnse); return; } - ret = iotcon_representation_set_state(representation, state); + ret = iotcon_representation_set_attributes(representation, attributes); if (IOTCON_ERROR_NONE != ret) { iotcon_list_destroy(list); - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(representation); iotcon_response_destroy(resopnse); return; @@ -129,7 +129,7 @@ static void _request_handler(iotcon_resource_h resource, iotcon_request_h reques ret = iotcon_response_set_representation(response, representation); if (IOTCON_ERROR_NONE != ret) { iotcon_list_destroy(list); - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(representation); iotcon_response_destroy(resopnse); return; @@ -138,14 +138,14 @@ static void _request_handler(iotcon_resource_h resource, iotcon_request_h reques ret = iotcon_response_send(response); if (IOTCON_ERROR_NONE != ret) { iotcon_list_destroy(list); - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(representation); iotcon_response_destroy(resopnse); return; } iotcon_list_destroy(list); - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(representation); iotcon_response_destroy(resopnse); } @@ -153,7 +153,7 @@ static void _request_handler(iotcon_resource_h resource, iotcon_request_h reques } * @endcode * - * @section CAPI_IOT_CONNECTIVITY_COMMON_REPRESENTATION_STATE_LIST_MODULE_FEATURE Related Features + * @section CAPI_IOT_CONNECTIVITY_COMMON_REPRESENTATION_ATTRIBUTES_LIST_MODULE_FEATURE Related Features * This API is related with the following features:\n * - http://tizen.org/feature/iot.ocf\n * @@ -322,14 +322,14 @@ int iotcon_list_add_byte_str(iotcon_list_h list, unsigned char *val, int len, in int iotcon_list_add_list(iotcon_list_h list, iotcon_list_h val, int pos); /** - * @brief Adds a new element state value into the list at the given position. + * @brief Adds a new element attributes value into the list at the given position. * @details If @a pos is negative, or is larger than the number of elements in the list, * the new value is added on to the end of the list. * * @since_tizen 3.0 * * @param[in] list The list handle - * @param[in] val The new state value + * @param[in] val The new attributes value * @param[in] pos The position to insert value * * @return 0 on success, otherwise a negative error value. @@ -339,7 +339,7 @@ int iotcon_list_add_list(iotcon_list_h list, iotcon_list_h val, int pos); * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter * @retval #IOTCON_ERROR_INVALID_TYPE Invalid type */ -int iotcon_list_add_state(iotcon_list_h list, iotcon_state_h val, int pos); +int iotcon_list_add_attributes(iotcon_list_h list, iotcon_attributes_h val, int pos); /** * @brief Gets the integer value at the given position. @@ -464,16 +464,16 @@ int iotcon_list_get_nth_byte_str(iotcon_list_h list, int pos, unsigned char **va int iotcon_list_get_nth_list(iotcon_list_h src, int pos, iotcon_list_h *dest); /** - * @brief Gets the state value at the given position. + * @brief Gets the attributes value at the given position. * @details Iterates over the list until it reaches the @a pos-1 position. * * @since_tizen 3.0 * - * @remarks @a state must not be released using iotcon_state_destroy(). + * @remarks @a attributes must not be released using iotcon_attributes_destroy(). * * @param[in] list The list handle * @param[in] pos The position - * @param[out] state The state value to get + * @param[out] attributes The attributes value to get * * @return 0 on success, otherwise a negative error value. * @retval #IOTCON_ERROR_NONE Successful @@ -482,7 +482,7 @@ int iotcon_list_get_nth_list(iotcon_list_h src, int pos, iotcon_list_h *dest); * @retval #IOTCON_ERROR_NO_DATA No data available * @retval #IOTCON_ERROR_REPRESENTATION Representation errors */ -int iotcon_list_get_nth_state(iotcon_list_h list, int pos, iotcon_state_h *state); +int iotcon_list_get_nth_attributes(iotcon_list_h list, int pos, iotcon_attributes_h *attributes); /** * @brief Removes the value at the given position. @@ -503,7 +503,7 @@ int iotcon_list_remove_nth(iotcon_list_h list, int pos); /** * @brief Gets the type of the list. - * @details It gets the data type of value related the @a key in @a state. + * @details It gets the data type of value related the @a key in @a attributes. * The data type could be one of #iotcon_type_e. * * @since_tizen 3.0 @@ -778,32 +778,32 @@ typedef bool (*iotcon_list_list_cb)(int pos, iotcon_list_h value, void *user_dat int iotcon_list_foreach_list(iotcon_list_h list, iotcon_list_list_cb cb, void *user_data); /** - * @brief Specifies the type of function passed to iotcon_list_foreach_state(). + * @brief Specifies the type of function passed to iotcon_list_foreach_attributes(). * * @since_tizen 3.0 * - * @param[in] pos The number of the state value (0 being the first) - * @param[in] value The state value + * @param[in] pos The number of the attributes value (0 being the first) + * @param[in] value The attributes value * @param[in] user_data The user data to pass to the function * * @return true to continue with the next iteration of the loop, * otherwise false to break out of the loop. #IOTCON_FUNC_CONTINUE and #IOTCON_FUNC_STOP * are more friendly values for the return. * - * @pre iotcon_list_foreach_state() will invoke this callback function. + * @pre iotcon_list_foreach_attributes() will invoke this callback function. * - * @see iotcon_list_foreach_state() + * @see iotcon_list_foreach_attributes() */ -typedef bool (*iotcon_list_state_cb)(int pos, iotcon_state_h value, void *user_data); +typedef bool (*iotcon_list_attributes_cb)(int pos, iotcon_attributes_h value, void *user_data); /** - * @brief Gets all state of the given list by invoking the callback function. - * @details iotcon_list_state_cb() will be called for each child. + * @brief Gets all attributes of the given list by invoking the callback function. + * @details iotcon_list_attributes_cb() will be called for each child. * * @since_tizen 3.0 * * @param[in] list The handle to the list - * @param[in] cb The callback function to get each state + * @param[in] cb The callback function to get each attributes * @param[in] user_data The user data to be passed to the callback function * * @return 0 on success, otherwise a negative error value. @@ -811,11 +811,11 @@ typedef bool (*iotcon_list_state_cb)(int pos, iotcon_state_h value, void *user_d * @retval #IOTCON_ERROR_NOT_SUPPORTED Not supported * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter * - * @post iotcon_list_state_cb() will be called for each item. + * @post iotcon_list_attributes_cb() will be called for each item. * - * @see iotcon_list_state_cb() + * @see iotcon_list_attributes_cb() */ -int iotcon_list_foreach_state(iotcon_list_h list, iotcon_list_state_cb cb, void *user_data); +int iotcon_list_foreach_attributes(iotcon_list_h list, iotcon_list_attributes_cb cb, void *user_data); /** * @} diff --git a/lib/include/iotcon-lite-resource.h b/lib/include/iotcon-lite-resource.h index d351cf1..c1ee6f9 100644 --- a/lib/include/iotcon-lite-resource.h +++ b/lib/include/iotcon-lite-resource.h @@ -36,7 +36,7 @@ * This API provides that the users manages resources without request handler. * When client request by CRUD functions, internal default request handler will be invoked. * The default request handler will create response and send to client automatically. - * When updated state by iotcon_lite_resource_update_state(), changes will notify to observers. + * When updated attributes by iotcon_lite_resource_update_attributes(), changes will notify to observers. * * Example : * @code @@ -44,7 +44,7 @@ ... static iotcon_lite_resource_h _resource; -static bool _state_changed_cb(iotcon_lite_resource_h resource, iotcon_state_h state, void *user_data) +static bool _attributes_changed_cb(iotcon_lite_resource_h resource, iotcon_attributes_h attributes, void *user_data) { return true; } @@ -54,7 +54,7 @@ static void _create_light_resource() int ret; iotcon_lite_resource_h resource = NULL; iotcon_resource_types_h resource_types = NULL; - iotcon_state_h state = NULL; + iotcon_attributes_h attributes = NULL; ret = iotcon_resource_types_create(&resource_types); if (IOTCON_ERROR_NONE != ret) @@ -66,36 +66,36 @@ static void _create_light_resource() return; } - ret = iotcon_state_create(&state); + ret = iotcon_attributes_create(&attributes); if (IOTCON_ERROR_NONE != ret) { iotcon_resource_types_destroy(resource_types); return; } - ret = iotcon_state_add_bool(state, "power", true); + ret = iotcon_attributes_add_bool(attributes, "power", true); if (IOTCON_ERROR_NONE != ret) { - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_resource_types_destroy(resource_types); return; } - ret = iotcon_state_add_int(state, "brightness", 75); + ret = iotcon_attributes_add_int(attributes, "brightness", 75); if (IOTCON_ERROR_NONE != ret) { - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_resource_types_destroy(resource_types); return; } ret = iotcon_lite_resource_create("/light/1", resource_types, - IOTCON_RESOURCE_DISCOVERABLE | IOTCON_RESOURCE_OBSERVABLE, state, - _state_changed_cb, NULL, &resource); + IOTCON_RESOURCE_DISCOVERABLE | IOTCON_RESOURCE_OBSERVABLE, attributes, + _attributes_changed_cb, NULL, &resource); if (IOTCON_ERROR_NONE != ret) { - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_resource_types_destroy(resource_types); return; } - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_resource_types_destroy(resource_types); _resource = resource; @@ -104,30 +104,30 @@ static void _create_light_resource() static void _update_brightness(int brightness) { int ret; - iotcon_state_h state = NULL; - iotcon_state_h state_clone = NULL; + iotcon_attributes_h attributes = NULL; + iotcon_attributes_h attributes_clone = NULL; - ret = iotcon_lite_resource_get_state(_resource, &state); + ret = iotcon_lite_resource_get_attributes(_resource, &attributes); if (IOTCON_ERROR_NONE != ret) return; - ret = iotcon_state_clone(state, &state_clone); + ret = iotcon_attributes_clone(attributes, &attributes_clone); if (IOTCON_ERROR_NONE != ret) return; - ret = iotcon_state_add_int(state_clone, "brightness", brightness); + ret = iotcon_attributes_add_int(attributes_clone, "brightness", brightness); if (IOTCON_ERROR_NONE != ret) { - iotcon_state_destroy(state_clone); + iotcon_attributes_destroy(attributes_clone); return; } - ret = iotcon_lite_resource_update_state(_resource, state_clone); + ret = iotcon_lite_resource_update_attributes(_resource, attributes_clone); if (IOTCON_ERROR_NONE != ret) { - iotcon_state_destroy(state_clone); + iotcon_attributes_destroy(attributes_clone); return; } - iotcon_state_destroy(state_clone); + iotcon_attributes_destroy(attributes_clone); } * @endcode @@ -153,7 +153,7 @@ static void _update_brightness(int brightness) * @since_tizen 3.0 * * @param[in] resource The handle of the lite resource - * @param[in] state The state of the lite resource + * @param[in] attributes The attributes of the lite resource * @param[in] user_data The user data to pass to the function * * @pre The callback must be registered using iotcon_lite_resource_create() @@ -163,12 +163,12 @@ static void _update_brightness(int brightness) * @see iotcon_lite_resource_create() */ typedef bool (*iotcon_lite_resource_post_request_cb)(iotcon_lite_resource_h resource, - iotcon_state_h state, void *user_data); + iotcon_attributes_h attributes, void *user_data); /** * @brief Creates a lite resource handle and registers the resource in server. - * @details Registers a resource specified by @a uri_path, @a res_types, @a state which have + * @details Registers a resource specified by @a uri_path, @a res_types, @a attributes which have * @a properties in IoTCon server.\n * When client requests some operations, it send a response to client, automatically.\n * The @a policies can contain multiple policies like @@ -185,7 +185,7 @@ typedef bool (*iotcon_lite_resource_post_request_cb)(iotcon_lite_resource_h reso * @param[in] uri_path The URI path of the resource * @param[in] res_types The list of type of the resource * @param[in] policies The policies of the resource\n Set of #iotcon_resource_policy_e - * @param[in] state The state handle to set + * @param[in] attributes The attributes handle to set * @param[in] cb The callback function to add into callback list * @param[in] user_data The user data to pass to the callback function * @param[out] resource_handle The handle of the resource @@ -205,7 +205,7 @@ typedef bool (*iotcon_lite_resource_post_request_cb)(iotcon_lite_resource_h reso int iotcon_lite_resource_create(const char *uri_path, iotcon_resource_types_h res_types, uint8_t policies, - iotcon_state_h state, + iotcon_attributes_h attributes, iotcon_lite_resource_post_request_cb cb, void *user_data, iotcon_lite_resource_h *resource_handle); @@ -236,14 +236,14 @@ int iotcon_lite_resource_create(const char *uri_path, int iotcon_lite_resource_destroy(iotcon_lite_resource_h resource); /** - * @brief Updates state into the lite resource handle. + * @brief Updates attributes into the lite resource handle. * * @since_tizen 3.0 * @privlevel public * @privilege %http://tizen.org/privilege/internet * * @param[in] resource The handle of the lite resource - * @param[in] state The state handle to update + * @param[in] attributes The attributes handle to update * * @return 0 on success, otherwise a negative error value. * @retval #IOTCON_ERROR_NONE Successful @@ -254,30 +254,30 @@ int iotcon_lite_resource_destroy(iotcon_lite_resource_h resource); * * @pre iotcon_initialize() should be called to initialize. * - * @see iotcon_lite_resource_get_state() + * @see iotcon_lite_resource_get_attributes() */ -int iotcon_lite_resource_update_state(iotcon_lite_resource_h resource, - iotcon_state_h state); +int iotcon_lite_resource_update_attributes(iotcon_lite_resource_h resource, + iotcon_attributes_h attributes); /** - * @brief Gets state from the lite resource handle. + * @brief Gets attributes from the lite resource handle. * * @since_tizen 3.0 * - * @remarks @a state must not be released using iotcon_state_destroy(). + * @remarks @a attributes must not be released using iotcon_attributes_destroy(). * * @param[in] resource The handle of the lite resource - * @param[out] state The state handle of the lite resource + * @param[out] attributes The attributes handle of the lite resource * * @return 0 on success, otherwise a negative error value. * @retval #IOTCON_ERROR_NONE Successful * @retval #IOTCON_ERROR_NOT_SUPPORTED Not supported * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter * - * @see iotcon_lite_resource_update_state() + * @see iotcon_lite_resource_update_attributes() */ -int iotcon_lite_resource_get_state(iotcon_lite_resource_h resource, - iotcon_state_h *state); +int iotcon_lite_resource_get_attributes(iotcon_lite_resource_h resource, + iotcon_attributes_h *attributes); /** * @} diff --git a/lib/include/iotcon-observers.h b/lib/include/iotcon-observers.h index 934c764..dcbb7a5 100644 --- a/lib/include/iotcon-observers.h +++ b/lib/include/iotcon-observers.h @@ -53,7 +53,7 @@ static void _request_handler(iotcon_resource_h resource, iotcon_request_h reques ... if (IOTCON_REQUEST_PUT & types) { - iotcon_state_h state = NULL; + iotcon_attributes_h attributes = NULL; iotcon_representation_h repr = NULL; ... @@ -61,7 +61,7 @@ static void _request_handler(iotcon_resource_h resource, iotcon_request_h reques if (IOTCON_ERROR_NONE != ret) return; - ret = iotcon_state_create(&state); + ret = iotcon_attributes_create(&attributes); if (IOTCON_ERROR_NONE != ret) { iotcon_representation_destroy(repr); return; @@ -69,12 +69,12 @@ static void _request_handler(iotcon_resource_h resource, iotcon_request_h reques ... ret = iotcon_resource_notify(resource, repr, _observers, IOTCON_QOS_HIGH); if (IOTCON_ERROR_NONE != ret) { - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(repr); return; } - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(repr); } diff --git a/lib/include/iotcon-representation.h b/lib/include/iotcon-representation.h index f730b8c..de97f7a 100644 --- a/lib/include/iotcon-representation.h +++ b/lib/include/iotcon-representation.h @@ -89,35 +89,35 @@ return; } - ret = iotcon_state_add_str(resp_repr, "type", "lamp"); + ret = iotcon_attributes_add_str(resp_repr, "type", "lamp"); if (IOTCON_ERROR_NONE != ret) { iotcon_resource_types_destroy(types); iotcon_representation_destroy(resp_repr); return; } - ret = iotcon_state_add_str(resp_repr, "where", "desk"); + ret = iotcon_attributes_add_str(resp_repr, "where", "desk"); if (IOTCON_ERROR_NONE != ret) { iotcon_resource_types_destroy(types); iotcon_representation_destroy(resp_repr); return; } - ret = iotcon_state_add_double(resp_repr, "default_bright", 200.0); + ret = iotcon_attributes_add_double(resp_repr, "default_bright", 200.0); if (IOTCON_ERROR_NONE != ret) { iotcon_resource_types_destroy(types); iotcon_representation_destroy(resp_repr); return; } - ret = iotcon_state_add_str(resp_repr, "unit", "lux"); + ret = iotcon_attributes_add_str(resp_repr, "unit", "lux"); if (IOTCON_ERROR_NONE != ret) { iotcon_resource_types_destroy(types); iotcon_representation_destroy(resp_repr); return; } - ret = iotcon_state_add_bool(resp_repr, "bright_step", true); + ret = iotcon_attributes_add_bool(resp_repr, "bright_step", true); if (IOTCON_ERROR_NONE != ret) { iotcon_resource_types_destroy(types); iotcon_representation_destroy(resp_repr); @@ -171,7 +171,7 @@ return; } - ret = iotcon_state_add_list(resp_repr, "bright_step_list", bright_step_list); + ret = iotcon_attributes_add_list(resp_repr, "bright_step_list", bright_step_list); if (IOTCON_ERROR_NONE != ret) { iotcon_list_destroy(bright_step_list); iotcon_resource_types_destroy(types); @@ -363,12 +363,12 @@ int iotcon_representation_get_resource_interfaces(iotcon_representation_h repr, iotcon_resource_interfaces_h *ifaces); /** - * @brief Sets a new state handle into the representation. + * @brief Sets a new attributes handle into the representation. * * @since_tizen 3.0 * * @param[in] repr The representation handle - * @param[in] state The state handle to set newly + * @param[in] attributes The attributes handle to set newly * * @return 0 on success, otherwise a negative error value. * @retval #IOTCON_ERROR_NONE Successful @@ -376,24 +376,24 @@ int iotcon_representation_get_resource_interfaces(iotcon_representation_h repr, * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter */ -int iotcon_representation_set_state(iotcon_representation_h repr, iotcon_state_h state); +int iotcon_representation_set_attributes(iotcon_representation_h repr, iotcon_attributes_h attributes); /** - * @brief Gets a state handle in the representation. + * @brief Gets a attributes handle in the representation. * * @since_tizen 3.0 * - * @remarks @a state must not be released using iotcon_state_destroy(). + * @remarks @a attributes must not be released using iotcon_attributes_destroy(). * * @param[in] repr The representation handle - * @param[in] state The state handle to get + * @param[in] attributes The attributes handle to get * * @return 0 on success, otherwise a negative error value. * @retval #IOTCON_ERROR_NONE Successful * @retval #IOTCON_ERROR_NOT_SUPPORTED Not supported * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter */ -int iotcon_representation_get_state(iotcon_representation_h repr, iotcon_state_h *state); +int iotcon_representation_get_attributes(iotcon_representation_h repr, iotcon_attributes_h *attributes); /** * @brief Adds a new child representation on to the end of the parent representation. diff --git a/lib/include/iotcon-response.h b/lib/include/iotcon-response.h index 9c123e8..14898f1 100644 --- a/lib/include/iotcon-response.h +++ b/lib/include/iotcon-response.h @@ -38,9 +38,9 @@ * @code #include <iotcon.h> -static void _state_foreach(iotcon_state_h state, const char *key, void *user_data) +static void _attributes_foreach(iotcon_attributes_h attributes, const char *key, void *user_data) { - // handle state + // handle attributes ... } @@ -50,7 +50,7 @@ static void _on_get(iotcon_remote_resource_h resource, iotcon_error_e err, int ret; iotcon_response_result_e response_result; iotcon_representation_h repr = NULL; - iotcon_state_h state = NULL; + iotcon_attributes_h attributes = NULL; if (IOTCON_ERROR_NONE != err) return; @@ -66,11 +66,11 @@ static void _on_get(iotcon_remote_resource_h resource, iotcon_error_e err, if (IOTCON_ERROR_NONE != ret) return; - ret = iotcon_representation_get_state(repr, &state); + ret = iotcon_representation_get_attributes(repr, &attributes); if (IOTCON_ERROR_NONE != ret) return; - ret = iotcon_state_foreach(state, _state_foreach, NULL); + ret = iotcon_attributes_foreach(attributes, _attributes_foreach, NULL); if (IOTCON_ERROR_NONE != ret) return; @@ -91,15 +91,15 @@ static void _request_get(iotcon_remote_resource_h resource) * @code #include <iotcon.h> -static iotcon_state_h _create_state() +static iotcon_attributes_h _create_attributes() { int ret; - iotcon_state_h state = NULL; + iotcon_attributes_h attributes = NULL; - // create & set state + // create & set attributes ... - return state; + return attributes; } static void _request_handler(iotcon_resource_h resource, iotcon_request_h request, void *user_data) @@ -122,7 +122,7 @@ static void _request_handler(iotcon_resource_h resource, iotcon_request_h reques if (IOTCON_REQUEST_GET & types) { iotcon_response_h response = NULL; iotcon_representation_h repr = NULL; - iotcon_state_h state = NULL; + iotcon_attributes_h attributes = NULL; ret = iotcon_response_create(request, &response); if (IOTCON_ERROR_NONE != ret) @@ -147,7 +147,7 @@ static void _request_handler(iotcon_resource_h resource, iotcon_request_h reques return; } - ret = iotcon_representation_set_state(response, _create_state()); + ret = iotcon_representation_set_attributes(response, _create_attributes()); if (IOTCON_ERROR_NONE != ret) { iotcon_representation_destroy(repr); iotcon_response_destroy(response); diff --git a/lib/include/iotcon-types.h b/lib/include/iotcon-types.h index 194ef34..8b6983f 100644 --- a/lib/include/iotcon-types.h +++ b/lib/include/iotcon-types.h @@ -40,8 +40,8 @@ * @ref CAPI_IOT_CONNECTIVITY_COMMON_QUERY_MODULE, * @ref CAPI_IOT_CONNECTIVITY_COMMON_OPTIONS_MODULE, * @ref CAPI_IOT_CONNECTIVITY_COMMON_REPRESENTATION_MODULE, - * @ref CAPI_IOT_CONNECTIVITY_COMMON_REPRESENTATION_STATE_MODULE, - * @ref CAPI_IOT_CONNECTIVITY_COMMON_REPRESENTATION_STATE_LIST_MODULE, + * @ref CAPI_IOT_CONNECTIVITY_COMMON_REPRESENTATION_ATTRIBUTES_MODULE, + * @ref CAPI_IOT_CONNECTIVITY_COMMON_REPRESENTATION_ATTRIBUTES_LIST_MODULE, * @ref CAPI_IOT_CONNECTIVITY_COMMON_RESPONSE_MODULE. * * @{ @@ -206,16 +206,16 @@ typedef struct icl_representation_s* iotcon_representation_h; typedef struct icl_list_s* iotcon_list_h; /** - * @brief The handle of state. - * @details @a iotcon_state_h is an opaque data structure to have attribute value map. + * @brief The handle of attributes. + * @details @a iotcon_attributes_h is an opaque data structure to have attribute value map. * Attribute value map consists of a key and a value. * Datatype of the key is string and the value should be one of them #IOTCON_TYPE_INT, * #IOTCON_TYPE_BOOL, #IOTCON_TYPE_DOUBLE, #IOTCON_TYPE_STR, #IOTCON_TYPE_NULL, - * #IOTCON_TYPE_LIST and #IOTCON_TYPE_STATE + * #IOTCON_TYPE_LIST and #IOTCON_TYPE_ATTRIBUTES * * @since_tizen 3.0 */ -typedef struct icl_state_s* iotcon_state_h; +typedef struct icl_attributes_s* iotcon_attributes_h; /** * @} @@ -223,7 +223,7 @@ typedef struct icl_state_s* iotcon_state_h; #include <iotcon-list.h> #include <iotcon-query.h> -#include <iotcon-state.h> +#include <iotcon-attributes.h> #include <iotcon-options.h> #include <iotcon-representation.h> #include <iotcon-resource-types.h> diff --git a/test/iotcon-test-basic-client.c b/test/iotcon-test-basic-client.c index 2410be2..ff3a2ee 100644 --- a/test/iotcon-test-basic-client.c +++ b/test/iotcon-test-basic-client.c @@ -35,7 +35,7 @@ static void _on_observe(iotcon_remote_resource_h resource, iotcon_error_e err, int ret; bool opened; static int i = 0; - iotcon_state_h state; + iotcon_attributes_h attributes; iotcon_representation_h repr; iotcon_response_result_e response_result; @@ -58,15 +58,15 @@ static void _on_observe(iotcon_remote_resource_h resource, iotcon_error_e err, return; } - ret = iotcon_representation_get_state(repr, &state); + ret = iotcon_representation_get_attributes(repr, &attributes); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_representation_get_state() Fail(%d)", ret); + ERR("iotcon_representation_get_attributes() Fail(%d)", ret); return; } - ret = iotcon_state_get_bool(state, "opened", &opened); + ret = iotcon_attributes_get_bool(attributes, "opened", &opened); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_get_bool() Fail(%d)", ret); + ERR("iotcon_attributes_get_bool() Fail(%d)", ret); return; } @@ -116,7 +116,7 @@ static void _on_response_post(iotcon_remote_resource_h resource, iotcon_response_h response, void *user_data) { int ret; - iotcon_state_h recv_state; + iotcon_attributes_h recv_attributes; char *host, *created_uri_path; iotcon_connectivity_type_e connectivity_type; iotcon_response_result_e response_result; @@ -144,15 +144,15 @@ static void _on_response_post(iotcon_remote_resource_h resource, return; } - ret = iotcon_representation_get_state(recv_repr, &recv_state); + ret = iotcon_representation_get_attributes(recv_repr, &recv_attributes); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_representation_get_state() Fail(%d)", ret); + ERR("iotcon_representation_get_attributes() Fail(%d)", ret); return; } - ret = iotcon_state_get_str(recv_state, "createduripath", &created_uri_path); + ret = iotcon_attributes_get_str(recv_attributes, "createduripath", &created_uri_path); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_get_str() Fail(%d)", ret); + ERR("iotcon_attributes_get_str() Fail(%d)", ret); return; } DBG("New resource created : %s", created_uri_path); @@ -237,8 +237,8 @@ static void _on_response_get(iotcon_remote_resource_h resource, iotcon_response_result_e response_result; iotcon_representation_h send_repr; iotcon_representation_h recv_repr; - iotcon_state_h send_state; - iotcon_state_h recv_state = NULL; + iotcon_attributes_h send_attributes; + iotcon_attributes_h recv_attributes = NULL; ret = iotcon_response_get_result(response, &response_result); if (IOTCON_ERROR_NONE != ret) { @@ -262,15 +262,15 @@ static void _on_response_get(iotcon_remote_resource_h resource, return; } - ret = iotcon_representation_get_state(recv_repr, &recv_state); + ret = iotcon_representation_get_attributes(recv_repr, &recv_attributes); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_representation_get_state() Fail(%d)", ret); + ERR("iotcon_representation_get_attributes() Fail(%d)", ret); return; } - ret = iotcon_state_get_bool(recv_state, "opened", &opened); + ret = iotcon_attributes_get_bool(recv_attributes, "opened", &opened); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_get_bool() Fail(%d)", ret); + ERR("iotcon_attributes_get_bool() Fail(%d)", ret); return; } @@ -280,30 +280,30 @@ static void _on_response_get(iotcon_remote_resource_h resource, return; } - ret = iotcon_state_create(&send_state); + ret = iotcon_attributes_create(&send_attributes); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_create() Fail(%d)", ret); + ERR("iotcon_attributes_create() Fail(%d)", ret); iotcon_representation_destroy(send_repr); return; } - ret = iotcon_state_add_bool(send_state, "opened", !opened); + ret = iotcon_attributes_add_bool(send_attributes, "opened", !opened); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_add_bool() Fail(%d)", ret); - iotcon_state_destroy(send_state); + ERR("iotcon_attributes_add_bool() Fail(%d)", ret); + iotcon_attributes_destroy(send_attributes); iotcon_representation_destroy(send_repr); return; } - ret = iotcon_representation_set_state(send_repr, send_state); + ret = iotcon_representation_set_attributes(send_repr, send_attributes); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_representation_set_state() Fail(%d)", ret); - iotcon_state_destroy(send_state); + ERR("iotcon_representation_set_attributes() Fail(%d)", ret); + iotcon_attributes_destroy(send_attributes); iotcon_representation_destroy(send_repr); return; } - iotcon_state_destroy(send_state); + iotcon_attributes_destroy(send_attributes); /* send PUT request */ ret = iotcon_remote_resource_put(resource, send_repr, NULL, _on_response, NULL); diff --git a/test/iotcon-test-basic-server.c b/test/iotcon-test-basic-server.c index 75e5033..0a259e6 100644 --- a/test/iotcon-test-basic-server.c +++ b/test/iotcon-test-basic-server.c @@ -26,7 +26,7 @@ /* Door Resource */ typedef struct _door_resource_s { - bool state; + bool attributes; char *uri_path; char *type; iotcon_resource_interfaces_h ifaces; @@ -45,7 +45,7 @@ static int _set_door_resource(door_resource_s *door) { int ret; - door->state = false; + door->attributes = false; door->uri_path = strdup(DOOR_RESOURCE_URI); if (NULL == door->uri_path) { @@ -99,9 +99,9 @@ static void _free_door_resource(door_resource_s *door) free(door->uri_path); } -static void _check_door_state(door_resource_s door) +static void _check_door_attributes(door_resource_s door) { - if (false == door.state) + if (false == door.attributes) INFO("[Door] closed."); else INFO("[Door] opened."); @@ -183,7 +183,7 @@ static int _send_response(iotcon_request_h request, iotcon_representation_h repr static iotcon_representation_h _get_door_representation(door_resource_s *door) { int ret; - iotcon_state_h state; + iotcon_attributes_h attributes; iotcon_representation_h repr; /* create a door Representation */ @@ -193,10 +193,10 @@ static iotcon_representation_h _get_door_representation(door_resource_s *door) return NULL; } - /* create a door state */ - ret = iotcon_state_create(&state); + /* create a door attributes */ + ret = iotcon_attributes_create(&attributes); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_create() Fail(%d)", ret); + ERR("iotcon_attributes_create() Fail(%d)", ret); iotcon_representation_destroy(repr); return NULL; } @@ -204,28 +204,28 @@ static iotcon_representation_h _get_door_representation(door_resource_s *door) ret = iotcon_representation_set_uri_path(repr, door->uri_path); if (IOTCON_ERROR_NONE != ret) { ERR("iotcon_representation_set_uri_path() Fail(%d)", ret); - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(repr); return NULL; } - ret = iotcon_state_add_bool(state, "opened", door->state); + ret = iotcon_attributes_add_bool(attributes, "opened", door->attributes); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_add_bool() Fail(%d)", ret); - iotcon_state_destroy(state); + ERR("iotcon_attributes_add_bool() Fail(%d)", ret); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(repr); return NULL; } - ret = iotcon_representation_set_state(repr, state); + ret = iotcon_representation_set_attributes(repr, attributes); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_representation_set_state() Fail(%d)", ret); - iotcon_state_destroy(state); + ERR("iotcon_representation_set_attributes() Fail(%d)", ret); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(repr); return NULL; } - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); return repr; } @@ -259,21 +259,21 @@ static int _set_door_representation(door_resource_s *door, { int ret; bool bval; - iotcon_state_h state; + iotcon_attributes_h attributes; - ret = iotcon_representation_get_state(repr, &state); + ret = iotcon_representation_get_attributes(repr, &attributes); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_representation_get_state() Fail(%d)", ret); + ERR("iotcon_representation_get_attributes() Fail(%d)", ret); return -1; } - ret = iotcon_state_get_bool(state, "opened", &bval); + ret = iotcon_attributes_get_bool(attributes, "opened", &bval); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_get_bool() Fail(%d)", ret); + ERR("iotcon_attributes_get_bool() Fail(%d)", ret); return -1; } - door->state = bval; + door->attributes = bval; return 0; } @@ -296,7 +296,7 @@ static int _request_handler_put(door_resource_s *door, iotcon_request_h request) return -1; } - _check_door_state(*door); + _check_door_attributes(*door); resp_repr = _get_door_representation(door); if (NULL == resp_repr) { @@ -321,7 +321,7 @@ static int _request_handler_put(door_resource_s *door, iotcon_request_h request) return 0; } -static gboolean _door_state_changer(gpointer user_data) +static gboolean _door_attributes_changer(gpointer user_data) { int ret; static int i = 0; @@ -331,11 +331,11 @@ static gboolean _door_state_changer(gpointer user_data) if ((5 == i++) || NULL == door->observers) return G_SOURCE_REMOVE; - if (false == door->state) { - door->state = true; + if (false == door->attributes) { + door->attributes = true; INFO("[Door] closed -> opened"); } else { - door->state = false; + door->attributes = false; INFO("[Door] opened -> closed"); } @@ -361,7 +361,7 @@ static gboolean _door_state_changer(gpointer user_data) static int _request_handler_post(door_resource_s *door, iotcon_request_h request) { int ret; - iotcon_state_h resp_state; + iotcon_attributes_h resp_attributes; iotcon_representation_h resp_repr = NULL; iotcon_resource_h new_door_handle; INFO("POST request"); @@ -386,30 +386,30 @@ static int _request_handler_post(door_resource_s *door, iotcon_request_h request return -1; } - ret = iotcon_state_create(&resp_state); + ret = iotcon_attributes_create(&resp_attributes); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_create() Fail(%d)", ret); + ERR("iotcon_attributes_create() Fail(%d)", ret); iotcon_representation_destroy(resp_repr); return -1; } - ret = iotcon_state_add_str(resp_state, "createduripath", DOOR_RESOURCE_URI2); + ret = iotcon_attributes_add_str(resp_attributes, "createduripath", DOOR_RESOURCE_URI2); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_add_str() Fail(%d)", ret); - iotcon_state_destroy(resp_state); + ERR("iotcon_attributes_add_str() Fail(%d)", ret); + iotcon_attributes_destroy(resp_attributes); iotcon_representation_destroy(resp_repr); return -1; } - ret = iotcon_representation_set_state(resp_repr, resp_state); + ret = iotcon_representation_set_attributes(resp_repr, resp_attributes); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_representation_set_state() Fail(%d)", ret); - iotcon_state_destroy(resp_state); + ERR("iotcon_representation_set_attributes() Fail(%d)", ret); + iotcon_attributes_destroy(resp_attributes); iotcon_representation_destroy(resp_repr); return -1; } - iotcon_state_destroy(resp_state); + iotcon_attributes_destroy(resp_attributes); ret = _send_response(request, resp_repr, IOTCON_RESPONSE_RESOURCE_CREATED); if (0 != ret) { @@ -602,10 +602,10 @@ int main(int argc, char **argv) return -1; } - _check_door_state(my_door); + _check_door_attributes(my_door); /* add observe */ - g_timeout_add_seconds(5, _door_state_changer, &my_door); + g_timeout_add_seconds(5, _door_attributes_changer, &my_door); g_main_loop_run(loop); g_main_loop_unref(loop); diff --git a/test/iotcon-test-encap-client.c b/test/iotcon-test-encap-client.c index 687352c..5bda770 100644 --- a/test/iotcon-test-encap-client.c +++ b/test/iotcon-test-encap-client.c @@ -70,19 +70,19 @@ static void _representation_changed_cb(iotcon_remote_resource_h resource, { int ret; bool opened; - iotcon_state_h state; + iotcon_attributes_h attributes; INFO("Resource is cached"); - ret = iotcon_representation_get_state(representation, &state); + ret = iotcon_representation_get_attributes(representation, &attributes); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_representation_get_state() Fail(%d)", ret); + ERR("iotcon_representation_get_attributes() Fail(%d)", ret); return; } - ret = iotcon_state_get_bool(state, "opened", &opened); + ret = iotcon_attributes_get_bool(attributes, "opened", &opened); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_get_bool() Fail(%d)", ret); + ERR("iotcon_attributes_get_bool() Fail(%d)", ret); return; } diff --git a/test/iotcon-test-encap-server.c b/test/iotcon-test-encap-server.c index 30cdd2a..df18804 100644 --- a/test/iotcon-test-encap-server.c +++ b/test/iotcon-test-encap-server.c @@ -60,7 +60,7 @@ static void _free_door_resource(door_resource_s *door) free(door->uri_path); } -static void _check_door_state(door_resource_s door) +static void _check_door_attributes(door_resource_s door) { if (false == door.state) INFO("[Door] closed."); @@ -68,21 +68,21 @@ static void _check_door_state(door_resource_s door) INFO("[Door] opened."); } -static gboolean _door_state_changer(gpointer user_data) +static gboolean _door_attributes_changer(gpointer user_data) { int ret; door_resource_s *door = user_data; - iotcon_state_h recv_state, send_state; + iotcon_attributes_h recv_attributes, send_attributes; - ret = iotcon_lite_resource_get_state(door->handle, &recv_state); + ret = iotcon_lite_resource_get_attributes(door->handle, &recv_attributes); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_lite_resource_get_state() Fail(%d)", ret); + ERR("iotcon_lite_resource_get_attributes() Fail(%d)", ret); return G_SOURCE_CONTINUE; } - ret = iotcon_state_get_bool(recv_state, "opened", &(door->state)); + ret = iotcon_attributes_get_bool(recv_attributes, "opened", &(door->state)); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_get_bool() Fail(%d)", ret); + ERR("iotcon_attributes_get_bool() Fail(%d)", ret); return G_SOURCE_CONTINUE; } @@ -91,43 +91,43 @@ static gboolean _door_state_changer(gpointer user_data) else door->state = true; - ret = iotcon_state_create(&send_state); + ret = iotcon_attributes_create(&send_attributes); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_create() Fail(%d)", ret); + ERR("iotcon_attributes_create() Fail(%d)", ret); return G_SOURCE_CONTINUE; } - ret = iotcon_state_add_bool(send_state, "opened", door->state); + ret = iotcon_attributes_add_bool(send_attributes, "opened", door->state); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_add_bool() Fail(%d)", ret); - iotcon_state_destroy(send_state); + ERR("iotcon_attributes_add_bool() Fail(%d)", ret); + iotcon_attributes_destroy(send_attributes); return G_SOURCE_CONTINUE; } - ret = iotcon_lite_resource_update_state(door->handle, send_state); + ret = iotcon_lite_resource_update_attributes(door->handle, send_attributes); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_lite_resource_update_state() Fail(%d)", ret); - iotcon_state_destroy(send_state); + ERR("iotcon_lite_resource_update_attributes() Fail(%d)", ret); + iotcon_attributes_destroy(send_attributes); return G_SOURCE_CONTINUE; } - iotcon_state_destroy(send_state); + iotcon_attributes_destroy(send_attributes); - _check_door_state(*door); + _check_door_attributes(*door); return G_SOURCE_CONTINUE; } -static bool _door_state_changed(iotcon_lite_resource_h resource, - iotcon_state_h state, void *user_data) +static bool _door_attributes_changed(iotcon_lite_resource_h resource, + iotcon_attributes_h attributes, void *user_data) { FN_CALL; bool opened; int ret; - ret = iotcon_state_get_bool(state, "opened", &opened); + ret = iotcon_attributes_get_bool(attributes, "opened", &opened); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_get_bool() Fail(%d)", ret); + ERR("iotcon_attributes_get_bool() Fail(%d)", ret); return false; } DBG("opened: %d", opened); @@ -139,7 +139,7 @@ static iotcon_lite_resource_h _create_door_resource(char *uri_path, char *type, uint8_t policies, void *user_data) { int ret; - iotcon_state_h state; + iotcon_attributes_h attributes; iotcon_lite_resource_h handle; iotcon_resource_types_h resource_types; @@ -156,32 +156,32 @@ static iotcon_lite_resource_h _create_door_resource(char *uri_path, char *type, return NULL; } - ret = iotcon_state_create(&state); + ret = iotcon_attributes_create(&attributes); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_create() Fail(%d)", ret); + ERR("iotcon_attributes_create() Fail(%d)", ret); iotcon_resource_types_destroy(resource_types); return NULL; } - ret = iotcon_state_add_bool(state, "opened", false); + ret = iotcon_attributes_add_bool(attributes, "opened", false); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_add_bool() Fail(%d)", ret); - iotcon_state_destroy(state); + ERR("iotcon_attributes_add_bool() Fail(%d)", ret); + iotcon_attributes_destroy(attributes); iotcon_resource_types_destroy(resource_types); return NULL; } /* register door resource */ - ret = iotcon_lite_resource_create(uri_path, resource_types, policies, state, - _door_state_changed, NULL, &handle); + ret = iotcon_lite_resource_create(uri_path, resource_types, policies, attributes, + _door_attributes_changed, NULL, &handle); if (IOTCON_ERROR_NONE != ret) { ERR("iotcon_lite_resource_create() Fail"); - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_resource_types_destroy(resource_types); return NULL; } - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_resource_types_destroy(resource_types); return handle; @@ -232,9 +232,9 @@ int main(int argc, char **argv) return -1; } - _check_door_state(my_door); + _check_door_attributes(my_door); - g_timeout_add_seconds(7, _door_state_changer, &my_door); + g_timeout_add_seconds(7, _door_attributes_changer, &my_door); g_main_loop_run(loop); g_main_loop_unref(loop); diff --git a/test/iotcon-test-iface-client.c b/test/iotcon-test-iface-client.c index 02c1192..ef34e29 100644 --- a/test/iotcon-test-iface-client.c +++ b/test/iotcon-test-iface-client.c @@ -42,7 +42,7 @@ static void _print_repr(iotcon_representation_h recv_repr) char *uri_path, *str_val; iotcon_list_h list_val; iotcon_representation_h child_repr; - iotcon_state_h recv_state, child_state; + iotcon_attributes_h recv_attributes, child_attributes; unsigned int key_count, children_count; INFO("GET request was successful"); @@ -55,29 +55,29 @@ static void _print_repr(iotcon_representation_h recv_repr) } DBG("uri_path : %s", uri_path); - ret = iotcon_representation_get_state(recv_repr, &recv_state); + ret = iotcon_representation_get_attributes(recv_repr, &recv_attributes); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_representation_get_state() Fail(%d)", ret); + ERR("iotcon_representation_get_attributes() Fail(%d)", ret); return; } - ret = iotcon_state_get_keys_count(recv_state, &key_count); + ret = iotcon_attributes_get_keys_count(recv_attributes, &key_count); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_get_keys_count() Fail(%d)", ret); + ERR("iotcon_attributes_get_keys_count() Fail(%d)", ret); return; } if (key_count) { - ret = iotcon_state_get_str(recv_state, "name", &str_val); + ret = iotcon_attributes_get_str(recv_attributes, "name", &str_val); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_get_str() Fail(%d)", ret); + ERR("iotcon_attributes_get_str() Fail(%d)", ret); return; } DBG("name : %s", str_val); - ret = iotcon_state_get_list(recv_state, "today_temp", &list_val); + ret = iotcon_attributes_get_list(recv_attributes, "today_temp", &list_val); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_get_list() Fail(%d)", ret); + ERR("iotcon_attributes_get_list() Fail(%d)", ret); return; } @@ -88,9 +88,9 @@ static void _print_repr(iotcon_representation_h recv_repr) return; } - ret = iotcon_state_is_null(recv_state, "null value", &is_null); + ret = iotcon_attributes_is_null(recv_attributes, "null value", &is_null); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_is_null() Fail(%d)", ret); + ERR("iotcon_attributes_is_null() Fail(%d)", ret); return; } @@ -120,39 +120,39 @@ static void _print_repr(iotcon_representation_h recv_repr) } DBG("uri_path : %s", uri_path); - ret = iotcon_representation_get_state(child_repr, &child_state); + ret = iotcon_representation_get_attributes(child_repr, &child_attributes); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_representation_get_state() Fail(%d)", ret); + ERR("iotcon_representation_get_attributes() Fail(%d)", ret); continue; } if (TEST_STR_EQUAL == strncmp(LIGHT_RESOURCE_URI_PREFIX, uri_path, strlen(LIGHT_RESOURCE_URI_PREFIX))) { - ret = iotcon_state_get_keys_count(child_state, &key_count); + ret = iotcon_attributes_get_keys_count(child_attributes, &key_count); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_get_keys_count() Fail(%d)", ret); + ERR("iotcon_attributes_get_keys_count() Fail(%d)", ret); continue; } if (key_count) { - ret = iotcon_state_get_int(child_state, "brightness", &int_val); + ret = iotcon_attributes_get_int(child_attributes, "brightness", &int_val); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_get_int() Fail(%d)", ret); + ERR("iotcon_attributes_get_int() Fail(%d)", ret); continue; } DBG("brightness : %d", int_val); } } else if (TEST_STR_EQUAL == strncmp(FAN_RESOURCE_URI_PREFIX, uri_path, strlen(FAN_RESOURCE_URI_PREFIX))) { - ret = iotcon_state_get_keys_count(child_state, &key_count); + ret = iotcon_attributes_get_keys_count(child_attributes, &key_count); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_get_keys_count() Fail(%d)", ret); + ERR("iotcon_attributes_get_keys_count() Fail(%d)", ret); continue; } if (key_count) { - ret = iotcon_state_get_bool(child_state, "state", &bool_val); + ret = iotcon_attributes_get_bool(child_attributes, "state", &bool_val); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_get_bool() Fail(%d)", ret); + ERR("iotcon_attributes_get_bool() Fail(%d)", ret); continue; } DBG("state : %d", bool_val); diff --git a/test/iotcon-test-iface-server.c b/test/iotcon-test-iface-server.c index 9354b63..90c737e 100644 --- a/test/iotcon-test-iface-server.c +++ b/test/iotcon-test-iface-server.c @@ -308,7 +308,7 @@ static int _send_response(iotcon_request_h request, iotcon_representation_h repr static iotcon_representation_h _get_light_representation(light_resource_s *light) { int ret; - iotcon_state_h state; + iotcon_attributes_h attributes; iotcon_representation_h repr; /* create a light Representation */ @@ -325,32 +325,32 @@ static iotcon_representation_h _get_light_representation(light_resource_s *light return NULL; } - /* create a light state */ - ret = iotcon_state_create(&state); + /* create a light attributes */ + ret = iotcon_attributes_create(&attributes); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_create() Fail(%d)", ret); + ERR("iotcon_attributes_create() Fail(%d)", ret); iotcon_representation_destroy(repr); return NULL; } - ret = iotcon_state_add_int(state, "brightness", light->brightness); + ret = iotcon_attributes_add_int(attributes, "brightness", light->brightness); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_add_int() Fail(%d)", ret); - iotcon_state_destroy(state); + ERR("iotcon_attributes_add_int() Fail(%d)", ret); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(repr); return NULL; } - /* Set a light state into light Representation */ - ret = iotcon_representation_set_state(repr, state); + /* Set a light attributes into light Representation */ + ret = iotcon_representation_set_attributes(repr, attributes); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_representation_set_state() Fail(%d)", ret); - iotcon_state_destroy(state); + ERR("iotcon_representation_set_attributes() Fail(%d)", ret); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(repr); return NULL; } - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); return repr; } @@ -385,7 +385,7 @@ static int _light_request_handler_get(light_resource_s *light, static iotcon_representation_h _get_fan_representation(fan_resource_s *fan) { int ret; - iotcon_state_h state; + iotcon_attributes_h attributes; iotcon_representation_h repr; /* create a fan Representation */ @@ -402,32 +402,32 @@ static iotcon_representation_h _get_fan_representation(fan_resource_s *fan) return NULL; } - /* create a fan state */ - ret = iotcon_state_create(&state); + /* create a fan attributes */ + ret = iotcon_attributes_create(&attributes); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_create() Fail(%d)", ret); + ERR("iotcon_attributes_create() Fail(%d)", ret); iotcon_representation_destroy(repr); return NULL; } - ret = iotcon_state_add_bool(state, "state", fan->state); + ret = iotcon_attributes_add_bool(attributes, "attributes", fan->state); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_add_bool() Fail(%d)", ret); - iotcon_state_destroy(state); + ERR("iotcon_attributes_add_bool() Fail(%d)", ret); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(repr); return NULL; } - /* Set a light state into light Representation */ - ret = iotcon_representation_set_state(repr, state); + /* Set a light attributes into light Representation */ + ret = iotcon_representation_set_attributes(repr, attributes); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_representation_set_state() Fail(%d)", ret); - iotcon_state_destroy(state); + ERR("iotcon_representation_set_attributes() Fail(%d)", ret); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(repr); return NULL; } - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); return repr; } @@ -460,7 +460,7 @@ static int _fan_request_handler_get(fan_resource_s *fan, iotcon_request_h reques static iotcon_representation_h _get_room_representation(room_resource_s *room) { int ret; - iotcon_state_h state; + iotcon_attributes_h attributes; iotcon_list_h today_temp; iotcon_representation_h repr, light_repr, fan_repr; @@ -478,27 +478,27 @@ static iotcon_representation_h _get_room_representation(room_resource_s *room) return NULL; } - /* create a room state */ - ret = iotcon_state_create(&state); + /* create a room attributes */ + ret = iotcon_attributes_create(&attributes); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_create() Fail(%d)", ret); + ERR("iotcon_attributes_create() Fail(%d)", ret); iotcon_representation_destroy(repr); return NULL; } - ret = iotcon_state_add_str(state, "name", room->name); + ret = iotcon_attributes_add_str(attributes, "name", room->name); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_add_str() Fail(%d)", ret); - iotcon_state_destroy(state); + ERR("iotcon_attributes_add_str() Fail(%d)", ret); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(repr); return NULL; } /* set null */ - ret = iotcon_state_add_null(state, "null value"); + ret = iotcon_attributes_add_null(attributes, "null value"); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_add_null() Fail(%d)", ret); - iotcon_state_destroy(state); + ERR("iotcon_attributes_add_null() Fail(%d)", ret); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(repr); return NULL; } @@ -506,7 +506,7 @@ static iotcon_representation_h _get_room_representation(room_resource_s *room) ret = iotcon_list_create(IOTCON_TYPE_INT, &today_temp); if (IOTCON_ERROR_NONE != ret) { ERR("iotcon_list_create() Fail(%d)", ret); - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(repr); return NULL; } @@ -515,7 +515,7 @@ static iotcon_representation_h _get_room_representation(room_resource_s *room) if (IOTCON_ERROR_NONE != ret) { ERR("iotcon_list_add_int() Fail(%d)", ret); iotcon_list_destroy(today_temp); - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(repr); return NULL; } @@ -524,7 +524,7 @@ static iotcon_representation_h _get_room_representation(room_resource_s *room) if (IOTCON_ERROR_NONE != ret) { ERR("iotcon_list_add_int() Fail(%d)", ret); iotcon_list_destroy(today_temp); - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(repr); return NULL; } @@ -533,7 +533,7 @@ static iotcon_representation_h _get_room_representation(room_resource_s *room) if (IOTCON_ERROR_NONE != ret) { ERR("iotcon_list_add_int() Fail(%d)", ret); iotcon_list_destroy(today_temp); - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(repr); return NULL; } @@ -542,7 +542,7 @@ static iotcon_representation_h _get_room_representation(room_resource_s *room) if (IOTCON_ERROR_NONE != ret) { ERR("iotcon_list_add_int() Fail(%d)", ret); iotcon_list_destroy(today_temp); - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(repr); return NULL; } @@ -551,32 +551,32 @@ static iotcon_representation_h _get_room_representation(room_resource_s *room) if (IOTCON_ERROR_NONE != ret) { ERR("iotcon_list_add_int() Fail(%d)", ret); iotcon_list_destroy(today_temp); - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(repr); return NULL; } - ret = iotcon_state_add_list(state, "today_temp", today_temp); + ret = iotcon_attributes_add_list(attributes, "today_temp", today_temp); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_state_add_list() Fail(%d)", ret); + ERR("iotcon_attributes_add_list() Fail(%d)", ret); iotcon_list_destroy(today_temp); - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(repr); return NULL; } iotcon_list_destroy(today_temp); - /* Set a room state into room Representation */ - ret = iotcon_representation_set_state(repr, state); + /* Set a room attributes into room Representation */ + ret = iotcon_representation_set_attributes(repr, attributes); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_representation_set_state() Fail(%d)", ret); - iotcon_state_destroy(state); + ERR("iotcon_representation_set_attributes() Fail(%d)", ret); + iotcon_attributes_destroy(attributes); iotcon_representation_destroy(repr); return NULL; } - iotcon_state_destroy(state); + iotcon_attributes_destroy(attributes); light_repr = _get_light_representation(room->child_light); if (NULL == light_repr) { |