Merge branch '1.3-rel' (5fdb8a1)
[iotivity.git] / service / easy-setup / enrollee / src / resourcehandler.c
index 24eedac..54b75f2 100644 (file)
@@ -25,7 +25,7 @@
 #include "oic_string.h"
 #include "oic_malloc.h"
 #include "cautilinterface.h"
-#include "payload_logging.h"
+#include "experimental/payload_logging.h"
 
 // TODO: Remove this flag and enable the code it guards.
 // This is a temporary workaround to ignore the failure of OCLinksPayloadArrayCreate
@@ -386,38 +386,33 @@ OCEntityHandlerResult updateEasySetupResource(OCEntityHandlerRequest* ehRequest,
             while(children)
             {
                 char* uri = children->uri;
-                if(NULL == uri)
+                if (NULL == uri)
                 {
-                    OIC_LOG(DEBUG, ES_RH_TAG,
-                        "No URI found in request, applying same request to all links in collection");
-
-                    ///TODO: Need to check if "input" should be passed, or the value of property OC_RSRVD_REPRESENTATION.
-                    updateEasySetupConnectProperty(input);
-                    updateWiFiConfResource(input);
-                    updateCoapCloudConfResource(input);
-                    updateDevConfResource(input);
-
-                    // As the request is applied to children already, no need to check next child.
-                    break;
+                    OIC_LOG(DEBUG, ES_RH_TAG, "No URI found in request");
+                }
+                else
+                {
+                    OIC_LOG_V(DEBUG, ES_RH_TAG, "Request URI [%s]", uri);
                 }
-
-                OIC_LOG_V(DEBUG, ES_RH_TAG, "uri [%s]", uri);
 
                 OCRepPayload *repPayload = NULL;
                 OCRepPayloadGetPropObject(children, OC_RSRVD_REPRESENTATION, &repPayload);
-
-                if(NULL == repPayload)
+                if (NULL == repPayload)
                 {
                     OIC_LOG(ERROR, ES_RH_TAG, "repPayload is null!");
                     children = children->next;
                     continue;
                 }
 
-                if (0 == strcmp(uri, OC_RSRVD_ES_URI_EASYSETUP))
+                // If uri is NULL, rep is applied to all resources in collection;
+                // otherwise its applied to specific target resources.
+                if (NULL == uri || 0 == strlen(uri) || 0 == strcmp(uri, OC_RSRVD_ES_URI_EASYSETUP))
                 {
                     updateEasySetupConnectProperty(repPayload);
                 }
-                else if (0 == strcmp(uri, OC_RSRVD_ES_URI_WIFICONF))
+
+                if (NULL == uri || 0 == strlen(uri)
+                    || 0 == strcmp(uri, OC_RSRVD_ES_URI_WIFICONF))
                 {
                     if (updateWiFiConfResource(repPayload) != OC_EH_OK)
                     {
@@ -427,11 +422,15 @@ OCEntityHandlerResult updateEasySetupResource(OCEntityHandlerRequest* ehRequest,
                         hasError = true;
                     }
                 }
-                else if (0 == strcmp(uri, OC_RSRVD_ES_URI_COAPCLOUDCONF))
+
+                if (NULL == uri ||  0 == strlen(uri)
+                    || 0 == strcmp(uri, OC_RSRVD_ES_URI_COAPCLOUDCONF))
                 {
                     updateCoapCloudConfResource(repPayload);
                 }
-                else if (0 == strcmp(uri, OC_RSRVD_ES_URI_DEVCONF))
+
+                if (NULL == uri ||  0 == strlen(uri)
+                    || 0 == strcmp(uri, OC_RSRVD_ES_URI_DEVCONF))
                 {
                     updateDevConfResource(repPayload);
                 }
@@ -1704,7 +1703,6 @@ OCEntityHandlerResult OCEntityHandlerCb(OCEntityHandlerFlag flag,
 
         // Format the response.  Note this requires some info about the request
         response.requestHandle = entityHandlerRequest->requestHandle;
-        response.resourceHandle = entityHandlerRequest->resource;
         response.ehResult = ehRet;
         //response uses OCPaylod while all get,put methodes use OCRepPayload
         response.payload = (OCPayload*) (payload);