LOGI("~JniDisplayPinListener()");
if (m_jgListener)
{
- jint ret;
+ jint ret = JNI_ERR;
JNIEnv *env = GetJNIEnv(ret);
if (NULL == env) return;
env->DeleteGlobalRef(m_jgListener);
void JniDisplayPinListener::displayPinCallback(char *pinBuf, size_t pinSize)
{
- jint ret;
+ jint ret = JNI_ERR;
JNIEnv *env = GetJNIEnv(ret);
- if (NULL == env) return;
+ if (NULL == env)
+ {
+ return;
+ }
jclass clsL = env->GetObjectClass(m_jgListener);
LOGD("~JniEntityHandler");
if (m_jListener)
{
- jint ret;
+ jint ret = JNI_ERR;
JNIEnv *env = GetJNIEnv(ret);
if (nullptr == env)
{
const std::shared_ptr<OCResourceRequest> request)
{
LOGD("JniEntityHandler_handleEntity");
- jint envRet;
+ jint envRet = JNI_ERR;
JNIEnv *env = GetJNIEnv(envRet);
if (nullptr == env)
{
jmethodID getValue_ID = env->GetMethodID(clsResult, "getValue", "()I");
if (!getValue_ID)
{
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return OC_EH_ERROR;
}
jint jResult = env->CallIntMethod(entityHandlerResult, getValue_ID);
break;
}
}
+
if (!onEventListener)
{
onEventListener = new T(env, jListener, owner);
{
LOGD("OnEventListener: Failed to create global listener ref.");
delete onEventListener;
+ return nullptr;
}
LOGD("OnEventListener: new listener");
}
+
m_mapMutex.unlock();
return onEventListener;
}
JniOcDirectPairDevice::JniOcDirectPairDevice(std::shared_ptr<OC::OCDirectPairing> directPairingDevice)
: m_sharedDirectPairDevice(directPairingDevice)
-{}
+{
+}
JniOcDirectPairDevice::~JniOcDirectPairDevice()
{
LOGD("OcDirectPairing_getHost");
JniOcDirectPairDevice* device = JniOcDirectPairDevice::getJniOcDirectPairDevicePtr(env,thiz);
- if (!device) return nullptr;
+ if (!device)
+ {
+ return nullptr;
+ }
std::string dev = device->getHost();
return env->NewStringUTF(dev.c_str());
std::vector<jint> pairingMethodList;
JniOcDirectPairDevice* device = JniOcDirectPairDevice::getJniOcDirectPairDevicePtr(env,thiz);
- if (!device) return nullptr;
+ if (!device)
+ {
+ return nullptr;
+ }
std::vector<OCPrm_t> pairingMethods = device->getPairingMethods();
return JniOcDirectPairDevice::JconvertIntVectorToJavaList(env,pairingMethods);
jsize len = static_cast<jsize>(vector.size());
jintArray intArray = env->NewIntArray(len);
- if (!intArray) return nullptr;
+ if (!intArray)
+ {
+ return nullptr;
+ }
env->SetIntArrayRegion(intArray, (jsize)0, len, (const jint*)&vector[0]);
{
LOGD("OcDirectPairDevice_getConnectivityType");
JniOcDirectPairDevice* device = JniOcDirectPairDevice::getJniOcDirectPairDevicePtr(env,thiz);
- if (!device) return -1;
+ if (!device)
+ {
+ return -1;
+ }
OCConnectivityType connectivityType = device->connectivityType();
return static_cast<jint>(connectivityType);
JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(
env, jResourceHandle);
- if (!jniOcResourceHandle) return;
+ if (!jniOcResourceHandle)
+ {
+ return;
+ }
try
{
return;
}
- try{
+ try {
OCStackResult result = OCPlatform::notifyAllObservers(
jniOcResourceHandle->getOCResourceHandle(),
JniUtils::getQOS(env, static_cast<int>(jQoS)));
return nullptr;
}
JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, jResource);
- if (!resource) return nullptr;
+ if (!resource)
+ {
+ return nullptr;
+ }
OCResourceHandle resourceHandle;
try
jstring jStr = (jstring)env->GetObjectArrayElement(jDeviceTypes, i);
if (!jStr)
{
+ delete deviceInfo.deviceName;
ThrowOcException(OC_STACK_INVALID_PARAM, "device type cannot be null");
return;
}
OCResourcePayloadAddStringLL(&deviceInfo.types, env->GetStringUTFChars(jStr, nullptr));
- if (env->ExceptionCheck()) return;
+ if (env->ExceptionCheck())
+ {
+ delete deviceInfo.deviceName;
+ return;
+ }
env->DeleteLocalRef(jStr);
}
}
JniOcResourceHandle* jniOcResourceCollectionHandle =
JniOcResourceHandle::getJniOcResourceHandlePtr(env, jResourceCollectionHandle);
- if (!jniOcResourceCollectionHandle) return;
+ if (!jniOcResourceCollectionHandle)
+ {
+ return;
+ }
JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(
env, jResourceHandle);
JniOcResourceHandle* jniOcResourceHandle =
JniOcResourceHandle::getJniOcResourceHandlePtr(env, jResourceHandle);
- if (!jniOcResourceHandle) return;
+ if (!jniOcResourceHandle)
+ {
+ return;
+ }
try
{
JniOcResourceResponse *jniResponse =
JniOcResourceResponse::getJniOcResourceResponsePtr(env, jResourceResponse);
- if (!jniResponse) return;
+ if (!jniResponse)
+ {
+ return;
+ }
try
{
JniOcPresenceHandle::JniOcPresenceHandle(JniOnPresenceListener* jniListener, OCPresenceHandle presenceHandle)
: m_jniListener(jniListener), m_presenceHandle(presenceHandle)
-{}
+{
+}
JniOcPresenceHandle::~JniOcPresenceHandle()
{
LOGD("OcPresenceHandle_dispose");
JniOcPresenceHandle *presenceHandle = JniOcPresenceHandle::getJniOcPresenceHandlePtr(env, thiz);
delete presenceHandle;
-}
\ No newline at end of file
+}
{
LOGD("OcRepresentation_getValues");
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return nullptr;
+ if (!rep)
+ {
+ return nullptr;
+ }
std::map<std::string, AttributeValue> values = rep->getValues();
jobject jHashMap = env->NewObject(g_cls_HashMap, g_mid_HashMap_ctor);
- if (!jHashMap) return nullptr;
+ if (!jHashMap)
+ {
+ return nullptr;
+ }
- for (std::map<std::string, AttributeValue>::const_iterator it = values.begin(); it != values.end(); it++) {
+ for (std::map<std::string, AttributeValue>::const_iterator it = values.begin(); it != values.end(); it++)
+ {
jobject key = static_cast<jobject>(env->NewStringUTF(it->first.c_str()));
jobject val = boost::apply_visitor(JObjectConverter(env), it->second);
env->CallObjectMethod(jHashMap, g_mid_HashMap_put, key, val);
return nullptr;
}
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return nullptr;
+ if (!rep)
+ {
+ return nullptr;
+ }
std::string key = env->GetStringUTFChars(jKey, nullptr);
return;
}
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return;
+ if (!rep)
+ {
+ return;
+ }
std::string str = env->GetStringUTFChars(jKey, nullptr);
rep->setValue(str, static_cast<int>(jValue));
return;
}
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return;
+ if (!rep)
+ {
+ return;
+ }
std::string str = env->GetStringUTFChars(jKey, nullptr);
rep->setValue(str, static_cast<double>(jValue));
return;
}
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return;
+ if (!rep)
+ {
+ return;
+ }
std::string str = env->GetStringUTFChars(jKey, nullptr);
rep->setValue(str, static_cast<bool>(jValue));
return;
}
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return;
+ if (!rep)
+ {
+ return;
+ }
std::string key = env->GetStringUTFChars(jKey, nullptr);
std::string value = env->GetStringUTFChars(jValue, nullptr);
return;
}
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return;
+ if (!rep)
+ {
+ return;
+ }
std::string key = env->GetStringUTFChars(jKey, nullptr);
if (jValue)
{
OCRepresentation *value = JniOcRepresentation::getOCRepresentationPtr(env, jValue);
- if (!value) return;
+ if (!value)
+ {
+ return;
+ }
rep->setValue(key, *value);
}
else
env->ReleaseIntArrayElements(jValue, ints, JNI_ABORT);
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return;
+ if (!rep)
+ {
+ return;
+ }
std::string key = env->GetStringUTFChars(jKey, nullptr);
rep->setValue(key, value);
}
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return;
+ if (!rep)
+ {
+ return;
+ }
std::string key = env->GetStringUTFChars(jKey, nullptr);
rep->setValue(key, value);
}
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return;
+ if (!rep)
+ {
+ return;
+ }
std::string key = env->GetStringUTFChars(jKey, nullptr);
rep->setValue(key, value);
env->ReleaseDoubleArrayElements(jValue, doubles, JNI_ABORT);
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return;
+ if (!rep)
+ {
+ return;
+ }
std::string key = env->GetStringUTFChars(jKey, nullptr);
rep->setValue(key, value);
}
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return;
+ if (!rep)
+ {
+ return;
+ }
std::string key = env->GetStringUTFChars(jKey, nullptr);
rep->setValue(key, value);
}
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return;
+ if (!rep)
+ {
+ return;
+ }
std::string key = env->GetStringUTFChars(jKey, nullptr);
rep->setValue(key, value);
env->ReleaseBooleanArrayElements(jValue, booleans, JNI_ABORT);
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return;
+ if (!rep)
+ {
+ return;
+ }
std::string key = env->GetStringUTFChars(jKey, nullptr);
rep->setValue(key, value);
}
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return;
+ if (!rep)
+ {
+ return;
+ }
std::string key = env->GetStringUTFChars(jKey, nullptr);
rep->setValue(key, value);
}
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return;
+ if (!rep)
+ {
+ return;
+ }
std::string key = env->GetStringUTFChars(jKey, nullptr);
rep->setValue(key, value);
JniUtils::convertJavaStrArrToStrVector(env, jValue, value);
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return;
+ if (!rep)
+ {
+ return;
+ }
std::string key = env->GetStringUTFChars(jKey, nullptr);
rep->setValue(key, value);
}
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return;
+ if (!rep)
+ {
+ return;
+ }
std::string key = env->GetStringUTFChars(jKey, nullptr);
rep->setValue(key, value);
}
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return;
-
+ if (!rep)
+ {
+ return;
+ }
std::string key = env->GetStringUTFChars(jKey, nullptr);
rep->setValue(key, value);
}
JniUtils::convertJavaRepresentationArrToVector(env, jValue, value);
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return;
+ if (!rep)
+ {
+ return;
+ }
std::string key = env->GetStringUTFChars(jKey, nullptr);
rep->setValue(key, value);
}
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return;
+ if (!rep)
+ {
+ return;
+ }
std::string key = env->GetStringUTFChars(jKey, nullptr);
rep->setValue(key, value);
}
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return;
+ if (!rep)
+ {
+ return;
+ }
std::string key = env->GetStringUTFChars(jKey, nullptr);
rep->setValue(key, value);
env->ReleaseByteArrayElements(jValue, bytes, JNI_ABORT);
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return;
+ if (!rep)
+ {
+ return;
+ }
std::string key = env->GetStringUTFChars(jKey, nullptr);
rep->setValue(key, value);
{
LOGD("OcRepresentation_addChild");
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return;
+ if (!rep)
+ {
+ return;
+ }
OCRepresentation *child = JniOcRepresentation::getOCRepresentationPtr(env, jOcRepresentation);
- if (!child) return;
+ if (!child)
+ {
+ return;
+ }
rep->addChild(*child);
}
{
LOGD("OcRepresentation_clearChildren");
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return;
+ if (!rep)
+ {
+ return;
+ }
rep->clearChildren();
}
{
LOGD("OcRepresentation_getChildrenArray");
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return nullptr;
+ if (!rep)
+ {
+ return nullptr;
+ }
return JniUtils::convertRepresentationVectorToJavaArray(env, rep->getChildren());
}
{
LOGD("OcRepresentation_getUri");
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return nullptr;
+ if (!rep)
+ {
+ return nullptr;
+ }
std::string uri(rep->getUri());
return env->NewStringUTF(uri.c_str());
{
LOGD("OcRepresentation_getHost");
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return nullptr;
+ if (!rep)
+ {
+ return nullptr;
+ }
std::string uri(rep->getHost());
return env->NewStringUTF(uri.c_str());
return;
}
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return;
+ if (!rep)
+ {
+ return;
+ }
rep->setUri(env->GetStringUTFChars(jUri, nullptr));
}
return false;
}
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return false;
+ if (!rep)
+ {
+ return false;
+ }
std::string str = env->GetStringUTFChars(jstr, nullptr);
return rep->hasAttribute(str);
{
LOGD("OcRepresentation_getResourceTypes");
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return nullptr;
+ if (!rep)
+ {
+ return nullptr;
+ }
std::vector<std::string> resourceTypes = rep->getResourceTypes();
return JniUtils::convertStrVectorToJavaStrList(env, resourceTypes);
return;
}
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return;
+ if (!rep)
+ {
+ return;
+ }
std::vector<std::string> resourceTypes;
JniUtils::convertJavaStrArrToStrVector(env, jResourceTypeArray, resourceTypes);
{
LOGD("OcRepresentation_getResourceInterfaces");
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return nullptr;
+ if (!rep)
+ {
+ return nullptr;
+ }
std::vector<std::string> resourceInterfaces = rep->getResourceInterfaces();
return JniUtils::convertStrVectorToJavaStrList(env, resourceInterfaces);
return;
}
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return;
+ if (!rep)
+ {
+ return;
+ }
std::vector<std::string> resourceInterfaces;
JniUtils::convertJavaStrArrToStrVector(env, jResourceInterfaceArray, resourceInterfaces);
{
LOGD("OcRepresentation_isEmpty");
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return false;
+ if (!rep)
+ {
+ return false;
+ }
return static_cast<jboolean>(rep->empty());
}
{
LOGD("OcRepresentation_size");
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return -1;
+ if (!rep)
+ {
+ return -1;
+ }
return static_cast<jint>(rep->numberOfAttributes());
}
return false;
}
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return false;
+ if (!rep)
+ {
+ return false;
+ }
std::string attributeKey = env->GetStringUTFChars(jAttributeKey, nullptr);
return static_cast<jboolean>(rep->erase(attributeKey));
return;
}
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return;
+ if (!rep)
+ {
+ return;
+ }
std::string attributeKey = env->GetStringUTFChars(jAttributeKey, nullptr);
rep->setNULL(attributeKey);
return false;
}
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
- if (!rep) return false;
+ if (!rep)
+ {
+ return false;
+ }
std::string attributeKey = env->GetStringUTFChars(jAttributeKey, nullptr);
return static_cast<jboolean>(rep->isNULL(attributeKey));
struct JObjectConverter : boost::static_visitor < jobject >
{
- JObjectConverter(JNIEnv *env) : env(env){}
+ JObjectConverter(JNIEnv *env) : env(env)
+ {
+ }
+
+ jobject operator()(const NullType&) const
+ {
+ return nullptr;
+ }
- jobject operator()(const NullType&) const { return nullptr; }
jobject operator()(const int& val) const
{
jobject jobj = env->NewObject(
{
size_t len = val.size();
jintArray jIntArray = env->NewIntArray(len);
- if (!jIntArray) return nullptr;
+ if (!jIntArray)
+ {
+ return nullptr;
+ }
const int* ints = &val[0];
env->SetIntArrayRegion(jIntArray, 0, len, reinterpret_cast<const jint*>(ints));
return jIntArray;
{
size_t len = val.size();
jdoubleArray jDoubleArray = env->NewDoubleArray(len);
- if (!jDoubleArray) return nullptr;
+ if (!jDoubleArray)
+ {
+ return nullptr;
+ }
const double* doubles = &val[0];
env->SetDoubleArrayRegion(jDoubleArray, 0, len, reinterpret_cast<const jdouble*>(doubles));
return jDoubleArray;
{
size_t len = val.size();
jbooleanArray jBooleanArray = env->NewBooleanArray(len);
- if (!jBooleanArray) return nullptr;
+ if (!jBooleanArray)
+ {
+ return nullptr;
+ }
jboolean* booleans = new jboolean[len];
- for (size_t i = 0; i < len; ++i) {
+ for (size_t i = 0; i < len; ++i)
+ {
booleans[i] = static_cast<jboolean>(val[i]);
}
env->SetBooleanArrayRegion(jBooleanArray, 0, len, booleans);
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->ReleaseBooleanArrayElements(jBooleanArray, booleans, 0);
return jBooleanArray;
}
{
size_t len = val.size();
jobjectArray strArr = env->NewObjectArray(len, g_cls_String, nullptr);
- if (!strArr) return nullptr;
+ if (!strArr)
+ {
+ return nullptr;
+ }
for (size_t i = 0; i < len; ++i)
{
jstring jString = env->NewStringUTF(val[i].c_str());
env->SetObjectArrayElement(strArr, static_cast<jsize>(i), jString);
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->DeleteLocalRef(jString);
}
return strArr;
{
jsize len = static_cast<jsize>(val.size());
jobjectArray repArr = env->NewObjectArray(len, g_cls_OcRepresentation, nullptr);
- if (!repArr) return nullptr;
+ if (!repArr)
+ {
+ return nullptr;
+ }
for (jsize i = 0; i < len; ++i)
{
OCRepresentation* rep = new OCRepresentation(val[i]);
{
size_t len = val.size();
jbyteArray jByteArray = env->NewByteArray(len);
- if (!jByteArray) return nullptr;
+ if (!jByteArray)
+ {
+ return nullptr;
+ }
const uint8_t* bytes = &val[0];
env->SetByteArrayRegion(jByteArray, 0, len, reinterpret_cast<const jbyte*>(bytes));
return jByteArray;
{
size_t lenInner = val[i].size();
jintArray jIntArray = env->NewIntArray(lenInner);
- if (!jIntArray) return nullptr;
+ if (!jIntArray)
+ {
+ return nullptr;
+ }
const int* ints = &val[i][0];
env->SetIntArrayRegion(jIntArray, 0, lenInner, reinterpret_cast<const jint*>(ints));
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->SetObjectArrayElement(jOuterArr, i, static_cast<jobject>(jIntArray));
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->DeleteLocalRef(jIntArray);
}
return jOuterArr;
{
jsize lenOuter = static_cast<jsize>(val.size());
jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_int2DArray, nullptr);
- if (!jOuterArr) return nullptr;
+ if (!jOuterArr)
+ {
+ return nullptr;
+ }
+
for (jsize k = 0; k < lenOuter; ++k)
{
jsize lenMiddle = static_cast<jsize>(val[k].size());
jobjectArray jMiddleArr = env->NewObjectArray(lenMiddle, g_cls_int1DArray, nullptr);
- if (!jMiddleArr) return nullptr;
+ if (!jMiddleArr)
+ {
+ return nullptr;
+ }
+
for (jsize i = 0; i < lenMiddle; ++i)
{
jsize lenInner = static_cast<jsize>(val[k][i].size());
jintArray jIntArray = env->NewIntArray(lenInner);
- if (!jIntArray) return nullptr;
+ if (!jIntArray)
+ {
+ return nullptr;
+ }
const int* ints = &val[k][i][0];
env->SetIntArrayRegion(jIntArray, 0, lenInner, reinterpret_cast<const jint*>(ints));
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->SetObjectArrayElement(jMiddleArr, i, jIntArray);
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->DeleteLocalRef(jIntArray);
}
env->SetObjectArrayElement(jOuterArr, k, jMiddleArr);
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->DeleteLocalRef(jMiddleArr);
}
return jOuterArr;
{
jsize lenOuter = static_cast<jsize>(val.size());
jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_double1DArray, nullptr);
- if (!jOuterArr) return nullptr;
+ if (!jOuterArr)
+ {
+ return nullptr;
+ }
+
for (jsize i = 0; i < lenOuter; ++i)
{
size_t lenInner = val[i].size();
jdoubleArray jDoubleArray = env->NewDoubleArray(lenInner);
- if (!jDoubleArray) return nullptr;
+ if (!jDoubleArray)
+ {
+ return nullptr;
+ }
+
const double* doubles = &val[i][0];
env->SetDoubleArrayRegion(jDoubleArray, 0, lenInner, reinterpret_cast<const jdouble*>(doubles));
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->SetObjectArrayElement(jOuterArr, i, jDoubleArray);
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->DeleteLocalRef(jDoubleArray);
}
{
jsize lenOuter = static_cast<jsize>(val.size());
jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_double2DArray, nullptr);
- if (!jOuterArr) return nullptr;
+ if (!jOuterArr)
+ {
+ return nullptr;
+ }
for (jsize k = 0; k < lenOuter; ++k)
{
jsize lenMiddle = static_cast<jsize>(val[k].size());
jobjectArray jMiddleArr = env->NewObjectArray(lenMiddle, g_cls_double1DArray, nullptr);
- if (!jMiddleArr) return nullptr;
+ if (!jMiddleArr)
+ {
+ return nullptr;
+ }
for (jsize i = 0; i < lenMiddle; ++i)
{
jsize lenInner = static_cast<jsize>(val[k][i].size());
jdoubleArray jDoubleArray = env->NewDoubleArray(lenInner);
- if (!jDoubleArray) return nullptr;
+ if (!jDoubleArray)
+ {
+ return nullptr;
+ }
const double* doubles = &val[k][i][0];
env->SetDoubleArrayRegion(jDoubleArray, 0, lenInner, reinterpret_cast<const jdouble*>(doubles));
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->SetObjectArrayElement(jMiddleArr, i, jDoubleArray);
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->DeleteLocalRef(jDoubleArray);
}
env->SetObjectArrayElement(jOuterArr, k, jMiddleArr);
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->DeleteLocalRef(jMiddleArr);
}
return jOuterArr;
{
jsize lenOuter = static_cast<jsize>(val.size());
jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_boolean1DArray, 0);
- if (!jOuterArr) return nullptr;
+ if (!jOuterArr)
+ {
+ return nullptr;
+ }
for (jsize i = 0; i < lenOuter; ++i)
{
size_t lenInner = val[i].size();
jbooleanArray jBooleanArray = env->NewBooleanArray(lenInner);
- if (!jBooleanArray) return nullptr;
+ if (!jBooleanArray)
+ {
+ return nullptr;
+ }
jboolean* booleans = new jboolean[lenInner];
- for (size_t j = 0; j < lenInner; ++j) {
+ for (size_t j = 0; j < lenInner; ++j)
+ {
booleans[j] = static_cast<jboolean>(val[i][j]);
}
env->SetBooleanArrayRegion(jBooleanArray, 0, lenInner, booleans);
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->SetObjectArrayElement(jOuterArr, i, jBooleanArray);
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->ReleaseBooleanArrayElements(jBooleanArray, booleans, 0);
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->DeleteLocalRef(jBooleanArray);
}
return jOuterArr;
{
jsize lenOuter = static_cast<jsize>(val.size());
jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_boolean2DArray, nullptr);
- if (!jOuterArr) return nullptr;
+ if (!jOuterArr)
+ {
+ return nullptr;
+ }
for (jsize k = 0; k < lenOuter; ++k)
{
jsize lenMiddle = static_cast<jsize>(val[k].size());
jobjectArray jMiddleArr = env->NewObjectArray(lenMiddle, g_cls_boolean1DArray, nullptr);
- if (!jMiddleArr) return nullptr;
+ if (!jMiddleArr)
+ {
+ return nullptr;
+ }
for (jsize i = 0; i < lenMiddle; ++i)
{
size_t lenInner = val[k][i].size();
jbooleanArray jBooleanArray = env->NewBooleanArray(lenInner);
jboolean* booleans = new jboolean[lenInner];
- for (size_t j = 0; j < lenInner; ++j) {
+ for (size_t j = 0; j < lenInner; ++j)
+ {
booleans[j] = val[k][i][j];
}
env->SetBooleanArrayRegion(jBooleanArray, 0, lenInner, booleans);
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->SetObjectArrayElement(jMiddleArr, i, jBooleanArray);
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->ReleaseBooleanArrayElements(jBooleanArray, booleans, 0);
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->DeleteLocalRef(jBooleanArray);
}
env->SetObjectArrayElement(jOuterArr, k, jMiddleArr);
- if (env->ExceptionCheck()) return nullptr;
- env->DeleteLocalRef(jMiddleArr);
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ } env->DeleteLocalRef(jMiddleArr);
}
return jOuterArr;
}
{
jsize lenOuter = static_cast<jsize>(val.size());
jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_String1DArray, nullptr);
- if (!jOuterArr) return nullptr;
+ if (!jOuterArr)
+ {
+ return nullptr;
+ }
for (jsize i = 0; i < lenOuter; ++i)
{
jsize lenInner = static_cast<jsize>(val[i].size());
jobjectArray strArr = env->NewObjectArray(lenInner, g_cls_String, nullptr);
- if (!strArr) return nullptr;
+ if (!strArr)
+ {
+ return nullptr;
+ }
for (jsize j = 0; j < lenInner; ++j)
{
jstring jString = env->NewStringUTF(val[i][j].c_str());
env->SetObjectArrayElement(strArr, j, jString);
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->DeleteLocalRef(jString);
}
env->SetObjectArrayElement(jOuterArr, i, strArr);
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->DeleteLocalRef(strArr);
}
{
jsize lenOuter = static_cast<jsize>(val.size());
jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_String2DArray, nullptr);
- if (!jOuterArr) return nullptr;
+ if (!jOuterArr)
+ {
+ return nullptr;
+ }
for (jsize k = 0; k < lenOuter; ++k)
{
jsize lenMiddle = static_cast<jsize>(val[k].size());
jobjectArray jMiddleArr = env->NewObjectArray(lenMiddle, g_cls_String1DArray, nullptr);
- if (!jMiddleArr) return nullptr;
+ if (!jMiddleArr)
+ {
+ return nullptr;
+ }
for (jsize i = 0; i < lenMiddle; ++i)
{
jsize lenInner = static_cast<jsize>(val[k][i].size());
jobjectArray strArr = env->NewObjectArray(lenInner, g_cls_String, nullptr);
- if (!strArr) return nullptr;
+ if (!strArr)
+ {
+ return nullptr;
+ }
for (jsize j = 0; j < lenInner; ++j)
{
jstring jString = env->NewStringUTF(val[k][i][j].c_str());
env->SetObjectArrayElement(strArr, j, jString);
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->DeleteLocalRef(jString);
}
env->SetObjectArrayElement(jMiddleArr, i, strArr);
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->DeleteLocalRef(strArr);
}
env->SetObjectArrayElement(jOuterArr, k, jMiddleArr);
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->DeleteLocalRef(jMiddleArr);
}
return jOuterArr;
{
jsize lenOuter = static_cast<jsize>(val.size());
jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_OcRepresentation1DArray, nullptr);
- if (!jOuterArr) return nullptr;
+ if (!jOuterArr)
+ {
+ return nullptr;
+ }
for (jsize i = 0; i < lenOuter; ++i)
{
jsize lenInner = static_cast<jsize>(val[i].size());
jobjectArray repArr = env->NewObjectArray(lenInner, g_cls_OcRepresentation, nullptr);
- if (!repArr) return nullptr;
+ if (!repArr)
+ {
+ return nullptr;
+ }
for (jsize j = 0; j < lenInner; ++j)
{
OCRepresentation* rep = new OCRepresentation(val[i][j]);
return nullptr;
}
env->SetObjectArrayElement(repArr, j, jRepresentation);
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->DeleteLocalRef(jRepresentation);
}
env->SetObjectArrayElement(jOuterArr, i, repArr);
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->DeleteLocalRef(repArr);
}
return jOuterArr;
{
jsize lenOuter = static_cast<jsize>(val.size());
jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_OcRepresentation2DArray, nullptr);
- if (!jOuterArr) return nullptr;
+ if (!jOuterArr)
+ {
+ return nullptr;
+ }
for (jsize k = 0; k < lenOuter; ++k)
{
jsize lenMiddle = static_cast<jsize>(val[k].size());
jobjectArray jMiddleArr = env->NewObjectArray(lenMiddle, g_cls_OcRepresentation1DArray, nullptr);
- if (!jMiddleArr) return nullptr;
+ if (!jMiddleArr)
+ {
+ return nullptr;
+ }
for (jsize i = 0; i < lenMiddle; ++i)
{
jsize lenInner = static_cast<jsize>(val[k][i].size());
jobjectArray repArr = env->NewObjectArray(lenInner, g_cls_OcRepresentation, nullptr);
- if (!repArr) return nullptr;
+ if (!repArr)
+ {
+ return nullptr;
+ }
for (jsize j = 0; j < lenInner; ++j)
{
OCRepresentation* rep = new OCRepresentation(val[k][i][j]);
return nullptr;
}
env->SetObjectArrayElement(repArr, j, jRepresentation);
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->DeleteLocalRef(jRepresentation);
}
env->SetObjectArrayElement(jMiddleArr, i, repArr);
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->DeleteLocalRef(repArr);
}
env->SetObjectArrayElement(jOuterArr, k, jMiddleArr);
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->DeleteLocalRef(jMiddleArr);
}
return jOuterArr;
#include "JniOcRequestHandle.h"
JniOcRequestHandle::JniOcRequestHandle(OCRequestHandle requestHandle) : m_requestHandle(requestHandle)
-{}
+{
+}
JniOcRequestHandle::~JniOcRequestHandle()
{
LOGD("OcRequestHandle_dispose");
JniOcRequestHandle *handle = JniOcRequestHandle::getJniOcRequestHandlePtr(env, thiz);
delete handle;
-}
\ No newline at end of file
+}
JniOcResource::JniOcResource(std::shared_ptr<OCResource> resource)
: m_sharedResource(resource)
-{}
+{
+}
JniOcResource::~JniOcResource()
{
m_sharedResource = nullptr;
- jint envRet;
+ jint envRet = JNI_ERR;
JNIEnv *env = GetJNIEnv(envRet);
- if (nullptr == env) return;
+ if (nullptr == env)
+ {
+ return;
+ }
m_onGetManager.removeAllListeners(env);
m_onPutManager.removeAllListeners(env);
m_onDeleteManager.removeAllListeners(env);
m_onObserveManager.removeAllListeners(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
OCStackResult JniOcResource::get(JNIEnv* env, const QueryParamsMap &queryParametersMap, jobject jListener)
return;
}
JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
- if (!resource) return;
+ if (!resource)
+ {
+ return;
+ }
QueryParamsMap qpm;
JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
return;
}
JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
- if (!resource) return;
+ if (!resource)
+ {
+ return;
+ }
QueryParamsMap qpm;
JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
return;
}
JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
- if (!resource) return;
+ if (!resource)
+ {
+ return;
+ }
QueryParamsMap qpm;
JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
resourceInterface = env->GetStringUTFChars(jResourceInterface, nullptr);
}
JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
- if (!resource) return;
+ if (!resource)
+ {
+ return;
+ }
QueryParamsMap qpm;
JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
return;
}
JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
- if (!resource) return;
+ if (!resource)
+ {
+ return;
+ }
OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);
- if (!representation) return;
+ if (!representation)
+ {
+ return;
+ }
QueryParamsMap qpm;
JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
return;
}
JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
- if (!resource) return;
+ if (!resource)
+ {
+ return;
+ }
OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);
- if (!representation) return;
+ if (!representation)
+ {
+ return;
+ }
QueryParamsMap qpm;
JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
return;
}
JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
- if (!resource) return;
+ if (!resource)
+ {
+ return;
+ }
OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);
- if (!representation) return;
+ if (!representation)
+ {
+ return;
+ }
QueryParamsMap qpm;
JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
}
JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
- if (!resource) return;
+ if (!resource)
+ {
+ return;
+ }
OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);
- if (!representation) return;
+ if (!representation)
+ {
+ return;
+ }
QueryParamsMap qpm;
JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
return;
}
JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
- if (!resource) return;
+ if (!resource)
+ {
+ return;
+ }
OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);
- if (!representation) return;
+ if (!representation)
+ {
+ return;
+ }
QueryParamsMap qpm;
JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
return;
}
JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
- if (!resource) return;
+ if (!resource)
+ {
+ return;
+ }
OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);
- if (!representation) return;
+ if (!representation)
+ {
+ return;
+ }
QueryParamsMap qpm;
JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
}
JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
- if (!resource) return;
+ if (!resource)
+ {
+ return;
+ }
OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);
- if (!representation) return;
+ if (!representation)
+ {
+ return;
+ }
QueryParamsMap qpm;
JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
}
JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
- if (!resource) return;
+ if (!resource)
+ {
+ return;
+ }
OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);
- if (!representation) return;
+ if (!representation)
+ {
+ return;
+ }
QueryParamsMap qpm;
JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
return;
}
JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
- if (!resource) return;
+ if (!resource)
+ {
+ return;
+ }
try
{
return;
}
JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
- if (!resource) return;
+ if (!resource)
+ {
+ return;
+ }
try
{
return;
}
JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
- if (!resource) return;
+ if (!resource)
+ {
+ return;
+ }
QueryParamsMap qpm;
JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
return;
}
JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
- if (!resource) return;
+ if (!resource)
+ {
+ return;
+ }
QueryParamsMap qpm;
JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
{
LOGD("OcResource_cancelObserve1");
JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
- if (!resource) return;
+ if (!resource)
+ {
+ return;
+ }
try
{
return;
}
JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
- if (!resource) return;
+ if (!resource)
+ {
+ return;
+ }
HeaderOptions headerOptions;
JniUtils::convertJavaHeaderOptionsArrToVector(env, jheaderOptionArr, headerOptions);
{
LOGD("OcResource_unsetHeaderOptions");
JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
- if (!resource) return;
+ if (!resource)
+ {
+ return;
+ }
resource->unsetHeaderOptions();
}
{
LOGD("OcResource_getHost");
JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
- if (!resource) return nullptr;
+ if (!resource)
+ {
+ return nullptr;
+ }
return env->NewStringUTF(resource->host().c_str());
}
{
LOGD("OcResource_getUri");
JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
- if (!resource) return nullptr;
+ if (!resource)
+ {
+ return nullptr;
+ }
return env->NewStringUTF(resource->uri().c_str());
}
{
LOGD("OcResource_getConnectivityType");
JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
- if (!resource) return -1;
+ if (!resource)
+ {
+ return -1;
+ }
OCConnectivityType connectivityType = resource->connectivityType();
return static_cast<jint>(connectivityType);
{
LOGD("OcResource_isObservable");
JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+ if (!resource)
+ {
+ return false;
+ }
+
return (jboolean)resource->isObservable();
}
{
LOGD("OcResource_getResourceTypes");
JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
- if (!resource) return nullptr;
+ if (!resource)
+ {
+ return nullptr;
+ }
std::vector<std::string> resourceTypes = resource->getResourceTypes();
{
LOGD("OcResource_getResourceInterfaces");
JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
- if (!resource) return nullptr;
+ if (!resource)
+ {
+ return nullptr;
+ }
std::vector<std::string> resourceInterfaces = resource->getResourceInterfaces();
{
LOGD("OcResource_getUniqueIdentifier");
JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
- if (!resource) return nullptr;
+ if (!resource)
+ {
+ return nullptr;
+ }
JniOcResourceIdentifier *jniResourceIdentifier =
new JniOcResourceIdentifier(resource->uniqueIdentifier());
- if (!jniResourceIdentifier) return nullptr;
+ if (!jniResourceIdentifier)
+ {
+ return nullptr;
+ }
jlong handle = reinterpret_cast<jlong>(jniResourceIdentifier);
jobject jResourceIdentifier = env->NewObject(g_cls_OcResourceIdentifier,
{
LOGD("OcResource_getServerId");
JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
- if (!resource) return nullptr;
+ if (!resource)
+ {
+ return nullptr;
+ }
return env->NewStringUTF(resource->sid().c_str());
}
LOGD("OcResource_dispose");
JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
delete resource;
-}
\ No newline at end of file
+}
JniOcResourceHandle::JniOcResourceHandle(OCResourceHandle resourceHandle)
: m_resourceHandle(resourceHandle)
-{}
+{
+}
JniOcResourceHandle::~JniOcResourceHandle()
{
LOGD("OcResourceHandle_dispose");
JniOcResourceHandle *resourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(env, thiz);
delete resourceHandle;
-}
\ No newline at end of file
+}
JniOcResourceIdentifier::JniOcResourceIdentifier(OC::OCResourceIdentifier resourceIdentifier)
: m_resourceIdentifier(resourceIdentifier)
-{}
+{
+}
JniOcResourceIdentifier::~JniOcResourceIdentifier()
{
(JNIEnv *env, jobject jThiz, jobject jOther)
{
JniOcResourceIdentifier *thiz = JniOcResourceIdentifier::getJniOcResourceIdentifierPtr(env, jThiz);
- if (!thiz) return false;
+ if (!thiz)
+ {
+ return false;
+ }
JniOcResourceIdentifier *other = JniOcResourceIdentifier::getJniOcResourceIdentifierPtr(env, jOther);
- if (!other) return false;
+ if (!other)
+ {
+ return false;
+ }
if (thiz->getOCResourceIdentifier() == other->getOCResourceIdentifier())
{
LOGD("JniOcResourceIdentifier_dispose");
JniOcResourceIdentifier *identifier = JniOcResourceIdentifier::getJniOcResourceIdentifierPtr(env, thiz);
delete identifier;
-}
\ No newline at end of file
+}
JniOcResourceRequest::JniOcResourceRequest(const std::shared_ptr<OCResourceRequest> request)
: m_request(request)
-{}
+{
+}
JniOcResourceRequest::~JniOcResourceRequest()
-{}
+{
+}
std::string
JniOcResourceRequest::getRequestType()
{
LOGD("OcResourceRequest_getRequestTypeNative");
JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
- if (!request) return nullptr;
-
+ if (!request)
+ {
+ return nullptr;
+ }
std::string requestType = request->getRequestType();
return env->NewStringUTF(requestType.c_str());
}
{
LOGD("OcResourceRequest_getQueryParameters");
JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
- if (!request) return nullptr;
+ if (!request)
+ {
+ return nullptr;
+ }
return JniUtils::convertQueryParamsMapToJavaMap(env, request->getQueryParameters());
}
{
LOGD("OcResourceRequest_getRequestHandlerFlagNative");
JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
- if (!request) return -1;
+ if (!request)
+ {
+ return -1;
+ }
return static_cast<jint>(request->getRequestHandlerFlag());
}
{
LOGD("OcResourceRequest_getResourceRepresentation");
JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
- if (!request) return nullptr;
+ if (!request)
+ {
+ return nullptr;
+ }
OCRepresentation *ocRepresentation = new OCRepresentation(request->getResourceRepresentation());
- if (!ocRepresentation) return nullptr;
+ if (!ocRepresentation)
+ {
+ return nullptr;
+ }
jlong handle = reinterpret_cast<jlong>(ocRepresentation);
jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool,
{
LOGD("OcResourceRequest_getObservationInfo");
JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
- if (!request) return nullptr;
-
+ if (!request)
+ {
+ return nullptr;
+ }
ObservationInfo oInfo = request->getObservationInfo();
jobject jObservationInfo = env->NewObject(g_cls_ObservationInfo, g_mid_ObservationInfo_N_ctor,
return;
}
JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
- if (!request) return;
-
+ if (!request)
+ {
+ return;
+ }
request->setResourceUri(env->GetStringUTFChars(jUri, 0));
}
{
LOGD("OcResourceRequest_getResourceUri");
JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
- if (!request) return nullptr;
-
+ if (!request)
+ {
+ return nullptr;
+ }
std::string requestUri = request->getResourceUri();
return env->NewStringUTF(requestUri.c_str());
}
{
LOGD("OcResourceRequest_getHeaderOptions");
JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
- if (!request) return nullptr;
-
+ if (!request)
+ {
+ return nullptr;
+ }
return JniUtils::convertHeaderOptionsVectorToJavaList(env, request->getHeaderOptions());
}
{
LOGD("OcResourceRequest_getRequestHandle");
JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
- if (!request) return nullptr;
+ if (!request)
+ {
+ return nullptr;
+ }
JniOcRequestHandle* jniHandle = new JniOcRequestHandle(request->getRequestHandle());
jlong handle = reinterpret_cast<jlong>(jniHandle);
{
LOGD("OcResourceRequest_getResourceHandle");
JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
- if (!request) return nullptr;
+ if (!request)
+ {
+ return nullptr;
+ }
JniOcResourceHandle* jniHandle = new JniOcResourceHandle(
request->getResourceHandle());
LOGD("OcResourceRequest_dispose");
JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
delete request;
-}
\ No newline at end of file
+}
JniOcResourceResponse::JniOcResourceResponse
(std::shared_ptr<OCResourceResponse> resourceResponse)
-: m_response(resourceResponse){}
+: m_response(resourceResponse)
+{
+}
JniOcResourceResponse::~JniOcResourceResponse()
-{}
+{
+}
void JniOcResourceResponse::setErrorCode(const int eCode)
{
{
LOGD("OcResourceResponse_setErrorCode");
JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);
- if (!response) return;
-
+ if (!response)
+ {
+ return;
+ }
response->setErrorCode(static_cast<int>(eCode));
}
{
LOGD("OcResourceResponse_getNewResourceUri");
JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);
- if (!response) return nullptr;
-
+ if (!response)
+ {
+ return nullptr;
+ }
return env->NewStringUTF(response->getNewResourceUri().c_str());
}
{
LOGD("OcResourceResponse_setNewResourceUri");
JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);
- if (!response) return;
-
+ if (!response)
+ {
+ return;
+ }
response->setNewResourceUri(env->GetStringUTFChars(jstr, 0));
}
return;
}
JniOcResourceResponse *jniResponse = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);
- if (!jniResponse) return;
-
+ if (!jniResponse)
+ {
+ return;
+ }
HeaderOptions headerOptions;
JniUtils::convertJavaHeaderOptionsArrToVector(env, jHeaderOptions, headerOptions);
return;
}
JniOcResourceResponse *jniResponse = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);
- if (!jniResponse) return;
-
+ if (!jniResponse)
+ {
+ return;
+ }
JniOcRequestHandle* jniOcRequestHandle = JniOcRequestHandle::getJniOcRequestHandlePtr(env, jRequestHandle);
- if (!jniOcRequestHandle) return;
-
+ if (!jniOcRequestHandle)
+ {
+ return;
+ }
jniResponse->setRequestHandle(jniOcRequestHandle->getOCRequestHandle());
}
return;
}
JniOcResourceResponse *jniResponse = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);
- if (!jniResponse) return;
-
+ if (!jniResponse)
+ {
+ return;
+ }
JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(env, jResourceHandle);
- if (!jniOcResourceHandle) return;
-
+ if (!jniOcResourceHandle)
+ {
+ return;
+ }
jniResponse->setResourceHandle(jniOcResourceHandle->getOCResourceHandle());
}
{
LOGD("OcResourceResponse_setResponseResult");
JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);
- if (!response) return;
-
+ if (!response)
+ {
+ return;
+ }
response->setResponseResult(JniUtils::getOCEntityHandlerResult(env, static_cast<int>(responseResult)));
}
JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env,
thiz);
- if (!response) return;
-
+ if (!response)
+ {
+ return;
+ }
OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env,
jRepresentation);
- if (!representation) return;
-
+ if (!representation)
+ {
+ return;
+ }
response->setResourceRepresentation(*representation, env->GetStringUTFChars(jstr, 0));
}
return;
}
JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);
- if (!response) return;
-
+ if (!response)
+ {
+ return;
+ }
OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env,
jRepresentation);
LOGD("OcResourceResponse_dispose");
JniOcResourceResponse *resp = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);
delete resp;
-}
\ No newline at end of file
+}
JniOcSecureResource::JniOcSecureResource(std::shared_ptr<OCSecureResource> device)
: m_sharedSecureResource(device)
-{}
+{
+}
JniOcSecureResource::~JniOcSecureResource()
{
#include "OCRepresentation.h"
#include "JniUtils.h"
+/**
+ * Macro to verify the validity of input argument.
+ *
+ * @param arg log level
+ */
+#define VERIFY_VARIABLE_NULL(arg) \
+ if (nullptr == (arg)) \
+ { \
+ LOGE("invalid input"); \
+ return JNI_ERR; \
+ } \
+
JavaVM* g_jvm = nullptr;
jclass g_cls_Integer = nullptr;
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
{
LOGI("JNI_OnLoad");
- JNIEnv* env;
+ JNIEnv* env = nullptr;
g_jvm = vm;
if (g_jvm->GetEnv((void **)&env, JNI_CURRENT_VERSION) != JNI_OK)
LOGE("Failed to get the environment using GetEnv()");
return JNI_ERR;
}
+ VERIFY_VARIABLE_NULL(env);
jclass clazz = nullptr;
//Integer
clazz = env->FindClass("java/lang/Integer");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
+
g_cls_Integer = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
g_mid_Integer_ctor = env->GetMethodID(g_cls_Integer, "<init>", "(I)V");
- if (!g_mid_Integer_ctor) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_Integer_ctor);
clazz = env->FindClass("[I");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_int1DArray = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
clazz = env->FindClass("[[I");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_int2DArray = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
//Double
clazz = env->FindClass("java/lang/Double");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_Double = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
g_mid_Double_ctor = env->GetMethodID(g_cls_Double, "<init>", "(D)V");
- if (!g_mid_Double_ctor) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_Double_ctor);
clazz = env->FindClass("[D");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_double1DArray = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
clazz = env->FindClass("[[D");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_double2DArray = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
//Boolean
clazz = env->FindClass("java/lang/Boolean");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_Boolean = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
g_mid_Boolean_ctor = env->GetMethodID(g_cls_Boolean, "<init>", "(Z)V");
- if (!g_mid_Boolean_ctor) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_Boolean_ctor);
clazz = env->FindClass("[Z");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_boolean1DArray = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
clazz = env->FindClass("[[Z");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_boolean2DArray = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
//String
clazz = env->FindClass("java/lang/String");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_String = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
clazz = env->FindClass("[Ljava/lang/String;");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_String1DArray = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
clazz = env->FindClass("[[Ljava/lang/String;");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_String2DArray = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
//LinkedList
clazz = env->FindClass("java/util/LinkedList");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_LinkedList = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
g_mid_LinkedList_ctor = env->GetMethodID(g_cls_LinkedList, "<init>", "()V");
- if (!g_mid_LinkedList_ctor) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_LinkedList_ctor);
g_mid_LinkedList_add_object = env->GetMethodID(g_cls_LinkedList, "add", "(Ljava/lang/Object;)Z");
- if (!g_mid_LinkedList_add_object) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_LinkedList_add_object);
//Map
clazz = env->FindClass("java/util/Map");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_Map = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
g_mid_Map_entrySet = env->GetMethodID(g_cls_Map, "entrySet", "()Ljava/util/Set;");
- if (!g_mid_Map_entrySet) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_Map_entrySet);
//MapEntry
clazz = env->FindClass("java/util/Map$Entry");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_MapEntry = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
g_mid_MapEntry_getKey = env->GetMethodID(g_cls_MapEntry, "getKey", "()Ljava/lang/Object;");
- if (!g_mid_MapEntry_getKey) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_MapEntry_getKey);
g_mid_MapEntry_getValue = env->GetMethodID(g_cls_MapEntry, "getValue", "()Ljava/lang/Object;");
- if (!g_mid_MapEntry_getValue) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_MapEntry_getValue);
//Set
clazz = env->FindClass("java/util/Set");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_Set = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
g_mid_Set_iterator = env->GetMethodID(g_cls_Set, "iterator", "()Ljava/util/Iterator;");
- if (!g_mid_Set_iterator) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_Set_iterator);
//Iterator
clazz = env->FindClass("java/util/Iterator");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_Iterator = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
g_mid_Iterator_hasNext = env->GetMethodID(g_cls_Iterator, "hasNext", "()Z");
- if (!g_mid_Iterator_hasNext) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_Iterator_hasNext);
g_mid_Iterator_next = env->GetMethodID(g_cls_Iterator, "next", "()Ljava/lang/Object;");
- if (!g_mid_Iterator_next) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_Iterator_next);
//HashMap
clazz = env->FindClass("java/util/HashMap");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_HashMap = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
g_mid_HashMap_ctor = env->GetMethodID(g_cls_HashMap, "<init>", "()V");
- if (!g_mid_HashMap_ctor) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_HashMap_ctor);
g_mid_HashMap_put = env->GetMethodID(g_cls_HashMap, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
- if (!g_mid_HashMap_put) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_HashMap_put);
//OcException
clazz = env->FindClass("org/iotivity/base/OcException");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_OcException = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
g_mid_OcException_ctor = env->GetMethodID(g_cls_OcException, "<init>", "(Ljava/lang/String;Ljava/lang/String;)V");
- if (!g_mid_OcException_ctor) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcException_ctor);
g_mid_OcException_setNativeExceptionLocation = env->GetMethodID(g_cls_OcException, "setNativeExceptionLocation",
"(Ljava/lang/String;""Ljava/lang/String;""I)V");
- if (!g_mid_OcException_setNativeExceptionLocation) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcException_setNativeExceptionLocation);
//OcResource
clazz = env->FindClass("org/iotivity/base/OcResource");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_OcResource = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
g_mid_OcResource_ctor = env->GetMethodID(g_cls_OcResource, "<init>", "(J)V");
- if (!g_mid_OcResource_ctor) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcResource_ctor);
//OcRepresentation
clazz = env->FindClass("org/iotivity/base/OcRepresentation");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_OcRepresentation = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
g_mid_OcRepresentation_N_ctor = env->GetMethodID(g_cls_OcRepresentation, "<init>", "(J)V");
- if (!g_mid_OcRepresentation_N_ctor) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcRepresentation_N_ctor);
g_mid_OcRepresentation_N_ctor_bool = env->GetMethodID(g_cls_OcRepresentation, "<init>", "(JZ)V");
- if (!g_mid_OcRepresentation_N_ctor_bool) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcRepresentation_N_ctor_bool);
clazz = env->FindClass("[Lorg/iotivity/base/OcRepresentation;");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_OcRepresentation1DArray = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
clazz = env->FindClass("[[Lorg/iotivity/base/OcRepresentation;");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_OcRepresentation2DArray = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
//HeaderOptions
clazz = env->FindClass("org/iotivity/base/OcHeaderOption");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_OcHeaderOption = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
g_mid_OcHeaderOption_ctor = env->GetMethodID(g_cls_OcHeaderOption, "<init>", "(ILjava/lang/String;)V");
- if (!g_mid_OcHeaderOption_ctor) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcHeaderOption_ctor);
g_mid_OcHeaderOption_get_id = env->GetMethodID(g_cls_OcHeaderOption, "getOptionId", "()I");
- if (!g_mid_OcHeaderOption_get_id) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcHeaderOption_get_id);
g_mid_OcHeaderOption_get_data = env->GetMethodID(g_cls_OcHeaderOption, "getOptionData", "()Ljava/lang/String;");
- if (!g_mid_OcHeaderOption_get_data) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcHeaderOption_get_data);
//OcResourceRequest
clazz = env->FindClass("org/iotivity/base/OcResourceRequest");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_OcResourceRequest = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
g_mid_OcResourceRequest_N_ctor = env->GetMethodID(g_cls_OcResourceRequest, "<init>", "(J)V");
- if (!g_mid_OcResourceRequest_N_ctor) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcResourceRequest_N_ctor);
//OcResourceResponse
clazz = env->FindClass("org/iotivity/base/OcResourceResponse");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_OcResourceResponse = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
g_mid_OcResourceResponse_N_ctor = env->GetMethodID(g_cls_OcResourceResponse, "<init>", "(J)V");
- if (!g_mid_OcResourceResponse_N_ctor) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcResourceResponse_N_ctor);
//OcResourceHandle
clazz = env->FindClass("org/iotivity/base/OcResourceHandle");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_OcResourceHandle = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
g_mid_OcResourceHandle_N_ctor = env->GetMethodID(g_cls_OcResourceHandle, "<init>", "(J)V");
- if (!g_mid_OcResourceHandle_N_ctor) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcResourceHandle_N_ctor);
//OcPresenceHandle
clazz = env->FindClass("org/iotivity/base/OcPresenceHandle");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_OcPresenceHandle = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
g_mid_OcPresenceHandle_N_ctor = env->GetMethodID(g_cls_OcPresenceHandle, "<init>", "(J)V");
- if (!g_mid_OcPresenceHandle_N_ctor) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcPresenceHandle_N_ctor);
//OcRequestHandle
clazz = env->FindClass("org/iotivity/base/OcRequestHandle");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_OcRequestHandle = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
g_mid_OcRequestHandle_N_ctor = env->GetMethodID(g_cls_OcRequestHandle, "<init>", "(J)V");
- if (!g_mid_OcRequestHandle_N_ctor) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcRequestHandle_N_ctor);
//OcPresenceStatus
clazz = env->FindClass("org/iotivity/base/OcPresenceStatus");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_OcPresenceStatus = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
g_mid_OcPresenceStatus_get = env->GetStaticMethodID(g_cls_OcPresenceStatus, "get",
"(Ljava/lang/String;)Lorg/iotivity/base/OcPresenceStatus;");
- if (!g_mid_OcPresenceStatus_get) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcPresenceStatus_get);
//ObservationInfo
clazz = env->FindClass("org/iotivity/base/ObservationInfo");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_ObservationInfo = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
g_mid_ObservationInfo_N_ctor = env->GetMethodID(g_cls_ObservationInfo, "<init>", "(IB)V");
- if (!g_mid_ObservationInfo_N_ctor) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_ObservationInfo_N_ctor);
clazz = env->FindClass("org/iotivity/base/OcResourceIdentifier");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_OcResourceIdentifier = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
g_mid_OcResourceIdentifier_N_ctor = env->GetMethodID(g_cls_OcResourceIdentifier, "<init>", "(J)V");
- if (!g_mid_OcResourceIdentifier_N_ctor) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcResourceIdentifier_N_ctor);
//OcSecureResource
clazz = env->FindClass("org/iotivity/base/OcSecureResource");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_OcSecureResource = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
g_mid_OcSecureResource_ctor = env->GetMethodID(g_cls_OcSecureResource, "<init>", "(J)V");
- if (!g_mid_OcSecureResource_ctor) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcSecureResource_ctor);
//ProvisionResult
clazz = env->FindClass("org/iotivity/base/ProvisionResult");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_OcProvisionResult = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
g_mid_OcProvisionResult_ctor = env->GetMethodID(g_cls_OcProvisionResult, "<init>", "(Ljava/lang/String;I)V");
- if (!g_mid_OcProvisionResult_ctor) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcProvisionResult_ctor);
//OcDirectPairDevice
clazz = env->FindClass("org/iotivity/base/OcDirectPairDevice");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_OcDirectPairDevice = (jclass)env->NewGlobalRef(clazz);
- //env->DeleteLocalRef(clazz);
g_mid_OcDirectPairDevice_ctor = env->GetMethodID(g_cls_OcDirectPairDevice, "<init>", "(J)V");
- if (!g_mid_OcDirectPairDevice_ctor) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcDirectPairDevice_ctor);
g_mid_OcDirectPairDevice_dev_ctor = env->GetMethodID(g_cls_OcDirectPairDevice, "<init>", "(Ljava/lang/String;)V");
- if (!g_mid_OcDirectPairDevice_dev_ctor) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcDirectPairDevice_dev_ctor);
env->DeleteLocalRef(clazz);
//OicSecAcl
clazz = env->FindClass("org/iotivity/base/OicSecAcl");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_OcOicSecAcl = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
g_mid_OcOicSecAcl_get_subject = env->GetMethodID(g_cls_OcOicSecAcl, "getSubject", "()Ljava/lang/String;");
- if (!g_mid_OcOicSecAcl_get_subject) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcOicSecAcl_get_subject);
g_mid_OcOicSecAcl_get_resources_cnt = env->GetMethodID(g_cls_OcOicSecAcl, "getResourcesCount", "()I");
- if (!g_mid_OcOicSecAcl_get_resources_cnt) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcOicSecAcl_get_resources_cnt);
g_mid_OcOicSecAcl_get_resources = env->GetMethodID(g_cls_OcOicSecAcl, "getResources", "(I)Ljava/lang/String;");
- if (!g_mid_OcOicSecAcl_get_resources) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcOicSecAcl_get_resources);
g_mid_OcOicSecAcl_get_permission = env->GetMethodID(g_cls_OcOicSecAcl, "getPermission", "()I");
- if (!g_mid_OcOicSecAcl_get_permission) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcOicSecAcl_get_permission);
g_mid_OcOicSecAcl_get_periods_cnt = env->GetMethodID(g_cls_OcOicSecAcl, "getPeriodsCount", "()I");
- if (!g_mid_OcOicSecAcl_get_periods_cnt) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcOicSecAcl_get_periods_cnt);
g_mid_OcOicSecAcl_get_periods = env->GetMethodID(g_cls_OcOicSecAcl, "getPeriods", "(I)Ljava/lang/String;");
- if (!g_mid_OcOicSecAcl_get_periods) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcOicSecAcl_get_periods);
g_mid_OcOicSecAcl_get_recurrences = env->GetMethodID(g_cls_OcOicSecAcl, "getRecurrences", "(I)Ljava/lang/String;");
- if (!g_mid_OcOicSecAcl_get_recurrences) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcOicSecAcl_get_recurrences);
g_mid_OcOicSecAcl_get_rownerID = env->GetMethodID(g_cls_OcOicSecAcl, "getRownerID", "()Ljava/lang/String;");
- if (!g_mid_OcOicSecAcl_get_rownerID) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcOicSecAcl_get_rownerID);
//OicSecPdAcl
clazz = env->FindClass("org/iotivity/base/OicSecPdAcl");
- if (!clazz) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(clazz);
g_cls_OcOicSecPdAcl = (jclass)env->NewGlobalRef(clazz);
env->DeleteLocalRef(clazz);
g_mid_OcOicSecPdAcl_get_resources_cnt = env->GetMethodID(g_cls_OcOicSecPdAcl, "getResourcesCount", "()I");
- if (!g_mid_OcOicSecPdAcl_get_resources_cnt) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcOicSecPdAcl_get_resources_cnt);
g_mid_OcOicSecPdAcl_get_resources = env->GetMethodID(g_cls_OcOicSecPdAcl, "getResources", "(I)Ljava/lang/String;");
- if (!g_mid_OcOicSecPdAcl_get_resources) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcOicSecPdAcl_get_resources);
g_mid_OcOicSecPdAcl_get_permission = env->GetMethodID(g_cls_OcOicSecPdAcl, "getPermission", "()I");
- if (!g_mid_OcOicSecPdAcl_get_permission) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcOicSecPdAcl_get_permission);
g_mid_OcOicSecPdAcl_get_periods_cnt = env->GetMethodID(g_cls_OcOicSecPdAcl, "getPeriodsCount", "()I");
- if (!g_mid_OcOicSecPdAcl_get_periods_cnt) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcOicSecPdAcl_get_periods_cnt);
g_mid_OcOicSecPdAcl_get_periods = env->GetMethodID(g_cls_OcOicSecPdAcl, "getPeriods", "(I)Ljava/lang/String;");
- if (!g_mid_OcOicSecPdAcl_get_periods) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcOicSecPdAcl_get_periods);
g_mid_OcOicSecPdAcl_get_recurrences = env->GetMethodID(g_cls_OcOicSecPdAcl, "getRecurrences", "(I)Ljava/lang/String;");
- if (!g_mid_OcOicSecPdAcl_get_recurrences) return JNI_ERR;
+ VERIFY_VARIABLE_NULL(g_mid_OcOicSecPdAcl_get_recurrences);
return JNI_CURRENT_VERSION;
}
return;
}
+
env->DeleteGlobalRef(g_cls_Integer);
env->DeleteGlobalRef(g_cls_int1DArray);
env->DeleteGlobalRef(g_cls_int2DArray);
JNIEnv *env = nullptr;
ret = g_jvm->GetEnv((void **)&env, JNI_CURRENT_VERSION);
- switch (ret) {
- case JNI_OK:
- return env;
- case JNI_EDETACHED:
- if (g_jvm->AttachCurrentThread(&env, nullptr) < 0)
- {
+ switch (ret)
+ {
+ case JNI_OK:
+ return env;
+ case JNI_EDETACHED:
+ if (g_jvm->AttachCurrentThread(&env, nullptr) < 0)
+ {
+ LOGE("Failed to get the environment");
+ return nullptr;
+ }
+ else
+ {
+ return env;
+ }
+
+ case JNI_EVERSION:
+ LOGE("JNI version not supported");
+ break;
+ default:
LOGE("Failed to get the environment");
return nullptr;
- }
- else
- {
- return env;
- }
-
- case JNI_EVERSION:
- LOGE("JNI version not supported");
- default:
- LOGE("Failed to get the environment");
- return nullptr;
}
+ return nullptr;
}
static void DuplicateString(char ** targetString, std::string sourceString)
strncpy(*targetString, sourceString.c_str(), (sourceString.length() + 1));
}
-#endif // _Included_org_iotivity_base_ocstack
\ No newline at end of file
+#endif // _Included_org_iotivity_base_ocstack
LOGI("~JniOnDPDevicesFoundListener()");
if (m_jwListener)
{
- jint ret;
+ jint ret = JNI_ERR;
JNIEnv *env = GetJNIEnv(ret);
- if (nullptr == env) return;
+ if (nullptr == env)
+ {
+ return;
+ }
env->DeleteWeakGlobalRef(m_jwListener);
m_jwListener = nullptr;
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
}
{
jint ret;
JNIEnv *env = GetJNIEnv(ret);
- if (nullptr == env) return;
+ if (nullptr == env)
+ {
+ return;
+ }
jobject jListener = env->NewLocalRef(m_jwListener);
if (!jListener)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
if (!clsL)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
{
calledFunc = "onGetDirectPairedListener";
}
+ break;
default:
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
return;
}
if (!midL)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
}
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
void JniOnDPDevicesFoundListener::checkExAndRemoveListener(JNIEnv* env)
{
if (m_jwListener)
{
- jint ret;
+ jint ret = JNI_ERR;
JNIEnv *env = GetJNIEnv(ret);
- if (nullptr == env) return;
-
+ if (nullptr == env)
+ {
+ return;
+ }
env->DeleteWeakGlobalRef(m_jwListener);
m_jwListener = nullptr;
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
}
void JniOnDeleteListener::onDeleteCallback(const HeaderOptions& headerOptions, const int eCode)
{
- jint envRet;
+ jint envRet = JNI_ERR;
JNIEnv *env = GetJNIEnv(envRet);
- if (nullptr == env) return;
+ if (nullptr == env)
+ {
+ return;
+ }
jobject jListener = env->NewLocalRef(m_jwListener);
if (!jListener)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
jclass clsL = env->GetObjectClass(jListener);
if (!clsL)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
if (!ex)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
jmethodID midL = env->GetMethodID(clsL, "onDeleteFailed", "(Ljava/lang/Throwable;)V");
if (!midL)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
env->CallVoidMethod(jListener, midL, ex);
if (!jHeaderOptionList)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
if (!midL)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
env->CallVoidMethod(jListener, midL, jHeaderOptionList);
}
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
void JniOnDeleteListener::checkExAndRemoveListener(JNIEnv* env)
{
m_ownerResource->removeOnDeleteListener(env, m_jwListener);
}
-}
\ No newline at end of file
+}
LOGI("~JniOnDeviceInfoListener");
if (m_jwListener)
{
- jint ret;
+ jint ret = JNI_ERR;
JNIEnv *env = GetJNIEnv(ret);
- if (nullptr == env) return;
+ if (nullptr == env)
+ {
+ return;
+ }
env->DeleteWeakGlobalRef(m_jwListener);
m_jwListener = nullptr;
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
}
void JniOnDeviceInfoListener::foundDeviceCallback(const OC::OCRepresentation& ocRepresentation)
{
- jint ret;
+ jint ret = JNI_ERR;
JNIEnv *env = GetJNIEnv(ret);
- if (nullptr == env) return;
+ if (nullptr == env)
+ {
+ return;
+ }
jobject jListener = env->NewLocalRef(m_jwListener);
if (!jListener)
{
LOGI("Java onDeviceInfoListener object is already destroyed, quiting");
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
{
delete rep;
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
{
delete rep;
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
jmethodID midL = env->GetMethodID(clsL, "onDeviceFound", "(Lorg/iotivity/base/OcRepresentation;)V");
{
delete rep;
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
checkExAndRemoveListener(env);
}
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
void JniOnDeviceInfoListener::checkExAndRemoveListener(JNIEnv* env)
{
m_removeListenerCallback(env, m_jwListener);
}
-}
\ No newline at end of file
+}
LOGI("~JniOnDirectPairingListener()");
if (m_jwListener)
{
- jint ret;
+ jint ret = JNI_ERR;
JNIEnv *env = GetJNIEnv(ret);
- if (nullptr == env) return;
+ if (nullptr == env)
+ {
+ return;
+ }
env->DeleteWeakGlobalRef(m_jwListener);
m_jwListener = nullptr;
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
}
void JniOnDirectPairingListener::doDirectPairingCB(std::shared_ptr<OC::OCDirectPairing> dpDev,
OCStackResult result)
{
- jint ret;
+ jint ret = JNI_ERR;
JNIEnv *env = GetJNIEnv(ret);
- if (nullptr == env) return;
+ if (nullptr == env)
+ {
+ return;
+ }
jobject jListener = env->NewLocalRef(m_jwListener);
if (!jListener)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
jclass clsL = env->GetObjectClass(jListener);
-
if (!clsL)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
JniOcDirectPairDevice *device = new JniOcDirectPairDevice(dpDev);
- if (!device) return;
+ if (!device)
+ {
+ return;
+ }
jstring jStr = env->NewStringUTF((dpDev->getDeviceID()).c_str());
if (!jStr)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
- return ;
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
+ return;
}
jobject jresult = env->NewObject(g_cls_OcDirectPairDevice, g_mid_OcDirectPairDevice_ctor);
if (!jresult)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
- return ;
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
+ return;
}
SetHandle<JniOcDirectPairDevice>(env, jresult, device);
if (!midL)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
}
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
void JniOnDirectPairingListener::checkExAndRemoveListener(JNIEnv* env)
LOGD("~JniOnGetListener");
if (m_jwListener)
{
- jint ret;
+ jint ret = JNI_ERR;
JNIEnv *env = GetJNIEnv(ret);
- if (nullptr == env) return;
+ if (nullptr == env)
+ {
+ return;
+ }
env->DeleteWeakGlobalRef(m_jwListener);
m_jwListener = nullptr;
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
}
void JniOnGetListener::onGetCallback(const HeaderOptions& headerOptions,
const OCRepresentation& ocRepresentation, const int eCode)
{
- jint envRet;
+ jint envRet = JNI_ERR;
JNIEnv *env = GetJNIEnv(envRet);
- if (nullptr == env) return;
+ if (nullptr == env)
+ {
+ return;
+ }
jobject jListener = env->NewLocalRef(m_jwListener);
if (!jListener)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
jclass clsL = env->GetObjectClass(jListener);
if (!clsL)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
if (!ex)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
jmethodID midL = env->GetMethodID(clsL, "onGetFailed", "(Ljava/lang/Throwable;)V");
if (!midL)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
env->CallVoidMethod(jListener, midL, ex);
if (!jHeaderOptionList)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
{
delete rep;
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
{
delete rep;
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
env->CallVoidMethod(jListener, midL, jHeaderOptionList, jRepresentation);
}
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
void JniOnGetListener::checkExAndRemoveListener(JNIEnv* env)
{
m_ownerResource->removeOnGetListener(env, m_jwListener);
}
-}
\ No newline at end of file
+}
{
if (m_jwListener)
{
- jint ret;
+ jint ret = JNI_ERR;
JNIEnv *env = GetJNIEnv(ret);
- if (nullptr == env) return;
+ if (nullptr == env)
+ {
+ return;
+ }
env->DeleteWeakGlobalRef(m_jwListener);
m_jwListener = nullptr;
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
}
void JniOnObserveListener::onObserveCallback(const HeaderOptions headerOptions,
const OCRepresentation& ocRepresentation, const int& eCode, const int& sequenceNumber)
{
- jint envRet;
+ jint envRet = JNI_ERR;
JNIEnv *env = GetJNIEnv(envRet);
- if (nullptr == env) return;
+ if (nullptr == env)
+ {
+ return;
+ }
jobject jListener = env->NewLocalRef(m_jwListener);
if (!jListener)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
jclass clsL = env->GetObjectClass(jListener);
if (!clsL)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
if (!ex)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
jmethodID midL = env->GetMethodID(clsL, "onObserveFailed", "(Ljava/lang/Throwable;)V");
if (!midL)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
env->CallVoidMethod(jListener, midL, ex);
if (!jHeaderOptionList)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
{
delete rep;
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
if (!midL)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
}
}
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
void JniOnObserveListener::checkExAndRemoveListener(JNIEnv* env)
{
m_ownerResource->removeOnObserveListener(env, m_jwListener);
}
-}
\ No newline at end of file
+}
LOGI("~JniOnPlatformInfoListener");
if (m_jwListener)
{
- jint ret;
+ jint ret = JNI_ERR;
JNIEnv *env = GetJNIEnv(ret);
- if (nullptr == env) return;
+ if (nullptr == env)
+ {
+ return;
+ }
env->DeleteWeakGlobalRef(m_jwListener);
m_jwListener = nullptr;
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
}
void JniOnPlatformInfoListener::foundPlatformCallback(const OC::OCRepresentation& ocRepresentation)
{
- jint ret;
+ jint ret = JNI_ERR;
JNIEnv *env = GetJNIEnv(ret);
- if (nullptr == env) return;
+ if (nullptr == env)
+ {
+ return;
+ }
jobject jListener = env->NewLocalRef(m_jwListener);
if (!jListener)
{
LOGI("Java onPlatformInfoListener object is already destroyed, quiting");
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
{
delete rep;
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
{
delete rep;
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
jmethodID midL = env->GetMethodID(clsL, "onPlatformFound", "(Lorg/iotivity/base/OcRepresentation;)V");
{
delete rep;
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
checkExAndRemoveListener(env);
}
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
void JniOnPlatformInfoListener::checkExAndRemoveListener(JNIEnv* env)
{
if (m_jwListener)
{
- jint ret;
+ jint ret = JNI_ERR;
JNIEnv *env = GetJNIEnv(ret);
- if (nullptr == env) return;
+ if (nullptr == env)
+ {
+ return;
+ }
env->DeleteWeakGlobalRef(m_jwListener);
m_jwListener = nullptr;
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
}
void JniOnPostListener::onPostCallback(const HeaderOptions& headerOptions,
const OCRepresentation& ocRepresentation, const int eCode)
{
- jint envRet;
+ jint envRet = JNI_ERR;
JNIEnv *env = GetJNIEnv(envRet);
- if (nullptr == env) return;
+ if (nullptr == env)
+ {
+ return;
+ }
jobject jListener = env->NewLocalRef(m_jwListener);
if (!jListener)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
jclass clsL = env->GetObjectClass(jListener);
if (!clsL)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
if (!ex)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
jmethodID midL = env->GetMethodID(clsL, "onPostFailed", "(Ljava/lang/Throwable;)V");
if (!midL)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
env->CallVoidMethod(jListener, midL, ex);
if (!jHeaderOptionList)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
{
delete rep;
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
if (!midL)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
}
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
void JniOnPostListener::checkExAndRemoveListener(JNIEnv* env)
{
m_ownerResource->removeOnPostListener(env, m_jwListener);
}
-}
\ No newline at end of file
+}
LOGD("~JniOnPresenceListener");
if (m_jwListener)
{
- jint ret;
+ jint ret = JNI_ERR;
JNIEnv *env = GetJNIEnv(ret);
- if (nullptr == env) return;
+ if (nullptr == env)
+ {
+ return;
+ }
env->DeleteWeakGlobalRef(m_jwListener);
m_jwListener = nullptr;
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
}
const std::string& hostAddress)
{
LOGI("JniOnPresenceListener::onPresenceCallback");
- if (!m_jwListener) return;
+ if (!m_jwListener)
+ {
+ return;
+ }
- jint ret;
+ jint ret = JNI_ERR;
JNIEnv *env = GetJNIEnv(ret);
- if (nullptr == env) return;
+ if (nullptr == env)
+ {
+ return;
+ }
if (OC_STACK_OK != result && OC_STACK_PRESENCE_STOPPED != result &&
OC_STACK_PRESENCE_TIMEOUT != result && OC_STACK_PRESENCE_DO_NOT_HANDLE != result)
{
ThrowOcException(result, "onPresenceCallback: stack failure");
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
if (enumField.empty())
{
ThrowOcException(JNI_INVALID_VALUE, "Unexpected OCStackResult value");
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
if (!jPresenceStatus)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
if (!jListener)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
if (!clsL)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
jmethodID midL = env->GetMethodID(clsL, "onPresence",
if (!midL)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
LOGE("Java exception is thrown");
checkExAndRemoveListener(env);
}
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
void JniOnPresenceListener::checkExAndRemoveListener(JNIEnv* env)
jweak JniOnPresenceListener::getJWListener()
{
return this->m_jwListener;
-}
\ No newline at end of file
+}
{
if (m_jwListener)
{
- jint ret;
+ jint ret = JNI_ERR;
JNIEnv *env = GetJNIEnv(ret);
- if (nullptr == env) return;
+ if (nullptr == env)
+ {
+ return;
+ }
env->DeleteWeakGlobalRef(m_jwListener);
m_jwListener = nullptr;
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
}
void JniOnPutListener::onPutCallback(const HeaderOptions& headerOptions,
const OCRepresentation& ocRepresentation, const int eCode)
{
- jint envRet;
+ jint envRet = JNI_ERR;
JNIEnv *env = GetJNIEnv(envRet);
- if (nullptr == env) return;
+ if (nullptr == env)
+ {
+ return;
+ }
jobject jListener = env->NewLocalRef(m_jwListener);
if (!jListener)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
jclass clsL = env->GetObjectClass(jListener);
if (!clsL)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
if (!ex)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
jmethodID midL = env->GetMethodID(clsL, "onPutFailed", "(Ljava/lang/Throwable;)V");
if (!midL)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
env->CallVoidMethod(jListener, midL, ex);
if (!jHeaderOptionList)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
{
delete rep;
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
if (!midL)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
}
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == envRet)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
void JniOnPutListener::checkExAndRemoveListener(JNIEnv* env)
{
m_ownerResource->removeOnPutListener(env, m_jwListener);
}
-}
\ No newline at end of file
+}
LOGI("~JniOnResourceFoundListener()");
if (m_jwListener)
{
- jint ret;
+ jint ret = JNI_ERR;
JNIEnv *env = GetJNIEnv(ret);
- if (nullptr == env) return;
+ if (nullptr == env)
+ {
+ return;
+ }
env->DeleteWeakGlobalRef(m_jwListener);
m_jwListener = nullptr;
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
}
void JniOnResourceFoundListener::foundResourceCallback(std::shared_ptr<OC::OCResource> resource)
{
- jint ret;
+ jint ret = JNI_ERR;
JNIEnv *env = GetJNIEnv(ret);
- if (nullptr == env) return;
+ if (nullptr == env)
+ {
+ return;
+ }
jobject jListener = env->NewLocalRef(m_jwListener);
if (!jListener)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
- return;
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
jobject jResource = env->NewObject(g_cls_OcResource, g_mid_OcResource_ctor);
if (!jResource)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
- return;
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
JniOcResource *jniOcResource = new JniOcResource(resource);
{
delete jniOcResource;
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
- return;
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
jclass clsL = env->GetObjectClass(jListener);
if (!clsL)
{
delete jniOcResource;
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
- return;
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
jmethodID midL = env->GetMethodID(clsL, "onResourceFound", "(Lorg/iotivity/base/OcResource;)V");
if (!midL)
{
delete jniOcResource;
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
- return;
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
env->CallVoidMethod(jListener, midL, jResource);
if (env->ExceptionCheck())
LOGE("Java exception is thrown");
delete jniOcResource;
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
- return;
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
void JniOnResourceFoundListener::checkExAndRemoveListener(JNIEnv* env)
{
m_removeListenerCallback(env, m_jwListener);
}
-}
\ No newline at end of file
+}
LOGI("~JniPinCheckListener()");
if (m_jListener)
{
- jint ret;
+ jint ret = JNI_ERR;
JNIEnv *env = GetJNIEnv(ret);
- if (NULL == env) return;
+ if (nullptr == env)
+ {
+ return;
+ }
env->DeleteGlobalRef(m_jListener);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
}
void JniPinCheckListener::PinCallback(char *pinBuf, size_t bufSize)
{
- jint ret;
-
+ jint ret = JNI_ERR;
JNIEnv *env = GetJNIEnv(ret);
- if (NULL == env) return;
+ if (nullptr == env)
+ {
+ return;
+ }
jclass clsL = env->GetObjectClass(m_jListener);
if (!clsL)
{
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
jmethodID midL = env->GetMethodID(clsL, "pinCallbackListener", "()Ljava/lang/String;");
if (!midL)
{
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
jstring jpin = (jstring)env->CallObjectMethod(m_jListener, midL);
if (env->ExceptionCheck())
{
LOGE("Java exception is thrown");
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
OICStrcpy(pinBuf, bufSize, str);
env->ReleaseStringUTFChars(jpin, str);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
LOGI("~JniProvisionResultListner()");
if (m_jwListener)
{
- jint ret;
+ jint ret = JNI_ERR;
JNIEnv *env = GetJNIEnv(ret);
- if (NULL == env) return;
+ if (nullptr == env)
+ {
+ return;
+ }
env->DeleteWeakGlobalRef(m_jwListener);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
}
void JniProvisionResultListner::ProvisionResultCallback(PMResultList_t *result, int hasError,
ListenerFunc func)
{
- jint ret;
+ jint ret = JNI_ERR;
JNIEnv *env = GetJNIEnv(ret);
- if (NULL == env) return;
+ if (nullptr == env)
+ {
+ return;
+ }
jobject jListener = env->NewLocalRef(m_jwListener);
if (!jListener)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
if (!clsL)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
if (!jResultList)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
default:
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
+ return;
}
return;
}
if (!midL)
{
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
return;
}
env->CallVoidMethod(jListener, midL, jResultList, (jint)hasError);
}
checkExAndRemoveListener(env);
- if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+ if (JNI_EDETACHED == ret)
+ {
+ g_jvm->DetachCurrentThread();
+ }
}
void JniProvisionResultListner::checkExAndRemoveListener(JNIEnv* env)
jobject JniUtils::convertStrVectorToJavaStrList(JNIEnv *env, std::vector<std::string> &vector)
{
jobject jList = env->NewObject(g_cls_LinkedList, g_mid_LinkedList_ctor);
- if (!jList) return nullptr;
+ if (!jList)
+ {
+ return nullptr;
+ }
for (size_t i = 0; i < vector.size(); ++i)
{
jstring jStr = env->NewStringUTF(vector[i].c_str());
- if (!jStr) return nullptr;
+ if (!jStr)
+ {
+ return nullptr;
+ }
env->CallBooleanMethod(jList, g_mid_LinkedList_add_object, jStr);
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->DeleteLocalRef(jStr);
}
return jList;
void JniUtils::convertJavaStrArrToStrVector(JNIEnv *env, jobjectArray jStrArr, std::vector<std::string> &vector)
{
- if (!jStrArr) return;
+ if (!jStrArr)
+ {
+ return;
+ }
jsize len = env->GetArrayLength(jStrArr);
for (jsize i = 0; i < len; ++i)
{
jstring jStr = (jstring)env->GetObjectArrayElement(jStrArr, i);
- if (!jStr) return;
+ if (!jStr)
+ {
+ return;
+ }
vector.push_back(env->GetStringUTFChars(jStr, nullptr));
- if (env->ExceptionCheck()) return;
+ if (env->ExceptionCheck())
+ {
+ return;
+ }
env->DeleteLocalRef(jStr);
}
}
void JniUtils::convertJavaHeaderOptionsArrToVector(JNIEnv *env, jobjectArray jHeaderOptions,
OC::HeaderOptions &headerOptions)
{
- if (!jHeaderOptions) return;
+ if (!jHeaderOptions)
+ {
+ return;
+ }
+
jsize len = env->GetArrayLength(jHeaderOptions);
for (jsize i = 0; i < len; ++i)
{
jobject header = env->GetObjectArrayElement(jHeaderOptions, i);
- if (!header) return;
+ if (!header)
+ {
+ return;
+ }
jint jId = env->CallIntMethod(header, g_mid_OcHeaderOption_get_id);
jstring jData = (jstring)env->CallObjectMethod(header, g_mid_OcHeaderOption_get_data);
OC::HeaderOption::OCHeaderOption hopt(
headerOptions.push_back(hopt);
- if (env->ExceptionCheck()) return;
+ if (env->ExceptionCheck())
+ {
+ return;
+ }
env->DeleteLocalRef(header);
env->DeleteLocalRef(jData);
}
jobject JniUtils::convertHeaderOptionsVectorToJavaList(JNIEnv *env, const OC::HeaderOptions& headerOptions)
{
jobject jHeaderOptionList = env->NewObject(g_cls_LinkedList, g_mid_LinkedList_ctor);
- if (!jHeaderOptionList) return nullptr;
+ if (!jHeaderOptionList)
+ {
+ return nullptr;
+ }
for (size_t i = 0; i < headerOptions.size(); ++i)
{
static_cast<jint>(headerOptions[i].getOptionID()),
env->NewStringUTF(headerOptions[i].getOptionData().c_str())
);
- if (!jHeaderOption) return nullptr;
+ if (!jHeaderOption)
+ {
+ return nullptr;
+ }
env->CallBooleanMethod(jHeaderOptionList, g_mid_LinkedList_add_object, jHeaderOption);
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->DeleteLocalRef(jHeaderOption);
}
void JniUtils::convertJavaMapToQueryParamsMap(JNIEnv *env, jobject hashMap, OC::QueryParamsMap &map)
{
- if (!hashMap) return;
+ if (!hashMap)
+ {
+ return;
+ }
jobject jEntrySet = env->CallObjectMethod(hashMap, g_mid_Map_entrySet);
jobject jIterator = env->CallObjectMethod(jEntrySet, g_mid_Set_iterator);
- if (!jEntrySet || !jIterator || env->ExceptionCheck()) return;
+ if (!jEntrySet || !jIterator || env->ExceptionCheck())
+ {
+ return;
+ }
while (env->CallBooleanMethod(jIterator, g_mid_Iterator_hasNext))
{
jobject jEntry = env->CallObjectMethod(jIterator, g_mid_Iterator_next);
- if (!jEntry) return;
+ if (!jEntry)
+ {
+ return;
+ }
jstring jKey = (jstring)env->CallObjectMethod(jEntry, g_mid_MapEntry_getKey);
- if (!jKey) return;
+ if (!jKey)
+ {
+ return;
+ }
jstring jValue = (jstring)env->CallObjectMethod(jEntry, g_mid_MapEntry_getValue);
- if (!jValue) return;
+ if (!jValue)
+ {
+ return;
+ }
map.insert(std::make_pair(env->GetStringUTFChars(jKey, nullptr),
env->GetStringUTFChars(jValue, nullptr)));
- if (env->ExceptionCheck()) return;
+ if (env->ExceptionCheck())
+ {
+ return;
+ }
env->DeleteLocalRef(jEntry);
env->DeleteLocalRef(jKey);
env->DeleteLocalRef(jValue);
jobject JniUtils::convertQueryParamsMapToJavaMap(JNIEnv *env, const OC::QueryParamsMap &map)
{
jobject hashMap = env->NewObject(g_cls_HashMap, g_mid_HashMap_ctor);
- if (!hashMap) return nullptr;
+ if (!hashMap)
+ {
+ return nullptr;
+ }
for (auto it = map.begin(); it != map.end(); ++it)
{
g_mid_HashMap_put,
env->NewStringUTF(key.c_str()),
env->NewStringUTF(value.c_str()));
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
}
return hashMap;
jobjectArray jRepresentationArray,
std::vector<OC::OCRepresentation>& representationVector)
{
- if (!jRepresentationArray) return;
+ if (!jRepresentationArray)
+ {
+ return;
+ }
jsize len = env->GetArrayLength(jRepresentationArray);
for (jsize i = 0; i < len; ++i)
{
jobject jRep = env->GetObjectArrayElement(jRepresentationArray, i);
- if (!jRep) return;
+ if (!jRep)
+ {
+ return;
+ }
OC::OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, jRep);
representationVector.push_back(*rep);
- if (env->ExceptionCheck()) return;
+ if (env->ExceptionCheck())
+ {
+ return;
+ }
env->DeleteLocalRef(jRep);
}
}
{
jsize len = static_cast<jsize>(representationVector.size());
jobjectArray repArr = env->NewObjectArray(len, g_cls_OcRepresentation, nullptr);
- if (!repArr) return nullptr;
+ if (!repArr)
+ {
+ return nullptr;
+ }
for (jsize i = 0; i < len; ++i)
{
OCRepresentation* rep = new OCRepresentation(representationVector[i]);
return nullptr;
}
env->SetObjectArrayElement(repArr, i, jRepresentation);
- if (env->ExceptionCheck()) return nullptr;
+ if (env->ExceptionCheck())
+ {
+ return nullptr;
+ }
env->DeleteLocalRef(jRepresentation);
}
return repArr;
-}
\ No newline at end of file
+}
static OC::ServiceType getServiceType(JNIEnv *env, int type)
{
- switch (type) {
- case 0:
- return OC::ServiceType::InProc;
- case 1:
- return OC::ServiceType::OutOfProc;
- default:
- ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected service type");
- return OC::ServiceType::OutOfProc;
+ switch (type)
+ {
+ case 0:
+ return OC::ServiceType::InProc;
+ case 1:
+ return OC::ServiceType::OutOfProc;
+ default:
+ ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected service type");
+ return OC::ServiceType::OutOfProc;
};
}
static OC::ModeType getModeType(JNIEnv *env, int type)
{
- switch (type) {
- case 0:
- return OC::ModeType::Server;
- case 1:
- return OC::ModeType::Client;
- case 2:
- return OC::ModeType::Both;
- case 3:
- return OC::ModeType::Gateway;
- default:
- ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected mode type");
- return OC::ModeType::Both;
+ switch (type)
+ {
+ case 0:
+ return OC::ModeType::Server;
+ case 1:
+ return OC::ModeType::Client;
+ case 2:
+ return OC::ModeType::Both;
+ case 3:
+ return OC::ModeType::Gateway;
+ default:
+ ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected mode type");
+ return OC::ModeType::Both;
};
}
static OC::QualityOfService getQOS(JNIEnv *env, int type)
{
- switch (type) {
- case 0:
- return OC::QualityOfService::LowQos;
- case 1:
- return OC::QualityOfService::MidQos;
- case 2:
- return OC::QualityOfService::HighQos;
- case 3:
- return OC::QualityOfService::NaQos;
- default:
- ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected quality of service");
- return OC::QualityOfService::NaQos;
+ switch (type)
+ {
+ case 0:
+ return OC::QualityOfService::LowQos;
+ case 1:
+ return OC::QualityOfService::MidQos;
+ case 2:
+ return OC::QualityOfService::HighQos;
+ case 3:
+ return OC::QualityOfService::NaQos;
+ default:
+ ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected quality of service");
+ return OC::QualityOfService::NaQos;
};
}
static OC::ObserveType getObserveType(JNIEnv *env, int type)
{
- switch (type) {
- case 0:
- return OC::ObserveType::Observe;
- case 1:
- return OC::ObserveType::ObserveAll;
- default:
- ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected observe type");
- return OC::ObserveType::ObserveAll;
+ switch (type)
+ {
+ case 0:
+ return OC::ObserveType::Observe;
+ case 1:
+ return OC::ObserveType::ObserveAll;
+ default:
+ ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected observe type");
+ return OC::ObserveType::ObserveAll;
};
}
static OCEntityHandlerResult getOCEntityHandlerResult(JNIEnv *env, int type)
{
- switch (type) {
- case 0:
- return OCEntityHandlerResult::OC_EH_OK;
- case 1:
- return OCEntityHandlerResult::OC_EH_ERROR;
- case 2:
- return OCEntityHandlerResult::OC_EH_RESOURCE_CREATED;
- case 3:
- return OCEntityHandlerResult::OC_EH_RESOURCE_DELETED;
- case 4:
- return OCEntityHandlerResult::OC_EH_SLOW;
- case 5:
- return OCEntityHandlerResult::OC_EH_FORBIDDEN;
- case 6:
- return OCEntityHandlerResult::OC_EH_RESOURCE_NOT_FOUND;
- default:
- ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected OCEntityHandlerResult");
- return OCEntityHandlerResult::OC_EH_ERROR;
+ switch (type)
+ {
+ case 0:
+ return OCEntityHandlerResult::OC_EH_OK;
+ case 1:
+ return OCEntityHandlerResult::OC_EH_ERROR;
+ case 2:
+ return OCEntityHandlerResult::OC_EH_RESOURCE_CREATED;
+ case 3:
+ return OCEntityHandlerResult::OC_EH_RESOURCE_DELETED;
+ case 4:
+ return OCEntityHandlerResult::OC_EH_SLOW;
+ case 5:
+ return OCEntityHandlerResult::OC_EH_FORBIDDEN;
+ case 6:
+ return OCEntityHandlerResult::OC_EH_RESOURCE_NOT_FOUND;
+ default:
+ ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected OCEntityHandlerResult");
+ return OCEntityHandlerResult::OC_EH_ERROR;
};
}
{
switch (result)
{
- /** Success status code - START HERE.*/
- case OC_STACK_OK:
- return "OK";
- case OC_STACK_RESOURCE_CREATED:
- return "RESOURCE_CREATED";
- case OC_STACK_RESOURCE_DELETED:
- return "RESOURCE_DELETED";
- case OC_STACK_CONTINUE:
- return "CONTINUE";
- /* Error status code - START HERE */
- case OC_STACK_INVALID_URI:
- return "INVALID_URI";
- case OC_STACK_INVALID_QUERY:
- return "INVALID_QUERY";
- case OC_STACK_INVALID_IP:
- return "INVALID_IP";
- case OC_STACK_INVALID_PORT:
- return "INVALID_PORT";
- case OC_STACK_INVALID_CALLBACK:
- return "INVALID_CALLBACK";
- case OC_STACK_INVALID_METHOD:
- return "INVALID_METHOD";
- /** Invalid parameter.*/
- case OC_STACK_INVALID_PARAM:
- return "INVALID_PARAM";
- case OC_STACK_INVALID_OBSERVE_PARAM:
- return "INVALID_OBSERVE_PARAM";
- case OC_STACK_NO_MEMORY:
- return "NO_MEMORY";
- case OC_STACK_COMM_ERROR:
- return "COMM_ERROR";
- case OC_STACK_TIMEOUT:
- return "TIMEOUT";
- case OC_STACK_ADAPTER_NOT_ENABLED:
- return "ADAPTER_NOT_ENABLED";
- case OC_STACK_NOTIMPL:
- return "NOTIMPL";
- /** Resource not found.*/
- case OC_STACK_NO_RESOURCE:
- return "NO_RESOURCE";
- /** e.g: not supported method or interface.*/
- case OC_STACK_RESOURCE_ERROR:
- return "RESOURCE_ERROR";
- case OC_STACK_SLOW_RESOURCE:
- return "SLOW_RESOURCE";
- case OC_STACK_DUPLICATE_REQUEST:
- return "DUPLICATE_REQUEST";
- /** Resource has no registered observers.*/
- case OC_STACK_NO_OBSERVERS:
- return "NO_OBSERVERS";
- case OC_STACK_OBSERVER_NOT_FOUND:
- return "OBSERVER_NOT_FOUND";
- case OC_STACK_VIRTUAL_DO_NOT_HANDLE:
- return "VIRTUAL_DO_NOT_HANDLE";
- case OC_STACK_INVALID_OPTION:
- return "INVALID_OPTION";
- /** The remote reply contained malformed data.*/
- case OC_STACK_MALFORMED_RESPONSE:
- return "MALFORMED_RESPONSE";
- case OC_STACK_PERSISTENT_BUFFER_REQUIRED:
- return "PERSISTENT_BUFFER_REQUIRED";
- case OC_STACK_INVALID_REQUEST_HANDLE:
- return "INVALID_REQUEST_HANDLE";
- case OC_STACK_INVALID_DEVICE_INFO:
- return "INVALID_DEVICE_INFO";
- case OC_STACK_INVALID_JSON:
- return "INVALID_JSON";
- /** Request is not authorized by Resource Server. */
- case OC_STACK_UNAUTHORIZED_REQ:
- return "UNAUTHORIZED_REQ";
- /** Error code from PDM */
- case OC_STACK_PDM_IS_NOT_INITIALIZED:
- return "PDM_IS_NOT_INITIALIZED";
- case OC_STACK_DUPLICATE_UUID:
- return "DUPLICATE_UUID";
- case OC_STACK_INCONSISTENT_DB:
- return "INCONSISTENT_DB";
- /** Error code from OTM */
- case OC_STACK_AUTHENTICATION_FAILURE:
- return "AUTHENTICATION_FAILURE";
- /** Insert all new error codes here!.*/
+ /** Success status code - START HERE.*/
+ case OC_STACK_OK:
+ return "OK";
+ case OC_STACK_RESOURCE_CREATED:
+ return "RESOURCE_CREATED";
+ case OC_STACK_RESOURCE_DELETED:
+ return "RESOURCE_DELETED";
+ case OC_STACK_CONTINUE:
+ return "CONTINUE";
+ /* Error status code - START HERE */
+ case OC_STACK_INVALID_URI:
+ return "INVALID_URI";
+ case OC_STACK_INVALID_QUERY:
+ return "INVALID_QUERY";
+ case OC_STACK_INVALID_IP:
+ return "INVALID_IP";
+ case OC_STACK_INVALID_PORT:
+ return "INVALID_PORT";
+ case OC_STACK_INVALID_CALLBACK:
+ return "INVALID_CALLBACK";
+ case OC_STACK_INVALID_METHOD:
+ return "INVALID_METHOD";
+ /** Invalid parameter.*/
+ case OC_STACK_INVALID_PARAM:
+ return "INVALID_PARAM";
+ case OC_STACK_INVALID_OBSERVE_PARAM:
+ return "INVALID_OBSERVE_PARAM";
+ case OC_STACK_NO_MEMORY:
+ return "NO_MEMORY";
+ case OC_STACK_COMM_ERROR:
+ return "COMM_ERROR";
+ case OC_STACK_TIMEOUT:
+ return "TIMEOUT";
+ case OC_STACK_ADAPTER_NOT_ENABLED:
+ return "ADAPTER_NOT_ENABLED";
+ case OC_STACK_NOTIMPL:
+ return "NOTIMPL";
+ /** Resource not found.*/
+ case OC_STACK_NO_RESOURCE:
+ return "NO_RESOURCE";
+ /** e.g: not supported method or interface.*/
+ case OC_STACK_RESOURCE_ERROR:
+ return "RESOURCE_ERROR";
+ case OC_STACK_SLOW_RESOURCE:
+ return "SLOW_RESOURCE";
+ case OC_STACK_DUPLICATE_REQUEST:
+ return "DUPLICATE_REQUEST";
+ /** Resource has no registered observers.*/
+ case OC_STACK_NO_OBSERVERS:
+ return "NO_OBSERVERS";
+ case OC_STACK_OBSERVER_NOT_FOUND:
+ return "OBSERVER_NOT_FOUND";
+ case OC_STACK_VIRTUAL_DO_NOT_HANDLE:
+ return "VIRTUAL_DO_NOT_HANDLE";
+ case OC_STACK_INVALID_OPTION:
+ return "INVALID_OPTION";
+ /** The remote reply contained malformed data.*/
+ case OC_STACK_MALFORMED_RESPONSE:
+ return "MALFORMED_RESPONSE";
+ case OC_STACK_PERSISTENT_BUFFER_REQUIRED:
+ return "PERSISTENT_BUFFER_REQUIRED";
+ case OC_STACK_INVALID_REQUEST_HANDLE:
+ return "INVALID_REQUEST_HANDLE";
+ case OC_STACK_INVALID_DEVICE_INFO:
+ return "INVALID_DEVICE_INFO";
+ case OC_STACK_INVALID_JSON:
+ return "INVALID_JSON";
+ /** Request is not authorized by Resource Server. */
+ case OC_STACK_UNAUTHORIZED_REQ:
+ return "UNAUTHORIZED_REQ";
+ /** Error code from PDM */
+ case OC_STACK_PDM_IS_NOT_INITIALIZED:
+ return "PDM_IS_NOT_INITIALIZED";
+ case OC_STACK_DUPLICATE_UUID:
+ return "DUPLICATE_UUID";
+ case OC_STACK_INCONSISTENT_DB:
+ return "INCONSISTENT_DB";
+ /** Error code from OTM */
+ case OC_STACK_AUTHENTICATION_FAILURE:
+ return "AUTHENTICATION_FAILURE";
+ /** Insert all new error codes here!.*/
#ifdef WITH_PRESENCE
- case OC_STACK_PRESENCE_STOPPED:
- return "PRESENCE_STOPPED";
- case OC_STACK_PRESENCE_TIMEOUT:
- return "PRESENCE_TIMEOUT";
- case OC_STACK_PRESENCE_DO_NOT_HANDLE:
- return "PRESENCE_DO_NOT_HANDLE";
+ case OC_STACK_PRESENCE_STOPPED:
+ return "PRESENCE_STOPPED";
+ case OC_STACK_PRESENCE_TIMEOUT:
+ return "PRESENCE_TIMEOUT";
+ case OC_STACK_PRESENCE_DO_NOT_HANDLE:
+ return "PRESENCE_DO_NOT_HANDLE";
#endif
- case OC_STACK_ERROR:
- return "ERROR";
+ case OC_STACK_ERROR:
+ return "ERROR";
- case JNI_EXCEPTION:
- return "JNI_EXCEPTION";
- case JNI_NO_NATIVE_POINTER:
- return "JNI_NO_NATIVE_POINTER";
- case JNI_INVALID_VALUE:
- return "JNI_INVALID_VALUE";
- default:
- return "";
+ case JNI_EXCEPTION:
+ return "JNI_EXCEPTION";
+ case JNI_NO_NATIVE_POINTER:
+ return "JNI_NO_NATIVE_POINTER";
+ case JNI_INVALID_VALUE:
+ return "JNI_INVALID_VALUE";
+ default:
+ return "";
}
}
};
requestInfo.info.payloadFormat = CA_FORMAT_UNDEFINED;
}
- if (result != OC_STACK_OK)
- {
- OIC_LOG(ERROR, TAG, "CACreateEndpoint error");
- goto exit;
- }
-
// prepare for response
#ifdef WITH_PRESENCE
if (method == OC_REST_PRESENCE)
previous = pointer;
pointer = pointer->next;
}
- previous->next = newInterface;
+
+ if (previous)
+ {
+ previous->next = newInterface;
+ }
}
}