Merge branch 'master' into notification-service 69/9269/1
authoruzchoi <uzchoi@samsung.com>
Mon, 11 Jul 2016 02:39:29 +0000 (11:39 +0900)
committeruzchoi <uzchoi@samsung.com>
Mon, 11 Jul 2016 02:43:44 +0000 (11:43 +0900)
Change-Id: I968cfa282e3ef1e3132ea0fbe93a7098115c7193
Signed-off-by: uzchoi <uzchoi@samsung.com>
471 files changed:
.gbs.conf [new file with mode: 0644]
.gitignore
SConstruct
android/android_api/base/build.gradle
android/android_api/base/jni/Android.mk
android/android_api/base/jni/JniCaInterface.c
android/android_api/base/jni/JniDisplayPinListener.cpp
android/android_api/base/jni/JniEntityHandler.cpp
android/android_api/base/jni/JniListenerManager.h
android/android_api/base/jni/JniOcDirectPairDevice.cpp [new file with mode: 0644]
android/android_api/base/jni/JniOcDirectPairDevice.h [new file with mode: 0644]
android/android_api/base/jni/JniOcPlatform.cpp
android/android_api/base/jni/JniOcPlatform.h
android/android_api/base/jni/JniOcPresenceHandle.cpp
android/android_api/base/jni/JniOcRepresentation.cpp
android/android_api/base/jni/JniOcRepresentation.h
android/android_api/base/jni/JniOcRequestHandle.cpp
android/android_api/base/jni/JniOcResource.cpp
android/android_api/base/jni/JniOcResourceHandle.cpp
android/android_api/base/jni/JniOcResourceIdentifier.cpp
android/android_api/base/jni/JniOcResourceRequest.cpp
android/android_api/base/jni/JniOcResourceResponse.cpp
android/android_api/base/jni/JniOcSecureResource.cpp
android/android_api/base/jni/JniOcSecureResource.h
android/android_api/base/jni/JniOcStack.cpp
android/android_api/base/jni/JniOcStack.h
android/android_api/base/jni/JniOnDPDevicesFoundListener.cpp [new file with mode: 0644]
android/android_api/base/jni/JniOnDPDevicesFoundListener.h [new file with mode: 0644]
android/android_api/base/jni/JniOnDeleteListener.cpp
android/android_api/base/jni/JniOnDeviceInfoListener.cpp
android/android_api/base/jni/JniOnDirectPairingListener.cpp [new file with mode: 0644]
android/android_api/base/jni/JniOnDirectPairingListener.h [new file with mode: 0644]
android/android_api/base/jni/JniOnGetListener.cpp
android/android_api/base/jni/JniOnObserveListener.cpp
android/android_api/base/jni/JniOnPlatformInfoListener.cpp
android/android_api/base/jni/JniOnPostListener.cpp
android/android_api/base/jni/JniOnPresenceListener.cpp
android/android_api/base/jni/JniOnPutListener.cpp
android/android_api/base/jni/JniOnResourceFoundListener.cpp
android/android_api/base/jni/JniPinCheckListener.cpp
android/android_api/base/jni/JniProvisionResultListner.cpp
android/android_api/base/jni/JniProvisionResultListner.h
android/android_api/base/jni/JniSecureUtils.cpp
android/android_api/base/jni/JniSecureUtils.h
android/android_api/base/jni/JniUtils.cpp
android/android_api/base/jni/JniUtils.h
android/android_api/base/src/main/java/org/iotivity/base/OcDirectPairDevice.java [new file with mode: 0644]
android/android_api/base/src/main/java/org/iotivity/base/OcPlatform.java
android/android_api/base/src/main/java/org/iotivity/base/OcPrmType.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/base/OcSecureResource.java
android/android_api/base/src/main/java/org/iotivity/base/OicSecPdAcl.java [new file with mode: 0644]
android/android_api/base/src/main/java/org/iotivity/ca/CaBtPairingInterface.java
android/android_api/base/src/main/java/org/iotivity/ca/CaEdrInterface.java
android/android_api/base/src/main/java/org/iotivity/ca/CaIpInterface.java
android/android_api/base/src/main/java/org/iotivity/ca/CaLeClientInterface.java
android/android_api/base/src/main/java/org/iotivity/ca/CaNfcInterface.java
android/examples/DirectPairing/.classpath [new file with mode: 0644]
android/examples/DirectPairing/.project [new file with mode: 0644]
android/examples/DirectPairing/DirectPairing.iml [new file with mode: 0644]
android/examples/DirectPairing/build.gradle [new file with mode: 0644]
android/examples/DirectPairing/project.properties [new file with mode: 0644]
android/examples/DirectPairing/src/main/AndroidManifest.xml [new file with mode: 0644]
android/examples/DirectPairing/src/main/assets/oic_svr_db_client_directpairing.dat [new file with mode: 0644]
android/examples/DirectPairing/src/main/java/org/iotivity/base/examples/DirectPairing/ExpandableListAdapter.java [new file with mode: 0644]
android/examples/DirectPairing/src/main/java/org/iotivity/base/examples/DirectPairing/Led.java [new file with mode: 0644]
android/examples/DirectPairing/src/main/java/org/iotivity/base/examples/DirectPairing/MainActivity.java [new file with mode: 0644]
android/examples/DirectPairing/src/main/java/org/iotivity/base/examples/DirectPairing/StringConstants.java [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/drawable-hdpi/arrow_down.png [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/drawable-hdpi/arrow_right.png [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/drawable-hdpi/ic_launcher.png [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/drawable-mdpi/ic_launcher.png [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/drawable-xhdpi/ic_launcher.png [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/drawable-xxhdpi/ic_launcher.png [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/layout/activity_main.xml [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/layout/custom_list_view.xml [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/layout/group_indicator.xml [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/layout/list_group.xml [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/layout/list_item.xml [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/menu/main.xml [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/values-v11/styles.xml [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/values-v14/styles.xml [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/values-w820dp/dimens.xml [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/values/dimens.xml [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/values/strings.xml [new file with mode: 0644]
android/examples/DirectPairing/src/main/res/values/styles.xml [new file with mode: 0644]
android/examples/provisioningclient/src/main/assets/oic_svr_db_client.dat
android/examples/provisioningclient/src/main/assets/oic_svr_db_client.json
android/examples/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/ProvisioningClient.java
android/examples/settings.gradle
android/examples/simpleclient/src/main/assets/oic_svr_db_client.dat
android/examples/simpleclient/src/main/assets/oic_svr_db_client.json
android/examples/simpleserver/src/main/assets/oic_svr_db_server.dat
android/examples/simpleserver/src/main/assets/oic_svr_db_server.json
build_common/SConscript
build_common/arduino/SConscript
build_common/external_libs.scons
build_common/msys_nt/SConscript [new file with mode: 0644]
build_common/tools/UnpackAll.py
build_common/windows/SConscript
examples/OICMiddle/SConscript
examples/OICMiddle/WrapResource.h
extlibs/boost/SConscript
extlibs/cjson/cJSON.h
extlibs/gtest/SConscript
extlibs/sqlite3/SConscript
extlibs/timer/SConscript
extlibs/timer/timer.c
extlibs/timer/timer.h
extlibs/tinydtls/SConscript
extlibs/tinydtls/alert.h
extlibs/tinydtls/ccm.c
extlibs/tinydtls/crypto.c
extlibs/tinydtls/crypto.h
extlibs/tinydtls/debug.c
extlibs/tinydtls/debug.h
extlibs/tinydtls/dtls.c
extlibs/tinydtls/dtls.h
extlibs/tinydtls/dtls_config.h
extlibs/tinydtls/dtls_time.c
extlibs/tinydtls/dtls_time.h
extlibs/tinydtls/global.h
extlibs/tinydtls/hmac.c
extlibs/tinydtls/hmac.h
extlibs/tinydtls/netq.c
extlibs/tinydtls/netq.h
extlibs/tinydtls/numeric.h
extlibs/tinydtls/peer.c
extlibs/tinydtls/peer.h
extlibs/tinydtls/prng.h
extlibs/tinydtls/session.c
extlibs/tinydtls/session.h
extlibs/tinydtls/t_list.h
extlibs/tinydtls/tests/dtls-client.c
extlibs/tinydtls/tests/dtls-server.c
extlibs/tinydtls/tinydtls.h
extlibs/tinydtls/utlist.h
plugins/SConscript
plugins/samples/linux/IotivityandZigbeeServer.c
plugins/src/SConscript
plugins/zigbee_wrapper/src/SConscript
plugins/zigbee_wrapper/src/zigbee_wrapper.c
plugins/zigbee_wrapper/telegesis_wrapper/src/SConscript
resource/SConscript
resource/c_common/SConscript
resource/c_common/ocrandom/include/ocrandom.h
resource/c_common/ocrandom/src/ocrandom.c
resource/c_common/oic_time/include/oic_time.h
resource/c_common/oic_time/src/oic_time.c
resource/c_common/platform_features.h
resource/c_common/windows/SConscript [new file with mode: 0644]
resource/c_common/windows/include/getopt.h [new file with mode: 0644]
resource/c_common/windows/include/pthread_create.h [new file with mode: 0644]
resource/c_common/windows/include/vs12_snprintf.h [new file with mode: 0644]
resource/c_common/windows/include/win_sleep.h [new file with mode: 0644]
resource/c_common/windows/src/getopt.c [new file with mode: 0644]
resource/c_common/windows/src/pthread_create.c [new file with mode: 0644]
resource/c_common/windows/src/snprintf.c [new file with mode: 0644]
resource/c_common/windows/src/win_sleep.c [new file with mode: 0644]
resource/csdk/SConscript
resource/csdk/connectivity/SConscript
resource/csdk/connectivity/api/cacommon.h
resource/csdk/connectivity/build/SConscript
resource/csdk/connectivity/build/tizen/packaging/com.oic.ca.spec
resource/csdk/connectivity/common/SConscript
resource/csdk/connectivity/common/src/camutex_noop.c
resource/csdk/connectivity/common/src/camutex_pthreads.c
resource/csdk/connectivity/common/src/cathreadpool_pthreads.c
resource/csdk/connectivity/inc/caadapternetdtls.h
resource/csdk/connectivity/inc/caadapterutils.h
resource/csdk/connectivity/inc/catcpinterface.h
resource/csdk/connectivity/lib/libcoap-4.1.1/SConscript
resource/csdk/connectivity/lib/libcoap-4.1.1/address.h
resource/csdk/connectivity/lib/libcoap-4.1.1/async.h
resource/csdk/connectivity/lib/libcoap-4.1.1/bits.h
resource/csdk/connectivity/lib/libcoap-4.1.1/block.h
resource/csdk/connectivity/lib/libcoap-4.1.1/coap_time.h
resource/csdk/connectivity/lib/libcoap-4.1.1/config.h
resource/csdk/connectivity/lib/libcoap-4.1.1/debug.c
resource/csdk/connectivity/lib/libcoap-4.1.1/encode.h
resource/csdk/connectivity/lib/libcoap-4.1.1/net.c
resource/csdk/connectivity/lib/libcoap-4.1.1/net.h
resource/csdk/connectivity/lib/libcoap-4.1.1/option.c
resource/csdk/connectivity/lib/libcoap-4.1.1/option.h
resource/csdk/connectivity/lib/libcoap-4.1.1/pdu.c
resource/csdk/connectivity/lib/libcoap-4.1.1/pdu.h
resource/csdk/connectivity/lib/libcoap-4.1.1/prng.h
resource/csdk/connectivity/lib/libcoap-4.1.1/resource.c
resource/csdk/connectivity/lib/libcoap-4.1.1/resource.h
resource/csdk/connectivity/lib/libcoap-4.1.1/t_list.h
resource/csdk/connectivity/lib/libcoap-4.1.1/uri.c
resource/csdk/connectivity/lib/libcoap-4.1.1/utlist.h
resource/csdk/connectivity/src/SConscript
resource/csdk/connectivity/src/adapter_util/caadapternetdtls.c
resource/csdk/connectivity/src/adapter_util/caadapterutils.c
resource/csdk/connectivity/src/bt_edr_adapter/android/caedrclient.c
resource/csdk/connectivity/src/bt_edr_adapter/android/caedrserver.c
resource/csdk/connectivity/src/bt_edr_adapter/tizen/caedrnwmonitor.c
resource/csdk/connectivity/src/bt_le_adapter/android/caleclient.c
resource/csdk/connectivity/src/bt_le_adapter/android/calenwmonitor.c
resource/csdk/connectivity/src/bt_le_adapter/android/caleserver.c
resource/csdk/connectivity/src/cablockwisetransfer.c
resource/csdk/connectivity/src/caconnectivitymanager.c
resource/csdk/connectivity/src/cainterfacecontroller.c
resource/csdk/connectivity/src/camessagehandler.c
resource/csdk/connectivity/src/caprotocolmessage.c
resource/csdk/connectivity/src/caqueueingthread.c
resource/csdk/connectivity/src/caretransmission.c
resource/csdk/connectivity/src/ip_adapter/SConscript
resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c
resource/csdk/connectivity/src/ip_adapter/arduino/caipserver_eth.cpp
resource/csdk/connectivity/src/ip_adapter/arduino/caipserver_wifi.cpp
resource/csdk/connectivity/src/ip_adapter/caipserver.c
resource/csdk/connectivity/src/ip_adapter/windows/SConscript [new file with mode: 0644]
resource/csdk/connectivity/src/ip_adapter/windows/caipnwmonitor.c [new file with mode: 0644]
resource/csdk/connectivity/src/nfc_adapter/android/canfcserver.c
resource/csdk/connectivity/src/tcp_adapter/catcpserver.c
resource/csdk/connectivity/test/SConscript
resource/csdk/connectivity/test/ca_api_unittest.cpp
resource/csdk/connectivity/test/cablocktransfertest.cpp
resource/csdk/connectivity/test/camutex_tests.cpp
resource/csdk/connectivity/test/catests.cpp
resource/csdk/connectivity/util/src/btpairing/android/cabtpairing.c
resource/csdk/connectivity/util/src/camanager/android/caleconnectionmanager.c
resource/csdk/logger/SConscript
resource/csdk/logger/include/logger.h
resource/csdk/logger/src/logger.c
resource/csdk/routing/src/routingutility.c
resource/csdk/security/SConscript
resource/csdk/security/include/internal/aclresource.h
resource/csdk/security/include/internal/srmresourcestrings.h
resource/csdk/security/include/securevirtualresourcetypes.h
resource/csdk/security/provisioning/SConscript
resource/csdk/security/provisioning/ck_manager/sample/oic_svr_db_door.dat [changed mode: 0755->0644]
resource/csdk/security/provisioning/ck_manager/sample/oic_svr_db_door.json [changed mode: 0755->0644]
resource/csdk/security/provisioning/ck_manager/sample/oic_svr_db_light.dat [changed mode: 0755->0644]
resource/csdk/security/provisioning/ck_manager/sample/oic_svr_db_light.json [changed mode: 0755->0644]
resource/csdk/security/provisioning/ck_manager/sample/oic_svr_db_pt.dat [changed mode: 0755->0644]
resource/csdk/security/provisioning/ck_manager/sample/oic_svr_db_pt.json [changed mode: 0755->0644]
resource/csdk/security/provisioning/ck_manager/sample/provisioningclient.c
resource/csdk/security/provisioning/ck_manager/unittest/ckm_info_test.cpp
resource/csdk/security/provisioning/ck_manager/unittest/test_data/CKMInfo.dat
resource/csdk/security/provisioning/ck_manager/unittest/test_data/CKMInfo.json
resource/csdk/security/provisioning/include/internal/credentialgenerator.h
resource/csdk/security/provisioning/include/internal/secureresourceprovider.h
resource/csdk/security/provisioning/include/ocprovisioningmanager.h
resource/csdk/security/provisioning/sample/SConscript
resource/csdk/security/provisioning/sample/oic_svr_db_client.dat
resource/csdk/security/provisioning/sample/oic_svr_db_client.json
resource/csdk/security/provisioning/sample/oic_svr_db_randompin_with_empty_deviceid.dat
resource/csdk/security/provisioning/sample/oic_svr_db_randompin_with_empty_deviceid.json
resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks.dat
resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks.json [changed mode: 0755->0644]
resource/csdk/security/provisioning/sample/oic_svr_db_server_randompin.dat
resource/csdk/security/provisioning/sample/oic_svr_db_server_randompin.json
resource/csdk/security/provisioning/sample/provisioningclient.c
resource/csdk/security/provisioning/sample/sampleserver_justworks.cpp
resource/csdk/security/provisioning/sample/sampleserver_randompin.cpp
resource/csdk/security/provisioning/src/credentialgenerator.c
resource/csdk/security/provisioning/src/ocprovisioningmanager.c
resource/csdk/security/provisioning/src/ownershiptransfermanager.c
resource/csdk/security/provisioning/src/pmutility.c
resource/csdk/security/provisioning/src/secureresourceprovider.c
resource/csdk/security/provisioning/unittest/SConscript
resource/csdk/security/provisioning/unittest/credentialgeneratortest.cpp [new file with mode: 0644]
resource/csdk/security/provisioning/unittest/ocprovisioningmanager.cpp
resource/csdk/security/provisioning/unittest/otmunittest.cpp
resource/csdk/security/provisioning/unittest/sampleserver1.cpp
resource/csdk/security/provisioning/unittest/sampleserver2.cpp
resource/csdk/security/src/aclresource.c
resource/csdk/security/src/amaclresource.c
resource/csdk/security/src/amsmgr.c
resource/csdk/security/src/credresource.c
resource/csdk/security/src/crlresource.c
resource/csdk/security/src/directpairing.c
resource/csdk/security/src/doxmresource.c
resource/csdk/security/src/dpairingresource.c [changed mode: 0755->0644]
resource/csdk/security/src/iotvticalendar.c
resource/csdk/security/src/pbkdf2.c
resource/csdk/security/src/pconfresource.c
resource/csdk/security/src/policyengine.c
resource/csdk/security/src/psinterface.c
resource/csdk/security/src/pstatresource.c
resource/csdk/security/src/secureresourcemanager.c
resource/csdk/security/src/srmresourcestrings.c
resource/csdk/security/src/srmutility.c
resource/csdk/security/src/strptime.c [new file with mode: 0644]
resource/csdk/security/src/svcresource.c
resource/csdk/security/src/verresource.c
resource/csdk/security/tool/json2cbor.c
resource/csdk/security/unittest/SConscript
resource/csdk/security/unittest/aclresourcetest.cpp
resource/csdk/security/unittest/credentialresource.cpp
resource/csdk/security/unittest/iotvticalendartest.cpp
resource/csdk/security/unittest/oic_svr_db.dat
resource/csdk/security/unittest/oic_svr_db.json
resource/csdk/security/unittest/oic_svr_db_prov.dat [changed mode: 0755->0644]
resource/csdk/security/unittest/oic_unittest.dat
resource/csdk/security/unittest/oic_unittest.json
resource/csdk/security/unittest/oic_unittest_acl1.dat
resource/csdk/security/unittest/oic_unittest_acl1.json
resource/csdk/security/unittest/oic_unittest_default_acl.dat
resource/csdk/security/unittest/oic_unittest_default_acl.json
resource/csdk/security/unittest/policyengine.cpp
resource/csdk/security/unittest/pstatresource.cpp
resource/csdk/security/unittest/securityresourcemanager.cpp
resource/csdk/security/unittest/srmtestcommon.cpp
resource/csdk/security/unittest/srmtestcommon.h
resource/csdk/stack/include/internal/ocpayloadcbor.h
resource/csdk/stack/include/internal/ocserverrequest.h
resource/csdk/stack/include/internal/ocstackinternal.h
resource/csdk/stack/include/ocpayload.h
resource/csdk/stack/include/ocstack.h
resource/csdk/stack/include/octypes.h
resource/csdk/stack/include/payload_logging.h
resource/csdk/stack/include/rdpayload.h
resource/csdk/stack/samples/linux/SimpleClientServer/SConscript
resource/csdk/stack/samples/linux/SimpleClientServer/common.cpp
resource/csdk/stack/samples/linux/SimpleClientServer/common.h [new file with mode: 0644]
resource/csdk/stack/samples/linux/SimpleClientServer/occlient.cpp
resource/csdk/stack/samples/linux/SimpleClientServer/occlientbasicops.cpp
resource/csdk/stack/samples/linux/SimpleClientServer/occlientcoll.cpp
resource/csdk/stack/samples/linux/SimpleClientServer/occlientslow.cpp
resource/csdk/stack/samples/linux/SimpleClientServer/ocremoteaccessclient.cpp
resource/csdk/stack/samples/linux/SimpleClientServer/ocserver.cpp
resource/csdk/stack/samples/linux/SimpleClientServer/ocserverbasicops.cpp
resource/csdk/stack/samples/linux/SimpleClientServer/ocservercoll.cpp
resource/csdk/stack/samples/linux/SimpleClientServer/ocserverslow.cpp
resource/csdk/stack/samples/linux/secure/SConscript
resource/csdk/stack/samples/linux/secure/ocamsservice.cpp
resource/csdk/stack/samples/linux/secure/occlientbasicops.cpp
resource/csdk/stack/samples/linux/secure/occlientdirectpairing.cpp
resource/csdk/stack/samples/linux/secure/ocserverbasicops.cpp
resource/csdk/stack/samples/linux/secure/oic_amss_db.dat
resource/csdk/stack/samples/linux/secure/oic_amss_db.json
resource/csdk/stack/samples/linux/secure/oic_svr_db_client_devowner.dat
resource/csdk/stack/samples/linux/secure/oic_svr_db_client_devowner.json
resource/csdk/stack/samples/linux/secure/oic_svr_db_client_directpairing.dat
resource/csdk/stack/samples/linux/secure/oic_svr_db_client_directpairing.json
resource/csdk/stack/samples/linux/secure/oic_svr_db_client_nondevowner.dat
resource/csdk/stack/samples/linux/secure/oic_svr_db_client_nondevowner.json
resource/csdk/stack/samples/linux/secure/oic_svr_db_server.dat
resource/csdk/stack/samples/linux/secure/oic_svr_db_server.json
resource/csdk/stack/samples/linux/secure/oic_svr_db_server_justworks.dat
resource/csdk/stack/samples/tizen/SimpleClientServer/SConscript
resource/csdk/stack/samples/tizen/SimpleClientServer/ocserver.cpp
resource/csdk/stack/samples/tizen/SimpleClientServer/packaging/com.oic.ri.sample.spec
resource/csdk/stack/samples/tizen/build/packaging/com.oic.ri.spec
resource/csdk/stack/src/occlientcb.c
resource/csdk/stack/src/occollection.c
resource/csdk/stack/src/ocobserve.c
resource/csdk/stack/src/ocpayload.c
resource/csdk/stack/src/ocpayloadconvert.c
resource/csdk/stack/src/ocpayloadparse.c [changed mode: 0755->0644]
resource/csdk/stack/src/ocresource.c
resource/csdk/stack/src/ocserverrequest.c
resource/csdk/stack/src/ocstack.c
resource/csdk/stack/src/oicgroup.c
resource/csdk/stack/src/oickeepalive.c
resource/csdk/stack/src/rdpayload.c
resource/csdk/stack/test/SConscript
resource/csdk/stack/test/cbortests.cpp
resource/csdk/stack/test/stacktests.cpp
resource/examples/SConscript
resource/examples/devicediscoveryserver.cpp
resource/examples/directpairingclient.cpp
resource/examples/fridgeserver.cpp
resource/examples/lightserver.cpp
resource/examples/mediaserver.cpp [new file with mode: 0644]
resource/examples/oic_svr_db_client.dat
resource/examples/oic_svr_db_client.json
resource/examples/oic_svr_db_client_directpairing.dat
resource/examples/oic_svr_db_client_directpairing.json
resource/examples/oic_svr_db_server.dat
resource/examples/oic_svr_db_server.json
resource/examples/presenceclient.cpp
resource/examples/presenceserver.cpp
resource/examples/simpleclient.cpp
resource/examples/simpleclientHQ.cpp
resource/examples/simpleserver.cpp
resource/examples/simpleserverHQ.cpp
resource/examples/threadingsample.cpp
resource/examples/winuiclient.cpp [new file with mode: 0644]
resource/examples/winuiclient.h [new file with mode: 0644]
resource/examples/winuiclientgui.cpp [new file with mode: 0644]
resource/include/AttributeValue.h
resource/include/OCApi.h
resource/include/OCHeaderOption.h
resource/include/OCRepresentation.h
resource/include/OCResource.h
resource/include/OCResourceRequest.h
resource/include/OCResourceResponse.h
resource/include/OCUtilities.h
resource/include/ResourceInitException.h
resource/include/StringConstants.h
resource/oc_logger/SConscript
resource/oc_logger/examples/SConscript
resource/oc_logger/include/oc_log_stream.hpp
resource/provisioning/SConscript
resource/provisioning/examples/SConscript
resource/provisioning/examples/oic_svr_db_client.dat
resource/provisioning/examples/oic_svr_db_client.json
resource/provisioning/examples/provisioningclient.cpp
resource/src/CAManager.cpp
resource/src/InProcClientWrapper.cpp
resource/src/InProcServerWrapper.cpp
resource/src/OCApi.cpp
resource/src/OCRepresentation.cpp
resource/src/OCResource.cpp
resource/src/SConscript
resource/third_party_libs.scons
resource/unit_tests.scons
resource/unittests/OCPlatformTest.cpp
resource/unittests/OCRepresentationEncodingTest.cpp
resource/unittests/OCResourceResponseTest.cpp
run.bat [new file with mode: 0644]
scons_script_how_to.txt
service/SConscript
service/easy-setup/enrollee/SConscript
service/easy-setup/mediator/csdk/unittests/SConscript
service/easy-setup/mediator/richsdk/SConscript
service/easy-setup/mediator/richsdk/android/jni/Android.mk
service/easy-setup/mediator/richsdk/unittests/SConscript
service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/SConscript
service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/build/SConscript
service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/packaging/com.oic.es.sample.spec
service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/assets/oic_svr_db_client.dat
service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/assets/oic_svr_db_client.json
service/easy-setup/sampleapp/mediator/linux/csdk_sample/SConscript
service/easy-setup/sampleapp/mediator/linux/richsdk_sample/SConscript
service/resource-container/SConscript
service/resource-container/examples/BMISensorBundle/src/BMISensorResource.cpp
service/resource-container/examples/BMISensorBundle/src/inputSensors/HeightSensorApp/SConscript
service/resource-container/examples/DiscomfortIndexSensorBundle/src/DiscomfortIndexSensorResource.cpp
service/resource-container/src/Configuration.h
service/resource-container/unittests/ResourceContainerTest.cpp
service/resource-container/unittests/SConscript
service/resource-container/unittests/TestBundle/include/TestBundleActivator.h
service/resource-directory/SConscript
service/resource-directory/samples/SConscript
service/resource-directory/samples/rd_main.c
service/resource-directory/src/internal/rd_storage.c
service/resource-directory/src/rd_client.c
service/resource-directory/src/rd_server.c
service/resource-encapsulation/SConscript
service/resource-encapsulation/examples/linux/secureResourceExample/oic_svr_db_client.dat
service/resource-encapsulation/examples/linux/secureResourceExample/oic_svr_db_client.json
service/resource-encapsulation/examples/linux/secureResourceExample/oic_svr_db_server.dat
service/resource-encapsulation/examples/linux/secureResourceExample/oic_svr_db_server.json
service/resource-encapsulation/include/RCSException.h
service/resource-encapsulation/include/RCSResourceAttributes.h
service/resource-encapsulation/src/common/SConscript
service/resource-encapsulation/src/resourceBroker/unittest/SConscript
service/resource-encapsulation/src/resourceCache/unittests/SConscript
service/resource-encapsulation/src/serverBuilder/SConscript
service/resource-encapsulation/unittests/SConscript
service/resource-hosting/SConscript
service/resource-hosting/src/HostingObject.h
service/resource-hosting/unittest/SConscript
service/scene-manager/SConscript
service/scene-manager/unittests/SConscript
service/things-manager/SConscript
service/things-manager/sdk/inc/ActionSet.h
service/things-manager/sdk/java/jni/SConscript
service/things-manager/sdk/src/GroupManager.cpp
service/things-manager/unittests/SConscript
service/third_party_libs.scons
tools/darwin/mkfwk_ios.sh
tools/darwin/mkfwk_osx.sh
tools/scons/RunTest.py
tools/scons/UnpackAll.py
tools/tizen/iotivity.spec

diff --git a/.gbs.conf b/.gbs.conf
new file mode 100644 (file)
index 0000000..e35c163
--- /dev/null
+++ b/.gbs.conf
@@ -0,0 +1,4 @@
+[general]
+upstream_branch = upstream
+upstream_tag = ${upstreamversion}
+
index b8c003a..62afd32 100644 (file)
@@ -103,7 +103,7 @@ extlibs/android/sdk/android-sdk_r24.2
 extlibs/android/sdk/android-sdk-linux
 extlibs/android/sdk/android-sdk-macosx
 extlibs/android/sdk/android-sdk-windows
-extlibs/boost/boost_1_58_0
+extlibs/boost/*
 extlibs/tinycbor/tinycbor
 *.tgz
 *.zip
index 35ff720..ac76f39 100644 (file)
@@ -56,7 +56,7 @@ build_dir = env.get('BUILD_DIR')
 # Build 'resource' sub-project
 SConscript(build_dir + 'resource/SConscript')
 
-if target_os not in ['arduino','darwin','ios', 'android']:
+if target_os not in ['arduino','darwin','ios', 'android', 'msys_nt', 'windows']:
        SConscript(build_dir + 'examples/OICMiddle/SConscript')
 
 # Build 'service' sub-project
@@ -76,6 +76,6 @@ env.PrintTargets()
 if target_os == 'arduino':
        env.UploadHelp()
 
-# to install the generated pc file into custome prefix location
+# to install the generated pc file into custom prefix location
 env.UserInstallTargetPCFile('iotivity.pc', 'iotivity.pc')
 
index 3e67020..834a82f 100755 (executable)
@@ -41,7 +41,7 @@ android {
         minSdkVersion 21\r
         targetSdkVersion 21\r
         versionCode 1\r
-        versionName "1.1"\r
+        versionName "1.1.1"\r
         buildConfigField 'int', 'SECURED', SECURED\r
     }\r
     buildTypes {\r
index cc43275..a513cb1 100644 (file)
@@ -58,7 +58,7 @@ LOCAL_SRC_FILES :=  JniOcStack.cpp \
                     JniEntityHandler.cpp \\r
                     JniOnResourceFoundListener.cpp \\r
                     JniOnDeviceInfoListener.cpp \\r
-                   JniOnPlatformInfoListener.cpp \\r
+                    JniOnPlatformInfoListener.cpp \\r
                     JniOnPresenceListener.cpp \\r
                     JniOnGetListener.cpp \\r
                     JniOnPutListener.cpp \\r
@@ -74,15 +74,18 @@ LOCAL_SRC_FILES :=  JniOcStack.cpp \
                     JniOcPlatform.cpp \\r
                     JniOcResource.cpp \\r
                     JniOcResourceIdentifier.cpp \\r
-                    JniOcSecurity.cpp\r
+                    JniOcSecurity.cpp \\r
+                    JniOnDPDevicesFoundListener.cpp \\r
+                    JniOnDirectPairingListener.cpp \\r
+                    JniOcDirectPairDevice.cpp\r
 ifeq ($(SECURED), 1)\r
-LOCAL_SRC_FILES +=  JniOcSecureResource.cpp \\r
-                    JniOcProvisioning.cpp \\r
-                    JniSecureUtils.cpp \\r
-                    JniProvisionResultListner.cpp \\r
-                    JniPinCheckListener.cpp \\r
-                    JniDisplayPinListener.cpp\r
-endif\r
+    LOCAL_SRC_FILES +=  JniOcSecureResource.cpp \\r
+                        JniOcProvisioning.cpp \\r
+                        JniSecureUtils.cpp \\r
+                        JniProvisionResultListner.cpp \\r
+                        JniPinCheckListener.cpp \\r
+                        JniDisplayPinListener.cpp\r
+                        endif\r
 \r
 LOCAL_LDLIBS := -llog\r
 LOCAL_STATIC_LIBRARIES := android-oc\r
index 81fcd81..e8649ec 100644 (file)
@@ -74,7 +74,7 @@ void CAManagerConnectionStateChangedCB(CATransportAdapter_t adapter,
     }
 
     bool isAttached = false;
-    JNIEnv* env;
+    JNIEnv* env = NULL;
     jint res = (*g_jvm)->GetEnv(g_jvm, (void**) &env, JNI_VERSION_1_6);
     if (JNI_OK != res)
     {
@@ -155,7 +155,7 @@ void CAManagerAdapterStateChangedCB(CATransportAdapter_t adapter, bool enabled)
     }
 
     bool isAttached = false;
-    JNIEnv* env;
+    JNIEnv* env = NULL;
     jint res = (*g_jvm)->GetEnv(g_jvm, (void**) &env, JNI_VERSION_1_6);
     if (JNI_OK != res)
     {
index 25ee926..1705bdf 100644 (file)
@@ -33,7 +33,7 @@ JniDisplayPinListener::~JniDisplayPinListener()
     LOGI("~JniDisplayPinListener()");
     if (m_jgListener)
     {
-        jint ret;
+        jint ret = JNI_ERR;
         JNIEnv *env = GetJNIEnv(ret);
         if (NULL == env) return;
         env->DeleteGlobalRef(m_jgListener);
@@ -43,9 +43,12 @@ JniDisplayPinListener::~JniDisplayPinListener()
 
 void JniDisplayPinListener::displayPinCallback(char *pinBuf, size_t pinSize)
 {
-    jint ret;
+    jint ret = JNI_ERR;
     JNIEnv *env = GetJNIEnv(ret);
-    if (NULL == env) return;
+    if (NULL == env)
+    {
+        return;
+    }
 
     jclass clsL = env->GetObjectClass(m_jgListener);
 
index 1d641ae..f46dde0 100644 (file)
@@ -33,7 +33,7 @@ JniEntityHandler::~JniEntityHandler()
     LOGD("~JniEntityHandler");
     if (m_jListener)
     {
-        jint ret;
+        jint ret = JNI_ERR;
         JNIEnv *env = GetJNIEnv(ret);
         if (nullptr == env)
         {
@@ -54,7 +54,7 @@ OCEntityHandlerResult JniEntityHandler::handleEntity(
     const std::shared_ptr<OCResourceRequest> request)
 {
     LOGD("JniEntityHandler_handleEntity");
-    jint envRet;
+    jint envRet = JNI_ERR;
     JNIEnv *env = GetJNIEnv(envRet);
     if (nullptr == env)
     {
@@ -133,7 +133,10 @@ OCEntityHandlerResult JniEntityHandler::handleEntity(
     jmethodID getValue_ID = env->GetMethodID(clsResult, "getValue", "()I");
     if (!getValue_ID)
     {
-        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == envRet)
+        {
+            g_jvm->DetachCurrentThread();
+        }
         return OC_EH_ERROR;
     }
     jint jResult = env->CallIntMethod(entityHandlerResult, getValue_ID);
index b082f7d..989dd3d 100644 (file)
@@ -51,6 +51,7 @@ public:
                 break;
             }
         }
+
         if (!onEventListener)
         {
             onEventListener = new T(env, jListener, owner);
@@ -66,9 +67,11 @@ public:
             {
                 LOGD("OnEventListener: Failed to create global listener ref.");
                 delete onEventListener;
+                return nullptr;
             }
             LOGD("OnEventListener: new listener");
         }
+
         m_mapMutex.unlock();
         return onEventListener;
     }
diff --git a/android/android_api/base/jni/JniOcDirectPairDevice.cpp b/android/android_api/base/jni/JniOcDirectPairDevice.cpp
new file mode 100644 (file)
index 0000000..ff4e626
--- /dev/null
@@ -0,0 +1,145 @@
+/*
+* //******************************************************************
+* //
+* // Copyright 2016 Samsung Electronics All Rights Reserved.
+* //
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+* //
+* // Licensed under the Apache License, Version 2.0 (the "License");
+* // you may not use this file except in compliance with the License.
+* // You may obtain a copy of the License at
+* //
+* //      http://www.apache.org/licenses/LICENSE-2.0
+* //
+* // Unless required by applicable law or agreed to in writing, software
+* // distributed under the License is distributed on an "AS IS" BASIS,
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* // See the License for the specific language governing permissions and
+* // limitations under the License.
+* //
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+*/
+
+#include "JniOcDirectPairDevice.h"
+#include "OCDirectPairing.h"
+#include "OCDirectPairing.h"
+using namespace OC;
+namespace PH = std::placeholders;
+
+JniOcDirectPairDevice::JniOcDirectPairDevice(std::shared_ptr<OC::OCDirectPairing> directPairingDevice)
+    : m_sharedDirectPairDevice(directPairingDevice)
+{
+}
+
+JniOcDirectPairDevice::~JniOcDirectPairDevice()
+{
+    LOGD("~JniOcDirectPairDevice()");
+    m_sharedDirectPairDevice = nullptr;
+}
+
+std::string JniOcDirectPairDevice::getHost()
+{
+   return m_sharedDirectPairDevice->getHost();
+}
+
+std::vector<OCPrm_t> JniOcDirectPairDevice::getPairingMethods()
+{
+
+   return m_sharedDirectPairDevice->getPairingMethods();
+}
+
+OCConnectivityType JniOcDirectPairDevice::connectivityType()
+{
+    return m_sharedDirectPairDevice->getConnType();
+}
+
+JniOcDirectPairDevice* JniOcDirectPairDevice::getJniOcDirectPairDevicePtr(JNIEnv *env, jobject thiz)
+{
+    JniOcDirectPairDevice *dpDev = GetHandle<JniOcDirectPairDevice>(env, thiz);
+    if (env->ExceptionCheck())
+    {
+        LOGE("Failed to get native handle from OcDirectPairingDevice");
+    }
+    if (!dpDev)
+    {
+        ThrowOcException(JNI_NO_NATIVE_POINTER, "");
+    }
+    return dpDev;
+}
+std::shared_ptr<OC::OCDirectPairing> JniOcDirectPairDevice::getPtr()
+{
+    return m_sharedDirectPairDevice;
+}
+
+JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcDirectPairDevice_getHost
+(JNIEnv *env, jobject thiz)
+{
+
+    LOGD("OcDirectPairing_getHost");
+
+    JniOcDirectPairDevice* device = JniOcDirectPairDevice::getJniOcDirectPairDevicePtr(env,thiz);
+    if (!device)
+    {
+        return nullptr;
+    }
+
+    std::string dev  = device->getHost();
+    return env->NewStringUTF(dev.c_str());
+}
+
+JNIEXPORT jintArray JNICALL Java_org_iotivity_base_OcDirectPairDevice_getPairingMethods
+        (JNIEnv *env, jobject thiz)
+{
+
+    LOGD("OcDirectPairing_getPairingMethods");
+
+    std::vector<jint> pairingMethodList;
+    JniOcDirectPairDevice* device = JniOcDirectPairDevice::getJniOcDirectPairDevicePtr(env,thiz);
+    if (!device)
+    {
+        return nullptr;
+    }
+
+    std::vector<OCPrm_t> pairingMethods = device->getPairingMethods();
+    return JniOcDirectPairDevice::JconvertIntVectorToJavaList(env,pairingMethods);
+}
+
+
+jintArray JniOcDirectPairDevice::JconvertIntVectorToJavaList(JNIEnv *env, std::vector<OCPrm_t> &vector)
+{
+
+    jsize len = static_cast<jsize>(vector.size());
+
+    jintArray intArray = env->NewIntArray(len);
+    if (!intArray)
+    {
+        return nullptr;
+    }
+
+    env->SetIntArrayRegion(intArray, (jsize)0, len, (const jint*)&vector[0]);
+
+    if (env->ExceptionCheck())
+    {
+        LOGE("ArrayIndexOutOfBoundsException in  JconvertIntVectorToJavaList");
+    }
+    return intArray;
+}
+
+/*
+* Class:     org_iotivity_base_OcDirectPairDevice
+* Method:    getConnectivityTypeN
+* Signature: ()I
+*/
+JNIEXPORT jint JNICALL Java_org_iotivity_base_OcDirectPairDevice_getConnectivityTypeN
+(JNIEnv *env, jobject thiz)
+{
+    LOGD("OcDirectPairDevice_getConnectivityType");
+    JniOcDirectPairDevice* device = JniOcDirectPairDevice::getJniOcDirectPairDevicePtr(env,thiz);
+    if (!device)
+    {
+        return -1;
+    }
+
+    OCConnectivityType connectivityType = device->connectivityType();
+    return static_cast<jint>(connectivityType);
+}
diff --git a/android/android_api/base/jni/JniOcDirectPairDevice.h b/android/android_api/base/jni/JniOcDirectPairDevice.h
new file mode 100644 (file)
index 0000000..505bac2
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+* //******************************************************************
+* //
+* // Copyright 2016 Samsung Electronics All Rights Reserved.
+* //
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+* //
+* // Licensed under the Apache License, Version 2.0 (the "License");
+* // you may not use this file except in compliance with the License.
+* // You may obtain a copy of the License at
+* //
+* //      http://www.apache.org/licenses/LICENSE-2.0
+* //
+* // Unless required by applicable law or agreed to in writing, software
+* // distributed under the License is distributed on an "AS IS" BASIS,
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* // See the License for the specific language governing permissions and
+* // limitations under the License.
+* //
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+*/
+
+#include "JniOcStack.h"
+#include "JniOnDPDevicesFoundListener.h"
+#include "OCDirectPairing.h"
+#include <mutex>
+
+#ifndef _Included_org_iotivity_base_OcDirectPairDevice
+#define _Included_org_iotivity_base_OcDirectPairDevice
+
+using namespace OC;
+
+class JniOcDirectPairDevice
+{
+    public:
+        JniOcDirectPairDevice(std::shared_ptr<OCDirectPairing> directPairingDevice);
+        ~JniOcDirectPairDevice();
+
+        static JniOcDirectPairDevice* getJniOcDirectPairDevicePtr(JNIEnv *env, jobject thiz);
+        static jintArray JconvertIntVectorToJavaList(JNIEnv *env, std::vector<OCPrm_t> &vector);
+
+        std::shared_ptr<OCDirectPairing> getPtr();
+        std::string getHost();
+        std::vector<OCPrm_t> getPairingMethods();
+        OCConnectivityType connectivityType();
+
+    private:
+          std::shared_ptr<OCDirectPairing> m_sharedDirectPairDevice;
+};
+
+/* DO NOT EDIT THIS FILE BEYOND THIS LINE - it is machine generated */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+    /*
+     * Class:     org_iotivity_base_OcDirectPairDevice
+     * Method:    getDirectPairedDevices
+     * Signature: (Lorg/iotivity/base/OcDirectPairDevice/GetDirectPairedListener;)V
+     */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcDirectPairDevice_getDirectPairedDevices
+        (JNIEnv *, jobject, jobject);
+
+   /*
+    * Class:     org_iotivity_base_OcDirectPairDevice
+    * Method:    getHost
+    * Signature: ()Ljava/lang/String;
+    */
+    JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcDirectPairDevice_getHost
+        (JNIEnv *, jobject);
+
+    /*
+     * Class:     org_iotivity_base_OcDirectPairDevice
+     * Method:    getPairingMethods
+     * Signature: ()Ljava/util/List;
+     */
+    JNIEXPORT jintArray JNICALL Java_org_iotivity_base_OcDirectPairDevice_getPairingMethods
+        (JNIEnv *, jobject);
+
+    /*
+     * Class:     org_iotivity_base_OcDirectPairDevice
+     * Method:    doDirectPairing
+     * Signature: (Lorg/iotivity/base/OcDirectPairDevice;Lorg/iotivity/base/OcPrmType;
+     *           Ljava/lang/String;Lorg/iotivity/base/OcDirectPairDevice/DirectPairingListener;)V
+     */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcDirectPairDevice_doDirectPairing
+        (JNIEnv *, jobject, jobject, jint, jstring, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcDirectPairDevice
+    * Method:    getConnectivityTypeN
+    * Signature: ()I
+    */
+    JNIEXPORT jint JNICALL Java_org_iotivity_base_OcDirectPairDevice_getConnectivityTypeN
+        (JNIEnv *env, jobject thiz);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
index 8987a69..5678341 100644 (file)
@@ -25,6 +25,7 @@
 #include "JniOcPresenceHandle.h"
 #include "JniOcResourceResponse.h"
 #include "JniOcSecurity.h"
+#include "JniOcDirectPairDevice.h"
 #include "JniUtils.h"
 #include "ocpayload.h"
 
@@ -321,6 +322,148 @@ void RemoveOnPresenceListener(JNIEnv* env, jobject jListener)
     presenceMapLock.unlock();
 }
 
+JniOnDPDevicesFoundListener* AddOnDPDevicesFoundListener(JNIEnv* env, jobject jListener)
+{
+    JniOnDPDevicesFoundListener *onDPDeviceListener = nullptr;
+
+    dpDevicesFoundListenerMapLock.lock();
+
+    for (auto it = onDPDevicesFoundListenerMap.begin(); it !=
+            onDPDevicesFoundListenerMap.end(); ++it)
+    {
+        if (env->IsSameObject(jListener, it->first))
+        {
+            auto refPair = it->second;
+            onDPDeviceListener = refPair.first;
+            refPair.second++;
+            it->second = refPair;
+            onDPDevicesFoundListenerMap.insert(*it);
+            LOGD("onDPDeviceListener: ref. count incremented");
+            break;
+        }
+    }
+    if (!onDPDeviceListener)
+    {
+        onDPDeviceListener = new JniOnDPDevicesFoundListener(env, jListener,
+                RemoveOnDPDevicesFoundListener);
+        jobject jgListener = env->NewGlobalRef(jListener);
+        onDPDevicesFoundListenerMap.insert(
+                std::pair<jobject, std::pair<JniOnDPDevicesFoundListener*, int>>(
+                    jgListener,
+                    std::pair<JniOnDPDevicesFoundListener*, int>(onDPDeviceListener, 1)));
+        LOGI("onDPDeviceListener: new listener");
+    }
+    dpDevicesFoundListenerMapLock.unlock();
+    return onDPDeviceListener;
+}
+
+void RemoveOnDPDevicesFoundListener(JNIEnv* env, jobject jListener)
+{
+    dpDevicesFoundListenerMapLock.lock();
+    bool isFound = false;
+    for (auto it = onDPDevicesFoundListenerMap.begin(); it !=
+            onDPDevicesFoundListenerMap.end(); ++it)
+    {
+        if (env->IsSameObject(jListener, it->first))
+        {
+            auto refPair = it->second;
+            if (refPair.second > 1)
+            {
+                refPair.second--;
+                it->second = refPair;
+                onDPDevicesFoundListenerMap.insert(*it);
+                LOGI("onDPDeviceListener: ref. count decremented");
+            }
+            else
+            {
+                env->DeleteGlobalRef(it->first);
+                JniOnDPDevicesFoundListener* listener = refPair.first;
+                delete listener;
+                onDPDevicesFoundListenerMap.erase(it);
+                LOGI("onDPDeviceListener is removed");
+            }
+            isFound = true;
+            break;
+        }
+    }
+    if (!isFound)
+    {
+        ThrowOcException(JNI_EXCEPTION, "onDPDeviceListener not found");
+    }
+    dpDevicesFoundListenerMapLock.unlock();
+}
+
+JniOnDirectPairingListener* AddOnDirectPairingListener(JNIEnv* env, jobject jListener)
+{
+    JniOnDirectPairingListener *onDirectPairingListener = nullptr;
+
+    directPairingListenerMapLock.lock();
+
+    for (auto it = directPairingListenerMap.begin(); it !=
+            directPairingListenerMap.end(); ++it)
+    {
+        if (env->IsSameObject(jListener, it->first))
+        {
+            auto refPair = it->second;
+            onDirectPairingListener = refPair.first;
+            refPair.second++;
+            it->second = refPair;
+            directPairingListenerMap.insert(*it);
+            LOGD("onDirectPairingListener: ref. count incremented");
+            break;
+        }
+    }
+    if (!onDirectPairingListener)
+    {
+        onDirectPairingListener = new JniOnDirectPairingListener(env, jListener,
+                RemoveOnDirectPairingListener);
+        jobject jgListener = env->NewGlobalRef(jListener);
+        directPairingListenerMap.insert(
+                std::pair<jobject, std::pair<JniOnDirectPairingListener*, int>>(
+                    jgListener,
+                    std::pair<JniOnDirectPairingListener*, int>(onDirectPairingListener, 1)));
+        LOGI("onDirectPairingListener: new listener");
+    }
+    directPairingListenerMapLock.unlock();
+    return onDirectPairingListener;
+}
+
+void RemoveOnDirectPairingListener(JNIEnv* env, jobject jListener)
+{
+    directPairingListenerMapLock.lock();
+    bool isFound = false;
+    for (auto it = directPairingListenerMap.begin(); it !=
+            directPairingListenerMap.end(); ++it)
+    {
+        if (env->IsSameObject(jListener, it->first))
+        {
+            auto refPair = it->second;
+            if (refPair.second > 1)
+            {
+                refPair.second--;
+                it->second = refPair;
+                directPairingListenerMap.insert(*it);
+                LOGI("onDirectPairingListener: ref. count decremented");
+            }
+            else
+            {
+                env->DeleteGlobalRef(it->first);
+                JniOnDirectPairingListener* listener = refPair.first;
+                delete listener;
+                directPairingListenerMap.erase(it);
+                LOGI("onDirectPairingListener is removed");
+            }
+            isFound = true;
+            break;
+        }
+    }
+    if (!isFound)
+    {
+        ThrowOcException(JNI_EXCEPTION, "onDirectPairingListener not found");
+    }
+    directPairingListenerMapLock.unlock();
+}
+
 /*
 * Class:     org_iotivity_base_OcPlatform
 * Method:    configure
@@ -377,7 +520,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyAllObservers0
 
     JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(
         env, jResourceHandle);
-    if (!jniOcResourceHandle) return;
+    if (!jniOcResourceHandle)
+    {
+        return;
+    }
 
     try
     {
@@ -420,7 +566,7 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyAllObservers1
         return;
     }
 
-    try{
+    try {
         OCStackResult result = OCPlatform::notifyAllObservers(
             jniOcResourceHandle->getOCResourceHandle(),
             JniUtils::getQOS(env, static_cast<int>(jQoS)));
@@ -703,6 +849,145 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_findResource1(
     }
 }
 
+/*
+ * Class:     org_iotivity_base_OcPlatform
+ * Method:    findDirectPairingDevices
+ * Signature: (ILorg/iotivity/base/OcPlatform/FindDirectPairingListener;)V
+ */
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_findDirectPairingDevices
+  (JNIEnv * env, jclass clazz, jint jTimeout, jobject jListener)
+{
+    LOGD("OcPlatform_findDirectPairingDevices");
+
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onDPDevicesFoundListener cannot be null");
+        return;
+    }
+    JniOnDPDevicesFoundListener *onDPDevsFoundListener = AddOnDPDevicesFoundListener(env,
+            jListener);
+
+    GetDirectPairedCallback getDirectPairedCallback =
+        [onDPDevsFoundListener](PairedDevices pairingDevList)
+        {
+            onDPDevsFoundListener->directPairingDevicesCallback(pairingDevList,
+                    DPFunc::FIND_DIRECT_PAIRED_DEV_LIST);
+        };
+
+    try
+    {
+        OCStackResult result = OCPlatform::findDirectPairingDevices(jTimeout,
+                getDirectPairedCallback);
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OCPlatform::findDirectPairingDevices has failed");
+            return;
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+}
+
+/*
+ * Class:     org_iotivity_base_OcPlatform
+ * Method:    getDirectPairedDevices
+ * Signature: (Lorg/iotivity/base/OcDirectPairDevice/GetDirectPairedListener;)V
+ */
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getDirectPairedDevices
+(JNIEnv *env, jclass jclazz, jobject jListener)
+{
+    LOGD("OcPlatform_getDirectPairedDevices");
+
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "getPairedDevList Callback cannot be null");
+        return;
+    }
+    JniOnDPDevicesFoundListener *onGetPairedDevicesListener = AddOnDPDevicesFoundListener(env,
+            jListener);
+
+    GetDirectPairedCallback getDirectPairedCallback =
+        [onGetPairedDevicesListener](PairedDevices pairedDevList)
+        {
+            onGetPairedDevicesListener->directPairingDevicesCallback(pairedDevList,
+                    DPFunc::GET_PAIRED_DEV_LIST);
+        };
+
+    try
+    {
+        OCStackResult result = OCPlatform::getDirectPairedDevices(getDirectPairedCallback);
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OcDirectPairDevice_getDirectPairedDevices");
+            return;
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+}
+
+/*
+ * Class:     org_iotivity_base_OcPlatform
+ * Method:    doDirectPairing
+ * Signature: (Lorg/iotivity/base/OcDirectPairDevice;Lorg/iotivity/base/OcPrmType;
+ *           Ljava/lang/String;Lorg/iotivity/base/OcDirectPairDevice/DirectPairingListener;)V
+ */
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_doDirectPairing0
+(JNIEnv *env, jclass clazz, jobject jpeer, jint jprmType, jstring jpin, jobject jListener)
+{
+    LOGD("OcPlatform_doDirectPairing");
+
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "doDirectPairing Callback cannot be null");
+        return;
+    }
+    if (!jpeer)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "Peer cannot be null");
+        return;
+    }
+
+    JniOnDirectPairingListener *onDirectPairingListener = AddOnDirectPairingListener(env,
+            jListener);
+
+    DirectPairingCallback DirectPairingCB =
+        [onDirectPairingListener](std::shared_ptr<OCDirectPairing> dpDev, OCStackResult result)
+        {
+            onDirectPairingListener->doDirectPairingCB(dpDev, result);
+        };
+
+    JniOcDirectPairDevice *dev = JniOcDirectPairDevice::getJniOcDirectPairDevicePtr(env, jpeer);
+
+    if (!dev)
+    {
+        return ;
+    }
+    std::string pin = env->GetStringUTFChars(jpin, 0);
+
+    try
+    {
+        OCStackResult result = OCPlatform::doDirectPairing(dev->getPtr(), (OCPrm_t)jprmType,
+                pin, DirectPairingCB);
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OcPlatform_oDirectPairing");
+            return;
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+}
+
 /*
 * Class:     org_iotivity_base_OcPlatform
 * Method:    getDeviceInfo0
@@ -950,7 +1235,10 @@ JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_registerResource0(
         return nullptr;
     }
     JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, jResource);
-    if (!resource) return nullptr;
+    if (!resource)
+    {
+        return nullptr;
+    }
 
     OCResourceHandle resourceHandle;
     try
@@ -1100,12 +1388,17 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_registerDeviceInfo0(
             jstring jStr = (jstring)env->GetObjectArrayElement(jDeviceTypes, i);
             if (!jStr)
             {
+                delete deviceInfo.deviceName;
                 ThrowOcException(OC_STACK_INVALID_PARAM, "device type cannot be null");
                 return;
             }
 
             OCResourcePayloadAddStringLL(&deviceInfo.types, env->GetStringUTFChars(jStr, nullptr));
-            if (env->ExceptionCheck()) return;
+            if (env->ExceptionCheck())
+            {
+                delete deviceInfo.deviceName;
+                return;
+            }
 
             env->DeleteLocalRef(jStr);
         }
@@ -1324,7 +1617,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindResource0
     }
     JniOcResourceHandle* jniOcResourceCollectionHandle =
         JniOcResourceHandle::getJniOcResourceHandlePtr(env, jResourceCollectionHandle);
-    if (!jniOcResourceCollectionHandle) return;
+    if (!jniOcResourceCollectionHandle)
+    {
+        return;
+    }
 
     JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(
         env, jResourceHandle);
@@ -1575,7 +1871,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindTypeToResource0(
 
     JniOcResourceHandle* jniOcResourceHandle =
         JniOcResourceHandle::getJniOcResourceHandlePtr(env, jResourceHandle);
-    if (!jniOcResourceHandle) return;
+    if (!jniOcResourceHandle)
+    {
+        return;
+    }
 
     try
     {
@@ -1975,7 +2274,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_sendResponse0(
 
     JniOcResourceResponse *jniResponse =
         JniOcResourceResponse::getJniOcResourceResponsePtr(env, jResourceResponse);
-    if (!jniResponse) return;
+    if (!jniResponse)
+    {
+        return;
+    }
 
     try
     {
index c66ad43..a45f059 100644 (file)
@@ -23,6 +23,8 @@
 #include "JniOnResourceFoundListener.h"
 #include "JniOnDeviceInfoListener.h"
 #include "JniOnPlatformInfoListener.h"
+#include "JniOnDPDevicesFoundListener.h"
+#include "JniOnDirectPairingListener.h"
 #include "JniOnPresenceListener.h"
 #include <mutex>
 
@@ -43,15 +45,26 @@ void RemoveOnPlatformInfoListener(JNIEnv* env, jobject jListener);
 JniOnPresenceListener* AddOnPresenceListener(JNIEnv* env, jobject jListener);
 void RemoveOnPresenceListener(JNIEnv* env, jobject jListener);
 
+JniOnDPDevicesFoundListener* AddOnDPDevicesFoundListener(JNIEnv* env, jobject jListener);
+void RemoveOnDPDevicesFoundListener(JNIEnv* env, jobject jListener);
+
+JniOnDirectPairingListener* AddOnDirectPairingListener(JNIEnv* env, jobject jListener);
+void RemoveOnDirectPairingListener(JNIEnv* env, jobject jListener);
+
+
 std::map<jobject, std::pair<JniOnResourceFoundListener*, int>> onResourceFoundListenerMap;
 std::map<jobject, std::pair<JniOnDeviceInfoListener*, int>> onDeviceInfoListenerMap;
 std::map<jobject, std::pair<JniOnPlatformInfoListener*, int>> onPlatformInfoListenerMap;
 std::map<jobject, std::pair<JniOnPresenceListener*, int>> onPresenceListenerMap;
+std::map<jobject, std::pair<JniOnDPDevicesFoundListener*, int>> onDPDevicesFoundListenerMap;
+std::map<jobject, std::pair<JniOnDirectPairingListener*, int>> directPairingListenerMap;
 
 std::mutex resourceFoundMapLock;
 std::mutex deviceInfoMapLock;
 std::mutex platformInfoMapLock;
 std::mutex presenceMapLock;
+std::mutex dpDevicesFoundListenerMapLock;
+std::mutex directPairingListenerMapLock;
 
 #ifdef __cplusplus
 extern "C" {
@@ -288,6 +301,30 @@ extern "C" {
     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_sendResponse0
         (JNIEnv *, jclass, jobject);
 
+    /*
+     * Class:     org_iotivity_base_OcPlatform
+     * Method:    findDirectPairingDevices
+     * Signature: (ILorg/iotivity/base/OcPlatform/FindDirectPairingListener;)V
+     */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_findDirectPairingDevices
+        (JNIEnv *, jclass, jint, jobject);
+
+    /*
+     * Class:     org_iotivity_base_OcPlatform
+     * Method:    getDirectPairedDevices
+     * Signature: (Lorg/iotivity/base/OcDirectPairDevice/GetDirectPairedListener;)V
+     */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getDirectPairedDevices
+        (JNIEnv *, jclass, jobject);
+
+    /*
+     * Class:     org_iotivity_base_OcPlatform
+     * Method:    doDirectPairing
+     * Signature: (Lorg/iotivity/base/OcDirectPairDevice;Lorg/iotivity/base/OcPrmType;
+     *           Ljava/lang/String;Lorg/iotivity/base/OcDirectPairDevice/DirectPairingListener;)V
+     */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_doDirectPairing0
+        (JNIEnv *, jclass, jobject, jint, jstring, jobject);
 #ifdef __cplusplus
 }
 #endif
index 00f81a1..28b7859 100644 (file)
@@ -24,7 +24,8 @@
 
 JniOcPresenceHandle::JniOcPresenceHandle(JniOnPresenceListener* jniListener, OCPresenceHandle presenceHandle)
     : m_jniListener(jniListener), m_presenceHandle(presenceHandle)
-{}
+{
+}
 
 JniOcPresenceHandle::~JniOcPresenceHandle()
 {
@@ -70,4 +71,4 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPresenceHandle_dispose
     LOGD("OcPresenceHandle_dispose");
     JniOcPresenceHandle *presenceHandle = JniOcPresenceHandle::getJniOcPresenceHandlePtr(env, thiz);
     delete presenceHandle;
-}
\ No newline at end of file
+}
index 1403349..042e2a4 100644 (file)
@@ -51,13 +51,20 @@ JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcRepresentation_getValues
 {
     LOGD("OcRepresentation_getValues");
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return nullptr;
+    if (!rep)
+    {
+        return nullptr;
+    }
 
     std::map<std::string, AttributeValue> values = rep->getValues();
     jobject jHashMap = env->NewObject(g_cls_HashMap, g_mid_HashMap_ctor);
-    if (!jHashMap) return nullptr;
+    if (!jHashMap)
+    {
+        return nullptr;
+    }
 
-    for (std::map<std::string, AttributeValue>::const_iterator it = values.begin(); it != values.end(); it++) {
+    for (std::map<std::string, AttributeValue>::const_iterator it = values.begin(); it != values.end(); it++)
+    {
         jobject key = static_cast<jobject>(env->NewStringUTF(it->first.c_str()));
         jobject val = boost::apply_visitor(JObjectConverter(env), it->second);
         env->CallObjectMethod(jHashMap, g_mid_HashMap_put, key, val);
@@ -80,7 +87,10 @@ JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcRepresentation_getValueN
         return nullptr;
     }
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return nullptr;
+    if (!rep)
+    {
+        return nullptr;
+    }
 
     std::string key = env->GetStringUTFChars(jKey, nullptr);
 
@@ -108,7 +118,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueInteger
         return;
     }
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return;
+    if (!rep)
+    {
+        return;
+    }
 
     std::string str = env->GetStringUTFChars(jKey, nullptr);
     rep->setValue(str, static_cast<int>(jValue));
@@ -129,7 +142,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDouble
         return;
     }
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return;
+    if (!rep)
+    {
+        return;
+    }
 
     std::string str = env->GetStringUTFChars(jKey, nullptr);
     rep->setValue(str, static_cast<double>(jValue));
@@ -150,7 +166,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBoolean
         return;
     }
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return;
+    if (!rep)
+    {
+        return;
+    }
 
     std::string str = env->GetStringUTFChars(jKey, nullptr);
     rep->setValue(str, static_cast<bool>(jValue));
@@ -171,7 +190,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueStringN
         return;
     }
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return;
+    if (!rep)
+    {
+        return;
+    }
 
     std::string key = env->GetStringUTFChars(jKey, nullptr);
     std::string value = env->GetStringUTFChars(jValue, nullptr);
@@ -194,14 +216,20 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresent
         return;
     }
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return;
+    if (!rep)
+    {
+        return;
+    }
 
     std::string key = env->GetStringUTFChars(jKey, nullptr);
 
     if (jValue)
     {
         OCRepresentation *value = JniOcRepresentation::getOCRepresentationPtr(env, jValue);
-        if (!value) return;
+        if (!value)
+        {
+            return;
+        }
         rep->setValue(key, *value);
     }
     else
@@ -236,7 +264,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueIntegerAr
     env->ReleaseIntArrayElements(jValue, ints, JNI_ABORT);
 
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return;
+    if (!rep)
+    {
+        return;
+    }
 
     std::string key = env->GetStringUTFChars(jKey, nullptr);
     rep->setValue(key, value);
@@ -274,7 +305,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueInteger2D
     }
 
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return;
+    if (!rep)
+    {
+        return;
+    }
 
     std::string key = env->GetStringUTFChars(jKey, nullptr);
     rep->setValue(key, value);
@@ -320,7 +354,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueInteger3D
     }
 
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return;
+    if (!rep)
+    {
+        return;
+    }
 
     std::string key = env->GetStringUTFChars(jKey, nullptr);
     rep->setValue(key, value);
@@ -352,7 +389,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDoubleArr
     env->ReleaseDoubleArrayElements(jValue, doubles, JNI_ABORT);
 
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return;
+    if (!rep)
+    {
+        return;
+    }
 
     std::string key = env->GetStringUTFChars(jKey, nullptr);
     rep->setValue(key, value);
@@ -390,7 +430,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDouble2DA
     }
 
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return;
+    if (!rep)
+    {
+        return;
+    }
 
     std::string key = env->GetStringUTFChars(jKey, nullptr);
     rep->setValue(key, value);
@@ -436,7 +479,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDouble3DA
     }
 
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return;
+    if (!rep)
+    {
+        return;
+    }
 
     std::string key = env->GetStringUTFChars(jKey, nullptr);
     rep->setValue(key, value);
@@ -468,7 +514,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBooleanAr
     env->ReleaseBooleanArrayElements(jValue, booleans, JNI_ABORT);
 
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return;
+    if (!rep)
+    {
+        return;
+    }
 
     std::string key = env->GetStringUTFChars(jKey, nullptr);
     rep->setValue(key, value);
@@ -507,7 +556,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBoolean2D
     }
 
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return;
+    if (!rep)
+    {
+        return;
+    }
 
     std::string key = env->GetStringUTFChars(jKey, nullptr);
     rep->setValue(key, value);
@@ -554,7 +606,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBoolean3D
     }
 
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return;
+    if (!rep)
+    {
+        return;
+    }
 
     std::string key = env->GetStringUTFChars(jKey, nullptr);
     rep->setValue(key, value);
@@ -579,7 +634,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueStringArr
     JniUtils::convertJavaStrArrToStrVector(env, jValue, value);
 
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return;
+    if (!rep)
+    {
+        return;
+    }
 
     std::string key = env->GetStringUTFChars(jKey, nullptr);
     rep->setValue(key, value);
@@ -611,7 +669,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueString2DA
     }
 
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return;
+    if (!rep)
+    {
+        return;
+    }
 
     std::string key = env->GetStringUTFChars(jKey, nullptr);
     rep->setValue(key, value);
@@ -651,8 +712,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueString3DA
     }
 
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return;
-
+    if (!rep)
+    {
+        return;
+    }
     std::string key = env->GetStringUTFChars(jKey, nullptr);
     rep->setValue(key, value);
 }
