Removing Internal calls to CA APIs in OCPlatform
[platform/upstream/iotivity.git] / resource / src / OCPlatform.cpp
1 //******************************************************************
2 //
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
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
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
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.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 //******************************************************************
22 // File name:
23 //     OCPlatform.cpp
24 //
25 // Description: Implementation of the OCPlatform.
26 //
27 //
28 //
29 //*********************************************************************
30 #include <OCPlatform.h>
31 namespace OC
32 {
33     namespace OCPlatform
34     {
35         void Configure(const PlatformConfig& config)
36         {
37             OCPlatform_impl::Configure(config);
38         }
39
40         OCStackResult setDefaultDeviceEntityHandler(EntityHandler entityHandler)
41         {
42             return OCPlatform_impl::Instance().setDefaultDeviceEntityHandler(entityHandler);
43         }
44
45         OCStackResult notifyAllObservers(OCResourceHandle resourceHandle,
46                                                 QualityOfService QoS)
47         {
48             return OCPlatform_impl::Instance().notifyAllObservers(resourceHandle, QoS);
49         }
50
51         OCStackResult notifyAllObservers(OCResourceHandle resourceHandle)
52         {
53             return OCPlatform_impl::Instance().notifyAllObservers(resourceHandle);
54         }
55
56         OCStackResult notifyListOfObservers(OCResourceHandle resourceHandle,
57                                                 ObservationIds& observationIds,
58                                                 const std::shared_ptr<OCResourceResponse> pResponse)
59         {
60             return OCPlatform_impl::Instance().notifyListOfObservers(resourceHandle,
61                                                 observationIds, pResponse);
62         }
63
64         OCStackResult notifyListOfObservers(OCResourceHandle resourceHandle,
65                                                 ObservationIds& observationIds,
66                                                 const std::shared_ptr<OCResourceResponse> pResponse,
67                                                 QualityOfService QoS)
68         {
69             return OCPlatform_impl::Instance().notifyListOfObservers(resourceHandle,
70                                                     observationIds, pResponse, QoS);
71         }
72
73 #ifdef CA_INT
74         OCResource::Ptr constructResourceObject(const std::string& host,
75                                                 const std::string& uri,
76                                                 OCConnectivityType connectivityType,
77                                                 bool isObservable,
78                                                 const std::vector<std::string>& resourceTypes,
79                                                 const std::vector<std::string>& interfaces)
80         {
81             return OCPlatform_impl::Instance().constructResourceObject(host, uri, connectivityType,
82                                                 isObservable,
83                                                 resourceTypes, interfaces);
84         }
85
86         OCStackResult findResource(const std::string& host,
87                                                 const std::string& resourceName,
88                                                 OCConnectivityType connectivityType,
89                                                 FindCallback resourceHandler)
90         {
91             return OCPlatform_impl::Instance().findResource(host, resourceName,
92                    connectivityType, resourceHandler);
93         }
94
95         OCStackResult findResource(const std::string& host,
96                                                 const std::string& resourceName,
97                                                 OCConnectivityType connectivityType,
98                                                 FindCallback resourceHandler, QualityOfService QoS)
99         {
100             return OCPlatform_impl::Instance().findResource(host, resourceName, connectivityType,
101                                                 resourceHandler, QoS);
102         }
103
104         OCStackResult getDeviceInfo(const std::string& host,
105                                                 const std::string& deviceURI,
106                                                 OCConnectivityType connectivityType,
107                                                 FindDeviceCallback deviceInfoHandler)
108         {
109             return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI,
110                    connectivityType, deviceInfoHandler);
111         }
112
113         OCStackResult getDeviceInfo(const std::string& host,
114                                                 const std::string& deviceURI,
115                                                 OCConnectivityType connectivityType,
116                                                 FindDeviceCallback deviceInfoHandler,
117                                                 QualityOfService QoS)
118         {
119             return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI, connectivityType,
120                     deviceInfoHandler, QoS);
121         }
122 #else
123
124         OCStackResult findResource(const std::string& host,
125                                                 const std::string& resourceName,
126                                                 FindCallback resourceHandler)
127         {
128             return OCPlatform_impl::Instance().findResource(host, resourceName, resourceHandler);
129         }
130
131         OCStackResult findResource(const std::string& host,
132                                                 const std::string& resourceName,
133                                                 FindCallback resourceHandler, QualityOfService QoS)
134         {
135             return OCPlatform_impl::Instance().findResource(host, resourceName,
136                                                 resourceHandler, QoS);
137         }
138
139         OCResource::Ptr constructResourceObject(const std::string& host,
140                                                 const std::string& uri,
141                                                 bool isObservable,
142                                                 const std::vector<std::string>& resourceTypes,
143                                                 const std::vector<std::string>& interfaces)
144         {
145             return OCPlatform_impl::Instance().constructResourceObject(host, uri, isObservable,
146                                                 resourceTypes, interfaces);
147         }
148
149         OCStackResult getDeviceInfo(const std::string& host,
150                                                 const std::string& deviceURI,
151                                                 FindDeviceCallback deviceInfoHandler)
152         {
153             return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI, deviceInfoHandler);
154         }
155
156         OCStackResult getDeviceInfo(const std::string& host,
157                                                 const std::string& deviceURI,
158                                                 FindDeviceCallback deviceInfoHandler,
159                                                 QualityOfService QoS)
160         {
161             return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI, deviceInfoHandler, QoS);
162         }
163 #endif
164
165         OCStackResult registerResource(OCResourceHandle& resourceHandle,
166                                                 std::string& resourceURI,
167                                                 const std::string& resourceTypeName,
168                                                 const std::string& resourceInterface,
169                                                 EntityHandler entityHandler,
170                                                 uint8_t resourceProperty)
171         {
172             return OCPlatform_impl::Instance().registerResource(resourceHandle, resourceURI,
173                                                 resourceTypeName, resourceInterface,
174                                                 entityHandler, resourceProperty);
175         }
176
177         OCStackResult registerResource(OCResourceHandle& resourceHandle,
178                                                 const std::shared_ptr< OCResource > resource)
179         {
180             return OCPlatform_impl::Instance().registerResource(resourceHandle, resource);
181         }
182
183         OCStackResult registerDeviceInfo(const OCDeviceInfo deviceInfo)
184         {
185             return OCPlatform_impl::Instance().registerDeviceInfo(deviceInfo);
186         }
187
188         OCStackResult unregisterResource(const OCResourceHandle& resourceHandle)
189         {
190             return OCPlatform_impl::Instance().unregisterResource(resourceHandle);
191         }
192
193         OCStackResult unbindResource(OCResourceHandle collectionHandle,
194                                                 OCResourceHandle resourceHandle)
195         {
196             return OCPlatform_impl::Instance().unbindResource(collectionHandle, resourceHandle);
197         }
198
199         OCStackResult unbindResources(const OCResourceHandle collectionHandle,
200                                                 const std::vector<OCResourceHandle>& resourceHandles
201                                                 )
202         {
203             return OCPlatform_impl::Instance().unbindResources(collectionHandle, resourceHandles);
204         }
205
206         OCStackResult bindResource(const OCResourceHandle collectionHandle,
207                                                 const OCResourceHandle resourceHandle)
208         {
209             return OCPlatform_impl::Instance().bindResource(collectionHandle, resourceHandle);
210         }
211
212         OCStackResult bindResources(const OCResourceHandle collectionHandle,
213                                                 const std::vector<OCResourceHandle>& resourceHandles
214                                                 )
215         {
216             return OCPlatform_impl::Instance().bindResources(collectionHandle, resourceHandles);
217         }
218
219         OCStackResult bindTypeToResource(const OCResourceHandle& resourceHandle,
220                                                 const std::string& resourceTypeName)
221         {
222             return OCPlatform_impl::Instance().bindTypeToResource(resourceHandle,resourceTypeName);
223         }
224
225         OCStackResult bindInterfaceToResource(const OCResourceHandle& resourceHandle,
226                                                 const std::string& resourceInterfaceName)
227         {
228             return OCPlatform_impl::Instance().bindInterfaceToResource(resourceHandle,
229                                                 resourceInterfaceName);
230         }
231
232         OCStackResult startPresence(const unsigned int announceDurationSeconds)
233         {
234             return OCPlatform_impl::Instance().startPresence(announceDurationSeconds);
235         }
236
237         OCStackResult stopPresence()
238         {
239             return OCPlatform_impl::Instance().stopPresence();
240         }
241
242 #ifdef CA_INT
243         OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
244                                                 const std::string& host,
245                                                 OCConnectivityType connectivityType,
246                                                 SubscribeCallback presenceHandler)
247         {
248             return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
249                                                 connectivityType, presenceHandler);
250         }
251
252         OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
253                                                 const std::string& host,
254                                                 const std::string& resourceType,
255                                                 OCConnectivityType connectivityType,
256                                                 SubscribeCallback presenceHandler)
257         {
258             return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
259                                                 resourceType, connectivityType, presenceHandler);
260         }
261 #else
262         OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
263                                                 const std::string& host,
264                                                 SubscribeCallback presenceHandler)
265         {
266             return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
267                                                 presenceHandler);
268         }
269
270         OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
271                                                 const std::string& host,
272                                                 const std::string& resourceType,
273                                                 SubscribeCallback presenceHandler)
274         {
275             return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
276                                                 resourceType, presenceHandler);
277         }
278 #endif
279
280         OCStackResult unsubscribePresence(OCPresenceHandle presenceHandle)
281         {
282             return OCPlatform_impl::Instance().unsubscribePresence(presenceHandle);
283         }
284
285         OCStackResult sendResponse(const std::shared_ptr<OCResourceResponse> pResponse)
286         {
287             return OCPlatform_impl::Instance().sendResponse(pResponse);
288         }
289     } // namespace OCPlatform
290 } //namespace OC