replace : iotivity -> iotivity-sec
[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         OCStackResult Configure(const PlatformConfig& config)
36         {
37             return OCPlatform_impl::Configure(config);
38         }
39
40         OCStackResult start()
41         {
42             return OCPlatform_impl::Instance().start();
43         }
44
45         OCStackResult stop()
46         {
47             return OCPlatform_impl::Instance().stop();
48         }
49
50         OCStackResult setDefaultDeviceEntityHandler(EntityHandler entityHandler)
51         {
52             return OCPlatform_impl::Instance().setDefaultDeviceEntityHandler(entityHandler);
53         }
54
55         OCStackResult notifyAllObservers(OCResourceHandle resourceHandle,
56                                      QualityOfService QoS)
57         {
58             return OCPlatform_impl::Instance().notifyAllObservers(resourceHandle, QoS);
59         }
60
61         OCStackResult notifyAllObservers(OCResourceHandle resourceHandle)
62         {
63             return OCPlatform_impl::Instance().notifyAllObservers(resourceHandle);
64         }
65
66         OCStackResult notifyListOfObservers(OCResourceHandle resourceHandle,
67                                      ObservationIds& observationIds,
68                                      const std::shared_ptr<OCResourceResponse> pResponse)
69         {
70             return OCPlatform_impl::Instance().notifyListOfObservers(resourceHandle,
71                                      observationIds, pResponse);
72         }
73
74         OCStackResult notifyListOfObservers(OCResourceHandle resourceHandle,
75                                      ObservationIds& observationIds,
76                                      const std::shared_ptr<OCResourceResponse> pResponse,
77                                      QualityOfService QoS)
78         {
79             return OCPlatform_impl::Instance().notifyListOfObservers(resourceHandle,
80                                      observationIds, pResponse, QoS);
81         }
82
83         OCResource::Ptr constructResourceObject(const std::string& host,
84                                      const std::string& uri,
85                                      OCConnectivityType connectivityType,
86                                      bool isObservable,
87                                      const std::vector<std::string>& resourceTypes,
88                                      const std::vector<std::string>& interfaces)
89         {
90             return OCPlatform_impl::Instance().constructResourceObject(host,
91                                      uri, connectivityType,
92                                      isObservable,
93                                      resourceTypes, interfaces);
94         }
95
96         OCStackResult findResource(const std::string& host,
97                                  const std::string& resourceName,
98                                  OCConnectivityType connectivityType,
99                                  FindCallback resourceHandler)
100         {
101             return OCPlatform_impl::Instance().findResource(host, resourceName,
102                                  connectivityType, resourceHandler);
103         }
104
105         OCStackResult findResource(const std::string& host,
106                                  const std::string& resourceName,
107                                  OCConnectivityType connectivityType,
108                                  FindCallback resourceHandler,
109                                  QualityOfService QoS)
110         {
111             return OCPlatform_impl::Instance().findResource(host, resourceName,
112                                  connectivityType, resourceHandler, QoS);
113         }
114
115         OCStackResult findResource(const std::string& host,
116                                             const std::string& resourceName,
117                                             OCConnectivityType connectivityType,
118                                             FindCallback resourceHandler,
119                                             FindErrorCallback errorHandler)
120         {
121             return OCPlatform_impl::Instance().findResource(host, resourceName,
122                                     connectivityType, resourceHandler, errorHandler);
123         }
124
125         OCStackResult findResource(const std::string& host,
126                                             const std::string& resourceName,
127                                             OCConnectivityType connectivityType,
128                                             FindCallback resourceHandler,
129                                             FindErrorCallback errorHandler,
130                                             QualityOfService QoS)
131         {
132             return OCPlatform_impl::Instance().findResource(host, resourceName,
133                                     connectivityType, resourceHandler, errorHandler, QoS);
134         }
135
136         OCStackResult findResourceList(const std::string& host, const std::string& resourceURI,
137                     OCConnectivityType connectivityType, FindResListCallback resourceHandler,
138                     QualityOfService QoS)
139         {
140             return OCPlatform_impl::Instance().findResourceList(host, resourceURI,
141                                     connectivityType, resourceHandler, QoS);
142         }
143
144         OCStackResult findResourceList(const std::string& host, const std::string& resourceURI,
145                     OCConnectivityType connectivityType, FindResListCallback resourceHandler,
146                     FindErrorCallback errorHandler, QualityOfService QoS)
147         {
148             return OCPlatform_impl::Instance().findResourceList(host, resourceURI,
149                                     connectivityType, resourceHandler, errorHandler, QoS);
150         }
151
152         OCStackResult getDeviceInfo(const std::string& host,
153                                  const std::string& deviceURI,
154                                  OCConnectivityType connectivityType,
155                                  FindDeviceCallback deviceInfoHandler)
156         {
157             return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI,
158                                  connectivityType, deviceInfoHandler);
159         }
160
161         OCStackResult getDeviceInfo(const std::string& host,
162                                  const std::string& deviceURI,
163                                  OCConnectivityType connectivityType,
164                                  FindDeviceCallback deviceInfoHandler,
165                                  QualityOfService QoS)
166         {
167             return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI, connectivityType,
168                                  deviceInfoHandler, QoS);
169         }
170
171         OCStackResult getPlatformInfo(const std::string& host,
172                                  const std::string& platformURI,
173                                  OCConnectivityType connectivityType,
174                                  FindPlatformCallback platformInfoHandler)
175         {
176             return OCPlatform_impl::Instance().getPlatformInfo(host, platformURI,
177                                  connectivityType, platformInfoHandler);
178         }
179
180         OCStackResult getPlatformInfo(const std::string& host,
181                                  const std::string& platformURI,
182                                  OCConnectivityType connectivityType,
183                                  FindPlatformCallback platformInfoHandler,
184                                  QualityOfService QoS)
185         {
186             return OCPlatform_impl::Instance().getPlatformInfo(host, platformURI, connectivityType,
187                                  platformInfoHandler, QoS);
188         }
189
190         OCStackResult registerResource(OCResourceHandle& resourceHandle,
191                                  std::string& resourceURI,
192                                  const std::string& resourceTypeName,
193                                  const std::string& resourceInterface,
194                                  EntityHandler entityHandler,
195                                  uint8_t resourceProperty)
196         {
197             return OCPlatform_impl::Instance().registerResource(resourceHandle, resourceURI,
198                                  resourceTypeName, resourceInterface,
199                                  entityHandler, resourceProperty);
200         }
201
202         OCStackResult registerResource(OCResourceHandle& resourceHandle,
203                                  const std::shared_ptr< OCResource > resource)
204         {
205             return OCPlatform_impl::Instance().registerResource(resourceHandle, resource);
206         }
207
208         OCStackResult registerDeviceInfo(const OCDeviceInfo deviceInfo)
209         {
210             return OCPlatform_impl::Instance().registerDeviceInfo(deviceInfo);
211         }
212
213         OCStackResult registerPlatformInfo(const OCPlatformInfo platformInfo)
214         {
215             return OCPlatform_impl::Instance().registerPlatformInfo(platformInfo);
216         }
217
218         OCStackResult setPropertyValue(OCPayloadType type, const std::string& tag, const std::string& value)
219         {
220             return OCPlatform_impl::Instance().setPropertyValue(type, tag, value);
221         }
222
223         OCStackResult setPropertyValue(OCPayloadType type, const std::string& tag, const std::vector<std::string>& value)
224         {
225             return OCPlatform_impl::Instance().setPropertyValue(type, tag, value);
226         }
227
228         OCStackResult getPropertyValue(OCPayloadType type, const std::string& tag, std::string& value)
229         {
230             return OCPlatform_impl::Instance().getPropertyValue(type, tag, value);
231         }
232
233         OCStackResult unregisterResource(const OCResourceHandle& resourceHandle)
234         {
235             return OCPlatform_impl::Instance().unregisterResource(resourceHandle);
236         }
237
238         OCStackResult unbindResource(OCResourceHandle collectionHandle,
239                                  OCResourceHandle resourceHandle)
240         {
241             return OCPlatform_impl::Instance().unbindResource(collectionHandle, resourceHandle);
242         }
243
244         OCStackResult unbindResources(const OCResourceHandle collectionHandle,
245                                  const std::vector<OCResourceHandle>& resourceHandles)
246         {
247             return OCPlatform_impl::Instance().unbindResources(collectionHandle, resourceHandles);
248         }
249
250         OCStackResult bindResource(const OCResourceHandle collectionHandle,
251                                  const OCResourceHandle resourceHandle)
252         {
253             return OCPlatform_impl::Instance().bindResource(collectionHandle, resourceHandle);
254         }
255
256         OCStackResult bindResources(const OCResourceHandle collectionHandle,
257                                  const std::vector<OCResourceHandle>& resourceHandles
258                                  )
259         {
260             return OCPlatform_impl::Instance().bindResources(collectionHandle, resourceHandles);
261         }
262
263         OCStackResult bindTypeToResource(const OCResourceHandle& resourceHandle,
264                                  const std::string& resourceTypeName)
265         {
266             return OCPlatform_impl::Instance().bindTypeToResource(resourceHandle,resourceTypeName);
267         }
268
269         OCStackResult bindInterfaceToResource(const OCResourceHandle& resourceHandle,
270                                  const std::string& resourceInterfaceName)
271         {
272             return OCPlatform_impl::Instance().bindInterfaceToResource(resourceHandle,
273                                                              resourceInterfaceName);
274         }
275
276         OCStackResult startPresence(const unsigned int announceDurationSeconds)
277         {
278             return OCPlatform_impl::Instance().startPresence(announceDurationSeconds);
279         }
280
281         OCStackResult stopPresence()
282         {
283             return OCPlatform_impl::Instance().stopPresence();
284         }
285
286         OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
287                                      const std::string& host,
288                                      OCConnectivityType connectivityType,
289                                      SubscribeCallback presenceHandler)
290         {
291             return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
292                                                              connectivityType, presenceHandler);
293         }
294
295         OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
296                                      const std::string& host,
297                                      const std::string& resourceType,
298                                      OCConnectivityType connectivityType,
299                                      SubscribeCallback presenceHandler)
300         {
301             return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
302                                              resourceType, connectivityType, presenceHandler);
303         }
304
305         OCStackResult unsubscribePresence(OCPresenceHandle presenceHandle)
306         {
307             return OCPlatform_impl::Instance().unsubscribePresence(presenceHandle);
308         }
309
310 #ifdef WITH_CLOUD
311         OCStackResult subscribeDevicePresence(OCPresenceHandle& presenceHandle,
312                                               const std::string& host,
313                                               const std::vector<std::string>& di,
314                                               OCConnectivityType connectivityType,
315                                               ObserveCallback callback)
316         {
317             return OCPlatform_impl::Instance().subscribeDevicePresence(presenceHandle,
318                                                                        host,
319                                                                        di,
320                                                                        connectivityType,
321                                                                        callback);
322         }
323 #endif
324
325         OCStackResult sendResponse(const std::shared_ptr<OCResourceResponse> pResponse)
326         {
327             return OCPlatform_impl::Instance().sendResponse(pResponse);
328         }
329
330         OCStackResult findDirectPairingDevices(unsigned short waittime,
331                                          GetDirectPairedCallback directPairingHandler)
332         {
333             return OCPlatform_impl::Instance().findDirectPairingDevices(waittime,
334                                          directPairingHandler);
335         }
336
337         OCStackResult getDirectPairedDevices(GetDirectPairedCallback directPairingHandler)
338         {
339             return OCPlatform_impl::Instance().getDirectPairedDevices(directPairingHandler);
340         }
341
342         OCStackResult doDirectPairing(std::shared_ptr<OCDirectPairing> peer, OCPrm_t pmSel,
343                                  const std::string& pinNumber,
344                                  DirectPairingCallback resultCallback)
345         {
346             return OCPlatform_impl::Instance().doDirectPairing(peer, pmSel,
347                                              pinNumber, resultCallback);
348         }
349 #ifdef WITH_CLOUD
350         OCAccountManager::Ptr constructAccountManagerObject(const std::string& host,
351                                                             OCConnectivityType connectivityType)
352         {
353             return OCPlatform_impl::Instance().constructAccountManagerObject(host,
354                                                                              connectivityType);
355         }
356 #endif // WITH_CLOUD
357 #ifdef TCP_ADAPTER
358         OCStackResult findKeepAliveResource(std::string host, KeepAliveCallback resultCallback)
359         {
360             return OCPlatform_impl::Instance().findKeepAliveResource(host, resultCallback);
361         }
362
363         OCStackResult sendKeepAliveRequest(std::string host, const OCRepresentation& rep,
364                                                              KeepAliveCallback pingHandler)
365         {
366             return OCPlatform_impl::Instance().sendKeepAliveRequest(host, rep, pingHandler);
367         }
368 #endif
369
370         OCStackResult getDeviceId(OCUUIdentity *deviceId)
371         {
372             return OCPlatform_impl::Instance().getDeviceId(deviceId);
373         }
374
375         OCStackResult setDeviceId(const OCUUIdentity *deviceId)
376         {
377             return OCPlatform_impl::Instance().setDeviceId(deviceId);
378         }
379     } // namespace OCPlatform
380 } //namespace OC