RETV_IF(NULL == value, NULL);
- node = json_node_new(JSON_NODE_VALUE);
+ if (IOTCON_TYPE_NULL == value->type)
+ node = json_node_new(JSON_NODE_NULL);
+ else
+ node = json_node_new(JSON_NODE_VALUE);
+
if (NULL == node) {
- ERR("json_node_new(VALUE) Fail");
+ ERR("json_node_new(%d) Fail", value->type);
return NULL;
}
json_node_set_string(node, real->val.s);
break;
case IOTCON_TYPE_NULL:
- node = json_node_init_null(node);
break;
default:
ERR("Invalid type(%d)", value->type);
}
JsonGenerator *gen = json_generator_new();
+#if JSON_CHECK_VERSION(0,14,0)
json_generator_set_pretty(gen, set_pretty);
+#endif
+
root_node = json_node_new(JSON_NODE_OBJECT);
json_node_set_object(root_node, obj);
json_generator_set_root(gen, root_node);
}
}
-static gpointer _ic_repr_copy_repr(gconstpointer src, gpointer data)
-{
- FN_CALL;
-
- return iotcon_repr_clone((iotcon_repr_h)src);
-}
-
API iotcon_repr_h iotcon_repr_clone(const iotcon_repr_h src)
{
FN_CALL;
- iotcon_repr_h dest = NULL;
+ GList *node;
+ iotcon_repr_h dest, copied_repr;
+ iotcon_str_list_s *list = NULL;
RETV_IF(NULL == src, NULL);
dest = iotcon_repr_new();
- if (src->uri)
+ if (NULL == dest) {
+ ERR("iotcon_repr_new() Fail");
+ return NULL;
+ }
+
+ if (src->uri) {
dest->uri = strdup(src->uri);
- dest->interfaces = src->interfaces;
- dest->res_types = iotcon_str_list_clone(src->res_types);
- dest->children = g_list_copy_deep(src->children, _ic_repr_copy_repr, NULL);
+ if (NULL == dest->uri) {
+ ERR("strdup() Fail");
+ iotcon_repr_free(dest);
+ return NULL;
+ }
+ }
+
+ if (src->interfaces)
+ dest->interfaces = src->interfaces;
+
+ if (src->res_types) {
+ list = iotcon_str_list_clone(src->res_types);
+ if (NULL == list) {
+ ERR("iotcon_str_list_clone() Fail");
+ iotcon_repr_free(dest);
+ return NULL;
+ }
+ dest->res_types = list;
+ }
+
+ for (node = g_list_first(src->children); node; node = node->next) {
+ copied_repr = iotcon_repr_clone((iotcon_repr_h)node->data);
+ if (NULL == copied_repr) {
+ ERR("iotcon_repr_clone(child) Fail");
+ iotcon_repr_free(dest);
+ return NULL;
+ }
+ dest->children = g_list_append(dest->children, copied_repr);
+ }
+
g_hash_table_foreach(src->hash_table, (GHFunc)_ic_repr_obj_clone, dest);
return dest;
IOTCON_OBSERVE_ALL = 1
} iotcon_observe_type_e;
+/**
+ * @ingroup CAPI_IOT_CONNECTIVITY_MODULE
+ * @brief Enumerations of Iotcon interface types.
+ * @since_tizen 3.0
+ */
typedef enum {
IOTCON_INTERFACE_NONE = 0,
- IOTCON_INTERFACE_DEFAULT = (1 << 0),
- IOTCON_INTERFACE_LINK = (1 << 1),
- IOTCON_INTERFACE_BATCH = (1 << 2),
- IOTCON_INTERFACE_GROUP = (1 << 3),
+ IOTCON_INTERFACE_DEFAULT = (1 << 0), /* default interface */
+ IOTCON_INTERFACE_LINK = (1 << 1), /* discovers children of the parent resource */
+ IOTCON_INTERFACE_BATCH = (1 << 2), /* requests CRUD to children of the parent resource */
+ IOTCON_INTERFACE_GROUP = (1 << 3), /* requests CRUD to remote resources of a group. */
IOTCON_INTERFACE_MAX = (1 << 4)
} iotcon_interface_e;
DBG("today's temperature :");
iotcon_list_foreach_int(list, _get_int_list_fn, NULL);
iotcon_str_list_free(key_list);
+
+ if (iotcon_repr_is_null(recv_repr, "null value"))
+ DBG("null value is null");
}
children_count = iotcon_repr_get_children_count(recv_repr);
iotcon_repr_set_uri(room_repr, "/a/room");
iotcon_repr_set_str(room_repr, "name", "Michael's Room");
+ /* set null */
+ iotcon_repr_set_null(room_repr, "null value");
+
temperature_list = iotcon_list_new(IOTCON_TYPE_INT);
iotcon_list_insert_int(temperature_list, 22, -1);
iotcon_list_insert_int(temperature_list, 23, -1);