@@ -676,7 +739,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresent
     JniUtils::convertJavaRepresentationArrToVector(env, jValue, value);
 
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return;
+    if (!rep)
+    {
+        return;
+    }
 
     std::string key = env->GetStringUTFChars(jKey, nullptr);
     rep->setValue(key, value);
@@ -708,7 +774,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresent
     }
 
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return;
+    if (!rep)
+    {
+        return;
+    }
 
     std::string key = env->GetStringUTFChars(jKey, nullptr);
     rep->setValue(key, value);
@@ -748,7 +817,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresent
     }
 
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return;
+    if (!rep)
+    {
+        return;
+    }
 
     std::string key = env->GetStringUTFChars(jKey, nullptr);
     rep->setValue(key, value);
@@ -780,7 +852,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueByteArray
     env->ReleaseByteArrayElements(jValue, bytes, JNI_ABORT);
 
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return;
+    if (!rep)
+    {
+        return;
+    }
 
     std::string key = env->GetStringUTFChars(jKey, nullptr);
     rep->setValue(key, value);
@@ -796,10 +871,16 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_addChild
 {
     LOGD("OcRepresentation_addChild");
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return;
+    if (!rep)
+    {
+        return;
+    }
 
     OCRepresentation *child = JniOcRepresentation::getOCRepresentationPtr(env, jOcRepresentation);
-    if (!child) return;
+    if (!child)
+    {
+        return;
+    }
 
     rep->addChild(*child);
 }
