Android Base API merge to master
authorTim Kourt <tim.a.kourt@intel.com>
Fri, 15 May 2015 20:16:29 +0000 (13:16 -0700)
committerErich Keane <erich.keane@intel.com>
Fri, 15 May 2015 21:47:42 +0000 (21:47 +0000)
Introduced support for automated Jenkins build for android

Change-Id: Ide54185a0e75ee8c75b3616beb5f935810220203
Signed-off-by: Erich Keane <erich.keane@intel.com>
Signed-off-by: Rahul Rahul <rahul.rahul@intel.com>
Signed-off-by: Tim Kourt <tim.a.kourt@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/894
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
271 files changed:
.gitignore
SConstruct
android/Base/app/build.gradle [deleted file]
android/Base/app/jni/ocheaderoption-jni.cpp [deleted file]
android/Base/app/jni/ocplatform-jni.cpp [deleted file]
android/Base/app/jni/ocrepresentation-jni.cpp [deleted file]
android/Base/app/jni/ocresource-jni.cpp [deleted file]
android/Base/app/jni/ocstack-jni.cpp [deleted file]
android/Base/app/jni/ocstack-jni.h [deleted file]
android/Base/app/jni/platformcfg-jni.cpp [deleted file]
android/Base/app/src/androidTest/java/org/iotivity/base/ApplicationTest.java [deleted file]
android/Base/app/src/main/AndroidManifest.xml [deleted file]
android/Base/app/src/main/java/org/iotivity/base/AbstractDeleteCallback.java [deleted file]
android/Base/app/src/main/java/org/iotivity/base/AbstractFindCallback.java [deleted file]
android/Base/app/src/main/java/org/iotivity/base/AbstractGetCallback.java [deleted file]
android/Base/app/src/main/java/org/iotivity/base/AbstractObserveCallback.java [deleted file]
android/Base/app/src/main/java/org/iotivity/base/AbstractPostCallback.java [deleted file]
android/Base/app/src/main/java/org/iotivity/base/AbstractPutCallback.java [deleted file]
android/Base/app/src/main/java/org/iotivity/base/AbstractSubscriberCallback.java [deleted file]
android/Base/app/src/main/java/org/iotivity/base/EntityHandler.java [deleted file]
android/Base/app/src/main/java/org/iotivity/base/OCHeaderOption.java [deleted file]
android/Base/app/src/main/java/org/iotivity/base/OCPlatform.java [deleted file]
android/Base/app/src/main/java/org/iotivity/base/OCRepresentation.java [deleted file]
android/Base/app/src/main/java/org/iotivity/base/OCResource.java [deleted file]
android/Base/app/src/main/java/org/iotivity/base/OCResourceRequest.java [deleted file]
android/Base/app/src/main/java/org/iotivity/base/OCResourceResponse.java [deleted file]
android/Base/app/src/main/java/org/iotivity/base/OCStackResult.java [deleted file]
android/Base/app/src/main/java/org/iotivity/base/ObserveType.java [deleted file]
android/Base/app/src/main/java/org/iotivity/base/PlatformConfig.java [deleted file]
android/Base/app/src/main/res/values/strings.xml [deleted file]
android/Base/gradle.properties [deleted file]
android/Base/settings.gradle [deleted file]
android/BuildInstructionsForAndroidAPI.txt [new file with mode: 0644]
android/SimpleClient/app/build.gradle [deleted file]
android/SimpleClient/app/proguard-rules.pro [deleted file]
android/SimpleClient/app/src/androidTest/java/org/iotivity/simpleclient/ApplicationTest.java [deleted file]
android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/FoundResource.java [deleted file]
android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/OnGet.java [deleted file]
android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/OnObserve.java [deleted file]
android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/OnPost.java [deleted file]
android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/OnPost2.java [deleted file]
android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/OnPut.java [deleted file]
android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/SimpleClient.java [deleted file]
android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/SimpleToast.java [deleted file]
android/SimpleClient/app/src/main/res/layout/activity_simple_client.xml [deleted file]
android/SimpleClient/app/src/main/res/menu/simple_client.xml [deleted file]
android/SimpleClient/build.gradle [deleted file]
android/SimpleClient/gradle.properties [deleted file]
android/SimpleClient/settings.gradle [deleted file]
android/android_api/.gitignore [new file with mode: 0755]
android/android_api/SConscript [new file with mode: 0755]
android/android_api/android_api.iml [new file with mode: 0755]
android/android_api/base/.gitignore [new file with mode: 0755]
android/android_api/base/base.iml [new file with mode: 0755]
android/android_api/base/build.gradle [new file with mode: 0755]
android/android_api/base/jni/Android.mk [new file with mode: 0755]
android/android_api/base/jni/Application.mk [new file with mode: 0755]
android/android_api/base/jni/JniCaInterface.c [new file with mode: 0644]
android/android_api/base/jni/JniCaInterface.h [new file with mode: 0644]
android/android_api/base/jni/JniEntityHandler.cpp [new file with mode: 0644]
android/android_api/base/jni/JniEntityHandler.h [new file with mode: 0644]
android/android_api/base/jni/JniListenerManager.cpp [new file with mode: 0644]
android/android_api/base/jni/JniListenerManager.h [new file with mode: 0644]
android/android_api/base/jni/JniOcPlatform.cpp [new file with mode: 0644]
android/android_api/base/jni/JniOcPlatform.h [new file with mode: 0644]
android/android_api/base/jni/JniOcPresenceHandle.cpp [new file with mode: 0644]
android/android_api/base/jni/JniOcPresenceHandle.h [new file with mode: 0644]
android/android_api/base/jni/JniOcRepresentation.cpp [new file with mode: 0644]
android/android_api/base/jni/JniOcRepresentation.h [new file with mode: 0644]
android/android_api/base/jni/JniOcRequestHandle.cpp [new file with mode: 0644]
android/android_api/base/jni/JniOcRequestHandle.h [new file with mode: 0644]
android/android_api/base/jni/JniOcResource.cpp [new file with mode: 0644]
android/android_api/base/jni/JniOcResource.h [new file with mode: 0644]
android/android_api/base/jni/JniOcResourceHandle.cpp [new file with mode: 0644]
android/android_api/base/jni/JniOcResourceHandle.h [new file with mode: 0644]
android/android_api/base/jni/JniOcResourceIdentifier.cpp [new file with mode: 0644]
android/android_api/base/jni/JniOcResourceIdentifier.h [new file with mode: 0644]
android/android_api/base/jni/JniOcResourceRequest.cpp [new file with mode: 0644]
android/android_api/base/jni/JniOcResourceRequest.h [new file with mode: 0644]
android/android_api/base/jni/JniOcResourceResponse.cpp [new file with mode: 0644]
android/android_api/base/jni/JniOcResourceResponse.h [new file with mode: 0644]
android/android_api/base/jni/JniOcStack.cpp [new file with mode: 0644]
android/android_api/base/jni/JniOcStack.h [new file with mode: 0644]
android/android_api/base/jni/JniOnDeleteListener.cpp [new file with mode: 0644]
android/android_api/base/jni/JniOnDeleteListener.h [new file with mode: 0644]
android/android_api/base/jni/JniOnDeviceInfoListener.cpp [new file with mode: 0644]
android/android_api/base/jni/JniOnDeviceInfoListener.h [new file with mode: 0644]
android/android_api/base/jni/JniOnGetListener.cpp [new file with mode: 0644]
android/android_api/base/jni/JniOnGetListener.h [new file with mode: 0644]
android/android_api/base/jni/JniOnObserveListener.cpp [new file with mode: 0644]
android/android_api/base/jni/JniOnObserveListener.h [new file with mode: 0644]
android/android_api/base/jni/JniOnPostListener.cpp [new file with mode: 0644]
android/android_api/base/jni/JniOnPostListener.h [new file with mode: 0644]
android/android_api/base/jni/JniOnPresenceListener.cpp [new file with mode: 0644]
android/android_api/base/jni/JniOnPresenceListener.h [new file with mode: 0644]
android/android_api/base/jni/JniOnPutListener.cpp [new file with mode: 0644]
android/android_api/base/jni/JniOnPutListener.h [new file with mode: 0644]
android/android_api/base/jni/JniOnResourceFoundListener.cpp [new file with mode: 0644]
android/android_api/base/jni/JniOnResourceFoundListener.h [new file with mode: 0644]
android/android_api/base/jni/JniUtils.cpp [new file with mode: 0644]
android/android_api/base/jni/JniUtils.h [new file with mode: 0644]
android/android_api/base/proguard-rules.pro [moved from android/Base/app/proguard-rules.pro with 86% similarity, mode: 0755]
android/android_api/base/src/androidTest/AndroidManifest.xml [new file with mode: 0755]
android/android_api/base/src/androidTest/java/org/iotivity/base/OcRepresentationTest.java [new file with mode: 0755]
android/android_api/base/src/androidTest/java/org/iotivity/base/SmokeTest.java [new file with mode: 0755]
android/android_api/base/src/main/AndroidManifest.xml [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/base/EntityHandlerResult.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/base/ErrorCode.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/base/ModeType.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/base/ObservationInfo.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/base/ObserveAction.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/base/ObserveType.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/base/OcConnectivityType.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/base/OcDeviceInfo.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/base/OcException.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/base/OcHeaderOption.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/base/OcPlatform.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/base/OcPlatformStatus.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/base/OcPresenceHandle.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/base/OcPresenceStatus.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/base/OcRepresentation.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/base/OcRequestHandle.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/base/OcResource.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/base/OcResourceHandle.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/base/OcResourceIdentifier.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/base/OcResourceRequest.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/base/OcResourceResponse.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/base/PlatformConfig.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/base/QualityOfService.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/base/RequestHandlerFlag.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/base/RequestType.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/base/ResourceProperty.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/base/ServiceType.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/ca/CaInterface.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/ca/CaIpInterface.java [new file with mode: 0755]
android/android_api/base/src/main/java/org/iotivity/ca/CaWiFiInterface.java [new file with mode: 0755]
android/android_api/build.gradle [new file with mode: 0755]
android/android_api/gradle.properties [new file with mode: 0755]
android/android_api/gradle/wrapper/gradle-wrapper.jar [new file with mode: 0755]
android/android_api/gradle/wrapper/gradle-wrapper.properties [new file with mode: 0755]
android/android_api/gradlew [moved from android/Base/gradlew with 96% similarity]
android/android_api/gradlew.bat [moved from android/SimpleClient/gradlew.bat with 100% similarity, mode: 0755]
android/android_api/settings.gradle [new file with mode: 0755]
android/examples/build.gradle [moved from android/Base/build.gradle with 83% similarity, mode: 0755]
android/examples/examples.iml [new file with mode: 0755]
android/examples/fridgeclient/.gitignore [new file with mode: 0755]
android/examples/fridgeclient/build.gradle [new file with mode: 0755]
android/examples/fridgeclient/fridgeclient.iml [new file with mode: 0755]
android/examples/fridgeclient/src/main/AndroidManifest.xml [new file with mode: 0755]
android/examples/fridgeclient/src/main/java/org/iotivity/base/examples/fridgeclient/FridgeClient.java [new file with mode: 0755]
android/examples/fridgeclient/src/main/java/org/iotivity/base/examples/fridgeclient/StringConstants.java [new file with mode: 0755]
android/examples/fridgeclient/src/main/res/drawable-hdpi/ic_launcher.png [moved from android/SimpleClient/app/src/main/res/drawable-hdpi/ic_launcher.png with 100% similarity, mode: 0755]
android/examples/fridgeclient/src/main/res/drawable-mdpi/ic_launcher.png [moved from android/SimpleClient/app/src/main/res/drawable-mdpi/ic_launcher.png with 100% similarity, mode: 0755]
android/examples/fridgeclient/src/main/res/drawable-xhdpi/ic_launcher.png [moved from android/SimpleClient/app/src/main/res/drawable-xhdpi/ic_launcher.png with 100% similarity, mode: 0755]
android/examples/fridgeclient/src/main/res/drawable-xxhdpi/ic_launcher.png [moved from android/SimpleClient/app/src/main/res/drawable-xxhdpi/ic_launcher.png with 100% similarity, mode: 0755]
android/examples/fridgeclient/src/main/res/layout/activity_fridge_client.xml [new file with mode: 0755]
android/examples/fridgeclient/src/main/res/menu/menu_fridge_client.xml [new file with mode: 0755]
android/examples/fridgeclient/src/main/res/values-w820dp/dimens.xml [moved from android/SimpleClient/app/src/main/res/values-w820dp/dimens.xml with 98% similarity, mode: 0755]
android/examples/fridgeclient/src/main/res/values/dimens.xml [moved from android/SimpleClient/app/src/main/res/values/dimens.xml with 97% similarity, mode: 0755]
android/examples/fridgeclient/src/main/res/values/strings.xml [moved from android/SimpleClient/app/src/main/res/values/strings.xml with 74% similarity, mode: 0755]
android/examples/fridgeclient/src/main/res/values/styles.xml [moved from android/Base/app/src/main/res/values/styles.xml with 59% similarity, mode: 0755]
android/examples/fridgeserver/.gitignore [new file with mode: 0755]
android/examples/fridgeserver/build.gradle [new file with mode: 0755]
android/examples/fridgeserver/fridgeserver.iml [new file with mode: 0755]
android/examples/fridgeserver/src/main/AndroidManifest.xml [new file with mode: 0755]
android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DeviceResource.java [new file with mode: 0755]
android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DoorResource.java [new file with mode: 0755]
android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/FridgeServer.java [new file with mode: 0755]
android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/LightResource.java [new file with mode: 0755]
android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Refrigerator.java [new file with mode: 0755]
android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Resource.java [new file with mode: 0755]
android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/StringConstants.java [new file with mode: 0755]
android/examples/fridgeserver/src/main/res/drawable-hdpi/ic_launcher.png [moved from android/Base/app/src/main/res/drawable-hdpi/ic_launcher.png with 100% similarity, mode: 0755]
android/examples/fridgeserver/src/main/res/drawable-mdpi/ic_launcher.png [moved from android/Base/app/src/main/res/drawable-mdpi/ic_launcher.png with 100% similarity, mode: 0755]
android/examples/fridgeserver/src/main/res/drawable-xhdpi/ic_launcher.png [moved from android/Base/app/src/main/res/drawable-xhdpi/ic_launcher.png with 100% similarity, mode: 0755]
android/examples/fridgeserver/src/main/res/drawable-xxhdpi/ic_launcher.png [moved from android/Base/app/src/main/res/drawable-xxhdpi/ic_launcher.png with 100% similarity, mode: 0755]
android/examples/fridgeserver/src/main/res/layout/activity_fridge_server.xml [new file with mode: 0755]
android/examples/fridgeserver/src/main/res/menu/menu_fridge_server.xml [new file with mode: 0755]
android/examples/fridgeserver/src/main/res/values-w820dp/dimens.xml [new file with mode: 0755]
android/examples/fridgeserver/src/main/res/values/dimens.xml [new file with mode: 0755]
android/examples/fridgeserver/src/main/res/values/strings.xml [new file with mode: 0755]
android/examples/fridgeserver/src/main/res/values/styles.xml [moved from android/SimpleClient/app/src/main/res/values/styles.xml with 59% similarity, mode: 0755]
android/examples/gradle/wrapper/gradle-wrapper.jar [new file with mode: 0755]
android/examples/gradle/wrapper/gradle-wrapper.properties [new file with mode: 0755]
android/examples/gradlew [moved from android/SimpleClient/gradlew with 96% similarity]
android/examples/gradlew.bat [moved from android/Base/gradlew.bat with 100% similarity, mode: 0755]
android/examples/message/.gitignore [new file with mode: 0755]
android/examples/message/build.gradle [new file with mode: 0755]
android/examples/message/message.iml [new file with mode: 0755]
android/examples/message/src/main/AndroidManifest.xml [new file with mode: 0755]
android/examples/message/src/main/java/base/iotivity/org/examples/message/IMessageLogger.java [new file with mode: 0755]
android/examples/settings.gradle [new file with mode: 0755]
android/examples/simpleclient/.gitignore [new file with mode: 0755]
android/examples/simpleclient/build.gradle [new file with mode: 0755]
android/examples/simpleclient/simpleclient.iml [new file with mode: 0755]
android/examples/simpleclient/src/main/AndroidManifest.xml [moved from android/SimpleClient/app/src/main/AndroidManifest.xml with 76% similarity, mode: 0755]
android/examples/simpleclient/src/main/java/org/iotivity/base/examples/simpleclient/Light.java [new file with mode: 0755]
android/examples/simpleclient/src/main/java/org/iotivity/base/examples/simpleclient/SimpleClient.java [new file with mode: 0755]
android/examples/simpleclient/src/main/java/org/iotivity/base/examples/simpleclient/StringConstants.java [new file with mode: 0755]
android/examples/simpleclient/src/main/res/drawable-hdpi/ic_launcher.png [new file with mode: 0755]
android/examples/simpleclient/src/main/res/drawable-mdpi/ic_launcher.png [new file with mode: 0755]
android/examples/simpleclient/src/main/res/drawable-xhdpi/ic_launcher.png [new file with mode: 0755]
android/examples/simpleclient/src/main/res/drawable-xxhdpi/ic_launcher.png [new file with mode: 0755]
android/examples/simpleclient/src/main/res/layout/activity_main.xml [new file with mode: 0755]
android/examples/simpleclient/src/main/res/menu/menu_main.xml [new file with mode: 0755]
android/examples/simpleclient/src/main/res/values-w820dp/dimens.xml [new file with mode: 0755]
android/examples/simpleclient/src/main/res/values/dimens.xml [new file with mode: 0755]
android/examples/simpleclient/src/main/res/values/strings.xml [new file with mode: 0755]
android/examples/simpleclient/src/main/res/values/styles.xml [new file with mode: 0755]
android/examples/simpleserver/.gitignore [new file with mode: 0755]
android/examples/simpleserver/build.gradle [new file with mode: 0755]
android/examples/simpleserver/simpleserver.iml [new file with mode: 0755]
android/examples/simpleserver/src/main/AndroidManifest.xml [new file with mode: 0755]
android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/LightRepThread.java [new file with mode: 0755]
android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/LightResource.java [new file with mode: 0755]
android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/SimpleServer.java [new file with mode: 0755]
android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/StringConstants.java [new file with mode: 0755]
android/examples/simpleserver/src/main/res/drawable-hdpi/ic_launcher.png [new file with mode: 0755]
android/examples/simpleserver/src/main/res/drawable-mdpi/ic_launcher.png [new file with mode: 0755]
android/examples/simpleserver/src/main/res/drawable-xhdpi/ic_launcher.png [new file with mode: 0755]
android/examples/simpleserver/src/main/res/drawable-xxhdpi/ic_launcher.png [new file with mode: 0755]
android/examples/simpleserver/src/main/res/layout/activity_main.xml [new file with mode: 0755]
android/examples/simpleserver/src/main/res/menu/menu_main.xml [new file with mode: 0755]
android/examples/simpleserver/src/main/res/values-w820dp/dimens.xml [new file with mode: 0755]
android/examples/simpleserver/src/main/res/values/dimens.xml [new file with mode: 0755]
android/examples/simpleserver/src/main/res/values/strings.xml [new file with mode: 0755]
android/examples/simpleserver/src/main/res/values/styles.xml [new file with mode: 0755]
auto_build.sh
build_common/android/SConscript
extlibs/android/gradle/SConscript [new file with mode: 0644]
extlibs/android/ndk/SConscript [new file with mode: 0644]
extlibs/android/sdk/SConscript [new file with mode: 0644]
extlibs/boost/SConscript
resource/SConscript
resource/csdk/connectivity/build/How_To_Build.txt [changed mode: 0644->0755]
resource/csdk/connectivity/build/SConscript [changed mode: 0644->0755]
resource/csdk/connectivity/build/android/Makefile [new file with mode: 0755]
resource/csdk/connectivity/build/android/README.txt [changed mode: 0644->0755]
resource/csdk/connectivity/build/android/SConscript [changed mode: 0644->0755]
resource/csdk/connectivity/build/android/jni/Android.mk [changed mode: 0644->0755]
resource/csdk/connectivity/build/android/jni/Application.mk [changed mode: 0644->0755]
resource/csdk/connectivity/build/arduino/Arduino_Setup_README.txt [changed mode: 0644->0755]
resource/csdk/connectivity/build/arduino/Makefile [new file with mode: 0755]
resource/csdk/connectivity/build/arduino/README.txt [changed mode: 0644->0755]
resource/csdk/connectivity/build/arduino/SConscript [changed mode: 0644->0755]
resource/csdk/connectivity/build/arduino/arduino.scons [changed mode: 0644->0755]
resource/csdk/connectivity/build/arduino/arduinomega.properties [changed mode: 0644->0755]
resource/csdk/connectivity/build/arduino/build.sh [changed mode: 0644->0755]
resource/csdk/connectivity/build/arduino/local.properties [changed mode: 0644->0755]
resource/csdk/connectivity/build/common.mk [new file with mode: 0755]
resource/csdk/connectivity/build/linux/SConscript [changed mode: 0644->0755]
resource/csdk/connectivity/build/tizen/Makefile [new file with mode: 0755]
resource/csdk/connectivity/build/tizen/SConscript [new file with mode: 0755]
resource/csdk/connectivity/build/tizen/SConstruct [changed mode: 0644->0755]
resource/csdk/connectivity/build/tizen/com.oic.ca.manifest [changed mode: 0644->0755]
resource/csdk/connectivity/build/tizen/com.oic.ca.pc [changed mode: 0644->0755]
resource/csdk/connectivity/build/tizen/gbsbuild.sh [changed mode: 0644->0755]
resource/csdk/connectivity/build/tizen/packaging/com.oic.ca.spec [changed mode: 0644->0755]
resource/csdk/connectivity/build/tizen/scons/SConscript [changed mode: 0644->0755]
resource/csdk/connectivity/lib/libcoap-4.1.1/SConscript
resource/csdk/connectivity/samples/android/sample_service/jni/Application.mk
resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/ca/CaIpInterface.java [new file with mode: 0644]
resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c
resource/csdk/connectivity/src/ip_adapter/android/org_iotivity_ca_CaIpInterface.h [new file with mode: 0644]
resource/csdk/connectivity/src/ip_adapter/android/org_iotivity_jar_caipinterface.h [deleted file]
resource/csdk/stack/samples/linux/secure/SConscript
resource/examples/SConscript
resource/include/OCRepresentation.h
resource/oc_logger/SConscript
resource/oc_logger/examples/SConscript
resource/src/SConscript

index d242a39..e34025b 100644 (file)
@@ -84,6 +84,10 @@ extlibs/master.zip
 extlibs/cereal/cereal
 extlibs/expat/expat*
 extlibs/cereal
+extlibs/android/gradle/gradle-2.2.1
+extlibs/android/ndk/android-ndk-r10d
+extlibs/android/sdk/android-sdk_r24.2
+extlibs/boost/boost_1_58_0
 *.tgz
 *.zip
 extlibs/arduino/arduino-1.5.8
index 2ea9acb..eeaa86a 100644 (file)
@@ -33,6 +33,10 @@ Import('env')
 target_os = env.get('TARGET_OS')
 if target_os == 'arduino':
        SConscript('arduino.scons')
+
+if target_os == 'android':
+       SConscript('android/android_api/SConscript')
+
 # By default, src_dir is current dir, the build_dir is:
 #     ./out/<target_os>/<target_arch>/<release or debug>/
 #
diff --git a/android/Base/app/build.gradle b/android/Base/app/build.gradle
deleted file mode 100644 (file)
index 31d66bb..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-apply plugin: 'com.android.library'
-
-android {
-    compileSdkVersion 19
-    buildToolsVersion "19.1.0"
-
-    defaultConfig {
-        applicationId "org.iotivity.base"
-        minSdkVersion 19
-        targetSdkVersion 19
-        versionCode 1
-        versionName "1.0"
-    }
-    buildTypes {
-        release {
-            runProguard false
-            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
-        }
-    }
-}
-
-dependencies {
-    compile fileTree(dir: 'libs', include: ['*.jar'])
-}
-
-
-//////////////
-// NDK Support
-//////////////
-// If using this, Android studio will fail run the following to set the environment variable for android studio:
-// launchctl setenv ANDROID_NDK_HOME /Users/boos_patrick/Development/Android/android-ndk-r8e
-// otherwise remove the dependsOn part and run ./gradlew buildNative from the command line
-task copyNativeLibs(type: Copy, dependsOn: 'buildNative') {
-    dependsOn 'buildNative'
-    from(new File('libs')) { include '**/*.so' }
-    into new File(buildDir, 'native-libs')
-}
-
-tasks.withType(Compile) { compileTask -> compileTask.dependsOn copyNativeLibs }
-
-clean.dependsOn 'cleanCopyNativeLibs'
-
-tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->
-    pkgTask.jniFolders = new HashSet<File>()
-    pkgTask.jniFolders.add(new File(buildDir, 'native-libs'))
-}
-
-task buildNative(type: Exec) {
-    if (System.env.ANDROID_NDK_HOME != null) {
-        def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build')
-        commandLine ndkBuild
-    } else {
-        doLast {
-            println '##################'
-            println 'Skipping NDK build'
-            println 'Reason: ANDROID_NDK_HOME not set.'
-            println '##################'
-        }
-    }
-}
diff --git a/android/Base/app/jni/ocheaderoption-jni.cpp b/android/Base/app/jni/ocheaderoption-jni.cpp
deleted file mode 100644 (file)
index 7dcd320..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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 "ocstack-jni.h"
-
-static const char* TAG = "OCHEADEROPTION-JNI";
-
-JNIEXPORT jint JNICALL getOptionID(JNIEnv *env, jobject jobj)
-{
-    OC::HeaderOption::OCHeaderOption *option = getHandle<OC::HeaderOption::OCHeaderOption>(env, jobj);
-    return option->getOptionID();
-}
-
-JNIEXPORT jstring JNICALL getOptionData(JNIEnv *env, jobject jobj)
-{
-    OC::HeaderOption::OCHeaderOption *option = getHandle<OC::HeaderOption::OCHeaderOption>(env, jobj);
-    std::string data = option->getOptionData();
-    return env->NewStringUTF(data.c_str());
-}
-
-JNIEXPORT jlong JNICALL OCHeaderOptionConstructor(JNIEnv *env, jobject jobj, jint joption, jstring jdata)
-{
-    OC::HeaderOption::OCHeaderOption *option = new OC::HeaderOption::OCHeaderOption(joption, env->GetStringUTFChars(jdata, 0));
-    jlong instptr = reinterpret_cast<jlong>(option);
-    return instptr;
-}
-
diff --git a/android/Base/app/jni/ocplatform-jni.cpp b/android/Base/app/jni/ocplatform-jni.cpp
deleted file mode 100644 (file)
index a69ac2d..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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 "ocstack-jni.h"
-
-static const char* TAG = "OCPLATFORM-JNI";
-
-JNIEXPORT void JNICALL configure(JNIEnv *env, jobject obj, jobject jcfg)
-{
-    OC::PlatformConfig *cfg = getHandle<OC::PlatformConfig>(env, jcfg);
-
-    __android_log_print(ANDROID_LOG_INFO, TAG, "service : %d\n", (int) cfg->serviceType);
-    __android_log_print(ANDROID_LOG_INFO, TAG, "mode    : %d\n", (int) cfg->mode);
-    __android_log_print(ANDROID_LOG_INFO, TAG, "IP      : %s\n", (cfg->ipAddress).c_str());
-    __android_log_print(ANDROID_LOG_INFO, TAG, "port    : %d\n", cfg->port);
-    __android_log_print(ANDROID_LOG_INFO, TAG, "QOS     : %d\n", (int) cfg->QoS);
-
-    OC::OCPlatform::Configure(*cfg);
-}
-
-
-JNIEXPORT jint JNICALL findResource(JNIEnv* env, jobject obj, jstring jhost, jstring juri, jobject found)
-{
-       string host = env->GetStringUTFChars(jhost,0);
-       string uri = env->GetStringUTFChars(juri,0);
-
-    JNICallBackContext *callbackContext;
-    string key = uri + "/FIND";
-    std:map<std::string, JNICallBackContext*>::iterator iter = gJNICallBackContextList.find(key);
-    if(iter == gJNICallBackContextList.end()) {
-        gJNICallBackContextList[key] = new JNICallBackContext(env->NewGlobalRef(found));
-        callbackContext = gJNICallBackContextList[key];
-        __android_log_print(ANDROID_LOG_INFO, TAG, "Adding %s to gJNICallBackContextList", key.c_str());
-    }
-    else
-        callbackContext = iter->second;
-
-    __android_log_print(ANDROID_LOG_ERROR, TAG, "Calling oic base findresource()\n");
-    try {
-        OC::OCPlatform::findResource(host, uri,
-            [callbackContext](std::shared_ptr<OC::OCResource> resource)
-            {
-                 JNIEnv * env;
-
-                // Attach to JavaVM
-                // double check it's all ok
-                int getEnvStat = g_JavaVM->GetEnv((void **)&env, JNI_VERSION_1_6);
-                if (getEnvStat == JNI_EDETACHED) {
-                    __android_log_print(ANDROID_LOG_ERROR, TAG, "GetEnv: not attached");
-                    if (g_JavaVM->AttachCurrentThread(&env, NULL) != 0) {
-                    __android_log_print(ANDROID_LOG_ERROR, TAG, "Failed to attach");
-                    }
-                    else
-                        __android_log_print(ANDROID_LOG_INFO, TAG, "Attached OK");
-                } else if (getEnvStat == JNI_OK) {
-                //
-                } else if (getEnvStat == JNI_EVERSION) {
-                    __android_log_print(ANDROID_LOG_ERROR, TAG, "GetEnv: version not supported");
-                }
-
-                // save the C++ resource ptr now
-                jmethodID resource_constructor = env->GetMethodID(g_ocresource_clazz, "<init>", "(J)V");
-
-                callbackContext->m_resource = resource;
-                jobject jresource = env->NewObject(g_ocresource_clazz, resource_constructor, \
-                                        (jlong) reinterpret_cast<jlong>(&callbackContext->m_resource));
-
-                if(jresource == NULL) {
-                    __android_log_print(ANDROID_LOG_ERROR, TAG, "cannot create OCResource class");
-                    return;
-                }
-
-                jclass clazz = env->GetObjectClass(callbackContext->m_callBackFunction);
-                if (clazz == NULL) {
-                    __android_log_print(ANDROID_LOG_ERROR, TAG, "Failed to find class");
-                }
-
-                // Find Callback function
-                jmethodID mid = env->GetMethodID(clazz, "Callback", \
-                        "(Lorg/iotivity/base/OCResource;)V");
-                if(mid == NULL) {
-                    __android_log_print(ANDROID_LOG_ERROR, TAG, "FoundResource.Callback() is not defined in JAVA");
-                    return;
-                }
-
-                __android_log_print(ANDROID_LOG_INFO, TAG, "calling JAVA FindCallback");
-                try {
-                    env->CallVoidMethod(callbackContext->m_callBackFunction, mid, jresource);
-                } catch(OC::OCException& e) {
-                    __android_log_print(ANDROID_LOG_ERROR, TAG, "callbackContext() exception : %s", e.reason(e).c_str());
-                }
-
-                __android_log_print(ANDROID_LOG_INFO, TAG, "fineResourceCB detach");
-                env->DeleteLocalRef(jresource);
-                g_JavaVM->DetachCurrentThread();
-
-            }
-        );
-    }
-    catch(OC::OCException& e) {
-        __android_log_print(ANDROID_LOG_ERROR, TAG, "FindCB() exception : %s", e.reason(e).c_str());
-    }
-    __android_log_print(ANDROID_LOG_ERROR, TAG, "Called oic base findresource()\n");
-
-    return 0;
-}
-
diff --git a/android/Base/app/jni/ocrepresentation-jni.cpp b/android/Base/app/jni/ocrepresentation-jni.cpp
deleted file mode 100644 (file)
index d7c894d..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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 "ocstack-jni.h"
-
-static const char* TAG = "OCREPRESENTATION-JNI";
-
-JNIEXPORT jlong JNICALL OCRepresentationConstructor(JNIEnv *env, jobject jobj)
-{
-    OC::OCRepresentation *rep = new OC::OCRepresentation();
-    jlong instptr = reinterpret_cast<jlong>(rep);
-    return instptr;
-}
-
-JNIEXPORT jstring JNICALL getUri(JNIEnv *env, jobject jobj)
-{
-    OC::OCRepresentation *rep = getHandle<OC::OCRepresentation>(env, jobj);
-    string uri = rep->getUri();
-    __android_log_print(ANDROID_LOG_INFO, TAG, "getUri() URI : %s", uri.c_str());
-    return env->NewStringUTF(uri.c_str());
-}
-
-JNIEXPORT jint JNICALL getValueInt(JNIEnv *env, jobject jobj, jstring jstr)
-{
-    OC::OCRepresentation *rep = getHandle<OC::OCRepresentation>(env, jobj);
-       string str = env->GetStringUTFChars(jstr,0);
-       int val;
-    rep->getValue(str, val);
-    __android_log_print(ANDROID_LOG_INFO, TAG, "getValueInt() : %d", val);
-    return((jint) val);
-}
-
-
-JNIEXPORT jboolean JNICALL getValueBool(JNIEnv *env, jobject jobj, jstring jstr)
-{
-    OC::OCRepresentation *rep = getHandle<OC::OCRepresentation>(env, jobj);
-       string str = env->GetStringUTFChars(jstr,0);
-    bool val;
-    rep->getValue(str, val);
-    __android_log_print(ANDROID_LOG_INFO, TAG, "getValueBool() : %d", val);
-    return((jboolean) val);
-}
-
-JNIEXPORT jstring JNICALL getValueString(JNIEnv *env, jobject jobj, jstring jstr)
-{
-    OC::OCRepresentation *rep = getHandle<OC::OCRepresentation>(env, jobj);
-       string str = env->GetStringUTFChars(jstr,0);
-       string get_val;
-    rep->getValue(str, get_val);
-
-    __android_log_print(ANDROID_LOG_INFO, TAG, "getValueString() : %s", get_val.c_str());
-    return env->NewStringUTF(get_val.c_str());
-}
-
-JNIEXPORT void JNICALL setValueInt(JNIEnv *env, jobject jobj, jstring jstr, jint jval)
-{
-    OC::OCRepresentation *rep = getHandle<OC::OCRepresentation>(env, jobj);
-       string str = env->GetStringUTFChars(jstr,0);
-    rep->setValue(str, jval);
-}
-
-JNIEXPORT void JNICALL setValueBool(JNIEnv *env, jobject jobj, jstring jstr, jboolean jval)
-{
-    OC::OCRepresentation *rep = getHandle<OC::OCRepresentation>(env, jobj);
-       string str = env->GetStringUTFChars(jstr,0);
-    rep->setValue(str, (bool) jval);
-}
-
-JNIEXPORT void JNICALL setValueString(JNIEnv *env, jobject jobj, jstring jstr, jstring jval)
-{
-    OC::OCRepresentation *rep = getHandle<OC::OCRepresentation>(env, jobj);
-       string str = env->GetStringUTFChars(jstr,0);
-       string val = env->GetStringUTFChars(jval,0);
-
-    rep->setValue(str, val);
-}
-
-JNIEXPORT jboolean JNICALL hasAttribute(JNIEnv *env, jobject jobj, jstring jstr)
-{
-    OC::OCRepresentation *rep = getHandle<OC::OCRepresentation>(env, jobj);
-       string str = env->GetStringUTFChars(jstr,0);
-
-    return rep->hasAttribute(str);
-}
diff --git a/android/Base/app/jni/ocresource-jni.cpp b/android/Base/app/jni/ocresource-jni.cpp
deleted file mode 100644 (file)
index 95c2c39..0000000
+++ /dev/null
@@ -1,445 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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 "ocstack-jni.h"
-
-static const char* TAG = "OCRESOURCE-JNI";
-
-JNIEXPORT jobject JNICALL jniOicGet(JNIEnv *env, jobject jobj, jobject jattributeHandler)
-{
-
-    std::shared_ptr<OC::OCResource> *resource = getHandle<std::shared_ptr<OC::OCResource>>(env, jobj);
-    __android_log_print(ANDROID_LOG_ERROR, TAG, "get() resource = %p\n", resource);
-
-    JNICallBackContext *callbackContext;
-    string key = (*resource)->uri() + "/GET";
-    std:map<std::string, JNICallBackContext*>::iterator iter = gJNICallBackContextList.find(key);
-    if(iter == gJNICallBackContextList.end()) {
-        gJNICallBackContextList[key] = new JNICallBackContext(*resource, env->NewGlobalRef(jattributeHandler));
-        callbackContext = gJNICallBackContextList[key];
-        __android_log_print(ANDROID_LOG_INFO, TAG, "Adding %s to gJNICallBackContextList", key.c_str());
-    }
-    else {
-        iter->second->m_callBackFunction = env->NewGlobalRef(jattributeHandler);
-        callbackContext = iter->second;
-    }
-
-       OC::QueryParamsMap test;
-    __android_log_print(ANDROID_LOG_ERROR, TAG, "calling oic base get()\n");
-
-    (*resource)->get(test,
-        [callbackContext](const OC::HeaderOptions& headerOptions, const OC::OCRepresentation& rep, const int eCode)
-        {
-             JNIEnv * env;
-
-            // Attach to JavaVM
-            // double check it's all ok
-            int getEnvStat = g_JavaVM->GetEnv((void **)&env, JNI_VERSION_1_6);
-            if (getEnvStat == JNI_EDETACHED) {
-                __android_log_print(ANDROID_LOG_ERROR, TAG, "GetEnv: not attached");
-                if (g_JavaVM->AttachCurrentThread(&env, NULL) != 0) {
-                __android_log_print(ANDROID_LOG_ERROR, TAG, "Failed to attach");
-                }
-                else
-                    __android_log_print(ANDROID_LOG_INFO, TAG, "Attached OK");
-            } else if (getEnvStat == JNI_OK) {
-            //
-            } else if (getEnvStat == JNI_EVERSION) {
-                __android_log_print(ANDROID_LOG_ERROR, TAG, "GetEnv: version not supported");
-            }
-
-            // save C++ ocheaderoption ptr now
-            jmethodID option_constructor = env->GetMethodID(g_ocheaderoption_clazz, "<init>", "(J)V");
-            int size = headerOptions.size();
-            jobjectArray joptions = env->NewObjectArray(size, g_ocheaderoption_clazz, 0);
-            for (int n=0; n<size;n++) {
-                jobject jelem = env->NewObject(g_ocheaderoption_clazz, option_constructor, \
-                                            (jlong) reinterpret_cast<jlong>(&headerOptions[n]));
-
-                __android_log_print(ANDROID_LOG_ERROR, TAG, "jelem : %llu",  (jlong) reinterpret_cast<jlong>(&headerOptions[n]));
-
-                env->SetObjectArrayElement(joptions, n, jelem);
-                env->DeleteLocalRef(jelem);
-            }
-
-            // save C++ ocrepresentation ptr now
-            jmethodID representation_constructor = env->GetMethodID(g_ocrepresentation_clazz, "<init>", "(J)V");
-            jobject jrepresentation = env->NewObject(g_ocrepresentation_clazz, representation_constructor, \
-                                    (jlong) reinterpret_cast<jlong>(&rep));
-            if(jrepresentation == NULL) {
-                __android_log_print(ANDROID_LOG_ERROR, TAG, "cannot create OCRepresentation class");
-                return;
-            }
-
-            jclass cb_clazz = env->GetObjectClass(callbackContext->m_callBackFunction);
-            if (cb_clazz == NULL) {
-                __android_log_print(ANDROID_LOG_ERROR, TAG, "Failed to find class");
-            }
-
-            // Find Callback function
-            jmethodID cb_mid = env->GetMethodID(cb_clazz, "Callback", \
-                    "([Lorg/iotivity/base/OCHeaderOption;Lorg/iotivity/base/OCRepresentation;I)V");
-            if(cb_mid == NULL) {
-                __android_log_print(ANDROID_LOG_ERROR, TAG, "onGet.Callback() is not defined in JAVA");
-                return;
-            }
-
-            __android_log_print(ANDROID_LOG_INFO, TAG, "calling JAVA GetCallback");
-            env->CallVoidMethod(callbackContext->m_callBackFunction, cb_mid, joptions, jrepresentation, eCode);
-
-            __android_log_print(ANDROID_LOG_INFO, TAG, "getCB detach");
-            g_JavaVM->DetachCurrentThread();
-
-        }
-        );
-    return NULL;
-
-}
-
-JNIEXPORT jobject JNICALL jniOicPut(JNIEnv *env, jobject jobj, jobject jocrepresentation, jobject jattributeHandler)
-{
-    std::shared_ptr<OC::OCResource> *resource = getHandle<std::shared_ptr<OC::OCResource>>(env, jobj);
-    __android_log_print(ANDROID_LOG_ERROR, TAG, "put1() resource = %p\n", resource);
-
-    JNICallBackContext *callbackContext;
-    string key = (*resource)->uri() + "/PUT";
-    std:map<std::string, JNICallBackContext*>::iterator iter = gJNICallBackContextList.find(key);
-    if(iter == gJNICallBackContextList.end()) {
-        gJNICallBackContextList[key] = new JNICallBackContext(*resource, env->NewGlobalRef(jattributeHandler));
-        callbackContext = gJNICallBackContextList[key];
-        __android_log_print(ANDROID_LOG_INFO, TAG, "Adding %s to gJNICallBackContextList", key.c_str());
-    }
-    else {
-        iter->second->m_callBackFunction = env->NewGlobalRef(jattributeHandler);
-        callbackContext = iter->second;
-    }
-
-    OC::OCRepresentation *rep = getHandle<OC::OCRepresentation>(env, jocrepresentation);
-       OC::QueryParamsMap test;
-    __android_log_print(ANDROID_LOG_ERROR, TAG, "calling oic base put()\n");
-
-    (*resource)->put(*rep, test,
-        [callbackContext](const OC::HeaderOptions& headerOptions, const OC::OCRepresentation& rep, const int eCode)
-        {
-             JNIEnv * env;
-
-            // Attach to JavaVM
-            // double check it's all ok
-            int getEnvStat = g_JavaVM->GetEnv((void **)&env, JNI_VERSION_1_6);
-            if (getEnvStat == JNI_EDETACHED) {
-                __android_log_print(ANDROID_LOG_ERROR, TAG, "GetEnv: not attached");
-                if (g_JavaVM->AttachCurrentThread(&env, NULL) != 0) {
-                __android_log_print(ANDROID_LOG_ERROR, TAG, "Failed to attach");
-                }
-                else
-                    __android_log_print(ANDROID_LOG_INFO, TAG, "Attached OK");
-            } else if (getEnvStat == JNI_OK) {
-            //
-            } else if (getEnvStat == JNI_EVERSION) {
-                __android_log_print(ANDROID_LOG_ERROR, TAG, "GetEnv: version not supported");
-            }
-
-            // save C++ ocheaderoption ptr now
-            jmethodID option_constructor = env->GetMethodID(g_ocheaderoption_clazz, "<init>", "(J)V");
-            int size = headerOptions.size();
-            jobjectArray joptions = env->NewObjectArray(size, g_ocheaderoption_clazz, 0);
-            for (int n=0; n<size;n++) {
-                jobject jelem = env->NewObject(g_ocheaderoption_clazz, option_constructor, \
-                                            (jlong) reinterpret_cast<jlong>(&headerOptions[n]));
-
-                __android_log_print(ANDROID_LOG_ERROR, TAG, "jelem : %llu",  (jlong) reinterpret_cast<jlong>(&headerOptions[n]));
-
-                env->SetObjectArrayElement(joptions, n, jelem);
-                env->DeleteLocalRef(jelem);
-            }
-
-            // save C++ ocrepresentation ptr now
-            jmethodID representation_constructor = env->GetMethodID(g_ocrepresentation_clazz, "<init>", "(J)V");
-            jobject jrepresentation = env->NewObject(g_ocrepresentation_clazz, representation_constructor, \
-                                    (jlong) reinterpret_cast<jlong>(&rep));
-            if(jrepresentation == NULL) {
-                __android_log_print(ANDROID_LOG_ERROR, TAG, "cannot create OCRepresentation class");
-                return;
-            }
-
-            jclass cb_clazz = env->GetObjectClass(callbackContext->m_callBackFunction);
-            if (cb_clazz == NULL) {
-                __android_log_print(ANDROID_LOG_ERROR, TAG, "Failed to find class");
-            }
-
-            // Find Callback function
-            jmethodID cb_mid = env->GetMethodID(cb_clazz, "Callback", \
-                    "([Lorg/iotivity/base/OCHeaderOption;Lorg/iotivity/base/OCRepresentation;I)V");
-            if(cb_mid == NULL) {
-                __android_log_print(ANDROID_LOG_ERROR, TAG, "onPut.Callback() is not defined in JAVA");
-                return;
-            }
-
-            __android_log_print(ANDROID_LOG_INFO, TAG, "calling JAVA PutCallback");
-            env->CallVoidMethod(callbackContext->m_callBackFunction, cb_mid, joptions, jrepresentation, eCode);
-
-            __android_log_print(ANDROID_LOG_INFO, TAG, "putCB detach");
-            g_JavaVM->DetachCurrentThread();
-        }
-        );
-    return NULL;
-}
-
-JNIEXPORT jobject JNICALL jniOicPost(JNIEnv *env, jobject jobj, jobject jocrepresentation, jobject jattributeHandler)
-{
-    std::shared_ptr<OC::OCResource> *resource = getHandle<std::shared_ptr<OC::OCResource>>(env, jobj);
-    __android_log_print(ANDROID_LOG_ERROR, TAG, "post1() resource = %p\n", resource);
-
-    JNICallBackContext *callbackContext;
-    string key = (*resource)->uri() + "/POST";
-    std:map<std::string, JNICallBackContext*>::iterator iter = gJNICallBackContextList.find(key);
-    if(iter == gJNICallBackContextList.end()) {
-        gJNICallBackContextList[key] = new JNICallBackContext(*resource, env->NewGlobalRef(jattributeHandler));
-        callbackContext = gJNICallBackContextList[key];
-        __android_log_print(ANDROID_LOG_INFO, TAG, "Adding %s to gJNICallBackContextList", key.c_str());
-    }
-    else {
-        iter->second->m_callBackFunction = env->NewGlobalRef(jattributeHandler);
-        callbackContext = iter->second;
-    }
-
-    OC::OCRepresentation *rep = getHandle<OC::OCRepresentation>(env, jocrepresentation);
-       OC::QueryParamsMap test;
-    __android_log_print(ANDROID_LOG_ERROR, TAG, "calling oic base post()\n");
-
-    (*resource)->post(*rep, test,
-        [callbackContext](const OC::HeaderOptions& headerOptions, const OC::OCRepresentation& rep, const int eCode)
-        {
-             JNIEnv * env;
-
-            // Attach to JavaVM
-            // double check it's all ok
-            int getEnvStat = g_JavaVM->GetEnv((void **)&env, JNI_VERSION_1_6);
-            if (getEnvStat == JNI_EDETACHED) {
-                __android_log_print(ANDROID_LOG_ERROR, TAG, "GetEnv: not attached");
-                if (g_JavaVM->AttachCurrentThread(&env, NULL) != 0) {
-                __android_log_print(ANDROID_LOG_ERROR, TAG, "Failed to attach");
-                }
-                else
-                    __android_log_print(ANDROID_LOG_INFO, TAG, "Attached OK");
-            } else if (getEnvStat == JNI_OK) {
-            //
-            } else if (getEnvStat == JNI_EVERSION) {
-                __android_log_print(ANDROID_LOG_ERROR, TAG, "GetEnv: version not supported");
-            }
-
-            // save C++ ocheaderoption ptr now
-            jmethodID option_constructor = env->GetMethodID(g_ocheaderoption_clazz, "<init>", "(J)V");
-            int size = headerOptions.size();
-            jobjectArray joptions = env->NewObjectArray(size, g_ocheaderoption_clazz, 0);
-            for (int n=0; n<size;n++) {
-                jobject jelem = env->NewObject(g_ocheaderoption_clazz, option_constructor, \
-                                            (jlong) reinterpret_cast<jlong>(&headerOptions[n]));
-
-                __android_log_print(ANDROID_LOG_ERROR, TAG, "jelem : %llu",  (jlong) reinterpret_cast<jlong>(&headerOptions[n]));
-
-                env->SetObjectArrayElement(joptions, n, jelem);
-                env->DeleteLocalRef(jelem);
-            }
-
-            // save C++ ocrepresentation ptr now
-            jmethodID representation_constructor = env->GetMethodID(g_ocrepresentation_clazz, "<init>", "(J)V");
-            jobject jrepresentation = env->NewObject(g_ocrepresentation_clazz, representation_constructor, \
-                                    (jlong) reinterpret_cast<jlong>(&rep));
-            if(jrepresentation == NULL) {
-                __android_log_print(ANDROID_LOG_ERROR, TAG, "cannot create OCRepresentation class");
-                return;
-            }
-
-            jclass cb_clazz = env->GetObjectClass(callbackContext->m_callBackFunction);
-            if (cb_clazz == NULL) {
-                __android_log_print(ANDROID_LOG_ERROR, TAG, "Failed to find class");
-            }
-
-            // Find Callback function
-            jmethodID cb_mid = env->GetMethodID(cb_clazz, "Callback", \
-                    "([Lorg/iotivity/base/OCHeaderOption;Lorg/iotivity/base/OCRepresentation;I)V");
-            if(cb_mid == NULL) {
-                __android_log_print(ANDROID_LOG_ERROR, TAG, "onPost.Callback() is not defined in JAVA");
-                return;
-            }
-
-            __android_log_print(ANDROID_LOG_INFO, TAG, "calling JAVA PostCallback");
-            env->CallVoidMethod(callbackContext->m_callBackFunction, cb_mid, joptions, jrepresentation, eCode);
-
-            __android_log_print(ANDROID_LOG_INFO, TAG, "postCB detach");
-            g_JavaVM->DetachCurrentThread();
-
-            }
-    );
-    return NULL;
-}
-
-JNIEXPORT jobject JNICALL jniOicObserve(JNIEnv *env, jobject jobj, jint jobservetype, jobject jattributeHandler)
-{
-    std::shared_ptr<OC::OCResource> *resource = getHandle<std::shared_ptr<OC::OCResource>>(env, jobj);
-    __android_log_print(ANDROID_LOG_ERROR, TAG, "observe1() resource = %p\n", resource);
-
-    JNICallBackContext *callbackContext;
-    string key = (*resource)->uri() + "/OBSERVE";
-    std:map<std::string, JNICallBackContext*>::iterator iter = gJNICallBackContextList.find(key);
-    if(iter == gJNICallBackContextList.end()) {
-        gJNICallBackContextList[key] = new JNICallBackContext(*resource, env->NewGlobalRef(jattributeHandler));
-        callbackContext = gJNICallBackContextList[key];
-        __android_log_print(ANDROID_LOG_INFO, TAG, "Adding %s to gJNICallBackContextList", key.c_str());
-    }
-    else {
-        iter->second->m_callBackFunction = env->NewGlobalRef(jattributeHandler);
-        callbackContext = iter->second;
-    }
-
-       OC::QueryParamsMap test;
-    __android_log_print(ANDROID_LOG_ERROR, TAG, "calling oic base observe()\n");
-
-    (*resource)->observe((OC::ObserveType) jobservetype, test,
-        [callbackContext](const OC::HeaderOptions& headerOptions, const OC::OCRepresentation& rep, const int eCode, const int seqNum)
-        {
-             JNIEnv * env;
-
-            // Attach to JavaVM
-            // double check it's all ok
-            int getEnvStat = g_JavaVM->GetEnv((void **)&env, JNI_VERSION_1_6);
-            if (getEnvStat == JNI_EDETACHED) {
-                __android_log_print(ANDROID_LOG_ERROR, TAG, "GetEnv: not attached");
-                if (g_JavaVM->AttachCurrentThread(&env, NULL) != 0) {
-                __android_log_print(ANDROID_LOG_ERROR, TAG, "Failed to attach");
-                }
-                else
-                    __android_log_print(ANDROID_LOG_INFO, TAG, "Attached OK");
-            } else if (getEnvStat == JNI_OK) {
-            //
-            } else if (getEnvStat == JNI_EVERSION) {
-                __android_log_print(ANDROID_LOG_ERROR, TAG, "GetEnv: version not supported");
-            }
-
-            // save C++ ocheaderoption ptr now
-            jmethodID option_constructor = env->GetMethodID(g_ocheaderoption_clazz, "<init>", "(J)V");
-            int size = headerOptions.size();
-            jobjectArray joptions = env->NewObjectArray(size, g_ocheaderoption_clazz, 0);
-            for (int n=0; n<size;n++) {
-                jobject jelem = env->NewObject(g_ocheaderoption_clazz, option_constructor, \
-                                            (jlong) reinterpret_cast<jlong>(&headerOptions[n]));
-
-                __android_log_print(ANDROID_LOG_ERROR, TAG, "jelem : %llu",  (jlong) reinterpret_cast<jlong>(&headerOptions[n]));
-
-                env->SetObjectArrayElement(joptions, n, jelem);
-                env->DeleteLocalRef(jelem);
-            }
-
-            // save C++ ocrepresentation ptr now
-            jmethodID representation_constructor = env->GetMethodID(g_ocrepresentation_clazz, "<init>", "(J)V");
-            jobject jrepresentation = env->NewObject(g_ocrepresentation_clazz, representation_constructor, \
-                                    (jlong) reinterpret_cast<jlong>(&rep));
-            if(jrepresentation == NULL) {
-                __android_log_print(ANDROID_LOG_ERROR, TAG, "cannot create OCRepresentation class");
-                return;
-            }
-
-            jclass cb_clazz = env->GetObjectClass(callbackContext->m_callBackFunction);
-            if (cb_clazz == NULL) {
-                __android_log_print(ANDROID_LOG_ERROR, TAG, "Failed to find class");
-            }
-
-            // Find Callback function
-            jmethodID cb_mid = env->GetMethodID(cb_clazz, "Callback", \
-                    "([Lorg/iotivity/base/OCHeaderOption;Lorg/iotivity/base/OCRepresentation;II)V");
-            if(cb_mid == NULL) {
-                __android_log_print(ANDROID_LOG_ERROR, TAG, "onObserve.Callback() is not defined in JAVA");
-                return;
-            }
-
-            __android_log_print(ANDROID_LOG_INFO, TAG, "calling JAVA ObserveCallback");
-            env->CallVoidMethod(callbackContext->m_callBackFunction, cb_mid, joptions, jrepresentation, eCode, seqNum);
-
-            __android_log_print(ANDROID_LOG_INFO, TAG, "observeCB detach");
-            g_JavaVM->DetachCurrentThread();
-
-        }
-    );
-    return NULL;
-}
-
-JNIEXPORT jobject JNICALL jniOicCancelObserve(JNIEnv *env, jobject jobj)
-{
-    std::shared_ptr<OC::OCResource> *resource = getHandle<std::shared_ptr<OC::OCResource>>(env, jobj);
-    __android_log_print(ANDROID_LOG_ERROR, TAG, "cancelObserve1() resource = %p\n", resource);
-    __android_log_print(ANDROID_LOG_ERROR, TAG, "calling oic base cancelObserve()\n");
-
-    (*resource)->cancelObserve();
-    return NULL;
-}
-
-JNIEXPORT jstring JNICALL uri(JNIEnv *env, jobject jobj)
-{
-    __android_log_print(ANDROID_LOG_ERROR, TAG, "uri()");
-    std::shared_ptr<OC::OCResource> *resource = getHandle<std::shared_ptr<OC::OCResource>>(env, jobj);
-    return env->NewStringUTF((*resource)->uri().c_str());
-}
-
-JNIEXPORT jstring JNICALL host(JNIEnv *env, jobject jobj)
-{
-    __android_log_print(ANDROID_LOG_ERROR, TAG, "host()");
-    std::shared_ptr<OC::OCResource> *resource = getHandle<std::shared_ptr<OC::OCResource>>(env, jobj);
-    return env->NewStringUTF((*resource)->host().c_str());
-}
-
-JNIEXPORT jobjectArray JNICALL getResourceTypes(JNIEnv *env, jobject jobj)
-{
-    __android_log_print(ANDROID_LOG_ERROR, TAG, "getResourceTypes()");
-    std::shared_ptr<OC::OCResource> *resource = getHandle<std::shared_ptr<OC::OCResource>>(env, jobj);
-
-    std::vector<std::string> resourceTypes = (*resource)->getResourceTypes();
-
-    int size = resourceTypes.size();
-    jclass clazz = env->FindClass("java/lang/String");
-    jobjectArray jresourceTypes = env->NewObjectArray(size, clazz, 0);
-
-    for (int n=0; n<size;n++) {
-        jstring jstr = env->NewStringUTF(resourceTypes[n].c_str());
-        env->SetObjectArrayElement(jresourceTypes, n, jstr);
-    }
-
-    return jresourceTypes;
-}
-
-JNIEXPORT jobjectArray JNICALL getResourceInterfaces(JNIEnv *env, jobject jobj)
-{
-    __android_log_print(ANDROID_LOG_ERROR, TAG, "getResourceInterfaces()");
-    std::shared_ptr<OC::OCResource> *resource = getHandle<std::shared_ptr<OC::OCResource>>(env, jobj);
-
-    std::vector<std::string> resourceInterfaces = (*resource)->getResourceInterfaces();
-
-    int size = resourceInterfaces.size();
-    jclass clazz = env->FindClass("java/lang/String");
-    jobjectArray jresourceInterfaces = env->NewObjectArray(size, clazz, 0);
-
-    for (int n=0; n<size;n++) {
-        jstring jstr = env->NewStringUTF(resourceInterfaces[n].c_str());
-        env->SetObjectArrayElement(jresourceInterfaces, n, jstr);
-    }
-
-    return jresourceInterfaces;
-}
-
diff --git a/android/Base/app/jni/ocstack-jni.cpp b/android/Base/app/jni/ocstack-jni.cpp
deleted file mode 100644 (file)
index d9ae850..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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 "ocstack-jni.h"
-
-// Global map to maintain callback functions and ocresource
-// with key = URL + callback operation
-// e.g. key = /a/light/GET
-std::map<string, JNICallBackContext*> gJNICallBackContextList;
-
-JavaVM* g_JavaVM = NULL;
-
-jclass g_ocplatform_clazz;
-jclass g_ocresource_clazz;
-jclass g_ocheaderoption_clazz;
-jclass g_ocrepresentation_clazz;
-jclass g_platformcfg_clazz;
-
-static const char* TAG = "OCSTACK-JNI";
-
-static JNINativeMethod ocplatform_method_table[] = {
-  { "configure", "(Lorg/iotivity/base/PlatformConfig;)V", (void *) configure},
-  { "findResource", "(Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/AbstractFindCallback;)I", (void *) findResource }
-};
-
-static int ocplatform_method_table_size = sizeof(ocplatform_method_table) / sizeof(ocplatform_method_table[0]);
-
-static JNINativeMethod platformconfig_method_table[] = {
-  { "createNativeInstance", "(IILjava/lang/String;II)J", (void *) createNativeInstance },
-};
-
-static int platformconfig_method_table_size = sizeof(platformconfig_method_table) / sizeof(platformconfig_method_table[0]);
-
-static JNINativeMethod ocresource_method_table[] = {
-  { "get", "(Lorg/iotivity/base/AbstractGetCallback;)Lorg/iotivity/base/OCStackResult;", (void *) jniOicGet},
-
-  { "put", "(Lorg/iotivity/base/OCRepresentation;Lorg/iotivity/base/AbstractPutCallback;)Lorg/iotivity/base/OCStackResult;", (void *) jniOicPut},
-  { "post", "(Lorg/iotivity/base/OCRepresentation;Lorg/iotivity/base/AbstractPostCallback;)Lorg/iotivity/base/OCStackResult;", (void *) jniOicPost},
-  { "observe", "(ILorg/iotivity/base/AbstractObserveCallback;)Lorg/iotivity/base/OCStackResult;", (void *) jniOicObserve},
-  { "cancelObserve", "()Lorg/iotivity/base/OCStackResult;", (void *) jniOicCancelObserve},
-  { "uri", "()Ljava/lang/String;", (void *) uri},
-  { "host", "()Ljava/lang/String;", (void *) host},
-  { "getResourceTypes", "()[Ljava/lang/String;", (void *) getResourceTypes},
-  { "getResourceInterfaces", "()[Ljava/lang/String;", (void *) getResourceInterfaces},
-};
-
-static int ocresource_method_table_size = sizeof(ocresource_method_table) / sizeof(ocresource_method_table[0]);
-
-static JNINativeMethod ocheaderoption_method_table[] = {
-  { "getOptionID", "()I", (void *) getOptionID},
-  { "getOptionData", "()Ljava/lang/String;", (void *) getOptionData},
-  { "OCHeaderOptionConstructor", "(ILjava/lang/String;)J", (void *) OCHeaderOptionConstructor},
-};
-
-static int ocheaderoption_method_table_size = sizeof(ocheaderoption_method_table) / sizeof(ocheaderoption_method_table[0]);
-
-static JNINativeMethod ocrepresentation_method_table[] = {
-  { "OCRepresentationConstructor", "()J", (void *) OCRepresentationConstructor},
-  { "getUri", "()Ljava/lang/String;", (void *) getUri},
-  { "getValueInt", "(Ljava/lang/String;)I", (void *) getValueInt},
-  { "getValueBool", "(Ljava/lang/String;)Z", (void *) getValueBool},
-  { "getValueString", "(Ljava/lang/String;)Ljava/lang/String;", (void *) getValueString},
-  { "setValueInt", "(Ljava/lang/String;I)V", (void *) setValueInt},
-  { "setValueBool", "(Ljava/lang/String;Z)V", (void *) setValueBool},
-  { "setValueString", "(Ljava/lang/String;Ljava/lang/String;)V", (void *) setValueString},
-  { "hasAttribute", "(Ljava/lang/String;)Z", (void *) hasAttribute},
-};
-
-static int ocrepresentation_method_table_size = sizeof(ocrepresentation_method_table) / sizeof(ocrepresentation_method_table[0]);
-
-// JNI OnLoad
-JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
-{
-  JNIEnv* env;
-
-  g_JavaVM = vm;
-  __android_log_print(ANDROID_LOG_ERROR, TAG, "g_JavaVM = %p\n", g_JavaVM);
-
-  if (vm->GetEnv((void **) &env, JNI_VERSION_1_6) != JNI_OK) {
-    return JNI_ERR;
-  } else {
-    jint ret;
-    jclass clazz;
-
-    clazz = env->FindClass("org/iotivity/base/OCPlatform");
-    g_ocplatform_clazz = (jclass) env->NewGlobalRef(clazz);
-    env->DeleteLocalRef(clazz);
-    ret = env->RegisterNatives(g_ocplatform_clazz, ocplatform_method_table, ocplatform_method_table_size);
-    __android_log_print(ANDROID_LOG_ERROR, TAG, "load ocplatform = %d\n", ret);
-
-    clazz = env->FindClass("org/iotivity/base/OCResource");
-    g_ocresource_clazz = (jclass) env->NewGlobalRef(clazz);
-    env->DeleteLocalRef(clazz);
-    ret = env->RegisterNatives(g_ocresource_clazz, ocresource_method_table, ocresource_method_table_size);
-    __android_log_print(ANDROID_LOG_ERROR, TAG, "load ocresource = %d\n", ret);
-
-    clazz = env->FindClass("org/iotivity/base/PlatformConfig");
-    g_platformcfg_clazz = (jclass) env->NewGlobalRef(clazz);
-    env->DeleteLocalRef(clazz);
-    ret = env->RegisterNatives(g_platformcfg_clazz, platformconfig_method_table, platformconfig_method_table_size);
-    __android_log_print(ANDROID_LOG_ERROR, TAG, "load platformconfig = %d\n", ret);
-
-    clazz = env->FindClass("org/iotivity/base/OCHeaderOption");
-    g_ocheaderoption_clazz = (jclass) env->NewGlobalRef(clazz);
-    env->DeleteLocalRef(clazz);
-    ret = env->RegisterNatives(g_ocheaderoption_clazz, ocheaderoption_method_table, ocheaderoption_method_table_size);
-    __android_log_print(ANDROID_LOG_ERROR, TAG, "load ocheaderoption = %d\n", ret);
-
-    clazz = env->FindClass("org/iotivity/base/OCRepresentation");
-    g_ocrepresentation_clazz = (jclass) env->NewGlobalRef(clazz);
-    env->DeleteLocalRef(clazz);
-    ret = env->RegisterNatives(g_ocrepresentation_clazz, ocrepresentation_method_table, ocrepresentation_method_table_size);
-    __android_log_print(ANDROID_LOG_ERROR, TAG, "load ocrepresentation = %d\n", ret);
-
-    return JNI_VERSION_1_6;
-  }
-}
diff --git a/android/Base/app/jni/ocstack-jni.h b/android/Base/app/jni/ocstack-jni.h
deleted file mode 100644 (file)
index dd55aa4..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-#ifndef _Included_org_iotivity_base_ocstack
-#define _Included_org_iotivity_base_ocstack
-
-#include <jni.h>
-#include <android/log.h>
-#include "OCApi.h"
-#include "OCPlatform.h"
-
-class JNICallBackContext {
-    public:
-
-    std::shared_ptr<OC::OCResource> m_resource;
-    jobject m_callBackFunction;
-
-    JNICallBackContext(jobject callback) {
-        m_resource = NULL;
-        m_callBackFunction = callback;
-    }
-
-    JNICallBackContext(std::shared_ptr<OC::OCResource> rsrc,
-        jobject callback) {
-        m_resource = rsrc;
-        m_callBackFunction = callback;
-    }
-};
-
-extern std::map<string, JNICallBackContext*> gJNICallBackContextList;
-
-extern JavaVM* g_JavaVM;
-
-extern jclass g_ocplatform_clazz;
-extern jclass g_ocresource_clazz;
-extern jclass g_ocheaderoption_clazz;
-extern jclass g_ocrepresentation_clazz;
-extern jclass g_platformcfg_clazz;
-
-template <typename T>
-T *getHandle(JNIEnv *env, jobject obj)
-{
-    jclass cls = env->GetObjectClass(obj);
-    jfieldID fid = env->GetFieldID(cls, "nativeHandle", "J");
-    jlong handle = env->GetLongField(obj, fid);
-    return reinterpret_cast<T *>(handle);
-}
-
-// ocplatform-jni
-extern JNIEXPORT void JNICALL configure(JNIEnv *env, jobject obj, jobject jcfg);
-extern JNIEXPORT jint JNICALL findResource(JNIEnv* env, jobject obj, jstring jhost, jstring juri, jobject found);
-
-// platformcfg-jni
-extern JNIEXPORT jlong JNICALL createNativeInstance
-  (JNIEnv *env, jobject obj, jint jServiceType, jint jModeType, jstring jIpAddress, jint port, jint jQOS);
-
-// ocheaderoption-jni
-extern JNIEXPORT jint JNICALL getOptionID(JNIEnv *env, jobject jobj);
-extern JNIEXPORT jstring JNICALL getOptionData(JNIEnv *env, jobject jobj);
-extern JNIEXPORT jlong JNICALL OCHeaderOptionConstructor(JNIEnv *env, jobject jobj, jint joption, jstring jdata);
-
-// ocrepresentation-jni
-extern JNIEXPORT jlong JNICALL OCRepresentationConstructor(JNIEnv *env, jobject jobj);
-extern JNIEXPORT jstring JNICALL getUri(JNIEnv *env, jobject jobj);
-extern JNIEXPORT jint JNICALL getValueInt(JNIEnv *env, jobject jobj, jstring jstr);
-extern JNIEXPORT jboolean JNICALL getValueBool(JNIEnv *env, jobject jobj, jstring jstr);
-extern JNIEXPORT jstring JNICALL getValueString(JNIEnv *env, jobject jobj, jstring jstr);
-extern JNIEXPORT void JNICALL setValueInt(JNIEnv *env, jobject jobj, jstring jstr, jint jval);
-extern JNIEXPORT void JNICALL setValueBool(JNIEnv *env, jobject jobj, jstring jstr, jboolean jval);
-extern JNIEXPORT void JNICALL setValueString(JNIEnv *env, jobject jobj, jstring jstr, jstring jval);
-extern JNIEXPORT jboolean JNICALL hasAttribute(JNIEnv *env, jobject jobj, jstring jstr);
-
-// ocresource-jni
-extern JNIEXPORT jobject JNICALL jniOicGet(JNIEnv *env, jobject jobj, jobject jattributeHandler);
-extern JNIEXPORT jobject JNICALL jniOicPut(JNIEnv *env, jobject jobj, jobject jocrepresentation, jobject jattributeHandler);
-extern JNIEXPORT jobject JNICALL jniOicPost(JNIEnv *env, jobject jobj, jobject jocrepresentation, jobject jattributeHandler);
-extern JNIEXPORT jobject JNICALL jniOicObserve(JNIEnv *env, jobject jobj, jint jobservetype, jobject jattributeHandler);
-extern JNIEXPORT jobject JNICALL jniOicCancelObserve(JNIEnv *env, jobject jobj);
-extern JNIEXPORT jstring JNICALL uri(JNIEnv *env, jobject jobj);
-extern JNIEXPORT jstring JNICALL host(JNIEnv *env, jobject jobj);
-extern JNIEXPORT jobjectArray JNICALL getResourceTypes(JNIEnv *env, jobject jobj);
-extern JNIEXPORT jobjectArray JNICALL getResourceInterfaces(JNIEnv *env, jobject jobj);
-
-#endif
diff --git a/android/Base/app/jni/platformcfg-jni.cpp b/android/Base/app/jni/platformcfg-jni.cpp
deleted file mode 100644 (file)
index 73d40f9..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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 "ocstack-jni.h"
-
-static const char* TAG = "PLATFORMCFG-JNI";
-
-OC::ServiceType getServiceType(int type)
-{
-    switch (type) {
-        case 0:
-            return OC::ServiceType::InProc;
-        case 1:
-        default:
-            return OC::ServiceType::OutOfProc;
-    };
-}
-
-OC::ModeType getModeType(int type)
-{
-    switch (type) {
-        case 0:
-            return OC::ModeType::Server;
-        case 1:
-            return OC::ModeType::Client;
-        case 2:
-        default:
-            return OC::ModeType::Both;
-    };
-}
-
-OC::QualityOfService getQOS(int type)
-{
-    switch (type) {
-        case 0:
-            return OC::QualityOfService::LowQos;
-        case 1:
-            return OC::QualityOfService::MidQos;
-        case 2:
-            return OC::QualityOfService::HighQos;
-        case 3:
-        default:
-            return OC::QualityOfService::NaQos;
-    };
-}
-
-OC::PlatformConfig *g_cfg;
-
-JNIEXPORT jlong JNICALL createNativeInstance
-  (JNIEnv *env, jobject obj, jint jServiceType, jint jModeType, jstring jIpAddress, jint port, jint jQOS)
-{
-
-    g_cfg = new OC::PlatformConfig{getServiceType(jServiceType),
-                            getModeType(jModeType),
-                            env->GetStringUTFChars(jIpAddress, 0),
-                            (uint16_t) port,
-                            getQOS(jQOS)
-    };
-
-
-    jlong instptr = reinterpret_cast<jlong>(g_cfg);
-    return instptr;
-}
diff --git a/android/Base/app/src/androidTest/java/org/iotivity/base/ApplicationTest.java b/android/Base/app/src/androidTest/java/org/iotivity/base/ApplicationTest.java
deleted file mode 100644 (file)
index ac4bdc3..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-package org.iotivity.base;
-
-import android.app.Application;
-import android.test.ApplicationTestCase;
-
-/**
- * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
- */
-public class ApplicationTest extends ApplicationTestCase<Application> {
-    public ApplicationTest() {
-        super(Application.class);
-    }
-}
diff --git a/android/Base/app/src/main/AndroidManifest.xml b/android/Base/app/src/main/AndroidManifest.xml
deleted file mode 100644 (file)
index 32cf1c1..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="org.iotivity.base">
-
-    <application android:allowBackup="true"
-        android:label="@string/app_name"
-        android:icon="@drawable/ic_launcher"
-        android:theme="@style/AppTheme">
-
-    </application>
-
-</manifest>
diff --git a/android/Base/app/src/main/java/org/iotivity/base/AbstractDeleteCallback.java b/android/Base/app/src/main/java/org/iotivity/base/AbstractDeleteCallback.java
deleted file mode 100644 (file)
index d1c26b4..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-package org.iotivity.base;
-
-public abstract class AbstractDeleteCallback {
-    public abstract void Callback(OCHeaderOption options, int a);
-}
diff --git a/android/Base/app/src/main/java/org/iotivity/base/AbstractFindCallback.java b/android/Base/app/src/main/java/org/iotivity/base/AbstractFindCallback.java
deleted file mode 100644 (file)
index 132b1a8..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-package org.iotivity.base;
-
-public abstract class AbstractFindCallback {
-    public abstract void Callback(OCResource resource);
-//    public OCResource ocresource = new OCResource();
-}
diff --git a/android/Base/app/src/main/java/org/iotivity/base/AbstractGetCallback.java b/android/Base/app/src/main/java/org/iotivity/base/AbstractGetCallback.java
deleted file mode 100644 (file)
index 6ba339b..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-package org.iotivity.base;
-
-public abstract class AbstractGetCallback {
-    public abstract void Callback(OCHeaderOption[] options, OCRepresentation rep, int a);
-//    public OCHeaderOption[] ocoptions;
-//    public OCRepresentation ocrep = new OCRepresentation();
-}
diff --git a/android/Base/app/src/main/java/org/iotivity/base/AbstractObserveCallback.java b/android/Base/app/src/main/java/org/iotivity/base/AbstractObserveCallback.java
deleted file mode 100644 (file)
index 6c90561..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-package org.iotivity.base;
-
-public abstract class AbstractObserveCallback {
-    public abstract void Callback(OCHeaderOption[] options, OCRepresentation rep, int a, int b);
-//    public OCHeaderOption[] ocoptions;
-//    public OCRepresentation ocrep = new OCRepresentation();
-}
diff --git a/android/Base/app/src/main/java/org/iotivity/base/AbstractPostCallback.java b/android/Base/app/src/main/java/org/iotivity/base/AbstractPostCallback.java
deleted file mode 100644 (file)
index 20acbea..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-package org.iotivity.base;
-
-public abstract class AbstractPostCallback {
-    public abstract void Callback(OCHeaderOption[] options, OCRepresentation rep, int a);
-//    public OCHeaderOption[] ocoptions;
-//    public OCRepresentation ocrep = new OCRepresentation();
-}
diff --git a/android/Base/app/src/main/java/org/iotivity/base/AbstractPutCallback.java b/android/Base/app/src/main/java/org/iotivity/base/AbstractPutCallback.java
deleted file mode 100644 (file)
index 46f2a19..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.iotivity.base;
-
-public abstract class AbstractPutCallback {
-    public abstract void Callback(OCHeaderOption[] options, OCRepresentation rep, int a);
-//    public OCHeaderOption[] ocoptions;
-//    public OCRepresentation ocrep = new OCRepresentation();
-}
diff --git a/android/Base/app/src/main/java/org/iotivity/base/AbstractSubscriberCallback.java b/android/Base/app/src/main/java/org/iotivity/base/AbstractSubscriberCallback.java
deleted file mode 100644 (file)
index 1f996cb..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-package org.iotivity.base;
-
-public abstract class AbstractSubscriberCallback {
-    public abstract void Callback(OCStackResult result, int a);
-}
diff --git a/android/Base/app/src/main/java/org/iotivity/base/EntityHandler.java b/android/Base/app/src/main/java/org/iotivity/base/EntityHandler.java
deleted file mode 100644 (file)
index 779543c..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-package org.iotivity.base;
-
-public interface EntityHandler {
-    public abstract void Callback(OCResourceRequest request, OCResourceResponse response);
-}
diff --git a/android/Base/app/src/main/java/org/iotivity/base/OCHeaderOption.java b/android/Base/app/src/main/java/org/iotivity/base/OCHeaderOption.java
deleted file mode 100644 (file)
index c169870..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-package org.iotivity.base;
-
-public class OCHeaderOption extends NativeInstance {
-    final private static String TAG = "OCHeaderOption";
-    static {
-        System.loadLibrary("ocstack-jni");
-    }
-
-    public OCHeaderOption(long instPtr) {
-        super.nativeHandle = instPtr;
-    }
-
-    public native int getOptionID();
-    public native String getOptionData();
-    public native long OCHeaderOptionConstructor(int optionID, String optionData);
-}
diff --git a/android/Base/app/src/main/java/org/iotivity/base/OCPlatform.java b/android/Base/app/src/main/java/org/iotivity/base/OCPlatform.java
deleted file mode 100644 (file)
index e4424a6..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-package org.iotivity.base;
-
-public class OCPlatform {
-    final private static String TAG = "OCPlatform";
-    static {
-        System.loadLibrary("ocstack-jni");
-    }
-
-    public static native void configure(PlatformConfig cfg);
-    public static native int findResource(String host, String Uri, AbstractFindCallback found);
-
-}
diff --git a/android/Base/app/src/main/java/org/iotivity/base/OCRepresentation.java b/android/Base/app/src/main/java/org/iotivity/base/OCRepresentation.java
deleted file mode 100644 (file)
index 06a2156..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-package org.iotivity.base;
-
-public class OCRepresentation extends NativeInstance {
-    final private static String TAG = "OCRepresentation";
-    static {
-        System.loadLibrary("ocstack-jni");
-    }
-
-    public OCRepresentation(long instPtr) {
-        super.nativeHandle = instPtr;
-    }
-    public OCRepresentation() {
-        super.nativeHandle = OCRepresentationConstructor();
-    }
-
-    public native long OCRepresentationConstructor();
-
-    public native int getValueInt(String str);
-    public native boolean getValueBool(String str);
-    public native String getValueString(String str);
-
-    public native void setValueInt (String str, int val);
-    public native void setValueBool (String str, boolean val);
-    public native void setValueString (String str, String val);
-
-    public native String getUri();
-
-    public native boolean hasAttribute(String str);
-}
diff --git a/android/Base/app/src/main/java/org/iotivity/base/OCResource.java b/android/Base/app/src/main/java/org/iotivity/base/OCResource.java
deleted file mode 100644 (file)
index 7a7f6c8..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-package org.iotivity.base;
-
-public class OCResource extends NativeInstance {
-    final private static String TAG = "OCResource";
-    static {
-        System.loadLibrary("ocstack-jni");
-    }
-
-    public native OCStackResult get(AbstractGetCallback attributeHandler);
-//    public native OCStackResult get(AbstractGetCallback attributeHandler, PlatformConfig.QualityOfService QoS);
-
-    public native OCStackResult get(String resourceType, String resourceInterface, AbstractGetCallback attributeHandler);
-//    public native OCStackResult get(String resourceType, String resourceInterface, AbstractGetCallback attributeHandler, PlatformConfig.QualityOfService QoS);
-
-    public native OCStackResult put(OCRepresentation rep, AbstractPutCallback attributeHandler);
-//    public native OCStackResult put(OCRepresentation rep, AbstractPutCallback attributeHandler, PlatformConfig.QualityOfService QoS);
-//    public native OCStackResult put(String resourceType, String resourceInterface, OCRepresentation rep, AbstractPutCallback attributeHandler);
-//    public native OCStackResult put(String resourceType, String resourceInterface, OCRepresentation rep, AbstractPutCallback attributeHandler, PlatformConfig.QualityOfService QoS);
-
-    public native OCStackResult post(OCRepresentation rep, AbstractPostCallback attributeHandler);
-//    public native OCStackResult post(OCRepresentation rep, AbstractPostCallback attributeHandler, PlatformConfig.QualityOfService QoS);
-//    public native OCStackResult post(String resourceType, String resourceInterface, OCRepresentation rep, AbstractPostCallback attributeHandler);
-//    public native OCStackResult post(String resourceType, String resourceInterface, OCRepresentation rep, AbstractPostCallback attributeHandler, PlatformConfig.QualityOfService QoS);
-
-    public native OCStackResult observe(int observeType, AbstractObserveCallback observerHandler);
-//    public native OCStackResult observe(int observeType, AbstractObserveCallback observerHandler, PlatformConfig.QualityOfService QoS);
-
-    public native OCStackResult cancelObserve();
-//    public native OCStackResult cancelObserve(PlatformConfig.QualityOfService QoS);
-
-    public native String uri();
-    public native String host();
-
-    public native String[] getResourceInterfaces();
-    public native String[] getResourceTypes();
-
-    public OCResource(long instPtr) {
-        super.nativeHandle = instPtr;
-    }
-}
diff --git a/android/Base/app/src/main/java/org/iotivity/base/OCResourceRequest.java b/android/Base/app/src/main/java/org/iotivity/base/OCResourceRequest.java
deleted file mode 100644 (file)
index 87c406e..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-package org.iotivity.base;
-
-public class OCResourceRequest {
-}
diff --git a/android/Base/app/src/main/java/org/iotivity/base/OCResourceResponse.java b/android/Base/app/src/main/java/org/iotivity/base/OCResourceResponse.java
deleted file mode 100644 (file)
index 283d8de..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-package org.iotivity.base;
-
-public class OCResourceResponse {
-}
diff --git a/android/Base/app/src/main/java/org/iotivity/base/OCStackResult.java b/android/Base/app/src/main/java/org/iotivity/base/OCStackResult.java
deleted file mode 100644 (file)
index 10440b6..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-package org.iotivity.base;
-
-public class OCStackResult {
-    /* Success status code - START HERE */
-    static final public int  OC_STACK_OK                    = 0;
-    static final public int  OC_STACK_RESOURCE_CREATED      = 1;
-    static final public int  OC_STACK_RESOURCE_DELETED      = 2;
-    /* Success status code - END HERE */
-    /* Error status code - START HERE */
-    static final public int  OC_STACK_INVALID_URI           = 3;
-    static final public int  OC_STACK_INVALID_QUERY         = 4;
-    static final public int  OC_STACK_INVALID_IP            = 5;
-    static final public int  OC_STACK_INVALID_PORT          = 6;
-    static final public int  OC_STACK_INVALID_CALLBACK      = 7;
-    static final public int  OC_STACK_INVALID_METHOD        = 8;
-    static final public int  OC_STACK_INVALID_PARAM         = 9;
-    static final public int  OC_STACK_INVALID_OBSERVE_PARAM = 10;
-    static final public int  OC_STACK_NO_MEMORY             = 11;
-    static final public int  OC_STACK_COMM_ERROR            = 12;
-    static final public int  OC_STACK_NOTIMPL               = 13;
-    static final public int  OC_STACK_NO_RESOURCE           = 14;               /* resource not found */
-    static final public int  OC_STACK_RESOURCE_ERROR        = 15;            /* ex: not supported method or interface */
-    static final public int  OC_STACK_SLOW_RESOURCE         = 16;
-    static final public int  OC_STACK_NO_OBSERVERS          = 17;              /* resource has no registered observers */
-    static final public int  OC_STACK_OBSERVER_NOT_FOUND    = 18;
-    static final public int  OC_STACK_OBSERVER_NOT_ADDED    = 19;
-    static final public int  OC_STACK_OBSERVER_NOT_REMOVED  = 20;
-    static final public int  OC_STACK_PRESENCE_STOPPED      = 21;
-    static final public int  OC_STACK_PRESENCE_DO_NOT_HANDLE = 22;
-    static final public int  OC_STACK_INVALID_OPTION        = 23;
-    static final public int  OC_STACK_MALFORMED_RESPONSE    = 24;        /* the remote reply contained malformed data */
-    static final public int  OC_STACK_ERROR                 = 25;
-    /* Error status code - END HERE */
-}
diff --git a/android/Base/app/src/main/java/org/iotivity/base/ObserveType.java b/android/Base/app/src/main/java/org/iotivity/base/ObserveType.java
deleted file mode 100644 (file)
index f61c5d8..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-package org.iotivity.base;
-
-public class ObserveType {
-    static final public int Observe    = 0;
-    static final public int ObserveAll = 1;
-}
diff --git a/android/Base/app/src/main/java/org/iotivity/base/PlatformConfig.java b/android/Base/app/src/main/java/org/iotivity/base/PlatformConfig.java
deleted file mode 100644 (file)
index 301cdde..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-package org.iotivity.base;
-
-public class PlatformConfig extends NativeInstance
-{
-    final private static String TAG = "PlatformConfig";
-    static {
-        System.loadLibrary("ocstack-jni");
-    }
-
-    // ENUM definition. Need to match with OCApi.h
-    public class ServiceType
-    {
-        static final public int INPROC  = 0;
-        static final public int OUTPROC = 1;
-    };
-
-    public class ModeType
-    {
-        static final public int SERVER = 0;
-        static final public int CLIENT = 1;
-        static final public int BOTH   = 2;
-
-    };
-
-    public class QualityOfService
-    {
-        static final public int LO_QOS  = 0;
-        static final public int ME_QOS  = 1;
-        static final public int HI_QOS  = 2;
-        static final public int NA_QOS  = 3;
-    }
-
-    public PlatformConfig(int serviceType,
-                          int mode,
-                          String ipAddress,
-                          int port,
-                          int QoS)
-    {
-        super.nativeHandle = createNativeInstance(serviceType, mode, ipAddress, port, QoS);
-    }
-   
-
-    protected native long createNativeInstance(int serviceType,
-             int mode,
-             String ipAddress,
-             int port,
-             int QoS);
-}
diff --git a/android/Base/app/src/main/res/values/strings.xml b/android/Base/app/src/main/res/values/strings.xml
deleted file mode 100644 (file)
index 73ef225..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-<resources>
-    <string name="app_name">Base</string>
-</resources>
diff --git a/android/Base/gradle.properties b/android/Base/gradle.properties
deleted file mode 100644 (file)
index 5d08ba7..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-# Project-wide Gradle settings.
-
-# IDE (e.g. Android Studio) users:
-# Settings specified in this file will override any Gradle settings
-# configured through the IDE.
-
-# For more details on how to configure your build environment visit
-# http://www.gradle.org/docs/current/userguide/build_environment.html
-
-# Specifies the JVM arguments used for the daemon process.
-# The setting is particularly useful for tweaking memory settings.
-# Default value: -Xmx10248m -XX:MaxPermSize=256m
-# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
-
-# When configured, Gradle will run in incubating parallel mode.
-# This option should only be used with decoupled projects. More details, visit
-# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
\ No newline at end of file
diff --git a/android/Base/settings.gradle b/android/Base/settings.gradle
deleted file mode 100644 (file)
index e7b4def..0000000
+++ /dev/null
@@ -1 +0,0 @@
-include ':app'
diff --git a/android/BuildInstructionsForAndroidAPI.txt b/android/BuildInstructionsForAndroidAPI.txt
new file mode 100644 (file)
index 0000000..8dda6db
--- /dev/null
@@ -0,0 +1,45 @@
+Build Instructions for Android-API:\r
+\r
+1.Verify that you have the latest JDK (you might need to set the JDK_HOME variable)\r
+2.Clone the latest iotivity codebase.\r
+3.set environment variables:\r
+    a.platform=android\r
+    b.If running in windows, change the following line in the build.gradle file (<iotivity>/android/android_api/base/build.gradle):\r
+        def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build')\r
+            to\r
+        def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build.cmd')\r
+\r
+4.Build scons for android and your targeted architecture (This will also build Android API):\r
+    a.scons TARGET_OS=android TARGET_ARCH=<target arch> TARGET_TRANSPORT=IP RELEASE=1 \r
+               where <target arch> can be armeabi, armeabi-v7a, x86.\r
+               Note: To build in debug mode, use RELEASE=0.\r
+               Note: The minimum SDK version supported is 21.\r
+               Note: Only TARGET_TRANSPORT currently supported is IP\r
+    b.If the project is setup correctly, you should see a BUILD SUCCESSFUL message on the terminal\r
+    c.You should see the .aar files generated inside of '<iotivity>/android/android_api/base/build/outputs/aar' directory. The .aar files contain jni directory and also a .jar file\r
+\r
+\r
+TO RUN UNIT TESTS IN ANDROID-API\r
+\r
+5.The '<iotivity>/android/android_api/base/src/androidTest/...' directory contains tests which can be used to get an idea about the Android API usage.\r
+\r
+\r
+TO USE THE .AAR FILE IN <iotivity>/android/examples project\r
+\r
+6. Verify that 9 different *.so files exist inside <iotivity>/android/android-api/base/libs/<TARGET_ARCH> directory. (They should already be present in the *.aar file.)\r
+7. Import Project 'Examples' into android-studio.\r
+8.To add an .aar file to the 'Examples' project,\r
+   a.Right click on Examples->New->Module->Import .JAR or .AAR Package\r
+   b.Select the .aar file from the location in step 6e above\r
+   c.Right click on Examples->Open Module Settings\r
+   d.Select each sample app module under 'Modules'->Dependencies->Add->Module Dependency\r
+   e.The .aar file selected in step 10b above should be present. Select it.\r
+   f.Repeat steps d and e for each sample app module.\r
+\r
+\r
+TO USE THE .AAR FILE IN A DIFFERENT PROJECT\r
+\r
+9. Verify that 9 different *.so files exist inside <iotivity base>/android/android-api/base/libs/<TARGET_ARCH> directory.\r
+10. Import the .aar file in your project to use it\r
+\r
+\r
diff --git a/android/SimpleClient/app/build.gradle b/android/SimpleClient/app/build.gradle
deleted file mode 100644 (file)
index bf753bf..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-apply plugin: 'com.android.application'
-
-android {
-    compileSdkVersion 20
-    buildToolsVersion "19.1.0"
-
-    defaultConfig {
-        applicationId "org.iotivity.simpleclient"
-        minSdkVersion 19
-        targetSdkVersion 20
-        versionCode 1
-        versionName "1.0"
-    }
-    buildTypes {
-        release {
-            runProguard false
-            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
-        }
-    }
-}
-
-dependencies {
-    compile fileTree(dir: 'libs', include: ['*.jar'])
-}
-
-repositories {
-    mavenCentral()
-    flatDir {
-        dirs 'libs'
-    }
-}
-
-
-dependencies {
-    compile fileTree(dir: 'libs', include: ['*.jar'])
-    compile fileTree(dir: 'libs', include: ['*.so'])
-    compile fileTree(dir: 'libs', include: ['**/*.so'])
-//    compile(name: 'OicLib', ext:'aar')
-    compile 'org.iotivity.Base:app:1.0@aar'
-}
\ No newline at end of file
diff --git a/android/SimpleClient/app/proguard-rules.pro b/android/SimpleClient/app/proguard-rules.pro
deleted file mode 100644 (file)
index 0e559b0..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in /home/vchen/ubuntu_sw/adt-bundle-linux-x86_64/sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-#   http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-#   public *;
-#}
diff --git a/android/SimpleClient/app/src/androidTest/java/org/iotivity/simpleclient/ApplicationTest.java b/android/SimpleClient/app/src/androidTest/java/org/iotivity/simpleclient/ApplicationTest.java
deleted file mode 100644 (file)
index a2b6778..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-package org.iotivity.simpleclient;
-
-import android.app.Application;
-import android.test.ApplicationTestCase;
-
-/**
- * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
- */
-public class ApplicationTest extends ApplicationTestCase<Application> {
-    public ApplicationTest() {
-        super(Application.class);
-    }
-}
diff --git a/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/FoundResource.java b/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/FoundResource.java
deleted file mode 100644 (file)
index cd558f4..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-package org.iotivity.simpleclient;
-
-import android.util.Log;
-
-import org.iotivity.base.AbstractFindCallback;
-import org.iotivity.base.OCResource;
-
-public class FoundResource extends AbstractFindCallback {
-    final private static String TAG = "FoundResource";
-
-
-    public void Callback(OCResource resource) {
-
-        if(SimpleClient.curResource != null) {
-            Log.e(TAG, "Found another resource, ignoring");
-        }
-
-        String resourceURI;
-        String hostAddress;
-
-        if(resource != null) {
-            Log.i(TAG, "DISCOVERED Resource");
-
-            resourceURI = resource.uri();
-            Log.i(TAG, "URI of the resource: " + resourceURI);
-
-            hostAddress = resource.host();
-            Log.i(TAG, "Host address of the resource: " + hostAddress);
-
-            new SimpleToast().execute("URI of the resource: " + resourceURI + "\nHost address of the resource: " + hostAddress);
-
-            String[] resourceTypes = resource.getResourceTypes();
-            for(int i=0; i<resourceTypes.length; i++) {
-                Log.i(TAG, "[" + i + "] : " + resourceTypes[i]);
-            }
-
-            String[] resourceInterfaces = resource.getResourceInterfaces();
-            for(int i=0; i<resourceInterfaces.length; i++) {
-                Log.i(TAG, "[" + i + "] : " + resourceInterfaces[i]);
-            }
-
-            if(resourceURI.equals("/a/light")) {
-                SimpleClient.curResource = resource;
-                SimpleClient.getLightRepresentation(resource);
-            }
-        }
-        else {
-            Log.e(TAG, "Resource is invalid");
-        }
-    }
-
-}
diff --git a/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/OnGet.java b/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/OnGet.java
deleted file mode 100644 (file)
index 428c65b..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-package org.iotivity.simpleclient;
-
-import android.util.Log;
-
-import org.iotivity.base.AbstractGetCallback;
-import org.iotivity.base.OCHeaderOption;
-import org.iotivity.base.OCRepresentation;
-import org.iotivity.base.OCStackResult;
-
-public class OnGet extends AbstractGetCallback {
-    final private static String TAG = "OnGet";
-    public void Callback(OCHeaderOption[] options, OCRepresentation rep, int eCode) {
-        if(eCode == OCStackResult.OC_STACK_OK) {
-
-            Log.i(TAG, "GET request was successful");
-            Log.i(TAG, "Resource URI : " + rep.getUri());
-
-            SimpleClient.mylight.m_state = rep.getValueBool("state");
-            Log.i(TAG, "state : " + SimpleClient.mylight.m_state);
-            SimpleClient.mylight.m_power = rep.getValueInt("power");
-            Log.i(TAG, "power : " + SimpleClient.mylight.m_power);
-            SimpleClient.mylight.m_name = rep.getValueString("name");
-            Log.i(TAG, "name  : " + SimpleClient.mylight.m_name);
-
-            new SimpleToast().execute(
-                    "state : " + SimpleClient.mylight.m_state +
-                            "\npower : " + SimpleClient.mylight.m_power +
-                            "\nname  : " + SimpleClient.mylight.m_name
-            );
-
-            SimpleClient.putLightRepresentation(SimpleClient.curResource);
-        }
-        else {
-           Log.e(TAG, "onGet Response error : " + eCode);
-        }
-    }
-
-}
diff --git a/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/OnObserve.java b/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/OnObserve.java
deleted file mode 100644 (file)
index 5a06cbc..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-package org.iotivity.simpleclient;
-
-import android.util.Log;
-
-import org.iotivity.base.AbstractObserveCallback;
-import org.iotivity.base.OCHeaderOption;
-import org.iotivity.base.OCRepresentation;
-import org.iotivity.base.OCStackResult;
-
-public class OnObserve extends AbstractObserveCallback {
-    final private static String TAG = "OnObserve";
-
-    public void Callback(OCHeaderOption[] options, OCRepresentation rep, int eCode, int seqNum) {
-        if(eCode == OCStackResult.OC_STACK_OK) {
-            {
-                Log.i(TAG, "OBSERVE RESULT :");
-                Log.i(TAG, "SequenceNumber : " + seqNum);
-
-                SimpleClient.mylight.m_state = rep.getValueBool("state");
-                Log.i(TAG, "state : " + SimpleClient.mylight.m_state);
-                SimpleClient.mylight.m_power = rep.getValueInt("power");
-                Log.i(TAG, "power : " + SimpleClient.mylight.m_power);
-                SimpleClient.mylight.m_name = rep.getValueString("name");
-                Log.i(TAG, "name  : " + SimpleClient.mylight.m_name);
-
-                new SimpleToast().execute(
-                        "state : " + SimpleClient.mylight.m_state +
-                                "\npower : " + SimpleClient.mylight.m_power +
-                                "\nname  : " + SimpleClient.mylight.m_name
-                );
-
-                if(SimpleClient.observe_count() > 5) {
-                    Log.i(TAG, "Cancelling Observe ...");
-                    OCStackResult result = SimpleClient.curResource.cancelObserve();
-                    Log.i(TAG, "Cancel result : " + result);
-                    try {
-                        Thread.sleep(10000); // 10 sec
-                    } catch (InterruptedException e) {
-                        // TODO Auto-generated catch block
-                        e.printStackTrace();
-                    }
-                    Log.i(TAG, "DONE");
-                    new SimpleToast().execute(
-                            "DONE"
-                    );
-                }
-
-            }
-        }
-        else {
-            Log.e(TAG, "onPut Response error : " + eCode);
-        }
-
-    }
-}
diff --git a/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/OnPost.java b/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/OnPost.java
deleted file mode 100644 (file)
index ca7e1ae..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-package org.iotivity.simpleclient;
-
-import android.util.Log;
-
-import org.iotivity.base.AbstractPostCallback;
-import org.iotivity.base.OCHeaderOption;
-import org.iotivity.base.OCRepresentation;
-
-public class OnPost extends AbstractPostCallback {
-
-    final private static String TAG = "OnPost";
-
-    public void Callback(OCHeaderOption[] options, OCRepresentation rep, int eCode) {
-//FIXME : Need to check why ocstack is returning error code 28 to us after 12/6/14 rebase
-//        if(eCode == OCStackResult.OC_STACK_OK || eCode == OCStackResult.OC_STACK_RESOURCE_CREATED) {
-        if(true) {
-                Log.i(TAG, "POST request was successful");
-
-            if(rep.hasAttribute("createduri")) {
-                Log.i(TAG, "Uri of the created resource : " + rep.getValueString("createduri"));
-            }
-            else {
-                SimpleClient.mylight.m_state = rep.getValueBool("state");
-                Log.i(TAG, "state : " + SimpleClient.mylight.m_state);
-                SimpleClient.mylight.m_power = rep.getValueInt("power");
-                Log.i(TAG, "power : " + SimpleClient.mylight.m_power);
-                SimpleClient.mylight.m_name = rep.getValueString("name");
-                Log.i(TAG, "name  : " + SimpleClient.mylight.m_name);
-
-                new SimpleToast().execute(
-                        "state : " + SimpleClient.mylight.m_state +
-                                "\npower : " + SimpleClient.mylight.m_power +
-                                "\nname  : " + SimpleClient.mylight.m_name
-                );
-            }
-
-            OCRepresentation rep2 = new OCRepresentation();
-
-            Log.e(TAG, "Posting Light Representation ...");
-
-            SimpleClient.mylight.m_state = true;
-            SimpleClient.mylight.m_power = 55;
-
-            Log.i(TAG, "setValueBool : " + SimpleClient.mylight.m_state);
-            Log.i(TAG, "setValueInt  : " + SimpleClient.mylight.m_power);
-            rep2.setValueBool("state", SimpleClient.mylight.m_state);
-            rep2.setValueInt("power", SimpleClient.mylight.m_power);
-
-            OnPost2 onPost2 = new OnPost2();
-            SimpleClient.curResource.post(rep2, onPost2);
-        }
-        else {
-            Log.e(TAG, "onPost Response error : " + eCode);
-        }
-
-    }
-}
diff --git a/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/OnPost2.java b/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/OnPost2.java
deleted file mode 100644 (file)
index cfc6ae6..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-package org.iotivity.simpleclient;
-
-import android.util.Log;
-
-import org.iotivity.base.AbstractPostCallback;
-import org.iotivity.base.OCHeaderOption;
-import org.iotivity.base.OCRepresentation;
-import org.iotivity.base.OCStackResult;
-import org.iotivity.base.ObserveType;
-
-public class OnPost2 extends AbstractPostCallback {
-
-    final private static String TAG = "OnPost2";
-
-    public void Callback(OCHeaderOption[] options, OCRepresentation rep, int eCode) {
-//FIXME : Need to check why ocstack is returning error code 28 to us after 12/6/14 rebase
-//        if(eCode == OCStackResult.OC_STACK_OK || eCode == OCStackResult.OC_STACK_RESOURCE_CREATED) {
-        if(true) {
-
-            Log.i(TAG, "POST2 request was successful");
-
-            if(rep.hasAttribute("createduri")) {
-                String createdUri =  rep.getValueString("createduri");
-                Log.i(TAG, "Uri of the created resource : " + createdUri); // FIXME
-                new SimpleToast().execute(
-                        "Uri of the created resource : " + createdUri
-                );
-            }
-            else {
-                SimpleClient.mylight.m_state = rep.getValueBool("state");
-                Log.i(TAG, "state : " + SimpleClient.mylight.m_state);
-                SimpleClient.mylight.m_power = rep.getValueInt("power");
-                Log.i(TAG, "power : " + SimpleClient.mylight.m_power);
-                SimpleClient.mylight.m_name = rep.getValueString("name");
-                Log.i(TAG, "name  : " + SimpleClient.mylight.m_name);
-                new SimpleToast().execute(
-                        "state : " + SimpleClient.mylight.m_state +
-                                "\npower : " + SimpleClient.mylight.m_power +
-                                "\nname  : " + SimpleClient.mylight.m_name
-                );
-            }
-
-            if(SimpleClient.OBSERVE_TYPE_TO_USE == ObserveType.Observe)
-                Log.i(TAG, "Observe is used");
-            else if(SimpleClient.OBSERVE_TYPE_TO_USE == ObserveType.ObserveAll)
-                Log.i(TAG, "ObserveAll is used");
-
-            OnObserve onObserve = new OnObserve();
-            SimpleClient.curResource.observe(SimpleClient.OBSERVE_TYPE_TO_USE, onObserve);
-        }
-        else {
-            Log.e(TAG, "onPost Response error : " + eCode);
-        }
-    }
-}
diff --git a/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/OnPut.java b/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/OnPut.java
deleted file mode 100644 (file)
index fa8410c..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-package org.iotivity.simpleclient;
-
-import android.util.Log;
-
-import org.iotivity.base.AbstractPutCallback;
-import org.iotivity.base.OCHeaderOption;
-import org.iotivity.base.OCRepresentation;
-import org.iotivity.base.OCStackResult;
-
-public class OnPut extends AbstractPutCallback {
-
-    final private static String TAG = "OnGet";
-
-    public void Callback(OCHeaderOption[] options, OCRepresentation rep, int eCode) {
-        if(eCode == OCStackResult.OC_STACK_OK) {
-            {
-                Log.i(TAG, "PUT request was successful");
-
-                SimpleClient.mylight.m_state = rep.getValueBool("state");
-                Log.i(TAG, "state : " + SimpleClient.mylight.m_state);
-                SimpleClient.mylight.m_power = rep.getValueInt("power");
-                Log.i(TAG, "power : " + SimpleClient.mylight.m_power);
-                SimpleClient.mylight.m_name = rep.getValueString("name");
-                Log.i(TAG, "name  : " + SimpleClient.mylight.m_name);
-                new SimpleToast().execute(
-                        "state : " + SimpleClient.mylight.m_state +
-                        "\npower : " + SimpleClient.mylight.m_power +
-                        "\nname  : " + SimpleClient.mylight.m_name
-                );
-
-                SimpleClient.postLightRepresentation(SimpleClient.curResource);
-            }
-        }
-        else {
-            Log.e(TAG, "onPut Response error : " + eCode);
-        }
-
-    }
-}
diff --git a/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/SimpleClient.java b/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/SimpleClient.java
deleted file mode 100644 (file)
index 7413ca2..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-package org.iotivity.simpleclient;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-
-import org.iotivity.base.OCPlatform;
-import org.iotivity.base.OCRepresentation;
-import org.iotivity.base.OCResource;
-import org.iotivity.base.ObserveType;
-import org.iotivity.base.PlatformConfig;
-
-
-public class SimpleClient extends Activity {
-    final private static String TAG = "SimpleClient";
-
-    class Light {
-        public boolean m_state;
-        public int m_power;
-        public String m_name;
-
-        public Light() {
-            m_state = false;
-            m_power = 0;
-            m_name = "vincent";
-        }
-    }
-
-    static int OBSERVE_TYPE_TO_USE = ObserveType.Observe;
-
-    public static Light mylight;
-    public static OCResource curResource;
-    static int oc = 0;
-    static Activity mActivity;
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        mActivity = this;
-
-        mylight = new Light();
-
-               PlatformConfig cfg = new PlatformConfig(PlatformConfig.ServiceType.INPROC,
-                                                               PlatformConfig.ModeType.CLIENT,
-                                                               "0.0.0.0",
-                                                               0,
-                                                               PlatformConfig.QualityOfService.LO_QOS);
-
-        OCPlatform.configure(cfg);
-        FoundResource foundResource = new FoundResource();
-        OCPlatform.findResource("", "coap://224.0.1.187/oc/core?rt=core.light", foundResource);
-
-        setContentView(R.layout.activity_simple_client);
-    }
-
-
-    @Override
-    public boolean onCreateOptionsMenu(Menu menu) {
-        // Inflate the menu; this adds items to the action bar if it is present.
-        getMenuInflater().inflate(R.menu.simple_client, menu);
-        return true;
-    }
-
-    @Override
-    public boolean onOptionsItemSelected(MenuItem item) {
-        // Handle action bar item clicks here. The action bar will
-        // automatically handle clicks on the Home/Up button, so long
-        // as you specify a parent activity in AndroidManifest.xml.
-        int id = item.getItemId();
-        if (id == R.id.action_settings) {
-            return true;
-        }
-        return super.onOptionsItemSelected(item);
-    }
-
-    protected static void getLightRepresentation(OCResource resource) {
-        if(resource != null) {
-            Log.e(TAG, "Getting Light Representation ...");
-
-            OnGet onGet = new OnGet();
-            resource.get(onGet);
-        }
-    }
-
-    protected static void putLightRepresentation(OCResource resource) {
-        if(resource != null) {
-
-            OCRepresentation rep = new OCRepresentation();
-
-            Log.e(TAG, "Putting Light Representation ...");
-
-            mylight.m_state = true;
-            mylight.m_power = 15;
-
-            Log.i(TAG, "setValueBool : " + SimpleClient.mylight.m_state);
-            Log.i(TAG, "setValueInt  : " + SimpleClient.mylight.m_power);
-            rep.setValueBool("state", mylight.m_state);
-            rep.setValueInt("power", mylight.m_power);
-
-            OnPut onPut = new OnPut();
-            resource.put(rep, onPut);
-        }
-    }
-
-    protected static void postLightRepresentation(OCResource resource) {
-        if(resource != null) {
-
-            OCRepresentation rep = new OCRepresentation();
-
-            Log.e(TAG, "Posting Light Representation ...");
-
-            mylight.m_state = false;
-            mylight.m_power = 105;
-
-            Log.i(TAG, "setValueBool : " + SimpleClient.mylight.m_state);
-            Log.i(TAG, "setValueInt  : " + SimpleClient.mylight.m_power);
-            rep.setValueBool("state", mylight.m_state);
-            rep.setValueInt("power", mylight.m_power);
-
-            OnPost onPost = new OnPost();
-            resource.post(rep, onPost);
-        }
-    }
-
-    protected static int observe_count() {
-        return ++oc;
-    }
-
-}
diff --git a/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/SimpleToast.java b/android/SimpleClient/app/src/main/java/org/iotivity/simpleclient/SimpleToast.java
deleted file mode 100644 (file)
index 8f7d672..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 MediaTek 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-package org.iotivity.simpleclient;
-
-import android.os.AsyncTask;
-import android.widget.Toast;
-
-public class SimpleToast extends AsyncTask<String, String, String> {
-    String toastMessage;
-
-    @Override
-    protected String doInBackground(String... params) {
-        toastMessage = params[0];
-        return toastMessage;
-    }
-
-    protected void OnProgressUpdate(String... values) {
-        super.onProgressUpdate(values);
-    }
-   // This is executed in the context of the main GUI thread
-    protected void onPostExecute(String result){
-           Toast toast = Toast.makeText(SimpleClient.mActivity, result, Toast.LENGTH_SHORT);
-           toast.show();
-    }
-
-}
diff --git a/android/SimpleClient/app/src/main/res/layout/activity_simple_client.xml b/android/SimpleClient/app/src/main/res/layout/activity_simple_client.xml
deleted file mode 100644 (file)
index f347f6c..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:paddingLeft="@dimen/activity_horizontal_margin"
-    android:paddingRight="@dimen/activity_horizontal_margin"
-    android:paddingTop="@dimen/activity_vertical_margin"
-    android:paddingBottom="@dimen/activity_vertical_margin"
-    tools:context=".SimpleClient">
-
-    <TextView
-        android:text="@string/hello_world"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content" />
-
-</RelativeLayout>
diff --git a/android/SimpleClient/app/src/main/res/menu/simple_client.xml b/android/SimpleClient/app/src/main/res/menu/simple_client.xml
deleted file mode 100644 (file)
index 1a65997..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<menu xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    tools:context=".SimpleClient" >
-    <item android:id="@+id/action_settings"
-        android:title="@string/action_settings"
-        android:orderInCategory="100"
-        android:showAsAction="never" />
-</menu>
diff --git a/android/SimpleClient/build.gradle b/android/SimpleClient/build.gradle
deleted file mode 100644 (file)
index 9b8abe4..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
-
-buildscript {
-    repositories {
-        jcenter()
-    }
-    dependencies {
-        classpath 'com.android.tools.build:gradle:0.12.2'
-
-        // NOTE: Do not place your application dependencies here; they belong
-        // in the individual module build.gradle files
-    }
-}
-
-allprojects {
-    repositories {
-        jcenter()
-    }
-}
diff --git a/android/SimpleClient/gradle.properties b/android/SimpleClient/gradle.properties
deleted file mode 100644 (file)
index 5d08ba7..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-# Project-wide Gradle settings.
-
-# IDE (e.g. Android Studio) users:
-# Settings specified in this file will override any Gradle settings
-# configured through the IDE.
-
-# For more details on how to configure your build environment visit
-# http://www.gradle.org/docs/current/userguide/build_environment.html
-
-# Specifies the JVM arguments used for the daemon process.
-# The setting is particularly useful for tweaking memory settings.
-# Default value: -Xmx10248m -XX:MaxPermSize=256m
-# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
-
-# When configured, Gradle will run in incubating parallel mode.
-# This option should only be used with decoupled projects. More details, visit
-# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
\ No newline at end of file
diff --git a/android/SimpleClient/settings.gradle b/android/SimpleClient/settings.gradle
deleted file mode 100644 (file)
index e7b4def..0000000
+++ /dev/null
@@ -1 +0,0 @@
-include ':app'
diff --git a/android/android_api/.gitignore b/android/android_api/.gitignore
new file mode 100755 (executable)
index 0000000..e86e67c
--- /dev/null
@@ -0,0 +1,10 @@
+.gradle\r
+/local.properties\r
+/.idea/workspace.xml\r
+/.idea/libraries\r
+.DS_Store\r
+/build/*\r
+/base/build/*\r
+/base/obj/*\r
+/base/libs/*\r
+/sample/*\r
diff --git a/android/android_api/SConscript b/android/android_api/SConscript
new file mode 100755 (executable)
index 0000000..2575c97
--- /dev/null
@@ -0,0 +1,48 @@
+import os\r
+import platform\r
+Import('env')\r
+\r
+android_home = env.get('ANDROID_HOME')\r
+\r
+ANDROID_TARGET_ARCH = env.get('TARGET_ARCH')\r
+if env.get('RELEASE'):\r
+       ANDROID_RELEASE="release"\r
+else:\r
+       ANDROID_RELEASE="debug"\r
+\r
+os.environ['ANDROID_HOME'] = env.get('ANDROID_HOME')\r
+os.environ['ANDROID_NDK_HOME'] = env.get('ANDROID_NDK')\r
+\r
+if not os.path.exists(android_home + '/platforms/android-21') or not os.path.exists(android_home + '/build-tools/20.0.0'):\r
+    print '''\r
+***************************************** Info ********************************\r
+*   Either 'Android API 21' is not installed or 'Android SDK Build Tools      *\r
+*   20.0.0' is not installed. The Android SDK Manager will now open. Please   *\r
+*   be sure to deselect all options, then select the following 2 packages:    *\r
+*       1. Under "Tools" select "Android SDK Build-tools" Revision 20.        *\r
+*       2. Under "Android 5.0.1 (API 21)" select "SDK Platform"               *\r
+*       3. Continue by selecting "Install 2 Packages"                         *\r
+*                                                                             *\r
+*   NOTE: If you have an http proxy, please press ctrl+c now and edit/create  *\r
+*         the following file in your $HOME directory as follows:              *\r
+*                                                                             *\r
+* Edit/Create file: "$HOME/.android/androidtool.cfg"                          *\r
+*                                                                             *\r
+*    http.proxyPort=<YOUR_PORT_NUMBER>                                        *\r
+*    sdkman.monitor.density=108                                               *\r
+*    http.proxyHost=<YOUR_HTTP_PROXY_ADDRESS>                                 *\r
+*    sdkman.show.update.only=true                                             *\r
+*    sdkman.ask.adb.restart=false                                             *\r
+*    sdkman.force.http=true                                                   *\r
+*    sdkman.show.updateonly=true                                              *\r
+*                                                                             *\r
+*******************************************************************************\r
+\r
+...Opening Android SDK Manager now. Once you are finished, the build will continue.\r
+'''\r
+    os.system(android_home + '/tools/android')\r
+\r
+jdk_env = Environment(ENV=os.environ)\r
+jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b' + os.getcwd()+'/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE))\r
+jdk_env.Gradle(target="base/objs", source="base/src/main/java/org/iotivity/base/OcResource.java")\r
+\r
diff --git a/android/android_api/android_api.iml b/android/android_api/android_api.iml
new file mode 100755 (executable)
index 0000000..8d49284
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">\r
+  <component name="FacetManager">\r
+    <facet type="java-gradle" name="Java-Gradle">\r
+      <configuration>\r
+        <option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />\r
+      </configuration>\r
+    </facet>\r
+  </component>\r
+  <component name="NewModuleRootManager" inherit-compiler-output="true">\r
+    <exclude-output />\r
+    <content url="file://$MODULE_DIR$">\r
+      <excludeFolder url="file://$MODULE_DIR$/.gradle" />\r
+    </content>\r
+    <orderEntry type="inheritedJdk" />\r
+    <orderEntry type="sourceFolder" forTests="false" />\r
+  </component>\r
+</module>\r
+\r
diff --git a/android/android_api/base/.gitignore b/android/android_api/base/.gitignore
new file mode 100755 (executable)
index 0000000..6e8872c
--- /dev/null
@@ -0,0 +1,5 @@
+.gradle/\r
+.idea/\r
+sample/\r
+base/build/\r
+base/obj/\r
diff --git a/android/android_api/base/base.iml b/android/android_api/base/base.iml
new file mode 100755 (executable)
index 0000000..36cf651
--- /dev/null
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="android_api" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">\r
+  <component name="FacetManager">\r
+    <facet type="android-gradle" name="Android-Gradle">\r
+      <configuration>\r
+        <option name="GRADLE_PROJECT_PATH" value=":base" />\r
+      </configuration>\r
+    </facet>\r
+    <facet type="android" name="Android">\r
+      <configuration>\r
+        <option name="SELECTED_BUILD_VARIANT" value="debug" />\r
+        <option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />\r
+        <option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />\r
+        <option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />\r
+        <option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />\r
+        <option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />\r
+        <option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugTestSources" />\r
+        <option name="ALLOW_USER_CONFIGURATION" value="false" />\r
+        <option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />\r
+        <option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />\r
+        <option name="RES_FOLDERS_RELATIVE_PATH" value="" />\r
+        <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />\r
+        <option name="LIBRARY_PROJECT" value="true" />\r
+      </configuration>\r
+    </facet>\r
+  </component>\r
+  <component name="NewModuleRootManager" inherit-compiler-output="false">\r
+    <output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />\r
+    <output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />\r
+    <exclude-output />\r
+    <content url="file://$MODULE_DIR$">\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/debug" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/test/debug" isTestSource="true" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/test/debug" isTestSource="true" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/test/debug" isTestSource="true" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/test/debug" isTestSource="true" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/test/debug" type="java-test-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/test/debug" type="java-test-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/native-libs" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/outputs" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/tmp" />\r
+    </content>\r
+    <orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />\r
+    <orderEntry type="sourceFolder" forTests="false" />\r
+  </component>\r
+</module>\r
+\r
diff --git a/android/android_api/base/build.gradle b/android/android_api/base/build.gradle
new file mode 100755 (executable)
index 0000000..9cbdaf8
--- /dev/null
@@ -0,0 +1,115 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+apply plugin: 'com.android.library'\r
+\r
+android {\r
+    compileSdkVersion 21\r
+    buildToolsVersion "20.0.0"\r
+    archivesBaseName = "iotivity"\r
+\r
+    libraryVariants.all { variant ->\r
+        variant.outputs.each { output ->\r
+            def outputFile = output.outputFile\r
+            if (outputFile != null && outputFile.name.endsWith('.aar')) {\r
+                def fileName = "${archivesBaseName}-${TARGET_ARCH}-${outputFile.name}"\r
+                output.outputFile = new File(outputFile.parent, fileName)\r
+            }\r
+        }\r
+    }\r
+\r
+    defaultConfig {\r
+        minSdkVersion 21\r
+        targetSdkVersion 21\r
+        versionCode 1\r
+        versionName "0.9"\r
+    }\r
+    buildTypes {\r
+        release {\r
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\r
+        }\r
+    }\r
+\r
+    lintOptions {\r
+       abortOnError false\r
+    }\r
+\r
+    sourceSets {\r
+        main {\r
+            manifest.srcFile 'src/main/AndroidManifest.xml'\r
+            jniLibs.srcDir 'libs'\r
+            jni.srcDirs = [] //disable automatic ndk-build call\r
+        }\r
+    }\r
+}\r
+\r
+\r
+dependencies {\r
+    compile fileTree(dir: 'libs', include: ['*.jar'])\r
+}\r
+\r
+////////////////\r
+////NDK Support\r
+////////////////\r
+//If using this, Android studio will fail run the following to set the environment variable for android studio:\r
+//launchctl setenv ANDROID_NDK_HOME /Users/boos_patrick/Development/Android/android-ndk-r8e\r
+//otherwise remove the dependsOn part and run ./gradlew buildNative from the command line\r
+\r
+task copyNativeLibs(type: Copy, dependsOn: 'buildNative') {\r
+    dependsOn 'buildNative'\r
+    from(new File('libs')) { include '**/*.so' }\r
+    into new File(buildDir, 'native-libs')\r
+}\r
+\r
+tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn copyNativeLibs }\r
+\r
+clean.dependsOn 'cleanCopyNativeLibs'\r
+\r
+tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->\r
+    pkgTask.jniFolders = new HashSet<File>()\r
+    pkgTask.jniFolders.add(new File(buildDir, 'native-libs'))\r
+}\r
+\r
+task buildNative(type: Exec) {\r
+    if (System.env.ANDROID_NDK_HOME != null) {\r
+        //for windows use 'ndk-build.cmd'\r
+        //def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build.cmd')\r
+        def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build')\r
+        commandLine ndkBuild, "APP_ABI=$TARGET_ARCH", "APP_OPTIM=$RELEASE"\r
+    } else {\r
+        println '##################'\r
+        println 'Skipping NDK build'\r
+        println 'Reason: ANDROID_NDK_HOME not set.'\r
+        println '##################'\r
+    }\r
+}\r
+//\r
+//task (copyARR, type: Copy) {\r
+//    copy {\r
+//        from 'build/outputs/aar/'\r
+//        into '../../../out/android/'\r
+//        include '**/*.aar'\r
+//    }\r
+//}\r
+//build.finalizedBy(copyARR)\r
+\r
+\r
diff --git a/android/android_api/base/jni/Android.mk b/android/android_api/base/jni/Android.mk
new file mode 100755 (executable)
index 0000000..aa2cbae
--- /dev/null
@@ -0,0 +1,78 @@
+LOCAL_PATH := $(call my-dir)\r
+TARGET_ARCH_ABI := $(APP_ABI)\r
+\r
+include $(CLEAR_VARS)\r
+OIC_LIB_PATH := ../../../../out/android/$(APP_ABI)/$(APP_OPTIM)\r
+LOCAL_MODULE := libandroid-oc_logger\r
+LOCAL_SRC_FILES := $(OIC_LIB_PATH)/liboc_logger.so\r
+include $(PREBUILT_SHARED_LIBRARY)\r
+\r
+include $(CLEAR_VARS)\r
+OIC_LIB_PATH := ../../../../out/android/$(APP_ABI)/$(APP_OPTIM)\r
+LOCAL_MODULE := libandroid-octbstack\r
+LOCAL_SRC_FILES := $(OIC_LIB_PATH)/liboctbstack.so\r
+include $(PREBUILT_SHARED_LIBRARY)\r
+\r
+include $(CLEAR_VARS)\r
+OIC_LIB_PATH := ../../../../out/android/$(APP_ABI)/$(APP_OPTIM)\r
+LOCAL_MODULE := libandroid-oc\r
+LOCAL_SRC_FILES := $(OIC_LIB_PATH)/liboc.so\r
+include $(PREBUILT_SHARED_LIBRARY)\r
+\r
+include $(CLEAR_VARS)\r
+OIC_LIB_PATH := ../../../../out/android/$(APP_ABI)/$(APP_OPTIM)\r
+LOCAL_MODULE := libandroid-ca\r
+LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libconnectivity_abstraction.so\r
+include $(PREBUILT_SHARED_LIBRARY)\r
+\r
+include $(CLEAR_VARS)\r
+OIC_SRC_PATH := ../../../resource\r
+LOCAL_MODULE := libca-interface\r
+LOCAL_SRC_FILES := JniCaInterface.c\r
+LOCAL_STATIC_LIBRARIES := libandroid-ca\r
+LOCAL_LDLIBS := -llog\r
+LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/connectivity/api\r
+include $(BUILD_SHARED_LIBRARY)\r
+\r
+include $(CLEAR_VARS)\r
+OIC_SRC_PATH := ../../../resource\r
+OIC_OUT_PATH := ../../../out\r
+LOCAL_MODULE    := ocstack-jni\r
+LOCAL_SRC_FILES :=  JniOcStack.cpp \\r
+                    JniUtils.cpp \\r
+                    JniEntityHandler.cpp \\r
+                    JniOnResourceFoundListener.cpp \\r
+                    JniOnDeviceInfoListener.cpp \\r
+                    JniOnPresenceListener.cpp \\r
+                    JniOnGetListener.cpp \\r
+                    JniOnPutListener.cpp \\r
+                    JniOnPostListener.cpp \\r
+                    JniOnDeleteListener.cpp \\r
+                    JniOnObserveListener.cpp \\r
+                    JniOcRepresentation.cpp \\r
+                    JniOcResourceHandle.cpp \\r
+                    JniOcPresenceHandle.cpp \\r
+                    JniOcRequestHandle.cpp \\r
+                    JniOcResourceRequest.cpp \\r
+                    JniOcResourceResponse.cpp \\r
+                    JniOcPlatform.cpp \\r
+                    JniOcResource.cpp \\r
+                    JniOcResourceIdentifier.cpp\r
+\r
+LOCAL_LDLIBS := -llog\r
+LOCAL_STATIC_LIBRARIES := android-oc\r
+LOCAL_STATIC_LIBRARIES += android-octbstack\r
+LOCAL_STATIC_LIBRARIES += android-coap\r
+LOCAL_STATIC_LIBRARIES += android-oc_logger\r
+LOCAL_STATIC_LIBRARIES += android-ca\r
+LOCAL_STATIC_LIBRARIES += android_cpp11_compat\r
+\r
+LOCAL_CPPFLAGS += -std=c++0x\r
+LOCAL_CPP_FEATURES := rtti exceptions\r
+LOCAL_C_INCLUDES := $(OIC_SRC_PATH)/include\r
+LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/stack/include\r
+LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/ocsocket/include\r
+LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/oc_logger/include\r
+LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/../extlibs/boost/boost_1_58_0\r
+LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/../build_common/android/compatibility\r
+include $(BUILD_SHARED_LIBRARY)\r
diff --git a/android/android_api/base/jni/Application.mk b/android/android_api/base/jni/Application.mk
new file mode 100755 (executable)
index 0000000..089c9b3
--- /dev/null
@@ -0,0 +1,2 @@
+NDK_TOOLCHAIN_VERSION := 4.9\r
+APP_STL               := gnustl_shared
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniCaInterface.c b/android/android_api/base/jni/JniCaInterface.c
new file mode 100644 (file)
index 0000000..eb1e07a
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+* //******************************************************************
+* //
+* // Copyright 2015 Intel Corporation.
+* //
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+* //
+* // 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 <android/log.h>
+#include <stdio.h>
+#include "cainterface.h"
+#include "JniCaInterface.h"
+
+#define  LOG_TAG   "JNI_CA_INTERFACE"
+#define  LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
+#define  LOGE(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
+
+JNIEXPORT jint JNI_OnLoad(JavaVM *jvm, void *reserved)
+{
+    LOGI("CaInterface_initialize");
+    CANativeJNISetJavaVM(jvm);
+
+    return JNI_VERSION_1_6;
+}
+
+void JNI_OnUnload(JavaVM *jvm, void *reserved)
+{
+    return;
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_ca_CaInterface_initialize
+(JNIEnv *env, jclass clazz, jobject context)
+{
+    LOGI("CaInterface_initialize");
+
+    CANativeJNISetContext(env, context);
+
+    CAResult_t res = CAInitialize();
+
+    if (CA_STATUS_OK != res)
+    {
+        LOGE("Could not Initialize");
+    }
+}
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniCaInterface.h b/android/android_api/base/jni/JniCaInterface.h
new file mode 100644 (file)
index 0000000..ee77a97
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+* //******************************************************************
+* //
+* // Copyright 2015 Intel Corporation.
+* //
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+* //
+* // 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>
+// THIS FILE IS SUBJECT TO CHANGE DUE TO THE ONGOING DEVELOPMENT OF THE CA FOR ANDROID
+// DO NOT REVIEW THIS FILE
+
+/* Header for class org_iotivity_ca_CaInterface */
+
+#ifndef _Included_org_iotivity_ca_CaInterface
+#define _Included_org_iotivity_ca_CaInterface
+#ifdef __cplusplus
+extern "C" {
+#endif
+    /*
+     * Class:     org_iotivity_ca_CaInterface_Initialize
+     * Method:    Initialize
+     * Signature: (Landroid/content/Context;)V
+     */
+    JNIEXPORT void JNICALL Java_org_iotivity_ca_CaInterface_initialize
+        (JNIEnv *, jclass, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniEntityHandler.cpp b/android/android_api/base/jni/JniEntityHandler.cpp
new file mode 100644 (file)
index 0000000..860d52b
--- /dev/null
@@ -0,0 +1,111 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniEntityHandler.h"\r
+#include "JniOcResourceRequest.h"\r
+#include "JniOcResourceResponse.h"\r
+#include "JniUtils.h"\r
+\r
+JniEntityHandler::JniEntityHandler(JNIEnv *env, jobject entityHandler)\r
+{\r
+    m_jListener = env->NewGlobalRef(entityHandler);\r
+}\r
+\r
+JniEntityHandler::~JniEntityHandler()\r
+{\r
+    LOGD("~JniEntityHandler");\r
+    if (m_jListener)\r
+    {\r
+        jint ret;\r
+        JNIEnv *env = GetJNIEnv(ret);\r
+        if (NULL == env) return;\r
+        env->DeleteGlobalRef(m_jListener);\r
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
+    }\r
+}\r
+\r
+OCEntityHandlerResult JniEntityHandler::handleEntity(const std::shared_ptr<OCResourceRequest> request)\r
+{\r
+    LOGD("JniEntityHandler_handleEntity");\r
+    jint envRet;\r
+    JNIEnv *env = GetJNIEnv(envRet);\r
+    if (NULL == env) return OC_EH_ERROR;\r
+\r
+    JniOcResourceRequest* jniResReq = new JniOcResourceRequest(request);\r
+    jlong reqHandle = reinterpret_cast<jlong>(jniResReq);\r
+    jobject jResourceRequest = env->NewObject(g_cls_OcResourceRequest, g_mid_OcResourceRequest_N_ctor,\r
+        reqHandle);\r
+    if (!jResourceRequest)\r
+    {\r
+        LOGE("Failed to create OcResourceRequest");\r
+        delete jniResReq;\r
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+        return OC_EH_ERROR;\r
+    }\r
+\r
+    jclass clsL = env->GetObjectClass(m_jListener);\r
+    if (!clsL)\r
+    {\r
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+        return OC_EH_ERROR;\r
+    }\r
+    jmethodID midL = env->GetMethodID(clsL, "handleEntity",\r
+        "(Lorg/iotivity/base/OcResourceRequest;)Lorg/iotivity/base/EntityHandlerResult;");\r
+    if (!midL)\r
+    {\r
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+        return OC_EH_ERROR;\r
+    }\r
+    jobject entityHandlerResult = env->CallObjectMethod(m_jListener, midL, jResourceRequest);\r
+    if (env->ExceptionCheck())\r
+    {\r
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+        return OC_EH_ERROR;\r
+    }\r
+    if (!entityHandlerResult)\r
+    {\r
+        ThrowOcException(JNI_INVALID_VALUE, "EntityHandlerResult cannot be null");\r
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+        return OC_EH_ERROR;\r
+    }\r
+    jclass clsResult = env->GetObjectClass(entityHandlerResult);\r
+    if (!clsResult)\r
+    {\r
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+        return OC_EH_ERROR;\r
+    }\r
+    jmethodID getValue_ID = env->GetMethodID(clsResult, "getValue", "()I");\r
+    if (!getValue_ID)\r
+    {\r
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+        return OC_EH_ERROR;\r
+    }\r
+    jint jResult = env->CallIntMethod(entityHandlerResult, getValue_ID);\r
+    if (env->ExceptionCheck())\r
+    {\r
+        LOGE("Java exception is thrown");\r
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+        return OC_EH_ERROR;\r
+    }\r
+\r
+    if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+    return JniUtils::getOCEntityHandlerResult(env, static_cast<int>(jResult));\r
+}
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniEntityHandler.h b/android/android_api/base/jni/JniEntityHandler.h
new file mode 100644 (file)
index 0000000..8cf3373
--- /dev/null
@@ -0,0 +1,39 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniOcStack.h"\r
+\r
+#ifndef _Included_org_iotivity_base_JniEntityHandler\r
+#define _Included_org_iotivity_base_JniEntityHandler\r
+\r
+class JniEntityHandler\r
+{\r
+public:\r
+    JniEntityHandler(JNIEnv *env, jobject listener);\r
+    ~JniEntityHandler();\r
+\r
+    OCEntityHandlerResult handleEntity(const std::shared_ptr<OC::OCResourceRequest> request);\r
+\r
+private:\r
+    jobject m_jListener;\r
+};\r
+\r
+#endif
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniListenerManager.cpp b/android/android_api/base/jni/JniListenerManager.cpp
new file mode 100644 (file)
index 0000000..c9ccaa3
--- /dev/null
@@ -0,0 +1,103 @@
+///*\r
+//* //******************************************************************\r
+//* //\r
+//* // Copyright 2015 Intel Corporation.\r
+//* //\r
+//* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+//* //\r
+//* // Licensed under the Apache License, Version 2.0 (the "License");\r
+//* // you may not use this file except in compliance with the License.\r
+//* // You may obtain a copy of the License at\r
+//* //\r
+//* //      http://www.apache.org/licenses/LICENSE-2.0\r
+//* //\r
+//* // Unless required by applicable law or agreed to in writing, software\r
+//* // distributed under the License is distributed on an "AS IS" BASIS,\r
+//* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+//* // See the License for the specific language governing permissions and\r
+//* // limitations under the License.\r
+//* //\r
+//* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+//*/\r
+//\r
+//#include "JniListenerManager.h"\r
+//\r
+//#include "JniOnGetListener.h"\r
+//\r
+//template<class T>\r
+//T* JniListenerManager<T>::addListener(JNIEnv* env, jobject jListener)\r
+//{\r
+//     T *onEventListener = NULL;\r
+//\r
+//     m_mapMutex.lock();\r
+//\r
+//     for (auto it = m_listenerMap.begin(); it != m_listenerMap.end(); ++it)\r
+//     {\r
+//             if (env->IsSameObject(jListener, it->first))\r
+//             {\r
+//                     auto refPair = it->second;\r
+//                     onEventListener = refPair.first;\r
+//                     refPair.second++;\r
+//                     it->second = refPair;\r
+//                     m_listenerMap.insert(*it);\r
+//                     LOGD("OnEventListener: ref. count is incremented");\r
+//                     break;\r
+//             }\r
+//     }\r
+//\r
+//     if (!onEventListener)\r
+//     {\r
+//             onEventListener = new T(env, jListener, this);\r
+//             jobject jgListener = env->NewGlobalRef(jListener);\r
+//\r
+//             m_listenerMap.insert(std::pair<jobject, std::pair<T*, int>>(jgListener, std::pair<T*, int>(onEventListener, 1)));\r
+//             LOGD("OnEventListener: new listener");\r
+//     }\r
+//\r
+//     m_mapMutex.unlock();\r
+//\r
+//     return onEventListener;\r
+//}\r
+//\r
+//template<class T>\r
+//void JniListenerManager<T>::removeListener(JNIEnv* env, jobject jListener)\r
+//{\r
+//     m_mapMutex.lock();\r
+//\r
+//     bool isFound = false;\r
+//\r
+//     for (auto it = m_listenerMap.begin(); it != m_listenerMap.end(); ++it)\r
+//     {\r
+//             if (env->IsSameObject(jListener, it->first))\r
+//             {\r
+//                     auto refPair = it->second;\r
+//                     if (refPair.second > 1)\r
+//                     {\r
+//                             refPair.second--;\r
+//                             it->second = refPair;\r
+//                             m_listenerMap.insert(*it);\r
+//                             LOGI("OnEventListener: ref. count is decremented");\r
+//                     }\r
+//                     else\r
+//                     {\r
+//                             env->DeleteGlobalRef(it->first);\r
+//                             T* listener = refPair.first;\r
+//                             delete listener;\r
+//                             m_listenerMap.erase(it);\r
+//\r
+//                             LOGI("OnEventListener is removed");\r
+//                     }\r
+//\r
+//                     isFound = true;\r
+//                     break;\r
+//             }\r
+//     }\r
+//\r
+//     if (!isFound)\r
+//     {\r
+//             ThrowOcException(JNI_EXCEPTION, "OnEventListener isn't found");\r
+//     }\r
+//\r
+//     m_mapMutex.unlock();\r
+//}\r
+//\r
diff --git a/android/android_api/base/jni/JniListenerManager.h b/android/android_api/base/jni/JniListenerManager.h
new file mode 100644 (file)
index 0000000..a43ea82
--- /dev/null
@@ -0,0 +1,125 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+\r
+#include "JniOcStack.h"\r
+#include <mutex>\r
+\r
+#ifndef _JniListenerManager\r
+#define _JniListenerManager\r
+\r
+class JniOcResource;\r
+\r
+template <class T>\r
+class JniListenerManager\r
+{\r
+public:\r
+    T* addListener(JNIEnv* env, jobject jListener, JniOcResource* owner)\r
+    {\r
+        T *onEventListener = NULL;\r
+\r
+        m_mapMutex.lock();\r
+\r
+        for (auto it = m_listenerMap.begin(); it != m_listenerMap.end(); ++it)\r
+        {\r
+            if (env->IsSameObject(jListener, it->first))\r
+            {\r
+                auto refPair = it->second;\r
+                onEventListener = refPair.first;\r
+                refPair.second++;\r
+                it->second = refPair;\r
+                m_listenerMap.insert(*it);\r
+                LOGD("OnEventListener: ref. count is incremented");\r
+                break;\r
+            }\r
+        }\r
+        if (!onEventListener)\r
+        {\r
+            onEventListener = new T(env, jListener, owner);\r
+            jobject jgListener = env->NewGlobalRef(jListener);\r
+\r
+            if (jgListener)\r
+            {\r
+                m_listenerMap.insert(std::pair<jobject, std::pair<T*, int>>(jgListener, std::pair<T*, int>(onEventListener, 1)));\r
+            }\r
+            else\r
+            {\r
+                LOGD("OnEventListener: Failed to create global listener ref.");\r
+                delete onEventListener;\r
+            }\r
+            LOGD("OnEventListener: new listener");\r
+        }\r
+        m_mapMutex.unlock();\r
+        return onEventListener;\r
+    }\r
+\r
+    void removeListener(JNIEnv* env, jobject jListener)\r
+    {\r
+        m_mapMutex.lock();\r
+        for (auto it = m_listenerMap.begin(); it != m_listenerMap.end(); ++it)\r
+        {\r
+            if (env->IsSameObject(jListener, it->first))\r
+            {\r
+                auto refPair = it->second;\r
+                if (refPair.second > 1)\r
+                {\r
+                    refPair.second--;\r
+                    it->second = refPair;\r
+                    m_listenerMap.insert(*it);\r
+                    LOGI("OnEventListener: ref. count is decremented");\r
+                }\r
+                else\r
+                {\r
+                    env->DeleteGlobalRef(it->first);\r
+                    T* listener = refPair.first;\r
+                    delete listener;\r
+                    m_listenerMap.erase(it);\r
+\r
+                    LOGI("OnEventListener is removed");\r
+                }\r
+                break;\r
+            }\r
+        }\r
+        m_mapMutex.unlock();\r
+    }\r
+\r
+    void removeAllListeners(JNIEnv* env)\r
+    {\r
+        m_mapMutex.lock();\r
+\r
+        for (auto it = m_listenerMap.begin(); it != m_listenerMap.end(); ++it)\r
+        {\r
+            env->DeleteGlobalRef(it->first);\r
+            auto refPair = it->second;\r
+            T* listener = refPair.first;\r
+            delete listener;\r
+            m_listenerMap.erase(it);\r
+        }\r
+\r
+        m_mapMutex.unlock();\r
+    }\r
+\r
+private:\r
+    std::map<jobject, std::pair<T*, int>> m_listenerMap;\r
+    std::mutex m_mapMutex;\r
+};\r
+\r
+#endif\r
diff --git a/android/android_api/base/jni/JniOcPlatform.cpp b/android/android_api/base/jni/JniOcPlatform.cpp
new file mode 100644 (file)
index 0000000..0a50d8e
--- /dev/null
@@ -0,0 +1,1591 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniOcPlatform.h"\r
+#include "OCPlatform.h"\r
+#include "JniOcResource.h"\r
+#include "JniOcResourceHandle.h"\r
+#include "JniOcPresenceHandle.h"\r
+#include "JniOcResourceResponse.h"\r
+#include "JniUtils.h"\r
+\r
+using namespace OC;\r
+\r
+JniOnResourceFoundListener* AddOnResourceFoundListener(JNIEnv* env, jobject jListener)\r
+{\r
+    JniOnResourceFoundListener *onResourceFoundListener = NULL;\r
+\r
+    resourceFoundMapLock.lock();\r
+\r
+    for (auto it = onResourceFoundListenerMap.begin(); it != onResourceFoundListenerMap.end(); ++it)\r
+    {\r
+        if (env->IsSameObject(jListener, it->first))\r
+        {\r
+            auto refPair = it->second;\r
+            onResourceFoundListener = refPair.first;\r
+            refPair.second++;\r
+            it->second = refPair;\r
+            onResourceFoundListenerMap.insert(*it);\r
+            LOGD("OnResourceFoundListener: ref. count incremented");\r
+            break;\r
+        }\r
+    }\r
+\r
+    if (!onResourceFoundListener)\r
+    {\r
+        onResourceFoundListener = new JniOnResourceFoundListener(env, jListener, RemoveOnResourceFoundListener);\r
+        jobject jgListener = env->NewGlobalRef(jListener);\r
+\r
+        onResourceFoundListenerMap.insert(std::pair < jobject, std::pair < JniOnResourceFoundListener*,\r
+            int >> (jgListener, std::pair<JniOnResourceFoundListener*, int>(onResourceFoundListener, 1)));\r
+        LOGD("OnResourceFoundListener: new listener");\r
+    }\r
+    resourceFoundMapLock.unlock();\r
+    return onResourceFoundListener;\r
+}\r
+\r
+void RemoveOnResourceFoundListener(JNIEnv* env, jobject jListener)\r
+{\r
+    resourceFoundMapLock.lock();\r
+\r
+    for (auto it = onResourceFoundListenerMap.begin(); it != onResourceFoundListenerMap.end(); ++it)\r
+    {\r
+        if (env->IsSameObject(jListener, it->first))\r
+        {\r
+            auto refPair = it->second;\r
+            if (refPair.second > 1)\r
+            {\r
+                refPair.second--;\r
+                it->second = refPair;\r
+                onResourceFoundListenerMap.insert(*it);\r
+                LOGI("OnResourceFoundListener: ref. count decremented");\r
+            }\r
+            else\r
+            {\r
+                env->DeleteGlobalRef(it->first);\r
+                JniOnResourceFoundListener* listener = refPair.first;\r
+                delete listener;\r
+                onResourceFoundListenerMap.erase(it);\r
+                LOGI("OnResourceFoundListener removed");\r
+            }\r
+            break;\r
+        }\r
+    }\r
+    resourceFoundMapLock.unlock();\r
+}\r
+\r
+JniOnDeviceInfoListener* AddOnDeviceInfoListener(JNIEnv* env, jobject jListener)\r
+{\r
+    JniOnDeviceInfoListener *onDeviceInfoListener = NULL;\r
+\r
+    deviceInfoMapLock.lock();\r
+\r
+    for (auto it = onDeviceInfoListenerMap.begin(); it != onDeviceInfoListenerMap.end(); ++it)\r
+    {\r
+        if (env->IsSameObject(jListener, it->first))\r
+        {\r
+            auto refPair = it->second;\r
+            onDeviceInfoListener = refPair.first;\r
+            refPair.second++;\r
+            it->second = refPair;\r
+            onDeviceInfoListenerMap.insert(*it);\r
+            LOGD("OnDeviceInfoListener: ref. count incremented");\r
+            break;\r
+        }\r
+    }\r
+\r
+    if (!onDeviceInfoListener)\r
+    {\r
+        onDeviceInfoListener = new JniOnDeviceInfoListener(env, jListener, RemoveOnDeviceInfoListener);\r
+        jobject jgListener = env->NewGlobalRef(jListener);\r
+\r
+        onDeviceInfoListenerMap.insert(std::pair < jobject, std::pair < JniOnDeviceInfoListener*,\r
+            int >> (jgListener, std::pair<JniOnDeviceInfoListener*, int>(onDeviceInfoListener, 1)));\r
+        LOGI("OnDeviceInfoListener: new listener");\r
+    }\r
+\r
+    deviceInfoMapLock.unlock();\r
+    return onDeviceInfoListener;\r
+}\r
+\r
+void RemoveOnDeviceInfoListener(JNIEnv* env, jobject jListener)\r
+{\r
+    deviceInfoMapLock.lock();\r
+    bool isFound = false;\r
+    for (auto it = onDeviceInfoListenerMap.begin(); it != onDeviceInfoListenerMap.end(); ++it)\r
+    {\r
+        if (env->IsSameObject(jListener, it->first))\r
+        {\r
+            auto refPair = it->second;\r
+            if (refPair.second > 1)\r
+            {\r
+                refPair.second--;\r
+                it->second = refPair;\r
+                onDeviceInfoListenerMap.insert(*it);\r
+                LOGI("OnDeviceInfoListener: ref. count decremented");\r
+            }\r
+            else\r
+            {\r
+                env->DeleteGlobalRef(it->first);\r
+                JniOnDeviceInfoListener* listener = refPair.first;\r
+                delete listener;\r
+                onDeviceInfoListenerMap.erase(it);\r
+\r
+                LOGI("OnDeviceInfoListener removed");\r
+            }\r
+\r
+            isFound = true;\r
+            break;\r
+        }\r
+    }\r
+\r
+    if (!isFound)\r
+    {\r
+        ThrowOcException(JNI_EXCEPTION, "OnDeviceInfoListenet not found");\r
+    }\r
+    deviceInfoMapLock.unlock();\r
+}\r
+\r
+JniOnPresenceListener* AddOnPresenceListener(JNIEnv* env, jobject jListener)\r
+{\r
+    JniOnPresenceListener *onPresenceListener = NULL;\r
+\r
+    presenceMapLock.lock();\r
+\r
+    for (auto it = onPresenceListenerMap.begin(); it != onPresenceListenerMap.end(); ++it)\r
+    {\r
+        if (env->IsSameObject(jListener, it->first))\r
+        {\r
+            auto refPair = it->second;\r
+            onPresenceListener = refPair.first;\r
+            refPair.second++;\r
+            it->second = refPair;\r
+            onPresenceListenerMap.insert(*it);\r
+            LOGD("OnPresenceListener: ref. count incremented");\r
+            break;\r
+        }\r
+    }\r
+    if (!onPresenceListener)\r
+    {\r
+        onPresenceListener = new JniOnPresenceListener(env, jListener, RemoveOnPresenceListener);\r
+        jobject jgListener = env->NewGlobalRef(jListener);\r
+        onPresenceListenerMap.insert(std::pair < jobject, std::pair < JniOnPresenceListener*,\r
+            int >> (jgListener, std::pair<JniOnPresenceListener*, int>(onPresenceListener, 1)));\r
+        LOGI("OnPresenceListener: new listener");\r
+    }\r
+    presenceMapLock.unlock();\r
+    return onPresenceListener;\r
+}\r
+\r
+void RemoveOnPresenceListener(JNIEnv* env, jobject jListener)\r
+{\r
+    presenceMapLock.lock();\r
+    bool isFound = false;\r
+    for (auto it = onPresenceListenerMap.begin(); it != onPresenceListenerMap.end(); ++it)\r
+    {\r
+        if (env->IsSameObject(jListener, it->first))\r
+        {\r
+            auto refPair = it->second;\r
+            if (refPair.second > 1)\r
+            {\r
+                refPair.second--;\r
+                it->second = refPair;\r
+                onPresenceListenerMap.insert(*it);\r
+                LOGI("OnPresenceListener: ref. count decremented");\r
+            }\r
+            else\r
+            {\r
+                env->DeleteGlobalRef(it->first);\r
+                JniOnPresenceListener* listener = refPair.first;\r
+                delete listener;\r
+                onPresenceListenerMap.erase(it);\r
+                LOGI("OnPresenceListener is removed");\r
+            }\r
+            isFound = true;\r
+            break;\r
+        }\r
+    }\r
+    if (!isFound)\r
+    {\r
+        ThrowOcException(JNI_EXCEPTION, "OnPresenceListener not found");\r
+    }\r
+    presenceMapLock.unlock();\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcPlatform\r
+* Method:    configure\r
+* Signature: (IILjava/lang/String;II)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_configure\r
+(JNIEnv *env, jclass clazz, jint jServiceType, jint jModeType, jstring jIpAddress, jint jPort, jint jQOS)\r
+{\r
+    LOGI("OcPlatform_configure");\r
+\r
+    std::string ipAddress;\r
+    if (jIpAddress)\r
+    {\r
+        ipAddress = env->GetStringUTFChars(jIpAddress, NULL);\r
+    }\r
+    uint16_t port;\r
+    if (jPort > 0)\r
+    {\r
+        port = static_cast<uint16_t>(jPort);\r
+    }\r
+    PlatformConfig cfg{\r
+        JniUtils::getServiceType(env, jServiceType),\r
+        JniUtils::getModeType(env, jModeType),\r
+        ipAddress,\r
+        port,\r
+        JniUtils::getQOS(env, static_cast<int>(jQOS))\r
+    };\r
+\r
+    OCPlatform::Configure(cfg);\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcPlatform\r
+* Method:    notifyAllObservers0\r
+* Signature: (Lorg/iotivity/base/OcResourceHandle;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyAllObservers0\r
+(JNIEnv *env, jclass clazz, jobject jResourceHandle)\r
+{\r
+    LOGI("OcPlatform_notifyAllObservers");\r
+    if (!jResourceHandle)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null");\r
+        return;\r
+    }\r
+\r
+    JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(\r
+        env, jResourceHandle);\r
+    if (!jniOcResourceHandle) return;\r
+\r
+    try\r
+    {\r
+        OCStackResult result = OCPlatform::notifyAllObservers(jniOcResourceHandle->getOCResourceHandle());\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "Failed to notify all observers");\r
+            return;\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcPlatform\r
+* Method:    notifyAllObservers1\r
+* Signature: (Lorg/iotivity/base/OcResourceHandle;I)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyAllObservers1\r
+(JNIEnv *env, jclass clazz, jobject jResourceHandle, jint jQoS)\r
+{\r
+    LOGI("OcPlatform_notifyAllObservers1");\r
+\r
+    if (!jResourceHandle)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null");\r
+        return;\r
+    }\r
+\r
+    JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(\r
+        env, jResourceHandle);\r
+    if (!jniOcResourceHandle) return;\r
+\r
+    try{\r
+        OCStackResult result = OCPlatform::notifyAllObservers(\r
+            jniOcResourceHandle->getOCResourceHandle(),\r
+            JniUtils::getQOS(env, static_cast<int>(jQoS)));\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "Failed to notify all observers");\r
+            return;\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcPlatform\r
+* Method:    notifyListOfObservers2\r
+* Signature: (Lorg/iotivity/base/OcResourceHandle;[Ljava/lang/Byte;Lorg/iotivity/base/OcResourceResponse;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyListOfObservers2\r
+(JNIEnv *env, jclass clazz, jobject jResourceHandle, jbyteArray jObservationIdArr, jobject jResourceResponse)\r
+{\r
+    LOGD("OcPlatform_notifyListOfObservers2");\r
+    if (!jResourceHandle)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null");\r
+        return;\r
+    }\r
+    if (!jObservationIdArr)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "observationIdList cannot be null");\r
+        return;\r
+    }\r
+    if (!jResourceResponse)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceResponse cannot be null");\r
+        return;\r
+    }\r
+\r
+    JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(\r
+        env, jResourceHandle);\r
+    if (!jniOcResourceHandle) return;\r
+\r
+    JniOcResourceResponse* jniOcResourceResponse = JniOcResourceResponse::getJniOcResourceResponsePtr(\r
+        env, jResourceResponse);\r
+    if (!jniOcResourceResponse) return;\r
+\r
+    int len = env->GetArrayLength(jObservationIdArr);\r
+    uint8_t* bArr = (uint8_t*)env->GetByteArrayElements(jObservationIdArr, 0);\r
+\r
+    ObservationIds observationIds;\r
+    for (int i = 0; i < len; ++i)\r
+    {\r
+        observationIds.push_back(bArr[i]);\r
+    }\r
+\r
+    env->ReleaseByteArrayElements(jObservationIdArr, (jbyte*)bArr, 0);\r
+\r
+    try{\r
+        OCStackResult result = OCPlatform::notifyListOfObservers(\r
+            jniOcResourceHandle->getOCResourceHandle(),\r
+            observationIds,\r
+            jniOcResourceResponse->getOCResourceResponse());\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "Failed to notify all observers");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcPlatform\r
+* Method:    notifyListOfObservers3\r
+* Signature: (Lorg/iotivity/base/OcResourceHandle;[Ljava/lang/Byte;Lorg/iotivity/base/OcResourceResponse;I)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyListOfObservers3\r
+(JNIEnv *env, jclass clazz, jobject jResourceHandle, jbyteArray jObservationIdArr, jobject jResourceResponse, jint jQoS)\r
+{\r
+    LOGD("OcPlatform_notifyListOfObservers3");\r
+    if (!jResourceHandle)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null");\r
+        return;\r
+    }\r
+    if (!jObservationIdArr)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "observationIdList cannot be null");\r
+        return;\r
+    }\r
+    if (!jResourceResponse)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceResponse cannot be null");\r
+        return;\r
+    }\r
+\r
+    JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(\r
+        env, jResourceHandle);\r
+    if (!jniOcResourceHandle) return;\r
+\r
+    JniOcResourceResponse* jniOcResourceResponse = JniOcResourceResponse::getJniOcResourceResponsePtr(\r
+        env, jResourceResponse);\r
+    if (!jniOcResourceResponse) return;\r
+\r
+    int len = env->GetArrayLength(jObservationIdArr);\r
+    uint8_t* bArr = (uint8_t*)env->GetByteArrayElements(jObservationIdArr, 0);\r
+\r
+    ObservationIds observationIds;\r
+    for (int i = 0; i < len; ++i)\r
+    {\r
+        observationIds.push_back(bArr[i]);\r
+    }\r
+\r
+    env->ReleaseByteArrayElements(jObservationIdArr, (jbyte*)bArr, 0);\r
+\r
+    try{\r
+        OCStackResult result = OCPlatform::notifyListOfObservers(\r
+            jniOcResourceHandle->getOCResourceHandle(),\r
+            observationIds,\r
+            jniOcResourceResponse->getOCResourceResponse(),\r
+            JniUtils::getQOS(env, static_cast<int>(jQoS)));\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "Failed to notify all observers");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcPlatform\r
+* Method:    findResource0\r
+* Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnResourceFoundListener;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_findResource0\r
+(JNIEnv *env, jclass clazz, jstring jHost, jstring jResourceUri, jint jConnectivityType, jobject jListener)\r
+{\r
+    LOGD("OcPlatform_findResource");\r
+    std::string host;\r
+    if (jHost)\r
+    {\r
+        host = env->GetStringUTFChars(jHost, NULL);\r
+    }\r
+    std::string resourceUri;\r
+    if (jResourceUri)\r
+    {\r
+        resourceUri = env->GetStringUTFChars(jResourceUri, NULL);\r
+    }\r
+    if (!jListener)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onResourceFoundListener cannot be null");\r
+        return;\r
+    }\r
+\r
+    JniOnResourceFoundListener *onResFoundListener = AddOnResourceFoundListener(env, jListener);\r
+\r
+    FindCallback findCallback = [onResFoundListener](std::shared_ptr<OCResource> resource)\r
+    {\r
+        onResFoundListener->foundResourceCallback(resource);\r
+    };\r
+\r
+    try\r
+    {\r
+        OCStackResult result = OCPlatform::findResource(\r
+            host,\r
+            resourceUri,\r
+            JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),\r
+            findCallback);\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "Find resource has failed");\r
+            return;\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcPlatform\r
+* Method:    findResource1\r
+* Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnResourceFoundListener;I)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_findResource1\r
+(JNIEnv *env, jclass clazz, jstring jHost, jstring jResourceUri, jint jConnectivityType, jobject jListener, jint jQoS)\r
+{\r
+    LOGD("OcPlatform_findResource");\r
+    std::string host;\r
+    if (jHost)\r
+    {\r
+        host = env->GetStringUTFChars(jHost, NULL);\r
+    }\r
+    std::string resourceUri;\r
+    if (jResourceUri)\r
+    {\r
+        resourceUri = env->GetStringUTFChars(jResourceUri, NULL);\r
+    }\r
+    if (!jListener)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onResourceFoundListener cannot be null");\r
+        return;\r
+    }\r
+    JniOnResourceFoundListener *onResFoundListener = AddOnResourceFoundListener(env, jListener);\r
+\r
+    FindCallback findCallback = [onResFoundListener](std::shared_ptr<OCResource> resource)\r
+    {\r
+        onResFoundListener->foundResourceCallback(resource);\r
+    };\r
+\r
+    try\r
+    {\r
+        OCStackResult result = OCPlatform::findResource(\r
+            host,\r
+            resourceUri,\r
+            JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),\r
+            findCallback,\r
+            JniUtils::getQOS(env, static_cast<int>(jQoS)));\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "Find resource has failed");\r
+            return;\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcPlatform\r
+* Method:    getDeviceInfo0\r
+* Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnDeviceFoundListener;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getDeviceInfo0\r
+(JNIEnv *env, jclass clazz, jstring jHost, jstring jResourceUri, jint jConnectivityType, jobject jListener)\r
+{\r
+    LOGD("OcPlatform_getDeviceInfo0");\r
+    std::string host;\r
+    if (jHost)\r
+    {\r
+        host = env->GetStringUTFChars(jHost, NULL);\r
+    }\r
+    std::string resourceUri;\r
+    if (jResourceUri)\r
+    {\r
+        resourceUri = env->GetStringUTFChars(jResourceUri, NULL);\r
+    }\r
+    if (!jListener)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onDeviceFoundListener cannot be null");\r
+        return;\r
+    }\r
+    JniOnDeviceInfoListener *onDeviceInfoListener = AddOnDeviceInfoListener(env, jListener);\r
+\r
+    FindDeviceCallback findDeviceCallback = [onDeviceInfoListener](const OCRepresentation& ocRepresentation)\r
+    {\r
+        onDeviceInfoListener->foundDeviceCallback(ocRepresentation);\r
+    };\r
+\r
+    try\r
+    {\r
+        OCStackResult result = OCPlatform::getDeviceInfo(\r
+            host,\r
+            resourceUri,\r
+            JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),\r
+            findDeviceCallback);\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "Find device has failed");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcPlatform\r
+* Method:    getDeviceInfo1\r
+* Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnDeviceFoundListener;I)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getDeviceInfo1\r
+(JNIEnv *env, jclass clazz, jstring jHost, jstring jResourceUri, jint jConnectivityType, jobject jListener, jint jQoS)\r
+{\r
+    LOGD("OcPlatform_getDeviceInfo1");\r
+    std::string host;\r
+    if (jHost)\r
+    {\r
+        host = env->GetStringUTFChars(jHost, NULL);\r
+    }\r
+    std::string resourceUri;\r
+    if (jResourceUri)\r
+    {\r
+        resourceUri = env->GetStringUTFChars(jResourceUri, NULL);\r
+    }\r
+    if (!jListener)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onDeviceFoundListener cannot be null");\r
+        return;\r
+    }\r
+    JniOnDeviceInfoListener *onDeviceInfoListener = AddOnDeviceInfoListener(env, jListener);\r
+\r
+    FindDeviceCallback findDeviceCallback = [onDeviceInfoListener](const OCRepresentation& ocRepresentation)\r
+    {\r
+        onDeviceInfoListener->foundDeviceCallback(ocRepresentation);\r
+    };\r
+\r
+    try\r
+    {\r
+        OCStackResult result = OCPlatform::getDeviceInfo(\r
+            host,\r
+            resourceUri,\r
+            JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),\r
+            findDeviceCallback,\r
+            JniUtils::getQOS(env, static_cast<int>(jQoS)));\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "Find device has failed");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcPlatform\r
+* Method:    registerResource0\r
+* Signature: (Lorg/iotivity/base/OcResource;)Lorg/iotivity/base/OcResourceHandle;\r
+*/\r
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_registerResource0\r
+(JNIEnv *env, jclass clazz, jobject jResource)\r
+{\r
+    LOGD("OcPlatform_registerResource");\r
+    if (!jResource)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "Resource cannot be null");\r
+        return nullptr;\r
+    }\r
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, jResource);\r
+    if (!resource) return nullptr;\r
+\r
+    OCResourceHandle resourceHandle;\r
+    try\r
+    {\r
+        OCStackResult result = OCPlatform::registerResource(\r
+            resourceHandle,\r
+            resource->getOCResource());\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "register resource");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
+        return nullptr;\r
+    }\r
+\r
+    JniOcResourceHandle* jniHandle = new JniOcResourceHandle(resourceHandle);\r
+    jlong handle = reinterpret_cast<jlong>(jniHandle);\r
+    jobject jResourceHandle = env->NewObject(g_cls_OcResourceHandle, g_mid_OcResourceHandle_N_ctor, handle);\r
+    if (!jResourceHandle)\r
+    {\r
+        LOGE("Failed to create OcResourceHandle");\r
+        delete jniHandle;\r
+    }\r
+    return jResourceHandle;\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcPlatform\r
+* Method:    registerResource1\r
+* Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcPlatform/EntityHandler;I)Lorg/iotivity/base/OcResourceHandle;\r
+*/\r
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_registerResource1\r
+(JNIEnv *env, jclass clazz, jstring jResourceUri, jstring jResourceTypeName, jstring jResourceInterface,\r
+jobject jListener, jint jResourceProperty)\r
+{\r
+    LOGI("OcPlatform_registerResource1");\r
+    std::string resourceUri;\r
+    if (jResourceUri)\r
+    {\r
+        resourceUri = env->GetStringUTFChars(jResourceUri, NULL);\r
+    }\r
+    std::string resourceTypeName;\r
+    if (jResourceTypeName)\r
+    {\r
+        resourceTypeName = env->GetStringUTFChars(jResourceTypeName, NULL);\r
+    }\r
+    std::string resourceInterface;\r
+    if (jResourceInterface)\r
+    {\r
+        resourceInterface = env->GetStringUTFChars(jResourceInterface, NULL);\r
+    }\r
+    if (!jListener)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "entityHandler cannot be null");\r
+        return nullptr;\r
+    }\r
+    JniEntityHandler* entityHandler = new JniEntityHandler(env, jListener);\r
+    EntityHandler handleEntityCallback = [entityHandler](const std::shared_ptr<OCResourceRequest> request) ->\r
+        OCEntityHandlerResult{\r
+        return entityHandler->handleEntity(request);\r
+    };\r
+\r
+    OCResourceHandle resourceHandle;\r
+    try\r
+    {\r
+        OCStackResult result = OCPlatform::registerResource(\r
+            resourceHandle,\r
+            resourceUri,\r
+            resourceTypeName,\r
+            resourceInterface,\r
+            handleEntityCallback,\r
+            static_cast<int>(jResourceProperty));\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            delete entityHandler;\r
+            ThrowOcException(result, "register resource");\r
+            return nullptr;\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        delete entityHandler;\r
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
+        return nullptr;\r
+    }\r
+\r
+    JniOcResourceHandle* jniHandle = new JniOcResourceHandle(resourceHandle);\r
+    jlong handle = reinterpret_cast<jlong>(jniHandle);\r
+    jobject jResourceHandle = env->NewObject(g_cls_OcResourceHandle, g_mid_OcResourceHandle_N_ctor, handle);\r
+    if (!jResourceHandle)\r
+    {\r
+        LOGE("Failed to create OcResourceHandle");\r
+        delete jniHandle;\r
+    }\r
+\r
+    return jResourceHandle;\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcPlatform\r
+* Method:    registerDeviceInfo0\r
+* Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_registerDeviceInfo0\r
+(JNIEnv *env,\r
+jclass clazz,\r
+jstring jDeviceName,\r
+jstring jHostName,\r
+jstring jDeviceUUID,\r
+jstring jContentType,\r
+jstring jVersion,\r
+jstring jManufacturerName,\r
+jstring jManufacturerUrl,\r
+jstring jModelNumber,\r
+jstring jDateOfManufacture,\r
+jstring jPlatformVersion,\r
+jstring jFirmwareVersion,\r
+jstring jSupportUrl)\r
+{\r
+    LOGI("OcPlatform_registerDeviceInfo");\r
+\r
+    std::string deviceName;\r
+    if (jDeviceName)\r
+    {\r
+        deviceName = env->GetStringUTFChars(jDeviceName, NULL);\r
+    }\r
+    std::string hostName;\r
+    if (jHostName)\r
+    {\r
+        hostName = env->GetStringUTFChars(jHostName, NULL);\r
+    }\r
+    std::string deviceUUID;\r
+    if (jDeviceUUID)\r
+    {\r
+        deviceUUID = env->GetStringUTFChars(jDeviceUUID, NULL);\r
+    }\r
+    std::string contentType;\r
+    if (jContentType)\r
+    {\r
+        contentType = env->GetStringUTFChars(jContentType, NULL);\r
+    }\r
+    std::string version;\r
+    if (jVersion)\r
+    {\r
+        version = env->GetStringUTFChars(jVersion, NULL);\r
+    }\r
+    std::string manufacturerName;\r
+    if (jManufacturerName)\r
+    {\r
+        manufacturerName = env->GetStringUTFChars(jManufacturerName, NULL);\r
+    }\r
+    std::string manufacturerUrl;\r
+    if (jManufacturerUrl)\r
+    {\r
+        manufacturerUrl = env->GetStringUTFChars(jManufacturerUrl, NULL);\r
+    }\r
+    std::string modelNumber;\r
+    if (jModelNumber)\r
+    {\r
+        modelNumber = env->GetStringUTFChars(jModelNumber, NULL);\r
+    }\r
+    std::string dateOfManufacture;\r
+    if (jDateOfManufacture)\r
+    {\r
+        dateOfManufacture = env->GetStringUTFChars(jDateOfManufacture, NULL);\r
+    }\r
+    std::string platformVersion;\r
+    if (jPlatformVersion)\r
+    {\r
+        platformVersion = env->GetStringUTFChars(jPlatformVersion, NULL);\r
+    }\r
+    std::string firmwareVersion;\r
+    if (jFirmwareVersion)\r
+    {\r
+        firmwareVersion = env->GetStringUTFChars(jFirmwareVersion, NULL);\r
+    }\r
+    std::string supportUrl;\r
+    if (jSupportUrl)\r
+    {\r
+        supportUrl = env->GetStringUTFChars(jSupportUrl, NULL);\r
+    }\r
+\r
+    OCDeviceInfo deviceInfo;\r
+    try\r
+    {\r
+        DuplicateString(&deviceInfo.contentType, contentType);\r
+        DuplicateString(&deviceInfo.dateOfManufacture, dateOfManufacture);\r
+        DuplicateString(&deviceInfo.deviceName, deviceName);\r
+        DuplicateString(&deviceInfo.deviceUUID, deviceUUID);\r
+        DuplicateString(&deviceInfo.firmwareVersion, firmwareVersion);\r
+        DuplicateString(&deviceInfo.hostName, hostName);\r
+        DuplicateString(&deviceInfo.manufacturerName, manufacturerName);\r
+        DuplicateString(&deviceInfo.manufacturerUrl, manufacturerUrl);\r
+        DuplicateString(&deviceInfo.modelNumber, modelNumber);\r
+        DuplicateString(&deviceInfo.platformVersion, platformVersion);\r
+        DuplicateString(&deviceInfo.supportUrl, supportUrl);\r
+        DuplicateString(&deviceInfo.version, version);\r
+    }\r
+    catch (std::exception &e)\r
+    {\r
+        ThrowOcException(JNI_EXCEPTION, "Failed to register device info");\r
+        return;\r
+    }\r
+\r
+    try\r
+    {\r
+        OCStackResult result = OCPlatform::registerDeviceInfo(deviceInfo);\r
+\r
+        delete deviceInfo.contentType;\r
+        delete deviceInfo.dateOfManufacture;\r
+        delete deviceInfo.deviceName;\r
+        delete deviceInfo.deviceUUID;\r
+        delete deviceInfo.firmwareVersion;\r
+        delete deviceInfo.hostName;\r
+        delete deviceInfo.manufacturerName;\r
+        delete deviceInfo.manufacturerUrl;\r
+        delete deviceInfo.modelNumber;\r
+        delete deviceInfo.platformVersion;\r
+        delete deviceInfo.supportUrl;\r
+        delete deviceInfo.version;\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "Failed to register device info");\r
+            return;\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcPlatform\r
+* Method:    unregisterResource0\r
+* Signature: (Lorg/iotivity/base/OcResourceHandle;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unregisterResource0\r
+(JNIEnv *env, jclass clazz, jobject jResourceHandle)\r
+{\r
+    LOGI("OcPlatform_unregisterResource");\r
+    if (!jResourceHandle)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null");\r
+        return;\r
+    }\r
+    JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(\r
+        env, jResourceHandle);\r
+    if (!jniOcResourceHandle) return;\r
+\r
+    try\r
+    {\r
+        OCResourceHandle resHandle = jniOcResourceHandle->getOCResourceHandle();\r
+        OCStackResult result = OCPlatform::unregisterResource(resHandle);\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "Failed to unregister resource");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcPlatform\r
+* Method:    bindResource0\r
+* Signature: (Lorg/iotivity/base/OcResourceHandle;Lorg/iotivity/base/OcResourceHandle;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindResource0\r
+(JNIEnv *env, jclass clazz, jobject jResourceCollectionHandle, jobject jResourceHandle)\r
+{\r
+    LOGI("OcPlatform_bindResource");\r
+    if (!jResourceCollectionHandle)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceCollectionHandle cannot be null");\r
+        return;\r
+    }\r
+    if (!jResourceHandle)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null");\r
+        return;\r
+    }\r
+    JniOcResourceHandle* jniOcResourceCollectionHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(\r
+        env, jResourceCollectionHandle);\r
+    if (!jniOcResourceCollectionHandle) return;\r
+\r
+    JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(\r
+        env, jResourceHandle);\r
+    if (!jniOcResourceHandle) return;\r
+\r
+    try\r
+    {\r
+        OCStackResult result = OCPlatform::bindResource(\r
+            jniOcResourceCollectionHandle->getOCResourceHandle(),\r
+            jniOcResourceHandle->getOCResourceHandle()\r
+            );\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "Failed to bind resource");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcPlatform\r
+* Method:    bindResources0\r
+* Signature: (Lorg/iotivity/base/OcResourceHandle;[Lorg/iotivity/base/OcResourceHandle;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindResources0\r
+(JNIEnv *env, jclass clazz, jobject jResourceCollectionHandle, jobjectArray jResourceHandleArray)\r
+{\r
+    LOGI("OcPlatform_bindResources");\r
+\r
+    if (!jResourceCollectionHandle)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceCollectionHandle cannot be null");\r
+        return;\r
+    }\r
+    if (!jResourceHandleArray)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandleList cannot be null");\r
+        return;\r
+    }\r
+\r
+    JniOcResourceHandle* jniOcResourceCollectionHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(\r
+        env, jResourceCollectionHandle);\r
+    if (!jniOcResourceCollectionHandle) return;\r
+\r
+    std::vector<OCResourceHandle> resourceHandleList;\r
+    int len = env->GetArrayLength(jResourceHandleArray);\r
+    for (int i = 0; i < len; ++i)\r
+    {\r
+        jobject jResourceHandle = env->GetObjectArrayElement(jResourceHandleArray, i);\r
+        if (!jResourceHandle)\r
+        {\r
+            ThrowOcException(JNI_EXCEPTION, "resource handle cannot be null");\r
+            return;\r
+        }\r
+\r
+        JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(\r
+            env, jResourceHandle);\r
+        if (!jniOcResourceHandle) return;\r
+\r
+        resourceHandleList.push_back(\r
+            jniOcResourceHandle->getOCResourceHandle());\r
+    }\r
+\r
+    try\r
+    {\r
+        OCStackResult result = OCPlatform::bindResources(\r
+            jniOcResourceCollectionHandle->getOCResourceHandle(),\r
+            resourceHandleList\r
+            );\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "Failed to bind resources");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcPlatform\r
+* Method:    unbindResource0\r
+* Signature: (Lorg/iotivity/base/OcResourceHandle;Lorg/iotivity/base/OcResourceHandle;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unbindResource0\r
+(JNIEnv *env, jclass clazz, jobject jResourceCollectionHandle, jobject jResourceHandle)\r
+{\r
+    LOGI("OcPlatform_unbindResource");\r
+    if (!jResourceCollectionHandle)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceCollectionHandle cannot be null");\r
+        return;\r
+    }\r
+    if (!jResourceHandle)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null");\r
+        return;\r
+    }\r
+\r
+    JniOcResourceHandle* jniOcResourceCollectionHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(\r
+        env, jResourceCollectionHandle);\r
+    if (!jniOcResourceCollectionHandle) return;\r
+\r
+    JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(\r
+        env, jResourceHandle);\r
+    if (!jniOcResourceHandle) return;\r
+\r
+    try\r
+    {\r
+        OCStackResult result = OCPlatform::unbindResource(\r
+            jniOcResourceCollectionHandle->getOCResourceHandle(),\r
+            jniOcResourceHandle->getOCResourceHandle()\r
+            );\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "Failed to unbind resource");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcPlatform\r
+* Method:    unbindResources0\r
+* Signature: (Lorg/iotivity/base/OcResourceHandle;[Lorg/iotivity/base/OcResourceHandle;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unbindResources0\r
+(JNIEnv *env, jclass clazz, jobject jResourceCollectionHandle, jobjectArray jResourceHandleArray)\r
+{\r
+    LOGI("OcPlatform_unbindResources");\r
+    if (!jResourceCollectionHandle)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceCollectionHandle cannot be null");\r
+        return;\r
+    }\r
+    if (!jResourceHandleArray)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandleList cannot be null");\r
+        return;\r
+    }\r
+\r
+    JniOcResourceHandle* jniOcResourceCollectionHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(\r
+        env, jResourceCollectionHandle);\r
+    if (!jniOcResourceCollectionHandle) return;\r
+\r
+    std::vector<OCResourceHandle> resourceHandleList;\r
+    int len = env->GetArrayLength(jResourceHandleArray);\r
+    for (int i = 0; i < len; ++i)\r
+    {\r
+        jobject jResourceHandle = env->GetObjectArrayElement(jResourceHandleArray, i);\r
+        if (!jResourceHandle)\r
+        {\r
+            ThrowOcException(JNI_EXCEPTION, "resource handle cannot be null");\r
+            return;\r
+        }\r
+\r
+        JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(\r
+            env, jResourceHandle);\r
+        if (!jniOcResourceHandle) return;\r
+\r
+        resourceHandleList.push_back(\r
+            jniOcResourceHandle->getOCResourceHandle());\r
+    }\r
+\r
+    try\r
+    {\r
+        OCStackResult result = OCPlatform::unbindResources(\r
+            jniOcResourceCollectionHandle->getOCResourceHandle(),\r
+            resourceHandleList\r
+            );\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "Failed to unbind resources");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcPlatform\r
+* Method:    bindTypeToResource0\r
+* Signature: (Lorg/iotivity/base/OcResourceHandle;Ljava/lang/String;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindTypeToResource0\r
+(JNIEnv *env, jclass clazz, jobject jResourceHandle, jstring jResourceTypeName)\r
+{\r
+    LOGI("OcPlatform_bindTypeToResource");\r
+    if (!jResourceHandle)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null");\r
+        return;\r
+    }\r
+    std::string typeName;\r
+    if (jResourceTypeName)\r
+    {\r
+        typeName = env->GetStringUTFChars(jResourceTypeName, NULL);\r
+    }\r
+\r
+    JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(\r
+        env, jResourceHandle);\r
+    if (!jniOcResourceHandle) return;\r
+\r
+    try\r
+    {\r
+        OCStackResult result = OCPlatform::bindTypeToResource(\r
+            jniOcResourceHandle->getOCResourceHandle(),\r
+            typeName\r
+            );\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "Failed to bind type to resource");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcPlatform\r
+* Method:    bindInterfaceToResource0\r
+* Signature: (Lorg/iotivity/base/OcResourceHandle;Ljava/lang/String;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindInterfaceToResource0\r
+(JNIEnv *env, jclass clazz, jobject jResourceHandle, jstring jResourceInterfaceName)\r
+{\r
+    LOGI("OcPlatform_bindInterfaceToResource");\r
+    if (!jResourceHandle)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null");\r
+        return;\r
+    }\r
+    std::string interfaceName;\r
+    if (jResourceInterfaceName)\r
+    {\r
+        interfaceName = env->GetStringUTFChars(jResourceInterfaceName, NULL);\r
+    }\r
+\r
+    JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(\r
+        env, jResourceHandle);\r
+    if (!jniOcResourceHandle) return;\r
+\r
+    try\r
+    {\r
+        OCStackResult result = OCPlatform::bindInterfaceToResource(\r
+            jniOcResourceHandle->getOCResourceHandle(),\r
+            interfaceName\r
+            );\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "Failed to bind interface to resource");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcPlatform\r
+* Method:    startPresence0\r
+* Signature: (I)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_startPresence0\r
+(JNIEnv *env, jclass clazz, jint ttl)\r
+{\r
+    LOGI("OcPlatform_startPresence");\r
+\r
+    try\r
+    {\r
+        OCStackResult result = OCPlatform::startPresence((unsigned int)ttl);\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "Failed to start presence");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcPlatform\r
+* Method:    stopPresence0\r
+* Signature: ()V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_stopPresence0\r
+(JNIEnv *env, jclass clazz)\r
+{\r
+    LOGI("OcPlatform_stopPresence");\r
+\r
+    try\r
+    {\r
+        OCStackResult result = OCPlatform::stopPresence();\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "Failed to stop presence");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcPlatform\r
+* Method:    subscribePresence0\r
+* Signature: (Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnPresenceListener;)Lorg/iotivity/base/OcPresenceHandle;\r
+*/\r
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_subscribePresence0\r
+(JNIEnv *env, jclass clazz, jstring jHost, jint jConnectivityType, jobject jListener)\r
+{\r
+    LOGD("OcPlatform_subscribePresence");\r
+    std::string host;\r
+    if (jHost)\r
+    {\r
+        host = env->GetStringUTFChars(jHost, NULL);\r
+    }\r
+    if (!jListener)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onPresenceListener cannot be null");\r
+        return nullptr;\r
+    }\r
+\r
+    JniOnPresenceListener *onPresenceListener = AddOnPresenceListener(env, jListener);\r
+\r
+    SubscribeCallback subscribeCallback = [onPresenceListener](OCStackResult result, const unsigned int nonce,\r
+        const std::string& hostAddress)\r
+    {\r
+        onPresenceListener->onPresenceCallback(result, nonce, hostAddress);\r
+    };\r
+\r
+    OCPlatform::OCPresenceHandle presenceHandle;\r
+    try\r
+    {\r
+        OCStackResult result = OCPlatform::subscribePresence(\r
+            presenceHandle,\r
+            host,\r
+            JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),\r
+            subscribeCallback);\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "subscribe presence has failed");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
+        return nullptr;\r
+    }\r
+\r
+    JniOcPresenceHandle* jniPresenceHandle = new JniOcPresenceHandle(onPresenceListener, presenceHandle);\r
+    jlong jhandle = reinterpret_cast<jlong>(jniPresenceHandle);\r
+    jobject jPresenceHandle = env->NewObject(g_cls_OcPresenceHandle, g_mid_OcPresenceHandle_N_ctor, jhandle);\r
+    if (!jPresenceHandle)\r
+    {\r
+        LOGE("Failed to create OcPresenceHandle");\r
+        delete jniPresenceHandle;\r
+    }\r
+\r
+    return jPresenceHandle;\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcPlatform\r
+* Method:    subscribePresence1\r
+* Signature: (Ljava/lang/String;Ljava/lang/String;I\r
+Lorg/iotivity/base/OcPlatform/OnPresenceListener;)Lorg/iotivity/base/OcPresenceHandle;\r
+*/\r
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_subscribePresence1\r
+(JNIEnv *env, jclass clazz, jstring jHost, jstring jResourceType, jint jConnectivityType, jobject jListener)\r
+{\r
+    LOGD("OcPlatform_subscribePresence1");\r
+    std::string host;\r
+    if (jHost)\r
+    {\r
+        host = env->GetStringUTFChars(jHost, NULL);\r
+    }\r
+    std::string resourceType;\r
+    if (jResourceType)\r
+    {\r
+        resourceType = env->GetStringUTFChars(jResourceType, NULL);\r
+    }\r
+    if (!jListener)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onPresenceListener cannot be null");\r
+        return nullptr;\r
+    }\r
+\r
+    JniOnPresenceListener *onPresenceListener = AddOnPresenceListener(env, jListener);\r
+\r
+    SubscribeCallback subscribeCallback = [onPresenceListener](OCStackResult result,\r
+        const unsigned int nonce, const std::string& hostAddress)\r
+    {\r
+        onPresenceListener->onPresenceCallback(result, nonce, hostAddress);\r
+    };\r
+\r
+    OCPlatform::OCPresenceHandle presenceHandle;\r
+    try\r
+    {\r
+        OCStackResult result = OCPlatform::subscribePresence(\r
+            presenceHandle,\r
+            host,\r
+            resourceType,\r
+            JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),\r
+            subscribeCallback);\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "subscribe presence has failed");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
+        return nullptr;\r
+    }\r
+\r
+    JniOcPresenceHandle* jniPresenceHandle = new JniOcPresenceHandle(onPresenceListener, presenceHandle);\r
+    jlong jhandle = reinterpret_cast<jlong>(jniPresenceHandle);\r
+    jobject jPresenceHandle = env->NewObject(g_cls_OcPresenceHandle, g_mid_OcPresenceHandle_N_ctor, jhandle);\r
+    if (!jPresenceHandle)\r
+    {\r
+        LOGE("Failed to create OcPresenceHandle");\r
+        delete jniPresenceHandle;\r
+    }\r
+    return jPresenceHandle;\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcPlatform\r
+* Method:    unsubscribePresence0\r
+* Signature: (Lorg/iotivity/base/OcPresenceHandle;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unsubscribePresence0\r
+(JNIEnv *env, jclass clazz, jobject jPresenceHandle)\r
+{\r
+    LOGD("OcPlatform_unsubscribePresence");\r
+    if (!jPresenceHandle)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "presenceHandle cannot be null");\r
+        return;\r
+    }\r
+    JniOcPresenceHandle* jniPresenceHandle = JniOcPresenceHandle::getJniOcPresenceHandlePtr(env, jPresenceHandle);\r
+    if (!jniPresenceHandle) return;\r
+\r
+    OCPresenceHandle presenceHandle = jniPresenceHandle->getOCPresenceHandle();\r
+\r
+    try\r
+    {\r
+        OCStackResult result = OCPlatform::unsubscribePresence(presenceHandle);\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "unsubscribe presence has failed");\r
+            return;\r
+        }\r
+        jweak jwOnPresenceListener = jniPresenceHandle->getJniOnPresenceListener()->getJWListener();\r
+        if (jwOnPresenceListener)\r
+        {\r
+            RemoveOnPresenceListener(env, jwOnPresenceListener);\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcPlatform\r
+* Method:    constructResourceObject0\r
+* Signature: (Ljava/lang/String;Ljava/lang/String;IZ[Ljava/lang/String;[Ljava/lang/String;)\r
+Lorg/iotivity/base/OcResource;\r
+*/\r
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_constructResourceObject0\r
+(JNIEnv *env, jclass clazz, jstring jHost, jstring jUri, jint jConnectivityType,\r
+jboolean jIsObservable, jobjectArray jResourceTypeArray, jobjectArray jInterfaceArray)\r
+{\r
+    LOGD("OcPlatform_constructResourceObject");\r
+    std::string host;\r
+    if (jHost)\r
+    {\r
+        host = env->GetStringUTFChars(jHost, NULL);\r
+    }\r
+    std::string uri;\r
+    if (jUri)\r
+    {\r
+        uri = env->GetStringUTFChars(jUri, NULL);\r
+    }\r
+    if (!jResourceTypeArray)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceTypeList cannot be null");\r
+        return nullptr;\r
+    }\r
+    if (!jInterfaceArray)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "interfaceList cannot be null");\r
+        return nullptr;\r
+    }\r
+\r
+    std::vector<std::string> resourceTypes;\r
+    JniUtils::convertJavaStrArrToStrVector(env, jResourceTypeArray, resourceTypes);\r
+\r
+    std::vector<std::string> interfaces;\r
+    JniUtils::convertJavaStrArrToStrVector(env, jInterfaceArray, interfaces);\r
+\r
+    std::shared_ptr<OCResource> resource = OCPlatform::constructResourceObject(\r
+        host,\r
+        uri,\r
+        JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),\r
+        static_cast<bool>(jIsObservable),\r
+        resourceTypes,\r
+        interfaces);\r
+\r
+    if (!resource)\r
+    {\r
+        ThrowOcException(OC_STACK_ERROR, "Failed to create OCResource");\r
+        return nullptr;\r
+    }\r
+\r
+    JniOcResource *jniOcResource = new JniOcResource(resource);\r
+    jlong handle = reinterpret_cast<jlong>(jniOcResource);\r
+\r
+    jobject jResource = env->NewObject(g_cls_OcResource, g_mid_OcResource_ctor);\r
+    if (!jResource)\r
+    {\r
+        delete jniOcResource;\r
+        return nullptr;\r
+    }\r
+    SetHandle<JniOcResource>(env, jResource, jniOcResource);\r
+    if (env->ExceptionCheck())\r
+    {\r
+        delete jniOcResource;\r
+        return nullptr;\r
+    }\r
+    return jResource;\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcPlatform\r
+* Method:    sendResponse0\r
+* Signature: (Lorg/iotivity/base/OcResourceResponse;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_sendResponse0\r
+(JNIEnv *env, jclass clazz, jobject jResourceResponse)\r
+{\r
+    LOGD("OcPlatform_sendResponse");\r
+    if (!jResourceResponse)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceResponse cannot be null");\r
+        return;\r
+    }\r
+\r
+    JniOcResourceResponse *jniResponse = JniOcResourceResponse::getJniOcResourceResponsePtr(\r
+        env, jResourceResponse);\r
+    if (!jniResponse) return;\r
+\r
+    try\r
+    {\r
+        OCStackResult result = OCPlatform::sendResponse(jniResponse->getOCResourceResponse());\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "failed to send response");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
+    }\r
+}
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniOcPlatform.h b/android/android_api/base/jni/JniOcPlatform.h
new file mode 100644 (file)
index 0000000..1019147
--- /dev/null
@@ -0,0 +1,264 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniOcStack.h"\r
+#include "JniOnResourceFoundListener.h"\r
+#include "JniOnDeviceInfoListener.h"\r
+#include "JniOnPresenceListener.h"\r
+#include <mutex>\r
+\r
+#ifndef _Included_org_iotivity_base_OcPlatform\r
+#define _Included_org_iotivity_base_OcPlatform\r
+\r
+using namespace OC;\r
+\r
+JniOnResourceFoundListener* AddOnResourceFoundListener(JNIEnv* env, jobject jListener);\r
+void RemoveOnResourceFoundListener(JNIEnv* env, jobject jListener);\r
+\r
+JniOnDeviceInfoListener* AddOnDeviceInfoListener(JNIEnv* env, jobject jListener);\r
+void RemoveOnDeviceInfoListener(JNIEnv* env, jobject jListener);\r
+\r
+JniOnPresenceListener* AddOnPresenceListener(JNIEnv* env, jobject jListener);\r
+void RemoveOnPresenceListener(JNIEnv* env, jobject jListener);\r
+\r
+std::map<jobject, std::pair<JniOnResourceFoundListener*, int>> onResourceFoundListenerMap;\r
+std::map<jobject, std::pair<JniOnDeviceInfoListener*, int>> onDeviceInfoListenerMap;\r
+std::map<jobject, std::pair<JniOnPresenceListener*, int>> onPresenceListenerMap;\r
+\r
+std::mutex resourceFoundMapLock;\r
+std::mutex deviceInfoMapLock;\r
+std::mutex presenceMapLock;\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+    /*\r
+    * Class:     org_iotivity_base_OcPlatform\r
+    * Method:    configure\r
+    * Signature: (IILjava/lang/String;II)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_configure\r
+        (JNIEnv *, jclass, jint, jint, jstring, jint, jint);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcPlatform\r
+    * Method:    notifyAllObservers0\r
+    * Signature: (Lorg/iotivity/base/OcResourceHandle;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyAllObservers0\r
+        (JNIEnv *, jclass, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcPlatform\r
+    * Method:    notifyAllObservers1\r
+    * Signature: (Lorg/iotivity/base/OcResourceHandle;I)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyAllObservers1\r
+        (JNIEnv *, jclass, jobject, jint);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcPlatform\r
+    * Method:    notifyListOfObservers2\r
+    * Signature: (Lorg/iotivity/base/OcResourceHandle;[BLorg/iotivity/base/OcResourceResponse;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyListOfObservers2\r
+        (JNIEnv *, jclass, jobject, jbyteArray, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcPlatform\r
+    * Method:    notifyListOfObservers3\r
+    * Signature: (Lorg/iotivity/base/OcResourceHandle;[BLorg/iotivity/base/OcResourceResponse;I)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyListOfObservers3\r
+        (JNIEnv *, jclass, jobject, jbyteArray, jobject, jint);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcPlatform\r
+    * Method:    findResource0\r
+    * Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnResourceFoundListener;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_findResource0\r
+        (JNIEnv *, jclass, jstring, jstring, jint, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcPlatform\r
+    * Method:    findResource1\r
+    * Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnResourceFoundListener;I)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_findResource1\r
+        (JNIEnv *, jclass, jstring, jstring, jint, jobject, jint);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcPlatform\r
+    * Method:    getDeviceInfo0\r
+    * Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnDeviceFoundListener;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getDeviceInfo0\r
+        (JNIEnv *, jclass, jstring, jstring, jint, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcPlatform\r
+    * Method:    getDeviceInfo1\r
+    * Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnDeviceFoundListener;I)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getDeviceInfo1\r
+        (JNIEnv *, jclass, jstring, jstring, jint, jobject, jint);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcPlatform\r
+    * Method:    registerResource0\r
+    * Signature: (Lorg/iotivity/base/OcResource;)Lorg/iotivity/base/OcResourceHandle;\r
+    */\r
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_registerResource0\r
+        (JNIEnv *, jclass, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcPlatform\r
+    * Method:    registerResource1\r
+    * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcPlatform/EntityHandler;I)Lorg/iotivity/base/OcResourceHandle;\r
+    */\r
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_registerResource1\r
+        (JNIEnv *, jclass, jstring, jstring, jstring, jobject, jint);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcPlatform\r
+    * Method:    registerDeviceInfo0\r
+    * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_registerDeviceInfo0\r
+        (JNIEnv *, jclass, jstring, jstring, jstring, jstring, jstring, jstring, jstring, jstring, jstring, jstring, jstring, jstring);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcPlatform\r
+    * Method:    unregisterResource0\r
+    * Signature: (Lorg/iotivity/base/OcResourceHandle;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unregisterResource0\r
+        (JNIEnv *, jclass, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcPlatform\r
+    * Method:    bindResource0\r
+    * Signature: (Lorg/iotivity/base/OcResourceHandle;Lorg/iotivity/base/OcResourceHandle;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindResource0\r
+        (JNIEnv *, jclass, jobject, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcPlatform\r
+    * Method:    bindResources0\r
+    * Signature: (Lorg/iotivity/base/OcResourceHandle;[Lorg/iotivity/base/OcResourceHandle;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindResources0\r
+        (JNIEnv *, jclass, jobject, jobjectArray);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcPlatform\r
+    * Method:    unbindResource0\r
+    * Signature: (Lorg/iotivity/base/OcResourceHandle;Lorg/iotivity/base/OcResourceHandle;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unbindResource0\r
+        (JNIEnv *, jclass, jobject, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcPlatform\r
+    * Method:    unbindResources0\r
+    * Signature: (Lorg/iotivity/base/OcResourceHandle;[Lorg/iotivity/base/OcResourceHandle;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unbindResources0\r
+        (JNIEnv *, jclass, jobject, jobjectArray);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcPlatform\r
+    * Method:    bindTypeToResource0\r
+    * Signature: (Lorg/iotivity/base/OcResourceHandle;Ljava/lang/String;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindTypeToResource0\r
+        (JNIEnv *, jclass, jobject, jstring);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcPlatform\r
+    * Method:    bindInterfaceToResource0\r
+    * Signature: (Lorg/iotivity/base/OcResourceHandle;Ljava/lang/String;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindInterfaceToResource0\r
+        (JNIEnv *, jclass, jobject, jstring);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcPlatform\r
+    * Method:    startPresence0\r
+    * Signature: (I)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_startPresence0\r
+        (JNIEnv *, jclass, jint);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcPlatform\r
+    * Method:    stopPresence0\r
+    * Signature: ()V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_stopPresence0\r
+        (JNIEnv *, jclass);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcPlatform\r
+    * Method:    subscribePresence0\r
+    * Signature: (Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnPresenceListener;)Lorg/iotivity/base/OcPresenceHandle;\r
+    */\r
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_subscribePresence0\r
+        (JNIEnv *, jclass, jstring, jint, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcPlatform\r
+    * Method:    subscribePresence1\r
+    * Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnPresenceListener;)Lorg/iotivity/base/OcPresenceHandle;\r
+    */\r
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_subscribePresence1\r
+        (JNIEnv *, jclass, jstring, jstring, jint, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcPlatform\r
+    * Method:    unsubscribePresence0\r
+    * Signature: (Lorg/iotivity/base/OcPresenceHandle;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unsubscribePresence0\r
+        (JNIEnv *, jclass, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcPlatform\r
+    * Method:    constructResourceObject0\r
+    * Signature: (Ljava/lang/String;Ljava/lang/String;IZ[Ljava/lang/String;[Ljava/lang/String;)Lorg/iotivity/base/OcResource;\r
+    */\r
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_constructResourceObject0\r
+        (JNIEnv *, jclass, jstring, jstring, jint, jboolean, jobjectArray, jobjectArray);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcPlatform0\r
+    * Method:    sendResponse0\r
+    * Signature: (Lorg/iotivity/base/OcResourceResponse;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_sendResponse0\r
+        (JNIEnv *, jclass, jobject);\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+#endif\r
diff --git a/android/android_api/base/jni/JniOcPresenceHandle.cpp b/android/android_api/base/jni/JniOcPresenceHandle.cpp
new file mode 100644 (file)
index 0000000..83950bc
--- /dev/null
@@ -0,0 +1,73 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniOcPresenceHandle.h"\r
+#include "OCPlatform.h"\r
+\r
+JniOcPresenceHandle::JniOcPresenceHandle(JniOnPresenceListener* jniListener, OCPresenceHandle presenceHandle)\r
+    : m_jniListener(jniListener), m_presenceHandle(presenceHandle)\r
+{}\r
+\r
+JniOcPresenceHandle::~JniOcPresenceHandle()\r
+{\r
+    LOGD("~JniOcPresenceHandle()");\r
+\r
+    //delete m_jniListener;\r
+    m_presenceHandle = nullptr;\r
+}\r
+\r
+JniOcPresenceHandle* JniOcPresenceHandle::getJniOcPresenceHandlePtr\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    JniOcPresenceHandle *handle = GetHandle<JniOcPresenceHandle>(env, thiz);\r
+    if (env->ExceptionCheck())\r
+    {\r
+        LOGE("Failed to get native handle from OcPresenceHandle");\r
+    }\r
+    if (!handle)\r
+    {\r
+        ThrowOcException(JNI_NO_NATIVE_POINTER, "");\r
+    }\r
+    return handle;\r
+}\r
+\r
+OCPresenceHandle JniOcPresenceHandle::getOCPresenceHandle()\r
+{\r
+    return this->m_presenceHandle;\r
+}\r
+\r
+JniOnPresenceListener* JniOcPresenceHandle::getJniOnPresenceListener()\r
+{\r
+    return this->m_jniListener;\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcPresenceHandle\r
+* Method:    dispose\r
+* Signature: ()V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPresenceHandle_dispose\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcPresenceHandle_dispose");\r
+    JniOcPresenceHandle *presenceHandle = JniOcPresenceHandle::getJniOcPresenceHandlePtr(env, thiz);\r
+    delete presenceHandle;\r
+}
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniOcPresenceHandle.h b/android/android_api/base/jni/JniOcPresenceHandle.h
new file mode 100644 (file)
index 0000000..26f6a8d
--- /dev/null
@@ -0,0 +1,65 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniOcStack.h"\r
+#include "JniOnPresenceListener.h"\r
+#include "OCPlatform.h"\r
+\r
+#ifndef _Included_org_iotivity_base_OcPresenceHandle\r
+#define _Included_org_iotivity_base_OcPresenceHandle\r
+\r
+using namespace OC::OCPlatform;\r
+\r
+class JniOcPresenceHandle\r
+{\r
+public:\r
+\r
+    JniOcPresenceHandle(JniOnPresenceListener* jniListener, OCPresenceHandle presenceHandle);\r
+    ~JniOcPresenceHandle();\r
+    JniOcPresenceHandle(const JniOcPresenceHandle &) = delete;\r
+    void operator=(const JniOcPresenceHandle &) = delete;\r
+\r
+    static JniOcPresenceHandle* getJniOcPresenceHandlePtr(JNIEnv *env, jobject thiz);\r
+\r
+    OCPresenceHandle getOCPresenceHandle();\r
+    JniOnPresenceListener* getJniOnPresenceListener();\r
+\r
+private:\r
+    JniOnPresenceListener* m_jniListener;\r
+    OCPresenceHandle m_presenceHandle;\r
+};\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcPresenceHandle\r
+    * Method:    dispose\r
+    * Signature: ()V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPresenceHandle_dispose\r
+        (JNIEnv *, jobject);\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+#endif\r
diff --git a/android/android_api/base/jni/JniOcRepresentation.cpp b/android/android_api/base/jni/JniOcRepresentation.cpp
new file mode 100644 (file)
index 0000000..e2c2cd0
--- /dev/null
@@ -0,0 +1,1040 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniOcRepresentation.h"\r
+#include "JniUtils.h"\r
+\r
+using namespace OC;\r
+\r
+OCRepresentation* JniOcRepresentation::getOCRepresentationPtr(JNIEnv *env, jobject thiz)\r
+{\r
+    OCRepresentation *rep = GetHandle<OCRepresentation>(env, thiz);\r
+    if (env->ExceptionCheck())\r
+    {\r
+        LOGE("Failed to get native handle from OcRepresentation");\r
+    }\r
+    if (!rep)\r
+    {\r
+        ThrowOcException(JNI_NO_NATIVE_POINTER, "");\r
+    }\r
+    return rep;\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    getValueN\r
+* Signature: (Ljava/lang/String;)Ljava/lang/Object;\r
+*/\r
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcRepresentation_getValueN\r
+(JNIEnv *env, jobject thiz, jstring jKey)\r
+{\r
+    LOGD("OcRepresentation_getValue");\r
+    if (!jKey)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "attributeKey cannot be null");\r
+        return nullptr;\r
+    }\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return nullptr;\r
+\r
+    std::string key = env->GetStringUTFChars(jKey, NULL);\r
+\r
+    AttributeValue attrValue;\r
+    if (!rep->getAttributeValue(key.c_str(), attrValue))\r
+    {\r
+        ThrowOcException(JNI_NO_SUCH_KEY, " attribute key does not exist");\r
+        return nullptr;\r
+    }\r
+    return boost::apply_visitor(JObjectConverter(env), attrValue);\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    setValueInteger\r
+* Signature: (Ljava/lang/String;I)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueInteger\r
+(JNIEnv *env, jobject thiz, jstring jKey, jint jValue)\r
+{\r
+    LOGD("OcRepresentation_setValueInteger");\r
+    if (!jKey)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
+        return;\r
+    }\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return;\r
+\r
+    std::string str = env->GetStringUTFChars(jKey, NULL);\r
+    rep->setValue(str, static_cast<int>(jValue));\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    setValueDouble\r
+* Signature: (Ljava/lang/String;D)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDouble\r
+(JNIEnv *env, jobject thiz, jstring jKey, jdouble jValue)\r
+{\r
+    LOGD("OcRepresentation_setValueDouble");\r
+    if (!jKey)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
+        return;\r
+    }\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return;\r
+\r
+    std::string str = env->GetStringUTFChars(jKey, NULL);\r
+    rep->setValue(str, static_cast<double>(jValue));\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    setValueBoolean\r
+* Signature: (Ljava/lang/String;Z)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBoolean\r
+(JNIEnv *env, jobject thiz, jstring jKey, jboolean jValue)\r
+{\r
+    LOGD("OcRepresentation_setValueBoolean");\r
+    if (!jKey)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
+        return;\r
+    }\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return;\r
+\r
+    std::string str = env->GetStringUTFChars(jKey, NULL);\r
+    rep->setValue(str, static_cast<bool>(jValue));\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    setValueStringN\r
+* Signature: (Ljava/lang/String;Ljava/lang/String;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueStringN\r
+(JNIEnv *env, jobject thiz, jstring jKey, jstring jValue)\r
+{\r
+    LOGD("OcRepresentation_setValueString");\r
+    if (!jKey)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
+        return;\r
+    }\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return;\r
+\r
+    std::string key = env->GetStringUTFChars(jKey, NULL);\r
+    std::string value = env->GetStringUTFChars(jValue, NULL);\r
+\r
+    rep->setValue(key, value);\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    setValueRepresentation\r
+* Signature: (Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresentation\r
+(JNIEnv *env, jobject thiz, jstring jKey, jobject jValue)\r
+{\r
+    LOGD("OcRepresentation_setValueRepresentation");\r
+    if (!jKey)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
+        return;\r
+    }\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return;\r
+\r
+    std::string key = env->GetStringUTFChars(jKey, NULL);\r
+    OCRepresentation *value = JniOcRepresentation::getOCRepresentationPtr(env, jValue);\r
+    if (!value) return;\r
+\r
+    rep->setValue(key, *value);\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    setValueIntegerArray\r
+* Signature: (Ljava/lang/String;[I)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueIntegerArray\r
+(JNIEnv *env, jobject thiz, jstring jKey, jintArray jValue)\r
+{\r
+    LOGD("OcRepresentation_setValueIntegerArray");\r
+    if (!jKey)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
+        return;\r
+    }\r
+\r
+    const jsize len = env->GetArrayLength(jValue);\r
+    jint* ints = env->GetIntArrayElements(jValue, NULL);\r
+\r
+    std::vector<int> value;\r
+    for (jsize i = 0; i < len; ++i)\r
+    {\r
+        value.push_back(static_cast<int>(ints[i]));\r
+    }\r
+    env->ReleaseIntArrayElements(jValue, ints, JNI_ABORT);\r
+\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return;\r
+\r
+    std::string key = env->GetStringUTFChars(jKey, NULL);\r
+    rep->setValue(key, value);\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    setValueInteger2DArray\r
+* Signature: (Ljava/lang/String;[[I)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueInteger2DArray\r
+(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)\r
+{\r
+    LOGD("OcRepresentation__setValueInteger2DArray");\r
+    if (!jKey)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
+        return;\r
+    }\r
+    std::vector<std::vector<int>> value;\r
+    const jsize lenOuter = env->GetArrayLength(jValue);\r
+    for (jsize j = 0; j < lenOuter; ++j)\r
+    {\r
+        jintArray jInnerArray = static_cast<jintArray>(env->GetObjectArrayElement(jValue, j));\r
+        jint* ints = env->GetIntArrayElements(jInnerArray, NULL);\r
+        std::vector<int> innerVector;\r
+        const jsize lenInner = env->GetArrayLength(jInnerArray);\r
+        for (jsize i = 0; i < lenInner; ++i)\r
+        {\r
+            innerVector.push_back(static_cast<int>(ints[i]));\r
+        }\r
+        env->ReleaseIntArrayElements(jInnerArray, ints, JNI_ABORT);\r
+        env->DeleteLocalRef(jInnerArray);\r
+        value.push_back(innerVector);\r
+    }\r
+\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return;\r
+\r
+    std::string key = env->GetStringUTFChars(jKey, NULL);\r
+    rep->setValue(key, value);\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    setValueInteger3DArray\r
+* Signature: (Ljava/lang/String;[[[I)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueInteger3DArray\r
+(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)\r
+{\r
+    LOGD("OcRepresentation_setValueInteger3DArray");\r
+    if (!jKey)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
+        return;\r
+    }\r
+    std::vector<std::vector<std::vector<int>>> value;\r
+    const jsize lenOuter = env->GetArrayLength(jValue);\r
+    for (jsize k = 0; k < lenOuter; ++k)\r
+    {\r
+        jobjectArray jMiddleArray = static_cast<jobjectArray>(env->GetObjectArrayElement(jValue, k));\r
+        const jsize lenMiddle = env->GetArrayLength(jMiddleArray);\r
+        std::vector<std::vector<int>> middleArray;\r
+        for (jsize j = 0; j < lenMiddle; ++j)\r
+        {\r
+            jintArray jInnerArray = static_cast<jintArray>(env->GetObjectArrayElement(jMiddleArray, j));\r
+            jint* ints = env->GetIntArrayElements(jInnerArray, NULL);\r
+            std::vector<int> innerVector;\r
+            const jsize lenInner = env->GetArrayLength(jInnerArray);\r
+            for (jsize i = 0; i < lenInner; ++i)\r
+            {\r
+                innerVector.push_back(static_cast<int>(ints[i]));\r
+            }\r
+            env->ReleaseIntArrayElements(jInnerArray, ints, JNI_ABORT);\r
+            env->DeleteLocalRef(jInnerArray);\r
+            middleArray.push_back(innerVector);\r
+        }\r
+        env->DeleteLocalRef(jMiddleArray);\r
+        value.push_back(middleArray);\r
+    }\r
+\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return;\r
+\r
+    std::string key = env->GetStringUTFChars(jKey, NULL);\r
+    rep->setValue(key, value);\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    setValueDoubleArray\r
+* Signature: (Ljava/lang/String;[D)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDoubleArray\r
+(JNIEnv *env, jobject thiz, jstring jKey, jdoubleArray jValue)\r
+{\r
+    LOGD("OcRepresentation_setValueDoubleArray");\r
+    if (!jKey)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
+        return;\r
+    }\r
+\r
+    const jsize len = env->GetArrayLength(jValue);\r
+    jdouble* doubles = env->GetDoubleArrayElements(jValue, NULL);\r
+\r
+    std::vector<double> value;\r
+    for (jsize i = 0; i < len; ++i)\r
+    {\r
+        value.push_back(static_cast<double>(doubles[i]));\r
+    }\r
+    env->ReleaseDoubleArrayElements(jValue, doubles, JNI_ABORT);\r
+\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return;\r
+\r
+    std::string key = env->GetStringUTFChars(jKey, NULL);\r
+    rep->setValue(key, value);\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    setValueDouble2DArray\r
+* Signature: (Ljava/lang/String;[[D)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDouble2DArray\r
+(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)\r
+{\r
+    LOGD("OcRepresentation_setValueDouble2DArray");\r
+    if (!jKey)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
+        return;\r
+    }\r
+    std::vector<std::vector<double>> value;\r
+    const jsize lenOuter = env->GetArrayLength(jValue);\r
+    for (jsize j = 0; j < lenOuter; ++j)\r
+    {\r
+        jdoubleArray jInnerArray = static_cast<jdoubleArray>(env->GetObjectArrayElement(jValue, j));\r
+        jdouble* doubles = env->GetDoubleArrayElements(jInnerArray, NULL);\r
+        std::vector<double> innerVector;\r
+        const jsize lenInner = env->GetArrayLength(jInnerArray);\r
+        for (jsize i = 0; i < lenInner; ++i)\r
+        {\r
+            innerVector.push_back(static_cast<double>(doubles[i]));\r
+        }\r
+        env->ReleaseDoubleArrayElements(jInnerArray, doubles, JNI_ABORT);\r
+        env->DeleteLocalRef(jInnerArray);\r
+        value.push_back(innerVector);\r
+    }\r
+\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return;\r
+\r
+    std::string key = env->GetStringUTFChars(jKey, NULL);\r
+    rep->setValue(key, value);\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    setValueDouble3DArray\r
+* Signature: (Ljava/lang/String;[[[D)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDouble3DArray\r
+(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)\r
+{\r
+    LOGD("OcRepresentation_setValueDouble3DArray");\r
+    if (!jKey)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
+        return;\r
+    }\r
+    std::vector<std::vector<std::vector<double>>> value;\r
+    const jsize lenOuter = env->GetArrayLength(jValue);\r
+    for (jsize k = 0; k < lenOuter; ++k)\r
+    {\r
+        jobjectArray jMiddleArray = static_cast<jobjectArray>(env->GetObjectArrayElement(jValue, k));\r
+        const jsize lenMiddle = env->GetArrayLength(jMiddleArray);\r
+        std::vector<std::vector<double>> middleArray;\r
+        for (jsize j = 0; j < lenMiddle; ++j)\r
+        {\r
+            jdoubleArray jInnerArray = static_cast<jdoubleArray>(env->GetObjectArrayElement(jMiddleArray, j));\r
+            jdouble* doubles = env->GetDoubleArrayElements(jInnerArray, NULL);\r
+            std::vector<double> innerVector;\r
+            const jsize lenInner = env->GetArrayLength(jInnerArray);\r
+            for (jsize i = 0; i < lenInner; ++i)\r
+            {\r
+                innerVector.push_back(static_cast<double>(doubles[i]));\r
+            }\r
+            env->ReleaseDoubleArrayElements(jInnerArray, doubles, JNI_ABORT);\r
+            env->DeleteLocalRef(jInnerArray);\r
+            middleArray.push_back(innerVector);\r
+        }\r
+        env->DeleteLocalRef(jMiddleArray);\r
+        value.push_back(middleArray);\r
+    }\r
+\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return;\r
+\r
+    std::string key = env->GetStringUTFChars(jKey, NULL);\r
+    rep->setValue(key, value);\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    setValueBooleanArray\r
+* Signature: (Ljava/lang/String;[Z)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBooleanArray\r
+(JNIEnv *env, jobject thiz, jstring jKey, jbooleanArray jValue)\r
+{\r
+    LOGD("OcRepresentation_setValueBooleanArray");\r
+    if (!jKey)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
+        return;\r
+    }\r
+\r
+    const jsize len = env->GetArrayLength(jValue);\r
+    jboolean* booleans = env->GetBooleanArrayElements(jValue, NULL);\r
+\r
+    std::vector<bool> value;\r
+    for (jsize i = 0; i < len; ++i)\r
+    {\r
+        value.push_back(static_cast<bool>(booleans[i]));\r
+    }\r
+    env->ReleaseBooleanArrayElements(jValue, booleans, JNI_ABORT);\r
+\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return;\r
+\r
+    std::string key = env->GetStringUTFChars(jKey, NULL);\r
+    rep->setValue(key, value);\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    setValueBoolean2DArray\r
+* Signature: (Ljava/lang/String;[[Z)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBoolean2DArray\r
+(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)\r
+{\r
+    LOGD("OcRepresentation_setValueBoolean2DArray");\r
+    if (!jKey)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
+        return;\r
+    }\r
+    std::vector<std::vector<bool>> value;\r
+    const jsize lenOuter = env->GetArrayLength(jValue);\r
+    for (jsize j = 0; j < lenOuter; ++j)\r
+    {\r
+        jbooleanArray jInnerArray = static_cast<jbooleanArray>(env->GetObjectArrayElement(jValue, j));\r
+        const jsize lenInner = env->GetArrayLength(jInnerArray);\r
+        jboolean* booleans = env->GetBooleanArrayElements(jInnerArray, NULL);\r
+\r
+        std::vector<bool> innerVector;\r
+        for (jsize i = 0; i < lenInner; ++i)\r
+        {\r
+            innerVector.push_back(static_cast<bool>(booleans[i]));\r
+        }\r
+        env->ReleaseBooleanArrayElements(jInnerArray, booleans, JNI_ABORT);\r
+        env->DeleteLocalRef(jInnerArray);\r
+        value.push_back(innerVector);\r
+    }\r
+\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return;\r
+\r
+    std::string key = env->GetStringUTFChars(jKey, NULL);\r
+    rep->setValue(key, value);\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    setValueBoolean3DArray\r
+* Signature: (Ljava/lang/String;[[[Z)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBoolean3DArray\r
+(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)\r
+{\r
+    LOGD("OcRepresentation_setValueBoolean3DArray");\r
+    if (!jKey)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
+        return;\r
+    }\r
+    std::vector<std::vector<std::vector<bool>>> value;\r
+    const jsize lenOuter = env->GetArrayLength(jValue);\r
+    for (jsize k = 0; k < lenOuter; ++k)\r
+    {\r
+        jobjectArray jMiddleArray = static_cast<jobjectArray>(env->GetObjectArrayElement(jValue, k));\r
+        const jsize lenMiddle = env->GetArrayLength(jMiddleArray);\r
+        std::vector<std::vector<bool>> middleArray;\r
+        for (jsize j = 0; j < lenMiddle; ++j)\r
+        {\r
+            jbooleanArray jInnerArray = static_cast<jbooleanArray>(env->GetObjectArrayElement(jMiddleArray, j));\r
+            const jsize lenInner = env->GetArrayLength(jInnerArray);\r
+            jboolean* booleans = env->GetBooleanArrayElements(jInnerArray, NULL);\r
+\r
+            std::vector<bool> innerVector;\r
+            for (jsize i = 0; i < lenInner; ++i)\r
+            {\r
+                innerVector.push_back(static_cast<bool>(booleans[i]));\r
+            }\r
+            env->ReleaseBooleanArrayElements(jInnerArray, booleans, JNI_ABORT);\r
+            env->DeleteLocalRef(jInnerArray);\r
+            middleArray.push_back(innerVector);\r
+        }\r
+        env->DeleteLocalRef(jMiddleArray);\r
+        value.push_back(middleArray);\r
+    }\r
+\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return;\r
+\r
+    std::string key = env->GetStringUTFChars(jKey, NULL);\r
+    rep->setValue(key, value);\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    setValueStringArray\r
+* Signature: (Ljava/lang/String;[Ljava/lang/String;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueStringArray\r
+(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)\r
+{\r
+    LOGD("OcRepresentation_setValueStringArray");\r
+    if (!jKey)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
+        return;\r
+    }\r
+\r
+    std::vector<std::string> value;\r
+    JniUtils::convertJavaStrArrToStrVector(env, jValue, value);\r
+\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return;\r
+\r
+    std::string key = env->GetStringUTFChars(jKey, NULL);\r
+    rep->setValue(key, value);\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    setValueString2DArray\r
+* Signature: (Ljava/lang/String;[[Ljava/lang/String;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueString2DArray\r
+(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)\r
+{\r
+    LOGD("OcRepresentation_setValueString2DArray");\r
+    if (!jKey)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
+        return;\r
+    }\r
+    std::vector<std::vector<std::string>> value;\r
+    const jsize lenOuter = env->GetArrayLength(jValue);\r
+    for (jsize j = 0; j < lenOuter; ++j)\r
+    {\r
+        jobjectArray jInnerArray = static_cast<jobjectArray>(env->GetObjectArrayElement(jValue, j));\r
+        std::vector<std::string> innerVector;\r
+        JniUtils::convertJavaStrArrToStrVector(env, jInnerArray, innerVector);\r
+        env->DeleteLocalRef(jInnerArray);\r
+        value.push_back(innerVector);\r
+    }\r
+\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return;\r
+\r
+    std::string key = env->GetStringUTFChars(jKey, NULL);\r
+    rep->setValue(key, value);\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    setValueString3DArray\r
+* Signature: (Ljava/lang/String;[[[Ljava/lang/String;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueString3DArray\r
+(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)\r
+{\r
+    LOGD("OcRepresentation_setValueString3DArray");\r
+    if (!jKey)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
+        return;\r
+    }\r
+    std::vector<std::vector<std::vector<std::string>>> value;\r
+    const jsize lenOuter = env->GetArrayLength(jValue);\r
+    for (jsize k = 0; k < lenOuter; ++k)\r
+    {\r
+        jobjectArray jMiddleArray = static_cast<jobjectArray>(env->GetObjectArrayElement(jValue, k));\r
+        const jsize lenMiddle = env->GetArrayLength(jMiddleArray);\r
+        std::vector<std::vector<std::string>> middleArray;\r
+        for (jsize j = 0; j < lenMiddle; ++j)\r
+        {\r
+            jobjectArray jInnerArray = static_cast<jobjectArray>(env->GetObjectArrayElement(jMiddleArray, j));\r
+            std::vector<std::string> innerVector;\r
+            JniUtils::convertJavaStrArrToStrVector(env, jInnerArray, innerVector);\r
+            env->DeleteLocalRef(jInnerArray);\r
+            middleArray.push_back(innerVector);\r
+        }\r
+        env->DeleteLocalRef(jMiddleArray);\r
+        value.push_back(middleArray);\r
+    }\r
+\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return;\r
+\r
+    std::string key = env->GetStringUTFChars(jKey, NULL);\r
+    rep->setValue(key, value);\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    setValueRepresentationArray\r
+* Signature: (Ljava/lang/String;[Lorg/iotivity/base/OcRepresentation;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresentationArray\r
+(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)\r
+{\r
+    LOGD("OcRepresentation_setValueRepresentationArray");\r
+    if (!jKey)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
+        return;\r
+    }\r
+\r
+    std::vector<OCRepresentation> value;\r
+    JniUtils::convertJavaRepresentationArrToVector(env, jValue, value);\r
+\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return;\r
+\r
+    std::string key = env->GetStringUTFChars(jKey, NULL);\r
+    rep->setValue(key, value);\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    setValueRepresentation2DArray\r
+* Signature: (Ljava/lang/String;[[Lorg/iotivity/base/OcRepresentation;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresentation2DArray\r
+(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)\r
+{\r
+    LOGD("OcRepresentation_setValueRepresentation2DArray");\r
+    if (!jKey)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
+        return;\r
+    }\r
+    std::vector<std::vector<OCRepresentation>> value;\r
+    const jsize lenOuter = env->GetArrayLength(jValue);\r
+    for (jsize j = 0; j < lenOuter; ++j)\r
+    {\r
+        jobjectArray jInnerArray = static_cast<jobjectArray>(env->GetObjectArrayElement(jValue, j));\r
+        std::vector<OCRepresentation> innerVector;\r
+        JniUtils::convertJavaRepresentationArrToVector(env, jInnerArray, innerVector);\r
+        env->DeleteLocalRef(jInnerArray);\r
+        value.push_back(innerVector);\r
+    }\r
+\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return;\r
+\r
+    std::string key = env->GetStringUTFChars(jKey, NULL);\r
+    rep->setValue(key, value);\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    setValueRepresentation3DArray\r
+* Signature: (Ljava/lang/String;[[[Lorg/iotivity/base/OcRepresentation;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresentation3DArray\r
+(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)\r
+{\r
+    LOGD("OcRepresentation_setValueRepresentation3DArray");\r
+    if (!jKey)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
+        return;\r
+    }\r
+    std::vector<std::vector<std::vector<OCRepresentation>>> value;\r
+    const jsize lenOuter = env->GetArrayLength(jValue);\r
+    for (jsize k = 0; k < lenOuter; ++k)\r
+    {\r
+        jobjectArray jMiddleArray = static_cast<jobjectArray>(env->GetObjectArrayElement(jValue, k));\r
+        const jsize lenMiddle = env->GetArrayLength(jMiddleArray);\r
+        std::vector<std::vector<OCRepresentation>> middleArray;\r
+        for (jsize j = 0; j < lenMiddle; ++j)\r
+        {\r
+            jobjectArray jInnerArray = static_cast<jobjectArray>(env->GetObjectArrayElement(jMiddleArray, j));\r
+            std::vector<OCRepresentation> innerVector;\r
+            JniUtils::convertJavaRepresentationArrToVector(env, jInnerArray, innerVector);\r
+            env->DeleteLocalRef(jInnerArray);\r
+            middleArray.push_back(innerVector);\r
+        }\r
+        env->DeleteLocalRef(jMiddleArray);\r
+        value.push_back(middleArray);\r
+    }\r
+\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return;\r
+\r
+    std::string key = env->GetStringUTFChars(jKey, NULL);\r
+    rep->setValue(key, value);\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    getJSONRepresentation\r
+* Signature: ()Ljava/lang/String;\r
+*/\r
+JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcRepresentation_getJSONRepresentation\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcRepresentation_getJSONRepresentation");\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return nullptr;\r
+\r
+    std::string jsonStr = rep->getJSONRepresentation();\r
+    return env->NewStringUTF(jsonStr.c_str());\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    addChild\r
+* Signature: (Lorg/iotivity/base/OcRepresentation;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_addChild\r
+(JNIEnv *env, jobject thiz, jobject jOcRepresentation)\r
+{\r
+    LOGD("OcRepresentation_addChild");\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return;\r
+\r
+    OCRepresentation *child = JniOcRepresentation::getOCRepresentationPtr(env, jOcRepresentation);\r
+    if (!child) return;\r
+\r
+    rep->addChild(*child);\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    clearChildren\r
+* Signature: ()V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_clearChildren\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcRepresentation_clearChildren");\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return;\r
+\r
+    rep->clearChildren();\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    getChildrenArray\r
+* Signature: ()[Lorg/iotivity/base/OcRepresentation;\r
+*/\r
+JNIEXPORT jobjectArray JNICALL Java_org_iotivity_base_OcRepresentation_getChildrenArray\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcRepresentation_getChildrenArray");\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return nullptr;\r
+\r
+    return JniUtils::convertRepresentationVectorToJavaArray(env, rep->getChildren());\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    getUri\r
+* Signature: ()Ljava/lang/String;\r
+*/\r
+JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcRepresentation_getUri\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcRepresentation_getUri");\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return nullptr;\r
+\r
+    std::string uri(rep->getUri());\r
+    return env->NewStringUTF(uri.c_str());\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    setUri\r
+* Signature: (Ljava/lang/String;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setUri\r
+(JNIEnv *env, jobject thiz, jstring jUri)\r
+{\r
+    LOGD("OcRepresentation_setUri");\r
+    if (!jUri)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "uri cannot be null");\r
+        return;\r
+    }\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return;\r
+\r
+    rep->setUri(env->GetStringUTFChars(jUri, NULL));\r
+}\r
+\r
+JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_hasAttribute\r
+(JNIEnv *env, jobject thiz, jstring jstr)\r
+{\r
+    LOGD("OcRepresentation_hasAttribute");\r
+    if (!jstr)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "attributeKey cannot be null");\r
+        return false;\r
+    }\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return false;\r
+\r
+    std::string str = env->GetStringUTFChars(jstr, NULL);\r
+    return rep->hasAttribute(str);\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    getResourceTypes\r
+* Signature: ()Ljava/util/List;\r
+*/\r
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcRepresentation_getResourceTypes\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcRepresentation_getResourceTypes");\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return nullptr;\r
+\r
+    std::vector<std::string> resourceTypes = rep->getResourceTypes();\r
+    return JniUtils::convertStrVectorToJavaStrList(env, resourceTypes);\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    setResourceTypeArray\r
+* Signature: ([Ljava/lang/String;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setResourceTypeArray\r
+(JNIEnv *env, jobject thiz, jobjectArray jResourceTypeArray)\r
+{\r
+    LOGD("OcRepresentation_setResourceTypeArray");\r
+    if (!jResourceTypeArray)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceTypeList cannot be null");\r
+        return;\r
+    }\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return;\r
+\r
+    std::vector<std::string> resourceTypes;\r
+    JniUtils::convertJavaStrArrToStrVector(env, jResourceTypeArray, resourceTypes);\r
+    rep->setResourceTypes(resourceTypes);\r
+}\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    getResourceInterfaces\r
+* Signature: ()Ljava/util/List;\r
+*/\r
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcRepresentation_getResourceInterfaces\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcRepresentation_getResourceInterfaces");\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return nullptr;\r
+\r
+    std::vector<std::string> resourceInterfaces = rep->getResourceInterfaces();\r
+    return JniUtils::convertStrVectorToJavaStrList(env, resourceInterfaces);\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    setResourceInterfaceArray\r
+* Signature: ([Ljava/lang/String;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setResourceInterfaceArray\r
+(JNIEnv *env, jobject thiz, jobjectArray jResourceInterfaceArray)\r
+{\r
+    LOGD("OcRepresentation_setResourceInterfaceArray");\r
+    if (!jResourceInterfaceArray)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceInterfaceList cannot be null");\r
+        return;\r
+    }\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return;\r
+\r
+    std::vector<std::string> resourceInterfaces;\r
+    JniUtils::convertJavaStrArrToStrVector(env, jResourceInterfaceArray, resourceInterfaces);\r
+    rep->setResourceInterfaces(resourceInterfaces);\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    isEmpty\r
+* Signature: ()Z\r
+*/\r
+JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_isEmpty\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcRepresentation_isEmpty");\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return false;\r
+\r
+    return static_cast<jboolean>(rep->empty());\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    size\r
+* Signature: ()I\r
+*/\r
+JNIEXPORT jint JNICALL Java_org_iotivity_base_OcRepresentation_size\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcRepresentation_size");\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return -1;\r
+\r
+    return static_cast<jint>(rep->numberOfAttributes());\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    remove\r
+* Signature: (Ljava/lang/String;)Z\r
+*/\r
+JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_remove\r
+(JNIEnv *env, jobject thiz, jstring jAttributeKey)\r
+{\r
+    LOGD("OcRepresentation_remove");\r
+    if (!jAttributeKey)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "attributeKey cannot be null");\r
+        return false;\r
+    }\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return false;\r
+\r
+    std::string attributeKey = env->GetStringUTFChars(jAttributeKey, NULL);\r
+    return static_cast<jboolean>(rep->erase(attributeKey));\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    setNull\r
+* Signature: (Ljava/lang/String;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setNull\r
+(JNIEnv *env, jobject thiz, jstring jAttributeKey)\r
+{\r
+    LOGD("OcRepresentation_setNull");\r
+    if (!jAttributeKey)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "attributeKey cannot be null");\r
+        return;\r
+    }\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return;\r
+\r
+    std::string attributeKey = env->GetStringUTFChars(jAttributeKey, NULL);\r
+    rep->setNULL(attributeKey);\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    isNull\r
+* Signature: (Ljava/lang/String;)Z\r
+*/\r
+JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_isNull\r
+(JNIEnv *env, jobject thiz, jstring jAttributeKey)\r
+{\r
+    LOGD("OcRepresentation_isNull");\r
+    if (!jAttributeKey)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "attributeKey cannot be null");\r
+        return false;\r
+    }\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+    if (!rep) return false;\r
+\r
+    std::string attributeKey = env->GetStringUTFChars(jAttributeKey, NULL);\r
+    return static_cast<jboolean>(rep->isNULL(attributeKey));\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    create\r
+* Signature: ()V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_create\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcRepresentation_create");\r
+    OCRepresentation *rep = new OCRepresentation();\r
+    SetHandle<OCRepresentation>(env, thiz, rep);\r
+    if (env->ExceptionCheck())\r
+    {\r
+        LOGE("Failed to set native handle for OcRepresentation");\r
+        delete rep;\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRepresentation\r
+* Method:    dispose\r
+* Signature: ()V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_dispose\r
+(JNIEnv *env, jobject thiz, jboolean jNeedsDelete)\r
+{\r
+    LOGD("OcRepresentation_dispose");\r
+    OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
+\r
+    if (jNeedsDelete)\r
+    {\r
+        delete rep;\r
+    }\r
+}
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniOcRepresentation.h b/android/android_api/base/jni/JniOcRepresentation.h
new file mode 100644 (file)
index 0000000..3f25c29
--- /dev/null
@@ -0,0 +1,769 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniOcStack.h"\r
+#include <AttributeValue.h>\r
+\r
+#ifndef _Included_org_iotivity_base_OcRepresentation\r
+#define _Included_org_iotivity_base_OcRepresentation\r
+\r
+using namespace OC;\r
+\r
+class JniOcRepresentation\r
+{\r
+public:\r
+    static OCRepresentation* getOCRepresentationPtr(JNIEnv *env, jobject thiz);\r
+};\r
+\r
+struct JObjectConverter : boost::static_visitor < jobject >\r
+{\r
+    JObjectConverter(JNIEnv *env) : env(env){}\r
+\r
+    jobject operator()(const NullType&) const { return nullptr; }
+    jobject operator()(const int& val) const
+    {
+        jobject jobj = env->NewObject(
+            g_cls_Integer,
+            g_mid_Integer_ctor,
+            static_cast<jint>(val));
+        return jobj;
+    }
+    jobject operator()(const double& val) const
+    {
+        jobject jobj = env->NewObject(
+            g_cls_Double,
+            g_mid_Double_ctor,
+            static_cast<jdouble>(val));
+        return jobj;
+    }
+    jobject operator()(const bool& val) const
+    {
+        jobject jobj = env->NewObject(
+            g_cls_Boolean,
+            g_mid_Boolean_ctor,
+            static_cast<jboolean>(val));
+        return jobj;
+    }
+    jobject operator()(const std::string& val) const
+    {
+        jstring jstr = env->NewStringUTF(val.c_str());
+        return static_cast<jobject>(jstr);
+    }
+    jobject operator()(const OC::OCRepresentation& val) const
+    {
+        OCRepresentation * rep = new OCRepresentation(val);\r
+        jlong handle = reinterpret_cast<jlong>(rep);\r
+        jobject jRepresentation = env->NewObject(
+            g_cls_OcRepresentation,
+            g_mid_OcRepresentation_N_ctor_bool,
+            handle, true);
+        if (!jRepresentation)
+        {
+            delete rep;
+        }
+        return jRepresentation;
+    }
+
+    // Sequences:
+    jobject operator()(const std::vector<int>& val) const
+    {
+        size_t len = val.size();
+        jintArray jIntArray = env->NewIntArray(len);\r
+        if (!jIntArray) return nullptr;\r
+        const int* ints = &val[0];\r
+        env->SetIntArrayRegion(jIntArray, 0, len, reinterpret_cast<const jint*>(ints));
+        return jIntArray;
+    }
+    jobject operator()(const std::vector<double>& val) const
+    {
+        size_t len = val.size();
+        jdoubleArray jDoubleArray = env->NewDoubleArray(len);\r
+        if (!jDoubleArray) return nullptr;\r
+        const double* doubles = &val[0];\r
+        env->SetDoubleArrayRegion(jDoubleArray, 0, len, reinterpret_cast<const jdouble*>(doubles));
+        return jDoubleArray;
+    }
+    jobject operator()(const std::vector<bool>& val) const
+    {
+        size_t len = val.size();
+        jbooleanArray jBooleanArray = env->NewBooleanArray(len);\r
+        if (!jBooleanArray) return nullptr;\r
+        jboolean* booleans = new jboolean[len];\r
+        for (size_t i = 0; i < len; ++i) {\r
+            booleans[i] = static_cast<jboolean>(val[i]);\r
+        }\r
+        env->SetBooleanArrayRegion(jBooleanArray, 0, len, booleans);
+        if (env->ExceptionCheck()) return nullptr;
+        env->ReleaseBooleanArrayElements(jBooleanArray, booleans, 0);
+        return jBooleanArray;
+    }
+    jobject operator()(const std::vector<std::string>& val) const
+    {
+        size_t len = val.size();\r
+        jobjectArray strArr = env->NewObjectArray(len, g_cls_String, NULL);\r
+        if (!strArr) return nullptr;\r
+        for (size_t i = 0; i < len; ++i)\r
+        {\r
+            jstring jString = env->NewStringUTF(val[i].c_str());\r
+            env->SetObjectArrayElement(strArr, static_cast<jsize>(i), jString);\r
+            if (env->ExceptionCheck()) return nullptr;\r
+            env->DeleteLocalRef(jString);\r
+        }\r
+        return strArr;
+    }
+    jobject operator()(const std::vector<OC::OCRepresentation>& val) const
+    {
+        jsize len = static_cast<jsize>(val.size());\r
+        jobjectArray repArr = env->NewObjectArray(len, g_cls_OcRepresentation, NULL);\r
+        if (!repArr) return nullptr;\r
+        for (jsize i = 0; i < len; ++i)\r
+        {\r
+            OCRepresentation* rep = new OCRepresentation(val[i]);\r
+            jlong handle = reinterpret_cast<jlong>(rep);\r
+            jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool,\r
+                handle, true);\r
+            if (!jRepresentation)\r
+            {\r
+                delete rep;\r
+                return nullptr;\r
+            }\r
+            env->SetObjectArrayElement(repArr, i, jRepresentation);\r
+            if (env->ExceptionCheck())\r
+            {\r
+                delete rep;\r
+                return nullptr;\r
+            }\r
+            env->DeleteLocalRef(jRepresentation);\r
+        }\r
+        return repArr;
+    }
+
+    // Nested sequences:
+    jobject operator()(const std::vector<std::vector<int>>& val) const
+    {
+        jsize lenOuter = static_cast<jsize>(val.size());\r
+        jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_int1DArray, NULL);\r
+        if (!jOuterArr)
+        {
+            return nullptr;
+        }\r
+        for (jsize i = 0; i < lenOuter; ++i)\r
+        {
+            size_t lenInner = val[i].size();
+            jintArray jIntArray = env->NewIntArray(lenInner);\r
+            if (!jIntArray) return nullptr;\r
+            const int* ints = &val[i][0];\r
+            env->SetIntArrayRegion(jIntArray, 0, lenInner, reinterpret_cast<const jint*>(ints));
+            if (env->ExceptionCheck()) return nullptr;
+            env->SetObjectArrayElement(jOuterArr, i, static_cast<jobject>(jIntArray));
+            if (env->ExceptionCheck()) return nullptr;
+            env->DeleteLocalRef(jIntArray);
+        }
+        return jOuterArr;
+    }
+    jobject operator()(const std::vector<std::vector<std::vector<int>>>& val) const
+    {
+        jsize lenOuter = static_cast<jsize>(val.size());\r
+        jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_int2DArray, NULL);\r
+        if (!jOuterArr) return nullptr;\r
+        for (jsize k = 0; k < lenOuter; ++k)\r
+        {\r
+            jsize lenMiddle = static_cast<jsize>(val[k].size());\r
+            jobjectArray jMiddleArr = env->NewObjectArray(lenMiddle, g_cls_int1DArray, NULL);\r
+            if (!jMiddleArr) return nullptr;\r
+            for (jsize i = 0; i < lenMiddle; ++i)\r
+            {
+                jsize lenInner = static_cast<jsize>(val[k][i].size());
+                jintArray jIntArray = env->NewIntArray(lenInner);\r
+                if (!jIntArray) return nullptr;\r
+                const int* ints = &val[k][i][0];\r
+                env->SetIntArrayRegion(jIntArray, 0, lenInner, reinterpret_cast<const jint*>(ints));
+                if (env->ExceptionCheck()) return nullptr;
+                env->SetObjectArrayElement(jMiddleArr, i, jIntArray);
+                if (env->ExceptionCheck()) return nullptr;
+                env->DeleteLocalRef(jIntArray);
+            }
+            env->SetObjectArrayElement(jOuterArr, k, jMiddleArr);
+            if (env->ExceptionCheck()) return nullptr;
+            env->DeleteLocalRef(jMiddleArr);
+        }
+        return jOuterArr;
+    }
+
+    jobject operator()(const std::vector<std::vector<double>>& val) const
+    {
+        jsize lenOuter = static_cast<jsize>(val.size());\r
+        jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_double1DArray, NULL);\r
+        if (!jOuterArr) return nullptr;\r
+        for (jsize i = 0; i < lenOuter; ++i)\r
+        {
+            size_t lenInner = val[i].size();
+            jdoubleArray jDoubleArray = env->NewDoubleArray(lenInner);\r
+            if (!jDoubleArray) return nullptr;\r
+            const double* doubles = &val[i][0];\r
+            env->SetDoubleArrayRegion(jDoubleArray, 0, lenInner, reinterpret_cast<const jdouble*>(doubles));
+            if (env->ExceptionCheck()) return nullptr;
+            env->SetObjectArrayElement(jOuterArr, i, jDoubleArray);
+            if (env->ExceptionCheck()) return nullptr;
+            env->DeleteLocalRef(jDoubleArray);
+        }
+
+        return jOuterArr;
+    }
+    jobject operator()(const std::vector<std::vector<std::vector<double>>>& val) const
+    {
+        jsize lenOuter = static_cast<jsize>(val.size());\r
+        jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_double2DArray, NULL);\r
+        if (!jOuterArr) return nullptr;\r
+        for (jsize k = 0; k < lenOuter; ++k)\r
+        {\r
+            jsize lenMiddle = static_cast<jsize>(val[k].size());\r
+            jobjectArray jMiddleArr = env->NewObjectArray(lenMiddle, g_cls_double1DArray, NULL);\r
+            if (!jMiddleArr) return nullptr;\r
+            for (jsize i = 0; i < lenMiddle; ++i)\r
+            {
+                jsize lenInner = static_cast<jsize>(val[k][i].size());
+                jdoubleArray jDoubleArray = env->NewDoubleArray(lenInner);\r
+                if (!jDoubleArray) return nullptr;\r
+                const double* doubles = &val[k][i][0];\r
+                env->SetDoubleArrayRegion(jDoubleArray, 0, lenInner, reinterpret_cast<const jdouble*>(doubles));
+                if (env->ExceptionCheck()) return nullptr;
+                env->SetObjectArrayElement(jMiddleArr, i, jDoubleArray);
+                if (env->ExceptionCheck()) return nullptr;
+                env->DeleteLocalRef(jDoubleArray);
+            }
+            env->SetObjectArrayElement(jOuterArr, k, jMiddleArr);
+            if (env->ExceptionCheck()) return nullptr;
+            env->DeleteLocalRef(jMiddleArr);
+        }
+        return jOuterArr;
+    }
+
+    jobject operator()(const std::vector<std::vector<bool>>& val) const
+    {
+        jsize lenOuter = static_cast<jsize>(val.size());\r
+        jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_boolean1DArray, 0);\r
+        if (!jOuterArr) return nullptr;\r
+        for (jsize i = 0; i < lenOuter; ++i)\r
+        {
+            size_t lenInner = val[i].size();
+            jbooleanArray jBooleanArray = env->NewBooleanArray(lenInner);\r
+            if (!jBooleanArray) return nullptr;\r
+            jboolean* booleans = new jboolean[lenInner];\r
+            for (size_t j = 0; j < lenInner; ++j) {\r
+                booleans[j] = static_cast<jboolean>(val[i][j]);\r
+            }\r
+            env->SetBooleanArrayRegion(jBooleanArray, 0, lenInner, booleans);
+            if (env->ExceptionCheck()) return nullptr;
+            env->SetObjectArrayElement(jOuterArr, i, jBooleanArray);
+            if (env->ExceptionCheck()) return nullptr;
+            env->ReleaseBooleanArrayElements(jBooleanArray, booleans, 0);
+            if (env->ExceptionCheck()) return nullptr;
+            env->DeleteLocalRef(jBooleanArray);
+        }
+        return jOuterArr;
+    }
+    jobject operator()(const std::vector<std::vector<std::vector<bool>>>& val) const
+    {
+        jsize lenOuter = static_cast<jsize>(val.size());\r
+        jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_boolean2DArray, NULL);\r
+        if (!jOuterArr) return nullptr;\r
+        for (jsize k = 0; k < lenOuter; ++k)\r
+        {\r
+            jsize lenMiddle = static_cast<jsize>(val[k].size());\r
+            jobjectArray jMiddleArr = env->NewObjectArray(lenMiddle, g_cls_boolean1DArray, NULL);\r
+            if (!jMiddleArr) return nullptr;\r
+            for (jsize i = 0; i < lenMiddle; ++i)\r
+            {
+                size_t lenInner = val[k][i].size();
+                jbooleanArray jBooleanArray = env->NewBooleanArray(lenInner);\r
+                jboolean* booleans = new jboolean[lenInner];\r
+                for (size_t j = 0; j < lenInner; ++j) {\r
+                    booleans[j] = val[k][i][j];\r
+                }\r
+                env->SetBooleanArrayRegion(jBooleanArray, 0, lenInner, booleans);
+                if (env->ExceptionCheck()) return nullptr;
+                env->SetObjectArrayElement(jMiddleArr, i, jBooleanArray);\r
+                if (env->ExceptionCheck()) return nullptr;\r
+                env->ReleaseBooleanArrayElements(jBooleanArray, booleans, 0);
+                if (env->ExceptionCheck()) return nullptr;
+                env->DeleteLocalRef(jBooleanArray);
+            }
+            env->SetObjectArrayElement(jOuterArr, k, jMiddleArr);
+            if (env->ExceptionCheck()) return nullptr;
+            env->DeleteLocalRef(jMiddleArr);
+        }
+        return jOuterArr;
+    }
+
+    jobject operator()(const std::vector<std::vector<std::string>>& val) const
+    {
+        jsize lenOuter = static_cast<jsize>(val.size());\r
+        jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_String1DArray, NULL);\r
+        if (!jOuterArr) return nullptr;\r
+        for (jsize i = 0; i < lenOuter; ++i)\r
+        {
+            jsize lenInner = static_cast<jsize>(val[i].size());\r
+            jobjectArray strArr = env->NewObjectArray(lenInner, g_cls_String, NULL);\r
+            if (!strArr) return nullptr;\r
+            for (jsize j = 0; j < lenInner; ++j)\r
+            {\r
+                jstring jString = env->NewStringUTF(val[i][j].c_str());\r
+                env->SetObjectArrayElement(strArr, j, jString);\r
+                if (env->ExceptionCheck()) return nullptr;\r
+                env->DeleteLocalRef(jString);\r
+            }
+            env->SetObjectArrayElement(jOuterArr, i, strArr);
+            if (env->ExceptionCheck()) return nullptr;
+            env->DeleteLocalRef(strArr);
+        }
+
+        return jOuterArr;
+    }
+    jobject operator()(const std::vector<std::vector<std::vector<std::string>>>& val) const
+    {
+        jsize lenOuter = static_cast<jsize>(val.size());\r
+        jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_String2DArray, NULL);\r
+        if (!jOuterArr) return nullptr;\r
+        for (jsize k = 0; k < lenOuter; ++k)\r
+        {\r
+            jsize lenMiddle = static_cast<jsize>(val[k].size());\r
+            jobjectArray jMiddleArr = env->NewObjectArray(lenMiddle, g_cls_String1DArray, NULL);\r
+            if (!jMiddleArr) return nullptr;\r
+            for (jsize i = 0; i < lenMiddle; ++i)\r
+            {
+                jsize lenInner = static_cast<jsize>(val[k][i].size());\r
+                jobjectArray strArr = env->NewObjectArray(lenInner, g_cls_String, NULL);\r
+                if (!strArr) return nullptr;\r
+                for (jsize j = 0; j < lenInner; ++j)\r
+                {\r
+                    jstring jString = env->NewStringUTF(val[k][i][j].c_str());\r
+                    env->SetObjectArrayElement(strArr, j, jString);\r
+                    if (env->ExceptionCheck()) return nullptr;\r
+                    env->DeleteLocalRef(jString);\r
+                }
+                env->SetObjectArrayElement(jMiddleArr, i, strArr);
+                if (env->ExceptionCheck()) return nullptr;
+                env->DeleteLocalRef(strArr);
+            }
+            env->SetObjectArrayElement(jOuterArr, k, jMiddleArr);
+            if (env->ExceptionCheck()) return nullptr;
+            env->DeleteLocalRef(jMiddleArr);
+        }
+        return jOuterArr;
+    }
+
+    jobject operator()(const std::vector<std::vector<OC::OCRepresentation>>& val) const
+    {
+        jsize lenOuter = static_cast<jsize>(val.size());\r
+        jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_OcRepresentation1DArray, NULL);\r
+        if (!jOuterArr) return nullptr;\r
+        for (jsize i = 0; i < lenOuter; ++i)\r
+        {
+            jsize lenInner = static_cast<jsize>(val[i].size());\r
+            jobjectArray repArr = env->NewObjectArray(lenInner, g_cls_OcRepresentation, NULL);\r
+            if (!repArr) return nullptr;\r
+            for (jsize j = 0; j < lenInner; ++j)\r
+            {\r
+                OCRepresentation* rep = new OCRepresentation(val[i][j]);\r
+                jlong handle = reinterpret_cast<jlong>(rep);\r
+                jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool,\r
+                    handle, true);\r
+                if (!jRepresentation)\r
+                {\r
+                    delete rep;\r
+                    return nullptr;\r
+                }\r
+                env->SetObjectArrayElement(repArr, j, jRepresentation);\r
+                if (env->ExceptionCheck()) return nullptr;\r
+                env->DeleteLocalRef(jRepresentation);\r
+            }
+            env->SetObjectArrayElement(jOuterArr, i, repArr);
+            if (env->ExceptionCheck()) return nullptr;
+            env->DeleteLocalRef(repArr);
+        }
+        return jOuterArr;
+    }
+    jobject operator()(const std::vector<std::vector<std::vector<OC::OCRepresentation>>>& val) const\r
+    {\r
+        jsize lenOuter = static_cast<jsize>(val.size());\r
+        jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_OcRepresentation2DArray, NULL);\r
+        if (!jOuterArr) return nullptr;\r
+        for (jsize k = 0; k < lenOuter; ++k)\r
+        {\r
+            jsize lenMiddle = static_cast<jsize>(val[k].size());\r
+            jobjectArray jMiddleArr = env->NewObjectArray(lenMiddle, g_cls_OcRepresentation1DArray, NULL);\r
+            if (!jMiddleArr) return nullptr;\r
+            for (jsize i = 0; i < lenMiddle; ++i)\r
+            {
+                jsize lenInner = static_cast<jsize>(val[k][i].size());\r
+                jobjectArray repArr = env->NewObjectArray(lenInner, g_cls_OcRepresentation, NULL);\r
+                if (!repArr) return nullptr;\r
+                for (jsize j = 0; j < lenInner; ++j)\r
+                {\r
+                    OCRepresentation* rep = new OCRepresentation(val[k][i][j]);\r
+                    jlong handle = reinterpret_cast<jlong>(rep);\r
+                    jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool,\r
+                        handle, true);\r
+                    if (!jRepresentation)\r
+                    {\r
+                        delete rep;\r
+                        return nullptr;\r
+                    }\r
+                    env->SetObjectArrayElement(repArr, j, jRepresentation);\r
+                    if (env->ExceptionCheck()) return nullptr;\r
+                    env->DeleteLocalRef(jRepresentation);\r
+                }
+                env->SetObjectArrayElement(jMiddleArr, i, repArr);
+                if (env->ExceptionCheck()) return nullptr;
+                env->DeleteLocalRef(repArr);
+            }
+            env->SetObjectArrayElement(jOuterArr, k, jMiddleArr);
+            if (env->ExceptionCheck()) return nullptr;
+            env->DeleteLocalRef(jMiddleArr);
+        }
+        return jOuterArr;\r
+    }\r
+\r
+private:\r
+    JNIEnv *env;\r
+};\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    getValueN\r
+    * Signature: (Ljava/lang/String;)Ljava/lang/Object;\r
+    */\r
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcRepresentation_getValueN\r
+        (JNIEnv *, jobject, jstring);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    setValueInteger\r
+    * Signature: (Ljava/lang/String;I)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueInteger\r
+        (JNIEnv *, jobject, jstring, jint);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    setValueDouble\r
+    * Signature: (Ljava/lang/String;D)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDouble\r
+        (JNIEnv *, jobject, jstring, jdouble);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    setValueBoolean\r
+    * Signature: (Ljava/lang/String;Z)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBoolean\r
+        (JNIEnv *, jobject, jstring, jboolean);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    setValueStringN\r
+    * Signature: (Ljava/lang/String;Ljava/lang/String;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueStringN\r
+        (JNIEnv *, jobject, jstring, jstring);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    setValueRepresentation\r
+    * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresentation\r
+        (JNIEnv *, jobject, jstring, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    setValueIntegerArray\r
+    * Signature: (Ljava/lang/String;[I)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueIntegerArray\r
+        (JNIEnv *, jobject, jstring, jintArray);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    setValueInteger2DArray\r
+    * Signature: (Ljava/lang/String;[[I)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueInteger2DArray\r
+        (JNIEnv *, jobject, jstring, jobjectArray);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    setValueInteger3DArray\r
+    * Signature: (Ljava/lang/String;[[[I)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueInteger3DArray\r
+        (JNIEnv *, jobject, jstring, jobjectArray);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    setValueDoubleArray\r
+    * Signature: (Ljava/lang/String;[D)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDoubleArray\r
+        (JNIEnv *, jobject, jstring, jdoubleArray);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    setValueDouble2DArray\r
+    * Signature: (Ljava/lang/String;[[D)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDouble2DArray\r
+        (JNIEnv *, jobject, jstring, jobjectArray);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    setValueDouble3DArray\r
+    * Signature: (Ljava/lang/String;[[[D)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDouble3DArray\r
+        (JNIEnv *, jobject, jstring, jobjectArray);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    setValueBooleanArray\r
+    * Signature: (Ljava/lang/String;[Z)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBooleanArray\r
+        (JNIEnv *, jobject, jstring, jbooleanArray);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    setValueBoolean2DArray\r
+    * Signature: (Ljava/lang/String;[[Z)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBoolean2DArray\r
+        (JNIEnv *, jobject, jstring, jobjectArray);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    setValueBoolean3DArray\r
+    * Signature: (Ljava/lang/String;[[[Z)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBoolean3DArray\r
+        (JNIEnv *, jobject, jstring, jobjectArray);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    setValueStringArray\r
+    * Signature: (Ljava/lang/String;[Ljava/lang/String;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueStringArray\r
+        (JNIEnv *, jobject, jstring, jobjectArray);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    setValueString2DArray\r
+    * Signature: (Ljava/lang/String;[[Ljava/lang/String;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueString2DArray\r
+        (JNIEnv *, jobject, jstring, jobjectArray);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    setValueString3DArray\r
+    * Signature: (Ljava/lang/String;[[[Ljava/lang/String;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueString3DArray\r
+        (JNIEnv *, jobject, jstring, jobjectArray);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    setValueRepresentationArray\r
+    * Signature: (Ljava/lang/String;[Lorg/iotivity/base/OcRepresentation;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresentationArray\r
+        (JNIEnv *, jobject, jstring, jobjectArray);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    setValueRepresentation2DArray\r
+    * Signature: (Ljava/lang/String;[[Lorg/iotivity/base/OcRepresentation;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresentation2DArray\r
+        (JNIEnv *, jobject, jstring, jobjectArray);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    setValueRepresentation3DArray\r
+    * Signature: (Ljava/lang/String;[[[Lorg/iotivity/base/OcRepresentation;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresentation3DArray\r
+        (JNIEnv *, jobject, jstring, jobjectArray);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    getJSONRepresentation\r
+    * Signature: ()Ljava/lang/String;\r
+    */\r
+    JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcRepresentation_getJSONRepresentation\r
+        (JNIEnv *, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    addChild\r
+    * Signature: (Lorg/iotivity/base/OcRepresentation;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_addChild\r
+        (JNIEnv *, jobject, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    clearChildren\r
+    * Signature: ()V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_clearChildren\r
+        (JNIEnv *, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    getChildrenArray\r
+    * Signature: ()[Lorg/iotivity/base/OcRepresentation;\r
+    */\r
+    JNIEXPORT jobjectArray JNICALL Java_org_iotivity_base_OcRepresentation_getChildrenArray\r
+        (JNIEnv *, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    getUri\r
+    * Signature: ()Ljava/lang/String;\r
+    */\r
+    JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcRepresentation_getUri\r
+        (JNIEnv *, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    setUri\r
+    * Signature: (Ljava/lang/String;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setUri\r
+        (JNIEnv *, jobject, jstring);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    getResourceTypes\r
+    * Signature: ()Ljava/util/List;\r
+    */\r
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcRepresentation_getResourceTypes\r
+        (JNIEnv *, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    setResourceTypeArray\r
+    * Signature: ([Ljava/lang/String;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setResourceTypeArray\r
+        (JNIEnv *, jobject, jobjectArray);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    getResourceInterfaces\r
+    * Signature: ()Ljava/util/List;\r
+    */\r
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcRepresentation_getResourceInterfaces\r
+        (JNIEnv *, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    setResourceInterfaceArray\r
+    * Signature: ([Ljava/lang/String;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setResourceInterfaceArray\r
+        (JNIEnv *, jobject, jobjectArray);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    isEmpty\r
+    * Signature: ()Z\r
+    */\r
+    JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_isEmpty\r
+        (JNIEnv *, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    size\r
+    * Signature: ()I\r
+    */\r
+    JNIEXPORT jint JNICALL Java_org_iotivity_base_OcRepresentation_size\r
+        (JNIEnv *, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    remove\r
+    * Signature: (Ljava/lang/String;)Z\r
+    */\r
+    JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_remove\r
+        (JNIEnv *, jobject, jstring);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    hasAttribute\r
+    * Signature: (Ljava/lang/String;)Z\r
+    */\r
+    JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_hasAttribute\r
+        (JNIEnv *, jobject, jstring);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    setNull\r
+    * Signature: (Ljava/lang/String;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setNull\r
+        (JNIEnv *, jobject, jstring);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    isNull\r
+    * Signature: (Ljava/lang/String;)Z\r
+    */\r
+    JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_isNull\r
+        (JNIEnv *, jobject, jstring);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    create\r
+    * Signature: ()V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_create\r
+        (JNIEnv *, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRepresentation\r
+    * Method:    dispose\r
+    * Signature: ()V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_dispose\r
+        (JNIEnv *, jobject, jboolean);\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+#endif
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniOcRequestHandle.cpp b/android/android_api/base/jni/JniOcRequestHandle.cpp
new file mode 100644 (file)
index 0000000..444689d
--- /dev/null
@@ -0,0 +1,63 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniOcRequestHandle.h"\r
+\r
+JniOcRequestHandle::JniOcRequestHandle(OCRequestHandle requestHandle) : m_requestHandle(requestHandle)\r
+{}\r
+\r
+JniOcRequestHandle::~JniOcRequestHandle()\r
+{\r
+    LOGD("~JniOcRequestHandle()");\r
+}\r
+\r
+JniOcRequestHandle* JniOcRequestHandle::getJniOcRequestHandlePtr\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    JniOcRequestHandle *handle = GetHandle<JniOcRequestHandle>(env, thiz);\r
+    if (env->ExceptionCheck())\r
+    {\r
+        LOGE("Failed to get native handle from OcRequestHandle");\r
+    }\r
+    if (!handle)\r
+    {\r
+        ThrowOcException(JNI_NO_NATIVE_POINTER, "");\r
+    }\r
+    return handle;\r
+}\r
+\r
+OCRequestHandle JniOcRequestHandle::getOCRequestHandle()\r
+{\r
+    return this->m_requestHandle;\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcRequestHandle\r
+* Method:    dispose\r
+* Signature: ()V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRequestHandle_dispose\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcRequestHandle_dispose");\r
+    JniOcRequestHandle *handle = JniOcRequestHandle::getJniOcRequestHandlePtr(env, thiz);\r
+    delete handle;\r
+}
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniOcRequestHandle.h b/android/android_api/base/jni/JniOcRequestHandle.h
new file mode 100644 (file)
index 0000000..2160728
--- /dev/null
@@ -0,0 +1,58 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniOcStack.h"\r
+#include "ocstack.h"\r
+\r
+#ifndef _Included_org_iotivity_base_OcRequestHandle\r
+#define _Included_org_iotivity_base_OcRequestHandle\r
+\r
+class JniOcRequestHandle\r
+{\r
+public:\r
+\r
+    JniOcRequestHandle(OCRequestHandle request);\r
+    ~JniOcRequestHandle();\r
+\r
+    static JniOcRequestHandle* getJniOcRequestHandlePtr(JNIEnv *env, jobject thiz);\r
+\r
+    OCRequestHandle getOCRequestHandle();\r
+\r
+private:\r
+    OCRequestHandle m_requestHandle;\r
+};\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcRequestHandle\r
+    * Method:    dispose\r
+    * Signature: ()V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRequestHandle_dispose\r
+        (JNIEnv *, jobject);\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+#endif\r
diff --git a/android/android_api/base/jni/JniOcResource.cpp b/android/android_api/base/jni/JniOcResource.cpp
new file mode 100644 (file)
index 0000000..2850d65
--- /dev/null
@@ -0,0 +1,1520 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+\r
+#include "JniOcResource.h"\r
+#include "JniOcRepresentation.h"\r
+#include "JniUtils.h"\r
+\r
+JniOcResource::JniOcResource(std::shared_ptr<OCResource> resource)\r
+    : m_sharedResource(resource)\r
+{}\r
+\r
+JniOcResource::~JniOcResource()\r
+{\r
+    LOGD("~JniOcResource()");\r
+    m_sharedResource = NULL;\r
+\r
+    jint envRet;\r
+    JNIEnv *env = GetJNIEnv(envRet);\r
+    if (NULL == env) return;\r
+\r
+    m_onGetManager.removeAllListeners(env);\r
+    m_onPutManager.removeAllListeners(env);\r
+    m_onPostManager.removeAllListeners(env);\r
+    m_onDeleteManager.removeAllListeners(env);\r
+    m_onObserveManager.removeAllListeners(env);\r
+\r
+    if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+}\r
+\r
+OCStackResult JniOcResource::get(JNIEnv* env, const QueryParamsMap &queryParametersMap, jobject jListener)\r
+{\r
+    JniOnGetListener *onGetListener = addOnGetListener(env, jListener);\r
+\r
+    GetCallback getCallback = [onGetListener](\r
+        const HeaderOptions& opts,\r
+        const OCRepresentation& rep,\r
+        const int eCode)\r
+    {\r
+        onGetListener->onGetCallback(opts, rep, eCode);\r
+    };\r
+\r
+    return m_sharedResource->get(queryParametersMap, getCallback);\r
+}\r
+\r
+OCStackResult JniOcResource::get(JNIEnv* env, const QueryParamsMap &queryParametersMap, jobject jListener,\r
+    QualityOfService QoS)\r
+{\r
+    JniOnGetListener *onGetListener = addOnGetListener(env, jListener);\r
+\r
+    GetCallback getCallback = [onGetListener](const HeaderOptions& opts, const OCRepresentation& rep,\r
+        const int eCode)\r
+    {\r
+        onGetListener->onGetCallback(opts, rep, eCode);\r
+    };\r
+\r
+    return m_sharedResource->get(queryParametersMap, getCallback, QoS);\r
+}\r
+\r
+OCStackResult JniOcResource::get(\r
+    JNIEnv* env,\r
+    const std::string &resourceType,\r
+    const std::string &resourceInterface,\r
+    const QueryParamsMap &queryParametersMap,\r
+    jobject jListener)\r
+{\r
+    JniOnGetListener *onGetListener = addOnGetListener(env, jListener);\r
+\r
+    GetCallback getCallback = [onGetListener](const HeaderOptions& opts,\r
+        const OCRepresentation& rep, const int eCode)\r
+    {\r
+        onGetListener->onGetCallback(opts, rep, eCode);\r
+    };\r
+\r
+    return m_sharedResource->get(resourceType, resourceInterface, queryParametersMap,\r
+        getCallback);\r
+}\r
+\r
+OCStackResult JniOcResource::get(JNIEnv* env, const std::string &resourceType,\r
+    const std::string &resourceInterface, const QueryParamsMap &queryParametersMap,\r
+    jobject jListener, QualityOfService QoS)\r
+{\r
+    JniOnGetListener *onGetListener = addOnGetListener(env, jListener);\r
+\r
+    GetCallback getCallback = [onGetListener](const HeaderOptions& opts,\r
+        const OCRepresentation& rep, const int eCode)\r
+    {\r
+        onGetListener->onGetCallback(opts, rep, eCode);\r
+    };\r
+\r
+    return m_sharedResource->get(resourceType, resourceInterface, queryParametersMap,\r
+        getCallback, QoS);\r
+}\r
+\r
+OCStackResult JniOcResource::put(JNIEnv* env, const OCRepresentation &representation,\r
+    const QueryParamsMap &queryParametersMap, jobject jListener)\r
+{\r
+    JniOnPutListener *onPutListener = addOnPutListener(env, jListener);\r
+\r
+    PutCallback putCallback = [onPutListener](const HeaderOptions& opts,\r
+        const OCRepresentation& rep, const int eCode)\r
+    {\r
+        onPutListener->onPutCallback(opts, rep, eCode);\r
+    };\r
+\r
+    return m_sharedResource->put(representation, queryParametersMap, putCallback);\r
+}\r
+\r
+OCStackResult JniOcResource::put(JNIEnv* env, const OCRepresentation &representation,\r
+    const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS)\r
+{\r
+    JniOnPutListener *onPutListener = addOnPutListener(env, jListener);\r
+\r
+    PutCallback putCallback = [onPutListener](const HeaderOptions& opts,\r
+        const OCRepresentation& rep, const int eCode)\r
+    {\r
+        onPutListener->onPutCallback(opts, rep, eCode);\r
+    };\r
+\r
+    return m_sharedResource->put(representation, queryParametersMap, putCallback, QoS);\r
+}\r
+\r
+OCStackResult JniOcResource::put(JNIEnv* env, const std::string &resourceType,\r
+    const std::string &resourceInterface, const OCRepresentation &representation,\r
+    const QueryParamsMap &queryParametersMap, jobject jListener)\r
+{\r
+    JniOnPutListener *onPutListener = addOnPutListener(env, jListener);\r
+\r
+    PutCallback putCallback = [onPutListener](const HeaderOptions& opts,\r
+        const OCRepresentation& rep, const int eCode)\r
+    {\r
+        onPutListener->onPutCallback(opts, rep, eCode);\r
+    };\r
+\r
+    return m_sharedResource->put(resourceType, resourceInterface, representation,\r
+        queryParametersMap, putCallback);\r
+}\r
+\r
+OCStackResult JniOcResource::put(JNIEnv* env, const std::string &resourceType,\r
+    const std::string &resourceInterface, const OCRepresentation &representation,\r
+    const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS)\r
+{\r
+    JniOnPutListener *onPutListener = addOnPutListener(env, jListener);\r
+\r
+    PutCallback putCallback = [onPutListener](const HeaderOptions& opts,\r
+        const OCRepresentation& rep, const int eCode)\r
+    {\r
+        onPutListener->onPutCallback(opts, rep, eCode);\r
+    };\r
+\r
+    return m_sharedResource->put(resourceType, resourceInterface, representation,\r
+        queryParametersMap, putCallback, QoS);\r
+}\r
+\r
+OCStackResult JniOcResource::post(JNIEnv* env, const OCRepresentation &representation,\r
+    const QueryParamsMap &queryParametersMap, jobject jListener)\r
+{\r
+    JniOnPostListener *onPostListener = addOnPostListener(env, jListener);\r
+\r
+    PostCallback postCallback = [onPostListener](const HeaderOptions& opts,\r
+        const OCRepresentation& rep, const int eCode)\r
+    {\r
+        onPostListener->onPostCallback(opts, rep, eCode);\r
+    };\r
+\r
+    return m_sharedResource->post(representation, queryParametersMap, postCallback);\r
+}\r
+\r
+OCStackResult JniOcResource::post(JNIEnv* env, const OCRepresentation &representation,\r
+    const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS)\r
+{\r
+    JniOnPostListener *onPostListener = addOnPostListener(env, jListener);\r
+\r
+    PostCallback postCallback = [onPostListener](const HeaderOptions& opts,\r
+        const OCRepresentation& rep, const int eCode)\r
+    {\r
+        onPostListener->onPostCallback(opts, rep, eCode);\r
+    };\r
+\r
+    return m_sharedResource->post(representation, queryParametersMap, postCallback, QoS);\r
+}\r
+\r
+OCStackResult JniOcResource::post(JNIEnv* env, const std::string &resourceType,\r
+    const std::string &resourceInterface, const OCRepresentation &representation,\r
+    const QueryParamsMap &queryParametersMap, jobject jListener)\r
+{\r
+    JniOnPostListener *onPostListener = addOnPostListener(env, jListener);\r
+\r
+    PostCallback postCallback = [onPostListener](const HeaderOptions& opts,\r
+        const OCRepresentation& rep, const int eCode)\r
+    {\r
+        onPostListener->onPostCallback(opts, rep, eCode);\r
+    };\r
+\r
+    return m_sharedResource->post(resourceType, resourceInterface, representation,\r
+        queryParametersMap, postCallback);\r
+}\r
+\r
+OCStackResult JniOcResource::post(JNIEnv* env, const std::string &resourceType,\r
+    const std::string &resourceInterface, const OCRepresentation &representation,\r
+    const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS)\r
+{\r
+    JniOnPostListener *onPostListener = addOnPostListener(env, jListener);\r
+\r
+    PostCallback postCallback = [onPostListener](const HeaderOptions& opts,\r
+        const OCRepresentation& rep, const int eCode)\r
+    {\r
+        onPostListener->onPostCallback(opts, rep, eCode);\r
+    };\r
+\r
+    return m_sharedResource->post(resourceType, resourceInterface, representation,\r
+        queryParametersMap, postCallback, QoS);\r
+}\r
+\r
+OCStackResult JniOcResource::deleteResource(JNIEnv* env, jobject jListener)\r
+{\r
+    JniOnDeleteListener *onDeleteListener = addOnDeleteListener(env, jListener);\r
+\r
+    DeleteCallback deleteCallback = [onDeleteListener](const HeaderOptions& opts,\r
+        const int eCode)\r
+    {\r
+        onDeleteListener->onDeleteCallback(opts, eCode);\r
+    };\r
+\r
+    return m_sharedResource->deleteResource(deleteCallback);\r
+}\r
+\r
+OCStackResult JniOcResource::deleteResource(JNIEnv* env, jobject jListener, QualityOfService QoS)\r
+{\r
+    JniOnDeleteListener *onDeleteListener = addOnDeleteListener(env, jListener);\r
+\r
+    DeleteCallback deleteCallback = [onDeleteListener](const HeaderOptions& opts, const int eCode)\r
+    {\r
+        onDeleteListener->onDeleteCallback(opts, eCode);\r
+    };\r
+\r
+    return m_sharedResource->deleteResource(deleteCallback, QoS);\r
+}\r
+\r
+OCStackResult JniOcResource::observe(JNIEnv* env, ObserveType observeType,\r
+    const QueryParamsMap &queryParametersMap, jobject jListener)\r
+{\r
+    JniOnObserveListener *onObserveListener = addOnObserveListener(env, jListener);\r
+\r
+    ObserveCallback observeCallback = [onObserveListener](const HeaderOptions& opts,\r
+        const OCRepresentation& rep, const int& eCode, const int& sequenceNumber)\r
+    {\r
+        onObserveListener->onObserveCallback(opts, rep, eCode, sequenceNumber);\r
+    };\r
+\r
+    return m_sharedResource->observe(observeType, queryParametersMap, observeCallback);\r
+}\r
+\r
+OCStackResult JniOcResource::observe(JNIEnv* env, ObserveType observeType,\r
+    const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS)\r
+{\r
+    JniOnObserveListener *onObserveListener = addOnObserveListener(env, jListener);\r
+\r
+    ObserveCallback observeCallback = [onObserveListener](const HeaderOptions& opts,\r
+        const OCRepresentation& rep, const int& eCode, const int& sequenceNumber)\r
+    {\r
+        onObserveListener->onObserveCallback(opts, rep, eCode, sequenceNumber);\r
+    };\r
+\r
+    return m_sharedResource->observe(observeType, queryParametersMap, observeCallback, QoS);\r
+}\r
+\r
+OCStackResult JniOcResource::cancelObserve(JNIEnv* env)\r
+{\r
+    this->m_onObserveManager.removeAllListeners(env);\r
+    return m_sharedResource->cancelObserve();\r
+}\r
+\r
+OCStackResult JniOcResource::cancelObserve(JNIEnv* env, QualityOfService qos)\r
+{\r
+    //TODO confirm behavior\r
+    //add removal of java listeners by qos\r
+    this->m_onObserveManager.removeAllListeners(env);\r
+    return m_sharedResource->cancelObserve(qos);\r
+}\r
+\r
+void JniOcResource::setHeaderOptions(const HeaderOptions &headerOptions)\r
+{\r
+    m_sharedResource->setHeaderOptions(headerOptions);\r
+}\r
+\r
+void JniOcResource::unsetHeaderOptions()\r
+{\r
+    m_sharedResource->unsetHeaderOptions();\r
+}\r
+\r
+std::string JniOcResource::host()\r
+{\r
+    return m_sharedResource->host();\r
+}\r
+\r
+std::string JniOcResource::uri()\r
+{\r
+    return m_sharedResource->uri();\r
+}\r
+\r
+OCConnectivityType JniOcResource::connectivityType() const\r
+{\r
+    return m_sharedResource->connectivityType();\r
+}\r
+\r
+bool JniOcResource::isObservable()\r
+{\r
+    return m_sharedResource->isObservable();\r
+}\r
+\r
+std::vector< std::string > JniOcResource::getResourceTypes() const\r
+{\r
+    return m_sharedResource->getResourceTypes();\r
+}\r
+\r
+std::vector< std::string > JniOcResource::getResourceInterfaces(void) const\r
+{\r
+    return m_sharedResource->getResourceInterfaces();\r
+}\r
+\r
+OCResourceIdentifier JniOcResource::uniqueIdentifier() const\r
+{\r
+    return m_sharedResource->uniqueIdentifier();\r
+}\r
+\r
+std::string JniOcResource::sid() const\r
+{\r
+    return m_sharedResource->sid();\r
+}\r
+\r
+JniOnGetListener* JniOcResource::addOnGetListener(JNIEnv* env, jobject jListener)\r
+{\r
+    return this->m_onGetManager.addListener(env, jListener, this);\r
+}\r
+\r
+JniOnPutListener* JniOcResource::addOnPutListener(JNIEnv* env, jobject jListener)\r
+{\r
+    return this->m_onPutManager.addListener(env, jListener, this);\r
+}\r
+\r
+JniOnPostListener* JniOcResource::addOnPostListener(JNIEnv* env, jobject jListener)\r
+{\r
+    return this->m_onPostManager.addListener(env, jListener, this);\r
+}\r
+\r
+JniOnDeleteListener* JniOcResource::addOnDeleteListener(JNIEnv* env, jobject jListener)\r
+{\r
+    return this->m_onDeleteManager.addListener(env, jListener, this);\r
+}\r
+\r
+JniOnObserveListener* JniOcResource::addOnObserveListener(JNIEnv* env, jobject jListener)\r
+{\r
+    return this->m_onObserveManager.addListener(env, jListener, this);\r
+}\r
+\r
+void JniOcResource::removeOnGetListener(JNIEnv* env, jobject jListener)\r
+{\r
+    this->m_onGetManager.removeListener(env, jListener);\r
+}\r
+\r
+void JniOcResource::removeOnPutListener(JNIEnv* env, jobject jListener)\r
+{\r
+    this->m_onPutManager.removeListener(env, jListener);\r
+}\r
+\r
+void JniOcResource::removeOnPostListener(JNIEnv* env, jobject jListener)\r
+{\r
+    this->m_onPostManager.removeListener(env, jListener);\r
+}\r
+\r
+void JniOcResource::removeOnDeleteListener(JNIEnv* env, jobject jListener)\r
+{\r
+    this->m_onDeleteManager.removeListener(env, jListener);\r
+}\r
+\r
+void JniOcResource::removeOnObserveListener(JNIEnv* env, jobject jListener)\r
+{\r
+    this->m_onObserveManager.removeListener(env, jListener);\r
+}\r
+\r
+std::shared_ptr<OCResource> JniOcResource::getOCResource()\r
+{\r
+    return this->m_sharedResource;\r
+}\r
+\r
+JniOcResource* JniOcResource::getJniOcResourcePtr(JNIEnv *env, jobject thiz)\r
+{\r
+    JniOcResource *resource = GetHandle<JniOcResource>(env, thiz);\r
+    if (env->ExceptionCheck())\r
+    {\r
+        LOGE("Failed to get native handle from OcResource");\r
+    }\r
+    if (!resource)\r
+    {\r
+        ThrowOcException(JNI_NO_NATIVE_POINTER, "");\r
+    }\r
+    return resource;\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResource\r
+* Method:    get\r
+* Signature: (Ljava/util/Map;Lorg/iotivity/base/OcResource/OnGetListener;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get\r
+(JNIEnv *env, jobject thiz, jobject jQueryParamsMap, jobject jListener)\r
+{\r
+    LOGD("OcResource_get");\r
+    if (!jQueryParamsMap)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
+        return;\r
+    }\r
+    if (!jListener)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onGetListener cannot be null");\r
+        return;\r
+    }\r
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
+    if (!resource) return;\r
+\r
+    QueryParamsMap qpm;\r
+    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);\r
+\r
+    try\r
+    {\r
+        OCStackResult result = resource->get(\r
+            env,\r
+            qpm,\r
+            jListener);\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "OcResource_get");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(e.code(), e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResource\r
+* Method:    get1\r
+* Signature: (Ljava/util/Map;Lorg/iotivity/base/OcResource/OnGetListener;I)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get1\r
+(JNIEnv *env, jobject thiz, jobject jQueryParamsMap, jobject jListener, jint jQoS)\r
+{\r
+    LOGD("OcResource_get");\r
+    if (!jQueryParamsMap)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
+        return;\r
+    }\r
+    if (!jListener)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onGetListener cannot be null");\r
+        return;\r
+    }\r
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
+    if (!resource) return;\r
+\r
+    QueryParamsMap qpm;\r
+    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);\r
+\r
+    try\r
+    {\r
+        OCStackResult result = resource->get(\r
+            env,\r
+            qpm,\r
+            jListener,\r
+            JniUtils::getQOS(env, static_cast<int>(jQoS)));\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "OcResource_get");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(e.code(), e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResource\r
+* Method:    get2\r
+* Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;\r
+Lorg/iotivity/base/OcResource/OnGetListener;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get2\r
+(JNIEnv *env, jobject thiz, jstring jResourceType, jstring jResourceInterface,\r
+jobject jQueryParamsMap, jobject jListener)\r
+{\r
+    LOGD("OcResource_get");\r
+    std::string resourceType;\r
+    if (jResourceType)\r
+    {\r
+        resourceType = env->GetStringUTFChars(jResourceType, NULL);\r
+    }\r
+    std::string resourceInterface;\r
+    if (jResourceInterface)\r
+    {\r
+        resourceInterface = env->GetStringUTFChars(jResourceInterface, NULL);\r
+    }\r
+    if (!jQueryParamsMap)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
+        return;\r
+    }\r
+    if (!jListener)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onGetListener cannot be null");\r
+        return;\r
+    }\r
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
+    if (!resource) return;\r
+\r
+    QueryParamsMap qpm;\r
+    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);\r
+    try\r
+    {\r
+        OCStackResult result = resource->get(\r
+            env,\r
+            resourceType,\r
+            resourceInterface,\r
+            qpm,\r
+            jListener);\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "OcResource_get");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(e.code(), e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResource\r
+* Method:    get3\r
+* Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;\r
+Lorg/iotivity/base/OcResource/OnGetListener;I)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get3\r
+(JNIEnv *env, jobject thiz, jstring jResourceType, jstring jResourceInterface,\r
+jobject jQueryParamsMap, jobject jListener, jint jQoS)\r
+{\r
+    LOGD("OcResource_get");\r
+    if (!jQueryParamsMap)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
+        return;\r
+    }\r
+    if (!jListener)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onGetListener cannot be null");\r
+        return;\r
+    }\r
+    std::string resourceType;\r
+    if (jResourceType)\r
+    {\r
+        resourceType = env->GetStringUTFChars(jResourceType, NULL);\r
+    }\r
+    std::string resourceInterface;\r
+    if (jResourceInterface)\r
+    {\r
+        resourceInterface = env->GetStringUTFChars(jResourceInterface, NULL);\r
+    }\r
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
+    if (!resource) return;\r
+\r
+    QueryParamsMap qpm;\r
+    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);\r
+\r
+    try\r
+    {\r
+        OCStackResult result = resource->get(\r
+            env,\r
+            resourceType,\r
+            resourceInterface,\r
+            qpm,\r
+            jListener,\r
+            JniUtils::getQOS(env, static_cast<int>(jQoS)));\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "OcResource_get");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(e.code(), e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResource\r
+* Method:    put\r
+* Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;\r
+Lorg/iotivity/base/OcResource/OnPutListener;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put\r
+(JNIEnv *env, jobject thiz, jobject jRepresentation, jobject jQueryParamsMap, jobject jListener)\r
+{\r
+    LOGD("OcResource_put");\r
+    if (!jRepresentation)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
+        return;\r
+    }\r
+    if (!jQueryParamsMap)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
+        return;\r
+    }\r
+    if (!jListener)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onPutListener cannot be null");\r
+        return;\r
+    }\r
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
+    if (!resource) return;\r
+\r
+    OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);\r
+    if (!representation) return;\r
+\r
+    QueryParamsMap qpm;\r
+    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);\r
+\r
+    try\r
+    {\r
+        OCStackResult result = resource->put(\r
+            env,\r
+            *representation,\r
+            qpm,\r
+            jListener);\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "OcResource_put");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(e.code(), e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResource\r
+* Method:    put1\r
+* Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;\r
+Lorg/iotivity/base/OcResource/OnPutListener;I)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put1\r
+(JNIEnv *env, jobject thiz, jobject jRepresentation, jobject jQueryParamsMap,\r
+jobject jListener, jint jQoS)\r
+{\r
+    LOGD("OcResource_put");\r
+    if (!jRepresentation)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
+        return;\r
+    }\r
+    if (!jQueryParamsMap)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
+        return;\r
+    }\r
+    if (!jListener)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onPutListener cannot be null");\r
+        return;\r
+    }\r
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
+    if (!resource) return;\r
+\r
+    OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);\r
+    if (!representation) return;\r
+\r
+    QueryParamsMap qpm;\r
+    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);\r
+\r
+    try\r
+    {\r
+        OCStackResult result = resource->put(\r
+            env,\r
+            *representation,\r
+            qpm,\r
+            jListener,\r
+            JniUtils::getQOS(env, static_cast<int>(jQoS)));\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "OcResource_put");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(e.code(), e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResource\r
+* Method:    put2\r
+* Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;\r
+Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPutListener;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put2\r
+(JNIEnv *env, jobject thiz, jstring jResourceType, jstring jResourceInterface,\r
+jobject jRepresentation, jobject jQueryParamsMap, jobject jListener)\r
+{\r
+    LOGD("OcResource_put");\r
+    std::string resourceType;\r
+    if (jResourceType)\r
+    {\r
+        resourceType = env->GetStringUTFChars(jResourceType, NULL);\r
+    }\r
+    std::string resourceInterface;\r
+    if (jResourceInterface)\r
+    {\r
+        resourceInterface = env->GetStringUTFChars(jResourceInterface, NULL);\r
+    }\r
+    if (!jRepresentation)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
+        return;\r
+    }\r
+    if (!jQueryParamsMap)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
+        return;\r
+    }\r
+    if (!jListener)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onPutListener cannot be null");\r
+        return;\r
+    }\r
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
+    if (!resource) return;\r
+\r
+    OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);\r
+    if (!representation) return;\r
+\r
+    QueryParamsMap qpm;\r
+    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);\r
+\r
+    try\r
+    {\r
+        OCStackResult result = resource->put(\r
+            env,\r
+            resourceType,\r
+            resourceInterface,\r
+            *representation,\r
+            qpm,\r
+            jListener);\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "OcResource_put");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(e.code(), e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResource\r
+* Method:    put3\r
+* Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;\r
+Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPutListener;I)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put3\r
+(JNIEnv *env, jobject thiz, jstring jResourceType, jstring jResourceInterface, jobject jRepresentation,\r
+jobject jQueryParamsMap, jobject jListener, jint jQoS)\r
+{\r
+    LOGD("OcResource_put");\r
+    if (!jRepresentation)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "representation cannot be null");\r
+        return;\r
+    }\r
+    if (!jQueryParamsMap)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
+        return;\r
+    }\r
+    if (!jListener)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onPutListener cannot be null");\r
+        return;\r
+    }\r
+    std::string resourceType;\r
+    if (jResourceType)\r
+    {\r
+        resourceType = env->GetStringUTFChars(jResourceType, NULL);\r
+    }\r
+    std::string resourceInterface;\r
+    if (jResourceInterface)\r
+    {\r
+        resourceInterface = env->GetStringUTFChars(jResourceInterface, NULL);\r
+    }\r
+\r
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
+    if (!resource) return;\r
+\r
+    OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);\r
+    if (!representation) return;\r
+\r
+    QueryParamsMap qpm;\r
+    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);\r
+\r
+    try\r
+    {\r
+        OCStackResult result = resource->put(\r
+            env,\r
+            resourceType,\r
+            resourceInterface,\r
+            *representation,\r
+            qpm,\r
+            jListener,\r
+            JniUtils::getQOS(env, static_cast<int>(jQoS)));\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "OcResource_put");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(e.code(), e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResource\r
+* Method:    post\r
+* Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post\r
+(JNIEnv *env, jobject thiz, jobject jRepresentation, jobject jQueryParamsMap, jobject jListener)\r
+{\r
+    LOGD("OcResource_post");\r
+    if (!jRepresentation)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "representation cannot be null");\r
+        return;\r
+    }\r
+    if (!jQueryParamsMap)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
+        return;\r
+    }\r
+    if (!jListener)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onPostListener cannot be null");\r
+        return;\r
+    }\r
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
+    if (!resource) return;\r
+\r
+    OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);\r
+    if (!representation) return;\r
+\r
+    QueryParamsMap qpm;\r
+    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);\r
+\r
+    try\r
+    {\r
+        OCStackResult result = resource->post(\r
+            env,\r
+            *representation,\r
+            qpm,\r
+            jListener);\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "OcResource_post");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(e.code(), e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResource\r
+* Method:    post1\r
+* Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;I)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post1\r
+(JNIEnv *env, jobject thiz, jobject jRepresentation, jobject jQueryParamsMap, jobject jListener, jint jQoS)\r
+{\r
+    LOGD("OcResource_post");\r
+    if (!jRepresentation)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "representation cannot be null");\r
+        return;\r
+    }\r
+    if (!jQueryParamsMap)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
+        return;\r
+    }\r
+    if (!jListener)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onPostListener cannot be null");\r
+        return;\r
+    }\r
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
+    if (!resource) return;\r
+\r
+    OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);\r
+    if (!representation) return;\r
+\r
+    QueryParamsMap qpm;\r
+    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);\r
+\r
+    try\r
+    {\r
+        OCStackResult result = resource->post(\r
+            env,\r
+            *representation,\r
+            qpm,\r
+            jListener,\r
+            JniUtils::getQOS(env, static_cast<int>(jQoS)));\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "OcResource_post");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(e.code(), e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResource\r
+* Method:    post2\r
+* Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;\r
+Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post2\r
+(JNIEnv *env, jobject thiz, jstring jResourceType, jstring jResourceInterface,\r
+jobject jRepresentation, jobject jQueryParamsMap, jobject jListener)\r
+{\r
+    LOGD("OcResource_post");\r
+    if (!jRepresentation)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "representation cannot be null");\r
+        return;\r
+    }\r
+    if (!jQueryParamsMap)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
+        return;\r
+    }\r
+    if (!jListener)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onPostListener cannot be null");\r
+        return;\r
+    }\r
+    std::string resourceType;\r
+    if (jResourceType)\r
+    {\r
+        resourceType = env->GetStringUTFChars(jResourceType, NULL);\r
+    }\r
+    std::string resourceInterface;\r
+    if (jResourceInterface)\r
+    {\r
+        resourceInterface = env->GetStringUTFChars(jResourceInterface, NULL);\r
+    }\r
+\r
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
+    if (!resource) return;\r
+\r
+    OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);\r
+    if (!representation) return;\r
+\r
+    QueryParamsMap qpm;\r
+    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);\r
+\r
+    try\r
+    {\r
+        OCStackResult result = resource->post(\r
+            env,\r
+            resourceType,\r
+            resourceInterface,\r
+            *representation,\r
+            qpm,\r
+            jListener);\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "OcResource_post");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(e.code(), e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResource\r
+* Method:    post3\r
+* Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;\r
+Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;I)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post3\r
+(JNIEnv *env, jobject thiz, jstring jResourceType, jstring jResourceInterface,\r
+jobject jRepresentation, jobject jQueryParamsMap, jobject jListener, jint jQoS)\r
+{\r
+    LOGD("OcResource_post");\r
+    if (!jRepresentation)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "representation cannot be null");\r
+        return;\r
+    }\r
+    if (!jQueryParamsMap)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
+        return;\r
+    }\r
+    if (!jListener)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onPostListener cannot be null");\r
+        return;\r
+    }\r
+    std::string resourceType;\r
+    if (jResourceType)\r
+    {\r
+        resourceType = env->GetStringUTFChars(jResourceType, NULL);\r
+    }\r
+    std::string resourceInterface;\r
+    if (jResourceInterface)\r
+    {\r
+        resourceInterface = env->GetStringUTFChars(jResourceInterface, NULL);\r
+    }\r
+\r
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
+    if (!resource) return;\r
+\r
+    OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);\r
+    if (!representation) return;\r
+\r
+    QueryParamsMap qpm;\r
+    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);\r
+\r
+    try\r
+    {\r
+        OCStackResult result = resource->post(\r
+            env,\r
+            resourceType,\r
+            resourceInterface,\r
+            *representation,\r
+            qpm,\r
+            jListener,\r
+            JniUtils::getQOS(env, static_cast<int>(jQoS)));\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "OcResource_post");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(e.code(), e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResource\r
+* Method:    deleteResource\r
+* Signature: (Lorg/iotivity/base/OcResource/OnDeleteListener;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_deleteResource\r
+(JNIEnv *env, jobject thiz, jobject jListener)\r
+{\r
+    LOGD("OcResource_deleteResource");\r
+    if (!jListener)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onDeleteListener cannot be null");\r
+        return;\r
+    }\r
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
+    if (!resource) return;\r
+\r
+    try\r
+    {\r
+        OCStackResult result = resource->deleteResource(\r
+            env,\r
+            jListener);\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "OcResource_deleteResource");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(e.code(), e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResource\r
+* Method:    deleteResource1\r
+* Signature: (Lorg/iotivity/base/OcResource/OnDeleteListener;I)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_deleteResource1\r
+(JNIEnv *env, jobject thiz, jobject jListener, jint jQoS)\r
+{\r
+    LOGD("OcResource_deleteResource");\r
+    if (!jListener)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onDeleteListener cannot be null");\r
+        return;\r
+    }\r
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
+    if (!resource) return;\r
+\r
+    try\r
+    {\r
+        OCStackResult result = resource->deleteResource(\r
+            env,\r
+            jListener,\r
+            JniUtils::getQOS(env, static_cast<int>(jQoS)));\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "OcResource_deleteResource");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(e.code(), e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResource\r
+* Method:    observe\r
+* Signature: (Lorg/iotivity/base/ObserveType;Ljava/util/Map;\r
+Lorg/iotivity/base/OcResource/OnObserveListener;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_observe\r
+(JNIEnv *env, jobject thiz, jint observeType, jobject jQueryParamsMap, jobject jListener)\r
+{\r
+    LOGD("OcResource_observe");\r
+    if (!jQueryParamsMap)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
+        return;\r
+    }\r
+    if (!jListener)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onObserveListener cannot be null");\r
+        return;\r
+    }\r
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
+    if (!resource) return;\r
+\r
+    QueryParamsMap qpm;\r
+    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);\r
+\r
+    try\r
+    {\r
+        OCStackResult result = resource->observe(\r
+            env,\r
+            JniUtils::getObserveType(env, static_cast<int>(observeType)),\r
+            qpm,\r
+            jListener);\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "OcResource_observe");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(e.code(), e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResource\r
+* Method:    observe1\r
+* Signature: (Lorg/iotivity/base/ObserveType;Ljava/util/Map;\r
+Lorg/iotivity/base/OcResource/OnObserveListener;I)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_observe1\r
+(JNIEnv *env, jobject thiz, jint observeType, jobject jQueryParamsMap,\r
+jobject jListener, jint jQoS)\r
+{\r
+    LOGD("OcResource_observe");\r
+    if (!jQueryParamsMap)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
+        return;\r
+    }\r
+    if (!jListener)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onObserveListener cannot be null");\r
+        return;\r
+    }\r
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
+    if (!resource) return;\r
+\r
+    QueryParamsMap qpm;\r
+    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);\r
+\r
+    try\r
+    {\r
+        OCStackResult result = resource->observe(\r
+            env,\r
+            JniUtils::getObserveType(env, static_cast<int>(observeType)),\r
+            qpm,\r
+            jListener,\r
+            JniUtils::getQOS(env, static_cast<int>(jQoS)));\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "OcResource_observe");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(e.code(), e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResource\r
+* Method:    cancelObserve\r
+* Signature: ()V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_cancelObserve\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcResource_cancelObserve");\r
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
+    if (!resource) return;\r
+\r
+    try\r
+    {\r
+        OCStackResult result = resource->cancelObserve(env);\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "OcResource_cancelObserve");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(e.code(), e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResource\r
+* Method:    cancelObserve1\r
+* Signature: I)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_cancelObserve1\r
+(JNIEnv *env, jobject thiz, jint jQoS)\r
+{\r
+    LOGD("OcResource_cancelObserve1");\r
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
+    if (!resource) return;\r
+\r
+    try\r
+    {\r
+        OCStackResult result = resource->cancelObserve(\r
+            env,\r
+            JniUtils::getQOS(env, static_cast<int>(jQoS)));\r
+\r
+        if (OC_STACK_OK != result)\r
+        {\r
+            ThrowOcException(result, "OcResource_cancelObserve");\r
+        }\r
+    }\r
+    catch (OCException& e)\r
+    {\r
+        LOGE("%s", e.reason().c_str());\r
+        ThrowOcException(e.code(), e.reason().c_str());\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResource\r
+* Method:    setHeaderOptions\r
+* Signature: ([Lorg/iotivity/OcHeaderOption;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_setHeaderOptions\r
+(JNIEnv *env, jobject thiz, jobjectArray jheaderOptionArr)\r
+{\r
+    LOGD("OcResource_setHeaderOptions");\r
+    if (!jheaderOptionArr)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "headerOptionList cannot be null");\r
+        return;\r
+    }\r
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
+    if (!resource) return;\r
+\r
+    HeaderOptions headerOptions;\r
+    JniUtils::convertJavaHeaderOptionsArrToVector(env, jheaderOptionArr, headerOptions);\r
+\r
+    resource->setHeaderOptions(headerOptions);\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResource\r
+* Method:    unsetHeaderOptions\r
+* Signature: ()V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_unsetHeaderOptions\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcResource_unsetHeaderOptions");\r
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
+    if (!resource) return;\r
+\r
+    resource->unsetHeaderOptions();\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResource\r
+* Method:    getHost\r
+* Signature: ()Ljava/lang/String;\r
+*/\r
+JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getHost\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcResource_getHost");\r
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
+    if (!resource) return nullptr;\r
+\r
+    return env->NewStringUTF(resource->host().c_str());\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResource\r
+* Method:    getUri\r
+* Signature: ()Ljava/lang/String;\r
+*/\r
+JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getUri\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcResource_getUri");\r
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
+    if (!resource) return nullptr;\r
+\r
+    return env->NewStringUTF(resource->uri().c_str());\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResource\r
+* Method:    getConnectivityTypeN\r
+* Signature: ()I\r
+*/\r
+JNIEXPORT jint JNICALL Java_org_iotivity_base_OcResource_getConnectivityTypeN\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcResource_getConnectivityType");\r
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
+    if (!resource) return -1;\r
+\r
+    OCConnectivityType connectivityType = resource->connectivityType();\r
+    return static_cast<jint>(connectivityType);\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResource\r
+* Method:    isObservable\r
+* Signature: ()Z\r
+*/\r
+JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcResource_isObservable\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcResource_isObservable");\r
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
+    return (jboolean)resource->isObservable();\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResource\r
+* Method:    getResourceTypes\r
+* Signature: ()Ljava/util/List;\r
+*/\r
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResource_getResourceTypes\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcResource_getResourceTypes");\r
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
+    if (!resource) return nullptr;\r
+\r
+    std::vector<std::string> resourceTypes = resource->getResourceTypes();\r
+\r
+    return JniUtils::convertStrVectorToJavaStrList(env, resourceTypes);\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResource\r
+* Method:    getResourceInterfaces\r
+* Signature: ()Ljava/util/List;\r
+*/\r
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResource_getResourceInterfaces\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcResource_getResourceInterfaces");\r
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
+    if (!resource) return nullptr;\r
+\r
+    std::vector<std::string> resourceInterfaces = resource->getResourceInterfaces();\r
+\r
+    return JniUtils::convertStrVectorToJavaStrList(env, resourceInterfaces);\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResource\r
+* Method:    getUniqueIdentifier\r
+* Signature: ()Lorg/iotivity/base/OcResourceIdentifier;\r
+*/\r
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResource_getUniqueIdentifier\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcResource_getUniqueIdentifier");\r
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
+    if (!resource) return nullptr;\r
+\r
+    JniOcResourceIdentifier *jniResourceIdentifier =\r
+        new JniOcResourceIdentifier(resource->uniqueIdentifier());\r
+    if (!jniResourceIdentifier) return nullptr;\r
+\r
+    jlong handle = reinterpret_cast<jlong>(jniResourceIdentifier);\r
+    jobject jResourceIdentifier = env->NewObject(g_cls_OcResourceIdentifier,\r
+        g_mid_OcResourceIdentifier_N_ctor, handle);\r
+    if (!jResourceIdentifier)\r
+    {\r
+        delete jniResourceIdentifier;\r
+    }\r
+    return jResourceIdentifier;\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResource\r
+* Method:    getServerId\r
+* Signature: ()Ljava/lang/String;\r
+*/\r
+JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getServerId\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcResource_getServerId");\r
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
+    if (!resource) return nullptr;\r
+\r
+    return env->NewStringUTF(resource->sid().c_str());\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResource\r
+* Method:    dispose\r
+* Signature: ()V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_dispose\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcResource_dispose");\r
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
+    delete resource;\r
+}
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniOcResource.h b/android/android_api/base/jni/JniOcResource.h
new file mode 100644 (file)
index 0000000..737dd5f
--- /dev/null
@@ -0,0 +1,359 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+\r
+#include "JniOcStack.h"\r
+#include "OCResource.h"\r
+#include "JniListenerManager.h"\r
+#include "JniOnGetListener.h"\r
+#include "JniOnPutListener.h"\r
+#include "JniOnPostListener.h"\r
+#include "JniOnDeleteListener.h"\r
+#include "JniOnObserveListener.h"\r
+#include "JniOcResourceIdentifier.h"\r
+\r
+#ifndef _Included_org_iotivity_base_OcResource\r
+#define _Included_org_iotivity_base_OcResource\r
+\r
+using namespace OC;\r
+\r
+class JniOcResource\r
+{\r
+public:\r
+    JniOcResource(std::shared_ptr<OCResource> resource);\r
+    ~JniOcResource();\r
+\r
+    OCStackResult get(JNIEnv* env, const QueryParamsMap &queryParametersMap, jobject jListener);\r
+    OCStackResult get(JNIEnv* env, const QueryParamsMap &queryParametersMap, jobject jListener,\r
+        QualityOfService QoS);\r
+    OCStackResult get(JNIEnv* env, const std::string &resourceType, const std::string &resourceInterface,\r
+        const QueryParamsMap &queryParametersMap, jobject jListener);\r
+    OCStackResult get(JNIEnv* env, const std::string &resourceType, const std::string &resourceInterface,\r
+        const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS);\r
+\r
+    OCStackResult put(JNIEnv* env, const OCRepresentation &representation, const QueryParamsMap &queryParametersMap,\r
+        jobject jListener);\r
+    OCStackResult put(JNIEnv* env, const OCRepresentation &representation, const QueryParamsMap &queryParametersMap,\r
+        jobject jListener, QualityOfService QoS);\r
+    OCStackResult put(JNIEnv* env, const std::string &resourceType, const std::string &resourceInterface,\r
+        const OCRepresentation &representation, const QueryParamsMap &queryParametersMap, jobject jListener);\r
+    OCStackResult put(JNIEnv* env, const std::string &resourceType, const std::string &resourceInterface,\r
+        const OCRepresentation &representation, const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS);\r
+\r
+    OCStackResult post(JNIEnv* env, const OCRepresentation &representation, const QueryParamsMap &queryParametersMap,\r
+        jobject jListener);\r
+    OCStackResult post(JNIEnv* env, const OCRepresentation &representation, const QueryParamsMap &queryParametersMap,\r
+        jobject jListener, QualityOfService QoS);\r
+    OCStackResult post(JNIEnv* env, const std::string &resourceType, const std::string &resourceInterface,\r
+        const OCRepresentation &representation, const QueryParamsMap &queryParametersMap, jobject jListener);\r
+    OCStackResult post(JNIEnv* env, const std::string &resourceType, const std::string &resourceInterface,\r
+        const OCRepresentation &representation, const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS);\r
+\r
+    OCStackResult deleteResource(JNIEnv* env, jobject jListener);\r
+    OCStackResult deleteResource(JNIEnv* env, jobject jListener, QualityOfService QoS);\r
+\r
+    OCStackResult observe(JNIEnv* env, ObserveType observeType, const QueryParamsMap &queryParametersMap,\r
+        jobject jListener);\r
+    OCStackResult observe(JNIEnv* env, ObserveType observeType, const QueryParamsMap &queryParametersMap,\r
+        jobject jListener, QualityOfService qos);\r
+\r
+    OCStackResult cancelObserve(JNIEnv* env);\r
+    OCStackResult cancelObserve(JNIEnv* env, QualityOfService qos);\r
+\r
+    void setHeaderOptions(const HeaderOptions &headerOptions);\r
+    void unsetHeaderOptions();\r
+    std::string host();\r
+    std::string uri();\r
+    OCConnectivityType connectivityType() const;\r
+    bool isObservable();\r
+    std::vector< std::string >         getResourceTypes() const;\r
+    std::vector< std::string >         getResourceInterfaces(void) const;\r
+    OCResourceIdentifier uniqueIdentifier() const;\r
+    std::string sid() const;\r
+\r
+    JniOnGetListener* addOnGetListener(JNIEnv* env, jobject jListener);\r
+    JniOnPutListener* addOnPutListener(JNIEnv* env, jobject jListener);\r
+    JniOnPostListener* addOnPostListener(JNIEnv* env, jobject jListener);\r
+    JniOnDeleteListener* addOnDeleteListener(JNIEnv* env, jobject jListener);\r
+    JniOnObserveListener* addOnObserveListener(JNIEnv* env, jobject jListener);\r
+\r
+    void removeOnGetListener(JNIEnv* env, jobject jListener);\r
+    void removeOnPutListener(JNIEnv* env, jobject jListener);\r
+    void removeOnPostListener(JNIEnv* env, jobject jListener);\r
+    void removeOnDeleteListener(JNIEnv* env, jobject jListener);\r
+    void removeOnObserveListener(JNIEnv* env, jobject jListener);\r
+\r
+    std::shared_ptr<OCResource> getOCResource();\r
+\r
+    static JniOcResource* getJniOcResourcePtr(JNIEnv *env, jobject thiz);\r
+\r
+private:\r
+    JniListenerManager<JniOnGetListener> m_onGetManager;\r
+    JniListenerManager<JniOnPutListener> m_onPutManager;\r
+    JniListenerManager<JniOnPostListener> m_onPostManager;\r
+    JniListenerManager<JniOnDeleteListener> m_onDeleteManager;\r
+    JniListenerManager<JniOnObserveListener> m_onObserveManager;\r
+\r
+    std::shared_ptr<OCResource> m_sharedResource;\r
+};\r
+\r
+/* DO NOT EDIT THIS FILE BEYOND THIS LINE - it is machine generated */\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResource\r
+    * Method:    get\r
+    * Signature: (Ljava/util/Map;Lorg/iotivity/base/OcResource/OnGetListener;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get\r
+        (JNIEnv *, jobject, jobject, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResource\r
+    * Method:    get1\r
+    * Signature: (Ljava/util/Map;Lorg/iotivity/base/OcResource/OnGetListener;I)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get1\r
+        (JNIEnv *, jobject, jobject, jobject, jint);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResource\r
+    * Method:    get2\r
+    * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnGetListener;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get2\r
+        (JNIEnv *, jobject, jstring, jstring, jobject, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResource\r
+    * Method:    get3\r
+    * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnGetListener;I)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get3\r
+        (JNIEnv *, jobject, jstring, jstring, jobject, jobject, jint);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResource\r
+    * Method:    put\r
+    * Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPutListener;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put\r
+        (JNIEnv *, jobject, jobject, jobject, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResource\r
+    * Method:    put1\r
+    * Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPutListener;I)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put1\r
+        (JNIEnv *, jobject, jobject, jobject, jobject, jint);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResource\r
+    * Method:    put2\r
+    * Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPutListener;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put2\r
+        (JNIEnv *, jobject, jstring, jstring, jobject, jobject, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResource\r
+    * Method:    put3\r
+    * Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPutListener;I)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put3\r
+        (JNIEnv *, jobject, jstring, jstring, jobject, jobject, jobject, jint);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResource\r
+    * Method:    post\r
+    * Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post\r
+        (JNIEnv *, jobject, jobject, jobject, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResource\r
+    * Method:    post1\r
+    * Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;I)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post1\r
+        (JNIEnv *, jobject, jobject, jobject, jobject, jint);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResource\r
+    * Method:    post2\r
+    * Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post2\r
+        (JNIEnv *, jobject, jstring, jstring, jobject, jobject, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResource\r
+    * Method:    post3\r
+    * Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;I)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post3\r
+        (JNIEnv *, jobject, jstring, jstring, jobject, jobject, jobject, jint);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResource\r
+    * Method:    deleteResource\r
+    * Signature: (Lorg/iotivity/base/OcResource/OnDeleteListener;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_deleteResource\r
+        (JNIEnv *, jobject, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResource\r
+    * Method:    deleteResource1\r
+    * Signature: (Lorg/iotivity/base/OcResource/OnDeleteListener;I)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_deleteResource1\r
+        (JNIEnv *, jobject, jobject, jint);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResource\r
+    * Method:    observe\r
+    * Signature: (Lorg/iotivity/base/ObserveType;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnObserveListener;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_observe\r
+        (JNIEnv *, jobject, jint, jobject, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResource\r
+    * Method:    observe1\r
+    * Signature: (Lorg/iotivity/base/ObserveType;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnObserveListener;I)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_observe1\r
+        (JNIEnv *, jobject, jint, jobject, jobject, jint);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResource\r
+    * Method:    cancelObserve\r
+    * Signature: ()V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_cancelObserve\r
+        (JNIEnv *, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResource\r
+    * Method:    cancelObserve1\r
+    * Signature: (I)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_cancelObserve1\r
+        (JNIEnv *, jobject, jint);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResource\r
+    * Method:    setHeaderOptions\r
+    * Signature: ([Lorg/iotivity/OcHeaderOption;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_setHeaderOptions\r
+        (JNIEnv *, jobject, jobjectArray);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResource\r
+    * Method:    unsetHeaderOptions\r
+    * Signature: ()V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_unsetHeaderOptions\r
+        (JNIEnv *, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResource\r
+    * Method:    getHost\r
+    * Signature: ()Ljava/lang/String;\r
+    */\r
+    JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getHost\r
+        (JNIEnv *, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResource\r
+    * Method:    getUri\r
+    * Signature: ()Ljava/lang/String;\r
+    */\r
+    JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getUri\r
+        (JNIEnv *, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResource\r
+    * Method:    getConnectivityTypeN\r
+    * Signature: ()I\r
+    */\r
+    JNIEXPORT jint JNICALL Java_org_iotivity_base_OcResource_getConnectivityTypeN\r
+        (JNIEnv *, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResource\r
+    * Method:    isObservable\r
+    * Signature: ()Z\r
+    */\r
+    JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcResource_isObservable\r
+        (JNIEnv *, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResource\r
+    * Method:    getResourceTypes\r
+    * Signature: ()Ljava/util/List;\r
+    */\r
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResource_getResourceTypes\r
+        (JNIEnv *, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResource\r
+    * Method:    getResourceInterfaces\r
+    * Signature: ()Ljava/util/List;\r
+    */\r
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResource_getResourceInterfaces\r
+        (JNIEnv *, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResource\r
+    * Method:    getUniqueIdentifier\r
+    * Signature: ()Lorg/iotivity/base/OcResourceIdentifier;\r
+    */\r
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResource_getUniqueIdentifier\r
+        (JNIEnv *, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResource\r
+    * Method:    getServerId\r
+    * Signature: ()Ljava/lang/String;\r
+    */\r
+    JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getServerId\r
+        (JNIEnv *, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResource\r
+    * Method:    dispose\r
+    * Signature: ()V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_dispose\r
+        (JNIEnv *, jobject);\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+#endif
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniOcResourceHandle.cpp b/android/android_api/base/jni/JniOcResourceHandle.cpp
new file mode 100644 (file)
index 0000000..84f748e
--- /dev/null
@@ -0,0 +1,66 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniOcResourceHandle.h"\r
+\r
+using namespace OC;\r
+\r
+JniOcResourceHandle::JniOcResourceHandle(OCResourceHandle resourceHandle)\r
+    : m_resourceHandle(resourceHandle)\r
+{}\r
+\r
+JniOcResourceHandle::~JniOcResourceHandle()\r
+{\r
+    LOGD("~JniOcResourceHandle()");\r
+}\r
+\r
+JniOcResourceHandle* JniOcResourceHandle::getJniOcResourceHandlePtr\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    JniOcResourceHandle *handle = GetHandle<JniOcResourceHandle>(env, thiz);\r
+    if (env->ExceptionCheck())\r
+    {\r
+        LOGE("Failed to get native handle from OcResourceHandle");\r
+    }\r
+    if (!handle)\r
+    {\r
+        ThrowOcException(JNI_NO_NATIVE_POINTER, "");\r
+    }\r
+    return handle;\r
+}\r
+\r
+OCResourceHandle JniOcResourceHandle::getOCResourceHandle()\r
+{\r
+    return this->m_resourceHandle;\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResourceHandle\r
+* Method:    dispose\r
+* Signature: ()V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceHandle_dispose\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcResourceHandle_dispose");\r
+    JniOcResourceHandle *resourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(env, thiz);\r
+    delete resourceHandle;\r
+}
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniOcResourceHandle.h b/android/android_api/base/jni/JniOcResourceHandle.h
new file mode 100644 (file)
index 0000000..b8b4e1c
--- /dev/null
@@ -0,0 +1,56 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniOcStack.h"\r
+#include "JniEntityHandler.h"\r
+\r
+#ifndef _Included_org_iotivity_base_OcResourceHandle\r
+#define _Included_org_iotivity_base_OcResourceHandle\r
+\r
+class JniOcResourceHandle\r
+{\r
+public:\r
+    JniOcResourceHandle(OCResourceHandle resourceHandle);\r
+    ~JniOcResourceHandle();\r
+\r
+    static JniOcResourceHandle* getJniOcResourceHandlePtr(JNIEnv *env, jobject thiz);\r
+\r
+    OCResourceHandle getOCResourceHandle();\r
+private:\r
+    OCResourceHandle m_resourceHandle;\r
+};\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResourceHandle\r
+    * Method:    dispose\r
+    * Signature: ()V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceHandle_dispose\r
+        (JNIEnv *, jobject);\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+#endif\r
diff --git a/android/android_api/base/jni/JniOcResourceIdentifier.cpp b/android/android_api/base/jni/JniOcResourceIdentifier.cpp
new file mode 100644 (file)
index 0000000..59b918c
--- /dev/null
@@ -0,0 +1,89 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+\r
+#include "JniOcResourceIdentifier.h"\r
+\r
+JniOcResourceIdentifier::JniOcResourceIdentifier(OC::OCResourceIdentifier resourceIdentifier)\r
+    : m_resourceIdentifier(resourceIdentifier)\r
+{}\r
+\r
+JniOcResourceIdentifier::~JniOcResourceIdentifier()\r
+{\r
+    LOGD("~JniOcResourceIdentifier()");\r
+}\r
+\r
+OC::OCResourceIdentifier JniOcResourceIdentifier::getOCResourceIdentifier()\r
+{\r
+    return this->m_resourceIdentifier;\r
+}\r
+\r
+JniOcResourceIdentifier* JniOcResourceIdentifier::getJniOcResourceIdentifierPtr\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    JniOcResourceIdentifier *identifier = GetHandle<JniOcResourceIdentifier>(env, thiz);\r
+    if (env->ExceptionCheck())\r
+    {\r
+        LOGE("Failed to get native handle from OcResourceIdentifier");\r
+    }\r
+    if (!identifier)\r
+    {\r
+        ThrowOcException(JNI_NO_NATIVE_POINTER, "");\r
+    }\r
+    return identifier;\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResourceIdentifier\r
+* Method:    equalsN\r
+* Signature: (Lorg/iotivity/base/OcResourceIdentifier;)Z\r
+*/\r
+JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcResourceIdentifier_equalsN\r
+(JNIEnv *env, jobject jThiz, jobject jOther)\r
+{\r
+    JniOcResourceIdentifier *thiz = JniOcResourceIdentifier::getJniOcResourceIdentifierPtr(env, jThiz);\r
+    if (!thiz) return false;\r
+\r
+    JniOcResourceIdentifier *other = JniOcResourceIdentifier::getJniOcResourceIdentifierPtr(env, jOther);\r
+    if (!other) return false;\r
+\r
+    if (thiz->getOCResourceIdentifier() == other->getOCResourceIdentifier())\r
+    {\r
+        return true;\r
+    }\r
+    else\r
+    {\r
+        return false;\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResourceIdentifier\r
+* Method:    dispose\r
+* Signature: ()V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceIdentifier_dispose\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("JniOcResourceIdentifier_dispose");\r
+    JniOcResourceIdentifier *identifier = JniOcResourceIdentifier::getJniOcResourceIdentifierPtr(env, thiz);\r
+    delete identifier;\r
+}
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniOcResourceIdentifier.h b/android/android_api/base/jni/JniOcResourceIdentifier.h
new file mode 100644 (file)
index 0000000..9c7651a
--- /dev/null
@@ -0,0 +1,65 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniOcStack.h"\r
+#include "OCResource.h"\r
+\r
+#ifndef _Included_org_iotivity_base_OcResourceIdentifier\r
+#define _Included_org_iotivity_base_OcResourceIdentifier\r
+\r
+class JniOcResourceIdentifier\r
+{\r
+public:\r
+\r
+    JniOcResourceIdentifier(OC::OCResourceIdentifier identifier);\r
+    ~JniOcResourceIdentifier();\r
+\r
+    static JniOcResourceIdentifier* getJniOcResourceIdentifierPtr(JNIEnv *env, jobject thiz);\r
+\r
+    OC::OCResourceIdentifier getOCResourceIdentifier();\r
+\r
+private:\r
+    OC::OCResourceIdentifier m_resourceIdentifier;\r
+};\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+    /*\r
+    * Class:     org_iotivity_base_OcResourceIdentifier\r
+    * Method:    equalsN\r
+    * Signature: (Lorg/iotivity/base/OcResourceIdentifier;)Z\r
+    */\r
+    JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcResourceIdentifier_equalsN\r
+        (JNIEnv *, jobject, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResourceIdentifier\r
+    * Method:    dispose\r
+    * Signature: ()V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceIdentifier_dispose\r
+        (JNIEnv *, jobject);\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+#endif
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniOcResourceRequest.cpp b/android/android_api/base/jni/JniOcResourceRequest.cpp
new file mode 100644 (file)
index 0000000..b1d981c
--- /dev/null
@@ -0,0 +1,321 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniOcResourceRequest.h"\r
+#include "OCResourceRequest.h"\r
+#include "JniOcResourceHandle.h"\r
+#include "JniOcRequestHandle.h"\r
+#include "JniUtils.h"\r
+\r
+using namespace OC;\r
+\r
+JniOcResourceRequest::JniOcResourceRequest(const std::shared_ptr<OCResourceRequest> request)\r
+    : m_request(request)\r
+{}\r
+\r
+JniOcResourceRequest::~JniOcResourceRequest()\r
+{}\r
+\r
+std::string\r
+JniOcResourceRequest::getRequestType()\r
+{\r
+    return m_request->getRequestType();\r
+}\r
+\r
+const QueryParamsMap&\r
+JniOcResourceRequest::getQueryParameters() const\r
+{\r
+    return m_request->getQueryParameters();\r
+}\r
+\r
+int\r
+JniOcResourceRequest::getRequestHandlerFlag() const\r
+{\r
+    return m_request->getRequestHandlerFlag();\r
+}\r
+\r
+const OCRepresentation&\r
+JniOcResourceRequest::getResourceRepresentation() const\r
+{\r
+    return m_request->getResourceRepresentation();\r
+}\r
+\r
+const ObservationInfo&\r
+JniOcResourceRequest::getObservationInfo() const\r
+{\r
+    return m_request->getObservationInfo();\r
+}\r
+\r
+void\r
+JniOcResourceRequest::setResourceUri(const std::string resourceUri)\r
+{\r
+    m_request->setResourceUri(resourceUri);\r
+}\r
+\r
+std::string\r
+JniOcResourceRequest::getResourceUri(void)\r
+{\r
+    return m_request->getResourceUri();\r
+}\r
+\r
+const HeaderOptions&\r
+JniOcResourceRequest::getHeaderOptions() const\r
+{\r
+    return m_request->getHeaderOptions();\r
+}\r
+\r
+const OCRequestHandle&\r
+JniOcResourceRequest::getRequestHandle() const\r
+{\r
+    return m_request->getRequestHandle();\r
+}\r
+\r
+const OCResourceHandle&\r
+JniOcResourceRequest::getResourceHandle() const\r
+{\r
+    return m_request->getResourceHandle();\r
+}\r
+\r
+JniOcResourceRequest* JniOcResourceRequest::getJniOcResourceRequestPtr\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    JniOcResourceRequest *request = GetHandle<JniOcResourceRequest>(env, thiz);\r
+    if (env->ExceptionCheck())\r
+    {\r
+        LOGE("Failed to get native handle from OcResourceRequest");\r
+    }\r
+    if (!request)\r
+    {\r
+        ThrowOcException(JNI_NO_NATIVE_POINTER, "");\r
+    }\r
+    return request;\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResourceRequest\r
+* Method:    getRequestTypeNative\r
+* Signature: ()Ljava/lang/String;\r
+*/\r
+JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResourceRequest_getRequestTypeNative\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcResourceRequest_getRequestTypeNative");\r
+    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);\r
+    if (!request) return nullptr;\r
+\r
+    std::string requestType = request->getRequestType();\r
+    return env->NewStringUTF(requestType.c_str());\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResourceRequest\r
+* Method:    getQueryParameters\r
+* Signature: ()Ljava/util/Map;\r
+*/\r
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getQueryParameters\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcResourceRequest_getQueryParameters");\r
+    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);\r
+    if (!request) return nullptr;\r
+\r
+    return JniUtils::convertQueryParamsMapToJavaMap(env, request->getQueryParameters());\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResourceRequest\r
+* Method:    getRequestHandlerFlagNative\r
+* Signature: ()I\r
+*/\r
+JNIEXPORT jint JNICALL Java_org_iotivity_base_OcResourceRequest_getRequestHandlerFlagNative\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcResourceRequest_getRequestHandlerFlagNative");\r
+    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);\r
+    if (!request) return -1;\r
+\r
+    return static_cast<jint>(request->getRequestHandlerFlag());\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResourceRequest\r
+* Method:    getResourceRepresentation\r
+* Signature: ()Lorg/iotivity/base/OcRepresentation;\r
+*/\r
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getResourceRepresentation\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcResourceRequest_getResourceRepresentation");\r
+    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);\r
+    if (!request) return nullptr;\r
+\r
+    OCRepresentation *ocRepresentation = new OCRepresentation(request->getResourceRepresentation());\r
+    if (!ocRepresentation) return nullptr;\r
+\r
+    jlong handle = reinterpret_cast<jlong>(ocRepresentation);\r
+    jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool,\r
+        handle, true);\r
+    if (!jRepresentation)\r
+    {\r
+        LOGE("Failed to create OcRepresentation");\r
+        delete ocRepresentation;\r
+    }\r
+\r
+    return jRepresentation;\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResourceRequest\r
+* Method:    getObservationInfo\r
+* Signature: ()Lorg/iotivity/base/ObservationInfo;\r
+*/\r
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getObservationInfo\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcResourceRequest_getObservationInfo");\r
+    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);\r
+    if (!request) return nullptr;\r
+\r
+    ObservationInfo oInfo = request->getObservationInfo();\r
+\r
+    jobject jObservationInfo = env->NewObject(g_cls_ObservationInfo, g_mid_ObservationInfo_N_ctor,\r
+        (jint)oInfo.action, (jbyte)oInfo.obsId);\r
+\r
+    if (!jObservationInfo)\r
+    {\r
+        LOGE("Failed to create ObservationInfo");\r
+    }\r
+\r
+    return jObservationInfo;\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResourceRequest\r
+* Method:    setResourceUri\r
+* Signature: (Ljava/lang/String);\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceRequest_setResourceUri\r
+(JNIEnv *env, jobject thiz, jstring jUri)\r
+{\r
+    LOGD("OcResourceRequest_setResourceUri");\r
+    if (!jUri)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "URI cannot be null");\r
+        return;\r
+    }\r
+    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);\r
+    if (!request) return;\r
+\r
+    request->setResourceUri(env->GetStringUTFChars(jUri, 0));\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResourceRequest\r
+* Method:    getResourceUri\r
+* Signature: ()Ljava/lang/String;\r
+*/\r
+JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResourceRequest_getResourceUri\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcResourceRequest_getResourceUri");\r
+    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);\r
+    if (!request) return nullptr;\r
+\r
+    std::string requestUri = request->getResourceUri();\r
+    return env->NewStringUTF(requestUri.c_str());\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResourceRequest\r
+* Method:    getHeaderOptions\r
+* Signature: ()Ljava/util/List;\r
+*/\r
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getHeaderOptions\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcResourceRequest_getHeaderOptions");\r
+    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);\r
+    if (!request) return nullptr;\r
+\r
+    return JniUtils::convertHeaderOptionsVectorToJavaList(env, request->getHeaderOptions());\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResourceRequest\r
+* Method:    getRequestHandle\r
+* Signature: ()Lorg/iotivity/base/OcRequestHandle;\r
+*/\r
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getRequestHandle\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcResourceRequest_getRequestHandle");\r
+    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);\r
+    if (!request) return nullptr;\r
+\r
+    JniOcRequestHandle* jniHandle = new JniOcRequestHandle(request->getRequestHandle());\r
+    jlong handle = reinterpret_cast<jlong>(jniHandle);\r
+    jobject jRequestHandle = env->NewObject(g_cls_OcRequestHandle, g_mid_OcRequestHandle_N_ctor, handle);\r
+    if (!jRequestHandle)\r
+    {\r
+        LOGE("Failed to create OcRequestHandle");\r
+        delete jniHandle;\r
+    }\r
+\r
+    return jRequestHandle;\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResourceRequest\r
+* Method:    getResourceHandle\r
+* Signature: ()Lorg/iotivity/base/OcResourceHandle;\r
+*/\r
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getResourceHandle\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcResourceRequest_getResourceHandle");\r
+    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);\r
+    if (!request) return nullptr;\r
+\r
+    JniOcResourceHandle* jniHandle = new JniOcResourceHandle(\r
+        request->getResourceHandle());\r
+    jlong handle = reinterpret_cast<jlong>(jniHandle);\r
+    jobject jResourceHandle = env->NewObject(g_cls_OcResourceHandle, g_mid_OcResourceHandle_N_ctor, handle);\r
+    if (!jResourceHandle)\r
+    {\r
+        LOGE("Failed to create OcResourceHandle");\r
+        delete jniHandle;\r
+    }\r
+\r
+    return jResourceHandle;\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResourceRequest\r
+* Method:    dispose\r
+* Signature: ()V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceRequest_dispose\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcResourceRequest_dispose");\r
+    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);\r
+    delete request;\r
+}
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniOcResourceRequest.h b/android/android_api/base/jni/JniOcResourceRequest.h
new file mode 100644 (file)
index 0000000..5b58f0c
--- /dev/null
@@ -0,0 +1,158 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniOcStack.h"\r
+\r
+#ifndef _Included_org_iotivity_base_OcResourceRequest\r
+#define _Included_org_iotivity_base_OcResourceRequest\r
+\r
+using namespace OC;\r
+\r
+class JniOcResourceRequest\r
+{\r
+public:\r
+    JniOcResourceRequest(const std::shared_ptr<OCResourceRequest> resourceRequest);\r
+\r
+    ~JniOcResourceRequest();\r
+\r
+    std::string getRequestType();\r
+\r
+    const QueryParamsMap& getQueryParameters() const;\r
+\r
+    int getRequestHandlerFlag() const;\r
+\r
+    const OCRepresentation& getResourceRepresentation() const;\r
+\r
+    const ObservationInfo& getObservationInfo() const;\r
+\r
+    void setResourceUri(const std::string resourceUri);\r
+\r
+    std::string getResourceUri(void);\r
+\r
+    const HeaderOptions& getHeaderOptions() const;\r
+\r
+    const OCRequestHandle& getRequestHandle() const;\r
+\r
+    const OCResourceHandle& getResourceHandle() const;\r
+\r
+    static JniOcResourceRequest* getJniOcResourceRequestPtr\r
+        (JNIEnv *env, jobject thiz);\r
+\r
+private:\r
+    std::shared_ptr<OCResourceRequest> m_request;\r
+};\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResourceRequest\r
+    * Method:    getRequestTypeNative\r
+    * Signature: ()Ljava/lang/String;\r
+    */\r
+    JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResourceRequest_getRequestTypeNative\r
+        (JNIEnv *, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResourceRequest\r
+    * Method:    getQueryParameters\r
+    * Signature: ()Ljava/util/Map;\r
+    */\r
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getQueryParameters\r
+        (JNIEnv *, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResourceRequest\r
+    * Method:    getRequestHandlerFlagNative\r
+    * Signature: ()I\r
+    */\r
+    JNIEXPORT jint JNICALL Java_org_iotivity_base_OcResourceRequest_getRequestHandlerFlagNative\r
+        (JNIEnv *, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResourceRequest\r
+    * Method:    getResourceRepresentation\r
+    * Signature: ()Lorg/iotivity/base/OcRepresentation;\r
+    */\r
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getResourceRepresentation\r
+        (JNIEnv *, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResourceRequest\r
+    * Method:    getObservationInfo\r
+    * Signature: ()Lorg/iotivity/base/ObservationInfo;\r
+    */\r
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getObservationInfo\r
+        (JNIEnv *, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResourceRequest\r
+    * Method:    setResourceUri\r
+    * Signature: (Ljava/lang/String;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceRequest_setResourceUri\r
+        (JNIEnv *, jobject, jstring);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResourceRequest\r
+    * Method:    getResourceUri\r
+    * Signature: ()Ljava/lang/String;\r
+    */\r
+    JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResourceRequest_getResourceUri\r
+        (JNIEnv *, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResourceRequest\r
+    * Method:    getHeaderOptions\r
+    * Signature: ()Ljava/util/List;\r
+    */\r
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getHeaderOptions\r
+        (JNIEnv *, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResourceRequest\r
+    * Method:    getRequestHandle\r
+    * Signature: ()Lorg/iotivity/base/OcRequestHandle;\r
+    */\r
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getRequestHandle\r
+        (JNIEnv *, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResourceRequest\r
+    * Method:    getResourceHandle\r
+    * Signature: ()Lorg/iotivity/base/OcResourceHandle;\r
+    */\r
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getResourceHandle\r
+        (JNIEnv *, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResourceRequest\r
+    * Method:    dispose\r
+    * Signature: ()V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceRequest_dispose\r
+        (JNIEnv *, jobject);\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+#endif
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniOcResourceResponse.cpp b/android/android_api/base/jni/JniOcResourceResponse.cpp
new file mode 100644 (file)
index 0000000..f8771c3
--- /dev/null
@@ -0,0 +1,320 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniOcResourceResponse.h"\r
+#include "OCResourceResponse.h"\r
+#include "JniOcRepresentation.h"\r
+#include "JniOcRequestHandle.h"\r
+#include "JniOcResourceHandle.h"\r
+#include "JniUtils.h"\r
+\r
+using namespace OC;\r
+\r
+JniOcResourceResponse::JniOcResourceResponse\r
+(std::shared_ptr<OCResourceResponse> resourceResponse)\r
+: m_response(resourceResponse){}\r
+\r
+JniOcResourceResponse::~JniOcResourceResponse()\r
+{}\r
+\r
+void JniOcResourceResponse::setErrorCode(const int eCode)\r
+{\r
+    this->m_response->setErrorCode(eCode);\r
+}\r
+\r
+std::string JniOcResourceResponse::getNewResourceUri(void)\r
+{\r
+    this->m_response->getNewResourceUri();\r
+}\r
+\r
+void\r
+JniOcResourceResponse::setNewResourceUri(const std::string newResourceUri)\r
+{\r
+    this->m_response->setNewResourceUri(newResourceUri);\r
+}\r
+\r
+void JniOcResourceResponse::setHeaderOptions(const HeaderOptions& headerOptions)\r
+{\r
+    this->m_response->setHeaderOptions(headerOptions);\r
+}\r
+\r
+void JniOcResourceResponse::setRequestHandle(const OCRequestHandle& requestHandle)\r
+{\r
+    this->m_response->setRequestHandle(requestHandle);\r
+}\r
+\r
+void JniOcResourceResponse::setResourceHandle(const OCResourceHandle& resourceHandle)\r
+{\r
+    this->m_response->setResourceHandle(resourceHandle);\r
+}\r
+\r
+void JniOcResourceResponse::setResponseResult(const OCEntityHandlerResult& responseResult)\r
+{\r
+    this->m_response->setResponseResult(responseResult);\r
+}\r
+\r
+void JniOcResourceResponse::setResourceRepresentation(OCRepresentation& rep,\r
+    std::string interfaceStr)\r
+{\r
+    this->m_response->setResourceRepresentation(rep, interfaceStr);\r
+}\r
+\r
+void JniOcResourceResponse::setResourceRepresentation(OCRepresentation& rep)\r
+{\r
+    this->m_response->setResourceRepresentation(rep);\r
+}\r
+\r
+std::shared_ptr<OCResourceResponse> JniOcResourceResponse::getOCResourceResponse()\r
+{\r
+    return this->m_response;\r
+}\r
+\r
+JniOcResourceResponse* JniOcResourceResponse::getJniOcResourceResponsePtr\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    JniOcResourceResponse *request = GetHandle<JniOcResourceResponse>(env, thiz);\r
+    if (env->ExceptionCheck())\r
+    {\r
+        LOGE("Failed to get native handle from JniOcResourceResponse");\r
+    }\r
+    if (!request)\r
+    {\r
+        ThrowOcException(JNI_NO_NATIVE_POINTER, "");\r
+    }\r
+    return request;\r
+}\r
+/*\r
+* Class:     org_iotivity_base_OcResourceResponse\r
+* Method:    setErrorCode\r
+* Signature: (I)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setErrorCode\r
+(JNIEnv *env, jobject thiz, jint eCode)\r
+{\r
+    LOGD("OcResourceResponse_setErrorCode");\r
+    JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);\r
+    if (!response) return;\r
+\r
+    response->setErrorCode(static_cast<int>(eCode));\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResourceResponse\r
+* Method:    getNewResourceUri\r
+* Signature: ()Ljava/lang/String;\r
+*/\r
+JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResourceResponse_getNewResourceUri\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcResourceResponse_getNewResourceUri");\r
+    JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);\r
+    if (!response) return nullptr;\r
+\r
+    return env->NewStringUTF(response->getNewResourceUri().c_str());\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResourceResponse\r
+* Method:    setNewResourceUri\r
+* Signature: (Ljava/lang/String;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setNewResourceUri\r
+(JNIEnv *env, jobject thiz, jstring jstr)\r
+{\r
+    LOGD("OcResourceResponse_setNewResourceUri");\r
+    JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);\r
+    if (!response) return;\r
+\r
+    response->setNewResourceUri(env->GetStringUTFChars(jstr, 0));\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResourceResponse\r
+* Method:    setHeaderOptions\r
+* Signature: (Ljava/util/List;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setHeaderOptions\r
+(JNIEnv *env, jobject thiz, jobjectArray jHeaderOptions)\r
+{\r
+    LOGD("OcResourceResponse_setHeaderOptions");\r
+    if (!jHeaderOptions)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "headerOptionList cannot be null");\r
+        return;\r
+    }\r
+    JniOcResourceResponse *jniResponse = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);\r
+    if (!jniResponse) return;\r
+\r
+    HeaderOptions headerOptions;\r
+    JniUtils::convertJavaHeaderOptionsArrToVector(env, jHeaderOptions, headerOptions);\r
+\r
+    jniResponse->setHeaderOptions(headerOptions);\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResourceResponse\r
+* Method:    setRequestHandle\r
+* Signature: (Lorg/iotivity/base/OcRequestHandle;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setRequestHandle\r
+(JNIEnv *env, jobject thiz, jobject jRequestHandle)\r
+{\r
+    LOGI("OcResourceResponse_setRequestHandle");\r
+    if (!jRequestHandle)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "requestHandle cannot be null");\r
+        return;\r
+    }\r
+    JniOcResourceResponse *jniResponse = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);\r
+    if (!jniResponse) return;\r
+\r
+    JniOcRequestHandle* jniOcRequestHandle = JniOcRequestHandle::getJniOcRequestHandlePtr(env, jRequestHandle);\r
+    if (!jniOcRequestHandle) return;\r
+\r
+    jniResponse->setRequestHandle(jniOcRequestHandle->getOCRequestHandle());\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResourceResponse\r
+* Method:    setResourceHandle\r
+* Signature: (Lorg/iotivity/base/OcResourceHandle;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResourceHandle\r
+(JNIEnv *env, jobject thiz, jobject jResourceHandle)\r
+{\r
+    LOGI("OcResourceResponse_setResourceHandle");\r
+    if (!jResourceHandle)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null");\r
+        return;\r
+    }\r
+    JniOcResourceResponse *jniResponse = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);\r
+    if (!jniResponse) return;\r
+\r
+    JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(env, jResourceHandle);\r
+    if (!jniOcResourceHandle) return;\r
+\r
+    jniResponse->setResourceHandle(jniOcResourceHandle->getOCResourceHandle());\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResourceResponse\r
+* Method:    setResponseResult\r
+* Signature: (I)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResponseResult\r
+(JNIEnv *env, jobject thiz, jint responseResult)\r
+{\r
+    LOGD("OcResourceResponse_setResponseResult");\r
+    JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);\r
+    if (!response) return;\r
+\r
+    response->setResponseResult(JniUtils::getOCEntityHandlerResult(env, static_cast<int>(responseResult)));\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResourceResponse\r
+* Method:    setResourceRepresentation\r
+* Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/lang/String;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResourceRepresentation\r
+(JNIEnv *env, jobject thiz, jobject jRepresentation, jstring jstr)\r
+{\r
+    LOGD("OcResourceResponse_setResourceRepresentation");\r
+    if (!jRepresentation)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "Representation cannot be null");\r
+        return;\r
+    }\r
+    if (!jstr)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "interface cannot be null");\r
+        return;\r
+    }\r
+\r
+    JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env,\r
+        thiz);\r
+    if (!response) return;\r
+\r
+    OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env,\r
+        jRepresentation);\r
+    if (!representation) return;\r
+\r
+    response->setResourceRepresentation(*representation, env->GetStringUTFChars(jstr, 0));\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResourceResponse\r
+* Method:    setResourceRepresentation1\r
+* Signature: (Lorg/iotivity/base/OcRepresentation;)V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResourceRepresentation1\r
+(JNIEnv *env, jobject thiz, jobject jRepresentation)\r
+{\r
+    LOGD("OcResourceResponse_setResourceRepresentation");\r
+    if (!jRepresentation)\r
+    {\r
+        ThrowOcException(OC_STACK_INVALID_PARAM, "Representation cannot be null");\r
+        return;\r
+    }\r
+    JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);\r
+    if (!response) return;\r
+\r
+    OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env,\r
+        jRepresentation);\r
+\r
+    if (representation)\r
+    {\r
+        response->setResourceRepresentation(*representation);\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResourceResponse\r
+* Method:    create\r
+* Signature: ()V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_create\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGI("OcResourceResponse_create");\r
+    auto pResponse = std::make_shared<OC::OCResourceResponse>();\r
+    JniOcResourceResponse* jniResourceResponse = new JniOcResourceResponse(pResponse);\r
+    SetHandle<JniOcResourceResponse>(env, thiz, jniResourceResponse);\r
+    if (env->ExceptionCheck())\r
+    {\r
+        LOGE("Failed to create OcResourceResponse");\r
+        delete jniResourceResponse;\r
+    }\r
+}\r
+\r
+/*\r
+* Class:     org_iotivity_base_OcResourceResponse\r
+* Method:    dispose\r
+* Signature: ()V\r
+*/\r
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_dispose\r
+(JNIEnv *env, jobject thiz)\r
+{\r
+    LOGD("OcResourceResponse_dispose");\r
+    JniOcResourceResponse *resp = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);\r
+    delete resp;\r
+}
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniOcResourceResponse.h b/android/android_api/base/jni/JniOcResourceResponse.h
new file mode 100644 (file)
index 0000000..acabdf6
--- /dev/null
@@ -0,0 +1,144 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniOcStack.h"\r
+#include "OCResourceResponse.h"\r
+\r
+#ifndef _Included_org_iotivity_base_OcResourceResponse\r
+#define _Included_org_iotivity_base_OcResourceResponse\r
+\r
+using namespace OC;\r
+\r
+class JniOcResourceResponse\r
+{\r
+public:\r
+    JniOcResourceResponse(std::shared_ptr<OCResourceResponse> resourceResponse);\r
+    ~JniOcResourceResponse();\r
+    void setErrorCode(const int eCode);\r
+    std::string getNewResourceUri(void);\r
+    void setNewResourceUri(const std::string newResourceUri);\r
+    void setHeaderOptions(const HeaderOptions& headerOptions);\r
+    void setRequestHandle(const OCRequestHandle& requestHandle);\r
+    void setResourceHandle(const OCResourceHandle& resourceHandle);\r
+    void setResponseResult(const OCEntityHandlerResult& responseResult);\r
+    void setResourceRepresentation(OCRepresentation& rep, std::string interfaceStr);\r
+    void setResourceRepresentation(OCRepresentation& rep);\r
+    std::shared_ptr<OCResourceResponse> getOCResourceResponse();\r
+    static JniOcResourceResponse* getJniOcResourceResponsePtr(JNIEnv *env, jobject thiz);\r
+private:\r
+    std::shared_ptr<OCResourceResponse> m_response;\r
+};\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResourceResponse\r
+    * Method:    setErrorCode\r
+    * Signature: (I)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setErrorCode\r
+        (JNIEnv *, jobject, jint);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResourceResponse\r
+    * Method:    getNewResourceUri\r
+    * Signature: ()Ljava/lang/String;\r
+    */\r
+    JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResourceResponse_getNewResourceUri\r
+        (JNIEnv *, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResourceResponse\r
+    * Method:    setNewResourceUri\r
+    * Signature: (Ljava/lang/String;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setNewResourceUri\r
+        (JNIEnv *, jobject, jstring);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResourceResponse\r
+    * Method:    setHeaderOptions\r
+    * Signature: (Ljava/util/List;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setHeaderOptions\r
+        (JNIEnv *, jobject, jobjectArray);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResourceResponse\r
+    * Method:    setRequestHandle\r
+    * Signature: (Lorg/iotivity/base/OcRequestHandle;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setRequestHandle\r
+        (JNIEnv *, jobject, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResourceResponse\r
+    * Method:    setResourceHandle\r
+    * Signature: (Lorg/iotivity/base/OcResourceHandle;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResourceHandle\r
+        (JNIEnv *, jobject, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResourceResponse\r
+    * Method:    setResponseResult\r
+    * Signature: (I)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResponseResult\r
+        (JNIEnv *, jobject, jint);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResourceResponse\r
+    * Method:    setResourceRepresentation\r
+    * Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/lang/String;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResourceRepresentation\r
+        (JNIEnv *, jobject, jobject, jstring);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResourceResponse\r
+    * Method:    setResourceRepresentation1\r
+    * Signature: (Lorg/iotivity/base/OcRepresentation;)V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResourceRepresentation1\r
+        (JNIEnv *, jobject, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResourceResponse\r
+    * Method:    create\r
+    * Signature: ()V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_create\r
+        (JNIEnv *, jobject);\r
+\r
+    /*\r
+    * Class:     org_iotivity_base_OcResourceResponse\r
+    * Method:    dispose\r
+    * Signature: ()V\r
+    */\r
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_dispose\r
+        (JNIEnv *, jobject);\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+#endif
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniOcStack.cpp b/android/android_api/base/jni/JniOcStack.cpp
new file mode 100644 (file)
index 0000000..5f6c1d4
--- /dev/null
@@ -0,0 +1,449 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniOcStack.h"\r
+#include "OCApi.h"\r
+#include "OCPlatform.h"\r
+#include "OCRepresentation.h"\r
+#include "JniUtils.h"\r
+\r
+JavaVM* g_jvm = NULL;\r
+\r
+jclass g_cls_Integer = NULL;\r
+jclass g_cls_int1DArray = NULL;\r
+jclass g_cls_int2DArray = NULL;\r
+jclass g_cls_Double = NULL;\r
+jclass g_cls_double1DArray = NULL;\r
+jclass g_cls_double2DArray = NULL;\r
+jclass g_cls_Boolean = NULL;\r
+jclass g_cls_boolean1DArray = NULL;\r
+jclass g_cls_boolean2DArray = NULL;\r
+jclass g_cls_String = NULL;\r
+jclass g_cls_String1DArray = NULL;\r
+jclass g_cls_String2DArray = NULL;\r
+jclass g_cls_LinkedList = NULL;\r
+jclass g_cls_Map = NULL;\r
+jclass g_cls_MapEntry = NULL;\r
+jclass g_cls_Set = NULL;\r
+jclass g_cls_Iterator = NULL;\r
+jclass g_cls_HashMap = NULL;\r
+jclass g_cls_OcException = NULL;\r
+jclass g_cls_OcResource = NULL;\r
+jclass g_cls_OcRepresentation = NULL;\r
+jclass g_cls_OcRepresentation1DArray = NULL;\r
+jclass g_cls_OcRepresentation2DArray = NULL;\r
+jclass g_cls_OcResourceRequest = NULL;\r
+jclass g_cls_OcResourceResponse = NULL;\r
+jclass g_cls_OcResourceHandle = NULL;\r
+jclass g_cls_OcPresenceHandle = NULL;\r
+jclass g_cls_OcRequestHandle = NULL;\r
+jclass g_cls_OcPresenceStatus = NULL;\r
+jclass g_cls_OcHeaderOption = NULL;\r
+jclass g_cls_ObservationInfo = NULL;\r
+jclass g_cls_OcResourceIdentifier = NULL;\r
+\r
+jmethodID g_mid_Integer_ctor = NULL;\r
+jmethodID g_mid_Double_ctor = NULL;\r
+jmethodID g_mid_Boolean_ctor = NULL;\r
+jmethodID g_mid_LinkedList_ctor = NULL;\r
+jmethodID g_mid_LinkedList_add_object = NULL;\r
+jmethodID g_mid_Map_entrySet = NULL;\r
+jmethodID g_mid_MapEntry_getKey = NULL;\r
+jmethodID g_mid_MapEntry_getValue = NULL;\r
+jmethodID g_mid_Set_iterator = NULL;\r
+jmethodID g_mid_Iterator_hasNext = NULL;\r
+jmethodID g_mid_Iterator_next = NULL;\r
+jmethodID g_mid_HashMap_ctor = NULL;\r
+jmethodID g_mid_HashMap_put = NULL;\r
+jmethodID g_mid_OcException_ctor = NULL;\r
+jmethodID g_mid_OcException_setNativeExceptionLocation = NULL;\r
+jmethodID g_mid_OcResource_ctor = NULL;\r
+jmethodID g_mid_OcRepresentation_N_ctor = NULL;\r
+jmethodID g_mid_OcRepresentation_N_ctor_bool = NULL;\r
+jmethodID g_mid_OcResourceRequest_N_ctor = NULL;\r
+jmethodID g_mid_OcResourceResponse_N_ctor = NULL;\r
+jmethodID g_mid_OcResourceHandle_N_ctor = NULL;\r
+jmethodID g_mid_OcPresenceHandle_N_ctor = NULL;\r
+jmethodID g_mid_OcRequestHandle_N_ctor = NULL;\r
+jmethodID g_mid_OcHeaderOption_ctor = NULL;\r
+jmethodID g_mid_OcHeaderOption_get_id = NULL;\r
+jmethodID g_mid_OcHeaderOption_get_data = NULL;\r
+jmethodID g_mid_ObservationInfo_N_ctor = NULL;\r
+jmethodID g_mid_OcPresenceStatus_get = NULL;\r
+jmethodID g_mid_OcResourceIdentifier_N_ctor = NULL;\r
+\r
+jobject getOcException(JNIEnv* env, const char* file, const char* functionName,\r
+    const int line, const int code, const char* message)\r
+{\r
+    std::string codeStr = JniUtils::stackResultToStr(code);\r
+    if (codeStr.empty())\r
+    {\r
+        codeStr = JniUtils::stackResultToStr(JNI_INVALID_VALUE);\r
+    }\r
+    jobject ex = env->NewObject(g_cls_OcException,\r
+        g_mid_OcException_ctor,\r
+        env->NewStringUTF(codeStr.c_str()),\r
+        env->NewStringUTF(message));\r
+    if (!ex)\r
+    {\r
+        return nullptr;\r
+    }\r
+    env->CallVoidMethod(ex,\r
+        g_mid_OcException_setNativeExceptionLocation,\r
+        env->NewStringUTF(file),\r
+        env->NewStringUTF(functionName),\r
+        line);\r
+    if (env->ExceptionCheck())\r
+    {\r
+        return nullptr;\r
+    }\r
+    return ex;\r
+}\r
+\r
+void throwOcException(JNIEnv* env, jobject ex)\r
+{\r
+    env->Throw((jthrowable)ex);\r
+}\r
+\r
+// JNI OnLoad\r
+JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)\r
+{\r
+    LOGI("JNI_OnLoad");\r
+    JNIEnv* env;\r
+    g_jvm = vm;\r
+\r
+    if (g_jvm->GetEnv((void **)&env, JNI_CURRENT_VERSION) != JNI_OK)\r
+    {\r
+        LOGE("Failed to get the environment using GetEnv()");\r
+        return JNI_ERR;\r
+    }\r
+\r
+    jclass clazz = nullptr;\r
+\r
+    //Integer\r
+    clazz = env->FindClass("java/lang/Integer");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_Integer = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+\r
+    g_mid_Integer_ctor = env->GetMethodID(g_cls_Integer, "<init>", "(I)V");\r
+    if (!g_mid_Integer_ctor) return JNI_ERR;\r
+\r
+    clazz = env->FindClass("[I");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_int1DArray = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+\r
+    clazz = env->FindClass("[[I");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_int2DArray = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+\r
+    //Double\r
+    clazz = env->FindClass("java/lang/Double");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_Double = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+\r
+    g_mid_Double_ctor = env->GetMethodID(g_cls_Double, "<init>", "(D)V");\r
+    if (!g_mid_Double_ctor) return JNI_ERR;\r
+\r
+    clazz = env->FindClass("[D");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_double1DArray = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+\r
+    clazz = env->FindClass("[[D");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_double2DArray = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+\r
+    //Boolean\r
+    clazz = env->FindClass("java/lang/Boolean");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_Boolean = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+\r
+    g_mid_Boolean_ctor = env->GetMethodID(g_cls_Boolean, "<init>", "(Z)V");\r
+    if (!g_mid_Boolean_ctor) return JNI_ERR;\r
+\r
+    clazz = env->FindClass("[Z");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_boolean1DArray = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+\r
+    clazz = env->FindClass("[[Z");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_boolean2DArray = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+\r
+    //String\r
+    clazz = env->FindClass("java/lang/String");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_String = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+\r
+    clazz = env->FindClass("[Ljava/lang/String;");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_String1DArray = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+\r
+    clazz = env->FindClass("[[Ljava/lang/String;");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_String2DArray = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+\r
+    //LinkedList\r
+    clazz = env->FindClass("java/util/LinkedList");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_LinkedList = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+\r
+    g_mid_LinkedList_ctor = env->GetMethodID(g_cls_LinkedList, "<init>", "()V");\r
+    if (!g_mid_LinkedList_ctor) return JNI_ERR;\r
+\r
+    g_mid_LinkedList_add_object = env->GetMethodID(g_cls_LinkedList, "add", "(Ljava/lang/Object;)Z");\r
+    if (!g_mid_LinkedList_add_object) return JNI_ERR;\r
+\r
+    //Map\r
+    clazz = env->FindClass("java/util/Map");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_Map = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+\r
+    g_mid_Map_entrySet = env->GetMethodID(g_cls_Map, "entrySet", "()Ljava/util/Set;");\r
+    if (!g_mid_Map_entrySet) return JNI_ERR;\r
+\r
+    //MapEntry\r
+    clazz = env->FindClass("java/util/Map$Entry");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_MapEntry = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+\r
+    g_mid_MapEntry_getKey = env->GetMethodID(g_cls_MapEntry, "getKey", "()Ljava/lang/Object;");\r
+    if (!g_mid_MapEntry_getKey) return JNI_ERR;\r
+    g_mid_MapEntry_getValue = env->GetMethodID(g_cls_MapEntry, "getValue", "()Ljava/lang/Object;");\r
+    if (!g_mid_MapEntry_getValue) return JNI_ERR;\r
+\r
+    //Set\r
+    clazz = env->FindClass("java/util/Set");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_Set = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+\r
+    g_mid_Set_iterator = env->GetMethodID(g_cls_Set, "iterator", "()Ljava/util/Iterator;");\r
+    if (!g_mid_Set_iterator) return JNI_ERR;\r
+\r
+    //Iterator\r
+    clazz = env->FindClass("java/util/Iterator");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_Iterator = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+\r
+    g_mid_Iterator_hasNext = env->GetMethodID(g_cls_Iterator, "hasNext", "()Z");\r
+    if (!g_mid_Iterator_hasNext) return JNI_ERR;\r
+\r
+    g_mid_Iterator_next = env->GetMethodID(g_cls_Iterator, "next", "()Ljava/lang/Object;");\r
+    if (!g_mid_Iterator_next) return JNI_ERR;\r
+\r
+    //HashMap\r
+    clazz = env->FindClass("java/util/HashMap");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_HashMap = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+\r
+    g_mid_HashMap_ctor = env->GetMethodID(g_cls_HashMap, "<init>", "()V");\r
+    if (!g_mid_HashMap_ctor) return JNI_ERR;\r
+\r
+    g_mid_HashMap_put = env->GetMethodID(g_cls_HashMap, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");\r
+    if (!g_mid_HashMap_put) return JNI_ERR;\r
+\r
+    //OcException\r
+    clazz = env->FindClass("org/iotivity/base/OcException");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_OcException = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+\r
+    g_mid_OcException_ctor = env->GetMethodID(g_cls_OcException, "<init>", "(Ljava/lang/String;Ljava/lang/String;)V");\r
+    if (!g_mid_OcException_ctor) return JNI_ERR;\r
+\r
+    g_mid_OcException_setNativeExceptionLocation = env->GetMethodID(g_cls_OcException, "setNativeExceptionLocation",\r
+        "(Ljava/lang/String;""Ljava/lang/String;""I)V");\r
+    if (!g_mid_OcException_setNativeExceptionLocation) return JNI_ERR;\r
+\r
+    //OcResource\r
+    clazz = env->FindClass("org/iotivity/base/OcResource");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_OcResource = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+\r
+    g_mid_OcResource_ctor = env->GetMethodID(g_cls_OcResource, "<init>", "(J)V");\r
+    if (!g_mid_OcResource_ctor) return JNI_ERR;\r
+\r
+    //OcRepresentation\r
+    clazz = env->FindClass("org/iotivity/base/OcRepresentation");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_OcRepresentation = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+\r
+    g_mid_OcRepresentation_N_ctor = env->GetMethodID(g_cls_OcRepresentation, "<init>", "(J)V");\r
+    if (!g_mid_OcRepresentation_N_ctor) return JNI_ERR;\r
+\r
+    g_mid_OcRepresentation_N_ctor_bool = env->GetMethodID(g_cls_OcRepresentation, "<init>", "(JZ)V");\r
+    if (!g_mid_OcRepresentation_N_ctor_bool) return JNI_ERR;\r
+\r
+    clazz = env->FindClass("[Lorg/iotivity/base/OcRepresentation;");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_OcRepresentation1DArray = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+\r
+    clazz = env->FindClass("[[Lorg/iotivity/base/OcRepresentation;");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_OcRepresentation2DArray = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+\r
+    //HeaderOptions\r
+    clazz = env->FindClass("org/iotivity/base/OcHeaderOption");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_OcHeaderOption = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+    g_mid_OcHeaderOption_ctor = env->GetMethodID(g_cls_OcHeaderOption, "<init>", "(ILjava/lang/String;)V");\r
+    if (!g_mid_OcHeaderOption_ctor) return JNI_ERR;\r
+\r
+    g_mid_OcHeaderOption_get_id = env->GetMethodID(g_cls_OcHeaderOption, "getOptionId", "()I");\r
+    if (!g_mid_OcHeaderOption_get_id) return JNI_ERR;\r
+\r
+    g_mid_OcHeaderOption_get_data = env->GetMethodID(g_cls_OcHeaderOption, "getOptionData", "()Ljava/lang/String;");\r
+    if (!g_mid_OcHeaderOption_get_data) return JNI_ERR;\r
+\r
+    //OcResourceRequest\r
+    clazz = env->FindClass("org/iotivity/base/OcResourceRequest");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_OcResourceRequest = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+\r
+    g_mid_OcResourceRequest_N_ctor = env->GetMethodID(g_cls_OcResourceRequest, "<init>", "(J)V");\r
+    if (!g_mid_OcResourceRequest_N_ctor) return JNI_ERR;\r
+\r
+    //OcResourceResponse\r
+    clazz = env->FindClass("org/iotivity/base/OcResourceResponse");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_OcResourceResponse = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+\r
+    g_mid_OcResourceResponse_N_ctor = env->GetMethodID(g_cls_OcResourceResponse, "<init>", "(J)V");\r
+    if (!g_mid_OcResourceResponse_N_ctor) return JNI_ERR;\r
+\r
+    //OcResourceHandle\r
+    clazz = env->FindClass("org/iotivity/base/OcResourceHandle");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_OcResourceHandle = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+    g_mid_OcResourceHandle_N_ctor = env->GetMethodID(g_cls_OcResourceHandle, "<init>", "(J)V");\r
+    if (!g_mid_OcResourceHandle_N_ctor) return JNI_ERR;\r
+\r
+    //OcPresenceHandle\r
+    clazz = env->FindClass("org/iotivity/base/OcPresenceHandle");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_OcPresenceHandle = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+    g_mid_OcPresenceHandle_N_ctor = env->GetMethodID(g_cls_OcPresenceHandle, "<init>", "(J)V");\r
+    if (!g_mid_OcPresenceHandle_N_ctor) return JNI_ERR;\r
+\r
+    //OcRequestHandle\r
+    clazz = env->FindClass("org/iotivity/base/OcRequestHandle");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_OcRequestHandle = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+    g_mid_OcRequestHandle_N_ctor = env->GetMethodID(g_cls_OcRequestHandle, "<init>", "(J)V");\r
+    if (!g_mid_OcRequestHandle_N_ctor) return JNI_ERR;\r
+\r
+    //OcPresenceStatus\r
+    clazz = env->FindClass("org/iotivity/base/OcPresenceStatus");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_OcPresenceStatus = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+    g_mid_OcPresenceStatus_get = env->GetStaticMethodID(g_cls_OcPresenceStatus, "get",\r
+        "(Ljava/lang/String;)Lorg/iotivity/base/OcPresenceStatus;");\r
+    if (!g_mid_OcPresenceStatus_get) return JNI_ERR;\r
+\r
+    //ObservationInfo\r
+    clazz = env->FindClass("org/iotivity/base/ObservationInfo");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_ObservationInfo = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+    g_mid_ObservationInfo_N_ctor = env->GetMethodID(g_cls_ObservationInfo, "<init>", "(IB)V");\r
+    if (!g_mid_ObservationInfo_N_ctor) return JNI_ERR;\r
+\r
+    clazz = env->FindClass("org/iotivity/base/OcResourceIdentifier");\r
+    if (!clazz) return JNI_ERR;\r
+    g_cls_OcResourceIdentifier = (jclass)env->NewGlobalRef(clazz);\r
+    env->DeleteLocalRef(clazz);\r
+    g_mid_OcResourceIdentifier_N_ctor = env->GetMethodID(g_cls_OcResourceIdentifier, "<init>", "(J)V");\r
+    if (!g_mid_OcResourceIdentifier_N_ctor) return JNI_ERR;\r
+\r
+    return JNI_CURRENT_VERSION;\r
+}\r
+\r
+JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved)\r
+{\r
+    LOGI("JNI_OnUnload");\r
+    JNIEnv* env;\r
+\r
+    if (g_jvm->GetEnv((void **)&env, JNI_CURRENT_VERSION) != JNI_OK)\r
+    {\r
+        LOGE("Failed to get the environment using GetEnv()");\r
+        return;\r
+    }\r
+\r
+    env->DeleteGlobalRef(g_cls_Integer);\r
+    env->DeleteGlobalRef(g_cls_int1DArray);\r
+    env->DeleteGlobalRef(g_cls_int2DArray);\r
+    env->DeleteGlobalRef(g_cls_Double);\r
+    env->DeleteGlobalRef(g_cls_double1DArray);\r
+    env->DeleteGlobalRef(g_cls_double2DArray);\r
+    env->DeleteGlobalRef(g_cls_Boolean);\r
+    env->DeleteGlobalRef(g_cls_boolean1DArray);\r
+    env->DeleteGlobalRef(g_cls_boolean2DArray);\r
+    env->DeleteGlobalRef(g_cls_String);\r
+    env->DeleteGlobalRef(g_cls_String1DArray);\r
+    env->DeleteGlobalRef(g_cls_String2DArray);\r
+    env->DeleteGlobalRef(g_cls_LinkedList);\r
+    env->DeleteGlobalRef(g_cls_Map);\r
+    env->DeleteGlobalRef(g_cls_MapEntry);\r
+    env->DeleteGlobalRef(g_cls_Set);\r
+    env->DeleteGlobalRef(g_cls_Iterator);\r
+    env->DeleteGlobalRef(g_cls_HashMap);\r
+    env->DeleteGlobalRef(g_cls_OcResource);\r
+    env->DeleteGlobalRef(g_cls_OcException);\r
+    env->DeleteGlobalRef(g_cls_OcRepresentation);\r
+    env->DeleteGlobalRef(g_cls_OcRepresentation1DArray);\r
+    env->DeleteGlobalRef(g_cls_OcRepresentation2DArray);\r
+    env->DeleteGlobalRef(g_cls_OcResourceRequest);\r
+    env->DeleteGlobalRef(g_cls_OcResourceResponse);\r
+    env->DeleteGlobalRef(g_cls_OcResourceHandle);\r
+    env->DeleteGlobalRef(g_cls_OcPresenceHandle);\r
+    env->DeleteGlobalRef(g_cls_OcRequestHandle);\r
+    env->DeleteGlobalRef(g_cls_OcPresenceStatus);\r
+    env->DeleteGlobalRef(g_cls_OcHeaderOption);\r
+    env->DeleteGlobalRef(g_cls_ObservationInfo);\r
+    env->DeleteGlobalRef(g_cls_OcResourceIdentifier);\r
+}
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniOcStack.h b/android/android_api/base/jni/JniOcStack.h
new file mode 100644 (file)
index 0000000..bd0ddd5
--- /dev/null
@@ -0,0 +1,169 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include <jni.h>\r
+#include <android/log.h>\r
+#include "OCApi.h"\r
+\r
+#ifndef _Included_org_iotivity_base_ocstack\r
+#define _Included_org_iotivity_base_ocstack\r
+\r
+#define TAG "OIC-JNI"\r
+\r
+#define JNI_CURRENT_VERSION JNI_VERSION_1_6\r
+\r
+#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__)\r
+#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__)\r
+#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__)\r
+\r
+#define JNI_EXCEPTION 1000\r
+#define JNI_NO_NATIVE_POINTER 1001\r
+#define JNI_INVALID_VALUE 1002\r
+#define JNI_NO_SUCH_KEY 1003\r
+\r
+jobject getOcException(JNIEnv* env, const char* file, const char* functionName, const int line,\r
+    const int code, const char* message);\r
+void throwOcException(JNIEnv* env, jobject ex);\r
+#define GetOcException(code, message) getOcException (env,__FILE__,__func__,__LINE__,code,message)\r
+#define ThrowOcException(code, message) throwOcException (env, GetOcException(code, message))\r
+\r
+extern JavaVM* g_jvm;\r
+\r
+extern jclass g_cls_Integer;\r
+extern jclass g_cls_int1DArray;\r
+extern jclass g_cls_int2DArray;\r
+extern jclass g_cls_Double;\r
+extern jclass g_cls_double1DArray;\r
+extern jclass g_cls_double2DArray;\r
+extern jclass g_cls_Boolean;\r
+extern jclass g_cls_boolean1DArray;\r
+extern jclass g_cls_boolean2DArray;\r
+extern jclass g_cls_String;\r
+extern jclass g_cls_String1DArray;\r
+extern jclass g_cls_String2DArray;\r
+extern jclass g_cls_LinkedList;\r
+extern jclass g_cls_Map;\r
+extern jclass g_cls_MapEntry;\r
+extern jclass g_cls_Set;\r
+extern jclass g_cls_Iterator;\r
+extern jclass g_cls_HashMap;\r
+extern jclass g_cls_OcException;\r
+extern jclass g_cls_OcResource;\r
+extern jclass g_cls_OcRepresentation;\r
+extern jclass g_cls_OcRepresentation1DArray;\r
+extern jclass g_cls_OcRepresentation2DArray;\r
+extern jclass g_cls_OcResourceRequest;\r
+extern jclass g_cls_OcResourceResponse;\r
+extern jclass g_cls_OcResourceHandle;\r
+extern jclass g_cls_OcPresenceHandle;\r
+extern jclass g_cls_OcRequestHandle;\r
+extern jclass g_cls_OcPresenceStatus;\r
+extern jclass g_cls_OcHeaderOption;\r
+extern jclass g_cls_ObservationInfo;\r
+extern jclass g_cls_OcResourceIdentifier;\r
+\r
+extern jmethodID g_mid_Integer_ctor;\r
+extern jmethodID g_mid_Double_ctor;\r
+extern jmethodID g_mid_Boolean_ctor;\r
+extern jmethodID g_mid_LinkedList_ctor;\r
+extern jmethodID g_mid_LinkedList_add_object;\r
+extern jmethodID g_mid_Map_entrySet;\r
+extern jmethodID g_mid_MapEntry_getKey;\r
+extern jmethodID g_mid_MapEntry_getValue;\r
+extern jmethodID g_mid_Set_iterator;\r
+extern jmethodID g_mid_Iterator_hasNext;\r
+extern jmethodID g_mid_Iterator_next;\r
+extern jmethodID g_mid_HashMap_ctor;\r
+extern jmethodID g_mid_HashMap_put;\r
+extern jmethodID g_mid_OcException_ctor;\r
+extern jmethodID g_mid_OcException_setNativeExceptionLocation;\r
+extern jmethodID g_mid_OcResource_ctor;\r
+extern jmethodID g_mid_OcRepresentation_N_ctor;\r
+extern jmethodID g_mid_OcRepresentation_N_ctor_bool;\r
+extern jmethodID g_mid_OcResourceRequest_N_ctor;\r
+extern jmethodID g_mid_OcResourceResponse_N_ctor;\r
+extern jmethodID g_mid_OcResourceHandle_N_ctor;\r
+extern jmethodID g_mid_OcPresenceHandle_N_ctor;\r
+extern jmethodID g_mid_OcRequestHandle_N_ctor;\r
+extern jmethodID g_mid_OcHeaderOption_ctor;\r
+extern jmethodID g_mid_OcHeaderOption_get_id;\r
+extern jmethodID g_mid_OcHeaderOption_get_data;\r
+extern jmethodID g_mid_ObservationInfo_N_ctor;\r
+extern jmethodID g_mid_OcPresenceStatus_get;\r
+extern jmethodID g_mid_OcResourceIdentifier_N_ctor;\r
+\r
+typedef void(*RemoveListenerCallback)(JNIEnv* env, jobject jListener);\r
+\r
+static jfieldID GetHandleField(JNIEnv *env, jobject jobj)\r
+{\r
+    jclass cls = env->GetObjectClass(jobj);\r
+    return env->GetFieldID(cls, "mNativeHandle", "J");\r
+}\r
+\r
+template <typename T>\r
+static T *GetHandle(JNIEnv *env, jobject jobj)\r
+{\r
+    jlong handle = env->GetLongField(jobj, GetHandleField(env, jobj));\r
+    return reinterpret_cast<T *>(handle);\r
+}\r
+\r
+template <typename T>\r
+static void SetHandle(JNIEnv *env, jobject jobj, T *type)\r
+{\r
+    jlong handle = reinterpret_cast<jlong>(type);\r
+\r
+    env->SetLongField(jobj, GetHandleField(env, jobj), handle);\r
+}\r
+\r
+static JNIEnv* GetJNIEnv(jint& ret)\r
+{\r
+    JNIEnv *env = NULL;\r
+\r
+    ret = g_jvm->GetEnv((void **)&env, JNI_CURRENT_VERSION);\r
+    switch (ret) {\r
+    case JNI_OK:\r
+        return env;\r
+    case JNI_EDETACHED:\r
+        if (g_jvm->AttachCurrentThread(&env, NULL) < 0)\r
+        {\r
+            LOGE("Failed to get the environment");\r
+            return nullptr;\r
+        }\r
+        else\r
+        {\r
+            return env;\r
+        }\r
+\r
+    case JNI_EVERSION:\r
+        LOGE("JNI version not supported");\r
+    default:\r
+        LOGE("Failed to get the environment");\r
+        return nullptr;\r
+    }\r
+}\r
+\r
+static void DuplicateString(char ** targetString, std::string sourceString)\r
+{\r
+    *targetString = new char[sourceString.length() + 1];\r
+    strncpy(*targetString, sourceString.c_str(), (sourceString.length() + 1));\r
+}\r
+\r
+#endif // _Included_org_iotivity_base_ocstack
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniOnDeleteListener.cpp b/android/android_api/base/jni/JniOnDeleteListener.cpp
new file mode 100644 (file)
index 0000000..ed39e3b
--- /dev/null
@@ -0,0 +1,121 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+\r
+#include "JniOnDeleteListener.h"\r
+#include "JniOcResource.h"\r
+#include "JniUtils.h"\r
+\r
+JniOnDeleteListener::JniOnDeleteListener(JNIEnv *env, jobject jListener, JniOcResource* owner)\r
+    : m_ownerResource(owner)\r
+{\r
+    m_jwListener = env->NewWeakGlobalRef(jListener);\r
+}\r
+\r
+JniOnDeleteListener::~JniOnDeleteListener()\r
+{\r
+    if (m_jwListener)\r
+    {\r
+        jint ret;\r
+        JNIEnv *env = GetJNIEnv(ret);\r
+        if (NULL == env) return;\r
+        env->DeleteWeakGlobalRef(m_jwListener);\r
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
+    }\r
+}\r
+\r
+void JniOnDeleteListener::onDeleteCallback(const HeaderOptions& headerOptions, const int eCode)\r
+{\r
+    jint envRet;\r
+    JNIEnv *env = GetJNIEnv(envRet);\r
+    if (NULL == env) return;\r
+\r
+    jobject jListener = env->NewLocalRef(m_jwListener);\r
+    if (!jListener)\r
+    {\r
+        checkExAndRemoveListener(env);\r
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+        return;\r
+    }\r
+    jclass clsL = env->GetObjectClass(jListener);\r
+    if (!clsL)\r
+    {\r
+        checkExAndRemoveListener(env);\r
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+        return;\r
+    }\r
+\r
+    if (OC_STACK_RESOURCE_DELETED != eCode)\r
+    {\r
+        jobject ex = GetOcException(eCode, "stack error in onDeleteCallback");\r
+        if (!ex)\r
+        {\r
+            checkExAndRemoveListener(env);\r
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+            return;\r
+        }\r
+        jmethodID midL = env->GetMethodID(clsL, "onDeleteFailed", "(Ljava/lang/Throwable;)V");\r
+        if (!midL)\r
+        {\r
+            checkExAndRemoveListener(env);\r
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+            return;\r
+        }\r
+        env->CallVoidMethod(jListener, midL, ex);\r
+    }\r
+    else\r
+    {\r
+        jobject jHeaderOptionList = JniUtils::convertHeaderOptionsVectorToJavaList(env, headerOptions);\r
+        if (!jHeaderOptionList)\r
+        {\r
+            checkExAndRemoveListener(env);\r
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+            return;\r
+        }\r
+\r
+        jmethodID midL = env->GetMethodID(clsL, "onDeleteCompleted", "(Ljava/util/List;)V");\r
+        if (!midL)\r
+        {\r
+            checkExAndRemoveListener(env);\r
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+            return;\r
+        }\r
+        env->CallVoidMethod(jListener, midL, jHeaderOptionList);\r
+    }\r
+\r
+    checkExAndRemoveListener(env);\r
+    if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+}\r
+\r
+void JniOnDeleteListener::checkExAndRemoveListener(JNIEnv* env)\r
+{\r
+    if (env->ExceptionCheck())\r
+    {\r
+        jthrowable ex = env->ExceptionOccurred();\r
+        env->ExceptionClear();\r
+        m_ownerResource->removeOnDeleteListener(env, m_jwListener);\r
+        env->Throw((jthrowable)ex);\r
+    }\r
+    else\r
+    {\r
+        m_ownerResource->removeOnDeleteListener(env, m_jwListener);\r
+    }\r
+}
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniOnDeleteListener.h b/android/android_api/base/jni/JniOnDeleteListener.h
new file mode 100644 (file)
index 0000000..45ae34b
--- /dev/null
@@ -0,0 +1,45 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniOcStack.h"\r
+\r
+#ifndef _Included_org_iotivity_base_OcResource_OnDeleteListener\r
+#define _Included_org_iotivity_base_OcResource_OnDeleteListener\r
+\r
+using namespace OC;\r
+\r
+class JniOcResource;\r
+\r
+class JniOnDeleteListener\r
+{\r
+public:\r
+    JniOnDeleteListener(JNIEnv *env, jobject jListener, JniOcResource* owner);\r
+    ~JniOnDeleteListener();\r
+\r
+    void onDeleteCallback(const HeaderOptions&, const int eCode);\r
+\r
+private:\r
+    jweak m_jwListener;\r
+    JniOcResource* m_ownerResource;\r
+    void checkExAndRemoveListener(JNIEnv *env);\r
+};\r
+\r
+#endif
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniOnDeviceInfoListener.cpp b/android/android_api/base/jni/JniOnDeviceInfoListener.cpp
new file mode 100644 (file)
index 0000000..483fac6
--- /dev/null
@@ -0,0 +1,113 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniOnDeviceInfoListener.h"\r
+#include "JniOcRepresentation.h"\r
+\r
+JniOnDeviceInfoListener::JniOnDeviceInfoListener(JNIEnv *env, jobject jListener,\r
+    RemoveListenerCallback removeListenerCallback)\r
+{\r
+    m_jwListener = env->NewWeakGlobalRef(jListener);\r
+    m_removeListenerCallback = removeListenerCallback;\r
+}\r
+\r
+JniOnDeviceInfoListener::~JniOnDeviceInfoListener()\r
+{\r
+    LOGI("~JniOnDeviceInfoListener");\r
+    if (m_jwListener)\r
+    {\r
+        jint ret;\r
+        JNIEnv *env = GetJNIEnv(ret);\r
+        if (NULL == env) return;\r
+        env->DeleteWeakGlobalRef(m_jwListener);\r
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
+    }\r
+}\r
+\r
+void JniOnDeviceInfoListener::foundDeviceCallback(const OC::OCRepresentation& ocRepresentation)\r
+{\r
+    jint ret;\r
+    JNIEnv *env = GetJNIEnv(ret);\r
+    if (NULL == env) return;\r
+\r
+    jobject jListener = env->NewLocalRef(m_jwListener);\r
+    if (!jListener)\r
+    {\r
+        LOGI("Java onDeviceInfoListener object is already destroyed, quiting");\r
+        checkExAndRemoveListener(env);\r
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
+        return;\r
+    }\r
+\r
+    OCRepresentation* rep = new OCRepresentation(ocRepresentation);\r
+    jlong handle = reinterpret_cast<jlong>(rep);\r
+    jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool,\r
+        handle, true);\r
+    if (!jRepresentation)\r
+    {\r
+        delete rep;\r
+        checkExAndRemoveListener(env);\r
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
+        return;\r
+    }\r
+\r
+    jclass clsL = env->GetObjectClass(jListener);\r
+    if (!clsL)\r
+    {\r
+        delete rep;\r
+        checkExAndRemoveListener(env);\r
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
+        return;\r
+    }\r
+    jmethodID midL = env->GetMethodID(clsL, "onDeviceFound", "(Lorg/iotivity/base/OcRepresentation;)V");\r
+    if (!midL)\r
+    {\r
+        delete rep;\r
+        checkExAndRemoveListener(env);\r
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
+        return;\r
+    }\r
+\r
+    env->CallVoidMethod(jListener, midL, jRepresentation);\r
+    if (env->ExceptionCheck())\r
+    {\r
+        LOGE("Java exception is thrown");\r
+        delete rep;\r
+        checkExAndRemoveListener(env);\r
+    }\r
+\r
+    if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
+}\r
+\r
+void JniOnDeviceInfoListener::checkExAndRemoveListener(JNIEnv* env)\r
+{\r
+    if (env->ExceptionCheck())\r
+    {\r
+        jthrowable ex = env->ExceptionOccurred();\r
+        env->ExceptionClear();\r
+        m_removeListenerCallback(env, m_jwListener);\r
+        env->Throw((jthrowable)ex);\r
+    }\r
+    else\r
+    {\r
+        m_removeListenerCallback(env, m_jwListener);\r
+    }\r
+}
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniOnDeviceInfoListener.h b/android/android_api/base/jni/JniOnDeviceInfoListener.h
new file mode 100644 (file)
index 0000000..152ca8c
--- /dev/null
@@ -0,0 +1,42 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include <jni.h>\r
+#include "JniOcStack.h"\r
+\r
+#ifndef _Included_org_iotivity_base_OcPlatform_OnDeviceFoundListener\r
+#define _Included_org_iotivity_base_OcPlatform_OnDeviceFoundListener\r
+\r
+class JniOnDeviceInfoListener\r
+{\r
+public:\r
+    JniOnDeviceInfoListener(JNIEnv *env, jobject jListener, RemoveListenerCallback removeListener);\r
+    ~JniOnDeviceInfoListener();\r
+\r
+    void foundDeviceCallback(const OC::OCRepresentation& ocRepresentation);\r
+\r
+private:\r
+    jweak m_jwListener;\r
+    RemoveListenerCallback m_removeListenerCallback;\r
+    void checkExAndRemoveListener(JNIEnv* env);\r
+};\r
+\r
+#endif\r
diff --git a/android/android_api/base/jni/JniOnGetListener.cpp b/android/android_api/base/jni/JniOnGetListener.cpp
new file mode 100644 (file)
index 0000000..4ac19bc
--- /dev/null
@@ -0,0 +1,144 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniOnGetListener.h"\r
+#include "JniOcResource.h"\r
+#include "JniOcRepresentation.h"\r
+#include "JniUtils.h"\r
+\r
+JniOnGetListener::JniOnGetListener(JNIEnv *env, jobject jListener, JniOcResource* owner)\r
+    : m_ownerResource(owner)\r
+{\r
+    m_jwListener = env->NewWeakGlobalRef(jListener);\r
+}\r
+\r
+JniOnGetListener::~JniOnGetListener()\r
+{\r
+    if (m_jwListener)\r
+    {\r
+        jint ret;\r
+        JNIEnv *env = GetJNIEnv(ret);\r
+        if (NULL == env) return;\r
+\r
+        env->DeleteWeakGlobalRef(m_jwListener);\r
+\r
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
+    }\r
+}\r
+\r
+void JniOnGetListener::onGetCallback(const HeaderOptions& headerOptions,\r
+    const OCRepresentation& ocRepresentation, const int eCode)\r
+{\r
+    jint envRet;\r
+    JNIEnv *env = GetJNIEnv(envRet);\r
+    if (NULL == env) return;\r
+\r
+    jobject jListener = env->NewLocalRef(m_jwListener);\r
+    if (!jListener)\r
+    {\r
+        checkExAndRemoveListener(env);\r
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+        return;\r
+    }\r
+    jclass clsL = env->GetObjectClass(jListener);\r
+\r
+    if (!clsL)\r
+    {\r
+        checkExAndRemoveListener(env);\r
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+        return;\r
+    }\r
+\r
+    if (OC_STACK_OK != eCode)\r
+    {\r
+        jobject ex = GetOcException(eCode, "stack error in onGetCallback");\r
+        if (!ex)\r
+        {\r
+            checkExAndRemoveListener(env);\r
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+            return;\r
+        }\r
+        jmethodID midL = env->GetMethodID(clsL, "onGetFailed", "(Ljava/lang/Throwable;)V");\r
+        if (!midL)\r
+        {\r
+            checkExAndRemoveListener(env);\r
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+            return;\r
+        }\r
+        env->CallVoidMethod(jListener, midL, ex);\r
+    }\r
+    else\r
+    {\r
+        jobject jHeaderOptionList = JniUtils::convertHeaderOptionsVectorToJavaList(env, headerOptions);\r
+        if (!jHeaderOptionList)\r
+        {\r
+            checkExAndRemoveListener(env);\r
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+            return;\r
+        }\r
+\r
+        OCRepresentation* rep = new OCRepresentation(ocRepresentation);\r
+        jlong handle = reinterpret_cast<jlong>(rep);\r
+        jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool,\r
+            handle, true);\r
+        if (!jRepresentation)\r
+        {\r
+            delete rep;\r
+            checkExAndRemoveListener(env);\r
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+            return;\r
+        }\r
+\r
+        jmethodID midL = env->GetMethodID(clsL, "onGetCompleted",\r
+            "(Ljava/util/List;Lorg/iotivity/base/OcRepresentation;)V");\r
+        if (!midL)\r
+        {\r
+            delete rep;\r
+            checkExAndRemoveListener(env);\r
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+            return;\r
+        }\r
+        env->CallVoidMethod(jListener, midL, jHeaderOptionList, jRepresentation);\r
+        if (env->ExceptionCheck())\r
+        {\r
+            LOGE("Java exception is thrown");\r
+            delete rep;\r
+        }\r
+    }\r
+\r
+    checkExAndRemoveListener(env);\r
+    if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+}\r
+\r
+void JniOnGetListener::checkExAndRemoveListener(JNIEnv* env)\r
+{\r
+    if (env->ExceptionCheck())\r
+    {\r
+        jthrowable ex = env->ExceptionOccurred();\r
+        env->ExceptionClear();\r
+        m_ownerResource->removeOnGetListener(env, m_jwListener);\r
+        env->Throw((jthrowable)ex);\r
+    }\r
+    else\r
+    {\r
+        m_ownerResource->removeOnGetListener(env, m_jwListener);\r
+    }\r
+}
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniOnGetListener.h b/android/android_api/base/jni/JniOnGetListener.h
new file mode 100644 (file)
index 0000000..af69f1b
--- /dev/null
@@ -0,0 +1,43 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniOcStack.h"\r
+\r
+#ifndef _Included_org_iotivity_base_OcResource_OnGetListener\r
+#define _Included_org_iotivity_base_OcResource_OnGetListener\r
+\r
+using namespace OC;\r
+\r
+class JniOcResource;\r
+\r
+class JniOnGetListener\r
+{\r
+public:\r
+    JniOnGetListener(JNIEnv *env, jobject listener, JniOcResource* resource);\r
+    ~JniOnGetListener();\r
+    void onGetCallback(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode);\r
+private:\r
+    jweak m_jwListener;\r
+    JniOcResource* m_ownerResource;\r
+    void checkExAndRemoveListener(JNIEnv *env);\r
+};\r
+\r
+#endif
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniOnObserveListener.cpp b/android/android_api/base/jni/JniOnObserveListener.cpp
new file mode 100644 (file)
index 0000000..7afb1e1
--- /dev/null
@@ -0,0 +1,147 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniOnObserveListener.h"\r
+#include "JniOcResource.h"\r
+#include "JniOcRepresentation.h"\r
+#include "JniUtils.h"\r
+\r
+JniOnObserveListener::JniOnObserveListener(JNIEnv *env, jobject jListener, JniOcResource* owner)\r
+    : m_ownerResource(owner)\r
+{\r
+    m_jwListener = env->NewWeakGlobalRef(jListener);\r
+}\r
+\r
+JniOnObserveListener::~JniOnObserveListener()\r
+{\r
+    if (m_jwListener)\r
+    {\r
+        jint ret;\r
+        JNIEnv *env = GetJNIEnv(ret);\r
+        if (NULL == env) return;\r
+\r
+        env->DeleteWeakGlobalRef(m_jwListener);\r
+\r
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
+    }\r
+}\r
+\r
+void JniOnObserveListener::onObserveCallback(const HeaderOptions headerOptions,\r
+    const OCRepresentation& ocRepresentation, const int& eCode, const int& sequenceNumber)\r
+{\r
+    jint envRet;\r
+    JNIEnv *env = GetJNIEnv(envRet);\r
+    if (NULL == env) return;\r
+\r
+    jobject jListener = env->NewLocalRef(m_jwListener);\r
+    if (!jListener)\r
+    {\r
+        checkExAndRemoveListener(env);\r
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+        return;\r
+    }\r
+    jclass clsL = env->GetObjectClass(jListener);\r
+    if (!clsL)\r
+    {\r
+        checkExAndRemoveListener(env);\r
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+        return;\r
+    }\r
+\r
+    if (OC_STACK_OK != eCode && OC_STACK_RESOURCE_CREATED != eCode && OC_STACK_RESOURCE_DELETED != eCode)\r
+    {\r
+        jobject ex = GetOcException(eCode, "stack error in onObserveCallback");\r
+        if (!ex)\r
+        {\r
+            checkExAndRemoveListener(env);\r
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+            return;\r
+        }\r
+        jmethodID midL = env->GetMethodID(clsL, "onObserveFailed", "(Ljava/lang/Throwable;)V");\r
+        if (!midL)\r
+        {\r
+            checkExAndRemoveListener(env);\r
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+            return;\r
+        }\r
+        env->CallVoidMethod(jListener, midL, ex);\r
+    }\r
+    else\r
+    {\r
+        jobject jHeaderOptionList = JniUtils::convertHeaderOptionsVectorToJavaList(env, headerOptions);\r
+        if (!jHeaderOptionList)\r
+        {\r
+            checkExAndRemoveListener(env);\r
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+            return;\r
+        }\r
+\r
+        OCRepresentation * rep = new OCRepresentation(ocRepresentation);\r
+        jlong handle = reinterpret_cast<jlong>(rep);\r
+        jobject jRepresentation = env->NewObject(g_cls_OcRepresentation,\r
+            g_mid_OcRepresentation_N_ctor_bool, handle, true);\r
+        if (!jRepresentation)\r
+        {\r
+            delete rep;\r
+            checkExAndRemoveListener(env);\r
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+            return;\r
+        }\r
+\r
+        jmethodID midL = env->GetMethodID(clsL, "onObserveCompleted",\r
+            "(Ljava/util/List;Lorg/iotivity/base/OcRepresentation;I)V");\r
+        if (!midL)\r
+        {\r
+            checkExAndRemoveListener(env);\r
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+            return;\r
+        }\r
+\r
+        env->CallVoidMethod(jListener, midL, jHeaderOptionList, jRepresentation,\r
+            static_cast<jint>(sequenceNumber));\r
+        if (env->ExceptionCheck())\r
+        {\r
+            LOGE("Java exception is thrown");\r
+            delete rep;\r
+            jthrowable ex = env->ExceptionOccurred();\r
+            env->ExceptionClear();\r
+            m_ownerResource->removeOnObserveListener(env, m_jwListener);\r
+            env->Throw((jthrowable)ex);\r
+        }\r
+    }\r
+\r
+    if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+}\r
+\r
+void JniOnObserveListener::checkExAndRemoveListener(JNIEnv* env)\r
+{\r
+    if (env->ExceptionCheck())\r
+    {\r
+        jthrowable ex = env->ExceptionOccurred();\r
+        env->ExceptionClear();\r
+        m_ownerResource->removeOnObserveListener(env, m_jwListener);\r
+        env->Throw((jthrowable)ex);\r
+    }\r
+    else\r
+    {\r
+        m_ownerResource->removeOnObserveListener(env, m_jwListener);\r
+    }\r
+}
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniOnObserveListener.h b/android/android_api/base/jni/JniOnObserveListener.h
new file mode 100644 (file)
index 0000000..ae1d042
--- /dev/null
@@ -0,0 +1,44 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniOcStack.h"\r
+\r
+#ifndef _Included_org_iotivity_base_OcResource_OnObserveListener\r
+#define _Included_org_iotivity_base_OcResource_OnObserveListener\r
+\r
+using namespace OC;\r
+\r
+class JniOcResource;\r
+\r
+class JniOnObserveListener\r
+{\r
+public:\r
+    JniOnObserveListener(JNIEnv *env, jobject jListener, JniOcResource* owner);\r
+    ~JniOnObserveListener();\r
+    void onObserveCallback(const HeaderOptions headerOptions, const OCRepresentation& rep,\r
+        const int& eCode, const int& sequenceNumber);\r
+private:\r
+    jweak m_jwListener;\r
+    JniOcResource* m_ownerResource;\r
+    void checkExAndRemoveListener(JNIEnv *env);\r
+};\r
+\r
+#endif
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniOnPostListener.cpp b/android/android_api/base/jni/JniOnPostListener.cpp
new file mode 100644 (file)
index 0000000..b9eb997
--- /dev/null
@@ -0,0 +1,143 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniOnPostListener.h"\r
+#include "JniOcResource.h"\r
+#include "JniOcRepresentation.h"\r
+#include "JniUtils.h"\r
+\r
+JniOnPostListener::JniOnPostListener(JNIEnv *env, jobject jListener, JniOcResource* owner)\r
+    : m_ownerResource(owner)\r
+{\r
+    m_jwListener = env->NewWeakGlobalRef(jListener);\r
+}\r
+\r
+JniOnPostListener::~JniOnPostListener()\r
+{\r
+    if (m_jwListener)\r
+    {\r
+        jint ret;\r
+        JNIEnv *env = GetJNIEnv(ret);\r
+        if (NULL == env) return;\r
+\r
+        env->DeleteWeakGlobalRef(m_jwListener);\r
+\r
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
+    }\r
+}\r
+\r
+void JniOnPostListener::onPostCallback(const HeaderOptions& headerOptions,\r
+    const OCRepresentation& ocRepresentation, const int eCode)\r
+{\r
+    jint envRet;\r
+    JNIEnv *env = GetJNIEnv(envRet);\r
+    if (NULL == env) return;\r
+\r
+    jobject jListener = env->NewLocalRef(m_jwListener);\r
+    if (!jListener)\r
+    {\r
+        checkExAndRemoveListener(env);\r
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+        return;\r
+    }\r
+    jclass clsL = env->GetObjectClass(jListener);\r
+    if (!clsL)\r
+    {\r
+        checkExAndRemoveListener(env);\r
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+        return;\r
+    }\r
+\r
+    if (OC_STACK_OK != eCode && OC_STACK_RESOURCE_CREATED != eCode)\r
+    {\r
+        jobject ex = GetOcException(eCode, "stack error in onPostCallback");\r
+        if (!ex)\r
+        {\r
+            checkExAndRemoveListener(env);\r
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+            return;\r
+        }\r
+        jmethodID midL = env->GetMethodID(clsL, "onPostFailed", "(Ljava/lang/Throwable;)V");\r
+        if (!midL)\r
+        {\r
+            checkExAndRemoveListener(env);\r
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+            return;\r
+        }\r
+        env->CallVoidMethod(jListener, midL, ex);\r
+    }\r
+    else\r
+    {\r
+        jobject jHeaderOptionList = JniUtils::convertHeaderOptionsVectorToJavaList(env, headerOptions);\r
+        if (!jHeaderOptionList)\r
+        {\r
+            checkExAndRemoveListener(env);\r
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+            return;\r
+        }\r
+\r
+        OCRepresentation * rep = new OCRepresentation(ocRepresentation);\r
+        jlong handle = reinterpret_cast<jlong>(rep);\r
+        jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool,\r
+            handle, true);\r
+        if (!jRepresentation)\r
+        {\r
+            delete rep;\r
+            checkExAndRemoveListener(env);\r
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+            return;\r
+        }\r
+\r
+        jmethodID midL = env->GetMethodID(clsL, "onPostCompleted",\r
+            "(Ljava/util/List;Lorg/iotivity/base/OcRepresentation;)V");\r
+        if (!midL)\r
+        {\r
+            checkExAndRemoveListener(env);\r
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+            return;\r
+        }\r
+\r
+        env->CallVoidMethod(jListener, midL, jHeaderOptionList, jRepresentation);\r
+        if (env->ExceptionCheck())\r
+        {\r
+            LOGE("Java exception is thrown");\r
+            delete rep;\r
+        }\r
+    }\r
+\r
+    checkExAndRemoveListener(env);\r
+    if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+}\r
+\r
+void JniOnPostListener::checkExAndRemoveListener(JNIEnv* env)\r
+{\r
+    if (env->ExceptionCheck())\r
+    {\r
+        jthrowable ex = env->ExceptionOccurred();\r
+        env->ExceptionClear();\r
+        m_ownerResource->removeOnPostListener(env, m_jwListener);\r
+        env->Throw((jthrowable)ex);\r
+    }\r
+    else\r
+    {\r
+        m_ownerResource->removeOnPostListener(env, m_jwListener);\r
+    }\r
+}
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniOnPostListener.h b/android/android_api/base/jni/JniOnPostListener.h
new file mode 100644 (file)
index 0000000..9090507
--- /dev/null
@@ -0,0 +1,45 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniOcStack.h"\r
+\r
+#ifndef _Included_org_iotivity_base_OcResource_OnPostListener\r
+#define _Included_org_iotivity_base_OcResource_OnPostListener\r
+\r
+using namespace OC;\r
+\r
+class JniOcResource;\r
+\r
+class JniOnPostListener\r
+{\r
+public:\r
+    JniOnPostListener(JNIEnv *env, jobject jListener, JniOcResource* owner);\r
+    ~JniOnPostListener();\r
+\r
+    void onPostCallback(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode);\r
+\r
+private:\r
+    jweak m_jwListener;\r
+    JniOcResource* m_ownerResource;\r
+    void checkExAndRemoveListener(JNIEnv *env);\r
+};\r
+\r
+#endif
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniOnPresenceListener.cpp b/android/android_api/base/jni/JniOnPresenceListener.cpp
new file mode 100644 (file)
index 0000000..7c99445
--- /dev/null
@@ -0,0 +1,133 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniOnPresenceListener.h"\r
+#include "JniUtils.h"\r
+\r
+JniOnPresenceListener::JniOnPresenceListener(JNIEnv *env, jobject jListener,\r
+    RemoveListenerCallback removeListenerCallback)\r
+{\r
+    m_jwListener = env->NewWeakGlobalRef(jListener);\r
+    m_removeListenerCallback = removeListenerCallback;\r
+}\r
+\r
+JniOnPresenceListener::~JniOnPresenceListener()\r
+{\r
+    LOGD("~JniOnPresenceListener");\r
+    if (m_jwListener)\r
+    {\r
+        jint ret;\r
+        JNIEnv *env = GetJNIEnv(ret);\r
+        if (NULL == env) return;\r
+        env->DeleteWeakGlobalRef(m_jwListener);\r
+        m_jwListener = nullptr;\r
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
+    }\r
+}\r
+\r
+void JniOnPresenceListener::onPresenceCallback(OCStackResult result, const unsigned int nonce,\r
+    const std::string& hostAddress)\r
+{\r
+    LOGI("JniOnPresenceListener::onPresenceCallback");\r
+    if (!m_jwListener) return;\r
+\r
+    jint ret;\r
+    JNIEnv *env = GetJNIEnv(ret);\r
+    if (NULL == env) return;\r
+\r
+    if (OC_STACK_OK != result && OC_STACK_PRESENCE_STOPPED != result &&\r
+        OC_STACK_PRESENCE_TIMEOUT != result &&  OC_STACK_PRESENCE_DO_NOT_HANDLE != result)\r
+    {\r
+        ThrowOcException(result, "onPresenceCallback: stack failure");\r
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
+        return;\r
+    }\r
+\r
+    std::string enumField = JniUtils::stackResultToStr(result);\r
+    if (enumField.empty())\r
+    {\r
+        ThrowOcException(JNI_INVALID_VALUE, "Unexpected OCStackResult value");\r
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
+        return;\r
+    }\r
+\r
+    jobject jPresenceStatus = env->CallStaticObjectMethod(g_cls_OcPresenceStatus,\r
+        g_mid_OcPresenceStatus_get, env->NewStringUTF(enumField.c_str()));\r
+    if (!jPresenceStatus)\r
+    {\r
+        checkExAndRemoveListener(env);\r
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
+        return;\r
+    }\r
+\r
+    jobject jListener = env->NewLocalRef(m_jwListener);\r
+    if (!jListener)\r
+    {\r
+        checkExAndRemoveListener(env);\r
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
+        return;\r
+    }\r
+\r
+    jclass clsL = env->GetObjectClass(jListener);\r
+    if (!clsL)\r
+    {\r
+        checkExAndRemoveListener(env);\r
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
+        return;\r
+    }\r
+    jmethodID midL = env->GetMethodID(clsL, "onPresence",\r
+        "(Lorg/iotivity/base/OcPresenceStatus;ILjava/lang/String;)V");\r
+    if (!midL)\r
+    {\r
+        checkExAndRemoveListener(env);\r
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
+        return;\r
+    }\r
+\r
+    env->CallVoidMethod(jListener, midL, jPresenceStatus,\r
+        (jint)nonce, env->NewStringUTF(hostAddress.c_str()));\r
+    if (env->ExceptionCheck())\r
+    {\r
+        LOGE("Java exception is thrown");\r
+        checkExAndRemoveListener(env);\r
+    }\r
+    if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
+}\r
+\r
+void JniOnPresenceListener::checkExAndRemoveListener(JNIEnv* env)\r
+{\r
+    if (env->ExceptionCheck())\r
+    {\r
+        jthrowable ex = env->ExceptionOccurred();\r
+        env->ExceptionClear();\r
+        m_removeListenerCallback(env, m_jwListener);\r
+        env->Throw((jthrowable)ex);\r
+    }\r
+    else\r
+    {\r
+        m_removeListenerCallback(env, m_jwListener);\r
+    }\r
+}\r
+\r
+jweak JniOnPresenceListener::getJWListener()\r
+{\r
+    return this->m_jwListener;\r
+}
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniOnPresenceListener.h b/android/android_api/base/jni/JniOnPresenceListener.h
new file mode 100644 (file)
index 0000000..7cea026
--- /dev/null
@@ -0,0 +1,43 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniOcStack.h"\r
+#include <mutex>\r
+\r
+#ifndef _Included_org_iotivity_base_OcPlatform_OnPresenceListener\r
+#define _Included_org_iotivity_base_OcPlatform_OnPresenceListener\r
+\r
+class JniOnPresenceListener\r
+{\r
+public:\r
+    JniOnPresenceListener(JNIEnv *env, jobject jListener, RemoveListenerCallback removeListener);\r
+    ~JniOnPresenceListener();\r
+\r
+    void onPresenceCallback(OCStackResult result, const unsigned int nonce, const std::string& hostAddress);\r
+    jweak getJWListener();\r
+\r
+private:\r
+    RemoveListenerCallback m_removeListenerCallback;\r
+    jweak m_jwListener;\r
+    void checkExAndRemoveListener(JNIEnv* env);\r
+};\r
+\r
+#endif\r
diff --git a/android/android_api/base/jni/JniOnPutListener.cpp b/android/android_api/base/jni/JniOnPutListener.cpp
new file mode 100644 (file)
index 0000000..df18490
--- /dev/null
@@ -0,0 +1,144 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniOnPutListener.h"\r
+#include "JniOcResource.h"\r
+#include "JniOcRepresentation.h"\r
+#include "JniUtils.h"\r
+\r
+JniOnPutListener::JniOnPutListener(JNIEnv *env, jobject jListener, JniOcResource* owner)\r
+    : m_ownerResource(owner)\r
+{\r
+    m_jwListener = env->NewWeakGlobalRef(jListener);\r
+}\r
+\r
+JniOnPutListener::~JniOnPutListener()\r
+{\r
+    if (m_jwListener)\r
+    {\r
+        jint ret;\r
+        JNIEnv *env = GetJNIEnv(ret);\r
+        if (NULL == env) return;\r
+\r
+        env->DeleteWeakGlobalRef(m_jwListener);\r
+\r
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
+    }\r
+}\r
+\r
+void JniOnPutListener::onPutCallback(const HeaderOptions& headerOptions,\r
+    const OCRepresentation& ocRepresentation, const int eCode)\r
+{\r
+    jint envRet;\r
+    JNIEnv *env = GetJNIEnv(envRet);\r
+    if (NULL == env) return;\r
+\r
+    jobject jListener = env->NewLocalRef(m_jwListener);\r
+    if (!jListener)\r
+    {\r
+        checkExAndRemoveListener(env);\r
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+        return;\r
+    }\r
+    jclass clsL = env->GetObjectClass(jListener);\r
+    if (!clsL)\r
+    {\r
+        checkExAndRemoveListener(env);\r
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+        return;\r
+    }\r
+\r
+    if (OC_STACK_OK != eCode)\r
+    {\r
+        jobject ex = GetOcException(eCode, "stack error in onPutCallback");\r
+        if (!ex)\r
+        {\r
+            checkExAndRemoveListener(env);\r
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+            return;\r
+        }\r
+        jmethodID midL = env->GetMethodID(clsL, "onPutFailed", "(Ljava/lang/Throwable;)V");\r
+        if (!midL)\r
+        {\r
+            checkExAndRemoveListener(env);\r
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+            return;\r
+        }\r
+        env->CallVoidMethod(jListener, midL, ex);\r
+    }\r
+    else\r
+    {\r
+        jobject jHeaderOptionList = JniUtils::convertHeaderOptionsVectorToJavaList(env, headerOptions);\r
+        if (!jHeaderOptionList)\r
+        {\r
+            checkExAndRemoveListener(env);\r
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+            return;\r
+        }\r
+\r
+        OCRepresentation * rep = new OCRepresentation(ocRepresentation);\r
+        jlong handle = reinterpret_cast<jlong>(rep);\r
+        jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool,\r
+            handle, true);\r
+        if (!jRepresentation)\r
+        {\r
+            delete rep;\r
+            checkExAndRemoveListener(env);\r
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+            return;\r
+        }\r
+\r
+        jmethodID midL = env->GetMethodID(clsL, "onPutCompleted",\r
+            "(Ljava/util/List;Lorg/iotivity/base/OcRepresentation;)V");\r
+\r
+        if (!midL)\r
+        {\r
+            checkExAndRemoveListener(env);\r
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+            return;\r
+        }\r
+\r
+        env->CallVoidMethod(jListener, midL, jHeaderOptionList, jRepresentation);\r
+        if (env->ExceptionCheck())\r
+        {\r
+            LOGE("Java exception is thrown");\r
+            delete rep;\r
+        }\r
+    }\r
+\r
+    checkExAndRemoveListener(env);\r
+    if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
+}\r
+\r
+void JniOnPutListener::checkExAndRemoveListener(JNIEnv* env)\r
+{\r
+    if (env->ExceptionCheck())\r
+    {\r
+        jthrowable ex = env->ExceptionOccurred();\r
+        env->ExceptionClear();\r
+        m_ownerResource->removeOnPutListener(env, m_jwListener);\r
+        env->Throw((jthrowable)ex);\r
+    }\r
+    else\r
+    {\r
+        m_ownerResource->removeOnPutListener(env, m_jwListener);\r
+    }\r
+}
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniOnPutListener.h b/android/android_api/base/jni/JniOnPutListener.h
new file mode 100644 (file)
index 0000000..f29e43f
--- /dev/null
@@ -0,0 +1,45 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniOcStack.h"\r
+\r
+#ifndef _Included_org_iotivity_base_OcResource_OnPutListener\r
+#define _Included_org_iotivity_base_OcResource_OnPutListener\r
+\r
+using namespace OC;\r
+\r
+class JniOcResource;\r
+\r
+class JniOnPutListener\r
+{\r
+public:\r
+    JniOnPutListener(JNIEnv *env, jobject jListener, JniOcResource* resource);\r
+    ~JniOnPutListener();\r
+\r
+    void onPutCallback(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode);\r
+\r
+private:\r
+    jweak m_jwListener;\r
+    JniOcResource* m_ownerResource;\r
+    void checkExAndRemoveListener(JNIEnv *env);\r
+};\r
+\r
+#endif\r
diff --git a/android/android_api/base/jni/JniOnResourceFoundListener.cpp b/android/android_api/base/jni/JniOnResourceFoundListener.cpp
new file mode 100644 (file)
index 0000000..652e0cb
--- /dev/null
@@ -0,0 +1,118 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include "JniOnResourceFoundListener.h"\r
+#include "JniOcResource.h"\r
+\r
+JniOnResourceFoundListener::JniOnResourceFoundListener(JNIEnv *env, jobject jListener,\r
+    RemoveListenerCallback removeListenerCallback)\r
+{\r
+    m_jwListener = env->NewWeakGlobalRef(jListener);\r
+    m_removeListenerCallback = removeListenerCallback;\r
+}\r
+\r
+JniOnResourceFoundListener::~JniOnResourceFoundListener()\r
+{\r
+    LOGI("~JniOnResourceFoundListener()");\r
+    if (m_jwListener)\r
+    {\r
+        jint ret;\r
+        JNIEnv *env = GetJNIEnv(ret);\r
+        if (NULL == env) return;\r
+        env->DeleteWeakGlobalRef(m_jwListener);\r
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
+    }\r
+}\r
+\r
+void JniOnResourceFoundListener::foundResourceCallback(std::shared_ptr<OC::OCResource> resource)\r
+{\r
+    jint ret;\r
+    JNIEnv *env = GetJNIEnv(ret);\r
+    if (NULL == env) return;\r
+\r
+    jobject jListener = env->NewLocalRef(m_jwListener);\r
+    if (!jListener)\r
+    {\r
+        checkExAndRemoveListener(env);\r
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
+        return;\r
+    }\r
+\r
+    jobject jResource = env->NewObject(g_cls_OcResource, g_mid_OcResource_ctor);\r
+    if (!jResource)\r
+    {\r
+        checkExAndRemoveListener(env);\r
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
+        return;\r
+    }\r
+\r
+    JniOcResource *jniOcResource = new JniOcResource(resource);\r
+    SetHandle<JniOcResource>(env, jResource, jniOcResource);\r
+    if (env->ExceptionCheck())\r
+    {\r
+        delete jniOcResource;\r
+        checkExAndRemoveListener(env);\r
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
+        return;\r
+    }\r
+    jclass clsL = env->GetObjectClass(jListener);\r
+    if (!clsL)\r
+    {\r
+        delete jniOcResource;\r
+        checkExAndRemoveListener(env);\r
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
+        return;\r
+    }\r
+    jmethodID midL = env->GetMethodID(clsL, "onResourceFound", "(Lorg/iotivity/base/OcResource;)V");\r
+    if (!midL)\r
+    {\r
+        delete jniOcResource;\r
+        checkExAndRemoveListener(env);\r
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
+        return;\r
+    }\r
+    env->CallVoidMethod(jListener, midL, jResource);\r
+    if (env->ExceptionCheck())\r
+    {\r
+        LOGE("Java exception is thrown");\r
+        delete jniOcResource;\r
+        checkExAndRemoveListener(env);\r
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
+        return;\r
+    }\r
+\r
+    if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
+}\r
+\r
+void JniOnResourceFoundListener::checkExAndRemoveListener(JNIEnv* env)\r
+{\r
+    if (env->ExceptionCheck())\r
+    {\r
+        jthrowable ex = env->ExceptionOccurred();\r
+        env->ExceptionClear();\r
+        m_removeListenerCallback(env, m_jwListener);\r
+        env->Throw((jthrowable)ex);\r
+    }\r
+    else\r
+    {\r
+        m_removeListenerCallback(env, m_jwListener);\r
+    }\r
+}
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniOnResourceFoundListener.h b/android/android_api/base/jni/JniOnResourceFoundListener.h
new file mode 100644 (file)
index 0000000..2cb9749
--- /dev/null
@@ -0,0 +1,43 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+#include <jni.h>\r
+#include "JniOcStack.h"\r
+\r
+#ifndef _Included_org_iotivity_base_OcPlatform_OnResourceFoundListener\r
+#define _Included_org_iotivity_base_OcPlatform_OnResourceFoundListener\r
+\r
+class JniOnResourceFoundListener\r
+{\r
+public:\r
+    JniOnResourceFoundListener(JNIEnv *env, jobject jListener,\r
+        RemoveListenerCallback removeListenerCallback);\r
+    ~JniOnResourceFoundListener();\r
+\r
+    void foundResourceCallback(std::shared_ptr<OC::OCResource> resource);\r
+\r
+private:\r
+    RemoveListenerCallback m_removeListenerCallback;\r
+    jweak m_jwListener;\r
+    void checkExAndRemoveListener(JNIEnv* env);\r
+};\r
+\r
+#endif\r
diff --git a/android/android_api/base/jni/JniUtils.cpp b/android/android_api/base/jni/JniUtils.cpp
new file mode 100644 (file)
index 0000000..6ec806c
--- /dev/null
@@ -0,0 +1,193 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+\r
+#include "JniUtils.h"\r
+#include "JniOcRepresentation.h"\r
+\r
+jobject JniUtils::convertStrVectorToJavaStrList(JNIEnv *env, std::vector<std::string> &vector)\r
+{\r
+    jobject jList = env->NewObject(g_cls_LinkedList, g_mid_LinkedList_ctor);\r
+    if (!jList) return nullptr;\r
+    for (size_t i = 0; i < vector.size(); ++i)\r
+    {\r
+        jstring jStr = env->NewStringUTF(vector[i].c_str());\r
+        if (!jStr) return nullptr;\r
+        env->CallBooleanMethod(jList, g_mid_LinkedList_add_object, jStr);\r
+        if (env->ExceptionCheck()) return nullptr;\r
+        env->DeleteLocalRef(jStr);\r
+    }\r
+    return jList;\r
+}\r
+\r
+void JniUtils::convertJavaStrArrToStrVector(JNIEnv *env, jobjectArray jStrArr, std::vector<std::string> &vector)\r
+{\r
+    if (!jStrArr) return;\r
+\r
+    jsize len = env->GetArrayLength(jStrArr);\r
+    for (jsize i = 0; i < len; ++i)\r
+    {\r
+        jstring jStr = (jstring)env->GetObjectArrayElement(jStrArr, i);\r
+        if (!jStr) return;\r
+        vector.push_back(env->GetStringUTFChars(jStr, NULL));\r
+        if (env->ExceptionCheck()) return;\r
+        env->DeleteLocalRef(jStr);\r
+    }\r
+}\r
+\r
+void JniUtils::convertJavaHeaderOptionsArrToVector(JNIEnv *env, jobjectArray jHeaderOptions,\r
+    OC::HeaderOptions &headerOptions)\r
+{\r
+    if (!jHeaderOptions) return;\r
+\r
+    jsize len = env->GetArrayLength(jHeaderOptions);\r
+    for (jsize i = 0; i < len; ++i)\r
+    {\r
+        jobject header = env->GetObjectArrayElement(jHeaderOptions, i);\r
+        if (!header) nullptr;\r
+        jint jId = env->CallIntMethod(header, g_mid_OcHeaderOption_get_id);\r
+        jstring jData = (jstring)env->CallObjectMethod(header, g_mid_OcHeaderOption_get_data);\r
+        if (jData) return;\r
+\r
+        OC::HeaderOption::OCHeaderOption hopt(\r
+            static_cast<int>(jId),\r
+            env->GetStringUTFChars(jData, NULL));\r
+\r
+        headerOptions.push_back(hopt);\r
+\r
+        if (env->ExceptionCheck()) return;\r
+        env->DeleteLocalRef(header);\r
+        env->DeleteLocalRef(jData);\r
+    }\r
+}\r
+\r
+jobject JniUtils::convertHeaderOptionsVectorToJavaList(JNIEnv *env, const OC::HeaderOptions& headerOptions)\r
+{\r
+    jobject jHeaderOptionList = env->NewObject(g_cls_LinkedList, g_mid_LinkedList_ctor);\r
+    if (!jHeaderOptionList) return nullptr;\r
+\r
+    for (size_t i = 0; i < headerOptions.size(); ++i)\r
+    {\r
+        jobject jHeaderOption = env->NewObject(\r
+            g_cls_OcHeaderOption,\r
+            g_mid_OcHeaderOption_ctor,\r
+            static_cast<jint>(headerOptions[i].getOptionID()),\r
+            env->NewStringUTF(headerOptions[i].getOptionData().c_str())\r
+            );\r
+        if (!jHeaderOption) return nullptr;\r
+\r
+        env->CallBooleanMethod(jHeaderOptionList, g_mid_LinkedList_add_object, jHeaderOption);\r
+        if (env->ExceptionCheck()) return nullptr;\r
+        env->DeleteLocalRef(jHeaderOption);\r
+    }\r
+\r
+    return jHeaderOptionList;\r
+}\r
+\r
+void JniUtils::convertJavaMapToQueryParamsMap(JNIEnv *env, jobject hashMap, OC::QueryParamsMap &map)\r
+{\r
+    if (!hashMap) return;\r
+\r
+    jobject jEntrySet = env->CallObjectMethod(hashMap, g_mid_Map_entrySet);\r
+    jobject jIterator = env->CallObjectMethod(jEntrySet, g_mid_Set_iterator);\r
+    if (!jEntrySet || !jIterator || env->ExceptionCheck()) return;\r
+\r
+    while (env->CallBooleanMethod(jIterator, g_mid_Iterator_hasNext))\r
+    {\r
+        jobject jEntry = env->CallObjectMethod(jIterator, g_mid_Iterator_next);\r
+        if (!jEntry) return;\r
+        jstring jKey = (jstring)env->CallObjectMethod(jEntry, g_mid_MapEntry_getKey);\r
+        if (!jKey) return;\r
+        jstring jValue = (jstring)env->CallObjectMethod(jEntry, g_mid_MapEntry_getValue);\r
+        if (!jValue) return;\r
+\r
+        map.insert(std::make_pair(env->GetStringUTFChars(jKey, NULL),\r
+            env->GetStringUTFChars(jValue, NULL)));\r
+\r
+        if (env->ExceptionCheck()) return;\r
+        env->DeleteLocalRef(jEntry);\r
+        env->DeleteLocalRef(jKey);\r
+        env->DeleteLocalRef(jValue);\r
+    }\r
+}\r
+\r
+jobject JniUtils::convertQueryParamsMapToJavaMap(JNIEnv *env, const OC::QueryParamsMap &map)\r
+{\r
+    jobject hashMap = env->NewObject(g_cls_HashMap, g_mid_HashMap_ctor);\r
+    if (!hashMap) return nullptr;\r
+\r
+    for (auto it = map.begin(); it != map.end(); ++it)\r
+    {\r
+        std::string key = it->first;\r
+        std::string value = it->second;\r
+\r
+        env->CallObjectMethod(hashMap,\r
+            g_mid_HashMap_put,\r
+            env->NewStringUTF(key.c_str()),\r
+            env->NewStringUTF(value.c_str()));\r
+        if (env->ExceptionCheck()) return nullptr;\r
+    }\r
+\r
+    return hashMap;\r
+}\r
+\r
+void JniUtils::convertJavaRepresentationArrToVector(JNIEnv *env,\r
+    jobjectArray jRepresentationArray,\r
+    std::vector<OC::OCRepresentation>& representationVector)\r
+{\r
+    if (!jRepresentationArray) return;\r
+    jsize len = env->GetArrayLength(jRepresentationArray);\r
+\r
+    for (jsize i = 0; i < len; ++i)\r
+    {\r
+        jobject jRep = env->GetObjectArrayElement(jRepresentationArray, i);\r
+        if (!jRep) return;\r
+        OC::OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, jRep);\r
+        representationVector.push_back(*rep);\r
+        if (env->ExceptionCheck()) return;\r
+        env->DeleteLocalRef(jRep);\r
+    }\r
+}\r
+\r
+jobjectArray JniUtils::convertRepresentationVectorToJavaArray(JNIEnv *env,\r
+    const std::vector<OC::OCRepresentation>& representationVector)\r
+{\r
+    jsize len = static_cast<jsize>(representationVector.size());\r
+    jobjectArray repArr = env->NewObjectArray(len, g_cls_OcRepresentation, NULL);\r
+    if (!repArr) return nullptr;\r
+    for (jsize i = 0; i < len; ++i)\r
+    {\r
+        OCRepresentation* rep = new OCRepresentation(representationVector[i]);\r
+        jlong handle = reinterpret_cast<jlong>(rep);\r
+        jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool,\r
+            handle, true);\r
+        if (!jRepresentation)\r
+        {\r
+            delete rep;\r
+            return nullptr;\r
+        }\r
+        env->SetObjectArrayElement(repArr, i, jRepresentation);\r
+        if (env->ExceptionCheck()) return nullptr;\r
+        env->DeleteLocalRef(jRepresentation);\r
+    }\r
+\r
+    return repArr;\r
+}
\ No newline at end of file
diff --git a/android/android_api/base/jni/JniUtils.h b/android/android_api/base/jni/JniUtils.h
new file mode 100644 (file)
index 0000000..e64e16b
--- /dev/null
@@ -0,0 +1,230 @@
+/*\r
+* //******************************************************************\r
+* //\r
+* // Copyright 2015 Intel Corporation.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+* //\r
+* // Licensed under the Apache License, Version 2.0 (the "License");\r
+* // you may not use this file except in compliance with the License.\r
+* // You may obtain a copy of the License at\r
+* //\r
+* //      http://www.apache.org/licenses/LICENSE-2.0\r
+* //\r
+* // Unless required by applicable law or agreed to in writing, software\r
+* // distributed under the License is distributed on an "AS IS" BASIS,\r
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* // See the License for the specific language governing permissions and\r
+* // limitations under the License.\r
+* //\r
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+*/\r
+\r
+#include "JniOcStack.h"\r
+#include "OCRepresentation.h"\r
+\r
+class JniUtils\r
+{\r
+public:\r
+    static void convertJavaMapToQueryParamsMap(JNIEnv *env, jobject hashMap,\r
+        OC::QueryParamsMap &map);\r
+    static jobject convertQueryParamsMapToJavaMap(JNIEnv *env, const OC::QueryParamsMap &map);\r
+\r
+    static jobject convertStrVectorToJavaStrList(JNIEnv *env, std::vector<std::string> &vector);\r
+    static void convertJavaStrArrToStrVector(JNIEnv *env, jobjectArray jStrArr,\r
+        std::vector<std::string> &vector);\r
+\r
+    static void convertJavaHeaderOptionsArrToVector(JNIEnv *env, jobjectArray jHeaderOptions,\r
+        OC::HeaderOptions& headerOptions);\r
+    static jobject convertHeaderOptionsVectorToJavaList(JNIEnv *env,\r
+        const OC::HeaderOptions& headerOptions);\r
+\r
+    static void convertJavaRepresentationArrToVector(JNIEnv *env,\r
+        jobjectArray jRepresentationArray,\r
+        std::vector<OC::OCRepresentation>& representationVector);\r
+    static jobjectArray convertRepresentationVectorToJavaArray(JNIEnv *env,\r
+        const std::vector<OC::OCRepresentation>& representationVector);\r
+\r
+    static OC::ServiceType getServiceType(JNIEnv *env, int type)\r
+    {\r
+        switch (type) {\r
+        case 0:\r
+            return OC::ServiceType::InProc;\r
+        case 1:\r
+            return OC::ServiceType::OutOfProc;\r
+        default:\r
+            ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected service type");\r
+            return OC::ServiceType::OutOfProc;\r
+        };\r
+    }\r
+\r
+    static OC::ModeType getModeType(JNIEnv *env, int type)\r
+    {\r
+        switch (type) {\r
+        case 0:\r
+            return OC::ModeType::Server;\r
+        case 1:\r
+            return OC::ModeType::Client;\r
+        case 2:\r
+            return OC::ModeType::Both;\r
+        default:\r
+            ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected mode type");\r
+            return OC::ModeType::Both;\r
+        };\r
+    }\r
+\r
+    static OC::QualityOfService getQOS(JNIEnv *env, int type)\r
+    {\r
+        switch (type) {\r
+        case 0:\r
+            return OC::QualityOfService::LowQos;\r
+        case 1:\r
+            return OC::QualityOfService::MidQos;\r
+        case 2:\r
+            return OC::QualityOfService::HighQos;\r
+        case 3:\r
+            return OC::QualityOfService::NaQos;\r
+        default:\r
+            ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected quality of service");\r
+            return OC::QualityOfService::NaQos;\r
+        };\r
+    }\r
+\r
+    static OC::ObserveType getObserveType(JNIEnv *env, int type)\r
+    {\r
+        switch (type) {\r
+        case 0:\r
+            return OC::ObserveType::Observe;\r
+        case 1:\r
+            return OC::ObserveType::ObserveAll;\r
+        default:\r
+            ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected observe type");\r
+            return OC::ObserveType::ObserveAll;\r
+        };\r
+    }\r
+\r
+    static OCEntityHandlerResult getOCEntityHandlerResult(JNIEnv *env, int type)\r
+    {\r
+        switch (type) {\r
+        case 0:\r
+            return OCEntityHandlerResult::OC_EH_OK;\r
+        case 1:\r
+            return OCEntityHandlerResult::OC_EH_ERROR;\r
+        case 2:\r
+            return OCEntityHandlerResult::OC_EH_RESOURCE_CREATED;\r
+        case 3:\r
+            return OCEntityHandlerResult::OC_EH_RESOURCE_DELETED;\r
+        case 4:\r
+            return OCEntityHandlerResult::OC_EH_SLOW;\r
+        case 5:\r
+            return OCEntityHandlerResult::OC_EH_FORBIDDEN;\r
+        default:\r
+            ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected OCEntityHandlerResult");\r
+            return OCEntityHandlerResult::OC_EH_ERROR;\r
+        };\r
+    }\r
+\r
+    static OCConnectivityType getConnectivityType(JNIEnv *env, int type)\r
+    {\r
+        switch (type) {\r
+        case 0:\r
+            return OCConnectivityType::OC_ETHERNET;\r
+        case 1:\r
+            return OCConnectivityType::OC_WIFI;\r
+        case 2:\r
+            return OCConnectivityType::OC_EDR;\r
+        case 3:\r
+            return OCConnectivityType::OC_LE;\r
+        case 4:\r
+            return OCConnectivityType::OC_ALL;\r
+        default:\r
+            ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected connectivity type");\r
+            return OCConnectivityType::OC_ALL;\r
+        };\r
+    }\r
+\r
+    static std::string stackResultToStr(const int result)\r
+    {\r
+        switch (result)\r
+        {\r
+        case OC_STACK_OK:\r
+            return "OK";\r
+        case OC_STACK_RESOURCE_CREATED:\r
+            return "RESOURCE_CREATED";\r
+        case OC_STACK_RESOURCE_DELETED:\r
+            return "RESOURCE_DELETED";\r
+        case OC_STACK_CONTINUE:\r
+            return "CONTINUE";\r
+            /* Success status code - END HERE */\r
+            /* Error status code - START HERE */\r
+        case OC_STACK_INVALID_URI:\r
+            return "INVALID_URI";\r
+        case OC_STACK_INVALID_QUERY:\r
+            return "INVALID_QUERY";\r
+        case OC_STACK_INVALID_IP:\r
+            return "INVALID_IP";\r
+\r
+        case OC_STACK_INVALID_PORT:\r
+            return "INVALID_PORT";\r
+        case OC_STACK_INVALID_CALLBACK:\r
+            return "INVALID_CALLBACK";\r
+        case OC_STACK_INVALID_METHOD:\r
+            return "INVALID_METHOD";\r
+        case OC_STACK_INVALID_PARAM:\r
+            return "INVALID_PARAM";\r
+        case OC_STACK_INVALID_OBSERVE_PARAM:\r
+            return "INVALID_OBSERVE_PARAM";\r
+        case OC_STACK_NO_MEMORY:\r
+            return "NO_MEMORY";\r
+        case OC_STACK_COMM_ERROR:\r
+            return "COMM_ERROR";\r
+        case OC_STACK_NOTIMPL:\r
+            return "NOTIMPL";\r
+        case OC_STACK_NO_RESOURCE:\r
+            return "NO_RESOURCE";\r
+        case  OC_STACK_RESOURCE_ERROR:\r
+            return "RESOURCE_ERROR";\r
+        case OC_STACK_SLOW_RESOURCE:\r
+            return "SLOW_RESOURCE";\r
+            //case OC_STACK_DUPLICATE_REQUEST:\r
+            //    return "DUPLICATE_REQUEST";\r
+        case OC_STACK_NO_OBSERVERS:\r
+            return "NO_OBSERVERS";\r
+        case OC_STACK_OBSERVER_NOT_FOUND:\r
+            return "OBSERVER_NOT_FOUND";\r
+        case OC_STACK_VIRTUAL_DO_NOT_HANDLE:\r
+            return "VIRTUAL_DO_NOT_HANDLE";\r
+        case OC_STACK_INVALID_OPTION:\r
+            return "INVALID_OPTION";\r
+        case OC_STACK_MALFORMED_RESPONSE:\r
+            return "MALFORMED_RESPONSE";\r
+        case OC_STACK_PERSISTENT_BUFFER_REQUIRED:\r
+            return "PERSISTENT_BUFFER_REQUIRED";\r
+        case OC_STACK_INVALID_REQUEST_HANDLE:\r
+            return "INVALID_REQUEST_HANDLE";\r
+        case OC_STACK_INVALID_DEVICE_INFO:\r
+            return "INVALID_DEVICE_INFO";\r
+            //case OC_STACK_INVALID_JSON:\r
+            //    return "INVALID_JSON";\r
+\r
+        case OC_STACK_PRESENCE_STOPPED:\r
+            return "PRESENCE_STOPPED";\r
+        case OC_STACK_PRESENCE_TIMEOUT:\r
+            return "PRESENCE_TIMEOUT";\r
+        case OC_STACK_PRESENCE_DO_NOT_HANDLE:\r
+            return "PRESENCE_DO_NOT_HANDLE";\r
+\r
+        case OC_STACK_ERROR:\r
+            return "ERROR";\r
+\r
+        case JNI_EXCEPTION:\r
+            return "JNI_EXCEPTION";\r
+        case JNI_NO_NATIVE_POINTER:\r
+            return "JNI_NO_NATIVE_POINTER";\r
+        case JNI_INVALID_VALUE:\r
+            return "JNI_INVALID_VALUE";\r
+        default:\r
+            return "";\r
+        }\r
+    }\r
+};
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
similarity index 86%
rename from android/Base/app/proguard-rules.pro
rename to android/android_api/base/proguard-rules.pro
index 0e559b0..ea26467
@@ -1,17 +1,17 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in /home/vchen/ubuntu_sw/adt-bundle-linux-x86_64/sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-#   http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-#   public *;
-#}
+# Add project specific ProGuard rules here.\r
+# By default, the flags in this file are appended to flags specified\r
+# in C:/android/sdk/tools/proguard/proguard-android.txt\r
+# You can edit the include path and order by changing the proguardFiles\r
+# directive in build.gradle.\r
+#\r
+# For more details, see\r
+#   http://developer.android.com/guide/developing/tools/proguard.html\r
+\r
+# Add any project specific keep options here:\r
+\r
+# If your project uses WebView with JS, uncomment the following\r
+# and specify the fully qualified class name to the JavaScript interface\r
+# class:\r
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\r
+#   public *;\r
+#}\r
diff --git a/android/android_api/base/src/androidTest/AndroidManifest.xml b/android/android_api/base/src/androidTest/AndroidManifest.xml
new file mode 100755 (executable)
index 0000000..183e674
--- /dev/null
@@ -0,0 +1,35 @@
+<!--\r
+  ~ //******************************************************************\r
+  ~ //\r
+  ~ // Copyright 2015 Intel Corporation.\r
+  ~ //\r
+  ~ //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+  ~ //\r
+  ~ // Licensed under the Apache License, Version 2.0 (the "License");\r
+  ~ // you may not use this file except in compliance with the License.\r
+  ~ // You may obtain a copy of the License at\r
+  ~ //\r
+  ~ //      http://www.apache.org/licenses/LICENSE-2.0\r
+  ~ //\r
+  ~ // Unless required by applicable law or agreed to in writing, software\r
+  ~ // distributed under the License is distributed on an "AS IS" BASIS,\r
+  ~ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+  ~ // See the License for the specific language governing permissions and\r
+  ~ // limitations under the License.\r
+  ~ //\r
+  ~ //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+  -->\r
+\r
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"\r
+    package="org.iotivity.base">\r
+    <uses-permission android:name="android.permission.BLUETOOTH" />\r
+    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />\r
+    <uses-permission android:name="android.permission.INTERNET" />\r
+    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />\r
+    <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />\r
+    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />\r
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />\r
+    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />\r
+\r
+    <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="21" />\r
+</manifest>\r
diff --git a/android/android_api/base/src/androidTest/java/org/iotivity/base/OcRepresentationTest.java b/android/android_api/base/src/androidTest/java/org/iotivity/base/OcRepresentationTest.java
new file mode 100755 (executable)
index 0000000..0834201
--- /dev/null
@@ -0,0 +1,593 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base;\r
+\r
+import android.test.InstrumentationTestCase;\r
+\r
+import java.security.InvalidParameterException;\r
+import java.util.Arrays;\r
+import java.util.LinkedList;\r
+import java.util.List;\r
+\r
+public class OcRepresentationTest extends InstrumentationTestCase {\r
+\r
+    private static final String TAG = "OcRepresentationTest";\r
+\r
+    @Override\r
+    protected void setUp() throws Exception {\r
+        super.setUp();\r
+    }\r
+\r
+    public void testChildrenManagement() throws OcException {\r
+        OcRepresentation representation = new OcRepresentation();\r
+\r
+        List<OcRepresentation> emptyList = representation.getChildren();\r
+        assertTrue(emptyList.isEmpty());\r
+\r
+        OcRepresentation child1 = new OcRepresentation();\r
+        OcRepresentation child2 = new OcRepresentation();\r
+        String key = "key";\r
+        int value = 75;\r
+\r
+        child1.setValue(key, value);\r
+        child2.setValue(key, value);\r
+        representation.addChild(child1);\r
+        representation.addChild(child2);\r
+        List<OcRepresentation> twoChildren = representation.getChildren();\r
+        assertEquals(2, twoChildren.size());\r
+        for (OcRepresentation rep : twoChildren) {\r
+            assertEquals(value, rep.getValue(key));\r
+        }\r
+\r
+        representation.clearChildren();\r
+        emptyList = representation.getChildren();\r
+        assertTrue(emptyList.isEmpty());\r
+    }\r
+\r
+    public void testUriGetSet() {\r
+        OcRepresentation representation = new OcRepresentation();\r
+\r
+        String emptyUri = representation.getUri();\r
+        assertTrue(emptyUri.isEmpty());\r
+\r
+        String expected = "a/resource/uri";\r
+        representation.setUri(expected);\r
+        String actual = representation.getUri();\r
+        assertEquals(expected, actual);\r
+    }\r
+\r
+    public void testJSONRepresentation() throws OcException {\r
+        OcRepresentation representation = new OcRepresentation();\r
+        String key = "key";\r
+        int value = 75;\r
+\r
+        String emptyJson1 = representation.getJSONRepresentation();\r
+        representation.setValue(key, value);\r
+        String intValue1 = representation.getJSONRepresentation();\r
+        representation.remove(key);\r
+        String emptyJson2 = representation.getJSONRepresentation();\r
+        assertEquals(emptyJson1, emptyJson2);\r
+        representation.setValue(key, value);\r
+        String intValue2 = representation.getJSONRepresentation();\r
+        assertEquals(intValue1, intValue2);\r
+    }\r
+\r
+    public void testResourceTypesGetSet() {\r
+        OcRepresentation representation = new OcRepresentation();\r
+\r
+        List<String> emptyResourceTypeList = representation.getResourceTypes();\r
+        assertTrue(emptyResourceTypeList.isEmpty());\r
+\r
+        representation.setResourceTypes(emptyResourceTypeList);\r
+        emptyResourceTypeList = representation.getResourceTypes();\r
+        assertTrue(emptyResourceTypeList.isEmpty());\r
+\r
+        List<String> resourceTypeListExpected = new LinkedList<String>();\r
+        resourceTypeListExpected.add("type1");\r
+        resourceTypeListExpected.add("type2");\r
+        resourceTypeListExpected.add("type3");\r
+\r
+        representation.setResourceTypes(resourceTypeListExpected);\r
+        List<String> resourceTypeListActual = representation.getResourceTypes();\r
+        assertEquals(resourceTypeListExpected.size(), resourceTypeListActual.size());\r
+        for (int i = 0; i < resourceTypeListExpected.size(); i++) {\r
+            assertEquals(resourceTypeListExpected.get(i), resourceTypeListActual.get(i));\r
+        }\r
+\r
+        boolean thrown = false;\r
+        try {\r
+            representation.setResourceTypes(null);\r
+        } catch (InvalidParameterException e) {\r
+            thrown = true;\r
+        }\r
+        assertTrue(thrown);\r
+    }\r
+\r
+    public void testResourceInterfacesGetSet() {\r
+        OcRepresentation representation = new OcRepresentation();\r
+\r
+        List<String> emptyResourceInterfaceList = representation.getResourceInterfaces();\r
+        assertTrue(emptyResourceInterfaceList.isEmpty());\r
+\r
+        representation.setResourceInterfaces(emptyResourceInterfaceList);\r
+        emptyResourceInterfaceList = representation.getResourceInterfaces();\r
+        assertTrue(emptyResourceInterfaceList.isEmpty());\r
+\r
+        List<String> resourceInterfaceListExpected = new LinkedList<String>();\r
+        resourceInterfaceListExpected.add("Interface1");\r
+        resourceInterfaceListExpected.add("Interface2");\r
+        resourceInterfaceListExpected.add("Interface3");\r
+\r
+        representation.setResourceInterfaces(resourceInterfaceListExpected);\r
+        List<String> resourceInterfaceListActual = representation.getResourceInterfaces();\r
+        assertEquals(resourceInterfaceListExpected.size(), resourceInterfaceListActual.size());\r
+        for (int i = 0; i < resourceInterfaceListExpected.size(); i++) {\r
+            assertEquals(resourceInterfaceListExpected.get(i), resourceInterfaceListActual.get(i));\r
+        }\r
+\r
+        boolean thrown = false;\r
+        try {\r
+            representation.setResourceInterfaces(null);\r
+        } catch (InvalidParameterException e) {\r
+            thrown = true;\r
+        }\r
+        assertTrue(thrown);\r
+    }\r
+\r
+    public void testAttributeManagement() {\r
+        OcRepresentation representation = new OcRepresentation();\r
+\r
+        assertTrue(representation.isEmpty());\r
+        assertEquals(0, representation.size());\r
+\r
+        try {\r
+            String integerKey = "integerKey";\r
+            int integerValue = 75;\r
+            representation.setValue(integerKey, integerValue);\r
+            assertFalse(representation.isEmpty());\r
+            assertEquals(1, representation.size());\r
+\r
+            int actualIntValue = representation.getValue(integerKey);\r
+            assertEquals(integerValue, actualIntValue);\r
+\r
+            String stringKey = "stringKey";\r
+            String stringValue = "stringValue";\r
+            representation.setValue(stringKey, stringValue);\r
+            assertEquals(2, representation.size());\r
+\r
+            assertTrue(representation.hasAttribute(integerKey));\r
+            representation.remove(integerKey);\r
+            assertFalse(representation.hasAttribute(integerKey));\r
+            assertEquals(1, representation.size());\r
+\r
+            representation.setValue(integerKey, integerValue);\r
+            assertFalse(representation.isNull(integerKey));\r
+            representation.setNull(integerKey);\r
+            assertTrue(representation.isNull(integerKey));\r
+        } catch (OcException e) {\r
+            assertTrue(false);\r
+        }\r
+\r
+        String nonexistentKey = "nonexistentKey";\r
+        assertFalse(representation.hasAttribute(nonexistentKey));\r
+        representation.setNull(nonexistentKey);\r
+        assertTrue(representation.isNull(nonexistentKey));\r
+\r
+        String nonexistentKey2 = "nonexistentKey2";\r
+        boolean thrown = false;\r
+        try {\r
+            boolean nonexistentValue = representation.getValue(nonexistentKey2);\r
+        } catch (OcException e) {\r
+            thrown = true;\r
+        }\r
+        assertTrue(thrown);\r
+    }\r
+\r
+    public void testAttributeAccessByType() throws OcException {\r
+        OcRepresentation rep = new OcRepresentation();\r
+\r
+        //integer\r
+        String intK = "intK";\r
+        int intV = 4;\r
+        rep.setValue(intK, intV);\r
+        int intVa = rep.getValue(intK);\r
+        assertEquals(intV, intVa);\r
+\r
+        //double\r
+        String doubleK = "doubleK";\r
+        double doubleV = 4.5;\r
+        rep.setValue(doubleK, doubleV);\r
+        double doubleVa = rep.getValue(doubleK);\r
+        assertEquals(doubleV, doubleVa);\r
+\r
+        //boolean\r
+        String booleanK = "booleanK";\r
+        boolean booleanV = true;\r
+        rep.setValue(booleanK, booleanV);\r
+        boolean booleanVa = rep.getValue(booleanK);\r
+        assertEquals(booleanV, booleanVa);\r
+\r
+        //String\r
+        String stringK = "stringK";\r
+        String stringV = "stringV";\r
+        rep.setValue(stringK, stringV);\r
+        String stringVa = rep.getValue(stringK);\r
+        assertEquals(stringV, stringVa);\r
+\r
+        //OcRepresentation\r
+        String repK = "repK";\r
+        OcRepresentation repV = new OcRepresentation();\r
+        repV.setValue(intK, intV);\r
+        rep.setValue(repK, repV);\r
+        OcRepresentation repVa = rep.getValue(repK);\r
+        assertEquals(intV, repVa.getValue(intK));\r
+    }\r
+\r
+    public void testAttributeAccessBySequenceType() throws OcException {\r
+        OcRepresentation rep = new OcRepresentation();\r
+\r
+        //integer\r
+        String intK = "intK";\r
+        int[] intArrV = {1, 2, 3, 4};\r
+        rep.setValue(intK, intArrV);\r
+        int[] intArrVa = rep.getValue(intK);\r
+        assertTrue(Arrays.equals(intArrV, intArrVa));\r
+\r
+        int[] intArrVEmpty = {};\r
+        rep.setValue(intK, intArrVEmpty);\r
+        int[] intArrVEmptyA = rep.getValue(intK);\r
+        assertTrue(Arrays.equals(intArrVEmpty, intArrVEmptyA));\r
+\r
+        //double\r
+        String doubleK = "doubleK";\r
+        double[] doubleArrV = {1.1, 2.2, 3.3, 4.4};\r
+        rep.setValue(doubleK, doubleArrV);\r
+        double[] doubleArrVa = rep.getValue(doubleK);\r
+        assertTrue(Arrays.equals(doubleArrV, doubleArrVa));\r
+\r
+        double[] doubleArrVEmpty = {};\r
+        rep.setValue(doubleK, doubleArrVEmpty);\r
+        double[] doubleArrVEmptyA = rep.getValue(doubleK);\r
+        assertTrue(Arrays.equals(doubleArrVEmpty, doubleArrVEmptyA));\r
+\r
+        //boolean\r
+        String booleanK = "booleanK";\r
+        boolean[] booleanArrV = {true, false, true, false};\r
+        rep.setValue(booleanK, booleanArrV);\r
+        boolean[] booleanArrVa = rep.getValue(booleanK);\r
+        assertTrue(Arrays.equals(booleanArrV, booleanArrVa));\r
+\r
+        boolean[] booleanArrVEmpty = {};\r
+        rep.setValue(booleanK, booleanArrVEmpty);\r
+        boolean[] booleanArrVEmptyA = rep.getValue(booleanK);\r
+        assertTrue(Arrays.equals(booleanArrVEmpty, booleanArrVEmptyA));\r
+\r
+        //String\r
+        String stringK = "stringK";\r
+        String[] stringArrV = {"aaa", "bbb", "ccc", "ddd"};\r
+        rep.setValue(stringK, stringArrV);\r
+        String[] stringArrVa = rep.getValue(stringK);\r
+        assertTrue(Arrays.equals(stringArrV, stringArrVa));\r
+\r
+        String[] stringArrVEmpty = {};\r
+        rep.setValue(stringK, stringArrVEmpty);\r
+        String[] stringArrVEmptyA = rep.getValue(stringK);\r
+        assertTrue(Arrays.equals(stringArrVEmpty, stringArrVEmptyA));\r
+\r
+        //OcRepresentation\r
+        String representationK = "representationK";\r
+        OcRepresentation[] representationArrV = {\r
+                new OcRepresentation(),\r
+                new OcRepresentation(),\r
+                new OcRepresentation(),\r
+                new OcRepresentation()};\r
+        representationArrV[0].setValue(intK, 0);\r
+        representationArrV[1].setValue(intK, 1);\r
+        representationArrV[2].setValue(intK, 2);\r
+        representationArrV[3].setValue(intK, 3);\r
+\r
+        rep.setValue(representationK, representationArrV);\r
+        OcRepresentation[] representationArrVa = rep.getValue(representationK);\r
+\r
+        assertEquals(representationArrV.length, representationArrVa.length);\r
+        for (int i = 0; i < representationArrV.length; ++i) {\r
+            assertEquals(representationArrV[i].getValue(intK),\r
+                    representationArrVa[i].getValue(intK));\r
+        }\r
+\r
+        OcRepresentation[] representationArrVEmpty = {};\r
+        rep.setValue(representationK, representationArrVEmpty);\r
+        OcRepresentation[] representationArrVEmptyA = rep.getValue(representationK);\r
+        assertEquals(representationArrVEmpty.length, representationArrVEmptyA.length);\r
+    }\r
+\r
+    public void testAttributeAccessBy2DType() throws OcException {\r
+        OcRepresentation rep = new OcRepresentation();\r
+        //integer\r
+        String int2DK = "int2DK";\r
+        int[] intArrV1 = {1, 2, 3, 4};\r
+        int[] intArrV2 = {5, 6, 7, 8};\r
+        int[][] int2DArrV = {intArrV1, intArrV2};\r
+        rep.setValue(int2DK, int2DArrV);\r
+        int[][] int2DArrVa = rep.getValue(int2DK);\r
+        for (int i = 0; i < int2DArrV.length; i++) {\r
+            assertTrue(Arrays.equals(int2DArrV[i], int2DArrVa[i]));\r
+        }\r
+        //double\r
+        String double2DK = "double2DK";\r
+        double[] doubleArrV1 = {1.1, 2.2, 3.3, 4.4};\r
+        double[] doubleArrV2 = {5, 6, 7, 8};\r
+        double[][] double2DArrV = {doubleArrV1, doubleArrV2};\r
+        rep.setValue(double2DK, double2DArrV);\r
+        double[][] double2DArrVa = rep.getValue(double2DK);\r
+        for (int i = 0; i < double2DArrV.length; i++) {\r
+            assertTrue(Arrays.equals(double2DArrV[i], double2DArrVa[i]));\r
+        }\r
+        double[][] double2DArrVEmpty = {{}};\r
+        rep.setValue(double2DK, double2DArrVEmpty);\r
+        double[][] double2DArrVEmptyA = rep.getValue(double2DK);\r
+        for (int i = 0; i < double2DArrVEmpty.length; i++) {\r
+            assertTrue(Arrays.equals(double2DArrVEmpty[i], double2DArrVEmptyA[i]));\r
+        }\r
+        //boolean\r
+        String boolean2DK = "boolean2DK";\r
+        boolean[] booleanArrV1 = {true, true, false};\r
+        boolean[] booleanArrV2 = {true, false, false, true};\r
+        boolean[][] boolean2DArrV = {booleanArrV1, booleanArrV2};\r
+        rep.setValue(boolean2DK, boolean2DArrV);\r
+        boolean[][] boolean2DArrVa = rep.getValue(boolean2DK);\r
+        for (int i = 0; i < boolean2DArrV.length; i++) {\r
+            assertTrue(Arrays.equals(boolean2DArrV[i], boolean2DArrVa[i]));\r
+        }\r
+        boolean[][] boolean2DArrVEmpty = {{}};\r
+        rep.setValue(boolean2DK, boolean2DArrVEmpty);\r
+        boolean[][] boolean2DArrVEmptyA = rep.getValue(boolean2DK);\r
+        for (int i = 0; i < boolean2DArrVEmpty.length; i++) {\r
+            assertTrue(Arrays.equals(boolean2DArrVEmpty[i], boolean2DArrVEmptyA[i]));\r
+        }\r
+\r
+        //String\r
+        String string2DK = "string2DK";\r
+        String[] stringArrV1 = {"aaa", "bbb", "ccc"};\r
+        String[] stringArrV2 = {"111", "222", "333", "444"};\r
+        String[][] string2DArrV = {stringArrV1, stringArrV2};\r
+        rep.setValue(string2DK, string2DArrV);\r
+        String[][] string2DArrVa = rep.getValue(string2DK);\r
+        for (int i = 0; i < string2DArrV.length; i++) {\r
+            assertTrue(Arrays.equals(string2DArrV[i], string2DArrVa[i]));\r
+        }\r
+        String[][] string2DArrVEmpty = {{}};\r
+        rep.setValue(string2DK, string2DArrVEmpty);\r
+        String[][] string2DArrVEmptyA = rep.getValue(string2DK);\r
+        for (int i = 0; i < string2DArrVEmpty.length; i++) {\r
+            assertTrue(Arrays.equals(string2DArrVEmpty[i], string2DArrVEmptyA[i]));\r
+        }\r
+\r
+        //OcRepresentation\r
+        String intK = "intK";\r
+        String representation2DK = "representation2DK";\r
+        OcRepresentation[] representation2DArrV1 = {\r
+                new OcRepresentation(),\r
+                new OcRepresentation(),\r
+                new OcRepresentation(),\r
+                new OcRepresentation()};\r
+        representation2DArrV1[0].setValue(intK, 0);\r
+        representation2DArrV1[1].setValue(intK, 1);\r
+        representation2DArrV1[2].setValue(intK, 2);\r
+        representation2DArrV1[3].setValue(intK, 3);\r
+\r
+        OcRepresentation[] representation2DArrV2 = {\r
+                new OcRepresentation(),\r
+                new OcRepresentation(),\r
+                new OcRepresentation(),\r
+                new OcRepresentation()};\r
+        representation2DArrV2[0].setValue(intK, 4);\r
+        representation2DArrV2[1].setValue(intK, 5);\r
+        representation2DArrV2[2].setValue(intK, 6);\r
+        representation2DArrV2[3].setValue(intK, 7);\r
+\r
+        OcRepresentation[][] representation2DArrV = {representation2DArrV1, representation2DArrV2};\r
+        rep.setValue(representation2DK, representation2DArrV);\r
+        OcRepresentation[][] representation2DArrVa = rep.getValue(representation2DK);\r
+        assertEquals(representation2DArrV.length, representation2DArrVa.length);\r
+        for (int i = 0; i < representation2DArrV.length; ++i) {\r
+            OcRepresentation[] repArrV = representation2DArrV[i];\r
+            OcRepresentation[] repArrVa = representation2DArrVa[i];\r
+            assertEquals(repArrV.length, repArrVa.length);\r
+            for (int j = 0; j < representation2DArrV.length; ++j) {\r
+                assertEquals(repArrV[j].getValue(intK),\r
+                        repArrVa[j].getValue(intK));\r
+            }\r
+        }\r
+\r
+        OcRepresentation[][] representation2DArrVEmpty = {{}};\r
+        rep.setValue(representation2DK, representation2DArrVEmpty);\r
+        OcRepresentation[][] representation2DArrVEmptyA = rep.getValue(representation2DK);\r
+        assertEquals(representation2DArrVEmpty.length, representation2DArrVEmptyA.length);\r
+    }\r
+\r
+    public void testAttributeAccessBy3DType() throws OcException {\r
+        OcRepresentation rep = new OcRepresentation();\r
+        //integer\r
+        String int3DK = "int3DK";\r
+        int[] intArrV1 = {0, 1, 2, 3, 4};\r
+        int[] intArrV2 = {5, 6, 7, 8};\r
+        int[][] int2DArrV1 = {intArrV1, intArrV2};\r
+        int[] intArrV3 = {9, 10};\r
+        int[] intArrV4 = {11};\r
+        int[][] int2DArrV2 = {intArrV3, intArrV4};\r
+        int[][][] int3DArrV = {int2DArrV1, int2DArrV2};\r
+        rep.setValue(int3DK, int3DArrV);\r
+        int[][][] int3DArrVa = rep.getValue(int3DK);\r
+        assertEquals(int3DArrV.length, int3DArrVa.length);\r
+        for (int i = 0; i < int3DArrV.length; i++) {\r
+            int[][] int2DT = int3DArrV[i];\r
+            int[][] int2DTa = int3DArrVa[i];\r
+            assertEquals(int2DT.length, int2DTa.length);\r
+            for (int j = 0; j < int2DT.length; j++) {\r
+                assertTrue(Arrays.equals(int2DT[j], int2DTa[j]));\r
+            }\r
+        }\r
+        //double\r
+        String double3DK = "double3DK";\r
+        double[] doubleArrV1 = {0.0, 1.1, 2.2, 3.3, 4.4};\r
+        double[] doubleArrV2 = {5.5, 6.6, 7.7, 8.8};\r
+        double[][] double2DArrV1 = {doubleArrV1, doubleArrV2};\r
+        double[] doubleArrV3 = {9.9, 10.1};\r
+        double[] doubleArrV4 = {11.1};\r
+        double[][] double2DArrV2 = {doubleArrV3, doubleArrV4};\r
+        double[][][] double3DArrV = {double2DArrV1, double2DArrV2};\r
+        rep.setValue(double3DK, double3DArrV);\r
+        double[][][] double3DArrVa = rep.getValue(double3DK);\r
+        assertEquals(double3DArrV.length, double3DArrVa.length);\r
+        for (int i = 0; i < double3DArrV.length; i++) {\r
+            double[][] double2DT = double3DArrV[i];\r
+            double[][] double2DTa = double3DArrVa[i];\r
+            assertEquals(double2DT.length, double2DTa.length);\r
+            for (int j = 0; j < double2DT.length; j++) {\r
+                assertTrue(Arrays.equals(double2DT[j], double2DTa[j]));\r
+            }\r
+        }\r
+        double[][][] double3DArrVEmpty = {};\r
+        rep.setValue(double3DK, double3DArrVEmpty);\r
+        double[][][] double3DArrVEmptyA = rep.getValue(double3DK);\r
+        assertEquals(double3DArrVEmpty.length, double3DArrVEmptyA.length);\r
+        for (int i = 0; i < double3DArrVEmpty.length; i++) {\r
+            double[][] double2DT = double3DArrVEmpty[i];\r
+            double[][] double2DTa = double3DArrVEmptyA[i];\r
+            assertEquals(double2DT.length, double2DTa.length);\r
+            for (int j = 0; j < double2DT.length; j++) {\r
+                assertTrue(Arrays.equals(double2DT[j], double2DTa[j]));\r
+            }\r
+        }\r
+\r
+        //boolean\r
+        String boolean3DK = "boolean3DK";\r
+        boolean[] booleanArrV1 = {true, false, true, true, false};\r
+        boolean[] booleanArrV2 = {false, false, false, true};\r
+        boolean[][] boolean2DArrV1 = {booleanArrV1, booleanArrV2};\r
+        boolean[] booleanArrV3 = {true, true};\r
+        boolean[] booleanArrV4 = {false};\r
+        boolean[][] boolean2DArrV2 = {booleanArrV3, booleanArrV4};\r
+        boolean[][][] boolean3DArrV = {boolean2DArrV1, boolean2DArrV2};\r
+        rep.setValue(boolean3DK, boolean3DArrV);\r
+        boolean[][][] boolean3DArrVa = rep.getValue(boolean3DK);\r
+        assertEquals(boolean3DArrV.length, boolean3DArrVa.length);\r
+        for (int i = 0; i < boolean3DArrV.length; i++) {\r
+            boolean[][] boolean2DT = boolean3DArrV[i];\r
+            boolean[][] boolean2DTa = boolean3DArrVa[i];\r
+            assertEquals(boolean2DT.length, boolean2DTa.length);\r
+            for (int j = 0; j < boolean2DT.length; j++) {\r
+                assertTrue(Arrays.equals(boolean2DT[j], boolean2DTa[j]));\r
+            }\r
+        }\r
+        boolean[][][] boolean3DArrVEmpty = {};\r
+        rep.setValue(boolean3DK, boolean3DArrVEmpty);\r
+        boolean[][][] boolean3DArrVEmptyA = rep.getValue(boolean3DK);\r
+        assertEquals(boolean3DArrVEmpty.length, boolean3DArrVEmptyA.length);\r
+        for (int i = 0; i < boolean3DArrVEmpty.length; i++) {\r
+            boolean[][] boolean2DT = boolean3DArrVEmpty[i];\r
+            boolean[][] boolean2DTa = boolean3DArrVEmptyA[i];\r
+            assertEquals(boolean2DT.length, boolean2DTa.length);\r
+            for (int j = 0; j < boolean2DT.length; j++) {\r
+                assertTrue(Arrays.equals(boolean2DT[j], boolean2DTa[j]));\r
+            }\r
+        }\r
+\r
+        //String\r
+        String string3DK = "string3DK";\r
+        String[] stringArrV1 = {"a", "bb", "ccc", "dddd", "eeee"};\r
+        String[] stringArrV2 = {"f", "gg", "hhh", "ii"};\r
+        String[][] string2DArrV1 = {stringArrV1, stringArrV2};\r
+        String[] stringArrV3 = {"j", "jj"};\r
+        String[] stringArrV4 = {"jjj"};\r
+        String[][] string2DArrV2 = {stringArrV3, stringArrV4};\r
+        String[][][] string3DArrV = {string2DArrV1, string2DArrV2};\r
+        rep.setValue(string3DK, string3DArrV);\r
+        String[][][] string3DArrVa = rep.getValue(string3DK);\r
+        assertEquals(string3DArrV.length, string3DArrVa.length);\r
+        for (int i = 0; i < string3DArrV.length; i++) {\r
+            String[][] string2DT = string3DArrV[i];\r
+            String[][] string2DTa = string3DArrVa[i];\r
+            assertEquals(string2DT.length, string2DTa.length);\r
+            for (int j = 0; j < string2DT.length; j++) {\r
+                assertTrue(Arrays.equals(string2DT[j], string2DTa[j]));\r
+            }\r
+        }\r
+        String[][][] string3DArrVEmpty = {};\r
+        rep.setValue(string3DK, string3DArrVEmpty);\r
+        String[][][] string3DArrVEmptyA = rep.getValue(string3DK);\r
+        assertEquals(string3DArrVEmpty.length, string3DArrVEmptyA.length);\r
+        for (int i = 0; i < string3DArrVEmpty.length; i++) {\r
+            String[][] string2DT = string3DArrVEmpty[i];\r
+            String[][] string2DTa = string3DArrVEmptyA[i];\r
+            assertEquals(string2DT.length, string2DTa.length);\r
+            for (int j = 0; j < string2DT.length; j++) {\r
+                assertTrue(Arrays.equals(string2DT[j], string2DTa[j]));\r
+            }\r
+        }\r
+\r
+        //OcRepresentation\r
+        String intK = "intK";\r
+        String representation3DK = "representation3DK";\r
+        OcRepresentation[] representation2DArrV1 = {\r
+                new OcRepresentation(),\r
+                new OcRepresentation(),\r
+                new OcRepresentation(),\r
+                new OcRepresentation()};\r
+        representation2DArrV1[0].setValue(intK, 0);\r
+        representation2DArrV1[1].setValue(intK, 1);\r
+        representation2DArrV1[2].setValue(intK, 2);\r
+        representation2DArrV1[3].setValue(intK, 3);\r
+\r
+        OcRepresentation[] representation2DArrV2 = {\r
+                new OcRepresentation(),\r
+                new OcRepresentation(),\r
+                new OcRepresentation(),\r
+                new OcRepresentation()};\r
+        representation2DArrV2[0].setValue(intK, 4);\r
+        representation2DArrV2[1].setValue(intK, 5);\r
+        representation2DArrV2[2].setValue(intK, 6);\r
+        representation2DArrV2[3].setValue(intK, 7);\r
+\r
+        OcRepresentation[][] representation2DArrV = {representation2DArrV1, representation2DArrV2};\r
+        OcRepresentation[][][] representation3DArrV = {representation2DArrV, representation2DArrV};\r
+\r
+        rep.setValue(representation3DK, representation3DArrV);\r
+        OcRepresentation[][][] representation3DArrVa = rep.getValue(representation3DK);\r
+        assertEquals(representation3DArrV.length, representation3DArrVa.length);\r
+        for (int i = 0; i < representation3DArrV.length; ++i) {\r
+            OcRepresentation[][] repArr2V = representation3DArrV[i];\r
+            OcRepresentation[][] repArr2Va = representation3DArrVa[i];\r
+            assertEquals(repArr2V.length, repArr2Va.length);\r
+            for (int j = 0; j < repArr2V.length; ++j) {\r
+                OcRepresentation[] repArrV = repArr2V[j];\r
+                OcRepresentation[] repArrVa = repArr2Va[j];\r
+                assertEquals(repArrV.length, repArrVa.length);\r
+                for (int k = 0; k < repArrV.length; ++k) {\r
+                    assertEquals(repArrV[k].getValue(intK), repArrVa[k].getValue(intK));\r
+                }\r
+            }\r
+        }\r
+    }\r
+}
\ No newline at end of file
diff --git a/android/android_api/base/src/androidTest/java/org/iotivity/base/SmokeTest.java b/android/android_api/base/src/androidTest/java/org/iotivity/base/SmokeTest.java
new file mode 100755 (executable)
index 0000000..04e8cb0
--- /dev/null
@@ -0,0 +1,1563 @@
+/*
+ * //******************************************************************
+ * //
+ * // Copyright 2015 Intel Corporation.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ * //
+ * // 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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base;
+
+import android.test.InstrumentationTestCase;
+import android.util.Log;
+
+import java.util.Date;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+public class SmokeTest extends InstrumentationTestCase {
+    private static final String TAG = "SmokeTest";
+    private Random rnd = new Random();
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        PlatformConfig cfg = new PlatformConfig(
+                getInstrumentation().getContext(),
+                ServiceType.IN_PROC,
+                ModeType.CLIENT_SERVER,
+                "0.0.0.0",
+                0,
+                QualityOfService.LOW);
+
+        OcPlatform.Configure(cfg);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    public void testResourceRegisterUnregister() throws InterruptedException {
+        final String resourceType = "unit.test.resource" +
+                new Date().getTime();
+        final CountDownLatch signal = new CountDownLatch(1);
+
+        OcPlatform.EntityHandler entityHandler = new OcPlatform.EntityHandler() {
+            @Override
+            public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) {
+                return EntityHandlerResult.OK;
+            }
+        };
+
+        OcPlatform.OnResourceFoundListener resourceFoundListener =
+                new OcPlatform.OnResourceFoundListener() {
+                    @Override
+                    public void onResourceFound(OcResource resource) {
+                        Log.i(TAG, "Host: " + resource.getHost());
+                        Log.i(TAG, "Server ID: " + resource.getServerId());
+                        Log.i(TAG, "Connectivity Type: " + resource.getConnectivityType());
+                        signal.countDown();
+                    }
+                };
+
+        try {
+            //server
+            OcResourceHandle resourceHandle = OcPlatform.registerResource(
+                    "/a/unittest",
+                    resourceType,
+                    OcPlatform.DEFAULT_INTERFACE,
+                    entityHandler,
+                    EnumSet.of(ResourceProperty.DISCOVERABLE)
+            );
+
+            //client
+            OcPlatform.findResource("",
+                    OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
+                    OcConnectivityType.WIFI,
+                    resourceFoundListener);
+
+            //wait for onResourceFound event
+            assertTrue(signal.await(60, TimeUnit.SECONDS));
+
+            //server
+            OcPlatform.unregisterResource(resourceHandle);
+        } catch (OcException e) {
+            Log.e(TAG, e.getMessage());
+            assertTrue(false);
+        }
+    }
+
+    public void testStartStopListenForPresence() throws InterruptedException {
+        final String resourceType = "unit.test.resource" +
+                new Date().getTime();
+        final CountDownLatch signal = new CountDownLatch(1);
+
+        OcPlatform.EntityHandler entityHandler = new OcPlatform.EntityHandler() {
+            @Override
+            public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) {
+                return EntityHandlerResult.OK;
+            }
+        };
+
+        final OcPlatform.OnPresenceListener presenceListener = new OcPlatform.OnPresenceListener() {
+            @Override
+            public void onPresence(OcPresenceStatus ocPresenceStatus, int nonce, String hostAddress) {
+                Log.i(TAG, "onPresence status " + ocPresenceStatus.toString() + " nonce " + nonce);
+                signal.countDown();
+            }
+        };
+
+        OcPlatform.OnResourceFoundListener resourceFoundListener =
+                new OcPlatform.OnResourceFoundListener() {
+                    @Override
+                    public void onResourceFound(OcResource resource) {
+                        try {
+                            //client
+                            OcPresenceHandle presenceHandle = OcPlatform.subscribePresence(
+                                    resource.getHost(),
+                                    OcConnectivityType.WIFI,
+                                    presenceListener
+                            );
+
+                            //wait for onPresence event
+                            assertTrue(signal.await(60, TimeUnit.SECONDS));
+
+                            //client
+                            OcPlatform.unsubscribePresence(presenceHandle);
+                        } catch (OcException e) {
+                            assertTrue(false);
+                        } catch (InterruptedException e) {
+                            assertTrue(false);
+                        }
+                    }
+                };
+
+        try {
+            //server
+            OcResourceHandle resourceHandle = OcPlatform.registerResource(
+                    "/a/unittest",
+                    resourceType,
+                    OcPlatform.DEFAULT_INTERFACE,
+                    entityHandler,
+                    EnumSet.of(ResourceProperty.DISCOVERABLE)
+            );
+
+            //client
+            OcPlatform.findResource("",
+                    OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
+                    OcConnectivityType.WIFI,
+                    resourceFoundListener);
+
+            //server
+            OcPlatform.startPresence(OcPlatform.DEFAULT_PRESENCE_TTL);
+
+            //wait for onPresence event
+            assertTrue(signal.await(60, TimeUnit.SECONDS));
+
+            //server
+            OcPlatform.stopPresence();
+
+            //client
+            OcPlatform.unregisterResource(resourceHandle);
+
+        } catch (OcException e) {
+            Log.e(TAG, e.getMessage());
+            assertTrue(false);
+        }
+    }
+
+    public void testHandleGetRequest() throws InterruptedException {
+        final String someKey = "SomeKey";
+        final String someValue = "SomeValue";
+        final String resourceType = "unit.test.resource" + new Date().getTime();
+        final CountDownLatch signal1 = new CountDownLatch(1);
+        final CountDownLatch signal2 = new CountDownLatch(1);
+        final List<OcResource> ocResourceList = new LinkedList<OcResource>();
+
+        //client
+        final OcResource.OnGetListener onGetListener = new OcResource.OnGetListener() {
+            @Override
+            public void onGetCompleted(List<OcHeaderOption> headerOptionList, OcRepresentation ocRepresentation) {
+                if (!headerOptionList.isEmpty()) {
+                    for (OcHeaderOption headerOption : headerOptionList) {
+                        Log.i(TAG, "Header option " +
+                                headerOption.getOptionId() +
+                                " : " +
+                                headerOption.getOptionData());
+                    }
+                }
+                try {
+                    Log.i(TAG, "Power: " + ocRepresentation.getValue("power"));
+                } catch (OcException e) {
+                    Log.e(TAG, e.toString());
+                    assertTrue(false);
+                }
+                signal2.countDown();
+            }
+
+            @Override
+            public void onGetFailed(Throwable ex) {
+                if (ex instanceof OcException) {
+                    OcException ocEx = (OcException) ex;
+                    ErrorCode errCode = ocEx.getErrorCode();
+                }
+                Log.e(TAG, ex.toString());
+                assertTrue(false);
+            }
+        };
+
+        //client
+        final OcPlatform.OnResourceFoundListener resourceFoundListener =
+                new OcPlatform.OnResourceFoundListener() {
+                    @Override
+                    public void onResourceFound(OcResource resource) {
+                        Map<String, String> queryParamsMap = new HashMap<String, String>();
+                        queryParamsMap.put(someKey, someValue);
+
+                        ocResourceList.add(resource);
+                        try {
+                            resource.get(queryParamsMap, onGetListener);
+                            //TODO there is a bug in the stack that prevents the usage of the following APIs
+//                            resource.get(resourceType, OcPlatform.DEFAULT_INTERFACE, queryParamsMap,
+//                                    onGetListener);
+//
+//                            resource.get(queryParamsMap, onGetListener, QualityOfService.LOW);
+//
+//                            resource.get(resourceType, OcPlatform.DEFAULT_INTERFACE,queryParamsMap,
+//                                    onGetListener, QualityOfService.LOW);
+                        } catch (OcException e) {
+                            Log.e(TAG, e.toString());
+                            assertTrue(false);
+                        }
+                        signal1.countDown();
+                    }
+                };
+
+        try {
+            //server
+            OcResourceHandle resourceHandle = OcPlatform.registerResource(
+                    "/a/unittest",
+                    resourceType,
+                    OcPlatform.DEFAULT_INTERFACE,
+                    new OcPlatform.EntityHandler() {
+                        @Override
+                        public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) {
+                            EnumSet<RequestHandlerFlag> handlerFlagSet =
+                                    ocResourceRequest.getRequestHandlerFlagSet();
+
+                            RequestType requestType = ocResourceRequest.getRequestType();
+
+                            if (handlerFlagSet.contains(RequestHandlerFlag.INIT)) {
+                            }
+                            if (handlerFlagSet.contains(RequestHandlerFlag.REQUEST)) {
+                                OcResourceResponse ocResourceResponse = new OcResourceResponse();
+                                ocResourceResponse.setRequestHandle(
+                                        ocResourceRequest.getRequestHandle());
+                                ocResourceResponse.setResourceHandle(
+                                        ocResourceRequest.getResourceHandle());
+
+                                switch (requestType) {
+                                    case GET:
+                                        Map<String, String> queryParams =
+                                                ocResourceRequest.getQueryParameters();
+//TODO after the merge with CA, the query params are missing
+//                                        if (!(queryParams.containsKey(someKey) &&
+//                                                someValue.equals(queryParams.get(someKey)))) {
+//                                            assertTrue(false);
+//                                        }
+
+                                        ocResourceResponse.setErrorCode(200);
+                                        ocResourceResponse.setResponseResult(EntityHandlerResult.OK);
+                                        ocResourceResponse.setResourceRepresentation(
+                                                getRepresentation(74));
+                                        break;
+                                }
+
+                                try {
+                                    OcPlatform.sendResponse(ocResourceResponse);
+                                } catch (OcException e) {
+                                    Log.e(TAG, e.getMessage());
+                                    return EntityHandlerResult.ERROR;
+                                }
+                            }
+                            if (handlerFlagSet.contains(RequestHandlerFlag.OBSERVER)) {
+                            }
+                            return EntityHandlerResult.OK;
+                        }
+                    },
+                    EnumSet.of(ResourceProperty.DISCOVERABLE)
+            );
+
+            //client
+            OcPlatform.findResource(null,
+                    OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
+                    OcConnectivityType.WIFI,
+                    resourceFoundListener);
+
+            //wait for onResourceFound event
+            assertTrue(signal1.await(60, TimeUnit.SECONDS));
+
+            //wait for onGetCompleted event
+            assertTrue(signal2.await(60, TimeUnit.SECONDS));
+
+            //server
+            OcPlatform.unregisterResource(resourceHandle);
+
+        } catch (OcException e) {
+            Log.e(TAG, e.getMessage());
+            assertTrue(false);
+        }
+    }
+
+    public void testHandlePutRequest() throws InterruptedException {
+        final String resourceType = "unit.test.resource" + new Date().getTime();
+        final CountDownLatch signal1 = new CountDownLatch(1);
+        final CountDownLatch signal2 = new CountDownLatch(3);
+        final List<OcResource> ocResourceList = new LinkedList<OcResource>();
+
+        final OcResource.OnPutListener onPutListener = new OcResource.OnPutListener() {
+            @Override
+            public void onPutCompleted(List<OcHeaderOption> headerOptionList, OcRepresentation ocRepresentation) {
+                if (!headerOptionList.isEmpty()) {
+                    for (OcHeaderOption headerOption : headerOptionList) {
+                        Log.i(TAG, "Header option " +
+                                headerOption.getOptionId() +
+                                " : " +
+                                headerOption.getOptionData());
+                    }
+                }
+                try {
+                    Log.i(TAG, "onPutCompleted Power: " + ocRepresentation.getValue("power"));
+                } catch (OcException e) {
+                    Log.e(TAG, e.getMessage());
+                    assertTrue(false);
+                }
+                Log.i(TAG, "onPutCompleted Uri: " + ocRepresentation.getUri());
+                signal2.countDown();
+            }
+
+            @Override
+            public void onPutFailed(Throwable ex) {
+                if (ex instanceof OcException) {
+                    OcException ocEx = (OcException) ex;
+                    ErrorCode errCode = ocEx.getErrorCode();
+                }
+                Log.e(TAG, ex.toString());
+                assertTrue(false);
+            }
+        };
+
+        final OcPlatform.OnResourceFoundListener resourceFoundListener =
+                new OcPlatform.OnResourceFoundListener() {
+                    @Override
+                    public void onResourceFound(OcResource resource) {
+                        ocResourceList.add(resource);
+                        try {
+                            resource.put(
+                                    getRepresentation(),
+                                    new HashMap<String, String>(),
+                                    onPutListener);
+
+                            resource.put(
+                                    getRepresentation(),
+                                    new HashMap<String, String>(),
+                                    onPutListener);
+
+                            resource.put(
+                                    getRepresentation(),
+                                    new HashMap<String, String>(),
+                                    new OcResource.OnPutListener() {
+                                        @Override
+                                        public void onPutCompleted(List<OcHeaderOption> headerOptionList, OcRepresentation ocRepresentation) {
+                                            signal2.countDown();
+                                        }
+
+                                        @Override
+                                        public void onPutFailed(Throwable ex) {
+                                            if (ex instanceof OcException) {
+                                                OcException ocEx = (OcException) ex;
+                                                ErrorCode errCode = ocEx.getErrorCode();
+                                            }
+                                            Log.e(TAG, ex.toString());
+                                            assertTrue(false);
+                                        }
+                                    });
+
+                        } catch (OcException e) {
+                            assertTrue(false);
+                        }
+                        signal1.countDown();
+                    }
+                };
+
+        try {
+            //server
+            OcResourceHandle resourceHandle = OcPlatform.registerResource(
+                    "/a/unittest",
+                    resourceType,
+                    OcPlatform.DEFAULT_INTERFACE,
+                    new OcPlatform.EntityHandler() {
+                        @Override
+                        public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) {
+                            EnumSet<RequestHandlerFlag> handlerFlagSet = ocResourceRequest.getRequestHandlerFlagSet();
+                            RequestType requestType = ocResourceRequest.getRequestType();
+
+                            if (handlerFlagSet.contains(RequestHandlerFlag.INIT)) {
+                            }
+                            if (handlerFlagSet.contains(RequestHandlerFlag.REQUEST)) {
+                                OcResourceResponse ocResourceResponse = new OcResourceResponse();
+                                ocResourceResponse.setRequestHandle(
+                                        ocResourceRequest.getRequestHandle());
+                                ocResourceResponse.setResourceHandle(
+                                        ocResourceRequest.getResourceHandle());
+
+                                switch (requestType) {
+                                    case GET:
+                                        assertTrue(false);
+                                        break;
+                                    case PUT:
+                                        OcRepresentation rep = ocResourceRequest.getResourceRepresentation();
+                                        try {
+                                            Log.i(TAG, "Put res. power: " + rep.getValue("power"));
+                                        } catch (OcException e) {
+                                            Log.e(TAG, e.toString());
+                                            assertTrue(false);
+                                        }
+                                        Log.i(TAG, "URI: " + rep.getUri());
+
+                                        ocResourceResponse.setResponseResult(EntityHandlerResult.OK);
+                                        ocResourceResponse.setErrorCode(200);
+                                        ocResourceResponse.setResourceRepresentation(rep);
+                                        break;
+                                    case POST:
+                                        assertTrue(false);
+                                        break;
+                                    case DELETE:
+                                        break;
+                                }
+
+                                try {
+                                    OcPlatform.sendResponse(ocResourceResponse);
+                                } catch (OcException e) {
+                                    Log.e(TAG, e.getMessage());
+                                    return EntityHandlerResult.ERROR;
+                                }
+                            }
+                            if (handlerFlagSet.contains(RequestHandlerFlag.OBSERVER)) {
+                            }
+                            return EntityHandlerResult.OK;
+                        }
+                    },
+                    EnumSet.of(ResourceProperty.DISCOVERABLE)
+            );
+
+            //client
+            OcPlatform.findResource("",
+                    OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
+                    OcConnectivityType.WIFI,
+                    resourceFoundListener);
+
+            //wait for onResourceFound event
+            assertTrue(signal1.await(60, TimeUnit.SECONDS));
+
+            //wait for onGetCompleted event
+            assertTrue(signal2.await(60, TimeUnit.SECONDS));
+
+            //server
+            OcPlatform.unregisterResource(resourceHandle);
+
+        } catch (OcException e) {
+            Log.e(TAG, e.getMessage());
+            assertTrue(false);
+        }
+    }
+
+    public void testHandlePostRequest() throws InterruptedException {
+        final String resourceType = "unit.test.resource" + new Date().getTime();
+        final CountDownLatch signal1 = new CountDownLatch(1);
+        final CountDownLatch signal2 = new CountDownLatch(3);
+        final List<OcResource> ocResourceList = new LinkedList<OcResource>();
+
+        final OcResource.OnPostListener onPostListener = new OcResource.OnPostListener() {
+            @Override
+            public void onPostCompleted(List<OcHeaderOption> headerOptionList, OcRepresentation ocRepresentation) {
+                if (!headerOptionList.isEmpty()) {
+                    for (OcHeaderOption headerOption : headerOptionList) {
+                        Log.i(TAG, "Header option " +
+                                headerOption.getOptionId() +
+                                " : " +
+                                headerOption.getOptionData());
+                    }
+                }
+                try {
+                    Log.i(TAG, "onPostCompleted Power: " + ocRepresentation.getValue("power"));
+                } catch (OcException e) {
+                    Log.e(TAG, e.toString());
+                    assertTrue(false);
+                }
+                Log.i(TAG, "onPostCompleted Uri: " + ocRepresentation.getUri());
+                signal2.countDown();
+            }
+
+            @Override
+            public void onPostFailed(Throwable ex) {
+                if (ex instanceof OcException) {
+                    OcException ocEx = (OcException) ex;
+                    ErrorCode errCode = ocEx.getErrorCode();
+                }
+                Log.e(TAG, ex.toString());
+                assertTrue(false);
+            }
+        };
+
+        final OcPlatform.OnResourceFoundListener resourceFoundListener =
+                new OcPlatform.OnResourceFoundListener() {
+                    @Override
+                    public void onResourceFound(OcResource resource) {
+                        ocResourceList.add(resource);
+                        try {
+                            resource.post(
+                                    getRepresentation(),
+                                    new HashMap<String, String>(),
+                                    onPostListener);
+
+                            resource.post(
+                                    getRepresentation(),
+                                    new HashMap<String, String>(),
+                                    onPostListener);
+
+                            resource.post(
+                                    getRepresentation(),
+                                    new HashMap<String, String>(),
+                                    new OcResource.OnPostListener() {
+                                        @Override
+                                        public void onPostCompleted(List<OcHeaderOption> headerOptionList, OcRepresentation ocRepresentation) {
+                                            signal2.countDown();
+                                        }
+
+                                        @Override
+                                        public void onPostFailed(Throwable ex) {
+                                            if (ex instanceof OcException) {
+                                                OcException ocEx = (OcException) ex;
+                                                ErrorCode errCode = ocEx.getErrorCode();
+                                            }
+                                            Log.e(TAG, ex.toString());
+                                            assertTrue(false);
+                                        }
+                                    });
+
+                        } catch (OcException e) {
+                            assertTrue(false);
+                        }
+                        signal1.countDown();
+                    }
+                };
+
+        try {
+            //server
+            OcResourceHandle resourceHandle = OcPlatform.registerResource(
+                    "/a/unittest",
+                    resourceType,
+                    OcPlatform.DEFAULT_INTERFACE,
+                    new OcPlatform.EntityHandler() {
+                        @Override
+                        public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) {
+                            EnumSet<RequestHandlerFlag> handlerFlagSet = ocResourceRequest.getRequestHandlerFlagSet();
+                            RequestType requestType = ocResourceRequest.getRequestType();
+
+                            if (handlerFlagSet.contains(RequestHandlerFlag.INIT)) {
+                            }
+                            if (handlerFlagSet.contains(RequestHandlerFlag.REQUEST)) {
+                                OcResourceResponse ocResourceResponse = new OcResourceResponse();
+                                ocResourceResponse.setRequestHandle(
+                                        ocResourceRequest.getRequestHandle());
+                                ocResourceResponse.setResourceHandle(
+                                        ocResourceRequest.getResourceHandle());
+
+                                switch (requestType) {
+                                    case GET:
+                                        assertTrue(false);
+                                        break;
+                                    case PUT:
+                                        assertTrue(false);
+                                        break;
+                                    case POST:
+                                        OcRepresentation rep = ocResourceRequest.getResourceRepresentation();
+                                        try {
+                                            Log.i(TAG, "Post res. power: " + rep.getValue("power"));
+                                        } catch (OcException e) {
+                                            Log.e(TAG, e.toString());
+                                            assertTrue(false);
+                                        }
+                                        Log.i(TAG, "URI: " + rep.getUri());
+
+                                        ocResourceResponse.setErrorCode(200);
+                                        ocResourceResponse.setResponseResult(EntityHandlerResult.OK);
+                                        ocResourceResponse.setResourceRepresentation(
+                                                getRepresentation(44));
+
+                                        break;
+                                    case DELETE:
+                                        assertTrue(false);
+                                        break;
+                                }
+
+                                try {
+                                    OcPlatform.sendResponse(ocResourceResponse);
+                                } catch (OcException e) {
+                                    Log.e(TAG, e.getMessage());
+                                    return EntityHandlerResult.ERROR;
+                                }
+                            }
+                            if (handlerFlagSet.contains(RequestHandlerFlag.OBSERVER)) {
+                            }
+                            return EntityHandlerResult.OK;
+                        }
+                    },
+                    EnumSet.of(ResourceProperty.DISCOVERABLE)
+            );
+
+            //client
+            OcPlatform.findResource("",
+                    OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
+                    OcConnectivityType.WIFI,
+                    resourceFoundListener);
+
+            //wait for onResourceFound event
+            assertTrue(signal1.await(60, TimeUnit.SECONDS));
+
+            //wait for onPostCompleted event
+            assertTrue(signal2.await(60, TimeUnit.SECONDS));
+
+            //server
+            OcPlatform.unregisterResource(resourceHandle);
+
+        } catch (OcException e) {
+            Log.e(TAG, e.getMessage());
+            assertTrue(false);
+        }
+
+    }
+
+    public void testHandleDeleteRequest() throws InterruptedException {
+        final String resourceType = "unit.test.resource" + new Date().getTime();
+        final CountDownLatch signal1 = new CountDownLatch(1);
+        final CountDownLatch signal2 = new CountDownLatch(1);
+        final List<OcResource> ocResourceList = new LinkedList<OcResource>();
+
+        final OcResource.OnDeleteListener onDeleteListener = new OcResource.OnDeleteListener() {
+            @Override
+            public void onDeleteCompleted(List<OcHeaderOption> headerOptionList) {
+                signal2.countDown();
+            }
+
+            @Override
+            public void onDeleteFailed(Throwable ex) {
+                if (ex instanceof OcException) {
+                    OcException ocEx = (OcException) ex;
+                    ErrorCode errCode = ocEx.getErrorCode();
+                }
+                Log.e(TAG, ex.toString());
+                assertTrue(false);
+            }
+        };
+
+        final OcPlatform.OnResourceFoundListener resourceFoundListener =
+                new OcPlatform.OnResourceFoundListener() {
+                    @Override
+                    public void onResourceFound(OcResource resource) {
+                        ocResourceList.add(resource);
+                        try {
+                            resource.deleteResource(onDeleteListener);
+                        } catch (OcException e) {
+                            assertTrue(false);
+                        }
+                        signal1.countDown();
+                    }
+                };
+
+        try {
+            //server
+            OcResourceHandle resourceHandle = OcPlatform.registerResource(
+                    "/a/unittest",
+                    resourceType,
+                    OcPlatform.DEFAULT_INTERFACE,
+                    new OcPlatform.EntityHandler() {
+                        @Override
+                        public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) {
+                            EnumSet<RequestHandlerFlag> handlerFlagSet =
+                                    ocResourceRequest.getRequestHandlerFlagSet();
+                            RequestType requestType = ocResourceRequest.getRequestType();
+
+                            if (handlerFlagSet.contains(RequestHandlerFlag.INIT)) {
+                            }
+                            if (handlerFlagSet.contains(RequestHandlerFlag.REQUEST)) {
+                                OcResourceResponse ocResourceResponse = new OcResourceResponse();
+                                ocResourceResponse.setRequestHandle(
+                                        ocResourceRequest.getRequestHandle());
+                                ocResourceResponse.setResourceHandle(
+                                        ocResourceRequest.getResourceHandle());
+
+                                switch (requestType) {
+                                    case DELETE:
+                                        ocResourceResponse.setErrorCode(200);
+                                        ocResourceResponse.setResponseResult(
+                                                EntityHandlerResult.RESOURCE_DELETED);
+                                        break;
+                                }
+
+                                try {
+                                    OcPlatform.sendResponse(ocResourceResponse);
+                                } catch (OcException e) {
+                                    Log.e(TAG, e.getMessage());
+                                    return EntityHandlerResult.ERROR;
+                                }
+                            }
+                            if (handlerFlagSet.contains(RequestHandlerFlag.OBSERVER)) {
+                            }
+                            return EntityHandlerResult.OK;
+                        }
+                    },
+                    EnumSet.of(ResourceProperty.DISCOVERABLE)
+            );
+
+            //client
+            OcPlatform.findResource("",
+                    OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
+                    OcConnectivityType.WIFI,
+                    resourceFoundListener);
+
+            //wait for onResourceFound event
+            assertTrue(signal1.await(60, TimeUnit.SECONDS));
+
+            //wait for onDeleteCompleted event
+            assertTrue(signal2.await(60, TimeUnit.SECONDS));
+
+            //server
+            OcPlatform.unregisterResource(resourceHandle);
+
+        } catch (OcException e) {
+            Log.e(TAG, e.getMessage());
+            assertTrue(false);
+        }
+    }
+
+    public void testHandleGetPutPostDeleteFailures() throws InterruptedException {
+        final String resourceType = "unit.test.resource" + new Date().getTime();
+        final CountDownLatch signal1 = new CountDownLatch(1);
+        final CountDownLatch signal2 = new CountDownLatch(1);
+        final CountDownLatch signal3 = new CountDownLatch(1);
+        final CountDownLatch signal4 = new CountDownLatch(1);
+        final CountDownLatch signal5 = new CountDownLatch(1);
+
+        final List<OcResource> ocResourceList = new LinkedList<OcResource>();
+        final OcResource.OnGetListener onGetListener = new OcResource.OnGetListener() {
+            @Override
+            public void onGetCompleted(List<OcHeaderOption> headerOptionList,
+                                       OcRepresentation ocRepresentation) {
+                assertTrue(false);
+            }
+
+            @Override
+            public void onGetFailed(Throwable ex) {
+                if (ex instanceof OcException) {
+                    OcException ocEx = (OcException) ex;
+                    ErrorCode errCode = ocEx.getErrorCode();
+                }
+                Log.i(TAG, ex.toString());
+                signal2.countDown();
+            }
+        };
+
+        final OcResource.OnPutListener onPutListener = new OcResource.OnPutListener() {
+            @Override
+            public void onPutCompleted(List<OcHeaderOption> headerOptionList,
+                                       OcRepresentation ocRepresentation) {
+                assertTrue(false);
+            }
+
+            @Override
+            public void onPutFailed(Throwable ex) {
+                if (ex instanceof OcException) {
+                    OcException ocEx = (OcException) ex;
+                    ErrorCode errCode = ocEx.getErrorCode();
+                }
+                Log.i(TAG, ex.toString());
+                signal3.countDown();
+            }
+        };
+        final OcResource.OnPostListener onPostListener = new OcResource.OnPostListener() {
+            @Override
+            public void onPostCompleted(List<OcHeaderOption> headerOptionList,
+                                        OcRepresentation ocRepresentation) {
+                assertTrue(false);
+            }
+
+            @Override
+            public void onPostFailed(Throwable ex) {
+                if (ex instanceof OcException) {
+                    OcException ocEx = (OcException) ex;
+                    ErrorCode errCode = ocEx.getErrorCode();
+                }
+                Log.i(TAG, ex.toString());
+                signal4.countDown();
+            }
+        };
+
+        final OcResource.OnDeleteListener onDeleteListener = new OcResource.OnDeleteListener() {
+            @Override
+            public void onDeleteCompleted(List<OcHeaderOption> headerOptionList) {
+                assertTrue(false);
+            }
+
+            @Override
+            public void onDeleteFailed(Throwable ex) {
+                if (ex instanceof OcException) {
+                    OcException ocEx = (OcException) ex;
+                    ErrorCode errCode = ocEx.getErrorCode();
+                }
+                Log.i(TAG, ex.toString());
+                signal5.countDown();
+            }
+        };
+
+        final OcPlatform.OnResourceFoundListener resourceFoundListener =
+                new OcPlatform.OnResourceFoundListener() {
+                    @Override
+                    public void onResourceFound(OcResource resource) {
+                        ocResourceList.add(resource);
+                        try {
+                            resource.get(new HashMap<String, String>(), onGetListener);
+                            resource.put(new OcRepresentation(), new HashMap<String, String>(),
+                                    onPutListener);
+                            resource.post(new OcRepresentation(), new HashMap<String, String>(),
+                                    onPostListener);
+                            resource.deleteResource(onDeleteListener);
+                        } catch (OcException e) {
+                            assertTrue(false);
+                        }
+                        signal1.countDown();
+                    }
+                };
+
+        try {
+            //server
+            OcResourceHandle resourceHandle = OcPlatform.registerResource(
+                    "/a/unittest",
+                    resourceType,
+                    OcPlatform.DEFAULT_INTERFACE,
+                    new OcPlatform.EntityHandler() {
+                        @Override
+                        public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) {
+                            EnumSet<RequestHandlerFlag> handlerFlagSet =
+                                    ocResourceRequest.getRequestHandlerFlagSet();
+                            RequestType requestType = ocResourceRequest.getRequestType();
+
+                            if (handlerFlagSet.contains(RequestHandlerFlag.INIT)) {
+                            }
+                            if (handlerFlagSet.contains(RequestHandlerFlag.REQUEST)) {
+                                OcResourceResponse ocResourceResponse = new OcResourceResponse();
+                                ocResourceResponse.setRequestHandle(
+                                        ocResourceRequest.getRequestHandle());
+                                ocResourceResponse.setResourceHandle(
+                                        ocResourceRequest.getResourceHandle());
+
+                                switch (requestType) {
+                                    case GET:
+                                        ocResourceResponse.setErrorCode(200);
+                                        ocResourceResponse.setResponseResult(
+                                                EntityHandlerResult.ERROR);
+                                        break;
+                                    case PUT:
+                                        ocResourceResponse.setErrorCode(200);
+                                        ocResourceResponse.setResponseResult(
+                                                EntityHandlerResult.ERROR);
+                                        break;
+                                    case POST:
+                                        ocResourceResponse.setErrorCode(200);
+                                        ocResourceResponse.setResponseResult(
+                                                EntityHandlerResult.ERROR);
+                                        break;
+                                    case DELETE:
+                                        ocResourceResponse.setErrorCode(200);
+                                        ocResourceResponse.setResponseResult(
+                                                EntityHandlerResult.ERROR);
+                                        break;
+                                }
+                                try {
+                                    OcPlatform.sendResponse(ocResourceResponse);
+                                } catch (OcException e) {
+                                    Log.e(TAG, e.getMessage());
+                                    return EntityHandlerResult.ERROR;
+                                }
+                            }
+                            if (handlerFlagSet.contains(RequestHandlerFlag.OBSERVER)) {
+                            }
+                            return EntityHandlerResult.OK;
+                        }
+                    },
+                    EnumSet.of(ResourceProperty.DISCOVERABLE)
+            );
+
+            //client
+            OcPlatform.findResource("",
+                    OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
+                    OcConnectivityType.WIFI,
+                    resourceFoundListener);
+
+            //wait for onResourceFound event
+            assertTrue(signal1.await(60, TimeUnit.SECONDS));
+            //wait for onGetCompleted event
+            assertTrue(signal2.await(60, TimeUnit.SECONDS));
+            //wait for onPutCompleted event
+            assertTrue(signal3.await(60, TimeUnit.SECONDS));
+            //wait for onPostCompleted event
+            assertTrue(signal4.await(60, TimeUnit.SECONDS));
+            //wait for onDeleteCompleted event
+            assertTrue(signal5.await(60, TimeUnit.SECONDS));
+
+            //server
+            OcPlatform.unregisterResource(resourceHandle);
+
+        } catch (OcException e) {
+            Log.e(TAG, e.getMessage());
+            assertTrue(false);
+        }
+    }
+
+    public void testRegisterDeviceInfoGetDeviceInfo() throws InterruptedException {
+        final String resourceType = "unit.test.resource" + new Date().getTime();
+        final CountDownLatch signal = new CountDownLatch(1);
+
+        OcPlatform.OnDeviceFoundListener deviceFoundListener = new OcPlatform.OnDeviceFoundListener() {
+            @Override
+            public void onDeviceFound(OcRepresentation ocRepresentation) {
+                try {
+                    Log.i(TAG, "Device Name: " + ocRepresentation.getValue("dn"));
+                } catch (OcException e) {
+                    Log.e(TAG, e.toString());
+                    assertTrue(false);
+                }
+                boolean hasDeviceNameAtr = ocRepresentation.hasAttribute("dn");
+                assertTrue(hasDeviceNameAtr);
+                boolean hasNonExistingAtr = ocRepresentation.hasAttribute("NonExisting");
+                assertFalse(hasNonExistingAtr);
+                Log.i(TAG, "URI: " + ocRepresentation.getUri());
+                signal.countDown();
+            }
+        };
+
+        OcDeviceInfo devInfo = new OcDeviceInfo();
+
+        devInfo.setContentType("myContentType");
+        devInfo.setDateOfManufacture("myDateOfManufacture");
+        devInfo.setDeviceName("myDeviceName");
+        devInfo.setDeviceUuid("myDeviceUUID");
+        devInfo.setFirmwareVersion("myFirmwareVersion");
+        devInfo.setHostName("myHostName");
+        devInfo.setManufacturerName("myManufacturerNa");
+        devInfo.setManufacturerUrl("myManufacturerUrl");
+        devInfo.setModelNumber("myModelNumber");
+        devInfo.setPlatformVersion("myPlatformVersion");
+        devInfo.setSupportUrl("mySupportUrl");
+        devInfo.setVersion("myVersion");
+
+        try {
+            //server
+            OcPlatform.registerDeviceInfo(devInfo);
+
+            //client
+            OcPlatform.getDeviceInfo(
+                    "",
+                    OcPlatform.WELL_KNOWN_QUERY + "/d",
+                    OcConnectivityType.WIFI,
+                    deviceFoundListener);
+
+            //wait for onDeviceFound event
+            assertTrue(signal.await(60, TimeUnit.SECONDS));
+
+        } catch (OcException e) {
+            Log.e(TAG, e.getMessage());
+            assertTrue(false);
+        }
+    }
+
+    public void testBindUnbindResources() throws InterruptedException {
+        final String resourceType = "unit.test.resource" + new Date().getTime();
+        final CountDownLatch signal1 = new CountDownLatch(3);
+        final CountDownLatch signal2 = new CountDownLatch(2);
+        final CountDownLatch signal3 = new CountDownLatch(1);
+        final CountDownLatch signal4 = new CountDownLatch(3);
+        final CountDownLatch signal5 = new CountDownLatch(3);
+        final CountDownLatch signal6 = new CountDownLatch(1);
+
+        OcPlatform.EntityHandler entityHandler = new OcPlatform.EntityHandler() {
+            @Override
+            public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) {
+                return EntityHandlerResult.OK;
+            }
+        };
+
+        OcPlatform.OnResourceFoundListener resourceFoundListener1 = new OcPlatform.OnResourceFoundListener() {
+            @Override
+            public void onResourceFound(OcResource resource) {
+                signal1.countDown();
+            }
+        };
+
+        OcPlatform.OnResourceFoundListener resourceFoundListener2 = new OcPlatform.OnResourceFoundListener() {
+            @Override
+            public void onResourceFound(OcResource resource) {
+                signal2.countDown();
+            }
+        };
+
+        OcPlatform.OnResourceFoundListener resourceFoundListener3 = new OcPlatform.OnResourceFoundListener() {
+            @Override
+            public void onResourceFound(OcResource resource) {
+                signal3.countDown();
+            }
+        };
+
+        OcPlatform.OnResourceFoundListener resourceFoundListener4 = new OcPlatform.OnResourceFoundListener() {
+            @Override
+            public void onResourceFound(OcResource resource) {
+                signal4.countDown();
+            }
+        };
+
+        OcPlatform.OnResourceFoundListener resourceFoundListener5 = new OcPlatform.OnResourceFoundListener() {
+            @Override
+            public void onResourceFound(OcResource resource) {
+                signal5.countDown();
+            }
+        };
+
+        OcPlatform.OnResourceFoundListener resourceFoundListener6 = new OcPlatform.OnResourceFoundListener() {
+            @Override
+            public void onResourceFound(OcResource resource) {
+                signal6.countDown();
+            }
+        };
+
+        try {
+
+            //server
+            OcResourceHandle resourceHandleCollection = OcPlatform.registerResource(
+                    "/a/unittest1",
+                    resourceType,
+                    OcPlatform.DEFAULT_INTERFACE,
+                    entityHandler,
+                    EnumSet.of(ResourceProperty.DISCOVERABLE)
+            );
+
+            OcResourceHandle resourceHandle1 = OcPlatform.registerResource(
+                    "/a/unittest2",
+                    resourceType,
+                    OcPlatform.DEFAULT_INTERFACE,
+                    entityHandler,
+                    EnumSet.of(ResourceProperty.DISCOVERABLE)
+            );
+
+            OcResourceHandle resourceHandle2 = OcPlatform.registerResource(
+                    "/a/unittest3",
+                    resourceType,
+                    OcPlatform.DEFAULT_INTERFACE,
+                    entityHandler,
+                    EnumSet.of(ResourceProperty.DISCOVERABLE)
+            );
+
+            //client
+            OcPlatform.findResource("",
+                    OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
+                    OcConnectivityType.WIFI,
+                    resourceFoundListener1);
+
+            //wait for onResourceFound event to find 3 registered resources
+            assertTrue(signal1.await(60, TimeUnit.SECONDS));
+
+            //server
+            OcPlatform.bindResource(resourceHandleCollection, resourceHandle1);
+            OcPlatform.bindResource(resourceHandleCollection, resourceHandle2);
+
+            //client
+            OcPlatform.findResource("",
+                    OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
+                    OcConnectivityType.WIFI,
+                    resourceFoundListener3);
+
+            //wait for onResourceFound event to find 1 collection resources
+            assertTrue(signal3.await(60, TimeUnit.SECONDS));
+
+            //server
+            OcPlatform.unbindResource(resourceHandleCollection, resourceHandle1);
+
+            //client
+            OcPlatform.findResource("",
+                    OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
+                    OcConnectivityType.WIFI,
+                    resourceFoundListener2);
+
+            //wait for onResourceFound event to find 2 resources
+            assertTrue(signal2.await(60, TimeUnit.SECONDS));
+
+            //server
+            OcPlatform.unbindResource(resourceHandleCollection, resourceHandle2);
+
+            //client
+            OcPlatform.findResource("",
+                    OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
+                    OcConnectivityType.WIFI,
+                    resourceFoundListener4);
+
+            //wait for onResourceFound event to find 3 registered resources
+            assertTrue(signal4.await(60, TimeUnit.SECONDS));
+
+            //Bind/unbind a list of resource handles
+            List<OcResourceHandle> resourceHandleList = new LinkedList<OcResourceHandle>();
+            resourceHandleList.add(resourceHandle1);
+            resourceHandleList.add(resourceHandle2);
+            OcPlatform.bindResources(resourceHandleCollection, resourceHandleList);
+
+            //client
+            OcPlatform.findResource("",
+                    OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
+                    OcConnectivityType.WIFI,
+                    resourceFoundListener6);
+
+            //wait for onResourceFound event to find 1 collection resources
+            assertTrue(signal6.await(60, TimeUnit.SECONDS));
+
+            OcPlatform.unbindResources(resourceHandleCollection, resourceHandleList);
+
+            //client
+            OcPlatform.findResource("",
+                    OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
+                    OcConnectivityType.WIFI,
+                    resourceFoundListener5);
+
+            //wait for onResourceFound event to find 1 collection resources
+            assertTrue(signal5.await(60, TimeUnit.SECONDS));
+
+            //server
+            OcPlatform.unregisterResource(resourceHandleCollection);
+            OcPlatform.unregisterResource(resourceHandle1);
+            OcPlatform.unregisterResource(resourceHandle2);
+        } catch (OcException e) {
+            Log.e(TAG, e.getMessage());
+            assertTrue(false);
+        }
+    }
+
+    public void testResourceMethods() throws InterruptedException {
+        final String resourceType1 = "unit.test.resource" + new Date().getTime();
+        final String resourceType2 = "unit.test.resource" + new Date().getTime();
+
+        final CountDownLatch signal = new CountDownLatch(2);
+        final List<OcResource> resourceList = new LinkedList<OcResource>();
+
+        OcPlatform.EntityHandler entityHandler = new OcPlatform.EntityHandler() {
+            @Override
+            public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) {
+                return EntityHandlerResult.OK;
+            }
+        };
+
+        OcPlatform.OnResourceFoundListener resourceFoundListener =
+                new OcPlatform.OnResourceFoundListener() {
+                    @Override
+                    public void onResourceFound(OcResource resource) {
+                        resourceList.add(resource);
+                        Log.i(TAG, "Host: " + resource.getHost());
+                        Log.i(TAG, "Uri: " + resource.getUri());
+                        Log.i(TAG, "Observable: " + resource.isObservable());
+
+                        for (String resourceType : resource.getResourceTypes()) {
+                            Log.i(TAG, "Type: " + resourceType);
+                        }
+
+                        for (String resourceInterface : resource.getResourceInterfaces()) {
+                            Log.i(TAG, "Interface: " + resourceInterface);
+                        }
+
+                        List<OcHeaderOption> headerOptionList = new LinkedList<OcHeaderOption>();
+                        headerOptionList.add(new OcHeaderOption(2885, "OptionData1"));
+                        headerOptionList.add(new OcHeaderOption(2886, "OptionData2"));
+                        resource.setHeaderOptions(headerOptionList);
+
+                        resource.setHeaderOptions(headerOptionList);
+                        resource.unsetHeaderOptions();
+
+                        OcResourceIdentifier resourceIdentifier = resource.getUniqueIdentifier();
+                        OcResourceIdentifier resourceIdentifier2 = resource.getUniqueIdentifier();
+                        assertTrue(resourceIdentifier.equals(resourceIdentifier2));
+
+                        signal.countDown();
+                    }
+                };
+
+        try {
+            //server
+            OcResourceHandle resourceHandle1 = OcPlatform.registerResource(
+                    "/a/unittest1",
+                    resourceType1,
+                    OcPlatform.DEFAULT_INTERFACE,
+                    entityHandler,
+                    EnumSet.of(ResourceProperty.DISCOVERABLE)
+            );
+
+            OcResourceHandle resourceHandle2 = OcPlatform.registerResource(
+                    "/a/unittest2",
+                    resourceType2,
+                    OcPlatform.DEFAULT_INTERFACE,
+                    entityHandler,
+                    EnumSet.of(ResourceProperty.DISCOVERABLE)
+            );
+
+            //client
+            OcPlatform.findResource("",
+                    OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType1,
+                    OcConnectivityType.WIFI,
+                    resourceFoundListener);
+
+            OcPlatform.findResource("",
+                    OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType2,
+                    OcConnectivityType.WIFI,
+                    resourceFoundListener);
+
+            //wait for onResourceFound event
+            assertTrue(signal.await(60, TimeUnit.SECONDS));
+
+            assertTrue(2 == resourceList.size());
+
+            OcResource res0 = resourceList.get(0);
+            OcResource res1 = resourceList.get(1);
+            assertFalse(res0.getUniqueIdentifier().equals(res1.getUniqueIdentifier()));
+            assertTrue(res0.getUniqueIdentifier().equals(res0.getUniqueIdentifier()));
+
+            //server
+            OcPlatform.unregisterResource(resourceHandle1);
+            OcPlatform.unregisterResource(resourceHandle2);
+
+        } catch (OcException e) {
+            Log.e(TAG, e.getMessage());
+            assertTrue(false);
+        }
+    }
+
+    public void testCreateResourceProxy() throws InterruptedException {
+        final String resourceType = "unit.test.resource" + new Date().getTime();
+        final CountDownLatch signal = new CountDownLatch(1);
+
+        OcPlatform.EntityHandler entityHandler = new OcPlatform.EntityHandler() {
+            @Override
+            public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) {
+                return EntityHandlerResult.OK;
+            }
+        };
+
+        OcPlatform.OnResourceFoundListener resourceFoundListener =
+                new OcPlatform.OnResourceFoundListener() {
+                    @Override
+                    public void onResourceFound(OcResource resource) {
+
+                        try {
+                            //client: construct resource proxy
+                            OcResource resourceProxy = OcPlatform.constructResourceObject(
+                                    resource.getHost(),
+                                    resource.getUri(),
+                                    OcConnectivityType.WIFI,
+                                    resource.isObservable(),
+                                    resource.getResourceTypes(),
+                                    resource.getResourceInterfaces());
+
+                            //client: register resource proxy
+                            OcResourceHandle resourceProxyHandle =
+                                    OcPlatform.registerResource(resourceProxy);
+
+                            OcPlatform.unregisterResource(resourceProxyHandle);
+                        } catch (OcException e) {
+                            assertTrue(false);
+                        }
+                        signal.countDown();
+                    }
+                };
+
+        try {
+            //server
+            OcResourceHandle resourceHandle = OcPlatform.registerResource(
+                    "/a/unittest",
+                    resourceType,
+                    OcPlatform.DEFAULT_INTERFACE,
+                    entityHandler,
+                    EnumSet.of(ResourceProperty.DISCOVERABLE)
+            );
+
+            //client
+            OcPlatform.findResource("",
+                    OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
+                    OcConnectivityType.WIFI,
+                    resourceFoundListener);
+
+            //wait for onResourceFound event
+            assertTrue(signal.await(60, TimeUnit.SECONDS));
+
+            //server
+            OcPlatform.unregisterResource(resourceHandle);
+
+        } catch (OcException e) {
+            Log.e(TAG, e.getMessage());
+            assertTrue(false);
+        }
+
+        try {
+            //server
+            OcResourceHandle resourceHandle = OcPlatform.registerResource(
+                    "/a/unittest",
+                    resourceType,
+                    OcPlatform.DEFAULT_INTERFACE,
+                    entityHandler,
+                    EnumSet.of(ResourceProperty.DISCOVERABLE)
+            );
+
+            //client
+            OcPlatform.findResource("",
+                    OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
+                    OcConnectivityType.WIFI,
+                    resourceFoundListener);
+
+            //wait for onResourceFound event
+            assertTrue(signal.await(60, TimeUnit.SECONDS));
+
+            //server
+            OcPlatform.unregisterResource(resourceHandle);
+
+        } catch (OcException e) {
+            Log.e(TAG, e.getMessage());
+            assertTrue(false);
+        }
+    }
+
+    public void testObserveClientServer() throws InterruptedException {
+        final int NUM_OBSERVES = 20;
+        final Timer timer = new Timer();
+        final List<OcResource> resourceList = new LinkedList<OcResource>();
+        final List<OcResourceHandle> resourceHandleList = new LinkedList<OcResourceHandle>();
+        final CountDownLatch signal1 = new CountDownLatch(1);
+        final CountDownLatch signal2 = new CountDownLatch(NUM_OBSERVES);
+        final CountDownLatch signal3 = new CountDownLatch(1);
+
+        final String resourceType = "unit.test.resource" + new Date().getTime();
+
+        final OcResource.OnObserveListener observeListener = new OcResource.OnObserveListener() {
+            @Override
+            public void onObserveCompleted(
+                    List<OcHeaderOption> headerOptionList,
+                    OcRepresentation ocRepresentation,
+                    int sequenceNumber) {
+
+                try {
+                    Log.i(TAG, "Observe #" + sequenceNumber + " power: " +
+                            ocRepresentation.getValue("power"));
+                } catch (OcException e) {
+                    Log.e(TAG, e.toString());
+                    assertTrue(false);
+                }
+                signal2.countDown();
+            }
+
+            @Override
+            public void onObserveFailed(Throwable ex) {
+                if (ex instanceof OcException) {
+                    OcException ocEx = (OcException) ex;
+                    ErrorCode errCode = ocEx.getErrorCode();
+                }
+                Log.e(TAG, ex.toString());
+                assertTrue(false);
+            }
+        };
+
+        final List<Byte> observationIdList = new LinkedList<Byte>();
+        OcPlatform.EntityHandler entityHandler = new OcPlatform.EntityHandler() {
+            @Override
+            public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) {
+                EnumSet<RequestHandlerFlag> handlerFlagSet = ocResourceRequest.getRequestHandlerFlagSet();
+                RequestType requestType = ocResourceRequest.getRequestType();
+
+                if (handlerFlagSet.contains(RequestHandlerFlag.INIT)) {
+
+                }
+                if (handlerFlagSet.contains(RequestHandlerFlag.REQUEST)) {
+                    OcResourceResponse ocResourceResponse = new OcResourceResponse();
+                    ocResourceResponse.setRequestHandle(ocResourceRequest.getRequestHandle());
+                    ocResourceResponse.setResourceHandle(ocResourceRequest.getResourceHandle());
+
+                    switch (requestType) {
+                        case GET:
+                            ocResourceResponse.setErrorCode(200);
+                            ocResourceResponse.setResponseResult(EntityHandlerResult.OK);
+                            ocResourceResponse.setResourceRepresentation(
+                                    getRepresentation(
+                                            rnd.nextInt(100)));
+                            try {
+                                OcPlatform.sendResponse(ocResourceResponse);
+                            } catch (OcException e) {
+                                Log.e(TAG, e.getMessage());
+                                return EntityHandlerResult.ERROR;
+                            }
+                            break;
+                    }
+                }
+
+                if (handlerFlagSet.contains(RequestHandlerFlag.OBSERVER)) {
+                    ObservationInfo observationInfo = ocResourceRequest.getObservationInfo();
+
+                    switch (observationInfo.getObserveAction()) {
+                        case REGISTER:
+                            synchronized (observationIdList) {
+                                observationIdList.add(observationInfo.getOcObservationId());
+                                timer.schedule(new TimerTask() {
+                                    int numNotified = 1;
+
+                                    @Override
+                                    public void run() {
+                                        if (0 < resourceHandleList.size()) {
+                                            synchronized (observationIdList) {
+                                                if (numNotified > NUM_OBSERVES) {
+                                                    timer.cancel();
+                                                    timer.purge();
+                                                    signal3.countDown();
+                                                } else {
+                                                    try {
+                                                        OcPlatform.notifyAllObservers(
+                                                                resourceHandleList.get(0));
+                                                    } catch (OcException e) {
+                                                        if (ErrorCode.NO_OBSERVERS == e.getErrorCode()) {
+                                                            timer.cancel();
+                                                            timer.purge();
+                                                            signal3.countDown();
+                                                        }
+                                                        Log.e(TAG, e.getMessage());
+                                                    }
+                                                    numNotified++;
+                                                }
+                                            }
+                                        }
+
+                                    }
+                                }, 0, 100);
+                            }
+                            break;
+                        case UNREGISTER:
+                            //TODO unregister isn't implemented in C++ API, yet
+                            synchronized (observationIdList) {
+                                timer.cancel();
+                                break;
+                            }
+                    }
+                }
+                return EntityHandlerResult.OK;
+            }
+        };
+
+        OcPlatform.OnResourceFoundListener resourceFoundListener =
+                new OcPlatform.OnResourceFoundListener() {
+                    @Override
+                    public void onResourceFound(OcResource resource) {
+                        resourceList.add(resource);
+                        if (resource.isObservable()) {
+                            try {
+                                resource.observe(
+                                        ObserveType.OBSERVE,
+                                        new HashMap<String, String>(),
+                                        observeListener);
+
+                                signal1.countDown();
+                            } catch (OcException e) {
+                                Log.e(TAG, e.getMessage());
+                                assertTrue(false);
+                            }
+                        }
+                    }
+                };
+        try {
+            //server
+            OcResourceHandle resourceHandle = OcPlatform.registerResource(
+                    "/a/unittest",
+                    resourceType,
+                    OcPlatform.DEFAULT_INTERFACE,
+                    entityHandler,
+                    EnumSet.of(ResourceProperty.DISCOVERABLE, ResourceProperty.OBSERVABLE)
+            );
+
+            resourceHandleList.add(resourceHandle);
+
+            //client
+            OcPlatform.findResource("",
+                    OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
+                    OcConnectivityType.WIFI,
+                    resourceFoundListener);
+
+            //wait for onResourceFound event
+            assertTrue(signal1.await(60, TimeUnit.SECONDS));
+
+            //wait for OnObserveListener event to observe 20 values
+            assertTrue(signal2.await(60, TimeUnit.SECONDS));
+
+            if (resourceList.size() > 0) {
+                OcResource resource = resourceList.get(0);
+                if (resource.isObservable()) {
+                    resource.cancelObserve();
+                }
+            }
+
+            //wait for server to finish
+            assertTrue(signal3.await(60, TimeUnit.SECONDS));
+
+            //server
+            OcPlatform.unregisterResource(resourceHandle);
+
+        } catch (OcException e) {
+            Log.e(TAG, e.getMessage());
+            assertTrue(false);
+        }
+    }
+
+    private OcRepresentation getRepresentation(int value) {
+        OcRepresentation rep = new OcRepresentation();
+        try {
+            rep.setValue("power", value);
+        } catch (OcException e) {
+            Log.e(TAG, e.toString());
+            assertTrue(false);
+        }
+        return rep;
+    }
+
+    private OcRepresentation getRepresentation() {
+        return getRepresentation(74);
+    }
+}
\ No newline at end of file
diff --git a/android/android_api/base/src/main/AndroidManifest.xml b/android/android_api/base/src/main/AndroidManifest.xml
new file mode 100755 (executable)
index 0000000..183e674
--- /dev/null
@@ -0,0 +1,35 @@
+<!--\r
+  ~ //******************************************************************\r
+  ~ //\r
+  ~ // Copyright 2015 Intel Corporation.\r
+  ~ //\r
+  ~ //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+  ~ //\r
+  ~ // Licensed under the Apache License, Version 2.0 (the "License");\r
+  ~ // you may not use this file except in compliance with the License.\r
+  ~ // You may obtain a copy of the License at\r
+  ~ //\r
+  ~ //      http://www.apache.org/licenses/LICENSE-2.0\r
+  ~ //\r
+  ~ // Unless required by applicable law or agreed to in writing, software\r
+  ~ // distributed under the License is distributed on an "AS IS" BASIS,\r
+  ~ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+  ~ // See the License for the specific language governing permissions and\r
+  ~ // limitations under the License.\r
+  ~ //\r
+  ~ //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+  -->\r
+\r
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"\r
+    package="org.iotivity.base">\r
+    <uses-permission android:name="android.permission.BLUETOOTH" />\r
+    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />\r
+    <uses-permission android:name="android.permission.INTERNET" />\r
+    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />\r
+    <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />\r
+    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />\r
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />\r
+    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />\r
+\r
+    <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="21" />\r
+</manifest>\r
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/EntityHandlerResult.java b/android/android_api/base/src/main/java/org/iotivity/base/EntityHandlerResult.java
new file mode 100755 (executable)
index 0000000..d8ed2fb
--- /dev/null
@@ -0,0 +1,42 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base;\r
+\r
+public enum EntityHandlerResult {\r
+    OK(0),\r
+    ERROR(1),\r
+    RESOURCE_CREATED(2),\r
+    RESOURCE_DELETED(3),\r
+    SLOW(4),\r
+    FORBIDDEN(5);\r
+\r
+    private int value;\r
+\r
+    private EntityHandlerResult(int value) {\r
+        this.value = value;\r
+    }\r
+\r
+    public int getValue() {\r
+        return this.value;\r
+    }\r
+}\r
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/ErrorCode.java b/android/android_api/base/src/main/java/org/iotivity/base/ErrorCode.java
new file mode 100755 (executable)
index 0000000..d1862e0
--- /dev/null
@@ -0,0 +1,95 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base;\r
+\r
+public enum ErrorCode {\r
+    /* Success status code - START HERE */\r
+    OK("OK", ""),\r
+    RESOURCE_CREATED("RESOURCE_CREATED", ""),\r
+    RESOURCE_DELETED("RESOURCE_DELETED", ""),\r
+    CONTINUE("CONTINUE", ""),\r
+    /* Success status code - END HERE */\r
+        /* Error status code - START HERE */\r
+    INVALID_URI("INVALID_URI", ""),\r
+    INVALID_QUERY("INVALID_QUERY", ""),\r
+    INVALID_IP("INVALID_IP", ""),\r
+    INVALID_PORT("INVALID_PORT", ""),\r
+    INVALID_CALLBACK("INVALID_CALLBACK", ""),\r
+    INVALID_METHOD("INVALID_METHOD", ""),\r
+    INVALID_PARAM("INVALID_PARAM", ""),\r
+    INVALID_OBSERVE_PARAM("INVALID_OBSERVE_PARAM", ""),\r
+    NO_MEMORY("NO_MEMORY", ""),\r
+    COMM_ERROR("COMM_ERROR", ""),\r
+    NOT_IMPL("NOTIMPL", ""),\r
+    NO_RESOURCE("NO_RESOURCE", "Resource not found"),\r
+    RESOURCE_ERROR("RESOURCE_ERROR", "Not supported method or interface"),\r
+    SLOW_RESOURCE("SLOW_RESOURCE", ""),\r
+    NO_OBSERVERS("NO_OBSERVERS", "Resource has no registered observers"),\r
+    OBSERVER_NOT_FOUND("OBSERVER_NOT_FOUND", ""),\r
+    PRESENCE_STOPPED("PRESENCE_STOPPED", ""),\r
+    PRESENCE_TIMEOUT("PRESENCE_TIMEOUT", ""),\r
+    PRESENCE_DO_NOT_HANDLE("PRESENCE_DO_NOT_HANDLE", ""),\r
+    VIRTUAL_DO_NOT_HANDLE("VIRTUAL_DO_NOT_HANDLE", ""),\r
+    INVALID_OPTION("INVALID_OPTION", ""),\r
+    MALFORMED_RESPONSE("MALFORMED_RESPONSE", "Remote reply contained malformed data"),\r
+    PERSISTENT_BUFFER_REQUIRED("PERSISTENT_BUFFER_REQUIRED", ""),\r
+    INVALID_REQUEST_HANDLE("INVALID_REQUEST_HANDLE", ""),\r
+    INVALID_DEVICE_INFO("INVALID_DEVICE_INFO", ""),\r
+    ERROR("ERROR", "Generic error"),\r
+\r
+    JNI_EXCEPTION("JNI_EXCEPTION", "Generic Java binder error"),\r
+    JNI_NO_NATIVE_OBJECT("JNI_NO_NATIVE_OBJECT", ""),\r
+    JNI_INVALID_VALUE("JNI_INVALID_VALUE", ""),\r
+\r
+    INVALID_CLASS_CAST("INVALID_CLASS_CAST", ""),;\r
+\r
+    private String error;\r
+    private String description;\r
+\r
+    private ErrorCode(String error, String description) {\r
+        this.error = error;\r
+        this.description = description;\r
+    }\r
+\r
+    public String getError() {\r
+        return error;\r
+    }\r
+\r
+    public String getDescription() {\r
+        return description;\r
+    }\r
+\r
+    public static ErrorCode get(String errorCode) {\r
+        for (ErrorCode eCode : ErrorCode.values()) {\r
+            if (eCode.getError().equals(errorCode)) {\r
+                return eCode;\r
+            }\r
+        }\r
+        throw new IllegalArgumentException("Unexpected ErrorCode value");\r
+    }\r
+\r
+    @Override\r
+    public String toString() {\r
+        return error + (description.isEmpty() ? "" : " : " + description);\r
+    }\r
+}\r
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/ModeType.java b/android/android_api/base/src/main/java/org/iotivity/base/ModeType.java
new file mode 100755 (executable)
index 0000000..81ea7c7
--- /dev/null
@@ -0,0 +1,39 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base;\r
+\r
+public enum ModeType {\r
+    SERVER(0),\r
+    CLIENT(1),\r
+    CLIENT_SERVER(2),;\r
+\r
+    private int value;\r
+\r
+    private ModeType(int value) {\r
+        this.value = value;\r
+    }\r
+\r
+    public int getValue() {\r
+        return this.value;\r
+    }\r
+}\r
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/ObservationInfo.java b/android/android_api/base/src/main/java/org/iotivity/base/ObservationInfo.java
new file mode 100755 (executable)
index 0000000..483d4cb
--- /dev/null
@@ -0,0 +1,55 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base;\r
+\r
+public class ObservationInfo {\r
+\r
+    private ObserveAction mObserveAction;\r
+    private byte mOcObservationId;\r
+\r
+    private ObservationInfo(int observationAction, byte observationId) {\r
+        this.mObserveAction = ObserveAction.get(observationAction);\r
+        this.mOcObservationId = observationId;\r
+    }\r
+\r
+    public ObservationInfo(ObserveAction observeAction, byte observationId) {\r
+        this.mObserveAction = observeAction;\r
+        this.mOcObservationId = observationId;\r
+    }\r
+\r
+    public ObserveAction getObserveAction() {\r
+        return mObserveAction;\r
+    }\r
+\r
+    public void setObserveAction(ObserveAction observeAction) {\r
+        this.mObserveAction = observeAction;\r
+    }\r
+\r
+    public byte getOcObservationId() {\r
+        return mOcObservationId;\r
+    }\r
+\r
+    public void setOcObservationId(byte ocObservationId) {\r
+        this.mOcObservationId = ocObservationId;\r
+    }\r
+}\r
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/ObserveAction.java b/android/android_api/base/src/main/java/org/iotivity/base/ObserveAction.java
new file mode 100755 (executable)
index 0000000..3e7c5ec
--- /dev/null
@@ -0,0 +1,47 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base;\r
+\r
+public enum ObserveAction {\r
+    REGISTER(0),\r
+    UNREGISTER(1),;\r
+\r
+    private int value;\r
+\r
+    private ObserveAction(int value) {\r
+        this.value = value;\r
+    }\r
+\r
+    public int getValue() {\r
+        return this.value;\r
+    }\r
+\r
+    public static ObserveAction get(int val) {\r
+        for (ObserveAction observeAction : ObserveAction.values()) {\r
+            if (observeAction.getValue() == val)\r
+                return observeAction;\r
+        }\r
+\r
+        throw new IllegalArgumentException("Unexpected ObserveAction value");\r
+    }\r
+}\r
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/ObserveType.java b/android/android_api/base/src/main/java/org/iotivity/base/ObserveType.java
new file mode 100755 (executable)
index 0000000..3432a47
--- /dev/null
@@ -0,0 +1,38 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base;\r
+\r
+public enum ObserveType {\r
+    OBSERVE(0),\r
+    OBSERVE_ALL(1),;\r
+\r
+    private int value;\r
+\r
+    private ObserveType(int value) {\r
+        this.value = value;\r
+    }\r
+\r
+    public int getValue() {\r
+        return this.value;\r
+    }\r
+}\r
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcConnectivityType.java b/android/android_api/base/src/main/java/org/iotivity/base/OcConnectivityType.java
new file mode 100755 (executable)
index 0000000..e405790
--- /dev/null
@@ -0,0 +1,52 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base;\r
+\r
+import java.security.InvalidParameterException;\r
+\r
+public enum OcConnectivityType {\r
+    ETHERNET(0),\r
+    WIFI    (1),\r
+    EDR     (2),\r
+    LE      (3),\r
+    ALL     (4),\r
+    ;\r
+\r
+    private int value;\r
+\r
+    private OcConnectivityType(int value) {\r
+        this.value = value;\r
+    }\r
+\r
+    public int getValue() {\r
+        return this.value;\r
+    }\r
+\r
+    public static OcConnectivityType get(int val) {\r
+        for (OcConnectivityType v : OcConnectivityType.values()) {\r
+            if (v.getValue() == val)\r
+                return v;\r
+        }\r
+        throw new InvalidParameterException("Unexpected OcConnectivityType value:" + val);\r
+    }\r
+}\r
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcDeviceInfo.java b/android/android_api/base/src/main/java/org/iotivity/base/OcDeviceInfo.java
new file mode 100755 (executable)
index 0000000..65e1497
--- /dev/null
@@ -0,0 +1,177 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base;\r
+\r
+public class OcDeviceInfo {\r
+\r
+    private String deviceName;\r
+    private String hostName;\r
+    private String deviceUuid;\r
+    private String contentType;\r
+    private String version;\r
+    private String manufacturerName;\r
+    private String manufacturerUrl;\r
+    private String modelNumber;\r
+    private String dateOfManufacture;\r
+    private String platformVersion;\r
+    private String firmwareVersion;\r
+    private String supportUrl;\r
+\r
+    public OcDeviceInfo() {\r
+        deviceName = "";\r
+        hostName = "";\r
+        deviceUuid = "";\r
+        contentType = "";\r
+        version = "";\r
+        manufacturerName = "";\r
+        manufacturerUrl = "";\r
+        modelNumber = "";\r
+        dateOfManufacture = "";\r
+        platformVersion = "";\r
+        firmwareVersion = "";\r
+        supportUrl = "";\r
+    }\r
+\r
+    public OcDeviceInfo(\r
+            String deviceName,\r
+            String hostName,\r
+            String deviceUuid,\r
+            String contentType,\r
+            String version,\r
+            String manufacturerName,\r
+            String manufacturerUrl,\r
+            String modelNumber,\r
+            String dateOfManufacture,\r
+            String platformVersion,\r
+            String firmwareVersion,\r
+            String supportUrl) {\r
+        this.deviceName = deviceName;\r
+        this.hostName = hostName;\r
+        this.deviceUuid = deviceUuid;\r
+        this.contentType = contentType;\r
+        this.version = version;\r
+        this.manufacturerName = manufacturerName;\r
+        this.manufacturerUrl = manufacturerUrl;\r
+        this.modelNumber = modelNumber;\r
+        this.dateOfManufacture = dateOfManufacture;\r
+        this.platformVersion = platformVersion;\r
+        this.firmwareVersion = firmwareVersion;\r
+        this.supportUrl = supportUrl;\r
+    }\r
+\r
+    public String getDeviceName() {\r
+        return deviceName;\r
+    }\r
+\r
+    public void setDeviceName(String deviceName) {\r
+        this.deviceName = deviceName;\r
+    }\r
+\r
+    public String getHostName() {\r
+        return hostName;\r
+    }\r
+\r
+    public void setHostName(String hostName) {\r
+        this.hostName = hostName;\r
+    }\r
+\r
+    public String getDeviceUuid() {\r
+        return deviceUuid;\r
+    }\r
+\r
+    public void setDeviceUuid(String deviceUuid) {\r
+        this.deviceUuid = deviceUuid;\r
+    }\r
+\r
+    public String getContentType() {\r
+        return contentType;\r
+    }\r
+\r
+    public void setContentType(String contentType) {\r
+        this.contentType = contentType;\r
+    }\r
+\r
+    public String getVersion() {\r
+        return version;\r
+    }\r
+\r
+    public void setVersion(String version) {\r
+        this.version = version;\r
+    }\r
+\r
+    public String getManufacturerName() {\r
+        return manufacturerName;\r
+    }\r
+\r
+    public void setManufacturerName(String manufacturerName) {\r
+        this.manufacturerName = manufacturerName;\r
+    }\r
+\r
+    public String getManufacturerUrl() {\r
+        return manufacturerUrl;\r
+    }\r
+\r
+    public void setManufacturerUrl(String manufacturerUrl) {\r
+        this.manufacturerUrl = manufacturerUrl;\r
+    }\r
+\r
+    public String getModelNumber() {\r
+        return modelNumber;\r
+    }\r
+\r
+    public void setModelNumber(String modelNumber) {\r
+        this.modelNumber = modelNumber;\r
+    }\r
+\r
+    public String getDateOfManufacture() {\r
+        return dateOfManufacture;\r
+    }\r
+\r
+    public void setDateOfManufacture(String dateOfManufacture) {\r
+        this.dateOfManufacture = dateOfManufacture;\r
+    }\r
+\r
+    public String getPlatformVersion() {\r
+        return platformVersion;\r
+    }\r
+\r
+    public void setPlatformVersion(String platformVersion) {\r
+        this.platformVersion = platformVersion;\r
+    }\r
+\r
+    public String getFirmwareVersion() {\r
+        return firmwareVersion;\r
+    }\r
+\r
+    public void setFirmwareVersion(String firmwareVersion) {\r
+        this.firmwareVersion = firmwareVersion;\r
+    }\r
+\r
+    public String getSupportUrl() {\r
+        return supportUrl;\r
+    }\r
+\r
+    public void setSupportUrl(String supportUrl) {\r
+        this.supportUrl = supportUrl;\r
+    }\r
+}\r
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcException.java b/android/android_api/base/src/main/java/org/iotivity/base/OcException.java
new file mode 100755 (executable)
index 0000000..f83bf6c
--- /dev/null
@@ -0,0 +1,58 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base;\r
+\r
+public class OcException extends Exception {\r
+\r
+    private ErrorCode errorCode;\r
+\r
+    public OcException(ErrorCode errorCode, String errMessage) {\r
+        super(errMessage + " " + errorCode.toString());\r
+        this.errorCode = errorCode;\r
+    }\r
+\r
+    private OcException(String error, String errMessage) {\r
+        super(errMessage + " " + error);\r
+        this.errorCode = ErrorCode.get(error);\r
+    }\r
+\r
+    public ErrorCode getErrorCode() {\r
+        return errorCode;\r
+    }\r
+\r
+    private static void addStackTrace(Throwable throwable,\r
+                                      String file,\r
+                                      String functionName,\r
+                                      int line) {\r
+        StackTraceElement[] stack = throwable.getStackTrace();\r
+        StackTraceElement[] newStack = new StackTraceElement[stack.length + 1];\r
+\r
+        System.arraycopy(stack, 0, newStack, 1, stack.length);\r
+        newStack[0] = new StackTraceElement("<native>", functionName, file, line);\r
+        throwable.setStackTrace(newStack);\r
+    }\r
+\r
+    private void setNativeExceptionLocation(String file, String functionName, int line) {\r
+        OcException.addStackTrace(this, file, functionName, line);\r
+    }\r
+}\r
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcHeaderOption.java b/android/android_api/base/src/main/java/org/iotivity/base/OcHeaderOption.java
new file mode 100755 (executable)
index 0000000..984bc27
--- /dev/null
@@ -0,0 +1,70 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base;\r
+\r
+import java.security.InvalidParameterException;\r
+\r
+/**\r
+ * OcHeaderOption class allows to create instances which comprises optionId\r
+ * and optionData as members. These are used in setting Header options.\r
+ * After creating instances of OcHeaderOptions, use setHeaderOptions API\r
+ * (in OcResource) to set header Options.\r
+ * NOTE: optionId  is an integer value which MUST be within\r
+ * range of 2048 to 3000 inclusive of lower and upper bound.\r
+ * HeaderOption instance creation fails if above condition is not satisfied.\r
+ */\r
+public class OcHeaderOption {\r
+\r
+    public static final int MIN_HEADER_OPTION_ID = 2048;\r
+    public static final int MAX_HEADER_OPTION_ID = 3000;\r
+\r
+    private int mOptionId;\r
+    private String mOptionData;\r
+\r
+    public OcHeaderOption(int optionId, String optionData) {\r
+        if (!(optionId >= MIN_HEADER_OPTION_ID && optionId <= MAX_HEADER_OPTION_ID)) {\r
+            throw new InvalidParameterException("Option ID range is invalid");\r
+        }\r
+\r
+        this.mOptionId = optionId;\r
+        this.mOptionData = optionData;\r
+    }\r
+\r
+    /**\r
+     * API to get Option ID\r
+     *\r
+     * @return option ID\r
+     */\r
+    public int getOptionId() {\r
+        return mOptionId;\r
+    }\r
+\r
+    /**\r
+     * API to get Option data\r
+     *\r
+     * @return option data\r
+     */\r
+    public String getOptionData() {\r
+        return mOptionData;\r
+    }\r
+}\r
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcPlatform.java b/android/android_api/base/src/main/java/org/iotivity/base/OcPlatform.java
new file mode 100755 (executable)
index 0000000..fe71268
--- /dev/null
@@ -0,0 +1,777 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base;\r
+\r
+import org.iotivity.ca.CaInterface;\r
+\r
+import java.util.EnumSet;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+\r
+/**\r
+ * Contains the main entrance/functionality of the product. To set a custom configuration, the\r
+ * implementer must make a call to OcPlatform.Configure before the first usage of a function in this\r
+ * class.\r
+ */\r
+public final class OcPlatform {\r
+\r
+    static {\r
+        System.loadLibrary("oc_logger");\r
+        System.loadLibrary("octbstack");\r
+        System.loadLibrary("connectivity_abstraction");\r
+        System.loadLibrary("oc");\r
+        System.loadLibrary("ocstack-jni");\r
+    }\r
+\r
+    /**\r
+     * Default interface\r
+     */\r
+    public static final String DEFAULT_INTERFACE = "oc.mi.def";\r
+\r
+    /**\r
+     * Used in discovering (GET) links to other resources of a collection\r
+     */\r
+    public static final String LINK_INTERFACE = "oc.mi.ll";\r
+\r
+    /**\r
+     * Used in GET, PUT, POST, DELETE methods on links to other resources of a collection\r
+     */\r
+    public static final String BATCH_INTERFACE = "oc.mi.b";\r
+\r
+    /**\r
+     * Used in GET, PUT, POST methods on links to other remote resources of a group\r
+     */\r
+    public static final String GROUP_INTERFACE = "oc.mi.grp";\r
+\r
+    public static final String WELL_KNOWN_QUERY = "224.0.1.187:5683/oc/core";\r
+    public static final String MULTICAST_PREFIX = "224.0.1.187:5683";\r
+    public static final String MULTICAST_IP = "224.0.1.187";\r
+    public static final int MULTICAST_PORT = 5683;\r
+    public static final int DEFAULT_PRESENCE_TTL = 60;\r
+    public static final String PRESENCE_URI = "/oc/presence";\r
+\r
+    private static volatile boolean sIsPlatformInitialized = false;\r
+\r
+    private OcPlatform() {\r
+    }\r
+\r
+    /**\r
+     * API for setting the configuration of the OcPlatform.\r
+     * Note: Any calls made to this AFTER the first call to OcPlatform.Configure will have no affect\r
+     *\r
+     * @param platformConfig platform configuration\r
+     */\r
+    public synchronized static void Configure(PlatformConfig platformConfig) {\r
+        if (!sIsPlatformInitialized) {\r
+            CaInterface.initialize(platformConfig.getContext());\r
+\r
+            OcPlatform.configure(\r
+                    platformConfig.getServiceType().getValue(),\r
+                    platformConfig.getModeType().getValue(),\r
+                    platformConfig.getIpAddress(),\r
+                    platformConfig.getPort(),\r
+                    platformConfig.getQualityOfService().getValue()\r
+            );\r
+\r
+            sIsPlatformInitialized = true;\r
+        }\r
+    }\r
+\r
+    private static native void configure(int serviceType,\r
+                                         int modeType,\r
+                                         String ipAddress,\r
+                                         int port,\r
+                                         int qualityOfService);\r
+\r
+    /**\r
+     * API for notifying base that resource's attributes have changed.\r
+     *\r
+     * @param ocResourceHandle resource handle of the resource\r
+     * @throws OcException\r
+     */\r
+    public static void notifyAllObservers(\r
+            OcResourceHandle ocResourceHandle) throws OcException {\r
+        OcPlatform.initCheck();\r
+        OcPlatform.notifyAllObservers0(ocResourceHandle);\r
+    }\r
+\r
+    private static native void notifyAllObservers0(\r
+            OcResourceHandle ocResourceHandle) throws OcException;\r
+\r
+    /**\r
+     * API for notifying base that resource's attributes have changed.\r
+     *\r
+     * @param ocResourceHandle resource handle of the resource\r
+     * @param qualityOfService the quality of communication\r
+     * @throws OcException\r
+     */\r
+    public static void notifyAllObservers(\r
+            OcResourceHandle ocResourceHandle,\r
+            QualityOfService qualityOfService) throws OcException {\r
+        OcPlatform.initCheck();\r
+        OcPlatform.notifyAllObservers1(ocResourceHandle, qualityOfService.getValue());\r
+    }\r
+\r
+    private static native void notifyAllObservers1(\r
+            OcResourceHandle ocResourceHandle,\r
+            int qualityOfService) throws OcException;\r
+\r
+    /**\r
+     * API for notifying only specific clients that resource's attributes have changed.\r
+     *\r
+     * @param ocResourceHandle    resource handle of the resource\r
+     * @param ocObservationIdList These set of ids are ones which which will be notified upon\r
+     *                            resource change.\r
+     * @param ocResourceResponse  OcResourceResponse object used by app to fill the response for\r
+     *                            this resource change\r
+     * @throws OcException\r
+     */\r
+    public static void notifyListOfObservers(\r
+            OcResourceHandle ocResourceHandle,\r
+            List<Byte> ocObservationIdList,\r
+            OcResourceResponse ocResourceResponse) throws OcException {\r
+        OcPlatform.initCheck();\r
+\r
+        byte[] idArr = new byte[ocObservationIdList.size()];\r
+        Iterator<Byte> it = ocObservationIdList.iterator();\r
+        int i = 0;\r
+        while (it.hasNext()) {\r
+            idArr[i++] = (byte) it.next();\r
+        }\r
+\r
+        OcPlatform.notifyListOfObservers2(\r
+                ocResourceHandle,\r
+                idArr,\r
+                ocResourceResponse);\r
+    }\r
+\r
+    private static native void notifyListOfObservers2(\r
+            OcResourceHandle ocResourceHandle,\r
+            byte[] ocObservationIdArray,\r
+            OcResourceResponse ocResourceResponse) throws OcException;\r
+\r
+    /**\r
+     * API for notifying only specific clients that resource's attributes have changed.\r
+     *\r
+     * @param ocResourceHandle    resource handle of the resource\r
+     * @param ocObservationIdList These set of ids are ones which which will be notified upon\r
+     *                            resource change.\r
+     * @param ocResourceResponse  OcResourceResponse object used by app to fill the response for\r
+     *                            this resource change\r
+     * @param qualityOfService    the quality of communication\r
+     * @throws OcException\r
+     */\r
+    public static void notifyListOfObservers(\r
+            OcResourceHandle ocResourceHandle,\r
+            List<Byte> ocObservationIdList,\r
+            OcResourceResponse ocResourceResponse,\r
+            QualityOfService qualityOfService) throws OcException {\r
+        OcPlatform.initCheck();\r
+\r
+        byte[] idArr = new byte[ocObservationIdList.size()];\r
+        Iterator<Byte> it = ocObservationIdList.iterator();\r
+        int i = 0;\r
+        while (it.hasNext()) {\r
+            idArr[i++] = (byte) it.next();\r
+        }\r
+\r
+        OcPlatform.notifyListOfObservers3(\r
+                ocResourceHandle,\r
+                idArr,\r
+                ocResourceResponse,\r
+                qualityOfService.getValue()\r
+        );\r
+    }\r
+\r
+    private static native void notifyListOfObservers3(\r
+            OcResourceHandle ocResourceHandle,\r
+            byte[] ocObservationIdArray,\r
+            OcResourceResponse ocResourceResponse,\r
+            int qualityOfService) throws OcException;\r
+\r
+    /**\r
+     * API for Service and Resource Discovery. NOTE: This API applies to client side only\r
+     *\r
+     * @param host                    Host IP Address of a service to direct resource discovery query.\r
+     *                                If empty, performs multicast resource discovery query\r
+     * @param resourceUri             name of the resource. If null or empty, performs search for all\r
+     *                                resource names\r
+     * @param connectivityType        a type of connectivity indicating the interface. Example: WIFI,\r
+     *                                ETHERNET, ALL\r
+     * @param onResourceFoundListener Handles events, success states and failure states.\r
+     * @throws OcException\r
+     */\r
+    public static void findResource(\r
+            String host,\r
+            String resourceUri,\r
+            OcConnectivityType connectivityType,\r
+            OnResourceFoundListener onResourceFoundListener) throws OcException {\r
+        OcPlatform.initCheck();\r
+        OcPlatform.findResource0(\r
+                host,\r
+                resourceUri,\r
+                connectivityType.getValue(),\r
+                onResourceFoundListener\r
+        );\r
+    }\r
+\r
+    private static native void findResource0(\r
+            String host,\r
+            String resourceUri,\r
+            int connectivityType,\r
+            OnResourceFoundListener onResourceFoundListener) throws OcException;\r
+\r
+    /**\r
+     * API for Service and Resource Discovery. NOTE: This API applies to client side only\r
+     *\r
+     * @param host                    Host IP Address of a service to direct resource discovery query.\r
+     *                                If empty, performs multicast resource discovery query\r
+     * @param resourceUri             name of the resource. If null or empty, performs search for all\r
+     *                                resource names\r
+     * @param connectivityType        a type of connectivity indicating the interface. Example: WIFI,\r
+     *                                ETHERNET, ALL\r
+     * @param onResourceFoundListener Handles events, success states and failure states.\r
+     * @param qualityOfService        the quality of communication\r
+     * @throws OcException\r
+     */\r
+    public static void findResource(\r
+            String host,\r
+            String resourceUri,\r
+            OcConnectivityType connectivityType,\r
+            OnResourceFoundListener onResourceFoundListener,\r
+            QualityOfService qualityOfService) throws OcException {\r
+        OcPlatform.initCheck();\r
+        OcPlatform.findResource1(host,\r
+                resourceUri,\r
+                connectivityType.getValue(),\r
+                onResourceFoundListener,\r
+                qualityOfService.getValue()\r
+        );\r
+    }\r
+\r
+    private static native void findResource1(\r
+            String host,\r
+            String resourceUri,\r
+            int connectivityType,\r
+            OnResourceFoundListener onResourceFoundListener,\r
+            int qualityOfService) throws OcException;\r
+\r
+    /**\r
+     * API for Device Discovery\r
+     *\r
+     * @param host                  Host IP Address. If null or empty, Multicast is performed.\r
+     * @param deviceUri             Uri containing address to the virtual device\r
+     * @param connectivityType      a type of connectivity indicating the interface. Example: WIFI,\r
+     *                              ETHERNET, ALL\r
+     * @param onDeviceFoundListener Handles events, success states and failure states.\r
+     * @throws OcException\r
+     */\r
+    public static void getDeviceInfo(\r
+            String host,\r
+            String deviceUri,\r
+            OcConnectivityType connectivityType,\r
+            OnDeviceFoundListener onDeviceFoundListener) throws OcException {\r
+        OcPlatform.initCheck();\r
+        OcPlatform.getDeviceInfo0(\r
+                host,\r
+                deviceUri,\r
+                connectivityType.getValue(),\r
+                onDeviceFoundListener\r
+        );\r
+    }\r
+\r
+    private static native void getDeviceInfo0(\r
+            String host,\r
+            String deviceUri,\r
+            int connectivityType,\r
+            OnDeviceFoundListener onDeviceFoundListener) throws OcException;\r
+\r
+    /**\r
+     * API for Device Discovery\r
+     *\r
+     * @param host                  Host IP Address. If null or empty, Multicast is performed.\r
+     * @param deviceUri             Uri containing address to the virtual device\r
+     * @param connectivityType      a type of connectivity indicating the interface. Example: WIFI,\r
+     *                              ETHERNET, ALL\r
+     * @param onDeviceFoundListener Handles events, success states and failure states.\r
+     * @param qualityOfService      the quality of communication\r
+     * @throws OcException\r
+     */\r
+    public static void getDeviceInfo(\r
+            String host,\r
+            String deviceUri,\r
+            OcConnectivityType connectivityType,\r
+            OnDeviceFoundListener onDeviceFoundListener,\r
+            QualityOfService qualityOfService) throws OcException {\r
+        OcPlatform.initCheck();\r
+        OcPlatform.getDeviceInfo1(\r
+                host,\r
+                deviceUri,\r
+                connectivityType.getValue(),\r
+                onDeviceFoundListener,\r
+                qualityOfService.getValue()\r
+        );\r
+    }\r
+\r
+    private static native void getDeviceInfo1(\r
+            String host,\r
+            String deviceUri,\r
+            int connectivityType,\r
+            OnDeviceFoundListener onDeviceFoundListener,\r
+            int qualityOfService) throws OcException;\r
+\r
+    /**\r
+     * This API registers a resource with the server NOTE: This API applies to server side only.\r
+     *\r
+     * @param ocResource The instance of OcResource with all data filled\r
+     * @return resource handle\r
+     * @throws OcException\r
+     */\r
+    public static OcResourceHandle registerResource(\r
+            OcResource ocResource) throws OcException {\r
+        OcPlatform.initCheck();\r
+        return OcPlatform.registerResource0(ocResource);\r
+    }\r
+\r
+    private static native OcResourceHandle registerResource0(\r
+            OcResource ocResource) throws OcException;\r
+\r
+    /**\r
+     * This API registers a resource with the server NOTE: This API applies to server side only.\r
+     *\r
+     * @param resourceUri         The URI of the resource. Example: "a/light"\r
+     * @param resourceTypeName    The resource type. Example: "light"\r
+     * @param resourceInterface   The resource interface (whether it is collection etc).\r
+     * @param entityHandler       entity handler.\r
+     * @param resourcePropertySet indicates the property of the resource\r
+     * @return resource handle\r
+     * @throws OcException\r
+     */\r
+    public static OcResourceHandle registerResource(\r
+            String resourceUri,\r
+            String resourceTypeName,\r
+            String resourceInterface,\r
+            EntityHandler entityHandler,\r
+            EnumSet<ResourceProperty> resourcePropertySet) throws OcException {\r
+        OcPlatform.initCheck();\r
+\r
+        int resProperty = 0;\r
+\r
+        for (ResourceProperty prop : ResourceProperty.values()) {\r
+            if (resourcePropertySet.contains(prop))\r
+                resProperty |= prop.getValue();\r
+        }\r
+\r
+        return OcPlatform.registerResource1(resourceUri,\r
+                resourceTypeName,\r
+                resourceInterface,\r
+                entityHandler,\r
+                resProperty);\r
+    }\r
+\r
+    private static native OcResourceHandle registerResource1(\r
+            String resourceUri,\r
+            String resourceTypeName,\r
+            String resourceInterface,\r
+            EntityHandler entityHandler,\r
+            int resourceProperty) throws OcException;\r
+\r
+    /**\r
+     * Register Device Info\r
+     *\r
+     * @param ocDeviceInfo object containing all the device specific information\r
+     * @throws OcException\r
+     */\r
+    public static void registerDeviceInfo(\r
+            OcDeviceInfo ocDeviceInfo) throws OcException {\r
+        OcPlatform.initCheck();\r
+        OcPlatform.registerDeviceInfo0(\r
+                ocDeviceInfo.getDeviceName(),\r
+                ocDeviceInfo.getHostName(),\r
+                ocDeviceInfo.getDeviceUuid(),\r
+                ocDeviceInfo.getContentType(),\r
+                ocDeviceInfo.getVersion(),\r
+                ocDeviceInfo.getManufacturerName(),\r
+                ocDeviceInfo.getManufacturerUrl(),\r
+                ocDeviceInfo.getModelNumber(),\r
+                ocDeviceInfo.getDateOfManufacture(),\r
+                ocDeviceInfo.getPlatformVersion(),\r
+                ocDeviceInfo.getFirmwareVersion(),\r
+                ocDeviceInfo.getSupportUrl()\r
+        );\r
+    }\r
+\r
+    private static native void registerDeviceInfo0(\r
+            String deviceName,\r
+            String hostName,\r
+            String deviceUUID,\r
+            String contentType,\r
+            String version,\r
+            String manufacturerName,\r
+            String manufacturerUrl,\r
+            String modelNumber,\r
+            String dateOfManufacture,\r
+            String platformVersion,\r
+            String firmwareVersion,\r
+            String supportUrl) throws OcException;\r
+\r
+    /**\r
+     * This API unregisters a resource with the server NOTE: This API applies to server side only.\r
+     *\r
+     * @param ocResourceHandle This is the resource handle which we which to unregister from the\r
+     *                         server\r
+     * @throws OcException\r
+     */\r
+    public static void unregisterResource(\r
+            OcResourceHandle ocResourceHandle) throws OcException {\r
+        OcPlatform.initCheck();\r
+        OcPlatform.unregisterResource0(ocResourceHandle);\r
+    }\r
+\r
+    private static native void unregisterResource0(\r
+            OcResourceHandle ocResourceHandle) throws OcException;\r
+\r
+\r
+    /**\r
+     * Add a resource to a collection resource\r
+     *\r
+     * @param ocResourceCollectionHandle handle to the collection resource\r
+     * @param ocResourceHandle           handle to resource to be added to the collection resource\r
+     * @throws OcException\r
+     */\r
+    public static void bindResource(\r
+            OcResourceHandle ocResourceCollectionHandle,\r
+            OcResourceHandle ocResourceHandle) throws OcException {\r
+        OcPlatform.initCheck();\r
+        OcPlatform.bindResource0(ocResourceCollectionHandle, ocResourceHandle);\r
+    }\r
+\r
+    private static native void bindResource0(\r
+            OcResourceHandle ocResourceCollectionHandle,\r
+            OcResourceHandle ocResourceHandle) throws OcException;\r
+\r
+    /**\r
+     * Add multiple resources to a collection resource.\r
+     *\r
+     * @param ocResourceCollectionHandle handle to the collection resource\r
+     * @param ocResourceHandleList       reference to list of resource handles to be added to the\r
+     *                                   collection resource\r
+     * @throws OcException\r
+     */\r
+    public static void bindResources(\r
+            OcResourceHandle ocResourceCollectionHandle,\r
+            List<OcResourceHandle> ocResourceHandleList) throws OcException {\r
+        OcPlatform.initCheck();\r
+        OcPlatform.bindResources0(\r
+                ocResourceCollectionHandle,\r
+                ocResourceHandleList.toArray(\r
+                        new OcResourceHandle[ocResourceHandleList.size()])\r
+        );\r
+    }\r
+\r
+    private static native void bindResources0(\r
+            OcResourceHandle ocResourceCollectionHandle,\r
+            OcResourceHandle[] ocResourceHandleArray) throws OcException;\r
+\r
+    /**\r
+     * Unbind a resource from a collection resource.\r
+     *\r
+     * @param ocResourceCollectionHandle handle to the collection resource\r
+     * @param ocResourceHandle           resource handle to be unbound from the collection resource\r
+     * @throws OcException\r
+     */\r
+    public static void unbindResource(\r
+            OcResourceHandle ocResourceCollectionHandle,\r
+            OcResourceHandle ocResourceHandle) throws OcException {\r
+        OcPlatform.initCheck();\r
+        OcPlatform.unbindResource0(ocResourceCollectionHandle, ocResourceHandle);\r
+    }\r
+\r
+    private static native void unbindResource0(\r
+            OcResourceHandle ocResourceCollectionHandle,\r
+            OcResourceHandle ocResourceHandle) throws OcException;\r
+\r
+    /**\r
+     * Unbind resources from a collection resource.\r
+     *\r
+     * @param ocResourceCollectionHandle Handle to the collection resource\r
+     * @param ocResourceHandleList       List of resource handles to be unbound from the collection\r
+     *                                   resource\r
+     * @throws OcException\r
+     */\r
+    public static void unbindResources(\r
+            OcResourceHandle ocResourceCollectionHandle,\r
+            List<OcResourceHandle> ocResourceHandleList) throws OcException {\r
+        OcPlatform.initCheck();\r
+        OcPlatform.unbindResources0(\r
+                ocResourceCollectionHandle,\r
+                ocResourceHandleList.toArray(\r
+                        new OcResourceHandle[ocResourceHandleList.size()])\r
+        );\r
+    }\r
+\r
+    private static native void unbindResources0(\r
+            OcResourceHandle ocResourceCollectionHandle,\r
+            OcResourceHandle[] ocResourceHandleArray) throws OcException;\r
+\r
+    /**\r
+     * Binds a type to a particular resource\r
+     *\r
+     * @param ocResourceHandle handle to the resource\r
+     * @param resourceTypeName new typename to bind to the resource\r
+     * @throws OcException\r
+     */\r
+    public static void bindTypeToResource(\r
+            OcResourceHandle ocResourceHandle,\r
+            String resourceTypeName) throws OcException {\r
+        OcPlatform.initCheck();\r
+        OcPlatform.bindTypeToResource0(ocResourceHandle, resourceTypeName);\r
+    }\r
+\r
+    private static native void bindTypeToResource0(\r
+            OcResourceHandle ocResourceHandle,\r
+            String resourceTypeName) throws OcException;\r
+\r
+    /**\r
+     * Binds an interface to a particular resource\r
+     *\r
+     * @param ocResourceHandle      handle to the resource\r
+     * @param resourceInterfaceName new interface to bind to the resource\r
+     * @throws OcException\r
+     */\r
+    public static void bindInterfaceToResource(\r
+            OcResourceHandle ocResourceHandle,\r
+            String resourceInterfaceName) throws OcException {\r
+        OcPlatform.initCheck();\r
+        OcPlatform.bindInterfaceToResource0(ocResourceHandle, resourceInterfaceName);\r
+    }\r
+\r
+    private static native void bindInterfaceToResource0(\r
+            OcResourceHandle ocResourceHandle,\r
+            String resourceInterfaceName) throws OcException;\r
+\r
+    /**\r
+     * Start Presence announcements.\r
+     *\r
+     * @param ttl time to live in seconds\r
+     * @throws OcException\r
+     */\r
+    public static void startPresence(int ttl) throws OcException {\r
+        OcPlatform.initCheck();\r
+        OcPlatform.startPresence0(ttl);\r
+    }\r
+\r
+    private static native void startPresence0(int ttl) throws OcException;\r
+\r
+    /**\r
+     * Stop Presence announcements.\r
+     *\r
+     * @throws OcException\r
+     */\r
+    public static void stopPresence() throws OcException {\r
+        OcPlatform.initCheck();\r
+        OcPlatform.stopPresence0();\r
+    }\r
+\r
+    private static native void stopPresence0() throws OcException;\r
+\r
+    /**\r
+     * Subscribes to a server's presence change events. By making this subscription, every time a\r
+     * server adds/removes/alters a resource, starts or is intentionally stopped\r
+     *\r
+     * @param host               The IP address/addressable name of the server to subscribe to\r
+     * @param connectivityType   a type of connectivity indicating the interface. Example: WIFI,\r
+     *                           ETHERNET, ALL\r
+     * @param onPresenceListener listener that will receive notifications/subscription events\r
+     * @return a handle object that can be used to identify this subscription request. It can be\r
+     * used to unsubscribe from these events in the future\r
+     * @throws OcException\r
+     */\r
+    public static OcPresenceHandle subscribePresence(\r
+            String host,\r
+            OcConnectivityType connectivityType,\r
+            OnPresenceListener onPresenceListener) throws OcException {\r
+        OcPlatform.initCheck();\r
+        return OcPlatform.subscribePresence0(\r
+                host,\r
+                connectivityType.getValue(),\r
+                onPresenceListener\r
+        );\r
+    }\r
+\r
+    private static native OcPresenceHandle subscribePresence0(\r
+            String host,\r
+            int connectivityType,\r
+            OnPresenceListener onPresenceListener) throws OcException;\r
+\r
+    /**\r
+     * Subscribes to a server's presence change events. By making this subscription, every time a\r
+     * server adds/removes/alters a resource, starts or is intentionally stopped\r
+     *\r
+     * @param host               The IP address/addressable name of the server to subscribe to\r
+     * @param resourceType       a resource type specified as a filter for subscription events.\r
+     * @param connectivityType   a type of connectivity indicating the interface. Example: WIFI,\r
+     *                           ETHERNET, ALL\r
+     * @param onPresenceListener listener that will receive notifications/subscription events\r
+     * @return a handle object that can be used to identify this subscription request. It can be\r
+     * used to unsubscribe from these events in the future\r
+     * @throws OcException\r
+     */\r
+    public static OcPresenceHandle subscribePresence(\r
+            String host,\r
+            String resourceType,\r
+            OcConnectivityType connectivityType,\r
+            OnPresenceListener onPresenceListener) throws OcException {\r
+        OcPlatform.initCheck();\r
+        return OcPlatform.subscribePresence1(\r
+                host,\r
+                resourceType,\r
+                connectivityType.getValue(),\r
+                onPresenceListener);\r
+    }\r
+\r
+    private static native OcPresenceHandle subscribePresence1(\r
+            String host,\r
+            String resourceType,\r
+            int connectivityType,\r
+            OnPresenceListener onPresenceListener) throws OcException;\r
+\r
+    /**\r
+     * Unsubscribes from a previously subscribed server's presence events. Note that you may for\r
+     * a short time still receive events from the server since it may take time for the\r
+     * unsubscribe to take effect.\r
+     *\r
+     * @param ocPresenceHandle the handle object provided by the subscribePresence call that\r
+     *                         identifies this subscription\r
+     * @throws OcException\r
+     */\r
+    public static void unsubscribePresence(\r
+            OcPresenceHandle ocPresenceHandle) throws OcException {\r
+        OcPlatform.initCheck();\r
+        OcPlatform.unsubscribePresence0(ocPresenceHandle);\r
+    }\r
+\r
+    private static native void unsubscribePresence0(\r
+            OcPresenceHandle ocPresenceHandle) throws OcException;\r
+\r
+    /**\r
+     * Creates a resource proxy object so that get/put/observe functionality can be used without\r
+     * discovering the object in advance. Note that the consumer of this method needs to provide\r
+     * all of the details required to correctly contact and observe the object. If the consumer\r
+     * lacks any of this information, they should discover the resource object normally.\r
+     * Additionally, you can only create this object if OcPlatform was initialized to be a Client\r
+     * or Client/Server.\r
+     *\r
+     * @param host             a string containing a resolvable host address of the server holding\r
+     *                         the resource\r
+     * @param uri              the rest of the resource's URI that will permit messages to be\r
+     *                         properly routed.\r
+     *                         Example: /a/light\r
+     * @param connectivityType a type of connectivity indicating the interface. Example: WIFI,\r
+     *                         ETHERNET, ALL\r
+     * @param isObservable     a boolean containing whether the resource supports observation\r
+     * @param resourceTypeList a collection of resource types implemented by the resource\r
+     * @param interfaceList    a collection of interfaces that the resource supports/implements\r
+     * @return new resource object\r
+     * @throws OcException\r
+     */\r
+    public static OcResource constructResourceObject(\r
+            String host,\r
+            String uri,\r
+            OcConnectivityType connectivityType,\r
+            boolean isObservable,\r
+            List<String> resourceTypeList,\r
+            List<String> interfaceList) throws OcException {\r
+        OcPlatform.initCheck();\r
+        return OcPlatform.constructResourceObject0(\r
+                host,\r
+                uri,\r
+                connectivityType.getValue(),\r
+                isObservable,\r
+                resourceTypeList.toArray(new String[resourceTypeList.size()]),\r
+                interfaceList.toArray(new String[interfaceList.size()])\r
+        );\r
+    }\r
+\r
+    private static native OcResource constructResourceObject0(\r
+            String host,\r
+            String uri,\r
+            int connectivityType,\r
+            boolean isObservable,\r
+            String[] resourceTypes,\r
+            String[] interfaces) throws OcException;\r
+\r
+    /**\r
+     * Allows application entity handler to send response to an incoming request.\r
+     *\r
+     * @param ocResourceResponse resource response\r
+     * @throws OcException\r
+     */\r
+    public static void sendResponse(OcResourceResponse ocResourceResponse)\r
+            throws OcException {\r
+        OcPlatform.initCheck();\r
+        OcPlatform.sendResponse0(ocResourceResponse);\r
+    }\r
+\r
+    private static native void sendResponse0(OcResourceResponse ocResourceResponse)\r
+            throws OcException;\r
+\r
+    /**\r
+     * An OnResourceFoundListener can be registered via the OcPlatform.findResource call.\r
+     * Event listeners are notified asynchronously\r
+     */\r
+    public interface OnResourceFoundListener {\r
+        public void onResourceFound(OcResource resource);\r
+    }\r
+\r
+    /**\r
+     * An OnDeviceFoundListener can be registered via the OcPlatform.getDeviceInfo call.\r
+     * Event listeners are notified asynchronously\r
+     */\r
+    public interface OnDeviceFoundListener {\r
+        public void onDeviceFound(OcRepresentation ocRepresentation);\r
+    }\r
+\r
+    /**\r
+     * An OnPresenceListener can be registered via the OcPlatform.subscribePresence call.\r
+     * Event listeners are notified asynchronously\r
+     */\r
+    public interface OnPresenceListener {\r
+        public void onPresence(OcPresenceStatus ocPresenceStatus, int nonce, String hostAddress);\r
+    }\r
+\r
+    /**\r
+     * An EntityHandler can be registered via the OcPlatform.registerResource call.\r
+     * Event listeners are notified asynchronously\r
+     */\r
+    public interface EntityHandler {\r
+        public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest);\r
+    }\r
+\r
+    private static void initCheck() {\r
+        if (!sIsPlatformInitialized) {\r
+            throw new IllegalStateException("OcPlatform must be configured by making a call to " +\r
+                    "OcPlatform.Configure before any other API calls are permitted");\r
+        }\r
+    }\r
+}
\ No newline at end of file
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcPlatformStatus.java b/android/android_api/base/src/main/java/org/iotivity/base/OcPlatformStatus.java
new file mode 100755 (executable)
index 0000000..4ef76da
--- /dev/null
@@ -0,0 +1,39 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base;\r
+\r
+\r
+public enum OcPlatformStatus {\r
+    UP(0),\r
+    DOWN(1),;\r
+\r
+    private int value;\r
+\r
+    private OcPlatformStatus(int value) {\r
+        this.value = value;\r
+    }\r
+\r
+    public int getValue() {\r
+        return this.value;\r
+    }\r
+}\r
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcPresenceHandle.java b/android/android_api/base/src/main/java/org/iotivity/base/OcPresenceHandle.java
new file mode 100755 (executable)
index 0000000..184be8f
--- /dev/null
@@ -0,0 +1,41 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base;\r
+\r
+public class OcPresenceHandle {\r
+\r
+    private OcPresenceHandle(long nativeHandle) {\r
+        this.mNativeHandle = nativeHandle;\r
+    }\r
+\r
+    @Override\r
+    protected void finalize() throws Throwable {\r
+        super.finalize();\r
+\r
+        dispose();\r
+    }\r
+\r
+    private native void dispose();\r
+\r
+    private long mNativeHandle;\r
+}\r
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcPresenceStatus.java b/android/android_api/base/src/main/java/org/iotivity/base/OcPresenceStatus.java
new file mode 100755 (executable)
index 0000000..ff2c7dc
--- /dev/null
@@ -0,0 +1,50 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base;\r
+\r
+import java.security.InvalidParameterException;\r
+\r
+public enum OcPresenceStatus {\r
+    OK("OK"),\r
+    STOPPED("PRESENCE_STOPPED"),\r
+    TIMEOUT("PRESENCE_TIMEOUT"),\r
+    DO_NOT_HANDLE("PRESENCE_DO_NOT_HANDLE");\r
+\r
+    private String value;\r
+\r
+    private OcPresenceStatus(String value) {\r
+        this.value = value;\r
+    }\r
+\r
+    public static OcPresenceStatus get(String val) {\r
+        for (OcPresenceStatus v : OcPresenceStatus.values()) {\r
+            if (v.getValue().equals(val))\r
+                return v;\r
+        }\r
+        throw new InvalidParameterException("Unexpected OcPresenceStatus value");\r
+    }\r
+\r
+    public String getValue() {\r
+        return this.value;\r
+    }\r
+}\r
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcRepresentation.java b/android/android_api/base/src/main/java/org/iotivity/base/OcRepresentation.java
new file mode 100755 (executable)
index 0000000..98ec0bc
--- /dev/null
@@ -0,0 +1,358 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base;\r
+\r
+import java.security.InvalidParameterException;\r
+import java.util.Arrays;\r
+import java.util.List;\r
+\r
+/**\r
+ *\r
+ */\r
+public class OcRepresentation {\r
+\r
+    static {\r
+        System.loadLibrary("oc");\r
+        System.loadLibrary("ocstack-jni");\r
+    }\r
+\r
+    public OcRepresentation() {\r
+        create();\r
+        //Native OCRepresentation object was created using "new" and needs to be deleted\r
+        this.mNativeNeedsDelete = true;\r
+    }\r
+\r
+    private OcRepresentation(long nativeHandle) {\r
+        this.mNativeHandle = nativeHandle;\r
+        this.mNativeNeedsDelete = false;\r
+    }\r
+\r
+    private OcRepresentation(long nativeHandle, boolean nativeNeedsDelete) {\r
+        this.mNativeHandle = nativeHandle;\r
+        this.mNativeNeedsDelete = nativeNeedsDelete;\r
+    }\r
+\r
+    public <T> T getValue(String key) throws OcException {\r
+        Object obj = this.getValueN(key);\r
+        @SuppressWarnings("unchecked")\r
+        T t = (T) obj;\r
+        return t;\r
+    }\r
+\r
+    private native Object getValueN(String key);\r
+\r
+    public void setValue(String key, int value) throws OcException {\r
+        this.setValueInteger(key, value);\r
+    }\r
+\r
+    public void setValue(String key, double value) throws OcException {\r
+        this.setValueDouble(key, value);\r
+    }\r
+\r
+    public void setValue(String key, boolean value) throws OcException {\r
+        this.setValueBoolean(key, value);\r
+    }\r
+\r
+    public void setValue(String key, String value) throws OcException {\r
+        this.setValueStringN(key, value);\r
+    }\r
+\r
+    public void setValue(String key, OcRepresentation value) throws OcException {\r
+        this.setValueRepresentation(key, value);\r
+    }\r
+\r
+    public void setValue(String key, int[] value) throws OcException {\r
+        this.setValueIntegerArray(key, value);\r
+    }\r
+\r
+    public void setValue(String key, int[][] value) throws OcException {\r
+        this.setValueInteger2DArray(key, value);\r
+    }\r
+\r
+    public void setValue(String key, int[][][] value) throws OcException {\r
+        this.setValueInteger3DArray(key, value);\r
+    }\r
+\r
+    public void setValue(String key, double[] value) throws OcException {\r
+        this.setValueDoubleArray(key, value);\r
+    }\r
+\r
+    public void setValue(String key, double[][] value) throws OcException {\r
+        this.setValueDouble2DArray(key, value);\r
+    }\r
+\r
+    public void setValue(String key, double[][][] value) throws OcException {\r
+        this.setValueDouble3DArray(key, value);\r
+    }\r
+\r
+    public void setValue(String key, boolean[] value) throws OcException {\r
+        this.setValueBooleanArray(key, value);\r
+    }\r
+\r
+    public void setValue(String key, boolean[][] value) throws OcException {\r
+        this.setValueBoolean2DArray(key, value);\r
+    }\r
+\r
+    public void setValue(String key, boolean[][][] value) throws OcException {\r
+        this.setValueBoolean3DArray(key, value);\r
+    }\r
+\r
+    public void setValue(String key, String[] value) throws OcException {\r
+        this.setValueStringArray(key, value);\r
+    }\r
+\r
+    public void setValue(String key, String[][] value) throws OcException {\r
+        this.setValueString2DArray(key, value);\r
+    }\r
+\r
+    public void setValue(String key, String[][][] value) throws OcException {\r
+        this.setValueString3DArray(key, value);\r
+    }\r
+\r
+    public void setValue(String key, OcRepresentation[] value) throws OcException {\r
+        this.setValueRepresentationArray(key, value);\r
+    }\r
+\r
+    public void setValue(String key, OcRepresentation[][] value) throws OcException {\r
+        this.setValueRepresentation2DArray(key, value);\r
+    }\r
+\r
+    public void setValue(String key, OcRepresentation[][][] value) throws OcException {\r
+        this.setValueRepresentation3DArray(key, value);\r
+    }\r
+\r
+    private native void setValueInteger(String key, int value) throws OcException;\r
+\r
+    private native void setValueDouble(String key, double value) throws OcException;\r
+\r
+    private native void setValueBoolean(String key, boolean value) throws OcException;\r
+\r
+    private native void setValueStringN(String key, String value) throws OcException;\r
+\r
+    private native void setValueRepresentation(String key, OcRepresentation value) throws OcException;\r
+\r
+    private native void setValueIntegerArray(String key, int[] value) throws OcException;\r
+\r
+    private native void setValueInteger2DArray(String key, int[][] value) throws OcException;\r
+\r
+    private native void setValueInteger3DArray(String key, int[][][] value) throws OcException;\r
+\r
+    private native void setValueDoubleArray(String key, double[] value) throws OcException;\r
+\r
+    private native void setValueDouble2DArray(String key, double[][] value) throws OcException;\r
+\r
+    private native void setValueDouble3DArray(String key, double[][][] value) throws OcException;\r
+\r
+    private native void setValueBooleanArray(String key, boolean[] value) throws OcException;\r
+\r
+    private native void setValueBoolean2DArray(String key, boolean[][] value) throws OcException;\r
+\r
+    private native void setValueBoolean3DArray(String key, boolean[][][] value) throws OcException;\r
+\r
+    private native void setValueStringArray(String key, String[] value) throws OcException;\r
+\r
+    private native void setValueString2DArray(String key, String[][] value) throws OcException;\r
+\r
+    private native void setValueString3DArray(String key, String[][][] value) throws OcException;\r
+\r
+    private native void setValueRepresentationArray(String key, OcRepresentation[] value) throws OcException;\r
+\r
+    private native void setValueRepresentation2DArray(String key, OcRepresentation[][] value) throws OcException;\r
+\r
+    private native void setValueRepresentation3DArray(String key, OcRepresentation[][][] value) throws OcException;\r
+\r
+    /**\r
+     * @deprecated use {@link #getValue(String key)} instead.\r
+     */\r
+    @Deprecated\r
+    public int getValueInt(String key) {\r
+        int value = 0;\r
+        try {\r
+            value = this.getValue(key);\r
+        } catch (OcException e) {\r
+            //simply catching here for the deprecated APIs, so the older usages don't have to handle\r
+            //it in the code\r
+        }\r
+        return value;\r
+    }\r
+\r
+    /**\r
+     * @deprecated use {@link #getValue(String key)} instead.\r
+     */\r
+    @Deprecated\r
+    public boolean getValueBool(String key) {\r
+        boolean value = false;\r
+        try {\r
+            value = this.getValue(key);\r
+        } catch (OcException e) {\r
+            //simply catching here for the deprecated APIs, so the older usages don't have to handle\r
+            //it in the code\r
+        }\r
+        return value;\r
+    }\r
+\r
+    /**\r
+     * @deprecated use {@link #getValue(String key)} instead.\r
+     */\r
+    @Deprecated\r
+    public String getValueString(String key) {\r
+        String value = "";\r
+        try {\r
+            value = this.getValue(key);\r
+        } catch (OcException e) {\r
+            //simply catching here for the deprecated APIs, so the older usages don't have to handle\r
+            //it in the code\r
+        }\r
+        return value;\r
+    }\r
+\r
+    /**\r
+     * @deprecated use {@link #setValue(String key, int value)} instead.\r
+     */\r
+    @Deprecated\r
+    public void setValueInt(String key, int value) {\r
+        try {\r
+            this.setValue(key, value);\r
+        } catch (OcException e) {\r
+            //simply catching here for the deprecated APIs, so the older usages don't have to handle\r
+            //it in the code\r
+        }\r
+    }\r
+\r
+    /**\r
+     * @deprecated use {@link #setValue(String key, boolean value)} instead.\r
+     */\r
+    @Deprecated\r
+    public void setValueBool(String key, boolean value) {\r
+        try {\r
+            this.setValue(key, value);\r
+        } catch (OcException e) {\r
+            //simply catching here for the deprecated APIs, so the older usages don't have to handle\r
+            //it in the code\r
+        }\r
+    }\r
+\r
+    /**\r
+     * @deprecated use {@link #setValue(String key, String value)} instead.\r
+     */\r
+    @Deprecated\r
+    public void setValueString(String key, String value) {\r
+        try {\r
+            this.setValue(key, value);\r
+        } catch (OcException e) {\r
+            //simply catching here for the deprecated APIs, so the older usages don't have to handle\r
+            //it in the code\r
+        }\r
+    }\r
+\r
+    public native String getJSONRepresentation();\r
+\r
+    public native void addChild(OcRepresentation representation);\r
+\r
+    public native void clearChildren();\r
+\r
+    public List<OcRepresentation> getChildren() {\r
+        return Arrays.asList(\r
+                getChildrenArray());\r
+    }\r
+\r
+    private native OcRepresentation[] getChildrenArray();\r
+\r
+    public native String getUri();\r
+\r
+    public native void setUri(String uri);\r
+\r
+    /**\r
+     * Method to get the list of resource types\r
+     *\r
+     * @return List of resource types\r
+     */\r
+    public native List<String> getResourceTypes();\r
+\r
+    /**\r
+     * Method to set the list of resource types\r
+     *\r
+     * @param resourceTypeList list of resources\r
+     */\r
+    public void setResourceTypes(List<String> resourceTypeList) {\r
+        if (null == resourceTypeList) {\r
+            throw new InvalidParameterException("resourceTypeList cannot be null");\r
+        }\r
+\r
+        this.setResourceTypeArray(\r
+                resourceTypeList.toArray(\r
+                        new String[resourceTypeList.size()]));\r
+    }\r
+\r
+    private native void setResourceTypeArray(String[] resourceTypeArray);\r
+\r
+    /**\r
+     * Method to get the list of resource interfaces\r
+     *\r
+     * @return List of resource interface\r
+     */\r
+    public native List<String> getResourceInterfaces();\r
+\r
+    /**\r
+     * Method to set the list of resource interfaces\r
+     *\r
+     * @param resourceInterfaceList list of interfaces\r
+     */\r
+    public void setResourceInterfaces(List<String> resourceInterfaceList) {\r
+        if (null == resourceInterfaceList) {\r
+            throw new InvalidParameterException("resourceInterfaceList cannot be null");\r
+        }\r
+\r
+        this.setResourceInterfaceArray(\r
+                resourceInterfaceList.toArray(\r
+                        new String[resourceInterfaceList.size()]));\r
+    }\r
+\r
+    private native void setResourceInterfaceArray(String[] resourceInterfaceArray);\r
+\r
+    public native boolean isEmpty();\r
+\r
+    public native int size();\r
+\r
+    public native boolean remove(String key);\r
+\r
+    public native boolean hasAttribute(String key);\r
+\r
+    public native void setNull(String key);\r
+\r
+    public native boolean isNull(String key);\r
+\r
+    @Override\r
+    protected void finalize() throws Throwable {\r
+        super.finalize();\r
+\r
+        dispose(this.mNativeNeedsDelete);\r
+    }\r
+\r
+    private native void create();\r
+\r
+    private native void dispose(boolean needsDelete);\r
+\r
+    private long mNativeHandle;\r
+    private boolean mNativeNeedsDelete;\r
+}
\ No newline at end of file
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcRequestHandle.java b/android/android_api/base/src/main/java/org/iotivity/base/OcRequestHandle.java
new file mode 100755 (executable)
index 0000000..73cd14b
--- /dev/null
@@ -0,0 +1,41 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base;\r
+\r
+public class OcRequestHandle {\r
+\r
+    private OcRequestHandle(long nativeHandle) {\r
+        this.mNativeHandle = nativeHandle;\r
+    }\r
+\r
+    @Override\r
+    protected void finalize() throws Throwable {\r
+        super.finalize();\r
+\r
+        dispose();\r
+    }\r
+\r
+    private native void dispose();\r
+\r
+    private long mNativeHandle;\r
+}\r
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcResource.java b/android/android_api/base/src/main/java/org/iotivity/base/OcResource.java
new file mode 100755 (executable)
index 0000000..b3f4b08
--- /dev/null
@@ -0,0 +1,575 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base;\r
+\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+/**\r
+ * OcResource represents an OC resource. A resource could be a light controller, temperature sensor,\r
+ * smoke detector, etc. A resource comes with a well-defined contract or interface onto which you\r
+ * can perform different operations, such as turning on the light, getting the current temperature\r
+ * or subscribing for event notifications from the smoke detector. A resource can be composed of\r
+ * one or more resources.\r
+ */\r
+public class OcResource {\r
+\r
+    private OcResource(long nativeHandle) {\r
+        this.mNativeHandle = nativeHandle;\r
+    }\r
+\r
+    /**\r
+     * Method to get the attributes of a resource.\r
+     *\r
+     * @param queryParamsMap map which can have the query parameter name and value\r
+     * @param onGetListener  The event handler will be invoked with a map of attribute name and\r
+     *                       values. The event handler will also have the result from this Get\r
+     *                       operation This will have error codes\r
+     * @throws OcException\r
+     */\r
+    public native void get(Map<String, String> queryParamsMap,\r
+                           OnGetListener onGetListener) throws OcException;\r
+\r
+    /**\r
+     * Method to get the attributes of a resource.\r
+     *\r
+     * @param queryParamsMap   map which can have the query parameter name and value\r
+     * @param onGetListener    The event handler will be invoked with a map of attribute name and\r
+     *                         values. The event handler will also have the result from this Get\r
+     *                         operation This will have error codes\r
+     * @param qualityOfService the quality of communication\r
+     * @throws OcException\r
+     */\r
+    public void get(Map<String, String> queryParamsMap,\r
+                    OnGetListener onGetListener,\r
+                    QualityOfService qualityOfService) throws OcException {\r
+        this.get1(queryParamsMap, onGetListener, qualityOfService.getValue());\r
+    }\r
+\r
+    private native void get1(Map<String, String> queryParamsMap,\r
+                             OnGetListener onGetListener,\r
+                             int qualityOfService) throws OcException;\r
+\r
+    /**\r
+     * Method to get the attributes of a resource.\r
+     *\r
+     * @param resourceType      resourceType of the resource to operate on\r
+     * @param resourceInterface interface type of the resource to operate on\r
+     * @param queryParamsMap    map which can have the query parameter name and value\r
+     * @param onGetListener     The event handler will be invoked with a map of attribute name and\r
+     *                          values. The event handler will also have the result from this Get\r
+     *                          operation This will have error codes\r
+     * @throws OcException\r
+     */\r
+    public void get(String resourceType,\r
+                    String resourceInterface,\r
+                    Map<String, String> queryParamsMap,\r
+                    OnGetListener onGetListener) throws OcException {\r
+        this.get2(\r
+                resourceType,\r
+                resourceInterface,\r
+                queryParamsMap,\r
+                onGetListener);\r
+    }\r
+\r
+    private native void get2(String resourceType,\r
+                             String resourceInterface,\r
+                             Map<String, String> queryParamsMap,\r
+                             OnGetListener onGetListener) throws OcException;\r
+\r
+    /**\r
+     * Method to get the attributes of a resource.\r
+     *\r
+     * @param resourceType      resourceType of the resource to operate on\r
+     * @param resourceInterface interface type of the resource to operate on\r
+     * @param queryParamsMap    map which can have the query parameter name and value\r
+     * @param onGetListener     The event handler will be invoked with a map of attribute name and\r
+     *                          values. The event handler will also have the result from this Get\r
+     *                          operation This will have error codes\r
+     * @param qualityOfService  the quality of communication\r
+     * @throws OcException\r
+     */\r
+    public void get(String resourceType,\r
+                    String resourceInterface,\r
+                    Map<String, String> queryParamsMap,\r
+                    OnGetListener onGetListener,\r
+                    QualityOfService qualityOfService) throws OcException {\r
+        this.get3(\r
+                resourceType,\r
+                resourceInterface,\r
+                queryParamsMap,\r
+                onGetListener,\r
+                qualityOfService.getValue());\r
+    }\r
+\r
+    private native void get3(String resourceType,\r
+                             String resourceInterface,\r
+                             Map<String, String> queryParamsMap,\r
+                             OnGetListener onGetListener,\r
+                             int qualityOfService) throws OcException;\r
+\r
+    /**\r
+     * Method to set the representation of a resource (via PUT)\r
+     *\r
+     * @param representation representation of the resource\r
+     * @param queryParamsMap Map which can have the query parameter name and value\r
+     * @param onPutListener  event handler The event handler will be invoked with a map of attribute\r
+     *                       name and values.\r
+     * @throws OcException\r
+     */\r
+    public native void put(OcRepresentation representation,\r
+                           Map<String, String> queryParamsMap,\r
+                           OnPutListener onPutListener) throws OcException;\r
+\r
+    /**\r
+     * Method to set the representation of a resource (via PUT)\r
+     *\r
+     * @param ocRepresentation representation of the resource\r
+     * @param queryParamsMap   Map which can have the query parameter name and value\r
+     * @param onPutListener    event handler The event handler will be invoked with a map of\r
+     *                         attribute name and values.\r
+     * @param qualityOfService the quality of communication\r
+     * @throws OcException\r
+     */\r
+    public void put(OcRepresentation ocRepresentation,\r
+                    Map<String, String> queryParamsMap,\r
+                    OnPutListener onPutListener,\r
+                    QualityOfService qualityOfService) throws OcException {\r
+        this.put1(\r
+                ocRepresentation,\r
+                queryParamsMap,\r
+                onPutListener,\r
+                qualityOfService.getValue());\r
+    }\r
+\r
+    private native void put1(OcRepresentation ocRepresentation,\r
+                             Map<String, String> queryParamsMap,\r
+                             OnPutListener onPutListener,\r
+                             int qualityOfService) throws OcException;\r
+\r
+    /**\r
+     * Method to set the representation of a resource (via PUT)\r
+     *\r
+     * @param resourceType      resource type of the resource to operate on\r
+     * @param resourceInterface interface type of the resource to operate on\r
+     * @param ocRepresentation  representation of the resource\r
+     * @param queryParamsMap    Map which can have the query parameter name and value\r
+     * @param onPutListener     event handler The event handler will be invoked with a map of\r
+     *                          attribute name and values.\r
+     * @throws OcException\r
+     */\r
+    public void put(String resourceType,\r
+                    String resourceInterface,\r
+                    OcRepresentation ocRepresentation,\r
+                    Map<String, String> queryParamsMap,\r
+                    OnPutListener onPutListener) throws OcException {\r
+        this.put2(\r
+                resourceType,\r
+                resourceInterface,\r
+                ocRepresentation,\r
+                queryParamsMap,\r
+                onPutListener);\r
+    }\r
+\r
+    private native void put2(String resourceType,\r
+                             String resourceInterface,\r
+                             OcRepresentation ocRepresentation,\r
+                             Map<String, String> queryParamsMap,\r
+                             OnPutListener onPutListener) throws OcException;\r
+\r
+    /**\r
+     * Method to set the representation of a resource (via PUT)\r
+     *\r
+     * @param resourceType      resource type of the resource to operate on\r
+     * @param resourceInterface interface type of the resource to operate on\r
+     * @param ocRepresentation  representation of the resource\r
+     * @param queryParamsMap    Map which can have the query parameter name and value\r
+     * @param onPutListener     event handler The event handler will be invoked with a map of\r
+     *                          attribute name and values.\r
+     * @param qualityOfService  the quality of communication\r
+     * @throws OcException\r
+     */\r
+    public void put(String resourceType,\r
+                    String resourceInterface,\r
+                    OcRepresentation ocRepresentation,\r
+                    Map<String, String> queryParamsMap,\r
+                    OnPutListener onPutListener,\r
+                    QualityOfService qualityOfService) throws OcException {\r
+        this.put3(\r
+                resourceType,\r
+                resourceInterface,\r
+                ocRepresentation,\r
+                queryParamsMap,\r
+                onPutListener,\r
+                qualityOfService.getValue());\r
+    }\r
+\r
+    private native void put3(String resourceType,\r
+                             String resourceInterface,\r
+                             OcRepresentation ocRepresentation,\r
+                             Map<String, String> queryParamsMap,\r
+                             OnPutListener onPutListener,\r
+                             int qualityOfService) throws OcException;\r
+\r
+    /**\r
+     * Method to POST on a resource\r
+     *\r
+     * @param ocRepresentation representation of the resource\r
+     * @param queryParamsMap   Map which can have the query parameter name and value\r
+     * @param onPostListener   event handler The event handler will be invoked with a map of\r
+     *                         attribute name and values.\r
+     * @throws OcException\r
+     */\r
+    public native void post(OcRepresentation ocRepresentation,\r
+                            Map<String, String> queryParamsMap,\r
+                            OnPostListener onPostListener) throws OcException;\r
+\r
+    /**\r
+     * Method to POST on a resource\r
+     *\r
+     * @param ocRepresentation representation of the resource\r
+     * @param queryParamsMap   Map which can have the query parameter name and value\r
+     * @param onPostListener   event handler The event handler will be invoked with a map of\r
+     *                         attribute name and values.\r
+     * @param qualityOfService the quality of communication\r
+     * @throws OcException\r
+     */\r
+    public void post(OcRepresentation ocRepresentation,\r
+                     Map<String, String> queryParamsMap,\r
+                     OnPostListener onPostListener,\r
+                     QualityOfService qualityOfService) throws OcException {\r
+        this.post1(\r
+                ocRepresentation,\r
+                queryParamsMap,\r
+                onPostListener,\r
+                qualityOfService.getValue());\r
+    }\r
+\r
+    private native void post1(OcRepresentation ocRepresentation,\r
+                              Map<String, String> queryParamsMap,\r
+                              OnPostListener onPostListener,\r
+                              int qualityOfService) throws OcException;\r
+\r
+    /**\r
+     * Method to POST on a resource\r
+     *\r
+     * @param resourceType      resource type of the resource to operate on\r
+     * @param resourceInterface interface type of the resource to operate on\r
+     * @param ocRepresentation  representation of the resource\r
+     * @param queryParamsMap    Map which can have the query parameter name and value\r
+     * @param onPostListener    event handler The event handler will be invoked with a map of\r
+     *                          attribute name and values.\r
+     * @throws OcException\r
+     */\r
+    public void post(String resourceType,\r
+                     String resourceInterface,\r
+                     OcRepresentation ocRepresentation,\r
+                     Map<String, String> queryParamsMap,\r
+                     OnPostListener onPostListener) throws OcException {\r
+        this.post2(\r
+                resourceType,\r
+                resourceInterface,\r
+                ocRepresentation,\r
+                queryParamsMap,\r
+                onPostListener);\r
+    }\r
+\r
+    private native void post2(String resourceType,\r
+                              String resourceInterface,\r
+                              OcRepresentation ocRepresentation,\r
+                              Map<String, String> queryParamsMap,\r
+                              OnPostListener onPostListener) throws OcException;\r
+\r
+    /**\r
+     * Method to POST on a resource\r
+     *\r
+     * @param resourceType      resource type of the resource to operate on\r
+     * @param resourceInterface interface type of the resource to operate on\r
+     * @param ocRepresentation  representation of the resource\r
+     * @param queryParamsMap    Map which can have the query parameter name and value\r
+     * @param onPostListener    event handler The event handler will be invoked with a map of\r
+     *                          attribute name and values.\r
+     * @param qualityOfService  the quality of communication\r
+     * @throws OcException\r
+     */\r
+    public void post(String resourceType,\r
+                     String resourceInterface,\r
+                     OcRepresentation ocRepresentation,\r
+                     Map<String, String> queryParamsMap,\r
+                     OnPostListener onPostListener,\r
+                     QualityOfService qualityOfService) throws OcException {\r
+        this.post3(\r
+                resourceType,\r
+                resourceInterface,\r
+                ocRepresentation,\r
+                queryParamsMap,\r
+                onPostListener,\r
+                qualityOfService.getValue());\r
+    }\r
+\r
+    private native void post3(String resourceType,\r
+                              String resourceInterface,\r
+                              OcRepresentation ocRepresentation,\r
+                              Map<String, String> queryParamsMap,\r
+                              OnPostListener onPostListener,\r
+                              int qualityOfService) throws OcException;\r
+\r
+    /**\r
+     * Method to perform DELETE operation\r
+     *\r
+     * @param onDeleteListener event handler The event handler will have headerOptionList\r
+     */\r
+    public native void deleteResource(OnDeleteListener onDeleteListener) throws OcException;\r
+\r
+    /**\r
+     * Method to perform DELETE operation\r
+     *\r
+     * @param onDeleteListener event handler The event handler will have headerOptionList\r
+     * @param qualityOfService the quality of communication\r
+     */\r
+    public void deleteResource(OnDeleteListener onDeleteListener,\r
+                               QualityOfService qualityOfService) throws OcException {\r
+        this.deleteResource1(onDeleteListener,\r
+                qualityOfService.getValue());\r
+    }\r
+\r
+    private native void deleteResource1(OnDeleteListener onDeleteListener,\r
+                                        int qualityOfService) throws OcException;\r
+\r
+    /**\r
+     * Method to set observation on the resource\r
+     *\r
+     * @param observeType       allows the client to specify how it wants to observe\r
+     * @param queryParamsMap    map which can have the query parameter name and value\r
+     * @param onObserveListener event handler The handler method will be invoked with a map\r
+     *                          of attribute name and values.\r
+     * @throws OcException\r
+     */\r
+    public void observe(ObserveType observeType,\r
+                        Map<String, String> queryParamsMap,\r
+                        OnObserveListener onObserveListener) throws OcException {\r
+        this.observe(\r
+                observeType.getValue(),\r
+                queryParamsMap,\r
+                onObserveListener);\r
+    }\r
+\r
+    private synchronized native void observe(int observeType,\r
+                                             Map<String, String> queryParamsMap,\r
+                                             OnObserveListener onObserveListener) throws OcException;\r
+\r
+    /**\r
+     * Method to set observation on the resource\r
+     *\r
+     * @param observeType       allows the client to specify how it wants to observe\r
+     * @param queryParamsMap    map which can have the query parameter name and value\r
+     * @param onObserveListener event handler The handler method will be invoked with a map\r
+     *                          of attribute name and values.\r
+     * @param qualityOfService  the quality of communication\r
+     * @throws OcException\r
+     */\r
+    public void observe(ObserveType observeType,\r
+                        Map<String, String> queryParamsMap,\r
+                        OnObserveListener onObserveListener,\r
+                        QualityOfService qualityOfService) throws OcException {\r
+        this.observe1(\r
+                observeType.getValue(),\r
+                queryParamsMap,\r
+                onObserveListener,\r
+                qualityOfService.getValue());\r
+    }\r
+\r
+    private synchronized native void observe1(int observeType,\r
+                                              Map<String, String> queryParamsMap,\r
+                                              OnObserveListener onObserveListener,\r
+                                              int qualityOfService) throws OcException;\r
+\r
+    /**\r
+     * Method to cancel the observation on the resource\r
+     *\r
+     * @throws OcException\r
+     */\r
+    public native void cancelObserve() throws OcException;\r
+\r
+    /**\r
+     * Method to cancel the observation on the resource\r
+     *\r
+     * @param qualityOfService the quality of communication\r
+     * @throws OcException\r
+     */\r
+    public void cancelObserve(QualityOfService qualityOfService) throws OcException {\r
+        this.cancelObserve1(qualityOfService.getValue());\r
+    }\r
+\r
+    private native void cancelObserve1(int qualityOfService) throws OcException;\r
+\r
+    /**\r
+     * Method to set header options\r
+     *\r
+     * @param headerOptionList List<OcHeaderOption> where header information(header optionID and\r
+     *                         optionData is passed\r
+     */\r
+    public void setHeaderOptions(List<OcHeaderOption> headerOptionList) {\r
+        this.setHeaderOptions(headerOptionList.toArray(\r
+                        new OcHeaderOption[headerOptionList.size()])\r
+        );\r
+    }\r
+\r
+    private native void setHeaderOptions(OcHeaderOption[] headerOptionList);\r
+\r
+    /**\r
+     * Method to unset header options\r
+     */\r
+    public native void unsetHeaderOptions();\r
+\r
+    /**\r
+     * Method to get the host address of this resource\r
+     *\r
+     * @return host address NOTE: This might or might not be exposed in future due to\r
+     * security concerns\r
+     */\r
+    public native String getHost();\r
+\r
+    /**\r
+     * Method to get the URI for this resource\r
+     *\r
+     * @return resource URI\r
+     */\r
+    public native String getUri();\r
+\r
+    /**\r
+     * Method to get the connectivity type of this resource\r
+     *\r
+     * @return OcConnectivityType connectivity type\r
+     */\r
+    public OcConnectivityType getConnectivityType() {\r
+        return OcConnectivityType.get(\r
+                this.getConnectivityTypeN()\r
+        );\r
+    }\r
+\r
+    private native int getConnectivityTypeN();\r
+\r
+    /**\r
+     * Method to provide ability to check if this resource is observable or not\r
+     *\r
+     * @return true indicates resource is observable; false indicates resource is not observable\r
+     */\r
+    public native boolean isObservable();\r
+\r
+    /**\r
+     * Method to get the list of resource types\r
+     *\r
+     * @return List of resource types\r
+     */\r
+    public native List<String> getResourceTypes();\r
+\r
+    /**\r
+     * Method to get the list of resource interfaces\r
+     *\r
+     * @return List of resource interface\r
+     */\r
+    public native List<String> getResourceInterfaces();\r
+\r
+    /**\r
+     * Method to get a unique identifier for this resource across network interfaces.  This will\r
+     * be guaranteed unique for every resource-per-server independent of how this was discovered.\r
+     *\r
+     * @return OcResourceIdentifier object, which can be used for all comparison and hashing\r
+     */\r
+    public native OcResourceIdentifier getUniqueIdentifier();\r
+\r
+    /**\r
+     * Method to get a string representation of the resource's server ID.\r
+     * * This is unique per- server independent on how it was discovered.\r
+     *\r
+     * @return server ID\r
+     */\r
+    public native String getServerId();\r
+\r
+    /**\r
+     * An OnGetListener can be registered via the resource get call.\r
+     * Event listeners are notified asynchronously\r
+     */\r
+    public interface OnGetListener {\r
+        public void onGetCompleted(List<OcHeaderOption> headerOptionList,\r
+                                   OcRepresentation ocRepresentation);\r
+\r
+        public void onGetFailed(Throwable ex);\r
+    }\r
+\r
+    /**\r
+     * An OnPutListener can be registered via the resource put call.\r
+     * Event listeners are notified asynchronously\r
+     */\r
+    public interface OnPutListener {\r
+        public void onPutCompleted(List<OcHeaderOption> headerOptionList,\r
+                                   OcRepresentation ocRepresentation);\r
+\r
+        public void onPutFailed(Throwable ex);\r
+    }\r
+\r
+    /**\r
+     * An OnPostListener can be registered via the resource post call.\r
+     * Event listeners are notified asynchronously\r
+     */\r
+    public interface OnPostListener {\r
+        public void onPostCompleted(List<OcHeaderOption> headerOptionList,\r
+                                    OcRepresentation ocRepresentation);\r
+\r
+        public void onPostFailed(Throwable ex);\r
+    }\r
+\r
+    /**\r
+     * An OnDeleteListener can be registered via the resource delete call.\r
+     * Event listeners are notified asynchronously\r
+     */\r
+    public interface OnDeleteListener {\r
+        public void onDeleteCompleted(List<OcHeaderOption> headerOptionList);\r
+\r
+        public void onDeleteFailed(Throwable ex);\r
+    }\r
+\r
+    /**\r
+     * An OnObserveListener can be registered via the resource observe call.\r
+     * Event listeners are notified asynchronously\r
+     */\r
+    public interface OnObserveListener {\r
+        public void onObserveCompleted(List<OcHeaderOption> headerOptionList,\r
+                                       OcRepresentation ocRepresentation,\r
+                                       int sequenceNumber);\r
+\r
+        public void onObserveFailed(Throwable ex);\r
+    }\r
+\r
+    @Override\r
+    protected void finalize() throws Throwable {\r
+        super.finalize();\r
+\r
+        dispose();\r
+    }\r
+\r
+    private native void dispose();\r
+\r
+    private long mNativeHandle;\r
+}\r
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcResourceHandle.java b/android/android_api/base/src/main/java/org/iotivity/base/OcResourceHandle.java
new file mode 100755 (executable)
index 0000000..3bab82f
--- /dev/null
@@ -0,0 +1,41 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base;\r
+\r
+public class OcResourceHandle {\r
+\r
+    private OcResourceHandle(long nativeHandle) {\r
+        this.mNativeHandle = nativeHandle;\r
+    }\r
+\r
+    @Override\r
+    protected void finalize() throws Throwable {\r
+        super.finalize();\r
+\r
+        dispose();\r
+    }\r
+\r
+    private native void dispose();\r
+\r
+    private long mNativeHandle;\r
+}\r
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcResourceIdentifier.java b/android/android_api/base/src/main/java/org/iotivity/base/OcResourceIdentifier.java
new file mode 100755 (executable)
index 0000000..a1de037
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base;\r
+\r
+public class OcResourceIdentifier {\r
+    private OcResourceIdentifier(long nativeHandle) {\r
+        this.mNativeHandle = nativeHandle;\r
+    }\r
+\r
+    @Override\r
+    protected void finalize() throws Throwable {\r
+        super.finalize();\r
+\r
+        dispose();\r
+    }\r
+\r
+    @Override\r
+    public boolean equals(Object obj) {\r
+        if (!(obj instanceof OcResourceIdentifier)) {\r
+            return false;\r
+        }\r
+        OcResourceIdentifier other = (OcResourceIdentifier) obj;\r
+        return equalsN(other);\r
+    }\r
+\r
+    private native boolean equalsN(OcResourceIdentifier other);\r
+\r
+    private native void dispose();\r
+\r
+    private long mNativeHandle;\r
+}\r
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcResourceRequest.java b/android/android_api/base/src/main/java/org/iotivity/base/OcResourceRequest.java
new file mode 100755 (executable)
index 0000000..5a24b02
--- /dev/null
@@ -0,0 +1,135 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base;\r
+\r
+import java.util.EnumSet;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+/**\r
+ * OcResourceRequest provides APIs to extract details from a request\r
+ */\r
+public class OcResourceRequest {\r
+\r
+    private OcResourceRequest(long nativeHandle) {\r
+        this.mNativeHandle = nativeHandle;\r
+    }\r
+\r
+    /**\r
+     * Retrieves the type of request for the entity handler function to operate\r
+     *\r
+     * @return request type. This could be 'GET'/'PUT'/'POST'/'DELETE'\r
+     */\r
+    public RequestType getRequestType() {\r
+        return RequestType.get(getRequestTypeNative());\r
+    }\r
+\r
+    private native String getRequestTypeNative();\r
+\r
+    /**\r
+     * Retrieves the query parameters from the request\r
+     *\r
+     * @return parameters in the request\r
+     */\r
+    public native Map<String, String> getQueryParameters();\r
+\r
+    /**\r
+     * Retrieves the request handler flag set. This can be INIT flag and/or REQUEST flag and/or\r
+     * OBSERVE flag.\r
+     * NOTE:\r
+     * INIT indicates that the vendor's entity handler should go and perform\r
+     * initialization operations\r
+     * REQUEST indicates that it is a request of certain type (GET/PUT/POST/DELETE) and entity\r
+     * handler needs to perform corresponding operations\r
+     * OBSERVE indicates that the request is of type Observe and entity handler needs to perform\r
+     * corresponding operations\r
+     *\r
+     * @return Set of handler flags\r
+     */\r
+    public EnumSet<RequestHandlerFlag> getRequestHandlerFlagSet() {\r
+        return RequestHandlerFlag.convertToEnumSet(getRequestHandlerFlagNative());\r
+    }\r
+\r
+    private native int getRequestHandlerFlagNative();\r
+\r
+    /**\r
+     * Provides the entire resource attribute representation\r
+     *\r
+     * @return OcRepresentation object containing the name value pairs representing\r
+     * the resource's attributes\r
+     */\r
+    public native OcRepresentation getResourceRepresentation();\r
+\r
+    /**\r
+     * Object provides observation information\r
+     *\r
+     * @return observation information\r
+     */\r
+    public native ObservationInfo getObservationInfo();\r
+\r
+    /**\r
+     * Specifies the resource uri\r
+     *\r
+     * @param resourceUri resource uri\r
+     */\r
+    public native void setResourceUri(String resourceUri);\r
+\r
+    /**\r
+     * Gets the resource URI\r
+     *\r
+     * @return resource URI\r
+     */\r
+    public native String getResourceUri();\r
+\r
+    /**\r
+     * This API retrieves a list of headerOptions which was sent from a client\r
+     *\r
+     * @return List of header options\r
+     */\r
+    public native List<OcHeaderOption> getHeaderOptions();\r
+\r
+    /**\r
+     * This API retrieves the request handle\r
+     *\r
+     * @return request handle\r
+     */\r
+    public native OcRequestHandle getRequestHandle();\r
+\r
+    /**\r
+     * This API retrieves the resource handle\r
+     *\r
+     * @return resource handle\r
+     */\r
+    public native OcResourceHandle getResourceHandle();\r
+\r
+    @Override\r
+    protected void finalize() throws Throwable {\r
+        super.finalize();\r
+\r
+        dispose();\r
+    }\r
+\r
+    private native void dispose();\r
+\r
+    private long mNativeHandle;\r
+}\r
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcResourceResponse.java b/android/android_api/base/src/main/java/org/iotivity/base/OcResourceResponse.java
new file mode 100755 (executable)
index 0000000..263de42
--- /dev/null
@@ -0,0 +1,139 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base;\r
+\r
+import java.util.List;\r
+\r
+/**\r
+ * OcResourceResponse provides APIs to set the response details\r
+ */\r
+public class OcResourceResponse {\r
+\r
+    static {\r
+        System.loadLibrary("oc");\r
+        System.loadLibrary("ocstack-jni");\r
+    }\r
+\r
+    public OcResourceResponse() {\r
+        super();\r
+\r
+        create();\r
+    }\r
+\r
+    private OcResourceResponse(long nativeHandle) {\r
+        this.mNativeHandle = nativeHandle;\r
+    }\r
+\r
+    /**\r
+     * This API sets the error code for this response\r
+     *\r
+     * @param eCode error code to set\r
+     */\r
+    public native void setErrorCode(int eCode);\r
+\r
+    /**\r
+     * Gets new resource uri\r
+     *\r
+     * @return new resource uri\r
+     */\r
+    public native String getNewResourceUri();\r
+\r
+    /**\r
+     * Sets new resource uri\r
+     *\r
+     * @param newResourceUri new resource uri\r
+     */\r
+    public native void setNewResourceUri(String newResourceUri);\r
+\r
+    /**\r
+     * This API allows to set headerOptions in the response\r
+     *\r
+     * @param headerOptionList List of HeaderOption entries\r
+     */\r
+    public void setHeaderOptions(List<OcHeaderOption> headerOptionList) {\r
+        this.setHeaderOptions(headerOptionList.toArray(\r
+                        new OcHeaderOption[headerOptionList.size()])\r
+        );\r
+    }\r
+\r
+    private native void setHeaderOptions(OcHeaderOption[] headerOptionList);\r
+\r
+    /**\r
+     * This API allows to set request handle\r
+     *\r
+     * @param ocRequestHandle request handle\r
+     */\r
+    public native void setRequestHandle(OcRequestHandle ocRequestHandle);\r
+\r
+    /**\r
+     * This API allows to set the resource handle\r
+     *\r
+     * @param ocResourceHandle resource handle\r
+     */\r
+    public native void setResourceHandle(OcResourceHandle ocResourceHandle);\r
+\r
+    /**\r
+     * This API allows to set the EntityHandler response result\r
+     *\r
+     * @param responseResult OcEntityHandlerResult type to set the result value\r
+     */\r
+    public void setResponseResult(EntityHandlerResult responseResult) {\r
+        this.setResponseResult(responseResult.getValue());\r
+    }\r
+\r
+    private native void setResponseResult(int responseResult);\r
+\r
+    /**\r
+     * API to set the entire resource attribute representation\r
+     *\r
+     * @param ocRepresentation the name value pairs representing the resource's attributes\r
+     * @param interfaceStr     specifies the interface\r
+     */\r
+    public native void setResourceRepresentation(OcRepresentation ocRepresentation,\r
+                                                 String interfaceStr);\r
+\r
+    /**\r
+     * API to set the entire resource attribute representation\r
+     *\r
+     * @param representation object containing the name value pairs representing the\r
+     *                       resource's attributes\r
+     */\r
+    public void setResourceRepresentation(OcRepresentation representation) {\r
+        this.setResourceRepresentation1(representation);\r
+    }\r
+\r
+    private native void setResourceRepresentation1(OcRepresentation representation);\r
+\r
+    @Override\r
+    protected void finalize() throws Throwable {\r
+        super.finalize();\r
+\r
+        dispose();\r
+    }\r
+\r
+    private native void create();\r
+\r
+    private native void dispose();\r
+\r
+    private long mNativeHandle;\r
+}\r
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/PlatformConfig.java b/android/android_api/base/src/main/java/org/iotivity/base/PlatformConfig.java
new file mode 100755 (executable)
index 0000000..7fd9ac0
--- /dev/null
@@ -0,0 +1,88 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base;\r
+\r
+import android.content.Context;\r
+\r
+/**\r
+ * Data structure to provide the configuration.\r
+ */\r
+public class PlatformConfig {\r
+\r
+    private Context mContext;\r
+    private ServiceType mServiceType;\r
+    private ModeType mModeType;\r
+    private String mIpAddress;\r
+    private int mPort;\r
+    private QualityOfService mQualityOfService;\r
+\r
+    /**\r
+     * @param context          app context\r
+     * @param serviceType      indicate IN_PROC or OUT_OF_PROC\r
+     * @param modeType         indicate whether we want to do server, client or both\r
+     * @param ipAddress        ip address of server\r
+     *                         if you specify 0.0.0.0 : it listens on any interface\r
+     * @param port             port of server\r
+     *                         if you specifiy 0 : next available random port is used\r
+     *                         if you specify 5683 : client discovery can work even if they don't\r
+     *                         specify port\r
+     * @param qualityOfService quality of service\r
+     */\r
+    public PlatformConfig(Context context,\r
+                          ServiceType serviceType,\r
+                          ModeType modeType,\r
+                          String ipAddress,\r
+                          int port,\r
+                          QualityOfService qualityOfService) {\r
+        this.mContext = context;\r
+        this.mServiceType = serviceType;\r
+        this.mModeType = modeType;\r
+        this.mIpAddress = ipAddress;\r
+        this.mPort = port;\r
+        this.mQualityOfService = qualityOfService;\r
+    }\r
+\r
+    public Context getContext() {\r
+        return mContext;\r
+    }\r
+\r
+    public ServiceType getServiceType() {\r
+        return mServiceType;\r
+    }\r
+\r
+    public ModeType getModeType() {\r
+        return mModeType;\r
+    }\r
+\r
+    public String getIpAddress() {\r
+        return mIpAddress;\r
+    }\r
+\r
+    public int getPort() {\r
+        return mPort;\r
+    }\r
+\r
+    public QualityOfService getQualityOfService() {\r
+        return mQualityOfService;\r
+    }\r
+}\r
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/QualityOfService.java b/android/android_api/base/src/main/java/org/iotivity/base/QualityOfService.java
new file mode 100755 (executable)
index 0000000..4c85981
--- /dev/null
@@ -0,0 +1,42 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base;\r
+\r
+/**\r
+ */\r
+public enum QualityOfService {\r
+    LOW(0),\r
+    MEDIUM(1),\r
+    HIGH(2),\r
+    NA(3);\r
+\r
+    private int value;\r
+\r
+    private QualityOfService(int value) {\r
+        this.value = value;\r
+    }\r
+\r
+    public int getValue() {\r
+        return this.value;\r
+    }\r
+}\r
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/RequestHandlerFlag.java b/android/android_api/base/src/main/java/org/iotivity/base/RequestHandlerFlag.java
new file mode 100755 (executable)
index 0000000..5e1f5ee
--- /dev/null
@@ -0,0 +1,61 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base;\r
+\r
+import java.util.EnumSet;\r
+\r
+public enum RequestHandlerFlag {\r
+    INIT(1 << 0),\r
+    REQUEST(1 << 1),\r
+    OBSERVER(1 << 2),;\r
+\r
+    private int value;\r
+\r
+    private RequestHandlerFlag(int value) {\r
+        this.value = value;\r
+    }\r
+\r
+    public int getValue() {\r
+        return this.value;\r
+    }\r
+\r
+    public static EnumSet<RequestHandlerFlag> convertToEnumSet(int value) {\r
+        EnumSet<RequestHandlerFlag> flagSet = null;\r
+\r
+        for (RequestHandlerFlag v : values()) {\r
+            if (0 != (value & v.getValue())) {\r
+                if (flagSet == null) {\r
+                    flagSet = EnumSet.of(v);\r
+                } else {\r
+                    flagSet.add(v);\r
+                }\r
+            }\r
+        }\r
+\r
+        if (null == flagSet || flagSet.isEmpty()) {\r
+            throw new IllegalArgumentException("Unexpected RequestHandlerFlag value");\r
+        }\r
+\r
+        return flagSet;\r
+    }\r
+}\r
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/RequestType.java b/android/android_api/base/src/main/java/org/iotivity/base/RequestType.java
new file mode 100755 (executable)
index 0000000..894429d
--- /dev/null
@@ -0,0 +1,48 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base;\r
+\r
+public enum RequestType {\r
+    GET("GET"),\r
+    PUT("PUT"),\r
+    POST("POST"),\r
+    DELETE("DELETE"),;\r
+    private String value;\r
+\r
+    private RequestType(String value) {\r
+        this.value = value;\r
+    }\r
+\r
+    public String getValue() {\r
+        return this.value;\r
+    }\r
+\r
+    public static RequestType get(String value) {\r
+        for (RequestType v : values()) {\r
+            if (v.getValue().equals(value)) {\r
+                return v;\r
+            }\r
+        }\r
+        throw new IllegalArgumentException("Unexpected RequestType value");\r
+    }\r
+}\r
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/ResourceProperty.java b/android/android_api/base/src/main/java/org/iotivity/base/ResourceProperty.java
new file mode 100755 (executable)
index 0000000..64345db
--- /dev/null
@@ -0,0 +1,41 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base;\r
+\r
+public enum ResourceProperty {\r
+    ACTIVE(1 << 0),\r
+    DISCOVERABLE(1 << 1),\r
+    OBSERVABLE(1 << 2),\r
+    SLOW(1 << 3),\r
+    SECURE(1 << 4);\r
+\r
+    private int value;\r
+\r
+    private ResourceProperty(int value) {\r
+        this.value = value;\r
+    }\r
+\r
+    public int getValue() {\r
+        return this.value;\r
+    }\r
+}\r
diff --git a/android/android_api/base/src/main/java/org/iotivity/base/ServiceType.java b/android/android_api/base/src/main/java/org/iotivity/base/ServiceType.java
new file mode 100755 (executable)
index 0000000..6dc65a7
--- /dev/null
@@ -0,0 +1,38 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base;\r
+\r
+public enum ServiceType {\r
+    IN_PROC(0),\r
+    OUT_OF_PROC(1),;\r
+\r
+    private int value;\r
+\r
+    private ServiceType(int value) {\r
+        this.value = value;\r
+    }\r
+\r
+    public int getValue() {\r
+        return this.value;\r
+    }\r
+}\r
diff --git a/android/android_api/base/src/main/java/org/iotivity/ca/CaInterface.java b/android/android_api/base/src/main/java/org/iotivity/ca/CaInterface.java
new file mode 100755 (executable)
index 0000000..81c457c
--- /dev/null
@@ -0,0 +1,34 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.ca;\r
+\r
+import android.content.Context;\r
+\r
+public class CaInterface {\r
+    static {\r
+        System.loadLibrary("connectivity_abstraction");\r
+        System.loadLibrary("ca-interface");\r
+    }\r
+\r
+    public static native void initialize(Context context);\r
+}
\ No newline at end of file
diff --git a/android/android_api/base/src/main/java/org/iotivity/ca/CaIpInterface.java b/android/android_api/base/src/main/java/org/iotivity/ca/CaIpInterface.java
new file mode 100755 (executable)
index 0000000..43d0ace
--- /dev/null
@@ -0,0 +1,70 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.ca;\r
+\r
+import android.content.BroadcastReceiver;\r
+import android.content.Context;\r
+import android.content.Intent;\r
+import android.content.IntentFilter;\r
+import android.net.ConnectivityManager;\r
+import android.net.NetworkInfo;\r
+import android.net.wifi.WifiManager;\r
+\r
+public class CaIpInterface {\r
+    private static Context mContext;\r
+\r
+    private CaIpInterface(Context context) {\r
+        mContext = context;\r
+        registerIpStateReceiver();\r
+    }\r
+\r
+    private void registerIpStateReceiver() {\r
+        IntentFilter intentFilter = new IntentFilter();\r
+        intentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);\r
+        intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);\r
+\r
+        mContext.registerReceiver(mReceiver, intentFilter);\r
+    }\r
+\r
+    private static BroadcastReceiver mReceiver = new BroadcastReceiver() {\r
+        @Override\r
+        public void onReceive(Context context, Intent intent) {\r
+            if (intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,\r
+                    WifiManager.WIFI_STATE_UNKNOWN) == WifiManager.WIFI_STATE_DISABLED) {\r
+                stateDisabled();\r
+            } else if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {\r
+                ConnectivityManager manager = (ConnectivityManager)\r
+                        mContext.getSystemService(Context.CONNECTIVITY_SERVICE);\r
+                NetworkInfo nwInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);\r
+\r
+                if(nwInfo.isConnected()) {\r
+                    stateEnabled();\r
+                }\r
+            }\r
+        }\r
+    };\r
+\r
+    private native static void stateEnabled();\r
+\r
+    private native static void stateDisabled();\r
+}
\ No newline at end of file
diff --git a/android/android_api/base/src/main/java/org/iotivity/ca/CaWiFiInterface.java b/android/android_api/base/src/main/java/org/iotivity/ca/CaWiFiInterface.java
new file mode 100755 (executable)
index 0000000..15cac58
--- /dev/null
@@ -0,0 +1,72 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.ca;\r
+\r
+import android.content.BroadcastReceiver;\r
+import android.content.Context;\r
+import android.content.Intent;\r
+import android.content.IntentFilter;\r
+import android.net.ConnectivityManager;\r
+import android.net.NetworkInfo;\r
+import android.net.wifi.WifiManager;\r
+\r
+public class CaWiFiInterface {\r
+\r
+    private static Context mContext;\r
+\r
+    private CaWiFiInterface(Context context) {\r
+        mContext = context;\r
+        registerWiFiStateReceiver();\r
+    }\r
+\r
+    private void registerWiFiStateReceiver() {\r
+        IntentFilter intentFilter = new IntentFilter();\r
+        intentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);\r
+        intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);\r
+\r
+        mContext.registerReceiver(mReceiver, intentFilter);\r
+    }\r
+\r
+    private static BroadcastReceiver mReceiver = new BroadcastReceiver() {\r
+\r
+        @Override\r
+        public void onReceive(Context context, Intent intent) {\r
+            if (intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,\r
+                    WifiManager.WIFI_STATE_UNKNOWN) == WifiManager.WIFI_STATE_DISABLED) {\r
+                CAWiFiStateDisabled();\r
+            } else if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {\r
+                ConnectivityManager manager = (ConnectivityManager)\r
+                        mContext.getSystemService(Context.CONNECTIVITY_SERVICE);\r
+                NetworkInfo nwInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);\r
+\r
+                if (nwInfo.isConnected()) {\r
+                    CAWiFiStateEnabled();\r
+                }\r
+            }\r
+        }\r
+    };\r
+\r
+    private native static void CAWiFiStateEnabled();\r
+\r
+    private native static void CAWiFiStateDisabled();\r
+}
\ No newline at end of file
diff --git a/android/android_api/build.gradle b/android/android_api/build.gradle
new file mode 100755 (executable)
index 0000000..478166f
--- /dev/null
@@ -0,0 +1,41 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2014 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+// Top-level build file where you can add configuration options common to all sub-projects/modules.\r
+\r
+buildscript {\r
+    repositories {\r
+        jcenter()\r
+    }\r
+    dependencies {\r
+        classpath 'com.android.tools.build:gradle:1.0.0'\r
+\r
+        // NOTE: Do not place your application dependencies here; they belong\r
+        // in the individual module build.gradle files\r
+    }\r
+}\r
+\r
+allprojects {\r
+    repositories {\r
+        jcenter()\r
+    }\r
+}\r
diff --git a/android/android_api/gradle.properties b/android/android_api/gradle.properties
new file mode 100755 (executable)
index 0000000..42a55d5
--- /dev/null
@@ -0,0 +1,40 @@
+#\r
+# //******************************************************************\r
+# //\r
+# // Copyright 2015 Intel Corporation.\r
+# //\r
+# //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+# //\r
+# // Licensed under the Apache License, Version 2.0 (the "License");\r
+# // you may not use this file except in compliance with the License.\r
+# // You may obtain a copy of the License at\r
+# //\r
+# //      http://www.apache.org/licenses/LICENSE-2.0\r
+# //\r
+# // Unless required by applicable law or agreed to in writing, software\r
+# // distributed under the License is distributed on an "AS IS" BASIS,\r
+# // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# // See the License for the specific language governing permissions and\r
+# // limitations under the License.\r
+# //\r
+# //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+#\r
+\r
+# Project-wide Gradle settings.\r
+\r
+# IDE (e.g. Android Studio) users:\r
+# Gradle settings configured through the IDE *will override*\r
+# any settings specified in this file.\r
+\r
+# For more details on how to configure your build environment visit\r
+# http://www.gradle.org/docs/current/userguide/build_environment.html\r
+\r
+# Specifies the JVM arguments used for the daemon process.\r
+# The setting is particularly useful for tweaking memory settings.\r
+# Default value: -Xmx10248m -XX:MaxPermSize=256m\r
+# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8\r
+\r
+# When configured, Gradle will run in incubating parallel mode.\r
+# This option should only be used with decoupled projects. More details, visit\r
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects\r
+# org.gradle.parallel=true\r
diff --git a/android/android_api/gradle/wrapper/gradle-wrapper.jar b/android/android_api/gradle/wrapper/gradle-wrapper.jar
new file mode 100755 (executable)
index 0000000..8c0fb64
Binary files /dev/null and b/android/android_api/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/android/android_api/gradle/wrapper/gradle-wrapper.properties b/android/android_api/gradle/wrapper/gradle-wrapper.properties
new file mode 100755 (executable)
index 0000000..c275376
--- /dev/null
@@ -0,0 +1,28 @@
+#\r
+# //******************************************************************\r
+# //\r
+# // Copyright 2014 Intel Corporation.\r
+# //\r
+# //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+# //\r
+# // Licensed under the Apache License, Version 2.0 (the "License");\r
+# // you may not use this file except in compliance with the License.\r
+# // You may obtain a copy of the License at\r
+# //\r
+# //      http://www.apache.org/licenses/LICENSE-2.0\r
+# //\r
+# // Unless required by applicable law or agreed to in writing, software\r
+# // distributed under the License is distributed on an "AS IS" BASIS,\r
+# // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# // See the License for the specific language governing permissions and\r
+# // limitations under the License.\r
+# //\r
+# //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+#\r
+\r
+#Fri Dec 12 12:28:50 PST 2014\r
+distributionBase=GRADLE_USER_HOME\r
+distributionPath=wrapper/dists\r
+zipStoreBase=GRADLE_USER_HOME\r
+zipStorePath=wrapper/dists\r
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip\r
similarity index 96%
rename from android/Base/gradlew
rename to android/android_api/gradlew
index 91a7e26..583ae08 100755 (executable)
-#!/usr/bin/env bash
-
-##############################################################################
-##
-##  Gradle start up script for UN*X
-##
-##############################################################################
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn ( ) {
-    echo "$*"
-}
-
-die ( ) {
-    echo
-    echo "$*"
-    echo
-    exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-case "`uname`" in
-  CYGWIN* )
-    cygwin=true
-    ;;
-  Darwin* )
-    darwin=true
-    ;;
-  MINGW* )
-    msys=true
-    ;;
-esac
-
-# For Cygwin, ensure paths are in UNIX format before anything is touched.
-if $cygwin ; then
-    [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
-fi
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
-    ls=`ls -ld "$PRG"`
-    link=`expr "$ls" : '.*-> \(.*\)$'`
-    if expr "$link" : '/.*' > /dev/null; then
-        PRG="$link"
-    else
-        PRG=`dirname "$PRG"`"/$link"
-    fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >&-
-APP_HOME="`pwd -P`"
-cd "$SAVED" >&-
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
-    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
-        # IBM's JDK on AIX uses strange locations for the executables
-        JAVACMD="$JAVA_HOME/jre/sh/java"
-    else
-        JAVACMD="$JAVA_HOME/bin/java"
-    fi
-    if [ ! -x "$JAVACMD" ] ; then
-        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-    fi
-else
-    JAVACMD="java"
-    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
-    MAX_FD_LIMIT=`ulimit -H -n`
-    if [ $? -eq 0 ] ; then
-        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
-            MAX_FD="$MAX_FD_LIMIT"
-        fi
-        ulimit -n $MAX_FD
-        if [ $? -ne 0 ] ; then
-            warn "Could not set maximum file descriptor limit: $MAX_FD"
-        fi
-    else
-        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
-    fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
-    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
-    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
-    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
-
-    # We build the pattern for arguments to be converted via cygpath
-    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
-    SEP=""
-    for dir in $ROOTDIRSRAW ; do
-        ROOTDIRS="$ROOTDIRS$SEP$dir"
-        SEP="|"
-    done
-    OURCYGPATTERN="(^($ROOTDIRS))"
-    # Add a user-defined pattern to the cygpath arguments
-    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
-        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
-    fi
-    # Now convert the arguments - kludge to limit ourselves to /bin/sh
-    i=0
-    for arg in "$@" ; do
-        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
-        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
-
-        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
-            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
-        else
-            eval `echo args$i`="\"$arg\""
-        fi
-        i=$((i+1))
-    done
-    case $i in
-        (0) set -- ;;
-        (1) set -- "$args0" ;;
-        (2) set -- "$args0" "$args1" ;;
-        (3) set -- "$args0" "$args1" "$args2" ;;
-        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
-        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
-        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
-        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
-        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
-        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
-    esac
-fi
-
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
-    JVM_OPTS=("$@")
-}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
-
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
+#!/usr/bin/env bash\r
+\r
+##############################################################################\r
+##\r
+##  Gradle start up script for UN*X\r
+##\r
+##############################################################################\r
+\r
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\r
+DEFAULT_JVM_OPTS=""\r
+\r
+APP_NAME="Gradle"\r
+APP_BASE_NAME=`basename "$0"`\r
+\r
+# Use the maximum available, or set MAX_FD != -1 to use that value.\r
+MAX_FD="maximum"\r
+\r
+warn ( ) {\r
+    echo "$*"\r
+}\r
+\r
+die ( ) {\r
+    echo\r
+    echo "$*"\r
+    echo\r
+    exit 1\r
+}\r
+\r
+# OS specific support (must be 'true' or 'false').\r
+cygwin=false\r
+msys=false\r
+darwin=false\r
+case "`uname`" in\r
+  CYGWIN* )\r
+    cygwin=true\r
+    ;;\r
+  Darwin* )\r
+    darwin=true\r
+    ;;\r
+  MINGW* )\r
+    msys=true\r
+    ;;\r
+esac\r
+\r
+# For Cygwin, ensure paths are in UNIX format before anything is touched.\r
+if $cygwin ; then\r
+    [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`\r
+fi\r
+\r
+# Attempt to set APP_HOME\r
+# Resolve links: $0 may be a link\r
+PRG="$0"\r
+# Need this for relative symlinks.\r
+while [ -h "$PRG" ] ; do\r
+    ls=`ls -ld "$PRG"`\r
+    link=`expr "$ls" : '.*-> \(.*\)$'`\r
+    if expr "$link" : '/.*' > /dev/null; then\r
+        PRG="$link"\r
+    else\r
+        PRG=`dirname "$PRG"`"/$link"\r
+    fi\r
+done\r
+SAVED="`pwd`"\r
+cd "`dirname \"$PRG\"`/" >&-\r
+APP_HOME="`pwd -P`"\r
+cd "$SAVED" >&-\r
+\r
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar\r
+\r
+# Determine the Java command to use to start the JVM.\r
+if [ -n "$JAVA_HOME" ] ; then\r
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then\r
+        # IBM's JDK on AIX uses strange locations for the executables\r
+        JAVACMD="$JAVA_HOME/jre/sh/java"\r
+    else\r
+        JAVACMD="$JAVA_HOME/bin/java"\r
+    fi\r
+    if [ ! -x "$JAVACMD" ] ; then\r
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME\r
+\r
+Please set the JAVA_HOME variable in your environment to match the\r
+location of your Java installation."\r
+    fi\r
+else\r
+    JAVACMD="java"\r
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\r
+\r
+Please set the JAVA_HOME variable in your environment to match the\r
+location of your Java installation."\r
+fi\r
+\r
+# Increase the maximum file descriptors if we can.\r
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then\r
+    MAX_FD_LIMIT=`ulimit -H -n`\r
+    if [ $? -eq 0 ] ; then\r
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then\r
+            MAX_FD="$MAX_FD_LIMIT"\r
+        fi\r
+        ulimit -n $MAX_FD\r
+        if [ $? -ne 0 ] ; then\r
+            warn "Could not set maximum file descriptor limit: $MAX_FD"\r
+        fi\r
+    else\r
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"\r
+    fi\r
+fi\r
+\r
+# For Darwin, add options to specify how the application appears in the dock\r
+if $darwin; then\r
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""\r
+fi\r
+\r
+# For Cygwin, switch paths to Windows format before running java\r
+if $cygwin ; then\r
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`\r
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`\r
+\r
+    # We build the pattern for arguments to be converted via cygpath\r
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`\r
+    SEP=""\r
+    for dir in $ROOTDIRSRAW ; do\r
+        ROOTDIRS="$ROOTDIRS$SEP$dir"\r
+        SEP="|"\r
+    done\r
+    OURCYGPATTERN="(^($ROOTDIRS))"\r
+    # Add a user-defined pattern to the cygpath arguments\r
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then\r
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"\r
+    fi\r
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh\r
+    i=0\r
+    for arg in "$@" ; do\r
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`\r
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option\r
+\r
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition\r
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`\r
+        else\r
+            eval `echo args$i`="\"$arg\""\r
+        fi\r
+        i=$((i+1))\r
+    done\r
+    case $i in\r
+        (0) set -- ;;\r
+        (1) set -- "$args0" ;;\r
+        (2) set -- "$args0" "$args1" ;;\r
+        (3) set -- "$args0" "$args1" "$args2" ;;\r
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;\r
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;\r
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;\r
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;\r
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;\r
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;\r
+    esac\r
+fi\r
+\r
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules\r
+function splitJvmOpts() {\r
+    JVM_OPTS=("$@")\r
+}\r
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS\r
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"\r
+\r
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"\r
old mode 100644 (file)
new mode 100755 (executable)
similarity index 100%
rename from android/SimpleClient/gradlew.bat
rename to android/android_api/gradlew.bat
diff --git a/android/android_api/settings.gradle b/android/android_api/settings.gradle
new file mode 100755 (executable)
index 0000000..d1bcc8a
--- /dev/null
@@ -0,0 +1,23 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+include ':base'\r
old mode 100644 (file)
new mode 100755 (executable)
similarity index 83%
rename from android/Base/build.gradle
rename to android/examples/build.gradle
index 9b8abe4..50e899c
@@ -1,19 +1,19 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
-
-buildscript {
-    repositories {
-        jcenter()
-    }
-    dependencies {
-        classpath 'com.android.tools.build:gradle:0.12.2'
-
-        // NOTE: Do not place your application dependencies here; they belong
-        // in the individual module build.gradle files
-    }
-}
-
-allprojects {
-    repositories {
-        jcenter()
-    }
-}
+// Top-level build file where you can add configuration options common to all sub-projects/modules.\r
+\r
+buildscript {\r
+    repositories {\r
+        jcenter()\r
+    }\r
+    dependencies {\r
+        classpath 'com.android.tools.build:gradle:1.0.0'\r
+\r
+        // NOTE: Do not place your application dependencies here; they belong\r
+        // in the individual module build.gradle files\r
+    }\r
+}\r
+\r
+allprojects {\r
+    repositories {\r
+        jcenter()\r
+    }\r
+}\r
diff --git a/android/examples/examples.iml b/android/examples/examples.iml
new file mode 100755 (executable)
index 0000000..8d49284
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">\r
+  <component name="FacetManager">\r
+    <facet type="java-gradle" name="Java-Gradle">\r
+      <configuration>\r
+        <option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />\r
+      </configuration>\r
+    </facet>\r
+  </component>\r
+  <component name="NewModuleRootManager" inherit-compiler-output="true">\r
+    <exclude-output />\r
+    <content url="file://$MODULE_DIR$">\r
+      <excludeFolder url="file://$MODULE_DIR$/.gradle" />\r
+    </content>\r
+    <orderEntry type="inheritedJdk" />\r
+    <orderEntry type="sourceFolder" forTests="false" />\r
+  </component>\r
+</module>\r
+\r
diff --git a/android/examples/fridgeclient/.gitignore b/android/examples/fridgeclient/.gitignore
new file mode 100755 (executable)
index 0000000..3543521
--- /dev/null
@@ -0,0 +1 @@
+/build\r
diff --git a/android/examples/fridgeclient/build.gradle b/android/examples/fridgeclient/build.gradle
new file mode 100755 (executable)
index 0000000..975453f
--- /dev/null
@@ -0,0 +1,26 @@
+apply plugin: 'com.android.application'\r
+\r
+android {\r
+    compileSdkVersion 21\r
+    buildToolsVersion "21.1.2"\r
+\r
+    defaultConfig {\r
+        applicationId "org.iotivity.base.examples.fridgeclient"\r
+        minSdkVersion 19\r
+        targetSdkVersion 21\r
+        versionCode 1\r
+        versionName "1.0"\r
+    }\r
+    buildTypes {\r
+        release {\r
+            minifyEnabled false\r
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\r
+        }\r
+    }\r
+}\r
+\r
+dependencies {\r
+    compile fileTree(dir: 'libs', include: ['*.jar'])\r
+    compile 'com.android.support:appcompat-v7:21.0.3'\r
+    compile project(':message')\r
+}\r
diff --git a/android/examples/fridgeclient/fridgeclient.iml b/android/examples/fridgeclient/fridgeclient.iml
new file mode 100755 (executable)
index 0000000..ea17290
--- /dev/null
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="examples" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">\r
+  <component name="FacetManager">\r
+    <facet type="android-gradle" name="Android-Gradle">\r
+      <configuration>\r
+        <option name="GRADLE_PROJECT_PATH" value=":fridgeclient" />\r
+      </configuration>\r
+    </facet>\r
+    <facet type="android" name="Android">\r
+      <configuration>\r
+        <option name="SELECTED_BUILD_VARIANT" value="debug" />\r
+        <option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />\r
+        <option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />\r
+        <option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />\r
+        <option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />\r
+        <option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />\r
+        <option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugTestSources" />\r
+        <option name="ALLOW_USER_CONFIGURATION" value="false" />\r
+        <option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />\r
+        <option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />\r
+        <option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />\r
+        <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />\r
+      </configuration>\r
+    </facet>\r
+  </component>\r
+  <component name="NewModuleRootManager" inherit-compiler-output="false">\r
+    <output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />\r
+    <output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />\r
+    <exclude-output />\r
+    <content url="file://$MODULE_DIR$">\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/debug" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/test/debug" isTestSource="true" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/test/debug" isTestSource="true" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/test/debug" isTestSource="true" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/test/debug" isTestSource="true" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/test/debug" type="java-test-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/test/debug" type="java-test-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/outputs" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/tmp" />\r
+    </content>\r
+    <orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />\r
+    <orderEntry type="sourceFolder" forTests="false" />\r
+    <orderEntry type="library" exported="" name="iotivity-x86-base-debug-unspecified" level="project" />\r
+    <orderEntry type="library" exported="" name="appcompat-v7-21.0.3" level="project" />\r
+    <orderEntry type="library" exported="" name="support-annotations-21.0.3" level="project" />\r
+    <orderEntry type="library" exported="" name="support-v4-21.0.3" level="project" />\r
+    <orderEntry type="module" module-name="message" exported="" />\r
+  </component>\r
+</module>\r
+\r
diff --git a/android/examples/fridgeclient/src/main/AndroidManifest.xml b/android/examples/fridgeclient/src/main/AndroidManifest.xml
new file mode 100755 (executable)
index 0000000..d560e70
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"\r
+    xmlns:tools="http://schemas.android.com/tools"\r
+    package="org.iotivity.base.examples.fridgeclient" >\r
+    <uses-sdk tools:overrideLibrary="org.iotivity.base"></uses-sdk>\r
+\r
+    <application\r
+        android:allowBackup="true"\r
+        android:icon="@drawable/ic_launcher"\r
+        android:label="@string/app_name"\r
+        android:theme="@style/AppTheme">\r
+        <activity\r
+            android:name=".FridgeClient"\r
+            android:label="@string/app_name" >\r
+            <intent-filter>\r
+                <action android:name="android.intent.action.MAIN" />\r
+\r
+                <category android:name="android.intent.category.LAUNCHER" />\r
+            </intent-filter>\r
+        </activity>\r
+    </application>\r
+</manifest>\r
diff --git a/android/examples/fridgeclient/src/main/java/org/iotivity/base/examples/fridgeclient/FridgeClient.java b/android/examples/fridgeclient/src/main/java/org/iotivity/base/examples/fridgeclient/FridgeClient.java
new file mode 100755 (executable)
index 0000000..a004c87
--- /dev/null
@@ -0,0 +1,362 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base.examples.fridgeclient;\r
+\r
+import android.app.Activity;\r
+import android.content.BroadcastReceiver;\r
+import android.content.Context;\r
+import android.content.Intent;\r
+import android.content.IntentFilter;\r
+import android.os.Bundle;\r
+import android.os.Message;\r
+import android.support.v4.content.LocalBroadcastManager;\r
+import android.text.method.ScrollingMovementMethod;\r
+import android.util.Log;\r
+import android.view.Menu;\r
+import android.view.MenuItem;\r
+import android.widget.LinearLayout;\r
+import android.widget.TextView;\r
+\r
+import org.iotivity.base.ErrorCode;\r
+import org.iotivity.base.ModeType;\r
+import org.iotivity.base.OcConnectivityType;\r
+import org.iotivity.base.OcException;\r
+import org.iotivity.base.OcHeaderOption;\r
+import org.iotivity.base.OcPlatform;\r
+import org.iotivity.base.OcRepresentation;\r
+import org.iotivity.base.OcResource;\r
+import org.iotivity.base.PlatformConfig;\r
+import org.iotivity.base.QualityOfService;\r
+import org.iotivity.base.ServiceType;\r
+\r
+import java.util.HashMap;\r
+import java.util.LinkedList;\r
+import java.util.List;\r
+\r
+import base.iotivity.org.examples.message.IMessageLogger;\r
+\r
+/**\r
+ * FridgeClient\r
+ * <p/>\r
+ * FridgeClient is a sample client app which should be started after the fridgeServer is started.\r
+ * It creates DeviceResource, DoorResource, LightResource and performs a get operation on them.\r
+ * This implements IMessageLogger to display messages on the screen\r
+ */\r
+public class FridgeClient extends Activity implements\r
+        OcPlatform.OnResourceFoundListener, IMessageLogger {\r
+    private static String TAG = "FridgeClient: ";\r
+\r
+    private MessageReceiver mMessageReceiver = new MessageReceiver();\r
+    private TextView mEventsTextView;\r
+    private String mDeviceName;\r
+    private int mDeviceCode;\r
+    private List<String> ifaces;\r
+    private final List<OcResource> resourceList = new LinkedList<OcResource>();\r
+\r
+    /**\r
+     * configure OIC platform and call findResource\r
+     */\r
+    private void initOICStack() {\r
+        PlatformConfig cfg = new PlatformConfig(\r
+                this,\r
+                ServiceType.IN_PROC,\r
+                ModeType.CLIENT,\r
+                "0.0.0.0", // bind to all available interfaces\r
+                0,\r
+                QualityOfService.LOW);\r
+\r
+        OcPlatform.Configure(cfg);\r
+        try {\r
+            OcPlatform.findResource("", OcPlatform.WELL_KNOWN_QUERY + "?rt=" + "intel.fridge",\r
+                    OcConnectivityType.WIFI, this);\r
+        } catch (OcException e) {\r
+            logMessage(TAG + " init Error. " + e.getMessage());\r
+            Log.e(TAG, e.getMessage());\r
+        }\r
+    }\r
+\r
+    /**\r
+     * prints out the appropriate messages depending on the device code\r
+     *\r
+     * @param representation representation of the OcResource\r
+     * @param value          clientDeviceCode\r
+     */\r
+    private void getResponse(OcRepresentation representation, int value) {\r
+        switch (value) {\r
+            case 0:\r
+                // Get on device\r
+                try {\r
+                    logMessage(TAG + "Name of device: " +\r
+                            representation.getValue(StringConstants.DEVICE_NAME));\r
+                } catch (OcException e) {\r
+                    Log.e(TAG, e.getMessage());\r
+                }\r
+                break;\r
+            case 1:\r
+                // get on fridge light\r
+                try {\r
+                    boolean lightOn = representation.getValue(StringConstants.ON);\r
+                    logMessage(TAG + "The fridge light is " +\r
+                            (lightOn ? "" : "not " + "on"));\r
+                } catch (OcException e) {\r
+                    Log.e(TAG, e.getMessage());\r
+                }\r
+                break;\r
+            case 2:\r
+            case 3:\r
+                // get on fridge door(s)\r
+                try {\r
+                    boolean doorOpen = representation.getValue(StringConstants.OPEN);\r
+                    logMessage(TAG + "Door is " + (doorOpen ?\r
+                            "open" : "not open") + " and is on the " +\r
+                            representation.getValue(StringConstants.SIDE) + " side");\r
+                } catch (OcException e) {\r
+                    Log.e(TAG, e.getMessage());\r
+                }\r
+                break;\r
+            case 4:\r
+                // get on fridge random door\r
+                try {\r
+                    logMessage("Name of fridge: " +\r
+                            representation.getValue(StringConstants.DEVICE_NAME));\r
+                } catch (OcException e) {\r
+                    Log.e(TAG, e.getMessage());\r
+                }\r
+                break;\r
+            default:\r
+                logMessage("Unexpected State");\r
+                break;\r
+        }\r
+    }\r
+\r
+    /**\r
+     * this method is used to wait for 1 second between calls to different resources.\r
+     * It is added for better readability\r
+     */\r
+    private void doWait() {\r
+        try {\r
+            Thread.sleep(StringConstants.WAIT_TIME);\r
+        } catch (InterruptedException e) {\r
+            logMessage(TAG + "doWait exception: " + e.getMessage());\r
+            Log.e(TAG, e.getMessage());\r
+        }\r
+    }\r
+\r
+    @Override\r
+    /**\r
+     *  callback when a resource is found. This method calls getResponse with the correct code\r
+     */\r
+    synchronized public void onResourceFound(OcResource ocResource) {\r
+        // eventHandler for onGetListener\r
+        resourceList.add(ocResource);\r
+        OcResource.OnGetListener onGetListener = new OcResource.OnGetListener() {\r
+            @Override\r
+            public void onGetCompleted(List<OcHeaderOption> headerOptionList, OcRepresentation rep) {\r
+                logMessage(TAG + " Got a response from " + getClientDeviceName());\r
+                getResponse(rep, getClientDeviceCode());\r
+            }\r
+\r
+            @Override\r
+            public void onGetFailed(Throwable throwable) {\r
+                if (throwable instanceof OcException) {\r
+                    OcException ocEx = (OcException) throwable;\r
+                    ErrorCode errCode = ocEx.getErrorCode();\r
+                    //do something based on errorCode\r
+                }\r
+                Log.e(TAG, throwable.toString());\r
+            }\r
+        };\r
+\r
+        if (ocResource.getUri().equals(StringConstants.RESOURCE_URI)) {\r
+            logMessage(TAG + "Discovered a device with \nHost: " + ocResource.getHost() +\r
+                    ", Uri: " + ocResource.getUri());\r
+        }\r
+        List<String> lightTypes = new LinkedList<>();\r
+        lightTypes.add("intel.fridge.light");\r
+        try {\r
+            OcResource light = OcPlatform.constructResourceObject(ocResource.getHost(),\r
+                    StringConstants.LIGHT, OcConnectivityType.WIFI, false, lightTypes, ifaces);\r
+\r
+            List<String> doorTypes = new LinkedList<>();\r
+            doorTypes.add("intel.fridge.door");\r
+            OcResource leftDoor = OcPlatform.constructResourceObject(ocResource.getHost(),\r
+                    StringConstants.LEFT_DOOR, OcConnectivityType.WIFI, false, doorTypes, ifaces);\r
+\r
+            OcResource rightDoor = OcPlatform.constructResourceObject(ocResource.getHost(),\r
+                    StringConstants.RIGHT_DOOR, OcConnectivityType.WIFI, false, doorTypes, ifaces);\r
+\r
+            OcResource randomDoor = OcPlatform.constructResourceObject(ocResource.getHost(),\r
+                    StringConstants.RANDOM_DOOR, OcConnectivityType.WIFI, false, doorTypes, ifaces);\r
+\r
+            List<OcHeaderOption> headerOptions = new LinkedList<>();\r
+            OcHeaderOption apiVersion = new OcHeaderOption(StringConstants.API_VERSION_KEY,\r
+                    StringConstants.API_VERSION);\r
+            OcHeaderOption clientToken = new OcHeaderOption(StringConstants.CLIENT_VERSION_KEY,\r
+                    StringConstants.CLIENT_TOKEN);\r
+            headerOptions.add(apiVersion);\r
+            headerOptions.add(clientToken);\r
+            ocResource.setHeaderOptions(headerOptions);\r
+            /**\r
+             *  wait for 1 second before calling get on different resources.\r
+             *  It is done for better readability.\r
+             *  doWait() is called before each call to get\r
+             */\r
+            doWait();\r
+\r
+            setupClientOptions("Device", 0);\r
+            ocResource.get(new HashMap<String, String>(), onGetListener);\r
+            doWait();\r
+\r
+            setupClientOptions("Fridge Light", 1);\r
+            light.get(new HashMap<String, String>(), onGetListener);\r
+            doWait();\r
+\r
+            setupClientOptions("Left Door", 2);\r
+            leftDoor.get(new HashMap<String, String>(), onGetListener);\r
+            doWait();\r
+\r
+            setupClientOptions("Right Door", 3);\r
+            rightDoor.get(new HashMap<String, String>(), onGetListener);\r
+            doWait();\r
+\r
+            setupClientOptions("Random Door", 4);\r
+            randomDoor.get(new HashMap<String, String>(), onGetListener);\r
+            doWait();\r
+\r
+            resourceList.add(leftDoor);\r
+            leftDoor.deleteResource(new OcResource.OnDeleteListener() {\r
+                @Override\r
+                public void onDeleteCompleted(List<OcHeaderOption> ocHeaderOptions) {\r
+                    logMessage(TAG + "Delete resource successful");\r
+                }\r
+\r
+                @Override\r
+                public void onDeleteFailed(Throwable throwable) {\r
+                    if (throwable instanceof OcException) {\r
+                        OcException ocEx = (OcException) throwable;\r
+                        ErrorCode errCode = ocEx.getErrorCode();\r
+                        //do something based on errorCode\r
+                    }\r
+                    Log.e(TAG, throwable.toString());\r
+                }\r
+            });\r
+        } catch (OcException e) {\r
+            logMessage(TAG + "onResourceFound Error. " + e.getMessage());\r
+            Log.e(TAG, e.getMessage());\r
+        }\r
+    }\r
+\r
+    @Override\r
+    protected void onCreate(Bundle savedInstanceState) {\r
+        super.onCreate(savedInstanceState);\r
+        setContentView(R.layout.activity_fridge_client);\r
+        registerReceiver(mMessageReceiver, new IntentFilter(StringConstants.INTENT));\r
+\r
+        mEventsTextView = new TextView(this);\r
+        mEventsTextView.setMovementMethod(new ScrollingMovementMethod());\r
+        LinearLayout layout = (LinearLayout) findViewById(R.id.linearLayout);\r
+        layout.addView(mEventsTextView, new LinearLayout.LayoutParams\r
+                (LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f));\r
+        ifaces = new LinkedList<>();\r
+        ifaces.add(StringConstants.RESOURCE_INTERFACE);\r
+        mDeviceCode = -1;\r
+        mDeviceName = "";\r
+\r
+        initOICStack();\r
+    }\r
+\r
+    public class MessageReceiver extends BroadcastReceiver {\r
+        @Override\r
+        public void onReceive(Context context, Intent intent) {\r
+            final String message = intent.getStringExtra(StringConstants.MESSAGE);\r
+            logMessage(message);\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public void logMessage(final String text) {\r
+        if (StringConstants.ENABLE_PRINTING) {\r
+            runOnUiThread(new Runnable() {\r
+                public void run() {\r
+                    final Message msg = new Message();\r
+                    msg.obj = text;\r
+                    mEventsTextView.append("\n");\r
+                    mEventsTextView.append(text);\r
+                }\r
+            });\r
+            Log.i(TAG, text);\r
+        }\r
+    }\r
+\r
+\r
+    private void setupClientOptions(String name, int value) {\r
+        mDeviceName = name;\r
+        mDeviceCode = value;\r
+    }\r
+\r
+    private String getClientDeviceName() {\r
+        return mDeviceName;\r
+    }\r
+\r
+    private int getClientDeviceCode() {\r
+        return mDeviceCode;\r
+    }\r
+\r
+\r
+    //method to print the headerOptions received from the server\r
+    void printHeaderOptions(List<OcHeaderOption> headerOptions) {\r
+        for (OcHeaderOption headerOption : headerOptions) {\r
+            if (StringConstants.API_VERSION_KEY == headerOption.getOptionId()) {\r
+                logMessage(TAG + "Server API version in GET response: " +\r
+                        headerOption.getOptionData());\r
+            }\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public boolean onCreateOptionsMenu(Menu menu) {\r
+        getMenuInflater().inflate(R.menu.menu_fridge_client, menu);\r
+        return true;\r
+    }\r
+\r
+    @Override\r
+    public boolean onOptionsItemSelected(MenuItem item) {\r
+        int id = item.getItemId();\r
+        if (id == R.id.action_settings) {\r
+            return true;\r
+        }\r
+        return super.onOptionsItemSelected(item);\r
+    }\r
+\r
+    @Override\r
+    public void onDestroy() {\r
+        super.onDestroy();\r
+        onStop();\r
+    }\r
+\r
+    @Override\r
+    protected void onStop() {\r
+        LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver);\r
+        super.onStop();\r
+    }\r
+}\r
diff --git a/android/examples/fridgeclient/src/main/java/org/iotivity/base/examples/fridgeclient/StringConstants.java b/android/examples/fridgeclient/src/main/java/org/iotivity/base/examples/fridgeclient/StringConstants.java
new file mode 100755 (executable)
index 0000000..da88e4d
--- /dev/null
@@ -0,0 +1,33 @@
+package org.iotivity.base.examples.fridgeclient;\r
+\r
+import org.iotivity.base.OcPlatform;\r
+\r
+/**\r
+ * StringConstant contains the fridgeclient specific constant values.  To add another supported\r
+ * Resource or Interface type to this app, begin by adding the new strings here, and then\r
+ * find the places throughout the app where Resource-specific case switches occur, and add\r
+ * the newly-supported type there.\r
+ */\r
+public interface StringConstants {\r
+    public static final String RESOURCE_URI = "/device";\r
+    public static final String DEVICE_NAME = "device_name";\r
+    public static final String LIGHT = "/light";\r
+    public static final String LEFT_DOOR = "/door/left";\r
+    public static final String RIGHT_DOOR = "/door/right";\r
+    public static final String RANDOM_DOOR = "/door/random";\r
+    public static final String MESSAGE = "message";\r
+    public static final String API_VERSION = "v.1.2";\r
+    public static final String CLIENT_TOKEN = "AaBbYyZz";\r
+    public static final String ON = "on";\r
+    public static final String OPEN = "open";\r
+    public static final String SIDE = "side";\r
+    public static final String INTENT = "org.iotivity.base.examples.fridgeclient";\r
+    public static final String RESOURCE_INTERFACE = OcPlatform.DEFAULT_INTERFACE;\r
+\r
+    public static final int WAIT_TIME = 1000;\r
+    public static final int API_VERSION_KEY = 2048;\r
+    public static final int CLIENT_VERSION_KEY = 3000;\r
+\r
+    public static final boolean ENABLE_PRINTING = true; // change to false to disable printing\r
+                                                        // of messages on the console and the screen\r
+}\r
diff --git a/android/examples/fridgeclient/src/main/res/layout/activity_fridge_client.xml b/android/examples/fridgeclient/src/main/res/layout/activity_fridge_client.xml
new file mode 100755 (executable)
index 0000000..d813c8a
--- /dev/null
@@ -0,0 +1,18 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
+    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"\r
+    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"\r
+    android:paddingRight="@dimen/activity_horizontal_margin"\r
+    android:paddingTop="@dimen/activity_vertical_margin"\r
+    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".FridgeClient">\r
+\r
+    <TextView android:text="@string/app_name" android:layout_width="wrap_content"\r
+        android:layout_height="wrap_content" />\r
+\r
+    <LinearLayout\r
+        android:layout_width="fill_parent"\r
+        android:layout_height="fill_parent"\r
+        android:orientation="vertical"\r
+        android:id="@+id/linearLayout" >\r
+    </LinearLayout>\r
+\r
+</RelativeLayout>\r
diff --git a/android/examples/fridgeclient/src/main/res/menu/menu_fridge_client.xml b/android/examples/fridgeclient/src/main/res/menu/menu_fridge_client.xml
new file mode 100755 (executable)
index 0000000..f812805
--- /dev/null
@@ -0,0 +1,6 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android"\r
+    xmlns:app="http://schemas.android.com/apk/res-auto"\r
+    xmlns:tools="http://schemas.android.com/tools" tools:context=".FridgeClient">\r
+    <item android:id="@+id/action_settings" android:title="@string/action_settings"\r
+        android:orderInCategory="100" app:showAsAction="never" />\r
+</menu>\r
old mode 100644 (file)
new mode 100755 (executable)
similarity index 98%
rename from android/SimpleClient/app/src/main/res/values-w820dp/dimens.xml
rename to android/examples/fridgeclient/src/main/res/values-w820dp/dimens.xml
index 63fc816..62df187
@@ -1,6 +1,6 @@
-<resources>
-    <!-- Example customization of dimensions originally defined in res/values/dimens.xml
-         (such as screen margins) for screens with more than 820dp of available width. This
-         would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
-    <dimen name="activity_horizontal_margin">64dp</dimen>
-</resources>
+<resources>\r
+    <!-- Example customization of dimensions originally defined in res/values/dimens.xml\r
+         (such as screen margins) for screens with more than 820dp of available width. This\r
+         would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->\r
+    <dimen name="activity_horizontal_margin">64dp</dimen>\r
+</resources>\r
old mode 100644 (file)
new mode 100755 (executable)
similarity index 97%
rename from android/SimpleClient/app/src/main/res/values/dimens.xml
rename to android/examples/fridgeclient/src/main/res/values/dimens.xml
index 47c8224..295b5a9
@@ -1,5 +1,5 @@
-<resources>
-    <!-- Default screen margins, per the Android Design guidelines. -->
-    <dimen name="activity_horizontal_margin">16dp</dimen>
-    <dimen name="activity_vertical_margin">16dp</dimen>
-</resources>
+<resources>\r
+    <!-- Default screen margins, per the Android Design guidelines. -->\r
+    <dimen name="activity_horizontal_margin">16dp</dimen>\r
+    <dimen name="activity_vertical_margin">16dp</dimen>\r
+</resources>\r
old mode 100644 (file)
new mode 100755 (executable)
similarity index 74%
rename from android/SimpleClient/app/src/main/res/values/strings.xml
rename to android/examples/fridgeclient/src/main/res/values/strings.xml
index 532e40d..152e2c9
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-
-    <string name="app_name">SimpleClient</string>
-    <string name="hello_world">Hello world!</string>
-    <string name="action_settings">Settings</string>
-
-</resources>
+<?xml version="1.0" encoding="utf-8"?>\r
+<resources>\r
+\r
+    <string name="app_name">FridgeClient</string>\r
+    <string name="hello_world">Hello world!</string>\r
+    <string name="action_settings">Settings</string>\r
+\r
+</resources>\r
old mode 100644 (file)
new mode 100755 (executable)
similarity index 59%
rename from android/Base/app/src/main/res/values/styles.xml
rename to android/examples/fridgeclient/src/main/res/values/styles.xml
index ff6c9d2..084b42b
@@ -1,8 +1,8 @@
-<resources>
-
-    <!-- Base application theme. -->
-    <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
-        <!-- Customize your theme here. -->
-    </style>
-
-</resources>
+<resources>\r
+\r
+    <!-- Base application theme. -->\r
+    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">\r
+        <!-- Customize your theme here. -->\r
+    </style>\r
+\r
+</resources>\r
diff --git a/android/examples/fridgeserver/.gitignore b/android/examples/fridgeserver/.gitignore
new file mode 100755 (executable)
index 0000000..3543521
--- /dev/null
@@ -0,0 +1 @@
+/build\r
diff --git a/android/examples/fridgeserver/build.gradle b/android/examples/fridgeserver/build.gradle
new file mode 100755 (executable)
index 0000000..b7327b6
--- /dev/null
@@ -0,0 +1,26 @@
+apply plugin: 'com.android.application'\r
+\r
+android {\r
+    compileSdkVersion 21\r
+    buildToolsVersion "21.1.2"\r
+\r
+    defaultConfig {\r
+        applicationId "org.iotivity.base.examples.fridgeserver"\r
+        minSdkVersion 19\r
+        targetSdkVersion 21\r
+        versionCode 1\r
+        versionName "1.0"\r
+    }\r
+    buildTypes {\r
+        release {\r
+            minifyEnabled false\r
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\r
+        }\r
+    }\r
+}\r
+\r
+dependencies {\r
+    compile fileTree(dir: 'libs', include: ['*.jar'])\r
+    compile 'com.android.support:appcompat-v7:21.0.3'\r
+    compile project(':message')\r
+}\r
diff --git a/android/examples/fridgeserver/fridgeserver.iml b/android/examples/fridgeserver/fridgeserver.iml
new file mode 100755 (executable)
index 0000000..65d2947
--- /dev/null
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="examples" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">\r
+  <component name="FacetManager">\r
+    <facet type="android-gradle" name="Android-Gradle">\r
+      <configuration>\r
+        <option name="GRADLE_PROJECT_PATH" value=":fridgeserver" />\r
+      </configuration>\r
+    </facet>\r
+    <facet type="android" name="Android">\r
+      <configuration>\r
+        <option name="SELECTED_BUILD_VARIANT" value="debug" />\r
+        <option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />\r
+        <option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />\r
+        <option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />\r
+        <option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />\r
+        <option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />\r
+        <option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugTestSources" />\r
+        <option name="ALLOW_USER_CONFIGURATION" value="false" />\r
+        <option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />\r
+        <option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />\r
+        <option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />\r
+        <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />\r
+      </configuration>\r
+    </facet>\r
+  </component>\r
+  <component name="NewModuleRootManager" inherit-compiler-output="false">\r
+    <output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />\r
+    <output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />\r
+    <exclude-output />\r
+    <content url="file://$MODULE_DIR$">\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/debug" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/test/debug" isTestSource="true" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/test/debug" isTestSource="true" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/test/debug" isTestSource="true" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/test/debug" isTestSource="true" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/test/debug" type="java-test-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/test/debug" type="java-test-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/outputs" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/tmp" />\r
+    </content>\r
+    <orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />\r
+    <orderEntry type="sourceFolder" forTests="false" />\r
+    <orderEntry type="library" exported="" name="iotivity-x86-base-debug-unspecified" level="project" />\r
+    <orderEntry type="library" exported="" name="appcompat-v7-21.0.3" level="project" />\r
+    <orderEntry type="library" exported="" name="support-annotations-21.0.3" level="project" />\r
+    <orderEntry type="library" exported="" name="support-v4-21.0.3" level="project" />\r
+    <orderEntry type="module" module-name="message" exported="" />\r
+  </component>\r
+</module>\r
+\r
diff --git a/android/examples/fridgeserver/src/main/AndroidManifest.xml b/android/examples/fridgeserver/src/main/AndroidManifest.xml
new file mode 100755 (executable)
index 0000000..cbcffd9
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"\r
+    xmlns:tools="http://schemas.android.com/tools"\r
+    package="org.iotivity.base.examples.fridgeserver">\r
+\r
+    <uses-sdk tools:overrideLibrary="org.iotivity.base"></uses-sdk>\r
+\r
+    <application\r
+        android:allowBackup="true"\r
+        android:icon="@drawable/ic_launcher"\r
+        android:label="@string/app_name"\r
+        android:theme="@style/AppTheme" >\r
+        <activity\r
+            android:name=".FridgeServer"\r
+            android:label="@string/app_name" >\r
+            <intent-filter>\r
+                <action android:name="android.intent.action.MAIN" />\r
+\r
+                <category android:name="android.intent.category.LAUNCHER" />\r
+            </intent-filter>\r
+        </activity>\r
+    </application>\r
+\r
+</manifest>\r
diff --git a/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DeviceResource.java b/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DeviceResource.java
new file mode 100755 (executable)
index 0000000..fc33258
--- /dev/null
@@ -0,0 +1,189 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base.examples.fridgeserver;\r
+\r
+import android.content.Context;\r
+import android.content.Intent;\r
+import android.util.Log;\r
+\r
+import org.iotivity.base.EntityHandlerResult;\r
+import org.iotivity.base.OcException;\r
+import org.iotivity.base.OcHeaderOption;\r
+import org.iotivity.base.OcPlatform;\r
+import org.iotivity.base.OcResourceRequest;\r
+import org.iotivity.base.OcResourceResponse;\r
+import org.iotivity.base.RequestHandlerFlag;\r
+import org.iotivity.base.ResourceProperty;\r
+\r
+import java.util.EnumSet;\r
+import java.util.LinkedList;\r
+import java.util.List;\r
+\r
+import base.iotivity.org.examples.message.IMessageLogger;\r
+\r
+/**\r
+ * DeviceResource\r
+ * <p/>\r
+ * Creates a device resource and performs action based on client requests\r
+ */\r
+public class DeviceResource extends Resource implements IMessageLogger {\r
+    private Context mContext;\r
+\r
+    private static String TAG = "DeviceResource: ";\r
+\r
+    /**\r
+     * constructor\r
+     *\r
+     * @param context to enable sending of broadcast messages to be displayed on the user screen\r
+     */\r
+    DeviceResource(Context context) {\r
+        mContext = context;\r
+\r
+        // eventHandler for register deviceResource\r
+        OcPlatform.EntityHandler eh = new OcPlatform.EntityHandler() {\r
+            @Override\r
+            public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) {\r
+                // this is where the main logic of DeviceResource is handled\r
+                return entityHandler(ocResourceRequest);\r
+            }\r
+        };\r
+\r
+        try {\r
+            logMessage(TAG + "RegisterDeviceResource " + StringConstants.DEVICE_URI + " : " +\r
+                    StringConstants.RESOURCE_TYPENAME + " : " + StringConstants.RESOURCE_INTERFACE);\r
+            mResourceHandle = OcPlatform.registerResource(StringConstants.DEVICE_URI,\r
+                    StringConstants.RESOURCE_TYPENAME, StringConstants.RESOURCE_INTERFACE,\r
+                    eh, EnumSet.of(ResourceProperty.DISCOVERABLE));\r
+        } catch (OcException e) {\r
+            logMessage(TAG + "registerResource error: " + e.getMessage());\r
+            Log.e(TAG, e.getMessage());\r
+        }\r
+    }\r
+\r
+    /**\r
+     * update current state of device\r
+     *\r
+     * @return device representation\r
+     */\r
+    private void updateRepresentationValues() {\r
+        try {\r
+            mRepresentation.setValue(StringConstants.DEVICE_NAME,\r
+                    "Intel Powered 2 door, 1 light refrigerator");\r
+        } catch (OcException e) {\r
+            Log.e(TAG, e.getMessage());\r
+        }\r
+    }\r
+\r
+    /**\r
+     * unregister the resource\r
+     */\r
+    private void deleteDeviceResource() {\r
+        try {\r
+            OcPlatform.unregisterResource(mResourceHandle);\r
+            logMessage(TAG + "Unregister DeviceResource successful");\r
+        } catch (OcException e) {\r
+            logMessage(TAG + e.getMessage());\r
+            Log.e(TAG, e.getMessage());\r
+        }\r
+    }\r
+\r
+    /**\r
+     * this is the main method which handles different incoming requests appropriately.\r
+     *\r
+     * @param request OcResourceRequest from the client\r
+     * @return EntityHandlerResult depending on whether the request was handled successfully or not\r
+     */\r
+    private EntityHandlerResult entityHandler(OcResourceRequest request) {\r
+        EntityHandlerResult result = EntityHandlerResult.ERROR;\r
+        if (null != request) {\r
+            List<OcHeaderOption> headerOptions = request.getHeaderOptions();\r
+            String clientAPIVersion = "";\r
+            String clientToken = "";\r
+\r
+            // search for header options map and look for API version and client token\r
+            for (OcHeaderOption headerOption : headerOptions) {\r
+                int optionId = headerOption.getOptionId();\r
+                if (StringConstants.API_VERSION_KEY == optionId) {\r
+                    clientAPIVersion = headerOption.getOptionData();\r
+                    logMessage(TAG + " Client API Version: " + clientAPIVersion);\r
+                } else if (StringConstants.CLIENT_VERSION_KEY == optionId) {\r
+                    clientToken = headerOption.getOptionData();\r
+                    logMessage(TAG + " Client Token: " + clientToken);\r
+                }\r
+            }\r
+            if (clientAPIVersion.equals(StringConstants.API_VERSION) &&\r
+                    clientToken.equals(StringConstants.CLIENT_TOKEN)) {\r
+                List<OcHeaderOption> serverHeaderOptions = new LinkedList<>();\r
+                OcHeaderOption apiVersion = new OcHeaderOption(StringConstants.API_VERSION_KEY,\r
+                        StringConstants.API_VERSION);\r
+                serverHeaderOptions.add(apiVersion);\r
+                try {\r
+                    if (request.getRequestHandlerFlagSet().contains(RequestHandlerFlag.REQUEST)) {\r
+                        OcResourceResponse response = new OcResourceResponse();\r
+                        response.setRequestHandle(request.getRequestHandle());\r
+                        response.setResourceHandle(request.getResourceHandle());\r
+                        response.setHeaderOptions(serverHeaderOptions);\r
+\r
+                        switch (request.getRequestType()) {\r
+                            case GET:\r
+                                response.setErrorCode(StringConstants.OK);\r
+                                response.setResponseResult(EntityHandlerResult.OK);\r
+                                updateRepresentationValues();\r
+                                response.setResourceRepresentation(mRepresentation);\r
+                                OcPlatform.sendResponse(response);\r
+                                break;\r
+                            case DELETE:\r
+                                deleteDeviceResource();\r
+                                response.setErrorCode(StringConstants.OK);\r
+                                response.setResponseResult(EntityHandlerResult.OK);\r
+                                break;\r
+                            case POST:\r
+                                response.setResponseResult(EntityHandlerResult.ERROR);\r
+                                OcPlatform.sendResponse(response);\r
+                                break;\r
+                        }\r
+                        result = EntityHandlerResult.OK;\r
+                    }\r
+                } catch (OcException e) {\r
+                    logMessage(TAG + e.getMessage());\r
+                    Log.e(TAG, e.getMessage());\r
+                }\r
+            }\r
+        }\r
+        return result;\r
+    }\r
+\r
+    @Override\r
+    public void logMessage(String msg) {\r
+        logMsg(msg);\r
+        if (StringConstants.ENABLE_PRINTING) {\r
+            Log.i(TAG, msg);\r
+        }\r
+    }\r
+\r
+    public void logMsg(final String text) {\r
+        Intent intent = new Intent(StringConstants.INTENT);\r
+        intent.putExtra("message", text);\r
+        mContext.sendBroadcast(intent);\r
+    }\r
+}\r
diff --git a/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DoorResource.java b/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DoorResource.java
new file mode 100755 (executable)
index 0000000..438022b
--- /dev/null
@@ -0,0 +1,178 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base.examples.fridgeserver;\r
+\r
+import android.content.Context;\r
+import android.content.Intent;\r
+import android.util.Log;\r
+\r
+import org.iotivity.base.EntityHandlerResult;\r
+import org.iotivity.base.OcException;\r
+import org.iotivity.base.OcPlatform;\r
+import org.iotivity.base.OcRepresentation;\r
+import org.iotivity.base.OcResourceRequest;\r
+import org.iotivity.base.OcResourceResponse;\r
+import org.iotivity.base.RequestHandlerFlag;\r
+import org.iotivity.base.ResourceProperty;\r
+\r
+import java.util.EnumSet;\r
+\r
+import base.iotivity.org.examples.message.IMessageLogger;\r
+\r
+/**\r
+ * DoorResource\r
+ * <p/>\r
+ * Creates a door resource and performs action based on client requests\r
+ */\r
+public class DoorResource extends Resource implements IMessageLogger {\r
+    private Context mContext;\r
+\r
+    private static String TAG = "DoorResource: ";\r
+    private String mSide = StringConstants.LEFT;\r
+    private boolean mOpen;\r
+    private String resourceURI;\r
+\r
+    /**\r
+     * Constructor\r
+     *\r
+     * @param side    left or right side of the door\r
+     * @param context to enable sending of broadcast messages to be displayed on the user screen\r
+     */\r
+    DoorResource(String side, Context context) {\r
+        mContext = context;\r
+        mSide = side;\r
+\r
+        resourceURI = StringConstants.DOOR_URI + mSide;\r
+\r
+        // eventHandler for register doorResource\r
+        OcPlatform.EntityHandler eh = new OcPlatform.EntityHandler() {\r
+            @Override\r
+            public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) {\r
+                // this is where the main logic of DoorResource is handled\r
+                return entityHandler(ocResourceRequest);\r
+            }\r
+        };\r
+        try {\r
+            logMessage(TAG + "RegisterDoorResource " + resourceURI + " : " +\r
+                    StringConstants.RESOURCE_TYPEDOOR + " : " + StringConstants.RESOURCE_INTERFACE);\r
+            mResourceHandle = OcPlatform.registerResource(resourceURI,\r
+                    StringConstants.RESOURCE_TYPEDOOR, StringConstants.RESOURCE_INTERFACE,\r
+                    eh, EnumSet.of(ResourceProperty.DISCOVERABLE));\r
+        } catch (OcException e) {\r
+            logMessage(TAG + "DoorResource registerResource error: " + e.getMessage());\r
+            Log.e(TAG, e.getMessage());\r
+        }\r
+    }\r
+\r
+    /**\r
+     * updates the current value of the door resource\r
+     *\r
+     * @return door representation\r
+     */\r
+    private void updateRepresentationValues() {\r
+        try {\r
+            mRepresentation.setValue(StringConstants.SIDE, mSide);\r
+            mRepresentation.setValue(StringConstants.OPEN, mOpen);\r
+            mRepresentation.setValue(StringConstants.DEVICE_NAME,\r
+                    "Intel Powered 2 door, 1 light refrigerator");\r
+        } catch (OcException e) {\r
+            Log.e(TAG, e.getMessage());\r
+        }\r
+    }\r
+\r
+    /**\r
+     * update the OPEN value of doorResource (door is open/ closed)\r
+     *\r
+     * @param representation get current state of door\r
+     */\r
+    private void put(OcRepresentation representation) {\r
+        try {\r
+            mOpen = representation.getValue(StringConstants.OPEN);\r
+        } catch (OcException e) {\r
+            Log.e(TAG, e.getMessage());\r
+        }\r
+        // Note, we won't let the user change the door side!\r
+    }\r
+\r
+    /**\r
+     * this is the main method which handles different incoming requests appropriately.\r
+     *\r
+     * @param request OcResourceRequest from the client\r
+     * @return EntityHandlerResult depending on whether the request was handled successfully or not\r
+     */\r
+    private EntityHandlerResult entityHandler(OcResourceRequest request) {\r
+        EntityHandlerResult result = EntityHandlerResult.ERROR;\r
+        if (null != request) {\r
+            try {\r
+                if (request.getRequestHandlerFlagSet().contains(RequestHandlerFlag.REQUEST)) {\r
+                    OcResourceResponse response = new OcResourceResponse();\r
+                    response.setRequestHandle(request.getRequestHandle());\r
+                    response.setResourceHandle(request.getResourceHandle());\r
+\r
+                    switch (request.getRequestType()) {\r
+                        case GET:\r
+                            response.setErrorCode(StringConstants.OK);\r
+                            updateRepresentationValues();\r
+                            response.setResourceRepresentation(mRepresentation);\r
+                            response.setResponseResult(EntityHandlerResult.OK);\r
+                            OcPlatform.sendResponse(response);\r
+                            break;\r
+                        case PUT:\r
+                            response.setErrorCode(StringConstants.OK);\r
+                            put(request.getResourceRepresentation());\r
+                            updateRepresentationValues();\r
+                            response.setResourceRepresentation(mRepresentation);\r
+                            response.setResponseResult(EntityHandlerResult.OK);\r
+                            OcPlatform.sendResponse(response);\r
+                            break;\r
+                        case DELETE:\r
+                            response.setResponseResult(EntityHandlerResult.RESOURCE_DELETED);\r
+                            response.setErrorCode(204);\r
+                            OcPlatform.sendResponse(response);\r
+                            break;\r
+                    }\r
+                    result = EntityHandlerResult.OK;\r
+                }\r
+            } catch (OcException e) {\r
+                logMessage(TAG + e.getMessage());\r
+                Log.e(TAG, e.getMessage());\r
+                return EntityHandlerResult.ERROR;\r
+            }\r
+        }\r
+        return result;\r
+    }\r
+\r
+    @Override\r
+    public void logMessage(String msg) {\r
+        logMsg(msg);\r
+        if (StringConstants.ENABLE_PRINTING) {\r
+            Log.i(TAG, msg);\r
+        }\r
+    }\r
+\r
+    public void logMsg(final String text) {\r
+        Intent intent = new Intent(StringConstants.INTENT);\r
+        intent.putExtra(StringConstants.MESSAGE, text);\r
+        mContext.sendBroadcast(intent);\r
+    }\r
+}\r
diff --git a/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/FridgeServer.java b/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/FridgeServer.java
new file mode 100755 (executable)
index 0000000..45971f7
--- /dev/null
@@ -0,0 +1,145 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base.examples.fridgeserver;\r
+\r
+import android.app.Activity;\r
+import android.content.BroadcastReceiver;\r
+import android.content.Context;\r
+import android.content.Intent;\r
+import android.content.IntentFilter;\r
+import android.os.Bundle;\r
+import android.os.Message;\r
+import android.support.v4.content.LocalBroadcastManager;\r
+import android.text.method.ScrollingMovementMethod;\r
+import android.util.Log;\r
+import android.view.Menu;\r
+import android.view.MenuItem;\r
+import android.widget.LinearLayout;\r
+import android.widget.TextView;\r
+\r
+import org.iotivity.base.ModeType;\r
+import org.iotivity.base.OcPlatform;\r
+import org.iotivity.base.PlatformConfig;\r
+import org.iotivity.base.QualityOfService;\r
+import org.iotivity.base.ServiceType;\r
+\r
+import base.iotivity.org.examples.message.IMessageLogger;\r
+\r
+/**\r
+ * FridgeServer\r
+ * <p/>\r
+ * This is the main fridgeServer class. This instantiates Refrigerator object\r
+ * which has different resources (DeviceResource, LightResource, DoorResource).\r
+ */\r
+public class FridgeServer extends Activity implements IMessageLogger {\r
+    private Context mContext;\r
+    private static String TAG = "FridgeServer: ";\r
+    private TextView mEventsTextView;\r
+    private MessageReceiver mMessageReceiver = new MessageReceiver();\r
+    private Refrigerator refrigerator;\r
+\r
+    /**\r
+     * configure OIC platform and call findResource\r
+     */\r
+    private void initOICStack() {\r
+        //create platform config\r
+        PlatformConfig cfg = new PlatformConfig(\r
+                this,\r
+                ServiceType.IN_PROC,\r
+                ModeType.SERVER,\r
+                "0.0.0.0", // bind to all available interfaces\r
+                0,\r
+                QualityOfService.LOW);\r
+        OcPlatform.Configure(cfg);\r
+        logMessage(TAG + "Creating refrigerator resources");\r
+\r
+        refrigerator = new Refrigerator(mContext);\r
+    }\r
+\r
+    @Override\r
+    protected void onCreate(Bundle savedInstanceState) {\r
+        super.onCreate(savedInstanceState);\r
+        setContentView(R.layout.activity_fridge_server);\r
+        registerReceiver(mMessageReceiver, new IntentFilter(StringConstants.INTENT));\r
+\r
+        mEventsTextView = new TextView(this);\r
+        mEventsTextView.setMovementMethod(new ScrollingMovementMethod());\r
+        LinearLayout layout = (LinearLayout) findViewById(R.id.linearLayout);\r
+        layout.addView(mEventsTextView, new LinearLayout.LayoutParams\r
+                (LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f));\r
+        mContext = this;\r
+\r
+        initOICStack();\r
+    }\r
+\r
+    public class MessageReceiver extends BroadcastReceiver {\r
+        @Override\r
+        public void onReceive(Context context, Intent intent) {\r
+            final String message = intent.getStringExtra(StringConstants.MESSAGE);\r
+            logMessage(message);\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public void logMessage(final String text) {\r
+        if (StringConstants.ENABLE_PRINTING) {\r
+            runOnUiThread(new Runnable() {\r
+                public void run() {\r
+                    final Message msg = new Message();\r
+                    msg.obj = text;\r
+                    mEventsTextView.append("\n");\r
+                    mEventsTextView.append(text);\r
+                }\r
+            });\r
+            Log.i(TAG, text);\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public boolean onCreateOptionsMenu(Menu menu) {\r
+        // Inflate the menu; this adds items to the action bar if it is present.\r
+        getMenuInflater().inflate(R.menu.menu_fridge_server, menu);\r
+        return true;\r
+    }\r
+\r
+    @Override\r
+    public boolean onOptionsItemSelected(MenuItem item) {\r
+        int id = item.getItemId();\r
+        if (id == R.id.action_settings) {\r
+            return true;\r
+        }\r
+        return super.onOptionsItemSelected(item);\r
+    }\r
+\r
+    @Override\r
+    public void onDestroy() {\r
+        super.onDestroy();\r
+        onStop();\r
+    }\r
+\r
+    @Override\r
+    protected void onStop() {\r
+        LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver);\r
+        super.onStop();\r
+    }\r
+}\r
diff --git a/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/LightResource.java b/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/LightResource.java
new file mode 100755 (executable)
index 0000000..09b7f43
--- /dev/null
@@ -0,0 +1,164 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base.examples.fridgeserver;\r
+\r
+import android.content.Context;\r
+import android.content.Intent;\r
+import android.util.Log;\r
+\r
+import org.iotivity.base.EntityHandlerResult;\r
+import org.iotivity.base.OcException;\r
+import org.iotivity.base.OcPlatform;\r
+import org.iotivity.base.OcRepresentation;\r
+import org.iotivity.base.OcResourceRequest;\r
+import org.iotivity.base.OcResourceResponse;\r
+import org.iotivity.base.RequestHandlerFlag;\r
+import org.iotivity.base.ResourceProperty;\r
+\r
+import java.util.EnumSet;\r
+\r
+import base.iotivity.org.examples.message.IMessageLogger;\r
+\r
+/**\r
+ * LightResource\r
+ * <p/>\r
+ * Creates a light resource and performs action based on client requests\r
+ */\r
+public class LightResource extends Resource implements IMessageLogger {\r
+    private Context mContext;\r
+\r
+    private static String TAG = "LightResource: ";\r
+\r
+    private boolean mIsOn = false;\r
+\r
+    /**\r
+     * constructor\r
+     *\r
+     * @param context to enable sending of broadcast messages to be displayed on the user screen\r
+     */\r
+    LightResource(Context context) {\r
+        mContext = context;\r
+        //eventHandler for register lightResource\r
+        OcPlatform.EntityHandler eh = new OcPlatform.EntityHandler() {\r
+            @Override\r
+            public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) {\r
+                // this is where the main logic of LightResource is handled\r
+                return entityHandler(ocResourceRequest);\r
+            }\r
+        };\r
+        try {\r
+            logMessage(TAG + "RegisterLightResource " + StringConstants.LIGHT_URI + " : " +\r
+                    StringConstants.RESOURCE_TYPELIGHT + " : " + StringConstants.RESOURCE_INTERFACE);\r
+            mResourceHandle = OcPlatform.registerResource(StringConstants.LIGHT_URI,\r
+                    StringConstants.RESOURCE_TYPELIGHT, StringConstants.RESOURCE_INTERFACE,\r
+                    eh, EnumSet.of(ResourceProperty.DISCOVERABLE));\r
+        } catch (OcException e) {\r
+            logMessage(TAG + "LightResource registerResource error: " + e.getMessage());\r
+            Log.e(TAG, e.getMessage());\r
+        }\r
+    }\r
+\r
+    /**\r
+     * updates the current state of the light (on/ off)\r
+     *\r
+     * @return light is on or off\r
+     */\r
+    private void updateRepresentationValues() {\r
+        try {\r
+            mRepresentation.setValue(StringConstants.ON, mIsOn);\r
+        } catch (OcException e) {\r
+            Log.e(TAG, e.getMessage());\r
+        }\r
+    }\r
+\r
+    /**\r
+     * update the value of mIsOn from the representation\r
+     *\r
+     * @param representation get current state of light\r
+     */\r
+    private void put(OcRepresentation representation) {\r
+        try {\r
+            mIsOn = representation.getValue(StringConstants.ON);\r
+        } catch (OcException e) {\r
+            Log.e(TAG, e.getMessage());\r
+        }\r
+    }\r
+\r
+    /**\r
+     * this is the main method which handles different incoming requests appropriately.\r
+     *\r
+     * @param request OcResourceRequest from the client\r
+     * @return EntityHandlerResult depending on whether the request was handled successfully or not\r
+     */\r
+    private EntityHandlerResult entityHandler(OcResourceRequest request) {\r
+        EntityHandlerResult result = EntityHandlerResult.ERROR;\r
+        if (null != request) {\r
+            try {\r
+                if (request.getRequestHandlerFlagSet().contains(RequestHandlerFlag.REQUEST)) {\r
+                    OcResourceResponse response = new OcResourceResponse();\r
+                    response.setRequestHandle(request.getRequestHandle());\r
+                    response.setResourceHandle(request.getResourceHandle());\r
+\r
+                    switch (request.getRequestType()) {\r
+                        case GET:\r
+                            response.setErrorCode(StringConstants.OK);\r
+                            updateRepresentationValues();\r
+                            response.setResourceRepresentation(mRepresentation);\r
+                            response.setResponseResult(EntityHandlerResult.OK);\r
+                            OcPlatform.sendResponse(response);\r
+                            result = EntityHandlerResult.OK;\r
+                            break;\r
+                        case PUT:\r
+                            response.setErrorCode(StringConstants.OK);\r
+                            put(request.getResourceRepresentation());\r
+                            updateRepresentationValues();\r
+                            response.setResourceRepresentation(mRepresentation);\r
+                            response.setResponseResult(EntityHandlerResult.OK);\r
+                            OcPlatform.sendResponse(response);\r
+                            result = EntityHandlerResult.OK;\r
+                            break;\r
+                    }\r
+                }\r
+            } catch (OcException e) {\r
+                logMessage(TAG + e.getMessage());\r
+                Log.e(TAG, e.getMessage());\r
+                return EntityHandlerResult.ERROR;\r
+            }\r
+        }\r
+        return result;\r
+    }\r
+\r
+    @Override\r
+    public void logMessage(String msg) {\r
+        logMsg(msg);\r
+        if (StringConstants.ENABLE_PRINTING) {\r
+            Log.i(TAG, msg);\r
+        }\r
+    }\r
+\r
+    public void logMsg(final String text) {\r
+        Intent intent = new Intent(StringConstants.INTENT);\r
+        intent.putExtra(StringConstants.MESSAGE, text);\r
+        mContext.sendBroadcast(intent);\r
+    }\r
+}\r
diff --git a/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Refrigerator.java b/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Refrigerator.java
new file mode 100755 (executable)
index 0000000..4432755
--- /dev/null
@@ -0,0 +1,57 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base.examples.fridgeserver;\r
+\r
+import android.content.Context;\r
+\r
+/**\r
+ * Refrigerator\r
+ * <p/>\r
+ * Refrigerator class has different objects (resources) which are instantiated when a\r
+ * Refrigerator object is created. Operations are performed on each of the individual resources.\r
+ */\r
+public class Refrigerator {\r
+    private Context mContext;\r
+\r
+    private LightResource mLight;\r
+    private DeviceResource mDevice;\r
+    private DoorResource mLeftDoor;\r
+    private DoorResource mRightDoor;\r
+    private DoorResource mRandomDoor;\r
+\r
+    /**\r
+     * constructor\r
+     *\r
+     * @param context needed by individual resources to be able to send broadcast\r
+     *                messages to be displayed on the user screen\r
+     */\r
+    Refrigerator(Context context) {\r
+        mContext = context;\r
+        mLight = new LightResource(context);\r
+        mDevice = new DeviceResource(context);\r
+        mLeftDoor = new DoorResource(StringConstants.LEFT, context);\r
+        mRightDoor = new DoorResource(StringConstants.RIGHT, context);\r
+        mRandomDoor = new DoorResource(StringConstants.RANDOM, context);\r
+    }\r
+\r
+}\r
diff --git a/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Resource.java b/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Resource.java
new file mode 100755 (executable)
index 0000000..350cee0
--- /dev/null
@@ -0,0 +1,41 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base.examples.fridgeserver;\r
+\r
+import org.iotivity.base.OcRepresentation;\r
+import org.iotivity.base.OcResourceHandle;\r
+\r
+/**\r
+ * Resource\r
+ * <p/>\r
+ * Each of the other resource classes (DeviceResource, DoorResource and LightResource extend Resource\r
+ */\r
+public class Resource {\r
+    protected OcResourceHandle mResourceHandle;\r
+    protected OcRepresentation mRepresentation;\r
+\r
+    Resource() {\r
+        mResourceHandle = null;\r
+        mRepresentation = new OcRepresentation();\r
+    }\r
+}
\ No newline at end of file
diff --git a/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/StringConstants.java b/android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/StringConstants.java
new file mode 100755 (executable)
index 0000000..1afe25b
--- /dev/null
@@ -0,0 +1,37 @@
+package org.iotivity.base.examples.fridgeserver;\r
+\r
+import org.iotivity.base.OcPlatform;\r
+\r
+/**\r
+ * StringConstant contains the fridgeserver specific constant values.  To add another supported\r
+ * Resource or Interface type to this app, begin by adding the new strings here, and then\r
+ * find the places throughout the app where Resource-specific case switches occur, and add\r
+ * the newly-supported type there.\r
+ */\r
+public interface StringConstants {\r
+    public static final String DEVICE_URI = "/device";\r
+    public static final String LIGHT_URI = "/light";\r
+    public static final String DOOR_URI = "/door/";\r
+    public static final String DEVICE_NAME = "device_name";\r
+    public static final String RESOURCE_TYPENAME = "intel.fridge";\r
+    public static final String RESOURCE_TYPEDOOR = "intel.fridge.door";\r
+    public static final String RESOURCE_TYPELIGHT = "intel.fridge.light";\r
+    public static final String API_VERSION = "v.1.2";\r
+    public static final String CLIENT_TOKEN = "AaBbYyZz";\r
+    public static final String SIDE = "side";\r
+    public static final String OPEN = "open";\r
+    public static final String MESSAGE = "message";\r
+    public static final String LEFT = "left";\r
+    public static final String RIGHT = "right";\r
+    public static final String RANDOM = "random";\r
+    public static final String ON = "on";\r
+    public static final String INTENT = "org.iotivity.base.examples.fridgeserver";\r
+    public static final String RESOURCE_INTERFACE = OcPlatform.DEFAULT_INTERFACE;\r
+\r
+    public static final int API_VERSION_KEY = 2048;\r
+    public static final int CLIENT_VERSION_KEY = 3000;\r
+    public static final int OK = 200;\r
+\r
+    public static final boolean ENABLE_PRINTING = true; // change to false to disable printing\r
+                                                        // of messages on the console and the screen\r
+}\r
diff --git a/android/examples/fridgeserver/src/main/res/layout/activity_fridge_server.xml b/android/examples/fridgeserver/src/main/res/layout/activity_fridge_server.xml
new file mode 100755 (executable)
index 0000000..39362b3
--- /dev/null
@@ -0,0 +1,18 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
+    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"\r
+    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"\r
+    android:paddingRight="@dimen/activity_horizontal_margin"\r
+    android:paddingTop="@dimen/activity_vertical_margin"\r
+    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".FridgeServer">\r
+\r
+    <TextView android:text="@string/app_name" android:layout_width="wrap_content"\r
+        android:layout_height="wrap_content" />\r
+\r
+    <LinearLayout\r
+        android:layout_width="fill_parent"\r
+        android:layout_height="fill_parent"\r
+        android:orientation="vertical"\r
+        android:id="@+id/linearLayout" >\r
+    </LinearLayout>\r
+\r
+</RelativeLayout>\r
diff --git a/android/examples/fridgeserver/src/main/res/menu/menu_fridge_server.xml b/android/examples/fridgeserver/src/main/res/menu/menu_fridge_server.xml
new file mode 100755 (executable)
index 0000000..2895144
--- /dev/null
@@ -0,0 +1,6 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android"\r
+    xmlns:app="http://schemas.android.com/apk/res-auto"\r
+    xmlns:tools="http://schemas.android.com/tools" tools:context=".FridgeServer">\r
+    <item android:id="@+id/action_settings" android:title="@string/action_settings"\r
+        android:orderInCategory="100" app:showAsAction="never" />\r
+</menu>\r
diff --git a/android/examples/fridgeserver/src/main/res/values-w820dp/dimens.xml b/android/examples/fridgeserver/src/main/res/values-w820dp/dimens.xml
new file mode 100755 (executable)
index 0000000..62df187
--- /dev/null
@@ -0,0 +1,6 @@
+<resources>\r
+    <!-- Example customization of dimensions originally defined in res/values/dimens.xml\r
+         (such as screen margins) for screens with more than 820dp of available width. This\r
+         would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->\r
+    <dimen name="activity_horizontal_margin">64dp</dimen>\r
+</resources>\r
diff --git a/android/examples/fridgeserver/src/main/res/values/dimens.xml b/android/examples/fridgeserver/src/main/res/values/dimens.xml
new file mode 100755 (executable)
index 0000000..295b5a9
--- /dev/null
@@ -0,0 +1,5 @@
+<resources>\r
+    <!-- Default screen margins, per the Android Design guidelines. -->\r
+    <dimen name="activity_horizontal_margin">16dp</dimen>\r
+    <dimen name="activity_vertical_margin">16dp</dimen>\r
+</resources>\r
diff --git a/android/examples/fridgeserver/src/main/res/values/strings.xml b/android/examples/fridgeserver/src/main/res/values/strings.xml
new file mode 100755 (executable)
index 0000000..3e317da
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<resources>\r
+\r
+    <string name="app_name">FridgeServer</string>\r
+    <string name="hello_world">Hello world!</string>\r
+    <string name="action_settings">Settings</string>\r
+\r
+</resources>\r
old mode 100644 (file)
new mode 100755 (executable)
similarity index 59%
rename from android/SimpleClient/app/src/main/res/values/styles.xml
rename to android/examples/fridgeserver/src/main/res/values/styles.xml
index ff6c9d2..084b42b
@@ -1,8 +1,8 @@
-<resources>
-
-    <!-- Base application theme. -->
-    <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
-        <!-- Customize your theme here. -->
-    </style>
-
-</resources>
+<resources>\r
+\r
+    <!-- Base application theme. -->\r
+    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">\r
+        <!-- Customize your theme here. -->\r
+    </style>\r
+\r
+</resources>\r
diff --git a/android/examples/gradle/wrapper/gradle-wrapper.jar b/android/examples/gradle/wrapper/gradle-wrapper.jar
new file mode 100755 (executable)
index 0000000..8c0fb64
Binary files /dev/null and b/android/examples/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/android/examples/gradle/wrapper/gradle-wrapper.properties b/android/examples/gradle/wrapper/gradle-wrapper.properties
new file mode 100755 (executable)
index 0000000..cdc433f
--- /dev/null
@@ -0,0 +1,6 @@
+#Wed Apr 10 15:27:10 PDT 2013\r
+distributionBase=GRADLE_USER_HOME\r
+distributionPath=wrapper/dists\r
+zipStoreBase=GRADLE_USER_HOME\r
+zipStorePath=wrapper/dists\r
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip\r
similarity index 96%
rename from android/SimpleClient/gradlew
rename to android/examples/gradlew
index 91a7e26..583ae08 100755 (executable)
-#!/usr/bin/env bash
-
-##############################################################################
-##
-##  Gradle start up script for UN*X
-##
-##############################################################################
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn ( ) {
-    echo "$*"
-}
-
-die ( ) {
-    echo
-    echo "$*"
-    echo
-    exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-case "`uname`" in
-  CYGWIN* )
-    cygwin=true
-    ;;
-  Darwin* )
-    darwin=true
-    ;;
-  MINGW* )
-    msys=true
-    ;;
-esac
-
-# For Cygwin, ensure paths are in UNIX format before anything is touched.
-if $cygwin ; then
-    [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
-fi
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
-    ls=`ls -ld "$PRG"`
-    link=`expr "$ls" : '.*-> \(.*\)$'`
-    if expr "$link" : '/.*' > /dev/null; then
-        PRG="$link"
-    else
-        PRG=`dirname "$PRG"`"/$link"
-    fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >&-
-APP_HOME="`pwd -P`"
-cd "$SAVED" >&-
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
-    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
-        # IBM's JDK on AIX uses strange locations for the executables
-        JAVACMD="$JAVA_HOME/jre/sh/java"
-    else
-        JAVACMD="$JAVA_HOME/bin/java"
-    fi
-    if [ ! -x "$JAVACMD" ] ; then
-        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-    fi
-else
-    JAVACMD="java"
-    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
-    MAX_FD_LIMIT=`ulimit -H -n`
-    if [ $? -eq 0 ] ; then
-        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
-            MAX_FD="$MAX_FD_LIMIT"
-        fi
-        ulimit -n $MAX_FD
-        if [ $? -ne 0 ] ; then
-            warn "Could not set maximum file descriptor limit: $MAX_FD"
-        fi
-    else
-        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
-    fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
-    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
-    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
-    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
-
-    # We build the pattern for arguments to be converted via cygpath
-    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
-    SEP=""
-    for dir in $ROOTDIRSRAW ; do
-        ROOTDIRS="$ROOTDIRS$SEP$dir"
-        SEP="|"
-    done
-    OURCYGPATTERN="(^($ROOTDIRS))"
-    # Add a user-defined pattern to the cygpath arguments
-    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
-        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
-    fi
-    # Now convert the arguments - kludge to limit ourselves to /bin/sh
-    i=0
-    for arg in "$@" ; do
-        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
-        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
-
-        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
-            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
-        else
-            eval `echo args$i`="\"$arg\""
-        fi
-        i=$((i+1))
-    done
-    case $i in
-        (0) set -- ;;
-        (1) set -- "$args0" ;;
-        (2) set -- "$args0" "$args1" ;;
-        (3) set -- "$args0" "$args1" "$args2" ;;
-        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
-        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
-        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
-        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
-        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
-        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
-    esac
-fi
-
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
-    JVM_OPTS=("$@")
-}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
-
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
+#!/usr/bin/env bash\r
+\r
+##############################################################################\r
+##\r
+##  Gradle start up script for UN*X\r
+##\r
+##############################################################################\r
+\r
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\r
+DEFAULT_JVM_OPTS=""\r
+\r
+APP_NAME="Gradle"\r
+APP_BASE_NAME=`basename "$0"`\r
+\r
+# Use the maximum available, or set MAX_FD != -1 to use that value.\r
+MAX_FD="maximum"\r
+\r
+warn ( ) {\r
+    echo "$*"\r
+}\r
+\r
+die ( ) {\r
+    echo\r
+    echo "$*"\r
+    echo\r
+    exit 1\r
+}\r
+\r
+# OS specific support (must be 'true' or 'false').\r
+cygwin=false\r
+msys=false\r
+darwin=false\r
+case "`uname`" in\r
+  CYGWIN* )\r
+    cygwin=true\r
+    ;;\r
+  Darwin* )\r
+    darwin=true\r
+    ;;\r
+  MINGW* )\r
+    msys=true\r
+    ;;\r
+esac\r
+\r
+# For Cygwin, ensure paths are in UNIX format before anything is touched.\r
+if $cygwin ; then\r
+    [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`\r
+fi\r
+\r
+# Attempt to set APP_HOME\r
+# Resolve links: $0 may be a link\r
+PRG="$0"\r
+# Need this for relative symlinks.\r
+while [ -h "$PRG" ] ; do\r
+    ls=`ls -ld "$PRG"`\r
+    link=`expr "$ls" : '.*-> \(.*\)$'`\r
+    if expr "$link" : '/.*' > /dev/null; then\r
+        PRG="$link"\r
+    else\r
+        PRG=`dirname "$PRG"`"/$link"\r
+    fi\r
+done\r
+SAVED="`pwd`"\r
+cd "`dirname \"$PRG\"`/" >&-\r
+APP_HOME="`pwd -P`"\r
+cd "$SAVED" >&-\r
+\r
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar\r
+\r
+# Determine the Java command to use to start the JVM.\r
+if [ -n "$JAVA_HOME" ] ; then\r
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then\r
+        # IBM's JDK on AIX uses strange locations for the executables\r
+        JAVACMD="$JAVA_HOME/jre/sh/java"\r
+    else\r
+        JAVACMD="$JAVA_HOME/bin/java"\r
+    fi\r
+    if [ ! -x "$JAVACMD" ] ; then\r
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME\r
+\r
+Please set the JAVA_HOME variable in your environment to match the\r
+location of your Java installation."\r
+    fi\r
+else\r
+    JAVACMD="java"\r
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\r
+\r
+Please set the JAVA_HOME variable in your environment to match the\r
+location of your Java installation."\r
+fi\r
+\r
+# Increase the maximum file descriptors if we can.\r
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then\r
+    MAX_FD_LIMIT=`ulimit -H -n`\r
+    if [ $? -eq 0 ] ; then\r
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then\r
+            MAX_FD="$MAX_FD_LIMIT"\r
+        fi\r
+        ulimit -n $MAX_FD\r
+        if [ $? -ne 0 ] ; then\r
+            warn "Could not set maximum file descriptor limit: $MAX_FD"\r
+        fi\r
+    else\r
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"\r
+    fi\r
+fi\r
+\r
+# For Darwin, add options to specify how the application appears in the dock\r
+if $darwin; then\r
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""\r
+fi\r
+\r
+# For Cygwin, switch paths to Windows format before running java\r
+if $cygwin ; then\r
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`\r
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`\r
+\r
+    # We build the pattern for arguments to be converted via cygpath\r
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`\r
+    SEP=""\r
+    for dir in $ROOTDIRSRAW ; do\r
+        ROOTDIRS="$ROOTDIRS$SEP$dir"\r
+        SEP="|"\r
+    done\r
+    OURCYGPATTERN="(^($ROOTDIRS))"\r
+    # Add a user-defined pattern to the cygpath arguments\r
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then\r
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"\r
+    fi\r
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh\r
+    i=0\r
+    for arg in "$@" ; do\r
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`\r
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option\r
+\r
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition\r
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`\r
+        else\r
+            eval `echo args$i`="\"$arg\""\r
+        fi\r
+        i=$((i+1))\r
+    done\r
+    case $i in\r
+        (0) set -- ;;\r
+        (1) set -- "$args0" ;;\r
+        (2) set -- "$args0" "$args1" ;;\r
+        (3) set -- "$args0" "$args1" "$args2" ;;\r
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;\r
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;\r
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;\r
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;\r
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;\r
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;\r
+    esac\r
+fi\r
+\r
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules\r
+function splitJvmOpts() {\r
+    JVM_OPTS=("$@")\r
+}\r
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS\r
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"\r
+\r
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"\r
old mode 100644 (file)
new mode 100755 (executable)
similarity index 100%
rename from android/Base/gradlew.bat
rename to android/examples/gradlew.bat
diff --git a/android/examples/message/.gitignore b/android/examples/message/.gitignore
new file mode 100755 (executable)
index 0000000..1a94a02
--- /dev/null
@@ -0,0 +1,3 @@
+/build\r
+\r
+src/main/res
\ No newline at end of file
diff --git a/android/examples/message/build.gradle b/android/examples/message/build.gradle
new file mode 100755 (executable)
index 0000000..1ed1a39
--- /dev/null
@@ -0,0 +1,24 @@
+apply plugin: 'com.android.library'\r
+\r
+android {\r
+    compileSdkVersion 21\r
+    buildToolsVersion "21.1.2"\r
+\r
+    defaultConfig {\r
+        minSdkVersion 19\r
+        targetSdkVersion 21\r
+        versionCode 1\r
+        versionName "1.0"\r
+    }\r
+    buildTypes {\r
+        release {\r
+            minifyEnabled false\r
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\r
+        }\r
+    }\r
+}\r
+\r
+dependencies {\r
+    compile fileTree(dir: 'libs', include: ['*.jar'])\r
+    compile 'com.android.support:appcompat-v7:21.0.3'\r
+}\r
diff --git a/android/examples/message/message.iml b/android/examples/message/message.iml
new file mode 100755 (executable)
index 0000000..e9cabc1
--- /dev/null
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="examples" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">\r
+  <component name="FacetManager">\r
+    <facet type="android-gradle" name="Android-Gradle">\r
+      <configuration>\r
+        <option name="GRADLE_PROJECT_PATH" value=":message" />\r
+      </configuration>\r
+    </facet>\r
+    <facet type="android" name="Android">\r
+      <configuration>\r
+        <option name="SELECTED_BUILD_VARIANT" value="debug" />\r
+        <option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />\r
+        <option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />\r
+        <option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />\r
+        <option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />\r
+        <option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />\r
+        <option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugTestSources" />\r
+        <option name="ALLOW_USER_CONFIGURATION" value="false" />\r
+        <option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />\r
+        <option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />\r
+        <option name="RES_FOLDERS_RELATIVE_PATH" value="" />\r
+        <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />\r
+        <option name="LIBRARY_PROJECT" value="true" />\r
+      </configuration>\r
+    </facet>\r
+  </component>\r
+  <component name="NewModuleRootManager" inherit-compiler-output="false">\r
+    <output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />\r
+    <output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />\r
+    <exclude-output />\r
+    <content url="file://$MODULE_DIR$">\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/debug" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/test/debug" isTestSource="true" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/test/debug" isTestSource="true" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/test/debug" isTestSource="true" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/test/debug" isTestSource="true" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/test/debug" type="java-test-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/test/debug" type="java-test-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/outputs" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/tmp" />\r
+    </content>\r
+    <orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />\r
+    <orderEntry type="sourceFolder" forTests="false" />\r
+    <orderEntry type="library" exported="" name="appcompat-v7-21.0.3" level="project" />\r
+    <orderEntry type="library" exported="" name="support-annotations-21.0.3" level="project" />\r
+    <orderEntry type="library" exported="" name="support-v4-21.0.3" level="project" />\r
+  </component>\r
+</module>\r
+\r
diff --git a/android/examples/message/src/main/AndroidManifest.xml b/android/examples/message/src/main/AndroidManifest.xml
new file mode 100755 (executable)
index 0000000..9922f58
--- /dev/null
@@ -0,0 +1,9 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"\r
+    package="base.iotivity.org.examples.message"\r
+    xmlns:tools="http://schemas.android.com/tools">\r
+\r
+    <uses-sdk tools:overrideLibrary="org.iotivity.base"></uses-sdk>\r
+\r
+    <application android:allowBackup="true" ></application>\r
+\r
+</manifest>\r
diff --git a/android/examples/message/src/main/java/base/iotivity/org/examples/message/IMessageLogger.java b/android/examples/message/src/main/java/base/iotivity/org/examples/message/IMessageLogger.java
new file mode 100755 (executable)
index 0000000..7ecd6b3
--- /dev/null
@@ -0,0 +1,27 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package base.iotivity.org.examples.message;\r
+\r
+public interface IMessageLogger {\r
+    public void logMessage(String msg);\r
+}\r
diff --git a/android/examples/settings.gradle b/android/examples/settings.gradle
new file mode 100755 (executable)
index 0000000..bf2b78b
--- /dev/null
@@ -0,0 +1 @@
+include ':simpleserver', ':simpleclient', ':message', ':fridgeserver', ':fridgeclient'
\ No newline at end of file
diff --git a/android/examples/simpleclient/.gitignore b/android/examples/simpleclient/.gitignore
new file mode 100755 (executable)
index 0000000..3543521
--- /dev/null
@@ -0,0 +1 @@
+/build\r
diff --git a/android/examples/simpleclient/build.gradle b/android/examples/simpleclient/build.gradle
new file mode 100755 (executable)
index 0000000..07cc15b
--- /dev/null
@@ -0,0 +1,25 @@
+apply plugin: 'com.android.application'\r
+\r
+android {\r
+    compileSdkVersion 21\r
+    buildToolsVersion "21.1.2"\r
+\r
+    defaultConfig {\r
+        applicationId "org.iotivity.base.examples.simpleclient"\r
+        minSdkVersion 19\r
+        targetSdkVersion 21\r
+        versionCode 1\r
+        versionName "1.0"\r
+    }\r
+    buildTypes {\r
+        release {\r
+            minifyEnabled false\r
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\r
+        }\r
+    }\r
+}\r
+\r
+dependencies {\r
+    compile project(':message')\r
+    compile 'com.android.support:appcompat-v7:21.0.3'\r
+}\r
diff --git a/android/examples/simpleclient/simpleclient.iml b/android/examples/simpleclient/simpleclient.iml
new file mode 100755 (executable)
index 0000000..4ba5a36
--- /dev/null
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="examples" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">\r
+  <component name="FacetManager">\r
+    <facet type="android-gradle" name="Android-Gradle">\r
+      <configuration>\r
+        <option name="GRADLE_PROJECT_PATH" value=":simpleclient" />\r
+      </configuration>\r
+    </facet>\r
+    <facet type="android" name="Android">\r
+      <configuration>\r
+        <option name="SELECTED_BUILD_VARIANT" value="debug" />\r
+        <option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />\r
+        <option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />\r
+        <option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />\r
+        <option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />\r
+        <option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />\r
+        <option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugTestSources" />\r
+        <option name="ALLOW_USER_CONFIGURATION" value="false" />\r
+        <option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />\r
+        <option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />\r
+        <option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />\r
+        <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />\r
+      </configuration>\r
+    </facet>\r
+  </component>\r
+  <component name="NewModuleRootManager" inherit-compiler-output="false">\r
+    <output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />\r
+    <output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />\r
+    <exclude-output />\r
+    <content url="file://$MODULE_DIR$">\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/debug" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/test/debug" isTestSource="true" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/test/debug" isTestSource="true" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/test/debug" isTestSource="true" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/test/debug" isTestSource="true" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/test/debug" type="java-test-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/test/debug" type="java-test-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/outputs" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/tmp" />\r
+    </content>\r
+    <orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />\r
+    <orderEntry type="sourceFolder" forTests="false" />\r
+    <orderEntry type="library" exported="" name="iotivity-x86-base-debug-unspecified" level="project" />\r
+    <orderEntry type="library" exported="" name="appcompat-v7-21.0.3" level="project" />\r
+    <orderEntry type="library" exported="" name="support-annotations-21.0.3" level="project" />\r
+    <orderEntry type="library" exported="" name="support-v4-21.0.3" level="project" />\r
+    <orderEntry type="module" module-name="message" exported="" />\r
+  </component>\r
+</module>\r
+\r
old mode 100644 (file)
new mode 100755 (executable)
similarity index 76%
rename from android/SimpleClient/app/src/main/AndroidManifest.xml
rename to android/examples/simpleclient/src/main/AndroidManifest.xml
index 08329da..0345054
@@ -1,23 +1,24 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="org.iotivity.simpleclient" >
-
-    <uses-permission android:name="android.permission.INTERNET" />
-
-    <application
-        android:allowBackup="true"
-        android:icon="@drawable/ic_launcher"
-        android:label="@string/app_name"
-        android:theme="@style/AppTheme" >
-        <activity
-            android:name=".SimpleClient"
-            android:label="@string/app_name" >
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-
-                <category android:name="android.intent.category.LAUNCHER" />
-            </intent-filter>
-        </activity>
-    </application>
-
-</manifest>
+<?xml version="1.0" encoding="utf-8"?>\r
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"\r
+    package="org.iotivity.base.examples.simpleclient"\r
+    xmlns:tools="http://schemas.android.com/tools">\r
+\r
+    <uses-sdk tools:overrideLibrary="org.iotivity.base"></uses-sdk>\r
+\r
+    <application\r
+        android:allowBackup="true"\r
+        android:icon="@drawable/ic_launcher"\r
+        android:label="@string/app_name"\r
+        android:theme="@style/AppTheme" >\r
+        <activity\r
+            android:name=".SimpleClient"\r
+            android:label="@string/app_name" >\r
+            <intent-filter>\r
+                <action android:name="android.intent.action.MAIN" />\r
+\r
+                <category android:name="android.intent.category.LAUNCHER" />\r
+            </intent-filter>\r
+        </activity>\r
+    </application>\r
+\r
+</manifest>\r
diff --git a/android/examples/simpleclient/src/main/java/org/iotivity/base/examples/simpleclient/Light.java b/android/examples/simpleclient/src/main/java/org/iotivity/base/examples/simpleclient/Light.java
new file mode 100755 (executable)
index 0000000..2f981b3
--- /dev/null
@@ -0,0 +1,65 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base.examples.simpleclient;\r
+\r
+/**\r
+ * Light\r
+ *\r
+ * This class is used by simpleclient to create an object and update the values depending on the server response\r
+ */\r
+public class Light {\r
+    private boolean mState;\r
+    private int mPower;\r
+    private String mName;\r
+\r
+    // constructor\r
+    Light() {\r
+        mState = false;\r
+        mPower = 0;\r
+        mName = "";\r
+    }\r
+\r
+    // accessor methods\r
+    public boolean getState() {\r
+        return mState;\r
+    }\r
+    void setState(boolean state) {\r
+        mState = state;\r
+    }\r
+    int getPower() {\r
+        return mPower;\r
+    }\r
+    void setPower(int power) {\r
+        mPower = power;\r
+    }\r
+    String getName() {\r
+        return mName;\r
+    }\r
+    void setName(String name) {\r
+        mName = name;\r
+    }\r
+}\r
+\r
+\r
+\r
+\r
diff --git a/android/examples/simpleclient/src/main/java/org/iotivity/base/examples/simpleclient/SimpleClient.java b/android/examples/simpleclient/src/main/java/org/iotivity/base/examples/simpleclient/SimpleClient.java
new file mode 100755 (executable)
index 0000000..b747c5a
--- /dev/null
@@ -0,0 +1,443 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base.examples.simpleclient;\r
+\r
+import android.app.Activity;\r
+import android.content.BroadcastReceiver;\r
+import android.content.Context;\r
+import android.content.Intent;\r
+import android.os.Bundle;\r
+import android.os.Message;\r
+import android.text.method.ScrollingMovementMethod;\r
+import android.util.Log;\r
+import android.widget.LinearLayout;\r
+import android.widget.TextView;\r
+\r
+import org.iotivity.base.ErrorCode;\r
+import org.iotivity.base.ModeType;\r
+import org.iotivity.base.ObserveType;\r
+import org.iotivity.base.OcConnectivityType;\r
+import org.iotivity.base.OcException;\r
+import org.iotivity.base.OcHeaderOption;\r
+import org.iotivity.base.OcPlatform;\r
+import org.iotivity.base.OcRepresentation;\r
+import org.iotivity.base.OcResource;\r
+import org.iotivity.base.PlatformConfig;\r
+import org.iotivity.base.QualityOfService;\r
+import org.iotivity.base.ServiceType;\r
+\r
+import java.util.HashMap;\r
+import java.util.List;\r
+\r
+import base.iotivity.org.examples.message.IMessageLogger;\r
+\r
+/**\r
+ * SimpleClient\r
+ * <p/>\r
+ * SimpleClient is a sample client app which should be started after the simpleServer is started.\r
+ * It finds resources advertised by the server and calls different operations on it (GET, PUT,\r
+ * POST and OBSERVE).\r
+ * This implements IMessageLogger to display messages on the screen\r
+ */\r
+public class SimpleClient extends Activity implements OcPlatform.OnResourceFoundListener,\r
+        IMessageLogger {\r
+    private static final String TAG = "SimpleClient: ";\r
+\r
+    private Light myLight;\r
+    private OcResource curResource;\r
+\r
+    //for display\r
+    private TextView mEventsTextView;\r
+    private static boolean printOnce = true;\r
+\r
+    /**\r
+     * configure OIC platform and call findResource\r
+     */\r
+    private void initOICStack() {\r
+        //create platform config\r
+        PlatformConfig cfg = new PlatformConfig(\r
+                this,\r
+                ServiceType.IN_PROC,\r
+                ModeType.CLIENT,\r
+                "0.0.0.0", // bind to all available interfaces\r
+                0,\r
+                QualityOfService.LOW);\r
+        OcPlatform.Configure(cfg);\r
+        try {\r
+            /**\r
+             * find all resources\r
+             */\r
+            OcPlatform.findResource("", OcPlatform.WELL_KNOWN_QUERY + "?rt=" + "core.light",\r
+                    OcConnectivityType.WIFI, this);\r
+        } catch (OcException e) {\r
+            logMessage(TAG + "findResource error: " + e.getMessage());\r
+            Log.e(TAG, e.getMessage());\r
+        }\r
+    }\r
+\r
+    @Override\r
+    /**\r
+     *  callback when a resource is found. This method calls doGetLightRepresentation to get the\r
+     *  current values of myLight\r
+     */\r
+    synchronized public void onResourceFound(OcResource ocResource) {\r
+        /**\r
+         *  this may potentially be called by multiple threads at the same time\r
+         */\r
+        synchronized (this) {\r
+            String resourceUri;\r
+            String hostAddress;\r
+            resourceUri = ocResource.getUri();\r
+            hostAddress = ocResource.getHost();\r
+            logMessage(TAG + "Discovered Resource\nUri: " + resourceUri + " \n Host: " + hostAddress);\r
+            // get the resource types\r
+            if (resourceUri.equals(StringConstants.RESOURCE_URI0)) {\r
+                curResource = ocResource;\r
+                doGetLightRepresentation();\r
+            }\r
+        }\r
+    }\r
+\r
+    /**\r
+     * get myLight values after observe\r
+     */\r
+    private void doObserveLightRepresentation() {\r
+        // eventhandler for observe()\r
+        OcResource.OnObserveListener onObserveListener = new OcResource.OnObserveListener() {\r
+            @Override\r
+            public void onObserveCompleted(List<OcHeaderOption> ocHeaderOptions,\r
+                                           OcRepresentation ocRepresentation, int seqNum) {\r
+                if (printOnce) {\r
+                    logMessage(TAG + "OBSERVE request was successful");\r
+                    printOnce = false;\r
+                }\r
+                try {\r
+                    boolean state = ocRepresentation.getValue(StringConstants.STATE);\r
+                    int power = ocRepresentation.getValue(StringConstants.POWER);\r
+                    String name = ocRepresentation.getValue(StringConstants.NAME);\r
+                    myLight.setState(state);\r
+                    myLight.setPower(power);\r
+                    myLight.setName(name);\r
+                } catch (OcException e) {\r
+                    Log.e(TAG, e.getMessage());\r
+                }\r
+                logMessage(TAG + "onObserve: Power: " + myLight.getPower());\r
+                if (seqNum > 20) {\r
+                    try {\r
+                        curResource.cancelObserve();\r
+                        logMessage(TAG + "Successfully cancelled observe");\r
+                   } catch (OcException e) {\r
+                        logMessage(TAG + "cancelObserve error. " + e.getMessage());\r
+                        Log.e(TAG, e.getMessage());\r
+                    }\r
+                }\r
+\r
+            }\r
+\r
+            @Override\r
+            public void onObserveFailed(Throwable throwable) {\r
+                if (throwable instanceof OcException) {\r
+                    OcException ocEx = (OcException) throwable;\r
+                    ErrorCode errCode = ocEx.getErrorCode();\r
+                    //do something based on errorCode\r
+                }\r
+                Log.e(TAG, throwable.toString());\r
+            }\r
+        };\r
+        try {\r
+            curResource.observe(ObserveType.OBSERVE, new HashMap<String, String>(), onObserveListener);\r
+        } catch (OcException e) {\r
+            logMessage(TAG + e.getMessage());\r
+            Log.e(TAG, e.getMessage());\r
+        }\r
+    }\r
+\r
+    /**\r
+     * get the current value of myLight after POST and call doObserveLightRepresentation\r
+     *\r
+     * @param ocRepresentation needed to invoke post()\r
+     */\r
+    private void doOnPost2(OcRepresentation ocRepresentation) {\r
+        // eventhandler for post()\r
+        OcResource.OnPostListener onPostListener2 = new OcResource.OnPostListener() {\r
+            @Override\r
+            public void onPostCompleted(List<OcHeaderOption> ocHeaderOptions, OcRepresentation rep) {\r
+                logMessage(TAG + "POST request was successful");\r
+                String createdUri = rep.getUri();\r
+                if (createdUri.equals(StringConstants.RESOURCE_URI1)) {\r
+                    logMessage(TAG + "Uri of the created resource: " + createdUri);\r
+                } else {\r
+                    try {\r
+                        boolean state = rep.getValue(StringConstants.STATE);\r
+                        int power = rep.getValue(StringConstants.POWER);\r
+                        String name = rep.getValue(StringConstants.NAME);\r
+                        myLight.setState(state);\r
+                        myLight.setPower(power);\r
+                        myLight.setName(name);\r
+                    } catch (OcException e) {\r
+                        Log.e(TAG, e.getMessage());\r
+                    }\r
+                    logMessage(TAG + "onPost\nState: " + myLight.getState() + "\nPower: " +\r
+                            myLight.getPower() + "\nName: " + myLight.getName());\r
+                }\r
+                doObserveLightRepresentation();\r
+            }\r
+\r
+            @Override\r
+            public void onPostFailed(Throwable throwable) {\r
+                if (throwable instanceof OcException) {\r
+                    OcException ocEx = (OcException) throwable;\r
+                    ErrorCode errCode = ocEx.getErrorCode();\r
+                    //do something based on errorCode\r
+                }\r
+                Log.e(TAG, throwable.toString());\r
+            }\r
+        };\r
+        try {\r
+            curResource.post(ocRepresentation, new HashMap<String, String>(), onPostListener2);\r
+        } catch (OcException e) {\r
+            logMessage(TAG + e.getMessage());\r
+            Log.e(TAG, e.getMessage());\r
+        }\r
+    }\r
+\r
+    /**\r
+     * create a new resource and update its value.\r
+     */\r
+    private void doPostLightRepresentation() {\r
+        // eventhandler for post()\r
+        OcResource.OnPostListener onPostListener = new OcResource.OnPostListener() {\r
+            @Override\r
+            public void onPostCompleted(List<OcHeaderOption> ocHeaderOptions,\r
+                                        OcRepresentation ocRepresentation) {\r
+                String createdUri = "";\r
+                try {\r
+                    createdUri = ocRepresentation.getValue(StringConstants.CREATED_URI);\r
+                } catch (OcException e) {\r
+                    Log.e(TAG, e.getMessage());\r
+                }\r
+                if (createdUri.equals(StringConstants.RESOURCE_URI1)) {\r
+                    logMessage(TAG + "Uri of the created resource: " + createdUri);\r
+                } else {\r
+                    boolean state = false;\r
+                    try {\r
+                        state = ocRepresentation.getValue(StringConstants.STATE);\r
+                        int power = ocRepresentation.getValue(StringConstants.POWER);\r
+                        String name = ocRepresentation.getValue(StringConstants.NAME);\r
+                        myLight.setState(state);\r
+                        myLight.setPower(power);\r
+                        myLight.setName(name);\r
+                    } catch (OcException e) {\r
+                        Log.e(TAG, e.getMessage());\r
+                    }\r
+                }\r
+                OcRepresentation rep = new OcRepresentation();\r
+                myLight.setState(true);\r
+                myLight.setPower(55);\r
+                try {\r
+                    rep.setValue(StringConstants.POWER, myLight.getPower());\r
+                    rep.setValue(StringConstants.STATE, myLight.getState());\r
+                } catch (OcException e) {\r
+                    Log.e(TAG, e.getMessage());\r
+                }\r
+                doOnPost2(rep);\r
+            }\r
+\r
+            @Override\r
+            public void onPostFailed(Throwable throwable) {\r
+                if (throwable instanceof OcException) {\r
+                    OcException ocEx = (OcException) throwable;\r
+                    ErrorCode errCode = ocEx.getErrorCode();\r
+                    //do something based on errorCode\r
+                }\r
+                Log.e(TAG, throwable.toString());\r
+            }\r
+        };\r
+\r
+        OcRepresentation rep = new OcRepresentation();\r
+        myLight.setState(false);\r
+        myLight.setPower(105);\r
+        try {\r
+            rep.setValue(StringConstants.STATE, myLight.getState());\r
+            rep.setValue(StringConstants.POWER, myLight.getPower());\r
+        } catch (OcException e) {\r
+            Log.e(TAG, e.getMessage());\r
+        }\r
+        try {\r
+            curResource.post(rep, new HashMap<String, String>(), onPostListener);\r
+        } catch (OcException e) {\r
+            logMessage(TAG + e.getMessage());\r
+            Log.e(TAG, e.getMessage());\r
+        }\r
+    }\r
+\r
+    /**\r
+     * modify the current value of myLight and call doPostLightRepresentation\r
+     */\r
+    private void doPutLightRepresentation() {\r
+        // eventhandler for put()\r
+        OcResource.OnPutListener onPutListener = new OcResource.OnPutListener() {\r
+            @Override\r
+            public void onPutCompleted(List<OcHeaderOption> ocHeaderOptions,\r
+                                       OcRepresentation ocRepresentation) {\r
+                logMessage(TAG + "PUT resource was successful");\r
+                try {\r
+                    boolean state = ocRepresentation.getValue(StringConstants.STATE);\r
+                    int power = ocRepresentation.getValue(StringConstants.POWER);\r
+                    String name = ocRepresentation.getValue(StringConstants.NAME);\r
+                    myLight.setState(state);\r
+                    myLight.setPower(power);\r
+                    myLight.setName(name);\r
+                } catch (OcException e) {\r
+                    Log.e(TAG, e.getMessage());\r
+                }\r
+\r
+                logMessage(TAG + "onPutCompleted:\nState:" + myLight.getState() + "\nPower: " +\r
+                        myLight.getPower() + "\nName: " + myLight.getName());\r
+                doPostLightRepresentation();\r
+            }\r
+\r
+            @Override\r
+            public void onPutFailed(Throwable throwable) {\r
+\r
+                if (throwable instanceof OcException) {\r
+                    OcException ocEx = (OcException) throwable;\r
+                    ErrorCode errCode = ocEx.getErrorCode();\r
+                    //do something based on errorCode\r
+                }\r
+                Log.e(TAG, throwable.toString());\r
+            }\r
+        };\r
+\r
+        OcRepresentation rep = new OcRepresentation();\r
+        Log.d(TAG, "myLight settings: power = 15");\r
+        myLight.setState(true);\r
+        myLight.setPower(15);\r
+        try {\r
+            rep.setValue(StringConstants.STATE, myLight.getState());\r
+            rep.setValue(StringConstants.POWER, myLight.getPower());\r
+            rep.setValue(StringConstants.NAME, myLight.getName());\r
+        } catch (OcException e) {\r
+            Log.e(TAG, e.getMessage());\r
+        }\r
+        try {\r
+            Log.d(TAG, "before calling put");\r
+            curResource.put(rep, new HashMap<String, String>(), onPutListener);\r
+        } catch (OcException e) {\r
+            logMessage(TAG + e.getMessage());\r
+            Log.e(TAG, e.getMessage());\r
+        }\r
+        Log.d(TAG, "end of put call");\r
+    }\r
+\r
+    /**\r
+     * get the existing value of myLight and call doPutLightRepresentation() to modify the current values\r
+     */\r
+    private void doGetLightRepresentation() {\r
+        // eventhandler for get()\r
+        OcResource.OnGetListener onGetListener = new OcResource.OnGetListener() {\r
+            @Override\r
+            public void onGetCompleted(List<OcHeaderOption> headerOptionList,\r
+                                       OcRepresentation ocRepresentation) {\r
+                logMessage(TAG + "GET resource was successful " + StringConstants.STATE);\r
+                try {\r
+                    boolean state = ocRepresentation.getValue(StringConstants.STATE);\r
+                    int power = ocRepresentation.getValue(StringConstants.POWER);\r
+                    String name = ocRepresentation.getValue(StringConstants.NAME);\r
+                    myLight.setState(state);\r
+                    myLight.setPower(power);\r
+                    myLight.setName(name);\r
+                } catch (OcException e) {\r
+                    Log.e(TAG, e.getMessage());\r
+                }\r
+                logMessage(TAG + "onGetCompleted\nState: " + myLight.getState() + "\nPower: " +\r
+                        myLight.getPower() + "\nName: " + myLight.getName());\r
+                doPutLightRepresentation();\r
+            }\r
+\r
+            @Override\r
+            public void onGetFailed(Throwable throwable) {\r
+                if (throwable instanceof OcException) {\r
+                    OcException ocEx = (OcException) throwable;\r
+                    ErrorCode errCode = ocEx.getErrorCode();\r
+                    //do something based on errorCode\r
+                }\r
+                Log.e(TAG, throwable.toString());\r
+            }\r
+        };\r
+\r
+        try {\r
+            curResource.get(new HashMap<String, String>(), onGetListener);\r
+        } catch (OcException e) {\r
+            logMessage(TAG + e.getMessage());\r
+            Log.e(TAG, e.getMessage());\r
+        }\r
+    }\r
+\r
+    /**\r
+     * to display on SimpleClient screen\r
+     */\r
+    public class MessageReceiver extends BroadcastReceiver {\r
+        @Override\r
+        public void onReceive(Context context, Intent intent) {\r
+            final String message = intent.getStringExtra(StringConstants.MESSAGE);\r
+            logMessage(message);\r
+        }\r
+    }\r
+\r
+    @Override\r
+    protected void onCreate(Bundle savedInstanceState) {\r
+        super.onCreate(savedInstanceState);\r
+        setContentView(R.layout.activity_main);\r
+        mEventsTextView = new TextView(this);\r
+        mEventsTextView.setMovementMethod(new ScrollingMovementMethod());\r
+        LinearLayout layout = (LinearLayout) findViewById(R.id.linearLayout);\r
+        layout.addView(mEventsTextView, new LinearLayout.LayoutParams(\r
+                LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f)\r
+        );\r
+        myLight = new Light();\r
+\r
+        initOICStack();\r
+    }\r
+\r
+    @Override\r
+    public void logMessage(String text) {\r
+        logMsg(text);\r
+    }\r
+\r
+    public void logMsg(final String text) {\r
+        runOnUiThread(new Runnable() {\r
+            public void run() {\r
+                Message msg = new Message();\r
+                msg.obj = text;\r
+                mEventsTextView.append("\n");\r
+                mEventsTextView.append(text);\r
+            }\r
+        });\r
+        Log.i(TAG, text);\r
+        //to print on SimpleServer screen\r
+        Intent intent = new Intent("org.iotivity.base.examples.simpleclient");\r
+        intent.putExtra(StringConstants.MESSAGE, text);\r
+        sendBroadcast(intent);\r
+    }\r
+}\r
diff --git a/android/examples/simpleclient/src/main/java/org/iotivity/base/examples/simpleclient/StringConstants.java b/android/examples/simpleclient/src/main/java/org/iotivity/base/examples/simpleclient/StringConstants.java
new file mode 100755 (executable)
index 0000000..f87c387
--- /dev/null
@@ -0,0 +1,17 @@
+package org.iotivity.base.examples.simpleclient;\r
+\r
+/**\r
+ * StringConstant contains the simpleclient specific constant values.  To add another supported\r
+ * Resource or Interface type to this app, begin by adding the new strings here, and then\r
+ * find the places throughout the app where Resource-specific case switches occur, and add\r
+ * the newly-supported type there.\r
+ */\r
+public interface StringConstants {\r
+    public static final String RESOURCE_URI0 = "/light0";\r
+    public static final String RESOURCE_URI1 = "/light1";\r
+    public static final String CREATED_URI = "createduri";\r
+    public static final String STATE = "state";\r
+    public static final String NAME = "name";\r
+    public static final String POWER = "power";\r
+    public static final String MESSAGE = "message";\r
+}\r
diff --git a/android/examples/simpleclient/src/main/res/drawable-hdpi/ic_launcher.png b/android/examples/simpleclient/src/main/res/drawable-hdpi/ic_launcher.png
new file mode 100755 (executable)
index 0000000..96a442e
Binary files /dev/null and b/android/examples/simpleclient/src/main/res/drawable-hdpi/ic_launcher.png differ
diff --git a/android/examples/simpleclient/src/main/res/drawable-mdpi/ic_launcher.png b/android/examples/simpleclient/src/main/res/drawable-mdpi/ic_launcher.png
new file mode 100755 (executable)
index 0000000..359047d
Binary files /dev/null and b/android/examples/simpleclient/src/main/res/drawable-mdpi/ic_launcher.png differ
diff --git a/android/examples/simpleclient/src/main/res/drawable-xhdpi/ic_launcher.png b/android/examples/simpleclient/src/main/res/drawable-xhdpi/ic_launcher.png
new file mode 100755 (executable)
index 0000000..71c6d76
Binary files /dev/null and b/android/examples/simpleclient/src/main/res/drawable-xhdpi/ic_launcher.png differ
diff --git a/android/examples/simpleclient/src/main/res/drawable-xxhdpi/ic_launcher.png b/android/examples/simpleclient/src/main/res/drawable-xxhdpi/ic_launcher.png
new file mode 100755 (executable)
index 0000000..4df1894
Binary files /dev/null and b/android/examples/simpleclient/src/main/res/drawable-xxhdpi/ic_launcher.png differ
diff --git a/android/examples/simpleclient/src/main/res/layout/activity_main.xml b/android/examples/simpleclient/src/main/res/layout/activity_main.xml
new file mode 100755 (executable)
index 0000000..9aecf74
--- /dev/null
@@ -0,0 +1,18 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
+    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"\r
+    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"\r
+    android:paddingRight="@dimen/activity_horizontal_margin"\r
+    android:paddingTop="@dimen/activity_vertical_margin"\r
+    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"\r
+    android:label="@string/app_name">\r
+\r
+    <TextView android:text="@string/app_name" android:layout_width="wrap_content"\r
+        android:layout_height="wrap_content" />\r
+\r
+    <LinearLayout\r
+        android:layout_width="fill_parent"\r
+        android:layout_height="fill_parent"\r
+        android:orientation="vertical"\r
+        android:id="@+id/linearLayout" >\r
+    </LinearLayout>\r
+</RelativeLayout>\r
diff --git a/android/examples/simpleclient/src/main/res/menu/menu_main.xml b/android/examples/simpleclient/src/main/res/menu/menu_main.xml
new file mode 100755 (executable)
index 0000000..a1045e9
--- /dev/null
@@ -0,0 +1,6 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android"\r
+    xmlns:app="http://schemas.android.com/apk/res-auto"\r
+    xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">\r
+    <item android:id="@+id/action_settings" android:title="@string/action_settings"\r
+        android:orderInCategory="100" app:showAsAction="never" />\r
+</menu>\r
diff --git a/android/examples/simpleclient/src/main/res/values-w820dp/dimens.xml b/android/examples/simpleclient/src/main/res/values-w820dp/dimens.xml
new file mode 100755 (executable)
index 0000000..62df187
--- /dev/null
@@ -0,0 +1,6 @@
+<resources>\r
+    <!-- Example customization of dimensions originally defined in res/values/dimens.xml\r
+         (such as screen margins) for screens with more than 820dp of available width. This\r
+         would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->\r
+    <dimen name="activity_horizontal_margin">64dp</dimen>\r
+</resources>\r
diff --git a/android/examples/simpleclient/src/main/res/values/dimens.xml b/android/examples/simpleclient/src/main/res/values/dimens.xml
new file mode 100755 (executable)
index 0000000..295b5a9
--- /dev/null
@@ -0,0 +1,5 @@
+<resources>\r
+    <!-- Default screen margins, per the Android Design guidelines. -->\r
+    <dimen name="activity_horizontal_margin">16dp</dimen>\r
+    <dimen name="activity_vertical_margin">16dp</dimen>\r
+</resources>\r
diff --git a/android/examples/simpleclient/src/main/res/values/strings.xml b/android/examples/simpleclient/src/main/res/values/strings.xml
new file mode 100755 (executable)
index 0000000..575b3e0
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<resources>\r
+\r
+    <string name="app_name">Starting Simple Client</string>\r
+    <string name="hello_world">Hello world!</string>\r
+    <string name="action_settings">Settings</string>\r
+\r
+</resources>\r
diff --git a/android/examples/simpleclient/src/main/res/values/styles.xml b/android/examples/simpleclient/src/main/res/values/styles.xml
new file mode 100755 (executable)
index 0000000..084b42b
--- /dev/null
@@ -0,0 +1,8 @@
+<resources>\r
+\r
+    <!-- Base application theme. -->\r
+    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">\r
+        <!-- Customize your theme here. -->\r
+    </style>\r
+\r
+</resources>\r
diff --git a/android/examples/simpleserver/.gitignore b/android/examples/simpleserver/.gitignore
new file mode 100755 (executable)
index 0000000..3543521
--- /dev/null
@@ -0,0 +1 @@
+/build\r
diff --git a/android/examples/simpleserver/build.gradle b/android/examples/simpleserver/build.gradle
new file mode 100755 (executable)
index 0000000..3ecd031
--- /dev/null
@@ -0,0 +1,27 @@
+apply plugin: 'com.android.application'\r
+\r
+android {\r
+    compileSdkVersion 21\r
+    buildToolsVersion "21.1.2"\r
+\r
+    defaultConfig {\r
+        applicationId "org.iotivity.base.examples.simpleserver"\r
+        minSdkVersion 19\r
+        targetSdkVersion 21\r
+        versionCode 1\r
+        versionName "1.0"\r
+    }\r
+    buildTypes {\r
+        release {\r
+            minifyEnabled false\r
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\r
+        }\r
+    }\r
+\r
+}\r
+\r
+dependencies {\r
+    //compile fileTree(dir: 'libs', include: ['*.so'])\r
+    compile project(':message')\r
+    compile 'com.android.support:appcompat-v7:21.0.3'\r
+}\r
diff --git a/android/examples/simpleserver/simpleserver.iml b/android/examples/simpleserver/simpleserver.iml
new file mode 100755 (executable)
index 0000000..c668fa1
--- /dev/null
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="examples" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">\r
+  <component name="FacetManager">\r
+    <facet type="android-gradle" name="Android-Gradle">\r
+      <configuration>\r
+        <option name="GRADLE_PROJECT_PATH" value=":simpleserver" />\r
+      </configuration>\r
+    </facet>\r
+    <facet type="android" name="Android">\r
+      <configuration>\r
+        <option name="SELECTED_BUILD_VARIANT" value="debug" />\r
+        <option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />\r
+        <option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />\r
+        <option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />\r
+        <option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />\r
+        <option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />\r
+        <option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugTestSources" />\r
+        <option name="ALLOW_USER_CONFIGURATION" value="false" />\r
+        <option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />\r
+        <option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />\r
+        <option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />\r
+        <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />\r
+      </configuration>\r
+    </facet>\r
+  </component>\r
+  <component name="NewModuleRootManager" inherit-compiler-output="false">\r
+    <output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />\r
+    <output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />\r
+    <exclude-output />\r
+    <content url="file://$MODULE_DIR$">\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/debug" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/test/debug" isTestSource="true" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/test/debug" isTestSource="true" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/test/debug" isTestSource="true" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/test/debug" isTestSource="true" generated="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/test/debug" type="java-test-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/test/debug" type="java-test-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />\r
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/outputs" />\r
+      <excludeFolder url="file://$MODULE_DIR$/build/tmp" />\r
+    </content>\r
+    <orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />\r
+    <orderEntry type="sourceFolder" forTests="false" />\r
+    <orderEntry type="library" exported="" name="iotivity-x86-base-debug-unspecified" level="project" />\r
+    <orderEntry type="library" exported="" name="appcompat-v7-21.0.3" level="project" />\r
+    <orderEntry type="library" exported="" name="support-annotations-21.0.3" level="project" />\r
+    <orderEntry type="library" exported="" name="support-v4-21.0.3" level="project" />\r
+    <orderEntry type="module" module-name="message" exported="" />\r
+  </component>\r
+</module>\r
+\r
diff --git a/android/examples/simpleserver/src/main/AndroidManifest.xml b/android/examples/simpleserver/src/main/AndroidManifest.xml
new file mode 100755 (executable)
index 0000000..43352f4
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"\r
+    package="org.iotivity.base.examples.simpleserver"\r
+    xmlns:tools="http://schemas.android.com/tools">\r
+\r
+    <uses-sdk tools:overrideLibrary="org.iotivity.base"></uses-sdk>\r
+\r
+    <application\r
+        android:allowBackup="true"\r
+        android:icon="@drawable/ic_launcher"\r
+        android:label="@string/app_name"\r
+        android:theme="@style/AppTheme" >\r
+        <activity\r
+            android:name=".SimpleServer"\r
+            android:label="@string/app_name" >\r
+            <intent-filter>\r
+                <action android:name="android.intent.action.MAIN" />\r
+\r
+                <category android:name="android.intent.category.LAUNCHER" />\r
+            </intent-filter>\r
+        </activity>\r
+    </application>\r
+\r
+</manifest>\r
diff --git a/android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/LightRepThread.java b/android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/LightRepThread.java
new file mode 100755 (executable)
index 0000000..0993995
--- /dev/null
@@ -0,0 +1,86 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+/*\r
+ * // Starts a new thread for OBSERVE. It increments the value of mPower by 10 every 3 seconds\r
+ */\r
+package org.iotivity.base.examples.simpleserver;\r
+\r
+import android.util.Log;\r
+\r
+import org.iotivity.base.EntityHandlerResult;\r
+import org.iotivity.base.OcException;\r
+import org.iotivity.base.OcPlatform;\r
+import org.iotivity.base.OcRepresentation;\r
+import org.iotivity.base.OcResourceResponse;\r
+\r
+import java.util.List;\r
+\r
+/**\r
+ * LightRepThread\r
+ *\r
+ * Spawn a thread for OBSERVE. This increments the resource's power value by 10 every 3 seconds.\r
+ * If there is an observationList, call notifyListOfObservers(). Otherwise, call notifyAllObservers()\r
+ */\r
+public class LightRepThread extends Thread {\r
+    private static String TAG = "LightRepThread: ";\r
+\r
+    private LightResource mLightResource;\r
+    private List<Byte> mObservationList;\r
+    private static int count = 0;\r
+\r
+    LightRepThread(Object lr, List<Byte> observationList) {\r
+        mLightResource = (LightResource)lr;\r
+        mObservationList = observationList;\r
+    }\r
+\r
+    public void run() {\r
+        while(count < 20) {\r
+            try {\r
+                sleep(3000);\r
+            } catch (InterruptedException e) {\r
+                Log.e(TAG, e.getMessage());\r
+            }\r
+\r
+            // increment current power value by 10 every 3 seconds\r
+            mLightResource.setPower(mLightResource.getPower() + 10);\r
+            try {\r
+                // if observationList is not empty, call notifyListOfObservers\r
+                if (mObservationList.size() > 0) {\r
+                    OcResourceResponse ocResourceResponse = new OcResourceResponse();\r
+                    ocResourceResponse.setErrorCode(StringConstants.ERROR_CODE);\r
+                    ocResourceResponse.setResponseResult(EntityHandlerResult.OK);\r
+                    OcRepresentation r = mLightResource.get();\r
+                    ocResourceResponse.setResourceRepresentation\r
+                            (mLightResource.get(), OcPlatform.DEFAULT_INTERFACE);\r
+                    OcPlatform.notifyListOfObservers(mLightResource.getHandle(), mObservationList, ocResourceResponse);\r
+                } else {\r
+                    // notify all observers if mObservationList is empty\r
+                    OcPlatform.notifyAllObservers(mLightResource.getHandle());\r
+                }\r
+            } catch (OcException e) {\r
+                Log.e(TAG, e.getMessage());\r
+            }\r
+            ++count;\r
+        }\r
+    }\r
+}\r
diff --git a/android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/LightResource.java b/android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/LightResource.java
new file mode 100755 (executable)
index 0000000..e8414a0
--- /dev/null
@@ -0,0 +1,308 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base.examples.simpleserver;\r
+\r
+import android.content.Context;\r
+import android.content.Intent;\r
+import android.util.Log;\r
+\r
+import org.iotivity.base.EntityHandlerResult;\r
+import org.iotivity.base.ObservationInfo;\r
+import org.iotivity.base.OcException;\r
+import org.iotivity.base.OcPlatform;\r
+import org.iotivity.base.OcRepresentation;\r
+import org.iotivity.base.OcResourceHandle;\r
+import org.iotivity.base.OcResourceRequest;\r
+import org.iotivity.base.OcResourceResponse;\r
+import org.iotivity.base.RequestHandlerFlag;\r
+import org.iotivity.base.RequestType;\r
+import org.iotivity.base.ResourceProperty;\r
+\r
+import java.util.EnumSet;\r
+import java.util.LinkedList;\r
+import java.util.List;\r
+\r
+import base.iotivity.org.examples.message.IMessageLogger;\r
+\r
+/**\r
+ * LightResource\r
+ *\r
+ * class LightResource is the main class of the simpleServer. This creates resources and handles incoming requests from the client.\r
+ */\r
+public class LightResource implements IMessageLogger {\r
+    private Context mContext;\r
+    private static String TAG = "SimpleServer: ";\r
+\r
+    private String mName;\r
+    private Boolean mState;\r
+    private Integer mPower;\r
+    private OcRepresentation mLightRep;\r
+    private OcResourceHandle mResourceHandle;\r
+    private List<Byte> mObservationIds;\r
+    private static boolean doOnce; // used in POST\r
+    LightRepThread lightRepThread;\r
+\r
+    // constructor\r
+    LightResource(Context context) {\r
+        mContext = context;\r
+        mName = "John's light";\r
+        mState = false;\r
+        mPower = 0;\r
+        mObservationIds = new LinkedList<>();\r
+        mLightRep = new OcRepresentation();\r
+        try {\r
+            mLightRep.setValue(StringConstants.STATE, mState);\r
+            mLightRep.setValue(StringConstants.POWER, mPower);\r
+            mLightRep.setValue(StringConstants.NAME, mName);\r
+        } catch (OcException e) {\r
+            Log.e(TAG, e.getMessage());\r
+        }\r
+        doOnce = true; // used in post\r
+        lightRepThread = null;\r
+    }\r
+\r
+    //accessor methods\r
+    protected int getPower() {\r
+        return mPower;\r
+    }\r
+    protected void setPower(int power) {\r
+        mPower = power;\r
+    }\r
+    protected OcResourceHandle getHandle() {\r
+        return mResourceHandle;\r
+    }\r
+\r
+    /**\r
+     *  creates a resource. this method internally calls registerResource\r
+     * @return returns the OcResourceHandle after creating and registering the resource\r
+     */\r
+    protected OcResourceHandle createResource0() {\r
+        // entityhandler for registerResource\r
+        OcPlatform.EntityHandler eh = new OcPlatform.EntityHandler() {\r
+            @Override\r
+            public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) {\r
+                // this is where the main logic of simpleserver is handled as different requests (GET, PUT, POST, OBSERVE, DELETE) are handled\r
+                return entityHandler(ocResourceRequest);\r
+            }\r
+        };\r
+\r
+        try {\r
+            mResourceHandle = OcPlatform.registerResource(StringConstants.RESOURCE_URI0, StringConstants.RESOURCE_TYPENAME,\r
+                StringConstants.RESOURCE_INTERFACE, eh,\r
+                EnumSet.of(ResourceProperty.DISCOVERABLE, ResourceProperty.OBSERVABLE));\r
+        } catch (OcException e) {\r
+            logMessage(TAG + "RegisterResource error. " + e.getMessage());\r
+            Log.e(TAG, e.getMessage());\r
+        }\r
+        logMessage(TAG + "Successfully registered resource");\r
+        return mResourceHandle;\r
+    }\r
+\r
+    /**\r
+     *  create another resource. this method internally calls registerResource\r
+     */\r
+    private void createResource1() {\r
+        // entityhandler for registerResource\r
+        OcPlatform.EntityHandler eh = new OcPlatform.EntityHandler() {\r
+            @Override\r
+            public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) {\r
+                // this is where the main logic of simpleserver is handled as different requests (GET, PUT, POST, OBSERVE, DELETE) are handled\r
+            return entityHandler(ocResourceRequest);\r
+            }\r
+        };\r
+\r
+        try {\r
+            OcPlatform.registerResource(StringConstants.RESOURCE_URI1, StringConstants.RESOURCE_TYPENAME,\r
+                StringConstants.RESOURCE_INTERFACE, eh,\r
+                EnumSet.of(ResourceProperty.DISCOVERABLE, ResourceProperty.OBSERVABLE));\r
+        } catch (OcException e) {\r
+            logMessage(TAG + "RegisterResource1 error: " + e.getMessage());\r
+            Log.e(TAG, e.getMessage());\r
+        }\r
+        logMessage(TAG + "Successfully registered resource1");\r
+    }\r
+\r
+    /**\r
+     * post representation . Post can act like put or can create a new resource.\r
+     * Gets value from the representation and updates the internal state\r
+     * @param rep current OcRepresentation of the object\r
+     * @return updated OcRepresentation\r
+     */\r
+    private OcRepresentation post(OcRepresentation rep) {\r
+        //create a resource the first time\r
+        if (true == doOnce) {\r
+            createResource1();\r
+            OcRepresentation representation = rep;\r
+            try {\r
+                representation.setValue(StringConstants.CREATED_URI, StringConstants.RESOURCE_URI1);\r
+            } catch (OcException e) {\r
+                Log.e(TAG, e.getMessage());\r
+            }\r
+            doOnce = false;\r
+            return representation;\r
+        }\r
+        // from second time onwards, put\r
+        put(rep);\r
+        return get();\r
+    }\r
+\r
+    /**\r
+     * puts representation . Gets value from the representation and updates the internal state\r
+     * @param rep current OcRepresentation of the object\r
+     */\r
+    private void put(OcRepresentation rep) {\r
+        try {\r
+            mState = rep.getValue(StringConstants.STATE);\r
+            mPower = rep.getValue(StringConstants.POWER);\r
+        } catch (OcException e) {\r
+            Log.e(TAG, e.getMessage());\r
+        }\r
+        logMessage(TAG + "Put State: " +  mState + " Name: " + mName + " Power: " + mPower);\r
+    }\r
+\r
+    /**\r
+     *  gets the updated representation. Updates the representation with internal state before sending out\r
+     * @return OcRepresentation after updating the values of the lightRepresentation\r
+     */\r
+    protected OcRepresentation get() {\r
+        try {\r
+            mLightRep.setValue(StringConstants.STATE, mState);\r
+            mLightRep.setValue(StringConstants.POWER, mPower);\r
+            mLightRep.setValue(StringConstants.NAME, mName);\r
+        } catch (OcException e) {\r
+            Log.e(TAG, e.getMessage());\r
+        }\r
+        return mLightRep;\r
+    }\r
+\r
+    /**\r
+     * this is the main method which handles different incoming requests appropriately.\r
+     * Init is not supported currently.\r
+     * @param request OcResourceRequest from the client\r
+     * @return EntityHandlerResult depending on whether the request was handled successfully or not\r
+     */\r
+    private EntityHandlerResult entityHandler(OcResourceRequest request) {\r
+        EntityHandlerResult result = EntityHandlerResult.ERROR;\r
+        if (null != request) {\r
+            RequestType requestType = request.getRequestType();\r
+            EnumSet<RequestHandlerFlag> requestFlag = request.getRequestHandlerFlagSet();\r
+\r
+            if (requestFlag.contains(RequestHandlerFlag.INIT)) {\r
+                logMessage(TAG + "Init");\r
+            }\r
+            if (requestFlag.contains(RequestHandlerFlag.REQUEST)) {\r
+                try {\r
+                    logMessage(TAG + "Request");\r
+                    OcResourceResponse ocResourceResponse = new OcResourceResponse();\r
+                    ocResourceResponse.setRequestHandle(request.getRequestHandle());\r
+                    ocResourceResponse.setResourceHandle(request.getResourceHandle());\r
+\r
+                    switch (requestType) {\r
+                        // handle GET request\r
+                        case GET:\r
+                            logMessage("GET");\r
+                            ocResourceResponse.setResponseResult(EntityHandlerResult.OK);\r
+                            ocResourceResponse.setErrorCode(StringConstants.ERROR_CODE);\r
+                            ocResourceResponse.setResourceRepresentation(get());\r
+                            OcPlatform.sendResponse(ocResourceResponse);\r
+                            break;\r
+                        // handle PUT request\r
+                        case PUT:\r
+                            OcRepresentation rep = request.getResourceRepresentation();\r
+                            put(rep);\r
+                            ocResourceResponse.setErrorCode(StringConstants.ERROR_CODE);\r
+                            ocResourceResponse.setResponseResult(EntityHandlerResult.OK);\r
+                            ocResourceResponse.setResourceRepresentation(get());\r
+                            OcPlatform.sendResponse(ocResourceResponse);\r
+                            break;\r
+                        // handle POST request\r
+                        case POST:\r
+                            rep = request.getResourceRepresentation();\r
+                            OcRepresentation rep_post = post(rep);\r
+                            ocResourceResponse.setResourceRepresentation(rep_post);\r
+                            ocResourceResponse.setErrorCode(StringConstants.ERROR_CODE);\r
+                            if (rep_post.hasAttribute(StringConstants.CREATED_URI)) {\r
+                                String createdUri = rep_post.getValue(StringConstants.CREATED_URI);\r
+                                if (createdUri.equals(StringConstants.RESOURCE_URI1)) {\r
+                                    ocResourceResponse.setNewResourceUri(createdUri);\r
+                                    ocResourceResponse.setResponseResult\r
+                                            (EntityHandlerResult.RESOURCE_CREATED);\r
+                                } else {\r
+                                    ocResourceResponse.setResponseResult(EntityHandlerResult.OK);\r
+                                }\r
+                            }\r
+                            OcPlatform.sendResponse(ocResourceResponse);\r
+                            break;\r
+                        // handle DELETE request\r
+                        case DELETE:\r
+                            logMessage(TAG + "DELETE");\r
+                            OcPlatform.unregisterResource(getHandle());\r
+                            OcPlatform.unregisterResource(getHandle());\r
+                            break;\r
+\r
+                    }\r
+\r
+                    result = EntityHandlerResult.OK;\r
+                } catch(OcException e) {\r
+                    logMessage(TAG + "Error in Request " + e.getMessage());\r
+                    Log.e(TAG, e.getMessage());\r
+                }\r
+            }\r
+            // handle OBSERVER request\r
+            if (requestFlag.contains(RequestHandlerFlag.OBSERVER)) {\r
+                logMessage(TAG + "OBSERVER");\r
+                ObservationInfo observationInfo = request.getObservationInfo();\r
+\r
+                switch (observationInfo.getObserveAction()) {\r
+                    case REGISTER:\r
+                        synchronized (mObservationIds) {\r
+                            mObservationIds.add(observationInfo.getOcObservationId());\r
+                        }\r
+                        break;\r
+                    case UNREGISTER:\r
+                        synchronized (mObservationIds) {\r
+                            mObservationIds.remove(observationInfo.getOcObservationId());\r
+                        }\r
+                        break;\r
+                }\r
+                if (null == lightRepThread) {\r
+                    lightRepThread = new LightRepThread(this, mObservationIds);\r
+                    lightRepThread.run();\r
+                }\r
+                result = EntityHandlerResult.OK;\r
+            }\r
+        }\r
+        return result;\r
+    }\r
+\r
+    @Override\r
+    public void logMessage(String msg) {\r
+        logMsg(msg);\r
+    }\r
+\r
+    public void logMsg(final String text) {\r
+        Intent intent = new Intent("org.iotivity.base.examples.simpleserver");\r
+        intent.putExtra(StringConstants.MESSAGE, text);\r
+        mContext.sendBroadcast(intent);\r
+    }\r
+}
\ No newline at end of file
diff --git a/android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/SimpleServer.java b/android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/SimpleServer.java
new file mode 100755 (executable)
index 0000000..31b5c6a
--- /dev/null
@@ -0,0 +1,145 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.base.examples.simpleserver;\r
+\r
+import android.app.Activity;\r
+import android.content.BroadcastReceiver;\r
+import android.content.Context;\r
+import android.content.Intent;\r
+import android.content.IntentFilter;\r
+import android.os.Bundle;\r
+import android.os.Message;\r
+import android.support.v4.content.LocalBroadcastManager;\r
+import android.text.method.ScrollingMovementMethod;\r
+import android.util.Log;\r
+import android.view.Menu;\r
+import android.view.MenuItem;\r
+import android.widget.LinearLayout;\r
+import android.widget.TextView;\r
+\r
+import org.iotivity.base.ModeType;\r
+import org.iotivity.base.OcPlatform;\r
+import org.iotivity.base.OcRepresentation;\r
+import org.iotivity.base.PlatformConfig;\r
+import org.iotivity.base.QualityOfService;\r
+import org.iotivity.base.ServiceType;\r
+\r
+import base.iotivity.org.examples.message.IMessageLogger;\r
+\r
+/**\r
+ * SimpleServer\r
+ *\r
+ * SimpleServer instantiates a TextView and creates and configures OICPlatform.\r
+ * It also creates a LightResource and waits for the incoming client requests to handle specific scenarios.\r
+ * This implements IMessageLogger to display messages on the screen\r
+ */\r
+\r
+public class SimpleServer extends Activity implements IMessageLogger {\r
+    private final static String TAG = "SimpleServer: ";\r
+    private TextView mEventsTextView;\r
+    private MessageReceiver mMessageReceiver = new MessageReceiver();\r
+\r
+    @Override\r
+    protected void onCreate(Bundle savedInstanceState) {\r
+        super.onCreate(savedInstanceState);\r
+        setContentView(R.layout.activity_main);\r
+        registerReceiver(mMessageReceiver, new IntentFilter("org.iotivity.base.examples.simpleserver"));\r
+\r
+        mEventsTextView = new TextView(this);\r
+        mEventsTextView.setMovementMethod(new ScrollingMovementMethod());\r
+        LinearLayout layout = (LinearLayout)findViewById(R.id.linearLayout);\r
+        layout.addView(mEventsTextView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f));\r
+\r
+        OcRepresentation rep = new OcRepresentation();\r
+        rep.setValueBool("test", false);\r
+        boolean result = rep.getValueBool("test");\r
+\r
+        initOICStack();\r
+    }\r
+\r
+    /**\r
+     * configure OIC platform and call findResource\r
+     */\r
+    private void initOICStack() {\r
+        //create platform config\r
+        PlatformConfig cfg = new PlatformConfig(\r
+                this,\r
+                ServiceType.IN_PROC,\r
+                ModeType.SERVER,\r
+                "0.0.0.0", // bind to all available interfaces\r
+                0,\r
+                QualityOfService.LOW);\r
+        OcPlatform.Configure(cfg);\r
+        // Create instance of lightResource\r
+        LightResource myLight = new LightResource(this);\r
+        // create and register a resource\r
+        myLight.createResource0();\r
+    }\r
+\r
+    public class MessageReceiver extends BroadcastReceiver {\r
+        @Override\r
+        public void onReceive(Context context, Intent intent) {\r
+            final String message = intent.getStringExtra(StringConstants.MESSAGE);\r
+            logMessage(message);\r
+        }\r
+    }\r
+\r
+    public void logMessage(final String text) {\r
+        runOnUiThread(new Runnable() {\r
+            public void run() {\r
+                final Message msg = new Message();\r
+                msg.obj = text;\r
+                mEventsTextView.append("\n");\r
+                mEventsTextView.append(text);\r
+            }\r
+        });\r
+        Log.i(TAG, text);\r
+    }\r
+\r
+    @Override\r
+    public boolean onCreateOptionsMenu(Menu menu) {\r
+        getMenuInflater().inflate(R.menu.menu_main, menu);\r
+        return true;\r
+    }\r
+\r
+    @Override\r
+    public boolean onOptionsItemSelected(MenuItem item) {\r
+        int id = item.getItemId();\r
+        if (id == R.id.action_settings) {\r
+            return true;\r
+        }\r
+        return super.onOptionsItemSelected(item);\r
+    }\r
+\r
+    @Override\r
+    public void onDestroy() {\r
+        super.onDestroy();\r
+        onStop();\r
+    }\r
+\r
+    @Override\r
+    protected void onStop() {\r
+        LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver);\r
+        super.onStop();\r
+    }\r
+}
\ No newline at end of file
diff --git a/android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/StringConstants.java b/android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/StringConstants.java
new file mode 100755 (executable)
index 0000000..98f33d0
--- /dev/null
@@ -0,0 +1,21 @@
+package org.iotivity.base.examples.simpleserver;\r
+\r
+import org.iotivity.base.OcPlatform;\r
+/**\r
+ * StringConstants contains the simpleserver specific constant values.  To add another supported\r
+ * Resource or Interface type to this app, begin by adding the new strings here, and then\r
+ * find the places throughout the app where Resource-specific case switches occur, and add\r
+ * the newly-supported type there.\r
+ */\r
+public interface StringConstants {\r
+    public static final String RESOURCE_URI0 = "/light0";\r
+    public static final String RESOURCE_URI1 = "/light1";\r
+    public static final String RESOURCE_TYPENAME = "core.light";\r
+    public static final String RESOURCE_INTERFACE = OcPlatform.DEFAULT_INTERFACE; //resource interface\r
+    public static final String CREATED_URI = "createduri";\r
+    public static final String STATE = "state";\r
+    public static final String NAME = "name";\r
+    public static final String POWER = "power";\r
+    public static final String MESSAGE = "message";\r
+    public static final int ERROR_CODE = 200;\r
+}\r
diff --git a/android/examples/simpleserver/src/main/res/drawable-hdpi/ic_launcher.png b/android/examples/simpleserver/src/main/res/drawable-hdpi/ic_launcher.png
new file mode 100755 (executable)
index 0000000..96a442e
Binary files /dev/null and b/android/examples/simpleserver/src/main/res/drawable-hdpi/ic_launcher.png differ
diff --git a/android/examples/simpleserver/src/main/res/drawable-mdpi/ic_launcher.png b/android/examples/simpleserver/src/main/res/drawable-mdpi/ic_launcher.png
new file mode 100755 (executable)
index 0000000..359047d
Binary files /dev/null and b/android/examples/simpleserver/src/main/res/drawable-mdpi/ic_launcher.png differ
diff --git a/android/examples/simpleserver/src/main/res/drawable-xhdpi/ic_launcher.png b/android/examples/simpleserver/src/main/res/drawable-xhdpi/ic_launcher.png
new file mode 100755 (executable)
index 0000000..71c6d76
Binary files /dev/null and b/android/examples/simpleserver/src/main/res/drawable-xhdpi/ic_launcher.png differ
diff --git a/android/examples/simpleserver/src/main/res/drawable-xxhdpi/ic_launcher.png b/android/examples/simpleserver/src/main/res/drawable-xxhdpi/ic_launcher.png
new file mode 100755 (executable)
index 0000000..4df1894
Binary files /dev/null and b/android/examples/simpleserver/src/main/res/drawable-xxhdpi/ic_launcher.png differ
diff --git a/android/examples/simpleserver/src/main/res/layout/activity_main.xml b/android/examples/simpleserver/src/main/res/layout/activity_main.xml
new file mode 100755 (executable)
index 0000000..ebe6ef7
--- /dev/null
@@ -0,0 +1,31 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
+    xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent"\r
+    android:layout_height="fill_parent" android:paddingLeft="@dimen/activity_horizontal_margin"\r
+    android:paddingRight="@dimen/activity_horizontal_margin"\r
+    android:paddingTop="@dimen/activity_vertical_margin"\r
+    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"\r
+    android:label="@string/app_name">\r
+\r
+    <ScrollView\r
+        android:layout_width="match_parent"\r
+        android:layout_height="match_parent"\r
+        android:id="@+id/scroll">\r
+\r
+        <TextView android:text="@string/simpleServer" android:layout_width="match_parent"\r
+            android:layout_height="match_parent"\r
+            android:id="@+id/textView"\r
+            android:scrollbars="vertical"\r
+            android:maxLines="10"/>\r
+\r
+    </ScrollView>\r
+\r
+    <LinearLayout\r
+        android:layout_width="match_parent"\r
+        android:layout_height="match_parent"\r
+        android:orientation="vertical"\r
+        android:id="@+id/linearLayout" >\r
+    </LinearLayout>\r
+\r
+\r
+</RelativeLayout>\r
+\r
diff --git a/android/examples/simpleserver/src/main/res/menu/menu_main.xml b/android/examples/simpleserver/src/main/res/menu/menu_main.xml
new file mode 100755 (executable)
index 0000000..a1045e9
--- /dev/null
@@ -0,0 +1,6 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android"\r
+    xmlns:app="http://schemas.android.com/apk/res-auto"\r
+    xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">\r
+    <item android:id="@+id/action_settings" android:title="@string/action_settings"\r
+        android:orderInCategory="100" app:showAsAction="never" />\r
+</menu>\r
diff --git a/android/examples/simpleserver/src/main/res/values-w820dp/dimens.xml b/android/examples/simpleserver/src/main/res/values-w820dp/dimens.xml
new file mode 100755 (executable)
index 0000000..62df187
--- /dev/null
@@ -0,0 +1,6 @@
+<resources>\r
+    <!-- Example customization of dimensions originally defined in res/values/dimens.xml\r
+         (such as screen margins) for screens with more than 820dp of available width. This\r
+         would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->\r
+    <dimen name="activity_horizontal_margin">64dp</dimen>\r
+</resources>\r
diff --git a/android/examples/simpleserver/src/main/res/values/dimens.xml b/android/examples/simpleserver/src/main/res/values/dimens.xml
new file mode 100755 (executable)
index 0000000..295b5a9
--- /dev/null
@@ -0,0 +1,5 @@
+<resources>\r
+    <!-- Default screen margins, per the Android Design guidelines. -->\r
+    <dimen name="activity_horizontal_margin">16dp</dimen>\r
+    <dimen name="activity_vertical_margin">16dp</dimen>\r
+</resources>\r
diff --git a/android/examples/simpleserver/src/main/res/values/strings.xml b/android/examples/simpleserver/src/main/res/values/strings.xml
new file mode 100755 (executable)
index 0000000..4414f1d
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<resources>\r
+\r
+    <string name="app_name">SimpleServer</string>\r
+    <string name="simpleServer">Starting Simple Server...</string>\r
+    <string name="action_settings">Settings</string>\r
+\r
+</resources>\r
diff --git a/android/examples/simpleserver/src/main/res/values/styles.xml b/android/examples/simpleserver/src/main/res/values/styles.xml
new file mode 100755 (executable)
index 0000000..084b42b
--- /dev/null
@@ -0,0 +1,8 @@
+<resources>\r
+\r
+    <!-- Base application theme. -->\r
+    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">\r
+        <!-- Customize your theme here. -->\r
+    </style>\r
+\r
+</resources>\r
index ea12dd6..19c3440 100755 (executable)
@@ -25,25 +25,18 @@ function build()
        # Note: for android, as oic-resource uses C++11 feature stoi and to_string,
        # it requires gcc-4.9, currently only android-ndk-r10(for linux)
        # and windows android-ndk-r10(64bit target version) support these features.
-       if [ "$BUILD_FOR_ANDROID" = "true" ]
-               then
-               echo "*********** Build Boost for android ***********"
-               pushd extlibs
-               .//buildDependencies.sh
-               popd
+       echo "*********** Build Boost for android ***********"
+       # disable parallel build for android as gradle depends on scons to finish first
+       export SCONSFLAGS="-Q"
 
-               echo "*********** Build for android x86 *************"
-               scons TARGET_OS=android TARGET_ARCH=x86 ANDROID_NDK=$1 RELEASE=$3
+       echo "*********** Build for android x86 *************"
+       scons TARGET_OS=android TARGET_ARCH=x86 RELEASE=$3 TARGET_TRANSPORT=IP
 
-               echo "*********** Build for android armeabi *************"
-               scons TARGET_OS=android TARGET_ARCH=armeabi ANDROID_NDK=$1 RELEASE=$3
+       echo "*********** Build for android armeabi *************"
+       scons TARGET_OS=android TARGET_ARCH=armeabi RELEASE=$3 TARGET_TRANSPORT=IP
 
-               echo "*********** Build for android armeabi-v7a *************"
-               scons TARGET_OS=android TARGET_ARCH=armeabi-v7a ANDROID_NDK=$1 RELEASE=$3
-
-               echo "*********** Build for android armeabi-v7a-hard *************"
-               scons TARGET_OS=android TARGET_ARCH=armeabi-v7a-hard ANDROID_NDK=$1 RELEASE=$3
-       fi
+       # enable parallel build
+       export SCONSFLAGS="-Q -j 4"
 
        echo "*********** Build for arduino avr *************"
        scons resource TARGET_OS=arduino UPLOAD=false BOARD=mega TARGET_ARCH=avr TARGET_TRANSPORT=IP SHIELD=ETH RELEASE=$3
@@ -53,6 +46,7 @@ function build()
        scons resource TARGET_OS=arduino UPLOAD=false BOARD=arduino_due_x TARGET_ARCH=arm TARGET_TRANSPORT=IP SHIELD=ETH RELEASE=$3
        scons resource TARGET_OS=arduino UPLOAD=false BOARD=arduino_due_x TARGET_ARCH=arm TARGET_TRANSPORT=IP SHIELD=WIFI RELEASE=$3
 
+
        if [ $(uname -s) = "Darwin" ]
        then
                echo "*********** Build for OSX *************"
@@ -109,3 +103,4 @@ scons resource LOGGING=false RELEASE=false
 scons resource TEST=1 RELEASE=false
 echo "===================== done ====================="
 
+
index 7dfac8c..6a88107 100644 (file)
@@ -6,22 +6,42 @@ import platform
 import subprocess
 
 Import('env')
+SConscript('../external_libs.scons')
+SConscript('../../extlibs/android/ndk/SConscript')
+SConscript('../../extlibs/android/gradle/SConscript')
+SConscript('../../extlibs/android/sdk/SConscript')
 
 help_vars = Variables()
-help_vars.Add(PathVariable('ANDROID_NDK', 'Android NDK root directory', os.environ.get('ANDROID_NDK')))
-help_vars.Update(env)
-Help(help_vars.GenerateHelpText(env))
+help_vars.Add(PathVariable('ANDROID_GRADLE', 'Android Gradle directory', os.path.join(env.get('SRC_DIR'), 'extlibs', 'android', 'gradle', 'gradle-2.2.1/bin/gradle')))
+help_vars.Add(PathVariable('ANDROID_NDK', 'Android NDK root directory', os.path.join(env.get('SRC_DIR'), 'extlibs', 'android', 'ndk', 'android-ndk-r10d')))
 
-android_ndk = env.get('ANDROID_NDK')
-if not android_ndk:
+if env.get('ANDROID_NDK'):
+       android_ndk = env.get('ANDROID_NDK')
+else:
        print '''
-*************************************** Error *********************************
-*    Android NDK path isn't set, you can set enviornment variable ANDROID_NDK *
-* or add it in command line as:                                               *
+*************************************** Info **********************************
+*    Android NDK path isn't set, the default will be used. You can set        *
+* environment variable ANDROID_NDK or add it in command line as:              *
 *      # scons ANDROID_NDK=<path to android NDK> ...                          *
 *******************************************************************************
 '''
-       Exit(1)
+       android_ndk = os.path.join(env.get('SRC_DIR'), 'extlibs', 'android', 'ndk', 'android-ndk-r10d')
+
+if env.get('ANDROID_GRADLE'):
+       android_gradle = env.get('ANDROID_GRADLE')
+else:
+       print '''
+*************************************** Info **********************************
+*    Android Gradle path isn't set, the default will be used. You can set     *
+* environment variable ANDROID_GRADLE or add it in command line as:           *
+*      # scons ANDROID_GRADLE=<path to android GRADLE> ...                    *
+*******************************************************************************
+'''
+       android_gradle = os.path.join(env.get('SRC_DIR'), 'extlibs', 'android', 'gradle', 'gradle-2.2.1', 'bin', 'gradle')
+
+help_vars.Update(env)
+Help(help_vars.GenerateHelpText(env))
+src_dir = env.get('SRC_DIR')
 
 # Overwrite suffixes and prefixes
 if env['HOST_OS'] == 'win32':
@@ -66,15 +86,17 @@ if not os.path.isfile(ndk_build_cmd):
 ''' % android_ndk
        Exit(1)
 
-ANDROID_HOME = os.environ.get('ANDROID_HOME')
-if ANDROID_HOME is not None:
-       ANDROID_HOME = os.path.abspath(ANDROID_HOME)
+# ANDROID_HOME build option
+help_vars = Variables()
+help_vars.Add(PathVariable('ANDROID_HOME', 'ANDROID SDK root directory', os.environ.get('ANDROID_HOME')))
+help_vars.Update(env)
+Help(help_vars.GenerateHelpText(env))
 
-if ANDROID_HOME is None or not os.path.exists(ANDROID_HOME):
-       print '''
-*************************************** Warning *******************************
-*   Enviornment variable ANDROID_HOME is not set properly. It should be the   *
-* root directory of android sdk. If you'd like build Java code, it's required.*
+print '''
+*************************************** Info **********************************
+*   Environment variable ANDROID_HOME will use default value. To override     *
+* root directory of android sdk, please specify ANDROID_HOME as follows:      *
+*       scons ANDROID_HOME= <path to Android SDK>                             *
 *******************************************************************************
 '''
 
@@ -88,6 +110,7 @@ for tc_ver in ['4.7', '4.8', '4.9', '']:
 
 cmd = [ndk_build_cmd]
 cmd.append('APP_ABI=' + target_arch)
+cmd.append('APP_PLATFORM=android-21')
 cmd.append('APP_STL=gnustl_shared')
 if env.get('RELEASE'):
        cmd.append('APP_OPTIM=release')
@@ -151,6 +174,12 @@ for flags in p.stdout.readlines():
                if not platform_ver.isdigit():
                        platform_ver = ''
 
+
+       elif cmp(flags[0:9], 'PLATFORM=') == 0:  # get target platform: android-x
+               platform_ver = flags[9+8:].strip()
+               if not platform_ver.isdigit():
+                       platform_ver = ''
+
 # Determine dependency faux SYS_ROOT
 dep_sys_root = os.path.join(env.get('SRC_DIR'), 'dep', 'android', target_arch, 'usr')
 dep_src_dir =  os.path.join(dep_sys_root, 'include')
@@ -181,7 +210,6 @@ env.AppendUnique(CCFLAGS = ['-Wall', '-fPIC'])
 #env.AppendUnique(LINKFLAGS = ['-ldl', '-lpthread'])
 
 env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-src_dir = env.get('SRC_DIR')
 env.AppendUnique(LIBPATH = [src_dir + '/resource/csdk/connectivity/lib/android'])
 env.AppendUnique(LIBS = ['log', 'coap'])
 
diff --git a/extlibs/android/gradle/SConscript b/extlibs/android/gradle/SConscript
new file mode 100644 (file)
index 0000000..9cece4b
--- /dev/null
@@ -0,0 +1,29 @@
+import os, sys, platform, subprocess
+
+Import('env')
+
+env = env.Clone()
+ndk_env = env.Clone()
+SConscript('../../../build_common/external_libs.scons')
+
+target_os = env.get('TARGET_OS')
+host_os = sys.platform
+print host_os
+SConscript('../../../build_common/external_libs.scons')
+######################################################################
+# Build flags
+######################################################################
+src_dir = env.get('SRC_DIR')
+
+path = os.path.join(src_dir, 'extlibs', 'android', 'gradle', 'gradle-2.2.1')
+
+# check 'gradle' library, if it doesn't exits, ask user to download it
+if not os.path.exists(path):
+       gradle_zip = env.Download('gradle2.2.1.zip', 'https://services.gradle.org/distributions/gradle-2.2.1-all.zip')
+       gradle_dir = env.UnpackAll('gradle-2.2.1', gradle_zip)
+       print '''
+***********************************************************************
+* Downloading gradle:                    *
+*******************************************************************************
+'''
+
diff --git a/extlibs/android/ndk/SConscript b/extlibs/android/ndk/SConscript
new file mode 100644 (file)
index 0000000..cc36c4e
--- /dev/null
@@ -0,0 +1,37 @@
+import os, string, sys, subprocess, struct
+
+Import('env')
+
+env = env.Clone()
+ndk_env = env.Clone()
+
+target_os = env.get('TARGET_OS')
+target_arch = env.get('TARGET_ARCH')
+
+host_os = sys.platform
+
+######################################################################
+# Build flags
+######################################################################
+src_dir = env.get('SRC_DIR')
+path = os.path.join(src_dir, 'extlibs', 'android', 'ndk', 'android-ndk-r10d')
+
+# check 'ndk' library, if it doesn't exits, ask user to download it
+if not os.path.exists(path):
+       ndk_env = Environment(ENV = os.environ)
+       if host_os == 'linux2' :
+               archType = 8 * struct.calcsize("P")
+               if archType == 64:
+                       env.Download('android-ndk-r10d.bin', 'http://dl.google.com/android/ndk/android-ndk-r10d-linux-x86_64.bin')
+               else:
+                       env.Download('android-ndk-r10d.bin', 'http://dl.google.com/android/ndk/android-ndk-r10d-linux-x86.bin')
+
+               os.system("chmod a+x android-ndk-r10d.bin")
+               os.system("./android-ndk-r10d.bin")
+       else:
+               if target_arch in ['x86_64']:
+                       env.Download('android-ndk-r10d', 'http://dl.google.com/android/ndk/android-ndk-r10d-windows-x86_64.exe')
+               if target_arch in ['x86']:
+                       env.Download('android-ndk-r10d', 'http://dl.google.com/android/ndk/android-ndk-r10d-windows-x86.exe')
+
+
diff --git a/extlibs/android/sdk/SConscript b/extlibs/android/sdk/SConscript
new file mode 100644 (file)
index 0000000..aa268e6
--- /dev/null
@@ -0,0 +1,58 @@
+##
+# Script to install (if they do not exist) the Android SDK library (ie. Android JDK)
+##
+
+import os, subprocess, struct
+import urllib2, urlparse
+import SCons.Errors
+import shutil
+
+Import('env')
+
+target_os = env.get('TARGET_OS')
+src_dir = env.get('SRC_DIR')
+
+SConscript(src_dir + '/build_common/tools/UnpackAll.py')
+SConscript(src_dir + '/build_common/external_libs.scons')
+
+# Download
+if target_os == 'android':
+       android_home = env.get('ANDROID_HOME')
+       if not android_home:
+               print 'Creating ANDROID_HOME for Android SDK'
+
+               androidlib_dir      = src_dir + '/extlibs/android/sdk/android-sdk_r24.2'
+
+               if not os.path.exists(androidlib_dir):
+                       from sys import platform as _platform
+                       if _platform == "linux" or _platform == "linux2":
+                               androidlib_zip_file = src_dir + '/extlibs/android/android-sdk_r24.2-linux.tgz'
+                               androidlib_url      = 'http://dl.google.com/android/android-sdk_r24.2-linux.tgz'
+                       elif _platform == "darwin":
+                               androidlib_zip_file = src_dir + '/extlibs/android/android-sdk_r24.2-macosx.zip'
+                               androidlib_url      = 'http://dl.google.com/android/android-sdk_r24.2-macosx.zip'
+                       elif _platform == "win32":
+                               androidlib_zip_file = src_dir + '/extlibs/android/android-sdk_r24.2-windows.zip'
+                               androidlib_url      = 'http://dl.google.com/android/android-sdk_r24.2-windows.zip'
+
+                       # If the zip file is not already present, download it
+                       if not os.path.exists(androidlib_zip_file):
+                               androidlib_zip = env.Download(androidlib_zip_file, androidlib_url)
+                       else:
+                               androidlib_zip = androidlib_zip_file
+
+                       # Unzip the lib
+                       print 'Unzipping android lib...'
+                       env.UnpackAll(androidlib_dir, androidlib_zip)
+                       print 'Unzipping android lib complete'
+    
+                       # Remove downloaded file
+#                      os.remove(androidlib_zip_file)
+       else:
+               androidlib_dir = env.get('ANDROID_HOME')
+
+# Set the ANDROID_HOME
+env.Replace(ANDROID_HOME = androidlib_dir)
+print 'ANDROID_HOME = ' + env.get('ANDROID_HOME')
+
+
index 1d8b47b..0fe0662 100644 (file)
@@ -20,7 +20,7 @@ if 'android' == target_os :
     env.Tool('BoostBootstrap', toolpath=['../../tools/scons'])
     env.Tool('BoostBuild',     toolpath=['../../tools/scons'])
 
-    boost_version   = '1.57.0'
+    boost_version   = '1.58.0'
     boost_base_name  = 'boost_'+string.replace(boost_version,'.','_')
     boost_arch_name  = boost_base_name+'.zip'
     boost_url       = 'http://downloads.sourceforge.net/project/boost/boost/'+boost_version+'/'+boost_arch_name+'?r=&ts=1421801329&use_mirror=iweb'
index e9cddf5..9f96e77 100644 (file)
@@ -30,7 +30,7 @@ Import('env')
 target_os = env.get('TARGET_OS')
 src_dir = env.get('SRC_DIR')
 
-if target_os not in ['arduino', 'darwin', 'ios']:
+if target_os not in ['arduino', 'darwin', 'ios', 'android']:
        env.AppendUnique(LIBS=['rt'])
 
 # Build libcoap
old mode 100644 (file)
new mode 100755 (executable)
index 7a64501..5b2c5b0
@@ -96,17 +96,18 @@ Note :- Currently Mega & Due build is supported.
 3) Execute following command to start build :
 
 For Arduino Mega
-    $ scons TARGET_OS=arduino TARGET_TRANSPORT=<transport> SHIELD=<shield> TARGET_ARCH=avr BOARD=mega ARDUINO_HOME=<path_to_arduino_installation>
+    $ scons TARGET_OS=arduino TARGET_TRANSPORT=<transport> TARGET_ARCH=avr BOARD=mega ARDUINO_HOME=<path_to_arduino_installation>
 For Arduino Due
-    $ scons TARGET_OS=arduino TARGET_TRANSPORT=<transport> SHIELD=<shield> TARGET_ARCH=arm BOARD=arduino_due_x_dbg ARDUINO_HOME=<path_to_arduino_installation>
+    $ scons TARGET_OS=arduino TARGET_TRANSPORT=<transport> TARGET_ARCH=arm BOARD=arduino_due_x_dbg ARDUINO_HOME=<path_to_arduino_installation>
     NOTE: BOARD=arduino_due_x_dbg|arduino_due_x. Default is arduino_due_x_dbg.
 
     Possible values for <transport> are:
-    -> IP :
-    $ scons TARGET_OS=arduino TARGET_TRANSPORT=IP SHIELD=WIFI TARGET_ARCH=avr BOARD=mega ARDUINO_HOME=<path_to_arduino_installation>
-    $ scons TARGET_OS=arduino TARGET_TRANSPORT=IP SHIELD=ETH TARGET_ARCH=avr BOARD=mega ARDUINO_HOME=<path_to_arduino_installation>
+    -> ETHERNET :
+    $ scons TARGET_OS=arduino TARGET_TRANSPORT=ETHERNET TARGET_ARCH=avr BOARD=mega ARDUINO_HOME=<path_to_arduino_installation>
+    -> WIFI :
+    $ scons TARGET_OS=arduino TARGET_TRANSPORT=WIFI TARGET_ARCH=avr BOARD=mega ARDUINO_HOME=<path_to_arduino_installation>
     -> BLE :
-    $ scons TARGET_OS=arduino TARGET_TRANSPORT=BLE SHIELD=RBL_NRF8001 TARGET_ARCH=avr BOARD=mega ARDUINO_HOME=<path_to_arduino_installation>
+    $ scons TARGET_OS=arduino TARGET_TRANSPORT=BLE TARGET_ARCH=avr BOARD=mega ARDUINO_HOME=<path_to_arduino_installation>
 
     Note :- Only single transport can be built at a time for Arduino.
 
@@ -114,11 +115,11 @@ For Arduino Due
 
 5) After building sample, script will try to install on "/dev/ttyACM0" port in 'sudo' mode.
    To skip installation, set command line argument 'UPLOAD=false'.
-   "scons TARGET_OS=arduino TARGET_TRANSPORT=IP SHIELD=ETH TARGET_ARCH=avr BOARD=mega ARDUINO_HOME=<path_to_arduino_installation> UPLOAD=false"
+   "scons TARGET_OS=arduino TARGET_TRANSPORT=ETHERNET TARGET_ARCH=avr BOARD=mega ARDUINO_HOME=<path_to_arduino_installation> UPLOAD=false"
 
 6) To set BLE Shield Name, include the option DEVICE_NAME during scons build.
 
-   -> $ scons TARGET_OS=arduino TARGET_TRANSPORT=BLE SHIELD=RBL_NRF8001 TARGET_ARCH=avr BOARD=mega ARDUINO_HOME=<path_to_arduino_installation> DEVICE_NAME=OIC
+   -> $ scons TARGET_OS=arduino TARGET_TRANSPORT=ETHERNET TARGET_ARCH=avr BOARD=mega ARDUINO_HOME=<path_to_arduino_installation> DEVICE_NAME=OIC
 
    Specified Device name length MUST be less than 10 characters. RBL Library has this limitation.
    By Default DEVICE_NAME=OIC-DEVICE, if device name option is not specified
old mode 100644 (file)
new mode 100755 (executable)
index b29c55a..b901f1a
@@ -267,4 +267,3 @@ if env.GetOption('clean'):
                Execute(Delete(dir + '/.sconf_temp'))
 
 Return('env')
-
diff --git a/resource/csdk/connectivity/build/android/Makefile b/resource/csdk/connectivity/build/android/Makefile
new file mode 100755 (executable)
index 0000000..038e36b
--- /dev/null
@@ -0,0 +1,19 @@
+#Assumes ndk directory is at ~/
+#set ndk directory PATH in .bashrc and use the ndk-build directly
+#change NDK_PATH to ${your_ndk_path}
+NDK_PATH = ~/ndk
+NDK_BUILD = $(NDK_PATH)/ndk-build
+
+BUILD_DIR = $(CURDIR)
+APPLICATION_BUILD = $(BUILD_DIR)
+ROOT_DIR = $(BUILD_DIR)
+
+#Clean files
+LIBS_DIR = $(ROOT_DIR)/libs
+OBJ_DIR = $(ROOT_DIR)/obj
+
+all:
+       $(NDK_BUILD) NDK_PROJECT_PATH=$(APPLICATION_BUILD)
+
+clean :
+       @$(RM) -rf $(LIBS_DIR) $(OBJ_DIR)
diff --git a/resource/csdk/connectivity/build/arduino/Makefile b/resource/csdk/connectivity/build/arduino/Makefile
new file mode 100755 (executable)
index 0000000..7524a33
--- /dev/null
@@ -0,0 +1,75 @@
+#
+# override with `make BUILD=debug`
+# override with `make PLATFORM=arduinomega` or `make PLATFORM=arduinodue`
+# TRANSPORT can be ETHERNET, WIFI, BT, BLE. Include Corresponding Transport during compilation. For Eg: `make PLATFORM=arduinomega TRANSPORT=BLE
+# default to release build
+# default to build for arduinomega
+# default to build for BLE Transport
+BUILD   := release
+PLATFORM := arduinomega
+TRANSPORT := BLE
+OBJ_DIR := ./bin
+APP_NAME := casample
+ARDUINO_PORT := ttyACM0
+
+include ./local.properties
+include ./$(PLATFORM).properties
+
+VPATH := $(SDIR_ARD_PLATFORM)
+
+#Include __ARDUINO_BLE__ flag for BLE Transport. Currently, BLE Sample APP is segregated with this MACRO
+ifeq ($(TRANSPORT),BLE)
+CFLAGS         := -Os -Wall -c -DTB_LOG -DOIC_ARDUINODUE -DINTERFACESAMPLE_ARDUINO -DARDUINO -DOIC_ARDUINODUE -D__ARDUINO__ -DWITH_ARDUINO -D__ARDUINO_BLE__ -DLE_ADAPTER
+else ifeq ($(TRANSPORT),WIFI)
+CFLAGS         := -Os -Wall -c -DTB_LOG -DOIC_ARDUINODUE -DINTERFACESAMPLE_ARDUINO -DARDUINO -DOIC_ARDUINODUE -D__ARDUINO__ -DWITH_ARDUINO -DWIFI_ADAPTER
+else
+CFLAGS         := -Os -Wall -c -DTB_LOG -DOIC_ARDUINODUE -DINTERFACESAMPLE_ARDUINO -DARDUINO -DOIC_ARDUINODUE -D__ARDUINO__ -DWITH_ARDUINO -DETHERNET_ADAPTER
+endif
+
+all: prep_dirs core.a $(APP_NAME).o $(APP_NAME).elf $(APP_NAME).hex
+
+$(info *********PLATFORM_OBJS!!**********)
+core.a: $(PLATFORM_OBJS)
+       @cd $(OBJ_DIR) && $(AR) -x ../../../lib/libcoap-4.1.1/$(BUILD)/libcoap.a
+       $(AR) rcs $@ $(CORE_COBJ) $(CORE_CPPOBJ) $(PLATFORM_OBJS) $(OBJ_DIR)/*.o
+       $(RANLIB) $@
+
+prep_dirs:
+       -mkdir $(OBJ_DIR)
+
+logger.c.o: logger.c
+       $(CCPLUS) $(CFLAGS) $(CFLAGS_PLATFORM) $(INC_DIR_PLATFORM) $< -o $@
+
+%.c.o: %.c
+       $(CC) $(CFLAGS) $(CFLAGS_PLATFORM) $(INC_DIR_PLATFORM) $< -o $@
+
+%.o: %.c
+       $(CC) $(CFLAGS) $(CFLAGS_PLATFORM) $(INC_DIR_PLATFORM) $< -o $@
+
+%.o: %.cpp
+       $(CCPLUS) $(CFLAGS) $(CFLAGS_PLATFORM) $(INC_DIR_PLATFORM) $< -o $@
+
+%.cpp.o: %.cpp
+       $(CCPLUS) $(CFLAGS) $(CFLAGS_PLATFORM) $(INC_DIR_PLATFORM) $< -o $@
+
+# core.a and $(APP_NAME).cpp.o are combined to generate $(APP_NAME).elf.
+# For Integration with Top Layer, we can link top layer with core.a
+$(APP_NAME).elf: $(APP_NAME).cpp.o core.a
+       $(CC) -w -Os -Wl,--gc-sections,--relax -mmcu=atmega2560 -o $@ $^ -L$(ARDUINO_DIR)/libraries -lm
+
+$(APP_NAME).hex: $(APP_NAME).elf
+       $(AVR_OBJCOPY) -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 $< $(APP_NAME).eep
+       $(AVR_OBJCOPY) -O ihex -R .eeprom $< $@
+
+install: all
+       $(AVR_PROGRAMMER) -C$(ARDUINO_DIR)/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega2560 -cstk500v2 -P/dev/$(ARDUINO_PORT) -b115200 -D -Uflash:w:$(APP_NAME).hex:i
+
+
+.PHONY: clean
+clean:
+       @rm -f *.o *.d *.elf *.eep core.a *.hex *.bin *.map *-
+       @rm -rf $(OBJ_DIR)
+
+
+
+
old mode 100644 (file)
new mode 100755 (executable)
index b6919e7..4c13ebd
@@ -26,3 +26,4 @@ env.ImportLib('Time/Time')
 env.AppendUnique(CPPDEFINES = ['WITH_ARDUINO', '__ARDUINO__'])
 if env.get('LOGGING'):
        env.AppendUnique(CPPDEFINES = ['TB_LOG'])
+
diff --git a/resource/csdk/connectivity/build/common.mk b/resource/csdk/connectivity/build/common.mk
new file mode 100755 (executable)
index 0000000..858dda1
--- /dev/null
@@ -0,0 +1,60 @@
+#/******************************************************************
+# *
+# * Copyright 2014 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.
+# *
+#******************************************************************/
+
+##
+##     Definitions
+##
+SHELL                                          = /bin/bash
+PROJECT_NAME                           = connectivity_abstraction
+PROJECT_ROOT_PATH                      = ..
+PROJECT_API_PATH                               = $(PROJECT_ROOT_PATH)/api
+PROJECT_INC_PATH                               = $(PROJECT_ROOT_PATH)/inc
+PROJECT_SRC_PATH                       = $(PROJECT_ROOT_PATH)/src
+PROJECT_COMMON_INC_PATH        = $(PROJECT_ROOT_PATH)/common/inc
+PROJECT_COMMON_SRC_PATH        = $(PROJECT_ROOT_PATH)/common/src
+PROJECT_COMMON_PATH            = $(PROJECT_ROOT_PATH)/common
+PROJECT_OUT_PATH                       = $(PROJECT_ROOT_PATH)/build/out
+PROJECT_LIB_PATH                               = $(PROJECT_ROOT_PATH)/lib
+
+##
+##     macro
+##
+define MAKE_PROJECT_OUT_PATH
+       @if     [ ! -d $(PROJECT_OUT_PATH) ]; then      \
+       mkdir $(PROJECT_OUT_PATH);      \
+       fi
+endef
+
+
+##
+##     Commands
+##
+CC                     = gcc
+CXX                    = g++
+RM                     = rm -rf
+CP                     = cp
+MV                     = mv
+AR                     = ar
+LD                     = ld
+LN                     = ln
+CD                     = cd
+RANLIB         = ranlib
+
+
diff --git a/resource/csdk/connectivity/build/tizen/Makefile b/resource/csdk/connectivity/build/tizen/Makefile
new file mode 100755 (executable)
index 0000000..8e56590
--- /dev/null
@@ -0,0 +1,65 @@
+##
+# override with `make BUILD=debug`
+# override with `make PLATFORM=arduinomega` or `make PLATFORM=arduinodue`
+# default to release build
+# default to build for linux
+BUILD   := debug
+PLATFORM := tizen
+OBJ_DIR := ./bin
+ROOT_DIR := .
+VERSION_MAJOR := 0
+VERSION_MINOR := 1
+VERSION_PATCH := 0
+ADAPTER_MACRO := -DWIFI_ADAPTER
+
+$(info *******************tizen Build !!******************)
+
+CC=gcc
+LIBCOAP=./lib/libcoap-4.1.1/
+LIBCOAP_OBJ_DIR=./lib/libcoap-4.1.1/obj
+
+TINYDTLS=./lib/extlibs/tinydtls
+TINYDTLS_OBJ_DIR=./lib/extlibs/tinydtls/obj
+
+# TODO : Currently Hardcoded WIFI_ADAPTER. Change it to generic
+CFLAGS.debug = -DWITH_POSIX -D__TIZEN__ -Wall -std=c99 -DSLP_SDK_LOG -g -D_GNU_SOURCE -DTIZEN_DEBUG_ENABLE -DTB_LOG $(ADAPTER_MACRO)
+CFLAGS.release = -DWITH_POSIX -D__TIZEN__ -Wall -std=c99 -DSLP_SDK_LOG -D_GNU_SOURCE -DTIZEN_DEBUG_ENABLE -DTB_LOG $(ADAPTER_MACRO)
+COMPILEFLAG = `pkg-config --cflags --libs capi-network-wifi dlog capi-network-bluetooth glib-2.0`
+
+# Include files will be copied into a single folder on gbsbuild.
+# NO NEED to mention the path explicitly.
+
+CA_INC              = $(ROOT_DIR)/
+DTLS_INC           = $(ROOT_DIR)/dtls/
+
+INC_DIRS        := -I$(CA_INC)
+INC_DIRS        += -I$(DTLS_INC)
+
+SRC = $(wildcard *.c)
+OBJECTS = $(patsubst %.c, %.o, $(SRC))
+
+#Currently compiling libcoap objects. If it's provided by external party. 
+#Then don't compile, Instead directly extract objects and create liboicinterface.a
+all: $(OBJECTS)
+       $(MAKE) -C $(LIBCOAP) clean
+       $(MAKE) -C $(LIBCOAP)
+       -mkdir $(LIBCOAP_OBJ_DIR)
+       @cd $(LIBCOAP_OBJ_DIR) && $(AR) -x ../libcoap.a
+       ar rcs liboicinterface.a $(OBJECTS) $(LIBCOAP_OBJ_DIR)/*.o
+
+%.o : %.c
+       $(CC) -c $(CFLAGS.$(BUILD)) $(COMPILEFLAG) $(INC_DIRS) $< -o $@
+
+
+pack:
+#$(CC) $(CFLAGS) $(COMPILEFLAG) WiFiInterface.c bt_interface.c tc_interface.c sample_main.c -o sample /usr/lib/liboctbstack.a -lm -pthread
+       $(info **************************************TEST***************************)
+install:
+#cp -rf sample ./usr/apps/com.samsung.oicca/bin/sample
+
+clean:
+       rm -rf *.o sample
+       rm -f *.o *.d *.elf *.eep core.a *.hex *.bin *.map *-
+       rm -rf $(OBJ_DIR)
+       rm -rf $(LIBCOAP_OBJ_DIR)
+
diff --git a/resource/csdk/connectivity/build/tizen/SConscript b/resource/csdk/connectivity/build/tizen/SConscript
new file mode 100755 (executable)
index 0000000..3c72392
--- /dev/null
@@ -0,0 +1,241 @@
+##
+# This script includes generic build options:
+#    release/debug, target os, target arch, cross toolchain, build environment etc
+##
+import os
+import platform
+
+# Map of host os and allowed target os (host: allowed target os)
+host_target_map = {
+               'linux': ['linux', 'android', 'arduino', 'yocto', 'tizen'],
+               'windows': ['windows', 'winrt', 'android', 'arduino', 'tizen'],
+               'darwin': ['darwin', 'ios', 'android', 'arduino'],
+               }
+
+# Map of os and allowed archs (os: allowed archs)
+os_arch_map = {
+               'linux': ['x86', 'x86_64', 'arm', 'arm64'],
+               'android': ['x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'armeabi-v7a-hard', 'arm64-v8a'],
+               'windows': ['x86', 'amd64', 'arm'],
+               'winrt': ['arm'],
+               'darwin': ['i386', 'x86_64'],
+               'ios': ['i386', 'x86_64', 'armv7', 'armv7s', 'arm64'],
+               'arduino': ['avr', 'arm'],
+                'yocto': ['x86', 'x86_64'],
+               'tizen': ['armv7'],
+               }
+
+host = platform.system().lower()
+
+if not host_target_map.has_key(host):
+       print "\nError: Current system (%s) isn't supported\n" % host
+       Exit(1)
+
+######################################################################
+# Get build options (the optins from command line)
+######################################################################
+target_os = ARGUMENTS.get('TARGET_OS', host).lower() # target os
+
+if target_os not in host_target_map[host]:
+       print "\nError: Unknown target os: %s (Allow values: %s)\n" % (target_os, host_target_map[host])
+       Exit(1)
+
+default_arch = platform.machine()
+if default_arch not in os_arch_map[target_os]:
+       default_arch = os_arch_map[target_os][0].lower()
+
+target_arch = ARGUMENTS.get('TARGET_ARCH', default_arch) # target arch
+
+######################################################################
+# Common build options (release, target os, target arch)
+######################################################################
+help_vars = Variables()
+help_vars.Add(BoolVariable('RELEASE', 'Build for release?', True)) # set to 'no', 'false' or 0 for debug
+help_vars.Add(EnumVariable('TARGET_OS', 'Target platform', host, host_target_map[host]))
+help_vars.Add(ListVariable('TARGET_TRANSPORT', 'Target transport', 'ALL', ['ALL', 'WIFI', 'ETHERNET', 'BT', 'BLE']))
+help_vars.Add(EnumVariable('TARGET_ARCH', 'Target architecture', default_arch, os_arch_map[target_os]))
+help_vars.Add(EnumVariable('SECURED', 'Build with DTLS', '0', allowed_values=('0', '1')))
+help_vars.Add(EnumVariable('BUILD_SAMPLE', 'Build with sample', 'ON', allowed_values=('ON', 'OFF')))
+
+######################################################################
+# Platform(build target) specific options: SDK/NDK & toolchain
+######################################################################
+targets_support_cc = ['linux', 'arduino', 'tizen']
+
+if target_os in targets_support_cc:
+       # Set cross compile toolchain
+       help_vars.Add('TC_PREFIX', "Toolchain prefix (Generally only be required for cross-compiling)", os.environ.get('TC_PREFIX'))
+       help_vars.Add(PathVariable('TC_PATH',
+                       'Toolchain path (Generally only be required for cross-compiling)',
+                       os.environ.get('TC_PATH')))
+
+if target_os in ['android', 'arduino']: # Android/Arduino always uses GNU compiler regardless of the host
+       env = Environment(variables = help_vars,
+                       tools = ['gnulink', 'gcc', 'g++', 'ar', 'as']
+                       )
+else:
+       env = Environment(variables = help_vars, TARGET_ARCH = target_arch, TARGET_OS = target_os)
+
+Help(help_vars.GenerateHelpText(env))
+
+tc_set_msg = '''
+************************************ Warning **********************************
+*   Enviornment variable TC_PREFIX/TC_PATH is set. It will change the default *
+* toolchain, if it isn't what you expect you should unset it, otherwise it may*
+* cause inexplicable errors.                                                  *
+*******************************************************************************
+'''
+
+if target_os in targets_support_cc:
+       prefix = env.get('TC_PREFIX')
+       tc_path = env.get('TC_PATH')
+       if prefix:
+               env.Replace(CC = prefix + 'gcc')
+               env.Replace(CXX = prefix + 'g++')
+               env.Replace(AR = prefix + 'ar')
+               env.Replace(AS = prefix + 'as')
+               env.Replace(LINK = prefix + 'ld')
+               env.Replace(RANLIB = prefix + 'ranlib')
+
+       if tc_path:
+               env.PrependENVPath('PATH', tc_path)
+               sys_root = os.path.abspath(tc_path + '/../')
+               env.AppendUnique(CCFLAGS = ['--sysroot=' + sys_root])
+               env.AppendUnique(LINKFLAGS = ['--sysroot=' + sys_root])
+
+       if prefix or tc_path:
+               print tc_set_msg
+
+# Ensure scons be able to change its working directory
+env.SConscriptChdir(1)
+
+# Set the source directory and build directory
+#   Source directory: 'dir'
+#   Build directory: 'dir'/out/<target_os>/<target_arch>/<release or debug>/
+#
+# You can get the directory as following:
+#   env.get('SRC_DIR')
+#   env.get('BUILD_DIR')
+
+def __set_dir(env, dir):
+       if not os.path.exists(dir + '/SConstruct'):
+               print '''
+*************************************** Error *********************************
+* The directory(%s) seems isn't a source code directory, no SConstruct file is
+* found. *
+*******************************************************************************
+''' % dir
+               Exit(1)
+
+       if env.get('RELEASE'):
+               build_dir = dir + '/out/' + target_os + '/' + target_arch + '/release/'
+       else:
+               build_dir = dir + '/out/' + target_os + '/' + target_arch + '/debug/'
+       env.VariantDir(build_dir, dir, duplicate=0)
+
+       env.Replace(BUILD_DIR = build_dir)
+       env.Replace(SRC_DIR = dir)
+
+def __src_to_obj(env, src, home = ''):
+       obj = env.get('BUILD_DIR') + src.replace(home, '')
+       if env.get('OBJSUFFIX'):
+               obj += env.get('OBJSUFFIX')
+       return env.Object(obj, src)
+
+def __install(ienv, targets, name):
+       i_n = ienv.Install(env.get('BUILD_DIR'), targets)
+       Alias(name, i_n)
+       env.AppendUnique(TS = [name])
+
+def __append_target(ienv, target):
+       env.AppendUnique(TS = [target])
+
+def __print_targets(env):
+       Help('''
+===============================================================================
+Targets:\n    ''')
+       for t in env.get('TS'):
+               Help(t + ' ')
+       Help('''
+\nDefault all targets will be built. You can specify the target to build:
+
+    $ scons [options] [target]
+===============================================================================
+''')
+
+env.AddMethod(__set_dir, 'SetDir')
+env.AddMethod(__print_targets, 'PrintTargets')
+env.AddMethod(__src_to_obj, 'SrcToObj')
+env.AddMethod(__append_target, 'AppendTarget')
+env.AddMethod(__install, 'InstallTarget')
+env.SetDir(env.GetLaunchDir())
+env['ROOT_DIR']=env.GetLaunchDir()
+
+Export('env')
+
+######################################################################
+# Link scons to Yocto cross-toolchain ONLY when target_os is yocto
+######################################################################
+if target_os == "yocto":
+    '''
+    This code injects Yocto cross-compilation tools+flags into scons' 
+    build environment in order to invoke the relevant tools while 
+    performing a build.
+    '''
+    import os.path
+    try:
+        CC = os.environ['CC']
+        target_prefix = CC.split()[0]
+        target_prefix = target_prefix[:len(target_prefix)-3]
+        tools = {"CC" : target_prefix+"gcc",
+                "CXX" : target_prefix+"g++",
+                "AS" : target_prefix+"as",
+                "LD" : target_prefix+"ld",
+                "GDB" : target_prefix+"gdb",
+                "STRIP" : target_prefix+"strip",
+                "RANLIB" : target_prefix+"ranlib",
+                "OBJCOPY" : target_prefix+"objcopy",
+                "OBJDUMP" : target_prefix+"objdump",
+                "AR" : target_prefix+"ar",
+                "NM" : target_prefix+"nm",
+                "M4" : "m4",
+                "STRINGS": target_prefix+"strings"}
+        PATH = os.environ['PATH'].split(os.pathsep)
+        for tool in tools:
+            if tool in os.environ:
+                for path in PATH:
+                    if os.path.isfile(os.path.join(path, tools[tool])):
+                        env[tool] = os.path.join(path, os.environ[tool])
+                        break
+    except:
+        print "ERROR in Yocto cross-toolchain environment"
+        Exit(1)
+    '''
+    Now reset TARGET_OS to linux so that all linux specific build configurations
+    hereupon apply for the entirety of the build process.
+    '''
+    env['TARGET_OS'] = 'linux'
+    '''
+    We want to preserve debug symbols to allow BitBake to generate both DEBUG and
+    RELEASE packages for OIC. 
+    '''
+    env['CCFLAGS'].append('-g')
+    Export('env')
+else:
+    '''
+    If target_os is not Yocto, continue with the regular build process
+    '''
+    # Load config of target os
+    env.SConscript(target_os + '/SConscript')
+
+# Delete the temp files of configuration
+if env.GetOption('clean'):
+       dir = env.get('SRC_DIR')
+
+       if os.path.exists(dir + '/config.log'):
+               Execute(Delete(dir + '/config.log'))
+               Execute(Delete(dir + '/.sconsign.dblite'))
+               Execute(Delete(dir + '/.sconf_temp'))
+
+Return('env')
+
old mode 100644 (file)
new mode 100755 (executable)
index aed6145..385fe5b
@@ -1,8 +1,6 @@
 #!/bin/sh
 
-cur_dir="./resource/csdk/connectivity/"
-
-spec=`ls ./resource/csdk/connectivity/build/tizen/packaging/*.spec`
+spec=`ls build/tizen/packaging/*.spec`
 version=`rpm --query --queryformat '%{version}\n' --specfile $spec`
 
 name=`echo $name|cut -d" " -f 1`
@@ -28,24 +26,18 @@ echo `pwd`
 
 mkdir ./tmp
 mkdir ./tmp/con/
-cp -R $cur_dir/* $sourcedir/tmp/con
-cp -R $cur_dir/SConscript $sourcedir/tmp/con
-cp -R $cur_dir/src/ip_adapter/SConscript $sourcedir/tmp/con/src/ip_adapter/
-cp -R $cur_dir/src/bt_le_adapter/SConscript $sourcedir/tmp/con/src/bt_le_adapter/
-cp -R $cur_dir/src/bt_edr_adapter/SConscript $sourcedir/tmp/con/src/bt_edr_adapter/
-cp -R $cur_dir/common/SConscript $sourcedir/tmp/con/common/
-cp -R $cur_dir/lib/libcoap-4.1.1/SConscript $sourcedir/tmp/con/lib/libcoap-4.1.1/
-cp -R $cur_dir/samples/tizen/ $sourcedir/tmp/con/sample/
+cp -R ./* $sourcedir/tmp/con
+cp -R ./SConscript $sourcedir/tmp/con
+cp -R ./src/wifi_adapter/SConscript $sourcedir/tmp/con/src/wifi_adapter/
+cp -R ./src/bt_le_adapter/SConscript $sourcedir/tmp/con/src/bt_le_adapter/
+cp -R ./src/bt_edr_adapter/SConscript $sourcedir/tmp/con/src/bt_edr_adapter/
+cp -R ./common/SConscript $sourcedir/tmp/con/common/
+cp -R ./lib/libcoap-4.1.1/SConscript $sourcedir/tmp/con/lib/libcoap-4.1.1/
+cp -R ./samples/tizen/ $sourcedir/tmp/con/sample/
 mkdir -p $sourcedir/tmp/con/sample/lib/tizen/ble/libs
-cp -R $cur_dir/lib/tizen/ble/libs/* $sourcedir/tmp/con/sample/lib/tizen/ble/libs/
-
-mkdir -p $sourcedir/tmp/iotivityconfig
-cd $sourcedir/build_common/
-cp -R ./iotivityconfig/* $sourcedir/tmp/iotivityconfig/
-cp -R ./SConscript $sourcedir/tmp/
+cp -R ./lib/tizen/ble/libs/* $sourcedir/tmp/con/sample/lib/tizen/ble/libs/
 
-cd $sourcedir
-cd $cur_dir/build/tizen
+cd $sourcedir/build/tizen
 
 cp -R ./* $sourcedir/tmp/
 cp SConscript $sourcedir/tmp/
old mode 100644 (file)
new mode 100755 (executable)
index 6fedada..a8689a3
@@ -40,12 +40,13 @@ scons TARGET_OS=tizen TARGET_TRANSPORT=%{TARGET_TRANSPORT} RELEASE=%{RELEASE}
 mkdir -p %{DEST_INC_DIR}
 mkdir -p %{DEST_LIB_DIR}/pkgconfig
 
-cp -f %{ROOTDIR}/con/src/libconnectivity_abstraction.so %{buildroot}/%{_libdir}
-cp -f %{ROOTDIR}/con/lib/libcoap-4.1.1/libcoap.so %{buildroot}/%{_libdir}
+cp -f %{ROOTDIR}/con/src/libconnectivity_abstraction.a %{buildroot}/%{_libdir}
+cp -f %{ROOTDIR}/con/lib/libcoap-4.1.1/libcoap.a %{buildroot}/%{_libdir}
 cp -rf %{ROOTDIR}/con/api/cacommon.h* %{DEST_INC_DIR}/
 cp -rf %{ROOTDIR}/con/inc/caadapterinterface.h* %{DEST_INC_DIR}/
 cp -rf %{ROOTDIR}/con/common/inc/cathreadpool.h* %{DEST_INC_DIR}/
-cp -rf %{ROOTDIR}/con/inc/caipadapter.h* %{DEST_INC_DIR}/
+cp -rf %{ROOTDIR}/con/inc/cawifiadapter.h* %{DEST_INC_DIR}/
+cp -rf %{ROOTDIR}/con/inc/caethernetadapter.h* %{DEST_INC_DIR}/
 cp -rf %{ROOTDIR}/con/inc/caedradapter.h* %{DEST_INC_DIR}/
 cp -rf %{ROOTDIR}/con/inc/caleadapter.h* %{DEST_INC_DIR}/
 cp -rf %{ROOTDIR}/con/api/cainterface.h* %{DEST_INC_DIR}/
@@ -55,7 +56,7 @@ cp -rf %{ROOTDIR}/com.oic.ca.pc %{DEST_LIB_DIR}/pkgconfig/
 %files
 %manifest com.oic.ca.manifest
 %defattr(-,root,root,-)
-%{_libdir}/lib*.so*
+%{_libdir}/lib*.a*
 %{_includedir}/OICHeaders/*
 %{_libdir}/pkgconfig/*.pc
 
old mode 100644 (file)
new mode 100755 (executable)
index f2d562f..318d954
@@ -20,7 +20,7 @@ if env.get('LOGGING'):
 
 env.ParseConfig("pkg-config --cflags --libs capi-network-wifi dlog glib-2.0")
 if 'ALL' in transport:
-               env.AppendUnique(CPPDEFINES = ['NO_IP_ADAPTER','EDR_ADAPTER','LE_ADAPTER'])
+               env.AppendUnique(CPPDEFINES = ['WIFI_ADAPTER', 'NO_ETHERNET_ADAPTER','EDR_ADAPTER','LE_ADAPTER'])
                print "CA Transport is ALL"
 else:
        if 'BT' in transport:
@@ -35,5 +35,12 @@ else:
        else:
                env.AppendUnique(CPPDEFINES = ['NO_LE_ADAPTER'])
 
+       if 'WIFI' in transport:
+               env.AppendUnique(CPPDEFINES = ['WIFI_ADAPTER'])
+               print "CA Transport is WIFI"
+       else:
+               env.AppendUnique(CPPDEFINES = ['NO_WIFI_ADAPTER'])
+
+
 env.SConscript(['../con/lib/libcoap-4.1.1/SConscript'])
 env.SConscript(['../con/SConscript'])
index c8143a1..167613c 100644 (file)
@@ -66,9 +66,6 @@ libcoap_src = [
        'block.c'
        ]
 
-if target_os in ['android', 'tizen'] :
-       libcoap = libcoap_env.SharedLibrary('libcoap', libcoap_src, OBJPREFIX='libcoap_')
-else :
-       libcoap = libcoap_env.StaticLibrary('libcoap', libcoap_src, OBJPREFIX='libcoap_')
+libcoap = libcoap_env.StaticLibrary('libcoap', libcoap_src, OBJPREFIX='libcoap_')
 
 libcoap_env.InstallTarget([libcoap], 'libcoap')
diff --git a/resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/ca/CaIpInterface.java b/resource/csdk/connectivity/samples/android/sample_service/src/org/iotivity/ca/CaIpInterface.java
new file mode 100644 (file)
index 0000000..43d0ace
--- /dev/null
@@ -0,0 +1,70 @@
+/*\r
+ * //******************************************************************\r
+ * //\r
+ * // Copyright 2015 Intel Corporation.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ * //\r
+ * // Licensed under the Apache License, Version 2.0 (the "License");\r
+ * // you may not use this file except in compliance with the License.\r
+ * // You may obtain a copy of the License at\r
+ * //\r
+ * //      http://www.apache.org/licenses/LICENSE-2.0\r
+ * //\r
+ * // Unless required by applicable law or agreed to in writing, software\r
+ * // distributed under the License is distributed on an "AS IS" BASIS,\r
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * // See the License for the specific language governing permissions and\r
+ * // limitations under the License.\r
+ * //\r
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ */\r
+\r
+package org.iotivity.ca;\r
+\r
+import android.content.BroadcastReceiver;\r
+import android.content.Context;\r
+import android.content.Intent;\r
+import android.content.IntentFilter;\r
+import android.net.ConnectivityManager;\r
+import android.net.NetworkInfo;\r
+import android.net.wifi.WifiManager;\r
+\r
+public class CaIpInterface {\r
+    private static Context mContext;\r
+\r
+    private CaIpInterface(Context context) {\r
+        mContext = context;\r
+        registerIpStateReceiver();\r
+    }\r
+\r
+    private void registerIpStateReceiver() {\r
+        IntentFilter intentFilter = new IntentFilter();\r
+        intentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);\r
+        intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);\r
+\r
+        mContext.registerReceiver(mReceiver, intentFilter);\r
+    }\r
+\r
+    private static BroadcastReceiver mReceiver = new BroadcastReceiver() {\r
+        @Override\r
+        public void onReceive(Context context, Intent intent) {\r
+            if (intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,\r
+                    WifiManager.WIFI_STATE_UNKNOWN) == WifiManager.WIFI_STATE_DISABLED) {\r
+                stateDisabled();\r
+            } else if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {\r
+                ConnectivityManager manager = (ConnectivityManager)\r
+                        mContext.getSystemService(Context.CONNECTIVITY_SERVICE);\r
+                NetworkInfo nwInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);\r
+\r
+                if(nwInfo.isConnected()) {\r
+                    stateEnabled();\r
+                }\r
+            }\r
+        }\r
+    };\r
+\r
+    private native static void stateEnabled();\r
+\r
+    private native static void stateDisabled();\r
+}
\ No newline at end of file
index 2d408fd..987504d 100644 (file)
@@ -33,7 +33,7 @@
 #include "logger.h"
 #include "oic_malloc.h"
 #include "oic_string.h"
-#include "org_iotivity_jar_caipinterface.h"
+#include "org_iotivity_ca_CaIpInterface.h"
 
 #define IP_MONITOR_TAG "IP_MONITOR"
 #define MAX_INTERFACE_INFO_LENGTH (1024)
@@ -176,7 +176,7 @@ CAResult_t CACreateIPJNIInterfaceObject(jobject context)
     }
 
     //Create caipinterface jni instance
-    jclass IPJniInterface = (*env)->FindClass(env, "org/iotivity/jar/caipinterface");
+    jclass IPJniInterface = (*env)->FindClass(env, "org/iotivity/ca/CaIpInterface");
     if (!IPJniInterface)
     {
         OIC_LOG(ERROR, IP_MONITOR_TAG, "Could not get caipinterface class");
@@ -471,7 +471,7 @@ static void CADestroyNetworkMonitorMutexes()
 
 CAResult_t CAIPInitializeNetworkMonitor(const ca_thread_pool_t threadPool)
 {
-    OIC_LOG(DEBUG, IP_MONITOR_TAG, "IN");
+    OIC_LOG(DEBUG, IP_MONITOR_TAG, "CAIPInitializeNetworkMonitor IN");
 
     VERIFY_NON_NULL(threadPool, IP_MONITOR_TAG, "threadPool is null");
 
@@ -763,6 +763,7 @@ void CAIPSendNetworkChangeCallback(CANetworkStatus_t currNetworkStatus)
 {
     OIC_LOG(DEBUG, IP_MONITOR_TAG, "IN");
     ca_mutex_lock(g_stopNetworkMonitorMutex);
+
     if (g_stopNetworkMonitor)
     {
         OIC_LOG(DEBUG, IP_MONITOR_TAG, "Stop Network Monitor Thread is called");
@@ -770,16 +771,22 @@ void CAIPSendNetworkChangeCallback(CANetworkStatus_t currNetworkStatus)
         return;
     }
     ca_mutex_unlock(g_stopNetworkMonitorMutex);
-
     ca_mutex_lock(g_networkMonitorContextMutex);
-    if (!g_networkMonitorContext->networkChangeCb)
+    if(!g_networkMonitorContext)
     {
-        OIC_LOG(ERROR, IP_MONITOR_TAG, "g_networkChangeCb is NULL");
+       OIC_LOG(DEBUG, IP_MONITOR_TAG, "g_networkChangeCb is NULL");
+       ca_mutex_unlock(g_networkMonitorContextMutex);
+       return;
+    }
+    if (!g_networkMonitorContext->networkChangeCb)
+    {    
+        OIC_LOG(ERROR, IP_MONITOR_TAG, "g_networkChangeCb->networkChangeCb is NULL");
         ca_mutex_unlock(g_networkMonitorContextMutex);
         return;
     }
-    ca_mutex_unlock(g_networkMonitorContextMutex);
 
+    ca_mutex_unlock(g_networkMonitorContextMutex);
+  
     u_arraylist_t *netInterfaceList = u_arraylist_create();
 
     VERIFY_NON_NULL_VOID(netInterfaceList, IP_MONITOR_TAG,
@@ -855,13 +862,13 @@ void CAIPSendNetworkChangeCallback(CANetworkStatus_t currNetworkStatus)
             OIC_LOG(DEBUG, IP_MONITOR_TAG, "CACheckIsInterfaceInfoChanged true");
         }
     }
-    CAClearNetInterfaceInfoList(netInterfaceList);
 
+    CAClearNetInterfaceInfoList(netInterfaceList);
     OIC_LOG(DEBUG, IP_MONITOR_TAG, "OUT");
 }
 
-JNIEXPORT void JNICALL
-Java_org_iotivity_jar_caipinterface_CAIPStateEnabled(JNIEnv *env, jclass class)
+JNIEXPORT void JNICALL Java_org_iotivity_ca_CaIpInterface_stateEnabled
+  (JNIEnv *env, jclass clazz)
 {
     CANetworkStatus_t currNetworkStatus = CA_INTERFACE_UP;
     OIC_LOG(DEBUG, IP_MONITOR_TAG, "CAIPStateEnabled");
@@ -869,8 +876,8 @@ Java_org_iotivity_jar_caipinterface_CAIPStateEnabled(JNIEnv *env, jclass class)
     CAIPSendNetworkChangeCallback(currNetworkStatus);
 }
 
-JNIEXPORT void JNICALL
-Java_org_iotivity_jar_caipinterface_CAIPStateDisabled(JNIEnv *env, jclass class)
+JNIEXPORT void JNICALL Java_org_iotivity_ca_CaIpInterface_stateDisabled
+  (JNIEnv *env, jclass clazz)
 {
     CANetworkStatus_t currNetworkStatus = CA_INTERFACE_DOWN;
     OIC_LOG(DEBUG, IP_MONITOR_TAG, "CAIPStateDisabled");
diff --git a/resource/csdk/connectivity/src/ip_adapter/android/org_iotivity_ca_CaIpInterface.h b/resource/csdk/connectivity/src/ip_adapter/android/org_iotivity_ca_CaIpInterface.h
new file mode 100644 (file)
index 0000000..1d66553
--- /dev/null
@@ -0,0 +1,29 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */\r
+#include <jni.h>\r
+/* Header for class org_iotivity_ca_CaIpInterface */\r
+\r
+#ifndef _Included_org_iotivity_ca_CaIpInterface\r
+#define _Included_org_iotivity_ca_CaIpInterface\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+/*\r
+ * Class:     org_iotivity_ca_CaIpInterface\r
+ * Method:    stateEnabled\r
+ * Signature: ()V\r
+ */\r
+JNIEXPORT void JNICALL Java_org_iotivity_ca_CaIpInterface_stateEnabled\r
+  (JNIEnv *, jclass);\r
+\r
+/*\r
+ * Class:     org_iotivity_ca_CaIpInterface\r
+ * Method:    stateDisabled\r
+ * Signature: ()V\r
+ */\r
+JNIEXPORT void JNICALL Java_org_iotivity_ca_CaIpInterface_stateDisabled\r
+  (JNIEnv *, jclass);\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+#endif\r
diff --git a/resource/csdk/connectivity/src/ip_adapter/android/org_iotivity_jar_caipinterface.h b/resource/csdk/connectivity/src/ip_adapter/android/org_iotivity_jar_caipinterface.h
deleted file mode 100644 (file)
index b66bad4..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#include <jni.h>
-/* Header for class org_iotivity_jar_caipinterface */
-
-#ifndef _Included_org_iotivity_jar_caipinterface
-#define _Included_org_iotivity_jar_caipinterface
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-/*
- * Class:     org_iotivity_jar_caipinterface
- * Method:    CAIPStateEnabled
- * Signature: ()V
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_jar_caipinterface_CAIPStateEnabled(JNIEnv *, jclass);
-
-/*
- * Class:     org_iotivity_jar_caipinterface
- * Method:    CAIPStateDisabled
- * Signature: ()V
- */
-JNIEXPORT
-void JNICALL Java_org_iotivity_jar_caipinterface_CAIPStateDisabled
-(JNIEnv *, jclass);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
index 82a298d..71e298f 100644 (file)
@@ -49,7 +49,7 @@ samples_env.Append(LINKFLAGS = ['-Wl,--no-as-needed'])
 
 if target_os == 'android':
        samples_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
-       samples_env.AppendUnique(LIBS = ['gnustl_static'])
+       samples_env.AppendUnique(LIBS = ['gnustl_shared'])
        samples_env.AppendUnique(CPPDEFINES = ['_GLIBCXX_USE_C99=1', '_GLIBCXX_HAVE_WCSTOF=1'])
 
        if not env.get('RELEASE'):
index 115f424..914a5ee 100644 (file)
@@ -56,7 +56,7 @@ if env.get('SECURED') == '1':
 
 if target_os == 'android':
        examples_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
-       examples_env.AppendUnique(LIBS = ['gnustl_static'])
+       examples_env.AppendUnique(LIBS = ['gnustl_shared'])
 
        if not env.get('RELEASE'):
                examples_env.AppendUnique(LIBS = ['log'])
index 63fbd62..534bb5a 100644 (file)
@@ -198,6 +198,29 @@ namespace OC
                 return val;
             }
 
+          /**
+            *  Retrieve the attributevalue structure associated with the supplied name
+            *
+            *  @param str Name of the attribute
+            *  @param attrValue Attribute Value structure
+            *  @return The getAttributeValue method returns true if the attribute was
+            *        found in the representation.  Otherwise it returns false.
+            */
+            bool getAttributeValue(const std::string& str, AttributeValue& attrValue) const
+            {
+                auto x = m_values.find(str);
+
+                if (x != m_values.end())
+                {
+                    attrValue = x->second;
+                    return true;
+                }
+                else
+                {
+                    return false;
+                }
+            }
+
             std::string getValueToString(const std::string& key) const;
             bool hasAttribute(const std::string& str) const;
 
index 761d401..8bd1edc 100644 (file)
@@ -36,7 +36,7 @@ liboc_logger_env.PrependUnique(CPPPATH = ['include'])
 target_os = env.get('TARGET_OS')
 if target_os == 'android':
        liboc_logger_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
-       liboc_logger_env.AppendUnique(LIBS = ['gnustl_static', 'log'])
+       liboc_logger_env.AppendUnique(LIBS = ['gnustl_shared', 'log'])
 
 if target_os not in ['arduino', 'windows', 'winrt']:
        liboc_logger_env.AppendUnique(CFLAGS = ['-Wall', '-std=c99', '-fPIC'])
index 644ec78..a3a4c91 100644 (file)
@@ -38,7 +38,7 @@ examples_env.AppendUnique(LIBS = ['oc_logger', 'stdc++'])
 target_os = env.get('TARGET_OS')
 if target_os == 'android':
        examples_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
-       examples_env.AppendUnique(LIBS = ['gnustl_static'])
+       examples_env.AppendUnique(LIBS = ['gnustl_shared'])
 
 if target_os not in ['arduino', 'windows', 'winrt']:
        examples_env.AppendUnique(CFLAGS = Split('-Wall -std=c99 -Werror'))
index 2966a60..2e2c94f 100644 (file)
@@ -48,7 +48,7 @@ if target_os not in ['windows', 'winrt']:
 if target_os == 'android':
        oclib_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
        oclib_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-       oclib_env.AppendUnique(LIBS = ['octbstack', 'oc_logger', 'boost_thread', 'gnustl_static', 'log'])
+       oclib_env.AppendUnique(LIBS = ['octbstack', 'oc_logger', 'boost_thread', 'gnustl_shared', 'log'])
 
 if target_os in ['darwin', 'ios']:
        oclib_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])