1 //******************************************************************
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #include <StringConstants.h>
22 #include "ocpayload.h"
27 class ListenOCContainer
30 static std::vector<std::string> StringLLToVector(OCStringLL* ll)
32 std::vector<std::string> strs;
35 strs.push_back(ll->value);
42 ListenOCContainer(std::weak_ptr<IClientWrapper> cw,
43 OCDevAddr& devAddr, OCDiscoveryPayload* payload)
44 : m_clientWrapper(cw), m_devAddr(devAddr)
46 OCResourcePayload* res = payload->resources;
47 OCResourceCollectionPayload* colRes = payload->collectionResources;
52 char uuidString[UUID_STRING_SIZE];
53 if(OCConvertUuidToString(res->sid, uuidString) != RAND_UUID_OK)
61 (OCTransportFlags)(OC_FLAG_SECURE | m_devAddr.flags);
66 m_devAddr.port = res->port;
69 m_resources.push_back(std::shared_ptr<OC::OCResource>(
70 new OC::OCResource(m_clientWrapper, m_devAddr,
71 std::string(res->uri),
72 std::string(uuidString),
73 (res->bitmap & OC_OBSERVABLE) == OC_OBSERVABLE,
74 StringLLToVector(res->types),
75 StringLLToVector(res->interfaces)
84 if (colRes->tags->bitmap & OC_SECURE)
87 (OCTransportFlags)(OC_FLAG_SECURE | m_devAddr.flags);
90 if (colRes->tags->port != 0)
92 m_devAddr.port = colRes->tags->port;
95 m_resources.push_back(std::shared_ptr<OC::OCResource>(
96 new OC::OCResource(m_clientWrapper, m_devAddr,
97 std::string(colRes->setLinks->href),
98 std::string((char*)colRes->tags->di.id),
99 (colRes->tags->bitmap & OC_OBSERVABLE) == OC_OBSERVABLE,
100 StringLLToVector(colRes->setLinks->rt),
101 StringLLToVector(colRes->setLinks->itf)
103 colRes = colRes->next;
108 const std::vector<std::shared_ptr<OCResource>>& Resources() const
113 std::vector<std::shared_ptr<OC::OCResource>> m_resources;
114 std::weak_ptr<IClientWrapper> m_clientWrapper;
115 OCDevAddr& m_devAddr;