@@ -814,7 +895,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_clearChildren
 {
     LOGD("OcRepresentation_clearChildren");
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return;
+    if (!rep)
+    {
+        return;
+    }
 
     rep->clearChildren();
 }
@@ -829,7 +913,10 @@ JNIEXPORT jobjectArray JNICALL Java_org_iotivity_base_OcRepresentation_getChildr
 {
     LOGD("OcRepresentation_getChildrenArray");
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return nullptr;
+    if (!rep)
+    {
+        return nullptr;
+    }
 
     return JniUtils::convertRepresentationVectorToJavaArray(env, rep->getChildren());
 }
@@ -844,7 +931,10 @@ JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcRepresentation_getUri
 {
     LOGD("OcRepresentation_getUri");
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return nullptr;
+    if (!rep)
+    {
+        return nullptr;
+    }
 
     std::string uri(rep->getUri());
     return env->NewStringUTF(uri.c_str());
@@ -860,7 +950,10 @@ JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcRepresentation_getHost
 {
     LOGD("OcRepresentation_getHost");
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return nullptr;
+    if (!rep)
+    {
+        return nullptr;
+    }
 
     std::string uri(rep->getHost());
     return env->NewStringUTF(uri.c_str());
@@ -881,7 +974,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setUri
         return;
     }
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return;
+    if (!rep)
+    {
+        return;
+    }
 
     rep->setUri(env->GetStringUTFChars(jUri, nullptr));
 }
