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, this);
92 JniOnPostListener* JniOcAccountManager::addOnPostListener(JNIEnv* env, jobject jListener)
94 return this->m_onPostManager.addListener(env, jListener, this);
97 JniOnDeleteListener* JniOcAccountManager::addOnDeleteListener(JNIEnv* env, jobject jListener)
99 return this->m_onDeleteManager.addListener(env, jListener, this);
102 JniOnObserveListener* JniOcAccountManager::addOnObserveListener(JNIEnv* env, jobject jListener)
104 return this->m_onObserveManager.addListener(env, jListener, this);
107 void JniOcAccountManager::removeOnGetListener(JNIEnv* env, jobject jListener)
109 this->m_onGetManager.removeListener(env, jListener);
112 void JniOcAccountManager::removeOnPostListener(JNIEnv* env, jobject jListener)
114 this->m_onPostManager.removeListener(env, jListener);
117 void JniOcAccountManager::removeOnDeleteListener(JNIEnv* env, jobject jListener)
119 this->m_onDeleteManager.removeListener(env, jListener);
122 void JniOcAccountManager::removeOnObserveListener(JNIEnv* env, jobject jListener)
124 this->m_onObserveManager.removeListener(env, jListener);
127 OCStackResult JniOcAccountManager::signUp(JNIEnv* env, const std::string& authProvider,
128 const std::string& authCode, jobject jListener)
130 JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
131 if (nullptr == onPostListener)
133 LOGE("onPostListener is null");
134 return OC_STACK_ERROR;
137 PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
138 const OCRepresentation& rep, const int eCode)
140 onPostListener->onPostCallback(opts, rep, eCode);
143 return m_sharedAccountManager->signUp(authProvider, authCode, postCallback);
146 OCStackResult JniOcAccountManager::signUp(JNIEnv* env, const std::string& authProvider,
147 const std::string& authCode,
148 const QueryParamsMap& options, jobject jListener)
150 JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
151 if (nullptr == onPostListener)
153 LOGE("onPostListener is null");
154 return OC_STACK_ERROR;
157 PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
158 const OCRepresentation& rep, const int eCode)
160 onPostListener->onPostCallback(opts, rep, eCode);
163 return m_sharedAccountManager->signUp(authProvider, authCode, options, postCallback);
166 OCStackResult JniOcAccountManager::signIn(JNIEnv* env, const std::string& userUuid,
167 const std::string& accessToken, jobject jListener)
169 JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
170 if (nullptr == onPostListener)
172 LOGE("onPostListener is null");
173 return OC_STACK_ERROR;
176 PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
177 const OCRepresentation& rep, const int eCode)
179 onPostListener->onPostCallback(opts, rep, eCode);
182 return m_sharedAccountManager->signIn(userUuid, accessToken, postCallback);
185 OCStackResult JniOcAccountManager::signOut(JNIEnv* env, const std::string& accessToken,
188 JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
189 if (nullptr == onPostListener)
191 LOGE("onPostListener is null");
192 return OC_STACK_ERROR;
195 PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
196 const OCRepresentation& rep, const int eCode)
198 onPostListener->onPostCallback(opts, rep, eCode);
201 return m_sharedAccountManager->signOut(accessToken, postCallback);
204 OCStackResult JniOcAccountManager::refreshAccessToken(JNIEnv* env, const std::string& userUuid,
205 const std::string& refreshToken,
208 JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
209 if (nullptr == onPostListener)
211 LOGE("onPostListener is null");
212 return OC_STACK_ERROR;
215 PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
216 const OCRepresentation& rep, const int eCode)
218 onPostListener->onPostCallback(opts, rep, eCode);
221 return m_sharedAccountManager->refreshAccessToken(userUuid, refreshToken, postCallback);
224 OCStackResult JniOcAccountManager::searchUser(JNIEnv* env, const QueryParamsMap& queryMap,
227 JniOnGetListener *onGetListener = addOnGetListener(env, jListener);
228 if (nullptr == onGetListener)
230 LOGE("onGetListener is null");
231 return OC_STACK_ERROR;
234 GetCallback getCallback = [onGetListener](const HeaderOptions& opts,
235 const OCRepresentation& rep, const int eCode)
237 onGetListener->onGetCallback(opts, rep, eCode);
240 return m_sharedAccountManager->searchUser(queryMap, getCallback);
243 OCStackResult JniOcAccountManager::deleteDevice(JNIEnv* env, const std::string& accessToken,
244 const std::string& deviceId, jobject jListener)
246 JniOnDeleteListener *onDeleteListener = addOnDeleteListener(env, jListener);
247 if (nullptr == onDeleteListener)
249 LOGE("onDeleteListener is null");
250 return OC_STACK_ERROR;
253 DeleteCallback deleteCallback = [onDeleteListener](const HeaderOptions& opts,
256 onDeleteListener->onDeleteCallback(opts, eCode);
259 return m_sharedAccountManager->deleteDevice(accessToken, deviceId, deleteCallback);
262 OCStackResult JniOcAccountManager::createGroup(JNIEnv* env, jobject jListener)
264 JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
265 if (nullptr == onPostListener)
267 LOGE("onPostListener is null");
268 return OC_STACK_ERROR;
271 PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
272 const OCRepresentation& rep, const int eCode)
274 onPostListener->onPostCallback(opts, rep, eCode);
277 return m_sharedAccountManager->createGroup(postCallback);
280 OCStackResult JniOcAccountManager::createGroup(JNIEnv* env, const QueryParamsMap& queryMap,
283 JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
284 if (nullptr == onPostListener)
286 LOGE("onPostListener is null");
287 return OC_STACK_ERROR;
290 PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
291 const OCRepresentation& rep, const int eCode)
293 onPostListener->onPostCallback(opts, rep, eCode);
296 return m_sharedAccountManager->createGroup(queryMap, postCallback);
299 OCStackResult JniOcAccountManager::deleteGroup(JNIEnv* env, const std::string& groupId,
302 JniOnDeleteListener *onDeleteListener = addOnDeleteListener(env, jListener);
303 if (nullptr == onDeleteListener)
305 LOGE("onDeleteListener is null");
306 return OC_STACK_ERROR;
309 DeleteCallback deleteCallback = [onDeleteListener](const HeaderOptions& opts,
312 onDeleteListener->onDeleteCallback(opts, eCode);
315 return m_sharedAccountManager->deleteGroup(groupId, deleteCallback);
318 OCStackResult JniOcAccountManager::getGroupInfoAll(JNIEnv* env, jobject jListener)
320 JniOnGetListener *onGetListener = addOnGetListener(env, jListener);
321 if (nullptr == onGetListener)
323 LOGE("onGetListener is null");
324 return OC_STACK_ERROR;
327 GetCallback getCallback = [onGetListener](const HeaderOptions& opts,
328 const OCRepresentation& rep, const int eCode)
330 onGetListener->onGetCallback(opts, rep, eCode);
333 return m_sharedAccountManager->getGroupInfoAll(getCallback);
336 OCStackResult JniOcAccountManager::getGroupInfo(JNIEnv* env, const std::string& groupId,
339 JniOnGetListener *onGetListener = addOnGetListener(env, jListener);
340 if (nullptr == onGetListener)
342 LOGE("onGetListener is null");
343 return OC_STACK_ERROR;
346 GetCallback getCallback = [onGetListener](const HeaderOptions& opts,
347 const OCRepresentation& rep, const int eCode)
349 onGetListener->onGetCallback(opts, rep, eCode);
352 return m_sharedAccountManager->getGroupInfo(groupId, getCallback);
355 OCStackResult JniOcAccountManager::addPropertyValueToGroup(JNIEnv* env, const std::string& groupId,
356 const OCRepresentation& propertyValue,
359 JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
360 if (nullptr == onPostListener)
362 LOGE("onPostListener is null");
363 return OC_STACK_ERROR;
366 PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
367 const OCRepresentation& rep, const int eCode)
369 onPostListener->onPostCallback(opts, rep, eCode);
372 return m_sharedAccountManager->addPropertyValueToGroup(groupId, propertyValue, postCallback);
375 OCStackResult JniOcAccountManager::deletePropertyValueFromGroup(JNIEnv* env,
376 const std::string& groupId,
377 const OCRepresentation& propertyValue,
380 JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
381 if (nullptr == onPostListener)
383 LOGE("onPostListener is null");
384 return OC_STACK_ERROR;
387 PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
388 const OCRepresentation& rep, const int eCode)
390 onPostListener->onPostCallback(opts, rep, eCode);
393 return m_sharedAccountManager->deletePropertyValueFromGroup(groupId, propertyValue,
397 OCStackResult JniOcAccountManager::updatePropertyValueOnGroup(JNIEnv* env,
398 const std::string& groupId,
399 const OCRepresentation& propertyValue,
402 JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
403 if (nullptr == onPostListener)
405 LOGE("onPostListener is null");
406 return OC_STACK_ERROR;
409 PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
410 const OCRepresentation& rep, const int eCode)
412 onPostListener->onPostCallback(opts, rep, eCode);
415 return m_sharedAccountManager->updatePropertyValueOnGroup(groupId, propertyValue,
419 OCStackResult JniOcAccountManager::observeGroup(JNIEnv* env, jobject jListener)
421 JniOnObserveListener *onObserveListener = addOnObserveListener(env, jListener);
422 if (nullptr == onObserveListener)
424 LOGE("onObserveListener is null");
425 return OC_STACK_ERROR;
428 ObserveCallback observeCallback = [onObserveListener](const HeaderOptions& opts,
429 const OCRepresentation& rep, const int& eCode, const int& sequenceNumber)
431 onObserveListener->onObserveCallback(opts, rep, eCode, sequenceNumber);
434 return m_sharedAccountManager->observeGroup(observeCallback);
437 OCStackResult JniOcAccountManager::cancelObserveGroup()
439 return m_sharedAccountManager->cancelObserveGroup();
442 OCStackResult JniOcAccountManager::observeInvitation(JNIEnv* env, jobject jListener)
444 JniOnObserveListener *onObserveListener = addOnObserveListener(env, jListener);
445 if (nullptr == onObserveListener)
447 LOGE("onObserveListener is null");
448 return OC_STACK_ERROR;
451 ObserveCallback observeCallback = [onObserveListener](const HeaderOptions& opts,
452 const OCRepresentation& rep, const int& eCode, const int& sequenceNumber)
454 onObserveListener->onObserveCallback(opts, rep, eCode, sequenceNumber);
457 return m_sharedAccountManager->observeInvitation(observeCallback);
460 OCStackResult JniOcAccountManager::cancelObserveInvitation()
462 return m_sharedAccountManager->cancelObserveInvitation();
465 OCStackResult JniOcAccountManager::sendInvitation(JNIEnv* env, const std::string& groupId,
466 const std::string& userUuid, jobject jListener)
468 JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
469 if (nullptr == onPostListener)
471 LOGE("onPostListener is null");
472 return OC_STACK_ERROR;
475 PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
476 const OCRepresentation& rep, const int eCode)
478 onPostListener->onPostCallback(opts, rep, eCode);
481 return m_sharedAccountManager->sendInvitation(groupId, userUuid, postCallback);
484 OCStackResult JniOcAccountManager::cancelInvitation(JNIEnv* env, const std::string& groupId,
485 const std::string& userUuid, jobject jListener)
487 JniOnDeleteListener *onDeleteListener = addOnDeleteListener(env, jListener);
488 if (nullptr == onDeleteListener)
490 LOGE("onDeleteListener is null");
491 return OC_STACK_ERROR;
494 DeleteCallback deleteCallback = [onDeleteListener](const HeaderOptions& opts,
497 onDeleteListener->onDeleteCallback(opts, eCode);
500 return m_sharedAccountManager->cancelInvitation(groupId, userUuid, deleteCallback);
503 OCStackResult JniOcAccountManager::replyToInvitation(JNIEnv* env, const std::string& groupId,
504 const bool accept, jobject jListener)
506 JniOnDeleteListener *onDeleteListener = addOnDeleteListener(env, jListener);
507 if (nullptr == onDeleteListener)
509 LOGE("onDeleteListener is null");
510 return OC_STACK_ERROR;
513 DeleteCallback deleteCallback = [onDeleteListener](const HeaderOptions& opts,
516 onDeleteListener->onDeleteCallback(opts, eCode);
519 return m_sharedAccountManager->replyToInvitation(groupId, accept, deleteCallback);
523 * Class: org_iotivity_base_OcAccountManager
525 * Signature: ()Ljava/lang/String;
527 JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcAccountManager_getHost
528 (JNIEnv *env, jobject thiz)
530 LOGD("OcAccountManager_getHost");
531 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
538 return env->NewStringUTF(accountManager->host().c_str());
542 * Class: org_iotivity_base_OcAccountManager
543 * Method: getConnectivityTypeN
546 JNIEXPORT jint JNICALL Java_org_iotivity_base_OcAccountManager_getConnectivityTypeN
547 (JNIEnv *env, jobject thiz)
549 LOGD("OcAccountManager_getConnectivityType");
550 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
557 OCConnectivityType connectivityType = accountManager->connectivityType();
558 return static_cast<jint>(connectivityType);
562 * Class: org_iotivity_base_OcAccountManager
564 * Signature: (Ljava/lang/String;Ljava/lang/String;
565 * Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
567 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_signUp0
568 (JNIEnv *env, jobject thiz, jstring jAuthProvider, jstring jAuthCode, jobject jListener)
570 LOGD("OcAccountManager_signUp");
571 VERIFY_NON_NULL_THROW_EXCEPTION(jAuthProvider, "authProvider cannot be null",
572 OC_STACK_INVALID_PARAM);
573 VERIFY_NON_NULL_THROW_EXCEPTION(jAuthCode, "authCode cannot be null", OC_STACK_INVALID_PARAM);
574 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
575 OC_STACK_INVALID_PARAM);
577 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
584 const char *charAuthProvider = env->GetStringUTFChars(jAuthProvider, nullptr);
585 VERIFY_NON_NULL_THROW_EXCEPTION(charAuthProvider, "charAuthProvider is null", JNI_EXCEPTION);
586 std::string authProvider(charAuthProvider);
587 env->ReleaseStringUTFChars(jAuthProvider, charAuthProvider);
589 const char *charAuthCode = env->GetStringUTFChars(jAuthCode, nullptr);
590 VERIFY_NON_NULL_THROW_EXCEPTION(charAuthCode, "charAuthCode is null", JNI_EXCEPTION);
591 std::string authCode(charAuthCode);
592 env->ReleaseStringUTFChars(jAuthCode, charAuthCode);
596 OCStackResult result = accountManager->signUp(env,
600 if (OC_STACK_OK != result)
602 ThrowOcException(result, "OcAccountManager_signUp");
605 catch (OCException& e)
607 LOGE("%s", e.reason().c_str());
608 ThrowOcException(e.code(), e.reason().c_str());
613 * Class: org_iotivity_base_OcAccountManager
615 * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;
616 * Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
618 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_signUp1
619 (JNIEnv *env, jobject thiz, jstring jAuthProvider, jstring jAuthCode, jobject jOptionsMap,
622 LOGD("OcAccountManager_signUp");
623 VERIFY_NON_NULL_THROW_EXCEPTION(jAuthProvider, "authProvider cannot be null",
624 OC_STACK_INVALID_PARAM);
625 VERIFY_NON_NULL_THROW_EXCEPTION(jAuthCode, "authCode cannot be null", OC_STACK_INVALID_PARAM);
626 VERIFY_NON_NULL_THROW_EXCEPTION(jOptionsMap, "options cannot be null", OC_STACK_INVALID_PARAM);
627 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
628 OC_STACK_INVALID_PARAM);
630 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
637 const char *charAuthProvider = env->GetStringUTFChars(jAuthProvider, nullptr);
638 VERIFY_NON_NULL_THROW_EXCEPTION(charAuthProvider, "charAuthProvider is null", JNI_EXCEPTION);
639 std::string authProvider(charAuthProvider);
640 env->ReleaseStringUTFChars(jAuthProvider, charAuthProvider);
642 const char *charAuthCode = env->GetStringUTFChars(jAuthCode, nullptr);
643 VERIFY_NON_NULL_THROW_EXCEPTION(charAuthCode, "charAuthCode is null", JNI_EXCEPTION);
644 std::string authCode(charAuthCode);
645 env->ReleaseStringUTFChars(jAuthCode, charAuthCode);
647 QueryParamsMap optionsMap;
648 JniUtils::convertJavaMapToQueryParamsMap(env, jOptionsMap, optionsMap);
652 OCStackResult result = accountManager->signUp(env,
657 if (OC_STACK_OK != result)
659 ThrowOcException(result, "OcAccountManager_signUp");
662 catch (OCException& e)
664 LOGE("%s", e.reason().c_str());
665 ThrowOcException(e.code(), e.reason().c_str());
670 * Class: org_iotivity_base_OcAccountManager
672 * Signature: (Ljava/lang/String;Ljava/lang/String;
673 * Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
675 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_signIn0
676 (JNIEnv *env, jobject thiz, jstring jUserUuid, jstring jAccessToken, jobject jListener)
678 LOGD("OcAccountManager_signIn");
679 VERIFY_NON_NULL_THROW_EXCEPTION(jUserUuid, "userUuid cannot be null", OC_STACK_INVALID_PARAM);
680 VERIFY_NON_NULL_THROW_EXCEPTION(jAccessToken, "accessToken cannot be null",
681 OC_STACK_INVALID_PARAM);
682 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
683 OC_STACK_INVALID_PARAM);
685 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
692 const char *charUserUuid = env->GetStringUTFChars(jUserUuid, nullptr);
693 VERIFY_NON_NULL_THROW_EXCEPTION(charUserUuid, "charUserUuid is null", JNI_EXCEPTION);
694 std::string userUuid(charUserUuid);
695 env->ReleaseStringUTFChars(jUserUuid, charUserUuid);
697 const char *charAccessToken = env->GetStringUTFChars(jAccessToken, nullptr);
698 VERIFY_NON_NULL_THROW_EXCEPTION(charAccessToken, "charAccessToken is null", JNI_EXCEPTION);
699 std::string accessToken(charAccessToken);
700 env->ReleaseStringUTFChars(jAccessToken, charAccessToken);
704 OCStackResult result = accountManager->signIn(env,
708 if (OC_STACK_OK != result)
710 ThrowOcException(result, "OcAccountManager_signIn");
713 catch (OCException& e)
715 LOGE("%s", e.reason().c_str());
716 ThrowOcException(e.code(), e.reason().c_str());
721 * Class: org_iotivity_base_OcAccountManager
723 * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
725 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_signOut0
726 (JNIEnv *env, jobject thiz, jstring jAccessToken, jobject jListener)
728 LOGD("OcAccountManager_signOut");
729 VERIFY_NON_NULL_THROW_EXCEPTION(jAccessToken, "accessToken cannot be null",
730 OC_STACK_INVALID_PARAM);
731 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
732 OC_STACK_INVALID_PARAM);
734 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
741 const char *charAccessToken = env->GetStringUTFChars(jAccessToken, nullptr);
742 VERIFY_NON_NULL_THROW_EXCEPTION(charAccessToken, "charAccessToken is null", JNI_EXCEPTION);
743 std::string accessToken(charAccessToken);
744 env->ReleaseStringUTFChars(jAccessToken, charAccessToken);
748 OCStackResult result = accountManager->signOut(env,
751 if (OC_STACK_OK != result)
753 ThrowOcException(result, "OcAccountManager_signOut");
756 catch (OCException& e)
758 LOGE("%s", e.reason().c_str());
759 ThrowOcException(e.code(), e.reason().c_str());
764 * Class: org_iotivity_base_OcAccountManager
765 * Method: refreshAccessToken0
766 * Signature: (Ljava/lang/String;Ljava/lang/String;
767 * Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
769 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_refreshAccessToken0
770 (JNIEnv *env, jobject thiz, jstring jUserUuid, jstring jRefreshAccessToken, jobject jListener)
772 LOGD("OcAccountManager_refreshAccessToken");
773 VERIFY_NON_NULL_THROW_EXCEPTION(jUserUuid, "userUuid cannot be null", OC_STACK_INVALID_PARAM);
774 VERIFY_NON_NULL_THROW_EXCEPTION(jRefreshAccessToken, "refreshAccessToken cannot be null",
775 OC_STACK_INVALID_PARAM);
776 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
777 OC_STACK_INVALID_PARAM);
779 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
786 const char *charUserUuid = env->GetStringUTFChars(jUserUuid, nullptr);
787 VERIFY_NON_NULL_THROW_EXCEPTION(charUserUuid, "charUserUuid is null", JNI_EXCEPTION);
788 std::string userUuid(charUserUuid);
789 env->ReleaseStringUTFChars(jUserUuid, charUserUuid);
791 const char *charRefreshAccessToken = env->GetStringUTFChars(jRefreshAccessToken, nullptr);
792 VERIFY_NON_NULL_THROW_EXCEPTION(charRefreshAccessToken, "charRefreshAccessToken is null",
794 std::string refreshAccessToken(charRefreshAccessToken);
795 env->ReleaseStringUTFChars(jRefreshAccessToken, charRefreshAccessToken);
799 OCStackResult result = accountManager->refreshAccessToken(env,
803 if (OC_STACK_OK != result)
805 ThrowOcException(result, "OcAccountManager_refreshAccessToken");
808 catch (OCException& e)
810 LOGE("%s", e.reason().c_str());
811 ThrowOcException(e.code(), e.reason().c_str());
816 * Class: org_iotivity_base_OcAccountManager
817 * Method: searchUser0
818 * Signature: (Ljava/util/Map;Lorg/iotivity/base/OcAccountManager/OnGetListener;)V
820 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_searchUser0
821 (JNIEnv *env, jobject thiz, jobject jQueryMap, jobject jListener)
823 LOGD("OcAccountManager_searchUser");
824 VERIFY_NON_NULL_THROW_EXCEPTION(jQueryMap, "queryMap cannot be null", OC_STACK_INVALID_PARAM);
825 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onGetListener cannot be null",
826 OC_STACK_INVALID_PARAM);
828 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
835 QueryParamsMap queryMap;
836 JniUtils::convertJavaMapToQueryParamsMap(env, jQueryMap, queryMap);
840 OCStackResult result = accountManager->searchUser(env,
843 if (OC_STACK_OK != result)
845 ThrowOcException(result, "OcAccountManager_searchUser");
848 catch (OCException& e)
850 LOGE("%s", e.reason().c_str());
851 ThrowOcException(e.code(), e.reason().c_str());
856 * Class: org_iotivity_base_OcAccountManager
857 * Method: deleteDevice0
858 * Signature: (Ljava/lang/String;Ljava/lang/String;
859 * Lorg/iotivity/base/OcAccountManager/onDeleteListener;)V
861 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_deleteDevice0
862 (JNIEnv *env, jobject thiz, jstring jAccessToken, jstring jDeviceId, jobject jListener)
864 LOGD("OcAccountManager_deleteDevice");
865 VERIFY_NON_NULL_THROW_EXCEPTION(jAccessToken, "accessToken cannot be null",
866 OC_STACK_INVALID_PARAM);
867 VERIFY_NON_NULL_THROW_EXCEPTION(jDeviceId, "deviceId cannot be null", OC_STACK_INVALID_PARAM);
868 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onDeleteListener cannot be null",
869 OC_STACK_INVALID_PARAM);
871 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
878 const char *charAccessToken = env->GetStringUTFChars(jAccessToken, nullptr);
879 VERIFY_NON_NULL_THROW_EXCEPTION(charAccessToken, "charAccessToken is null", JNI_EXCEPTION);
880 std::string accessToken(charAccessToken);
881 env->ReleaseStringUTFChars(jAccessToken, charAccessToken);
883 const char *charDeviceId = env->GetStringUTFChars(jDeviceId, nullptr);
884 VERIFY_NON_NULL_THROW_EXCEPTION(charDeviceId, "charDeviceId is null", JNI_EXCEPTION);
885 std::string deviceId(charDeviceId);
886 env->ReleaseStringUTFChars(jDeviceId, charDeviceId);
890 OCStackResult result = accountManager->deleteDevice(env,
894 if (OC_STACK_OK != result)
896 ThrowOcException(result, "OcAccountManager_deleteDevice");
899 catch (OCException& e)
901 LOGE("%s", e.reason().c_str());
902 ThrowOcException(e.code(), e.reason().c_str());
907 * Class: org_iotivity_base_OcAccountManager
908 * Method: createGroup0
909 * Signature: (Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
911 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_createGroup0
912 (JNIEnv *env, jobject thiz, jobject jListener)
914 LOGD("OcAccountManager_createGroup");
915 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
916 OC_STACK_INVALID_PARAM);
918 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
927 OCStackResult result = accountManager->createGroup(env,
929 if (OC_STACK_OK != result)
931 ThrowOcException(result, "OcAccountManager_createGroup");
934 catch (OCException& e)
936 LOGE("%s", e.reason().c_str());
937 ThrowOcException(e.code(), e.reason().c_str());
942 * Class: org_iotivity_base_OcAccountManager
943 * Method: createGroup1
944 * Signature: (Ljava/util/Map;Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
946 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_createGroup1
947 (JNIEnv *env, jobject thiz, jobject jQueryMap, jobject jListener)
949 LOGD("OcAccountManager_createGroup");
950 VERIFY_NON_NULL_THROW_EXCEPTION(jQueryMap, "queryMap cannot be null", OC_STACK_INVALID_PARAM);
951 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
952 OC_STACK_INVALID_PARAM);
954 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
961 QueryParamsMap queryMap;
962 JniUtils::convertJavaMapToQueryParamsMap(env, jQueryMap, queryMap);
966 OCStackResult result = accountManager->createGroup(env,
969 if (OC_STACK_OK != result)
971 ThrowOcException(result, "OcAccountManager_createGroup");
974 catch (OCException& e)
976 LOGE("%s", e.reason().c_str());
977 ThrowOcException(e.code(), e.reason().c_str());
982 * Class: org_iotivity_base_OcAccountManager
983 * Method: deleteGroup0
984 * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/onDeleteListener;)V
986 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_deleteGroup0
987 (JNIEnv *env, jobject thiz, jstring jGroupId, jobject jListener)
989 LOGD("OcAccountManager_deleteGroup");
990 VERIFY_NON_NULL_THROW_EXCEPTION(jGroupId, "groupId cannot be null", OC_STACK_INVALID_PARAM);
991 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onDeleteListener cannot be null",
992 OC_STACK_INVALID_PARAM);
994 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
1001 const char *charGroupId = env->GetStringUTFChars(jGroupId, nullptr);
1002 VERIFY_NON_NULL_THROW_EXCEPTION(charGroupId, "charGroupId is null", JNI_EXCEPTION);
1003 std::string groupId(charGroupId);
1004 env->ReleaseStringUTFChars(jGroupId, charGroupId);
1008 OCStackResult result = accountManager->deleteGroup(env,
1011 if (OC_STACK_OK != result)
1013 ThrowOcException(result, "OcAccountManager_deleteGroup");
1016 catch (OCException& e)
1018 LOGE("%s", e.reason().c_str());
1019 ThrowOcException(e.code(), e.reason().c_str());
1024 * Class: org_iotivity_base_OcAccountManager
1025 * Method: getGroupInfoAll0
1026 * Signature: (Lorg/iotivity/base/OcAccountManager/OnGetListener;)V
1028 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_getGroupInfoAll0
1029 (JNIEnv *env, jobject thiz, jobject jListener)
1031 LOGD("OcAccountManager_getGroupInfoAll");
1032 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onGetListener cannot be null",
1033 OC_STACK_INVALID_PARAM);
1035 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
1037 if (!accountManager)
1044 OCStackResult result = accountManager->getGroupInfoAll(env,
1046 if (OC_STACK_OK != result)
1048 ThrowOcException(result, "OcAccountManager_getGroupInfoAll");
1051 catch (OCException& e)
1053 LOGE("%s", e.reason().c_str());
1054 ThrowOcException(e.code(), e.reason().c_str());
1059 * Class: org_iotivity_base_OcAccountManager
1060 * Method: getGroupInfo0
1061 * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/OnGetListener;)V
1063 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_getGroupInfo0
1064 (JNIEnv *env, jobject thiz, jstring jGroupId, jobject jListener)
1066 LOGD("OcAccountManager_getGroupInfo");
1067 VERIFY_NON_NULL_THROW_EXCEPTION(jGroupId, "groupId cannot be null", OC_STACK_INVALID_PARAM);
1068 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onGetListener cannot be null",
1069 OC_STACK_INVALID_PARAM);
1071 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
1073 if (!accountManager)
1078 const char *charGroupId = env->GetStringUTFChars(jGroupId, nullptr);
1079 VERIFY_NON_NULL_THROW_EXCEPTION(charGroupId, "charGroupId is null", JNI_EXCEPTION);
1080 std::string groupId(charGroupId);
1081 env->ReleaseStringUTFChars(jGroupId, charGroupId);
1085 OCStackResult result = accountManager->getGroupInfo(env,
1088 if (OC_STACK_OK != result)
1090 ThrowOcException(result, "OcAccountManager_getGroupInfo");
1093 catch (OCException& e)
1095 LOGE("%s", e.reason().c_str());
1096 ThrowOcException(e.code(), e.reason().c_str());
1101 * Class: org_iotivity_base_OcAccountManager
1102 * Method: addPropertyValueToGroup0
1103 * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;
1104 * Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
1106 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_addPropertyValueToGroup0
1107 (JNIEnv *env, jobject thiz, jstring jGroupId, jobject jPropertyValue, jobject jListener)
1109 LOGD("OcAccountManager_addPropertyValueToGroup");
1110 VERIFY_NON_NULL_THROW_EXCEPTION(jGroupId, "groupId cannot be null", OC_STACK_INVALID_PARAM);
1111 VERIFY_NON_NULL_THROW_EXCEPTION(jPropertyValue, "propertyValue cannot be null",
1112 OC_STACK_INVALID_PARAM);
1113 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
1114 OC_STACK_INVALID_PARAM);
1116 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
1118 if (!accountManager)
1123 OCRepresentation *propertyValue = JniOcRepresentation::getOCRepresentationPtr(env,
1130 const char *charGroupId = env->GetStringUTFChars(jGroupId, nullptr);
1131 VERIFY_NON_NULL_THROW_EXCEPTION(charGroupId, "charGroupId is null", JNI_EXCEPTION);
1132 std::string groupId(charGroupId);
1133 env->ReleaseStringUTFChars(jGroupId, charGroupId);
1137 OCStackResult result = accountManager->addPropertyValueToGroup(env,
1142 if (OC_STACK_OK != result)
1144 ThrowOcException(result, "OcAccountManager_addPropertyValueToGroup");
1147 catch (OCException& e)
1149 LOGE("%s", e.reason().c_str());
1150 ThrowOcException(e.code(), e.reason().c_str());
1155 * Class: org_iotivity_base_OcAccountManager
1156 * Method: deletePropertyValueFromGroup0
1157 * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;
1158 * Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
1160 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_deletePropertyValueFromGroup0
1161 (JNIEnv *env, jobject thiz, jstring jGroupId, jobject jPropertyValue, jobject jListener)
1163 LOGD("OcAccountManager_deletePropertyValueFromGroup");
1164 VERIFY_NON_NULL_THROW_EXCEPTION(jGroupId, "groupId cannot be null", OC_STACK_INVALID_PARAM);
1165 VERIFY_NON_NULL_THROW_EXCEPTION(jPropertyValue, "propertyValue cannot be null",
1166 OC_STACK_INVALID_PARAM);
1167 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
1168 OC_STACK_INVALID_PARAM);
1170 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
1172 if (!accountManager)
1177 OCRepresentation *propertyValue = JniOcRepresentation::getOCRepresentationPtr(env,
1184 const char *charGroupId = env->GetStringUTFChars(jGroupId, nullptr);
1185 VERIFY_NON_NULL_THROW_EXCEPTION(charGroupId, "charGroupId is null", JNI_EXCEPTION);
1186 std::string groupId(charGroupId);
1187 env->ReleaseStringUTFChars(jGroupId, charGroupId);
1191 OCStackResult result = accountManager->deletePropertyValueFromGroup(env,
1196 if (OC_STACK_OK != result)
1198 ThrowOcException(result, "OcAccountManager_deletePropertyValueFromGroup");
1201 catch (OCException& e)
1203 LOGE("%s", e.reason().c_str());
1204 ThrowOcException(e.code(), e.reason().c_str());
1209 * Class: org_iotivity_base_OcAccountManager
1210 * Method: updatePropertyValueOnGroup0
1211 * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;
1212 * Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
1214 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_updatePropertyValueOnGroup0
1215 (JNIEnv *env, jobject thiz, jstring jGroupId, jobject jPropertyValue, jobject jListener)
1217 LOGD("OcAccountManager_updatePropertyValueOnGroup");
1218 VERIFY_NON_NULL_THROW_EXCEPTION(jGroupId, "groupId cannot be null", OC_STACK_INVALID_PARAM);
1219 VERIFY_NON_NULL_THROW_EXCEPTION(jPropertyValue, "propertyValue cannot be null",
1220 OC_STACK_INVALID_PARAM);
1221 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
1222 OC_STACK_INVALID_PARAM);
1224 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
1226 if (!accountManager)
1231 OCRepresentation *propertyValue = JniOcRepresentation::getOCRepresentationPtr(env,
1238 const char *charGroupId = env->GetStringUTFChars(jGroupId, nullptr);
1239 VERIFY_NON_NULL_THROW_EXCEPTION(charGroupId, "charGroupId is null", JNI_EXCEPTION);
1240 std::string groupId(charGroupId);
1241 env->ReleaseStringUTFChars(jGroupId, charGroupId);
1245 OCStackResult result = accountManager->updatePropertyValueOnGroup(env,
1250 if (OC_STACK_OK != result)
1252 ThrowOcException(result, "OcAccountManager_updatePropertyValueOnGroup");
1255 catch (OCException& e)
1257 LOGE("%s", e.reason().c_str());
1258 ThrowOcException(e.code(), e.reason().c_str());
1263 * Class: org_iotivity_base_OcAccountManager
1264 * Method: observeGroup0
1265 * Signature: (Lorg/iotivity/base/OcResource/OnObserveListener;)V
1267 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_observeGroup0
1268 (JNIEnv *env, jobject thiz, jobject jListener)
1270 LOGD("OcAccountManager_observeGroup");
1271 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onObserveListener cannot be null",
1272 OC_STACK_INVALID_PARAM);
1274 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
1276 if (!accountManager)
1283 OCStackResult result = accountManager->observeGroup(env,
1285 if (OC_STACK_OK != result)
1287 ThrowOcException(result, "OcAccountManager_observeGroup");
1290 catch (OCException& e)
1292 LOGE("%s", e.reason().c_str());
1293 ThrowOcException(e.code(), e.reason().c_str());
1298 * Class: org_iotivity_base_OcAccountManager
1299 * Method: cancelObserveGroup0
1302 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_cancelObserveGroup0
1303 (JNIEnv *env, jobject thiz)
1305 LOGD("OcAccountManager_cancelObserveGroup");
1307 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
1309 if (!accountManager)
1316 OCStackResult result = accountManager->cancelObserveGroup();
1317 if (OC_STACK_OK != result)
1319 ThrowOcException(result, "OcAccountManager_cancelObserveGroup");
1322 catch (OCException& e)
1324 LOGE("%s", e.reason().c_str());
1325 ThrowOcException(e.code(), e.reason().c_str());
1330 * Class: org_iotivity_base_OcAccountManager
1331 * Method: observeInvitation0
1332 * Signature: (Lorg/iotivity/base/OcResource/OnObserveListener;)V
1334 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_observeInvitation0
1335 (JNIEnv *env, jobject thiz, jobject jListener)
1337 LOGD("OcAccountManager_observeInvitation");
1338 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onObserveListener cannot be null",
1339 OC_STACK_INVALID_PARAM);
1341 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
1343 if (!accountManager)
1350 OCStackResult result = accountManager->observeInvitation(env,
1352 if (OC_STACK_OK != result)
1354 ThrowOcException(result, "OcAccountManager_observeInvitation");
1357 catch (OCException& e)
1359 LOGE("%s", e.reason().c_str());
1360 ThrowOcException(e.code(), e.reason().c_str());
1365 * Class: org_iotivity_base_OcAccountManager
1366 * Method: cancelObserveInvitation0
1369 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_cancelObserveInvitation0
1370 (JNIEnv *env, jobject thiz)
1372 LOGD("OcAccountManager_cancelObserveInvitation");
1374 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
1376 if (!accountManager)
1383 OCStackResult result = accountManager->cancelObserveInvitation();
1384 if (OC_STACK_OK != result)
1386 ThrowOcException(result, "OcAccountManager_cancelObserveInvitation");
1389 catch (OCException& e)
1391 LOGE("%s", e.reason().c_str());
1392 ThrowOcException(e.code(), e.reason().c_str());
1397 * Class: org_iotivity_base_OcAccountManager
1398 * Method: sendInvitation0
1399 * Signature: (Ljava/lang/String;Ljava/lang/String;
1400 * Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
1402 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_sendInvitation0
1403 (JNIEnv *env, jobject thiz, jstring jGroupId, jstring jUserUuid, jobject jListener)
1405 LOGD("OcAccountManager_sendInvitation");
1406 VERIFY_NON_NULL_THROW_EXCEPTION(jGroupId, "groupId cannot be null", OC_STACK_INVALID_PARAM);
1407 VERIFY_NON_NULL_THROW_EXCEPTION(jUserUuid, "userUuid cannot be null", OC_STACK_INVALID_PARAM);
1408 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
1409 OC_STACK_INVALID_PARAM);
1411 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
1413 if (!accountManager)
1418 const char *charGroupId = env->GetStringUTFChars(jGroupId, nullptr);
1419 VERIFY_NON_NULL_THROW_EXCEPTION(charGroupId, "charGroupId is null", JNI_EXCEPTION);
1420 std::string groupId(charGroupId);
1421 env->ReleaseStringUTFChars(jGroupId, charGroupId);
1423 const char *charUserUuid = env->GetStringUTFChars(jUserUuid, nullptr);
1424 VERIFY_NON_NULL_THROW_EXCEPTION(charUserUuid, "charUserUuid is null", JNI_EXCEPTION);
1425 std::string userUuid(charUserUuid);
1426 env->ReleaseStringUTFChars(jUserUuid, charUserUuid);
1430 OCStackResult result = accountManager->sendInvitation(env,
1434 if (OC_STACK_OK != result)
1436 ThrowOcException(result, "OcAccountManager_sendInvitation");
1439 catch (OCException& e)
1441 LOGE("%s", e.reason().c_str());
1442 ThrowOcException(e.code(), e.reason().c_str());
1447 * Class: org_iotivity_base_OcAccountManager
1448 * Method: cancelInvitation0
1449 * Signature: (Ljava/lang/String;Ljava/lang/String;
1450 * Lorg/iotivity/base/OcAccountManager/onDeleteListener;)V
1452 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_cancelInvitation0
1453 (JNIEnv *env, jobject thiz, jstring jGroupId, jstring jUserUuid, jobject jListener)
1455 LOGD("OcAccountManager_cancelInvitation");
1456 VERIFY_NON_NULL_THROW_EXCEPTION(jGroupId, "groupId cannot be null", OC_STACK_INVALID_PARAM);
1457 VERIFY_NON_NULL_THROW_EXCEPTION(jUserUuid, "userUuid cannot be null", OC_STACK_INVALID_PARAM);
1458 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onDeleteListener cannot be null",
1459 OC_STACK_INVALID_PARAM);
1461 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
1463 if (!accountManager)
1468 const char *charGroupId = env->GetStringUTFChars(jGroupId, nullptr);
1469 VERIFY_NON_NULL_THROW_EXCEPTION(charGroupId, "charGroupId is null", JNI_EXCEPTION);
1470 std::string groupId(charGroupId);
1471 env->ReleaseStringUTFChars(jGroupId, charGroupId);
1473 const char *charUserUuid = env->GetStringUTFChars(jUserUuid, nullptr);
1474 VERIFY_NON_NULL_THROW_EXCEPTION(charUserUuid, "charUserUuid is null", JNI_EXCEPTION);
1475 std::string userUuid(charUserUuid);
1476 env->ReleaseStringUTFChars(jUserUuid, charUserUuid);
1480 OCStackResult result = accountManager->cancelInvitation(env,
1484 if (OC_STACK_OK != result)
1486 ThrowOcException(result, "OcAccountManager_cancelInvitation");
1489 catch (OCException& e)
1491 LOGE("%s", e.reason().c_str());
1492 ThrowOcException(e.code(), e.reason().c_str());
1497 * Class: org_iotivity_base_OcAccountManager
1498 * Method: replyToInvitation0
1499 * Signature: (Ljava/lang/String;ZLorg/iotivity/base/OcAccountManager/onDeleteListener;)V
1501 JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_replyToInvitation0
1502 (JNIEnv *env, jobject thiz, jstring jGroupId, jboolean jAccept, jobject jListener)
1504 LOGD("OcAccountManager_replyToInvitation");
1505 VERIFY_NON_NULL_THROW_EXCEPTION(jGroupId, "groupId cannot be null", OC_STACK_INVALID_PARAM);
1506 VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onDeleteListener cannot be null",
1507 OC_STACK_INVALID_PARAM);
1509 JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
1511 if (!accountManager)
1516 const char *charGroupId = env->GetStringUTFChars(jGroupId, nullptr);
1517 VERIFY_NON_NULL_THROW_EXCEPTION(charGroupId, "charGroupId is null", JNI_EXCEPTION);
1518 std::string groupId(charGroupId);
1519 env->ReleaseStringUTFChars(jGroupId, charGroupId);
1523 OCStackResult result = accountManager->replyToInvitation(env,
1525 static_cast<bool>(jAccept),
1527 if (OC_STACK_OK != result)
1529 ThrowOcException(result, "OcAccountManager_replyToInvitation");
1532 catch (OCException& e)
1534 LOGE("%s", e.reason().c_str());
1535 ThrowOcException(e.code(), e.reason().c_str());