Imported Upstream version 0.9.1
[platform/upstream/iotivity.git] / service / things-manager / sdk / java / jni / tm / inc / jni_things_manager.h
1 /******************************************************************
2  *
3  * Copyright 2015 Samsung Electronics 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 /** @file   jni_things_manager.h
22  *
23  *   @brief  This file contains the declaration of Things Manager service API's
24  *              for JNI implementation
25  */
26
27 #ifndef __JNI_THINGS_MANAGER_H_
28 #define __JNI_THINGS_MANAGER_H_
29
30
31 #include <stdio.h>
32 #include <string.h>
33
34 #include <jni.h>
35 #include <jni_string.h>
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40
41 /**
42  * API for discoverying candidate resources.
43  *
44  * @param resourceTypes - required resource types(called "candidate")
45  * @param waitSec - Delay time in seconds to add before starting to find the resources in network.
46  *
47  * @return OCStackResult - return value of this API.
48  *                         It returns OC_STACK_OK if success.
49  *
50  * NOTE: OCStackResult is defined in ocstack.h.
51  */
52 JNIEXPORT jint JNICALL JNIThingsManagerFindCandidateResource
53 (JNIEnv *env, jobject interfaceObject, jobject resourceTypes, jint waitSec);
54
55 /**
56  * API for subscribing child's state.
57  *
58  * @param resource - collection resource for subscribing presence of all child resources.
59  *
60  * @return OCStackResult - return value of this API.
61  *                         It returns OC_STACK_OK if success.
62  *
63  * NOTE: OCStackResult is defined in ocstack.h.
64  */
65 JNIEXPORT jint JNICALL JNIThingsManagerSubscribeCollectionPresence
66 (JNIEnv *env, jobject interfaceObject, jobject resource);
67
68 /**
69  * API for register and bind resource to group.
70  *
71  * @param resource - resource for register and bind to group. It has all data.
72  * @param collectionHandle - collection resource handle. It will be added child resource.
73  *
74  * @return childHandle - child resource handle.
75  *
76  * NOTE: OCStackResult is defined in ocstack.h.
77  */
78 JNIEXPORT jobject JNICALL JNIThingsManagerBindResourceToGroup
79 (JNIEnv *env, jobject interfaceObject, jobject resource, jobject collectionHandle);
80
81 /**
82  * API for finding a specific remote group when a resource tries to join a group.
83  * Callback is called when a group is found or not.
84  *
85  * @param resourceTypes - resource types of a group to find and join
86  *
87  * @return OCStackResult - return value of this API.
88  *                         It returns OC_STACK_OK if success.
89  *
90  * NOTE: It return OC_STACK ERROR when It was finding a group.
91  *       You should call this api when the group finding process has stopped.
92  *       OCStackResult is defined in ocstack.h.
93  */
94
95 JNIEXPORT jint JNICALL JNIThingsManagerFindGroup
96 (JNIEnv *env, jobject interfaceObject, jobject resourceTypes);
97
98 /**
99  * API for creating a new group.
100  *
101  * @param resourceType - resource type of a group to create
102  *
103  * @return OCStackResult - return value of this API.
104  *                         It returns OC_STACK_OK if success.
105  *
106  * NOTE: OCStackResult is defined in ocstack.h.
107  */
108 JNIEXPORT jint JNICALL JNIThingsManagerCreateGroup
109 (JNIEnv *env, jobject interfaceObject, jstring resourceType);
110
111 /**
112  * API for joining a group. This API is used when a resource that has a group tries
113  * to find a specific remote resource and makes it join a group
114  *
115  * @param resourceType - resource type of a group to join.
116  * @param resourceHandle - resource handle to join a group.
117  *
118  * @return OCStackResult - return value of this API.
119  *                         It returns OC_STACK_OK if success.
120  *
121  * NOTE: If you want to join the resource in the remote(other) process, use the API
122  *       jniThingsManagerJoinGroupObject instead of this.
123  *       OCStackResult is defined in ocstack.h.
124  */
125 JNIEXPORT jint JNICALL JNIThingsManagerJoinGroupString
126 (JNIEnv *env, jobject interfaceObject, jstring resourceType, jobject resourceHandle);
127
128 /**
129  * API for joining a group. This API is used when a resource that
130  * doesn't have a group tries to find and join a specific remote group.
131  *
132  * @param resource - group resource pointer to join.
133  * @param resourceHandle - resource handle to join a group.
134  *
135  * @return OCStackResult - return value of this API.
136  *                         It returns OC_STACK_OK if success.
137  *
138  * NOTE: NOTE: If you want to join the resource in the same process, use the API
139  *       jniThingsManagerJoinGroupString instead of this.
140  *       OCStackResult is defined in ocstack.h.
141  */
142 JNIEXPORT jint JNICALL JNIThingsManagerJoinGroupObject
143 (JNIEnv *env, jobject interfaceObject, jobject resource, jobject resourceHandle);
144
145 /**
146  * API for leaving a joined group.
147  *
148  * @param resourceType - resource type of a group to leave.
149  * @param resourceHandle - resource handle to join a group.
150  *
151  * @return OCStackResult - return value of this API.
152  *                         It returns OC_STACK_OK if success.
153  *
154  * NOTE: OCStackResult is defined in ocstack.h.
155  */
156 JNIEXPORT jint JNICALL JNIThingsManagerLeaveGroup
157 (JNIEnv *env, jobject interfaceObject, jstring resourceType, jobject resourceHandle);
158
159 /**
160  * API for leaving a joined group.
161  *
162  * @param resource - resource of a group to leave.
163  * @param resourceType - resource type of a group to leave.
164  * @param resourceHandle - resource handle to join a group.
165  *
166  * @return OCStackResult - return value of this API.
167  *                         It returns OC_STACK_OK if success.
168  *
169  * NOTE: OCStackResult is defined in ocstack.h.
170  */
171 JNIEXPORT jint JNICALL JNIThingsManagerLeaveGroupForResource
172 (JNIEnv *env, jobject interfaceObject, jobject resource, jstring resourceType,
173  jobject resourceHandle);
174 /**
175  * API for deleting a group.
176  *
177  * @param collectionResourceType - resource type of a group to delete.
178  *
179  * @return void
180  */
181 JNIEXPORT void JNICALL JNIThingsManagerDeleteGroup
182 (JNIEnv *env, jobject interfaceObject, jstring collectionResourceType);
183
184 /**
185  * API for getting a list of joined groups.
186  *
187  * @return std::map - return value of this API.
188  *                  It returns group resource type and group resource handle as a map type.
189  */
190 JNIEXPORT jobject JNICALL JNIThingsManagerGetGroupList
191 (JNIEnv *env, jobject interfaceObject);
192
193 /**
194  * API for updating configuration value of multiple things of a target group
195  * or a single thing.
196  * Before using the below function, a developer should acquire a resource pointer of
197  * (collection) resource that he wants to send a request by calling findResource() function
198  * provided in OCPlatform. And he should also notice a "Configuration Name" term which
199  * represents a nickname of a target attribute of a resource that he wants to update.
200  * The base motivation to introduce the term is to avoid a usage of URI to access a resource
201  * from a developer. Thus, a developer should know which configuration names are supported
202  * by Things Configuration class and what the configuration name means.
203  * To get a list of supported configuration names,  use getListOfSupportedConfigurationUnits()
204  * function, which provides the list in JSON format.
205  *
206  * @param resource - resource pointer representing the target group or the single thing.
207  * @param configurations - ConfigurationUnit: a nickname of attribute of target resource
208  *                         (e.g., installedlocation, currency, (IP)address)
209  *                         Value : a value to be updated
210  *
211  * @return OCStackResult - return value of this API.
212  *                         It returns OC_STACK_OK if success.
213  *
214  * NOTE: OCStackResult is defined in ocstack.h.
215  */
216 JNIEXPORT jint JNICALL JNIThingsManagerUpdateConfigurations
217 (JNIEnv *env, jobject interfaceObject, jobject resource, jobject configurations);
218
219 /**
220  * API for getting configuration value of multiple things of a target group
221  * or a single thing.
222  *
223  * @param resource - resource pointer representing the target group or the single thing.
224  * @param configurations - ConfigurationUnit: a nickname of attribute of target resource.
225  *
226  * @return OCStackResult - return value of this API.
227  *                         It returns OC_STACK_OK if success.
228  *
229  * NOTE: OCStackResult is defined in ocstack.h.
230  */
231 JNIEXPORT jint JNICALL JNIThingsManagerGetConfigurations
232 (JNIEnv *env, jobject interfaceObject, jobject resource, jobject configurations);
233
234 /**
235  * API for showing the list of supported configuration units (configurable parameters)
236  *
237  * @return std::string - return value of this API.
238  *                       It returns the list in JSON format
239  */
240 JNIEXPORT jstring JNICALL JNIThingsManagerGetListOfSupportedConfigurationUnits
241 (JNIEnv *env, jobject interfaceObject);
242
243 /**
244  * API for boostrapping system configuration parameters from a bootstrap server.
245  *
246  * @return OCStackResult - return value of this API.
247  *                         It returns OC_STACK_OK if success.
248  *
249  * NOTE: OCStackResult is defined in ocstack.h.
250  */
251 JNIEXPORT jint JNICALL JNIThingsManagerDoBootstrap
252 (JNIEnv *env, jobject interfaceObject);
253
254 /**
255  * API to let thing(device) reboot.
256  * The target thing could be a group of multiple things or a single thing.
257  *
258  * @param resource - resource type representing the target group
259  *
260  * @return OCStackResult - return value of this API.
261  *                         It returns OC_STACK_OK if success.
262  *
263  * NOTE: OCStackResult is defined in ocstack.h.
264  */
265 JNIEXPORT jint JNICALL JNIThingsManagerReboot
266 (JNIEnv *env, jobject interfaceObject, jobject resource);
267
268 /**
269  * API for factory reset on thing(device).
270  * The target thing could be a group of multiple things or a single thing.
271  *
272  * @param resource - resource type representing the target group
273  *
274  * @return OCStackResult - return value of this API.
275  *                         It returns OC_STACK_OK if success.
276  *
277  * NOTE: OCStackResult is defined in ocstack.h.
278  */
279 JNIEXPORT jint JNICALL JNIThingsManagerFactoryReset
280 (JNIEnv *env, jobject interfaceObject, jobject resource);
281
282 /**
283  * API for adding an Action Set.
284  *
285  * @param resource - resource type representing the target group
286  * @param newActionSet - list of Action Set to be added
287  *
288  * @return OCStackResult - return value of this API.
289  *                         It returns OC_STACK_OK if success.
290  *
291  * NOTE: OCStackResult is defined in ocstack.h.
292  */
293
294 JNIEXPORT jint JNICALL JNIThingsManagerAddActionSet
295 (JNIEnv *env, jobject interfaceObject, jobject resource, jobject newActionSet);
296
297 /**
298  * API for executing the Action Set.
299  *
300  * @param resource - resource type representing the target group
301  * @param actionSetName - Action Set name for executing the Action set
302  *
303  * @return OCStackResult - return value of this API.
304  *                         It returns OC_STACK_OK if success.
305  *
306  * NOTE: OCStackResult is defined in ocstack.h.
307  */
308 JNIEXPORT jint JNICALL JNIThingsManagerExecuteActionSet
309 (JNIEnv *env, jobject interfaceObject, jobject resource, jstring actionSetName);
310
311 /**
312  * API for executing the Action Set.
313  *
314  * @param resource - resource type representing the target group
315  * @param actionSetName - Action Set name for executing the Action set
316  * @param delay - waiting time for until action set run.
317  *
318  * @return OCStackResult - return value of this API.
319  *                         It returns OC_STACK_OK if success.
320  *
321  * NOTE: OCStackResult is defined in ocstack.h.
322  */
323 JNIEXPORT jint JNICALL JNIThingsManagerExecuteActionSetWithDelay
324 (JNIEnv *env, jobject interfaceObject, jobject resource, jstring actionSetName, jlong delay);
325
326 /**
327  * API for cancelling the Action Set.
328  *
329  * @param resource - resource type representing the target group
330  * @param actionSetName - Action Set name for cancelling the Action set
331  *
332  * @return OCStackResult - return value of this API.
333  *                         It returns OC_STACK_OK if success.
334  *
335  * NOTE: OCStackResult is defined in ocstack.h.
336  */
337 JNIEXPORT jint JNICALL JNIThingsManagerCancelActionSet
338 (JNIEnv *env, jobject interfaceObject, jobject resource, jstring actionSetName);
339
340
341 /**
342  * API for reading the Action Set.
343  *
344  * @param resource - resource type representing the target group
345  * @param actionSetName - Action Set name for reading the Action set
346  *
347  * @return OCStackResult - return value of this API.
348  *                         It returns OC_STACK_OK if success.
349  *
350  * NOTE: OCStackResult is defined in ocstack.h.
351  */
352 JNIEXPORT jint JNICALL JNIThingsManagerGetActionSet
353 (JNIEnv *env, jobject interfaceObject, jobject resource, jstring actionSetName);
354
355 /**
356  * API for removing the Action Set.
357  *
358  * @param resource - resource type representing the target group
359  * @param actionSetName - Action Set name for removing the Action set
360  *
361  * @return OCStackResult - return value of this API.
362  *                         It returns OC_STACK_OK if success.
363  *
364  * NOTE: OCStackResult is defined in ocstack.h.
365  */
366 JNIEXPORT jint JNICALL JNIThingsManagerDeleteActionSet
367 (JNIEnv *env, jobject interfaceObject, jobject resource, jstring actionSetName);
368
369 #ifdef __cplusplus
370 }
371 #endif
372 #endif //__JNI_THINGS_MANAGER_H_