@@ -896,7 +992,10 @@ JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_hasAttribute
         return false;
     }
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return false;
+    if (!rep)
+    {
+        return false;
+    }
 
     std::string str = env->GetStringUTFChars(jstr, nullptr);
     return rep->hasAttribute(str);
@@ -912,7 +1011,10 @@ JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcRepresentation_getResourceTyp
 {
     LOGD("OcRepresentation_getResourceTypes");
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return nullptr;
+    if (!rep)
+    {
+        return nullptr;
+    }
 
     std::vector<std::string> resourceTypes = rep->getResourceTypes();
     return JniUtils::convertStrVectorToJavaStrList(env, resourceTypes);
@@ -933,7 +1035,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setResourceTypeAr
         return;
     }
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return;
+    if (!rep)
+    {
+        return;
+    }
 
     std::vector<std::string> resourceTypes;
     JniUtils::convertJavaStrArrToStrVector(env, jResourceTypeArray, resourceTypes);
@@ -949,7 +1054,10 @@ JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcRepresentation_getResourceInt
 {
     LOGD("OcRepresentation_getResourceInterfaces");
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return nullptr;
+    if (!rep)
+    {
+        return nullptr;
+    }
 
     std::vector<std::string> resourceInterfaces = rep->getResourceInterfaces();
     return JniUtils::convertStrVectorToJavaStrList(env, resourceInterfaces);
@@ -970,7 +1078,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setResourceInterf
         return;
     }
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return;
+    if (!rep)
+    {
+        return;
+    }
 
     std::vector<std::string> resourceInterfaces;
     JniUtils::convertJavaStrArrToStrVector(env, jResourceInterfaceArray, resourceInterfaces);
@@ -987,7 +1098,10 @@ JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_isEmpty
 {
     LOGD("OcRepresentation_isEmpty");
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return false;
+    if (!rep)
+    {
+        return false;
+    }
 
     return static_cast<jboolean>(rep->empty());
 }
@@ -1002,7 +1116,10 @@ JNIEXPORT jint JNICALL Java_org_iotivity_base_OcRepresentation_size
 {
     LOGD("OcRepresentation_size");
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return -1;
+    if (!rep)
+    {
+        return -1;
+    }
 
     return static_cast<jint>(rep->numberOfAttributes());
 }
@@ -1022,7 +1139,10 @@ JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_remove
         return false;
     }
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return false;
+    if (!rep)
+    {
+        return false;
+    }
 
     std::string attributeKey = env->GetStringUTFChars(jAttributeKey, nullptr);
     return static_cast<jboolean>(rep->erase(attributeKey));
@@ -1043,7 +1163,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setNull
         return;
     }
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return;
+    if (!rep)
+    {
+        return;
+    }
 
     std::string attributeKey = env->GetStringUTFChars(jAttributeKey, nullptr);
     rep->setNULL(attributeKey);
@@ -1064,7 +1187,10 @@ JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_isNull
         return false;
     }
     OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
-    if (!rep) return false;
+    if (!rep)
+    {
+        return false;
+    }
 
     std::string attributeKey = env->GetStringUTFChars(jAttributeKey, nullptr);
     return static_cast<jboolean>(rep->isNULL(attributeKey));
index a153dd7..e9acd35 100644 (file)
@@ -35,9 +35,15 @@ public:
 
 struct JObjectConverter : boost::static_visitor < jobject >
 {
-    JObjectConverter(JNIEnv *env) : env(env){}
+    JObjectConverter(JNIEnv *env) : env(env)
+    {
+    }
+
+    jobject operator()(const NullType&) const
+    {
+        return nullptr;
+    }
 
-    jobject operator()(const NullType&) const { return nullptr; }
     jobject operator()(const int& val) const
     {
         jobject jobj = env->NewObject(
@@ -87,7 +93,10 @@ struct JObjectConverter : boost::static_visitor < jobject >
     {
         size_t len = val.size();
         jintArray jIntArray = env->NewIntArray(len);
-        if (!jIntArray) return nullptr;
+        if (!jIntArray)
+        {
+            return nullptr;
+        }
         const int* ints = &val[0];
         env->SetIntArrayRegion(jIntArray, 0, len, reinterpret_cast<const jint*>(ints));
         return jIntArray;
@@ -96,7 +105,10 @@ struct JObjectConverter : boost::static_visitor < jobject >
     {
         size_t len = val.size();
         jdoubleArray jDoubleArray = env->NewDoubleArray(len);
-        if (!jDoubleArray) return nullptr;
+        if (!jDoubleArray)
+        {
+            return nullptr;
+        }
         const double* doubles = &val[0];
         env->SetDoubleArrayRegion(jDoubleArray, 0, len, reinterpret_cast<const jdouble*>(doubles));
         return jDoubleArray;
@@ -105,13 +117,20 @@ struct JObjectConverter : boost::static_visitor < jobject >
     {
         size_t len = val.size();
         jbooleanArray jBooleanArray = env->NewBooleanArray(len);
-        if (!jBooleanArray) return nullptr;
+        if (!jBooleanArray)
+        {
+            return nullptr;
+        }
         jboolean* booleans = new jboolean[len];
-        for (size_t i = 0; i < len; ++i) {
+        for (size_t i = 0; i < len; ++i)
+        {
             booleans[i] = static_cast<jboolean>(val[i]);
         }
         env->SetBooleanArrayRegion(jBooleanArray, 0, len, booleans);
-        if (env->ExceptionCheck()) return nullptr;
+        if (env->ExceptionCheck())
+        {
+            return nullptr;
+        }
         env->ReleaseBooleanArrayElements(jBooleanArray, booleans, 0);
         return jBooleanArray;
     }
@@ -119,12 +138,18 @@ struct JObjectConverter : boost::static_visitor < jobject >
     {
         size_t len = val.size();
         jobjectArray strArr = env->NewObjectArray(len, g_cls_String, nullptr);
-        if (!strArr) return nullptr;
+        if (!strArr)
+        {
+            return nullptr;
+        }
         for (size_t i = 0; i < len; ++i)
         {
             jstring jString = env->NewStringUTF(val[i].c_str());
             env->SetObjectArrayElement(strArr, static_cast<jsize>(i), jString);
-            if (env->ExceptionCheck()) return nullptr;
+            if (env->ExceptionCheck())
+            {
+                return nullptr;
+            }
             env->DeleteLocalRef(jString);
         }
         return strArr;
@@ -133,7 +158,10 @@ struct JObjectConverter : boost::static_visitor < jobject >
     {
         jsize len = static_cast<jsize>(val.size());
         jobjectArray repArr = env->NewObjectArray(len, g_cls_OcRepresentation, nullptr);
-        if (!repArr) return nullptr;
+        if (!repArr)
+        {
+            return nullptr;
+        }
         for (jsize i = 0; i < len; ++i)
         {
             OCRepresentation* rep = new OCRepresentation(val[i]);
@@ -159,7 +187,10 @@ struct JObjectConverter : boost::static_visitor < jobject >
     {
         size_t len = val.size();
         jbyteArray jByteArray = env->NewByteArray(len);
-        if (!jByteArray) return nullptr;
+        if (!jByteArray)
+        {
+            return nullptr;
+        }
         const uint8_t* bytes = &val[0];
         env->SetByteArrayRegion(jByteArray, 0, len, reinterpret_cast<const jbyte*>(bytes));
         return jByteArray;
@@ -178,12 +209,21 @@ struct JObjectConverter : boost::static_visitor < jobject >
         {
             size_t lenInner = val[i].size();
             jintArray jIntArray = env->NewIntArray(lenInner);
-            if (!jIntArray) return nullptr;
+            if (!jIntArray)
+            {
+                return nullptr;
+            }
             const int* ints = &val[i][0];
             env->SetIntArrayRegion(jIntArray, 0, lenInner, reinterpret_cast<const jint*>(ints));
-            if (env->ExceptionCheck()) return nullptr;
+            if (env->ExceptionCheck())
+            {
+                return nullptr;
+            }
             env->SetObjectArrayElement(jOuterArr, i, static_cast<jobject>(jIntArray));
-            if (env->ExceptionCheck()) return nullptr;
+            if (env->ExceptionCheck())
+            {
+                return nullptr;
+            }
             env->DeleteLocalRef(jIntArray);
         }
         return jOuterArr;
@@ -192,26 +232,46 @@ struct JObjectConverter : boost::static_visitor < jobject >
     {
         jsize lenOuter = static_cast<jsize>(val.size());
         jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_int2DArray, nullptr);
-        if (!jOuterArr) return nullptr;
+        if (!jOuterArr)
+        {
+            return nullptr;
+        }
+
         for (jsize k = 0; k < lenOuter; ++k)
         {
             jsize lenMiddle = static_cast<jsize>(val[k].size());
             jobjectArray jMiddleArr = env->NewObjectArray(lenMiddle, g_cls_int1DArray, nullptr);
-            if (!jMiddleArr) return nullptr;
+            if (!jMiddleArr)
+            {
+                return nullptr;
+            }
+
             for (jsize i = 0; i < lenMiddle; ++i)
             {
                 jsize lenInner = static_cast<jsize>(val[k][i].size());
                 jintArray jIntArray = env->NewIntArray(lenInner);
-                if (!jIntArray) return nullptr;
+                if (!jIntArray)
+                {
+                    return nullptr;
+                }
                 const int* ints = &val[k][i][0];
                 env->SetIntArrayRegion(jIntArray, 0, lenInner, reinterpret_cast<const jint*>(ints));
-                if (env->ExceptionCheck()) return nullptr;
+                if (env->ExceptionCheck())
+                {
+                    return nullptr;
+                }
                 env->SetObjectArrayElement(jMiddleArr, i, jIntArray);
-                if (env->ExceptionCheck()) return nullptr;
+                if (env->ExceptionCheck())
+                {
+                    return nullptr;
+                }
                 env->DeleteLocalRef(jIntArray);
             }
             env->SetObjectArrayElement(jOuterArr, k, jMiddleArr);
-            if (env->ExceptionCheck()) return nullptr;
+            if (env->ExceptionCheck())
+            {
+                return nullptr;
+            }
             env->DeleteLocalRef(jMiddleArr);
         }
         return jOuterArr;
@@ -221,17 +281,31 @@ struct JObjectConverter : boost::static_visitor < jobject >
     {
         jsize lenOuter = static_cast<jsize>(val.size());
         jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_double1DArray, nullptr);
-        if (!jOuterArr) return nullptr;
+        if (!jOuterArr)
+        {
+            return nullptr;
+        }
+
         for (jsize i = 0; i < lenOuter; ++i)
         {
             size_t lenInner = val[i].size();
             jdoubleArray jDoubleArray = env->NewDoubleArray(lenInner);
-            if (!jDoubleArray) return nullptr;
+            if (!jDoubleArray)
+            {
+                return nullptr;
+            }
+
             const double* doubles = &val[i][0];
             env->SetDoubleArrayRegion(jDoubleArray, 0, lenInner, reinterpret_cast<const jdouble*>(doubles));
-            if (env->ExceptionCheck()) return nullptr;
+            if (env->ExceptionCheck())
+            {
+                return nullptr;
+            }
             env->SetObjectArrayElement(jOuterArr, i, jDoubleArray);
-            if (env->ExceptionCheck()) return nullptr;
+            if (env->ExceptionCheck())
+            {
+                return nullptr;
+            }
             env->DeleteLocalRef(jDoubleArray);
         }
 
@@ -241,26 +315,44 @@ struct JObjectConverter : boost::static_visitor < jobject >
     {
         jsize lenOuter = static_cast<jsize>(val.size());
         jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_double2DArray, nullptr);
-        if (!jOuterArr) return nullptr;
+        if (!jOuterArr)
+        {
+            return nullptr;
+        }
         for (jsize k = 0; k < lenOuter; ++k)
         {
             jsize lenMiddle = static_cast<jsize>(val[k].size());
             jobjectArray jMiddleArr = env->NewObjectArray(lenMiddle, g_cls_double1DArray, nullptr);
-            if (!jMiddleArr) return nullptr;
+            if (!jMiddleArr)
+            {
+                return nullptr;
+            }
             for (jsize i = 0; i < lenMiddle; ++i)
             {
                 jsize lenInner = static_cast<jsize>(val[k][i].size());
                 jdoubleArray jDoubleArray = env->NewDoubleArray(lenInner);
-                if (!jDoubleArray) return nullptr;
+                if (!jDoubleArray)
+                {
+                    return nullptr;
+                }
                 const double* doubles = &val[k][i][0];
                 env->SetDoubleArrayRegion(jDoubleArray, 0, lenInner, reinterpret_cast<const jdouble*>(doubles));
-                if (env->ExceptionCheck()) return nullptr;
+                if (env->ExceptionCheck())
+                {
+                    return nullptr;
+                }
                 env->SetObjectArrayElement(jMiddleArr, i, jDoubleArray);
-                if (env->ExceptionCheck()) return nullptr;
+                if (env->ExceptionCheck())
+                {
+                    return nullptr;
+                }
                 env->DeleteLocalRef(jDoubleArray);
             }
             env->SetObjectArrayElement(jOuterArr, k, jMiddleArr);
-            if (env->ExceptionCheck()) return nullptr;
+            if (env->ExceptionCheck())
+            {
+                return nullptr;
+            }
             env->DeleteLocalRef(jMiddleArr);
         }
         return jOuterArr;
@@ -270,22 +362,38 @@ struct JObjectConverter : boost::static_visitor < jobject >
     {
         jsize lenOuter = static_cast<jsize>(val.size());
         jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_boolean1DArray, 0);
-        if (!jOuterArr) return nullptr;
+        if (!jOuterArr)
+        {
+            return nullptr;
+        }
         for (jsize i = 0; i < lenOuter; ++i)
         {
             size_t lenInner = val[i].size();
             jbooleanArray jBooleanArray = env->NewBooleanArray(lenInner);
-            if (!jBooleanArray) return nullptr;
+            if (!jBooleanArray)
+            {
+                return nullptr;
+            }
             jboolean* booleans = new jboolean[lenInner];
-            for (size_t j = 0; j < lenInner; ++j) {
+            for (size_t j = 0; j < lenInner; ++j)
+            {
                 booleans[j] = static_cast<jboolean>(val[i][j]);
             }
             env->SetBooleanArrayRegion(jBooleanArray, 0, lenInner, booleans);
-            if (env->ExceptionCheck()) return nullptr;
+            if (env->ExceptionCheck())
+            {
+                return nullptr;
+            }
             env->SetObjectArrayElement(jOuterArr, i, jBooleanArray);
-            if (env->ExceptionCheck()) return nullptr;
+            if (env->ExceptionCheck())
+            {
+                return nullptr;
+            }
             env->ReleaseBooleanArrayElements(jBooleanArray, booleans, 0);
-            if (env->ExceptionCheck()) return nullptr;
+            if (env->ExceptionCheck())
+            {
+                return nullptr;
+            }
             env->DeleteLocalRef(jBooleanArray);
         }
         return jOuterArr;
@@ -294,31 +402,49 @@ struct JObjectConverter : boost::static_visitor < jobject >
     {
         jsize lenOuter = static_cast<jsize>(val.size());
         jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_boolean2DArray, nullptr);
-        if (!jOuterArr) return nullptr;
+        if (!jOuterArr)
+        {
+            return nullptr;
+        }
         for (jsize k = 0; k < lenOuter; ++k)
         {
             jsize lenMiddle = static_cast<jsize>(val[k].size());
             jobjectArray jMiddleArr = env->NewObjectArray(lenMiddle, g_cls_boolean1DArray, nullptr);
-            if (!jMiddleArr) return nullptr;
+            if (!jMiddleArr)
+            {
+                return nullptr;
+            }
             for (jsize i = 0; i < lenMiddle; ++i)
             {
                 size_t lenInner = val[k][i].size();
                 jbooleanArray jBooleanArray = env->NewBooleanArray(lenInner);
                 jboolean* booleans = new jboolean[lenInner];
-                for (size_t j = 0; j < lenInner; ++j) {
+                for (size_t j = 0; j < lenInner; ++j)
+                {
                     booleans[j] = val[k][i][j];
                 }
                 env->SetBooleanArrayRegion(jBooleanArray, 0, lenInner, booleans);
-                if (env->ExceptionCheck()) return nullptr;
+                if (env->ExceptionCheck())
+                {
+                    return nullptr;
+                }
                 env->SetObjectArrayElement(jMiddleArr, i, jBooleanArray);
-                if (env->ExceptionCheck()) return nullptr;
+                if (env->ExceptionCheck())
+                {
+                    return nullptr;
+                }
                 env->ReleaseBooleanArrayElements(jBooleanArray, booleans, 0);
-                if (env->ExceptionCheck()) return nullptr;
+                if (env->ExceptionCheck())
+                {
+                    return nullptr;
+                }
                 env->DeleteLocalRef(jBooleanArray);
             }
             env->SetObjectArrayElement(jOuterArr, k, jMiddleArr);
-            if (env->ExceptionCheck()) return nullptr;
-            env->DeleteLocalRef(jMiddleArr);
+            if (env->ExceptionCheck())
+            {
+                return nullptr;
+            }            env->DeleteLocalRef(jMiddleArr);
         }
         return jOuterArr;
     }
@@ -327,21 +453,33 @@ struct JObjectConverter : boost::static_visitor < jobject >
     {
         jsize lenOuter = static_cast<jsize>(val.size());
         jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_String1DArray, nullptr);
-        if (!jOuterArr) return nullptr;
+        if (!jOuterArr)
+        {
+            return nullptr;
+        }
         for (jsize i = 0; i < lenOuter; ++i)
         {
             jsize lenInner = static_cast<jsize>(val[i].size());
             jobjectArray strArr = env->NewObjectArray(lenInner, g_cls_String, nullptr);
-            if (!strArr) return nullptr;
+            if (!strArr)
+            {
+                return nullptr;
+            }
             for (jsize j = 0; j < lenInner; ++j)
             {
                 jstring jString = env->NewStringUTF(val[i][j].c_str());
                 env->SetObjectArrayElement(strArr, j, jString);
-                if (env->ExceptionCheck()) return nullptr;
+                if (env->ExceptionCheck())
+                {
+                    return nullptr;
+                }
                 env->DeleteLocalRef(jString);
             }
             env->SetObjectArrayElement(jOuterArr, i, strArr);
-            if (env->ExceptionCheck()) return nullptr;
+            if (env->ExceptionCheck())
+            {
+                return nullptr;
+            }
             env->DeleteLocalRef(strArr);
         }
 
@@ -351,30 +489,48 @@ struct JObjectConverter : boost::static_visitor < jobject >
     {
         jsize lenOuter = static_cast<jsize>(val.size());
         jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_String2DArray, nullptr);
-        if (!jOuterArr) return nullptr;
+        if (!jOuterArr)
+        {
+            return nullptr;
+        }
         for (jsize k = 0; k < lenOuter; ++k)
         {
             jsize lenMiddle = static_cast<jsize>(val[k].size());
             jobjectArray jMiddleArr = env->NewObjectArray(lenMiddle, g_cls_String1DArray, nullptr);
-            if (!jMiddleArr) return nullptr;
+            if (!jMiddleArr)
+            {
+                return nullptr;
+            }
             for (jsize i = 0; i < lenMiddle; ++i)
             {
                 jsize lenInner = static_cast<jsize>(val[k][i].size());
                 jobjectArray strArr = env->NewObjectArray(lenInner, g_cls_String, nullptr);
-                if (!strArr) return nullptr;
+                if (!strArr)
+                {
+                    return nullptr;
+                }
                 for (jsize j = 0; j < lenInner; ++j)
                 {
                     jstring jString = env->NewStringUTF(val[k][i][j].c_str());
                     env->SetObjectArrayElement(strArr, j, jString);
-                    if (env->ExceptionCheck()) return nullptr;
+                    if (env->ExceptionCheck())
+                    {
+                        return nullptr;
+                    }
                     env->DeleteLocalRef(jString);
                 }
                 env->SetObjectArrayElement(jMiddleArr, i, strArr);
-                if (env->ExceptionCheck()) return nullptr;
+                if (env->ExceptionCheck())
+                {
+                    return nullptr;
+                }
                 env->DeleteLocalRef(strArr);
             }
             env->SetObjectArrayElement(jOuterArr, k, jMiddleArr);
-            if (env->ExceptionCheck()) return nullptr;
+            if (env->ExceptionCheck())
+            {
+                return nullptr;
+            }
             env->DeleteLocalRef(jMiddleArr);
         }
         return jOuterArr;
@@ -384,12 +540,18 @@ struct JObjectConverter : boost::static_visitor < jobject >
     {
         jsize lenOuter = static_cast<jsize>(val.size());
         jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_OcRepresentation1DArray, nullptr);
-        if (!jOuterArr) return nullptr;
+        if (!jOuterArr)
+        {
+            return nullptr;
+        }
         for (jsize i = 0; i < lenOuter; ++i)
         {
             jsize lenInner = static_cast<jsize>(val[i].size());
             jobjectArray repArr = env->NewObjectArray(lenInner, g_cls_OcRepresentation, nullptr);
-            if (!repArr) return nullptr;
+            if (!repArr)
+            {
+                return nullptr;
+            }
             for (jsize j = 0; j < lenInner; ++j)
             {
                 OCRepresentation* rep = new OCRepresentation(val[i][j]);
@@ -402,11 +564,17 @@ struct JObjectConverter : boost::static_visitor < jobject >
                     return nullptr;
                 }
                 env->SetObjectArrayElement(repArr, j, jRepresentation);
-                if (env->ExceptionCheck()) return nullptr;
+                if (env->ExceptionCheck())
+                {
+                    return nullptr;
+                }
                 env->DeleteLocalRef(jRepresentation);
             }
             env->SetObjectArrayElement(jOuterArr, i, repArr);
-            if (env->ExceptionCheck()) return nullptr;
+            if (env->ExceptionCheck())
+            {
+                return nullptr;
+            }
             env->DeleteLocalRef(repArr);
         }
         return jOuterArr;
@@ -415,17 +583,26 @@ struct JObjectConverter : boost::static_visitor < jobject >
     {
         jsize lenOuter = static_cast<jsize>(val.size());
         jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_OcRepresentation2DArray, nullptr);
-        if (!jOuterArr) return nullptr;
+        if (!jOuterArr)
+        {
+            return nullptr;
+        }
         for (jsize k = 0; k < lenOuter; ++k)
         {
             jsize lenMiddle = static_cast<jsize>(val[k].size());
             jobjectArray jMiddleArr = env->NewObjectArray(lenMiddle, g_cls_OcRepresentation1DArray, nullptr);
-            if (!jMiddleArr) return nullptr;
+            if (!jMiddleArr)
+            {
+                return nullptr;
+            }
             for (jsize i = 0; i < lenMiddle; ++i)
             {
                 jsize lenInner = static_cast<jsize>(val[k][i].size());
                 jobjectArray repArr = env->NewObjectArray(lenInner, g_cls_OcRepresentation, nullptr);
-                if (!repArr) return nullptr;
+                if (!repArr)
+                {
+                    return nullptr;
+                }
                 for (jsize j = 0; j < lenInner; ++j)
                 {
                     OCRepresentation* rep = new OCRepresentation(val[k][i][j]);
@@ -438,15 +615,24 @@ struct JObjectConverter : boost::static_visitor < jobject >
                         return nullptr;
                     }
                     env->SetObjectArrayElement(repArr, j, jRepresentation);
-                    if (env->ExceptionCheck()) return nullptr;
+                    if (env->ExceptionCheck())
+                    {
+                        return nullptr;
+                    }
                     env->DeleteLocalRef(jRepresentation);
                 }
                 env->SetObjectArrayElement(jMiddleArr, i, repArr);
-                if (env->ExceptionCheck()) return nullptr;
+                if (env->ExceptionCheck())
+                {
+                    return nullptr;
+                }
                 env->DeleteLocalRef(repArr);
             }
             env->SetObjectArrayElement(jOuterArr, k, jMiddleArr);
-            if (env->ExceptionCheck()) return nullptr;
+            if (env->ExceptionCheck())
+            {
+                return nullptr;
+            }
             env->DeleteLocalRef(jMiddleArr);
         }
         return jOuterArr;
index b916490..9585c55 100644 (file)
@@ -22,7 +22,8 @@
 #include "JniOcRequestHandle.h"
 
 JniOcRequestHandle::JniOcRequestHandle(OCRequestHandle requestHandle) : m_requestHandle(requestHandle)
-{}
+{
+}
 
 JniOcRequestHandle::~JniOcRequestHandle()
 {
@@ -60,4 +61,4 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRequestHandle_dispose
     LOGD("OcRequestHandle_dispose");
     JniOcRequestHandle *handle = JniOcRequestHandle::getJniOcRequestHandlePtr(env, thiz);
     delete handle;
-}
\ No newline at end of file
+}
index 9e6925a..743c1bc 100644 (file)
@@ -26,7 +26,8 @@
 
 JniOcResource::JniOcResource(std::shared_ptr<OCResource> resource)
     : m_sharedResource(resource)
-{}
+{
+}
 
 JniOcResource::~JniOcResource()
 {
@@ -34,9 +35,12 @@ JniOcResource::~JniOcResource()
 
     m_sharedResource = nullptr;
 
-    jint envRet;
+    jint envRet = JNI_ERR;
     JNIEnv *env = GetJNIEnv(envRet);
-    if (nullptr == env) return;
+    if (nullptr == env)
+    {
+        return;
+    }
 
     m_onGetManager.removeAllListeners(env);
     m_onPutManager.removeAllListeners(env);
@@ -44,7 +48,10 @@ JniOcResource::~JniOcResource()
     m_onDeleteManager.removeAllListeners(env);
     m_onObserveManager.removeAllListeners(env);
 
-    if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+    if (JNI_EDETACHED == envRet)
+    {
+        g_jvm->DetachCurrentThread();
+    }
 }
 
 OCStackResult JniOcResource::get(JNIEnv* env, const QueryParamsMap &queryParametersMap, jobject jListener)
@@ -432,7 +439,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get
         return;
     }
     JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
-    if (!resource) return;
+    if (!resource)
+    {
+        return;
+    }
 
     QueryParamsMap qpm;
     JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
@@ -476,7 +486,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get1
         return;
     }
     JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
-    if (!resource) return;
+    if (!resource)
+    {
+        return;
+    }
 
     QueryParamsMap qpm;
     JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
@@ -533,7 +546,10 @@ jobject jQueryParamsMap, jobject jListener)
         return;
     }
     JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
-    if (!resource) return;
+    if (!resource)
+    {
+        return;
+    }
 
     QueryParamsMap qpm;
     JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
@@ -590,7 +606,10 @@ jobject jQueryParamsMap, jobject jListener, jint jQoS)
         resourceInterface = env->GetStringUTFChars(jResourceInterface, nullptr);
     }
     JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
-    if (!resource) return;
+    if (!resource)
+    {
+        return;
+    }
 
     QueryParamsMap qpm;
     JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
@@ -643,10 +662,16 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put
         return;
     }
     JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
-    if (!resource) return;
+    if (!resource)
+    {
+        return;
+    }
 
     OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);
