Update function name & data struct name in ESRichCommon.h and implement JNI logic...
[platform/upstream/iotivity.git] / service / easy-setup / mediator / richsdk / android / jni / JniRemoteEnrollee.h
1 /******************************************************************
2  *
3  * Copyright 2016 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   JniRemoteEnrollee.h
22  *
23  *   @brief  This file contains the JniRemoteEnrollee class
24  *               & declaration of RemoteEnrollee APIs for JNI implementation
25  */
26
27 #ifndef __JNI_ES_REMOTEENROLLEE_H
28 #define __JNI_ES_REMOTEENROLLEE_H
29
30 #include "RemoteEnrollee.h"
31 #include "ESRichCommon.h"
32 #include "ESException.h"
33
34 #include "JniJvm.h"
35 #include "JniEsUtils.h"
36 #include "JniRequestPropertyDataStatusListener.h"
37 #include "JniSecurityStatusListener.h"
38 #include "JniDataProvisioningStatusListener.h"
39 #include "JniCloudProvisioningStatusListener.h"
40 #include "JniEsListenerManager.h"
41
42 using namespace OIC::Service;
43
44 /**
45  * @class   JniRemoteEnrollee
46  * @brief   This class contains all the APIs for RemoteEnrollee
47  *
48  * NOTE: JNI APIs internally call the APIs of this class.
49  */
50 class JniRemoteEnrollee
51 {
52     public:
53
54         /**
55         *@brief constructor
56         */
57         JniRemoteEnrollee(std::shared_ptr< RemoteEnrollee> remoteEnrollee);
58
59         /**
60          *@brief destructor
61         */
62         ~JniRemoteEnrollee();
63
64         // ***** JNI APIs internally call the APIs of this class ***** //
65         void initRemoteEnrollee(JNIEnv *env);
66         void requestPropertyData(JNIEnv *env, jobject jListener);
67         void startSecurityProvisioning(JNIEnv *env, jobject jListener);
68         void startDataProvisioning(JNIEnv *env, jobject jListener);
69         void startCloudProvisioning(JNIEnv *env, jobject jListener);
70         void setDataProvInfo(JNIEnv *env, jstring jssid, jstring jpwd, jint jauthType,
71                                             jint jencType, jstring jlanguage, jstring jcountry);
72         void setCloudProvInfo(JNIEnv *env, jstring authCode, jstring authProvider, jstring ciServer);
73
74         static JniRemoteEnrollee *getJniRemoteEnrollee(JNIEnv *env, jobject thiz);
75
76         template <class T>
77         T *addStatusListener(JNIEnv *env, jobject jListener)
78         {
79             return JniEsListenerManager<T>().addListener(env, jListener, this);
80         };
81
82         template <class T>
83         void removeStatusListener(JNIEnv *env, jobject jListener)
84         {
85             JniEsListenerManager<T>().removeListener(env, jListener);
86         };
87
88     private:
89         std::shared_ptr<RemoteEnrollee> m_sharedResource;
90
91 };
92
93
94 #ifdef __cplusplus
95 extern "C" {
96 #endif
97
98 /**
99  * API for starting the initRemoteEnrollee process.
100  */
101 JNIEXPORT void JNICALL
102 Java_org_iotivity_service_easysetup_mediator_RemoteEnrollee_nativeInitRemoteEnrollee
103 (JNIEnv *env, jobject jClass);
104
105 /**
106  * API for starting the Request PropertyData process.
107  */
108 JNIEXPORT void JNICALL
109 Java_org_iotivity_service_easysetup_mediator_RemoteEnrollee_nativeRequestPropertyData
110 (JNIEnv *env, jobject jClass, jobject jListener);
111
112 /**
113  * API for starting the Sequrity provisioning process.
114  */
115 JNIEXPORT void JNICALL
116 Java_org_iotivity_service_easysetup_mediator_RemoteEnrollee_nativeStartSecurityProvision
117 (JNIEnv *env, jobject jClass, jobject jListener);
118
119 /**
120  * API for starting the Data provisioning process.
121  */
122 JNIEXPORT void JNICALL
123 Java_org_iotivity_service_easysetup_mediator_RemoteEnrollee_nativeStartDataProvision
124 (JNIEnv *env, jobject jClass);
125
126 /**
127  * API for setting data provisioning information.
128  */
129 JNIEXPORT void JNICALL
130 Java_org_iotivity_service_easysetup_mediator_RemoteEnrollee_nativeSetDataProvInfo
131 (JNIEnv *env, jobject jClass, jstring jssid, jstring jpwd, jint jauthType, jint jencType,
132     jstring jlanguage, jstring jcountry);
133
134 /**
135  * API for setting cloud provisioning information.
136  */
137 JNIEXPORT void JNICALL
138 Java_org_iotivity_service_easysetup_mediator_RemoteEnrollee_nativeSetCloudProvInfo
139 (JNIEnv *env, jobject jClass, jstring jauthCode, jstring jauthProvider, jstring jciServer);
140
141 /**
142  * API for starting the cloud provisioning process.
143  */
144 JNIEXPORT void JNICALL
145 Java_org_iotivity_service_easysetup_mediator_RemoteEnrollee_nativeStartCloudProvisioning
146 (JNIEnv *env, jobject jClass, jobject jListener);
147
148 #ifdef __cplusplus
149 }
150 #endif
151 #endif // __JNI_ES_REMOTEENROLLEE_H