Remove iotcon_representation_del_state, Rename iotcon_representation_append_child
authorsung.goo.kim <sung.goo.kim@samsung.com>
Thu, 19 Nov 2015 08:51:02 +0000 (17:51 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Fri, 20 Nov 2015 06:13:51 +0000 (15:13 +0900)
Change-Id: Ie803b4b8879e647837e39af0ea86e0fca67501a8

lib/icl-representation.c
lib/include/iotcon-representation.h
test/iotcon-test-iface-server.c

index eeba7ee3395a9fa12b80ac55c6fd90e725d11374..0325ea34f5e795e74a409b6e49a66339deb2bbfc 100644 (file)
@@ -174,19 +174,22 @@ API int iotcon_representation_set_resource_interfaces(iotcon_representation_h re
        return IOTCON_ERROR_NONE;
 }
 
-
 API int iotcon_representation_set_state(iotcon_representation_h repr,
                iotcon_state_h state)
 {
        RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER);
+
+       if (state == repr->state)
+               return IOTCON_ERROR_NONE;
 
        if (repr->state) {
-               ERR("state already set. Remove first !");
-               return IOTCON_ERROR_ALREADY;
+               iotcon_state_destroy(repr->state);
+               repr->state = NULL;
        }
 
-       icl_state_inc_ref_count(state);
+       if (state)
+               icl_state_inc_ref_count(state);
+
        repr->state = state;
 
        return IOTCON_ERROR_NONE;
@@ -204,19 +207,7 @@ API int iotcon_representation_get_state(iotcon_representation_h repr,
        return IOTCON_ERROR_NONE;
 }
 
-
-API int iotcon_representation_del_state(iotcon_representation_h repr)
-{
-       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
-
-       if (repr->state)
-               iotcon_state_destroy(repr->state);
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-API int iotcon_representation_append_child(iotcon_representation_h parent,
+API int iotcon_representation_add_child(iotcon_representation_h parent,
                iotcon_representation_h child)
 {
        RETV_IF(NULL == parent, IOTCON_ERROR_INVALID_PARAMETER);
index db83bc74d1cd9ba8d0b28aef896337d48e650d17..e4c9a9072b0ccc550c932251cd9a568bed5201da 100644 (file)
@@ -368,20 +368,7 @@ int iotcon_representation_set_state(iotcon_representation_h repr, iotcon_state_h
 int iotcon_representation_get_state(iotcon_representation_h repr, iotcon_state_h *state);
 
 /**
- * @brief Deletes state handle in the representation.
- *
- * @since_tizen 3.0
- *
- * @param[in] repr The representation handle
- *
- * @return 0 on success, otherwise a negative error value.
- * @retval #IOTCON_ERROR_NONE  Successful
- * @retval #IOTCON_ERROR_INVALID_PARAMETER  Invalid parameter
- */
-int iotcon_representation_del_state(iotcon_representation_h repr);
-
-/**
- * @brief Appends a new child representation on to the end of the parent representation
+ * @brief Adds a new child representation on to the end of the parent representation
  * @details Duplicated child representation is allowed to append.
  *
  * @since_tizen 3.0
@@ -393,7 +380,7 @@ int iotcon_representation_del_state(iotcon_representation_h repr);
  * @retval #IOTCON_ERROR_NONE  Successful
  * @retval #IOTCON_ERROR_INVALID_PARAMETER  Invalid parameter
  */
-int iotcon_representation_append_child(iotcon_representation_h parent,
+int iotcon_representation_add_child(iotcon_representation_h parent,
                iotcon_representation_h child);
 
 /**
index 1ecec0853743642ec7f87b3853c154ac695b81d8..130a7b8cc7c9fc77827af38e845d861d59790c16 100644 (file)
@@ -513,9 +513,9 @@ static iotcon_representation_h _get_room_representation(room_resource_s *room)
                return NULL;
        }
 
-       ret = iotcon_representation_append_child(repr, light_repr);
+       ret = iotcon_representation_add_child(repr, light_repr);
        if (IOTCON_ERROR_NONE != ret) {
-               ERR("iotcon_representation_append_child() Fail(%d)", ret);
+               ERR("iotcon_representation_add_child() Fail(%d)", ret);
                iotcon_representation_destroy(light_repr);
                iotcon_representation_destroy(repr);
                return NULL;
@@ -530,9 +530,9 @@ static iotcon_representation_h _get_room_representation(room_resource_s *room)
                return NULL;
        }
 
-       ret = iotcon_representation_append_child(repr, fan_repr);
+       ret = iotcon_representation_add_child(repr, fan_repr);
        if (IOTCON_ERROR_NONE != ret) {
-               ERR("iotcon_representation_append_child() Fail(%d)", ret);
+               ERR("iotcon_representation_add_child() Fail(%d)", ret);
                iotcon_representation_destroy(fan_repr);
                iotcon_representation_destroy(repr);
                return NULL;