-    if (!representation) return;
+    if (!representation)
+    {
+        return;
+    }
 
     QueryParamsMap qpm;
     JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
@@ -698,10 +723,16 @@ jobject jListener, jint jQoS)
         return;
     }
     JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
-    if (!resource) return;
+    if (!resource)
+    {
+        return;
+    }
 
     OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);
-    if (!representation) return;
+    if (!representation)
+    {
+        return;
+    }
 
     QueryParamsMap qpm;
     JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
@@ -764,10 +795,16 @@ jobject jRepresentation, jobject jQueryParamsMap, jobject jListener)
         return;
     }
     JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
-    if (!resource) return;
+    if (!resource)
+    {
+        return;
+    }
 
     OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);
-    if (!representation) return;
+    if (!representation)
+    {
+        return;
+    }
 
     QueryParamsMap qpm;
     JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
@@ -832,10 +869,16 @@ jobject jQueryParamsMap, jobject jListener, jint jQoS)
     }
 
     JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
-    if (!resource) return;
+    if (!resource)
+    {
+        return;
+    }
 
     OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);
-    if (!representation) return;
+    if (!representation)
+    {
+        return;
+    }
 
     QueryParamsMap qpm;
     JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
@@ -888,10 +931,16 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post
         return;
     }
     JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
-    if (!resource) return;
+    if (!resource)
+    {
+        return;
+    }
 
     OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);
-    if (!representation) return;
+    if (!representation)
+    {
+        return;
+    }
 
     QueryParamsMap qpm;
     JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
@@ -941,10 +990,16 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post1
         return;
     }
     JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
-    if (!resource) return;
+    if (!resource)
+    {
+        return;
+    }
 
     OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);
-    if (!representation) return;
+    if (!representation)
+    {
+        return;
+    }
 
     QueryParamsMap qpm;
     JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
@@ -1008,10 +1063,16 @@ jobject jRepresentation, jobject jQueryParamsMap, jobject jListener)
     }
 
     JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
-    if (!resource) return;
+    if (!resource)
+    {
+        return;
+    }
 
     OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);
-    if (!representation) return;
+    if (!representation)
+    {
+        return;
+    }
 
     QueryParamsMap qpm;
     JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
@@ -1076,10 +1137,16 @@ jobject jRepresentation, jobject jQueryParamsMap, jobject jListener, jint jQoS)
     }
 
     JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
-    if (!resource) return;
+    if (!resource)
+    {
+        return;
+    }
 
     OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);
-    if (!representation) return;
+    if (!representation)
+    {
+        return;
+    }
 
     QueryParamsMap qpm;
     JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
@@ -1122,7 +1189,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_deleteResource
         return;
     }
     JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
-    if (!resource) return;
+    if (!resource)
+    {
+        return;
+    }
 
     try
     {
@@ -1157,7 +1227,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_deleteResource1
         return;
     }
     JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
-    if (!resource) return;
+    if (!resource)
+    {
+        return;
+    }
 
     try
     {
@@ -1199,7 +1272,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_observe
         return;
     }
     JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
-    if (!resource) return;
+    if (!resource)
+    {
+        return;
+    }
 
     QueryParamsMap qpm;
     JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
@@ -1246,7 +1322,10 @@ jobject jListener, jint jQoS)
         return;
     }
     JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
-    if (!resource) return;
+    if (!resource)
+    {
+        return;
+    }
 
     QueryParamsMap qpm;
     JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
@@ -1282,7 +1361,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_cancelObserve1
 {
     LOGD("OcResource_cancelObserve1");
     JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
-    if (!resource) return;
+    if (!resource)
+    {
+        return;
+    }
 
     try
     {
@@ -1317,7 +1399,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_setHeaderOptions
         return;
     }
     JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
-    if (!resource) return;
+    if (!resource)
+    {
+        return;
+    }
 
     HeaderOptions headerOptions;
     JniUtils::convertJavaHeaderOptionsArrToVector(env, jheaderOptionArr, headerOptions);
@@ -1335,7 +1420,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_unsetHeaderOptions
 {
     LOGD("OcResource_unsetHeaderOptions");
     JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
-    if (!resource) return;
+    if (!resource)
+    {
+        return;
+    }
 
     resource->unsetHeaderOptions();
 }
@@ -1350,7 +1438,10 @@ JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getHost
 {
     LOGD("OcResource_getHost");
     JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
-    if (!resource) return nullptr;
+    if (!resource)
+    {
+        return nullptr;
+    }
 
     return env->NewStringUTF(resource->host().c_str());
 }
@@ -1365,7 +1456,10 @@ JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getUri
 {
     LOGD("OcResource_getUri");
     JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
-    if (!resource) return nullptr;
+    if (!resource)
+    {
+        return nullptr;
+    }
 
     return env->NewStringUTF(resource->uri().c_str());
 }
@@ -1380,7 +1474,10 @@ JNIEXPORT jint JNICALL Java_org_iotivity_base_OcResource_getConnectivityTypeN
 {
     LOGD("OcResource_getConnectivityType");
     JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
-    if (!resource) return -1;
+    if (!resource)
+    {
+        return -1;
+    }
 
     OCConnectivityType connectivityType = resource->connectivityType();
     return static_cast<jint>(connectivityType);
@@ -1396,6 +1493,11 @@ JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcResource_isObservable
 {
     LOGD("OcResource_isObservable");
     JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    if (!resource)
+    {
+        return false;
+    }
+
     return (jboolean)resource->isObservable();
 }
 
@@ -1409,7 +1511,10 @@ JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResource_getResourceTypes
 {
     LOGD("OcResource_getResourceTypes");
     JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
-    if (!resource) return nullptr;
+    if (!resource)
+    {
+        return nullptr;
+    }
 
     std::vector<std::string> resourceTypes = resource->getResourceTypes();
 
@@ -1426,7 +1531,10 @@ JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResource_getResourceInterface
 {
     LOGD("OcResource_getResourceInterfaces");
     JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
-    if (!resource) return nullptr;
+    if (!resource)
+    {
+        return nullptr;
+    }
 
     std::vector<std::string> resourceInterfaces = resource->getResourceInterfaces();
 
@@ -1443,11 +1551,17 @@ JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResource_getUniqueIdentifier
 {
     LOGD("OcResource_getUniqueIdentifier");
     JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
-    if (!resource) return nullptr;
+    if (!resource)
+    {
+        return nullptr;
+    }
 
     JniOcResourceIdentifier *jniResourceIdentifier =
         new JniOcResourceIdentifier(resource->uniqueIdentifier());
-    if (!jniResourceIdentifier) return nullptr;
+    if (!jniResourceIdentifier)
+    {
+        return nullptr;
+    }
 
     jlong handle = reinterpret_cast<jlong>(jniResourceIdentifier);
     jobject jResourceIdentifier = env->NewObject(g_cls_OcResourceIdentifier,
@@ -1469,7 +1583,10 @@ JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getServerId
 {
     LOGD("OcResource_getServerId");
     JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
-    if (!resource) return nullptr;
+    if (!resource)
+    {
+        return nullptr;
+    }
 
     return env->NewStringUTF(resource->sid().c_str());
 }
@@ -1485,4 +1602,4 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_dispose
     LOGD("OcResource_dispose");
     JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
     delete resource;
-}
\ No newline at end of file
+}
index 2d438f2..92371f4 100644 (file)
@@ -25,7 +25,8 @@ using namespace OC;
 
 JniOcResourceHandle::JniOcResourceHandle(OCResourceHandle resourceHandle)
     : m_resourceHandle(resourceHandle)
-{}
+{
+}
 
 JniOcResourceHandle::~JniOcResourceHandle()
 {
@@ -63,4 +64,4 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceHandle_dispose
     LOGD("OcResourceHandle_dispose");
     JniOcResourceHandle *resourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(env, thiz);
     delete resourceHandle;
-}
\ No newline at end of file
+}
index b0b7d65..beeb724 100644 (file)
@@ -24,7 +24,8 @@
 
 JniOcResourceIdentifier::JniOcResourceIdentifier(OC::OCResourceIdentifier resourceIdentifier)
     : m_resourceIdentifier(resourceIdentifier)
-{}
+{
+}
 
 JniOcResourceIdentifier::~JniOcResourceIdentifier()
 {
@@ -60,10 +61,16 @@ JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcResourceIdentifier_equalsN
 (JNIEnv *env, jobject jThiz, jobject jOther)
 {
     JniOcResourceIdentifier *thiz = JniOcResourceIdentifier::getJniOcResourceIdentifierPtr(env, jThiz);
-    if (!thiz) return false;
+    if (!thiz)
+    {
+        return false;
+    }
 
     JniOcResourceIdentifier *other = JniOcResourceIdentifier::getJniOcResourceIdentifierPtr(env, jOther);
-    if (!other) return false;
+    if (!other)
+    {
+        return false;
+    }
 
     if (thiz->getOCResourceIdentifier() == other->getOCResourceIdentifier())
     {
@@ -86,4 +93,4 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceIdentifier_dispose
     LOGD("JniOcResourceIdentifier_dispose");
     JniOcResourceIdentifier *identifier = JniOcResourceIdentifier::getJniOcResourceIdentifierPtr(env, thiz);
     delete identifier;
-}
\ No newline at end of file
+}
index c943f70..c977bac 100644 (file)
@@ -29,10 +29,12 @@ using namespace OC;
 
 JniOcResourceRequest::JniOcResourceRequest(const std::shared_ptr<OCResourceRequest> request)
     : m_request(request)
-{}
+{
+}
 
 JniOcResourceRequest::~JniOcResourceRequest()
-{}
+{
+}
 
 std::string
 JniOcResourceRequest::getRequestType()
@@ -119,8 +121,10 @@ JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResourceRequest_getRequestTyp
 {
     LOGD("OcResourceRequest_getRequestTypeNative");
     JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
-    if (!request) return nullptr;
-
+    if (!request)
+    {
+        return nullptr;
+    }
     std::string requestType = request->getRequestType();
     return env->NewStringUTF(requestType.c_str());
 }
@@ -135,7 +139,10 @@ JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getQueryParam
 {
     LOGD("OcResourceRequest_getQueryParameters");
     JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
-    if (!request) return nullptr;
+    if (!request)
+    {
+        return nullptr;
+    }
 
     return JniUtils::convertQueryParamsMapToJavaMap(env, request->getQueryParameters());
 }
@@ -150,7 +157,10 @@ JNIEXPORT jint JNICALL Java_org_iotivity_base_OcResourceRequest_getRequestHandle
 {
     LOGD("OcResourceRequest_getRequestHandlerFlagNative");
     JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
-    if (!request) return -1;
+    if (!request)
+    {
+        return -1;
+    }
 
     return static_cast<jint>(request->getRequestHandlerFlag());
 }
@@ -165,10 +175,16 @@ JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getResourceRe
 {
     LOGD("OcResourceRequest_getResourceRepresentation");
     JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
-    if (!request) return nullptr;
+    if (!request)
+    {
+        return nullptr;
+    }
 
     OCRepresentation *ocRepresentation = new OCRepresentation(request->getResourceRepresentation());
-    if (!ocRepresentation) return nullptr;
+    if (!ocRepresentation)
+    {
+        return nullptr;
+    }
 
     jlong handle = reinterpret_cast<jlong>(ocRepresentation);
     jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool,
@@ -192,8 +208,10 @@ JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getObservatio
 {
     LOGD("OcResourceRequest_getObservationInfo");
     JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
-    if (!request) return nullptr;
-
+    if (!request)
+    {
+        return nullptr;
+    }
     ObservationInfo oInfo = request->getObservationInfo();
 
     jobject jObservationInfo = env->NewObject(g_cls_ObservationInfo, g_mid_ObservationInfo_N_ctor,
@@ -222,8 +240,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceRequest_setResourceUri
         return;
     }
     JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
-    if (!request) return;
-
+    if (!request)
+    {
+        return;
+    }
     request->setResourceUri(env->GetStringUTFChars(jUri, 0));
 }
 
@@ -237,8 +257,10 @@ JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResourceRequest_getResourceUr
 {
     LOGD("OcResourceRequest_getResourceUri");
     JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
-    if (!request) return nullptr;
-
+    if (!request)
+    {
+        return nullptr;
+    }
     std::string requestUri = request->getResourceUri();
     return env->NewStringUTF(requestUri.c_str());
 }
@@ -253,8 +275,10 @@ JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getHeaderOpti
 {
     LOGD("OcResourceRequest_getHeaderOptions");
     JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
-    if (!request) return nullptr;
-
+    if (!request)
+    {
+        return nullptr;
+    }
     return JniUtils::convertHeaderOptionsVectorToJavaList(env, request->getHeaderOptions());
 }
 
@@ -268,7 +292,10 @@ JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getRequestHan
 {
     LOGD("OcResourceRequest_getRequestHandle");
     JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
-    if (!request) return nullptr;
+    if (!request)
+    {
+        return nullptr;
+    }
 
     JniOcRequestHandle* jniHandle = new JniOcRequestHandle(request->getRequestHandle());
     jlong handle = reinterpret_cast<jlong>(jniHandle);
@@ -292,7 +319,10 @@ JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getResourceHa
 {
     LOGD("OcResourceRequest_getResourceHandle");
     JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
-    if (!request) return nullptr;
+    if (!request)
+    {
+        return nullptr;
+    }
 
     JniOcResourceHandle* jniHandle = new JniOcResourceHandle(
         request->getResourceHandle());
@@ -318,4 +348,4 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceRequest_dispose
     LOGD("OcResourceRequest_dispose");
     JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
     delete request;
-}
\ No newline at end of file
+}
index 0781d9f..8189073 100644 (file)
@@ -30,10 +30,13 @@ using namespace OC;
 
 JniOcResourceResponse::JniOcResourceResponse
 (std::shared_ptr<OCResourceResponse> resourceResponse)
-: m_response(resourceResponse){}
+: m_response(resourceResponse)
+{
+}
 
 JniOcResourceResponse::~JniOcResourceResponse()
-{}
+{
+}
 
 void JniOcResourceResponse::setErrorCode(const int eCode)
 {
@@ -111,8 +114,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setErrorCode
 {
     LOGD("OcResourceResponse_setErrorCode");
     JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);
-    if (!response) return;
-
+    if (!response)
+    {
+        return;
+    }
     response->setErrorCode(static_cast<int>(eCode));
 }
 
@@ -126,8 +131,10 @@ JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResourceResponse_getNewResour
 {
     LOGD("OcResourceResponse_getNewResourceUri");
     JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);
-    if (!response) return nullptr;
-
+    if (!response)
+    {
+        return nullptr;
+    }
     return env->NewStringUTF(response->getNewResourceUri().c_str());
 }
 
@@ -141,8 +148,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setNewResourceU
 {
     LOGD("OcResourceResponse_setNewResourceUri");
     JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);
-    if (!response) return;
-
+    if (!response)
+    {
+        return;
+    }
     response->setNewResourceUri(env->GetStringUTFChars(jstr, 0));
 }
 
@@ -161,8 +170,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setHeaderOption
         return;
     }
     JniOcResourceResponse *jniResponse = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);
-    if (!jniResponse) return;
-
+    if (!jniResponse)
+    {
+        return;
+    }
     HeaderOptions headerOptions;
     JniUtils::convertJavaHeaderOptionsArrToVector(env, jHeaderOptions, headerOptions);
 
@@ -184,11 +195,15 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setRequestHandl
         return;
     }
     JniOcResourceResponse *jniResponse = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);
-    if (!jniResponse) return;
-
+    if (!jniResponse)
+    {
+        return;
+    }
     JniOcRequestHandle* jniOcRequestHandle = JniOcRequestHandle::getJniOcRequestHandlePtr(env, jRequestHandle);
-    if (!jniOcRequestHandle) return;
-
+    if (!jniOcRequestHandle)
+    {
+        return;
+    }
     jniResponse->setRequestHandle(jniOcRequestHandle->getOCRequestHandle());
 }
 
@@ -207,11 +222,15 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResourceHand
         return;
     }
     JniOcResourceResponse *jniResponse = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);
-    if (!jniResponse) return;
-
+    if (!jniResponse)
+    {
+        return;
+    }
     JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(env, jResourceHandle);
-    if (!jniOcResourceHandle) return;
-
+    if (!jniOcResourceHandle)
+    {
+        return;
+    }
     jniResponse->setResourceHandle(jniOcResourceHandle->getOCResourceHandle());
 }
 
@@ -225,8 +244,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResponseResu
 {
     LOGD("OcResourceResponse_setResponseResult");
     JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);
