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 SubscribePresenceContext
57 SubscribeCallback callback;
62 DeleteCallback callback;
67 ObserveCallback callback;
71 class InProcClientWrapper : public IClientWrapper
76 InProcClientWrapper(std::weak_ptr<std::recursive_mutex> csdkLock,
78 virtual ~InProcClientWrapper();
80 virtual OCStackResult ListenForResource(const std::string& serviceUrl,
81 const std::string& resourceType, FindCallback& callback,
82 QualityOfService QoS);
84 virtual OCStackResult GetResourceRepresentation(const std::string& host,
85 const std::string& uri, const QueryParamsMap& queryParams,
86 const HeaderOptions& headerOptions,
87 GetCallback& callback, QualityOfService QoS);
89 virtual OCStackResult PutResourceRepresentation(const std::string& host,
90 const std::string& uri, const OCRepresentation& attributes,
91 const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
92 PutCallback& callback, QualityOfService QoS);
94 virtual OCStackResult PostResourceRepresentation(const std::string& host,
95 const std::string& uri, const OCRepresentation& attributes,
96 const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
97 PostCallback& callback, QualityOfService QoS);
99 virtual OCStackResult DeleteResource(const std::string& host, const std::string& uri,
100 const HeaderOptions& headerOptions, DeleteCallback& callback, QualityOfService QoS);
102 virtual OCStackResult ObserveResource(ObserveType observeType, OCDoHandle* handle,
103 const std::string& host, const std::string& uri, const QueryParamsMap& queryParams,
104 const HeaderOptions& headerOptions, ObserveCallback& callback, QualityOfService QoS);
106 virtual OCStackResult CancelObserveResource(OCDoHandle handle, const std::string& host,
107 const std::string& uri, const HeaderOptions& headerOptions, QualityOfService QoS);
109 virtual OCStackResult SubscribePresence(OCDoHandle* handle, const std::string& host,
110 const std::string& resourceType, SubscribeCallback& presenceHandler);
112 virtual OCStackResult UnsubscribePresence(OCDoHandle handle);
113 OCStackResult GetDefaultQos(QualityOfService& QoS);
115 void listeningFunc();
116 std::string assembleSetResourceUri(std::string uri, const QueryParamsMap& queryParams);
117 std::string assembleSetResourcePayload(const OCRepresentation& attributes);
118 void assembleHeaderOptions(OCHeaderOption options[],
119 const HeaderOptions& headerOptions);
120 std::thread m_listeningThread;
122 std::weak_ptr<std::recursive_mutex> m_csdkLock;
125 PlatformConfig m_cfg;