send empty representation
authoryoungman <yman.jung@samsung.com>
Thu, 12 Nov 2015 08:24:47 +0000 (17:24 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Thu, 19 Nov 2015 05:54:46 +0000 (14:54 +0900)
Change-Id: I3eab47bb318009a5722dfe0f3a58a8d6a21a6318
Signed-off-by: youngman <yman.jung@samsung.com>
lib/icl-payload.c
lib/icl-response.c

index 769e958..4e50ada 100644 (file)
@@ -158,6 +158,21 @@ static GVariant* _icl_state_value_to_gvariant(GHashTable *hash)
 }
 
 
+static GVariant* _icl_representation_empty_gvariant(void)
+{
+       GVariant *value;
+       GVariantBuilder types, repr, children;
+
+       g_variant_builder_init(&types, G_VARIANT_TYPE("as"));
+       g_variant_builder_init(&repr, G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_init(&children, G_VARIANT_TYPE("av"));
+
+       value = g_variant_new("(siasa{sv}av)", IC_STR_NULL, 0, &types, &repr, &children);
+
+       return value;
+}
+
+
 GVariant* icl_representation_to_gvariant(iotcon_representation_h repr)
 {
        GList *node;
@@ -168,7 +183,8 @@ GVariant* icl_representation_to_gvariant(iotcon_representation_h repr)
        GVariantBuilder *repr_gvar = NULL;
        GVariantBuilder children, resource_types;
 
-       RETV_IF(NULL == repr, NULL);
+       if (NULL == repr)
+               return _icl_representation_empty_gvariant();
 
        /* uri path */
        uri_path = ic_utils_dbus_encode_str(repr->uri_path);
index 67b3066..4c54da0 100644 (file)
@@ -175,7 +175,8 @@ static int _icl_response_check_representation_visibility(iotcon_response_h resp)
        int ret;
 
        RETV_IF(NULL == resp, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == resp->repr, IOTCON_ERROR_INVALID_PARAMETER);
+       if (NULL == resp->repr)
+               return IOTCON_ERROR_NONE;
 
        iotcon_representation_h first = resp->repr;
 
@@ -217,7 +218,6 @@ API int iotcon_response_send(iotcon_response_h resp)
 
        RETV_IF(NULL == icl_dbus_get_object(), IOTCON_ERROR_DBUS);
        RETV_IF(NULL == resp, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == resp->repr, IOTCON_ERROR_INVALID_PARAMETER);
 
        ret = _icl_response_check_representation_visibility(resp);
        if (IOTCON_ERROR_NONE != ret) {