Imported Upstream version 0.9.1
[platform/upstream/iotivity.git] / service / things-manager / sdk / java / src / org / iotivity / service / tm / ThingsManagerNativeInterface.java
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    ThingsManagerNativeInterface.java
22  *
23  * @brief     This file provides a class which provides a set of native functions relating to group
24  *        management, synchronization of group, configuration of things, and
25  *        diagnostics about things.
26  */
27
28 package org.iotivity.service.tm;
29
30 import java.util.Map;
31 import java.util.Vector;
32
33 import org.iotivity.base.OcResource;
34 import org.iotivity.base.OcResourceHandle;
35
36 /**
37  * This class provides a set of native functions relating to group
38  * management, synchronization of group, configuration of things, and
39  * diagnostics about things.
40  *
41  */
42 class ThingsManagerNativeInterface {
43     /**
44      * Native function for discoverying candidate resources.
45      *
46      * @param resourceTypes
47      *            - required resource types(called "candidate")
48      * @param waitTime
49      *            - Delay time in seconds to add before starting to find the
50      *            resources in network.
51      *
52      * @return OCStackResult - return value of this API. It returns OC_STACK_OK
53      *         if success.
54      *
55      */
56     public static native int findCandidateResources(
57             Vector<String> resourceTypes, int waitTime);
58
59     /**
60      * Native function for subscribing child's state.
61      *
62      * @param resource
63      *            - collection resource for subscribing presence of all child
64      *            resources.
65      *
66      * @return OCStackResult - return value of this API. It returns OC_STACK_OK
67      *         if success.
68      *
69      */
70     public static native int subscribeCollectionPresence(OcResource resource);
71
72     /**
73      * Native function for register and bind resource to group.
74      *
75      * @param resource
76      *            - resource for register and bind to group. It has all data.
77      * @param collectionHandle
78      *            - collection resource handle. It will be added child resource.
79      *
80      * @return OcResourceHandle - Child resource handle.
81      *
82      */
83     public static native OcResourceHandle bindResourceToGroup(OcResource resource,
84             OcResourceHandle collectionHandle);
85
86     /**
87      * Native function for finding a specific remote group when a resource tries
88      * to join a group. Callback is called when a group is found or not.
89      *
90      * @param collectionResourceTypes
91      *            - resource types of a group to find and join
92      *
93      * @return OCStackResult - return value of this API. It returns OC_STACK_OK
94      *         if success.
95      *
96      */
97     public static native int findGroup(Vector<String> collectionResourceTypes);
98
99     /**
100      * Native function for creating a new group.
101      *
102      * @param collectionResourceType
103      *            - resource type of a group to create
104      *
105      * @return OCStackResult - return value of this API. It returns OC_STACK_OK
106      *         if success.
107      */
108     public static native int createGroup(String collectionResourceType);
109
110     /**
111      * Native function for joining a group. This API is used when a resource
112      * that has a group tries to find a specific remote resource and makes it
113      * join a group.
114      *
115      * @param collectionResourceType
116      *            - resource type of a group to join.
117      * @param resourceHandle
118      *            - resource handle to join a group.
119      *
120      * @return OCStackResult - return value of this API. It returns OC_STACK_OK
121      *         if success.
122      *
123      */
124     public static native int joinGroup(String collectionResourceType,
125             OcResourceHandle resourceHandle);
126
127     /**
128      * Native function for joining a group. This is used when a resource that
129      * doesn't have a group tries to find and join a specific remote group.
130      *
131      * @param resource
132      *            - group resource to join.
133      * @param resourceHandle
134      *            - resource handle to join a group.
135      *
136      * @return OCStackResult - return value of this API. It returns OC_STACK_OK
137      *         if success.
138      *
139      */
140     public static native int joinGroup(OcResource resource,
141             OcResourceHandle resourceHandle);
142
143     /**
144      * Native function for leaving a joined group.
145      *
146      * @param collectionResourceType
147      *            - resource type of a group to leave.
148      * @param resourceHandle
149      *            - resource handle to leave a group.
150      *
151      * @return OCStackResult - return value of this API. It returns OC_STACK_OK
152      *         if success.
153      *
154      */
155     public static native int leaveGroup(String collectionResourceType,
156             OcResourceHandle resourceHandle);
157
158     /**
159      * Native function for leaving a joined group.
160      *
161      * @param resource
162      *            - resource of a group to leave.
163      * @param collectionResourceType
164      *            - resource type of a group to leave.
165      * @param resourceHandle
166      *            - resource handle to leave a group.
167      *
168      * @return OCStackResult - return value of this API. It returns OC_STACK_OK
169      *         if success.
170      *
171      */
172     public static native int leaveGroup(OcResource resource,
173             String collectionResourceType, OcResourceHandle resourceHandle);
174
175     /**
176      * Native function for deleting a group.
177      *
178      * @param collectionResourceType
179      *            - resource type of a group to delete.
180      *
181      *
182      */
183     public static native void deleteGroup(String collectionResourceType);
184
185     /**
186      * Native function for getting a list of joined groups.
187      *
188      * @return Returns group resource type and group resource handle as a map
189      *         table.
190      *
191      */
192     public static native Map<String, OcResourceHandle> getGroupList();
193
194     /**
195      * Native function for updating configuration value of multiple things of a
196      * target group or a single thing.
197      *
198      * @param resource
199      *            - resource representing the target group or the single thing.
200      * @param configurations
201      *            - ConfigurationUnit: a nickname of attribute of target
202      *            resource (e.g., installed location, currency, (IP)address)
203      *            Value : a value to be updated
204      *
205      * @return OCStackResult - return value of this API. It returns OC_STACK_OK
206      *         if success.
207      *
208      */
209     public static native int updateConfigurations(OcResource resource,
210             Map<String, String> configurations);
211
212     /**
213      * Native function for getting configuration value of multiple things of a
214      * target group or a single thing.
215      *
216      * @param resource
217      *            - resource representing the target group or the single thing.
218      * @param configurations
219      *            - ConfigurationUnit: a nickname of attribute of target
220      *            resource.
221      *
222      * @return OCStackResult - return value of this API. It returns OC_STACK_OK
223      *         if success.
224      *
225      */
226     public static native int getConfigurations(OcResource resource,
227             Vector<String> configurations);
228
229     /**
230      * Native function for showing the list of supported configuration units
231      * (configurable parameters)
232      *
233      * @return Returns the configuration list in JSON format.
234      *
235      */
236     public static native String getListOfSupportedConfigurationUnits();
237
238     /**
239      * Native function for bootstrapping system configuration parameters from a
240      * bootstrap server.
241      *
242      * @return OCStackResult - return value of this API. It returns OC_STACK_OK
243      *         if success.
244      */
245     public static native int doBootstrap();
246
247     /**
248      * Native function to let thing(device) reboot. The target thing could be a
249      * group of multiple things or a single thing.
250      *
251      * @param resource
252      *            - resource pointer representing the target group
253      *
254      * @return OCStackResult - return value of this API. It returns OC_STACK_OK
255      *         if success
256      */
257     public static native int reboot(OcResource resource);
258
259     /**
260      * Native function for factory reset on thing(device). The target thing
261      * could be a group of multiple things or a single thing.
262      *
263      * @param resource
264      *            - resource pointer representing the target group
265      *
266      * @return OCStackResult - return value of this API. It returns OC_STACK_OK
267      *         if success.
268      */
269     public static native int factoryReset(OcResource resource);
270
271     /**
272      * Native function for adding an Action Set. Callback is called when the
273      * response of PUT operation arrives.
274      *
275      * @param resource
276      *            - resource pointer of the group resource
277      * @param actionSet
278      *            - pointer of Action Set
279      *
280      * @return OCStackResult - return value of this API. It returns OC_STACK_OK
281      *         if success.
282      */
283     public static native int addActionSet(OcResource resource,
284             ActionSet actionSet);
285
286     /**
287      * Native function for executing the Action Set. Callback is called when the
288      * response of POST operation arrives.
289      *
290      * @param resource
291      *            - resource pointer of the group resource
292      * @param actionsetName
293      *            - Action Set name for removing the Action set
294      *
295      * @return OCStackResult - return value of this API. It returns OC_STACK_OK
296      *         if success.
297      */
298     public static native int executeActionSet(OcResource resource,
299             String actionsetName);
300
301     /**
302      * Native function for executing the Action Set. Callback is called when the
303      * response of POST operation arrives.
304      *
305      * @param resource
306      *            - resource pointer of the group resource
307      * @param actionsetName
308      *            - Action Set name for removing the Action set
309      * @param delay
310      *            - waiting time for until action set run.
311      *
312      * @return OCStackResult - return value of this API. It returns OC_STACK_OK
313      *         if success.
314      */
315     public static native int executeActionSet(OcResource resource,
316             String actionsetName, long delay);
317
318     /**
319      * Native function for cancelling the Action Set. Callback is called when
320      * the response of POST operation arrives.
321      *
322      * @param resource
323      *            - resource pointer of the group resource
324      * @param actionsetName
325      *            - Action Set name for removing the Action set
326      *
327      * @return OCStackResult - return value of this API. It returns OC_STACK_OK
328      *         if success.
329      */
330     public static native int cancelActionSet(OcResource resource,
331             String actionsetName);
332
333     /**
334      * Native function for reading the Action Set. Callback is called when the
335      * response of GET operation arrives.
336      *
337      * @param resource
338      *            - resource pointer of the group resource
339      * @param actionsetName
340      *            - Action Set name for removing the Action set
341      *
342      * @return OCStackResult - return value of this API. It returns OC_STACK_OK
343      *         if success.
344      */
345     public static native int getActionSet(OcResource resource,
346             String actionsetName);
347
348     /**
349      * Native function for removing the action set. Callback is called when the
350      * response of POST operation arrives.
351      *
352      * @param resource
353      *            - resource pointer of the group resource
354      * @param actionsetName
355      *            - Action Set name for removing the Action set
356      *
357      * @return OCStackResult - return value of this API. It returns OC_STACK_OK
358      *         if success.
359      */
360     public static native int deleteActionSet(OcResource resource,
361             String actionsetName);
362 }