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 #ifndef _IN_PROC_CLIENT_WRAPPER_H_
22 #define _IN_PROC_CLIENT_WRAPPER_H_
31 #include <IClientWrapper.h>
32 #include <InitializeException.h>
33 #include <ResourceInitException.h>
37 namespace ClientCallbackContext
51 FindCallback callback;
52 std::weak_ptr<IClientWrapper> clientWrapper;
55 struct DeviceListenContext
57 FindDeviceCallback callback;
58 IClientWrapper::Ptr clientWrapper;
61 struct SubscribePresenceContext
63 SubscribeCallback callback;
68 DeleteCallback callback;
73 ObserveCallback callback;
77 class InProcClientWrapper : public IClientWrapper
82 InProcClientWrapper(std::weak_ptr<std::recursive_mutex> csdkLock,
84 virtual ~InProcClientWrapper();
87 virtual OCStackResult ListenForResource(const std::string& serviceUrl,
88 const std::string& resourceType, uint8_t connectivityType, FindCallback& callback,
89 QualityOfService QoS);
91 virtual OCStackResult ListenForDevice(const std::string& serviceUrl,
92 const std::string& deviceURI, uint8_t connectivityType, FindDeviceCallback& callback,
93 QualityOfService QoS);
95 virtual OCStackResult GetResourceRepresentation(const std::string& host,
96 const std::string& uri, uint8_t connectivityType, const QueryParamsMap& queryParams,
97 const HeaderOptions& headerOptions,
98 GetCallback& callback, QualityOfService QoS);
100 virtual OCStackResult PutResourceRepresentation(const std::string& host,
101 const std::string& uri, uint8_t connectivityType, const OCRepresentation& attributes,
102 const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
103 PutCallback& callback, QualityOfService QoS);
105 virtual OCStackResult PostResourceRepresentation(const std::string& host,
106 const std::string& uri, uint8_t connectivityType, const OCRepresentation& attributes,
107 const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
108 PostCallback& callback, QualityOfService QoS);
110 virtual OCStackResult DeleteResource(const std::string& host, const std::string& uri,
111 uint8_t connectivityType, const HeaderOptions& headerOptions,
112 DeleteCallback& callback, QualityOfService QoS);
114 virtual OCStackResult ObserveResource(ObserveType observeType, OCDoHandle* handle,
115 const std::string& host, const std::string& uri, uint8_t connectivityType,
116 const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
117 ObserveCallback& callback, QualityOfService QoS);
119 virtual OCStackResult ListenForResource(const std::string& serviceUrl,
120 const std::string& resourceType, FindCallback& callback,
121 QualityOfService QoS);
123 virtual OCStackResult ListenForDevice(const std::string& serviceUrl,
124 const std::string& deviceURI, FindDeviceCallback& callback,
125 QualityOfService QoS);
127 virtual OCStackResult GetResourceRepresentation(const std::string& host,
128 const std::string& uri, const QueryParamsMap& queryParams,
129 const HeaderOptions& headerOptions,
130 GetCallback& callback, QualityOfService QoS);
132 virtual OCStackResult PutResourceRepresentation(const std::string& host,
133 const std::string& uri, const OCRepresentation& attributes,
134 const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
135 PutCallback& callback, QualityOfService QoS);
137 virtual OCStackResult PostResourceRepresentation(const std::string& host,
138 const std::string& uri, const OCRepresentation& attributes,
139 const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
140 PostCallback& callback, QualityOfService QoS);
142 virtual OCStackResult DeleteResource(const std::string& host, const std::string& uri,
143 const HeaderOptions& headerOptions, DeleteCallback& callback, QualityOfService QoS);
145 virtual OCStackResult ObserveResource(ObserveType observeType, OCDoHandle* handle,
146 const std::string& host, const std::string& uri, const QueryParamsMap& queryParams,
147 const HeaderOptions& headerOptions, ObserveCallback& callback, QualityOfService QoS);
149 virtual OCStackResult CancelObserveResource(OCDoHandle handle, const std::string& host,
150 const std::string& uri, const HeaderOptions& headerOptions, QualityOfService QoS);
153 virtual OCStackResult SubscribePresence(OCDoHandle* handle, const std::string& host,
154 const std::string& resourceType, uint8_t connectivityType,
155 SubscribeCallback& presenceHandler);
157 virtual OCStackResult SubscribePresence(OCDoHandle* handle, const std::string& host,
158 const std::string& resourceType, SubscribeCallback& presenceHandler);
161 virtual OCStackResult UnsubscribePresence(OCDoHandle handle);
162 OCStackResult GetDefaultQos(QualityOfService& QoS);
164 void listeningFunc();
165 std::string assembleSetResourceUri(std::string uri, const QueryParamsMap& queryParams);
166 std::string assembleSetResourcePayload(const OCRepresentation& attributes);
167 void assembleHeaderOptions(OCHeaderOption options[],
168 const HeaderOptions& headerOptions);
169 std::thread m_listeningThread;
171 std::weak_ptr<std::recursive_mutex> m_csdkLock;
174 PlatformConfig m_cfg;