code refactoring 26/112626/3
authorJooseok Park <jooseok.park@samsung.com>
Thu, 2 Feb 2017 04:42:00 +0000 (13:42 +0900)
committerJooseok Park <jooseok.park@samsung.com>
Mon, 6 Feb 2017 11:28:27 +0000 (20:28 +0900)
 - separate api layer not to use internally
 - fix potential memory leak

patchset 1:
 - iotcon
 - iotcon-atrribtues
 - iotcon-device
 - iotcon-lite
 - iotcon-lite-resource

patchset 2:
 - iotcon-observer
 - iotcon-options
 - iotcon-presence
 - iotcon-provisiong
 - iotcon-query
 - iotcon-remote-resource
 - iotcon-remote-resource-crud
 - iotcon-representation
 - iotcon-request

patchset 3:
 - iotcon-resource
 - iotcon-resource-interfaces
 - iotcon-resource-types
 - iotcon-response-types
 - iotcon-response

Change-Id: I84256c194a1b9d5ccf9c792832d46c3fd0865785

66 files changed:
include/iotcon-response.h
packaging/iotcon.spec
src/ic-attributes.c
src/ic-attributes.h
src/ic-device.c [deleted file]
src/ic-ioty-ocprocess.c
src/ic-ioty-parse.c
src/ic-ioty.c
src/ic-list.c
src/ic-list.h
src/ic-lite-resource.c [deleted file]
src/ic-log.h
src/ic-observation.c [deleted file]
src/ic-observation.h [deleted file]
src/ic-observers.c [new file with mode: 0644]
src/ic-observers.h [new file with mode: 0644]
src/ic-options.c
src/ic-options.h
src/ic-presence.c [deleted file]
src/ic-provisioning-find.c
src/ic-provisioning-remove.c
src/ic-provisioning-struct.c
src/ic-provisioning-struct.h
src/ic-provisioning.c
src/ic-provisioning.h [new file with mode: 0644]
src/ic-query.c
src/ic-query.h
src/ic-remote-resource-caching.c [deleted file]
src/ic-remote-resource-crud.c [deleted file]
src/ic-remote-resource-monitoring.c [deleted file]
src/ic-remote-resource.c
src/ic-remote-resource.h
src/ic-representation.c
src/ic-representation.h
src/ic-request.c [deleted file]
src/ic-resource-interfaces.c
src/ic-resource-interfaces.h
src/ic-resource-types.c
src/ic-resource-types.h
src/ic-resource.c
src/ic-response.c
src/ic-response.h
src/ic-types.c
src/ic-utils.c
src/ic-value.c
src/ic.c
src/ic.h
src/iotcon-attributes.c [new file with mode: 0644]
src/iotcon-device.c [new file with mode: 0644]
src/iotcon-list.c [new file with mode: 0644]
src/iotcon-lite-resource.c [new file with mode: 0644]
src/iotcon-observers.c [new file with mode: 0644]
src/iotcon-options.c [new file with mode: 0644]
src/iotcon-presence.c [new file with mode: 0644]
src/iotcon-provisioning-struct.c [new file with mode: 0644]
src/iotcon-provisioning.c [new file with mode: 0644]
src/iotcon-query.c [new file with mode: 0644]
src/iotcon-remote-resource-crud.c [new file with mode: 0644]
src/iotcon-remote-resource.c [new file with mode: 0644]
src/iotcon-representation.c [new file with mode: 0644]
src/iotcon-request.c [new file with mode: 0644]
src/iotcon-resource-interfaces.c [new file with mode: 0644]
src/iotcon-resource-types.c [new file with mode: 0644]
src/iotcon-resource.c [new file with mode: 0644]
src/iotcon-response.c [new file with mode: 0644]
src/iotcon.c [new file with mode: 0644]

index 47344e2a8de62fc104d9cd82a30da4db16faeb56..78d93c329466f6bcde3131ffda37b6ad799a4d5c 100644 (file)
@@ -39,7 +39,7 @@
  * @code
 #include <iotcon.h>
 
-static void _attributes_foreach(iotcon_attributes_h attributes, const char *key, void *user_data)
+static bool _attributes_foreach(iotcon_attributes_h attributes, const char *key, void *user_data)
 {
        // handle attributes
        ...
index 852d74c629a99c08601e61710837bb76622afb15..6e9dbe9a79de02d8814e3e22f1e7558d7997a937 100644 (file)
@@ -1,6 +1,6 @@
 Name:       iotcon
 Summary:    Tizen IoT Connectivity
-Version:    0.3.12
+Version:    0.3.13
 Release:    0
 Group:      Network & Connectivity/Service
 License:    Apache-2.0
index 47d500ebb7357dbf447ff4b8b8f02858c8636d1a..9b400079a6b8f44af77364c5847ff77d57b799a0 100644 (file)
@@ -34,13 +34,11 @@ iotcon_attributes_h icl_attributes_ref(iotcon_attributes_h attributes)
        return attributes;
 }
 
-
-API int iotcon_attributes_create(iotcon_attributes_h *ret_attributes)
+int icl_attributes_create(iotcon_attributes_h *ret_attributes)
 {
        FN_CALL;
-       iotcon_attributes_h attributes;
+       iotcon_attributes_h attributes = NULL;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == ret_attributes, IOTCON_ERROR_INVALID_PARAMETER);
 
        attributes = calloc(1, sizeof(struct icl_attributes_s));
@@ -58,17 +56,17 @@ API int iotcon_attributes_create(iotcon_attributes_h *ret_attributes)
        return IOTCON_ERROR_NONE;
 }
 
-
-API int iotcon_attributes_destroy(iotcon_attributes_h attributes)
+int icl_attributes_destroy(iotcon_attributes_h attributes)
 {
        FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER);
 
        attributes->ref_count--;
 
-       if (0 != attributes->ref_count)
+       if (0 != attributes->ref_count) {
+               WARN("already destroyed!!");
                return IOTCON_ERROR_NONE;
+       }
 
        g_hash_table_destroy(attributes->hash_table);
        free(attributes);
@@ -76,68 +74,11 @@ API int iotcon_attributes_destroy(iotcon_attributes_h attributes)
        return IOTCON_ERROR_NONE;
 }
 
