Merge remote-tracking branch 'origin/master' into generic-java
[iotivity.git] / java / jni / JniOcPlatform.h
1 /*
2 * //******************************************************************
3 * //
4 * // Copyright 2015 Intel Corporation.
5 * //
6 * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 * //
8 * // Licensed under the Apache License, Version 2.0 (the "License");
9 * // you may not use this file except in compliance with the License.
10 * // You may obtain a copy of the License at
11 * //
12 * //      http://www.apache.org/licenses/LICENSE-2.0
13 * //
14 * // Unless required by applicable law or agreed to in writing, software
15 * // distributed under the License is distributed on an "AS IS" BASIS,
16 * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * // See the License for the specific language governing permissions and
18 * // limitations under the License.
19 * //
20 * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 */
22 #include "JniOcStack.h"
23 #include "JniOnResourceFoundListener.h"
24 #include "JniOnDeviceInfoListener.h"
25 #include "JniOnPlatformInfoListener.h"
26 #include "JniOnDPDevicesFoundListener.h"
27 #include "JniOnDirectPairingListener.h"
28 #include "JniOnPresenceListener.h"
29 #include "JniOnObserveListener.h"
30
31 #include <mutex>
32
33 #ifndef _Included_org_iotivity_base_OcPlatform
34 #define _Included_org_iotivity_base_OcPlatform
35
36 using namespace OC;
37
38 JniOnResourceFoundListener* AddOnResourceFoundListener(JNIEnv* env, jobject jListener);
39 void RemoveOnResourceFoundListener(JNIEnv* env, jobject jListener);
40
41 JniOnDeviceInfoListener* AddOnDeviceInfoListener(JNIEnv* env, jobject jListener);
42 void RemoveOnDeviceInfoListener(JNIEnv* env, jobject jListener);
43
44 JniOnPlatformInfoListener* AddOnPlatformInfoListener(JNIEnv* env, jobject jListener);
45 void RemoveOnPlatformInfoListener(JNIEnv* env, jobject jListener);
46
47 JniOnPresenceListener* AddOnPresenceListener(JNIEnv* env, jobject jListener);
48 void RemoveOnPresenceListener(JNIEnv* env, jobject jListener);
49
50 JniOnObserveListener* AddOnObserveListener(JNIEnv* env, jobject jListener);
51 void RemoveOnObserveListener(JNIEnv* env, jobject jListener);
52
53 JniOnDPDevicesFoundListener* AddOnDPDevicesFoundListener(JNIEnv* env, jobject jListener);
54 void RemoveOnDPDevicesFoundListener(JNIEnv* env, jobject jListener);
55
56 JniOnDirectPairingListener* AddOnDirectPairingListener(JNIEnv* env, jobject jListener);
57 void RemoveOnDirectPairingListener(JNIEnv* env, jobject jListener);
58
59 std::map<jobject, std::pair<JniOnResourceFoundListener*, int>> onResourceFoundListenerMap;
60 std::map<jobject, std::pair<JniOnDeviceInfoListener*, int>> onDeviceInfoListenerMap;
61 std::map<jobject, std::pair<JniOnPlatformInfoListener*, int>> onPlatformInfoListenerMap;
62 std::map<jobject, std::pair<JniOnPresenceListener*, int>> onPresenceListenerMap;
63 std::map<jobject, std::pair<JniOnObserveListener*, int>> onObserveListenerMap;
64 std::map<jobject, std::pair<JniOnDPDevicesFoundListener*, int>> onDPDevicesFoundListenerMap;
65 std::map<jobject, std::pair<JniOnDirectPairingListener*, int>> directPairingListenerMap;
66
67 std::mutex resourceFoundMapLock;
68 std::mutex deviceInfoMapLock;
69 std::mutex platformInfoMapLock;
70 std::mutex presenceMapLock;
71 std::mutex observeMapLock;
72 std::mutex dpDevicesFoundListenerMapLock;
73 std::mutex directPairingListenerMapLock;
74
75 #ifdef __cplusplus
76 extern "C" {
77 #endif
78     /*
79     * Class:     org_iotivity_base_OcPlatform
80     * Method:    configure
81     * Signature: (IILjava/lang/String;II)V
82     */
83     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_configure
84         (JNIEnv *, jclass, jint, jint, jstring, jint, jint, jstring);
85
86     /*
87     * Class:     org_iotivity_base_OcPlatform
88     * Method:    notifyAllObservers0
89     * Signature: (Lorg/iotivity/base/OcResourceHandle;)V
90     */
91     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyAllObservers0
92         (JNIEnv *, jclass, jobject);
93
94     /*
95     * Class:     org_iotivity_base_OcPlatform
96     * Method:    notifyAllObservers1
97     * Signature: (Lorg/iotivity/base/OcResourceHandle;I)V
98     */
99     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyAllObservers1
100         (JNIEnv *, jclass, jobject, jint);
101
102     /*
103     * Class:     org_iotivity_base_OcPlatform
104     * Method:    notifyListOfObservers2
105     * Signature: (Lorg/iotivity/base/OcResourceHandle;[BLorg/iotivity/base/OcResourceResponse;)V
106     */
107     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyListOfObservers2
108         (JNIEnv *, jclass, jobject, jbyteArray, jobject);
109
110     /*
111     * Class:     org_iotivity_base_OcPlatform
112     * Method:    notifyListOfObservers3
113     * Signature: (Lorg/iotivity/base/OcResourceHandle;[BLorg/iotivity/base/OcResourceResponse;I)V
114     */
115     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyListOfObservers3
116         (JNIEnv *, jclass, jobject, jbyteArray, jobject, jint);
117
118     /*
119     * Class:     org_iotivity_base_OcPlatform
120     * Method:    findResource0
121     * Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnResourceFoundListener;)V
122     */
123     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_findResource0
124         (JNIEnv *, jclass, jstring, jstring, jint, jobject);
125
126     /*
127     * Class:     org_iotivity_base_OcPlatform
128     * Method:    findResource1
129     * Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnResourceFoundListener;I)V
130     */
131     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_findResource1
132         (JNIEnv *, jclass, jstring, jstring, jint, jobject, jint);
133
134     /*
135     * Class:     org_iotivity_base_OcPlatform
136     * Method:    getDeviceInfo0
137     * Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnDeviceFoundListener;)V
138     */
139     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getDeviceInfo0
140         (JNIEnv *, jclass, jstring, jstring, jint, jobject);
141
142     /*
143     * Class:     org_iotivity_base_OcPlatform
144     * Method:    getDeviceInfo1
145     * Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnDeviceFoundListener;I)V
146     */
147     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getDeviceInfo1
148         (JNIEnv *, jclass, jstring, jstring, jint, jobject, jint);
149
150     /*
151      * Class:     org_iotivity_base_OcPlatform
152      * Method:    getPlatformInfo0
153      * Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnPlatformFoundListener;)V
154      */
155      JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getPlatformInfo0
156         (JNIEnv *, jclass, jstring, jstring, jint, jobject);
157
158     /*
159      * Class:     org_iotivity_base_OcPlatform
160      * Method:    getPlatformInfo1
161      * Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnPlatformFoundListener;I)V
162      */
163      JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getPlatformInfo1
164         (JNIEnv *, jclass, jstring, jstring, jint, jobject, jint);
165
166     /*
167     * Class:     org_iotivity_base_OcPlatform
168     * Method:    registerResource0
169     * Signature: (Lorg/iotivity/base/OcResource;)Lorg/iotivity/base/OcResourceHandle;
170     */
171     JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_registerResource0
172         (JNIEnv *, jclass, jobject);
173
174     /*
175     * Class:     org_iotivity_base_OcPlatform
176     * Method:    registerResource1
177     * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcPlatform/EntityHandler;I)Lorg/iotivity/base/OcResourceHandle;
178     */
179     JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_registerResource1
180         (JNIEnv *, jclass, jstring, jstring, jstring, jobject, jint);
181
182     /*
183     * Class:     org_iotivity_base_OcPlatform
184     * Method:    registerDeviceInfo0
185     * Signature: (Ljava/lang/String;[Ljava/lang/String;)V
186     */
187     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_registerDeviceInfo0
188         (JNIEnv *, jclass, jstring, jobjectArray);
189
190     /*
191     * Class:     org_iotivity_base_OcPlatform
192     * Method:    registerPlatformInfo0
193     * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
194     */
195     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_registerPlatformInfo0
196         (JNIEnv *, jclass, jstring, jstring, jstring, jstring, jstring, jstring, jstring, jstring, jstring, jstring, jstring);
197
198     /*
199     * Class:     org_iotivity_base_OcPlatform
200     * Method:    setPropertyValue0
201     * Signature: (Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)V
202     */
203     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_setPropertyValue0
204         (JNIEnv *, jclass, jint, jstring, jobjectArray);
205
206     /*
207     * Class:     org_iotivity_base_OcPlatform
208     * Method:    setPropertyValue1
209     * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
210     */
211     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_setPropertyValue1
212         (JNIEnv *, jclass, jint, jstring, jstring);
213
214     /*
215     * Class:     org_iotivity_base_OcPlatform
216     * Method:    getPropertyValue0
217     * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
218     */
219     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getPropertyValue0
220         (JNIEnv *, jint, jstring, jstring);
221
222     /*
223     * Class:     org_iotivity_base_OcPlatform
224     * Method:    unregisterResource0
225     * Signature: (Lorg/iotivity/base/OcResourceHandle;)V
226     */
227     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unregisterResource0
228         (JNIEnv *, jclass, jobject);
229
230     /*
231     * Class:     org_iotivity_base_OcPlatform
232     * Method:    bindResource0
233     * Signature: (Lorg/iotivity/base/OcResourceHandle;Lorg/iotivity/base/OcResourceHandle;)V
234     */
235     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindResource0
236         (JNIEnv *, jclass, jobject, jobject);
237
238     /*
239     * Class:     org_iotivity_base_OcPlatform
240     * Method:    bindResources0
241     * Signature: (Lorg/iotivity/base/OcResourceHandle;[Lorg/iotivity/base/OcResourceHandle;)V
242     */
243     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindResources0
244         (JNIEnv *, jclass, jobject, jobjectArray);
245
246     /*
247     * Class:     org_iotivity_base_OcPlatform
248     * Method:    unbindResource0
249     * Signature: (Lorg/iotivity/base/OcResourceHandle;Lorg/iotivity/base/OcResourceHandle;)V
250     */
251     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unbindResource0
252         (JNIEnv *, jclass, jobject, jobject);
253
254     /*
255     * Class:     org_iotivity_base_OcPlatform
256     * Method:    unbindResources0
257     * Signature: (Lorg/iotivity/base/OcResourceHandle;[Lorg/iotivity/base/OcResourceHandle;)V
258     */
259     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unbindResources0
260         (JNIEnv *, jclass, jobject, jobjectArray);
261
262     /*
263     * Class:     org_iotivity_base_OcPlatform
264     * Method:    bindTypeToResource0
265     * Signature: (Lorg/iotivity/base/OcResourceHandle;Ljava/lang/String;)V
266     */
267     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindTypeToResource0
268         (JNIEnv *, jclass, jobject, jstring);
269
270     /*
271     * Class:     org_iotivity_base_OcPlatform
272     * Method:    bindInterfaceToResource0
273     * Signature: (Lorg/iotivity/base/OcResourceHandle;Ljava/lang/String;)V
274     */
275     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindInterfaceToResource0
276         (JNIEnv *, jclass, jobject, jstring);
277
278     /*
279     * Class:     org_iotivity_base_OcPlatform
280     * Method:    startPresence0
281     * Signature: (I)V
282     */
283     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_startPresence0
284         (JNIEnv *, jclass, jint);
285
286     /*
287     * Class:     org_iotivity_base_OcPlatform
288     * Method:    stopPresence0
289     * Signature: ()V
290     */
291     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_stopPresence0
292         (JNIEnv *, jclass);
293
294     /*
295     * Class:     org_iotivity_base_OcPlatform
296     * Method:    subscribePresence0
297     * Signature: (Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnPresenceListener;)Lorg/iotivity/base/OcPresenceHandle;
298     */
299     JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_subscribePresence0
300         (JNIEnv *, jclass, jstring, jint, jobject);
301
302     /*
303     * Class:     org_iotivity_base_OcPlatform
304     * Method:    subscribePresence1
305     * Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnPresenceListener;)Lorg/iotivity/base/OcPresenceHandle;
306     */
307     JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_subscribePresence1
308         (JNIEnv *, jclass, jstring, jstring, jint, jobject);
309
310     /*
311     * Class:     org_iotivity_base_OcPlatform
312     * Method:    unsubscribePresence0
313     * Signature: (Lorg/iotivity/base/OcPresenceHandle;)V
314     */
315     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unsubscribePresence0
316         (JNIEnv *, jclass, jobject);
317
318     /*
319     * Class:     org_iotivity_base_OcPlatform
320     * Method:    subscribeDevicePresence0
321     * Signature: (Ljava/lang/String;[Ljava/lang/String;I
322     * Lorg/iotivity/base/OcResource/OnObserveListener;)Lorg/iotivity/base/OcPresenceHandle;
323     */
324     JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_subscribeDevicePresence0
325         (JNIEnv *, jclass, jstring, jobjectArray, jint, jobject);
326
327     /*
328     * Class:     org_iotivity_base_OcPlatform
329     * Method:    constructResourceObject0
330     * Signature: (Ljava/lang/String;Ljava/lang/String;IZ[Ljava/lang/String;[Ljava/lang/String;)Lorg/iotivity/base/OcResource;
331     */
332     JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_constructResourceObject0
333         (JNIEnv *, jclass, jstring, jstring, jint, jboolean, jobjectArray, jobjectArray);
334
335     /*
336     * Class:     org_iotivity_base_OcPlatform0
337     * Method:    sendResponse0
338     * Signature: (Lorg/iotivity/base/OcResourceResponse;)V
339     */
340     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_sendResponse0
341         (JNIEnv *, jclass, jobject);
342
343     /*
344      * Class:     org_iotivity_base_OcPlatform
345      * Method:    findDirectPairingDevices
346      * Signature: (ILorg/iotivity/base/OcPlatform/FindDirectPairingListener;)V
347      */
348     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_findDirectPairingDevices
349         (JNIEnv *, jclass, jint, jobject);
350
351     /*
352      * Class:     org_iotivity_base_OcPlatform
353      * Method:    getDirectPairedDevices
354      * Signature: (Lorg/iotivity/base/OcDirectPairDevice/GetDirectPairedListener;)V
355      */
356     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getDirectPairedDevices
357         (JNIEnv *, jclass, jobject);
358
359     /*
360      * Class:     org_iotivity_base_OcPlatform
361      * Method:    doDirectPairing
362      * Signature: (Lorg/iotivity/base/OcDirectPairDevice;Lorg/iotivity/base/OcPrmType;
363      *           Ljava/lang/String;Lorg/iotivity/base/OcDirectPairDevice/DirectPairingListener;)V
364      */
365     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_doDirectPairing0
366         (JNIEnv *, jclass, jobject, jint, jstring, jobject);
367
368     /*
369     * Class:     org_iotivity_base_OcPlatform
370     * Method:    constructAccountManagerObject0
371     * Signature: (Ljava/lang/String;I)Lorg/iotivity/base/OcAccountManager;
372     */
373     JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_constructAccountManagerObject0
374         (JNIEnv *, jclass, jstring, jint);
375
376     /*
377      * Class:     org_iotivity_base_OcPlatform
378      * Method:    getDeviceId
379      * Signature: (I)V
380      */
381     JNIEXPORT jbyteArray JNICALL Java_org_iotivity_base_OcPlatform_getDeviceId
382         (JNIEnv *, jobject);
383
384     /*
385      * Class:     org_iotivity_base_OcPlatform
386      * Method:    setDeviceId
387      * Signature: (Ljava/lang/byte;)V
388      */
389     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_setDeviceId(
390             JNIEnv *, jobject, jbyteArray);
391
392 #ifdef __cplusplus
393 }
394 #endif
395 #endif