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
42 GetContext(GetCallback cb) : callback(cb){}
48 SetContext(PutCallback cb) : callback(cb){}
53 FindCallback callback;
54 std::weak_ptr<IClientWrapper> clientWrapper;
56 ListenContext(FindCallback cb, std::weak_ptr<IClientWrapper> cw)
57 : callback(cb), clientWrapper(cw){}
60 struct DeviceListenContext
62 FindDeviceCallback callback;
63 IClientWrapper::Ptr clientWrapper;
64 DeviceListenContext(FindDeviceCallback cb, IClientWrapper::Ptr cw)
65 : callback(cb), clientWrapper(cw){}
68 struct SubscribePresenceContext
70 SubscribeCallback callback;
71 SubscribePresenceContext(SubscribeCallback cb) : callback(cb){}
76 DeleteCallback callback;
77 DeleteContext(DeleteCallback cb) : callback(cb){}
82 ObserveCallback callback;
83 ObserveContext(ObserveCallback cb) : callback(cb){}
87 class InProcClientWrapper : public IClientWrapper
92 InProcClientWrapper(std::weak_ptr<std::recursive_mutex> csdkLock,
94 virtual ~InProcClientWrapper();
96 virtual OCStackResult ListenForResource(const std::string& serviceUrl,
97 const std::string& resourceType, OCConnectivityType connectivityType,
98 FindCallback& callback, QualityOfService QoS);
100 virtual OCStackResult ListenForDevice(const std::string& serviceUrl,
101 const std::string& deviceURI, OCConnectivityType connectivityType,
102 FindDeviceCallback& callback, QualityOfService QoS);
104 virtual OCStackResult GetResourceRepresentation(const std::string& host,
105 const std::string& uri, OCConnectivityType connectivityType,
106 const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
107 GetCallback& callback, QualityOfService QoS);
109 virtual OCStackResult PutResourceRepresentation(const std::string& host,
110 const std::string& uri, OCConnectivityType connectivityType,
111 const OCRepresentation& attributes, const QueryParamsMap& queryParams,
112 const HeaderOptions& headerOptions, PutCallback& callback, QualityOfService QoS);
114 virtual OCStackResult PostResourceRepresentation(const std::string& host,
115 const std::string& uri, OCConnectivityType connectivityType,
116 const OCRepresentation& attributes, const QueryParamsMap& queryParams,
117 const HeaderOptions& headerOptions, PostCallback& callback, QualityOfService QoS);
119 virtual OCStackResult DeleteResource(const std::string& host, const std::string& uri,
120 OCConnectivityType connectivityType, const HeaderOptions& headerOptions,
121 DeleteCallback& callback, QualityOfService QoS);
123 virtual OCStackResult ObserveResource(ObserveType observeType, OCDoHandle* handle,
124 const std::string& host, const std::string& uri, OCConnectivityType connectivityType,
125 const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
126 ObserveCallback& callback, QualityOfService QoS);
128 virtual OCStackResult CancelObserveResource(OCDoHandle handle, const std::string& host,
129 const std::string& uri, const HeaderOptions& headerOptions, QualityOfService QoS);
131 virtual OCStackResult SubscribePresence(OCDoHandle* handle, const std::string& host,
132 const std::string& resourceType, OCConnectivityType connectivityType,
133 SubscribeCallback& presenceHandler);
135 virtual OCStackResult UnsubscribePresence(OCDoHandle handle);
136 OCStackResult GetDefaultQos(QualityOfService& QoS);
138 void listeningFunc();
139 std::string assembleSetResourceUri(std::string uri, const QueryParamsMap& queryParams);
140 std::string assembleSetResourcePayload(const OCRepresentation& attributes);
141 OCHeaderOption* assembleHeaderOptions(OCHeaderOption options[],
142 const HeaderOptions& headerOptions);
143 std::thread m_listeningThread;
145 std::weak_ptr<std::recursive_mutex> m_csdkLock;
148 PlatformConfig m_cfg;