Fix invalid parameter handling code in iotcon_start_presence API 67/64067/1
authorsung.goo.kim <sung.goo.kim@samsung.com>
Tue, 29 Mar 2016 23:46:38 +0000 (08:46 +0900)
committersung.goo.kim <sung.goo.kim@samsung.com>
Tue, 29 Mar 2016 23:46:38 +0000 (08:46 +0900)
Change-Id: I1cd4198f6db04b8007bdfc456a3283df1cec7e25

lib/icl-presence.c

index 4693bb2441f9a8f74de9b24c643a9b8c3a1c3b69..b3ff556a69b7156126c7dc44ea9033e4d453850a 100644 (file)
@@ -28,6 +28,7 @@
 #include "icl-resource-types.h"
 #include "icl-dbus.h"
 
+#define ICL_PRESENCE_TTL_SECONDS_DEFAULT 60 /* 60 sec */
 #define ICL_PRESENCE_TTL_SECONDS_MAX (60 * 60 * 24) /* 60 sec/min * 60 min/hr * 24 hr/day */
 
 typedef struct icl_presence {
@@ -58,7 +59,11 @@ API int iotcon_start_presence(unsigned int time_to_live)
 
        RETV_IF(false == ic_utils_check_oic_feature_supported(), IOTCON_ERROR_NOT_SUPPORTED);
        RETV_IF(NULL == icl_dbus_get_object(), IOTCON_ERROR_DBUS);
-       RETV_IF(ICL_PRESENCE_TTL_SECONDS_MAX < time_to_live, IOTCON_ERROR_INVALID_PARAMETER);
+
+       if (0 == time_to_live)
+               time_to_live = ICL_PRESENCE_TTL_SECONDS_DEFAULT;
+       else if (ICL_PRESENCE_TTL_SECONDS_MAX < time_to_live)
+               time_to_live = ICL_PRESENCE_TTL_SECONDS_MAX;
 
        ic_dbus_call_start_presence_sync(icl_dbus_get_object(), time_to_live, &ret, NULL,
                        &error);