-
-API int iotcon_attributes_remove(iotcon_attributes_h attributes, const char *key)
-{
-       FN_CALL;
-       gboolean ret = FALSE;
-       iotcon_value_h value = NULL;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
-
-       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(attributes->hash_table, key);
-       if (FALSE == ret) {
-               ERR("g_hash_table_remove(%s) Fail", key);
-               return IOTCON_ERROR_NO_DATA;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_attributes_get_int(iotcon_attributes_h attributes, const char *key,
-               int *val)
-{
-       FN_CALL;
-       iotcon_value_h value;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       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(attributes->hash_table, key);
-       if (NULL == value) {
-               ERR("g_hash_table_lookup() Fail");
-               return IOTCON_ERROR_NO_DATA;
-       }
-
-       icl_basic_s *real = (icl_basic_s*)value;
-       if (IOTCON_TYPE_INT != real->type) {
-               ERR("Invalid Type(%d)", real->type);
-               return IOTCON_ERROR_INVALID_TYPE;
-       }
-
-       *val = real->val.i;
-
-       return IOTCON_ERROR_NONE;
-}
-
-API int iotcon_attributes_add_int(iotcon_attributes_h attributes, const char *key,
-               int val)
+int icl_attributes_add_int(iotcon_attributes_h attributes, const char *key, int val)
 {
        FN_CALL;
        iotcon_value_h value;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
 
@@ -152,42 +93,11 @@ API int iotcon_attributes_add_int(iotcon_attributes_h attributes, const char *ke
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_attributes_get_bool(iotcon_attributes_h attributes, const char *key,
-               bool *val)
-{
-       FN_CALL;
-       icl_basic_s *real = NULL;
-       iotcon_value_h value = NULL;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       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(attributes->hash_table, key);
-       if (NULL == value) {
-               ERR("g_hash_table_lookup() Fail");
-               return IOTCON_ERROR_NO_DATA;
-       }
-
-       real = (icl_basic_s*)value;
-       if (IOTCON_TYPE_BOOL != real->type) {
-               ERR("Invalid Type(%d)", real->type);
-               return IOTCON_ERROR_INVALID_TYPE;
-       }
-
-       *val = real->val.b;
-
-       return IOTCON_ERROR_NONE;
-}
-
-API int iotcon_attributes_add_bool(iotcon_attributes_h attributes, const char *key,
-               bool val)
+int icl_attributes_add_bool(iotcon_attributes_h attributes, const char *key, bool val)
 {
        FN_CALL;
        iotcon_value_h value = NULL;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
 
@@ -202,42 +112,11 @@ API int iotcon_attributes_add_bool(iotcon_attributes_h attributes, const char *k
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_attributes_get_double(iotcon_attributes_h attributes,
-               const char *key, double *val)
+int icl_attributes_add_double(iotcon_attributes_h attributes, const char *key, double val)
 {
        FN_CALL;
-       icl_basic_s *real = NULL;
        iotcon_value_h value = NULL;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       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(attributes->hash_table, key);
-       if (NULL == value) {
-               ERR("g_hash_table_lookup() Fail");
-               return IOTCON_ERROR_NO_DATA;
-       }
-
-       real = (icl_basic_s*)value;
-       if (IOTCON_TYPE_DOUBLE != real->type) {
-               ERR("Invalid Type(%d)", real->type);
-               return IOTCON_ERROR_INVALID_TYPE;
-       }
-
-       *val = real->val.d;
-
-       return IOTCON_ERROR_NONE;
-}
-
-API int iotcon_attributes_add_double(iotcon_attributes_h attributes,
-               const char *key, double val)
-{
-       FN_CALL;
-       iotcon_value_h value = NULL;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
 
@@ -252,42 +131,11 @@ API int iotcon_attributes_add_double(iotcon_attributes_h attributes,
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_attributes_get_str(iotcon_attributes_h attributes, const char *key,
-               char **val)
-{
-       FN_CALL;
-       icl_basic_s *real = NULL;
-       iotcon_value_h value = NULL;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       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(attributes->hash_table, key);
-       if (NULL == value) {
-               ERR("g_hash_table_lookup() Fail");
-               return IOTCON_ERROR_NO_DATA;
-       }
-
-       real = (icl_basic_s*)value;
-       if (IOTCON_TYPE_STR != real->type) {
-               ERR("Invalid Type(%d)", real->type);
-               return IOTCON_ERROR_INVALID_TYPE;
-       }
-
-       *val = real->val.s;
-
-       return IOTCON_ERROR_NONE;
-}
-
-API int iotcon_attributes_add_str(iotcon_attributes_h attributes, const char *key,
-               char *val)
+int icl_attributes_add_str(iotcon_attributes_h attributes, const char *key, char *val)
 {
        FN_CALL;
        iotcon_value_h value = NULL;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER);
@@ -303,44 +151,11 @@ API int iotcon_attributes_add_str(iotcon_attributes_h attributes, const char *ke
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_attributes_get_byte_str(iotcon_attributes_h attributes, const char *key,
-               unsigned char **val, int *len)
-{
-       FN_CALL;
-       iotcon_value_h value = NULL;
-       icl_val_byte_str_s *real = NULL;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       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(attributes->hash_table, key);
-       if (NULL == value) {
-               ERR("g_hash_table_lookup() Fail");
-               return IOTCON_ERROR_NO_DATA;
-       }
-
-       real = (icl_val_byte_str_s*)value;
-       if (IOTCON_TYPE_BYTE_STR != real->type) {
-               ERR("Invalid Type(%d)", real->type);
-               return IOTCON_ERROR_INVALID_TYPE;
-       }
-
-       *val = real->s;
-       *len = real->len;
-
-       return IOTCON_ERROR_NONE;
-}
-
-API int iotcon_attributes_add_byte_str(iotcon_attributes_h attributes,
-               const char *key, unsigned char *val, int len)
+int icl_attributes_add_byte_str(iotcon_attributes_h attributes, const char *key, unsigned char *val, int len)
 {
        FN_CALL;
        iotcon_value_h value = NULL;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER);
@@ -357,36 +172,11 @@ API int iotcon_attributes_add_byte_str(iotcon_attributes_h attributes,
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_attributes_is_null(iotcon_attributes_h attributes, const char *key,
-               bool *is_null)
+int icl_attributes_add_null(iotcon_attributes_h attributes, const char *key)
 {
        FN_CALL;
-       icl_basic_s *real = NULL;
        iotcon_value_h value = NULL;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       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(attributes->hash_table, key);
-       if (NULL == value) {
-               ERR("g_hash_table_lookup() Fail");
-               return IOTCON_ERROR_NO_DATA;
-       }
-
-       real = (icl_basic_s*)value;
-       *is_null = (IOTCON_TYPE_NULL == real->type) ? true : false;
-
-       return IOTCON_ERROR_NONE;
-}
-
-API int iotcon_attributes_add_null(iotcon_attributes_h attributes, const char *key)
-{
-       FN_CALL;
-       iotcon_value_h value = NULL;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
 
@@ -401,42 +191,11 @@ API int iotcon_attributes_add_null(iotcon_attributes_h attributes, const char *k
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_attributes_get_list(iotcon_attributes_h attributes, const char *key,
-               iotcon_list_h *list)
-{
-       FN_CALL;
-       iotcon_value_h value = NULL;
-       icl_val_list_s *real = NULL;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       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(attributes->hash_table, key);
-       if (NULL == value) {
-               ERR("g_hash_table_lookup() Fail");
-               return IOTCON_ERROR_NO_DATA;
-       }
-
-       real = (icl_val_list_s*)value;
-       if (IOTCON_TYPE_LIST != real->type) {
-               ERR("Invalid Type(%d)", real->type);
-               return IOTCON_ERROR_INVALID_TYPE;
-       }
-
-       *list = real->list;
-
-       return IOTCON_ERROR_NONE;
-}
-
-API int iotcon_attributes_add_list(iotcon_attributes_h attributes, const char *key,
-               iotcon_list_h list)
+int icl_attributes_add_list(iotcon_attributes_h attributes, const char *key, iotcon_list_h list)
 {
        FN_CALL;
        iotcon_value_h value = NULL;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
@@ -453,42 +212,11 @@ API int iotcon_attributes_add_list(iotcon_attributes_h attributes, const char *k
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_attributes_get_attributes(iotcon_attributes_h src, const char *key,
-               iotcon_attributes_h *dest)
-{
-       FN_CALL;
-       icl_val_attributes_s *real = NULL;
-       iotcon_value_h value = NULL;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == src, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == dest, IOTCON_ERROR_INVALID_PARAMETER);
-
-       value = g_hash_table_lookup(src->hash_table, key);
-       if (NULL == value) {
-               ERR("g_hash_table_lookup() Fail");
-               return IOTCON_ERROR_NO_DATA;
-       }
-
-       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->attributes;
-
-       return IOTCON_ERROR_NONE;
-}
-
-API int iotcon_attributes_add_attributes(iotcon_attributes_h attributes,
-               const char *key, iotcon_attributes_h val)
+int icl_attributes_add_attributes(iotcon_attributes_h attributes, const char *key, iotcon_attributes_h val)
 {
        FN_CALL;
        iotcon_value_h value = NULL;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER);
@@ -504,29 +232,7 @@ API int iotcon_attributes_add_attributes(iotcon_attributes_h attributes,
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_attributes_get_type(iotcon_attributes_h attributes, const char *key,
-               iotcon_type_e *type)
-{
-       FN_CALL;
-       iotcon_value_h value = NULL;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       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(attributes->hash_table, key);
-       if (NULL == value) {
-               ERR("g_hash_table_lookup() Fail");
-               return IOTCON_ERROR_NO_DATA;
-       }
-       *type = value->type;
-
-       return IOTCON_ERROR_NONE;
-}
-
-int icl_attributes_set_value(iotcon_attributes_h attributes, const char *key,
-               iotcon_value_h value)
+static int _icl_attributes_set_value(iotcon_attributes_h attributes, const char *key, iotcon_value_h value)
 {
        FN_CALL;
        RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER);
@@ -538,42 +244,35 @@ int icl_attributes_set_value(iotcon_attributes_h attributes, const char *key,
        return IOTCON_ERROR_NONE;
 }
 
-
-API int iotcon_attributes_get_keys_count(iotcon_attributes_h attributes,
-               unsigned int *count)
+static void _icl_attributes_clone_foreach(char *key, iotcon_value_h src_val, iotcon_attributes_h dest_attributes)
 {
        FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == count, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == attributes->hash_table, IOTCON_ERROR_INVALID_PARAMETER);
+       iotcon_value_h copied_val;
 
-       *count = g_hash_table_size(attributes->hash_table);
+       copied_val = icl_value_clone(src_val);
+       if (NULL == copied_val) {
+               ERR("icl_value_clone() Fail");
+               return;
+       }
 
-       return IOTCON_ERROR_NONE;
+       _icl_attributes_set_value(dest_attributes, key, copied_val);
 }
 
-
-API int iotcon_attributes_clone(iotcon_attributes_h attributes,
-               iotcon_attributes_h *attributes_clone)
+int icl_attributes_clone(iotcon_attributes_h attributes, iotcon_attributes_h *attributes_clone)
 {
        FN_CALL;
        int ret;
-
        iotcon_attributes_h temp = NULL;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == attributes_clone, IOTCON_ERROR_INVALID_PARAMETER);
 
        if (attributes->hash_table) {
-               ret = iotcon_attributes_create(&temp);
-               if (IOTCON_ERROR_NONE != ret) {
-                       ERR("iotcon_attributes_create() Fail(%d)", ret);
+               ret = icl_attributes_create(&temp);
+               if (IOTCON_ERROR_NONE != ret)
                        return ret;
-               }
 
-               g_hash_table_foreach(attributes->hash_table, (GHFunc)icl_attributes_clone_foreach,
+               g_hash_table_foreach(attributes->hash_table, (GHFunc)_icl_attributes_clone_foreach,
                                temp);
        }
 
@@ -581,41 +280,3 @@ API int iotcon_attributes_clone(iotcon_attributes_h attributes,
 
        return IOTCON_ERROR_NONE;
 }
-
-
-void icl_attributes_clone_foreach(char *key, iotcon_value_h src_val,
-               iotcon_attributes_h dest_attributes)
-{
-       FN_CALL;
-       iotcon_value_h copied_val;
-
-       copied_val = icl_value_clone(src_val);
-       if (NULL == copied_val) {
-               ERR("icl_value_clone() Fail");
-               return;
-       }
-
-       icl_attributes_set_value(dest_attributes, key, copied_val);
-}
-
-
-API int iotcon_attributes_foreach(iotcon_attributes_h attributes,
-               iotcon_attributes_cb cb, void *user_data)
-{
-       FN_CALL;
-       GHashTableIter iter;
-       gpointer key;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
-
-       g_hash_table_iter_init(&iter, attributes->hash_table);
-       while (g_hash_table_iter_next(&iter, &key, NULL)) {
-               if (IOTCON_FUNC_STOP == cb(attributes, key, user_data))
-                       break;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
-
index 2259767871594e28d77e4dc26101e1db69613495..e85a3206ba121381634132b2b7df5a4a00585990 100644 (file)
 #include "ic-value.h"
 #include "ic-representation.h"
 
-int icl_attributes_set_value(iotcon_attributes_h attributes, const char *key,
-               iotcon_value_h value);
-
-void icl_attributes_clone_foreach(char *key, iotcon_value_h src_val,
-               iotcon_attributes_h dest_attributes);
-
 iotcon_attributes_h icl_attributes_ref(iotcon_attributes_h attributes);
+int icl_attributes_create(iotcon_attributes_h *ret_attributes);
+int icl_attributes_destroy(iotcon_attributes_h attributes);
+int icl_attributes_add_int(iotcon_attributes_h attributes, const char *key, int val);
+int icl_attributes_add_bool(iotcon_attributes_h attributes, const char *key, bool val);
+int icl_attributes_add_double(iotcon_attributes_h attributes, const char *key, double val);
+int icl_attributes_add_str(iotcon_attributes_h attributes, const char *key, char *val);
+int icl_attributes_add_byte_str(iotcon_attributes_h attributes, const char *key, unsigned char *val, int len);
+int icl_attributes_add_null(iotcon_attributes_h attributes, const char *key);
+int icl_attributes_add_list(iotcon_attributes_h attributes, const char *key, iotcon_list_h list);
+int icl_attributes_add_attributes(iotcon_attributes_h attributes, const char *key, iotcon_attributes_h val);
+int icl_attributes_clone(iotcon_attributes_h attributes, iotcon_attributes_h *attributes_clone);
 
 #endif /* __IOTCON_INTERNAL_ATTRIBUTES_H__ */
diff --git a/src/ic-device.c b/src/ic-device.c
deleted file mode 100644 (file)
index d82912d..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "iotcon.h"
-#include "ic.h"
-#include "ic-utils.h"
-#include "ic-representation.h"
-#include "ic-device.h"
-#include "ic-ioty.h"
-
-API int iotcon_device_info_get_property(iotcon_device_info_h device_info,
-               iotcon_device_info_e property, char **value)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == device_info, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == value, IOTCON_ERROR_INVALID_PARAMETER);
-
-       switch (property) {
-       case IOTCON_DEVICE_INFO_NAME:
-               *value = device_info->device_name;
-               break;
-       case IOTCON_DEVICE_INFO_SPEC_VER:
-               *value = device_info->spec_ver;
-               break;
-       case IOTCON_DEVICE_INFO_ID:
-               *value = device_info->device_id;
-               break;
-       case IOTCON_DEVICE_INFO_DATA_MODEL_VER:
-               *value = device_info->data_model_ver;
-               break;
-       default:
-               ERR("Invalid property(%d)", property);
-               return IOTCON_ERROR_INVALID_PARAMETER;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
-
-API int iotcon_find_device_info(const char *host_address,
-               int connectivity_type,
-               iotcon_query_h query,
-               iotcon_device_info_cb cb,
-               void *user_data)
-{
-       FN_CALL;
-       int ret;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
-                       IOTCON_ERROR_PERMISSION_DENIED);
-       RETV_IF(false == ic_utils_check_connectivity_type(connectivity_type),
-                       IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
-
-       ret = icl_ioty_find_device_info(host_address, connectivity_type, query, cb,
-                       user_data);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_find_device_info() Fail(%d)", ret);
-               return ret;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
-
-API int iotcon_set_device_name(const char *device_name)
-{
-       FN_CALL;
-       int ret;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == device_name || '\0' == *device_name, IOTCON_ERROR_INVALID_PARAMETER);
-
-       ret = icl_ioty_set_device_info(device_name);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_set_device_info() Fail(%d)", ret);
-               return ret;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
-
-API int iotcon_platform_info_get_property(iotcon_platform_info_h platform_info,
-               iotcon_platform_info_e property, char **value)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == platform_info, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == value, IOTCON_ERROR_INVALID_PARAMETER);
-
-       switch (property) {
-       case IOTCON_PLATFORM_INFO_ID:
-               *value = platform_info->platform_id;
-               break;
-       case IOTCON_PLATFORM_INFO_MANUF_NAME:
-               *value = platform_info->manuf_name;
-               break;
-       case IOTCON_PLATFORM_INFO_MANUF_URL:
-               *value = platform_info->manuf_url;
-               break;
-       case IOTCON_PLATFORM_INFO_MODEL_NUMBER:
-               *value = platform_info->model_number;
-               break;
-       case IOTCON_PLATFORM_INFO_DATE_OF_MANUF:
-               *value = platform_info->date_of_manuf;
-               break;
-       case IOTCON_PLATFORM_INFO_PLATFORM_VER:
-               *value = platform_info->platform_ver;
-               break;
-       case IOTCON_PLATFORM_INFO_OS_VER:
-               *value = platform_info->os_ver;
-               break;
-       case IOTCON_PLATFORM_INFO_HARDWARE_VER:
-               *value = platform_info->hardware_ver;
-               break;
-       case IOTCON_PLATFORM_INFO_FIRMWARE_VER:
-               *value = platform_info->firmware_ver;
-               break;
-       case IOTCON_PLATFORM_INFO_SUPPORT_URL:
-               *value = platform_info->support_url;
-               break;
-       case IOTCON_PLATFORM_INFO_SYSTEM_TIME:
-               *value = platform_info->system_time;
-               break;
-       default:
-               ERR("Invalid property(%d)", property);
-               return IOTCON_ERROR_INVALID_PARAMETER;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
-
-API int iotcon_find_platform_info(const char *host_address,
-               int connectivity_type,
-               iotcon_query_h query,
-               iotcon_platform_info_cb cb,
-               void *user_data)
-{
-       FN_CALL;
-       int ret;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
-                       IOTCON_ERROR_PERMISSION_DENIED);
-       RETV_IF(false == ic_utils_check_connectivity_type(connectivity_type),
-                       IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
-
-       ret = icl_ioty_find_platform_info(host_address, connectivity_type, query, cb,
-                       user_data);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_find_platform_info() Fail(%d)", ret);
-               return ret;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
index e1f8ce2fa9ab563c400078d30a8e32cf5edd47c6..36befbe0843c2801b3f8cb507c6bd3024ae64b0d 100644 (file)
 #include "ic-lite-resource.h"
 #include "ic-ioty.h"
 #include "ic-ioty-ocprocess.h"
-
-#define ICL_IOTY_TIME_INTERVAL_MIN 0
-#define ICL_IOTY_TIME_INTERVAL_DEFAULT 100
+#include "ic-observers.h"
+#include "ic-options.h"
+#include "ic-query.h"
+#include "ic-resource-interfaces.h"
 
 static int icl_ioty_alive = 1;
-static int icl_ioty_polling_interval;
 
 void icl_ioty_ocprocess_stop()
 {
@@ -54,50 +54,13 @@ void icl_ioty_ocprocess_start()
        icl_ioty_alive = 1;
 }
 
-
-API int iotcon_polling_get_interval(int *interval)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == interval, IOTCON_ERROR_INVALID_PARAMETER);
-
-       *interval = icl_ioty_polling_interval;
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_polling_set_interval(int interval)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(interval <= ICL_IOTY_TIME_INTERVAL_MIN, IOTCON_ERROR_INVALID_PARAMETER);
-
-       icl_ioty_polling_interval = interval;
-
-       ic_utils_cond_signal(IC_UTILS_COND_POLLING);
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_polling_invoke(void)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-
-       ic_utils_cond_signal(IC_UTILS_COND_POLLING);
-
-       return IOTCON_ERROR_NONE;
-}
-
-
 void* icl_ioty_ocprocess_thread(void *data)
 {
        FN_CALL;
        int ret;
+       int interval;
 
-       icl_ioty_polling_interval = ICL_IOTY_TIME_INTERVAL_DEFAULT;
+       icl_polling_get_interval(&interval);
 
        /* For setting this thread name */
        ret = prctl(PR_SET_NAME, "iotcon_ocprocess_thread");
@@ -115,7 +78,7 @@ void* icl_ioty_ocprocess_thread(void *data)
                }
 
                ic_utils_cond_timedwait(IC_UTILS_COND_POLLING, IC_UTILS_MUTEX_POLLING,
-                               icl_ioty_polling_interval);
+                               interval);
        }
        ic_utils_mutex_unlock(IC_UTILS_MUTEX_POLLING);
 
@@ -124,6 +87,8 @@ void* icl_ioty_ocprocess_thread(void *data)
 
 static gboolean _icl_ioty_ocprocess_find_idle_cb(gpointer p)
 {
+       FN_CALL;
+
        int ret;
        icl_cb_s *cb_data;
        icl_find_cb_s *find_cb_data = p;
@@ -141,11 +106,7 @@ static gboolean _icl_ioty_ocprocess_find_idle_cb(gpointer p)
                        resource = resource_list->data;
                        resource->is_found = true;
                        cb = (iotcon_found_resource_cb)cb_data->cb;
-                       if (NULL == cb) {
-                               WARN("It is already stopped");
-                               return G_SOURCE_REMOVE;
-                       }
-                       INFO("Call the callback");
+                       INFO("Call the callback [%p]", cb);
                        if (IOTCON_FUNC_STOP == cb(resource, IOTCON_ERROR_NONE, cb_data->user_data)) {
                                /* Stop */
                                INFO("Stop the callback");
@@ -207,8 +168,7 @@ OCStackApplicationResult icl_ioty_ocprocess_find_cb(void *ctx, OCDoHandle handle
 
        RETV_IF(NULL == ctx, OC_STACK_KEEP_TRANSACTION);
        RETV_IF(NULL == resp, OC_STACK_KEEP_TRANSACTION);
-       if (NULL == resp->payload) /* normal case : payload COULD be NULL */
-               return OC_STACK_KEEP_TRANSACTION;
+       RETV_IF(NULL == resp->payload, OC_STACK_KEEP_TRANSACTION); /* normal case : payload COULD be NULL */
        RETVM_IF(PAYLOAD_TYPE_DISCOVERY != resp->payload->type,
                        OC_STACK_KEEP_TRANSACTION, "Invalid payload type(%d)", resp->payload->type);
 
@@ -238,6 +198,8 @@ OCStackApplicationResult icl_ioty_ocprocess_find_cb(void *ctx, OCDoHandle handle
 
 static gboolean _icl_ioty_ocprocess_device_info_idle_cb(gpointer p)
 {
+       FN_CALL;
+
        int ret;
        icl_cb_s *cb_data;
        icl_device_cb_s *device_cb_data = p;
@@ -248,8 +210,10 @@ static gboolean _icl_ioty_ocprocess_device_info_idle_cb(gpointer p)
 
        if (cb_data && cb_data->cb) {
                cb = (iotcon_device_info_cb)cb_data->cb;
+               INFO("Call the callback [%p]", cb);
                if (IOTCON_FUNC_STOP == cb(device_cb_data->device_info, IOTCON_ERROR_NONE,
                                        cb_data->user_data)) { /* Stop */
+                       INFO("Stop the callback");
                        cb_data->cb = NULL;
 
                        ret = icl_ioty_mutex_lock();
@@ -313,6 +277,8 @@ OCStackApplicationResult icl_ioty_ocprocess_device_info_cb(void *ctx,
 
 static gboolean _icl_ioty_ocprocess_platform_info_idle_cb(gpointer p)
 {
+       FN_CALL;
+
        int ret;
        icl_cb_s *cb_data;
        icl_platform_cb_s *platform_cb_data = p;
@@ -323,8 +289,10 @@ static gboolean _icl_ioty_ocprocess_platform_info_idle_cb(gpointer p)
 
        if (cb_data && cb_data->cb) {
                cb = (iotcon_platform_info_cb)cb_data->cb;
+               INFO("Call the callback [%p]", cb);
                if (IOTCON_FUNC_STOP == cb(platform_cb_data->platform_info, IOTCON_ERROR_NONE,
                                        cb_data->user_data)) { /* Stop */
+                       INFO("Stop the callback");
                        cb_data->cb = NULL;
 
                        ret = icl_ioty_mutex_lock();
@@ -388,6 +356,8 @@ OCStackApplicationResult icl_ioty_ocprocess_platform_info_cb(void *ctx,
 
 static gboolean _icl_ioty_ocprocess_presence_idle_cb(gpointer p)
 {
+       FN_CALL;
+
        icl_presence_cb_s *cb_data = p;
        iotcon_presence_h presence;
 
@@ -442,6 +412,8 @@ OCStackApplicationResult icl_ioty_ocprocess_presence_cb(void *ctx,
 
 static gboolean _icl_ioty_ocprocess_observe_idle_cb(gpointer p)
 {
+       FN_CALL;
+
        icl_observe_cb_s *cb_data = p;
 
        RETV_IF(NULL == cb_data, G_SOURCE_REMOVE);
@@ -506,8 +478,8 @@ OCStackApplicationResult icl_ioty_ocprocess_observe_cb(void *ctx,
        if (NULL == response) {
                ERR("calloc() Fail(%d)", errno);
                if (options)
-                       iotcon_options_destroy(options);
-               iotcon_representation_destroy(repr);
+                       icl_options_destroy(options);
+               icl_representation_destroy(repr);
                return OC_STACK_KEEP_TRANSACTION;
        }
        response->header_options = options;
@@ -518,7 +490,7 @@ OCStackApplicationResult icl_ioty_ocprocess_observe_cb(void *ctx,
                        &observe_cb_data);
        if (IOTCON_ERROR_NONE != ret) {
                ERR("icl_create_observe_cb_data() Fail(%d)", ret);
-               iotcon_response_destroy(response);
+               icl_response_destroy(response);
                return OC_STACK_KEEP_TRANSACTION;
        }
 
@@ -532,6 +504,8 @@ OCStackApplicationResult icl_ioty_ocprocess_observe_cb(void *ctx,
 
 static gboolean _icl_ioty_ocprocess_crud_idle_cb(gpointer p)
 {
+       FN_CALL;
+
        icl_response_cb_s *cb_data = p;
 
        RETV_IF(NULL == cb_data, G_SOURCE_REMOVE);
@@ -611,8 +585,8 @@ OCStackApplicationResult icl_ioty_ocprocess_crud_cb(void *ctx,
        if (NULL == response) {
                ERR("calloc() Fail(%d)", errno);
                if (options)
-                       iotcon_options_destroy(options);
-               iotcon_representation_destroy(repr);
+                       icl_options_destroy(options);
+               icl_representation_destroy(repr);
                return OC_STACK_DELETE_TRANSACTION;
        }
        response->header_options = options;
@@ -622,7 +596,7 @@ OCStackApplicationResult icl_ioty_ocprocess_crud_cb(void *ctx,
        ret = icl_create_response_cb_data(cb_container, response, &response_cb_data);
        if (IOTCON_ERROR_NONE != ret) {
                ERR("icl_create_observe_cb_data() Fail(%d)", ret);
-               iotcon_response_destroy(response);
+               icl_response_destroy(response);
                return OC_STACK_DELETE_TRANSACTION;
        }
 
@@ -641,6 +615,8 @@ OCStackApplicationResult icl_ioty_ocprocess_crud_cb(void *ctx,
 
 static gboolean _icl_ioty_ocprocess_request_idle_cb(gpointer p)
 {
+       FN_CALL;
+
        iotcon_resource_h resource;
        iotcon_request_h request;
        icl_request_container_s *req_container = p;
@@ -701,7 +677,7 @@ OCEntityHandlerResult icl_ioty_ocprocess_request_cb(OCEntityHandlerFlag flag,
 
        /* query */
        if (request->query && *request->query) {
-               iotcon_query_create(&query);
+               icl_query_create(&query);
                query_str = request->query;
                while ((token = strtok_r(query_str, "&;", &save_ptr1))) {
                        while ((query_key = strtok_r(token, "=", &save_ptr2))) {
@@ -709,7 +685,7 @@ OCEntityHandlerResult icl_ioty_ocprocess_request_cb(OCEntityHandlerFlag flag,
                                query_value = strtok_r(token, "=", &save_ptr2);
                                if (NULL == query_value)
                                        break;
-                               iotcon_query_add(query, query_key, query_value);
+                               icl_query_add(query, query_key, query_value);
                        }
                        query_str = NULL;
                }
@@ -730,10 +706,10 @@ OCEntityHandlerResult icl_ioty_ocprocess_request_cb(OCEntityHandlerFlag flag,
        /* for iotcon_resource_notify */
        if (IOTCON_OBSERVE_REGISTER == obs_type) {
                if (NULL == resource->observers)
-                       iotcon_observers_create(&resource->observers);
-               iotcon_observers_add(resource->observers, observe_id);
+                       icl_observers_create(&resource->observers);
+               icl_observers_add(resource->observers, observe_id);
        } else if (IOTCON_OBSERVE_DEREGISTER == obs_type) {
-               iotcon_observers_remove(resource->observers, observe_id);
+               icl_observers_remove(resource->observers, observe_id);
        }
 
        ic_ioty_parse_oic_dev_address(&request->devAddr, &host_address, &conn_type);
@@ -743,11 +719,11 @@ OCEntityHandlerResult icl_ioty_ocprocess_request_cb(OCEntityHandlerFlag flag,
                ERR("calloc() Fail(%d)", errno);
                free(host_address);
                if (options)
-                       iotcon_options_destroy(options);
+                       icl_options_destroy(options);
                if (query)
-                       iotcon_query_destroy(query);
+                       icl_query_destroy(query);
                if (repr)
-                       iotcon_representation_destroy(repr);
+                       icl_representation_destroy(repr);
                return OC_EH_ERROR;
        }
 
@@ -781,48 +757,48 @@ static int _icl_ioty_ocprocess_lite_resource_get_repr(
        RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == representation, IOTCON_ERROR_INVALID_PARAMETER);
 
-       ret = iotcon_representation_create(&repr);
+       ret = icl_representation_create(&repr);
        if (IOTCON_ERROR_NONE != ret) {
-               ERR("iotcon_representation_create() Fail(%d)", ret);
+               ERR("icl_representation_create() Fail(%d)", ret);
                return ret;
        }
 
-       ret = iotcon_representation_set_uri_path(repr, resource->uri_path);
+       ret = icl_representation_set_uri_path(repr, resource->uri_path);
        if (IOTCON_ERROR_NONE != ret) {
-               ERR("iotcon_representation_set_uri_path() Fail(%d)", ret);
-               iotcon_representation_destroy(repr);
+               ERR("icl_representation_set_uri_path() Fail(%d)", ret);
+               icl_representation_destroy(repr);
                return ret;
        }
 
-       ret = iotcon_representation_set_attributes(repr, resource->attributes);
+       ret = icl_representation_set_attributes(repr, resource->attributes);
        if (IOTCON_ERROR_NONE != ret) {
-               ERR("iotcon_representation_set_attributes() Fail(%d)", ret);
-               iotcon_representation_destroy(repr);
+               ERR("icl_representation_set_attributes() Fail(%d)", ret);
+               icl_representation_destroy(repr);
                return ret;
        }
 
-       ret = iotcon_resource_interfaces_create(&ifaces);
+       ret = icl_resource_interfaces_create(&ifaces);
        if (IOTCON_ERROR_NONE != ret) {
-               ERR("iotcon_resource_interfaces_create() Fail(%d)", ret);
-               iotcon_representation_destroy(repr);
+               ERR("icl_resource_interfaces_create() Fail(%d)", ret);
+               icl_representation_destroy(repr);
                return ret;
        }
 
-       ret = iotcon_resource_interfaces_add(ifaces, IOTCON_INTERFACE_DEFAULT);
+       ret = icl_resource_interfaces_add(ifaces, IOTCON_INTERFACE_DEFAULT);
        if (IOTCON_ERROR_NONE != ret) {
-               ERR("iotcon_resource_interfaces_add() Fail(%d)", ret);
-               iotcon_resource_interfaces_destroy(ifaces);
-               iotcon_representation_destroy(repr);
+               ERR("icl_resource_interfaces_add() Fail(%d)", ret);
+               icl_resource_interfaces_destroy(ifaces);
+               icl_representation_destroy(repr);
                return ret;
        }
 
-       ret = iotcon_representation_set_resource_interfaces(repr, ifaces);
+       ret = icl_representation_set_resource_interfaces(repr, ifaces);
        if (IOTCON_ERROR_NONE != ret) {
-               ERR("iotcon_representation_set_resource_interfaces() Fail(%d)", ret);
-               iotcon_representation_destroy(repr);
+               ERR("icl__representation_set_resource_interfaces() Fail(%d)", ret);
+               icl_representation_destroy(repr);
                return ret;
        }
-       iotcon_resource_interfaces_destroy(ifaces);
+       icl_resource_interfaces_destroy(ifaces);
 
        *representation = repr;
        return IOTCON_ERROR_NONE;
@@ -830,26 +806,18 @@ static int _icl_ioty_ocprocess_lite_resource_get_repr(
 
 static gboolean _icl_ioty_ocprocess_lite_resource_response_idle_cb(gpointer p)
 {
-       int ret;
+       FN_CALL;
 
-       ret = icl_ioty_response_send(p);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_response_send() Fail(%d)", ret);
-               return G_SOURCE_REMOVE;
-       }
-       iotcon_response_destroy(p);
+       icl_ioty_response_send(p);
+       icl_response_destroy(p);
        return G_SOURCE_REMOVE;
 }
 
 static gboolean _icl_ioty_ocprocess_lite_resource_notify_idle_cb(gpointer p)
 {
-       int ret;
+       FN_CALL;
 
-       ret = icl_ioty_lite_resource_notify(p);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_lite_resource_notify() Fail(%d)", ret);
-               return G_SOURCE_REMOVE;
-       }
+       icl_ioty_lite_resource_notify(p);
        return G_SOURCE_REMOVE;
 }
 
@@ -903,7 +871,7 @@ OCEntityHandlerResult icl_ioty_ocprocess_lite_request_cb(OCEntityHandlerFlag fla
                                break;
                        }
                }
-               iotcon_attributes_destroy(resource->attributes);
+               icl_attributes_destroy(resource->attributes);
                resource->attributes = repr->attributes;
                repr->attributes = NULL;
                _icl_ioty_ocprocess_lite_resource_get_repr(resource, &(res->repr));
index 188df57b0fbe6c7906814ae2d2f4355546ac8c18..f3eadf196a9f18559c5af8f55d002b3c90e22b83 100644 (file)
 #include "ic-types.h"
 #include "ic-representation.h"
 #include "ic-ioty-parse.h"
+#include "ic-attributes.h"
+#include "ic-list.h"
+#include "ic-resource-interfaces.h"
+#include "ic-resource-types.h"
 
 static int _ioty_parse_oic_rep_payload_value(OCRepPayloadValue *val,
                iotcon_attributes_h *attributes);
@@ -228,7 +232,7 @@ void ic_ioty_free_resource_list(gpointer data)
 
        resource->is_found = false;
 
-       iotcon_remote_resource_destroy(resource);
+       icl_remote_resource_destroy(resource);
 }
 
 static int _parse_remote_resource(OCDevAddr *dev_addr,
@@ -282,17 +286,17 @@ static int _parse_remote_resource(OCDevAddr *dev_addr,
        }
 
        /* remote resource */
-       ret = iotcon_remote_resource_create(host_address, conn_type, uri, policies, types,
+       ret = icl_remote_resource_create(host_address, conn_type, uri, policies, types,
                        ifaces, &temp);
        if (IOTCON_ERROR_NONE != ret) {
-               ERR("iotcon_remote_resource_create() Fail(%d)", ret);
+               ERR("icl_remote_resource_create() Fail(%d)", ret);
                return ret;
        }
 
        temp->device_id = strdup(device_id);
        if (NULL == temp->device_id) {
                ERR("strdup(device_id) Fail(%d)", errno);
-               iotcon_remote_resource_destroy(temp);
+               icl_remote_resource_destroy(temp);
                return IOTCON_ERROR_OUT_OF_MEMORY;
        }
 
@@ -302,7 +306,7 @@ static int _parse_remote_resource(OCDevAddr *dev_addr,
                temp->device_name = strdup("");
        if (NULL == temp->device_name) {
                ERR("strdup(device_name) Fail(%d)", errno);
-               iotcon_remote_resource_destroy(temp);
+               icl_remote_resource_destroy(temp);
                return IOTCON_ERROR_OUT_OF_MEMORY;
        }
 
@@ -350,18 +354,18 @@ int ic_ioty_parse_oic_discovery_payload(OCDevAddr *dev_addr,
                        return IOTCON_ERROR_IOTIVITY;
                }
 
-               ret = iotcon_resource_types_create(&types);
+               ret = icl_resource_types_create(&types);
                if (IOTCON_ERROR_NONE != ret) {
-                       ERR("iotcon_resource_types_create() Fail(%d)", ret);
+                       ERR("icl_resource_types_create() Fail(%d)", ret);
                        g_list_free_full(res_list, ic_ioty_free_resource_list);
                        return ret;
                }
 
                while (node) {
-                       ret = iotcon_resource_types_add(types, node->value);
+                       ret = icl_resource_types_add(types, node->value);
                        if (IOTCON_ERROR_NONE != ret) {
-                               ERR("iotcon_resource_types_add() Fail(%d)", ret);
-                               iotcon_resource_types_destroy(types);
+                               ERR("icl_resource_types_add() Fail(%d)", ret);
+                               icl_resource_types_destroy(types);
                                g_list_free_full(res_list, ic_ioty_free_resource_list);
                                return ret;
                        }
@@ -369,15 +373,15 @@ int ic_ioty_parse_oic_discovery_payload(OCDevAddr *dev_addr,
                }
 
                /* Resource Interfaces */
-               iotcon_resource_interfaces_create(&ifaces);
+               icl_resource_interfaces_create(&ifaces);
                node = res_payload->interfaces;
                if (NULL == node) {
                        ERR("res_payload interfaces is NULL");
-                       iotcon_resource_types_destroy(types);
+                       icl_resource_types_destroy(types);
                        continue;
                }
                for (; node; node = node->next)
-                       iotcon_resource_interfaces_add(ifaces, node->value);
+                       icl_resource_interfaces_add(ifaces, node->value);
 
                /* Resource Policies */
                policies = _ioty_parse_oic_policies(res_payload->bitmap);
@@ -403,8 +407,8 @@ int ic_ioty_parse_oic_discovery_payload(OCDevAddr *dev_addr,
                                        res_payload->uri, ifaces, types, payload->sid, payload->name, &res);
                        if (IOTCON_ERROR_NONE != ret) {
                                ERR("_parse_remote_resource() Fail(%d)", ret);
-                               iotcon_resource_interfaces_destroy(ifaces);
-                               iotcon_resource_types_destroy(types);
+                               icl_resource_interfaces_destroy(ifaces);
+                               icl_resource_types_destroy(types);
                                continue;
                        }
 
@@ -420,16 +424,16 @@ int ic_ioty_parse_oic_discovery_payload(OCDevAddr *dev_addr,
                                        res_payload->uri, ifaces, types, payload->sid, payload->name, &res);
                        if (IOTCON_ERROR_NONE != ret) {
                                ERR("_parse_remote_resource() Fail(%d)", ret);
-                               iotcon_resource_interfaces_destroy(ifaces);
-                               iotcon_resource_types_destroy(types);
+                               icl_resource_interfaces_destroy(ifaces);
+                               icl_resource_types_destroy(types);
                                continue;
                        }
 
                        res_list = g_list_append(res_list, res);
                }
 
-               iotcon_resource_interfaces_destroy(ifaces);
-               iotcon_resource_types_destroy(types);
+               icl_resource_interfaces_destroy(ifaces);
+               icl_resource_types_destroy(types);
        }
 
        *resource_list = res_list;
@@ -563,85 +567,85 @@ static int _icl_ioty_parse_oic_rep_payload_value_array_attr(
 
        switch (arr->type) {
        case OCREP_PROP_INT:
-               ret = iotcon_list_create(IOTCON_TYPE_INT, &l);
+               ret = icl_list_create(IOTCON_TYPE_INT, &l);
                if (IOTCON_ERROR_NONE != ret) {
-                       ERR("iotcon_list_create(IOTCON_TYPE_INT) Fail(%d)", ret);
+                       ERR("icl_list_create(IOTCON_TYPE_INT) Fail(%d)", ret);
                        return ret;
                }
                for (i = 0; i < len; i++) {
-                       ret = iotcon_list_add_int(l, arr->iArray[index + i], -1);
+                       ret = icl_list_add_int(l, arr->iArray[index + i], -1);
                        if (IOTCON_ERROR_NONE != ret) {
-                               ERR("iotcon_list_add_int() Fail(%d)", ret);
-                               iotcon_list_destroy(l);
+                               ERR("icl_list_add_int() Fail(%d)", ret);
+                               icl_list_destroy(l);
                                return ret;
                        }
                }
                break;
        case OCREP_PROP_BOOL:
-               ret = iotcon_list_create(IOTCON_TYPE_BOOL, &l);
+               ret = icl_list_create(IOTCON_TYPE_BOOL, &l);
                if (IOTCON_ERROR_NONE != ret) {
-                       ERR("iotcon_list_create(IOTCON_TYPE_BOOL) Fail(%d)", ret);
+                       ERR("icl_list_create(IOTCON_TYPE_BOOL) Fail(%d)", ret);
                        return ret;
                }
                for (i = 0; i < len; i++) {
-                       ret = iotcon_list_add_bool(l, arr->bArray[index + i], -1);
+                       ret = icl_list_add_bool(l, arr->bArray[index + i], -1);
                        if (IOTCON_ERROR_NONE != ret) {
-                               ERR("iotcon_list_add_bool() Fail(%d)", ret);
-                               iotcon_list_destroy(l);
+                               ERR("icl_list_add_bool() Fail(%d)", ret);
+                               icl_list_destroy(l);
                                return ret;
                        }
                }
                break;
        case OCREP_PROP_DOUBLE:
-               ret = iotcon_list_create(IOTCON_TYPE_DOUBLE, &l);
+               ret = icl_list_create(IOTCON_TYPE_DOUBLE, &l);
                if (IOTCON_ERROR_NONE != ret) {
-                       ERR("iotcon_list_create(IOTCON_TYPE_DOUBLE) Fail(%d)", ret);
+                       ERR("icl_list_create(IOTCON_TYPE_DOUBLE) Fail(%d)", ret);
                        return ret;
                }
                for (i = 0; i < len; i++) {
-                       ret = iotcon_list_add_double(l, arr->dArray[index + i], -1);
+                       ret = icl_list_add_double(l, arr->dArray[index + i], -1);
                        if (IOTCON_ERROR_NONE != ret) {
-                               ERR("iotcon_list_add_double() Fail(%d)", ret);
-                               iotcon_list_destroy(l);
+                               ERR("icl_list_add_double() Fail(%d)", ret);
+                               icl_list_destroy(l);
                                return ret;
                        }
                }
                break;
        case OCREP_PROP_STRING:
-               ret = iotcon_list_create(IOTCON_TYPE_STR, &l);
+               ret = icl_list_create(IOTCON_TYPE_STR, &l);
                if (IOTCON_ERROR_NONE != ret) {
-                       ERR("iotcon_list_create(IOTCON_TYPE_STR) Fail(%d)", ret);
+                       ERR("icl_list_create(IOTCON_TYPE_STR) Fail(%d)", ret);
                        return ret;
                }
                for (i = 0; i < len; i++) {
-                       ret = iotcon_list_add_str(l, arr->strArray[index + i], -1);
+                       ret = icl_list_add_str(l, arr->strArray[index + i], -1);
                        if (IOTCON_ERROR_NONE != ret) {
-                               ERR("iotcon_list_add_str() Fail(%d)", ret);
-                               iotcon_list_destroy(l);
+                               ERR("icl_list_add_str() Fail(%d)", ret);
+                               icl_list_destroy(l);
                                return ret;
                        }
                }
                break;
        case OCREP_PROP_BYTE_STRING:
-               ret = iotcon_list_create(IOTCON_TYPE_BYTE_STR, &l);
+               ret = icl_list_create(IOTCON_TYPE_BYTE_STR, &l);
                if (IOTCON_ERROR_NONE != ret) {
-                       ERR("iotcon_list_create(IOTCON_TYPE_BYTE_STR) Fail(%d)", ret);
+                       ERR("icl_list_create(IOTCON_TYPE_BYTE_STR) Fail(%d)", ret);
                        return ret;
                }
                for (i = 0; i < len; i++) {
-                       ret = iotcon_list_add_byte_str(l, arr->ocByteStrArray[index + i].bytes,
+                       ret = icl_list_add_byte_str(l, arr->ocByteStrArray[index + i].bytes,
                                        arr->ocByteStrArray[index + i].len, -1);
                        if (IOTCON_ERROR_NONE != ret) {
-                               ERR("iotcon_list_add_byte_str() Fail(%d)", ret);
-                               iotcon_list_destroy(l);
+                               ERR("icl_list_add_byte_str() Fail(%d)", ret);
+                               icl_list_destroy(l);
                                return ret;
                        }
                }
                break;
        case OCREP_PROP_OBJECT:
-               ret = iotcon_list_create(IOTCON_TYPE_ATTRIBUTES, &l);
+               ret = icl_list_create(IOTCON_TYPE_ATTRIBUTES, &l);
                if (IOTCON_ERROR_NONE != ret) {
-                       ERR("iotcon_list_create(IOTCON_TYPE_ATTRIBUTES) Fail(%d)", ret);
+                       ERR("icl_list_create(IOTCON_TYPE_ATTRIBUTES) Fail(%d)", ret);
                        return ret;
                }
                for (i = 0; i < len; i++) {
@@ -650,18 +654,18 @@ static int _icl_ioty_parse_oic_rep_payload_value_array_attr(
                                        &attributes);
                        if (IOTCON_ERROR_NONE != ret) {
                                ERR("_ioty_parse_oic_rep_payload_value(%d)", ret);
-                               iotcon_list_destroy(l);
+                               icl_list_destroy(l);
                                return ret;
                        }
 
-                       ret = iotcon_list_add_attributes(l, attributes, -1);
+                       ret = icl_list_add_attributes(l, attributes, -1);
                        if (IOTCON_ERROR_NONE != ret) {
-                               ERR("iotcon_list_add_attributes() Fail(%d)", ret);
-                               iotcon_attributes_destroy(attributes);
-                               iotcon_list_destroy(l);
+                               ERR("icl_list_add_attributes() Fail(%d)", ret);
+                               icl_attributes_destroy(attributes);
+                               icl_list_destroy(l);
                                return ret;
                        }
-                       iotcon_attributes_destroy(attributes);
+                       icl_attributes_destroy(attributes);
                }
                break;
        case OCREP_PROP_ARRAY:
@@ -698,9 +702,9 @@ static int _icl_ioty_parse_oic_rep_payload_value_array(
        next_len = len / arr->dimensions[depth];
        index -= next_len;
 
-       ret = iotcon_list_create(IOTCON_TYPE_LIST, &l);
+       ret = icl_list_create(IOTCON_TYPE_LIST, &l);
        if (IOTCON_ERROR_NONE != ret) {
-               ERR("iotcon_list_create() Fail(%d)", ret);
+               ERR("icl_list_create() Fail(%d)", ret);
                return ret;
        }
 
@@ -710,18 +714,18 @@ static int _icl_ioty_parse_oic_rep_payload_value_array(
                                &l_child);
                if (IOTCON_ERROR_NONE != ret) {
                        ERR("_icl_ioty_parse_oic_rep_payload_value_array() Fail(%d)", ret);
-                       iotcon_list_destroy(l);
+                       icl_list_destroy(l);
                        return ret;
                }
 
-               ret = iotcon_list_add_list(l, l_child, -1);
+               ret = icl_list_add_list(l, l_child, -1);
                if (IOTCON_ERROR_NONE != ret) {
-                       ERR("iotcon_list_add_list() Fail(%d)", ret);
-                       iotcon_list_destroy(l_child);
-                       iotcon_list_destroy(l);
+                       ERR("icl_list_add_list() Fail(%d)", ret);
+                       icl_list_destroy(l_child);
+                       icl_list_destroy(l);
                        return ret;
                }
-               iotcon_list_destroy(l_child);
+               icl_list_destroy(l_child);
        }
        *list = l;
        return IOTCON_ERROR_NONE;
@@ -738,60 +742,55 @@ static int _ioty_parse_oic_rep_payload_value(OCRepPayloadValue *val,
        RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER);
 
-       ret = iotcon_attributes_create(&s);
+       ret = icl_attributes_create(&s);
        if (IOTCON_ERROR_NONE != ret) {
-               ERR("iotcon_attributes_create() Fail(%d)", ret);
+               ERR("icl_attributes_create() Fail(%d)", ret);
                return ret;
        }
 
        while (val) {
                switch (val->type) {
                case OCREP_PROP_INT:
-                       ret = iotcon_attributes_add_int(s, val->name, val->i);
+                       ret = icl_attributes_add_int(s, val->name, val->i);
                        if (IOTCON_ERROR_NONE != ret) {
-                               ERR("iotcon_attributes_add_int() Fail(%d)", ret);
-                               iotcon_attributes_destroy(s);
+                               icl_attributes_destroy(s);
                                return ret;
                        }
                        break;
                case OCREP_PROP_BOOL:
-                       ret = iotcon_attributes_add_bool(s, val->name, val->b);
+                       ret = icl_attributes_add_bool(s, val->name, val->b);
                        if (IOTCON_ERROR_NONE != ret) {
-                               ERR("iotcon_attributes_add_bool() Fail(%d)", ret);
-                               iotcon_attributes_destroy(s);
+                               icl_attributes_destroy(s);
                                return ret;
                        }
                        break;
                case OCREP_PROP_DOUBLE:
-                       ret = iotcon_attributes_add_double(s, val->name, val->d);
+                       ret = icl_attributes_add_double(s, val->name, val->d);
                        if (IOTCON_ERROR_NONE != ret) {
-                               ERR("iotcon_attributes_add_double() Fail(%d)", ret);
-                               iotcon_attributes_destroy(s);
+                               icl_attributes_destroy(s);
                                return ret;
                        }
                        break;
                case OCREP_PROP_STRING:
-                       ret = iotcon_attributes_add_str(s, val->name, val->str);
+                       ret = icl_attributes_add_str(s, val->name, val->str);
                        if (IOTCON_ERROR_NONE != ret) {
                                ERR("iotcon_attributes_add_str() Fail(%d)", ret);
-                               iotcon_attributes_destroy(s);
+                               icl_attributes_destroy(s);
                                return ret;
                        }
                        break;
                case OCREP_PROP_BYTE_STRING:
-                       ret = iotcon_attributes_add_byte_str(s, val->name, val->ocByteStr.bytes,
+                       ret = icl_attributes_add_byte_str(s, val->name, val->ocByteStr.bytes,
                                        val->ocByteStr.len);
                        if (IOTCON_ERROR_NONE != ret) {
-                               ERR("iotcon_attributes_add_byte_str() Fail(%d)", ret);
-                               iotcon_attributes_destroy(s);
+                               icl_attributes_destroy(s);
                                return ret;
                        }
                        break;
                case OCREP_PROP_NULL:
-                       ret = iotcon_attributes_add_null(s, val->name);
+                       ret = icl_attributes_add_null(s, val->name);
                        if (IOTCON_ERROR_NONE != ret) {
-                               ERR("iotcon_attributes_add_null() Fail(%d)", ret);
-                               iotcon_attributes_destroy(s);
+                               icl_attributes_destroy(s);
                                return ret;
                        }
                        break;
@@ -801,33 +800,31 @@ static int _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_attributes_destroy(s);
+                               icl_attributes_destroy(s);
                                return ret;
                        }
-                       ret = iotcon_attributes_add_list(s, val->name, list);
+                       ret = icl_attributes_add_list(s, val->name, list);
                        if (IOTCON_ERROR_NONE != ret) {
-                               ERR("iotcon_attributes_add_list() Fail(%d)", ret);
-                               iotcon_list_destroy(list);
-                               iotcon_attributes_destroy(s);
+                               icl_list_destroy(list);
+                               icl_attributes_destroy(s);
                                return ret;
                        }
-                       iotcon_list_destroy(list);
+                       icl_list_destroy(list);
                        break;
                case OCREP_PROP_OBJECT:
                        ret = _ioty_parse_oic_rep_payload_value(val->obj->values, &s_obj);
                        if (IOTCON_ERROR_NONE != ret) {
                                ERR("_ioty_parse_oic_rep_payload_value() Fail(%d)", ret);
-                               iotcon_attributes_destroy(s);
+                               icl_attributes_destroy(s);
                                return ret;
                        }
-                       ret = iotcon_attributes_add_attributes(s, val->name, s_obj);
+                       ret = icl_attributes_add_attributes(s, val->name, s_obj);
                        if (IOTCON_ERROR_NONE != ret) {
-                               ERR("iotcon_attributes_add_attributes() Fail(%d)", ret);
-                               iotcon_attributes_destroy(s_obj);
-                               iotcon_attributes_destroy(s);
+                               icl_attributes_destroy(s_obj);
+                               icl_attributes_destroy(s);
                                return ret;
                        }
-                       iotcon_attributes_destroy(s_obj);
+                       icl_attributes_destroy(s_obj);
                        break;
                default:
                        ERR("Invalid Type(%d)", val->type);
@@ -854,9 +851,9 @@ int ic_ioty_parse_oic_rep_payload(OCRepPayload *payload, bool is_parent,
        RETV_IF(NULL == payload, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == representation, IOTCON_ERROR_INVALID_PARAMETER);
 
-       ret = iotcon_representation_create(&repr);
+       ret = icl_representation_create(&repr);
        if (IOTCON_ERROR_NONE != ret) {
-               ERR("iotcon_representation_create() Fail(%d)", ret);
+               ERR("icl_representation_create() Fail(%d)", ret);
                return ret;
        }
 
@@ -869,71 +866,71 @@ int ic_ioty_parse_oic_rep_payload(OCRepPayload *payload, bool is_parent,
                node = payload->types;
                while (node) {
                        if (NULL == types) {
-                               ret = iotcon_resource_types_create(&types);
+                               ret = icl_resource_types_create(&types);
                                if (IOTCON_ERROR_NONE != ret) {
-                                       ERR("iotcon_resource_types_add() Fail(%d)", ret);
-                                       iotcon_representation_destroy(repr);
+                                       ERR("icl_resource_types_add() Fail(%d)", ret);
+                                       icl_representation_destroy(repr);
                                        return ret;
                                }
                        }
-                       ret = iotcon_resource_types_add(types, node->value);
+                       ret = icl_resource_types_add(types, node->value);
                        if (IOTCON_ERROR_NONE != ret) {
-                               ERR("iotcon_resource_types_add() Fail(%d)", ret);
-                               iotcon_resource_types_destroy(types);
-                               iotcon_representation_destroy(repr);
+                               ERR("icl_resource_types_add() Fail(%d)", ret);
+                               icl_resource_types_destroy(types);
+                               icl_representation_destroy(repr);
                                return ret;
                        }
                        node = node->next;
                }
-               ret = iotcon_representation_set_resource_types(repr, types);
+               ret = icl_representation_set_resource_types(repr, types);
                if (IOTCON_ERROR_NONE != ret) {
-                       ERR("iotcon_representation_set_resource_types() Fail(%d)", ret);
-                       iotcon_resource_types_destroy(types);
-                       iotcon_representation_destroy(repr);
+                       ERR("icl_representation_set_resource_types() Fail(%d)", ret);
+                       icl_resource_types_destroy(types);
+                       icl_representation_destroy(repr);
                        return ret;
                }
-               iotcon_resource_types_destroy(types);
+               icl_resource_types_destroy(types);
        }
 
-       iotcon_resource_interfaces_create(&ifaces);
+       icl_resource_interfaces_create(&ifaces);
 
        /* resource interfaces */
        node = payload->interfaces;
        if (node) {
                while (node) {
-                       iotcon_resource_interfaces_add(ifaces, node->value);
+                       icl_resource_interfaces_add(ifaces, node->value);
                        node = node->next;
                }
        } else {
                /* TODO: verify spec */
-               iotcon_resource_interfaces_add(ifaces, IOTCON_INTERFACE_DEFAULT);
+               icl_resource_interfaces_add(ifaces, IOTCON_INTERFACE_DEFAULT);
        }
 
-       ret = iotcon_representation_set_resource_interfaces(repr, ifaces);
+       ret = icl_representation_set_resource_interfaces(repr, ifaces);
        if (IOTCON_ERROR_NONE != ret) {
-               ERR("iotcon_representation_set_resource_interfaces() Fail(%d)", ret);
-               iotcon_resource_interfaces_destroy(ifaces);
-               iotcon_representation_destroy(repr);
+               ERR("icl_representation_set_resource_interfaces() Fail(%d)", ret);
+               icl_resource_interfaces_destroy(ifaces);
+               icl_representation_destroy(repr);
                return ret;
        }
-       iotcon_resource_interfaces_destroy(ifaces);
+       icl_resource_interfaces_destroy(ifaces);
 
        /* attributes */
        if (payload->values) {
                ret = _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);
+                       icl_representation_destroy(repr);
                        return ret;
                }
-               ret = iotcon_representation_set_attributes(repr, attributes);
+               ret = icl_representation_set_attributes(repr, attributes);
                if (IOTCON_ERROR_NONE != ret) {
-                       ERR("iotcon_representation_set_attributes() Fail(%d)", ret);
-                       iotcon_attributes_destroy(attributes);
-                       iotcon_representation_destroy(repr);
+                       ERR("icl_representation_set_attributes() Fail(%d)", ret);
+                       icl_attributes_destroy(attributes);
+                       icl_representation_destroy(repr);
                        return ret;
                }
-               iotcon_attributes_destroy(attributes);
+               icl_attributes_destroy(attributes);
        }
 
        /* children */
@@ -945,18 +942,18 @@ int ic_ioty_parse_oic_rep_payload(OCRepPayload *payload, bool is_parent,
                ret = ic_ioty_parse_oic_rep_payload(child_node, false, &repr_child);
                if (IOTCON_ERROR_NONE != ret) {
                        ERR("ic_ioty_parse_oic_rep_payload() Fail(%d)", ret);
-                       iotcon_representation_destroy(repr);
+                       icl_representation_destroy(repr);
                        return ret;
                }
 
-               ret = iotcon_representation_add_child(repr, repr_child);
+               ret = icl_representation_add_child(repr, repr_child);
                if (IOTCON_ERROR_NONE != ret) {
-                       ERR("iotcon_representation_add_child() Fail(%d)", ret);
-                       iotcon_representation_destroy(repr_child);
-                       iotcon_representation_destroy(repr);
+                       ERR("icl_representation_add_child() Fail(%d)", ret);
+                       icl_representation_destroy(repr_child);
+                       icl_representation_destroy(repr);
                        return ret;
                }
-               iotcon_representation_destroy(repr_child);
+               icl_representation_destroy(repr_child);
 
                child_node = child_node->next;
        }
@@ -979,9 +976,9 @@ int ic_ioty_parse_oic_header_option(OCHeaderOption *option, int option_size,
                return IOTCON_ERROR_NONE;
        }
 
-       ret = iotcon_options_create(&op);
+       ret = icl_options_create(&op);
        if (IOTCON_ERROR_NONE != ret) {
-               ERR("iotcon_options_create() Fail(%d)", ret);
+               ERR("icl_options_create() Fail(%d)", ret);
                return ret;
        }
 
index 6355378486faf991f4e0d82eb9a7cd8b7b6d9ab8..15dffe913178983be04d949f99d69bafa7cfdbc1 100644 (file)
@@ -37,7 +37,7 @@
 #include "ic-resource-interfaces.h"
 #include "ic-resource-types.h"
 #include "ic-response.h"
-#include "ic-observation.h"
+#include "ic-observers.h"
 #include "ic-attributes.h"
 #include "ic-lite-resource.h"
 #include "ic-ioty.h"
@@ -69,18 +69,15 @@ void icl_ioty_deinit(pthread_t thread)
        if (0 != ret)
                ERR("pthread_join() Fail(%d)", ret);
 
-       INFO("pthread_join finished");
-
        ic_utils_cond_polling_destroy();
 
        ic_utils_mutex_lock(IC_UTILS_MUTEX_IOTY);
        ret = OCStop();
-       if (OC_STACK_OK != ret) {
+       if (OC_STACK_OK != ret)
                ERR("OCStop() Fail(%d)", ret);
-               ic_utils_mutex_unlock(IC_UTILS_MUTEX_IOTY);
-               return;
-       }
-       icl_state = false;
+       else
+               icl_state = false;
+
        ic_utils_mutex_unlock(IC_UTILS_MUTEX_IOTY);
 }
 
@@ -91,32 +88,27 @@ static FILE* _icl_ioty_ps_fopen(const char *path, const char *mode)
 
 int icl_ioty_set_persistent_storage(const char *file_path, bool is_pt)
 {
-       FN_CALL;
        int ret;
 
        RETV_IF(NULL == file_path, IOTCON_ERROR_INVALID_PARAMETER);
+       SECURE_DBG("file_path: [%s], is_pt: [%d]", file_path, is_pt);
 
        if (-1 == access(file_path, F_OK)) {
+               INFO("Create file");
                if (true == is_pt) {
                        ret = icl_cbor_create_pt_svr_db(file_path);
-                       if (IOTCON_ERROR_NONE != ret) {
-                               ERR("icl_cbor_create_pt_svr_db() Fail(%d)", ret);
+                       if (IOTCON_ERROR_NONE != ret)
                                return ret;
-                       }
                } else {
                        ret = icl_cbor_create_svr_db(file_path);
-                       if (IOTCON_ERROR_NONE != ret) {
-                               ERR("icl_cbor_create_svr_db() Fail(%d)", ret);
+                       if (IOTCON_ERROR_NONE != ret)
                                return ret;
-                       }
                }
        } else if (-1 == access(file_path, R_OK | W_OK)) {
                ERR("access() Fail(%d)", errno);
                return IOTCON_ERROR_PERMISSION_DENIED;
        }
-
        snprintf(icl_svr_db_file, sizeof(icl_svr_db_file), "%s", file_path);
-       SECURE_DBG("icl_svr_db_file : %s", icl_svr_db_file);
 
        icl_ioty_ps.open = _icl_ioty_ps_fopen;
        icl_ioty_ps.read = fread;
@@ -128,13 +120,14 @@ int icl_ioty_set_persistent_storage(const char *file_path, bool is_pt)
        ret = OCRegisterPersistentStorageHandler(&icl_ioty_ps);
        if (OC_STACK_OK != ret) {
                ERR("OCRegisterPersistentStorageHandler() Fail(%d)", ret);
-               ic_utils_mutex_unlock(IC_UTILS_MUTEX_IOTY);
-               return IOTCON_ERROR_IOTIVITY;
+               ret = IOTCON_ERROR_IOTIVITY;
+       } else {
+               icl_state = true;
+               ret = IOTCON_ERROR_NONE;
        }
-       icl_state = true;
        ic_utils_mutex_unlock(IC_UTILS_MUTEX_IOTY);
 
-       return IOTCON_ERROR_NONE;
+       return ret;
 }
 
 /* LCOV_EXCL_START */
@@ -174,7 +167,8 @@ static icl_generated_pin_cb_container_s* _find_generated_pin_cb(
 
 int icl_ioty_add_generated_pin_cb(iotcon_generated_pin_cb cb, void *user_data)
 {
-       icl_generated_pin_cb_container_s *container;
+       icl_generated_pin_cb_container_s *container = NULL;
+       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
 
        if (_find_generated_pin_cb(cb)) {
                ERR("This callback is already registered.");
@@ -202,6 +196,7 @@ int icl_ioty_add_generated_pin_cb(iotcon_generated_pin_cb cb, void *user_data)
 int icl_ioty_remove_generated_pin_cb(iotcon_generated_pin_cb cb)
 {
        icl_generated_pin_cb_container_s *container;
+       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
 
        container = _find_generated_pin_cb(cb);
        if (NULL == container) {
@@ -329,6 +324,8 @@ static gboolean _icl_ioty_timeout(gpointer user_data)
 
 static gboolean _icl_ioty_free_cb_data_idle_cb(gpointer p)
 {
+       FN_CALL;
+
        icl_cb_s *cb_info = p;
        free(cb_info);
        return G_SOURCE_REMOVE;
@@ -394,21 +391,18 @@ int icl_ioty_find_resource(const char *host_address,
                iotcon_found_resource_cb cb,
                void *user_data)
 {
-       FN_CALL;
        int conn_options;
        int ret, timeout;
        char *coap_str = NULL;
        char *full_uri;
        char uri[PATH_MAX] = {0};
        icl_cb_s *cb_data;
-       OCDoHandle handle;
+       OCDoHandle handle = NULL;
        OCCallbackData cbdata = {0};
        OCConnectivityType oic_conn_type;
 
-       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
-
-       if (host_address
-                       && IC_EQUAL != strncmp(IC_COAP_PREFIX, host_address, strlen(IC_COAP_PREFIX)))
+       SECURE_DBG("host_address:[%s], connectivity_type:[0x%x]", host_address, connectivity_type);
+       if (host_address        && IC_EQUAL != strncmp(IC_COAP_PREFIX, host_address, strlen(IC_COAP_PREFIX)))
                coap_str = IC_COAPS;
 
        if (NULL == host_address) {
@@ -461,7 +455,7 @@ int icl_ioty_find_resource(const char *host_address,
                free(full_uri);
                return ret;
        }
-
+       SECURE_DBG("full_uri:[%s], oic_conn_type:[0x%x]", full_uri, oic_conn_type);
        ret = OCDoResource(&handle, OC_REST_DISCOVER, full_uri, NULL, NULL, oic_conn_type,
                        OC_LOW_QOS, &cbdata, NULL, 0);
        icl_ioty_mutex_unlock();
@@ -475,7 +469,9 @@ int icl_ioty_find_resource(const char *host_address,
        free(full_uri);
 
        cb_data->handle = handle;
-       iotcon_get_timeout(&timeout);
+       DBG("handle [%p], cb [%p]", cb_data->handle, cb_data->cb);
+
+       icl_get_timeout(&timeout);
        cb_data->timeout = g_timeout_add_seconds(timeout, _icl_ioty_timeout, cb_data);
 
        return IOTCON_ERROR_NONE;
@@ -494,14 +490,12 @@ int icl_ioty_find_device_info(const char *host_address,
        char *full_uri;
        char uri[PATH_MAX] = {0};
        icl_cb_s *cb_data = NULL;
-       OCDoHandle handle;
+       OCDoHandle handle = NULL;
        OCCallbackData cbdata = {0};
        OCConnectivityType oic_conn_type;
 
-       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
-
-       if (host_address
-                       && IC_EQUAL != strncmp(IC_COAP_PREFIX, host_address, strlen(IC_COAP_PREFIX)))
+       SECURE_DBG("host_address:[%s], connectivity_type:[0x%x]", host_address, connectivity_type);
+       if (host_address        && IC_EQUAL != strncmp(IC_COAP_PREFIX, host_address, strlen(IC_COAP_PREFIX)))
                coap_str = IC_COAP;
 
        if (NULL == host_address)
@@ -551,7 +545,7 @@ int icl_ioty_find_device_info(const char *host_address,
                free(full_uri);
                return ret;
        }
-
+       SECURE_DBG("full_uri:[%s], oic_conn_type:[0x%x]", full_uri, oic_conn_type);
        ret = OCDoResource(&handle, OC_REST_DISCOVER, full_uri, NULL, NULL, oic_conn_type,
                        OC_LOW_QOS, &cbdata, NULL, 0);
        icl_ioty_mutex_unlock();
@@ -564,7 +558,9 @@ int icl_ioty_find_device_info(const char *host_address,
        }
 
        cb_data->handle = handle;
-       iotcon_get_timeout(&timeout);
+       DBG("handle [%p], cb [%p]", cb_data->handle, cb_data->cb);
+
+       icl_get_timeout(&timeout);
        cb_data->timeout = g_timeout_add_seconds(timeout, _icl_ioty_timeout, cb_data);
 
        return IOTCON_ERROR_NONE;
@@ -583,14 +579,12 @@ int icl_ioty_find_platform_info(const char *host_address,
        char *full_uri;
        char uri[PATH_MAX] = {0};
        icl_cb_s *cb_data = NULL;
-       OCDoHandle handle;
+       OCDoHandle handle = NULL;
        OCCallbackData cbdata = {0};
        OCConnectivityType oic_conn_type;
 
-       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
-
-       if (host_address
-                       && IC_EQUAL != strncmp(IC_COAP_PREFIX, host_address, strlen(IC_COAP_PREFIX)))
+       SECURE_DBG("host_address:[%s], connectivity_type:[0x%x]", host_address, connectivity_type);
+       if (host_address        && IC_EQUAL != strncmp(IC_COAP_PREFIX, host_address, strlen(IC_COAP_PREFIX)))
                coap_str = IC_COAP;
 
        if (NULL == host_address)
@@ -640,7 +634,7 @@ int icl_ioty_find_platform_info(const char *host_address,
                free(full_uri);
                return ret;
        }
-
+       SECURE_DBG("full_uri:[%s], oic_conn_type:[0x%x]", full_uri, oic_conn_type);
        ret = OCDoResource(&handle, OC_REST_DISCOVER, full_uri, NULL, NULL, oic_conn_type,
                        OC_LOW_QOS, &cbdata, NULL, 0);
        icl_ioty_mutex_unlock();
@@ -653,7 +647,9 @@ int icl_ioty_find_platform_info(const char *host_address,
        }
 
        cb_data->handle = handle;
-       iotcon_get_timeout(&timeout);
+       DBG("handle [%p], cb [%p]", cb_data->handle, cb_data->cb);
+
+       icl_get_timeout(&timeout);
        cb_data->timeout = g_timeout_add_seconds(timeout, _icl_ioty_timeout, cb_data);
 
        return IOTCON_ERROR_NONE;
@@ -729,7 +725,7 @@ int icl_ioty_add_presence_cb(const char *host_address,
                iotcon_presence_h *presence_handle)
 {
        int ret;
-       OCDoHandle handle;
+       OCDoHandle handle = NULL;
        char uri[PATH_MAX] = {0};
        OCCallbackData cbdata = {0};
        OCConnectivityType oic_conn_type = CT_ADAPTER_IP;
@@ -789,9 +785,7 @@ int icl_ioty_add_presence_cb(const char *host_address,
                icl_destroy_presence(presence);
                return ret;
        }
-
-       DBG("uri:[%s], connectivity_type:[%d(0x%x)], oic_conn_type:[%d(0x%x)]",
-               uri, connectivity_type, connectivity_type, oic_conn_type, oic_conn_type);
+       SECURE_DBG("uri:[%s], oic_conn_type:[0x%x]", uri, oic_conn_type);
        if (NULL != host_address) {
                DBG("dev_addr.addr:[%s], dev_addr.port:[%d]", dev_addr.addr, dev_addr.port);
                ret = OCDoResource(&handle, OC_REST_PRESENCE, uri, &dev_addr, NULL, oic_conn_type,
@@ -800,7 +794,7 @@ int icl_ioty_add_presence_cb(const char *host_address,
                ret = OCDoResource(&handle, OC_REST_PRESENCE, uri, NULL, NULL, oic_conn_type,
                        OC_LOW_QOS, &cbdata, NULL, 0);
        }
-       DBG("oic handle:[%p]", handle);
+       DBG("handle:[%p]", handle);
 
        icl_ioty_mutex_unlock();
        presence->handle = handle;
@@ -942,6 +936,7 @@ static int _icl_ioty_remote_resource_observe(iotcon_remote_resource_h resource,
                return ret;
        }
 
+       SECURE_DBG("uri:[%s], oic_conn_type:[0x%x]", uri, oic_conn_type);
        ret = OCDoResource(obs_handle, method, uri, &dev_addr, NULL, oic_conn_type,
                        OC_HIGH_QOS, &cbdata, oic_options_ptr, options_size);
        icl_ioty_mutex_unlock();
@@ -1080,7 +1075,6 @@ static int _icl_ioty_remote_resource_crud(
                iotcon_remote_resource_response_cb cb,
                void *user_data)
 {
-       FN_CALL;
        int ret, timeout, options_size = 0;
        char *uri;
        icl_response_container_s *cb_container;
@@ -1095,6 +1089,7 @@ static int _icl_ioty_remote_resource_crud(
        RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
 
+       DBG("req_type [%d]", req_type);
        /* method (request type) */
        method = ic_ioty_convert_request_type(req_type);
 
@@ -1168,6 +1163,7 @@ static int _icl_ioty_remote_resource_crud(
                _icl_ioty_free_response_container(cb_container);
                return ret;
        }
+       SECURE_DBG("uri:[%s], oic_conn_type:[0x%x]", uri, oic_conn_type);
        ret = OCDoResource(NULL, method, uri, &dev_addr, payload, oic_conn_type,
                        OC_HIGH_QOS, &cbdata, oic_options_ptr, options_size);
        icl_ioty_mutex_unlock();
@@ -1180,7 +1176,7 @@ static int _icl_ioty_remote_resource_crud(
        }
 
        free(uri);
-       iotcon_get_timeout(&timeout);
+       icl_get_timeout(&timeout);
        cb_container->timeout = g_timeout_add_seconds(timeout, _icl_ioty_response_timeout,
                        cb_container);
 
@@ -1316,7 +1312,7 @@ static void _icl_ioty_encap_get_cb(iotcon_remote_resource_h resource,
                ret = icl_representation_compare(resource->caching.repr, repr);
                if (IC_EQUAL != ret) { /* updated */
                        if (resource->caching.repr)
-                               iotcon_representation_destroy(resource->caching.repr);
+                               icl_representation_destroy(resource->caching.repr);
                        resource->caching.repr = repr;
                        if (response)
                                response->repr = NULL;
@@ -1604,7 +1600,6 @@ int icl_ioty_resource_create(const char *uri_path,
                void *user_data,
                iotcon_resource_h *resource_handle)
 {
-       FN_CALL;
        GList *c;
        OCResourceHandle handle;
        int ret, i;
@@ -1620,7 +1615,6 @@ int icl_ioty_resource_create(const char *uri_path,
        resource = calloc(1, sizeof(struct icl_resource));
        if (NULL == resource) {
                ERR("calloc() Fail(%d)", errno);
-               OCDeleteResource(handle);
                return IOTCON_ERROR_OUT_OF_MEMORY;
        }
        resource->uri_path = strdup(uri_path);
@@ -1636,14 +1630,19 @@ int icl_ioty_resource_create(const char *uri_path,
        ret = icl_ioty_mutex_lock();
        if (IOTCON_ERROR_NONE != ret) {
                ERR("icl_ioty_mutex_lock() Fail(%d)", ret);
+               free(resource->uri_path);
+               free(resource);
                return ret;
        }
+       SECURE_DBG("res type [%s], res intf [%s], uri [%s], policy [0x%x]",
+               (char *) res_types->type_list->data, (char *) ifaces->iface_list->data, uri_path, policies);
        ret = OCCreateResource(&handle, res_types->type_list->data, ifaces->iface_list->data,
                        uri_path, icl_ioty_ocprocess_request_cb, resource, policies);
        icl_ioty_mutex_unlock();
        if (OC_STACK_OK != ret) {
                ERR("OCCreateResource() Fail(%d)", ret);
-               iotcon_resource_destroy(resource);
+               free(resource->uri_path);
+               free(resource);
                return IOTCON_ERROR_IOTIVITY;
        }
        resource->res_handle = handle;
@@ -1675,27 +1674,27 @@ int icl_ioty_resource_bind_type(iotcon_resource_h resource,
        RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == resource_type, IOTCON_ERROR_INVALID_PARAMETER);
 
-       ret = iotcon_resource_types_clone(resource->types, &resource_types);
+       ret = icl_resource_types_clone(resource->types, &resource_types);
        if (IOTCON_ERROR_NONE != ret) {
-               ERR("iotcon_resource_types_clone() Fail(%d)", ret);
+               ERR("icl_resource_types_clone() Fail(%d)", ret);
                return ret;
        }
 
-       ret = iotcon_resource_types_add(resource_types, resource_type);
+       ret = icl_resource_types_add(resource_types, resource_type);
        if (IOTCON_ERROR_NONE != ret) {
-               ERR("iotcon_resource_types_add() Fail(%d)", ret);
-               iotcon_resource_types_destroy(resource_types);
+               ERR("icl_resource_types_add() Fail(%d)", ret);
+               icl_resource_types_destroy(resource_types);
                return ret;
        }
 
        ret = _icl_ioty_resource_bind_type(resource->res_handle, resource_type);
        if (IOTCON_ERROR_NONE != ret) {
                ERR("_icl_ioty_resource_bind_type Fail(%d)", ret);
-               iotcon_resource_types_destroy(resource_types);
+               icl_resource_types_destroy(resource_types);
                return ret;
        }
 
-       iotcon_resource_types_destroy(resource->types);
+       icl_resource_types_destroy(resource->types);
        resource->types = resource_types;
 
        return ret;
@@ -1709,9 +1708,9 @@ int icl_ioty_resource_bind_interface(iotcon_resource_h resource,
 
        RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
 
-       ret = iotcon_resource_interfaces_add(resource->ifaces, iface);
+       ret = icl_resource_interfaces_add(resource->ifaces, iface);
        if (IOTCON_ERROR_NONE != ret) {
-               ERR("iotcon_resource_interfaces_add() Fail(%d)", ret);
+               ERR("icl_resource_interfaces_add() Fail(%d)", ret);
                return ret;
        }
 
@@ -1834,25 +1833,32 @@ int icl_ioty_resource_notify(iotcon_resource_h resource, iotcon_representation_h
 int icl_ioty_resource_destroy(iotcon_resource_h resource)
 {
        FN_CALL;
-       int ret;
+       int ret = IOTCON_ERROR_NONE;
 
        RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
 
-       ret = icl_ioty_mutex_lock();
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_mutex_lock() Fail(%d)", ret);
-               return ret;
-       }
-       ret = OCDeleteResource(resource->res_handle);
-       icl_ioty_mutex_unlock();
+       if (resource->res_handle) {
+               ret = icl_ioty_mutex_lock();
+               if (IOTCON_ERROR_NONE != ret) {
+                       ERR("icl_ioty_mutex_lock() Fail(%d)", ret);
+                       goto OUT;
+               }
+               ret = OCDeleteResource(resource->res_handle);
+               icl_ioty_mutex_unlock();
 
-       if (OC_STACK_OK != ret) {
-               ERR("OCDeleteResource() Fail(%d)", ret);
-               return ic_ioty_parse_oic_error(ret);
+               if (OC_STACK_OK != ret) {
+                       ERR("OCDeleteResource() Fail(%d)", ret);
+                       ret = ic_ioty_parse_oic_error(ret);
+                       goto OUT;
+               }
+       } else {
+               ERR("resource->res_handle is NULL");
        }
-       resource->res_handle = NULL;
 
-       return IOTCON_ERROR_NONE;
+OUT:
+       free(resource->uri_path);
+       free(resource);
+       return ret;
 }
 
 int icl_ioty_lite_resource_create(const char *uri_path,
@@ -1896,15 +1902,20 @@ int icl_ioty_lite_resource_create(const char *uri_path,
        ret = icl_ioty_mutex_lock();
        if (IOTCON_ERROR_NONE != ret) {
                ERR("icl_ioty_mutex_lock() Fail(%d)", ret);
-               icl_ioty_lite_resource_destroy(resource);
+               free(resource->uri_path);
+               free(resource);
                return ret;
        }
+
+       SECURE_DBG("res type [%s], uri [%s], policy [0x%x]",
+               (char *) res_types->type_list->data, uri_path, policies);
        ret = OCCreateResource(&(resource->res_handle), res_types->type_list->data, res_iface, uri_path,
                        icl_ioty_ocprocess_lite_request_cb, resource, policies);
        icl_ioty_mutex_unlock();
        if (OC_STACK_OK != ret) {
                ERR("OCCreateResource() Fail(%d)", ret);
-               icl_ioty_lite_resource_destroy(resource);
+               free(resource->uri_path);
+               free(resource);
                return IOTCON_ERROR_IOTIVITY;
        }
 
@@ -1922,27 +1933,32 @@ int icl_ioty_lite_resource_create(const char *uri_path,
 int icl_ioty_lite_resource_destroy(iotcon_lite_resource_h resource)
 {
        FN_CALL;
-       int ret;
+       int ret = IOTCON_ERROR_NONE;
 
        RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
 
-       ret = icl_ioty_mutex_lock();
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_mutex_lock() Fail(%d)", ret);
-               return ret;
-       }
-       ret = OCDeleteResource(resource->res_handle);
-       icl_ioty_mutex_unlock();
+       if (resource->res_handle) {
+               ret = icl_ioty_mutex_lock();
+               if (IOTCON_ERROR_NONE != ret) {
+                       ERR("icl_ioty_mutex_lock() Fail(%d)", ret);
+                       goto OUT;
+               }
+               ret = OCDeleteResource(resource->res_handle);
+               icl_ioty_mutex_unlock();
 
-       if (OC_STACK_OK != ret) {
-               ERR("OCDeleteResource() Fail(%d)", ret);
-               return ic_ioty_parse_oic_error(ret);
+               if (OC_STACK_OK != ret) {
+                       ERR("OCDeleteResource() Fail(%d)", ret);
+                       ret = ic_ioty_parse_oic_error(ret);
+                       goto OUT;
+               }
+       } else {
+               ERR("resource->res_handle is NULL");
        }
-       resource->res_handle = NULL;
+
+OUT:
        free(resource->uri_path);
        free(resource);
-
-       return IOTCON_ERROR_NONE;
+       return ret;
 }
 
 int icl_ioty_lite_resource_notify(iotcon_lite_resource_h resource)
@@ -1974,21 +1990,17 @@ int icl_ioty_lite_resource_notify(iotcon_lite_resource_h resource)
 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 (attributes)
                attributes = icl_attributes_ref(attributes);
 
        if (resource->attributes)
-               iotcon_attributes_destroy(resource->attributes);
+               icl_attributes_destroy(resource->attributes);
 
        resource->attributes = attributes;
 
-       ret = icl_ioty_lite_resource_notify(resource);
-       if (IOTCON_ERROR_NONE != ret)
-               WARN("icl_ioty_lite_resource_notify() Fail");
+       icl_ioty_lite_resource_notify(resource);
 
        return IOTCON_ERROR_NONE;
 
@@ -2035,6 +2047,7 @@ int icl_ioty_response_send(iotcon_response_h response_handle)
                return ic_ioty_parse_oic_error(ret);
        }
 
+       FN_END;
        return IOTCON_ERROR_NONE;
 }
 
index 189f0b9664e3bf8c2389e1859329a4ae89552156..90f5d7ad009ab2a211927e865f03503cb926bee2 100644 (file)
@@ -36,12 +36,11 @@ iotcon_list_h icl_list_ref(iotcon_list_h list)
 }
 
 
-API int iotcon_list_create(iotcon_type_e type, iotcon_list_h *ret_list)
+int icl_list_create(iotcon_type_e type, iotcon_list_h *ret_list)
 {
        FN_CALL;
        iotcon_list_h list;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == ret_list, IOTCON_ERROR_INVALID_PARAMETER);
 
        if (type < IOTCON_TYPE_INT || IOTCON_TYPE_ATTRIBUTES < type) {
@@ -64,12 +63,11 @@ API int iotcon_list_create(iotcon_type_e type, iotcon_list_h *ret_list)
 }
 
 
-API int iotcon_list_add_int(iotcon_list_h list, int val, int pos)
+int icl_list_add_int(iotcon_list_h list, int val, int pos)
 {
        FN_CALL;
        iotcon_value_h value;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
        RETVM_IF(IOTCON_TYPE_INT != list->type, IOTCON_ERROR_INVALID_TYPE, "Invalid Type(%d)",
                        list->type);
@@ -80,16 +78,16 @@ API int iotcon_list_add_int(iotcon_list_h list, int val, int pos)
                return IOTCON_ERROR_OUT_OF_MEMORY;
        }
 
-       return icl_list_insert(list, value, pos);
+       list->list = g_list_insert(list->list, value, pos);
+       return IOTCON_ERROR_NONE;
 }
 
 
-API int iotcon_list_add_bool(iotcon_list_h list, bool val, int pos)
+int icl_list_add_bool(iotcon_list_h list, bool val, int pos)
 {
        FN_CALL;
        iotcon_value_h value;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
        RETVM_IF(IOTCON_TYPE_BOOL != list->type, IOTCON_ERROR_INVALID_TYPE,
                        "Invalid Type(%d)", list->type);
@@ -100,16 +98,16 @@ API int iotcon_list_add_bool(iotcon_list_h list, bool val, int pos)
                return IOTCON_ERROR_OUT_OF_MEMORY;
        }
 
-       return icl_list_insert(list, value, pos);
+       list->list = g_list_insert(list->list, value, pos);
+       return IOTCON_ERROR_NONE;
 }
 
 
-API int iotcon_list_add_double(iotcon_list_h list, double val, int pos)
+int icl_list_add_double(iotcon_list_h list, double val, int pos)
 {
        FN_CALL;
        iotcon_value_h value;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
        RETVM_IF(IOTCON_TYPE_DOUBLE != list->type, IOTCON_ERROR_INVALID_TYPE,
                        "Invalid Type(%d)", list->type);
@@ -120,16 +118,16 @@ API int iotcon_list_add_double(iotcon_list_h list, double val, int pos)
                return IOTCON_ERROR_OUT_OF_MEMORY;
        }
 
-       return icl_list_insert(list, value, pos);
+       list->list = g_list_insert(list->list, value, pos);
+       return IOTCON_ERROR_NONE;
 }
 
 
-API int iotcon_list_add_str(iotcon_list_h list, char *val, int pos)
+int icl_list_add_str(iotcon_list_h list, char *val, int pos)
 {
        FN_CALL;
        iotcon_value_h value;
 
-       RETV_IF(false == ic_utils_check_ocf_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_STR != list->type, IOTCON_ERROR_INVALID_TYPE,
@@ -141,17 +139,17 @@ API int iotcon_list_add_str(iotcon_list_h list, char *val, int pos)
                return IOTCON_ERROR_OUT_OF_MEMORY;
        }
 
-       return icl_list_insert(list, value, pos);
+       list->list = g_list_insert(list->list, value, pos);
+       return IOTCON_ERROR_NONE;
 }
 
 
-API int iotcon_list_add_byte_str(iotcon_list_h list, unsigned char *val, int len,
+int icl_list_add_byte_str(iotcon_list_h list, unsigned char *val, int len,
                int pos)
 {
        FN_CALL;
        iotcon_value_h value;
 
-       RETV_IF(false == ic_utils_check_ocf_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_BYTE_STR != list->type, IOTCON_ERROR_INVALID_TYPE,
@@ -163,16 +161,16 @@ API int iotcon_list_add_byte_str(iotcon_list_h list, unsigned char *val, int len
                return IOTCON_ERROR_OUT_OF_MEMORY;
        }
 
-       return icl_list_insert(list, value, pos);
+       list->list = g_list_insert(list->list, value, pos);
+       return IOTCON_ERROR_NONE;
 }
 
 
-API int iotcon_list_add_list(iotcon_list_h list, iotcon_list_h val, int pos)
+int icl_list_add_list(iotcon_list_h list, iotcon_list_h val, int pos)
 {
        FN_CALL;
        iotcon_value_h value;
 
-       RETV_IF(false == ic_utils_check_ocf_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_LIST != list->type, IOTCON_ERROR_INVALID_TYPE,
@@ -184,16 +182,16 @@ API int iotcon_list_add_list(iotcon_list_h list, iotcon_list_h val, int pos)
                return IOTCON_ERROR_OUT_OF_MEMORY;
        }
 
-       return icl_list_insert(list, value, pos);
+       list->list = g_list_insert(list->list, value, pos);
+       return IOTCON_ERROR_NONE;
 }
 
 
-API int iotcon_list_add_attributes(iotcon_list_h list, iotcon_attributes_h val, int pos)
+int icl_list_add_attributes(iotcon_list_h list, iotcon_attributes_h val, int pos)
 {
        FN_CALL;
        iotcon_value_h value;
 
-       RETV_IF(false == ic_utils_check_ocf_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_ATTRIBUTES != list->type, IOTCON_ERROR_INVALID_TYPE,
@@ -205,17 +203,17 @@ API int iotcon_list_add_attributes(iotcon_list_h list, iotcon_attributes_h val,
                return IOTCON_ERROR_OUT_OF_MEMORY;
        }
 
-       return icl_list_insert(list, value, pos);
+       list->list = g_list_insert(list->list, value, pos);
+       return IOTCON_ERROR_NONE;
 }
 
 
-API int iotcon_list_get_nth_int(iotcon_list_h list, int pos, int *val)
+int icl_list_get_nth_int(iotcon_list_h list, int pos, int *val)
 {
        FN_CALL;
        int ival, ret;
        iotcon_value_h value;
 
-       RETV_IF(false == ic_utils_check_ocf_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 == val, IOTCON_ERROR_INVALID_PARAMETER);
@@ -238,14 +236,13 @@ API int iotcon_list_get_nth_int(iotcon_list_h list, int pos, int *val)
 }
 
 
-API int iotcon_list_get_nth_bool(iotcon_list_h list, int pos, bool *val)
+int icl_list_get_nth_bool(iotcon_list_h list, int pos, bool *val)
 {
        FN_CALL;
        int ret;
        bool bval;
        iotcon_value_h value;
 
-       RETV_IF(false == ic_utils_check_ocf_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 == val, IOTCON_ERROR_INVALID_PARAMETER);
@@ -268,14 +265,13 @@ API int iotcon_list_get_nth_bool(iotcon_list_h list, int pos, bool *val)
 }
 
 
-API int iotcon_list_get_nth_double(iotcon_list_h list, int pos, double *val)
+int icl_list_get_nth_double(iotcon_list_h list, int pos, double *val)
 {
        FN_CALL;
        int ret;
        double dbval;
        iotcon_value_h value;
 
-       RETV_IF(false == ic_utils_check_ocf_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 == val, IOTCON_ERROR_INVALID_PARAMETER);
@@ -298,14 +294,13 @@ API int iotcon_list_get_nth_double(iotcon_list_h list, int pos, double *val)
 }
 
 
-API int iotcon_list_get_nth_str(iotcon_list_h list, int pos, char **val)
+int icl_list_get_nth_str(iotcon_list_h list, int pos, char **val)
 {
        FN_CALL;
        int ret;
        char *strval;
        iotcon_value_h value;
 
-       RETV_IF(false == ic_utils_check_ocf_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 == val, IOTCON_ERROR_INVALID_PARAMETER);
@@ -328,7 +323,7 @@ API int iotcon_list_get_nth_str(iotcon_list_h list, int pos, char **val)
 }
 
 
-API int iotcon_list_get_nth_byte_str(iotcon_list_h list, int pos,
+int icl_list_get_nth_byte_str(iotcon_list_h list, int pos,
                unsigned char **val, int *len)
 {
        FN_CALL;
@@ -336,7 +331,6 @@ API int iotcon_list_get_nth_byte_str(iotcon_list_h list, int pos,
        int ret, byte_len;
        iotcon_value_h value;
 
-       RETV_IF(false == ic_utils_check_ocf_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 == val, IOTCON_ERROR_INVALID_PARAMETER);
@@ -361,14 +355,13 @@ API int iotcon_list_get_nth_byte_str(iotcon_list_h list, int pos,
 }
 
 
-API int iotcon_list_get_nth_list(iotcon_list_h src, int pos, iotcon_list_h *dest)
+int icl_list_get_nth_list(iotcon_list_h src, int pos, iotcon_list_h *dest)
 {
        FN_CALL;
        int ret;
        iotcon_value_h value;
        iotcon_list_h list_val;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == src, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == src->list, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == dest, IOTCON_ERROR_INVALID_PARAMETER);
@@ -391,7 +384,7 @@ API int iotcon_list_get_nth_list(iotcon_list_h src, int pos, iotcon_list_h *dest
 }
 
 
-API int iotcon_list_get_nth_attributes(iotcon_list_h list, int pos,
+int icl_list_get_nth_attributes(iotcon_list_h list, int pos,
                iotcon_attributes_h *attributes)
 {
        FN_CALL;
@@ -399,7 +392,6 @@ API int iotcon_list_get_nth_attributes(iotcon_list_h list, int pos,
        iotcon_value_h value;
        iotcon_attributes_h attributes_val;
 
-       RETV_IF(false == ic_utils_check_ocf_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 == attributes, IOTCON_ERROR_INVALID_PARAMETER);
@@ -422,12 +414,11 @@ API int iotcon_list_get_nth_attributes(iotcon_list_h list, int pos,
 }
 
 
-API int iotcon_list_remove_nth(iotcon_list_h list, int pos)
+int icl_list_remove_nth(iotcon_list_h list, int pos)
 {
        FN_CALL;
        iotcon_value_h value;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == list->list, IOTCON_ERROR_INVALID_PARAMETER);
 
@@ -445,10 +436,9 @@ API int iotcon_list_remove_nth(iotcon_list_h list, int pos)
 }
 
 
-API int iotcon_list_get_type(iotcon_list_h list, iotcon_type_e *type)
+int icl_list_get_type(iotcon_list_h list, iotcon_type_e *type)
 {
        FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == type, IOTCON_ERROR_INVALID_PARAMETER);
 
@@ -458,10 +448,9 @@ API int iotcon_list_get_type(iotcon_list_h list, iotcon_type_e *type)
 }
 
 
-API int iotcon_list_get_length(iotcon_list_h list, unsigned int *length)
+int icl_list_get_length(iotcon_list_h list, unsigned int *length)
 {
        FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == length, IOTCON_ERROR_INVALID_PARAMETER);
 
@@ -474,16 +463,7 @@ API int iotcon_list_get_length(iotcon_list_h list, unsigned int *length)
 }
 
 
-int icl_list_insert(iotcon_list_h list, iotcon_value_h value, int pos)
-{
-       RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
-
-       list->list = g_list_insert(list->list, value, pos);
-
-       return IOTCON_ERROR_NONE;
-}
-
-API int iotcon_list_foreach_int(iotcon_list_h list, iotcon_list_int_cb cb,
+int icl_list_foreach_int(iotcon_list_h list, iotcon_list_int_cb cb,
                void *user_data)
 {
        FN_CALL;
@@ -491,7 +471,6 @@ API int iotcon_list_foreach_int(iotcon_list_h list, iotcon_list_int_cb cb,
        int index = 0;
        icl_basic_s *real = NULL;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
        RETVM_IF(IOTCON_TYPE_INT != list->type, IOTCON_ERROR_INVALID_TYPE, "Invalid Type(%d)",
                        list->type);
@@ -510,7 +489,7 @@ API int iotcon_list_foreach_int(iotcon_list_h list, iotcon_list_int_cb cb,
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_list_foreach_bool(iotcon_list_h list, iotcon_list_bool_cb cb,
+int icl_list_foreach_bool(iotcon_list_h list, iotcon_list_bool_cb cb,
                void *user_data)
 {
        FN_CALL;
@@ -518,7 +497,6 @@ API int iotcon_list_foreach_bool(iotcon_list_h list, iotcon_list_bool_cb cb,
        int index = 0;
        icl_basic_s *real = NULL;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
        RETVM_IF(IOTCON_TYPE_BOOL != list->type, IOTCON_ERROR_INVALID_TYPE,
                        "Invalid Type(%d)", list->type);
@@ -537,7 +515,7 @@ API int iotcon_list_foreach_bool(iotcon_list_h list, iotcon_list_bool_cb cb,
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_list_foreach_double(iotcon_list_h list, iotcon_list_double_cb cb,
+int icl_list_foreach_double(iotcon_list_h list, iotcon_list_double_cb cb,
                void *user_data)
 {
        FN_CALL;
@@ -545,7 +523,6 @@ API int iotcon_list_foreach_double(iotcon_list_h list, iotcon_list_double_cb cb,
        int index = 0;
        icl_basic_s *real = NULL;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
        RETVM_IF(IOTCON_TYPE_DOUBLE != list->type, IOTCON_ERROR_INVALID_TYPE,
                        "Invalid Type(%d)", list->type);
@@ -564,7 +541,7 @@ API int iotcon_list_foreach_double(iotcon_list_h list, iotcon_list_double_cb cb,
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_list_foreach_str(iotcon_list_h list, iotcon_list_str_cb cb,
+int icl_list_foreach_str(iotcon_list_h list, iotcon_list_str_cb cb,
                void *user_data)
 {
        FN_CALL;
@@ -572,7 +549,6 @@ API int iotcon_list_foreach_str(iotcon_list_h list, iotcon_list_str_cb cb,
        int index = 0;
        icl_basic_s *real = NULL;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
        RETVM_IF(IOTCON_TYPE_STR != list->type, IOTCON_ERROR_INVALID_TYPE, "Invalid Type(%d)",
                        list->type);
@@ -591,7 +567,7 @@ API int iotcon_list_foreach_str(iotcon_list_h list, iotcon_list_str_cb cb,
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_list_foreach_byte_str(iotcon_list_h list, iotcon_list_byte_str_cb cb,
+int icl_list_foreach_byte_str(iotcon_list_h list, iotcon_list_byte_str_cb cb,
                void *user_data)
 {
        FN_CALL;
@@ -599,7 +575,6 @@ API int iotcon_list_foreach_byte_str(iotcon_list_h list, iotcon_list_byte_str_cb
        int index = 0;
        icl_val_byte_str_s *real = NULL;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
        RETVM_IF(IOTCON_TYPE_BYTE_STR != list->type, IOTCON_ERROR_INVALID_TYPE,
                        "Invalid Type(%d)", list->type);
@@ -618,7 +593,7 @@ API int iotcon_list_foreach_byte_str(iotcon_list_h list, iotcon_list_byte_str_cb
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_list_foreach_list(iotcon_list_h list, iotcon_list_list_cb cb,
+int icl_list_foreach_list(iotcon_list_h list, iotcon_list_list_cb cb,
                void *user_data)
 {
        FN_CALL;
@@ -626,7 +601,6 @@ API int iotcon_list_foreach_list(iotcon_list_h list, iotcon_list_list_cb cb,
        GList *cur = NULL;
        icl_val_list_s *real = NULL;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
        RETVM_IF(IOTCON_TYPE_LIST != list->type, IOTCON_ERROR_INVALID_TYPE,
                        "Invalid Type(%d)", list->type);
@@ -645,7 +619,7 @@ API int iotcon_list_foreach_list(iotcon_list_h list, iotcon_list_list_cb cb,
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_list_foreach_attributes(iotcon_list_h list,
+int icl_list_foreach_attributes(iotcon_list_h list,
                iotcon_list_attributes_cb cb, void *user_data)
 {
        FN_CALL;
@@ -653,7 +627,6 @@ API int iotcon_list_foreach_attributes(iotcon_list_h list,
        GList *cur = NULL;
        icl_val_attributes_s *real = NULL;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
        RETVM_IF(IOTCON_TYPE_ATTRIBUTES != list->type, IOTCON_ERROR_INVALID_TYPE,
                        "Invalid Type(%d)", list->type);
@@ -673,12 +646,11 @@ API int iotcon_list_foreach_attributes(iotcon_list_h list,
 }
 
 
-API int iotcon_list_destroy(iotcon_list_h list)
+int icl_list_destroy(iotcon_list_h list)
 {
        FN_CALL;
        GList *cur = NULL;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
 
        list->ref_count--;
index bbf6ad1bb55dd7033896e54e742a34228cf6563a..f3a5622149d027048e8a4395f8854fba5d908d47 100644 (file)
@@ -27,9 +27,33 @@ struct icl_list_s {
        GList *list;
 };
 
-int icl_list_remove(iotcon_list_h list, iotcon_value_h val);
-int icl_list_insert(iotcon_list_h list, iotcon_value_h value, int pos);
-
 iotcon_list_h icl_list_ref(iotcon_list_h list);
+int icl_list_create(iotcon_type_e type, iotcon_list_h *ret_list);
+int icl_list_add_int(iotcon_list_h list, int val, int pos);
+int icl_list_add_bool(iotcon_list_h list, bool val, int pos);
+int icl_list_add_double(iotcon_list_h list, double val, int pos);
+int icl_list_add_str(iotcon_list_h list, char *val, int pos);
+int icl_list_add_byte_str(iotcon_list_h list, unsigned char *val, int len, int pos);
+int icl_list_add_list(iotcon_list_h list, iotcon_list_h val, int pos);
+int icl_list_add_attributes(iotcon_list_h list, iotcon_attributes_h val, int pos);
+int icl_list_get_nth_int(iotcon_list_h list, int pos, int *val);
+int icl_list_get_nth_bool(iotcon_list_h list, int pos, bool *val);
+int icl_list_get_nth_double(iotcon_list_h list, int pos, double *val);
+int icl_list_get_nth_str(iotcon_list_h list, int pos, char **val);
+int icl_list_get_nth_byte_str(iotcon_list_h list, int pos,     unsigned char **val, int *len);
+int icl_list_get_nth_list(iotcon_list_h src, int pos, iotcon_list_h *dest);
+int icl_list_get_nth_attributes(iotcon_list_h list, int pos, iotcon_attributes_h *attributes);
+int icl_list_remove_nth(iotcon_list_h list, int pos);
+int icl_list_get_type(iotcon_list_h list, iotcon_type_e *type);
+int icl_list_get_length(iotcon_list_h list, unsigned int *length);
+int icl_list_foreach_int(iotcon_list_h list, iotcon_list_int_cb cb, void *user_data);
+int icl_list_foreach_bool(iotcon_list_h list, iotcon_list_bool_cb cb, void *user_data);
+int icl_list_foreach_double(iotcon_list_h list, iotcon_list_double_cb cb, void *user_data);
+int icl_list_foreach_str(iotcon_list_h list, iotcon_list_str_cb cb, void *user_data);
+int icl_list_foreach_byte_str(iotcon_list_h list, iotcon_list_byte_str_cb cb,  void *user_data);
+int icl_list_foreach_list(iotcon_list_h list, iotcon_list_list_cb cb, void *user_data);
+int icl_list_foreach_attributes(iotcon_list_h list, iotcon_list_attributes_cb cb, void *user_data);
+int icl_list_destroy(iotcon_list_h list);
+
 
 #endif /* __IOTCON_INTERNAL_LIST_H__ */
diff --git a/src/ic-lite-resource.c b/src/ic-lite-resource.c
deleted file mode 100644 (file)
index 16917c6..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "iotcon-types.h"
-#include "ic.h"
-#include "ic-utils.h"
-#include "ic-representation.h"
-#include "ic-attributes.h"
-#include "ic-value.h"
-#include "ic-list.h"
-#include "ic-resource.h"
-#include "ic-response.h"
-#include "ic-lite-resource.h"
-#include "ic-ioty.h"
-
-
-/* The length of uri_path should be less than 128. */
-API int iotcon_lite_resource_create(const char *uri_path,
-               iotcon_resource_types_h res_types,
-               uint8_t policies,
-               iotcon_attributes_h attributes,
-               iotcon_lite_resource_post_request_cb cb,
-               void *user_data,
-               iotcon_lite_resource_h *resource_handle)
-{
-       FN_CALL;
-       int ret;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
-                       IOTCON_ERROR_PERMISSION_DENIED);
-       RETV_IF(NULL == uri_path, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(false == icl_resource_check_uri_path(uri_path),
-                       IOTCON_ERROR_INVALID_PARAMETER);
-       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, attributes, cb,
-                       user_data, resource_handle);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_lite_resource_create() Fail(%d)", ret);
-               return ret;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_lite_resource_destroy(iotcon_lite_resource_h resource)
-{
-       FN_CALL;
-       int ret;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
-                       IOTCON_ERROR_PERMISSION_DENIED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-
-       ret = icl_ioty_lite_resource_destroy(resource);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_lite_resource_destroy() Fail(%d)", ret);
-               return ret;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_lite_resource_update_attributes(iotcon_lite_resource_h resource,
-               iotcon_attributes_h attributes)
-{
-       FN_CALL;
-       int ret;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
-                       IOTCON_ERROR_PERMISSION_DENIED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-
-       ret = icl_ioty_lite_resource_update_attributes(resource, attributes);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_lite_resource_update_attributes() Fail(%d)", ret);
-               return ret;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_lite_resource_get_attributes(iotcon_lite_resource_h resource,
-               iotcon_attributes_h *attributes)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER);
-
-       *attributes = resource->attributes;
-
-       return IOTCON_ERROR_NONE;
-}
index 33d7de623250ef70de8989a0c8dff7761550857a..617f1e4c8c62cb7b5ba82e31b8789466be4b5aae 100644 (file)
 #define LOG_TAG "IOTCON"
 #include <dlog.h>
 
-#if 1
-#define _DBG(fmt, arg...) SLOGD(fmt, ##arg)
+#define _DBG(fmt, arg...) SLOGI(fmt, ##arg) /* use SLOGI instead of SLOGD*/
 #define _INFO(fmt, arg...) SLOGI(fmt, ##arg)
 #define _WARN(fmt, arg...) SLOGW(fmt, ##arg)
 #define _ERR(fmt, arg...) SLOGE(fmt, ##arg)
-#else
-#define _DBG(fmt, arg...) \
-       printf("[IoTCon]%s(%d):" fmt "\n", __FUNCTION__, __LINE__, ##arg)
-#define _INFO(fmt, arg...) \
-       printf("[IoTCon]%s(%d):" fmt "\n", __FUNCTION__, __LINE__, ##arg)
-#define _WARN(fmt, arg...) \
-       printf("[IoTCon]%s(%d):" fmt "\n", __FUNCTION__, __LINE__, ##arg)
-#define _ERR(fmt, arg...) \
-       printf("[IoTCon]%s(%d):" fmt "\n", __FUNCTION__, __LINE__, ##arg)
-#endif
 
 #define IC_DEBUGGING
 
 #ifdef IC_DEBUGGING
-
-#define FN_CALL _INFO(">>>>>>>> called")
-#define FN_END _INFO("<<<<<<<< ended")
+#define API_CALL _DBG(">>>>>>>> API called")
+#define API_END _DBG(">>>>>>>> API ended")
+#define FN_CALL _DBG(">>>>>>>> called")
+#define FN_END _DBG("<<<<<<<< ended")
 #define DBG(fmt, arg...) _DBG(fmt, ##arg)
-#define WARN(fmt, arg...) _WARN(IC_LOG_BROWN fmt IC_LOG_END, ##arg)
-#define ERR(fmt, arg...) _ERR(IC_LOG_RED fmt IC_LOG_END, ##arg)
-#define INFO(fmt, arg...) _INFO(IC_LOG_BLUE fmt IC_LOG_END, ##arg)
-#define SECURE_DBG(fmt, arg...) SECURE_SLOGD(fmt, ##arg)
+#define WARN(fmt, arg...) _WARN(fmt, ##arg)
+#define ERR(fmt, arg...) _ERR(fmt, ##arg)
+#define INFO(fmt, arg...) _INFO(fmt, ##arg)
+#define SECURE_DBG(fmt, arg...) SECURE_SLOGI(fmt, ##arg)
 #define SECURE_ERR(fmt, arg...) SECURE_SLOGE(fmt, ##arg)
 
 #else /* IC_DEBUGGING */
-
+#define API_CALL
+#define API_END
 #define FN_CALL
 #define FN_END
 #define DBG(fmt, arg...)
 #define WARN(fmt, arg...)
-#define ERR(fmt, arg...) _ERR(fmt, ##arg)
+#define ERR(fmt, arg...)
 #define INFO(fmt, arg...)
 #define SECURE_DBG(fmt, arg...)
-#define SECURE_ERR(fmt, arg...) SECURE_SLOGE(fmt, ##arg)
+#define SECURE_ERR(fmt, arg...)
 
 #endif /* IC_DEBUGGING */
 
diff --git a/src/ic-observation.c b/src/ic-observation.c
deleted file mode 100644 (file)
index 2f508a1..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <stdlib.h>
-#include <errno.h>
-#include <glib.h>
-
-#include "iotcon-types.h"
-#include "ic.h"
-#include "ic-utils.h"
-#include "ic-observation.h"
-
-API int iotcon_observers_create(iotcon_observers_h *ret_observers)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == ret_observers, IOTCON_ERROR_INVALID_PARAMETER);
-
-       iotcon_observers_h observers = calloc(1, sizeof(struct icl_observers));
-       if (NULL == observers) {
-               ERR("calloc() Fail(%d)", errno);
-               return IOTCON_ERROR_OUT_OF_MEMORY;
-       }
-
-       *ret_observers = observers;
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_observers_destroy(iotcon_observers_h observers)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == observers, IOTCON_ERROR_INVALID_PARAMETER);
-
-       g_list_free(observers->observers_list);
-       free(observers);
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_observers_add(iotcon_observers_h observers, int obs_id)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == observers, IOTCON_ERROR_INVALID_PARAMETER);
-
-       observers->observers_list = g_list_append(observers->observers_list,
-                       GUINT_TO_POINTER(obs_id));
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_observers_remove(iotcon_observers_h observers, int obs_id)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == observers, IOTCON_ERROR_INVALID_PARAMETER);
-
-       observers->observers_list = g_list_remove(observers->observers_list,
-                       GUINT_TO_POINTER(obs_id));
-
-       return IOTCON_ERROR_NONE;
-}
-
diff --git a/src/ic-observation.h b/src/ic-observation.h
deleted file mode 100644 (file)
index e882f31..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef __IOTCON_INTERNAL_OBSERVATION_H__
-#define __IOTCON_INTERNAL_OBSERVATION_H__
-
-#include <glib.h>
-#include "iotcon-types.h"
-
-struct icl_observers {
-       GList *observers_list;
-};
-
-#endif /* __IOTCON_INTERNAL_OBSERVATION_H__ */
diff --git a/src/ic-observers.c b/src/ic-observers.c
new file mode 100644 (file)
index 0000000..ca20a32
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <stdlib.h>
+#include <errno.h>
+#include <glib.h>
+
+#include "iotcon-types.h"
+#include "ic.h"
+#include "ic-utils.h"
+#include "ic-observers.h"
+
+int icl_observers_create(iotcon_observers_h *ret_observers)
+{
+       FN_CALL;
+       RETV_IF(NULL == ret_observers, IOTCON_ERROR_INVALID_PARAMETER);
+
+       iotcon_observers_h observers = calloc(1, sizeof(struct icl_observers));
+       if (NULL == observers) {
+               ERR("calloc() Fail(%d)", errno);
+               return IOTCON_ERROR_OUT_OF_MEMORY;
+       }
+
+       *ret_observers = observers;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+int icl_observers_destroy(iotcon_observers_h observers)
+{
+       FN_CALL;
+       RETV_IF(NULL == observers, IOTCON_ERROR_INVALID_PARAMETER);
+
+       g_list_free(observers->observers_list);
+       free(observers);
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+int icl_observers_add(iotcon_observers_h observers, int obs_id)
+{
+       FN_CALL;
+       RETV_IF(NULL == observers, IOTCON_ERROR_INVALID_PARAMETER);
+
+       observers->observers_list = g_list_append(observers->observers_list,
+                       GUINT_TO_POINTER(obs_id));
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+int icl_observers_remove(iotcon_observers_h observers, int obs_id)
+{
+       FN_CALL;
+       RETV_IF(NULL == observers, IOTCON_ERROR_INVALID_PARAMETER);
+
+       observers->observers_list = g_list_remove(observers->observers_list,
+                       GUINT_TO_POINTER(obs_id));
+
+       return IOTCON_ERROR_NONE;
+}
+
diff --git a/src/ic-observers.h b/src/ic-observers.h
new file mode 100644 (file)
index 0000000..3968548
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __IOTCON_INTERNAL_OBSERVATION_H__
+#define __IOTCON_INTERNAL_OBSERVATION_H__
+
+#include <glib.h>
+#include "iotcon-types.h"
+
+struct icl_observers {
+       GList *observers_list;
+};
+
+int icl_observers_create(iotcon_observers_h *ret_observers);
+int icl_observers_destroy(iotcon_observers_h observers);
+int icl_observers_add(iotcon_observers_h observers, int obs_id);
+int icl_observers_remove(iotcon_observers_h observers, int obs_id);
+
+#endif /* __IOTCON_INTERNAL_OBSERVATION_H__ */
index 846cca1162ee04a77449c71b55cbd5ede88b37e5..03cb95f4d011c355edab61772145c0f24ad3949e 100644 (file)
@@ -65,12 +65,11 @@ iotcon_options_h icl_options_ref(iotcon_options_h options)
 }
 
 
-API int iotcon_options_create(iotcon_options_h *ret_options)
+int icl_options_create(iotcon_options_h *ret_options)
 {
        FN_CALL;
        iotcon_options_h options;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == ret_options, IOTCON_ERROR_INVALID_PARAMETER);
 
        options = calloc(1, sizeof(struct icl_options));
@@ -88,10 +87,9 @@ API int iotcon_options_create(iotcon_options_h *ret_options)
 }
 
 
-API int iotcon_options_destroy(iotcon_options_h options)
+int icl_options_destroy(iotcon_options_h options)
 {
        FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == options, IOTCON_ERROR_INVALID_PARAMETER);
 
        options->ref_count--;
@@ -108,11 +106,10 @@ API int iotcon_options_destroy(iotcon_options_h options)
 /* iotcon_options_h can have up to 2 options.
  * option id is always situated between 2048 and 3000.
  * Length of option data is less than or equal to 15. */
-API int iotcon_options_add(iotcon_options_h options, unsigned short id,
+int icl_options_add(iotcon_options_h options, unsigned short id,
                const char *data)
 {
        FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == options, IOTCON_ERROR_INVALID_PARAMETER);
        RETVM_IF(1 < options->ref_count, IOTCON_ERROR_INVALID_PARAMETER,
                        "Don't modify it. It is already set.");
@@ -132,12 +129,11 @@ API int iotcon_options_add(iotcon_options_h options, unsigned short id,
 }
 
 
-API int iotcon_options_remove(iotcon_options_h options, unsigned short id)
+int icl_options_remove(iotcon_options_h options, unsigned short id)
 {
        FN_CALL;
        gboolean is_removed;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == options, IOTCON_ERROR_INVALID_PARAMETER);
        RETVM_IF(1 < options->ref_count, IOTCON_ERROR_INVALID_PARAMETER,
                        "Don't modify it. It is already set.");
@@ -151,13 +147,12 @@ API int iotcon_options_remove(iotcon_options_h options, unsigned short id)
 }
 
 
-API int iotcon_options_lookup(iotcon_options_h options, unsigned short id,
+int icl_options_lookup(iotcon_options_h options, unsigned short id,
                char **data)
 {
        FN_CALL;
        char *value;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == options, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == data, IOTCON_ERROR_INVALID_PARAMETER);
 
@@ -173,14 +168,13 @@ API int iotcon_options_lookup(iotcon_options_h options, unsigned short id,
 }
 
 
-API int iotcon_options_foreach(iotcon_options_h options,
+int icl_options_foreach(iotcon_options_h options,
                iotcon_options_foreach_cb cb, void *user_data)
 {
        FN_CALL;
        GHashTableIter iter;
        gpointer key, value;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == options, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
 
@@ -192,3 +186,4 @@ API int iotcon_options_foreach(iotcon_options_h options,
 
        return IOTCON_ERROR_NONE;
 }
+
index 9e4b1bab4022396e3dfb9d133600ca597dbfb3c5..3584eda43db3715f771df27ee5a3b9965fc51840 100644 (file)
@@ -25,5 +25,11 @@ struct icl_options {
 };
 
 iotcon_options_h icl_options_ref(iotcon_options_h options);
+int icl_options_create(iotcon_options_h *ret_options);
+int icl_options_destroy(iotcon_options_h options);
+int icl_options_add(iotcon_options_h options, unsigned short id, const char *data);
+int icl_options_remove(iotcon_options_h options, unsigned short id);
+int icl_options_lookup(iotcon_options_h options, unsigned short id, char **data);
+int icl_options_foreach(iotcon_options_h options, iotcon_options_foreach_cb cb, void *user_data);
 
 #endif /* __IOTCON_INTERNAL_OPTIONS_H__ */
diff --git a/src/ic-presence.c b/src/ic-presence.c
deleted file mode 100644 (file)
index 8e37397..0000000
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "iotcon-types.h"
-#include "ic.h"
-#include "ic-utils.h"
-#include "ic-resource.h"
-#include "ic-presence.h"
-#include "ic-resource-types.h"
-#include "ic-ioty.h"
-
-API int iotcon_start_presence(unsigned int time_to_live)
-{
-       FN_CALL;
-       int ret;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
-                       IOTCON_ERROR_PERMISSION_DENIED);
-
-       ret = icl_ioty_start_presence(time_to_live);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_start_presence() Fail(%d)", ret);
-               return ret;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_stop_presence(void)
-{
-       FN_CALL;
-       int ret;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
-                       IOTCON_ERROR_PERMISSION_DENIED);
-
-       ret = icl_ioty_stop_presence();
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_stop_presence() Fail(%d)", ret);
-               return ret;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
-
-/* The length of resource_type should be less than or equal to 61. */
-API int iotcon_add_presence_cb(const char *host_address,
-               iotcon_connectivity_type_e connectivity_type,
-               const char *resource_type,
-               iotcon_presence_cb cb,
-               void *user_data,
-               iotcon_presence_h *presence_handle)
-{
-       FN_CALL;
-       int ret;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
-                       IOTCON_ERROR_PERMISSION_DENIED);
-       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == presence_handle, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(resource_type && (false == icl_resource_check_type(resource_type)),
-                       IOTCON_ERROR_INVALID_PARAMETER);
-
-       ret = icl_ioty_add_presence_cb(host_address, connectivity_type, resource_type,
-                       cb, user_data, presence_handle);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_add_presence_cb() Fail(%d)", ret);
-               return ret;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_remove_presence_cb(iotcon_presence_h presence)
-{
-       FN_CALL;
-       int ret;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
-                       IOTCON_ERROR_PERMISSION_DENIED);
-       RETV_IF(NULL == presence, IOTCON_ERROR_INVALID_PARAMETER);
-
-       ret = icl_ioty_remove_presence_cb(presence);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_remove_presence_cb() Fail(%d)", ret);
-               return ret;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_presence_get_host_address(iotcon_presence_h presence,
-               char **host_address)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == presence, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == host_address, IOTCON_ERROR_INVALID_PARAMETER);
-
-       *host_address = presence->host_address;
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_presence_get_connectivity_type(iotcon_presence_h presence,
-               iotcon_connectivity_type_e *connectivity_type)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == presence, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == connectivity_type, IOTCON_ERROR_INVALID_PARAMETER);
-
-       *connectivity_type = presence->connectivity_type;
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_presence_get_resource_type(iotcon_presence_h presence,
-               char **resource_type)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == presence, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == resource_type, IOTCON_ERROR_INVALID_PARAMETER);
-
-       *resource_type = presence->resource_type;
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_presence_response_get_host_address(
-               iotcon_presence_response_h response, char **host_address)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == response, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == host_address, IOTCON_ERROR_INVALID_PARAMETER);
-
-       *host_address = response->host_address;
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_presence_response_get_connectivity_type(
-               iotcon_presence_response_h response, iotcon_connectivity_type_e *connectivity_type)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == response, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == connectivity_type, IOTCON_ERROR_INVALID_PARAMETER);
-
-       *connectivity_type = response->connectivity_type;
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_presence_response_get_resource_type(
-               iotcon_presence_response_h response, char **resource_type)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == response, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == resource_type, IOTCON_ERROR_INVALID_PARAMETER);
-
-       *resource_type = response->resource_type;
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_presence_response_get_result(iotcon_presence_response_h response,
-               iotcon_presence_result_e *result)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == response, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == result, IOTCON_ERROR_INVALID_PARAMETER);
-
-       *result = response->result;
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_presence_response_get_trigger(iotcon_presence_response_h response,
-               iotcon_presence_trigger_e *trigger)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == response, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == trigger, IOTCON_ERROR_INVALID_PARAMETER);
-
-       if (IOTCON_PRESENCE_OK != response->result) {
-               ERR("trigger is valid if IOTCON_PRESENCE_OK");
-               return IOTCON_ERROR_INVALID_PARAMETER;
-       }
-
-       *trigger = response->trigger;
-
-       return IOTCON_ERROR_NONE;
-}
-
index 9c08eb1f7a485007f0b7c9490f8b8363d9217491..65527d9b4342b904751389b90f8703f3b6dfc275 100644 (file)
@@ -266,10 +266,12 @@ static gboolean _provisioning_find_timeout(gpointer user_data)
 
 static void _provisioning_free_find_cb_container(void *data)
 {
+       FN_CALL;
+
        icl_provisioning_find_cb_container_s *container = data;
 
        if (container->device) {
-               iotcon_provisioning_device_destroy(container->device);
+               icl_provisioning_device_destroy(container->device);
                container->oic_device = NULL;
        }
        if (container->oic_device)
@@ -437,6 +439,7 @@ static int _provisioning_find_security_version(
        }
        ICL_PROVISIONING_MUTEX_FIND_UNLOCK(container->cb_data);
 
+       SECURE_DBG("uri:[%s], connType:[0x%x]", uri, container->oic_device->connType);
        ret = OCDoResource(&container->handle, OC_REST_DISCOVER, uri, 0, 0,
                        container->oic_device->connType, OC_LOW_QOS, &cbdata, NULL, 0);
        icl_ioty_mutex_unlock();
@@ -545,7 +548,7 @@ static int _provisioning_find_secure_port(icl_provisioning_find_cb_container_s *
        }
        ICL_PROVISIONING_MUTEX_FIND_UNLOCK(container->cb_data);
 
-       DBG("uri:[%s]", uri);
+       SECURE_DBG("uri:[%s], connType:[0x%x]", uri, container->oic_device->connType);
        ret = OCDoResource(&container->handle, OC_REST_DISCOVER, uri, 0, 0,
                        container->oic_device->connType, OC_HIGH_QOS, &cbdata, NULL, 0);
        icl_ioty_mutex_unlock();
@@ -641,7 +644,7 @@ static OCStackApplicationResult _provisioning_find_cb(void *ctx, OCDoHandle hand
 }
 
 
-API int iotcon_provisioning_find_device(iotcon_provisioning_find_e type,
+int icl_provisioning_find_device(iotcon_provisioning_find_e type,
                iotcon_provisioning_found_device_cb cb, void *user_data)
 {
        FN_CALL;
@@ -650,7 +653,6 @@ API int iotcon_provisioning_find_device(iotcon_provisioning_find_e type,
        OCCallbackData cbdata = {0};
        icl_provisioning_find_cb_s *cb_data;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
 
        switch (type) {
@@ -687,6 +689,7 @@ API int iotcon_provisioning_find_device(iotcon_provisioning_find_e type,
                _provisioning_free_cb_data(cb_data);
                return ret;
        }
+       SECURE_DBG("uri:[%s], connType:[0x%x]", query, CT_DEFAULT);
        ret = OCDoResource(&cb_data->handle, OC_REST_DISCOVER, query, 0, 0, CT_DEFAULT,
                        OC_LOW_QOS, &cbdata, NULL, 0);
        icl_ioty_mutex_unlock();
@@ -697,7 +700,7 @@ API int iotcon_provisioning_find_device(iotcon_provisioning_find_e type,
        }
 
        /* timeout */
-       iotcon_get_timeout(&cb_data->timeout);
+       icl_get_timeout(&cb_data->timeout);
        cb_data->timer_id = g_timeout_add_seconds(cb_data->timeout,
                        _provisioning_find_timeout, cb_data);
 
index 50da7d348c05f4672a2eec022f6f4475bb6d91ef..e08c943f5efc1320c0a5587074544225b9e78da5 100644 (file)
@@ -29,6 +29,7 @@
 #include "ic-utils.h"
 #include "ic-ioty-parse.h"
 #include "ic-provisioning-struct.h"
+#include "ic-provisioning.h"
 
 #define ICL_PROVISIONING_REMOVE_TIMEOUT -1
 
@@ -60,9 +61,11 @@ static icl_provisioning_remove_cb_container_s* _provisioning_remove_cb_ref(
 }
 
 
-static void icl_provisioning_free_remove_cb_container(
+static void _icl_provisioning_free_remove_cb_container(
                icl_provisioning_remove_cb_container_s *container, bool is_complete)
 {
+       FN_CALL;
+
        int ret;
        OicUuid_t *uuid;
 
@@ -74,7 +77,7 @@ static void icl_provisioning_free_remove_cb_container(
                return;
 
        if (true == is_complete) {
-               uuid = icl_provisioning_convert_device_id(container->device_id);
+               uuid = icl_provisioning_oic_convert_device_id(container->device_id);
 
                ret = PDMDeleteDevice(uuid);
                if (OC_STACK_OK != ret)
@@ -90,15 +93,15 @@ static void icl_provisioning_free_remove_cb_container(
 }
 
 
-static void icl_provisioning_free_remove_delete_container(
+static void _icl_provisioning_free_remove_delete_container(
                icl_provisioning_remove_delete_container_s *container, bool is_complete)
 {
        FN_CALL;
 
        RET_IF(NULL == container);
 
-       iotcon_provisioning_device_destroy(container->dest_device);
-       icl_provisioning_free_remove_cb_container(container->cb_data, is_complete);
+       icl_provisioning_device_destroy(container->dest_device);
+       _icl_provisioning_free_remove_cb_container(container->cb_data, is_complete);
 
        free(container);
 }
@@ -124,7 +127,7 @@ static gboolean _provisioning_remove_idle_cb(gpointer p)
                                IOTCON_ERROR_NONE, is_complete, container->cb_data->user_data);
        }
 
-       icl_provisioning_free_remove_delete_container(container, is_complete);
+       _icl_provisioning_free_remove_delete_container(container, is_complete);
 
        return G_SOURCE_REMOVE;
 }
@@ -147,7 +150,7 @@ static gboolean _provisioning_remove_fail_idle_cb(gpointer p)
                is_complete = true;
 
                if (num_of_devices < 0) {
-                       icl_provisioning_free_remove_delete_container(container, is_complete);
+                       _icl_provisioning_free_remove_delete_container(container, is_complete);
                        return G_SOURCE_REMOVE;
                }
                if (container->cb_data->cb) {
@@ -166,7 +169,7 @@ static gboolean _provisioning_remove_fail_idle_cb(gpointer p)
                }
        }
 
-       icl_provisioning_free_remove_delete_container(container, is_complete);
+       _icl_provisioning_free_remove_delete_container(container, is_complete);
 
        return G_SOURCE_REMOVE;
 }
@@ -175,6 +178,8 @@ static gboolean _provisioning_remove_fail_idle_cb(gpointer p)
 static OCStackApplicationResult _provisioning_remove_device_delete_cb(void *ctx,
                OCDoHandle handle, OCClientResponse *resp)
 {
+       FN_CALL;
+
        int ret;
        OicUuid_t *uuid;
        OicUuid_t device_id = { {0} };
@@ -183,7 +188,7 @@ static OCStackApplicationResult _provisioning_remove_device_delete_cb(void *ctx,
        RETV_IF(NULL == container, OC_STACK_DELETE_TRANSACTION);
 
        if (ICL_PROVISIONING_REMOVE_TIMEOUT == container->timer_id) {
-               icl_provisioning_free_remove_delete_container(container, true);
+               _icl_provisioning_free_remove_delete_container(container, true);
                return OC_STACK_DELETE_TRANSACTION;
        }
 
@@ -208,7 +213,7 @@ static OCStackApplicationResult _provisioning_remove_device_delete_cb(void *ctx,
 
        memcpy(device_id.id, resp->identity.id, sizeof(device_id.id));
 
-       uuid = icl_provisioning_convert_device_id(container->cb_data->device_id);
+       uuid = icl_provisioning_oic_convert_device_id(container->cb_data->device_id);
 
        ret = PDMUnlinkDevices(uuid, &device_id);
        if (OC_STACK_OK != ret) {
@@ -243,6 +248,8 @@ static gboolean _provisioning_remove_device_delete_timeout(gpointer p)
 static int _provisioning_remove_device_delete(
                icl_provisioning_remove_delete_container_s *container)
 {
+       FN_CALL;
+
        int ret, timeout;
        char *host_address;
        char uri[PATH_MAX] = {0};
@@ -251,7 +258,7 @@ static int _provisioning_remove_device_delete(
        const char *cred_uri = "/oic/sec/cred";
        const char *subject_uuid = "subjectuuid";
 
-       device = icl_provisioning_device_get_device(container->dest_device);
+       device = icl_provisioning_oic_device_get_device(container->dest_device);
 
        ret = icl_provisioning_parse_oic_dev_address(&device->endpoint, device->securePort,
                        device->connType, &host_address);
@@ -273,6 +280,7 @@ static int _provisioning_remove_device_delete(
                ERR("icl_ioty_mutex_lock() Fail(%d)", ret);
                return ret;
        }
+       SECURE_DBG("uri:[%s], connType:[0x%x]", uri, device->connType);
        ret = OCDoResource(NULL, OC_REST_DELETE, uri, &device->endpoint, NULL,
                        device->connType, OC_HIGH_QOS, &cbdata, NULL, 0);
        icl_ioty_mutex_unlock();
@@ -282,7 +290,7 @@ static int _provisioning_remove_device_delete(
        }
 
        /* timeout */
-       iotcon_get_timeout(&timeout);
+       icl_get_timeout(&timeout);
        container->timer_id = g_timeout_add_seconds(timeout,
                        _provisioning_remove_device_delete_timeout, container);
 
@@ -313,7 +321,7 @@ static bool _provisioning_remove_device_found_cb(iotcon_provisioning_device_h de
                return IOTCON_FUNC_STOP;
        }
 
-       found_device = icl_provisioning_device_get_device(device);
+       found_device = icl_provisioning_oic_device_get_device(device);
 
        for (cur = cb_data->linked_devices; cur; cur = cur->next) {
                if (IC_EQUAL == memcmp(found_device->doxm->deviceID.id, cur->dev.id,
@@ -321,14 +329,14 @@ static bool _provisioning_remove_device_found_cb(iotcon_provisioning_device_h de
                        ret = iotcon_provisioning_device_clone(device, &container->dest_device);
                        if (IOTCON_ERROR_NONE != ret) {
                                ERR("iotcon_provisioning_device_clone() Fail");
-                               icl_provisioning_free_remove_delete_container(container, false);
+                               _icl_provisioning_free_remove_delete_container(container, false);
                                return IOTCON_FUNC_CONTINUE;
                        }
 
                        ret = _provisioning_remove_device_delete(container);
                        if (IOTCON_ERROR_NONE != ret) {
                                ERR("_provisioning_remove_device_delete() Fail(%d)", ret);
-                               icl_provisioning_free_remove_delete_container(container, false);
+                               _icl_provisioning_free_remove_delete_container(container, false);
                                return IOTCON_FUNC_CONTINUE;
                        }
                }
@@ -355,13 +363,13 @@ static gboolean _provisioning_remove_complete_idle_cb(gpointer p)
                                container->user_data);
        }
 
-       icl_provisioning_free_remove_cb_container(container, is_complete);
+       _icl_provisioning_free_remove_cb_container(container, is_complete);
 
        return G_SOURCE_REMOVE;
 }
 /* LCOV_EXCL_STOP */
 
-API int iotcon_provisioning_remove_device(const char *device_id,
+int icl_provisioning_remove_device(const char *device_id,
                iotcon_provisioning_remove_device_cb cb, void *user_data)
 {
        FN_CALL;
@@ -370,7 +378,6 @@ API int iotcon_provisioning_remove_device(const char *device_id,
        OCUuidList_t *cur;
        icl_provisioning_remove_cb_container_s *container;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == device_id, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
 
@@ -385,7 +392,7 @@ API int iotcon_provisioning_remove_device(const char *device_id,
        container->device_id = strdup(device_id);
        container->ref_count = 1;
 
-       uuid = icl_provisioning_convert_device_id(container->device_id);
+       uuid = icl_provisioning_oic_convert_device_id(container->device_id);
 
        /* Get Linked devices */
        ret = PDMGetLinkedDevices(uuid, &container->linked_devices,
@@ -393,7 +400,7 @@ API int iotcon_provisioning_remove_device(const char *device_id,
        if (OC_STACK_OK != ret) {
                ERR("PDMGetLinkedDevices() Fail(%d)", ret);
                free(uuid);
-               icl_provisioning_free_remove_cb_container(container, false);
+               _icl_provisioning_free_remove_cb_container(container, false);
                return ic_ioty_parse_oic_error(ret);
        }
 
@@ -410,18 +417,18 @@ API int iotcon_provisioning_remove_device(const char *device_id,
                if (OC_STACK_OK != ret) {
                        ERR("PDMSetLinkStale() Fail(%d)", ret);
                        free(uuid);
-                       icl_provisioning_free_remove_cb_container(container, false);
+                       _icl_provisioning_free_remove_cb_container(container, false);
                        return ic_ioty_parse_oic_error(ret);
                }
        }
        free(uuid);
 
        /* Find owned devices */
-       ret = iotcon_provisioning_find_device(IOTCON_PROVISIONING_FIND_OWNED,
+       ret = icl_provisioning_find_device(IOTCON_PROVISIONING_FIND_OWNED,
                        _provisioning_remove_device_found_cb, container);
        if (IOTCON_ERROR_NONE != ret) {
-               ERR("iotcon_provisioning_find_device() Fail(%d)", ret);
-               icl_provisioning_free_remove_cb_container(container, false);
+               ERR("icl_provisioning_find_device() Fail(%d)", ret);
+               _icl_provisioning_free_remove_cb_container(container, false);
                return ret;
        }
 
index e28d0d14aad64c85fb443b8ef66993dbd3c29b23..ef83418477fe7a1434d68b0f320edc4bf60d06ef 100644 (file)
@@ -78,7 +78,7 @@ void icl_provisioning_print_uuid(OicUuid_t *uuid)
 }
 
 
-OicUuid_t* icl_provisioning_convert_device_id(const char *device_id)
+OicUuid_t* icl_provisioning_oic_convert_device_id(const char *device_id)
 {
        OicUuid_t *uuid;
 
@@ -159,7 +159,7 @@ int icl_provisioning_parse_oic_dev_address(OCDevAddr *dev_addr, int secure_port,
 }
 
 
-OCProvisionDev_t* icl_provisioning_device_clone(OCProvisionDev_t *src)
+OCProvisionDev_t* icl_provisioning_oic_device_clone(OCProvisionDev_t *src)
 {
        FN_CALL;
 
@@ -251,9 +251,9 @@ int icl_provisioning_device_create(OCProvisionDev_t *device,
                return IOTCON_ERROR_OUT_OF_MEMORY;
        }
 
-       temp->device = icl_provisioning_device_clone(device);
+       temp->device = icl_provisioning_oic_device_clone(device);
        if (NULL == temp->device) {
-               ERR("icl_provisioning_device_clone() Fail");
+               ERR("icl_provisioning_oic_device_clone() Fail");
                free(temp);
                return IOTCON_ERROR_OUT_OF_MEMORY;
        }
@@ -277,14 +277,13 @@ int icl_provisioning_device_create(OCProvisionDev_t *device,
 }
 
 
-API int iotcon_provisioning_device_clone(iotcon_provisioning_device_h device,
+int icl_provisioning_device_clone(iotcon_provisioning_device_h device,
                iotcon_provisioning_device_h *cloned_device)
 {
        FN_CALL;
        int ret;
        iotcon_provisioning_device_h temp;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == device, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == cloned_device, IOTCON_ERROR_INVALID_PARAMETER);
 
@@ -311,11 +310,10 @@ iotcon_provisioning_device_h icl_provisioning_device_ref(
 }
 
 
-API int iotcon_provisioning_device_destroy(iotcon_provisioning_device_h device)
+int icl_provisioning_device_destroy(iotcon_provisioning_device_h device)
 {
        FN_CALL;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == device, IOTCON_ERROR_INVALID_PARAMETER);
 
        if (true == device->is_found) {
@@ -365,7 +363,7 @@ bool icl_provisioning_device_is_found(iotcon_provisioning_device_h device)
 }
 
 
-OCProvisionDev_t* icl_provisioning_device_get_device(
+OCProvisionDev_t* icl_provisioning_oic_device_get_device(
                iotcon_provisioning_device_h device)
 {
        FN_CALL;
@@ -375,12 +373,11 @@ OCProvisionDev_t* icl_provisioning_device_get_device(
 }
 
 
-API int iotcon_provisioning_device_get_host_address(iotcon_provisioning_device_h device,
+int icl_provisioning_device_get_host_address(iotcon_provisioning_device_h device,
                char **host_address)
 {
        FN_CALL;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == device, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == host_address, IOTCON_ERROR_INVALID_PARAMETER);
 
@@ -390,12 +387,11 @@ API int iotcon_provisioning_device_get_host_address(iotcon_provisioning_device_h
 }
 
 
-API int iotcon_provisioning_device_get_connectivity_type(
+int icl_provisioning_device_get_connectivity_type(
                iotcon_provisioning_device_h device,
                iotcon_connectivity_type_e *connectivity_type)
 {
        FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == device, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == connectivity_type, IOTCON_ERROR_INVALID_PARAMETER);
 
@@ -405,11 +401,10 @@ API int iotcon_provisioning_device_get_connectivity_type(
 }
 
 
-API int iotcon_provisioning_device_get_id(iotcon_provisioning_device_h device,
+int icl_provisioning_device_get_id(iotcon_provisioning_device_h device,
                char **device_id)
 {
        FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == device, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == device_id, IOTCON_ERROR_INVALID_PARAMETER);
 
@@ -442,14 +437,13 @@ static int _provisioning_parse_oxm(OicSecOxm_t oic_oxm, iotcon_provisioning_oxm_
 }
 
 
-API int iotcon_provisioning_device_get_oxm(iotcon_provisioning_device_h device,
+int icl_provisioning_device_get_oxm(iotcon_provisioning_device_h device,
                iotcon_provisioning_oxm_e *oxm)
 {
        FN_CALL;
        int ret;
        iotcon_provisioning_oxm_e temp;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == device, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == oxm, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == device->device, IOTCON_ERROR_INVALID_PARAMETER);
@@ -467,11 +461,10 @@ API int iotcon_provisioning_device_get_oxm(iotcon_provisioning_device_h device,
 }
 
 
-API int iotcon_provisioning_device_is_owned(iotcon_provisioning_device_h device,
+int icl_provisioning_device_is_owned(iotcon_provisioning_device_h device,
                bool *is_owned)
 {
        FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == device, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == device->device, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == device->device->doxm, IOTCON_ERROR_INVALID_PARAMETER);
@@ -506,12 +499,11 @@ void icl_provisioning_device_print(iotcon_provisioning_device_h device)
 }
 
 
-API int iotcon_provisioning_acl_create(iotcon_provisioning_acl_h *acl)
+int icl_provisioning_acl_create(iotcon_provisioning_acl_h *acl)
 {
        FN_CALL;
        iotcon_provisioning_acl_h temp;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == acl, IOTCON_ERROR_INVALID_PARAMETER);
 
        temp = calloc(1, sizeof(struct icl_provisioning_acl));
@@ -538,10 +530,9 @@ iotcon_provisioning_acl_h icl_provisioning_acl_ref(iotcon_provisioning_acl_h acl
 }
 
 
-API int iotcon_provisioning_acl_destroy(iotcon_provisioning_acl_h acl)
+int icl_provisioning_acl_destroy(iotcon_provisioning_acl_h acl)
 {
        FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == acl, IOTCON_ERROR_INVALID_PARAMETER);
 
        acl->ref_count--;
@@ -556,19 +547,18 @@ API int iotcon_provisioning_acl_destroy(iotcon_provisioning_acl_h acl)
 }
 
 
-API int iotcon_provisioning_acl_set_subject(iotcon_provisioning_acl_h acl,
+int icl_provisioning_acl_set_subject(iotcon_provisioning_acl_h acl,
                iotcon_provisioning_device_h device)
 {
        FN_CALL;
        OCProvisionDev_t *dev;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == acl, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == device, IOTCON_ERROR_INVALID_PARAMETER);
 
-       dev = icl_provisioning_device_clone(device->device);
+       dev = icl_provisioning_oic_device_clone(device->device);
        if (NULL == dev) {
-               ERR("icl_provisioning_device_clone() Fail");
+               ERR("icl_provisioning_oic_device_clone() Fail");
                return IOTCON_ERROR_OUT_OF_MEMORY;
        }
 
@@ -580,12 +570,11 @@ API int iotcon_provisioning_acl_set_subject(iotcon_provisioning_acl_h acl,
 }
 
 
-API int iotcon_provisioning_acl_set_all_subject(iotcon_provisioning_acl_h acl)
+int icl_provisioning_acl_set_all_subject(iotcon_provisioning_acl_h acl)
 {
        FN_CALL;
        OCProvisionDev_t *dev;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == acl, IOTCON_ERROR_INVALID_PARAMETER);
 
        dev = calloc(1, sizeof(OCProvisionDev_t));
@@ -610,7 +599,7 @@ API int iotcon_provisioning_acl_set_all_subject(iotcon_provisioning_acl_h acl)
 }
 
 
-OCProvisionDev_t* icl_provisioning_acl_get_subject(iotcon_provisioning_acl_h acl)
+OCProvisionDev_t* icl_provisioning_oic_acl_get_subject(iotcon_provisioning_acl_h acl)
 {
        RETV_IF(NULL == acl, NULL);
 
@@ -618,11 +607,10 @@ OCProvisionDev_t* icl_provisioning_acl_get_subject(iotcon_provisioning_acl_h acl
 }
 
 
-API int iotcon_provisioning_acl_add_resource(iotcon_provisioning_acl_h acl,
+int icl_provisioning_acl_add_resource(iotcon_provisioning_acl_h acl,
                const char *uri_path)
 {
        FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == acl, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == uri_path, IOTCON_ERROR_INVALID_PARAMETER);
 
@@ -632,11 +620,10 @@ API int iotcon_provisioning_acl_add_resource(iotcon_provisioning_acl_h acl,
 }
 
 
-API int iotcon_provisioning_acl_set_permission(iotcon_provisioning_acl_h acl,
+int icl_provisioning_acl_set_permission(iotcon_provisioning_acl_h acl,
                int permission)
 {
        FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == acl, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(permission <= 0 || IOTCON_PERMISSION_FULL_CONTROL < permission,
                        IOTCON_ERROR_INVALID_PARAMETER);
index 9f6aac2a789a5c5dff04ff747a217f595f4aeb64..d4745ebd8c4db95e8708f7b7ee5892208b9e68f0 100644 (file)
 
 #include <ocprovisioningmanager.h>
 
+int icl_provisioning_device_clone(iotcon_provisioning_device_h device,
+               iotcon_provisioning_device_h *cloned_device);
+int icl_provisioning_device_destroy(iotcon_provisioning_device_h device);
+int icl_provisioning_device_get_host_address(iotcon_provisioning_device_h device,
+               char **host_address);
+int icl_provisioning_device_get_connectivity_type(
+               iotcon_provisioning_device_h device,
+               iotcon_connectivity_type_e *connectivity_type);
+int icl_provisioning_device_get_id(iotcon_provisioning_device_h device,
+               char **device_id);
+int icl_provisioning_device_get_oxm(iotcon_provisioning_device_h device,
+               iotcon_provisioning_oxm_e *oxm);
+int icl_provisioning_device_is_owned(iotcon_provisioning_device_h device,
+               bool *is_owned);
+int icl_provisioning_acl_create(iotcon_provisioning_acl_h *acl);
+int icl_provisioning_acl_destroy(iotcon_provisioning_acl_h acl);
+int icl_provisioning_acl_set_subject(iotcon_provisioning_acl_h acl,
+               iotcon_provisioning_device_h device);
+int icl_provisioning_acl_set_all_subject(iotcon_provisioning_acl_h acl);
+int icl_provisioning_acl_add_resource(iotcon_provisioning_acl_h acl,
+               const char *uri_path);
+int icl_provisioning_acl_set_permission(iotcon_provisioning_acl_h acl,
+               int permission);
+
+
 void icl_provisioning_print_uuid(OicUuid_t *uuid);
-OicUuid_t* icl_provisioning_convert_device_id(const char *device_id);
+OicUuid_t* icl_provisioning_oic_convert_device_id(const char *device_id);
 int icl_provisioning_parse_oic_dev_address(OCDevAddr *dev_addr, int secure_port,
                OCConnectivityType conn_type, char **host_address);
 
 iotcon_provisioning_device_h icl_provisioning_device_ref(
                iotcon_provisioning_device_h device);
-OCProvisionDev_t* icl_provisioning_device_clone(OCProvisionDev_t *src);
+OCProvisionDev_t* icl_provisioning_oic_device_clone(OCProvisionDev_t *src);
 int icl_provisioning_device_create(OCProvisionDev_t *device,
                iotcon_provisioning_device_h *ret_device);
 iotcon_provisioning_device_h icl_provisioning_device_ref(
@@ -36,7 +61,7 @@ void icl_provisioning_device_unset_found(iotcon_provisioning_device_h device);
 bool icl_provisioning_device_is_found(iotcon_provisioning_device_h device);
 void icl_provisioning_device_set_owned(iotcon_provisioning_device_h device);
 
-OCProvisionDev_t* icl_provisioning_device_get_device(
+OCProvisionDev_t* icl_provisioning_oic_device_get_device(
                iotcon_provisioning_device_h device);
 
 void icl_provisioning_device_print(iotcon_provisioning_device_h device);
@@ -45,7 +70,7 @@ void icl_provisioning_device_print_uuid(iotcon_provisioning_device_h device);
 
 iotcon_provisioning_acl_h icl_provisioning_acl_ref(iotcon_provisioning_acl_h acl);
 
-OCProvisionDev_t* icl_provisioning_acl_get_subject(
+OCProvisionDev_t* icl_provisioning_oic_acl_get_subject(
                iotcon_provisioning_acl_h acl);
 int icl_provisioning_acl_get_resource_count(iotcon_provisioning_acl_h acl);
 char* icl_provisioning_acl_get_nth_resource(iotcon_provisioning_acl_h acl, int index);
index 41679101ab775887477a848c49c2509663b62ad6..acd37b01e13649355af9716f7ca7cbc2d3b71a26 100644 (file)
@@ -31,6 +31,7 @@
 #include "ic-utils.h"
 #include "ic-ioty.h"
 #include "ic-ioty-parse.h"
+#include "ic-provisioning.h"
 #include "ic-provisioning-struct.h"
 
 #define ICL_PROVISIONING_TIMEOUT_MAX 10
@@ -121,14 +122,10 @@ static void _provisioning_set_randompin()
 }
 
 
-API int iotcon_provisioning_initialize(const char *file_path, const char *db_path)
+int icl_provisioning_initialize(const char *file_path, const char *db_path)
 {
-       FN_CALL;
        int ret;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(false == ic_utils_check_permission((IC_PERMISSION_INTERNET
-                                       |IC_PERMISSION_NETWORK_GET)), IOTCON_ERROR_PERMISSION_DENIED);
        RETV_IF(NULL == file_path, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == db_path, IOTCON_ERROR_INVALID_PARAMETER);
 
@@ -144,28 +141,22 @@ API int iotcon_provisioning_initialize(const char *file_path, const char *db_pat
        else
                DBG("No provisioning DB File, creating new.");
 
-       ret = icl_ioty_mutex_lock();
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_mutex_lock() Fail(%d)", ret);
-               iotcon_deinitialize();
-               return ret;
-       }
-
+       ic_utils_mutex_lock(IC_UTILS_MUTEX_IOTY);
        ret = OCInitPM(db_path);
        if (OC_STACK_OK != ret) {
                ERR("OCInitPM() Fail(%d)", ret);
                ic_utils_mutex_unlock(IC_UTILS_MUTEX_IOTY);
-               iotcon_deinitialize();
+               icl_deinitialize();
                return _provisioning_parse_oic_error(ret);
        }
 
        _provisioning_set_justworks();
 
        ret = OCSetOwnerTransferCallbackData(OIC_JUST_WORKS, &icl_justworks_otmcb);
-       icl_ioty_mutex_unlock();
+       ic_utils_mutex_unlock(IC_UTILS_MUTEX_IOTY);
        if (OC_STACK_OK != ret) {
                ERR("OCSetOwnerTransferCallbackData() Fail(%d)", ret);
-               iotcon_deinitialize();
+               icl_deinitialize();
                return _provisioning_parse_oic_error(ret);
        }
 
@@ -192,13 +183,12 @@ static void _provisioning_input_pin_cb(char *pin, size_t len)
 }
 /* LCOV_EXCL_STOP */
 
-API int iotcon_provisioning_set_randompin_cb(iotcon_provisioning_randompin_cb cb,
+int icl_provisioning_set_randompin_cb(iotcon_provisioning_randompin_cb cb,
                void *user_data)
 {
        FN_CALL;
        int ret;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
 
        _provisioning_set_randompin();
@@ -247,7 +237,7 @@ static void _provisioning_ownership_transfer_cb_container_destroy(
                struct icl_provisioning_ownership_transfer_cb_container *container)
 {
        if (container->device) {
-               iotcon_provisioning_device_destroy(container->device);
+               icl_provisioning_device_destroy(container->device);
                container->device = NULL;
        }
 
@@ -257,6 +247,8 @@ static void _provisioning_ownership_transfer_cb_container_destroy(
 
 static gboolean _provisioning_ownership_transfer_idle_cb(gpointer p)
 {
+       FN_CALL;
+
        struct icl_provisioning_ownership_transfer_cb_container *container = p;
 
        icl_provisioning_device_set_owned(container->device);
@@ -291,6 +283,8 @@ static void _provisioning_ownership_transfer_cb(void *ctx, int n_of_res,
 
 static gboolean _provisioning_register_unowned_device(gpointer p)
 {
+       FN_CALL;
+
        int ret;
        OCProvisionDev_t *dev_list;
        struct icl_provisioning_ownership_transfer_cb_container *container;
@@ -310,7 +304,7 @@ static gboolean _provisioning_register_unowned_device(gpointer p)
                return G_SOURCE_CONTINUE;
        }
 
-       dev_list = icl_provisioning_device_get_device(container->device);
+       dev_list = icl_provisioning_oic_device_get_device(container->device);
 
        ret = icl_ioty_mutex_lock();
        if (IOTCON_ERROR_NONE != ret) {
@@ -331,7 +325,7 @@ static gboolean _provisioning_register_unowned_device(gpointer p)
 }
 
 
-API int iotcon_provisioning_register_unowned_device(
+int icl_provisioning_register_unowned_device(
                iotcon_provisioning_device_h device,
                iotcon_provisioning_ownership_transfer_cb cb,
                void *user_data)
@@ -339,7 +333,6 @@ API int iotcon_provisioning_register_unowned_device(
        FN_CALL;
        struct icl_provisioning_ownership_transfer_cb_container *container;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == device, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
 
@@ -377,11 +370,11 @@ static void _provisioning_provision_cred_cb_container_destroy(
        FN_CALL;
 
        if (container->device1) {
-               iotcon_provisioning_device_destroy(container->device1);
+               icl_provisioning_device_destroy(container->device1);
                container->device1 = NULL;
        }
        if (container->device2) {
-               iotcon_provisioning_device_destroy(container->device2);
+               icl_provisioning_device_destroy(container->device2);
                container->device2 = NULL;
        }
 
@@ -391,6 +384,8 @@ static void _provisioning_provision_cred_cb_container_destroy(
 
 static gboolean _provisioning_provision_cred_idle_cb(gpointer p)
 {
+       FN_CALL;
+
        struct icl_provisioning_provision_cred_cb_container *container = p;
 
        if (container->cb) {
@@ -425,7 +420,7 @@ static void _provisioning_provision_cred_cb(void *ctx, int n_of_res,
 }
 
 
-API int iotcon_provisioning_provision_cred(iotcon_provisioning_device_h device1,
+int icl_provisioning_provision_cred(iotcon_provisioning_device_h device1,
                iotcon_provisioning_device_h device2,
                iotcon_provisioning_provision_cred_cb cb,
                void *user_data)
@@ -435,7 +430,6 @@ API int iotcon_provisioning_provision_cred(iotcon_provisioning_device_h device1,
        size_t key_size;
        struct icl_provisioning_provision_cred_cb_container *container;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == device1, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == device2, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
@@ -473,8 +467,8 @@ API int iotcon_provisioning_provision_cred(iotcon_provisioning_device_h device1,
        ret = OCProvisionCredentials(container,
                        SYMMETRIC_PAIR_WISE_KEY,
                        key_size,
-                       icl_provisioning_device_get_device(container->device1),
-                       icl_provisioning_device_get_device(container->device2),
+                       icl_provisioning_oic_device_get_device(container->device1),
+                       icl_provisioning_oic_device_get_device(container->device2),
                        _provisioning_provision_cred_cb);
        icl_ioty_mutex_unlock();
        if (OC_STACK_OK != ret) {
@@ -493,7 +487,7 @@ static void _provisioning_provision_acl_cb_container_destroy(
        FN_CALL;
 
        if (container->device) {
-               iotcon_provisioning_device_destroy(container->device);
+               icl_provisioning_device_destroy(container->device);
                container->device = NULL;
        }
 
@@ -544,7 +538,7 @@ static OicSecAcl_t* _provisioning_convert_acl(iotcon_provisioning_device_h devic
        }
        oic_acl->aces = ace;
 
-       subject = icl_provisioning_acl_get_subject(acl);
+       subject = icl_provisioning_oic_acl_get_subject(acl);
 
        memcpy(&ace->subjectuuid, &subject->doxm->deviceID, 128/8);
 
@@ -598,7 +592,7 @@ static OicSecAcl_t* _provisioning_convert_acl(iotcon_provisioning_device_h devic
        permission = icl_provisioning_acl_get_permission(acl);
        ace->permission = icl_provisioning_acl_convert_permission(permission);
 
-       oic_device = icl_provisioning_device_get_device(device);
+       oic_device = icl_provisioning_oic_device_get_device(device);
 
        memcpy(&oic_acl->rownerID, &oic_device->doxm->deviceID, sizeof(OicUuid_t));
 
@@ -610,6 +604,8 @@ static OicSecAcl_t* _provisioning_convert_acl(iotcon_provisioning_device_h devic
 
 static gboolean _provisioning_provision_acl_idle_cb(void *p)
 {
+       FN_CALL;
+
        struct icl_provisioning_provision_acl_cb_container *container = p;
 
        if (container->cb) {
@@ -644,7 +640,7 @@ static void _provisioning_provision_acl_cb(void *ctx, int n_of_res,
 }
 
 
-API int iotcon_provisioning_provision_acl(iotcon_provisioning_device_h device,
+int icl_provisioning_provision_acl(iotcon_provisioning_device_h device,
                iotcon_provisioning_acl_h acl,
                iotcon_provisioning_provision_acl_cb cb,
                void *user_data)
@@ -654,7 +650,6 @@ API int iotcon_provisioning_provision_acl(iotcon_provisioning_device_h device,
        OicSecAcl_t *oic_acl;
        struct icl_provisioning_provision_acl_cb_container *container;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == device, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == acl, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
@@ -681,7 +676,7 @@ API int iotcon_provisioning_provision_acl(iotcon_provisioning_device_h device,
        }
 
        ret = OCProvisionACL(container,
-                       icl_provisioning_device_get_device(container->device),
+                       icl_provisioning_oic_device_get_device(container->device),
                        oic_acl,
                        _provisioning_provision_acl_cb);
        icl_ioty_mutex_unlock();
@@ -701,19 +696,19 @@ static void _provisioning_pairwise_devices_cb_container_destroy(
        FN_CALL;
 
        if (container->device1) {
-               iotcon_provisioning_device_destroy(container->device1);
+               icl_provisioning_device_destroy(container->device1);
                container->device1 = NULL;
        }
        if (container->acl1) {
-               iotcon_provisioning_acl_destroy(container->acl1);
+               icl_provisioning_acl_destroy(container->acl1);
                container->acl1 = NULL;
        }
        if (container->device2) {
-               iotcon_provisioning_device_destroy(container->device2);
+               icl_provisioning_device_destroy(container->device2);
                container->device2 = NULL;
        }
        if (container->acl2) {
-               iotcon_provisioning_acl_destroy(container->acl2);
+               icl_provisioning_acl_destroy(container->acl2);
                container->acl2 = NULL;
        }
 
@@ -723,6 +718,8 @@ static void _provisioning_pairwise_devices_cb_container_destroy(
 
 static gboolean _provisioning_pairwise_devices_idle_cb(void *p)
 {
+       FN_CALL;
+
        struct icl_provisioning_pairwise_devices_cb_container *container = p;
 
        if (container->cb) {
@@ -757,7 +754,7 @@ static void _provisioning_pairwise_devices_cb(void *ctx, int n_of_res,
 }
 
 
-API int iotcon_provisioning_pairwise_devices(iotcon_provisioning_device_h device1,
+int icl_provisioning_pairwise_devices(iotcon_provisioning_device_h device1,
                iotcon_provisioning_acl_h acl1,
                iotcon_provisioning_device_h device2,
                iotcon_provisioning_acl_h acl2,
@@ -772,7 +769,6 @@ API int iotcon_provisioning_pairwise_devices(iotcon_provisioning_device_h device
        OicSecAcl_t *oic_acl2 = NULL;
        struct icl_provisioning_pairwise_devices_cb_container *container;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == device1, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == device2, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
@@ -812,9 +808,9 @@ API int iotcon_provisioning_pairwise_devices(iotcon_provisioning_device_h device
        ret = OCProvisionPairwiseDevices(container,
                        SYMMETRIC_PAIR_WISE_KEY,
                        key_size,
-                       icl_provisioning_device_get_device(container->device1),
+                       icl_provisioning_oic_device_get_device(container->device1),
                        oic_acl1,
-                       icl_provisioning_device_get_device(container->device2),
+                       icl_provisioning_oic_device_get_device(container->device2),
                        oic_acl2,
                        _provisioning_pairwise_devices_cb);
        icl_ioty_mutex_unlock();
@@ -832,11 +828,11 @@ static void _provisioning_unlink_pairwise_cb_container_destroy(
                struct icl_provisioning_unlink_pairwise_cb_container *container)
 {
        if (container->device1) {
-               iotcon_provisioning_device_destroy(container->device1);
+               icl_provisioning_device_destroy(container->device1);
                container->device1 = NULL;
        }
        if (container->device2) {
-               iotcon_provisioning_device_destroy(container->device2);
+               icl_provisioning_device_destroy(container->device2);
                container->device2 = NULL;
        }
 
@@ -846,6 +842,8 @@ static void _provisioning_unlink_pairwise_cb_container_destroy(
 
 static gboolean _provisioning_unlink_pairwise_idle_cb(gpointer p)
 {
+       FN_CALL;
+
        struct icl_provisioning_unlink_pairwise_cb_container *container = p;
 
        if (container->cb) {
@@ -879,7 +877,7 @@ static void _provisioning_unlink_pairwise_cb(void *ctx, int n_of_res,
 }
 
 
-API int iotcon_provisioning_unlink_pairwise(iotcon_provisioning_device_h device1,
+int icl_provisioning_unlink_pairwise(iotcon_provisioning_device_h device1,
                iotcon_provisioning_device_h device2,
                iotcon_provisioning_unlink_pairwise_cb cb,
                void *user_data)
@@ -888,7 +886,6 @@ API int iotcon_provisioning_unlink_pairwise(iotcon_provisioning_device_h device1
        int ret;
        struct icl_provisioning_unlink_pairwise_cb_container *container;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == device1, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == device2, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
@@ -913,8 +910,8 @@ API int iotcon_provisioning_unlink_pairwise(iotcon_provisioning_device_h device1
        }
 
        ret = OCUnlinkDevices(container,
-                       icl_provisioning_device_get_device(container->device1),
-                       icl_provisioning_device_get_device(container->device2),
+                       icl_provisioning_oic_device_get_device(container->device1),
+                       icl_provisioning_oic_device_get_device(container->device2),
                        _provisioning_unlink_pairwise_cb);
        icl_ioty_mutex_unlock();
        if (OC_STACK_OK != ret) {
diff --git a/src/ic-provisioning.h b/src/ic-provisioning.h
new file mode 100644 (file)
index 0000000..265f65b
--- /dev/null
@@ -0,0 +1,53 @@
+/*\r
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+#ifndef __IOTCON_INTERNAL_PROVISIONING_H__\r
+#define __IOTCON_INTERNAL_PROVISIONING_H__\r
+\r
+#include <iotcon-provisioning.h>\r
+\r
+int icl_provisioning_initialize(const char *file_path, const char *db_path);\r
+int icl_provisioning_set_randompin_cb(iotcon_provisioning_randompin_cb cb,\r
+               void *user_data);\r
+int icl_provisioning_register_unowned_device(\r
+               iotcon_provisioning_device_h device,\r
+               iotcon_provisioning_ownership_transfer_cb cb,\r
+               void *user_data);\r
+int icl_provisioning_provision_cred(iotcon_provisioning_device_h device1,\r
+               iotcon_provisioning_device_h device2,\r
+               iotcon_provisioning_provision_cred_cb cb,\r
+               void *user_data);\r
+int icl_provisioning_provision_acl(iotcon_provisioning_device_h device,\r
+               iotcon_provisioning_acl_h acl,\r
+               iotcon_provisioning_provision_acl_cb cb,\r
+               void *user_data);\r
+int icl_provisioning_pairwise_devices(iotcon_provisioning_device_h device1,\r
+               iotcon_provisioning_acl_h acl1,\r
+               iotcon_provisioning_device_h device2,\r
+               iotcon_provisioning_acl_h acl2,\r
+               iotcon_provisioning_pairwise_devices_cb cb,\r
+               void *user_data);\r
+int icl_provisioning_unlink_pairwise(iotcon_provisioning_device_h device1,\r
+               iotcon_provisioning_device_h device2,\r
+               iotcon_provisioning_unlink_pairwise_cb cb,\r
+               void *user_data);\r
+\r
+int icl_provisioning_find_device(iotcon_provisioning_find_e type,\r
+               iotcon_provisioning_found_device_cb cb, void *user_data);\r
+\r
+int icl_provisioning_remove_device(const char *device_id,\r
+               iotcon_provisioning_remove_device_cb cb, void *user_data);\r
+\r
+#endif /* __IOTCON_INTERNAL_PROVISIONING_H__ */\r
index fa9cd3d8056929426972244845c40098e3465633..90f26c0c3d99631b14915fdb55dd98a38962380a 100644 (file)
 #include "ic-resource-types.h"
 #include "ic-query.h"
 
-API int iotcon_query_create(iotcon_query_h *ret_query)
+int icl_query_create(iotcon_query_h *ret_query)
 {
        FN_CALL;
        iotcon_query_h query;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == ret_query, IOTCON_ERROR_INVALID_PARAMETER);
 
        query = calloc(1, sizeof(struct icl_query));
@@ -49,10 +48,9 @@ API int iotcon_query_create(iotcon_query_h *ret_query)
 }
 
 
-API int iotcon_query_destroy(iotcon_query_h query)
+int icl_query_destroy(iotcon_query_h query)
 {
        FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == query, IOTCON_ERROR_INVALID_PARAMETER);
 
        g_hash_table_unref(query->hash);
@@ -62,17 +60,16 @@ API int iotcon_query_destroy(iotcon_query_h query)
 }
 
 
-API int iotcon_query_get_resource_type(iotcon_query_h query,
+int icl_query_get_resource_type(iotcon_query_h query,
                char **resource_type)
 {
        FN_CALL;
        char *type;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == query, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == resource_type, IOTCON_ERROR_INVALID_PARAMETER);
 
-       iotcon_query_lookup(query, ICL_QUERY_KEY_RESOURCE_TYPE, &type);
+       icl_query_lookup(query, ICL_QUERY_KEY_RESOURCE_TYPE, &type);
        if (NULL == type) {
                ERR("resource_type is NULL");
                return IOTCON_ERROR_NO_DATA;
@@ -83,16 +80,15 @@ API int iotcon_query_get_resource_type(iotcon_query_h query,
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_query_get_interface(iotcon_query_h query, char **resource_iface)
+int icl_query_get_interface(iotcon_query_h query, char **resource_iface)
 {
        FN_CALL;
        char *iface = NULL;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == query, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == resource_iface, IOTCON_ERROR_INVALID_PARAMETER);
 
-       iotcon_query_lookup(query, ICL_QUERY_KEY_INTERFACE, &iface);
+       icl_query_lookup(query, ICL_QUERY_KEY_INTERFACE, &iface);
        if (NULL == iface) {
                ERR("iface is NULL");
                return IOTCON_ERROR_NO_DATA;
@@ -103,7 +99,7 @@ API int iotcon_query_get_interface(iotcon_query_h query, char **resource_iface)
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_query_set_resource_type(iotcon_query_h query,
+int icl_query_set_resource_type(iotcon_query_h query,
                const char *resource_type)
 {
        FN_CALL;
@@ -111,7 +107,6 @@ API int iotcon_query_set_resource_type(iotcon_query_h query,
        int length_new = 0;
        char *value = NULL;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == query, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(resource_type && (false == icl_resource_check_type(resource_type)),
                        IOTCON_ERROR_INVALID_PARAMETER);
@@ -129,22 +124,21 @@ API int iotcon_query_set_resource_type(iotcon_query_h query,
        }
 
        if (value)
-               iotcon_query_remove(query, ICL_QUERY_KEY_RESOURCE_TYPE);
+               icl_query_remove(query, ICL_QUERY_KEY_RESOURCE_TYPE);
 
        if (resource_type)
-               iotcon_query_add(query, ICL_QUERY_KEY_RESOURCE_TYPE, resource_type);
+               icl_query_add(query, ICL_QUERY_KEY_RESOURCE_TYPE, resource_type);
 
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_query_set_interface(iotcon_query_h query, const char *resource_iface)
+int icl_query_set_interface(iotcon_query_h query, const char *resource_iface)
 {
        FN_CALL;
        int length_old = 0;
        int length_new = 0;
        char *value = NULL;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == query, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(resource_iface && (false == icl_resource_check_interface(resource_iface)),
                        IOTCON_ERROR_INVALID_PARAMETER);
@@ -162,20 +156,19 @@ API int iotcon_query_set_interface(iotcon_query_h query, const char *resource_if
        }
 
        if (value)
-               iotcon_query_remove(query, ICL_QUERY_KEY_INTERFACE);
+               icl_query_remove(query, ICL_QUERY_KEY_INTERFACE);
 
-       iotcon_query_add(query, ICL_QUERY_KEY_INTERFACE, resource_iface);
+       icl_query_add(query, ICL_QUERY_KEY_INTERFACE, resource_iface);
 
        return IOTCON_ERROR_NONE;
 }
 
 /* The full length of query should be less than or equal to 64. */
-API int iotcon_query_add(iotcon_query_h query, const char *key, const char *value)
+int icl_query_add(iotcon_query_h query, const char *key, const char *value)
 {
        FN_CALL;
        int query_len;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == query, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == value, IOTCON_ERROR_INVALID_PARAMETER);
@@ -195,14 +188,13 @@ API int iotcon_query_add(iotcon_query_h query, const char *key, const char *valu
 }
 
 
-API int iotcon_query_remove(iotcon_query_h query, const char *key)
+int icl_query_remove(iotcon_query_h query, const char *key)
 {
        FN_CALL;
        gboolean is_removed;
        int query_len;
        char *value;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == query, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
 
@@ -225,12 +217,11 @@ API int iotcon_query_remove(iotcon_query_h query, const char *key)
 }
 
 
-API int iotcon_query_lookup(iotcon_query_h query, const char *key, char **data)
+int icl_query_lookup(iotcon_query_h query, const char *key, char **data)
 {
        FN_CALL;
        char *value = NULL;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == query, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == data, IOTCON_ERROR_INVALID_PARAMETER);
@@ -246,14 +237,13 @@ API int iotcon_query_lookup(iotcon_query_h query, const char *key, char **data)
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_query_foreach(iotcon_query_h query, iotcon_query_foreach_cb cb,
+int icl_query_foreach(iotcon_query_h query, iotcon_query_foreach_cb cb,
                void *user_data)
 {
        FN_CALL;
        GHashTableIter iter;
        gpointer key, value;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == query, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
 
index c1c7897a5aa39ab4d03b037d06c40ea0318923a5..f010277c3c5f5b5d1ef0de9e271ef477c3d59609 100644 (file)
@@ -34,4 +34,15 @@ struct icl_query {
        GHashTable *hash;
 };
 
+int icl_query_create(iotcon_query_h *ret_query);
+int icl_query_destroy(iotcon_query_h query);
+int icl_query_get_resource_type(iotcon_query_h query, char **resource_type);
+int icl_query_get_interface(iotcon_query_h query, char **resource_iface);
+int icl_query_set_resource_type(iotcon_query_h query, const char *resource_type);
+int icl_query_set_interface(iotcon_query_h query, const char *resource_iface);
+int icl_query_add(iotcon_query_h query, const char *key, const char *value);
+int icl_query_remove(iotcon_query_h query, const char *key);
+int icl_query_lookup(iotcon_query_h query, const char *key, char **data);
+int icl_query_foreach(iotcon_query_h query, iotcon_query_foreach_cb cb, void *user_data);
+
 #endif /* __IOTCON_INTERNAL_QUERY_H__ */
diff --git a/src/ic-remote-resource-caching.c b/src/ic-remote-resource-caching.c
deleted file mode 100644 (file)
index b812340..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "iotcon.h"
-#include "ic.h"
-#include "ic-utils.h"
-#include "ic-types.h"
-#include "ic-representation.h"
-#include "ic-list.h"
-#include "ic-value.h"
-#include "ic-remote-resource.h"
-#include "ic-ioty.h"
-
-API int iotcon_remote_resource_start_caching(iotcon_remote_resource_h resource,
-               iotcon_remote_resource_cached_representation_changed_cb cb, void *user_data)
-{
-       FN_CALL;
-       int ret;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
-                       IOTCON_ERROR_PERMISSION_DENIED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-
-       if (true == resource->is_found) {
-               ERR("The resource should be cloned.");
-               return IOTCON_ERROR_INVALID_PARAMETER;
-       }
-       if (resource->caching.obs_handle) {
-               ERR("Already Start Caching");
-               return IOTCON_ERROR_ALREADY;
-       }
-
-       INFO("Start Caching");
-
-       icl_remote_resource_ref(resource);
-       ret = icl_ioty_remote_resource_start_caching(resource, cb, user_data);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_remote_resource_start_caching() Fail(%d)", ret);
-               icl_remote_resource_unref(resource);
-               return ret;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_remote_resource_stop_caching(iotcon_remote_resource_h resource)
-{
-       FN_CALL;
-       int ret;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
-                       IOTCON_ERROR_PERMISSION_DENIED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-
-       if (0 == resource->caching.obs_handle) {
-               ERR("Not Cached");
-               return IOTCON_ERROR_INVALID_PARAMETER;
-       }
-
-       INFO("Stop Caching");
-
-       ret = icl_ioty_remote_resource_stop_caching(resource);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_remote_resource_stop_caching() Fail(%d)", ret);
-               return ret;
-       }
-       icl_remote_resource_unref(resource);
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_remote_resource_get_cached_representation(
-               iotcon_remote_resource_h resource,
-               iotcon_representation_h *representation)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == representation, IOTCON_ERROR_INVALID_PARAMETER);
-       WARN_IF(NULL == resource->caching.repr, "No Cached Representation");
-
-       *representation = resource->caching.repr;
-
-       return IOTCON_ERROR_NONE;
-}
-
diff --git a/src/ic-remote-resource-crud.c b/src/ic-remote-resource-crud.c
deleted file mode 100644 (file)
index 589da0f..0000000
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "iotcon.h"
-#include "ic.h"
-#include "ic-utils.h"
-#include "ic-ioty.h"
-#include "ic-options.h"
-#include "ic-response.h"
-#include "ic-representation.h"
-#include "ic-remote-resource.h"
-
-API int iotcon_remote_resource_get(iotcon_remote_resource_h resource,
-               iotcon_query_h query, iotcon_remote_resource_response_cb cb, void *user_data)
-{
-       FN_CALL;
-       int ret;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
-                       IOTCON_ERROR_PERMISSION_DENIED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
-
-       if (true == resource->is_found) {
-               ERR("The resource should be cloned.");
-               return IOTCON_ERROR_INVALID_PARAMETER;
-       }
-
-       ret = icl_ioty_remote_resource_get(resource, query, cb, user_data);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_remote_resource_get() Fail(%d)", ret);
-               return ret;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_remote_resource_put(iotcon_remote_resource_h resource,
-               iotcon_representation_h repr,
-               iotcon_query_h query,
-               iotcon_remote_resource_response_cb cb,
-               void *user_data)
-{
-       FN_CALL;
-       int ret;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
-                       IOTCON_ERROR_PERMISSION_DENIED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
-
-       if (true == resource->is_found) {
-               ERR("The resource should be cloned.");
-               return IOTCON_ERROR_INVALID_PARAMETER;
-       }
-
-       ret = icl_ioty_remote_resource_put(resource, repr, query, cb, user_data);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_remote_resource_put() Fail(%d)", ret);
-               return ret;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_remote_resource_post(iotcon_remote_resource_h resource,
-               iotcon_representation_h repr,
-               iotcon_query_h query,
-               iotcon_remote_resource_response_cb cb,
-               void *user_data)
-{
-       FN_CALL;
-
-       int ret;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
-                       IOTCON_ERROR_PERMISSION_DENIED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
-
-       if (true == resource->is_found) {
-               ERR("The resource should be cloned.");
-               return IOTCON_ERROR_INVALID_PARAMETER;
-       }
-
-       ret = icl_ioty_remote_resource_post(resource, repr, query, cb, user_data);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_remote_resource_post() Fail(%d)", ret);
-               return ret;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
-
-API int iotcon_remote_resource_delete(iotcon_remote_resource_h resource,
-               iotcon_remote_resource_response_cb cb, void *user_data)
-{
-       FN_CALL;
-       int ret;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
-                       IOTCON_ERROR_PERMISSION_DENIED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
-
-       if (true == resource->is_found) {
-               ERR("The resource should be cloned.");
-               return IOTCON_ERROR_INVALID_PARAMETER;
-       }
-
-       ret = icl_ioty_remote_resource_delete(resource, cb, user_data);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_remote_resource_delete() Fail(%d)", ret);
-               return ret;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
-
-API int iotcon_remote_resource_observe_register(
-               iotcon_remote_resource_h resource,
-               iotcon_observe_policy_e observe_policy,
-               iotcon_query_h query,
-               iotcon_remote_resource_observe_cb cb,
-               void *user_data)
-{
-       FN_CALL;
-       int ret;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
-                       IOTCON_ERROR_PERMISSION_DENIED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(resource->obs_handle, IOTCON_ERROR_ALREADY);
-
-       if (true == resource->is_found) {
-               ERR("The resource should be cloned.");
-               return IOTCON_ERROR_INVALID_PARAMETER;
-       }
-
-       ret = icl_ioty_remote_resource_observe_register(resource, observe_policy, query, cb,
-                       user_data);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_remote_resource_observe_register() Fail(%d)", ret);
-               return ret;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_remote_resource_observe_deregister(
-               iotcon_remote_resource_h resource)
-{
-       FN_CALL;
-       int ret;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
-                       IOTCON_ERROR_PERMISSION_DENIED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-
-       if (true == resource->is_found) {
-               ERR("The resource should be cloned.");
-               return IOTCON_ERROR_INVALID_PARAMETER;
-       }
-
-       if (NULL == resource->obs_handle) {
-               ERR("It doesn't have a observe_handle");
-               return IOTCON_ERROR_INVALID_PARAMETER;
-       }
-
-       ret = icl_ioty_remote_resource_observe_deregister(resource);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_remote_resource_observe_deregister() Fail(%d)", ret);
-               return ret;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
-
diff --git a/src/ic-remote-resource-monitoring.c b/src/ic-remote-resource-monitoring.c
deleted file mode 100644 (file)
index cf133ef..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "iotcon.h"
-#include "ic.h"
-#include "ic-types.h"
-#include "ic-utils.h"
-#include "ic-remote-resource.h"
-#include "ic-ioty.h"
-
-API int iotcon_remote_resource_start_monitoring(
-               iotcon_remote_resource_h resource,
-               iotcon_remote_resource_state_changed_cb cb,
-               void *user_data)
-{
-       FN_CALL;
-       int ret;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
-                       IOTCON_ERROR_PERMISSION_DENIED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
-
-       if (true == resource->is_found) {
-               ERR("The resource should be cloned.");
-               return IOTCON_ERROR_INVALID_PARAMETER;
-       }
-       if (resource->monitoring.presence) {
-               ERR("Already Start Monitoring");
-               return IOTCON_ERROR_ALREADY;
-       }
-
-       INFO("Start Monitoring");
-
-       resource->monitoring.state = IOTCON_REMOTE_RESOURCE_ALIVE;
-
-       icl_remote_resource_ref(resource);
-       ret = icl_ioty_remote_resource_start_monitoring(resource, cb, user_data);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_remote_resource_start_monitoring() Fail(%d)", ret);
-               icl_remote_resource_unref(resource);
-               return ret;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_remote_resource_stop_monitoring(iotcon_remote_resource_h resource)
-{
-       FN_CALL;
-       int ret;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
-                       IOTCON_ERROR_PERMISSION_DENIED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-
-       if (NULL == resource->monitoring.presence) {
-               ERR("Not Monitoring");
-               return IOTCON_ERROR_INVALID_PARAMETER;
-       }
-
-       INFO("Stop Monitoring");
-
-       ret = icl_ioty_remote_resource_stop_monitoring(resource);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_remote_resource_stop_monitoring() Fail(%d)", ret);
-               return ret;
-       }
-       icl_remote_resource_unref(resource);
-
-       return IOTCON_ERROR_NONE;
-}
-
index 31af696b6fc5657e9539f6e1d7aafc69801a2abd..cd5b14c11b10f720c9e0ac48eb4899bcca884eb6 100644 (file)
 #include "ic-resource-interfaces.h"
 #include "ic-ioty.h"
 
-#define ICL_REMOTE_RESOURCE_MAX_CHECKING_INTERVAL 3600 /* 60 min */
 #define ICL_REMOTE_RESOURCE_DEFAULT_CHECKING_INTERVAL 10 /* 10 sec */
 
 /* The length of resource_type should be less than or equal to 61.
  * If resource_type is NULL, then All resources in host are discovered. */
-API int iotcon_find_resource(const char *host_address,
+int icl_find_resource(const char *host_address,
                int connectivity_type,
                iotcon_query_h query,
                iotcon_found_resource_cb cb,
                void *user_data)
 {
-       FN_CALL;
        int ret;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
-                       IOTCON_ERROR_PERMISSION_DENIED);
        RETV_IF(false == ic_utils_check_connectivity_type(connectivity_type),
                        IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
@@ -61,7 +56,7 @@ API int iotcon_find_resource(const char *host_address,
 }
 
 /* If you know the information of resource, then you can make a proxy of the resource. */
-API int iotcon_remote_resource_create(const char *host_address,
+int icl_remote_resource_create(const char *host_address,
                iotcon_connectivity_type_e connectivity_type,
                const char *uri_path,
                uint8_t policies,
@@ -73,7 +68,6 @@ API int iotcon_remote_resource_create(const char *host_address,
        char temp[PATH_MAX] = {0};
        iotcon_remote_resource_h resource = NULL;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == host_address, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == uri_path, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(false == icl_resource_check_uri_path(uri_path),
@@ -114,15 +108,23 @@ API int iotcon_remote_resource_create(const char *host_address,
        return IOTCON_ERROR_NONE;
 }
 
-static void _icl_remote_resource_destroy(iotcon_remote_resource_h resource)
+void icl_remote_resource_ref(iotcon_remote_resource_h resource)
+{
+       RET_IF(NULL == resource);
+
+       resource->ref_count++;
+}
+
+void icl_remote_resource_unref(iotcon_remote_resource_h resource)
 {
        RET_IF(NULL == resource);
 
-       if (resource->ref_count < 0) {
-               ERR("Invalid ref_count (%d)", resource->ref_count);
+       resource->ref_count--;
+       if (0 != resource->ref_count)
                return;
-       }
 
+       /* ref_count is zero, so destroy remote resource */
+       DBG("remote resource will be freed.");
        if (true == resource->is_found) {
                ERR("It can't be destroyed by user.");
                return;
@@ -132,47 +134,30 @@ static void _icl_remote_resource_destroy(iotcon_remote_resource_h resource)
        free(resource->host_address);
        free(resource->device_id);
        free(resource->device_name);
-       iotcon_resource_interfaces_destroy(resource->ifaces);
-       iotcon_resource_types_destroy(resource->types);
+       icl_resource_interfaces_destroy(resource->ifaces);
+       icl_resource_types_destroy(resource->types);
 
        /* null COULD be allowed */
        if (resource->header_options)
-               iotcon_options_destroy(resource->header_options);
+               icl_options_destroy(resource->header_options);
 
        if (resource->monitoring.presence)
-               iotcon_remote_resource_stop_monitoring(resource);
+               icl_remote_resource_stop_monitoring(resource);
 
        if (resource->caching.obs_handle)
-               iotcon_remote_resource_stop_caching(resource);
+               icl_remote_resource_stop_caching(resource);
 
        free(resource);
 }
 
-void icl_remote_resource_ref(iotcon_remote_resource_h resource)
-{
-       RET_IF(NULL == resource);
-
-       resource->ref_count++;
-}
-
-void icl_remote_resource_unref(iotcon_remote_resource_h resource)
-{
-       RET_IF(NULL == resource);
-
-       resource->ref_count--;
-       if (0 == resource->ref_count)
-               _icl_remote_resource_destroy(resource);
-}
-
 
-API int iotcon_remote_resource_destroy(iotcon_remote_resource_h resource)
+int icl_remote_resource_destroy(iotcon_remote_resource_h resource)
 {
        FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
 
-       if (resource->obs_handle)
-               iotcon_remote_resource_observe_deregister(resource);
+       if ((NULL != resource->obs_handle) && (false == resource->is_found))
+               icl_ioty_remote_resource_observe_deregister(resource);
 
        icl_remote_resource_unref(resource);
 
@@ -188,14 +173,14 @@ static bool _icl_remote_resource_header_foreach_cb(unsigned short id,
        RETV_IF(NULL == resource, IOTCON_FUNC_STOP);
 
        if (NULL == resource->header_options) {
-               ret = iotcon_options_create(&resource->header_options);
+               ret = icl_options_create(&resource->header_options);
                if (IOTCON_ERROR_NONE != ret) {
                        ERR("resource->header_options() Fail(%d)", ret);
                        return IOTCON_FUNC_STOP;
                }
        }
 
-       ret = iotcon_options_add(resource->header_options, id, data);
+       ret = icl_options_add(resource->header_options, id, data);
        if (IOTCON_ERROR_NONE != ret) {
                ERR("iotcon_options_add() Fail(%d)", ret);
                return IOTCON_FUNC_STOP;
@@ -204,14 +189,13 @@ static bool _icl_remote_resource_header_foreach_cb(unsigned short id,
        return IOTCON_FUNC_CONTINUE;
 }
 
-API int iotcon_remote_resource_clone(iotcon_remote_resource_h src,
+int icl_remote_resource_clone(iotcon_remote_resource_h src,
                iotcon_remote_resource_h *dest)
 {
        FN_CALL;
        int ret;
        iotcon_remote_resource_h resource = NULL;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == src, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == dest, IOTCON_ERROR_INVALID_PARAMETER);
 
@@ -232,26 +216,26 @@ API int iotcon_remote_resource_clone(iotcon_remote_resource_h src,
        resource->ref_count = 1;
 
        if (src->header_options) {
-               ret = iotcon_options_foreach(src->header_options,
+               ret = icl_options_foreach(src->header_options,
                                _icl_remote_resource_header_foreach_cb, resource);
                if (IOTCON_ERROR_NONE != ret) {
                        ERR("iotcon_options_foreach() Fail(%d)", ret);
-                       iotcon_remote_resource_destroy(resource);
+                       icl_remote_resource_destroy(resource);
                        return ret;
                }
        }
 
-       ret = iotcon_resource_types_clone(src->types, &resource->types);
+       ret = icl_resource_types_clone(src->types, &resource->types);
        if (IOTCON_ERROR_NONE != ret) {
-               ERR("iotcon_resource_types_clone() Fail(%d)", ret);
-               iotcon_remote_resource_destroy(resource);
+               ERR("icl_resource_types_clone() Fail(%d)", ret);
+               icl_remote_resource_destroy(resource);
                return ret;
        }
 
-       ret = iotcon_resource_interfaces_clone(src->ifaces, &resource->ifaces);
+       ret = icl_resource_interfaces_clone(src->ifaces, &resource->ifaces);
        if (IOTCON_ERROR_NONE != ret) {
-               ERR("iotcon_resource_interfaces_clone() Fail(%d)", ret);
-               iotcon_remote_resource_destroy(resource);
+               ERR("icl_resource_interfaces_clone() Fail(%d)", ret);
+               icl_remote_resource_destroy(resource);
                return ret;
        }
 
@@ -262,197 +246,109 @@ API int iotcon_remote_resource_clone(iotcon_remote_resource_h src,
        return IOTCON_ERROR_NONE;
 }
 
-
-/* The content of the resource should not be freed by user. */
-API int iotcon_remote_resource_get_uri_path(iotcon_remote_resource_h resource,
-               char **uri_path)
+int icl_remote_resource_start_caching(iotcon_remote_resource_h resource,
+               iotcon_remote_resource_cached_representation_changed_cb cb, void *user_data)
 {
        FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == uri_path, IOTCON_ERROR_INVALID_PARAMETER);
-
-       *uri_path = resource->uri_path;
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-/* The content of the resource should not be freed by user. */
-API int iotcon_remote_resource_get_host_address(
-               iotcon_remote_resource_h resource, char **host_address)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == host_address, IOTCON_ERROR_INVALID_PARAMETER);
-
-       *host_address = resource->host_address;
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-/* The content of the resource should not be freed by user. */
-API int iotcon_remote_resource_get_connectivity_type(
-               iotcon_remote_resource_h resource, iotcon_connectivity_type_e *connectivity_type)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == connectivity_type, IOTCON_ERROR_INVALID_PARAMETER);
-
-       *connectivity_type = resource->connectivity_type;
-
-       return IOTCON_ERROR_NONE;
-}
-
+       int ret;
 
-/* The content of the resource should not be freed by user. */
-API int iotcon_remote_resource_get_device_id(iotcon_remote_resource_h resource,
-               char **device_id)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == device_id, IOTCON_ERROR_INVALID_PARAMETER);
-       RETVM_IF(NULL == resource->device_id, IOTCON_ERROR_NO_DATA,
-                       "If you want to get device ID, you should call iotcon_find_resource().");
-
-       *device_id = resource->device_id;
 
-       return IOTCON_ERROR_NONE;
-}
-
-
-/* The content of the resource should not be freed by user. */
-API int iotcon_remote_resource_get_device_name(iotcon_remote_resource_h resource,
-               char **device_name)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == device_name, IOTCON_ERROR_INVALID_PARAMETER);
-       RETVM_IF(NULL == resource->device_name, IOTCON_ERROR_NO_DATA,
-                       "If you want to get device name, you should call iotcon_find_resource().");
+       if (true == resource->is_found) {
+               ERR("The resource should be cloned.");
+               return IOTCON_ERROR_INVALID_PARAMETER;
+       }
+       if (resource->caching.obs_handle) {
+               ERR("Already Start Caching");
+               return IOTCON_ERROR_ALREADY;
+       }
 
-       *device_name = resource->device_name;
+       icl_remote_resource_ref(resource);
+       ret = icl_ioty_remote_resource_start_caching(resource, cb, user_data);
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("icl_ioty_remote_resource_start_caching() Fail(%d)", ret);
+               icl_remote_resource_unref(resource);
+               return ret;
+       }
 
        return IOTCON_ERROR_NONE;
 }
 
 
-/* The content of the resource should not be freed by user. */
-API int iotcon_remote_resource_get_types(iotcon_remote_resource_h resource,
-               iotcon_resource_types_h *types)
+int icl_remote_resource_stop_caching(iotcon_remote_resource_h resource)
 {
        FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == types, IOTCON_ERROR_INVALID_PARAMETER);
-
-       *types = resource->types;
-
-       return IOTCON_ERROR_NONE;
-}
-
+       int ret;
 
-/* The content of the resource should not be freed by user. */
-API int iotcon_remote_resource_get_interfaces(iotcon_remote_resource_h resource,
-               iotcon_resource_interfaces_h *ifaces)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == ifaces, IOTCON_ERROR_INVALID_PARAMETER);
-
-       *ifaces = resource->ifaces;
 
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_remote_resource_get_policies(iotcon_remote_resource_h resource,
-               uint8_t *policies)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == policies, IOTCON_ERROR_INVALID_PARAMETER);
+       if (0 == resource->caching.obs_handle) {
+               ERR("Not Cached");
+               return IOTCON_ERROR_INVALID_PARAMETER;
+       }
 
-       *policies = resource->policies;
+       ret = icl_ioty_remote_resource_stop_caching(resource);
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("icl_ioty_remote_resource_stop_caching() Fail(%d)", ret);
+               return ret;
+       }
+       icl_remote_resource_unref(resource);
 
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_remote_resource_get_options(iotcon_remote_resource_h resource,
-               iotcon_options_h *options)
+int icl_remote_resource_start_monitoring(
+               iotcon_remote_resource_h resource,
+               iotcon_remote_resource_state_changed_cb cb,
+               void *user_data)
 {
        FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == options, IOTCON_ERROR_INVALID_PARAMETER);
-       WARN_IF(NULL == resource->header_options, "Not Set header options");
-
-       *options = resource->header_options;
-
-       return IOTCON_ERROR_NONE;
-}
+       int ret;
 
-/* if header_options is NULL, then client's header_options is unset */
-API int iotcon_remote_resource_set_options(iotcon_remote_resource_h resource,
-               iotcon_options_h options)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
 
-       if (options)
-               options = icl_options_ref(options);
-
-       if (resource->header_options)
-               iotcon_options_destroy(resource->header_options);
-
-       resource->header_options = options;
+       if (true == resource->is_found) {
+               ERR("The resource should be cloned.");
+               return IOTCON_ERROR_INVALID_PARAMETER;
+       }
+       if (resource->monitoring.presence) {
+               ERR("Already Start Monitoring");
+               return IOTCON_ERROR_ALREADY;
+       }
 
-       return IOTCON_ERROR_NONE;
-}
+       resource->monitoring.state = IOTCON_REMOTE_RESOURCE_ALIVE;
 
-API int iotcon_remote_resource_get_checking_interval(iotcon_remote_resource_h resource,
-               int *interval)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == interval, IOTCON_ERROR_INVALID_PARAMETER);
-
-       *interval = resource->checking_interval;
+       icl_remote_resource_ref(resource);
+       ret = icl_ioty_remote_resource_start_monitoring(resource, cb, user_data);
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("icl_ioty_remote_resource_start_monitoring() Fail(%d)", ret);
+               icl_remote_resource_unref(resource);
+               return ret;
+       }
 
        return IOTCON_ERROR_NONE;
 }
 
 
-API int iotcon_remote_resource_set_checking_interval(iotcon_remote_resource_h resource,
-               int interval)
+int icl_remote_resource_stop_monitoring(iotcon_remote_resource_h resource)
 {
        FN_CALL;
        int ret;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(ICL_REMOTE_RESOURCE_MAX_CHECKING_INTERVAL < interval || interval <= 0,
-                       IOTCON_ERROR_INVALID_PARAMETER);
 
-       if (resource->monitoring.presence || resource->caching.obs_handle) {
-               ret = icl_ioty_remote_resource_set_checking_interval(resource, interval);
-               if (IOTCON_ERROR_NONE != ret) {
-                       ERR("icl_ioty_remote_resource_set_checking_interval() Fail(%d)", ret);
-                       return ret;
-               }
+       if (NULL == resource->monitoring.presence) {
+               ERR("Not Monitoring");
+               return IOTCON_ERROR_INVALID_PARAMETER;
        }
 
-       resource->checking_interval = interval;
+       ret = icl_ioty_remote_resource_stop_monitoring(resource);
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("icl_ioty_remote_resource_stop_monitoring() Fail(%d)", ret);
+               return ret;
+       }
+       icl_remote_resource_unref(resource);
 
        return IOTCON_ERROR_NONE;
 }
-
index fb4221ad58e1eab2dee0d91aac22d49738f39850..eb39f42d631ea1348d5b056e3ca01d7b0dba1691 100644 (file)
@@ -58,7 +58,31 @@ struct icl_remote_resource {
        icl_remote_resource_monitoring_s monitoring;
 };
 
+int icl_find_resource(const char *host_address,
+               int connectivity_type,
+               iotcon_query_h query,
+               iotcon_found_resource_cb cb,
+               void *user_data);
+int icl_remote_resource_create(const char *host_address,
+               iotcon_connectivity_type_e connectivity_type,
+               const char *uri_path,
+               uint8_t policies,
+               iotcon_resource_types_h resource_types,
+               iotcon_resource_interfaces_h resource_ifaces,
+               iotcon_remote_resource_h *resource_handle);
 void icl_remote_resource_ref(iotcon_remote_resource_h resource);
 void icl_remote_resource_unref(iotcon_remote_resource_h resource);
+int icl_remote_resource_destroy(iotcon_remote_resource_h resource);
+int icl_remote_resource_clone(iotcon_remote_resource_h src,
+               iotcon_remote_resource_h *dest);
 
+int icl_remote_resource_start_caching(iotcon_remote_resource_h resource,
+               iotcon_remote_resource_cached_representation_changed_cb cb, void *user_data);
+int icl_remote_resource_stop_caching(iotcon_remote_resource_h resource);
+
+int icl_remote_resource_start_monitoring(
+               iotcon_remote_resource_h resource,
+               iotcon_remote_resource_state_changed_cb cb,
+               void *user_data);
+int icl_remote_resource_stop_monitoring(iotcon_remote_resource_h resource);
 #endif /* __IOTCON_INTERNAL_REMOTE_RESOURCE_H__ */
index 4fd958c51c81c43fb6e4e4bcb3ff58cf4308b28b..e446d6d381fdb2123ac70bc2049c6eb779ea2156 100644 (file)
@@ -49,12 +49,11 @@ iotcon_representation_h icl_representation_ref(iotcon_representation_h repr)
 }
 
 
-API int iotcon_representation_create(iotcon_representation_h *ret_repr)
+int icl_representation_create(iotcon_representation_h *ret_repr)
 {
        FN_CALL;
        iotcon_representation_h repr;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == ret_repr, IOTCON_ERROR_INVALID_PARAMETER);
 
        repr = calloc(1, sizeof(struct icl_representation_s));
@@ -72,10 +71,9 @@ API int iotcon_representation_create(iotcon_representation_h *ret_repr)
 }
 
 
-API int iotcon_representation_destroy(iotcon_representation_h repr)
+int icl_representation_destroy(iotcon_representation_h repr)
 {
        FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
 
        repr->ref_count--;
@@ -86,19 +84,19 @@ API int iotcon_representation_destroy(iotcon_representation_h repr)
        free(repr->uri_path);
 
        /* (GDestroyNotify) : iotcon_representation_h is proper type than gpointer */
-       g_list_free_full(repr->children, (GDestroyNotify)iotcon_representation_destroy);
+       g_list_free_full(repr->children, (GDestroyNotify)icl_representation_destroy);
 
        /* null COULD be allowed */
        if (repr->interfaces)
-               iotcon_resource_interfaces_destroy(repr->interfaces);
+               icl_resource_interfaces_destroy(repr->interfaces);
 
        /* null COULD be allowed */
        if (repr->res_types)
-               iotcon_resource_types_destroy(repr->res_types);
+               icl_resource_types_destroy(repr->res_types);
 
        /* null COULD be allowed */
        if (repr->attributes)
-               iotcon_attributes_destroy(repr->attributes);
+               icl_attributes_destroy(repr->attributes);
 
        free(repr);
 
@@ -106,11 +104,9 @@ API int iotcon_representation_destroy(iotcon_representation_h repr)
 }
 
 
-API int iotcon_representation_get_uri_path(iotcon_representation_h repr,
+int icl_representation_get_uri_path(iotcon_representation_h repr,
                char **uri_path)
 {
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == uri_path, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == repr->uri_path, IOTCON_ERROR_NO_DATA);
@@ -120,11 +116,9 @@ API int iotcon_representation_get_uri_path(iotcon_representation_h repr,
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_representation_set_uri_path(iotcon_representation_h repr,
+int icl_representation_set_uri_path(iotcon_representation_h repr,
                const char *uri_path)
 {
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == uri_path, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(false == icl_resource_check_uri_path(uri_path),
@@ -140,11 +134,9 @@ API int iotcon_representation_set_uri_path(iotcon_representation_h repr,
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_representation_get_resource_types(iotcon_representation_h repr,
+int icl_representation_get_resource_types(iotcon_representation_h repr,
                iotcon_resource_types_h *types)
 {
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == types, IOTCON_ERROR_INVALID_PARAMETER);
        WARN_IF(NULL == repr->res_types, "Not Set Resource Types");
@@ -154,29 +146,25 @@ API int iotcon_representation_get_resource_types(iotcon_representation_h repr,
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_representation_set_resource_types(iotcon_representation_h repr,
+int icl_representation_set_resource_types(iotcon_representation_h repr,
                iotcon_resource_types_h types)
 {
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
 
        if (types)
                types = icl_resource_types_ref(types);
 
        if (repr->res_types)
-               iotcon_resource_types_destroy(repr->res_types);
+               icl_resource_types_destroy(repr->res_types);
 
        repr->res_types = types;
 
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_representation_get_resource_interfaces(
+int icl_representation_get_resource_interfaces(
                iotcon_representation_h repr, iotcon_resource_interfaces_h *ifaces)
 {
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == ifaces, IOTCON_ERROR_INVALID_PARAMETER);
        WARN_IF(NULL == repr->interfaces, "Not Set Resource Interfaces");
@@ -186,36 +174,32 @@ API int iotcon_representation_get_resource_interfaces(
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_representation_set_resource_interfaces(
+int icl_representation_set_resource_interfaces(
                iotcon_representation_h repr, iotcon_resource_interfaces_h ifaces)
 {
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
 
        if (ifaces)
                ifaces = icl_resource_interfaces_ref(ifaces);
 
        if (repr->interfaces)
-               iotcon_resource_interfaces_destroy(repr->interfaces);
+               icl_resource_interfaces_destroy(repr->interfaces);
 
        repr->interfaces = ifaces;
 
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_representation_set_attributes(iotcon_representation_h repr,
+int icl_representation_set_attributes(iotcon_representation_h repr,
                iotcon_attributes_h attributes)
 {
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
 
        if (attributes)
                attributes = icl_attributes_ref(attributes);
 
        if (repr->attributes)
-               iotcon_attributes_destroy(repr->attributes);
+               icl_attributes_destroy(repr->attributes);
 
        repr->attributes = attributes;
 
@@ -223,11 +207,9 @@ API int iotcon_representation_set_attributes(iotcon_representation_h repr,
 }
 
 
-API int iotcon_representation_get_attributes(iotcon_representation_h repr,
+int icl_representation_get_attributes(iotcon_representation_h repr,
                iotcon_attributes_h *attributes)
 {
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER);
 
@@ -236,13 +218,12 @@ API int iotcon_representation_get_attributes(iotcon_representation_h repr,
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_representation_add_child(iotcon_representation_h parent,
+int icl_representation_add_child(iotcon_representation_h parent,
                iotcon_representation_h child)
 {
        FN_CALL;
        iotcon_representation_h repr;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == parent, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == child, IOTCON_ERROR_INVALID_PARAMETER);
 
@@ -254,29 +235,26 @@ API int iotcon_representation_add_child(iotcon_representation_h parent,
 }
 
 
-API int iotcon_representation_remove_child(iotcon_representation_h parent,
+int icl_representation_remove_child(iotcon_representation_h parent,
                iotcon_representation_h child)
 {
        FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == parent, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == child, IOTCON_ERROR_INVALID_PARAMETER);
 
        parent->children = g_list_remove(parent->children, child);
 
-       iotcon_representation_destroy(child);
+       icl_representation_destroy(child);
 
        return IOTCON_ERROR_NONE;
 }
 
 
-API int iotcon_representation_foreach_children(iotcon_representation_h parent,
+int icl_representation_foreach_children(iotcon_representation_h parent,
                iotcon_children_cb cb, void *user_data)
 {
-       FN_CALL;
        GList *list, *next;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == parent, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
 
@@ -291,11 +269,9 @@ API int iotcon_representation_foreach_children(iotcon_representation_h parent,
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_representation_get_child_count(iotcon_representation_h parent,
+int icl_representation_get_child_count(iotcon_representation_h parent,
                unsigned int *count)
 {
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == parent, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == count, IOTCON_ERROR_INVALID_PARAMETER);
 
@@ -304,13 +280,11 @@ API int iotcon_representation_get_child_count(iotcon_representation_h parent,
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_representation_get_nth_child(iotcon_representation_h parent,
+int icl_representation_get_nth_child(iotcon_representation_h parent,
                int pos, iotcon_representation_h *child)
 {
-       FN_CALL;
        iotcon_representation_h repr;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == parent, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == child, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(pos < 0, IOTCON_ERROR_INVALID_PARAMETER);
@@ -328,7 +302,7 @@ API int iotcon_representation_get_nth_child(iotcon_representation_h parent,
 }
 
 
-API int iotcon_representation_clone(const iotcon_representation_h src,
+int icl_representation_clone(const iotcon_representation_h src,
                iotcon_representation_h *dest)
 {
        FN_CALL;
@@ -338,13 +312,12 @@ API int iotcon_representation_clone(const iotcon_representation_h src,
        iotcon_resource_interfaces_h ifaces;
        iotcon_representation_h cloned_repr, copied_repr;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == src, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == dest, IOTCON_ERROR_INVALID_PARAMETER);
 
-       ret = iotcon_representation_create(&cloned_repr);
+       ret = icl_representation_create(&cloned_repr);
        if (IOTCON_ERROR_NONE != ret) {
-               ERR("iotcon_representation_create() Fail(%d)", ret);
+               ERR("icl_representation_create() Fail(%d)", ret);
                return ret;
        }
 
@@ -352,26 +325,26 @@ API int iotcon_representation_clone(const iotcon_representation_h src,
                cloned_repr->uri_path = strdup(src->uri_path);
                if (NULL == cloned_repr->uri_path) {
                        ERR("strdup() Fail");
-                       iotcon_representation_destroy(cloned_repr);
+                       icl_representation_destroy(cloned_repr);
                        return IOTCON_ERROR_OUT_OF_MEMORY;
                }
        }
 
        if (src->interfaces) {
-               ret = iotcon_resource_interfaces_clone(src->interfaces, &ifaces);
+               ret = icl_resource_interfaces_clone(src->interfaces, &ifaces);
                if (IOTCON_ERROR_NONE != ret) {
-                       ERR("iotcon_resource_interfaces_clone() Fail(%d)");
-                       iotcon_representation_destroy(cloned_repr);
+                       ERR("icl_resource_interfaces_clone() Fail(%d)");
+                       icl_representation_destroy(cloned_repr);
                        return ret;
                }
                cloned_repr->interfaces = ifaces;
        }
 
        if (src->res_types) {
-               ret = iotcon_resource_types_clone(src->res_types, &types);
+               ret = icl_resource_types_clone(src->res_types, &types);
                if (IOTCON_ERROR_NONE != ret) {
-                       ERR("iotcon_resource_types_clone() Fail");
-                       iotcon_representation_destroy(cloned_repr);
+                       ERR("icl_resource_types_clone() Fail");
+                       icl_representation_destroy(cloned_repr);
                        return ret;
                }
                cloned_repr->res_types = types;
@@ -379,11 +352,11 @@ API int iotcon_representation_clone(const iotcon_representation_h src,
 
        if (src->children) {
                for (node = g_list_first(src->children); node; node = node->next) {
-                       ret = iotcon_representation_clone((iotcon_representation_h)node->data,
+                       ret = icl_representation_clone((iotcon_representation_h)node->data,
                                        &copied_repr);
                        if (IOTCON_ERROR_NONE != ret) {
-                               ERR("iotcon_representation_clone(child) Fail(%d)", ret);
-                               iotcon_representation_destroy(cloned_repr);
+                               ERR("icl_representation_clone(child) Fail(%d)", ret);
+                               icl_representation_destroy(cloned_repr);
                                return ret;
                        }
                        cloned_repr->children = g_list_append(cloned_repr->children, copied_repr);
@@ -391,10 +364,9 @@ API int iotcon_representation_clone(const iotcon_representation_h src,
        }
 
        if (src->attributes) {
-               ret = iotcon_attributes_clone(src->attributes, &cloned_repr->attributes);
+               ret = icl_attributes_clone(src->attributes, &cloned_repr->attributes);
                if (IOTCON_ERROR_NONE != ret) {
-                       ERR("iotcon_attributes_clone() Fail(%d)", ret);
-                       iotcon_representation_destroy(cloned_repr);
+                       icl_representation_destroy(cloned_repr);
                        return ret;
                }
        }
index 9ca1a40af5816a8aa7c2fafd886e947492d0683d..49394a067da47ef919dbf2fb55acf592ecef7c2b 100644 (file)
@@ -37,8 +37,37 @@ struct icl_representation_s {
 };
 
 iotcon_representation_h icl_representation_ref(iotcon_representation_h repr);
+int icl_representation_create(iotcon_representation_h *ret_repr);
+int icl_representation_destroy(iotcon_representation_h repr);
+int icl_representation_get_uri_path(iotcon_representation_h repr,
+               char **uri_path);
+int icl_representation_set_uri_path(iotcon_representation_h repr,
+               const char *uri_path);
+int icl_representation_get_resource_types(iotcon_representation_h repr,
+               iotcon_resource_types_h *types);
+int icl_representation_set_resource_types(iotcon_representation_h repr,
+               iotcon_resource_types_h types);
+int icl_representation_get_resource_interfaces(
+               iotcon_representation_h repr, iotcon_resource_interfaces_h *ifaces);
+int icl_representation_set_resource_interfaces(
+               iotcon_representation_h repr, iotcon_resource_interfaces_h ifaces);
+int icl_representation_set_attributes(iotcon_representation_h repr,
+               iotcon_attributes_h attributes);
+int icl_representation_get_attributes(iotcon_representation_h repr,
+               iotcon_attributes_h *attributes);
+int icl_representation_add_child(iotcon_representation_h parent,
+               iotcon_representation_h child);
+int icl_representation_remove_child(iotcon_representation_h parent,
+               iotcon_representation_h child);
+int icl_representation_foreach_children(iotcon_representation_h parent,
+               iotcon_children_cb cb, void *user_data);
+int icl_representation_get_child_count(iotcon_representation_h parent,
+               unsigned int *count);
+int icl_representation_get_nth_child(iotcon_representation_h parent,
+               int pos, iotcon_representation_h *child);
+int icl_representation_clone(const iotcon_representation_h src,
+               iotcon_representation_h *dest);
 int icl_representation_compare(iotcon_representation_h repr1,
                iotcon_representation_h repr2);
 
-
 #endif /* __IOTCON_INTERNAL_REPRESENTATION_H__ */
diff --git a/src/ic-request.c b/src/ic-request.c
deleted file mode 100644 (file)
index 5eee5d3..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "iotcon-types.h"
-#include "ic.h"
-#include "ic-utils.h"
-#include "ic-request.h"
-
-API int iotcon_request_get_host_address(iotcon_request_h request,
-               char **host_address)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == request, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == host_address, IOTCON_ERROR_INVALID_PARAMETER);
-
-       *host_address = request->host_address;
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_request_get_connectivity_type(iotcon_request_h request,
-               iotcon_connectivity_type_e *connectivity_type)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == request, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == connectivity_type, IOTCON_ERROR_INVALID_PARAMETER);
-
-       *connectivity_type = request->connectivity_type;
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-/* The content of the request should not be freed by user. */
-API int iotcon_request_get_representation(iotcon_request_h request,
-               iotcon_representation_h *repr)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == request, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
-
-       *repr = request->repr;
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_request_get_request_type(iotcon_request_h request,
-               iotcon_request_type_e *type)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == request, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == type, IOTCON_ERROR_INVALID_PARAMETER);
-
-       *type = request->type;
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-/* The content of the request should not be freed by user. */
-API int iotcon_request_get_options(iotcon_request_h request,
-               iotcon_options_h *options)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == request, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == options, IOTCON_ERROR_INVALID_PARAMETER);
-       WARN_IF(NULL == request->header_options, "Not Set header options");
-
-       *options = request->header_options;
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-/* The content of the request should not be freed by user. */
-API int iotcon_request_get_query(iotcon_request_h request, iotcon_query_h *query)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == request, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == query, IOTCON_ERROR_INVALID_PARAMETER);
-       WARN_IF(NULL == request->query, "Not Set query");
-
-       *query = request->query;
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_request_get_observe_type(iotcon_request_h request,
-               iotcon_observe_type_e *observe_type)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == request, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == observe_type, IOTCON_ERROR_INVALID_PARAMETER);
-
-       *observe_type = request->observation_info.action;
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_request_get_observe_id(iotcon_request_h request, int *observe_id)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == request, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == observe_id, IOTCON_ERROR_INVALID_PARAMETER);
-
-       *observe_id = request->observation_info.observe_id;
-
-       return IOTCON_ERROR_NONE;
-}
-
index f998db965fb4c6b4bccc6af38f3670906c26dda1..8463d963b37d5090b7be0999a31005197e2a24a9 100644 (file)
@@ -35,12 +35,11 @@ iotcon_resource_interfaces_h icl_resource_interfaces_ref(
        return ifaces;
 }
 
-API int iotcon_resource_interfaces_create(iotcon_resource_interfaces_h *ret_ifaces)
+int icl_resource_interfaces_create(iotcon_resource_interfaces_h *ret_ifaces)
 {
        FN_CALL;
        iotcon_resource_interfaces_h ifaces;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == ret_ifaces, IOTCON_ERROR_INVALID_PARAMETER);
 
        ifaces = calloc(1, sizeof(struct icl_resource_ifaces));
@@ -57,10 +56,9 @@ API int iotcon_resource_interfaces_create(iotcon_resource_interfaces_h *ret_ifac
 }
 
 
-API int iotcon_resource_interfaces_destroy(iotcon_resource_interfaces_h ifaces)
+int icl_resource_interfaces_destroy(iotcon_resource_interfaces_h ifaces)
 {
        FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == ifaces, IOTCON_ERROR_INVALID_PARAMETER);
 
        ifaces->ref_count--;
@@ -97,13 +95,12 @@ static bool _icl_resource_interfaces_duplicate_check(
 
 
 /* Duplicate strings are not allowed. */
-API int iotcon_resource_interfaces_add(iotcon_resource_interfaces_h ifaces,
+int icl_resource_interfaces_add(iotcon_resource_interfaces_h ifaces,
                const char *iface)
 {
-       FN_CALL;
        char *resource_iface;
+       DBG("iface: [%s]", iface);
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == ifaces, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == iface, IOTCON_ERROR_INVALID_PARAMETER);
        RETVM_IF(1 < ifaces->ref_count, IOTCON_ERROR_INVALID_PARAMETER,
@@ -127,14 +124,13 @@ API int iotcon_resource_interfaces_add(iotcon_resource_interfaces_h ifaces,
 }
 
 
-API int iotcon_resource_interfaces_remove(iotcon_resource_interfaces_h ifaces,
+int icl_resource_interfaces_remove(iotcon_resource_interfaces_h ifaces,
                const char *iface)
 {
-       FN_CALL;
        GList *node;
        char *node_data;
+       DBG("iface: [%s]", iface);
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == ifaces, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == iface, IOTCON_ERROR_INVALID_PARAMETER);
        RETVM_IF(1 < ifaces->ref_count, IOTCON_ERROR_INVALID_PARAMETER,
@@ -154,13 +150,12 @@ API int iotcon_resource_interfaces_remove(iotcon_resource_interfaces_h ifaces,
 }
 
 
-API int iotcon_resource_interfaces_foreach(iotcon_resource_interfaces_h ifaces,
+int icl_resource_interfaces_foreach(iotcon_resource_interfaces_h ifaces,
                iotcon_resource_interfaces_foreach_cb cb, void *user_data)
 {
        FN_CALL;
        GList *node;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == ifaces, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
 
@@ -173,7 +168,7 @@ API int iotcon_resource_interfaces_foreach(iotcon_resource_interfaces_h ifaces,
 }
 
 
-API int iotcon_resource_interfaces_clone(iotcon_resource_interfaces_h src,
+int icl_resource_interfaces_clone(iotcon_resource_interfaces_h src,
                iotcon_resource_interfaces_h *dest)
 {
        FN_CALL;
@@ -181,7 +176,6 @@ API int iotcon_resource_interfaces_clone(iotcon_resource_interfaces_h src,
        char *resource_iface;
        iotcon_resource_interfaces_h resource_ifaces;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == src, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == dest, IOTCON_ERROR_INVALID_PARAMETER);
 
index 57f9ba8b1d67eb5b535ed286324e425835fdd6ba..adb17767958d2f4f52ce4f6e598ede5bd7328026 100644 (file)
@@ -26,5 +26,15 @@ struct icl_resource_ifaces {
 
 iotcon_resource_interfaces_h icl_resource_interfaces_ref(
                iotcon_resource_interfaces_h res_ifaces);
+int icl_resource_interfaces_create(iotcon_resource_interfaces_h *ret_ifaces);
+int icl_resource_interfaces_destroy(iotcon_resource_interfaces_h ifaces);
+int icl_resource_interfaces_add(iotcon_resource_interfaces_h ifaces,
+               const char *iface);
+int icl_resource_interfaces_remove(iotcon_resource_interfaces_h ifaces,
+               const char *iface);
+int icl_resource_interfaces_foreach(iotcon_resource_interfaces_h ifaces,
+               iotcon_resource_interfaces_foreach_cb cb, void *user_data);
+int icl_resource_interfaces_clone(iotcon_resource_interfaces_h src,
+               iotcon_resource_interfaces_h *dest);
 
 #endif /* __IOTCON_INTERNAL_RESOURCE_INTERFACES_H__ */
index 35c9812873d942a149b3ce1b0efe4f3b67eb0049..6f44d07d76e592d2fd6f86fe0b0dcb3421016dd0 100644 (file)
@@ -35,12 +35,11 @@ iotcon_resource_types_h icl_resource_types_ref(iotcon_resource_types_h types)
 }
 
 
-API int iotcon_resource_types_create(iotcon_resource_types_h *ret_types)
+int icl_resource_types_create(iotcon_resource_types_h *ret_types)
 {
        FN_CALL;
        iotcon_resource_types_h types;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == ret_types, IOTCON_ERROR_INVALID_PARAMETER);
 
        types = calloc(1, sizeof(struct icl_resource_types));
@@ -57,10 +56,9 @@ API int iotcon_resource_types_create(iotcon_resource_types_h *ret_types)
 }
 
 
-API int iotcon_resource_types_destroy(iotcon_resource_types_h types)
+int icl_resource_types_destroy(iotcon_resource_types_h types)
 {
        FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == types, IOTCON_ERROR_INVALID_PARAMETER);
 
        types->ref_count--;
@@ -98,12 +96,11 @@ static bool _icl_resource_types_duplicate_check(iotcon_resource_types_h types,
 
 /* The length of resource type should be less than or equal to 61.
  * Duplicate strings are not allowed. */
-API int iotcon_resource_types_add(iotcon_resource_types_h types, const char *type)
+int icl_resource_types_add(iotcon_resource_types_h types, const char *type)
 {
-       FN_CALL;
        char *resource_type;
+       DBG("type: [%s]", type);
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == types, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == type, IOTCON_ERROR_INVALID_PARAMETER);
        RETVM_IF(1 < types->ref_count, IOTCON_ERROR_INVALID_PARAMETER,
@@ -127,14 +124,13 @@ API int iotcon_resource_types_add(iotcon_resource_types_h types, const char *typ
 }
 
 
-API int iotcon_resource_types_remove(iotcon_resource_types_h types,
+int icl_resource_types_remove(iotcon_resource_types_h types,
                const char *type)
 {
-       FN_CALL;
        GList *found_node;
        char *node_data;
+       DBG("type: [%s]", type);
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == types, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == type, IOTCON_ERROR_INVALID_PARAMETER);
        RETVM_IF(1 < types->ref_count, IOTCON_ERROR_INVALID_PARAMETER,
@@ -154,13 +150,12 @@ API int iotcon_resource_types_remove(iotcon_resource_types_h types,
 }
 
 
-API int iotcon_resource_types_foreach(iotcon_resource_types_h types,
+int icl_resource_types_foreach(iotcon_resource_types_h types,
                iotcon_resource_types_foreach_cb cb, void *user_data)
 {
        FN_CALL;
        GList *node;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == types, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
 
@@ -173,7 +168,7 @@ API int iotcon_resource_types_foreach(iotcon_resource_types_h types,
 }
 
 
-API int iotcon_resource_types_clone(iotcon_resource_types_h src,
+int icl_resource_types_clone(iotcon_resource_types_h src,
                iotcon_resource_types_h *dest)
 {
        FN_CALL;
@@ -181,7 +176,6 @@ API int iotcon_resource_types_clone(iotcon_resource_types_h src,
        char *resource_type;
        iotcon_resource_types_h resource_types;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == src, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == dest, IOTCON_ERROR_INVALID_PARAMETER);
 
@@ -194,7 +188,7 @@ API int iotcon_resource_types_clone(iotcon_resource_types_h src,
        for (node = src->type_list; node; node = node->next) {
                resource_type = ic_utils_strdup(node->data);
                if (NULL == resource_type) {
-                       iotcon_resource_types_destroy(resource_types);
+                       icl_resource_types_destroy(resource_types);
                        ERR("ic_utils_strdup() Fail");
                        return IOTCON_ERROR_OUT_OF_MEMORY;
                }
index d693df1684d3c70db92c3adb894cfc4d49c92d01..3db032b4e834e76a727906938d776c7bdea1b06e 100644 (file)
@@ -34,5 +34,14 @@ struct icl_resource_types {
 };
 
 iotcon_resource_types_h icl_resource_types_ref(iotcon_resource_types_h res_types);
+int icl_resource_types_create(iotcon_resource_types_h *ret_types);
+int icl_resource_types_destroy(iotcon_resource_types_h types);
+int icl_resource_types_add(iotcon_resource_types_h types, const char *type);
+int icl_resource_types_remove(iotcon_resource_types_h types,
+               const char *type);
+int icl_resource_types_foreach(iotcon_resource_types_h types,
+               iotcon_resource_types_foreach_cb cb, void *user_data);
+int icl_resource_types_clone(iotcon_resource_types_h src,
+               iotcon_resource_types_h *dest);
 
 #endif /* __IOTCON_INTERNAL_RESOURCE_TYPES_H__ */
index 215652b2fcaf26fe0258504a5d1a570ec783b025..45507934c269d0310989a727cb3efac2ca1551a6 100644 (file)
@@ -101,293 +101,3 @@ bool icl_resource_check_interface(const char *iface)
        return _check_type_interface(iface);
 }
 
-
-/* The length of uri_path should be less than 128. */
-API int iotcon_resource_create(const char *uri_path,
-               iotcon_resource_types_h res_types,
-               iotcon_resource_interfaces_h ifaces,
-               uint8_t policies,
-               iotcon_request_handler_cb cb,
-               void *user_data,
-               iotcon_resource_h *resource_handle)
-{
-       FN_CALL;
-       int ret;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
-                       IOTCON_ERROR_PERMISSION_DENIED);
-       RETV_IF(NULL == uri_path, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(false == icl_resource_check_uri_path(uri_path),
-                       IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == res_types, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == ifaces, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == resource_handle, IOTCON_ERROR_INVALID_PARAMETER);
-
-       ret = icl_ioty_resource_create(uri_path, res_types, ifaces, policies, cb,
-                       user_data, resource_handle);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_resource_create() Fail(%d)", ret);
-               return ret;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_resource_destroy(iotcon_resource_h resource)
-{
-       FN_CALL;
-       int ret;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
-                       IOTCON_ERROR_PERMISSION_DENIED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-
-       ret = icl_ioty_resource_destroy(resource);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_resource_destroy() Fail(%d)", ret);
-               return ret;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_resource_bind_interface(iotcon_resource_h resource,
-               const char *iface)
-{
-       FN_CALL;
-       int ret;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
-                       IOTCON_ERROR_PERMISSION_DENIED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == iface, IOTCON_ERROR_INVALID_PARAMETER);
-
-       ret = icl_ioty_resource_bind_interface(resource, iface);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_resource_bind_interface() Fail(%d)", ret);
-               return ret;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_resource_bind_type(iotcon_resource_h resource,
-               const char *resource_type)
-{
-       FN_CALL;
-       int ret;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
-                       IOTCON_ERROR_PERMISSION_DENIED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == resource_type, IOTCON_ERROR_INVALID_PARAMETER);
-
-       ret = icl_ioty_resource_bind_type(resource, resource_type);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_resource_bind_type() Fail(%d)", ret);
-               return ret;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
-
-API int iotcon_resource_set_request_handler(iotcon_resource_h resource,
-               iotcon_request_handler_cb cb, void *user_data)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
-
-       DBG("Request handler is changed");
-       resource->cb = cb;
-       resource->user_data = user_data;
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_resource_bind_child_resource(iotcon_resource_h parent,
-               iotcon_resource_h child)
-{
-       FN_CALL;
-       int ret;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
-                       IOTCON_ERROR_PERMISSION_DENIED);
-       RETV_IF(NULL == parent, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == child, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(parent == child, IOTCON_ERROR_INVALID_PARAMETER);
-
-       if (g_list_find(parent->children, child)) {
-               ERR("Child resource was already bound to parent resource.");
-               return IOTCON_ERROR_ALREADY;
-       }
-
-       ret = icl_ioty_resource_bind_child_resource(parent, child);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_resource_bind_child_resource() Fail(%d)", ret);
-               return ret;
-       }
-       parent->children = g_list_append(parent->children, child);
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_resource_unbind_child_resource(iotcon_resource_h parent,
-               iotcon_resource_h child)
-{
-       FN_CALL;
-       int ret;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
-                       IOTCON_ERROR_PERMISSION_DENIED);
-       RETV_IF(NULL == parent, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == child, IOTCON_ERROR_INVALID_PARAMETER);
-
-       if (NULL == g_list_find(parent->children, child)) {
-               ERR("child resource is not bound to parent resource.");
-               return IOTCON_ERROR_NO_DATA;
-       }
-
-       ret = icl_ioty_resource_unbind_child_resource(parent, child);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_resource_unbind_child_resource() Fail(%d)", ret);
-               return ret;
-       }
-
-       parent->children = g_list_remove(parent->children, child);
-
-       if (0 == g_list_length(parent->children)) {
-               g_list_free(parent->children);
-               parent->children = NULL;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_resource_get_child_count(iotcon_resource_h resource,
-               unsigned int *count)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == count, IOTCON_ERROR_INVALID_PARAMETER);
-
-       *count = g_list_length(resource->children);
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_resource_get_nth_child(iotcon_resource_h parent, int index,
-               iotcon_resource_h *child)
-{
-       FN_CALL;
-       iotcon_resource_h resource;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == parent, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == child, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(index < 0, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == parent->children, IOTCON_ERROR_NO_DATA);
-
-       resource = g_list_nth_data(parent->children, index);
-       if (NULL == resource) {
-               ERR("g_list_nth_data() Fail");
-               return IOTCON_ERROR_NO_DATA;
-       }
-
-       *child = resource;
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-/* The content of the resource should not be freed by user. */
-API int iotcon_resource_get_uri_path(iotcon_resource_h resource, char **uri_path)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == uri_path, IOTCON_ERROR_INVALID_PARAMETER);
-
-       *uri_path = resource->uri_path;
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-/* The content of the resource should not be freed by user. */
-API int iotcon_resource_get_types(iotcon_resource_h resource,
-               iotcon_resource_types_h *types)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == types, IOTCON_ERROR_INVALID_PARAMETER);
-
-       *types = resource->types;
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_resource_get_interfaces(iotcon_resource_h resource,
-               iotcon_resource_interfaces_h *ifaces)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == ifaces, IOTCON_ERROR_INVALID_PARAMETER);
-
-       *ifaces = resource->ifaces;
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_resource_get_policies(iotcon_resource_h resource, uint8_t *policies)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == policies, IOTCON_ERROR_INVALID_PARAMETER);
-
-       *policies = resource->policies;
-
-       return IOTCON_ERROR_NONE;
-}
-
-API int iotcon_resource_notify(iotcon_resource_h resource,
-               iotcon_representation_h repr, iotcon_observers_h observers, iotcon_qos_e qos)
-{
-       FN_CALL;
-       int ret;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
-                       IOTCON_ERROR_PERMISSION_DENIED);
-       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
-
-       ret = icl_ioty_resource_notify(resource, repr, observers, qos);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_resource_notify() Fail(%d)", ret);
-               return ret;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
-
index 4c38407f09d9e99502af415d5736505b3c363e12..400decfb492ddd6365b7c045cec9416708b13e7c 100644 (file)
 
 #include "ic-ioty.h"
 
-/* the last index of iotcon_response_result_e */
-#define ICL_RESPONSE_RESULT_MAX (IOTCON_RESPONSE_FORBIDDEN + 1)
-
-API int iotcon_response_create(iotcon_request_h request,
-               iotcon_response_h *response)
-{
-       FN_CALL;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == request, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == response, IOTCON_ERROR_INVALID_PARAMETER);
-
-       iotcon_response_h resp = calloc(1, sizeof(struct icl_resource_response));
-       if (NULL == resp) {
-               ERR("calloc() Fail(%d)", errno);
-               return IOTCON_ERROR_OUT_OF_MEMORY;
-       }
-
-       resp->oic_request_h = request->oic_request_h;
-       resp->oic_resource_h = request->oic_resource_h;
-
-       *response = resp;
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_response_destroy(iotcon_response_h resp)
+int icl_response_destroy(iotcon_response_h resp)
 {
        FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == resp, IOTCON_ERROR_INVALID_PARAMETER);
 
        if (resp->repr)
-               iotcon_representation_destroy(resp->repr);
+               icl_representation_destroy(resp->repr);
        if (resp->header_options)
-               iotcon_options_destroy(resp->header_options);
+               icl_options_destroy(resp->header_options);
        free(resp);
 
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_response_get_options(iotcon_response_h resp,
-               iotcon_options_h *options)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == resp, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == options, IOTCON_ERROR_INVALID_PARAMETER);
-       WARN_IF(NULL == resp->header_options, "Not Set header options");
-
-       *options = resp->header_options;
-
-       return IOTCON_ERROR_NONE;
-}
-
-API int iotcon_response_get_representation(iotcon_response_h resp,
-               iotcon_representation_h *repr)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == resp, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == resp->repr, IOTCON_ERROR_NO_DATA);
-
-       *repr = resp->repr;
-
-       return IOTCON_ERROR_NONE;
-
-}
-
-API int iotcon_response_get_result(iotcon_response_h resp,
-               iotcon_response_result_e *result)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == resp, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == result, IOTCON_ERROR_INVALID_PARAMETER);
-
-       *result = resp->result;
-
-       return IOTCON_ERROR_NONE;
-}
-
-API int iotcon_response_set_result(iotcon_response_h resp,
-               iotcon_response_result_e result)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == resp, IOTCON_ERROR_INVALID_PARAMETER);
-
-       if (result < IOTCON_RESPONSE_OK || ICL_RESPONSE_RESULT_MAX <= result) {
-               ERR("Invalid result(%d)", result);
-               return IOTCON_ERROR_INVALID_PARAMETER;
-       }
-       resp->result = result;
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_response_set_representation(iotcon_response_h resp,
-               iotcon_representation_h repr)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == resp, IOTCON_ERROR_INVALID_PARAMETER);
-
-       if (repr)
-               repr = icl_representation_ref(repr);
-
-       if (resp->repr)
-               iotcon_representation_destroy(resp->repr);
-
-       resp->repr = repr;
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_response_set_options(iotcon_response_h resp,
-               iotcon_options_h options)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == resp, IOTCON_ERROR_INVALID_PARAMETER);
-
-       if (options)
-               options = icl_options_ref(options);
-
-       if (resp->header_options)
-               iotcon_options_destroy(resp->header_options);
-
-       resp->header_options = options;
-
-       return IOTCON_ERROR_NONE;
-}
-
-API int iotcon_response_send(iotcon_response_h resp)
-{
-       FN_CALL;
-       int ret;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
-                       IOTCON_ERROR_PERMISSION_DENIED);
-       RETV_IF(NULL == resp, IOTCON_ERROR_INVALID_PARAMETER);
-
-       ret = icl_ioty_response_send(resp);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_response_send() Fail(%d)", ret);
-               return ret;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
index 29143fb78e36e568a37c43eaf76ee35b975236d1..18b97a48d4e859cd8e920298cce74dd75f4ee901 100644 (file)
@@ -35,4 +35,6 @@ struct icl_resource_response {
        OCResourceHandle oic_resource_h;
 };
 
+int icl_response_destroy(iotcon_response_h resp);
+
 #endif /* __IOTCON_INTERNAL_RESPONSE_H__ */
index a714c19d649b847d0266c32a648b206a3708306f..8938ffc1d6de02d5d430ad11e04b1537596d6d86 100644 (file)
 #include "ic-request.h"
 #include "ic-ioty-parse.h"
 #include "ic-types.h"
+#include "ic-query.h"
+#include "ic-representation.h"
+#include "ic-resource-types.h"
+#include "ic-response.h"
 
 void icl_destroy_find_cb_data(icl_find_cb_s *cb_data)
 {
@@ -191,7 +195,7 @@ void icl_destroy_observe_cb_data(icl_observe_cb_s *cb_data)
 {
        RET_IF(NULL == cb_data);
 
-       iotcon_response_destroy(cb_data->response);
+       icl_response_destroy(cb_data->response);
        icl_remote_resource_unref(cb_data->resource);
 
        free(cb_data);
@@ -226,7 +230,7 @@ void icl_destroy_response_cb_data(icl_response_cb_s *cb_data)
 {
        RET_IF(NULL == cb_data);
 
-       iotcon_response_destroy(cb_data->response);
+       icl_response_destroy(cb_data->response);
        icl_remote_resource_unref(cb_data->resource);
        free(cb_data);
 }
@@ -262,11 +266,11 @@ static void _icl_destroy_request(iotcon_request_h request)
 
        free(request->host_address);
        if (request->header_options)
-               iotcon_options_destroy(request->header_options);
+               icl_options_destroy(request->header_options);
        if (request->query)
-               iotcon_query_destroy(request->query);
+               icl_query_destroy(request->query);
        if (request->repr)
-               iotcon_representation_destroy(request->repr);
+               icl_representation_destroy(request->repr);
        free(request);
 }
 
index 8b0c172ef99181723433c272d9581d564ca73db9..9f1a1fddab30a751c72830d50b21f26ac6ada0a0 100644 (file)
@@ -279,7 +279,6 @@ void ic_utils_mutex_unlock(int type)
 
 int ic_utils_cond_polling_init()
 {
-       FN_CALL;
        int ret;
        pthread_condattr_t attr;
 
index 182b63594d918f5529d11d7f7b219b104f236a86..7163b69bc7154690fef0300a97b73868f92727a4 100644 (file)
@@ -318,7 +318,7 @@ void icl_value_destroy(gpointer data)
                        ERR("icl_value_get_list() Fail(%d)", ret);
                        break;
                }
-               iotcon_list_destroy(list);
+               icl_list_destroy(list);
                break;
        case IOTCON_TYPE_ATTRIBUTES:
                ret = icl_value_get_attributes(value, &attributes);
@@ -326,7 +326,7 @@ void icl_value_destroy(gpointer data)
                        ERR("icl_value_get_attributes() Fail(%d)", ret);
                        break;
                }
-               iotcon_attributes_destroy(attributes);
+               icl_attributes_destroy(attributes);
                break;
        default:
                ERR("Invalid type(%d)", type);
index 68e357f60e84dc074549ada7f52b3eaaf1003262..b1fbd5536107b3186aaa743e3fa72dc59cf1e944 100644 (file)
--- a/src/ic.c
+++ b/src/ic.c
 #include "ic-utils.h"
 #include "ic-ioty.h"
 
-#define ICL_TIMEOUT_DEFAULT 30 /* 30 sec */
 #define ICL_TIMEOUT_MAX 60*60 /* 60 min */
-
+#define ICL_TIMEOUT_DEFAULT 30 /* 30 sec */
 #define ICL_DEFAULT_DEVICE_NAME "UNKNOWN"
 
+#define ICL_IOTY_TIME_INTERVAL_DEFAULT 100 /* 100 ms */
+
 static pthread_t icl_thread;
 static int icl_timeout_seconds = ICL_TIMEOUT_DEFAULT;
 static int icl_init_count;
 
+static int icl_ioty_polling_interval = ICL_IOTY_TIME_INTERVAL_DEFAULT;
+
 int icl_initialize(const char *file_path, bool is_pt)
 {
        int ret;
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(false == ic_utils_check_permission((IC_PERMISSION_INTERNET|IC_PERMISSION_NETWORK_GET)),
-                       IOTCON_ERROR_PERMISSION_DENIED);
        RETV_IF(NULL == file_path, IOTCON_ERROR_INVALID_PARAMETER);
 
 #if !GLIB_CHECK_VERSION(2, 35, 0)
@@ -79,17 +79,8 @@ int icl_initialize(const char *file_path, bool is_pt)
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_initialize(const char *file_path)
+int icl_deinitialize(void)
 {
-       FN_CALL;
-       return icl_initialize(file_path, false);
-}
-
-API int iotcon_deinitialize(void)
-{
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-
        ic_utils_mutex_lock(IC_UTILS_MUTEX_INIT);
 
        icl_init_count--;
@@ -103,10 +94,8 @@ API int iotcon_deinitialize(void)
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_get_timeout(int *timeout_seconds)
+int icl_get_timeout(int *timeout_seconds)
 {
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == timeout_seconds, IOTCON_ERROR_INVALID_PARAMETER);
 
        *timeout_seconds = icl_timeout_seconds;
@@ -114,51 +103,43 @@ API int iotcon_get_timeout(int *timeout_seconds)
        return IOTCON_ERROR_NONE;
 }
 
-
-API int iotcon_set_timeout(int timeout_seconds)
+int icl_set_timeout(int timeout_seconds)
 {
-       FN_CALL;
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
        if (ICL_TIMEOUT_MAX < timeout_seconds || timeout_seconds <= 0) {
                ERR("timeout_seconds(%d) must be in range from 1 to 3600", timeout_seconds);
                return IOTCON_ERROR_INVALID_PARAMETER;
        }
+       INFO("timeout_seconds [%d]", timeout_seconds);
 
        icl_timeout_seconds = timeout_seconds;
 
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_add_generated_pin_cb(iotcon_generated_pin_cb cb, void *user_data)
+int icl_polling_get_interval(int *interval)
 {
-       FN_CALL;
-       int ret;
-
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == interval, IOTCON_ERROR_INVALID_PARAMETER);
 
-       ret = icl_ioty_add_generated_pin_cb(cb, user_data);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_set_generate_pin_cb() Fail(%d)", ret);
-               return ret;
-       }
+       *interval = icl_ioty_polling_interval;
 
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_remove_generated_pin_cb(iotcon_generated_pin_cb cb)
+int icl_polling_set_interval(int interval)
 {
-       FN_CALL;
-       int ret;
+       RETV_IF(interval <= 0, IOTCON_ERROR_INVALID_PARAMETER);
+       INFO("interval [%d]", interval);
 
-       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
-       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
+       icl_ioty_polling_interval = interval;
 
-       ret = icl_ioty_remove_generated_pin_cb(cb);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("icl_ioty_remove_generated_pin_cb() Fail(%d)", ret);
-               return ret;
-       }
+       ic_utils_cond_signal(IC_UTILS_COND_POLLING);
+
+       return IOTCON_ERROR_NONE;
+}
+
+int icl_polling_invoke(void)
+{
+       ic_utils_cond_signal(IC_UTILS_COND_POLLING);
 
        return IOTCON_ERROR_NONE;
 }
index dcaa9f6052240d2c224404551723e1896c8c4052..a939f7afc167103b4e0d817e0eb41fc9dba72fd7 100644 (file)
--- a/src/ic.h
+++ b/src/ic.h
@@ -13,8 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#ifndef __IOTCON_INTERNAL_H__
-#define __IOTCON_INTERNAL_H__
+#ifndef __IOTCON_INTERNAL_IC_H__
+#define __IOTCON_INTERNAL_IC_H__
 
 #include "iotcon.h"
 #include "ic-common.h"
 #define API __attribute__((visibility("default")))
 
 int icl_initialize(const char *file_path, bool is_pt);
+int icl_deinitialize(void);
+int icl_get_timeout(int *timeout_seconds);
+int icl_set_timeout(int timeout_seconds);
+int icl_polling_get_interval(int *interval);
+int icl_polling_set_interval(int interval);
+int icl_polling_invoke(void);
 
-#endif /* __IOTCON_INTERNAL_H__ */
+#endif /* __IOTCON_INTERNAL_IC_H__ */
diff --git a/src/iotcon-attributes.c b/src/iotcon-attributes.c
new file mode 100644 (file)
index 0000000..977b0a9
--- /dev/null
@@ -0,0 +1,432 @@
+/* Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <stdlib.h>
+#include <errno.h>
+#include <glib.h>
+
+#include "iotcon-types.h"
+#include "ic.h"
+#include "ic-list.h"
+#include "ic-value.h"
+#include "ic-utils.h"
+#include "ic-representation.h"
+#include "ic-attributes.h"
+
+API int iotcon_attributes_create(iotcon_attributes_h *ret_attributes)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+
+       return icl_attributes_create(ret_attributes);
+}
+
+
+API int iotcon_attributes_destroy(iotcon_attributes_h attributes)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+
+       return icl_attributes_destroy(attributes);
+}
+
+API int iotcon_attributes_remove(iotcon_attributes_h attributes, const char *key)
+{
+       API_CALL;
+       gboolean ret = FALSE;
+       iotcon_value_h value = NULL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
+
+       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(attributes->hash_table, key);
+       if (FALSE == ret) {
+               ERR("g_hash_table_remove(%s) Fail", key);
+               return IOTCON_ERROR_NO_DATA;
+       }
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_attributes_get_int(iotcon_attributes_h attributes, const char *key,
+               int *val)
+{
+       API_CALL;
+       iotcon_value_h value;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       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(attributes->hash_table, key);
+       if (NULL == value) {
+               ERR("g_hash_table_lookup() Fail");
+               return IOTCON_ERROR_NO_DATA;
+       }
+
+       icl_basic_s *real = (icl_basic_s*)value;
+       if (IOTCON_TYPE_INT != real->type) {
+               ERR("Invalid Type(%d)", real->type);
+               return IOTCON_ERROR_INVALID_TYPE;
+       }
+
+       *val = real->val.i;
+
+       return IOTCON_ERROR_NONE;
+}
+
+API int iotcon_attributes_add_int(iotcon_attributes_h attributes, const char *key,
+               int val)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+
+       return icl_attributes_add_int(attributes, key, val);
+}
+
+API int iotcon_attributes_get_bool(iotcon_attributes_h attributes, const char *key,
+               bool *val)
+{
+       API_CALL;
+       icl_basic_s *real = NULL;
+       iotcon_value_h value = NULL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       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(attributes->hash_table, key);
+       if (NULL == value) {
+               ERR("g_hash_table_lookup() Fail");
+               return IOTCON_ERROR_NO_DATA;
+       }
+
+       real = (icl_basic_s*)value;
+       if (IOTCON_TYPE_BOOL != real->type) {
+               ERR("Invalid Type(%d)", real->type);
+               return IOTCON_ERROR_INVALID_TYPE;
+       }
+
+       *val = real->val.b;
+
+       return IOTCON_ERROR_NONE;
+}
+
+API int iotcon_attributes_add_bool(iotcon_attributes_h attributes, const char *key,
+               bool val)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+
+       return icl_attributes_add_bool(attributes, key, val);
+}
+
+API int iotcon_attributes_get_double(iotcon_attributes_h attributes,
+               const char *key, double *val)
+{
+       API_CALL;
+       icl_basic_s *real = NULL;
+       iotcon_value_h value = NULL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       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(attributes->hash_table, key);
+       if (NULL == value) {
+               ERR("g_hash_table_lookup() Fail");
+               return IOTCON_ERROR_NO_DATA;
+       }
+
+       real = (icl_basic_s*)value;
+       if (IOTCON_TYPE_DOUBLE != real->type) {
+               ERR("Invalid Type(%d)", real->type);
+               return IOTCON_ERROR_INVALID_TYPE;
+       }
+
+       *val = real->val.d;
+
+       return IOTCON_ERROR_NONE;
+}
+
+API int iotcon_attributes_add_double(iotcon_attributes_h attributes,
+               const char *key, double val)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+
+       return icl_attributes_add_double(attributes, key, val);
+}
+
+API int iotcon_attributes_get_str(iotcon_attributes_h attributes, const char *key,
+               char **val)
+{
+       API_CALL;
+       icl_basic_s *real = NULL;
+       iotcon_value_h value = NULL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       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(attributes->hash_table, key);
+       if (NULL == value) {
+               ERR("g_hash_table_lookup() Fail");
+               return IOTCON_ERROR_NO_DATA;
+       }
+
+       real = (icl_basic_s*)value;
+       if (IOTCON_TYPE_STR != real->type) {
+               ERR("Invalid Type(%d)", real->type);
+               return IOTCON_ERROR_INVALID_TYPE;
+       }
+
+       *val = real->val.s;
+
+       return IOTCON_ERROR_NONE;
+}
+
+API int iotcon_attributes_add_str(iotcon_attributes_h attributes, const char *key,
+               char *val)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+
+       return icl_attributes_add_str(attributes, key, val);
+}
+
+API int iotcon_attributes_get_byte_str(iotcon_attributes_h attributes, const char *key,
+               unsigned char **val, int *len)
+{
+       API_CALL;
+       iotcon_value_h value = NULL;
+       icl_val_byte_str_s *real = NULL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       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(attributes->hash_table, key);
+       if (NULL == value) {
+               ERR("g_hash_table_lookup() Fail");
+               return IOTCON_ERROR_NO_DATA;
+       }
+
+       real = (icl_val_byte_str_s*)value;
+       if (IOTCON_TYPE_BYTE_STR != real->type) {
+               ERR("Invalid Type(%d)", real->type);
+               return IOTCON_ERROR_INVALID_TYPE;
+       }
+
+       *val = real->s;
+       *len = real->len;
+
+       return IOTCON_ERROR_NONE;
+}
+
+API int iotcon_attributes_add_byte_str(iotcon_attributes_h attributes,
+               const char *key, unsigned char *val, int len)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+
+       return icl_attributes_add_byte_str(attributes, key, val, len);
+}
+
+API int iotcon_attributes_is_null(iotcon_attributes_h attributes, const char *key,
+               bool *is_null)
+{
+       API_CALL;
+       icl_basic_s *real = NULL;
+       iotcon_value_h value = NULL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       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(attributes->hash_table, key);
+       if (NULL == value) {
+               ERR("g_hash_table_lookup() Fail");
+               return IOTCON_ERROR_NO_DATA;
+       }
+
+       real = (icl_basic_s*)value;
+       *is_null = (IOTCON_TYPE_NULL == real->type) ? true : false;
+
+       return IOTCON_ERROR_NONE;
+}
+
+API int iotcon_attributes_add_null(iotcon_attributes_h attributes, const char *key)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+
+       return icl_attributes_add_null(attributes, key);
+}
+
+API int iotcon_attributes_get_list(iotcon_attributes_h attributes, const char *key,
+               iotcon_list_h *list)
+{
+       API_CALL;
+       iotcon_value_h value = NULL;
+       icl_val_list_s *real = NULL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       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(attributes->hash_table, key);
+       if (NULL == value) {
+               ERR("g_hash_table_lookup() Fail");
+               return IOTCON_ERROR_NO_DATA;
+       }
+
+       real = (icl_val_list_s*)value;
+       if (IOTCON_TYPE_LIST != real->type) {
+               ERR("Invalid Type(%d)", real->type);
+               return IOTCON_ERROR_INVALID_TYPE;
+       }
+
+       *list = real->list;
+
+       return IOTCON_ERROR_NONE;
+}
+
+API int iotcon_attributes_add_list(iotcon_attributes_h attributes, const char *key,
+               iotcon_list_h list)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+
+       return icl_attributes_add_list(attributes, key, list);
+}
+
+API int iotcon_attributes_get_attributes(iotcon_attributes_h src, const char *key,
+               iotcon_attributes_h *dest)
+{
+       API_CALL;
+       icl_val_attributes_s *real = NULL;
+       iotcon_value_h value = NULL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == src, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == dest, IOTCON_ERROR_INVALID_PARAMETER);
+
+       value = g_hash_table_lookup(src->hash_table, key);
+       if (NULL == value) {
+               ERR("g_hash_table_lookup() Fail");
+               return IOTCON_ERROR_NO_DATA;
+       }
+
+       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->attributes;
+
+       return IOTCON_ERROR_NONE;
+}
+
+API int iotcon_attributes_add_attributes(iotcon_attributes_h attributes,
+               const char *key, iotcon_attributes_h val)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+
+       return icl_attributes_add_attributes(attributes, key, val);
+}
+
+API int iotcon_attributes_get_type(iotcon_attributes_h attributes, const char *key,
+               iotcon_type_e *type)
+{
+       API_CALL;
+       iotcon_value_h value = NULL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       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(attributes->hash_table, key);
+       if (NULL == value) {
+               ERR("g_hash_table_lookup() Fail");
+               return IOTCON_ERROR_NO_DATA;
+       }
+       *type = value->type;
+
+       return IOTCON_ERROR_NONE;
+}
+
+API int iotcon_attributes_get_keys_count(iotcon_attributes_h attributes,
+               unsigned int *count)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == count, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == attributes->hash_table, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *count = g_hash_table_size(attributes->hash_table);
+
+       return IOTCON_ERROR_NONE;
+}
+
+API int iotcon_attributes_clone(iotcon_attributes_h attributes,
+               iotcon_attributes_h *attributes_clone)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+
+       return icl_attributes_clone(attributes, attributes_clone);
+}
+
+API int iotcon_attributes_foreach(iotcon_attributes_h attributes,
+               iotcon_attributes_cb cb, void *user_data)
+{
+       API_CALL;
+       GHashTableIter iter;
+       gpointer key;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
+
+       g_hash_table_iter_init(&iter, attributes->hash_table);
+       while (g_hash_table_iter_next(&iter, &key, NULL)) {
+               if (IOTCON_FUNC_STOP == cb(attributes, key, user_data))
+                       break;
+       }
+
+       return IOTCON_ERROR_NONE;
+}
+
diff --git a/src/iotcon-device.c b/src/iotcon-device.c
new file mode 100644 (file)
index 0000000..554341d
--- /dev/null
@@ -0,0 +1,173 @@
+/*
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "iotcon.h"
+#include "ic.h"
+#include "ic-utils.h"
+#include "ic-representation.h"
+#include "ic-device.h"
+#include "ic-ioty.h"
+
+API int iotcon_device_info_get_property(iotcon_device_info_h device_info,
+               iotcon_device_info_e property, char **value)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == device_info, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == value, IOTCON_ERROR_INVALID_PARAMETER);
+
+       switch (property) {
+       case IOTCON_DEVICE_INFO_NAME:
+               *value = device_info->device_name;
+               break;
+       case IOTCON_DEVICE_INFO_SPEC_VER:
+               *value = device_info->spec_ver;
+               break;
+       case IOTCON_DEVICE_INFO_ID:
+               *value = device_info->device_id;
+               break;
+       case IOTCON_DEVICE_INFO_DATA_MODEL_VER:
+               *value = device_info->data_model_ver;
+               break;
+       default:
+               ERR("Invalid property(%d)", property);
+               return IOTCON_ERROR_INVALID_PARAMETER;
+       }
+
+       return IOTCON_ERROR_NONE;
+}
+
+API int iotcon_find_device_info(const char *host_address,
+               int connectivity_type,
+               iotcon_query_h query,
+               iotcon_device_info_cb cb,
+               void *user_data)
+{
+       API_CALL;
+       int ret;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
+                       IOTCON_ERROR_PERMISSION_DENIED);
+       RETV_IF(false == ic_utils_check_connectivity_type(connectivity_type),
+                       IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
+
+       ret = icl_ioty_find_device_info(host_address, connectivity_type, query, cb,
+                       user_data);
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("icl_ioty_find_device_info() Fail(%d)", ret);
+               return ret;
+       }
+
+       return IOTCON_ERROR_NONE;
+}
+
+API int iotcon_set_device_name(const char *device_name)
+{
+       API_CALL;
+       int ret;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == device_name || '\0' == *device_name, IOTCON_ERROR_INVALID_PARAMETER);
+
+       ret = icl_ioty_set_device_info(device_name);
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("icl_ioty_set_device_info() Fail(%d)", ret);
+               return ret;
+       }
+
+       return IOTCON_ERROR_NONE;
+}
+
+API int iotcon_platform_info_get_property(iotcon_platform_info_h platform_info,
+               iotcon_platform_info_e property, char **value)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == platform_info, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == value, IOTCON_ERROR_INVALID_PARAMETER);
+
+       switch (property) {
+       case IOTCON_PLATFORM_INFO_ID:
+               *value = platform_info->platform_id;
+               break;
+       case IOTCON_PLATFORM_INFO_MANUF_NAME:
+               *value = platform_info->manuf_name;
+               break;
+       case IOTCON_PLATFORM_INFO_MANUF_URL:
+               *value = platform_info->manuf_url;
+               break;
+       case IOTCON_PLATFORM_INFO_MODEL_NUMBER:
+               *value = platform_info->model_number;
+               break;
+       case IOTCON_PLATFORM_INFO_DATE_OF_MANUF:
+               *value = platform_info->date_of_manuf;
+               break;
+       case IOTCON_PLATFORM_INFO_PLATFORM_VER:
+               *value = platform_info->platform_ver;
+               break;
+       case IOTCON_PLATFORM_INFO_OS_VER:
+               *value = platform_info->os_ver;
+               break;
+       case IOTCON_PLATFORM_INFO_HARDWARE_VER:
+               *value = platform_info->hardware_ver;
+               break;
+       case IOTCON_PLATFORM_INFO_FIRMWARE_VER:
+               *value = platform_info->firmware_ver;
+               break;
+       case IOTCON_PLATFORM_INFO_SUPPORT_URL:
+               *value = platform_info->support_url;
+               break;
+       case IOTCON_PLATFORM_INFO_SYSTEM_TIME:
+               *value = platform_info->system_time;
+               break;
+       default:
+               ERR("Invalid property(%d)", property);
+               return IOTCON_ERROR_INVALID_PARAMETER;
+       }
+
+       return IOTCON_ERROR_NONE;
+}
+
+API int iotcon_find_platform_info(const char *host_address,
+               int connectivity_type,
+               iotcon_query_h query,
+               iotcon_platform_info_cb cb,
+               void *user_data)
+{
+       API_CALL;
+       int ret;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
+                       IOTCON_ERROR_PERMISSION_DENIED);
+       RETV_IF(false == ic_utils_check_connectivity_type(connectivity_type),
+                       IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
+
+       ret = icl_ioty_find_platform_info(host_address, connectivity_type, query, cb,
+                       user_data);
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("icl_ioty_find_platform_info() Fail(%d)", ret);
+               return ret;
+       }
+
+       return IOTCON_ERROR_NONE;
+}
diff --git a/src/iotcon-list.c b/src/iotcon-list.c
new file mode 100644 (file)
index 0000000..1526adf
--- /dev/null
@@ -0,0 +1,253 @@
+/*
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <errno.h>
+
+#include "iotcon-types.h"
+#include "ic.h"
+#include "ic-utils.h"
+#include "ic-attributes.h"
+#include "ic-representation.h"
+#include "ic-value.h"
+#include "ic-list.h"
+
+API int iotcon_list_create(iotcon_type_e type, iotcon_list_h *ret_list)
+{
+       API_CALL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_list_create(type, ret_list);
+}
+
+
+API int iotcon_list_add_int(iotcon_list_h list, int val, int pos)
+{
+       API_CALL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_list_add_int(list, val, pos);
+}
+
+
+API int iotcon_list_add_bool(iotcon_list_h list, bool val, int pos)
+{
+       API_CALL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_list_add_bool(list, val, pos);
+}
+
+
+API int iotcon_list_add_double(iotcon_list_h list, double val, int pos)
+{
+       API_CALL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_list_add_double(list, val, pos);
+}
+
+
+API int iotcon_list_add_str(iotcon_list_h list, char *val, int pos)
+{
+       API_CALL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_list_add_str(list, val, pos);
+}
+
+
+API int iotcon_list_add_byte_str(iotcon_list_h list, unsigned char *val, int len, int pos)
+{
+       API_CALL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_list_add_byte_str(list, val, len, pos);
+}
+
+
+API int iotcon_list_add_list(iotcon_list_h list, iotcon_list_h val, int pos)
+{
+       API_CALL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_list_add_list(list, val, pos);
+}
+
+
+API int iotcon_list_add_attributes(iotcon_list_h list, iotcon_attributes_h val, int pos)
+{
+       API_CALL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_list_add_attributes(list, val, pos);
+}
+
+
+API int iotcon_list_get_nth_int(iotcon_list_h list, int pos, int *val)
+{
+       API_CALL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_list_get_nth_int(list, pos, val);
+}
+
+
+API int iotcon_list_get_nth_bool(iotcon_list_h list, int pos, bool *val)
+{
+       API_CALL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_list_get_nth_bool(list, pos, val);
+}
+
+
+API int iotcon_list_get_nth_double(iotcon_list_h list, int pos, double *val)
+{
+       API_CALL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_list_get_nth_double(list, pos, val);
+}
+
+
+API int iotcon_list_get_nth_str(iotcon_list_h list, int pos, char **val)
+{
+       API_CALL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_list_get_nth_str(list, pos, val);
+}
+
+
+API int iotcon_list_get_nth_byte_str(iotcon_list_h list, int pos, unsigned char **val, int *len)
+{
+       API_CALL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_list_get_nth_byte_str(list, pos, val, len);
+}
+
+
+API int iotcon_list_get_nth_list(iotcon_list_h src, int pos, iotcon_list_h *dest)
+{
+       API_CALL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_list_get_nth_list(src, pos, dest);
+}
+
+
+API int iotcon_list_get_nth_attributes(iotcon_list_h list, int pos, iotcon_attributes_h *attributes)
+{
+       API_CALL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_list_get_nth_attributes(list, pos, attributes);
+}
+
+
+API int iotcon_list_remove_nth(iotcon_list_h list, int pos)
+{
+       API_CALL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_list_remove_nth(list, pos);
+}
+
+
+API int iotcon_list_get_type(iotcon_list_h list, iotcon_type_e *type)
+{
+       API_CALL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_list_get_type(list, type);
+}
+
+
+API int iotcon_list_get_length(iotcon_list_h list, unsigned int *length)
+{
+       API_CALL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_list_get_length(list, length);
+}
+
+
+API int iotcon_list_foreach_int(iotcon_list_h list, iotcon_list_int_cb cb, void *user_data)
+{
+       API_CALL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_list_foreach_int(list, cb, user_data);
+}
+
+API int iotcon_list_foreach_bool(iotcon_list_h list, iotcon_list_bool_cb cb, void *user_data)
+{
+       API_CALL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_list_foreach_bool(list, cb, user_data);
+}
+
+API int iotcon_list_foreach_double(iotcon_list_h list, iotcon_list_double_cb cb, void *user_data)
+{
+       API_CALL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_list_foreach_double(list, cb, user_data);
+}
+
+API int iotcon_list_foreach_str(iotcon_list_h list, iotcon_list_str_cb cb, void *user_data)
+{
+       API_CALL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_list_foreach_str(list, cb, user_data);
+}
+
+API int iotcon_list_foreach_byte_str(iotcon_list_h list, iotcon_list_byte_str_cb cb, void *user_data)
+{
+       API_CALL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_list_foreach_byte_str(list, cb, user_data);
+}
+
+API int iotcon_list_foreach_list(iotcon_list_h list, iotcon_list_list_cb cb, void *user_data)
+{
+       API_CALL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_list_foreach_list(list, cb, user_data);
+}
+
+API int iotcon_list_foreach_attributes(iotcon_list_h list, iotcon_list_attributes_cb cb, void *user_data)
+{
+       API_CALL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_list_foreach_attributes(list, cb, user_data);
+}
+
+
+API int iotcon_list_destroy(iotcon_list_h list)
+{
+       API_CALL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_list_destroy(list);
+}
diff --git a/src/iotcon-lite-resource.c b/src/iotcon-lite-resource.c
new file mode 100644 (file)
index 0000000..7c0d779
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "iotcon-types.h"
+#include "ic.h"
+#include "ic-utils.h"
+#include "ic-representation.h"
+#include "ic-attributes.h"
+#include "ic-value.h"
+#include "ic-list.h"
+#include "ic-resource.h"
+#include "ic-response.h"
+#include "ic-lite-resource.h"
+#include "ic-ioty.h"
+
+
+/* The length of uri_path should be less than 128. */
+API int iotcon_lite_resource_create(const char *uri_path,
+               iotcon_resource_types_h res_types,
+               uint8_t policies,
+               iotcon_attributes_h attributes,
+               iotcon_lite_resource_post_request_cb cb,
+               void *user_data,
+               iotcon_lite_resource_h *resource_handle)
+{
+       API_CALL;
+       int ret;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
+                       IOTCON_ERROR_PERMISSION_DENIED);
+       RETV_IF(NULL == uri_path, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(false == icl_resource_check_uri_path(uri_path),
+                       IOTCON_ERROR_INVALID_PARAMETER);
+       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, attributes, cb,
+                       user_data, resource_handle);
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("icl_ioty_lite_resource_create() Fail(%d)", ret);
+               return ret;
+       }
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_lite_resource_destroy(iotcon_lite_resource_h resource)
+{
+       API_CALL;
+       int ret;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
+                       IOTCON_ERROR_PERMISSION_DENIED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+
+       ret = icl_ioty_lite_resource_destroy(resource);
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("icl_ioty_lite_resource_destroy() Fail(%d)", ret);
+               return ret;
+       }
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_lite_resource_update_attributes(iotcon_lite_resource_h resource,
+               iotcon_attributes_h attributes)
+{
+       API_CALL;
+       int ret;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
+                       IOTCON_ERROR_PERMISSION_DENIED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+
+       ret = icl_ioty_lite_resource_update_attributes(resource, attributes);
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("icl_ioty_lite_resource_update_attributes() Fail(%d)", ret);
+               return ret;
+       }
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_lite_resource_get_attributes(iotcon_lite_resource_h resource,
+               iotcon_attributes_h *attributes)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == attributes, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *attributes = resource->attributes;
+
+       return IOTCON_ERROR_NONE;
+}
diff --git a/src/iotcon-observers.c b/src/iotcon-observers.c
new file mode 100644 (file)
index 0000000..646806a
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <stdlib.h>
+#include <errno.h>
+#include <glib.h>
+
+#include "iotcon-types.h"
+#include "ic.h"
+#include "ic-utils.h"
+#include "ic-observers.h"
+
+API int iotcon_observers_create(iotcon_observers_h *ret_observers)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+
+       return icl_observers_create(ret_observers);
+}
+
+
+API int iotcon_observers_destroy(iotcon_observers_h observers)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+
+       return icl_observers_destroy(observers);
+}
+
+
+API int iotcon_observers_add(iotcon_observers_h observers, int obs_id)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+
+       return icl_observers_add(observers, obs_id);
+}
+
+
+API int iotcon_observers_remove(iotcon_observers_h observers, int obs_id)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+
+       return icl_observers_remove(observers, obs_id);
+}
+
diff --git a/src/iotcon-options.c b/src/iotcon-options.c
new file mode 100644 (file)
index 0000000..825bbc9
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <stdlib.h>
+#include <errno.h>
+#include <glib.h>
+
+#include "iotcon-types.h"
+#include "ic.h"
+#include "ic-utils.h"
+#include "ic-options.h"
+
+API int iotcon_options_create(iotcon_options_h *ret_options)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+
+       return icl_options_create(ret_options);
+}
+
+
+API int iotcon_options_destroy(iotcon_options_h options)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+
+       return icl_options_destroy(options);
+}
+
+
+/* iotcon_options_h can have up to 2 options.
+ * option id is always situated between 2048 and 3000.
+ * Length of option data is less than or equal to 15. */
+API int iotcon_options_add(iotcon_options_h options, unsigned short id,
+               const char *data)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+
+       return icl_options_add(options, id, data);
+}
+
+
+API int iotcon_options_remove(iotcon_options_h options, unsigned short id)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+
+       return icl_options_remove(options, id);
+}
+
+
+API int iotcon_options_lookup(iotcon_options_h options, unsigned short id,
+               char **data)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+
+       return icl_options_lookup(options, id, data);
+}
+
+
+API int iotcon_options_foreach(iotcon_options_h options,
+               iotcon_options_foreach_cb cb, void *user_data)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+
+       return icl_options_foreach(options, cb, user_data);
+}
diff --git a/src/iotcon-presence.c b/src/iotcon-presence.c
new file mode 100644 (file)
index 0000000..1640283
--- /dev/null
@@ -0,0 +1,230 @@
+/*
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "iotcon-types.h"
+#include "ic.h"
+#include "ic-utils.h"
+#include "ic-resource.h"
+#include "ic-presence.h"
+#include "ic-resource-types.h"
+#include "ic-ioty.h"
+
+API int iotcon_start_presence(unsigned int time_to_live)
+{
+       API_CALL;
+       int ret;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
+                       IOTCON_ERROR_PERMISSION_DENIED);
+
+       ret = icl_ioty_start_presence(time_to_live);
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("icl_ioty_start_presence() Fail(%d)", ret);
+               return ret;
+       }
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_stop_presence(void)
+{
+       API_CALL;
+       int ret;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
+                       IOTCON_ERROR_PERMISSION_DENIED);
+
+       ret = icl_ioty_stop_presence();
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("icl_ioty_stop_presence() Fail(%d)", ret);
+               return ret;
+       }
+
+       return IOTCON_ERROR_NONE;
+}
+
+/* The length of resource_type should be less than or equal to 61. */
+API int iotcon_add_presence_cb(const char *host_address,
+               iotcon_connectivity_type_e connectivity_type,
+               const char *resource_type,
+               iotcon_presence_cb cb,
+               void *user_data,
+               iotcon_presence_h *presence_handle)
+{
+       API_CALL;
+       int ret;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
+                       IOTCON_ERROR_PERMISSION_DENIED);
+       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == presence_handle, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(resource_type && (false == icl_resource_check_type(resource_type)),
+                       IOTCON_ERROR_INVALID_PARAMETER);
+
+       ret = icl_ioty_add_presence_cb(host_address, connectivity_type, resource_type,
+                       cb, user_data, presence_handle);
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("icl_ioty_add_presence_cb() Fail(%d)", ret);
+               return ret;
+       }
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_remove_presence_cb(iotcon_presence_h presence)
+{
+       API_CALL;
+       int ret;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
+                       IOTCON_ERROR_PERMISSION_DENIED);
+       RETV_IF(NULL == presence, IOTCON_ERROR_INVALID_PARAMETER);
+
+       ret = icl_ioty_remove_presence_cb(presence);
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("icl_ioty_remove_presence_cb() Fail(%d)", ret);
+               return ret;
+       }
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_presence_get_host_address(iotcon_presence_h presence,
+               char **host_address)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == presence, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == host_address, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *host_address = presence->host_address;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_presence_get_connectivity_type(iotcon_presence_h presence,
+               iotcon_connectivity_type_e *connectivity_type)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == presence, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == connectivity_type, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *connectivity_type = presence->connectivity_type;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_presence_get_resource_type(iotcon_presence_h presence,
+               char **resource_type)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == presence, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == resource_type, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *resource_type = presence->resource_type;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_presence_response_get_host_address(
+               iotcon_presence_response_h response, char **host_address)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == response, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == host_address, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *host_address = response->host_address;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_presence_response_get_connectivity_type(
+               iotcon_presence_response_h response, iotcon_connectivity_type_e *connectivity_type)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == response, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == connectivity_type, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *connectivity_type = response->connectivity_type;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_presence_response_get_resource_type(
+               iotcon_presence_response_h response, char **resource_type)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == response, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == resource_type, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *resource_type = response->resource_type;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_presence_response_get_result(iotcon_presence_response_h response,
+               iotcon_presence_result_e *result)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == response, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == result, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *result = response->result;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_presence_response_get_trigger(iotcon_presence_response_h response,
+               iotcon_presence_trigger_e *trigger)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == response, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == trigger, IOTCON_ERROR_INVALID_PARAMETER);
+
+       if (IOTCON_PRESENCE_OK != response->result) {
+               ERR("trigger is valid if IOTCON_PRESENCE_OK");
+               return IOTCON_ERROR_INVALID_PARAMETER;
+       }
+
+       *trigger = response->trigger;
+
+       return IOTCON_ERROR_NONE;
+}
+
diff --git a/src/iotcon-provisioning-struct.c b/src/iotcon-provisioning-struct.c
new file mode 100644 (file)
index 0000000..2831bdc
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <stdlib.h>
+#include <stdint.h>
+#include <unistd.h>
+#include <errno.h>
+#include <glib.h>
+#include <octypes.h>
+#include <ocstack.h>
+#include <ocprovisioningmanager.h>
+#include <oxmjustworks.h>
+#include <oxmrandompin.h>
+#include <pmutility.h>
+
+#include "iotcon.h"
+#include "iotcon-provisioning.h"
+#include "ic.h"
+#include "ic-utils.h"
+#include "ic-ioty.h"
+#include "ic-provisioning-struct.h"
+
+API int iotcon_provisioning_device_clone(iotcon_provisioning_device_h device,
+               iotcon_provisioning_device_h *cloned_device)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_provisioning_device_clone(device, cloned_device);
+}
+
+API int iotcon_provisioning_device_destroy(iotcon_provisioning_device_h device)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_provisioning_device_destroy(device);
+}
+
+API int iotcon_provisioning_device_get_host_address(iotcon_provisioning_device_h device,
+               char **host_address)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_provisioning_device_get_host_address(device, host_address);
+}
+
+API int iotcon_provisioning_device_get_connectivity_type(
+               iotcon_provisioning_device_h device,
+               iotcon_connectivity_type_e *connectivity_type)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_provisioning_device_get_connectivity_type(device, connectivity_type);
+}
+
+API int iotcon_provisioning_device_get_id(iotcon_provisioning_device_h device,
+               char **device_id)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_provisioning_device_get_id(device, device_id);
+}
+
+API int iotcon_provisioning_device_get_oxm(iotcon_provisioning_device_h device,
+               iotcon_provisioning_oxm_e *oxm)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_provisioning_device_get_oxm(device, oxm);
+}
+
+API int iotcon_provisioning_device_is_owned(iotcon_provisioning_device_h device,
+               bool *is_owned)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_provisioning_device_is_owned(device, is_owned);
+}
+
+API int iotcon_provisioning_acl_create(iotcon_provisioning_acl_h *acl)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_provisioning_acl_create(acl);
+}
+
+API int iotcon_provisioning_acl_destroy(iotcon_provisioning_acl_h acl)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_provisioning_acl_destroy(acl);
+}
+
+API int iotcon_provisioning_acl_set_subject(iotcon_provisioning_acl_h acl,
+               iotcon_provisioning_device_h device)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_provisioning_acl_set_subject(acl, device);
+}
+
+API int iotcon_provisioning_acl_set_all_subject(iotcon_provisioning_acl_h acl)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_provisioning_acl_set_all_subject(acl);
+}
+
+API int iotcon_provisioning_acl_add_resource(iotcon_provisioning_acl_h acl,
+               const char *uri_path)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_provisioning_acl_add_resource(acl, uri_path);
+}
+
+API int iotcon_provisioning_acl_set_permission(iotcon_provisioning_acl_h acl,
+               int permission)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_provisioning_acl_set_permission(acl, permission);
+}
diff --git a/src/iotcon-provisioning.c b/src/iotcon-provisioning.c
new file mode 100644 (file)
index 0000000..7d43339
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <stdlib.h>
+#include <stdint.h>
+#include <unistd.h>
+#include <errno.h>
+#include <glib.h>
+
+#include "iotcon.h"
+#include "iotcon-provisioning.h"
+#include "ic-provisioning-struct.h"
+#include "ic-provisioning.h"
+#include "ic.h"
+#include "ic-utils.h"
+#include "ic-ioty.h"
+#include "ic-ioty-parse.h"
+
+API int iotcon_provisioning_initialize(const char *file_path, const char *db_path)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(false == ic_utils_check_permission((IC_PERMISSION_INTERNET
+                                       |IC_PERMISSION_NETWORK_GET)), IOTCON_ERROR_PERMISSION_DENIED);
+       return icl_provisioning_initialize(file_path, db_path);
+}
+
+API int iotcon_provisioning_set_randompin_cb(iotcon_provisioning_randompin_cb cb,
+               void *user_data)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_provisioning_set_randompin_cb(cb, user_data);
+}
+
+API int iotcon_provisioning_register_unowned_device(
+               iotcon_provisioning_device_h device,
+               iotcon_provisioning_ownership_transfer_cb cb,
+               void *user_data)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_provisioning_register_unowned_device(device, cb, user_data);
+}
+
+API int iotcon_provisioning_provision_cred(iotcon_provisioning_device_h device1,
+               iotcon_provisioning_device_h device2,
+               iotcon_provisioning_provision_cred_cb cb,
+               void *user_data)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_provisioning_provision_cred(device1, device2, cb, user_data);
+}
+
+API int iotcon_provisioning_provision_acl(iotcon_provisioning_device_h device,
+               iotcon_provisioning_acl_h acl,
+               iotcon_provisioning_provision_acl_cb cb,
+               void *user_data)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_provisioning_provision_acl(device, acl, cb, user_data);
+}
+
+API int iotcon_provisioning_pairwise_devices(iotcon_provisioning_device_h device1,
+               iotcon_provisioning_acl_h acl1,
+               iotcon_provisioning_device_h device2,
+               iotcon_provisioning_acl_h acl2,
+               iotcon_provisioning_pairwise_devices_cb cb,
+               void *user_data)
+
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_provisioning_pairwise_devices(device1, acl1, device2, acl2, cb, user_data);
+}
+
+API int iotcon_provisioning_unlink_pairwise(iotcon_provisioning_device_h device1,
+               iotcon_provisioning_device_h device2,
+               iotcon_provisioning_unlink_pairwise_cb cb,
+               void *user_data)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_provisioning_unlink_pairwise(device1, device2, cb, user_data);
+}
+
+API int iotcon_provisioning_find_device(iotcon_provisioning_find_e type,
+               iotcon_provisioning_found_device_cb cb, void *user_data)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_provisioning_find_device(type, cb, user_data);
+}
+
+API int iotcon_provisioning_remove_device(const char *device_id,
+               iotcon_provisioning_remove_device_cb cb, void *user_data)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_provisioning_remove_device(device_id, cb, user_data);
+}
diff --git a/src/iotcon-query.c b/src/iotcon-query.c
new file mode 100644 (file)
index 0000000..9ebd1c2
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <glib.h>
+
+#include "iotcon-types.h"
+#include "ic.h"
+#include "ic-utils.h"
+#include "ic-resource.h"
+#include "ic-resource-types.h"
+#include "ic-query.h"
+
+API int iotcon_query_create(iotcon_query_h *ret_query)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_query_create(ret_query);
+}
+
+API int iotcon_query_destroy(iotcon_query_h query)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_query_destroy(query);
+}
+
+API int iotcon_query_get_resource_type(iotcon_query_h query,
+               char **resource_type)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_query_get_resource_type(query, resource_type);
+}
+
+API int iotcon_query_get_interface(iotcon_query_h query, char **resource_iface)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_query_get_interface(query, resource_iface);
+}
+
+API int iotcon_query_set_resource_type(iotcon_query_h query, const char *resource_type)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_query_set_resource_type(query, resource_type);
+}
+
+API int iotcon_query_set_interface(iotcon_query_h query, const char *resource_iface)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_query_set_interface(query, resource_iface);
+}
+
+/* The full length of query should be less than or equal to 64. */
+API int iotcon_query_add(iotcon_query_h query, const char *key, const char *value)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_query_add(query, key, value);
+}
+
+API int iotcon_query_remove(iotcon_query_h query, const char *key)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_query_remove(query, key);
+}
+
+API int iotcon_query_lookup(iotcon_query_h query, const char *key, char **data)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_query_lookup(query, key, data);
+}
+
+API int iotcon_query_foreach(iotcon_query_h query, iotcon_query_foreach_cb cb, void *user_data)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_query_foreach(query, cb, user_data);
+}
+
diff --git a/src/iotcon-remote-resource-crud.c b/src/iotcon-remote-resource-crud.c
new file mode 100644 (file)
index 0000000..4df85da
--- /dev/null
@@ -0,0 +1,202 @@
+/*
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "iotcon.h"
+#include "ic.h"
+#include "ic-utils.h"
+#include "ic-ioty.h"
+#include "ic-options.h"
+#include "ic-response.h"
+#include "ic-representation.h"
+#include "ic-remote-resource.h"
+
+API int iotcon_remote_resource_get(iotcon_remote_resource_h resource,
+               iotcon_query_h query, iotcon_remote_resource_response_cb cb, void *user_data)
+{
+       API_CALL;
+       int ret;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
+                       IOTCON_ERROR_PERMISSION_DENIED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
+
+       if (true == resource->is_found) {
+               ERR("The resource should be cloned.");
+               return IOTCON_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = icl_ioty_remote_resource_get(resource, query, cb, user_data);
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("icl_ioty_remote_resource_get() Fail(%d)", ret);
+               return ret;
+       }
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_remote_resource_put(iotcon_remote_resource_h resource,
+               iotcon_representation_h repr,
+               iotcon_query_h query,
+               iotcon_remote_resource_response_cb cb,
+               void *user_data)
+{
+       API_CALL;
+       int ret;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
+                       IOTCON_ERROR_PERMISSION_DENIED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
+
+       if (true == resource->is_found) {
+               ERR("The resource should be cloned.");
+               return IOTCON_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = icl_ioty_remote_resource_put(resource, repr, query, cb, user_data);
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("icl_ioty_remote_resource_put() Fail(%d)", ret);
+               return ret;
+       }
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_remote_resource_post(iotcon_remote_resource_h resource,
+               iotcon_representation_h repr,
+               iotcon_query_h query,
+               iotcon_remote_resource_response_cb cb,
+               void *user_data)
+{
+       API_CALL;
+
+       int ret;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
+                       IOTCON_ERROR_PERMISSION_DENIED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
+
+       if (true == resource->is_found) {
+               ERR("The resource should be cloned.");
+               return IOTCON_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = icl_ioty_remote_resource_post(resource, repr, query, cb, user_data);
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("icl_ioty_remote_resource_post() Fail(%d)", ret);
+               return ret;
+       }
+
+       return IOTCON_ERROR_NONE;
+}
+
+API int iotcon_remote_resource_delete(iotcon_remote_resource_h resource,
+               iotcon_remote_resource_response_cb cb, void *user_data)
+{
+       API_CALL;
+       int ret;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
+                       IOTCON_ERROR_PERMISSION_DENIED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
+
+       if (true == resource->is_found) {
+               ERR("The resource should be cloned.");
+               return IOTCON_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = icl_ioty_remote_resource_delete(resource, cb, user_data);
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("icl_ioty_remote_resource_delete() Fail(%d)", ret);
+               return ret;
+       }
+
+       return IOTCON_ERROR_NONE;
+}
+
+API int iotcon_remote_resource_observe_register(
+               iotcon_remote_resource_h resource,
+               iotcon_observe_policy_e observe_policy,
+               iotcon_query_h query,
+               iotcon_remote_resource_observe_cb cb,
+               void *user_data)
+{
+       API_CALL;
+       int ret;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
+                       IOTCON_ERROR_PERMISSION_DENIED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(resource->obs_handle, IOTCON_ERROR_ALREADY);
+
+       if (true == resource->is_found) {
+               ERR("The resource should be cloned.");
+               return IOTCON_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = icl_ioty_remote_resource_observe_register(resource, observe_policy, query, cb,
+                       user_data);
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("icl_ioty_remote_resource_observe_register() Fail(%d)", ret);
+               return ret;
+       }
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_remote_resource_observe_deregister(
+               iotcon_remote_resource_h resource)
+{
+       API_CALL;
+       int ret;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
+                       IOTCON_ERROR_PERMISSION_DENIED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+
+       if (true == resource->is_found) {
+               ERR("The resource should be cloned.");
+               return IOTCON_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == resource->obs_handle) {
+               ERR("It doesn't have a observe_handle");
+               return IOTCON_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = icl_ioty_remote_resource_observe_deregister(resource);
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("icl_ioty_remote_resource_observe_deregister() Fail(%d)", ret);
+               return ret;
+       }
+
+       return IOTCON_ERROR_NONE;
+}
+
diff --git a/src/iotcon-remote-resource.c b/src/iotcon-remote-resource.c
new file mode 100644 (file)
index 0000000..50c17a9
--- /dev/null
@@ -0,0 +1,343 @@
+/*
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include "iotcon-types.h"
+#include "ic.h"
+#include "ic-utils.h"
+#include "ic-options.h"
+#include "ic-representation.h"
+#include "ic-remote-resource.h"
+#include "ic-resource.h"
+#include "ic-resource-types.h"
+#include "ic-resource-interfaces.h"
+#include "ic-ioty.h"
+
+#define ICL_REMOTE_RESOURCE_MAX_CHECKING_INTERVAL 3600 /* 60 min */
+
+/* The length of resource_type should be less than or equal to 61.
+ * If resource_type is NULL, then All resources in host are discovered. */
+API int iotcon_find_resource(const char *host_address,
+               int connectivity_type,
+               iotcon_query_h query,
+               iotcon_found_resource_cb cb,
+               void *user_data)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
+                       IOTCON_ERROR_PERMISSION_DENIED);
+       return icl_find_resource(host_address, connectivity_type, query, cb, user_data);
+}
+
+/* If you know the information of resource, then you can make a proxy of the resource. */
+API int iotcon_remote_resource_create(const char *host_address,
+               iotcon_connectivity_type_e connectivity_type,
+               const char *uri_path,
+               uint8_t policies,
+               iotcon_resource_types_h resource_types,
+               iotcon_resource_interfaces_h resource_ifaces,
+               iotcon_remote_resource_h *resource_handle)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_remote_resource_create(host_address, connectivity_type, uri_path,
+                                               policies, resource_types, resource_ifaces, resource_handle);
+
+}
+
+API int iotcon_remote_resource_destroy(iotcon_remote_resource_h resource)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_remote_resource_destroy(resource);
+}
+
+API int iotcon_remote_resource_clone(iotcon_remote_resource_h src,
+               iotcon_remote_resource_h *dest)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_remote_resource_clone(src, dest);
+}
+
+
+/* The content of the resource should not be freed by user. */
+API int iotcon_remote_resource_get_uri_path(iotcon_remote_resource_h resource,
+               char **uri_path)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == uri_path, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *uri_path = resource->uri_path;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+/* The content of the resource should not be freed by user. */
+API int iotcon_remote_resource_get_host_address(
+               iotcon_remote_resource_h resource, char **host_address)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == host_address, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *host_address = resource->host_address;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+/* The content of the resource should not be freed by user. */
+API int iotcon_remote_resource_get_connectivity_type(
+               iotcon_remote_resource_h resource, iotcon_connectivity_type_e *connectivity_type)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == connectivity_type, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *connectivity_type = resource->connectivity_type;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+/* The content of the resource should not be freed by user. */
+API int iotcon_remote_resource_get_device_id(iotcon_remote_resource_h resource,
+               char **device_id)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == device_id, IOTCON_ERROR_INVALID_PARAMETER);
+       RETVM_IF(NULL == resource->device_id, IOTCON_ERROR_NO_DATA,
+                       "If you want to get device ID, you should call iotcon_find_resource().");
+
+       *device_id = resource->device_id;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+/* The content of the resource should not be freed by user. */
+API int iotcon_remote_resource_get_device_name(iotcon_remote_resource_h resource,
+               char **device_name)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == device_name, IOTCON_ERROR_INVALID_PARAMETER);
+       RETVM_IF(NULL == resource->device_name, IOTCON_ERROR_NO_DATA,
+                       "If you want to get device name, you should call iotcon_find_resource().");
+
+       *device_name = resource->device_name;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+/* The content of the resource should not be freed by user. */
+API int iotcon_remote_resource_get_types(iotcon_remote_resource_h resource,
+               iotcon_resource_types_h *types)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == types, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *types = resource->types;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+/* The content of the resource should not be freed by user. */
+API int iotcon_remote_resource_get_interfaces(iotcon_remote_resource_h resource,
+               iotcon_resource_interfaces_h *ifaces)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == ifaces, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *ifaces = resource->ifaces;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_remote_resource_get_policies(iotcon_remote_resource_h resource,
+               uint8_t *policies)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == policies, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *policies = resource->policies;
+
+       return IOTCON_ERROR_NONE;
+}
+
+API int iotcon_remote_resource_get_options(iotcon_remote_resource_h resource,
+               iotcon_options_h *options)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == options, IOTCON_ERROR_INVALID_PARAMETER);
+       WARN_IF(NULL == resource->header_options, "Not Set header options");
+
+       *options = resource->header_options;
+
+       return IOTCON_ERROR_NONE;
+}
+
+/* if header_options is NULL, then client's header_options is unset */
+API int iotcon_remote_resource_set_options(iotcon_remote_resource_h resource,
+               iotcon_options_h options)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+
+       if (options)
+               options = icl_options_ref(options);
+
+       if (resource->header_options)
+               icl_options_destroy(resource->header_options);
+
+       resource->header_options = options;
+
+       return IOTCON_ERROR_NONE;
+}
+
+API int iotcon_remote_resource_get_checking_interval(iotcon_remote_resource_h resource,
+               int *interval)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == interval, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *interval = resource->checking_interval;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_remote_resource_set_checking_interval(iotcon_remote_resource_h resource,
+               int interval)
+{
+       API_CALL;
+       int ret;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(ICL_REMOTE_RESOURCE_MAX_CHECKING_INTERVAL < interval || interval <= 0,
+                       IOTCON_ERROR_INVALID_PARAMETER);
+
+       if (resource->monitoring.presence || resource->caching.obs_handle) {
+               ret = icl_ioty_remote_resource_set_checking_interval(resource, interval);
+               if (IOTCON_ERROR_NONE != ret) {
+                       ERR("icl_ioty_remote_resource_set_checking_interval() Fail(%d)", ret);
+                       return ret;
+               }
+       }
+
+       resource->checking_interval = interval;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+/*
+ *******************
+ * start / stop caching
+ *******************
+ */
+API int iotcon_remote_resource_start_caching(iotcon_remote_resource_h resource,
+               iotcon_remote_resource_cached_representation_changed_cb cb, void *user_data)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
+                       IOTCON_ERROR_PERMISSION_DENIED);
+       return icl_remote_resource_start_caching(resource, cb, user_data);
+}
+
+
+API int iotcon_remote_resource_stop_caching(iotcon_remote_resource_h resource)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
+                       IOTCON_ERROR_PERMISSION_DENIED);
+       return icl_remote_resource_stop_caching(resource);
+}
+
+
+API int iotcon_remote_resource_get_cached_representation(
+               iotcon_remote_resource_h resource,
+               iotcon_representation_h *representation)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == representation, IOTCON_ERROR_INVALID_PARAMETER);
+       WARN_IF(NULL == resource->caching.repr, "No Cached Representation");
+
+       *representation = resource->caching.repr;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+/*
+ *******************
+ * start / stop monitoring
+ *******************
+ */
+API int iotcon_remote_resource_start_monitoring(
+               iotcon_remote_resource_h resource,
+               iotcon_remote_resource_state_changed_cb cb,
+               void *user_data)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
+                       IOTCON_ERROR_PERMISSION_DENIED);
+       return icl_remote_resource_start_monitoring(resource, cb, user_data);
+}
+
+
+API int iotcon_remote_resource_stop_monitoring(iotcon_remote_resource_h resource)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
+                       IOTCON_ERROR_PERMISSION_DENIED);
+       return icl_remote_resource_stop_monitoring(resource);
+}
+
diff --git a/src/iotcon-representation.c b/src/iotcon-representation.c
new file mode 100644 (file)
index 0000000..be2177e
--- /dev/null
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <limits.h>
+#include <glib.h>
+
+#include "iotcon-types.h"
+#include "ic.h"
+#include "ic-utils.h"
+#include "ic-resource.h"
+#include "ic-resource-types.h"
+#include "ic-resource-interfaces.h"
+#include "ic-response.h"
+#include "ic-list.h"
+#include "ic-value.h"
+#include "ic-attributes.h"
+#include "ic-representation.h"
+
+API int iotcon_representation_create(iotcon_representation_h *ret_repr)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_representation_create(ret_repr);
+}
+
+API int iotcon_representation_destroy(iotcon_representation_h repr)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_representation_destroy(repr);
+}
+
+API int iotcon_representation_get_uri_path(iotcon_representation_h repr,
+               char **uri_path)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_representation_get_uri_path(repr, uri_path);
+}
+
+API int iotcon_representation_set_uri_path(iotcon_representation_h repr,
+               const char *uri_path)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_representation_set_uri_path(repr, uri_path);
+}
+
+API int iotcon_representation_get_resource_types(iotcon_representation_h repr,
+               iotcon_resource_types_h *types)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_representation_get_resource_types(repr, types);
+}
+
+API int iotcon_representation_set_resource_types(iotcon_representation_h repr,
+               iotcon_resource_types_h types)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_representation_set_resource_types(repr, types);
+}
+
+API int iotcon_representation_get_resource_interfaces(
+               iotcon_representation_h repr, iotcon_resource_interfaces_h *ifaces)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_representation_get_resource_interfaces(repr, ifaces);
+}
+
+API int iotcon_representation_set_resource_interfaces(
+               iotcon_representation_h repr, iotcon_resource_interfaces_h ifaces)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_representation_set_resource_interfaces(repr, ifaces);
+}
+
+API int iotcon_representation_set_attributes(iotcon_representation_h repr,
+               iotcon_attributes_h attributes)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_representation_set_attributes(repr, attributes);
+}
+
+API int iotcon_representation_get_attributes(iotcon_representation_h repr,
+               iotcon_attributes_h *attributes)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_representation_get_attributes(repr, attributes);
+}
+
+API int iotcon_representation_add_child(iotcon_representation_h parent,
+               iotcon_representation_h child)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_representation_add_child(parent, child);
+}
+
+
+API int iotcon_representation_remove_child(iotcon_representation_h parent,
+               iotcon_representation_h child)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_representation_add_child(parent, child);
+}
+
+
+API int iotcon_representation_foreach_children(iotcon_representation_h parent,
+               iotcon_children_cb cb, void *user_data)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_representation_foreach_children(parent, cb, user_data);
+}
+
+API int iotcon_representation_get_child_count(iotcon_representation_h parent,
+               unsigned int *count)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_representation_get_child_count(parent, count);
+}
+
+API int iotcon_representation_get_nth_child(iotcon_representation_h parent,
+               int pos, iotcon_representation_h *child)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_representation_get_nth_child(parent, pos, child);
+}
+
+API int iotcon_representation_clone(const iotcon_representation_h src,
+               iotcon_representation_h *dest)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_representation_clone(src, dest);
+}
diff --git a/src/iotcon-request.c b/src/iotcon-request.c
new file mode 100644 (file)
index 0000000..b795a71
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "iotcon-types.h"
+#include "ic.h"
+#include "ic-utils.h"
+#include "ic-request.h"
+
+API int iotcon_request_get_host_address(iotcon_request_h request,
+               char **host_address)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == request, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == host_address, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *host_address = request->host_address;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_request_get_connectivity_type(iotcon_request_h request,
+               iotcon_connectivity_type_e *connectivity_type)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == request, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == connectivity_type, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *connectivity_type = request->connectivity_type;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+/* The content of the request should not be freed by user. */
+API int iotcon_request_get_representation(iotcon_request_h request,
+               iotcon_representation_h *repr)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == request, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *repr = request->repr;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_request_get_request_type(iotcon_request_h request,
+               iotcon_request_type_e *type)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == request, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == type, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *type = request->type;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+/* The content of the request should not be freed by user. */
+API int iotcon_request_get_options(iotcon_request_h request,
+               iotcon_options_h *options)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == request, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == options, IOTCON_ERROR_INVALID_PARAMETER);
+       WARN_IF(NULL == request->header_options, "Not Set header options");
+
+       *options = request->header_options;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+/* The content of the request should not be freed by user. */
+API int iotcon_request_get_query(iotcon_request_h request, iotcon_query_h *query)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == request, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == query, IOTCON_ERROR_INVALID_PARAMETER);
+       WARN_IF(NULL == request->query, "Not Set query");
+
+       *query = request->query;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_request_get_observe_type(iotcon_request_h request,
+               iotcon_observe_type_e *observe_type)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == request, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == observe_type, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *observe_type = request->observation_info.action;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_request_get_observe_id(iotcon_request_h request, int *observe_id)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == request, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == observe_id, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *observe_id = request->observation_info.observe_id;
+
+       return IOTCON_ERROR_NONE;
+}
+
diff --git a/src/iotcon-resource-interfaces.c b/src/iotcon-resource-interfaces.c
new file mode 100644 (file)
index 0000000..265eec0
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <glib.h>
+
+#include "iotcon-types.h"
+#include "ic.h"
+#include "ic-utils.h"
+#include "ic-resource.h"
+#include "ic-resource-interfaces.h"
+
+API int iotcon_resource_interfaces_create(iotcon_resource_interfaces_h *ret_ifaces)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_resource_interfaces_create(ret_ifaces);
+}
+
+
+API int iotcon_resource_interfaces_destroy(iotcon_resource_interfaces_h ifaces)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_resource_interfaces_destroy(ifaces);
+}
+
+/* Duplicate strings are not allowed. */
+API int iotcon_resource_interfaces_add(iotcon_resource_interfaces_h ifaces,
+               const char *iface)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_resource_interfaces_add(ifaces, iface);
+}
+
+
+API int iotcon_resource_interfaces_remove(iotcon_resource_interfaces_h ifaces,
+               const char *iface)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_resource_interfaces_remove(ifaces, iface);
+}
+
+
+API int iotcon_resource_interfaces_foreach(iotcon_resource_interfaces_h ifaces,
+               iotcon_resource_interfaces_foreach_cb cb, void *user_data)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_resource_interfaces_foreach(ifaces, cb, user_data);
+}
+
+
+API int iotcon_resource_interfaces_clone(iotcon_resource_interfaces_h src,
+               iotcon_resource_interfaces_h *dest)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_resource_interfaces_clone(src, dest);
+}
+
diff --git a/src/iotcon-resource-types.c b/src/iotcon-resource-types.c
new file mode 100644 (file)
index 0000000..2441e41
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <glib.h>
+
+#include "iotcon-types.h"
+#include "ic.h"
+#include "ic-utils.h"
+#include "ic-resource.h"
+#include "ic-resource-types.h"
+
+API int iotcon_resource_types_create(iotcon_resource_types_h *ret_types)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_resource_types_create(ret_types);
+}
+
+
+API int iotcon_resource_types_destroy(iotcon_resource_types_h types)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_resource_types_destroy(types);
+}
+
+
+/* The length of resource type should be less than or equal to 61.
+ * Duplicate strings are not allowed. */
+API int iotcon_resource_types_add(iotcon_resource_types_h types, const char *type)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_resource_types_add(types, type);
+}
+
+
+API int iotcon_resource_types_remove(iotcon_resource_types_h types,
+               const char *type)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_resource_types_remove(types, type);
+}
+
+
+API int iotcon_resource_types_foreach(iotcon_resource_types_h types,
+               iotcon_resource_types_foreach_cb cb, void *user_data)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_resource_types_foreach(types, cb, user_data);
+}
+
+
+API int iotcon_resource_types_clone(iotcon_resource_types_h src,
+               iotcon_resource_types_h *dest)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_resource_types_clone(src, dest);
+}
+
diff --git a/src/iotcon-resource.c b/src/iotcon-resource.c
new file mode 100644 (file)
index 0000000..645361a
--- /dev/null
@@ -0,0 +1,321 @@
+/*
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <tizen_type.h>
+
+#include "iotcon.h"
+#include "ic.h"
+#include "ic-utils.h"
+#include "ic-representation.h"
+#include "ic-request.h"
+#include "ic-resource-types.h"
+#include "ic-resource-interfaces.h"
+#include "ic-resource.h"
+#include "ic-ioty.h"
+
+
+/* The length of uri_path should be less than 128. */
+API int iotcon_resource_create(const char *uri_path,
+               iotcon_resource_types_h res_types,
+               iotcon_resource_interfaces_h ifaces,
+               uint8_t policies,
+               iotcon_request_handler_cb cb,
+               void *user_data,
+               iotcon_resource_h *resource_handle)
+{
+       API_CALL;
+       int ret;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
+                       IOTCON_ERROR_PERMISSION_DENIED);
+       RETV_IF(NULL == uri_path, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(false == icl_resource_check_uri_path(uri_path),
+                       IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == res_types, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == ifaces, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == resource_handle, IOTCON_ERROR_INVALID_PARAMETER);
+
+       ret = icl_ioty_resource_create(uri_path, res_types, ifaces, policies, cb,
+                       user_data, resource_handle);
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("icl_ioty_resource_create() Fail(%d)", ret);
+               return ret;
+       }
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_resource_destroy(iotcon_resource_h resource)
+{
+       API_CALL;
+       int ret;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
+                       IOTCON_ERROR_PERMISSION_DENIED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+
+       ret = icl_ioty_resource_destroy(resource);
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("icl_ioty_resource_destroy() Fail(%d)", ret);
+               return ret;
+       }
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_resource_bind_interface(iotcon_resource_h resource,
+               const char *iface)
+{
+       API_CALL;
+       int ret;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
+                       IOTCON_ERROR_PERMISSION_DENIED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == iface, IOTCON_ERROR_INVALID_PARAMETER);
+
+       ret = icl_ioty_resource_bind_interface(resource, iface);
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("icl_ioty_resource_bind_interface() Fail(%d)", ret);
+               return ret;
+       }
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_resource_bind_type(iotcon_resource_h resource,
+               const char *resource_type)
+{
+       API_CALL;
+       int ret;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
+                       IOTCON_ERROR_PERMISSION_DENIED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == resource_type, IOTCON_ERROR_INVALID_PARAMETER);
+
+       ret = icl_ioty_resource_bind_type(resource, resource_type);
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("icl_ioty_resource_bind_type() Fail(%d)", ret);
+               return ret;
+       }
+
+       return IOTCON_ERROR_NONE;
+}
+
+API int iotcon_resource_set_request_handler(iotcon_resource_h resource,
+               iotcon_request_handler_cb cb, void *user_data)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
+
+       DBG("Request handler is changed. cb:[%p]", cb);
+       resource->cb = cb;
+       resource->user_data = user_data;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_resource_bind_child_resource(iotcon_resource_h parent,
+               iotcon_resource_h child)
+{
+       API_CALL;
+       int ret;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
+                       IOTCON_ERROR_PERMISSION_DENIED);
+       RETV_IF(NULL == parent, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == child, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(parent == child, IOTCON_ERROR_INVALID_PARAMETER);
+
+       if (g_list_find(parent->children, child)) {
+               ERR("Child resource was already bound to parent resource.");
+               return IOTCON_ERROR_ALREADY;
+       }
+
+       ret = icl_ioty_resource_bind_child_resource(parent, child);
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("icl_ioty_resource_bind_child_resource() Fail(%d)", ret);
+               return ret;
+       }
+       parent->children = g_list_append(parent->children, child);
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_resource_unbind_child_resource(iotcon_resource_h parent,
+               iotcon_resource_h child)
+{
+       API_CALL;
+       int ret;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
+                       IOTCON_ERROR_PERMISSION_DENIED);
+       RETV_IF(NULL == parent, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == child, IOTCON_ERROR_INVALID_PARAMETER);
+
+       if (NULL == g_list_find(parent->children, child)) {
+               ERR("child resource is not bound to parent resource.");
+               return IOTCON_ERROR_NO_DATA;
+       }
+
+       ret = icl_ioty_resource_unbind_child_resource(parent, child);
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("icl_ioty_resource_unbind_child_resource() Fail(%d)", ret);
+               return ret;
+       }
+
+       parent->children = g_list_remove(parent->children, child);
+
+       if (0 == g_list_length(parent->children)) {
+               g_list_free(parent->children);
+               parent->children = NULL;
+       }
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_resource_get_child_count(iotcon_resource_h resource,
+               unsigned int *count)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == count, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *count = g_list_length(resource->children);
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_resource_get_nth_child(iotcon_resource_h parent, int index,
+               iotcon_resource_h *child)
+{
+       API_CALL;
+       iotcon_resource_h resource;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == parent, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == child, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(index < 0, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == parent->children, IOTCON_ERROR_NO_DATA);
+
+       resource = g_list_nth_data(parent->children, index);
+       if (NULL == resource) {
+               ERR("g_list_nth_data() Fail");
+               return IOTCON_ERROR_NO_DATA;
+       }
+
+       *child = resource;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+/* The content of the resource should not be freed by user. */
+API int iotcon_resource_get_uri_path(iotcon_resource_h resource, char **uri_path)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == uri_path, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *uri_path = resource->uri_path;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+/* The content of the resource should not be freed by user. */
+API int iotcon_resource_get_types(iotcon_resource_h resource,
+               iotcon_resource_types_h *types)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == types, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *types = resource->types;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_resource_get_interfaces(iotcon_resource_h resource,
+               iotcon_resource_interfaces_h *ifaces)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == ifaces, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *ifaces = resource->ifaces;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_resource_get_policies(iotcon_resource_h resource, uint8_t *policies)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == policies, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *policies = resource->policies;
+
+       return IOTCON_ERROR_NONE;
+}
+
+API int iotcon_resource_notify(iotcon_resource_h resource,
+               iotcon_representation_h repr, iotcon_observers_h observers, iotcon_qos_e qos)
+{
+       API_CALL;
+       int ret;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
+                       IOTCON_ERROR_PERMISSION_DENIED);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+
+       ret = icl_ioty_resource_notify(resource, repr, observers, qos);
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("icl_ioty_resource_notify() Fail(%d)", ret);
+               return ret;
+       }
+
+       return IOTCON_ERROR_NONE;
+}
+
diff --git a/src/iotcon-response.c b/src/iotcon-response.c
new file mode 100644 (file)
index 0000000..8653a90
--- /dev/null
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <stdlib.h>
+#include <errno.h>
+#include <glib.h>
+
+#include "iotcon.h"
+#include "ic.h"
+#include "ic-utils.h"
+#include "ic-resource.h"
+#include "ic-representation.h"
+#include "ic-options.h"
+#include "ic-request.h"
+#include "ic-response.h"
+
+#include "ic-ioty.h"
+
+/* the last index of iotcon_response_result_e */
+#define ICL_RESPONSE_RESULT_MAX (IOTCON_RESPONSE_FORBIDDEN + 1)
+
+API int iotcon_response_create(iotcon_request_h request,
+               iotcon_response_h *response)
+{
+       API_CALL;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == request, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == response, IOTCON_ERROR_INVALID_PARAMETER);
+
+       iotcon_response_h resp = calloc(1, sizeof(struct icl_resource_response));
+       if (NULL == resp) {
+               ERR("calloc() Fail(%d)", errno);
+               return IOTCON_ERROR_OUT_OF_MEMORY;
+       }
+
+       resp->oic_request_h = request->oic_request_h;
+       resp->oic_resource_h = request->oic_resource_h;
+
+       *response = resp;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_response_destroy(iotcon_response_h resp)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       return icl_response_destroy(resp);
+}
+
+API int iotcon_response_get_options(iotcon_response_h resp,
+               iotcon_options_h *options)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == resp, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == options, IOTCON_ERROR_INVALID_PARAMETER);
+       WARN_IF(NULL == resp->header_options, "Not Set header options");
+
+       *options = resp->header_options;
+
+       return IOTCON_ERROR_NONE;
+}
+
+API int iotcon_response_get_representation(iotcon_response_h resp,
+               iotcon_representation_h *repr)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == resp, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == resp->repr, IOTCON_ERROR_NO_DATA);
+
+       *repr = resp->repr;
+
+       return IOTCON_ERROR_NONE;
+
+}
+
+API int iotcon_response_get_result(iotcon_response_h resp,
+               iotcon_response_result_e *result)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == resp, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == result, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *result = resp->result;
+
+       return IOTCON_ERROR_NONE;
+}
+
+API int iotcon_response_set_result(iotcon_response_h resp,
+               iotcon_response_result_e result)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == resp, IOTCON_ERROR_INVALID_PARAMETER);
+
+       if (result < IOTCON_RESPONSE_OK || ICL_RESPONSE_RESULT_MAX <= result) {
+               ERR("Invalid result(%d)", result);
+               return IOTCON_ERROR_INVALID_PARAMETER;
+       }
+       resp->result = result;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_response_set_representation(iotcon_response_h resp,
+               iotcon_representation_h repr)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == resp, IOTCON_ERROR_INVALID_PARAMETER);
+
+       if (repr)
+               repr = icl_representation_ref(repr);
+
+       if (resp->repr)
+               icl_representation_destroy(resp->repr);
+
+       resp->repr = repr;
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+API int iotcon_response_set_options(iotcon_response_h resp,
+               iotcon_options_h options)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(NULL == resp, IOTCON_ERROR_INVALID_PARAMETER);
+
+       if (options)
+               options = icl_options_ref(options);
+
+       if (resp->header_options)
+               icl_options_destroy(resp->header_options);
+
+       resp->header_options = options;
+
+       return IOTCON_ERROR_NONE;
+}
+
+API int iotcon_response_send(iotcon_response_h resp)
+{
+       API_CALL;
+       int ret;
+
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
+                       IOTCON_ERROR_PERMISSION_DENIED);
+       RETV_IF(NULL == resp, IOTCON_ERROR_INVALID_PARAMETER);
+
+       ret = icl_ioty_response_send(resp);
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("icl_ioty_response_send() Fail(%d)", ret);
+               return ret;
+       }
+
+       return IOTCON_ERROR_NONE;
+}
diff --git a/src/iotcon.c b/src/iotcon.c
new file mode 100644 (file)
index 0000000..4477c0d
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <glib.h>
+#include <glib-object.h>
+
+#include "ic.h"
+#include "ic-utils.h"
+#include "ic-ioty.h"
+
+API int iotcon_initialize(const char *file_path)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+       RETV_IF(false == ic_utils_check_permission((IC_PERMISSION_INTERNET|IC_PERMISSION_NETWORK_GET)),
+                       IOTCON_ERROR_PERMISSION_DENIED);
+
+       return icl_initialize(file_path, false);
+}
+
+API int iotcon_deinitialize(void)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+
+       return icl_deinitialize();
+}
+
+API int iotcon_get_timeout(int *timeout_seconds)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+
+       return icl_get_timeout(timeout_seconds);
+}
+
+API int iotcon_set_timeout(int timeout_seconds)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+
+       return icl_set_timeout(timeout_seconds);
+}
+
+API int iotcon_polling_get_interval(int *interval)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+
+       return icl_polling_get_interval(interval);
+}
+
+API int iotcon_polling_set_interval(int interval)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+
+       return icl_polling_set_interval(interval);
+}
+
+API int iotcon_polling_invoke(void)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+
+       return icl_polling_invoke();
+}
+
+API int iotcon_add_generated_pin_cb(iotcon_generated_pin_cb cb, void *user_data)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+
+       return icl_ioty_add_generated_pin_cb(cb, user_data);
+}
+
+API int iotcon_remove_generated_pin_cb(iotcon_generated_pin_cb cb)
+{
+       API_CALL;
+       RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+
+       return icl_ioty_remove_generated_pin_cb(cb);
+}