* @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
...
Name: iotcon
Summary: Tizen IoT Connectivity
-Version: 0.3.12
+Version: 0.3.13
Release: 0
Group: Network & Connectivity/Service
License: Apache-2.0
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));
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
}
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;
-}
-
#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__ */
+++ /dev/null
-/*
- * 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;
-}
#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()
{
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");
}
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);
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;
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");
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);
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;
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();
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;
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();
static gboolean _icl_ioty_ocprocess_presence_idle_cb(gpointer p)
{
+ FN_CALL;
+
icl_presence_cb_s *cb_data = p;
iotcon_presence_h presence;
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);
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;
&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;
}
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);
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;
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;
}
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;
/* 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))) {
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;
}
/* 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);
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;
}
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;
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;
}
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));
#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);
resource->is_found = false;
- iotcon_remote_resource_destroy(resource);
+ icl_remote_resource_destroy(resource);
}
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;
}
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;
}
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;
}
}
/* 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);
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_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;
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++) {
&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:
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;
}
&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;
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;
&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);
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;
}
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 */
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;
}
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;
}
#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"
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);
}
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;
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 */
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.");
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) {
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;
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) {
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();
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;
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)
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();
}
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;
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)
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();
}
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;
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;
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,
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;
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();
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;
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);
_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();
}
free(uri);
- iotcon_get_timeout(&timeout);
+ icl_get_timeout(&timeout);
cb_container->timeout = g_timeout_add_seconds(timeout, _icl_ioty_response_timeout,
cb_container);
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;
void *user_data,
iotcon_resource_h *resource_handle)
{
- FN_CALL;
GList *c;
OCResourceHandle handle;
int ret, i;
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);
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;
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;
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;
}
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,
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;
}
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)
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;
return ic_ioty_parse_oic_error(ret);
}
+ FN_END;
return IOTCON_ERROR_NONE;
}
}
-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) {
}
-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);
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);
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);
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,
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,
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,
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,
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);
}
-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);
}
-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);
}
-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);
}
-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;
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);
}
-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);
}
-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;
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);
}
-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);
}
-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);
}
-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);
}
-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;
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);
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;
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);
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;
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);
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;
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);
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;
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);
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;
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);
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;
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);
}
-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--;
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__ */
+++ /dev/null
-/*
- * 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;
-}
#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 */
+++ /dev/null
-/*
- * 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;
-}
-
+++ /dev/null
-/*
- * 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__ */
--- /dev/null
+/*
+ * 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;
+}
+
--- /dev/null
+/*
+ * 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__ */
}
-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));
}
-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--;
/* 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.");
}
-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.");
}
-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);
}
-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);
return IOTCON_ERROR_NONE;
}
+
};
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__ */
+++ /dev/null
-/*
- * 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;
-}
-
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)
}
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();
}
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();
}
-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;
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) {
_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();
}
/* 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);
#include "ic-utils.h"
#include "ic-ioty-parse.h"
#include "ic-provisioning-struct.h"
+#include "ic-provisioning.h"
#define ICL_PROVISIONING_REMOVE_TIMEOUT -1
}
-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;
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)
}
-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);
}
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;
}
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) {
}
}
- icl_provisioning_free_remove_delete_container(container, is_complete);
+ _icl_provisioning_free_remove_delete_container(container, is_complete);
return G_SOURCE_REMOVE;
}
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} };
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;
}
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) {
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};
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);
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();
}
/* timeout */
- iotcon_get_timeout(&timeout);
+ icl_get_timeout(&timeout);
container->timer_id = g_timeout_add_seconds(timeout,
_provisioning_remove_device_delete_timeout, container);
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,
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;
}
}
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;
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);
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,
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);
}
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;
}
}
-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;
}
-OCProvisionDev_t* icl_provisioning_device_clone(OCProvisionDev_t *src)
+OCProvisionDev_t* icl_provisioning_oic_device_clone(OCProvisionDev_t *src)
{
FN_CALL;
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;
}
}
-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);
}
-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) {
}
-OCProvisionDev_t* icl_provisioning_device_get_device(
+OCProvisionDev_t* icl_provisioning_oic_device_get_device(
iotcon_provisioning_device_h device)
{
FN_CALL;
}
-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);
}
-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);
}
-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);
}
-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);
}
-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);
}
-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));
}
-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--;
}
-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;
}
}
-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));
}
-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);
}
-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);
}
-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);
#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(
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);
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);
#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
}
-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);
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);
}
}
/* 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();
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;
}
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);
static gboolean _provisioning_register_unowned_device(gpointer p)
{
+ FN_CALL;
+
int ret;
OCProvisionDev_t *dev_list;
struct icl_provisioning_ownership_transfer_cb_container *container;
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) {
}
-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)
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);
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;
}
static gboolean _provisioning_provision_cred_idle_cb(gpointer p)
{
+ FN_CALL;
+
struct icl_provisioning_provision_cred_cb_container *container = p;
if (container->cb) {
}
-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)
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);
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) {
FN_CALL;
if (container->device) {
- iotcon_provisioning_device_destroy(container->device);
+ icl_provisioning_device_destroy(container->device);
container->device = NULL;
}
}
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);
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));
static gboolean _provisioning_provision_acl_idle_cb(void *p)
{
+ FN_CALL;
+
struct icl_provisioning_provision_acl_cb_container *container = p;
if (container->cb) {
}
-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)
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);
}
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();
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;
}
static gboolean _provisioning_pairwise_devices_idle_cb(void *p)
{
+ FN_CALL;
+
struct icl_provisioning_pairwise_devices_cb_container *container = p;
if (container->cb) {
}
-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,
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);
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();
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;
}
static gboolean _provisioning_unlink_pairwise_idle_cb(gpointer p)
{
+ FN_CALL;
+
struct icl_provisioning_unlink_pairwise_cb_container *container = p;
if (container->cb) {
}
-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)
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);
}
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) {
--- /dev/null
+/*\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
#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));
}
-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);
}
-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;
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;
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;
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);
}
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);
}
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);
}
-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);
}
-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);
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);
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__ */
+++ /dev/null
-/*
- * 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;
-}
-
+++ /dev/null
-/*
- * 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;
-}
-
+++ /dev/null
-/*
- * 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;
-}
-
#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);
}
/* 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,
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),
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;
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);
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;
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);
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;
}
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;
}
-
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__ */
}
-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));
}
-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--;
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);
}
-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);
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),
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");
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");
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;
}
-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);
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);
}
-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);
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);
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);
}
-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;
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;
}
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;
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);
}
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;
}
}
};
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__ */
+++ /dev/null
-/*
- * 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;
-}
-
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));
}
-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--;
/* 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,
}
-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,
}
-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);
}
-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;
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);
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__ */
}
-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));
}
-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--;
/* 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,
}
-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,
}
-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);
}
-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;
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);
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;
}
};
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__ */
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;
-}
-
#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;
-}
OCResourceHandle oic_resource_h;
};
+int icl_response_destroy(iotcon_response_h resp);
+
#endif /* __IOTCON_INTERNAL_RESPONSE_H__ */
#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)
{
{
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);
{
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);
}
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);
}
int ic_utils_cond_polling_init()
{
- FN_CALL;
int ret;
pthread_condattr_t attr;
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);
ERR("icl_value_get_attributes() Fail(%d)", ret);
break;
}
- iotcon_attributes_destroy(attributes);
+ icl_attributes_destroy(attributes);
break;
default:
ERR("Invalid type(%d)", type);
#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)
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--;
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;
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;
}
* 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__ */
--- /dev/null
+/* 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;
+}
+
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+/*
+ * 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);
+}
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+/*
+ * 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);
+}
+
--- /dev/null
+/*
+ * 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);
+}
--- /dev/null
+/*
+ * 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;
+}
+
--- /dev/null
+/*
+ * 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);
+}
--- /dev/null
+/*
+ * 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);
+}
--- /dev/null
+/*
+ * 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);
+}
+
--- /dev/null
+/*
+ * 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;
+}
+
--- /dev/null
+/*
+ * 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);
+}
+
--- /dev/null
+/*
+ * 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);
+}
--- /dev/null
+/*
+ * 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;
+}
+
--- /dev/null
+/*
+ * 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);
+}
+
--- /dev/null
+/*
+ * 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);
+}
+
--- /dev/null
+/*
+ * 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;
+}
+
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+/*
+ * 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);
+}