-    if (!response) return;
-
+    if (!response)
+    {
+        return;
+    }
     response->setResponseResult(JniUtils::getOCEntityHandlerResult(env, static_cast<int>(responseResult)));
 }
 
@@ -252,12 +273,16 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResourceRepr
 
     JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env,
         thiz);
-    if (!response) return;
-
+    if (!response)
+    {
+        return;
+    }
     OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env,
         jRepresentation);
-    if (!representation) return;
-
+    if (!representation)
+    {
+        return;
+    }
     response->setResourceRepresentation(*representation, env->GetStringUTFChars(jstr, 0));
 }
 
@@ -276,8 +301,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResourceRepr
         return;
     }
     JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);
-    if (!response) return;
-
+    if (!response)
+    {
+        return;
+    }
     OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env,
         jRepresentation);
 
@@ -317,4 +344,4 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_dispose
     LOGD("OcResourceResponse_dispose");
     JniOcResourceResponse *resp = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);
     delete resp;
-}
\ No newline at end of file
+}
index 77c8dc6..7585b7b 100644 (file)
 
 #include "JniOcSecureResource.h"
 #include "JniSecureUtils.h"
+#include "oic_string.h"
 namespace PH = std::placeholders;
 
 JniOcSecureResource::JniOcSecureResource(std::shared_ptr<OCSecureResource> device)
     : m_sharedSecureResource(device)
-{}
+{
+}
 
 JniOcSecureResource::~JniOcSecureResource()
 {
@@ -240,6 +242,89 @@ OCStackResult JniOcSecureResource::provisionACL(JNIEnv* env, jobject _acl, jobje
     return ret;
 }
 
+OCStackResult JniOcSecureResource::provisionDirectPairing(JNIEnv* env, jobjectArray jpdacls,
+        jobject jListener, std::string pin, std::vector<int> prms, int edp)
+{
+    OCStackResult ret;
+    JniProvisionResultListner *resultListener = AddProvisionResultListener(env, jListener);
+
+    jsize len = env->GetArrayLength(jpdacls);
+
+    OicSecPconf_t *pconf = nullptr;
+    OicSecPdAcl_t *head = nullptr;
+
+    for (jsize i = 0; i < len; ++i)
+    {
+        OicSecPdAcl_t *pdacl = new OicSecPdAcl_t;
+        if (!pdacl)
+        {
+            return OC_STACK_NO_MEMORY;
+        }
+
+        memset(pdacl, 0, sizeof(OicSecPdAcl_t));
+        pdacl->next = nullptr;
+
+        jobject jpdacl  = env->GetObjectArrayElement(jpdacls, i);
+
+        if (OC_STACK_OK != JniSecureUtils::convertJavaPdACLToOCAcl(env, jpdacl, pdacl))
+        {
+            delete pdacl;
+            return OC_STACK_ERROR;
+        }
+
+        pdacl->next = head;
+        head = pdacl;
+    }
+
+    pconf = new OicSecPconf_t;
+    memset(pconf, 0, sizeof(OicSecPconf_t));
+    pconf->edp = edp;
+    pconf->prmLen = prms.size();
+    pconf->prm = new OicSecPrm_t[pconf->prmLen];
+    pconf->pddevLen = 0;
+
+    for (int i = 0 ; i < prms.size(); i++)
+        pconf->prm[i] = (OicSecPrm_t)prms[i];
+
+    memcpy(pconf->pin.val, pin.c_str(), DP_PIN_LENGTH);
+    pconf->pdacls = head;
+
+    ResultCallBack resultCallback = [head, resultListener, pconf, prms]
+        (PMResultList_t *result, int hasError)
+        {
+            OicSecPdAcl_t *tmp1, *tmp2;
+            tmp1 = head;
+            while (tmp1)
+            {
+                tmp2 = tmp1->next;
+                delete tmp1;
+                tmp1 = tmp2;
+            }
+
+            delete pconf->prm;
+            delete pconf;
+            resultListener->ProvisionResultCallback(result, hasError, ListenerFunc::PROVISIONDIRECTPAIRING);
+        };
+
+    ret = m_sharedSecureResource->provisionDirectPairing(pconf, resultCallback);
+
+    if (ret != OC_STACK_OK)
+    {
+        OicSecPdAcl_t *tmp1, *tmp2;
+        tmp1 = head;
+        while (tmp1)
+        {
+            tmp2 = tmp1->next;
+            delete tmp1;
+            tmp1 = tmp2;
+        }
+
+        delete pconf->prm;
+        delete pconf;
+    }
+    return ret;
+}
+
 OCStackResult JniOcSecureResource::provisionPairwiseDevices(JNIEnv* env, jint type, jint keySize,
         jobject _acl1, jobject _device2, jobject _acl2, jobject jListener)
 {
@@ -541,6 +626,55 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcSecureResource_provisionPairwise
     }
 }
 
+/*
+ * Class:     org_iotivity_base_OcSecureResource
+ * Method:    provisionDirectPairing
+ * Signature: (Ljava/lang/String;[Lorg/iotivity/base/OicSecPdAcl;ILorg/iotivity/base/OcSecureResource/ProvisionDirectPairingListener;I)V
+ */
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcSecureResource_provisionDirectPairing
+(JNIEnv *env, jobject thiz, jstring jpin, jobjectArray pdacls, jintArray jprmType,
+    jint jedp, jobject jListener)
+{
+    LOGD("OcSecureResource_provisionDirectPairing");
+    if (!jListener || !pdacls || !jpin || ! jprmType)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "Invalid Parameters");
+        return;
+    }
+    std::string pin = env->GetStringUTFChars(jpin, nullptr);
+
+    JniOcSecureResource *secureResource = JniOcSecureResource::getJniOcSecureResourcePtr(env, thiz);
+    if (!secureResource)
+    {
+        return;
+    }
+
+    const jsize len = env->GetArrayLength(jprmType);
+    jint* ints = env->GetIntArrayElements(jprmType, nullptr);
+    std::vector<int> value;
+    for (jsize i = 0; i < len; ++i)
+    {
+        value.push_back(static_cast<int>(ints[i]));
+    }
+    env->ReleaseIntArrayElements(jprmType, ints, JNI_ABORT);
+
+    try
+    {
+        OCStackResult result = secureResource->provisionDirectPairing(env, pdacls, jListener,
+                pin, value, static_cast<int>(jedp));
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OcSecureResource_provisionDirectPairing");
+            return;
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+}
+
 /*
  * Class:     org_iotivity_base_OcSecureResource
  * Method:    getLinkedDevices
index 0b98f75..d071e96 100644 (file)
@@ -55,7 +55,8 @@ class JniOcSecureResource
                 jobject device2, jobject jListener);
         OCStackResult unlinkDevices(JNIEnv* env, jobject device2, jobject jListener);
         OCStackResult removeDevice(JNIEnv* env, jint timeout, jobject jListener);
-
+        OCStackResult provisionDirectPairing(JNIEnv* env, jobjectArray jpdacls,jobject jListener,
+                std::string pin, std::vector<int> prms, int edp);
     private:
 
         std::map<jobject, std::pair<JniProvisionResultListner*, int>> resultMap;
@@ -116,6 +117,14 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcSecureResource_provisionACL
 JNIEXPORT void JNICALL Java_org_iotivity_base_OcSecureResource_provisionPairwiseDevices1
   (JNIEnv *, jobject, jint, jint, jobject, jobject, jobject, jobject);
 
+/*
+ * Class:     org_iotivity_base_OcSecureResource
+ * Method:    provisionDirectPairing
+ * Signature: (Ljava/lang/Object;Lorg/iotivity/base/OcSecureResource/ProvisionDirectPairingListener;)V
+ */
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcSecureResource_provisionDirectPairing
+  (JNIEnv *, jobject, jstring, jobjectArray, jintArray, jint, jobject);
+
 /*
  * Class:     org_iotivity_base_OcSecureResource
  * Method:    getLinkedDevices
index c5c3d7d..e2c6175 100644 (file)
 #include "OCRepresentation.h"
 #include "JniUtils.h"
 
+/**
+ * Macro to verify the validity of input argument.
+ *
+ * @param  arg  log level
+ */
+#define VERIFY_VARIABLE_NULL(arg) \
+    if (nullptr == (arg)) \
+    { \
+        LOGE("invalid input"); \
+        return JNI_ERR; \
+    } \
+
 JavaVM* g_jvm = nullptr;
 
 jclass g_cls_Integer = nullptr;
@@ -62,6 +74,8 @@ jclass g_cls_OcResourceIdentifier = nullptr;
 jclass g_cls_OcProvisionResult = nullptr;
 jclass g_cls_OcSecureResource = nullptr;
 jclass g_cls_OcOicSecAcl = nullptr;
+jclass g_cls_OcOicSecPdAcl = nullptr;
+jclass g_cls_OcDirectPairDevice = nullptr;
 
 jmethodID g_mid_Integer_ctor = nullptr;
 jmethodID g_mid_Double_ctor = nullptr;
@@ -94,6 +108,8 @@ jmethodID g_mid_OcPresenceStatus_get = nullptr;
 jmethodID g_mid_OcResourceIdentifier_N_ctor = nullptr;
 jmethodID g_mid_OcProvisionResult_ctor = nullptr;
 jmethodID g_mid_OcSecureResource_ctor = nullptr;
+jmethodID g_mid_OcDirectPairDevice_ctor = nullptr;
+jmethodID g_mid_OcDirectPairDevice_dev_ctor = nullptr;
 
 jmethodID g_mid_OcOicSecAcl_get_subject = nullptr;
 jmethodID g_mid_OcOicSecAcl_get_resources_cnt = nullptr;
@@ -103,6 +119,12 @@ jmethodID g_mid_OcOicSecAcl_get_periods_cnt = nullptr;
 jmethodID g_mid_OcOicSecAcl_get_periods = nullptr;
 jmethodID g_mid_OcOicSecAcl_get_recurrences = nullptr;
 jmethodID g_mid_OcOicSecAcl_get_rownerID = nullptr;
+jmethodID g_mid_OcOicSecPdAcl_get_resources_cnt = nullptr;
+jmethodID g_mid_OcOicSecPdAcl_get_resources = nullptr;
+jmethodID g_mid_OcOicSecPdAcl_get_permission = nullptr;
+jmethodID g_mid_OcOicSecPdAcl_get_periods_cnt = nullptr;
+jmethodID g_mid_OcOicSecPdAcl_get_periods = nullptr;
+jmethodID g_mid_OcOicSecPdAcl_get_recurrences = nullptr;
 
 jobject getOcException(JNIEnv* env, const char* file, const char* functionName,
     const int line, const int code, const char* message)
@@ -141,7 +163,7 @@ void throwOcException(JNIEnv* env, jobject ex)
 JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
 {
     LOGI("JNI_OnLoad");
-    JNIEnv* env;
+    JNIEnv* env = nullptr;
     g_jvm = vm;
 
     if (g_jvm->GetEnv((void **)&env, JNI_CURRENT_VERSION) != JNI_OK)
@@ -149,316 +171,353 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
         LOGE("Failed to get the environment using GetEnv()");
         return JNI_ERR;
     }
+    VERIFY_VARIABLE_NULL(env);
 
     jclass clazz = nullptr;
 
     //Integer
     clazz = env->FindClass("java/lang/Integer");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
+
     g_cls_Integer = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
 
     g_mid_Integer_ctor = env->GetMethodID(g_cls_Integer, "<init>", "(I)V");
-    if (!g_mid_Integer_ctor) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_Integer_ctor);
 
     clazz = env->FindClass("[I");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_int1DArray = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
 
     clazz = env->FindClass("[[I");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_int2DArray = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
 
     //Double
     clazz = env->FindClass("java/lang/Double");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_Double = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
 
     g_mid_Double_ctor = env->GetMethodID(g_cls_Double, "<init>", "(D)V");
-    if (!g_mid_Double_ctor) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_Double_ctor);
 
     clazz = env->FindClass("[D");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_double1DArray = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
 
     clazz = env->FindClass("[[D");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_double2DArray = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
 
     //Boolean
     clazz = env->FindClass("java/lang/Boolean");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_Boolean = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
 
     g_mid_Boolean_ctor = env->GetMethodID(g_cls_Boolean, "<init>", "(Z)V");
-    if (!g_mid_Boolean_ctor) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_Boolean_ctor);
 
     clazz = env->FindClass("[Z");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_boolean1DArray = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
 
     clazz = env->FindClass("[[Z");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_boolean2DArray = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
 
     //String
     clazz = env->FindClass("java/lang/String");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_String = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
 
     clazz = env->FindClass("[Ljava/lang/String;");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_String1DArray = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
 
     clazz = env->FindClass("[[Ljava/lang/String;");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_String2DArray = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
 
     //LinkedList
     clazz = env->FindClass("java/util/LinkedList");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_LinkedList = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
 
     g_mid_LinkedList_ctor = env->GetMethodID(g_cls_LinkedList, "<init>", "()V");
-    if (!g_mid_LinkedList_ctor) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_LinkedList_ctor);
 
     g_mid_LinkedList_add_object = env->GetMethodID(g_cls_LinkedList, "add", "(Ljava/lang/Object;)Z");
-    if (!g_mid_LinkedList_add_object) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_LinkedList_add_object);
 
     //Map
     clazz = env->FindClass("java/util/Map");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_Map = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
 
     g_mid_Map_entrySet = env->GetMethodID(g_cls_Map, "entrySet", "()Ljava/util/Set;");
-    if (!g_mid_Map_entrySet) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_Map_entrySet);
 
     //MapEntry
     clazz = env->FindClass("java/util/Map$Entry");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_MapEntry = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
 
     g_mid_MapEntry_getKey = env->GetMethodID(g_cls_MapEntry, "getKey", "()Ljava/lang/Object;");
-    if (!g_mid_MapEntry_getKey) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_MapEntry_getKey);
     g_mid_MapEntry_getValue = env->GetMethodID(g_cls_MapEntry, "getValue", "()Ljava/lang/Object;");
-    if (!g_mid_MapEntry_getValue) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_MapEntry_getValue);
 
     //Set
     clazz = env->FindClass("java/util/Set");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_Set = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
 
     g_mid_Set_iterator = env->GetMethodID(g_cls_Set, "iterator", "()Ljava/util/Iterator;");
-    if (!g_mid_Set_iterator) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_Set_iterator);
 
     //Iterator
     clazz = env->FindClass("java/util/Iterator");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_Iterator = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
 
     g_mid_Iterator_hasNext = env->GetMethodID(g_cls_Iterator, "hasNext", "()Z");
-    if (!g_mid_Iterator_hasNext) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_Iterator_hasNext);
 
     g_mid_Iterator_next = env->GetMethodID(g_cls_Iterator, "next", "()Ljava/lang/Object;");
-    if (!g_mid_Iterator_next) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_Iterator_next);
 
     //HashMap
     clazz = env->FindClass("java/util/HashMap");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_HashMap = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
 
     g_mid_HashMap_ctor = env->GetMethodID(g_cls_HashMap, "<init>", "()V");
-    if (!g_mid_HashMap_ctor) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_HashMap_ctor);
 
     g_mid_HashMap_put = env->GetMethodID(g_cls_HashMap, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
-    if (!g_mid_HashMap_put) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_HashMap_put);
 
     //OcException
     clazz = env->FindClass("org/iotivity/base/OcException");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_OcException = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
 
     g_mid_OcException_ctor = env->GetMethodID(g_cls_OcException, "<init>", "(Ljava/lang/String;Ljava/lang/String;)V");
-    if (!g_mid_OcException_ctor) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_OcException_ctor);
 
     g_mid_OcException_setNativeExceptionLocation = env->GetMethodID(g_cls_OcException, "setNativeExceptionLocation",
         "(Ljava/lang/String;""Ljava/lang/String;""I)V");
-    if (!g_mid_OcException_setNativeExceptionLocation) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_OcException_setNativeExceptionLocation);
 
     //OcResource
     clazz = env->FindClass("org/iotivity/base/OcResource");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_OcResource = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
 
     g_mid_OcResource_ctor = env->GetMethodID(g_cls_OcResource, "<init>", "(J)V");
-    if (!g_mid_OcResource_ctor) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_OcResource_ctor);
 
     //OcRepresentation
     clazz = env->FindClass("org/iotivity/base/OcRepresentation");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_OcRepresentation = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
 
     g_mid_OcRepresentation_N_ctor = env->GetMethodID(g_cls_OcRepresentation, "<init>", "(J)V");
-    if (!g_mid_OcRepresentation_N_ctor) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_OcRepresentation_N_ctor);
 
     g_mid_OcRepresentation_N_ctor_bool = env->GetMethodID(g_cls_OcRepresentation, "<init>", "(JZ)V");
-    if (!g_mid_OcRepresentation_N_ctor_bool) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_OcRepresentation_N_ctor_bool);
 
     clazz = env->FindClass("[Lorg/iotivity/base/OcRepresentation;");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_OcRepresentation1DArray = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
 
     clazz = env->FindClass("[[Lorg/iotivity/base/OcRepresentation;");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_OcRepresentation2DArray = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
 
     //HeaderOptions
     clazz = env->FindClass("org/iotivity/base/OcHeaderOption");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_OcHeaderOption = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
     g_mid_OcHeaderOption_ctor = env->GetMethodID(g_cls_OcHeaderOption, "<init>", "(ILjava/lang/String;)V");
-    if (!g_mid_OcHeaderOption_ctor) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_OcHeaderOption_ctor);
 
     g_mid_OcHeaderOption_get_id = env->GetMethodID(g_cls_OcHeaderOption, "getOptionId", "()I");
-    if (!g_mid_OcHeaderOption_get_id) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_OcHeaderOption_get_id);
 
     g_mid_OcHeaderOption_get_data = env->GetMethodID(g_cls_OcHeaderOption, "getOptionData", "()Ljava/lang/String;");
-    if (!g_mid_OcHeaderOption_get_data) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_OcHeaderOption_get_data);
 
     //OcResourceRequest
     clazz = env->FindClass("org/iotivity/base/OcResourceRequest");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_OcResourceRequest = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
 
     g_mid_OcResourceRequest_N_ctor = env->GetMethodID(g_cls_OcResourceRequest, "<init>", "(J)V");
-    if (!g_mid_OcResourceRequest_N_ctor) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_OcResourceRequest_N_ctor);
 
     //OcResourceResponse
     clazz = env->FindClass("org/iotivity/base/OcResourceResponse");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_OcResourceResponse = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
 
     g_mid_OcResourceResponse_N_ctor = env->GetMethodID(g_cls_OcResourceResponse, "<init>", "(J)V");
-    if (!g_mid_OcResourceResponse_N_ctor) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_OcResourceResponse_N_ctor);
 
     //OcResourceHandle
     clazz = env->FindClass("org/iotivity/base/OcResourceHandle");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_OcResourceHandle = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
     g_mid_OcResourceHandle_N_ctor = env->GetMethodID(g_cls_OcResourceHandle, "<init>", "(J)V");
-    if (!g_mid_OcResourceHandle_N_ctor) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_OcResourceHandle_N_ctor);
 
     //OcPresenceHandle
     clazz = env->FindClass("org/iotivity/base/OcPresenceHandle");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_OcPresenceHandle = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
     g_mid_OcPresenceHandle_N_ctor = env->GetMethodID(g_cls_OcPresenceHandle, "<init>", "(J)V");
-    if (!g_mid_OcPresenceHandle_N_ctor) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_OcPresenceHandle_N_ctor);
 
     //OcRequestHandle
     clazz = env->FindClass("org/iotivity/base/OcRequestHandle");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_OcRequestHandle = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
     g_mid_OcRequestHandle_N_ctor = env->GetMethodID(g_cls_OcRequestHandle, "<init>", "(J)V");
-    if (!g_mid_OcRequestHandle_N_ctor) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_OcRequestHandle_N_ctor);
 
     //OcPresenceStatus
     clazz = env->FindClass("org/iotivity/base/OcPresenceStatus");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_OcPresenceStatus = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
     g_mid_OcPresenceStatus_get = env->GetStaticMethodID(g_cls_OcPresenceStatus, "get",
         "(Ljava/lang/String;)Lorg/iotivity/base/OcPresenceStatus;");
-    if (!g_mid_OcPresenceStatus_get) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_OcPresenceStatus_get);
 
     //ObservationInfo
     clazz = env->FindClass("org/iotivity/base/ObservationInfo");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_ObservationInfo = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
     g_mid_ObservationInfo_N_ctor = env->GetMethodID(g_cls_ObservationInfo, "<init>", "(IB)V");
-    if (!g_mid_ObservationInfo_N_ctor) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_ObservationInfo_N_ctor);
 
     clazz = env->FindClass("org/iotivity/base/OcResourceIdentifier");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_OcResourceIdentifier = (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
     g_mid_OcResourceIdentifier_N_ctor = env->GetMethodID(g_cls_OcResourceIdentifier, "<init>", "(J)V");
-    if (!g_mid_OcResourceIdentifier_N_ctor) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_OcResourceIdentifier_N_ctor);
 
     //OcSecureResource
     clazz = env->FindClass("org/iotivity/base/OcSecureResource");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_OcSecureResource =  (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
     g_mid_OcSecureResource_ctor = env->GetMethodID(g_cls_OcSecureResource, "<init>", "(J)V");
-    if (!g_mid_OcSecureResource_ctor) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_OcSecureResource_ctor);
 
     //ProvisionResult
     clazz = env->FindClass("org/iotivity/base/ProvisionResult");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_OcProvisionResult =  (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
     g_mid_OcProvisionResult_ctor = env->GetMethodID(g_cls_OcProvisionResult, "<init>", "(Ljava/lang/String;I)V");
-    if (!g_mid_OcProvisionResult_ctor) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_OcProvisionResult_ctor);
+
+    //OcDirectPairDevice
+    clazz = env->FindClass("org/iotivity/base/OcDirectPairDevice");
+    VERIFY_VARIABLE_NULL(clazz);
+    g_cls_OcDirectPairDevice =  (jclass)env->NewGlobalRef(clazz);
+    g_mid_OcDirectPairDevice_ctor = env->GetMethodID(g_cls_OcDirectPairDevice, "<init>", "(J)V");
+    VERIFY_VARIABLE_NULL(g_mid_OcDirectPairDevice_ctor);
+
+    g_mid_OcDirectPairDevice_dev_ctor = env->GetMethodID(g_cls_OcDirectPairDevice, "<init>", "(Ljava/lang/String;)V");
+    VERIFY_VARIABLE_NULL(g_mid_OcDirectPairDevice_dev_ctor);
+    env->DeleteLocalRef(clazz);
 
     //OicSecAcl
     clazz = env->FindClass("org/iotivity/base/OicSecAcl");
