b916490d8f10285c1c0bd3aad27beda94fd5b07a
[platform/upstream/iotivity.git] / android / android_api / base / jni / JniOcRequestHandle.cpp
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 "JniOcRequestHandle.h"
23
24 JniOcRequestHandle::JniOcRequestHandle(OCRequestHandle requestHandle) : m_requestHandle(requestHandle)
25 {}
26
27 JniOcRequestHandle::~JniOcRequestHandle()
28 {
29     LOGD("~JniOcRequestHandle()");
30 }
31
32 JniOcRequestHandle* JniOcRequestHandle::getJniOcRequestHandlePtr
33 (JNIEnv *env, jobject thiz)
34 {
35     JniOcRequestHandle *handle = GetHandle<JniOcRequestHandle>(env, thiz);
36     if (env->ExceptionCheck())
37     {
38         LOGE("Failed to get native handle from OcRequestHandle");
39     }
40     if (!handle)
41     {
42         ThrowOcException(JNI_NO_NATIVE_POINTER, "");
43     }
44     return handle;
45 }
46
47 OCRequestHandle JniOcRequestHandle::getOCRequestHandle()
48 {
49     return this->m_requestHandle;
50 }
51
52 /*
53 * Class:     org_iotivity_base_OcRequestHandle
54 * Method:    dispose
55 * Signature: ()V
56 */
57 JNIEXPORT void JNICALL Java_org_iotivity_base_OcRequestHandle_dispose
58 (JNIEnv *env, jobject thiz)
59 {
60     LOGD("OcRequestHandle_dispose");
61     JniOcRequestHandle *handle = JniOcRequestHandle::getJniOcRequestHandlePtr(env, thiz);
62     delete handle;
63 }