1 /******************************************************************
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
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 /** @file jni_things_manager.h
23 * @brief This file contains the declaration of Things Manager service API's
24 * for JNI implementation
27 #ifndef __JNI_THINGS_MANAGER_H_
28 #define __JNI_THINGS_MANAGER_H_
35 #include <jni_string.h>
42 * API for discoverying candidate resources.
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.
47 * @return OCStackResult - return value of this API.
48 * It returns OC_STACK_OK if success.
50 * NOTE: OCStackResult is defined in ocstack.h.
52 JNIEXPORT jint JNICALL JNIThingsManagerFindCandidateResource
53 (JNIEnv *env, jobject interfaceObject, jobject resourceTypes, jint waitSec);
56 * API for subscribing child's state.
58 * @param resource - collection resource for subscribing presence of all child resources.
60 * @return OCStackResult - return value of this API.
61 * It returns OC_STACK_OK if success.
63 * NOTE: OCStackResult is defined in ocstack.h.
65 JNIEXPORT jint JNICALL JNIThingsManagerSubscribeCollectionPresence
66 (JNIEnv *env, jobject interfaceObject, jobject resource);
69 * API for register and bind resource to group.
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.
74 * @return childHandle - child resource handle.
76 * NOTE: OCStackResult is defined in ocstack.h.
78 JNIEXPORT jobject JNICALL JNIThingsManagerBindResourceToGroup
79 (JNIEnv *env, jobject interfaceObject, jobject resource, jobject collectionHandle);
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.
85 * @param resourceTypes - resource types of a group to find and join
87 * @return OCStackResult - return value of this API.
88 * It returns OC_STACK_OK if success.
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.
95 JNIEXPORT jint JNICALL JNIThingsManagerFindGroup
96 (JNIEnv *env, jobject interfaceObject, jobject resourceTypes);
99 * API for creating a new group.
101 * @param resourceType - resource type of a group to create
103 * @return OCStackResult - return value of this API.
104 * It returns OC_STACK_OK if success.
106 * NOTE: OCStackResult is defined in ocstack.h.
108 JNIEXPORT jint JNICALL JNIThingsManagerCreateGroup
109 (JNIEnv *env, jobject interfaceObject, jstring resourceType);
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
115 * @param resourceType - resource type of a group to join.
116 * @param resourceHandle - resource handle to join a group.
118 * @return OCStackResult - return value of this API.
119 * It returns OC_STACK_OK if success.
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.
125 JNIEXPORT jint JNICALL JNIThingsManagerJoinGroupString
126 (JNIEnv *env, jobject interfaceObject, jstring resourceType, jobject resourceHandle);
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.
132 * @param resource - group resource pointer to join.
133 * @param resourceHandle - resource handle to join a group.
135 * @return OCStackResult - return value of this API.
136 * It returns OC_STACK_OK if success.
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.
142 JNIEXPORT jint JNICALL JNIThingsManagerJoinGroupObject
143 (JNIEnv *env, jobject interfaceObject, jobject resource, jobject resourceHandle);
146 * API for leaving a joined group.
148 * @param resourceType - resource type of a group to leave.
149 * @param resourceHandle - resource handle to join a group.
151 * @return OCStackResult - return value of this API.
152 * It returns OC_STACK_OK if success.
154 * NOTE: OCStackResult is defined in ocstack.h.
156 JNIEXPORT jint JNICALL JNIThingsManagerLeaveGroup
157 (JNIEnv *env, jobject interfaceObject, jstring resourceType, jobject resourceHandle);
160 * API for leaving a joined group.
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.
166 * @return OCStackResult - return value of this API.
167 * It returns OC_STACK_OK if success.
169 * NOTE: OCStackResult is defined in ocstack.h.
171 JNIEXPORT jint JNICALL JNIThingsManagerLeaveGroupForResource
172 (JNIEnv *env, jobject interfaceObject, jobject resource, jstring resourceType,
173 jobject resourceHandle);
175 * API for deleting a group.
177 * @param collectionResourceType - resource type of a group to delete.
181 JNIEXPORT void JNICALL JNIThingsManagerDeleteGroup
182 (JNIEnv *env, jobject interfaceObject, jstring collectionResourceType);
185 * API for getting a list of joined groups.
187 * @return std::map - return value of this API.
188 * It returns group resource type and group resource handle as a map type.
190 JNIEXPORT jobject JNICALL JNIThingsManagerGetGroupList
191 (JNIEnv *env, jobject interfaceObject);
194 * API for updating configuration value of multiple things of a target group
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.
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
211 * @return OCStackResult - return value of this API.
212 * It returns OC_STACK_OK if success.
214 * NOTE: OCStackResult is defined in ocstack.h.
216 JNIEXPORT jint JNICALL JNIThingsManagerUpdateConfigurations
217 (JNIEnv *env, jobject interfaceObject, jobject resource, jobject configurations);
220 * API for getting configuration value of multiple things of a target group
223 * @param resource - resource pointer representing the target group or the single thing.
224 * @param configurations - ConfigurationUnit: a nickname of attribute of target resource.
226 * @return OCStackResult - return value of this API.
227 * It returns OC_STACK_OK if success.
229 * NOTE: OCStackResult is defined in ocstack.h.
231 JNIEXPORT jint JNICALL JNIThingsManagerGetConfigurations
232 (JNIEnv *env, jobject interfaceObject, jobject resource, jobject configurations);
235 * API for showing the list of supported configuration units (configurable parameters)
237 * @return std::string - return value of this API.
238 * It returns the list in JSON format
240 JNIEXPORT jstring JNICALL JNIThingsManagerGetListOfSupportedConfigurationUnits
241 (JNIEnv *env, jobject interfaceObject);
244 * API for boostrapping system configuration parameters from a bootstrap server.
246 * @return OCStackResult - return value of this API.
247 * It returns OC_STACK_OK if success.
249 * NOTE: OCStackResult is defined in ocstack.h.
251 JNIEXPORT jint JNICALL JNIThingsManagerDoBootstrap
252 (JNIEnv *env, jobject interfaceObject);
255 * API to let thing(device) reboot.
256 * The target thing could be a group of multiple things or a single thing.
258 * @param resource - resource type representing the target group
260 * @return OCStackResult - return value of this API.
261 * It returns OC_STACK_OK if success.
263 * NOTE: OCStackResult is defined in ocstack.h.
265 JNIEXPORT jint JNICALL JNIThingsManagerReboot
266 (JNIEnv *env, jobject interfaceObject, jobject resource);
269 * API for factory reset on thing(device).
270 * The target thing could be a group of multiple things or a single thing.
272 * @param resource - resource type representing the target group
274 * @return OCStackResult - return value of this API.
275 * It returns OC_STACK_OK if success.
277 * NOTE: OCStackResult is defined in ocstack.h.
279 JNIEXPORT jint JNICALL JNIThingsManagerFactoryReset
280 (JNIEnv *env, jobject interfaceObject, jobject resource);
283 * API for adding an Action Set.
285 * @param resource - resource type representing the target group
286 * @param newActionSet - list of Action Set to be added
288 * @return OCStackResult - return value of this API.
289 * It returns OC_STACK_OK if success.
291 * NOTE: OCStackResult is defined in ocstack.h.
294 JNIEXPORT jint JNICALL JNIThingsManagerAddActionSet
295 (JNIEnv *env, jobject interfaceObject, jobject resource, jobject newActionSet);
298 * API for executing the Action Set.
300 * @param resource - resource type representing the target group
301 * @param actionSetName - Action Set name for executing the Action set
303 * @return OCStackResult - return value of this API.
304 * It returns OC_STACK_OK if success.
306 * NOTE: OCStackResult is defined in ocstack.h.
308 JNIEXPORT jint JNICALL JNIThingsManagerExecuteActionSet
309 (JNIEnv *env, jobject interfaceObject, jobject resource, jstring actionSetName);
312 * API for executing the Action Set.
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.
318 * @return OCStackResult - return value of this API.
319 * It returns OC_STACK_OK if success.
321 * NOTE: OCStackResult is defined in ocstack.h.
323 JNIEXPORT jint JNICALL JNIThingsManagerExecuteActionSetWithDelay
324 (JNIEnv *env, jobject interfaceObject, jobject resource, jstring actionSetName, jlong delay);
327 * API for cancelling the Action Set.
329 * @param resource - resource type representing the target group
330 * @param actionSetName - Action Set name for cancelling the Action set
332 * @return OCStackResult - return value of this API.
333 * It returns OC_STACK_OK if success.
335 * NOTE: OCStackResult is defined in ocstack.h.
337 JNIEXPORT jint JNICALL JNIThingsManagerCancelActionSet
338 (JNIEnv *env, jobject interfaceObject, jobject resource, jstring actionSetName);
342 * API for reading the Action Set.
344 * @param resource - resource type representing the target group
345 * @param actionSetName - Action Set name for reading the Action set
347 * @return OCStackResult - return value of this API.
348 * It returns OC_STACK_OK if success.
350 * NOTE: OCStackResult is defined in ocstack.h.
352 JNIEXPORT jint JNICALL JNIThingsManagerGetActionSet
353 (JNIEnv *env, jobject interfaceObject, jobject resource, jstring actionSetName);
356 * API for removing the Action Set.
358 * @param resource - resource type representing the target group
359 * @param actionSetName - Action Set name for removing the Action set
361 * @return OCStackResult - return value of this API.
362 * It returns OC_STACK_OK if success.
364 * NOTE: OCStackResult is defined in ocstack.h.
366 JNIEXPORT jint JNICALL JNIThingsManagerDeleteActionSet
367 (JNIEnv *env, jobject interfaceObject, jobject resource, jstring actionSetName);
372 #endif //__JNI_THINGS_MANAGER_H_