Merge branch 'master' into easysetup
[platform/upstream/iotivity.git] / resource / include / OCSerialization.h
index 4c21ea3..be044bf 100644 (file)
@@ -45,13 +45,12 @@ namespace OC
                     : m_clientWrapper(cw), m_devAddr(devAddr)
             {
                 OCResourcePayload* res = payload->resources;
-                OCResourceCollectionPayload* colRes = payload->collectionResources;
                 if (res)
                 {
                     while(res)
                     {
                         char uuidString[UUID_STRING_SIZE];
-                        if(OCConvertUuidToString(res->sid, uuidString) != RAND_UUID_OK)
+                        if(OCConvertUuidToString(payload->sid, uuidString) != RAND_UUID_OK)
                         {
                             uuidString[0]= '\0';
                         }
@@ -66,8 +65,23 @@ namespace OC
                         {
                              m_devAddr.port = res->port;
                         }
-
-                        m_resources.push_back(std::shared_ptr<OC::OCResource>(
+                        if (payload->baseURI)
+                        {
+                            OCDevAddr rdPubAddr = m_devAddr;
+                            OICStrcpy(rdPubAddr.addr, sizeof(rdPubAddr.addr), payload->baseURI);
+                            rdPubAddr.port = res->port;
+                            m_resources.push_back(std::shared_ptr<OC::OCResource>(
+                                        new OC::OCResource(m_clientWrapper, rdPubAddr,
+                                            std::string(res->uri),
+                                            std::string((char*)uuidString),
+                                            (res->bitmap & OC_OBSERVABLE) == OC_OBSERVABLE,
+                                            StringLLToVector(res->types),
+                                            StringLLToVector(res->interfaces)
+                                            )));
+                        }
+                        else
+                        {
+                            m_resources.push_back(std::shared_ptr<OC::OCResource>(
                                     new OC::OCResource(m_clientWrapper, m_devAddr,
                                         std::string(res->uri),
                                         std::string(uuidString),
@@ -75,38 +89,8 @@ namespace OC
                                         StringLLToVector(res->types),
                                         StringLLToVector(res->interfaces)
                                         )));
-                        res = res->next;
-                    }
-                }
-                else if (colRes)
-                {
-                    while(colRes)
-                    {
-                        OCDevAddr colAddr;
-                        OICStrcpy(colAddr.addr, sizeof(colAddr.addr), colRes->tags->baseURI);
-                        if (colRes->tags->bitmap & OC_SECURE)
-                        {
-                            colAddr.flags =
-                                  (OCTransportFlags)(OC_FLAG_SECURE | colRes->tags->bitmap);
-                            if (colRes->tags->port != 0)
-                            {
-                               colAddr.port = colRes->tags->port;
-                            }
-                        }
-                        else
-                        {
-                            colAddr.port = colRes->tags->port;
                         }
-
-                        m_resources.push_back(std::shared_ptr<OC::OCResource>(
-                                    new OC::OCResource(m_clientWrapper, colAddr,
-                                        std::string(colRes->setLinks->href),
-                                        std::string((char*)colRes->tags->di.id),
-                                        (colRes->tags->bitmap & OC_OBSERVABLE) == OC_OBSERVABLE,
-                                        StringLLToVector(colRes->setLinks->rt),
-                                        StringLLToVector(colRes->setLinks->itf)
-                                        )));
-                        colRes = colRes->next;
+                        res = res->next;
                     }
                 }
             }