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_
30 #include <IClientWrapper.h>
31 #include <InitializeException.h>
32 #include <ResourceInitException.h>
36 namespace ClientCallbackContext
41 GetContext(GetCallback cb) : callback(cb){}
47 SetContext(PutCallback cb) : callback(cb){}
52 FindCallback callback;
53 std::weak_ptr<IClientWrapper> clientWrapper;
55 ListenContext(FindCallback cb, std::weak_ptr<IClientWrapper> cw)
56 : callback(cb), clientWrapper(cw){}
59 struct DeviceListenContext
61 FindDeviceCallback callback;
62 IClientWrapper::Ptr clientWrapper;
63 DeviceListenContext(FindDeviceCallback cb, IClientWrapper::Ptr cw)
64 : callback(cb), clientWrapper(cw){}
67 struct SubscribePresenceContext
69 SubscribeCallback callback;
70 SubscribePresenceContext(SubscribeCallback cb) : callback(cb){}
75 DeleteCallback callback;
76 DeleteContext(DeleteCallback cb) : callback(cb){}
81 ObserveCallback callback;
82 ObserveContext(ObserveCallback cb) : callback(cb){}
86 class InProcClientWrapper : public IClientWrapper
91 InProcClientWrapper(std::weak_ptr<std::recursive_mutex> csdkLock,
93 virtual ~InProcClientWrapper();
95 virtual OCStackResult ListenForResource(const std::string& serviceUrl,
96 const std::string& resourceType, OCConnectivityType transportFlags,
97 FindCallback& callback, QualityOfService QoS);
99 virtual OCStackResult ListenForDevice(const std::string& serviceUrl,
100 const std::string& deviceURI, OCConnectivityType transportFlags,
101 FindDeviceCallback& callback, QualityOfService QoS);
103 virtual OCStackResult GetResourceRepresentation(
104 const OCDevAddr& devAddr,
105 const std::string& uri,
106 const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
107 GetCallback& callback, QualityOfService QoS);
109 virtual OCStackResult PutResourceRepresentation(
110 const OCDevAddr& devAddr,
111 const std::string& uri,
112 const OCRepresentation& attributes, const QueryParamsMap& queryParams,
113 const HeaderOptions& headerOptions, PutCallback& callback, QualityOfService QoS);
115 virtual OCStackResult PostResourceRepresentation(
116 const OCDevAddr& devAddr,
117 const std::string& uri,
118 const OCRepresentation& attributes, const QueryParamsMap& queryParams,
119 const HeaderOptions& headerOptions, PostCallback& callback, QualityOfService QoS);
121 virtual OCStackResult DeleteResource(
122 const OCDevAddr& devAddr,
123 const std::string& uri,
124 const HeaderOptions& headerOptions,
125 DeleteCallback& callback, QualityOfService QoS);
127 virtual OCStackResult ObserveResource(
128 ObserveType observeType, OCDoHandle* handle,
129 const OCDevAddr& devAddr,
130 const std::string& uri,
131 const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
132 ObserveCallback& callback, QualityOfService QoS);
134 virtual OCStackResult CancelObserveResource(
136 const std::string& host,
137 const std::string& uri,
138 const HeaderOptions& headerOptions, QualityOfService QoS);
140 virtual OCStackResult SubscribePresence(
142 const std::string& host,
143 const std::string& resourceType,
144 OCConnectivityType transportFlags,
145 SubscribeCallback& presenceHandler);
147 virtual OCStackResult UnsubscribePresence(OCDoHandle handle);
148 OCStackResult GetDefaultQos(QualityOfService& QoS);
150 void listeningFunc();
151 std::string assembleSetResourceUri(std::string uri, const QueryParamsMap& queryParams);
152 OCPayload* assembleSetResourcePayload(const OCRepresentation& attributes);
153 OCHeaderOption* assembleHeaderOptions(OCHeaderOption options[],
154 const HeaderOptions& headerOptions);
155 std::thread m_listeningThread;
157 std::weak_ptr<std::recursive_mutex> m_csdkLock;
160 PlatformConfig m_cfg;