-    if (!clazz) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(clazz);
     g_cls_OcOicSecAcl =  (jclass)env->NewGlobalRef(clazz);
     env->DeleteLocalRef(clazz);
 
     g_mid_OcOicSecAcl_get_subject = env->GetMethodID(g_cls_OcOicSecAcl, "getSubject", "()Ljava/lang/String;");
-    if (!g_mid_OcOicSecAcl_get_subject) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_OcOicSecAcl_get_subject);
 
     g_mid_OcOicSecAcl_get_resources_cnt = env->GetMethodID(g_cls_OcOicSecAcl, "getResourcesCount", "()I");
-    if (!g_mid_OcOicSecAcl_get_resources_cnt) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_OcOicSecAcl_get_resources_cnt);
 
     g_mid_OcOicSecAcl_get_resources = env->GetMethodID(g_cls_OcOicSecAcl, "getResources", "(I)Ljava/lang/String;");
-    if (!g_mid_OcOicSecAcl_get_resources) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_OcOicSecAcl_get_resources);
 
     g_mid_OcOicSecAcl_get_permission = env->GetMethodID(g_cls_OcOicSecAcl, "getPermission", "()I");
-    if (!g_mid_OcOicSecAcl_get_permission) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_OcOicSecAcl_get_permission);
 
     g_mid_OcOicSecAcl_get_periods_cnt = env->GetMethodID(g_cls_OcOicSecAcl, "getPeriodsCount", "()I");
-    if (!g_mid_OcOicSecAcl_get_periods_cnt) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_OcOicSecAcl_get_periods_cnt);
 
     g_mid_OcOicSecAcl_get_periods = env->GetMethodID(g_cls_OcOicSecAcl, "getPeriods", "(I)Ljava/lang/String;");
-    if (!g_mid_OcOicSecAcl_get_periods) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_OcOicSecAcl_get_periods);
 
     g_mid_OcOicSecAcl_get_recurrences = env->GetMethodID(g_cls_OcOicSecAcl, "getRecurrences", "(I)Ljava/lang/String;");
-    if (!g_mid_OcOicSecAcl_get_recurrences) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_OcOicSecAcl_get_recurrences);
 
     g_mid_OcOicSecAcl_get_rownerID = env->GetMethodID(g_cls_OcOicSecAcl, "getRownerID", "()Ljava/lang/String;");
-    if (!g_mid_OcOicSecAcl_get_rownerID) return JNI_ERR;
+    VERIFY_VARIABLE_NULL(g_mid_OcOicSecAcl_get_rownerID);
+
+    //OicSecPdAcl
+    clazz = env->FindClass("org/iotivity/base/OicSecPdAcl");
+    VERIFY_VARIABLE_NULL(clazz);
+    g_cls_OcOicSecPdAcl =  (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+
+    g_mid_OcOicSecPdAcl_get_resources_cnt = env->GetMethodID(g_cls_OcOicSecPdAcl, "getResourcesCount", "()I");
+    VERIFY_VARIABLE_NULL(g_mid_OcOicSecPdAcl_get_resources_cnt);
+
+    g_mid_OcOicSecPdAcl_get_resources = env->GetMethodID(g_cls_OcOicSecPdAcl, "getResources", "(I)Ljava/lang/String;");
+    VERIFY_VARIABLE_NULL(g_mid_OcOicSecPdAcl_get_resources);
+
+    g_mid_OcOicSecPdAcl_get_permission = env->GetMethodID(g_cls_OcOicSecPdAcl, "getPermission", "()I");
+    VERIFY_VARIABLE_NULL(g_mid_OcOicSecPdAcl_get_permission);
+
+    g_mid_OcOicSecPdAcl_get_periods_cnt = env->GetMethodID(g_cls_OcOicSecPdAcl, "getPeriodsCount", "()I");
+    VERIFY_VARIABLE_NULL(g_mid_OcOicSecPdAcl_get_periods_cnt);
+
+    g_mid_OcOicSecPdAcl_get_periods = env->GetMethodID(g_cls_OcOicSecPdAcl, "getPeriods", "(I)Ljava/lang/String;");
+    VERIFY_VARIABLE_NULL(g_mid_OcOicSecPdAcl_get_periods);
+
+    g_mid_OcOicSecPdAcl_get_recurrences = env->GetMethodID(g_cls_OcOicSecPdAcl, "getRecurrences", "(I)Ljava/lang/String;");
+    VERIFY_VARIABLE_NULL(g_mid_OcOicSecPdAcl_get_recurrences);
 
     return JNI_CURRENT_VERSION;
 }
@@ -474,6 +533,7 @@ JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved)
         return;
     }
 
+
     env->DeleteGlobalRef(g_cls_Integer);
     env->DeleteGlobalRef(g_cls_int1DArray);
     env->DeleteGlobalRef(g_cls_int2DArray);
@@ -509,4 +569,4 @@ JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved)
     env->DeleteGlobalRef(g_cls_OcSecureResource);
     env->DeleteGlobalRef(g_cls_OcProvisionResult);
     env->DeleteGlobalRef(g_cls_OcOicSecAcl);
-}
\ No newline at end of file
+}
index b9f2ccd..7f7e851 100644 (file)
@@ -82,6 +82,8 @@ extern jclass g_cls_OcResourceIdentifier;
 extern jclass g_cls_OcProvisionResult;
 extern jclass g_cls_OcSecureResource;
 extern jclass g_cls_OcOicSecAcl;
+extern jclass g_cls_OcOicSecPdAcl;
+extern jclass g_cls_OcDirectPairDevice;
 
 extern jmethodID g_mid_Integer_ctor;
 extern jmethodID g_mid_Double_ctor;
@@ -114,6 +116,8 @@ extern jmethodID g_mid_OcPresenceStatus_get;
 extern jmethodID g_mid_OcResourceIdentifier_N_ctor;
 extern jmethodID g_mid_OcProvisionResult_ctor;
 extern jmethodID g_mid_OcSecureResource_ctor;
+extern jmethodID g_mid_OcDirectPairDevice_ctor;
+extern jmethodID g_mid_OcDirectPairDevice_dev_ctor;
 extern jmethodID g_mid_OcOicSecAcl_get_subject;
 extern jmethodID g_mid_OcOicSecAcl_get_resources_cnt;
 extern jmethodID g_mid_OcOicSecAcl_get_resources;
@@ -122,6 +126,12 @@ extern jmethodID g_mid_OcOicSecAcl_get_periods_cnt;
 extern jmethodID g_mid_OcOicSecAcl_get_periods;
 extern jmethodID g_mid_OcOicSecAcl_get_recurrences;
 extern jmethodID g_mid_OcOicSecAcl_get_rownerID;
+extern jmethodID g_mid_OcOicSecPdAcl_get_resources_cnt;
+extern jmethodID g_mid_OcOicSecPdAcl_get_resources;
+extern jmethodID g_mid_OcOicSecPdAcl_get_permission;
+extern jmethodID g_mid_OcOicSecPdAcl_get_periods_cnt;
+extern jmethodID g_mid_OcOicSecPdAcl_get_periods;
+extern jmethodID g_mid_OcOicSecPdAcl_get_recurrences;
 
 typedef void(*RemoveListenerCallback)(JNIEnv* env, jobject jListener);
 
@@ -151,26 +161,29 @@ static JNIEnv* GetJNIEnv(jint& ret)
     JNIEnv *env = nullptr;
 
     ret = g_jvm->GetEnv((void **)&env, JNI_CURRENT_VERSION);
-    switch (ret) {
-    case JNI_OK:
-        return env;
-    case JNI_EDETACHED:
-        if (g_jvm->AttachCurrentThread(&env, nullptr) < 0)
-        {
+    switch (ret)
+    {
+        case JNI_OK:
+            return env;
+        case JNI_EDETACHED:
+            if (g_jvm->AttachCurrentThread(&env, nullptr) < 0)
+            {
+                LOGE("Failed to get the environment");
+                return nullptr;
+            }
+            else
+            {
+                return env;
+            }
+
+        case JNI_EVERSION:
+            LOGE("JNI version not supported");
+            break;
+        default:
             LOGE("Failed to get the environment");
             return nullptr;
-        }
-        else
-        {
-            return env;
-        }
-
-    case JNI_EVERSION:
-        LOGE("JNI version not supported");
-    default:
-        LOGE("Failed to get the environment");
-        return nullptr;
     }
+    return nullptr;
 }
 
 static void DuplicateString(char ** targetString, std::string sourceString)
@@ -179,4 +192,4 @@ static void DuplicateString(char ** targetString, std::string sourceString)
     strncpy(*targetString, sourceString.c_str(), (sourceString.length() + 1));
 }
 
-#endif // _Included_org_iotivity_base_ocstack
\ No newline at end of file
+#endif // _Included_org_iotivity_base_ocstack
diff --git a/android/android_api/base/jni/JniOnDPDevicesFoundListener.cpp b/android/android_api/base/jni/JniOnDPDevicesFoundListener.cpp
new file mode 100644 (file)
index 0000000..13db923
--- /dev/null
@@ -0,0 +1,190 @@
+/*
+* //******************************************************************
+* //
+* // Copyright 2016 Samsung Electronics All Rights Reserved.
+* //
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+* //
+* // Licensed under the Apache License, Version 2.0 (the "License");
+* // you may not use this file except in compliance with the License.
+* // You may obtain a copy of the License at
+* //
+* //      http://www.apache.org/licenses/LICENSE-2.0
+* //
+* // Unless required by applicable law or agreed to in writing, software
+* // distributed under the License is distributed on an "AS IS" BASIS,
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* // See the License for the specific language governing permissions and
+* // limitations under the License.
+* //
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+*/
+#include "JniOnDPDevicesFoundListener.h"
+#include "JniOcDirectPairDevice.h"
+#include "OCApi.h"
+using namespace OC;
+
+JniOnDPDevicesFoundListener::JniOnDPDevicesFoundListener(JNIEnv *env, jobject jListener,
+    RemoveListenerCallback removeListenerCallback)
+{
+    m_jwListener = env->NewWeakGlobalRef(jListener);
+    m_removeListenerCallback = removeListenerCallback;
+}
+
+jobject JniOnDPDevicesFoundListener::convertdpDevVectorToJavaList(JNIEnv *env, PairedDevices DPdevList)
+{
+    jobject jResultList = env->NewObject(g_cls_LinkedList, g_mid_LinkedList_ctor);
+    if (!jResultList)
+    {
+        return nullptr;
+    }
+
+    for (size_t i = 0; i < DPdevList.size(); ++i)
+    {
+        JniOcDirectPairDevice *device = new JniOcDirectPairDevice(DPdevList.at(i));
+        if (!device)
+        {
+            return nullptr;
+        }
+
+        jstring jStr = env->NewStringUTF(((DPdevList.at(i))->getDeviceID()).c_str());
+        if (!jStr)
+        {
+            return nullptr;
+        }
+        jobject jresult = env->NewObject(g_cls_OcDirectPairDevice,
+                g_mid_OcDirectPairDevice_dev_ctor,jStr);
+        if (!jresult)
+        {
+            return nullptr;
+        }
+
+        SetHandle<JniOcDirectPairDevice>(env, jresult, device);
+
+        env->CallBooleanMethod(jResultList, g_mid_LinkedList_add_object, jresult);
+        if (env->ExceptionCheck())
+        {
+            return nullptr;
+        }
+        env->DeleteLocalRef(jresult);
+        env->DeleteLocalRef(jStr);
+    }
+    return jResultList;
+}
+
+JniOnDPDevicesFoundListener::~JniOnDPDevicesFoundListener()
+{
+    LOGI("~JniOnDPDevicesFoundListener()");
+    if (m_jwListener)
+    {
+        jint ret = JNI_ERR;
+        JNIEnv *env = GetJNIEnv(ret);
+        if (nullptr == env)
+        {
+            return;
+        }
+        env->DeleteWeakGlobalRef(m_jwListener);
+        m_jwListener = nullptr;
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
+    }
+}
+
+void JniOnDPDevicesFoundListener::directPairingDevicesCallback(PairedDevices paringDevicesList, DPFunc func)
+{
+    jint ret;
+    JNIEnv *env = GetJNIEnv(ret);
+    if (nullptr == env)
+    {
+        return;
+    }
+
+    jobject jListener = env->NewLocalRef(m_jwListener);
+    if (!jListener)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
+        return;
+    }
+
+    jclass clsL = env->GetObjectClass(jListener);
+
+    if (!clsL)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
+        return;
+    }
+
+    jobject jpairingDevicesList = convertdpDevVectorToJavaList(env, paringDevicesList);
+    std::string calledFunc;
+    switch (func)
+    {
+        case DPFunc::FIND_DIRECT_PAIRED_DEV_LIST:
+            {
+                calledFunc = "onFindDirectPairingListener";
+            }
+            break;
+        case DPFunc::GET_PAIRED_DEV_LIST:
+            {
+                calledFunc = "onGetDirectPairedListener";
+            }
+            break;
+        default:
+            {
+                checkExAndRemoveListener(env);
+                if (JNI_EDETACHED == ret)
+                {
+                    g_jvm->DetachCurrentThread();
+                }
+            }
+            return;
+    }
+
+    jmethodID midL = env->GetMethodID(clsL, calledFunc.c_str(), "(Ljava/util/List;)V");
+
+    if (!midL)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
+        return;
+    }
+
+    env->CallVoidMethod(jListener, midL, jpairingDevicesList);
+    if (env->ExceptionCheck())
+    {
+        LOGE("Java exception is thrown");
+    }
+
+    checkExAndRemoveListener(env);
+    if (JNI_EDETACHED == ret)
+    {
+        g_jvm->DetachCurrentThread();
+    }
+}
+
+void JniOnDPDevicesFoundListener::checkExAndRemoveListener(JNIEnv* env)
+{
+    if (env->ExceptionCheck())
+    {
+        jthrowable ex = env->ExceptionOccurred();
+        env->ExceptionClear();
+        m_removeListenerCallback(env, m_jwListener);
+        env->Throw((jthrowable)ex);
+    }
+    else
+    {
+        m_removeListenerCallback(env, m_jwListener);
+    }
+}
diff --git a/android/android_api/base/jni/JniOnDPDevicesFoundListener.h b/android/android_api/base/jni/JniOnDPDevicesFoundListener.h
new file mode 100644 (file)
index 0000000..88acb61
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+* //******************************************************************
+* //
+* // Copyright 2016 Samsung Electronics All Rights Reserved.
+* //
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+* //
+* // Licensed under the Apache License, Version 2.0 (the "License");
+* // you may not use this file except in compliance with the License.
+* // You may obtain a copy of the License at
+* //
+* //      http://www.apache.org/licenses/LICENSE-2.0
+* //
+* // Unless required by applicable law or agreed to in writing, software
+* // distributed under the License is distributed on an "AS IS" BASIS,
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* // See the License for the specific language governing permissions and
+* // limitations under the License.
+* //
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+*/
+#include <jni.h>
+#include "OCDirectPairing.h"
+#include "OCApi.h"
+#include "JniOcStack.h"
+
+#ifndef _Included_org_iotivity_base_OcPlatform_JniOnDPDevicesFoundListener
+#define _Included_org_iotivity_base_OcPlatform_JniOnDPDevicesFoundListener
+
+enum class DPFunc
+{
+    FIND_DIRECT_PAIRED_DEV_LIST = 1,
+    GET_PAIRED_DEV_LIST,
+};
+
+class JniOnDPDevicesFoundListener
+{
+public:
+    JniOnDPDevicesFoundListener(JNIEnv *env, jobject jListener,
+            RemoveListenerCallback removeListenerCallback);
+    ~JniOnDPDevicesFoundListener();
+
+   jobject convertdpDevVectorToJavaList(JNIEnv *env, OC::PairedDevices DPdevList);
+   void directPairingDevicesCallback(OC::PairedDevices paringDevicesList, DPFunc);
+
+private:
+    RemoveListenerCallback m_removeListenerCallback;
+    jweak m_jwListener;
+    void checkExAndRemoveListener(JNIEnv* env);
+};
+#endif
index 87ebd71..4f95a4c 100644 (file)
@@ -34,35 +34,49 @@ JniOnDeleteListener::~JniOnDeleteListener()
 {
     if (m_jwListener)
     {
-        jint ret;
+        jint ret = JNI_ERR;
         JNIEnv *env = GetJNIEnv(ret);
-        if (nullptr == env) return;
-
+        if (nullptr == env)
+        {
+            return;
+        }
         env->DeleteWeakGlobalRef(m_jwListener);
         m_jwListener = nullptr;
 
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
     }
 }
 
 void JniOnDeleteListener::onDeleteCallback(const HeaderOptions& headerOptions, const int eCode)
 {
-    jint envRet;
+    jint envRet = JNI_ERR;
     JNIEnv *env = GetJNIEnv(envRet);
-    if (nullptr == env) return;
+    if (nullptr == env)
+    {
+        return;
+    }
 
     jobject jListener = env->NewLocalRef(m_jwListener);
     if (!jListener)
     {
         checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == envRet)
+        {
+            g_jvm->DetachCurrentThread();
+        }
         return;
     }
     jclass clsL = env->GetObjectClass(jListener);
     if (!clsL)
     {
         checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == envRet)
+        {
+            g_jvm->DetachCurrentThread();
+        }
         return;
     }
 
