From a6bcace051728ec5c7f4370a002629b3fefc6050 Mon Sep 17 00:00:00 2001 From: "sy01.youn" Date: Wed, 10 Aug 2016 09:28:17 +0900 Subject: [PATCH] [Enrollee] DeleteEasySetupResourcess() is fixed in resource handler. . Unbind logic is added . Check whether handle is NULL or not Change-Id: I0b69d29735af06b75b4e775484cf835ca12007f0 Signed-off-by: sy01.youn Reviewed-on: https://gerrit.iotivity.org/gerrit/10207 Reviewed-by: Jihun Ha Tested-by: jenkins-iotivity Reviewed-by: Madan Lanka --- service/easy-setup/enrollee/src/resourcehandler.c | 64 ++++++++++++++++++----- 1 file changed, 52 insertions(+), 12 deletions(-) diff --git a/service/easy-setup/enrollee/src/resourcehandler.c b/service/easy-setup/enrollee/src/resourcehandler.c index b655e27..53ff8ec 100755 --- a/service/easy-setup/enrollee/src/resourcehandler.c +++ b/service/easy-setup/enrollee/src/resourcehandler.c @@ -679,26 +679,66 @@ OCStackResult DeleteProvisioningResource() OCStackResult DeleteEasySetupResources() { - OCStackResult res = OCDeleteResource(gWiFiResource.handle); - if (res != OC_STACK_OK) + OCStackResult res = OC_STACK_ERROR; + if (gWiFiResource.handle != NULL) { - OIC_LOG_V(ERROR, ES_RH_TAG, "Deleting WiFi resource error with result: %s", getResult(res)); + res = OCUnBindResource(gProvResource.handle, gWiFiResource.handle); + if(res != OC_STACK_OK) + { + OIC_LOG_V(ERROR, ES_RH_TAG, "Unbind WiFi resource error with result: %s", getResult(res)); + } } - res = OCDeleteResource(gCloudResource.handle); - if (res != OC_STACK_OK) + if (gCloudResource.handle != NULL) { - OIC_LOG_V(ERROR, ES_RH_TAG, "Deleting CloudServer resource error with result: %s", getResult(res)); + res = OCUnBindResource(gProvResource.handle, gCloudResource.handle); + if(res != OC_STACK_OK) + { + OIC_LOG_V(ERROR, ES_RH_TAG, "Unbind CloudServer resource error with result: %s", getResult(res)); + } } - res = OCDeleteResource(gDevConfResource.handle); - if (res != OC_STACK_OK) + if (gDevConfResource.handle != NULL) { - OIC_LOG_V(ERROR, ES_RH_TAG, "Deleting DevConf resource error with result: %s", getResult(res)); + res = OCUnBindResource(gProvResource.handle, gDevConfResource.handle); + if(res != OC_STACK_OK) + { + OIC_LOG_V(ERROR, ES_RH_TAG, "Unbind DevConf resource error with result: %s", getResult(res)); + } } - res = OCDeleteResource(gProvResource.handle); - if (res != OC_STACK_OK) + if (gWiFiResource.handle != NULL) { - OIC_LOG_V(ERROR, ES_RH_TAG, "Deleting Prov resource error with result: %s", getResult(res)); + res = OCDeleteResource(gWiFiResource.handle); + if (res != OC_STACK_OK) + { + OIC_LOG_V(ERROR, ES_RH_TAG, "Deleting WiFi resource error with result: %s", getResult(res)); + } + } + + if(gCloudResource.handle != NULL) + { + res = OCDeleteResource(gCloudResource.handle); + if (res != OC_STACK_OK) + { + OIC_LOG_V(ERROR, ES_RH_TAG, "Deleting CloudServer resource error with result: %s", getResult(res)); + } + } + + if(gDevConfResource.handle != NULL) + { + res = OCDeleteResource(gDevConfResource.handle); + if (res != OC_STACK_OK) + { + OIC_LOG_V(ERROR, ES_RH_TAG, "Deleting DevConf resource error with result: %s", getResult(res)); + } + } + + if(gProvResource.handle != NULL) + { + res = OCDeleteResource(gProvResource.handle); + if (res != OC_STACK_OK) + { + OIC_LOG_V(ERROR, ES_RH_TAG, "Deleting Prov resource error with result: %s", getResult(res)); + } } return res; -- 2.7.4