Return IOTCON_ERROR_NO_DATA when value is not set. 99/65199/3
authoryoungman <yman.jung@samsung.com>
Fri, 8 Apr 2016 01:29:26 +0000 (10:29 +0900)
committeryoungman <yman.jung@samsung.com>
Mon, 11 Apr 2016 01:36:29 +0000 (10:36 +0900)
Change-Id: I0d4f1b234237693db9ae336bb57993b6e142150d
Signed-off-by: youngman <yman.jung@samsung.com>
lib/icl-remote-resource.c
lib/icl-representation.c
lib/icl-resource.c
lib/include/iotcon-remote-resource.h
lib/include/iotcon-representation.h
lib/include/iotcon-resource.h

index a6bc98a6d5404c98b16f6ad649c9c1cbb39277f9..2ffb6a744c3cf43d95be9196e6b19eed0b5844c8 100644 (file)
@@ -407,6 +407,8 @@ API int iotcon_remote_resource_get_device_id(iotcon_remote_resource_h resource,
        RETV_IF(false == ic_utils_check_oic_feature_supported(), 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;
 
@@ -459,6 +461,7 @@ API int iotcon_remote_resource_get_options(iotcon_remote_resource_h resource,
        RETV_IF(false == ic_utils_check_oic_feature_supported(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == options, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == resource->header_options, IOTCON_ERROR_NO_DATA);
 
        *options = resource->header_options;
 
index 53884bce4d5aa3207b89b488b52ee3203ef9c047..ee9b2b8c5eb332ad7b1206e5f290c953fb701997 100644 (file)
@@ -102,6 +102,7 @@ API int iotcon_representation_get_uri_path(iotcon_representation_h repr, char **
        RETV_IF(false == ic_utils_check_oic_feature_supported(), 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);
 
        *uri_path = repr->uri_path;
 
@@ -133,6 +134,7 @@ API int iotcon_representation_get_resource_types(iotcon_representation_h repr,
        RETV_IF(false == ic_utils_check_oic_feature_supported(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == types, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == repr->res_types, IOTCON_ERROR_NO_DATA);
 
        *types = repr->res_types;
 
@@ -162,6 +164,7 @@ API int iotcon_representation_get_resource_interfaces(iotcon_representation_h re
        RETV_IF(false == ic_utils_check_oic_feature_supported(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == ifaces, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == repr->interfaces, IOTCON_ERROR_NO_DATA);
 
        *ifaces = repr->interfaces;
 
index 90f9346d1079e3f6f8d4b9f7222f0ed621dfdac3..61c91615cd63c21ae1468bb206f7292ef61cdb9d 100644 (file)
@@ -614,6 +614,7 @@ API int iotcon_resource_get_nth_child(iotcon_resource_h parent, int index,
                ERR("Invalid index(%d)", index);
                return IOTCON_ERROR_INVALID_PARAMETER;
        }
+       RETV_IF(NULL == parent->children[index], IOTCON_ERROR_NO_DATA);
 
        *child = parent->children[index];
 
index 7cf831263c789859b6e5fac176e4c2ff884ed91d..df6d9fb93c5d81f5b3007b76b69d036e71cee3a6 100644 (file)
@@ -594,7 +594,7 @@ int iotcon_remote_resource_get_uri_path(iotcon_remote_resource_h resource,
                char **uri_path);
 
 /**
- * @brief Gets connectivity type of the remote resource
+ * @brief Gets connectivity type of the remote resource
  *
  * @since_tizen 3.0
  *
@@ -619,7 +619,7 @@ int iotcon_remote_resource_get_connectivity_type(iotcon_remote_resource_h resour
                iotcon_connectivity_type_e *connectivity_type);
 
 /**
- * @brief Gets an host address of the remote resource
+ * @brief Gets a host address of the remote resource
  *
  * @since_tizen 3.0
  *
@@ -645,11 +645,13 @@ int iotcon_remote_resource_get_host_address(iotcon_remote_resource_h resource,
                char **host_address);
 
 /**
- * @brief Gets an device id of the remote resource
+ * @brief Gets a device id of the remote resource
  *
  * @since_tizen 3.0
  *
- * @remarks @a device_id must not be released using free().
+ * @remarks @a device_id must not be released using free().\n
+ * If @a resource is created by calling iotcon_remote_resource_create(), you cannot get
+ * @a device_id. In this case, the return value of this function is #IOTCON_ERROR_NO_DATA.
  *
  * @param[in] resource The handle of the remote resource
  * @param[out] device_id The device id of the remote resource
@@ -658,6 +660,7 @@ int iotcon_remote_resource_get_host_address(iotcon_remote_resource_h resource,
  * @retval #IOTCON_ERROR_NONE  Successful
  * @retval #IOTCON_ERROR_NOT_SUPPORTED  Not supported
  * @retval #IOTCON_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #IOTCON_ERROR_NO_DATA No data available
  *
  * @see iotcon_remote_resource_get_uri_path()
  * @see iotcon_remote_resource_get_host_address()
@@ -763,6 +766,7 @@ int iotcon_remote_resource_get_properties(iotcon_remote_resource_h resource,
  * @retval #IOTCON_ERROR_NONE  Successful
  * @retval #IOTCON_ERROR_NOT_SUPPORTED  Not supported
  * @retval #IOTCON_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #IOTCON_ERROR_NO_DATA No data available
  *
  * @see iotcon_remote_resource_get_uri_path()
  * @see iotcon_remote_resource_get_host_address()
index afd4caadb30ed89c0e9b5040bd258a01ed90adf2..e942475449aeb6f4f136f1293c4ac833bbd9d0f3 100644 (file)
@@ -286,6 +286,7 @@ int iotcon_representation_set_uri_path(iotcon_representation_h repr,
  * @retval #IOTCON_ERROR_NONE  Successful
  * @retval #IOTCON_ERROR_NOT_SUPPORTED  Not supported
  * @retval #IOTCON_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #IOTCON_ERROR_NO_DATA No data available
  */
 int iotcon_representation_get_uri_path(iotcon_representation_h repr, char **uri_path);
 
@@ -320,6 +321,7 @@ int iotcon_representation_set_resource_types(iotcon_representation_h repr,
  * @retval #IOTCON_ERROR_NONE  Successful
  * @retval #IOTCON_ERROR_NOT_SUPPORTED  Not supported
  * @retval #IOTCON_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #IOTCON_ERROR_NO_DATA No data available
  */
 int iotcon_representation_get_resource_types(iotcon_representation_h repr,
                iotcon_resource_types_h *types);
@@ -357,6 +359,7 @@ int iotcon_representation_set_resource_interfaces(iotcon_representation_h repr,
  * @retval #IOTCON_ERROR_NONE  Successful
  * @retval #IOTCON_ERROR_NOT_SUPPORTED  Not supported
  * @retval #IOTCON_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #IOTCON_ERROR_NO_DATA No data available
  */
 int iotcon_representation_get_resource_interfaces(iotcon_representation_h repr,
                iotcon_resource_interfaces_h *ifaces);
index 13a4b1345afa6130967dd06447f29ff73e546d73..0397ab94c8e44a73fa39ed4e2d6b4171096ed4d4 100644 (file)
@@ -513,6 +513,7 @@ int iotcon_resource_get_number_of_children(iotcon_resource_h resource, int *numb
  * @retval #IOTCON_ERROR_NONE  Successful
  * @retval #IOTCON_ERROR_NOT_SUPPORTED  Not supported
  * @retval #IOTCON_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #IOTCON_ERROR_NO_DATA No data available
  *
  * @see iotcon_resource_get_number_of_children()
  * @see iotcon_resource_get_uri_path()