@@ -72,14 +86,20 @@ void JniOnDeleteListener::onDeleteCallback(const HeaderOptions& headerOptions, c
         if (!ex)
         {
             checkExAndRemoveListener(env);
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            if (JNI_EDETACHED == envRet)
+            {
+                g_jvm->DetachCurrentThread();
+            }
             return;
         }
         jmethodID midL = env->GetMethodID(clsL, "onDeleteFailed", "(Ljava/lang/Throwable;)V");
         if (!midL)
         {
             checkExAndRemoveListener(env);
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            if (JNI_EDETACHED == envRet)
+            {
+                g_jvm->DetachCurrentThread();
+            }
             return;
         }
         env->CallVoidMethod(jListener, midL, ex);
@@ -90,7 +110,10 @@ void JniOnDeleteListener::onDeleteCallback(const HeaderOptions& headerOptions, c
         if (!jHeaderOptionList)
         {
             checkExAndRemoveListener(env);
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            if (JNI_EDETACHED == envRet)
+            {
+                g_jvm->DetachCurrentThread();
+            }
             return;
         }
 
@@ -98,14 +121,20 @@ void JniOnDeleteListener::onDeleteCallback(const HeaderOptions& headerOptions, c
         if (!midL)
         {
             checkExAndRemoveListener(env);
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            if (JNI_EDETACHED == envRet)
+            {
+                g_jvm->DetachCurrentThread();
+            }
             return;
         }
         env->CallVoidMethod(jListener, midL, jHeaderOptionList);
     }
 
     checkExAndRemoveListener(env);
-    if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+    if (JNI_EDETACHED == envRet)
+    {
+        g_jvm->DetachCurrentThread();
+    }
 }
 
 void JniOnDeleteListener::checkExAndRemoveListener(JNIEnv* env)
@@ -121,4 +150,4 @@ void JniOnDeleteListener::checkExAndRemoveListener(JNIEnv* env)
     {
         m_ownerResource->removeOnDeleteListener(env, m_jwListener);
     }
-}
\ No newline at end of file
+}
index 28d8e44..520cdfd 100644 (file)
@@ -34,29 +34,41 @@ JniOnDeviceInfoListener::~JniOnDeviceInfoListener()
     LOGI("~JniOnDeviceInfoListener");
     if (m_jwListener)
     {
-        jint ret;
+        jint ret = JNI_ERR;
         JNIEnv *env = GetJNIEnv(ret);
-        if (nullptr == env) return;
+        if (nullptr == env)
+        {
+            return;
+        }
 
         env->DeleteWeakGlobalRef(m_jwListener);
         m_jwListener = nullptr;
 
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
     }
 }
 
 void JniOnDeviceInfoListener::foundDeviceCallback(const OC::OCRepresentation& ocRepresentation)
 {
-    jint ret;
+    jint ret = JNI_ERR;
     JNIEnv *env = GetJNIEnv(ret);
-    if (nullptr == env) return;
+    if (nullptr == env)
+    {
+        return;
+    }
 
     jobject jListener = env->NewLocalRef(m_jwListener);
     if (!jListener)
     {
         LOGI("Java onDeviceInfoListener object is already destroyed, quiting");
         checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
         return;
     }
 
@@ -68,7 +80,10 @@ void JniOnDeviceInfoListener::foundDeviceCallback(const OC::OCRepresentation& oc
     {
         delete rep;
         checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
         return;
     }
 
@@ -77,7 +92,10 @@ void JniOnDeviceInfoListener::foundDeviceCallback(const OC::OCRepresentation& oc
     {
         delete rep;
         checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
         return;
     }
     jmethodID midL = env->GetMethodID(clsL, "onDeviceFound", "(Lorg/iotivity/base/OcRepresentation;)V");
@@ -85,7 +103,10 @@ void JniOnDeviceInfoListener::foundDeviceCallback(const OC::OCRepresentation& oc
     {
         delete rep;
         checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
         return;
     }
 
@@ -97,7 +118,10 @@ void JniOnDeviceInfoListener::foundDeviceCallback(const OC::OCRepresentation& oc
         checkExAndRemoveListener(env);
     }
 
-    if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+    if (JNI_EDETACHED == ret)
+    {
+        g_jvm->DetachCurrentThread();
+    }
 }
 
 void JniOnDeviceInfoListener::checkExAndRemoveListener(JNIEnv* env)
@@ -113,4 +137,4 @@ void JniOnDeviceInfoListener::checkExAndRemoveListener(JNIEnv* env)
     {
         m_removeListenerCallback(env, m_jwListener);
     }
-}
\ No newline at end of file
+}
diff --git a/android/android_api/base/jni/JniOnDirectPairingListener.cpp b/android/android_api/base/jni/JniOnDirectPairingListener.cpp
new file mode 100644 (file)
index 0000000..085c2b9
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+* //******************************************************************
+* //
+* // Copyright 2016 Samsung Electronics All Rights Reserved.
+* //
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+* //
+* // Licensed under the Apache License, Version 2.0 (the "License");
+* // you may not use this file except in compliance with the License.
+* // You may obtain a copy of the License at
+* //
+* //      http://www.apache.org/licenses/LICENSE-2.0
+* //
+* // Unless required by applicable law or agreed to in writing, software
+* // distributed under the License is distributed on an "AS IS" BASIS,
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* // See the License for the specific language governing permissions and
+* // limitations under the License.
+* //
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+*/
+#include "JniOnDirectPairingListener.h"
+#include "JniOcDirectPairDevice.h"
+#include "OCDirectPairing.h"
+#include "OCApi.h"
+using namespace OC;
+
+JniOnDirectPairingListener::JniOnDirectPairingListener(JNIEnv *env, jobject jListener,
+    RemoveListenerCallback removeListenerCallback)
+{
+    m_jwListener = env->NewWeakGlobalRef(jListener);
+    m_removeListenerCallback = removeListenerCallback;
+}
+
+
+JniOnDirectPairingListener::~JniOnDirectPairingListener()
+{
+    LOGI("~JniOnDirectPairingListener()");
+    if (m_jwListener)
+    {
+        jint ret = JNI_ERR;
+        JNIEnv *env = GetJNIEnv(ret);
+        if (nullptr == env)
+        {
+            return;
+        }
+        env->DeleteWeakGlobalRef(m_jwListener);
+        m_jwListener = nullptr;
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
+    }
+}
+
+void JniOnDirectPairingListener::doDirectPairingCB(std::shared_ptr<OC::OCDirectPairing> dpDev,
+                                                                    OCStackResult result)
+{
+    jint ret = JNI_ERR;
+    JNIEnv *env = GetJNIEnv(ret);
+    if (nullptr == env)
+    {
+        return;
+    }
+
+    jobject jListener = env->NewLocalRef(m_jwListener);
+    if (!jListener)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
+        return;
+    }
+
+    jclass clsL = env->GetObjectClass(jListener);
+    if (!clsL)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
+        return;
+    }
+
+    JniOcDirectPairDevice *device = new JniOcDirectPairDevice(dpDev);
+    if (!device)
+    {
+        return;
+    }
+
+    jstring jStr = env->NewStringUTF((dpDev->getDeviceID()).c_str());
+    if (!jStr)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
+        return;
+    }
+
+    jobject jresult = env->NewObject(g_cls_OcDirectPairDevice, g_mid_OcDirectPairDevice_ctor);
+    if (!jresult)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
+        return;
+    }
+
+    SetHandle<JniOcDirectPairDevice>(env, jresult, device);
+
+    jint jres = static_cast<jint>(result);
+
+    jmethodID midL = env->GetMethodID(clsL, "onDirectPairingListener", "(Ljava/lang/String;I)V");
+
+    if (!midL)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
+        return;
+    }
+
+    env->CallVoidMethod(jListener, midL, jStr, jres);
+    if (env->ExceptionCheck())
+    {
+        LOGE("Java exception is thrown");
+    }
+
+    checkExAndRemoveListener(env);
+
+    if (JNI_EDETACHED == ret)
+    {
+        g_jvm->DetachCurrentThread();
+    }
+}
+
+void JniOnDirectPairingListener::checkExAndRemoveListener(JNIEnv* env)
+{
+    if (env->ExceptionCheck())
+    {
+        jthrowable ex = env->ExceptionOccurred();
+        env->ExceptionClear();
+        m_removeListenerCallback(env, m_jwListener);
+        env->Throw((jthrowable)ex);
+    }
+    else
+    {
+        m_removeListenerCallback(env, m_jwListener);
+    }
+}
diff --git a/android/android_api/base/jni/JniOnDirectPairingListener.h b/android/android_api/base/jni/JniOnDirectPairingListener.h
new file mode 100644 (file)
index 0000000..8ec2b7e
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+* //******************************************************************
+* //
+* // Copyright 2016 Samsung Electronics All Rights Reserved.
+* //
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+* //
+* // Licensed under the Apache License, Version 2.0 (the "License");
+* // you may not use this file except in compliance with the License.
+* // You may obtain a copy of the License at
+* //
+* //      http://www.apache.org/licenses/LICENSE-2.0
+* //
+* // Unless required by applicable law or agreed to in writing, software
+* // distributed under the License is distributed on an "AS IS" BASIS,
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* // See the License for the specific language governing permissions and
+* // limitations under the License.
+* //
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+*/
+#include <jni.h>
+#include "OCDirectPairing.h"
+#include "JniOcStack.h"
+
+#ifndef _Included_org_iotivity_base_OcPlatform_JniOnDirectPairingListener
+#define _Included_org_iotivity_base_OcPlatform_JniOnDirectPairingListener
+
+class JniOnDirectPairingListener
+{
+public:
+    JniOnDirectPairingListener(JNIEnv *env, jobject jListener,
+            RemoveListenerCallback removeListenerCallback);
+    ~JniOnDirectPairingListener();
+
+   void doDirectPairingCB(std::shared_ptr<OC::OCDirectPairing>, OCStackResult);
+
+private:
+    RemoveListenerCallback m_removeListenerCallback;
+    jweak m_jwListener;
+    void checkExAndRemoveListener(JNIEnv* env);
+};
+#endif
index 2bc8624..1a46903 100644 (file)
@@ -35,29 +35,41 @@ JniOnGetListener::~JniOnGetListener()
     LOGD("~JniOnGetListener");
     if (m_jwListener)
     {
-        jint ret;
+        jint ret = JNI_ERR;
         JNIEnv *env = GetJNIEnv(ret);
-        if (nullptr == env) return;
+        if (nullptr == env)
+        {
+            return;
+        }
 
         env->DeleteWeakGlobalRef(m_jwListener);
         m_jwListener = nullptr;
 
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
     }
 }
 
 void JniOnGetListener::onGetCallback(const HeaderOptions& headerOptions,
     const OCRepresentation& ocRepresentation, const int eCode)
 {
-    jint envRet;
+    jint envRet = JNI_ERR;
     JNIEnv *env = GetJNIEnv(envRet);
-    if (nullptr == env) return;
+    if (nullptr == env)
+    {
+        return;
+    }
 
     jobject jListener = env->NewLocalRef(m_jwListener);
     if (!jListener)
     {
         checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == envRet)
+        {
+            g_jvm->DetachCurrentThread();
+        }
         return;
     }
     jclass clsL = env->GetObjectClass(jListener);
@@ -65,7 +77,10 @@ void JniOnGetListener::onGetCallback(const HeaderOptions& headerOptions,
     if (!clsL)
     {
         checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == envRet)
+        {
+            g_jvm->DetachCurrentThread();
+        }
         return;
     }
 
@@ -75,14 +90,20 @@ void JniOnGetListener::onGetCallback(const HeaderOptions& headerOptions,
         if (!ex)
         {
             checkExAndRemoveListener(env);
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            if (JNI_EDETACHED == envRet)
+            {
+                g_jvm->DetachCurrentThread();
+            }
             return;
         }
         jmethodID midL = env->GetMethodID(clsL, "onGetFailed", "(Ljava/lang/Throwable;)V");
         if (!midL)
         {
             checkExAndRemoveListener(env);
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            if (JNI_EDETACHED == envRet)
+            {
+                g_jvm->DetachCurrentThread();
+            }
             return;
         }
         env->CallVoidMethod(jListener, midL, ex);
@@ -93,7 +114,10 @@ void JniOnGetListener::onGetCallback(const HeaderOptions& headerOptions,
         if (!jHeaderOptionList)
         {
             checkExAndRemoveListener(env);
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            if (JNI_EDETACHED == envRet)
+            {
+                g_jvm->DetachCurrentThread();
+            }
             return;
         }
 
@@ -105,7 +129,10 @@ void JniOnGetListener::onGetCallback(const HeaderOptions& headerOptions,
         {
             delete rep;
             checkExAndRemoveListener(env);
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            if (JNI_EDETACHED == envRet)
+            {
+                g_jvm->DetachCurrentThread();
+            }
             return;
         }
 
@@ -115,7 +142,10 @@ void JniOnGetListener::onGetCallback(const HeaderOptions& headerOptions,
         {
             delete rep;
             checkExAndRemoveListener(env);
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            if (JNI_EDETACHED == envRet)
+            {
+                g_jvm->DetachCurrentThread();
+            }
             return;
         }
         env->CallVoidMethod(jListener, midL, jHeaderOptionList, jRepresentation);
@@ -127,7 +157,10 @@ void JniOnGetListener::onGetCallback(const HeaderOptions& headerOptions,
     }
 
     checkExAndRemoveListener(env);
-    if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+    if (JNI_EDETACHED == envRet)
+    {
+        g_jvm->DetachCurrentThread();
+    }
 }
 
 void JniOnGetListener::checkExAndRemoveListener(JNIEnv* env)
@@ -143,4 +176,4 @@ void JniOnGetListener::checkExAndRemoveListener(JNIEnv* env)
     {
         m_ownerResource->removeOnGetListener(env, m_jwListener);
     }
-}
\ No newline at end of file
+}
index 3ad1d11..03d92f0 100644 (file)
@@ -34,36 +34,51 @@ JniOnObserveListener::~JniOnObserveListener()
 {
     if (m_jwListener)
     {
-        jint ret;
+        jint ret = JNI_ERR;
         JNIEnv *env = GetJNIEnv(ret);
-        if (nullptr == env) return;
+        if (nullptr == env)
+        {
+            return;
+        }
 
         env->DeleteWeakGlobalRef(m_jwListener);
         m_jwListener = nullptr;
 
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
     }
 }
 
 void JniOnObserveListener::onObserveCallback(const HeaderOptions headerOptions,
     const OCRepresentation& ocRepresentation, const int& eCode, const int& sequenceNumber)
 {
-    jint envRet;
+    jint envRet = JNI_ERR;
     JNIEnv *env = GetJNIEnv(envRet);
-    if (nullptr == env) return;
+    if (nullptr == env)
+    {
+        return;
+    }
 
     jobject jListener = env->NewLocalRef(m_jwListener);
     if (!jListener)
     {
         checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == envRet)
+        {
+            g_jvm->DetachCurrentThread();
+        }
         return;
     }
     jclass clsL = env->GetObjectClass(jListener);
     if (!clsL)
     {
         checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == envRet)
+        {
+            g_jvm->DetachCurrentThread();
+        }
         return;
     }
 
@@ -73,14 +88,20 @@ void JniOnObserveListener::onObserveCallback(const HeaderOptions headerOptions,
         if (!ex)
         {
             checkExAndRemoveListener(env);
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            if (JNI_EDETACHED == envRet)
+            {
+                g_jvm->DetachCurrentThread();
+            }
             return;
         }
         jmethodID midL = env->GetMethodID(clsL, "onObserveFailed", "(Ljava/lang/Throwable;)V");
         if (!midL)
         {
             checkExAndRemoveListener(env);
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            if (JNI_EDETACHED == envRet)
+            {
+                g_jvm->DetachCurrentThread();
+            }
             return;
         }
         env->CallVoidMethod(jListener, midL, ex);
@@ -91,7 +112,10 @@ void JniOnObserveListener::onObserveCallback(const HeaderOptions headerOptions,
         if (!jHeaderOptionList)
         {
             checkExAndRemoveListener(env);
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            if (JNI_EDETACHED == envRet)
+            {
+                g_jvm->DetachCurrentThread();
+            }
             return;
         }
 
@@ -103,7 +127,10 @@ void JniOnObserveListener::onObserveCallback(const HeaderOptions headerOptions,
         {
             delete rep;
             checkExAndRemoveListener(env);
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            if (JNI_EDETACHED == envRet)
+            {
+                g_jvm->DetachCurrentThread();
+            }
             return;
         }
 
@@ -112,7 +139,10 @@ void JniOnObserveListener::onObserveCallback(const HeaderOptions headerOptions,
         if (!midL)
         {
             checkExAndRemoveListener(env);
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            if (JNI_EDETACHED == envRet)
+            {
+                g_jvm->DetachCurrentThread();
+            }
             return;
         }
 
@@ -134,7 +164,10 @@ void JniOnObserveListener::onObserveCallback(const HeaderOptions headerOptions,
         }
     }
 
-    if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+    if (JNI_EDETACHED == envRet)
+    {
+        g_jvm->DetachCurrentThread();
+    }
 }
 
 void JniOnObserveListener::checkExAndRemoveListener(JNIEnv* env)
@@ -150,4 +183,4 @@ void JniOnObserveListener::checkExAndRemoveListener(JNIEnv* env)
     {
         m_ownerResource->removeOnObserveListener(env, m_jwListener);
     }
-}
\ No newline at end of file
+}
index 03e2ed8..7a220bf 100644 (file)
@@ -34,29 +34,41 @@ JniOnPlatformInfoListener::~JniOnPlatformInfoListener()
     LOGI("~JniOnPlatformInfoListener");
     if (m_jwListener)
     {
-        jint ret;
+        jint ret = JNI_ERR;
         JNIEnv *env = GetJNIEnv(ret);
-        if (nullptr == env) return;
+        if (nullptr == env)
+        {
+            return;
+        }
 
         env->DeleteWeakGlobalRef(m_jwListener);
         m_jwListener = nullptr;
 
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
     }
 }
 
 void JniOnPlatformInfoListener::foundPlatformCallback(const OC::OCRepresentation& ocRepresentation)
 {
-    jint ret;
+    jint ret = JNI_ERR;
     JNIEnv *env = GetJNIEnv(ret);
-    if (nullptr == env) return;
+    if (nullptr == env)
+    {
+        return;
+    }
 
     jobject jListener = env->NewLocalRef(m_jwListener);
     if (!jListener)
     {
         LOGI("Java onPlatformInfoListener object is already destroyed, quiting");
         checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
         return;
     }
 
@@ -68,7 +80,10 @@ void JniOnPlatformInfoListener::foundPlatformCallback(const OC::OCRepresentation
     {
         delete rep;
         checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
         return;
     }
 
@@ -77,7 +92,10 @@ void JniOnPlatformInfoListener::foundPlatformCallback(const OC::OCRepresentation
     {
         delete rep;
         checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
         return;
     }
     jmethodID midL = env->GetMethodID(clsL, "onPlatformFound", "(Lorg/iotivity/base/OcRepresentation;)V");
@@ -85,7 +103,10 @@ void JniOnPlatformInfoListener::foundPlatformCallback(const OC::OCRepresentation
     {
         delete rep;
         checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
         return;
     }
 
@@ -97,7 +118,10 @@ void JniOnPlatformInfoListener::foundPlatformCallback(const OC::OCRepresentation
         checkExAndRemoveListener(env);
     }
 
-    if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+    if (JNI_EDETACHED == ret)
+    {
+        g_jvm->DetachCurrentThread();
+    }
 }
 
 void JniOnPlatformInfoListener::checkExAndRemoveListener(JNIEnv* env)
index 575748e..6a9bb06 100644 (file)
@@ -34,36 +34,51 @@ JniOnPostListener::~JniOnPostListener()
 {
     if (m_jwListener)
     {
-        jint ret;
+        jint ret = JNI_ERR;
         JNIEnv *env = GetJNIEnv(ret);
-        if (nullptr == env) return;
+        if (nullptr == env)
+        {
+            return;
+        }
 
         env->DeleteWeakGlobalRef(m_jwListener);
         m_jwListener = nullptr;
 
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
     }
 }
 
 void JniOnPostListener::onPostCallback(const HeaderOptions& headerOptions,
     const OCRepresentation& ocRepresentation, const int eCode)
 {
-    jint envRet;
+    jint envRet = JNI_ERR;
     JNIEnv *env = GetJNIEnv(envRet);
-    if (nullptr == env) return;
+    if (nullptr == env)
+    {
+        return;
+    }
 
     jobject jListener = env->NewLocalRef(m_jwListener);
     if (!jListener)
     {
         checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == envRet)
+        {
+            g_jvm->DetachCurrentThread();
+        }
         return;
     }
     jclass clsL = env->GetObjectClass(jListener);
     if (!clsL)
     {
         checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == envRet)
+        {
+            g_jvm->DetachCurrentThread();
+        }
         return;
     }
 
@@ -73,14 +88,20 @@ void JniOnPostListener::onPostCallback(const HeaderOptions& headerOptions,
         if (!ex)
         {
             checkExAndRemoveListener(env);
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            if (JNI_EDETACHED == envRet)
+            {
+                g_jvm->DetachCurrentThread();
+            }
             return;
         }
         jmethodID midL = env->GetMethodID(clsL, "onPostFailed", "(Ljava/lang/Throwable;)V");
         if (!midL)
         {
             checkExAndRemoveListener(env);
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            if (JNI_EDETACHED == envRet)
+            {
+                g_jvm->DetachCurrentThread();
+            }
             return;
         }
         env->CallVoidMethod(jListener, midL, ex);
@@ -91,7 +112,10 @@ void JniOnPostListener::onPostCallback(const HeaderOptions& headerOptions,
         if (!jHeaderOptionList)
         {
             checkExAndRemoveListener(env);
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            if (JNI_EDETACHED == envRet)
+            {
+                g_jvm->DetachCurrentThread();
+            }
             return;
         }
 
@@ -103,7 +127,10 @@ void JniOnPostListener::onPostCallback(const HeaderOptions& headerOptions,
         {
             delete rep;
             checkExAndRemoveListener(env);
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            if (JNI_EDETACHED == envRet)
+            {
+                g_jvm->DetachCurrentThread();
+            }
             return;
         }
 
@@ -112,7 +139,10 @@ void JniOnPostListener::onPostCallback(const HeaderOptions& headerOptions,
         if (!midL)
         {
             checkExAndRemoveListener(env);
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            if (JNI_EDETACHED == envRet)
+            {
+                g_jvm->DetachCurrentThread();
+            }
             return;
         }
 
@@ -125,7 +155,10 @@ void JniOnPostListener::onPostCallback(const HeaderOptions& headerOptions,
     }
 
     checkExAndRemoveListener(env);
-    if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+    if (JNI_EDETACHED == envRet)
+    {
+        g_jvm->DetachCurrentThread();
+    }
 }
 
 void JniOnPostListener::checkExAndRemoveListener(JNIEnv* env)
@@ -141,4 +174,4 @@ void JniOnPostListener::checkExAndRemoveListener(JNIEnv* env)
     {
         m_ownerResource->removeOnPostListener(env, m_jwListener);
     }
-}
\ No newline at end of file
+}
index 023c61d..9223250 100644 (file)
@@ -34,14 +34,20 @@ JniOnPresenceListener::~JniOnPresenceListener()
     LOGD("~JniOnPresenceListener");
     if (m_jwListener)
     {
-        jint ret;
+        jint ret = JNI_ERR;
         JNIEnv *env = GetJNIEnv(ret);
-        if (nullptr == env) return;
+        if (nullptr == env)
+        {
+            return;
+        }
 
         env->DeleteWeakGlobalRef(m_jwListener);
         m_jwListener = nullptr;
 
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
     }
 }
 
@@ -49,17 +55,26 @@ void JniOnPresenceListener::onPresenceCallback(OCStackResult result, const unsig
     const std::string& hostAddress)
 {
     LOGI("JniOnPresenceListener::onPresenceCallback");
-    if (!m_jwListener) return;
+    if (!m_jwListener)
+    {
+        return;
+    }
 
-    jint ret;
+    jint ret = JNI_ERR;
     JNIEnv *env = GetJNIEnv(ret);
-    if (nullptr == env) return;
+    if (nullptr == env)
+    {
+        return;
+    }
 
     if (OC_STACK_OK != result && OC_STACK_PRESENCE_STOPPED != result &&
         OC_STACK_PRESENCE_TIMEOUT != result &&  OC_STACK_PRESENCE_DO_NOT_HANDLE != result)
     {
         ThrowOcException(result, "onPresenceCallback: stack failure");
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
         return;
     }
 
@@ -67,7 +82,10 @@ void JniOnPresenceListener::onPresenceCallback(OCStackResult result, const unsig
     if (enumField.empty())
     {
         ThrowOcException(JNI_INVALID_VALUE, "Unexpected OCStackResult value");
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
         return;
     }
 
@@ -76,7 +94,10 @@ void JniOnPresenceListener::onPresenceCallback(OCStackResult result, const unsig
     if (!jPresenceStatus)
     {
         checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
         return;
     }
 
@@ -84,7 +105,10 @@ void JniOnPresenceListener::onPresenceCallback(OCStackResult result, const unsig
     if (!jListener)
     {
         checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
         return;
     }
 
@@ -92,7 +116,10 @@ void JniOnPresenceListener::onPresenceCallback(OCStackResult result, const unsig
     if (!clsL)
     {
         checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
         return;
     }
     jmethodID midL = env->GetMethodID(clsL, "onPresence",
@@ -100,7 +127,10 @@ void JniOnPresenceListener::onPresenceCallback(OCStackResult result, const unsig
     if (!midL)
     {
         checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
         return;
     }
 
@@ -111,7 +141,11 @@ void JniOnPresenceListener::onPresenceCallback(OCStackResult result, const unsig
         LOGE("Java exception is thrown");
         checkExAndRemoveListener(env);
     }
-    if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+
+    if (JNI_EDETACHED == ret)
+    {
+        g_jvm->DetachCurrentThread();
+    }
 }
 
 void JniOnPresenceListener::checkExAndRemoveListener(JNIEnv* env)
@@ -132,4 +166,4 @@ void JniOnPresenceListener::checkExAndRemoveListener(JNIEnv* env)
 jweak JniOnPresenceListener::getJWListener()
 {
     return this->m_jwListener;
-}
\ No newline at end of file
+}
index 7f375b9..961280a 100644 (file)
@@ -34,36 +34,51 @@ JniOnPutListener::~JniOnPutListener()
 {
     if (m_jwListener)
     {
-        jint ret;
+        jint ret = JNI_ERR;
         JNIEnv *env = GetJNIEnv(ret);
-        if (nullptr == env) return;
+        if (nullptr == env)
+        {
+            return;
+        }
 
         env->DeleteWeakGlobalRef(m_jwListener);
         m_jwListener = nullptr;
 
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
     }
 }
 
 void JniOnPutListener::onPutCallback(const HeaderOptions& headerOptions,
     const OCRepresentation& ocRepresentation, const int eCode)
 {
-    jint envRet;
+    jint envRet = JNI_ERR;
     JNIEnv *env = GetJNIEnv(envRet);
-    if (nullptr == env) return;
+    if (nullptr == env)
+    {
+        return;
+    }
 
     jobject jListener = env->NewLocalRef(m_jwListener);
     if (!jListener)
     {
         checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == envRet)
+        {
+            g_jvm->DetachCurrentThread();
+        }
         return;
     }
     jclass clsL = env->GetObjectClass(jListener);
     if (!clsL)
     {
         checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        if (JNI_EDETACHED == envRet)
+        {
+            g_jvm->DetachCurrentThread();
+        }
         return;
     }
 
@@ -73,14 +88,20 @@ void JniOnPutListener::onPutCallback(const HeaderOptions& headerOptions,
         if (!ex)
         {
             checkExAndRemoveListener(env);
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            if (JNI_EDETACHED == envRet)
+            {