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"
24 #include "oic_string.h"
28 class ListenOCContainer
31 static std::vector<std::string> StringLLToVector(OCStringLL* ll)
33 std::vector<std::string> strs;
36 strs.push_back(ll->value);
43 ListenOCContainer(std::weak_ptr<IClientWrapper> cw,
44 OCDevAddr& devAddr, OCDiscoveryPayload* payload)
45 : m_clientWrapper(cw), m_devAddr(devAddr)
49 OCResourcePayload* res = payload->resources;
55 (OCTransportFlags)(OC_FLAG_SECURE | m_devAddr.flags);
60 m_devAddr.port = res->port;
64 OCDevAddr rdPubAddr = m_devAddr;
65 OICStrcpy(rdPubAddr.addr, sizeof(rdPubAddr.addr), payload->baseURI);
66 rdPubAddr.port = res->port;
67 m_resources.push_back(std::shared_ptr<OC::OCResource>(
68 new OC::OCResource(m_clientWrapper, rdPubAddr,
69 std::string(res->uri),
70 std::string(payload->sid),
71 (res->bitmap & OC_OBSERVABLE) == OC_OBSERVABLE,
72 StringLLToVector(res->types),
73 StringLLToVector(res->interfaces)
78 m_resources.push_back(std::shared_ptr<OC::OCResource>(
79 new OC::OCResource(m_clientWrapper, m_devAddr,
80 std::string(res->uri),
81 std::string(payload->sid),
82 (res->bitmap & OC_OBSERVABLE) == OC_OBSERVABLE,
83 StringLLToVector(res->types),
84 StringLLToVector(res->interfaces)
88 if (res->tcpPort != 0)
90 OCDevAddr tcpDevAddr = m_devAddr;
91 tcpDevAddr.port = res->tcpPort;
92 tcpDevAddr.adapter = OC_ADAPTER_TCP;
93 m_resources.push_back(std::shared_ptr<OC::OCResource>(
94 new OC::OCResource(m_clientWrapper, tcpDevAddr,
95 std::string(res->uri),
96 std::string(payload->sid),
97 (res->bitmap & OC_OBSERVABLE) == OC_OBSERVABLE,
98 StringLLToVector(res->types),
99 StringLLToVector(res->interfaces)
106 payload = payload->next;
110 const std::vector<std::shared_ptr<OCResource>>& Resources() const
115 std::vector<std::shared_ptr<OC::OCResource>> m_resources;
116 std::weak_ptr<IClientWrapper> m_clientWrapper;
117 OCDevAddr& m_devAddr;