Imported Upstream version 1.1.1
[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         OCResource::Ptr constructResourceObject(const std::string& host,
74                                      const std::string& uri,
75                                      OCConnectivityType connectivityType,
76                                      bool isObservable,
77                                      const std::vector<std::string>& resourceTypes,
78                                      const std::vector<std::string>& interfaces)
79         {
80             return OCPlatform_impl::Instance().constructResourceObject(host,
81                                      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,
99                                  QualityOfService QoS)
100         {
101             return OCPlatform_impl::Instance().findResource(host, resourceName,
102                                  connectivityType, resourceHandler, QoS);
103         }
104
105         OCStackResult getDeviceInfo(const std::string& host,
106                                  const std::string& deviceURI,
107                                  OCConnectivityType connectivityType,
108                                  FindDeviceCallback deviceInfoHandler)
109         {
110             return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI,
111                                  connectivityType, deviceInfoHandler);
112         }
113
114         OCStackResult getDeviceInfo(const std::string& host,
115                                  const std::string& deviceURI,
116                                  OCConnectivityType connectivityType,
117                                  FindDeviceCallback deviceInfoHandler,
118                                  QualityOfService QoS)
119         {
120             return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI, connectivityType,
121                                  deviceInfoHandler, QoS);
122         }
123
124         OCStackResult getPlatformInfo(const std::string& host,
125                                  const std::string& platformURI,
126                                  OCConnectivityType connectivityType,
127                                  FindPlatformCallback platformInfoHandler)
128         {
129             return OCPlatform_impl::Instance().getPlatformInfo(host, platformURI,
130                                  connectivityType, platformInfoHandler);
131         }
132
133         OCStackResult getPlatformInfo(const std::string& host,
134                                  const std::string& platformURI,
135                                  OCConnectivityType connectivityType,
136                                  FindPlatformCallback platformInfoHandler,
137                                  QualityOfService QoS)
138         {
139             return OCPlatform_impl::Instance().getPlatformInfo(host, platformURI, connectivityType,
140                                  platformInfoHandler, QoS);
141         }
142
143         OCStackResult registerResource(OCResourceHandle& resourceHandle,
144                                  std::string& resourceURI,
145                                  const std::string& resourceTypeName,
146                                  const std::string& resourceInterface,
147                                  EntityHandler entityHandler,
148                                  uint8_t resourceProperty)
149         {
150             return OCPlatform_impl::Instance().registerResource(resourceHandle, resourceURI,
151                                  resourceTypeName, resourceInterface,
152                                  entityHandler, resourceProperty);
153         }
154
155         OCStackResult registerResource(OCResourceHandle& resourceHandle,
156                                  const std::shared_ptr< OCResource > resource)
157         {
158             return OCPlatform_impl::Instance().registerResource(resourceHandle, resource);
159         }
160
161         OCStackResult registerDeviceInfo(const OCDeviceInfo deviceInfo)
162         {
163             return OCPlatform_impl::Instance().registerDeviceInfo(deviceInfo);
164         }
165
166         OCStackResult registerPlatformInfo(const OCPlatformInfo platformInfo)
167         {
168             return OCPlatform_impl::Instance().registerPlatformInfo(platformInfo);
169         }
170
171         OCStackResult unregisterResource(const OCResourceHandle& resourceHandle)
172         {
173             return OCPlatform_impl::Instance().unregisterResource(resourceHandle);
174         }
175
176         OCStackResult unbindResource(OCResourceHandle collectionHandle,
177                                  OCResourceHandle resourceHandle)
178         {
179             return OCPlatform_impl::Instance().unbindResource(collectionHandle, resourceHandle);
180         }
181
182         OCStackResult unbindResources(const OCResourceHandle collectionHandle,
183                                  const std::vector<OCResourceHandle>& resourceHandles)
184         {
185             return OCPlatform_impl::Instance().unbindResources(collectionHandle, resourceHandles);
186         }
187
188         OCStackResult bindResource(const OCResourceHandle collectionHandle,
189                                  const OCResourceHandle resourceHandle)
190         {
191             return OCPlatform_impl::Instance().bindResource(collectionHandle, resourceHandle);
192         }
193
194         OCStackResult bindResources(const OCResourceHandle collectionHandle,
195                                  const std::vector<OCResourceHandle>& resourceHandles
196                                  )
197         {
198             return OCPlatform_impl::Instance().bindResources(collectionHandle, resourceHandles);
199         }
200
201         OCStackResult bindTypeToResource(const OCResourceHandle& resourceHandle,
202                                  const std::string& resourceTypeName)
203         {
204             return OCPlatform_impl::Instance().bindTypeToResource(resourceHandle,resourceTypeName);
205         }
206
207         OCStackResult bindInterfaceToResource(const OCResourceHandle& resourceHandle,
208                                  const std::string& resourceInterfaceName)
209         {
210             return OCPlatform_impl::Instance().bindInterfaceToResource(resourceHandle,
211                                                              resourceInterfaceName);
212         }
213
214         OCStackResult startPresence(const unsigned int announceDurationSeconds)
215         {
216             return OCPlatform_impl::Instance().startPresence(announceDurationSeconds);
217         }
218
219         OCStackResult stopPresence()
220         {
221             return OCPlatform_impl::Instance().stopPresence();
222         }
223
224         OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
225                                      const std::string& host,
226                                      OCConnectivityType connectivityType,
227                                      SubscribeCallback presenceHandler)
228         {
229             return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
230                                                              connectivityType, presenceHandler);
231         }
232
233         OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
234                                      const std::string& host,
235                                      const std::string& resourceType,
236                                      OCConnectivityType connectivityType,
237                                      SubscribeCallback presenceHandler)
238         {
239             return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
240                                              resourceType, connectivityType, presenceHandler);
241         }
242
243         OCStackResult unsubscribePresence(OCPresenceHandle presenceHandle)
244         {
245             return OCPlatform_impl::Instance().unsubscribePresence(presenceHandle);
246         }
247
248         OCStackResult sendResponse(const std::shared_ptr<OCResourceResponse> pResponse)
249         {
250             return OCPlatform_impl::Instance().sendResponse(pResponse);
251         }
252
253         OCStackResult findDirectPairingDevices(unsigned short waittime,
254                                          GetDirectPairedCallback directPairingHandler)
255         {
256             return OCPlatform_impl::Instance().findDirectPairingDevices(waittime,
257                                          directPairingHandler);
258         }
259
260         OCStackResult getDirectPairedDevices(GetDirectPairedCallback directPairingHandler)
261         {
262             return OCPlatform_impl::Instance().getDirectPairedDevices(directPairingHandler);
263         }
264
265         OCStackResult doDirectPairing(std::shared_ptr<OCDirectPairing> peer, OCPrm_t pmSel,
266                                  const std::string& pinNumber,
267                                  DirectPairingCallback resultCallback)
268         {
269             return OCPlatform_impl::Instance().doDirectPairing(peer, pmSel,
270                                              pinNumber, resultCallback);
271         }
272
273     } // namespace OCPlatform
274 } //namespace OC
275