2 *******************************************************************
4 * Copyright 2016 Samsung Electronics All Rights Reserved.
6 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
20 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
23 #include "JniOcAccountManager.h"
24 #include "JniOcRepresentation.h"
27 #define VERIFY_NON_NULL_THROW_EXCEPTION(arg, log_message, exc) \
30 ThrowOcException(exc, log_message); \
34 JniOcAccountManager::JniOcAccountManager(std::shared_ptr<OCAccountManager> accountManager)
35 : m_sharedAccountManager(accountManager)
39 JniOcAccountManager::~JniOcAccountManager()
41 LOGD("~JniOcAccountManager()");
43 m_sharedAccountManager = nullptr;
45 jint envRet = JNI_ERR;
46 JNIEnv *env = GetJNIEnv(envRet);
52 m_onGetManager.removeAllListeners(env);
53 m_onPostManager.removeAllListeners(env);
54 m_onDeleteManager.removeAllListeners(env);
55 m_onObserveManager.removeAllListeners(env);
57 if (JNI_EDETACHED == envRet)
59 g_jvm->DetachCurrentThread();
63 std::string JniOcAccountManager::host()
65 return m_sharedAccountManager->host();
68 OCConnectivityType JniOcAccountManager::connectivityType() const
70 return m_sharedAccountManager->connectivityType();
73 JniOcAccountManager* JniOcAccountManager::getJniOcAccountManagerPtr(JNIEnv *env, jobject thiz)
75 JniOcAccountManager *accountManager = GetHandle<JniOcAccountManager>(env, thiz);
76 if (env->ExceptionCheck())
78 LOGE("Failed to get native handle from OcAccountManager");
82 ThrowOcException(JNI_NO_NATIVE_POINTER, "");
84 return accountManager;
87 JniOnGetListener* JniOcAccountManager::addOnGetListener(JNIEnv* env, jobject jListener)
89 return this->m_onGetManager.addListener(env, jListener,
90 std::bind(&JniOcAccountManager::removeOnGetListener, this,
91 std::placeholders::_1, std::placeholders::_2));
94 JniOnPostListener* JniOcAccountManager::addOnPostListener(JNIEnv* env, jobject jListener)
96 return this->m_onPostManager.addListener(env, jListener,
97 std::bind(&JniOcAccountManager::removeOnPostListener, this,
98 std::placeholders::_1, std::placeholders::_2));
101 JniOnDeleteListener* JniOcAccountManager::addOnDeleteListener(JNIEnv* env, jobject jListener)
103 return this->m_onDeleteManager.addListener(env, jListener,
104 std::bind(&JniOcAccountManager::removeOnDeleteListener, this,
105 std::placeholders::_1, std::placeholders::_2));
108 JniOnObserveListener* JniOcAccountManager::addOnObserveListener(JNIEnv* env, jobject jListener)
110 return this->m_onObserveManager.addListener(env, jListener,
111 std::bind(&JniOcAccountManager::removeOnObserveListener, this,
112 std::placeholders::_1, std::placeholders::_2));
115 void JniOcAccountManager::removeOnGetListener(JNIEnv* env, jobject jListener)
117 this->m_onGetManager.removeListener(env, jListener);
120 void JniOcAccountManager::removeOnPostListener(JNIEnv* env, jobject jListener)
122 this->m_onPostManager.removeListener(env, jListener);
125 void JniOcAccountManager::removeOnDeleteListener(JNIEnv* env, jobject jListener)
127 this->m_onDeleteManager.removeListener(env, jListener);
130 void JniOcAccountManager::removeOnObserveListener(JNIEnv* env, jobject jListener)
132 this->m_onObserveManager.removeListener(env, jListener);
135 OCStackResult JniOcAccountManager::signUp(JNIEnv* env, const std::string& authProvider,
136 const std::string& authCode, jobject jListener)
138 JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
139 if (nullptr == onPostListener)
141 LOGE("onPostListener is null");
142 return OC_STACK_ERROR;
145 PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
146 const OCRepresentation& rep, const int eCode)
148 onPostListener->onPostCallback(opts, rep, eCode);
151 return m_sharedAccountManager->signUp(authProvider, authCode, postCallback);
154 OCStackResult JniOcAccountManager::signUp(JNIEnv* env, const std::string& authProvider,
155 const std::string& authCode,
156 const QueryParamsMap& options, jobject jListener)
158 JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
159 if (nullptr == onPostListener)
161 LOGE("onPostListener is null");
162 return OC_STACK_ERROR;
165 PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
166 const OCRepresentation& rep, const int eCode)
168 onPostListener->onPostCallback(opts, rep, eCode);
171 return m_sharedAccountManager->signUp(authProvider, authCode, options, postCallback);
174 OCStackResult JniOcAccountManager::signIn(JNIEnv* env, const std::string& userUuid,
175 const std::string& accessToken, jobject jListener)
177 JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
178 if (nullptr == onPostListener)
180 LOGE("onPostListener is null");
181 return OC_STACK_ERROR;
184 PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
185 const OCRepresentation& rep, const int eCode)
187 onPostListener->onPostCallback(opts, rep, eCode);
190 return m_sharedAccountManager->signIn(userUuid, accessToken, postCallback);
193 OCStackResult JniOcAccountManager::signOut(JNIEnv* env, const std::string& accessToken,
196 JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
197 if (nullptr == onPostListener)
199 LOGE("onPostListener is null");
200 return OC_STACK_ERROR;
203 PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
204 const OCRepresentation& rep, const int eCode)
206 onPostListener->onPostCallback(opts, rep, eCode);
209 return m_sharedAccountManager->signOut(accessToken, postCallback);
212 OCStackResult JniOcAccountManager::refreshAccessToken(JNIEnv* env, const std::string& userUuid,
213 const std::string& refreshToken,
216 JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
217 if (nullptr == onPostListener)
219 LOGE("onPostListener is null");
220 return OC_STACK_ERROR;
223 PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
224 const OCRepresentation& rep, const int eCode)
226 onPostListener->onPostCallback(opts, rep, eCode);
229 return m_sharedAccountManager->refreshAccessToken(userUuid, refreshToken, postCallback);
232 OCStackResult JniOcAccountManager::searchUser(JNIEnv* env, const QueryParamsMap& queryMap,
235 JniOnGetListener *onGetListener = addOnGetListener(env, jListener);
236 if (nullptr == onGetListener)
238 LOGE("onGetListener is null");
239 return OC_STACK_ERROR;
242 GetCallback getCallback = [onGetListener](const HeaderOptions& opts,
243 const OCRepresentation& rep, const int eCode)
245 onGetListener->onGetCallback(opts, rep, eCode);
248 return m_sharedAccountManager->searchUser(queryMap, getCallback);
251 OCStackResult JniOcAccountManager::deleteDevice(JNIEnv* env, const std::string& accessToken,
252 const std::string& deviceId, jobject jListener)
254 JniOnDeleteListener *onDeleteListener = addOnDeleteListener(env, jListener);
255 if (nullptr == onDeleteListener)
257 LOGE("onDeleteListener is null");
258 return OC_STACK_ERROR;
261 DeleteCallback deleteCallback = [onDeleteListener](const HeaderOptions& opts,
264 onDeleteListener->onDeleteCallback(opts, eCode);
267 return m_sharedAccountManager->deleteDevice(accessToken, deviceId, deleteCallback);
270 OCStackResult JniOcAccountManager::createGroup(JNIEnv* env, jobject jListener)
272 JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
273 if (nullptr == onPostListener)
275 LOGE("onPostListener is null");
276 return OC_STACK_ERROR;
279 PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
280 const OCRepresentation& rep, const int eCode)
282 onPostListener->onPostCallback(opts, rep, eCode);
285 return m_sharedAccountManager->createGroup(postCallback);
288 OCStackResult JniOcAccountManager::createGroup(JNIEnv* env, const QueryParamsMap& queryMap,
291 JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
292 if (nullptr == onPostListener)
294 LOGE("onPostListener is null");
295 return OC_STACK_ERROR;
298 PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
299 const OCRepresentation& rep, const int eCode)
301 onPostListener->onPostCallback(opts, rep, eCode);
304 return m_sharedAccountManager->createGroup(queryMap, postCallback);
307 OCStackResult JniOcAccountManager::deleteGroup(JNIEnv* env, const std::string& groupId,
310 JniOnDeleteListener *onDeleteListener = addOnDeleteListener(env, jListener);
311 if (nullptr == onDeleteListener)
313 LOGE("onDeleteListener is null");
314 return OC_STACK_ERROR;
317 DeleteCallback deleteCallback = [onDeleteListener](const HeaderOptions& opts,
320 onDeleteListener->onDeleteCallback(opts, eCode);
323 return m_sharedAccountManager->deleteGroup(groupId, deleteCallback);
326 OCStackResult JniOcAccountManager::getGroupInfoAll(JNIEnv* env, jobject jListener)
328 JniOnGetListener *onGetListener = addOnGetListener(env, jListener);
329 if (nullptr == onGetListener)
331 LOGE("onGetListener is null");
332 return OC_STACK_ERROR;
335 GetCallback getCallback = [onGetListener](const HeaderOptions& opts,
336 const OCRepresentation& rep, const int eCode)
338 onGetListener->onGetCallback(opts, rep, eCode);
341 return m_sharedAccountManager->getGroupInfoAll(getCallback);
344 OCStackResult JniOcAccountManager::getGroupInfo(JNIEnv* env, const std::string& groupId,
347 JniOnGetListener *onGetListener = addOnGetListener(env, jListener);
348 if (nullptr == onGetListener)
350 LOGE("onGetListener is null");
351 return OC_STACK_ERROR;
354 GetCallback getCallback = [onGetListener](const HeaderOptions& opts,
355 const OCRepresentation& rep, const int eCode)
357 onGetListener->onGetCallback(opts, rep, eCode);
360 return m_sharedAccountManager->getGroupInfo(groupId, getCallback);
363 OCStackResult JniOcAccountManager::addPropertyValueToGroup(JNIEnv* env, const std::string& groupId,
364 const OCRepresentation& propertyValue,
367 JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
368 if (nullptr == onPostListener)
370 LOGE("onPostListener is null");
371 return OC_STACK_ERROR;
374 PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
375 const OCRepresentation& rep, const int eCode)
377 onPostListener->onPostCallback(opts, rep, eCode);
380 return m_sharedAccountManager->addPropertyValueToGroup(groupId, propertyValue, postCallback);
383 OCStackResult JniOcAccountManager::deletePropertyValueFromGroup(JNIEnv* env,
384 const std::string& groupId,
385 const OCRepresentation& propertyValue,
388 JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
389 if (nullptr == onPostListener)
391 LOGE("onPostListener is null");
392 return OC_STACK_ERROR;
395 PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
396 const OCRepresentation& rep, const int eCode)
398 onPostListener->onPostCallback(opts, rep, eCode);
401 return m_sharedAccountManager->deletePropertyValueFromGroup(groupId, propertyValue,
405 OCStackResult JniOcAccountManager::updatePropertyValueOnGroup(JNIEnv* env,
406 const std::string& groupId,
407 const OCRepresentation& propertyValue,
410 JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
411 if (nullptr == onPostListener)
413 LOGE("onPostListener is null");
414 return OC_STACK_ERROR;
417 PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
418 const OCRepresentation& rep, const int eCode)
420 onPostListener->onPostCallback(opts, rep, eCode);
423 return m_sharedAccountManager->updatePropertyValueOnGroup(groupId, propertyValue,
427 OCStackResult JniOcAccountManager::observeGroup(JNIEnv* env, jobject jListener)
429 JniOnObserveListener *onObserveListener = addOnObserveListener(env, jListener);
430 if (nullptr == onObserveListener)
432 LOGE("onObserveListener is null");
433 return OC_STACK_ERROR;
436 ObserveCallback observeCallback = [onObserveListener](const HeaderOptions& opts,
437 const OCRepresentation& rep, const int& eCode, const int& sequenceNumber)
439 onObserveListener->onObserveCallback(opts, rep, eCode, sequenceNumber);
442 return m_sharedAccountManager->observeGroup(observeCallback);
445 OCStackResult JniOcAccountManager::cancelObserveGroup()
447 return m_sharedAccountManager->cancelObserveGroup();
450 OCStackResult JniOcAccountManager::observeInvitation(JNIEnv* env, jobject jListener)
452 JniOnObserveListener *onObserveListener = addOnObserveListener(env, jListener);
453 if (nullptr == onObserveListener)
455 LOGE("onObserveListener is null");
456 return OC_STACK_ERROR;
459 ObserveCallback observeCallback = [onObserveListener](const HeaderOptions& opts,
460 const OCRepresentation& rep, const int& eCode, const int& sequenceNumber)
462 onObserveListener->onObserveCallback(opts, rep, eCode, sequenceNumber);
465 return m_sharedAccountManager->observeInvitation(observeCallback);
468 OCStackResult JniOcAccountManager::cancelObserveInvitation()
470 return m_sharedAccountManager->cancelObserveInvitation();
473 OCStackResult JniOcAccountManager::sendInvitation(JNIEnv* env, const std::string& groupId,
474 const std::string& userUuid, jobject jListener)
476 JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
477 if (nullptr == onPostListener)
479 LOGE("onPostListener is null");
480 return OC_STACK_ERROR;
483 PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
484 const OCRepresentation& rep, const int eCode)
486 onPostListener->onPostCallback(opts, rep, eCode);
489 return m_sharedAccountManager->sendInvitation(groupId, userUuid, postCallback);
492 OCStackResult JniOcAccountManager::cancelInvitation(JNIEnv* env, const std::string& groupId,
493 const std::string& userUuid, jobject jListener)
495 JniOnDeleteListener *onDeleteListener = addOnDeleteListener(env, jListener);
496 if (nullptr == onDeleteListener)
498 LOGE("onDeleteListener is null");
499 return OC_STACK_ERROR;
502 DeleteCallback deleteCallback = [onDeleteListener](const HeaderOptions& opts,
505 onDeleteListener->onDeleteCallback(opts, eCode);
508 return m_sharedAccountManager->cancelInvitation(groupId, userUuid, deleteCallback);
511 OCStackResult JniOcAccountManager::replyToInvitation(JNIEnv* env, const std::string& groupId,
512 const bool accept, jobject jListener)
514 JniOnDeleteListener *onDeleteListener = addOnDeleteListener(env, jListener);
515 if (nullptr == onDeleteListener)
517 LOGE("onDeleteListener is null");
518 return OC_STACK_ERROR;
521 DeleteCallback deleteCallback = [onDeleteListener](const HeaderOptions& opts,
524 onDeleteListener->onDeleteCallback(opts, eCode);
527 return m_sharedAccountManager->replyToInvitation(groupId, accept, deleteCallback);
531 * Class: org_iotivity_base_OcAccountManager
533 * Signature: ()Ljava/lang/String;
535 JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcAccountManager_getHost
536 (JNIEnv *env, jobject thiz)
538 LOGD("OcAccountManager_getHost");
539 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
546 return env->NewStringUTF(accountManager->host().c_str());
550 * Class: org_iotivity_base_OcAccountManager
551 * Method: getConnectivityTypeN
554 JNIEXPORT jint JNICALL Java_org_iotivity_base_OcAccountManager_getConnectivityTypeN
555 (JNIEnv *env, jobject thiz)
557 LOGD("OcAccountManager_getConnectivityType");
558 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
565 OCConnectivityType connectivityType = accountManager->connectivityType();
566 return static_cast<jint>(connectivityType);
570 * Class: org_iotivity_base_OcAccountManager
572 * Signature: (Ljava/lang/String;Ljava/lang/String;
573 * Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
575 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_signUp0
576 (JNIEnv *env, jobject thiz, jstring jAuthProvider, jstring jAuthCode, jobject jListener)
578 LOGD("OcAccountManager_signUp");
579 VERIFY_NON_NULL_THROW_EXCEPTION(jAuthProvider, "authProvider cannot be null",
580 OC_STACK_INVALID_PARAM);
581 VERIFY_NON_NULL_THROW_EXCEPTION(jAuthCode, "authCode cannot be null", OC_STACK_INVALID_PARAM);
582 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
583 OC_STACK_INVALID_PARAM);
585 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
592 const char *charAuthProvider = env->GetStringUTFChars(jAuthProvider, nullptr);
593 VERIFY_NON_NULL_THROW_EXCEPTION(charAuthProvider, "charAuthProvider is null", JNI_EXCEPTION);
594 std::string authProvider(charAuthProvider);
595 env->ReleaseStringUTFChars(jAuthProvider, charAuthProvider);
597 const char *charAuthCode = env->GetStringUTFChars(jAuthCode, nullptr);
598 VERIFY_NON_NULL_THROW_EXCEPTION(charAuthCode, "charAuthCode is null", JNI_EXCEPTION);
599 std::string authCode(charAuthCode);
600 env->ReleaseStringUTFChars(jAuthCode, charAuthCode);
604 OCStackResult result = accountManager->signUp(env,
608 if (OC_STACK_OK != result)
610 ThrowOcException(result, "OcAccountManager_signUp");
613 catch (OCException& e)
615 LOGE("%s", e.reason().c_str());
616 ThrowOcException(e.code(), e.reason().c_str());
621 * Class: org_iotivity_base_OcAccountManager
623 * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;
624 * Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
626 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_signUp1
627 (JNIEnv *env, jobject thiz, jstring jAuthProvider, jstring jAuthCode, jobject jOptionsMap,
630 LOGD("OcAccountManager_signUp");
631 VERIFY_NON_NULL_THROW_EXCEPTION(jAuthProvider, "authProvider cannot be null",
632 OC_STACK_INVALID_PARAM);
633 VERIFY_NON_NULL_THROW_EXCEPTION(jAuthCode, "authCode cannot be null", OC_STACK_INVALID_PARAM);
634 VERIFY_NON_NULL_THROW_EXCEPTION(jOptionsMap, "options cannot be null", OC_STACK_INVALID_PARAM);
635 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
636 OC_STACK_INVALID_PARAM);
638 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
645 const char *charAuthProvider = env->GetStringUTFChars(jAuthProvider, nullptr);
646 VERIFY_NON_NULL_THROW_EXCEPTION(charAuthProvider, "charAuthProvider is null", JNI_EXCEPTION);
647 std::string authProvider(charAuthProvider);
648 env->ReleaseStringUTFChars(jAuthProvider, charAuthProvider);
650 const char *charAuthCode = env->GetStringUTFChars(jAuthCode, nullptr);
651 VERIFY_NON_NULL_THROW_EXCEPTION(charAuthCode, "charAuthCode is null", JNI_EXCEPTION);
652 std::string authCode(charAuthCode);
653 env->ReleaseStringUTFChars(jAuthCode, charAuthCode);
655 QueryParamsMap optionsMap;
656 JniUtils::convertJavaMapToQueryParamsMap(env, jOptionsMap, optionsMap);
660 OCStackResult result = accountManager->signUp(env,
665 if (OC_STACK_OK != result)
667 ThrowOcException(result, "OcAccountManager_signUp");
670 catch (OCException& e)
672 LOGE("%s", e.reason().c_str());
673 ThrowOcException(e.code(), e.reason().c_str());
678 * Class: org_iotivity_base_OcAccountManager
680 * Signature: (Ljava/lang/String;Ljava/lang/String;
681 * Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
683 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_signIn0
684 (JNIEnv *env, jobject thiz, jstring jUserUuid, jstring jAccessToken, jobject jListener)
686 LOGD("OcAccountManager_signIn");
687 VERIFY_NON_NULL_THROW_EXCEPTION(jUserUuid, "userUuid cannot be null", OC_STACK_INVALID_PARAM);
688 VERIFY_NON_NULL_THROW_EXCEPTION(jAccessToken, "accessToken cannot be null",
689 OC_STACK_INVALID_PARAM);
690 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
691 OC_STACK_INVALID_PARAM);
693 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
700 const char *charUserUuid = env->GetStringUTFChars(jUserUuid, nullptr);
701 VERIFY_NON_NULL_THROW_EXCEPTION(charUserUuid, "charUserUuid is null", JNI_EXCEPTION);
702 std::string userUuid(charUserUuid);
703 env->ReleaseStringUTFChars(jUserUuid, charUserUuid);
705 const char *charAccessToken = env->GetStringUTFChars(jAccessToken, nullptr);
706 VERIFY_NON_NULL_THROW_EXCEPTION(charAccessToken, "charAccessToken is null", JNI_EXCEPTION);
707 std::string accessToken(charAccessToken);
708 env->ReleaseStringUTFChars(jAccessToken, charAccessToken);
712 OCStackResult result = accountManager->signIn(env,
716 if (OC_STACK_OK != result)
718 ThrowOcException(result, "OcAccountManager_signIn");
721 catch (OCException& e)
723 LOGE("%s", e.reason().c_str());
724 ThrowOcException(e.code(), e.reason().c_str());
729 * Class: org_iotivity_base_OcAccountManager
731 * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
733 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_signOut0
734 (JNIEnv *env, jobject thiz, jstring jAccessToken, jobject jListener)
736 LOGD("OcAccountManager_signOut");
737 VERIFY_NON_NULL_THROW_EXCEPTION(jAccessToken, "accessToken cannot be null",
738 OC_STACK_INVALID_PARAM);
739 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
740 OC_STACK_INVALID_PARAM);
742 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
749 const char *charAccessToken = env->GetStringUTFChars(jAccessToken, nullptr);
750 VERIFY_NON_NULL_THROW_EXCEPTION(charAccessToken, "charAccessToken is null", JNI_EXCEPTION);
751 std::string accessToken(charAccessToken);
752 env->ReleaseStringUTFChars(jAccessToken, charAccessToken);
756 OCStackResult result = accountManager->signOut(env,
759 if (OC_STACK_OK != result)
761 ThrowOcException(result, "OcAccountManager_signOut");
764 catch (OCException& e)
766 LOGE("%s", e.reason().c_str());
767 ThrowOcException(e.code(), e.reason().c_str());
772 * Class: org_iotivity_base_OcAccountManager
773 * Method: refreshAccessToken0
774 * Signature: (Ljava/lang/String;Ljava/lang/String;
775 * Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
777 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_refreshAccessToken0
778 (JNIEnv *env, jobject thiz, jstring jUserUuid, jstring jRefreshAccessToken, jobject jListener)
780 LOGD("OcAccountManager_refreshAccessToken");
781 VERIFY_NON_NULL_THROW_EXCEPTION(jUserUuid, "userUuid cannot be null", OC_STACK_INVALID_PARAM);
782 VERIFY_NON_NULL_THROW_EXCEPTION(jRefreshAccessToken, "refreshAccessToken cannot be null",
783 OC_STACK_INVALID_PARAM);
784 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
785 OC_STACK_INVALID_PARAM);
787 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
794 const char *charUserUuid = env->GetStringUTFChars(jUserUuid, nullptr);
795 VERIFY_NON_NULL_THROW_EXCEPTION(charUserUuid, "charUserUuid is null", JNI_EXCEPTION);
796 std::string userUuid(charUserUuid);
797 env->ReleaseStringUTFChars(jUserUuid, charUserUuid);
799 const char *charRefreshAccessToken = env->GetStringUTFChars(jRefreshAccessToken, nullptr);
800 VERIFY_NON_NULL_THROW_EXCEPTION(charRefreshAccessToken, "charRefreshAccessToken is null",
802 std::string refreshAccessToken(charRefreshAccessToken);
803 env->ReleaseStringUTFChars(jRefreshAccessToken, charRefreshAccessToken);
807 OCStackResult result = accountManager->refreshAccessToken(env,
811 if (OC_STACK_OK != result)
813 ThrowOcException(result, "OcAccountManager_refreshAccessToken");
816 catch (OCException& e)
818 LOGE("%s", e.reason().c_str());
819 ThrowOcException(e.code(), e.reason().c_str());
824 * Class: org_iotivity_base_OcAccountManager
825 * Method: searchUser0
826 * Signature: (Ljava/util/Map;Lorg/iotivity/base/OcAccountManager/OnGetListener;)V
828 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_searchUser0
829 (JNIEnv *env, jobject thiz, jobject jQueryMap, jobject jListener)
831 LOGD("OcAccountManager_searchUser");
832 VERIFY_NON_NULL_THROW_EXCEPTION(jQueryMap, "queryMap cannot be null", OC_STACK_INVALID_PARAM);
833 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onGetListener cannot be null",
834 OC_STACK_INVALID_PARAM);
836 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
843 QueryParamsMap queryMap;
844 JniUtils::convertJavaMapToQueryParamsMap(env, jQueryMap, queryMap);
848 OCStackResult result = accountManager->searchUser(env,
851 if (OC_STACK_OK != result)
853 ThrowOcException(result, "OcAccountManager_searchUser");
856 catch (OCException& e)
858 LOGE("%s", e.reason().c_str());
859 ThrowOcException(e.code(), e.reason().c_str());
864 * Class: org_iotivity_base_OcAccountManager
865 * Method: deleteDevice0
866 * Signature: (Ljava/lang/String;Ljava/lang/String;
867 * Lorg/iotivity/base/OcAccountManager/onDeleteListener;)V
869 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_deleteDevice0
870 (JNIEnv *env, jobject thiz, jstring jAccessToken, jstring jDeviceId, jobject jListener)
872 LOGD("OcAccountManager_deleteDevice");
873 VERIFY_NON_NULL_THROW_EXCEPTION(jAccessToken, "accessToken cannot be null",
874 OC_STACK_INVALID_PARAM);
875 VERIFY_NON_NULL_THROW_EXCEPTION(jDeviceId, "deviceId cannot be null", OC_STACK_INVALID_PARAM);
876 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onDeleteListener cannot be null",
877 OC_STACK_INVALID_PARAM);
879 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
886 const char *charAccessToken = env->GetStringUTFChars(jAccessToken, nullptr);
887 VERIFY_NON_NULL_THROW_EXCEPTION(charAccessToken, "charAccessToken is null", JNI_EXCEPTION);
888 std::string accessToken(charAccessToken);
889 env->ReleaseStringUTFChars(jAccessToken, charAccessToken);
891 const char *charDeviceId = env->GetStringUTFChars(jDeviceId, nullptr);
892 VERIFY_NON_NULL_THROW_EXCEPTION(charDeviceId, "charDeviceId is null", JNI_EXCEPTION);
893 std::string deviceId(charDeviceId);
894 env->ReleaseStringUTFChars(jDeviceId, charDeviceId);
898 OCStackResult result = accountManager->deleteDevice(env,
902 if (OC_STACK_OK != result)
904 ThrowOcException(result, "OcAccountManager_deleteDevice");
907 catch (OCException& e)
909 LOGE("%s", e.reason().c_str());
910 ThrowOcException(e.code(), e.reason().c_str());
915 * Class: org_iotivity_base_OcAccountManager
916 * Method: createGroup0
917 * Signature: (Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
919 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_createGroup0
920 (JNIEnv *env, jobject thiz, jobject jListener)
922 LOGD("OcAccountManager_createGroup");
923 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
924 OC_STACK_INVALID_PARAM);
926 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
935 OCStackResult result = accountManager->createGroup(env,
937 if (OC_STACK_OK != result)
939 ThrowOcException(result, "OcAccountManager_createGroup");
942 catch (OCException& e)
944 LOGE("%s", e.reason().c_str());
945 ThrowOcException(e.code(), e.reason().c_str());
950 * Class: org_iotivity_base_OcAccountManager
951 * Method: createGroup1
952 * Signature: (Ljava/util/Map;Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
954 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_createGroup1
955 (JNIEnv *env, jobject thiz, jobject jQueryMap, jobject jListener)
957 LOGD("OcAccountManager_createGroup");
958 VERIFY_NON_NULL_THROW_EXCEPTION(jQueryMap, "queryMap cannot be null", OC_STACK_INVALID_PARAM);
959 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
960 OC_STACK_INVALID_PARAM);
962 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
969 QueryParamsMap queryMap;
970 JniUtils::convertJavaMapToQueryParamsMap(env, jQueryMap, queryMap);
974 OCStackResult result = accountManager->createGroup(env,
977 if (OC_STACK_OK != result)
979 ThrowOcException(result, "OcAccountManager_createGroup");
982 catch (OCException& e)
984 LOGE("%s", e.reason().c_str());
985 ThrowOcException(e.code(), e.reason().c_str());
990 * Class: org_iotivity_base_OcAccountManager
991 * Method: deleteGroup0
992 * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/onDeleteListener;)V
994 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_deleteGroup0
995 (JNIEnv *env, jobject thiz, jstring jGroupId, jobject jListener)
997 LOGD("OcAccountManager_deleteGroup");
998 VERIFY_NON_NULL_THROW_EXCEPTION(jGroupId, "groupId cannot be null", OC_STACK_INVALID_PARAM);
999 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onDeleteListener cannot be null",
1000 OC_STACK_INVALID_PARAM);
1002 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
1004 if (!accountManager)
1009 const char *charGroupId = env->GetStringUTFChars(jGroupId, nullptr);
1010 VERIFY_NON_NULL_THROW_EXCEPTION(charGroupId, "charGroupId is null", JNI_EXCEPTION);
1011 std::string groupId(charGroupId);
1012 env->ReleaseStringUTFChars(jGroupId, charGroupId);
1016 OCStackResult result = accountManager->deleteGroup(env,
1019 if (OC_STACK_OK != result)
1021 ThrowOcException(result, "OcAccountManager_deleteGroup");
1024 catch (OCException& e)
1026 LOGE("%s", e.reason().c_str());
1027 ThrowOcException(e.code(), e.reason().c_str());
1032 * Class: org_iotivity_base_OcAccountManager
1033 * Method: getGroupInfoAll0
1034 * Signature: (Lorg/iotivity/base/OcAccountManager/OnGetListener;)V
1036 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_getGroupInfoAll0
1037 (JNIEnv *env, jobject thiz, jobject jListener)
1039 LOGD("OcAccountManager_getGroupInfoAll");
1040 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onGetListener cannot be null",
1041 OC_STACK_INVALID_PARAM);
1043 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
1045 if (!accountManager)
1052 OCStackResult result = accountManager->getGroupInfoAll(env,
1054 if (OC_STACK_OK != result)
1056 ThrowOcException(result, "OcAccountManager_getGroupInfoAll");
1059 catch (OCException& e)
1061 LOGE("%s", e.reason().c_str());
1062 ThrowOcException(e.code(), e.reason().c_str());
1067 * Class: org_iotivity_base_OcAccountManager
1068 * Method: getGroupInfo0
1069 * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/OnGetListener;)V
1071 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_getGroupInfo0
1072 (JNIEnv *env, jobject thiz, jstring jGroupId, jobject jListener)
1074 LOGD("OcAccountManager_getGroupInfo");
1075 VERIFY_NON_NULL_THROW_EXCEPTION(jGroupId, "groupId cannot be null", OC_STACK_INVALID_PARAM);
1076 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onGetListener cannot be null",
1077 OC_STACK_INVALID_PARAM);
1079 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
1081 if (!accountManager)
1086 const char *charGroupId = env->GetStringUTFChars(jGroupId, nullptr);
1087 VERIFY_NON_NULL_THROW_EXCEPTION(charGroupId, "charGroupId is null", JNI_EXCEPTION);
1088 std::string groupId(charGroupId);
1089 env->ReleaseStringUTFChars(jGroupId, charGroupId);
1093 OCStackResult result = accountManager->getGroupInfo(env,
1096 if (OC_STACK_OK != result)
1098 ThrowOcException(result, "OcAccountManager_getGroupInfo");
1101 catch (OCException& e)
1103 LOGE("%s", e.reason().c_str());
1104 ThrowOcException(e.code(), e.reason().c_str());
1109 * Class: org_iotivity_base_OcAccountManager
1110 * Method: addPropertyValueToGroup0
1111 * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;
1112 * Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
1114 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_addPropertyValueToGroup0
1115 (JNIEnv *env, jobject thiz, jstring jGroupId, jobject jPropertyValue, jobject jListener)
1117 LOGD("OcAccountManager_addPropertyValueToGroup");
1118 VERIFY_NON_NULL_THROW_EXCEPTION(jGroupId, "groupId cannot be null", OC_STACK_INVALID_PARAM);
1119 VERIFY_NON_NULL_THROW_EXCEPTION(jPropertyValue, "propertyValue cannot be null",
1120 OC_STACK_INVALID_PARAM);
1121 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
1122 OC_STACK_INVALID_PARAM);
1124 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
1126 if (!accountManager)
1131 OCRepresentation *propertyValue = JniOcRepresentation::getOCRepresentationPtr(env,
1138 const char *charGroupId = env->GetStringUTFChars(jGroupId, nullptr);
1139 VERIFY_NON_NULL_THROW_EXCEPTION(charGroupId, "charGroupId is null", JNI_EXCEPTION);
1140 std::string groupId(charGroupId);
1141 env->ReleaseStringUTFChars(jGroupId, charGroupId);
1145 OCStackResult result = accountManager->addPropertyValueToGroup(env,
1150 if (OC_STACK_OK != result)
1152 ThrowOcException(result, "OcAccountManager_addPropertyValueToGroup");
1155 catch (OCException& e)
1157 LOGE("%s", e.reason().c_str());
1158 ThrowOcException(e.code(), e.reason().c_str());
1163 * Class: org_iotivity_base_OcAccountManager
1164 * Method: deletePropertyValueFromGroup0
1165 * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;
1166 * Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
1168 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_deletePropertyValueFromGroup0
1169 (JNIEnv *env, jobject thiz, jstring jGroupId, jobject jPropertyValue, jobject jListener)
1171 LOGD("OcAccountManager_deletePropertyValueFromGroup");
1172 VERIFY_NON_NULL_THROW_EXCEPTION(jGroupId, "groupId cannot be null", OC_STACK_INVALID_PARAM);
1173 VERIFY_NON_NULL_THROW_EXCEPTION(jPropertyValue, "propertyValue cannot be null",
1174 OC_STACK_INVALID_PARAM);
1175 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
1176 OC_STACK_INVALID_PARAM);
1178 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
1180 if (!accountManager)
1185 OCRepresentation *propertyValue = JniOcRepresentation::getOCRepresentationPtr(env,
1192 const char *charGroupId = env->GetStringUTFChars(jGroupId, nullptr);
1193 VERIFY_NON_NULL_THROW_EXCEPTION(charGroupId, "charGroupId is null", JNI_EXCEPTION);
1194 std::string groupId(charGroupId);
1195 env->ReleaseStringUTFChars(jGroupId, charGroupId);
1199 OCStackResult result = accountManager->deletePropertyValueFromGroup(env,
1204 if (OC_STACK_OK != result)
1206 ThrowOcException(result, "OcAccountManager_deletePropertyValueFromGroup");
1209 catch (OCException& e)
1211 LOGE("%s", e.reason().c_str());
1212 ThrowOcException(e.code(), e.reason().c_str());
1217 * Class: org_iotivity_base_OcAccountManager
1218 * Method: updatePropertyValueOnGroup0
1219 * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;
1220 * Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
1222 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_updatePropertyValueOnGroup0
1223 (JNIEnv *env, jobject thiz, jstring jGroupId, jobject jPropertyValue, jobject jListener)
1225 LOGD("OcAccountManager_updatePropertyValueOnGroup");
1226 VERIFY_NON_NULL_THROW_EXCEPTION(jGroupId, "groupId cannot be null", OC_STACK_INVALID_PARAM);
1227 VERIFY_NON_NULL_THROW_EXCEPTION(jPropertyValue, "propertyValue cannot be null",
1228 OC_STACK_INVALID_PARAM);
1229 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
1230 OC_STACK_INVALID_PARAM);
1232 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
1234 if (!accountManager)
1239 OCRepresentation *propertyValue = JniOcRepresentation::getOCRepresentationPtr(env,
1246 const char *charGroupId = env->GetStringUTFChars(jGroupId, nullptr);
1247 VERIFY_NON_NULL_THROW_EXCEPTION(charGroupId, "charGroupId is null", JNI_EXCEPTION);
1248 std::string groupId(charGroupId);
1249 env->ReleaseStringUTFChars(jGroupId, charGroupId);
1253 OCStackResult result = accountManager->updatePropertyValueOnGroup(env,
1258 if (OC_STACK_OK != result)
1260 ThrowOcException(result, "OcAccountManager_updatePropertyValueOnGroup");
1263 catch (OCException& e)
1265 LOGE("%s", e.reason().c_str());
1266 ThrowOcException(e.code(), e.reason().c_str());
1271 * Class: org_iotivity_base_OcAccountManager
1272 * Method: observeGroup0
1273 * Signature: (Lorg/iotivity/base/OcResource/OnObserveListener;)V
1275 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_observeGroup0
1276 (JNIEnv *env, jobject thiz, jobject jListener)
1278 LOGD("OcAccountManager_observeGroup");
1279 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onObserveListener cannot be null",
1280 OC_STACK_INVALID_PARAM);
1282 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
1284 if (!accountManager)
1291 OCStackResult result = accountManager->observeGroup(env,
1293 if (OC_STACK_OK != result)
1295 ThrowOcException(result, "OcAccountManager_observeGroup");
1298 catch (OCException& e)
1300 LOGE("%s", e.reason().c_str());
1301 ThrowOcException(e.code(), e.reason().c_str());
1306 * Class: org_iotivity_base_OcAccountManager
1307 * Method: cancelObserveGroup0
1310 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_cancelObserveGroup0
1311 (JNIEnv *env, jobject thiz)
1313 LOGD("OcAccountManager_cancelObserveGroup");
1315 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
1317 if (!accountManager)
1324 OCStackResult result = accountManager->cancelObserveGroup();
1325 if (OC_STACK_OK != result)
1327 ThrowOcException(result, "OcAccountManager_cancelObserveGroup");
1330 catch (OCException& e)
1332 LOGE("%s", e.reason().c_str());
1333 ThrowOcException(e.code(), e.reason().c_str());
1338 * Class: org_iotivity_base_OcAccountManager
1339 * Method: observeInvitation0
1340 * Signature: (Lorg/iotivity/base/OcResource/OnObserveListener;)V
1342 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_observeInvitation0
1343 (JNIEnv *env, jobject thiz, jobject jListener)
1345 LOGD("OcAccountManager_observeInvitation");
1346 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onObserveListener cannot be null",
1347 OC_STACK_INVALID_PARAM);
1349 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
1351 if (!accountManager)
1358 OCStackResult result = accountManager->observeInvitation(env,
1360 if (OC_STACK_OK != result)
1362 ThrowOcException(result, "OcAccountManager_observeInvitation");
1365 catch (OCException& e)
1367 LOGE("%s", e.reason().c_str());
1368 ThrowOcException(e.code(), e.reason().c_str());
1373 * Class: org_iotivity_base_OcAccountManager
1374 * Method: cancelObserveInvitation0
1377 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_cancelObserveInvitation0
1378 (JNIEnv *env, jobject thiz)
1380 LOGD("OcAccountManager_cancelObserveInvitation");
1382 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
1384 if (!accountManager)
1391 OCStackResult result = accountManager->cancelObserveInvitation();
1392 if (OC_STACK_OK != result)
1394 ThrowOcException(result, "OcAccountManager_cancelObserveInvitation");
1397 catch (OCException& e)
1399 LOGE("%s", e.reason().c_str());
1400 ThrowOcException(e.code(), e.reason().c_str());
1405 * Class: org_iotivity_base_OcAccountManager
1406 * Method: sendInvitation0
1407 * Signature: (Ljava/lang/String;Ljava/lang/String;
1408 * Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
1410 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_sendInvitation0
1411 (JNIEnv *env, jobject thiz, jstring jGroupId, jstring jUserUuid, jobject jListener)
1413 LOGD("OcAccountManager_sendInvitation");
1414 VERIFY_NON_NULL_THROW_EXCEPTION(jGroupId, "groupId cannot be null", OC_STACK_INVALID_PARAM);
1415 VERIFY_NON_NULL_THROW_EXCEPTION(jUserUuid, "userUuid cannot be null", OC_STACK_INVALID_PARAM);
1416 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
1417 OC_STACK_INVALID_PARAM);
1419 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
1421 if (!accountManager)
1426 const char *charGroupId = env->GetStringUTFChars(jGroupId, nullptr);
1427 VERIFY_NON_NULL_THROW_EXCEPTION(charGroupId, "charGroupId is null", JNI_EXCEPTION);
1428 std::string groupId(charGroupId);
1429 env->ReleaseStringUTFChars(jGroupId, charGroupId);
1431 const char *charUserUuid = env->GetStringUTFChars(jUserUuid, nullptr);
1432 VERIFY_NON_NULL_THROW_EXCEPTION(charUserUuid, "charUserUuid is null", JNI_EXCEPTION);
1433 std::string userUuid(charUserUuid);
1434 env->ReleaseStringUTFChars(jUserUuid, charUserUuid);
1438 OCStackResult result = accountManager->sendInvitation(env,
1442 if (OC_STACK_OK != result)
1444 ThrowOcException(result, "OcAccountManager_sendInvitation");
1447 catch (OCException& e)
1449 LOGE("%s", e.reason().c_str());
1450 ThrowOcException(e.code(), e.reason().c_str());
1455 * Class: org_iotivity_base_OcAccountManager
1456 * Method: cancelInvitation0
1457 * Signature: (Ljava/lang/String;Ljava/lang/String;
1458 * Lorg/iotivity/base/OcAccountManager/onDeleteListener;)V
1460 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_cancelInvitation0
1461 (JNIEnv *env, jobject thiz, jstring jGroupId, jstring jUserUuid, jobject jListener)
1463 LOGD("OcAccountManager_cancelInvitation");
1464 VERIFY_NON_NULL_THROW_EXCEPTION(jGroupId, "groupId cannot be null", OC_STACK_INVALID_PARAM);
1465 VERIFY_NON_NULL_THROW_EXCEPTION(jUserUuid, "userUuid cannot be null", OC_STACK_INVALID_PARAM);
1466 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onDeleteListener cannot be null",
1467 OC_STACK_INVALID_PARAM);
1469 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
1471 if (!accountManager)
1476 const char *charGroupId = env->GetStringUTFChars(jGroupId, nullptr);
1477 VERIFY_NON_NULL_THROW_EXCEPTION(charGroupId, "charGroupId is null", JNI_EXCEPTION);
1478 std::string groupId(charGroupId);
1479 env->ReleaseStringUTFChars(jGroupId, charGroupId);
1481 const char *charUserUuid = env->GetStringUTFChars(jUserUuid, nullptr);
1482 VERIFY_NON_NULL_THROW_EXCEPTION(charUserUuid, "charUserUuid is null", JNI_EXCEPTION);
1483 std::string userUuid(charUserUuid);
1484 env->ReleaseStringUTFChars(jUserUuid, charUserUuid);
1488 OCStackResult result = accountManager->cancelInvitation(env,
1492 if (OC_STACK_OK != result)
1494 ThrowOcException(result, "OcAccountManager_cancelInvitation");
1497 catch (OCException& e)
1499 LOGE("%s", e.reason().c_str());
1500 ThrowOcException(e.code(), e.reason().c_str());
1505 * Class: org_iotivity_base_OcAccountManager
1506 * Method: replyToInvitation0
1507 * Signature: (Ljava/lang/String;ZLorg/iotivity/base/OcAccountManager/onDeleteListener;)V
1509 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_replyToInvitation0
1510 (JNIEnv *env, jobject thiz, jstring jGroupId, jboolean jAccept, jobject jListener)
1512 LOGD("OcAccountManager_replyToInvitation");
1513 VERIFY_NON_NULL_THROW_EXCEPTION(jGroupId, "groupId cannot be null", OC_STACK_INVALID_PARAM);
1514 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onDeleteListener cannot be null",
1515 OC_STACK_INVALID_PARAM);
1517 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
1519 if (!accountManager)
1524 const char *charGroupId = env->GetStringUTFChars(jGroupId, nullptr);
1525 VERIFY_NON_NULL_THROW_EXCEPTION(charGroupId, "charGroupId is null", JNI_EXCEPTION);
1526 std::string groupId(charGroupId);
1527 env->ReleaseStringUTFChars(jGroupId, charGroupId);
1531 OCStackResult result = accountManager->replyToInvitation(env,
1533 static_cast<bool>(jAccept),
1535 if (OC_STACK_OK != result)
1537 ThrowOcException(result, "OcAccountManager_replyToInvitation");
1540 catch (OCException& e)
1542 LOGE("%s", e.reason().c_str());
1543 ThrowOcException(e.code(), e.reason().c_str());