#include "JniOcRepresentation.h"
#include "JniUtils.h"
+#define VERIFY_NON_NULL_THROW_EXCEPTION(arg, log_message, exc) \
+ if (!(arg)) \
+ { \
+ ThrowOcException(exc, log_message); \
+ return; \
+ } \
+
JniOcAccountManager::JniOcAccountManager(std::shared_ptr<OCAccountManager> accountManager)
: m_sharedAccountManager(accountManager)
{
const std::string& authCode, jobject jListener)
{
JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
+ if (nullptr == onPostListener)
+ {
+ LOGE("onPostListener is null");
+ return OC_STACK_ERROR;
+ }
PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
const OCRepresentation& rep, const int eCode)
const QueryParamsMap& options, jobject jListener)
{
JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
+ if (nullptr == onPostListener)
+ {
+ LOGE("onPostListener is null");
+ return OC_STACK_ERROR;
+ }
PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
const OCRepresentation& rep, const int eCode)
const std::string& accessToken, jobject jListener)
{
JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
+ if (nullptr == onPostListener)
+ {
+ LOGE("onPostListener is null");
+ return OC_STACK_ERROR;
+ }
PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
const OCRepresentation& rep, const int eCode)
return m_sharedAccountManager->signIn(userUuid, accessToken, postCallback);
}
-OCStackResult JniOcAccountManager::signOut(JNIEnv* env, jobject jListener)
+OCStackResult JniOcAccountManager::signOut(JNIEnv* env, const std::string& accessToken,
+ jobject jListener)
{
JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
+ if (nullptr == onPostListener)
+ {
+ LOGE("onPostListener is null");
+ return OC_STACK_ERROR;
+ }
PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
const OCRepresentation& rep, const int eCode)
onPostListener->onPostCallback(opts, rep, eCode);
};
- return m_sharedAccountManager->signOut(postCallback);
+ return m_sharedAccountManager->signOut(accessToken, postCallback);
}
OCStackResult JniOcAccountManager::refreshAccessToken(JNIEnv* env, const std::string& userUuid,
jobject jListener)
{
JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
+ if (nullptr == onPostListener)
+ {
+ LOGE("onPostListener is null");
+ return OC_STACK_ERROR;
+ }
PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
const OCRepresentation& rep, const int eCode)
jobject jListener)
{
JniOnGetListener *onGetListener = addOnGetListener(env, jListener);
+ if (nullptr == onGetListener)
+ {
+ LOGE("onGetListener is null");
+ return OC_STACK_ERROR;
+ }
GetCallback getCallback = [onGetListener](const HeaderOptions& opts,
const OCRepresentation& rep, const int eCode)
jobject jListener)
{
JniOnGetListener *onGetListener = addOnGetListener(env, jListener);
+ if (nullptr == onGetListener)
+ {
+ LOGE("onGetListener is null");
+ return OC_STACK_ERROR;
+ }
GetCallback getCallback = [onGetListener](const HeaderOptions& opts,
const OCRepresentation& rep, const int eCode)
return m_sharedAccountManager->searchUser(queryMap, getCallback);
}
-OCStackResult JniOcAccountManager::deleteDevice(JNIEnv* env, const std::string& deviceId,
- jobject jListener)
+OCStackResult JniOcAccountManager::deleteDevice(JNIEnv* env, const std::string& accessToken,
+ const std::string& deviceId, jobject jListener)
{
JniOnDeleteListener *onDeleteListener = addOnDeleteListener(env, jListener);
+ if (nullptr == onDeleteListener)
+ {
+ LOGE("onDeleteListener is null");
+ return OC_STACK_ERROR;
+ }
DeleteCallback deleteCallback = [onDeleteListener](const HeaderOptions& opts,
const int eCode)
onDeleteListener->onDeleteCallback(opts, eCode);
};
- return m_sharedAccountManager->deleteDevice(deviceId, deleteCallback);
+ return m_sharedAccountManager->deleteDevice(accessToken, deviceId, deleteCallback);
}
-OCStackResult JniOcAccountManager::createGroup(JNIEnv* env, AclGroupType groupType,
- jobject jListener)
+OCStackResult JniOcAccountManager::createGroup(JNIEnv* env, jobject jListener)
{
JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
+ if (nullptr == onPostListener)
+ {
+ LOGE("onPostListener is null");
+ return OC_STACK_ERROR;
+ }
PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
const OCRepresentation& rep, const int eCode)
onPostListener->onPostCallback(opts, rep, eCode);
};
- return m_sharedAccountManager->createGroup(groupType, postCallback);
+ return m_sharedAccountManager->createGroup(postCallback);
}
-OCStackResult JniOcAccountManager::getGroupList(JNIEnv* env, jobject jListener)
+OCStackResult JniOcAccountManager::createGroup(JNIEnv* env, const QueryParamsMap& queryMap,
+ jobject jListener)
{
- JniOnGetListener *onGetListener = addOnGetListener(env, jListener);
+ JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
+ if (nullptr == onPostListener)
+ {
+ LOGE("onPostListener is null");
+ return OC_STACK_ERROR;
+ }
- GetCallback getCallback = [onGetListener](const HeaderOptions& opts,
+ PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
const OCRepresentation& rep, const int eCode)
{
- onGetListener->onGetCallback(opts, rep, eCode);
+ onPostListener->onPostCallback(opts, rep, eCode);
};
- return m_sharedAccountManager->getGroupList(getCallback);
+ return m_sharedAccountManager->createGroup(queryMap, postCallback);
}
OCStackResult JniOcAccountManager::deleteGroup(JNIEnv* env, const std::string& groupId,
jobject jListener)
{
JniOnDeleteListener *onDeleteListener = addOnDeleteListener(env, jListener);
+ if (nullptr == onDeleteListener)
+ {
+ LOGE("onDeleteListener is null");
+ return OC_STACK_ERROR;
+ }
DeleteCallback deleteCallback = [onDeleteListener](const HeaderOptions& opts,
const int eCode)
return m_sharedAccountManager->deleteGroup(groupId, deleteCallback);
}
-OCStackResult JniOcAccountManager::joinGroup(JNIEnv* env, const std::string& groupId,
- jobject jListener)
+OCStackResult JniOcAccountManager::getGroupInfoAll(JNIEnv* env, jobject jListener)
{
- JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
+ JniOnGetListener *onGetListener = addOnGetListener(env, jListener);
+ if (nullptr == onGetListener)
+ {
+ LOGE("onGetListener is null");
+ return OC_STACK_ERROR;
+ }
- PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
+ GetCallback getCallback = [onGetListener](const HeaderOptions& opts,
const OCRepresentation& rep, const int eCode)
{
- onPostListener->onPostCallback(opts, rep, eCode);
+ onGetListener->onGetCallback(opts, rep, eCode);
};
- return m_sharedAccountManager->joinGroup(groupId, postCallback);
+ return m_sharedAccountManager->getGroupInfoAll(getCallback);
}
-OCStackResult JniOcAccountManager::addDeviceToGroup(JNIEnv* env, const std::string& groupId,
- const std::vector<std::string>& deviceId,
- jobject jListener)
+OCStackResult JniOcAccountManager::getGroupInfo(JNIEnv* env, const std::string& groupId,
+ jobject jListener)
{
- JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
+ JniOnGetListener *onGetListener = addOnGetListener(env, jListener);
+ if (nullptr == onGetListener)
+ {
+ LOGE("onGetListener is null");
+ return OC_STACK_ERROR;
+ }
- PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
+ GetCallback getCallback = [onGetListener](const HeaderOptions& opts,
const OCRepresentation& rep, const int eCode)
{
- onPostListener->onPostCallback(opts, rep, eCode);
+ onGetListener->onGetCallback(opts, rep, eCode);
};
- return m_sharedAccountManager->addDeviceToGroup(groupId, deviceId, postCallback);
+ return m_sharedAccountManager->getGroupInfo(groupId, getCallback);
}
-OCStackResult JniOcAccountManager::getGroupInfo(JNIEnv* env, const std::string& groupId,
- jobject jListener)
+OCStackResult JniOcAccountManager::addPropertyValueToGroup(JNIEnv* env, const std::string& groupId,
+ const OCRepresentation& propertyValue,
+ jobject jListener)
{
- JniOnGetListener *onGetListener = addOnGetListener(env, jListener);
+ JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
+ if (nullptr == onPostListener)
+ {
+ LOGE("onPostListener is null");
+ return OC_STACK_ERROR;
+ }
- GetCallback getCallback = [onGetListener](const HeaderOptions& opts,
+ PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
const OCRepresentation& rep, const int eCode)
{
- onGetListener->onGetCallback(opts, rep, eCode);
+ onPostListener->onPostCallback(opts, rep, eCode);
};
- return m_sharedAccountManager->getGroupInfo(groupId, getCallback);
+ return m_sharedAccountManager->addPropertyValueToGroup(groupId, propertyValue, postCallback);
}
-OCStackResult JniOcAccountManager::leaveGroup(JNIEnv* env, const std::string& groupId,
- jobject jListener)
+OCStackResult JniOcAccountManager::deletePropertyValueFromGroup(JNIEnv* env,
+ const std::string& groupId,
+ const OCRepresentation& propertyValue,
+ jobject jListener)
{
- JniOnDeleteListener *onDeleteListener = addOnDeleteListener(env, jListener);
+ JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
+ if (nullptr == onPostListener)
+ {
+ LOGE("onPostListener is null");
+ return OC_STACK_ERROR;
+ }
- DeleteCallback deleteCallback = [onDeleteListener](const HeaderOptions& opts,
- const int eCode)
+ PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
+ const OCRepresentation& rep, const int eCode)
{
- onDeleteListener->onDeleteCallback(opts, eCode);
+ onPostListener->onPostCallback(opts, rep, eCode);
};
- return m_sharedAccountManager->leaveGroup(groupId, deleteCallback);
+ return m_sharedAccountManager->deletePropertyValueFromGroup(groupId, propertyValue,
+ postCallback);
}
-OCStackResult JniOcAccountManager::deleteDeviceFromGroup(JNIEnv* env, const std::string& groupId,
- const std::vector<std::string>& deviceId,
- jobject jListener)
+OCStackResult JniOcAccountManager::updatePropertyValueOnGroup(JNIEnv* env,
+ const std::string& groupId,
+ const OCRepresentation& propertyValue,
+ jobject jListener)
{
- JniOnDeleteListener *onDeleteListener = addOnDeleteListener(env, jListener);
+ JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
+ if (nullptr == onPostListener)
+ {
+ LOGE("onPostListener is null");
+ return OC_STACK_ERROR;
+ }
- DeleteCallback deleteCallback = [onDeleteListener](const HeaderOptions& opts,
- const int eCode)
+ PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
+ const OCRepresentation& rep, const int eCode)
{
- onDeleteListener->onDeleteCallback(opts, eCode);
+ onPostListener->onPostCallback(opts, rep, eCode);
};
- return m_sharedAccountManager->deleteDeviceFromGroup(groupId, deviceId, deleteCallback);
+ return m_sharedAccountManager->updatePropertyValueOnGroup(groupId, propertyValue,
+ postCallback);
}
-OCStackResult JniOcAccountManager::observeGroup(JNIEnv* env, const std::string& groupId,
- jobject jListener)
+OCStackResult JniOcAccountManager::observeGroup(JNIEnv* env, jobject jListener)
{
JniOnObserveListener *onObserveListener = addOnObserveListener(env, jListener);
+ if (nullptr == onObserveListener)
+ {
+ LOGE("onObserveListener is null");
+ return OC_STACK_ERROR;
+ }
ObserveCallback observeCallback = [onObserveListener](const HeaderOptions& opts,
const OCRepresentation& rep, const int& eCode, const int& sequenceNumber)
onObserveListener->onObserveCallback(opts, rep, eCode, sequenceNumber);
};
- return m_sharedAccountManager->observeGroup(groupId, observeCallback);
+ return m_sharedAccountManager->observeGroup(observeCallback);
}
-OCStackResult JniOcAccountManager::cancelObserveGroup(const std::string& groupId)
+OCStackResult JniOcAccountManager::cancelObserveGroup()
{
- return m_sharedAccountManager->cancelObserveGroup(groupId);
+ return m_sharedAccountManager->cancelObserveGroup();
}
OCStackResult JniOcAccountManager::observeInvitation(JNIEnv* env, jobject jListener)
{
JniOnObserveListener *onObserveListener = addOnObserveListener(env, jListener);
+ if (nullptr == onObserveListener)
+ {
+ LOGE("onObserveListener is null");
+ return OC_STACK_ERROR;
+ }
ObserveCallback observeCallback = [onObserveListener](const HeaderOptions& opts,
const OCRepresentation& rep, const int& eCode, const int& sequenceNumber)
const std::string& userUuid, jobject jListener)
{
JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
+ if (nullptr == onPostListener)
+ {
+ LOGE("onPostListener is null");
+ return OC_STACK_ERROR;
+ }
PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
const OCRepresentation& rep, const int eCode)
const std::string& userUuid, jobject jListener)
{
JniOnDeleteListener *onDeleteListener = addOnDeleteListener(env, jListener);
+ if (nullptr == onDeleteListener)
+ {
+ LOGE("onDeleteListener is null");
+ return OC_STACK_ERROR;
+ }
DeleteCallback deleteCallback = [onDeleteListener](const HeaderOptions& opts,
const int eCode)
return m_sharedAccountManager->cancelInvitation(groupId, userUuid, deleteCallback);
}
-OCStackResult JniOcAccountManager::deleteInvitation(JNIEnv* env, const std::string& groupId,
- jobject jListener)
+OCStackResult JniOcAccountManager::replyToInvitation(JNIEnv* env, const std::string& groupId,
+ const bool accept, jobject jListener)
{
JniOnDeleteListener *onDeleteListener = addOnDeleteListener(env, jListener);
+ if (nullptr == onDeleteListener)
+ {
+ LOGE("onDeleteListener is null");
+ return OC_STACK_ERROR;
+ }
DeleteCallback deleteCallback = [onDeleteListener](const HeaderOptions& opts,
const int eCode)
onDeleteListener->onDeleteCallback(opts, eCode);
};
- return m_sharedAccountManager->deleteInvitation(groupId, deleteCallback);
+ return m_sharedAccountManager->replyToInvitation(groupId, accept, deleteCallback);
}
-
/*
* Class: org_iotivity_base_OcAccountManager
* Method: getHost
/*
* Class: org_iotivity_base_OcAccountManager
* Method: signUp0
-* Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
+* Signature: (Ljava/lang/String;Ljava/lang/String;
+* Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
*/
JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_signUp0
(JNIEnv *env, jobject thiz, jstring jAuthProvider, jstring jAuthCode, jobject jListener)
{
LOGD("OcAccountManager_signUp");
- if (!jListener)
- {
- ThrowOcException(OC_STACK_INVALID_PARAM, "onPostListener cannot be null");
- return;
- }
+ VERIFY_NON_NULL_THROW_EXCEPTION(jAuthProvider, "authProvider cannot be null",
+ OC_STACK_INVALID_PARAM);
+ VERIFY_NON_NULL_THROW_EXCEPTION(jAuthCode, "authCode cannot be null", OC_STACK_INVALID_PARAM);
+ VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
+ OC_STACK_INVALID_PARAM);
JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
thiz);
return;
}
- std::string authProvider;
- std::string authCode;
- if (jAuthProvider)
- {
- authProvider = env->GetStringUTFChars(jAuthProvider, nullptr);
- }
- if (jAuthCode)
- {
- authCode = env->GetStringUTFChars(jAuthCode, nullptr);
- }
+ const char *charAuthProvider = env->GetStringUTFChars(jAuthProvider, nullptr);
+ VERIFY_NON_NULL_THROW_EXCEPTION(charAuthProvider, "charAuthProvider is null", JNI_EXCEPTION);
+ std::string authProvider(charAuthProvider);
+ env->ReleaseStringUTFChars(jAuthProvider, charAuthProvider);
+
+ const char *charAuthCode = env->GetStringUTFChars(jAuthCode, nullptr);
+ VERIFY_NON_NULL_THROW_EXCEPTION(charAuthCode, "charAuthCode is null", JNI_EXCEPTION);
+ std::string authCode(charAuthCode);
+ env->ReleaseStringUTFChars(jAuthCode, charAuthCode);
try
{
authProvider,
authCode,
jListener);
-
if (OC_STACK_OK != result)
{
ThrowOcException(result, "OcAccountManager_signUp");
/*
* Class: org_iotivity_base_OcAccountManager
* Method: signUp1
-* Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
+* Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;
+* Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
*/
JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_signUp1
(JNIEnv *env, jobject thiz, jstring jAuthProvider, jstring jAuthCode, jobject jOptionsMap,
jobject jListener)
{
LOGD("OcAccountManager_signUp");
- if (!jListener)
- {
- ThrowOcException(OC_STACK_INVALID_PARAM, "onPostListener cannot be null");
- return;
- }
- if (!jOptionsMap)
- {
- ThrowOcException(OC_STACK_INVALID_PARAM, "options cannot be null");
- return;
- }
+ VERIFY_NON_NULL_THROW_EXCEPTION(jAuthProvider, "authProvider cannot be null",
+ OC_STACK_INVALID_PARAM);
+ VERIFY_NON_NULL_THROW_EXCEPTION(jAuthCode, "authCode cannot be null", OC_STACK_INVALID_PARAM);
+ VERIFY_NON_NULL_THROW_EXCEPTION(jOptionsMap, "options cannot be null", OC_STACK_INVALID_PARAM);
+ VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
+ OC_STACK_INVALID_PARAM);
JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
thiz);
return;
}
- std::string authProvider;
- std::string authCode;
- if (jAuthProvider)
- {
- authProvider = env->GetStringUTFChars(jAuthProvider, nullptr);
- }
- if (jAuthCode)
- {
- authCode = env->GetStringUTFChars(jAuthCode, nullptr);
- }
+ const char *charAuthProvider = env->GetStringUTFChars(jAuthProvider, nullptr);
+ VERIFY_NON_NULL_THROW_EXCEPTION(charAuthProvider, "charAuthProvider is null", JNI_EXCEPTION);
+ std::string authProvider(charAuthProvider);
+ env->ReleaseStringUTFChars(jAuthProvider, charAuthProvider);
+
+ const char *charAuthCode = env->GetStringUTFChars(jAuthCode, nullptr);
+ VERIFY_NON_NULL_THROW_EXCEPTION(charAuthCode, "charAuthCode is null", JNI_EXCEPTION);
+ std::string authCode(charAuthCode);
+ env->ReleaseStringUTFChars(jAuthCode, charAuthCode);
QueryParamsMap optionsMap;
JniUtils::convertJavaMapToQueryParamsMap(env, jOptionsMap, optionsMap);
authCode,
optionsMap,
jListener);
-
if (OC_STACK_OK != result)
{
ThrowOcException(result, "OcAccountManager_signUp");
/*
* Class: org_iotivity_base_OcAccountManager
* Method: signIn0
-* Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
+* Signature: (Ljava/lang/String;Ljava/lang/String;
+* Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
*/
JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_signIn0
(JNIEnv *env, jobject thiz, jstring jUserUuid, jstring jAccessToken, jobject jListener)
{
LOGD("OcAccountManager_signIn");
- if (!jListener)
- {
- ThrowOcException(OC_STACK_INVALID_PARAM, "onPostListener cannot be null");
- return;
- }
+ VERIFY_NON_NULL_THROW_EXCEPTION(jUserUuid, "userUuid cannot be null", OC_STACK_INVALID_PARAM);
+ VERIFY_NON_NULL_THROW_EXCEPTION(jAccessToken, "accessToken cannot be null",
+ OC_STACK_INVALID_PARAM);
+ VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
+ OC_STACK_INVALID_PARAM);
JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
thiz);
return;
}
- std::string userUuid;
- std::string accessToken;
- if (jUserUuid)
- {
- userUuid = env->GetStringUTFChars(jUserUuid, nullptr);
- }
- if (jAccessToken)
- {
- accessToken = env->GetStringUTFChars(jAccessToken, nullptr);
- }
+ const char *charUserUuid = env->GetStringUTFChars(jUserUuid, nullptr);
+ VERIFY_NON_NULL_THROW_EXCEPTION(charUserUuid, "charUserUuid is null", JNI_EXCEPTION);
+ std::string userUuid(charUserUuid);
+ env->ReleaseStringUTFChars(jUserUuid, charUserUuid);
+
+ const char *charAccessToken = env->GetStringUTFChars(jAccessToken, nullptr);
+ VERIFY_NON_NULL_THROW_EXCEPTION(charAccessToken, "charAccessToken is null", JNI_EXCEPTION);
+ std::string accessToken(charAccessToken);
+ env->ReleaseStringUTFChars(jAccessToken, charAccessToken);
try
{
userUuid,
accessToken,
jListener);
-
if (OC_STACK_OK != result)
{
ThrowOcException(result, "OcAccountManager_signIn");
/*
* Class: org_iotivity_base_OcAccountManager
* Method: signOut0
-* Signature: (Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
+* Signature: (Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
*/
JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_signOut0
- (JNIEnv *env, jobject thiz, jobject jListener)
+ (JNIEnv *env, jobject thiz, jstring jAccessToken, jobject jListener)
{
LOGD("OcAccountManager_signOut");
- if (!jListener)
- {
- ThrowOcException(OC_STACK_INVALID_PARAM, "onPostListener cannot be null");
- return;
- }
+ VERIFY_NON_NULL_THROW_EXCEPTION(jAccessToken, "accessToken cannot be null",
+ OC_STACK_INVALID_PARAM);
+ VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
+ OC_STACK_INVALID_PARAM);
JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
thiz);
return;
}
+ const char *charAccessToken = env->GetStringUTFChars(jAccessToken, nullptr);
+ VERIFY_NON_NULL_THROW_EXCEPTION(charAccessToken, "charAccessToken is null", JNI_EXCEPTION);
+ std::string accessToken(charAccessToken);
+ env->ReleaseStringUTFChars(jAccessToken, charAccessToken);
+
try
{
OCStackResult result = accountManager->signOut(env,
+ accessToken,
jListener);
-
if (OC_STACK_OK != result)
{
ThrowOcException(result, "OcAccountManager_signOut");
/*
* Class: org_iotivity_base_OcAccountManager
* Method: refreshAccessToken0
-* Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
+* Signature: (Ljava/lang/String;Ljava/lang/String;
+* Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
*/
JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_refreshAccessToken0
(JNIEnv *env, jobject thiz, jstring jUserUuid, jstring jRefreshAccessToken, jobject jListener)
{
LOGD("OcAccountManager_refreshAccessToken");
- if (!jListener)
- {
- ThrowOcException(OC_STACK_INVALID_PARAM, "onPostListener cannot be null");
- return;
- }
+ VERIFY_NON_NULL_THROW_EXCEPTION(jUserUuid, "userUuid cannot be null", OC_STACK_INVALID_PARAM);
+ VERIFY_NON_NULL_THROW_EXCEPTION(jRefreshAccessToken, "refreshAccessToken cannot be null",
+ OC_STACK_INVALID_PARAM);
+ VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
+ OC_STACK_INVALID_PARAM);
JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
thiz);
return;
}
- std::string userUuid;
- std::string refreshAccessToken;
- if (jUserUuid)
- {
- userUuid = env->GetStringUTFChars(jUserUuid, nullptr);
- }
- if (jRefreshAccessToken)
- {
- refreshAccessToken = env->GetStringUTFChars(jRefreshAccessToken, nullptr);
- }
+ const char *charUserUuid = env->GetStringUTFChars(jUserUuid, nullptr);
+ VERIFY_NON_NULL_THROW_EXCEPTION(charUserUuid, "charUserUuid is null", JNI_EXCEPTION);
+ std::string userUuid(charUserUuid);
+ env->ReleaseStringUTFChars(jUserUuid, charUserUuid);
+
+ const char *charRefreshAccessToken = env->GetStringUTFChars(jRefreshAccessToken, nullptr);
+ VERIFY_NON_NULL_THROW_EXCEPTION(charRefreshAccessToken, "charRefreshAccessToken is null",
+ JNI_EXCEPTION);
+ std::string refreshAccessToken(charRefreshAccessToken);
+ env->ReleaseStringUTFChars(jRefreshAccessToken, charRefreshAccessToken);
try
{
userUuid,
refreshAccessToken,
jListener);
-
if (OC_STACK_OK != result)
{
ThrowOcException(result, "OcAccountManager_refreshAccessToken");
(JNIEnv *env, jobject thiz, jstring jUserUuid, jobject jListener)
{
LOGD("OcAccountManager_searchUser");
- if (!jListener)
- {
- ThrowOcException(OC_STACK_INVALID_PARAM, "onGetListener cannot be null");
- return;
- }
+ VERIFY_NON_NULL_THROW_EXCEPTION(jUserUuid, "userUuid cannot be null", OC_STACK_INVALID_PARAM);
+ VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onGetListener cannot be null",
+ OC_STACK_INVALID_PARAM);
JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
thiz);
return;
}
- std::string userUuid;
- if (jUserUuid)
- {
- userUuid = env->GetStringUTFChars(jUserUuid, nullptr);
- }
+ const char *charUserUuid = env->GetStringUTFChars(jUserUuid, nullptr);
+ VERIFY_NON_NULL_THROW_EXCEPTION(charUserUuid, "charUserUuid is null", JNI_EXCEPTION);
+ std::string userUuid(charUserUuid);
+ env->ReleaseStringUTFChars(jUserUuid, charUserUuid);
try
{
OCStackResult result = accountManager->searchUser(env,
userUuid,
jListener);
-
if (OC_STACK_OK != result)
{
ThrowOcException(result, "OcAccountManager_searchUser");
(JNIEnv *env, jobject thiz, jobject jQueryMap, jobject jListener)
{
LOGD("OcAccountManager_searchUser");
- if (!jListener)
- {
- ThrowOcException(OC_STACK_INVALID_PARAM, "onGetListener cannot be null");
- return;
- }
- if (!jQueryMap)
- {
- ThrowOcException(OC_STACK_INVALID_PARAM, "queryMap cannot be null");
- return;
- }
+ VERIFY_NON_NULL_THROW_EXCEPTION(jQueryMap, "queryMap cannot be null", OC_STACK_INVALID_PARAM);
+ VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onGetListener cannot be null",
+ OC_STACK_INVALID_PARAM);
JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
thiz);
OCStackResult result = accountManager->searchUser(env,
queryMap,
jListener);
-
if (OC_STACK_OK != result)
{
ThrowOcException(result, "OcAccountManager_searchUser");
/*
* Class: org_iotivity_base_OcAccountManager
* Method: deleteDevice0
-* Signature: (Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/onDeleteListener;)V
+* Signature: (Ljava/lang/String;Ljava/lang/String;
+* Lorg/iotivity/base/OcAccountManager/onDeleteListener;)V
*/
JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_deleteDevice0
- (JNIEnv *env, jobject thiz, jstring jDeviceId, jobject jListener)
+ (JNIEnv *env, jobject thiz, jstring jAccessToken, jstring jDeviceId, jobject jListener)
{
LOGD("OcAccountManager_deleteDevice");
- if (!jListener)
- {
- ThrowOcException(OC_STACK_INVALID_PARAM, "onDeleteListener cannot be null");
- return;
- }
+ VERIFY_NON_NULL_THROW_EXCEPTION(jAccessToken, "accessToken cannot be null",
+ OC_STACK_INVALID_PARAM);
+ VERIFY_NON_NULL_THROW_EXCEPTION(jDeviceId, "deviceId cannot be null", OC_STACK_INVALID_PARAM);
+ VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onDeleteListener cannot be null",
+ OC_STACK_INVALID_PARAM);
JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
thiz);
return;
}
- std::string deviceId;
- if (jDeviceId)
- {
- deviceId = env->GetStringUTFChars(jDeviceId, nullptr);
- }
+ const char *charAccessToken = env->GetStringUTFChars(jAccessToken, nullptr);
+ VERIFY_NON_NULL_THROW_EXCEPTION(charAccessToken, "charAccessToken is null", JNI_EXCEPTION);
+ std::string accessToken(charAccessToken);
+ env->ReleaseStringUTFChars(jAccessToken, charAccessToken);
+
+ const char *charDeviceId = env->GetStringUTFChars(jDeviceId, nullptr);
+ VERIFY_NON_NULL_THROW_EXCEPTION(charDeviceId, "charDeviceId is null", JNI_EXCEPTION);
+ std::string deviceId(charDeviceId);
+ env->ReleaseStringUTFChars(jDeviceId, charDeviceId);
try
{
OCStackResult result = accountManager->deleteDevice(env,
+ accessToken,
deviceId,
jListener);
-
if (OC_STACK_OK != result)
{
ThrowOcException(result, "OcAccountManager_deleteDevice");
/*
* Class: org_iotivity_base_OcAccountManager
* Method: createGroup0
-* Signature: (Lorg/iotivity/base/AclGroupType;Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
+* Signature: (Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
*/
JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_createGroup0
- (JNIEnv *env, jobject thiz, jint groupType, jobject jListener)
+ (JNIEnv *env, jobject thiz, jobject jListener)
{
LOGD("OcAccountManager_createGroup");
- if (!jListener)
- {
- ThrowOcException(OC_STACK_INVALID_PARAM, "onPostListener cannot be null");
- return;
- }
+ VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
+ OC_STACK_INVALID_PARAM);
JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
thiz);
try
{
OCStackResult result = accountManager->createGroup(env,
- JniUtils::getAclGroupType(env, static_cast<int>(groupType)),
- jListener);
-
+ jListener);
if (OC_STACK_OK != result)
{
ThrowOcException(result, "OcAccountManager_createGroup");
/*
* Class: org_iotivity_base_OcAccountManager
-* Method: getGroupList0
-* Signature: (Lorg/iotivity/base/OcAccountManager/OnGetListener;)V
+* Method: createGroup1
+* Signature: (Ljava/util/Map;Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
*/
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_getGroupList0
- (JNIEnv *env, jobject thiz, jobject jListener)
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_createGroup1
+ (JNIEnv *env, jobject thiz, jobject jQueryMap, jobject jListener)
{
- LOGD("OcAccountManager_getGroupList");
- if (!jListener)
- {
- ThrowOcException(OC_STACK_INVALID_PARAM, "onGetListener cannot be null");
- return;
- }
+ LOGD("OcAccountManager_createGroup");
+ VERIFY_NON_NULL_THROW_EXCEPTION(jQueryMap, "queryMap cannot be null", OC_STACK_INVALID_PARAM);
+ VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
+ OC_STACK_INVALID_PARAM);
JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
thiz);
return;
}
+ QueryParamsMap queryMap;
+ JniUtils::convertJavaMapToQueryParamsMap(env, jQueryMap, queryMap);
+
try
{
- OCStackResult result = accountManager->getGroupList(env,
- jListener);
-
+ OCStackResult result = accountManager->createGroup(env,
+ queryMap,
+ jListener);
if (OC_STACK_OK != result)
{
- ThrowOcException(result, "OcAccountManager_getGroupList");
+ ThrowOcException(result, "OcAccountManager_createGroup");
}
}
catch (OCException& e)
(JNIEnv *env, jobject thiz, jstring jGroupId, jobject jListener)
{
LOGD("OcAccountManager_deleteGroup");
- if (!jListener)
- {
- ThrowOcException(OC_STACK_INVALID_PARAM, "onDeleteListener cannot be null");
- return;
- }
+ VERIFY_NON_NULL_THROW_EXCEPTION(jGroupId, "groupId cannot be null", OC_STACK_INVALID_PARAM);
+ VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onDeleteListener cannot be null",
+ OC_STACK_INVALID_PARAM);
JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
thiz);
return;
}
- std::string groupId;
- if (jGroupId)
- {
- groupId = env->GetStringUTFChars(jGroupId, nullptr);
- }
+ const char *charGroupId = env->GetStringUTFChars(jGroupId, nullptr);
+ VERIFY_NON_NULL_THROW_EXCEPTION(charGroupId, "charGroupId is null", JNI_EXCEPTION);
+ std::string groupId(charGroupId);
+ env->ReleaseStringUTFChars(jGroupId, charGroupId);
try
{
OCStackResult result = accountManager->deleteGroup(env,
groupId,
jListener);
-
if (OC_STACK_OK != result)
{
ThrowOcException(result, "OcAccountManager_deleteGroup");
/*
* Class: org_iotivity_base_OcAccountManager
-* Method: joinGroup0
-* Signature: (Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
+* Method: getGroupInfoAll0
+* Signature: (Lorg/iotivity/base/OcAccountManager/OnGetListener;)V
*/
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_joinGroup0
- (JNIEnv *env, jobject thiz, jstring jGroupId, jobject jListener)
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_getGroupInfoAll0
+ (JNIEnv *env, jobject thiz, jobject jListener)
{
- LOGD("OcAccountManager_joinGroup");
- if (!jListener)
- {
- ThrowOcException(OC_STACK_INVALID_PARAM, "onPostListener cannot be null");
- return;
- }
+ LOGD("OcAccountManager_getGroupInfoAll");
+ VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onGetListener cannot be null",
+ OC_STACK_INVALID_PARAM);
JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
thiz);
return;
}
- std::string groupId;
- if (jGroupId)
- {
- groupId = env->GetStringUTFChars(jGroupId, nullptr);
- }
-
try
{
- OCStackResult result = accountManager->joinGroup(env,
- groupId,
- jListener);
-
+ OCStackResult result = accountManager->getGroupInfoAll(env,
+ jListener);
if (OC_STACK_OK != result)
{
- ThrowOcException(result, "OcAccountManager_joinGroup");
+ ThrowOcException(result, "OcAccountManager_getGroupInfoAll");
}
}
catch (OCException& e)
/*
* Class: org_iotivity_base_OcAccountManager
-* Method: addDeviceToGroup0
-* Signature: (Ljava/lang/String;[Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
+* Method: getGroupInfo0
+* Signature: (Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/OnGetListener;)V
*/
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_addDeviceToGroup0
- (JNIEnv *env, jobject thiz, jstring jGroupId, jobjectArray jDeviceIdArray, jobject jListener)
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_getGroupInfo0
+ (JNIEnv *env, jobject thiz, jstring jGroupId, jobject jListener)
{
- LOGD("OcAccountManager_addDeviceToGroup");
- if (!jListener)
- {
- ThrowOcException(OC_STACK_INVALID_PARAM, "onPostListener cannot be null");
- return;
- }
- if (!jDeviceIdArray)
- {
- ThrowOcException(OC_STACK_INVALID_PARAM, "deviceId cannot be null");
- return;
- }
+ LOGD("OcAccountManager_getGroupInfo");
+ VERIFY_NON_NULL_THROW_EXCEPTION(jGroupId, "groupId cannot be null", OC_STACK_INVALID_PARAM);
+ VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onGetListener cannot be null",
+ OC_STACK_INVALID_PARAM);
JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
thiz);
return;
}
- std::string groupId;
- if (jGroupId)
- {
- groupId = env->GetStringUTFChars(jGroupId, nullptr);
- }
-
- std::vector<std::string> deviceIds;
- JniUtils::convertJavaStrArrToStrVector(env, jDeviceIdArray, deviceIds);
+ const char *charGroupId = env->GetStringUTFChars(jGroupId, nullptr);
+ VERIFY_NON_NULL_THROW_EXCEPTION(charGroupId, "charGroupId is null", JNI_EXCEPTION);
+ std::string groupId(charGroupId);
+ env->ReleaseStringUTFChars(jGroupId, charGroupId);
try
{
- OCStackResult result = accountManager->addDeviceToGroup(env,
- groupId,
- deviceIds,
- jListener);
-
+ OCStackResult result = accountManager->getGroupInfo(env,
+ groupId,
+ jListener);
if (OC_STACK_OK != result)
{
- ThrowOcException(result, "OcAccountManager_addDeviceToGroup");
+ ThrowOcException(result, "OcAccountManager_getGroupInfo");
}
}
catch (OCException& e)
/*
* Class: org_iotivity_base_OcAccountManager
-* Method: getGroupInfo0
-* Signature: (Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/OnGetListener;)V
+* Method: addPropertyValueToGroup0
+* Signature: (Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;
+* Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
*/
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_getGroupInfo0
- (JNIEnv *env, jobject thiz, jstring jGroupId, jobject jListener)
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_addPropertyValueToGroup0
+ (JNIEnv *env, jobject thiz, jstring jGroupId, jobject jPropertyValue, jobject jListener)
{
- LOGD("OcAccountManager_getGroupInfo");
- if (!jListener)
- {
- ThrowOcException(OC_STACK_INVALID_PARAM, "onGetListener cannot be null");
- return;
- }
+ LOGD("OcAccountManager_addPropertyValueToGroup");
+ VERIFY_NON_NULL_THROW_EXCEPTION(jGroupId, "groupId cannot be null", OC_STACK_INVALID_PARAM);
+ VERIFY_NON_NULL_THROW_EXCEPTION(jPropertyValue, "propertyValue cannot be null",
+ OC_STACK_INVALID_PARAM);
+ VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
+ OC_STACK_INVALID_PARAM);
JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
thiz);
return;
}
- std::string groupId;
- if (jGroupId)
+ OCRepresentation *propertyValue = JniOcRepresentation::getOCRepresentationPtr(env,
+ jPropertyValue);
+ if (!propertyValue)
{
- groupId = env->GetStringUTFChars(jGroupId, nullptr);
+ return;
}
+ const char *charGroupId = env->GetStringUTFChars(jGroupId, nullptr);
+ VERIFY_NON_NULL_THROW_EXCEPTION(charGroupId, "charGroupId is null", JNI_EXCEPTION);
+ std::string groupId(charGroupId);
+ env->ReleaseStringUTFChars(jGroupId, charGroupId);
+
try
{
- OCStackResult result = accountManager->getGroupInfo(env,
- groupId,
- jListener);
+ OCStackResult result = accountManager->addPropertyValueToGroup(env,
+ groupId,
+ *propertyValue,
+ jListener);
if (OC_STACK_OK != result)
{
- ThrowOcException(result, "OcAccountManager_getGroupInfo");
+ ThrowOcException(result, "OcAccountManager_addPropertyValueToGroup");
}
}
catch (OCException& e)
/*
* Class: org_iotivity_base_OcAccountManager
-* Method: leaveGroup0
-* Signature: (Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/onDeleteListener;)V
+* Method: deletePropertyValueFromGroup0
+* Signature: (Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;
+* Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
*/
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_leaveGroup0
- (JNIEnv *env, jobject thiz, jstring jGroupId, jobject jListener)
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_deletePropertyValueFromGroup0
+ (JNIEnv *env, jobject thiz, jstring jGroupId, jobject jPropertyValue, jobject jListener)
{
- LOGD("OcAccountManager_leaveGroup");
- if (!jListener)
- {
- ThrowOcException(OC_STACK_INVALID_PARAM, "onDeleteListener cannot be null");
- return;
- }
+ LOGD("OcAccountManager_deletePropertyValueFromGroup");
+ VERIFY_NON_NULL_THROW_EXCEPTION(jGroupId, "groupId cannot be null", OC_STACK_INVALID_PARAM);
+ VERIFY_NON_NULL_THROW_EXCEPTION(jPropertyValue, "propertyValue cannot be null",
+ OC_STACK_INVALID_PARAM);
+ VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
+ OC_STACK_INVALID_PARAM);
JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
thiz);
return;
}
- std::string groupId;
- if (jGroupId)
+ OCRepresentation *propertyValue = JniOcRepresentation::getOCRepresentationPtr(env,
+ jPropertyValue);
+ if (!propertyValue)
{
- groupId = env->GetStringUTFChars(jGroupId, nullptr);
+ return;
}
+ const char *charGroupId = env->GetStringUTFChars(jGroupId, nullptr);
+ VERIFY_NON_NULL_THROW_EXCEPTION(charGroupId, "charGroupId is null", JNI_EXCEPTION);
+ std::string groupId(charGroupId);
+ env->ReleaseStringUTFChars(jGroupId, charGroupId);
+
try
{
- OCStackResult result = accountManager->leaveGroup(env,
- groupId,
- jListener);
+ OCStackResult result = accountManager->deletePropertyValueFromGroup(env,
+ groupId,
+ *propertyValue,
+ jListener);
if (OC_STACK_OK != result)
{
- ThrowOcException(result, "OcAccountManager_leaveGroup");
+ ThrowOcException(result, "OcAccountManager_deletePropertyValueFromGroup");
}
}
catch (OCException& e)
/*
* Class: org_iotivity_base_OcAccountManager
-* Method: deleteDeviceFromGroup0
-* Signature: (Ljava/lang/String;[Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/onDeleteListener;)V
+* Method: updatePropertyValueOnGroup0
+* Signature: (Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;
+* Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
*/
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_deleteDeviceFromGroup0
- (JNIEnv *env, jobject thiz, jstring jGroupId, jobjectArray jDeviceIdArray, jobject jListener)
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_updatePropertyValueOnGroup0
+ (JNIEnv *env, jobject thiz, jstring jGroupId, jobject jPropertyValue, jobject jListener)
{
- LOGD("OcAccountManager_deleteDeviceFromGroup");
- if (!jListener)
- {
- ThrowOcException(OC_STACK_INVALID_PARAM, "onDeleteListener cannot be null");
- return;
- }
- if (!jDeviceIdArray)
- {
- ThrowOcException(OC_STACK_INVALID_PARAM, "deviceId cannot be null");
- return;
- }
+ LOGD("OcAccountManager_updatePropertyValueOnGroup");
+ VERIFY_NON_NULL_THROW_EXCEPTION(jGroupId, "groupId cannot be null", OC_STACK_INVALID_PARAM);
+ VERIFY_NON_NULL_THROW_EXCEPTION(jPropertyValue, "propertyValue cannot be null",
+ OC_STACK_INVALID_PARAM);
+ VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
+ OC_STACK_INVALID_PARAM);
JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
thiz);
return;
}
- std::string groupId;
- if (jGroupId)
+ OCRepresentation *propertyValue = JniOcRepresentation::getOCRepresentationPtr(env,
+ jPropertyValue);
+ if (!propertyValue)
{
- groupId = env->GetStringUTFChars(jGroupId, nullptr);
+ return;
}
- std::vector<std::string> deviceIds;
- JniUtils::convertJavaStrArrToStrVector(env, jDeviceIdArray, deviceIds);
+ const char *charGroupId = env->GetStringUTFChars(jGroupId, nullptr);
+ VERIFY_NON_NULL_THROW_EXCEPTION(charGroupId, "charGroupId is null", JNI_EXCEPTION);
+ std::string groupId(charGroupId);
+ env->ReleaseStringUTFChars(jGroupId, charGroupId);
try
{
- OCStackResult result = accountManager->deleteDeviceFromGroup(env,
- groupId,
- deviceIds,
- jListener);
+ OCStackResult result = accountManager->updatePropertyValueOnGroup(env,
+ groupId,
+ *propertyValue,
+ jListener);
if (OC_STACK_OK != result)
{
- ThrowOcException(result, "OcAccountManager_deleteDeviceFromGroup");
+ ThrowOcException(result, "OcAccountManager_updatePropertyValueOnGroup");
}
}
catch (OCException& e)
/*
* Class: org_iotivity_base_OcAccountManager
* Method: observeGroup0
-* Signature: (Ljava/lang/String;Lorg/iotivity/base/OcResource/OnObserveListener;)V
+* Signature: (Lorg/iotivity/base/OcResource/OnObserveListener;)V
*/
JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_observeGroup0
- (JNIEnv *env, jobject thiz, jstring jGroupId, jobject jListener)
+ (JNIEnv *env, jobject thiz, jobject jListener)
{
LOGD("OcAccountManager_observeGroup");
- if (!jListener)
- {
- ThrowOcException(OC_STACK_INVALID_PARAM, "onObserveListener cannot be null");
- return;
- }
+ VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onObserveListener cannot be null",
+ OC_STACK_INVALID_PARAM);
JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
thiz);
return;
}
- std::string groupId;
- if (jGroupId)
- {
- groupId = env->GetStringUTFChars(jGroupId, nullptr);
- }
-
try
{
OCStackResult result = accountManager->observeGroup(env,
- groupId,
jListener);
-
if (OC_STACK_OK != result)
{
ThrowOcException(result, "OcAccountManager_observeGroup");
/*
* Class: org_iotivity_base_OcAccountManager
* Method: cancelObserveGroup0
-* Signature: (Ljava/lang/String;)V
+* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_cancelObserveGroup0
- (JNIEnv *env, jobject thiz, jstring jGroupId)
+ (JNIEnv *env, jobject thiz)
{
LOGD("OcAccountManager_cancelObserveGroup");
return;
}
- std::string groupId;
- if (jGroupId)
- {
- groupId = env->GetStringUTFChars(jGroupId, nullptr);
- }
-
try
{
- OCStackResult result = accountManager->cancelObserveGroup(groupId);
-
+ OCStackResult result = accountManager->cancelObserveGroup();
if (OC_STACK_OK != result)
{
ThrowOcException(result, "OcAccountManager_cancelObserveGroup");
(JNIEnv *env, jobject thiz, jobject jListener)
{
LOGD("OcAccountManager_observeInvitation");
- if (!jListener)
- {
- ThrowOcException(OC_STACK_INVALID_PARAM, "onObserveListener cannot be null");
- return;
- }
+ VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onObserveListener cannot be null",
+ OC_STACK_INVALID_PARAM);
JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
thiz);
{
OCStackResult result = accountManager->observeInvitation(env,
jListener);
-
if (OC_STACK_OK != result)
{
ThrowOcException(result, "OcAccountManager_observeInvitation");
try
{
OCStackResult result = accountManager->cancelObserveInvitation();
-
if (OC_STACK_OK != result)
{
ThrowOcException(result, "OcAccountManager_cancelObserveInvitation");
/*
* Class: org_iotivity_base_OcAccountManager
* Method: sendInvitation0
-* Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
+* Signature: (Ljava/lang/String;Ljava/lang/String;
+* Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
*/
JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_sendInvitation0
(JNIEnv *env, jobject thiz, jstring jGroupId, jstring jUserUuid, jobject jListener)
{
LOGD("OcAccountManager_sendInvitation");
- if (!jListener)
- {
- ThrowOcException(OC_STACK_INVALID_PARAM, "onPostListener cannot be null");
- return;
- }
+ VERIFY_NON_NULL_THROW_EXCEPTION(jGroupId, "groupId cannot be null", OC_STACK_INVALID_PARAM);
+ VERIFY_NON_NULL_THROW_EXCEPTION(jUserUuid, "userUuid cannot be null", OC_STACK_INVALID_PARAM);
+ VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onPostListener cannot be null",
+ OC_STACK_INVALID_PARAM);
JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
thiz);
return;
}
- std::string groupId, userUuid;
- if (jGroupId)
- {
- groupId = env->GetStringUTFChars(jGroupId, nullptr);
- }
- if (jUserUuid)
- {
- userUuid = env->GetStringUTFChars(jUserUuid, nullptr);
- }
+ const char *charGroupId = env->GetStringUTFChars(jGroupId, nullptr);
+ VERIFY_NON_NULL_THROW_EXCEPTION(charGroupId, "charGroupId is null", JNI_EXCEPTION);
+ std::string groupId(charGroupId);
+ env->ReleaseStringUTFChars(jGroupId, charGroupId);
+
+ const char *charUserUuid = env->GetStringUTFChars(jUserUuid, nullptr);
+ VERIFY_NON_NULL_THROW_EXCEPTION(charUserUuid, "charUserUuid is null", JNI_EXCEPTION);
+ std::string userUuid(charUserUuid);
+ env->ReleaseStringUTFChars(jUserUuid, charUserUuid);
try
{
groupId,
userUuid,
jListener);
-
if (OC_STACK_OK != result)
{
ThrowOcException(result, "OcAccountManager_sendInvitation");
/*
* Class: org_iotivity_base_OcAccountManager
* Method: cancelInvitation0
-* Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/onDeleteListener;)V
+* Signature: (Ljava/lang/String;Ljava/lang/String;
+* Lorg/iotivity/base/OcAccountManager/onDeleteListener;)V
*/
JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_cancelInvitation0
(JNIEnv *env, jobject thiz, jstring jGroupId, jstring jUserUuid, jobject jListener)
{
LOGD("OcAccountManager_cancelInvitation");
- if (!jListener)
- {
- ThrowOcException(OC_STACK_INVALID_PARAM, "onDeleteListener cannot be null");
- return;
- }
+ VERIFY_NON_NULL_THROW_EXCEPTION(jGroupId, "groupId cannot be null", OC_STACK_INVALID_PARAM);
+ VERIFY_NON_NULL_THROW_EXCEPTION(jUserUuid, "userUuid cannot be null", OC_STACK_INVALID_PARAM);
+ VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onDeleteListener cannot be null",
+ OC_STACK_INVALID_PARAM);
JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
thiz);
return;
}
- std::string groupId, userUuid;
- if (jGroupId)
- {
- groupId = env->GetStringUTFChars(jGroupId, nullptr);
- }
- if (jUserUuid)
- {
- userUuid = env->GetStringUTFChars(jUserUuid, nullptr);
- }
+ const char *charGroupId = env->GetStringUTFChars(jGroupId, nullptr);
+ VERIFY_NON_NULL_THROW_EXCEPTION(charGroupId, "charGroupId is null", JNI_EXCEPTION);
+ std::string groupId(charGroupId);
+ env->ReleaseStringUTFChars(jGroupId, charGroupId);
+
+ const char *charUserUuid = env->GetStringUTFChars(jUserUuid, nullptr);
+ VERIFY_NON_NULL_THROW_EXCEPTION(charUserUuid, "charUserUuid is null", JNI_EXCEPTION);
+ std::string userUuid(charUserUuid);
+ env->ReleaseStringUTFChars(jUserUuid, charUserUuid);
try
{
groupId,
userUuid,
jListener);
-
if (OC_STACK_OK != result)
{
ThrowOcException(result, "OcAccountManager_cancelInvitation");
/*
* Class: org_iotivity_base_OcAccountManager
-* Method: deleteInvitation0
-* Signature: (Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/onDeleteListener;)V
+* Method: replyToInvitation0
+* Signature: (Ljava/lang/String;ZLorg/iotivity/base/OcAccountManager/onDeleteListener;)V
*/
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_deleteInvitation0
- (JNIEnv *env, jobject thiz, jstring jGroupId, jobject jListener)
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_replyToInvitation0
+ (JNIEnv *env, jobject thiz, jstring jGroupId, jboolean jAccept, jobject jListener)
{
- LOGD("OcAccountManager_deleteInvitation");
- if (!jListener)
- {
- ThrowOcException(OC_STACK_INVALID_PARAM, "onDeleteListener cannot be null");
- return;
- }
+ LOGD("OcAccountManager_replyToInvitation");
+ VERIFY_NON_NULL_THROW_EXCEPTION(jGroupId, "groupId cannot be null", OC_STACK_INVALID_PARAM);
+ VERIFY_NON_NULL_THROW_EXCEPTION(jListener, "onDeleteListener cannot be null",
+ OC_STACK_INVALID_PARAM);
JniOcAccountManager *accountManager = JniOcAccountManager::getJniOcAccountManagerPtr(env,
thiz);
return;
}
- std::string groupId;
- if (jGroupId)
- {
- groupId = env->GetStringUTFChars(jGroupId, nullptr);
- }
+ const char *charGroupId = env->GetStringUTFChars(jGroupId, nullptr);
+ VERIFY_NON_NULL_THROW_EXCEPTION(charGroupId, "charGroupId is null", JNI_EXCEPTION);
+ std::string groupId(charGroupId);
+ env->ReleaseStringUTFChars(jGroupId, charGroupId);
try
{
- OCStackResult result = accountManager->deleteInvitation(env,
- groupId,
- jListener);
-
+ OCStackResult result = accountManager->replyToInvitation(env,
+ groupId,
+ static_cast<bool>(jAccept),
+ jListener);
if (OC_STACK_OK != result)
{
- ThrowOcException(result, "OcAccountManager_deleteInvitation");
+ ThrowOcException(result, "OcAccountManager_replyToInvitation");
}
}
catch (OCException& e)
const QueryParamsMap& options, jobject jListener);
OCStackResult signIn(JNIEnv* env, const std::string& userUuid, const std::string& accessToken,
jobject jListener);
- OCStackResult signOut(JNIEnv* env, jobject jListener);
+ OCStackResult signOut(JNIEnv* env, const std::string& accessToken, jobject jListener);
OCStackResult refreshAccessToken(JNIEnv* env, const std::string& userUuid,
const std::string& refreshToken, jobject jListener);
OCStackResult searchUser(JNIEnv* env, const std::string& userUuid, jobject jListener);
OCStackResult searchUser(JNIEnv* env, const QueryParamsMap& queryMap, jobject jListener);
- OCStackResult deleteDevice(JNIEnv* env, const std::string& deviceId, jobject jListener);
- OCStackResult createGroup(JNIEnv* env, AclGroupType groupType, jobject jListener);
- OCStackResult getGroupList(JNIEnv* env, jobject jListener);
+ OCStackResult deleteDevice(JNIEnv* env, const std::string& accessToken,
+ const std::string& deviceId, jobject jListener);
+ OCStackResult createGroup(JNIEnv* env, jobject jListener);
+ OCStackResult createGroup(JNIEnv* env, const QueryParamsMap& queryMap, jobject jListener);
OCStackResult deleteGroup(JNIEnv* env, const std::string& groupId, jobject jListener);
- OCStackResult joinGroup(JNIEnv* env, const std::string& groupId, jobject jListener);
- OCStackResult addDeviceToGroup(JNIEnv* env, const std::string& groupId,
- const std::vector<std::string>& deviceId, jobject jListener);
+ OCStackResult getGroupInfoAll(JNIEnv* env, jobject jListener);
OCStackResult getGroupInfo(JNIEnv* env, const std::string& groupId, jobject jListener);
- OCStackResult leaveGroup(JNIEnv* env, const std::string& groupId, jobject jListener);
- OCStackResult deleteDeviceFromGroup(JNIEnv* env, const std::string& groupId,
- const std::vector<std::string>& deviceId,
- jobject jListener);
- OCStackResult observeGroup(JNIEnv* env, const std::string& groupId, jobject jListener);
- OCStackResult cancelObserveGroup(const std::string& groupId);
+ OCStackResult addPropertyValueToGroup(JNIEnv* env, const std::string& groupId,
+ const OCRepresentation& propertyValue, jobject jListener);
+ OCStackResult deletePropertyValueFromGroup(JNIEnv* env, const std::string& groupId,
+ const OCRepresentation& propertyValue, jobject jListener);
+ OCStackResult updatePropertyValueOnGroup(JNIEnv* env, const std::string& groupId,
+ const OCRepresentation& propertyValue, jobject jListener);
+ OCStackResult observeGroup(JNIEnv* env, jobject jListener);
+ OCStackResult cancelObserveGroup();
OCStackResult observeInvitation(JNIEnv* env, jobject jListener);
OCStackResult cancelObserveInvitation();
OCStackResult sendInvitation(JNIEnv* env, const std::string& groupId,
const std::string& userUuid, jobject jListener);
OCStackResult cancelInvitation(JNIEnv* env, const std::string& groupId,
const std::string& userUuid, jobject jListener);
- OCStackResult deleteInvitation(JNIEnv* env, const std::string& groupId, jobject jListener);
+ OCStackResult replyToInvitation(JNIEnv* env, const std::string& groupId, const bool accept,
+ jobject jListener);
JniOnGetListener* addOnGetListener(JNIEnv* env, jobject jListener);
JniOnPostListener* addOnPostListener(JNIEnv* env, jobject jListener);
* Signature: (Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/OnGetListener;)V
*/
JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_searchUser0
- (JNIEnv *env, jobject thiz, jstring juserUuid, jobject jListener);
+ (JNIEnv *, jobject, jstring, jobject);
/*
* Class: org_iotivity_base_OcAccountManager
* Signature: (Ljava/util/Map;Lorg/iotivity/base/OcAccountManager/OnGetListener;)V
*/
JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_searchUser1
- (JNIEnv *env, jobject thiz, jobject jQueryMap, jobject jListener);
+ (JNIEnv *, jobject, jobject, jobject);
/*
* Class: org_iotivity_base_OcAccountManager
* Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/onDeleteListener;)V
*/
JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_deleteDevice0
- (JNIEnv *env, jobject thiz, jstring jDeviceId, jobject jListener);
+ (JNIEnv *, jobject, jstring, jstring, jobject);
/*
* Class: org_iotivity_base_OcAccountManager
* Method: createGroup0
- * Signature: (Lorg/iotivity/base/AclGroupType;Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
+ * Signature: (Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
*/
JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_createGroup0
- (JNIEnv *env, jobject thiz, jint groupType, jobject jListener);
+ (JNIEnv *, jobject, jobject);
/*
* Class: org_iotivity_base_OcAccountManager
- * Method: getGroupList0
- * Signature: (Lorg/iotivity/base/OcAccountManager/OnGetListener;)V
+ * Method: createGroup1
+ * Signature: (Ljava/util/Map;Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
*/
- JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_getGroupList0
- (JNIEnv *env, jobject thiz, jobject jListener);
+ JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_createGroup1
+ (JNIEnv *, jobject, jobject, jobject);
/*
* Class: org_iotivity_base_OcAccountManager
* Signature: (Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/onDeleteListener;)V
*/
JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_deleteGroup0
- (JNIEnv *env, jobject thiz, jstring jGroupId, jobject jListener);
+ (JNIEnv *, jobject, jstring, jobject);
/*
* Class: org_iotivity_base_OcAccountManager
- * Method: joinGroup0
- * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
+ * Method: getGroupInfoAll0
+ * Signature: (Lorg/iotivity/base/OcAccountManager/OnGetListener;)V
*/
- JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_joinGroup0
- (JNIEnv *env, jobject thiz, jstring jGroupId, jobject jListener);
+ JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_getGroupInfoAll0
+ (JNIEnv *, jobject, jobject);
/*
* Class: org_iotivity_base_OcAccountManager
- * Method: addDeviceToGroup0
- * Signature: (Ljava/lang/String;[Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
+ * Method: getGroupInfo0
+ * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/OnGetListener;)V
*/
- JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_addDeviceToGroup0
- (JNIEnv *env, jobject thiz, jstring jGroupId, jobjectArray jDeviceIdArray, jobject jListener);
+ JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_getGroupInfo0
+ (JNIEnv *, jobject, jstring, jobject);
/*
* Class: org_iotivity_base_OcAccountManager
- * Method: getGroupInfo0
- * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/OnGetListener;)V
+ * Method: addPropertyValueToGroup0
+ * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;
+ * Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
*/
- JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_getGroupInfo0
- (JNIEnv *env, jobject thiz, jstring jGroupId, jobject jListener);
+ JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_addPropertyValueToGroup0
+ (JNIEnv *, jobject, jstring, jobject, jobject);
/*
* Class: org_iotivity_base_OcAccountManager
- * Method: leaveGroup0
- * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/onDeleteListener;)V
+ * Method: deletePropertyValueFromGroup0
+ * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;
+ * Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
*/
- JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_leaveGroup0
- (JNIEnv *env, jobject thiz, jstring jGroupId, jobject jListener);
+ JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_deletePropertyValueFromGroup0
+ (JNIEnv *, jobject, jstring, jobject, jobject);
/*
* Class: org_iotivity_base_OcAccountManager
- * Method: deleteDeviceFromGroup0
- * Signature: (Ljava/lang/String;[Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/onDeleteListener;)V
+ * Method: updatePropertyValueOnGroup0
+ * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;
+ * Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
*/
- JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_deleteDeviceFromGroup0
- (JNIEnv *env, jobject thiz, jstring jGroupId, jobjectArray jDeviceIdArray, jobject jListener);
+ JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_updatePropertyValueOnGroup0
+ (JNIEnv *, jobject, jstring, jobject, jobject);
/*
* Class: org_iotivity_base_OcAccountManager
* Method: observeGroup0
- * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcResource/OnObserveListener;)V
+ * Signature: (Lorg/iotivity/base/OcResource/OnObserveListener;)V
*/
JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_observeGroup0
- (JNIEnv *env, jobject thiz, jstring jGroupId, jobject jListener);
+ (JNIEnv *, jobject, jobject);
/*
* Class: org_iotivity_base_OcAccountManager
* Method: cancelObserveGroup0
- * Signature: (Ljava/lang/String;)V
+ * Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_cancelObserveGroup0
- (JNIEnv *env, jobject thiz, jstring jGroupId);
+ (JNIEnv *, jobject);
/*
* Class: org_iotivity_base_OcAccountManager
* Signature: (Lorg/iotivity/base/OcResource/OnObserveListener;)V
*/
JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_observeInvitation0
- (JNIEnv *env, jobject thiz, jobject jListener);
+ (JNIEnv *, jobject, jobject);
/*
* Class: org_iotivity_base_OcAccountManager
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_cancelObserveInvitation0
- (JNIEnv *env, jobject thiz);
+ (JNIEnv *, jobject);
/*
* Class: org_iotivity_base_OcAccountManager
* Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/OnPostListener;)V
*/
JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_sendInvitation0
- (JNIEnv *env, jobject thiz, jstring jGroupId, jstring jUserUuid, jobject jListener);
+ (JNIEnv *, jobject, jstring, jstring, jobject);
/*
* Class: org_iotivity_base_OcAccountManager
* Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/onDeleteListener;)V
*/
JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_cancelInvitation0
- (JNIEnv *env, jobject thiz, jstring jGroupId, jstring jUserUuid, jobject jListener);
+ (JNIEnv *, jobject, jstring, jstring, jobject);
/*
* Class: org_iotivity_base_OcAccountManager
- * Method: deleteInvitation0
- * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcAccountManager/onDeleteListener;)V
+ * Method: replyToInvitation0
+ * Signature: (Ljava/lang/String;ZLorg/iotivity/base/OcAccountManager/onDeleteListener;)V
*/
- JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_deleteInvitation0
- (JNIEnv *env, jobject thiz, jstring jGroupId, jobject jListener);
+ JNIEXPORT void JNICALL Java_org_iotivity_base_OcAccountManager_replyToInvitation0
+ (JNIEnv *, jobject, jstring, jboolean, jobject);
#ifdef __cplusplus
}
return OC::ObserveType::ObserveAll;
};
}
-#ifdef WITH_CLOUD
- static OC::AclGroupType getAclGroupType(JNIEnv *env, int type)
- {
- switch (type)
- {
- case 0:
- return OC::AclGroupType::PUBLIC;
- case 1:
- return OC::AclGroupType::PRIVATE;
- default:
- ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected acl group type");
- return OC::AclGroupType::PUBLIC;
- };
- }
-#endif
+
static OCEntityHandlerResult getOCEntityHandlerResult(JNIEnv *env, int type)
{
switch (type)
+++ /dev/null
-/*
- *******************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- */
-
-package org.iotivity.base;
-
-public enum AclGroupType {
- PUBLIC(0),
- PRIVATE(1),;
-
- private int value;
-
- private AclGroupType(int value) {
- this.value = value;
- }
-
- public int getValue() {
- return this.value;
- }
-}
OnPostListener onPostListener) throws OcException;
/**
- * overload
+ * Method for account registration to account server
*
* @param authProvider Provider name used for authentication.
* @param authCode The authorization code obtained by using an authorization server
/**
* Method for sign-out to account server
*
+ * @param accessToken Identifier of the resource obtained by account registration.
* @param onPostListener event handler The event handler will be invoked with a map of
* attribute name and values.
* @throws OcException if failure
*/
- public void signOut(OnPostListener onPostListener) throws OcException {
- this.signOut0(onPostListener);
+ public void signOut(String accessToken,
+ OnPostListener onPostListener) throws OcException {
+ this.signOut0(accessToken, onPostListener);
}
- private native void signOut0(OnPostListener onPostListener) throws OcException;
+ private native void signOut0(String accessToken,
+ OnPostListener onPostListener) throws OcException;
/**
* Method to refresh access token to account server
*
* @param userUuid Identifier of the user to get information.
* @param onGetListener The event handler will be invoked with a map of attribute name and
- * values. The event handler will also have the result from this Get
- * operation This will have error codes
+ * values. It will also have the result from this Get operation.
* @throws OcException if failure
*/
public void searchUser(String userUuid,
OnGetListener onGetListener) throws OcException;
/**
- * Overload
+ * Method to get information of the user to account server
*
* @param queryMap Map which can have the query key and value for specific users.
* account server can response information of more than one user.
* @param onGetListener The event handler will be invoked with a map of attribute name and
- * values. The event handler will also have the result from this Get
- * operation This will have error codes
+ * values. It will also have the result from this Get operation.
* @throws OcException if failure
*/
public void searchUser(Map<String, String> queryMap,
/**
* Method to delete the device registered on the account signed-in
*
+ * @param accessToken Identifier of the resource obtained by account registration.
* @param deviceId Device ID to delete.
* @param onDeleteListener event handler The event handler will have headerOptionList
* @throws OcException if failure
*/
- public void deleteDevice(String deviceId,
+ public void deleteDevice(String accessToken,
+ String deviceId,
OnDeleteListener onDeleteListener) throws OcException {
- this.deleteDevice0(deviceId, onDeleteListener);
+ this.deleteDevice0(accessToken, deviceId, onDeleteListener);
}
- private native void deleteDevice0(String deviceId,
+ private native void deleteDevice0(String accessToken,
+ String deviceId,
OnDeleteListener onDeleteListener) throws OcException;
/**
* Method to delete the device registered on the account signed-in
*
- * @param groupType Group type that can be used for referencing default group ACL creation.
* @param onPostListener event handler The event handler will be invoked with a map of
* attribute name and values.
* @throws OcException if failure
*/
- public void createGroup(AclGroupType groupType,
- OnPostListener onPostListener) throws OcException {
- this.createGroup0(groupType.getValue(), onPostListener);
+ public void createGroup(OnPostListener onPostListener) throws OcException {
+ this.createGroup0(onPostListener);
}
- private native void createGroup0(int groupType,
- OnPostListener onPostListener) throws OcException;
+ private native void createGroup0(OnPostListener onPostListener) throws OcException;
/**
- * Method to get a list of groups joined from account server
- *
- * @param onGetListener The event handler will be invoked with a map of attribute name and
- * values. The event handler will also have the result from this Get
- * operation This will have error codes
+ * Method to delete the device registered on the account signed-in
*
- * @return Returns ::OC_STACK_OK if success
+ * @param queryMap Map that has optional properties and values to create a group.
+ * Defined properties on the OCF spec are [gname, parent] so far.
+ * (2016/10/19)
+ * @param onPostListener event handler The event handler will be invoked with a map of
+ * attribute name and values.
+ * @throws OcException if failure
*/
- public void getGroupList(OnGetListener onGetListener) throws OcException {
- this.getGroupList0(onGetListener);
+ public void createGroup(Map<String, String> queryMap,
+ OnPostListener onPostListener) throws OcException {
+ this.createGroup1(queryMap, onPostListener);
}
- private native void getGroupList0(OnGetListener onGetListener) throws OcException;
+ private native void createGroup1(Map<String, String> queryMap,
+ OnPostListener onPostListener) throws OcException;
/**
- * Method to delete the group from account server
+ * Method to delete the group from account server.
*
* @param groupId Group ID to delete.
* @param onDeleteListener event handler The event handler will have headerOptionList.
- *
- * @return Returns ::OC_STACK_OK if success
+ * @throws OcException if failure
*/
public void deleteGroup(String groupId,
OnDeleteListener onDeleteListener) throws OcException {
OnDeleteListener onDeleteListener) throws OcException;
/**
- * Method to join the group on account server
+ * Method to get infomation of all your group from account server.
*
- * @param groupId Group ID to join
- * @param onPostListener event handler The event handler will be invoked with a map of
- * attribute name and values.
- *
- * @return Returns ::OC_STACK_OK if success
- */
- public void joinGroup(String groupId,
- OnPostListener onPostListener) throws OcException {
- this.joinGroup0(groupId, onPostListener);
- }
-
- private native void joinGroup0(String groupId,
- OnPostListener onPostListener) throws OcException;
-
- /**
- * Method to add devices to the group on account server
- *
- * @param groupId Group ID to add devices.
- * @param deviceId List of devices to add.
- * @param onPostListener event handler The event handler will be invoked with a map of
- * attribute name and values.
- *
- * @return Returns ::OC_STACK_OK if success
+ * @param onGetListener The event handler will be invoked with a map of attribute name and
+ * values. It will also have the result from this Get operation.
+ * @throws OcException if failure
*/
- public void addDeviceToGroup(String groupId,
- List<String> deviceId,
- OnPostListener onPostListener) throws OcException {
- this.addDeviceToGroup0(groupId, deviceId.toArray(new String[deviceId.size()]),
- onPostListener);
+ public void getGroupInfoAll(OnGetListener onGetListener) throws OcException {
+ this.getGroupInfoAll0(onGetListener);
}
- private native void addDeviceToGroup0(String groupId,
- String[] deviceId,
- OnPostListener onPostListener) throws OcException;
+ private native void getGroupInfoAll0(OnGetListener onGetListener) throws OcException;
/**
- * Method to get information of the group from account server
+ * Method to get information of the specific group from account server.
*
* @param groupId Group ID to get information.
* @param onGetListener The event handler will be invoked with a map of attribute name and
- * values. The event handler will also have the result from this Get
- * operation This will have error codes
- *
- * @return Returns ::OC_STACK_OK if success
+ * values. It will also have the result from this Get operation.
+ * @throws OcException if failure
*/
- public void getGroupInfo(String groupId,
- OnGetListener onGetListener) throws OcException {
+ public void getGroupInfo(String groupId, OnGetListener onGetListener) throws OcException {
this.getGroupInfo0(groupId, onGetListener);
}
OnGetListener onGetListener) throws OcException;
/**
- * Method to leave the group joined on account server
- *
- * @param groupId Group ID to leave.
- * @param onDeleteListener event handler The event handler will have headerOptionList.
+ * Method to add values for properties to the group on account server.
*
- * @return Returns ::OC_STACK_OK if success
+ * @param groupId Group ID to add property values.
+ * @param propertyValue OCRepresentation info that has pairs of property and value.
+ * Defined properties on the OCF spec are [members, masters, devices,
+ * resources, links] so far. (2016/10/19)
+ * @param onPostListener event handler The event handler will be invoked with a map of
+ * attribute name and values.
+ * @throws OcException if failure
*/
- public void leaveGroup(String groupId,
- OnDeleteListener onDeleteListener) throws OcException {
- this.leaveGroup0(groupId, onDeleteListener);
+ public void addPropertyValueToGroup(String groupId,
+ OcRepresentation propertyValue,
+ OnPostListener onPostListener) throws OcException {
+ this.addPropertyValueToGroup0(groupId, propertyValue, onPostListener);
}
- private native void leaveGroup0(String groupId,
- OnDeleteListener onDeleteListener) throws OcException;
+ private native void addPropertyValueToGroup0(String groupId,
+ OcRepresentation propertyValue,
+ OnPostListener onPostListener) throws OcException;
/**
- * Method to delete devices from the group on account server
- *
- * @param groupId Group ID to delete devices.
- * @param deviceId List of devices to delete.
- * @param onDeleteListener event handler The event handler will have headerOptionList.
+ * Method to delete values for properties from the group on account server.
*
- * @return Returns ::OC_STACK_OK if success
+ * @param groupId Group ID to add property values.
+ * @param propertyValue OCRepresentation info that has pairs of property and value.
+ * Defined properties on the OCF spec are [members, masters, devices,
+ * resources, links] so far. (2016/10/19)
+ * @param onPostListener event handler The event handler will be invoked with a map of
+ * attribute name and values.
+ * @throws OcException if failure
*/
- public void deleteDeviceFromGroup(String groupId,
- List<String> deviceId,
- OnDeleteListener onDeleteListener) throws OcException {
- this.deleteDeviceFromGroup0(groupId, deviceId.toArray(new String[deviceId.size()]),
- onDeleteListener);
+ public void deletePropertyValueFromGroup(String groupId,
+ OcRepresentation propertyValue,
+ OnPostListener onPostListener) throws OcException {
+ this.deletePropertyValueFromGroup0(groupId, propertyValue, onPostListener);
}
- private native void deleteDeviceFromGroup0(String groupId,
- String[] deviceId,
- OnDeleteListener onDeleteListener) throws OcException;
+ private native void deletePropertyValueFromGroup0(String groupId,
+ OcRepresentation propertyValue,
+ OnPostListener onPostListener) throws OcException;
/**
- * Method to register observe to the group on account server
- * User can receive a notify when the group get changed (eg. new user/device added)
- *
- * @param groupId Group ID to observe.
- * @param cloudConnectHandler Callback function that will get the result of the operation.
- *
- * @return Returns ::OC_STACK_OK if success
+ * Method to update values for properties on the group on account server.
+ * It completely replaces existing values for specific properties.
+ *
+ * @param groupId Group ID to add property values.
+ * @param propertyValue OCRepresentation info that has pairs of property and value.
+ * Defined properties on the OCF spec are [members, gname, owner,
+ * masters, devices, resources, latitude, longitude, radius,
+ * backgroundImage] so far. (2016/10/19)
+ * @param onPostListener event handler The event handler will be invoked with a map of
+ * attribute name and values.
+ * @throws OcException if failure
*/
- public void observeGroup(String groupId,
- OnObserveListener onObserveListener) throws OcException {
- this.observeGroup0(groupId, onObserveListener);
+ public void updatePropertyValueOnGroup(String groupId,
+ OcRepresentation propertyValue,
+ OnPostListener onPostListener) throws OcException {
+ this.updatePropertyValueOnGroup0(groupId, propertyValue, onPostListener);
}
- private native void observeGroup0(String groupId,
- OnObserveListener onObserveListener) throws OcException;
+ private native void updatePropertyValueOnGroup0(String groupId,
+ OcRepresentation propertyValue,
+ OnPostListener onPostListener) throws OcException;
/**
- * Method to cancel observe to the group on account server
- *
- * @param groupId Group ID to observe.
+ * Method to register observe to group resource on account server.
+ * You can receive a notification when any value of property get changed in the group you
+ * joined.
*
- * @return Returns ::OC_STACK_OK if success
+ * @param onObserveListener event handler The handler method will be invoked with a map
+ * of attribute name and values.
+ * @throws OcException if failure
*/
- public void cancelObserveGroup(String groupId) throws OcException {
- this.cancelObserveGroup0(groupId);
+ public void observeGroup(OnObserveListener onObserveListener) throws OcException {
+ this.observeGroup0(onObserveListener);
}
- private native void cancelObserveGroup0(String groupId) throws OcException;
+ private native void observeGroup0(OnObserveListener onObserveListener) throws OcException;
/**
- * Method to register observe to invitation resource on account server
- * User can receive a invitation which is including group ID to join
- * Once receive a invitation, user should call 'deleteInvitation' to delete a invitation
- * on account server.
- *
- * @param cloudConnectHandler Callback function that will get the result of the operation.
+ * Method to cancel observe to group resource on account server.
*
- * @return Returns ::OC_STACK_OK if success
+ * @throws OcException if failure
+ */
+ public void cancelObserveGroup() throws OcException {
+ this.cancelObserveGroup0();
+ }
+
+ private native void cancelObserveGroup0() throws OcException;
+
+ /**
+ * Method to register observe to invitation resource on account server.
+ * You can receive a notification when you send or receive a invitation.
+ * Sending a invitation will be notified as 'invite' and Receiving will be as 'invited'.
+ * If you receive a invitation from other user, you should call 'replyToInvitation' to
+ * delete the invitation on account server, otherwise it will remain on the server.
+ *
+ * @param onObserveListener event handler The handler method will be invoked with a map
+ * of attribute name and values.
+ * @throws OcException if failure
*/
public void observeInvitation(OnObserveListener onObserveListener) throws OcException {
this.observeInvitation0(onObserveListener);
/**
* Method to cancel observe to invitation resource on account server
*
- * @return Returns ::OC_STACK_OK if success
+ * @throws OcException if failure
*/
public void cancelObserveInvitation() throws OcException {
this.cancelObserveInvitation0();
private native void cancelObserveInvitation0() throws OcException;
/**
- * Method to send a invitation to invite a user into a group
+ * Method to send a invitation to invite a user into a group.
*
* @param groupId Group ID for inviting.
* @param userUuid Identifier of the user to invite.
* @param onPostListener event handler The event handler will be invoked with a map of
* attribute name and values.
- *
- * @return Returns ::OC_STACK_OK if success
+ * @throws OcException if failure
*/
public void sendInvitation(String groupId,
String userUuid,
OnPostListener onPostListener) throws OcException;
/**
- * Method to cancel a invitation on account server that user has sent
+ * Method to cancel a invitation on account server you has sent before the invited user
+ * replies.
*
* @param groupId Group ID to cancel a invitation.
* @param userUuid Identifier of the user to cancel a invitation.
* @param onDeleteListener event handler The event handler will have headerOptionList.
- *
- * @return Returns ::OC_STACK_OK if success
+ * @throws OcException if failure
*/
public void cancelInvitation(String groupId,
String userUuid,
OnDeleteListener onDeleteListener) throws OcException;
/**
- * Method to delete a invitation on account server that user has received
+ * Method to reply to the invitation that you has received.
+ * If you set accept as true, you will join the group as a member and the invitation will be
+ * deleted on account server. If false, only the invitation will be deleted.
*
* @param groupId Group ID to delete a invitation.
+ * @param accept boolean whether to join the group or not.
* @param onDeleteListener event handler The event handler will have headerOptionList.
- *
- * @return Returns ::OC_STACK_OK if success
+ * @throws OcException if failure
*/
- public void deleteInvitation(String groupId,
- OnDeleteListener onDeleteListener) throws OcException {
- this.deleteInvitation0(groupId, onDeleteListener);
+ public void replyToInvitation(String groupId,
+ boolean accept,
+ OnDeleteListener onDeleteListener) throws OcException {
+ this.replyToInvitation0(groupId, accept, onDeleteListener);
}
- private native void deleteInvitation0(String groupId,
- OnDeleteListener onDeleteListener) throws OcException;
+ private native void replyToInvitation0(String groupId,
+ boolean accept,
+ OnDeleteListener onDeleteListener) throws OcException;
/**
* An OnGetListener can be registered via the resource get call.
import android.widget.TextView;
import android.widget.Toast;
-import org.iotivity.base.AclGroupType;
import org.iotivity.base.EntityHandlerResult;
import org.iotivity.base.ErrorCode;
import org.iotivity.base.ModeType;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.regex.Pattern;
/**
private void signOut() {
try {
msg("signOut");
- mAccountManager.signOut(onSignOut);
+ mAccountManager.signOut(mAccessToken, onSignOut);
} catch (OcException e) {
e.printStackTrace();
}
private void createGroup() {
try {
msg("createGroup");
- mAccountManager.createGroup(AclGroupType.PUBLIC, onCreateGroup);
+ mAccountManager.createGroup(onCreateGroup);
} catch (OcException e) {
e.printStackTrace();
}
}
+ private void deleteGroup() {
+ if (mGroupId == null) {
+ msg("there is no any group");
+ } else {
+ try {
+ msg("deleteGroup");
+ mAccountManager.deleteGroup(mGroupId, onDeleteGroup);
+ } catch (OcException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
private void inviteUser() {
if (mGroupId == null) {
msg("there is no any group");
}
}
- private void leaveGroup() {
- try {
- if (mGroupId == null) {
- msg("there is no any group");
- } else {
- msg("leaveGroup");
- mAccountManager.leaveGroup(mGroupId, onLeaveGroup);
- }
- } catch (OcException e) {
- e.printStackTrace();
+ private void addPropertyValueToGroup() {
+ if (mGroupId == null) {
+ msg("there is no any group");
+ } else {
+ showPostPropertyValueToGroup(0);
}
}
+ private void deletePropertyValueFromGroup() {
+ if (mGroupId == null) {
+ msg("there is no any group");
+ } else {
+ showPostPropertyValueToGroup(1);
+ }
+ }
+
+ private void updatePropertyValueOnGroup() {
+ if (mGroupId == null) {
+ msg("there is no any group");
+ } else {
+ showPostPropertyValueToGroup(2);
+ }
+ }
// FOR WEB-VIEW
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
try {
msg("observeInvitation");
mAccountManager.observeInvitation(onObserveInvitation);
+ msg("observeGroup");
+ mAccountManager.observeGroup(onObserveGroup);
msg("getGroupList");
- mAccountManager.getGroupList(onGetGroupList);
+ mAccountManager.getGroupInfoAll(onGetGroupInfoAll);
} catch (OcException e) {
Log.e(TAG, e.toString());
}
}
};
- OcAccountManager.OnGetListener onGetGroupList = new OcAccountManager.OnGetListener() {
+ OcAccountManager.OnGetListener onGetGroupInfoAll = new OcAccountManager.OnGetListener() {
@Override
public void onGetCompleted(List<OcHeaderOption> list, OcRepresentation ocRepresentation) {
- msg("getGroupList was successful");
+ msg("getGroupInfoAll was successful");
try {
- String[] gidlist = ocRepresentation.getValue("gidlist");
- if (gidlist == null) {
+
+ OcRepresentation[] gidlist = ocRepresentation.getValue("groups");
+ if (gidlist == null || gidlist.length == 0) {
msg("\tgroup list is empty");
mGroupId = null;
} else {
msg("\tgroup list");
- for (String group : gidlist) {
- msg("\t\t" + group);
- mGroupId = group;
+
+ for (OcRepresentation group : gidlist) {
+ String gid = group.getValue("gid");
+ String gname = group.getValue("gname");
+ String owner = group.getValue("owner");
+
+ msg("\t\t-GroupID : " + gid);
+ msg("\t\t Group name : " + gname);
+ msg("\t\t Owner : " + owner);
+
+ String[] members = group.getValue("members");
+ if (members != null && members.length != 0) {
+ msg("\t\t members :");
+ for (String member : members) {
+ msg("\t\t\t" + member);
+ }
+ }
+
+ String[] devices = group.getValue("devices");
+ if (devices != null && devices.length != 0) {
+ msg("\t\t devices");
+ for (String device : devices) {
+ msg("\t\t\t" + device);
+ }
+ }
+
+ if (group.hasAttribute("parent")) {
+ msg("\t\t parent group : " + group.getValue("parent"));
+ }
+
+ mGroupId = gid;
}
msg("\tcurrent group is " + mGroupId);
}
@Override
public void onGetFailed(Throwable throwable) {
- msg("Failed to getGroupList");
+ msg("Failed to getGroupInfoAll");
+ if (throwable instanceof OcException) {
+ OcException ocEx = (OcException) throwable;
+ Log.e(TAG, ocEx.toString());
+ ErrorCode errCode = ocEx.getErrorCode();
+ msg("Error code: " + errCode);
+ }
+ }
+ };
+
+ OcAccountManager.OnGetListener onGetGroupInfo = new OcAccountManager.OnGetListener() {
+ @Override
+ public void onGetCompleted(List<OcHeaderOption> list, OcRepresentation ocRepresentation) {
+ msg("getGroupInfo was successful");
+
+ Map<String, Object> valueMap = ocRepresentation.getValues();
+
+ for (Map.Entry<String, Object> entry : valueMap.entrySet()) {
+ msg("\tproperty: " + entry.getKey() + " value: " + entry.getValue());
+ }
+ }
+
+ @Override
+ public void onGetFailed(Throwable throwable) {
+ msg("Failed to getGroupInfo");
if (throwable instanceof OcException) {
OcException ocEx = (OcException) throwable;
Log.e(TAG, ocEx.toString());
OcRepresentation[] sendInvitationList =
ocRepresentation.getValue("invite");
- if (sendInvitationList != null) {
+ if (sendInvitationList != null && sendInvitationList.length != 0) {
msg("\tList of invitation that I sent");
for (OcRepresentation invitation : sendInvitationList) {
String gid = invitation.getValue("gid");
OcRepresentation[] receiveInvitationList =
ocRepresentation.getValue("invited");
- if (receiveInvitationList != null) {
+ if (receiveInvitationList != null && receiveInvitationList.length != 0) {
msg("\tList of invitation that I received");
for (OcRepresentation invitation : receiveInvitationList) {
String gid = invitation.getValue("gid");
} else {
OcRepresentation[] sendInvitationList =
ocRepresentation.getValue("invite");
- if (sendInvitationList != null) {
+ if (sendInvitationList != null && sendInvitationList.length != 0) {
msg("\tList of invitation that I sent");
for (OcRepresentation invitation : sendInvitationList) {
String gid = invitation.getValue("gid");
OcRepresentation[] receivInvitationList =
ocRepresentation.getValue("invited");
- if (receivInvitationList != null) {
+ if (receivInvitationList != null && receivInvitationList.length != 0) {
msg("\tList of invitation that I received");
for (OcRepresentation invitation : receivInvitationList) {
mGroupId = invitation.getValue("gid");
}
};
- OcAccountManager.OnPostListener onJoinGroup = new OcAccountManager.OnPostListener() {
+ OcAccountManager.OnDeleteListener onDeleteGroup = new OcAccountManager.OnDeleteListener() {
@Override
- public synchronized void onPostCompleted(List<OcHeaderOption> list,
- OcRepresentation ocRepresentation) {
- msg("joinGroup was successful");
- try {
- msg("observeGroup");
- mAccountManager.observeGroup(mGroupId, onObserveGroup);
- } catch (OcException e) {
- Log.e(TAG, e.toString());
- }
+ public void onDeleteCompleted(List<OcHeaderOption> list) {
+ msg("deleteGroup was successful");
}
@Override
- public synchronized void onPostFailed(Throwable throwable) {
- msg("Failed to joinGroup");
- if (throwable instanceof OcException) {
- OcException ocEx = (OcException) throwable;
- Log.e(TAG, ocEx.toString());
- ErrorCode errCode = ocEx.getErrorCode();
- msg("Error code: " + errCode);
- }
+ public void onDeleteFailed(Throwable throwable) {
+ msg("Failed to deleteGroup");
}
};
- OcAccountManager.OnDeleteListener onDeleteInvitation = new OcAccountManager.OnDeleteListener() {
+ OcAccountManager.OnDeleteListener onReplyToInvitation = new OcAccountManager.OnDeleteListener() {
@Override
public void onDeleteCompleted(List<OcHeaderOption> list) {
- msg("deleteInvitation was successful");
+ msg("replyToInvitation was successful");
try {
- mAccountManager.getGroupList(onGetGroupList);
+ mAccountManager.getGroupInfoAll(onGetGroupInfoAll);
} catch (OcException e) {
e.printStackTrace();
}
mGroupId = ocRepresentation.getValue("gid");
msg("\tgroupId: " + mGroupId);
- msg("observeGroup");
- mAccountManager.observeGroup(mGroupId, onObserveGroup);
+ msg("getGroupInfo");
+ mAccountManager.getGroupInfo(mGroupId, onGetGroupInfo);
} catch (OcException e) {
Log.e(TAG, e.toString());
}
msg("\tGroupMasterID: " + gmid);
String[] midlist = ocRepresentation.getValue("midlist");
- if (midlist == null) {
+ if (midlist == null || midlist.length == 0) {
msg("\tMember List is empty");
} else {
msg("\tMember List(" + midlist.length + ")");
}
String[] dilist = ocRepresentation.getValue("dilist");
- if (dilist == null) {
+ if (dilist == null || dilist.length == 0) {
msg("\tDevice List is empty");
} else {
msg("\tDevice List(" + dilist.length + ")");
}
};
- OcAccountManager.OnPostListener onSendInvitation = new OcAccountManager.OnPostListener() {
+ OcAccountManager.OnPostListener onPostPropertyValue = new OcAccountManager.OnPostListener() {
@Override
public synchronized void onPostCompleted(List<OcHeaderOption> list,
OcRepresentation ocRepresentation) {
- msg("sendInvitation was successful");
+ msg("Post was successful (changed property value)");
}
@Override
public synchronized void onPostFailed(Throwable throwable) {
- msg("Failed to sendInvitation");
+ msg("Failed to Post (changed property value)");
if (throwable instanceof OcException) {
OcException ocEx = (OcException) throwable;
Log.e(TAG, ocEx.toString());
}
};
- OcAccountManager.OnDeleteListener onLeaveGroup = new OcAccountManager.OnDeleteListener() {
+ OcAccountManager.OnPostListener onSendInvitation = new OcAccountManager.OnPostListener() {
@Override
- public void onDeleteCompleted(List<OcHeaderOption> list) {
- msg("leaveGroup was successful");
- try {
- msg("getGroupList");
- mAccountManager.getGroupList(onGetGroupList);
- } catch (OcException e) {
- e.printStackTrace();
- }
+ public synchronized void onPostCompleted(List<OcHeaderOption> list,
+ OcRepresentation ocRepresentation) {
+ msg("sendInvitation was successful");
}
@Override
- public void onDeleteFailed(Throwable throwable) {
- msg("Failed to leaveGroup");
+ public synchronized void onPostFailed(Throwable throwable) {
+ msg("Failed to sendInvitation");
+ if (throwable instanceof OcException) {
+ OcException ocEx = (OcException) throwable;
+ Log.e(TAG, ocEx.toString());
+ ErrorCode errCode = ocEx.getErrorCode();
+ msg("Error code: " + errCode);
+ }
}
};
alert.show();
}
+
+ private void showPostPropertyValueToGroup(int operation) {
+ LayoutInflater layoutInflater = LayoutInflater.from(mContext);
+ View inputView = layoutInflater.inflate(R.layout.input, null);
+ AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mActivity);
+ alertDialogBuilder.setView(inputView);
+
+ final int op = operation;
+
+ final TextView textView = (TextView) inputView.getRootView().findViewById(R.id.inputView);
+ final EditText editText = (EditText) inputView.getRootView().findViewById(R.id.inputText);
+ final TextView textView2 = (TextView) inputView.getRootView().findViewById(R.id.inputView2);
+ final EditText editText2 = (EditText) inputView.getRootView().findViewById(R.id.inputText2);
+
+ textView.setText("Please enter property.");
+ textView2.setText("Please enter value(String Array).");
+ textView2.setVisibility(View.VISIBLE);
+ editText2.setVisibility(View.VISIBLE);
+
+
+ alertDialogBuilder
+ .setCancelable(true)
+ .setPositiveButton("OK", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ if (editText.getText().length() != 0 && editText2.getText().length() != 0){
+ final String property = editText.getText().toString();
+ final String value = editText2.getText().toString();
+ String[] values = {value};
+
+ try {
+ OcRepresentation propertyValue = new OcRepresentation();
+ propertyValue.setValue(property, values);
+
+ if (op == 0) {
+ msg("addPropertyValueToGroup");
+ mAccountManager.addPropertyValueToGroup(mGroupId, propertyValue, onPostPropertyValue);
+ } else if (op == 1){
+ msg("deletePropertyValueFromGroup");
+ mAccountManager.deletePropertyValueFromGroup(mGroupId, propertyValue, onPostPropertyValue);
+ } else if (op == 2){
+ msg("updatePropertyValueOnGroup");
+ mAccountManager.updatePropertyValueOnGroup(mGroupId, propertyValue, onPostPropertyValue);
+ }
+ } catch (OcException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ })
+ .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ dialog.cancel();
+ }
+ });
+
+ AlertDialog alert = alertDialogBuilder.create();
+ alert.show();
+ }
+
private void showInviteMsg(String userID) {
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mActivity);
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
try {
- msg("joinGroup");
- mAccountManager.joinGroup(mGroupId, onJoinGroup);
- msg("deleteInvitation");
- mAccountManager.deleteInvitation(mGroupId, onDeleteInvitation);
+ msg("replyToInvitation (accept:yes)");
+ mAccountManager.replyToInvitation(mGroupId, true, onReplyToInvitation);
} catch (OcException e) {
e.printStackTrace();
}
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
try {
- msg("gid: " + mGroupId);
- msg("deleteInvitation");
- mAccountManager.deleteInvitation(mGroupId, onDeleteInvitation);
+ msg("replyToInvitation (accept:no)");
+ mAccountManager.replyToInvitation(mGroupId, false, onReplyToInvitation);
} catch (OcException e) {
e.printStackTrace();
}
int viewID = view.getId();
if (mAccountManager == null && (viewID == R.id.signin_button
|| viewID == R.id.signout_button || viewID == R.id.creategroup_button
- || viewID == R.id.invite_button || viewID == R.id.leavegroup_button)) {
+ || viewID == R.id.invite_button || viewID == R.id.addpropertyvalue_button
+ || viewID == R.id.deletepropertyvalue_button || viewID == R.id.updatepropertyvalue_button)) {
mActionLog.append("Do 'SignUp' first" + EOL);
return;
}
mActionLog.append("Create Group" + EOL);
createGroup();
break;
+ case R.id.deletegroup_button:
+ mActionLog.append("Delete Group" + EOL);
+ deleteGroup();
+ break;
case R.id.invite_button:
mActionLog.append("Invite User" + EOL);
inviteUser();
break;
- case R.id.leavegroup_button:
- mActionLog.append("Leave Group" + EOL);
- leaveGroup();
+ case R.id.addpropertyvalue_button:
+ mActionLog.append("Add Property Value To Group" + EOL);
+ addPropertyValueToGroup();
+ break;
+ case R.id.deletepropertyvalue_button:
+ mActionLog.append("Delete Property Value From Group" + EOL);
+ deletePropertyValueFromGroup();
+ break;
+ case R.id.updatepropertyvalue_button:
+ mActionLog.append("Update Property Value On Group" + EOL);
+ updatePropertyValueOnGroup();
break;
// RD
Button signOutButton = (Button) rootView.findViewById(R.id.signout_button);
Button createGroupButton = (Button) rootView.findViewById(R.id.creategroup_button);
Button inviteButton = (Button) rootView.findViewById(R.id.invite_button);
- Button leaveGroupButton = (Button) rootView.findViewById(R.id.leavegroup_button);
+ Button addValueToGroup = (Button) rootView.findViewById(R.id.addpropertyvalue_button);
+ Button deleteValueFromGroup = (Button) rootView.findViewById(R.id.deletepropertyvalue_button);
+ Button updateValueOnGroup = (Button) rootView.findViewById(R.id.updatepropertyvalue_button);
setIPButton.setOnClickListener(this);
signUpButton.setOnClickListener(this);
signInButton.setOnClickListener(this);
signOutButton.setOnClickListener(this);
createGroupButton.setOnClickListener(this);
inviteButton.setOnClickListener(this);
- leaveGroupButton.setOnClickListener(this);
+ addValueToGroup.setOnClickListener(this);
+ deleteValueFromGroup.setOnClickListener(this);
+ updateValueOnGroup.setOnClickListener(this);
Button rdPubButton = (Button) rootView.findViewById(R.id.rdpub_button);
Button rdDelButton = (Button) rootView.findViewById(R.id.rddel_button);
android:text="CREATE\nGROUP" />
<Button
+ android:id="@+id/deletegroup_button"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="DELETE\nGROUP" />
+
+ <Button
android:id="@+id/invite_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="INVITE\nUSER" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_marginBottom="2dp"
+ android:gravity="center_horizontal"
+ android:orientation="horizontal">
+
+ <Button
+ android:id="@+id/addpropertyvalue_button"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="ADD VALUE\nTO GROUP" />
+
+ <Button
+ android:id="@+id/deletepropertyvalue_button"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="DELETE VALUE\nFROM GROUP" />
+
<Button
- android:id="@+id/leavegroup_button"
+ android:id="@+id/updatepropertyvalue_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
- android:text="LEAVE\nGROUP" />
+ android:text="UPDATE VALUE\nON GROUP" />
</LinearLayout>
</LinearLayout>
android:layout_height="wrap_content"
android:padding="@dimen/activity_vertical_margin" />
+ <TextView
+ android:id="@+id/inputView2"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="Input Server IP and Port"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:visibility="gone" />
+
+ <EditText
+ android:id="@+id/inputText2"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="@dimen/activity_vertical_margin"
+ android:visibility="gone" />
+
<CheckBox
android:id="@+id/secured"
android:layout_width="match_parent"
cout << " 2 - searchUser using email" << endl;
cout << " 3 - searchUser using phone" << endl;
cout << " 4 - deleteDevice" << endl;
- cout << " 5 - createGroup" << endl;
- cout << " 6 - observeGroup" << endl;
- cout << " 7 - getGroupList" << endl;
- cout << " 8 - deleteGroup" << endl;
- cout << " 9 - joinGroup" << endl;
- cout << " 10 - addDeviceToGroup" << endl;
- cout << " 11 - getGroupInfo" << endl;
- cout << " 12 - leaveGroup" << endl;
- cout << " 13 - deleteDeviceFromGroup" << endl;
- cout << " 14 - observeInvitation" << endl;
- cout << " 15 - sendInvitation" << endl;
- cout << " 16 - cancelInvitation" << endl;
- cout << " 17 - deleteInvitation" << endl;
- cout << " 18 - cancelObserveGroup" << endl;
- cout << " 19 - cancelObserveInvitation" << endl;
+ cout << " 5 - observeGroup" << endl;
+ cout << " 6 - createGroup" << endl;
+ cout << " 7 - deleteGroup" << endl;
+ cout << " 8 - getGroupInfoAll" << endl;
+ cout << " 9 - getGroupInfo" << endl;
+ cout << " 10 - addPropertyValueToGroup" << endl;
+ cout << " 11 - deletePropertyValueFromGroup" << endl;
+ cout << " 12 - updatePropertyValueOnGroup" << endl;
+ cout << " 13 - observeInvitation" << endl;
+ cout << " 14 - sendInvitation" << endl;
+ cout << " 15 - cancelInvitation" << endl;
+ cout << " 16 - deleteInvitation" << endl;
+ cout << " 17 - cancelObserveGroup" << endl;
+ cout << " 18 - cancelObserveInvitation" << endl;
cout << " 20 - exit" << endl;
string cmd;
OCRepresentation rep;
switch (atoi(cmd.c_str()))
+ {
+ case 1:
+ cout << "Put userUUID to search:" << endl;
+ cin >> cmd;
+ result = accountMgr->searchUser(cmd, &ocPost);
+ break;
+
+ case 2:
+ cout << "Put email to search:" << endl;
+ cin >> cmd;
+ query["email"] = cmd;
+ result = accountMgr->searchUser(query, &ocPost);
+ break;
+
+ case 3:
+ cout << "Put phone number to search:" << endl;
+ cin >> cmd;
+ query["phone"] = cmd;
+ result = accountMgr->searchUser(query, &ocPost);
+ break;
+
+ case 4:
{
- case 1:
- cout << "Put userUUID to search:" << endl;
- cin >> cmd;
- result = accountMgr->searchUser(cmd, &ocPost);
- break;
+ string accessToken, deviceId;
- case 2:
- cout << "Put email to search:" << endl;
- cin >> cmd;
- query["email"] = cmd;
- result = accountMgr->searchUser(query, &ocPost);
- break;
+ cout << "PUT accessToken:";
+ cin >> accessToken;
- case 3:
- cout << "Put phone number to search:" << endl;
- cin >> cmd;
- query["phone"] = cmd;
- result = accountMgr->searchUser(query, &ocPost);
- break;
+ cout << "PUT deviceID to delete:";
+ cin >> deviceId;
- case 4:
- cout << "PUT deviceID to delete:";
- cin >> cmd;
- result = accountMgr->deleteDevice(cmd, &onDelete);
- break;
+ result = accountMgr->deleteDevice(accessToken, deviceId, &onDelete);
+ break;
+ }
- case 5:
- result = accountMgr->createGroup(OC::AclGroupType::PUBLIC, &ocPost);
- break;
+ case 5:
+ result = accountMgr->observeGroup(&onObserve);
+ break;
- case 6:
- cout << "PUT groupId to observe:";
- cin >> cmd;
- result = accountMgr->observeGroup(cmd, &onObserve);
- break;
+ case 6:
+ result = accountMgr->createGroup(&ocPost);
+ break;
- case 7:
- result = accountMgr->getGroupList(&ocPost);
- break;
+ case 7:
+ cout << "PUT groupId to delete:";
+ cin >> cmd;
+ result = accountMgr->deleteGroup(cmd, &onDelete);
+ break;
- case 8:
- cout << "PUT groupId to delete:";
- cin >> cmd;
- result = accountMgr->deleteGroup(cmd, &onDelete);
- break;
+ case 8:
+ result = accountMgr->getGroupInfoAll(&ocPost);
+ break;
- case 9:
- cout << "PUT groupId to join:";
- cin >> cmd;
- result = accountMgr->joinGroup(cmd, &ocPost);
- break;
+ case 9:
+ cout << "PUT groupId to get info:";
+ cin >> cmd;
+ result = accountMgr->getGroupInfo(cmd, &ocPost);
+ break;
- case 10:
- cout << "PUT groupId to add device:";
- cin >> cmd;
- cout << "PUT deviceId to add to group:";
- cin >> cmd2;
- {
- vector<string> deviceIds;
- deviceIds.push_back(cmd2);
- result = accountMgr->addDeviceToGroup(cmd, deviceIds, &ocPost);
- }
- break;
+ case 10:
+ {
+ string groupId, property, value;
+ vector<string> values;
+ OCRepresentation propertyValue;
- case 11:
- cout << "PUT groupId to get info:";
- cin >> cmd;
- result = accountMgr->getGroupInfo(cmd, &ocPost);
- break;
+ cout << "PUT groupId to add property values:";
+ cin >> groupId;
- case 12:
- cout << "PUT groupId to leave:";
- cin >> cmd;
- result = accountMgr->leaveGroup(cmd, &onDelete);
- break;
+ cout << "PUT property name:";
+ cin >> property;
- case 13:
- cout << "PUT groupId to remove device:";
- cin >> cmd;
- cout << "PUT deviceId to remove from group:";
- cin >> cmd2;
- {
- vector<string> deviceIds;
- deviceIds.push_back(cmd2);
- result = accountMgr->deleteDeviceFromGroup(cmd, deviceIds, &onDelete);
- }
- break;
+ cout << "PUT value:";
+ cin >> value;
- case 14:
- result = accountMgr->observeInvitation(&onObserve);
- break;
+ values.push_back(value);
+ propertyValue.setValue<vector<string>>(property, values);
- case 15:
- cout << "PUT groupId to invite:";
- cin >> cmd;
- cout << "PUT userUUID to invite:";
- cin >> cmd2;
- result = accountMgr->sendInvitation(cmd, cmd2, &ocPost);
- break;
+ accountMgr->addPropertyValueToGroup(groupId, propertyValue, &ocPost);
+ break;
+ }
- case 16:
- cout << "PUT groupId to cancel invitation:";
- cin >> cmd;
- cout << "PUT userUUID to cancel invitation:";
- cin >> cmd2;
- result = accountMgr->cancelInvitation(cmd, cmd2, &onDelete);
- break;
+ case 11:
+ {
+ string groupId, property, value;
+ vector<string> values;
+ OCRepresentation propertyValue;
- case 17:
- cout << "PUT groupId to delete invitation:";
- cin >> cmd;
- result = accountMgr->deleteInvitation(cmd, &onDelete);
- break;
+ cout << "PUT groupId to delete property values:";
+ cin >> groupId;
- case 18:
- cout << "PUT groupId to cancel observe:";
- cin >> cmd;
- result = accountMgr->cancelObserveGroup(cmd);
- break;
+ cout << "PUT property name:";
+ cin >> property;
- case 19:
- result = accountMgr->cancelObserveInvitation();
- break;
+ cout << "PUT value:";
+ cin >> value;
+
+ values.push_back(value);
+ propertyValue.setValue<vector<string>>(property, values);
+
+ accountMgr->deletePropertyValueFromGroup(groupId, propertyValue, &ocPost);
+ break;
+ }
- case 20:
- goto exit;
+ case 12:
+ {
+ string groupId, property, value;
+ OCRepresentation propertyValue;
+
+ cout << "PUT groupId to update property values:";
+ cin >> groupId;
+
+ cout << "PUT property name:";
+ cin >> property;
+
+ int type;
+ cout << "PUT value type(1:string / 2:array):";
+ cin >> type;
+
+ cout << "PUT value:";
+ cin >> value;
+
+ if (1 == type)
+ {
+ propertyValue.setValue<string>(property, value);
+ }
+ else if (2 == type)
+ {
+ vector<string> values;
+ values.push_back(value);
+ propertyValue.setValue<vector<string>>(property, values);
+ }
+ else
+ {
break;
+ }
+
+ accountMgr->updatePropertyValueOnGroup(groupId, propertyValue, &ocPost);
+ break;
+ }
+
+ case 13:
+ result = accountMgr->observeInvitation(&onObserve);
+ break;
+
+ case 14:
+ cout << "PUT groupId to invite:";
+ cin >> cmd;
+ cout << "PUT userUUID to invite:";
+ cin >> cmd2;
+ result = accountMgr->sendInvitation(cmd, cmd2, &ocPost);
+ break;
+
+ case 15:
+ cout << "PUT groupId to cancel invitation:";
+ cin >> cmd;
+ cout << "PUT userUUID to cancel invitation:";
+ cin >> cmd2;
+ result = accountMgr->cancelInvitation(cmd, cmd2, &onDelete);
+ break;
+
+ case 16:
+ cout << "PUT groupId to reply to invitation:";
+ cin >> cmd;
+ cout << "accept to invitation? (1:yes)";
+ cin >> cmd2;
+
+ if (cmd2 == "1")
+ {
+ result = accountMgr->replyToInvitation(cmd, true, &onDelete);
+ }
+ else
+ {
+ result = accountMgr->replyToInvitation(cmd, false, &onDelete);
+ }
+ break;
+
+ case 17:
+ result = accountMgr->cancelObserveGroup();
+ break;
+
+ case 18:
+ result = accountMgr->cancelObserveInvitation();
+ break;
+
+ case 20:
+ goto exit;
+ break;
+
+ default:
+ break;
}
if (result != OC_STACK_OK)
RDClient::Instance().publishResourceToRD(g_host, OCConnectivityType::CT_ADAPTER_TCP, resourceHandles,
&onPublish);
g_callbackLock.wait(lock);
+/* TODO: need to modify the below according to the OCAccountManager API changed.
if (g_option == "owner")
{
cout << "Creating group" << endl;
cin >> cmd;
}
-
+*/
return 0;
}
/** Defines user UUID. */
#define OC_RSRVD_USER_UUID "uid"
-/** Defines user ID. */
-#define OC_RSRVD_USER_ID "userid"
-
/** Defines group ID. */
#define OC_RSRVD_GROUP_ID "gid"
-/** Defines group Master ID. */
-#define OC_RSRVD_GROUP_MASTER_ID "gmid"
-
-/** Defines group type. */
-#define OC_RSRVD_GROUP_TYPE "gtype"
-
/** Defines member of group ID. */
#define OC_RSRVD_MEMBER_ID "mid"
-/** Defines device ID list. */
-#define OC_RSRVD_DEVICE_ID_LIST "dilist"
+/** Defines invite. */
+#define OC_RSRVD_INVITE "invite"
+
+/** Defines accept. */
+#define OC_RSRVD_ACCEPT "accept"
-/** Defines public. */
-#define OC_RSRVD_PUBLIC "Public"
+/** Defines operation. */
+#define OC_RSRVD_OPERATION "op"
-/** Defines private. */
-#define OC_RSRVD_PRIVATE "Private"
+/** Defines add. */
+#define OC_RSRVD_ADD "add"
-/** Defines invite. */
-#define OC_RSRVD_INVITE "invite"
+/** Defines delete. */
+#define OC_RSRVD_DELETE "delete"
+
+/** Defines owner. */
+#define OC_RSRVD_OWNER "owner"
+
+/** Defines members. */
+#define OC_RSRVD_MEMBERS "members"
/** To represent grant type with refresh token. */
#define OC_RSRVD_GRANT_TYPE_REFRESH_TOKEN "refresh_token"
virtual ~OCAccountManager(void);
/**
- * Function to get the host address of account server
+ * Function to get the host address of account server.
*
* @return std::string host address
*/
std::string host() const;
/**
- * Function to get the connectivity type for account server
+ * Function to get the connectivity type for account server.
*
* @return enum connectivity type (flags and adapter)
*/
OCConnectivityType connectivityType() const;
/**
- * Function for account registration to account server
+ * Function for account registration to account server.
*
* @param authProvider Provider name used for authentication.
* @param authCode The authorization code obtained by using an authorization server
PostCallback cloudConnectHandler);
/**
- * Function for sign-in to account server
+ * Function for sign-in to account server.
*
* @param userUuid Identifier of the user obtained by account registration.
* @param accessToken Identifier of the resource obtained by account registration.
PostCallback cloudConnectHandler);
/**
- * Function for sign-out to account server
+ * Function for sign-out to account server.
*
+ * @param accessToken Identifier of the resource obtained by account registration.
* @param cloudConnectHandler Callback function that will get the result of the operation.
*
* @return Returns ::OC_STACK_OK if success
*/
- OCStackResult signOut(PostCallback cloudConnectHandler);
+ OCStackResult signOut(const std::string& accessToken,
+ PostCallback cloudConnectHandler);
/**
- * Function for refresh access token to account server
+ * Function for refresh access token to account server.
*
* @param userUuid Identifier of the user obtained by account registration.
* @param refreshToken Refresh token used for access token refresh.
PostCallback cloudConnectHandler);
/**
- * Function to get information of the user to account server
+ * Function to get information of the user to account server.
*
* @param userUuid Identifier of the user to get information.
* @param cloudConnectHandler Callback function that will get the result of the operation.
/**
* Overload
*
- * @param queryParams Map which can have the query key and value for specific users.
- * account server can response information of more than one user.
+ * @param queryParams Map that has a query key and value for specific users.
+ * Account server can response information of more than one user.
* @param cloudConnectHandler Callback function that will get the result of the operation.
*
* @return Returns ::OC_STACK_OK if success
GetCallback cloudConnectHandler);
/**
- * Function to delete the device registered on the account signed-in
+ * Function to delete the device registered on the account signed-in.
*
+ * @param accessToken Identifier of the resource obtained by account registration.
* @param deviceId Device ID to delete.
* @param cloudConnectHandler Callback function that will get the result of the operation.
*
* @return Returns ::OC_STACK_OK if success
*/
- OCStackResult deleteDevice(const std::string& deviceId,
+ OCStackResult deleteDevice(const std::string& accessToken,
+ const std::string& deviceId,
DeleteCallback cloudConnectHandler);
/**
- * Function to create a group on account server
+ * Function to create a group on account server.
*
- * @param groupType Group type that can be used for referencing default group ACL creation.
* @param cloudConnectHandler Callback function that will get the result of the operation.
*
* @return Returns ::OC_STACK_OK if success
*/
- OCStackResult createGroup(AclGroupType groupType,
- PostCallback cloudConnectHandler);
+ OCStackResult createGroup(PostCallback cloudConnectHandler);
/**
- * Function to get a list of groups joined from account server
+ * Overload
*
+ * @param queryParams Map that has optional properties and values to create a group.
+ * Defined properties on the OCF spec are [gname, parent] so far.
+ * (2016/10/19)
* @param cloudConnectHandler Callback function that will get the result of the operation.
*
* @return Returns ::OC_STACK_OK if success
*/
- OCStackResult getGroupList(GetCallback cloudConnectHandler);
+ OCStackResult createGroup(const QueryParamsMap& queryParams,
+ PostCallback cloudConnectHandler);
/**
- * Function to delete the group from account server
+ * Function to delete the group from account server.
*
* @param groupId Group ID to delete.
* @param cloudConnectHandler Callback function that will get the result of the operation.
DeleteCallback cloudConnectHandler);
/**
- * Function to join the group on account server
+ * Function to get infomation of all your group from account server.
*
- * @param groupId Group ID to join
* @param cloudConnectHandler Callback function that will get the result of the operation.
*
* @return Returns ::OC_STACK_OK if success
*/
- OCStackResult joinGroup(const std::string& groupId,
- PostCallback cloudConnectHandler);
+
+ OCStackResult getGroupInfoAll(GetCallback cloudConnectHandler);
/**
- * Function to add devices to the group on account server
+ * Function to get information of the specific group from account server.
*
- * @param groupId Group ID to add devices.
- * @param deviceId List of devices to add.
+ * @param groupId Group ID to get information.
* @param cloudConnectHandler Callback function that will get the result of the operation.
*
* @return Returns ::OC_STACK_OK if success
*/
- OCStackResult addDeviceToGroup(const std::string& groupId,
- const std::vector<std::string>& deviceId,
- PostCallback cloudConnectHandler);
+ OCStackResult getGroupInfo(const std::string& groupId,
+ GetCallback cloudConnectHandler);
/**
- * Function to get information of the group from account server
+ * Function to add values for properties to the group on account server.
*
- * @param groupId Group ID to get information.
+ * @param groupId Group ID to add property values.
+ * @param propertyValue OCRepresentation info that has pairs of property and value.
+ * Defined properties on the OCF spec are [members, masters, devices,
+ * resources, links] so far. (2016/10/19)
* @param cloudConnectHandler Callback function that will get the result of the operation.
*
* @return Returns ::OC_STACK_OK if success
*/
- OCStackResult getGroupInfo(const std::string& groupId,
- GetCallback cloudConnectHandler);
+ OCStackResult addPropertyValueToGroup(const std::string& groupId,
+ const OCRepresentation propertyValue,
+ PostCallback cloudConnectHandler);
/**
- * Function to leave the group joined on account server
+ * Function to delete values for properties from the group on account server.
*
- * @param groupId Group ID to leave.
+ * @param groupId Group ID to delete information.
+ * @param propertyValue OCRepresentation info that has pairs of property and value.
+ * Defined properties on the OCF spec are [members, masters, devices,
+ * resources, links] so far. (2016/10/19)
* @param cloudConnectHandler Callback function that will get the result of the operation.
*
* @return Returns ::OC_STACK_OK if success
*/
- OCStackResult leaveGroup(const std::string& groupId,
- DeleteCallback cloudConnectHandler);
+ OCStackResult deletePropertyValueFromGroup(const std::string& groupId,
+ const OCRepresentation propertyValue,
+ PostCallback cloudConnectHandler);
/**
- * Function to delete devices from the group on account server
+ * Function to update values for properties on the group on account server.
+ * It completely replaces existing values for specific properties.
*
- * @param groupId Group ID to delete devices.
- * @param deviceId List of devices to delete.
+ * @param groupId Group ID to add devices.
+ * @param propertyValue OCRepresentation info that has pairs of property and value.
+ * Defined properties on the OCF spec are [members, gname, owner,
+ * masters, devices, resources, latitude, longitude, radius,
+ * backgroundImage] so far. (2016/10/19)
* @param cloudConnectHandler Callback function that will get the result of the operation.
*
* @return Returns ::OC_STACK_OK if success
*/
- OCStackResult deleteDeviceFromGroup(const std::string& groupId,
- const std::vector<std::string>& deviceId,
- DeleteCallback cloudConnectHandler);
+ OCStackResult updatePropertyValueOnGroup(const std::string& groupId,
+ const OCRepresentation propertyValue,
+ PostCallback cloudConnectHandler);
/**
- * Function to register observe to the group on account server
- * User can receive a notify when the group get changed (eg. new user/device added)
+ * Function to register observe to group resource on account server.
+ * You can receive a notify when any value of property get changed in the group you joined.
*
- * @param groupId Group ID to observe.
* @param cloudConnectHandler Callback function that will get the result of the operation.
*
* @return Returns ::OC_STACK_OK if success
*/
- OCStackResult observeGroup(const std::string& groupId,
- ObserveCallback cloudConnectHandler);
+ OCStackResult observeGroup(ObserveCallback cloudConnectHandler);
/**
- * Function to cancel observe to the group on account server
- *
- * @param groupId Group ID to observe.
+ * Function to cancel observe to group resource on account server.
*
* @return Returns ::OC_STACK_OK if success
*/
- OCStackResult cancelObserveGroup(const std::string& groupId);
+ OCStackResult cancelObserveGroup();
/**
- * Function to register observe to invitation resource on account server
- * User can receive a invitation which is including group ID to join
- * Once receive a invitation, user should call 'deleteInvitation' to delete a invitation
- * on account server.
+ * Function to register observe to invitation resource on account server.
+ * You can receive a notify when you send or receive a invitation.
+ * Sending a invitation will be notified as 'invite' and Receiving will be as 'invited'.
+ * If you receive a invitation from other user, you should call 'replyToInvitation' to
+ * delete the invitation on account server, otherwise it will remain on the server.
*
* @param cloudConnectHandler Callback function that will get the result of the operation.
*
OCStackResult observeInvitation(ObserveCallback cloudConnectHandler);
/**
- * Function to cancel observe to invitation resource on account server
+ * Function to cancel observe to invitation resource on account server.
*
* @return Returns ::OC_STACK_OK if success
*/
OCStackResult cancelObserveInvitation();
/**
- * Function to send a invitation to invite a user into a group
+ * Function to send a invitation to invite a user into a group.
*
* @param groupId Group ID for inviting.
* @param userUuid Identifier of the user to invite.
PostCallback cloudConnectHandler);
/**
- * Function to cancel a invitation on account server that user has sent
+ * Function to cancel a invitation you has sent on account server before the invited user
+ * replies.
*
* @param groupId Group ID to cancel a invitation.
* @param userUuid Identifier of the user to cancel a invitation.
DeleteCallback cloudConnectHandler);
/**
- * Function to delete a invitation on account server that user has received
+ * Function to reply to the invitation that you has received.
+ * If you set accept as true, you will join the group as a member and the invitation
+ * will be deleted on account server.
+ * If false, only the invitation will be deleted.
*
* @param groupId Group ID to delete a invitation.
+ * @param accept boolean whether to join the group or not.
* @param cloudConnectHandler Callback function that will get the result of the operation.
*
* @return Returns ::OC_STACK_OK if success
*/
- OCStackResult deleteInvitation(const std::string& groupId,
- DeleteCallback cloudConnectHandler);
+ OCStackResult replyToInvitation(const std::string& groupId,
+ const bool accept,
+ DeleteCallback cloudConnectHandler);
private:
std::weak_ptr<IClientWrapper> m_clientWrapper;
std::string m_deviceID;
std::string m_host;
+ std::string m_userUuid;
OCDoHandle m_invitationObserveHandle;
- mutable std::map<std::string, OCDoHandle> m_groupObserveHandles;
+ OCDoHandle m_groupObserveHandle;
OCConnectivityType m_connType;
QualityOfService m_defaultQos;
Observe,
ObserveAll
};
-#ifdef WITH_CLOUD
- enum class AclGroupType
- {
- PUBLIC,
- PRIVATE
- };
-#endif
+
// Typedef for list of resource handles.
typedef std::vector<OCResourceHandle> ResourceHandles;
#include "ocstack.h"
+#define VERIFY_NON_EMPTY(arg, log_message, ret) \
+ if ((arg).empty()) \
+ { \
+ oclog() << log_message << std::flush; \
+ return result_guard(ret); \
+ } \
+
namespace OC {
using OC::result_guard;
OCAccountManager::OCAccountManager(std::weak_ptr<IClientWrapper> clientWrapper,
const std::string& host,
OCConnectivityType connectivityType)
- : m_clientWrapper(clientWrapper), m_host(host), m_connType(connectivityType),
- m_invitationObserveHandle(nullptr)
+ : m_clientWrapper(clientWrapper), m_host(host), m_userUuid(""),
+ m_invitationObserveHandle(nullptr), m_groupObserveHandle(nullptr), m_connType(connectivityType)
{
if (m_host.empty() || m_clientWrapper.expired())
{
}
m_deviceID.append(di);
- m_groupObserveHandles = {};
checked_guard(m_clientWrapper.lock(), &IClientWrapper::GetDefaultQos, m_defaultQos);
}
const QueryParamsMap& options,
PostCallback cloudConnectHandler)
{
- if (authProvider.empty() || authCode.empty())
- {
- return result_guard(OC_STACK_INVALID_PARAM);
- }
+ VERIFY_NON_EMPTY(authProvider, "authProvider cannot be empty.", OC_STACK_INVALID_PARAM);
+ VERIFY_NON_EMPTY(authCode, "authCode cannot be empty.", OC_STACK_INVALID_PARAM);
std::string uri = m_host + OC_RSRVD_ACCOUNT_URI;
OCRepresentation rep;
- rep.setValue(OC_RSRVD_DEVICE_ID, m_deviceID);
- rep.setValue(OC_RSRVD_AUTHPROVIDER, authProvider);
- rep.setValue(OC_RSRVD_AUTHCODE, authCode);
+ rep.setValue<std::string>(OC_RSRVD_DEVICE_ID, m_deviceID);
+ rep.setValue<std::string>(OC_RSRVD_AUTHPROVIDER, authProvider);
+ rep.setValue<std::string>(OC_RSRVD_AUTHCODE, authCode);
if (!options.empty())
{
const std::string& accessToken,
PostCallback cloudConnectHandler)
{
- if (userUuid.empty() || accessToken.empty())
+ VERIFY_NON_EMPTY(userUuid, "userUuid cannot be empty.", OC_STACK_INVALID_PARAM);
+ VERIFY_NON_EMPTY(accessToken, "accessToken cannot be empty.", OC_STACK_INVALID_PARAM);
+
+ OCStackResult result = result_guard(signInOut(userUuid, accessToken, true,
+ cloudConnectHandler));
+ if (OC_STACK_OK == result)
{
- return result_guard(OC_STACK_INVALID_PARAM);
+ m_userUuid = userUuid;
}
- return result_guard(signInOut(userUuid, accessToken, true, cloudConnectHandler));
+ return result;
}
-OCStackResult OCAccountManager::signOut(PostCallback cloudConnectHandler)
+OCStackResult OCAccountManager::signOut(const std::string& accessToken,
+ PostCallback cloudConnectHandler)
{
- return result_guard(signInOut("", "", false, cloudConnectHandler));
+ VERIFY_NON_EMPTY(m_userUuid, "Need to sign-in first.", OC_STACK_ERROR);
+ VERIFY_NON_EMPTY(accessToken, "accessToken cannot be empty.", OC_STACK_INVALID_PARAM);
+
+ OCStackResult result = result_guard(signInOut(m_userUuid, accessToken, false,
+ cloudConnectHandler));
+ if (OC_STACK_OK == result)
+ {
+ m_userUuid = "";
+ }
+
+ return result;
}
OCStackResult OCAccountManager::signInOut(const std::string& userUuid,
std::string uri = m_host + OC_RSRVD_ACCOUNT_SESSION_URI;
OCRepresentation rep;
+
if (isSignIn)
{
- rep.setValue(OC_RSRVD_USER_UUID, userUuid);
- rep.setValue(OC_RSRVD_DEVICE_ID, m_deviceID);
- rep.setValue(OC_RSRVD_ACCESS_TOKEN, accessToken);
+ rep.setValue<std::string>(OC_RSRVD_USER_UUID, userUuid);
}
- rep.setValue(OC_RSRVD_LOGIN, isSignIn);
+ rep.setValue<std::string>(OC_RSRVD_DEVICE_ID, m_deviceID);
+ rep.setValue<std::string>(OC_RSRVD_ACCESS_TOKEN, accessToken);
+ rep.setValue<bool>(OC_RSRVD_LOGIN, isSignIn);
return checked_guard(m_clientWrapper.lock(), &IClientWrapper::PostResourceRepresentation,
OCDevAddr(), uri, rep, QueryParamsMap(), HeaderOptions(),
const std::string& refreshToken,
PostCallback cloudConnectHandler)
{
- if (userUuid.empty() || refreshToken.empty())
- {
- return result_guard(OC_STACK_INVALID_PARAM);
- }
+ VERIFY_NON_EMPTY(userUuid, "userUuid cannot be empty.", OC_STACK_INVALID_PARAM);
+ VERIFY_NON_EMPTY(refreshToken, "refreshToken cannot be empty.", OC_STACK_INVALID_PARAM);
std::string uri = m_host + OC_RSRVD_ACCOUNT_TOKEN_REFRESH_URI;
OCRepresentation rep;
- rep.setValue(OC_RSRVD_USER_UUID, userUuid);
- rep.setValue(OC_RSRVD_DEVICE_ID, m_deviceID);
- rep.setValue(OC_RSRVD_GRANT_TYPE, std::string(OC_RSRVD_GRANT_TYPE_REFRESH_TOKEN));
- rep.setValue(OC_RSRVD_REFRESH_TOKEN, refreshToken);
+ rep.setValue<std::string>(OC_RSRVD_USER_UUID, userUuid);
+ rep.setValue<std::string>(OC_RSRVD_DEVICE_ID, m_deviceID);
+ rep.setValue<std::string>(OC_RSRVD_GRANT_TYPE, std::string(OC_RSRVD_GRANT_TYPE_REFRESH_TOKEN));
+ rep.setValue<std::string>(OC_RSRVD_REFRESH_TOKEN, refreshToken);
return checked_guard(m_clientWrapper.lock(), &IClientWrapper::PostResourceRepresentation,
OCDevAddr(), uri, rep, QueryParamsMap(), HeaderOptions(),
OCStackResult OCAccountManager::searchUser(const std::string& userUuid,
GetCallback cloudConnectHandler)
{
- if (userUuid.empty())
- {
- return result_guard(OC_STACK_INVALID_PARAM);
- }
+ VERIFY_NON_EMPTY(userUuid, "userUuid cannot be empty.", OC_STACK_INVALID_PARAM);
return result_guard(searchUser(userUuid, QueryParamsMap(), cloudConnectHandler));
}
OCStackResult OCAccountManager::searchUser(const QueryParamsMap& queryParams,
GetCallback cloudConnectHandler)
{
- if (queryParams.empty())
- {
- return result_guard(OC_STACK_INVALID_PARAM);
- }
+ VERIFY_NON_EMPTY(queryParams, "queryParams cannot be empty.", OC_STACK_INVALID_PARAM);
return result_guard(searchUser("", queryParams, cloudConnectHandler));
}
m_connType, cloudConnectHandler, m_defaultQos);
}
-OCStackResult OCAccountManager::deleteDevice(const std::string& deviceId,
+OCStackResult OCAccountManager::deleteDevice(const std::string& accessToken,
+ const std::string& deviceId,
DeleteCallback cloudConnectHandler)
{
- if (deviceId.empty())
- {
- return result_guard(OC_STACK_INVALID_PARAM);
- }
+ VERIFY_NON_EMPTY(accessToken, "accessToken cannot be empty.", OC_STACK_INVALID_PARAM);
+ VERIFY_NON_EMPTY(deviceId, "deviceId cannot be empty.", OC_STACK_INVALID_PARAM);
std::string uri = m_host + OC_RSRVD_ACCOUNT_URI
- + "?" + OC_RSRVD_DEVICE_ID + "=" + deviceId;
+ + "?" + OC_RSRVD_ACCESS_TOKEN + "=" + accessToken
+ + ";" + OC_RSRVD_DEVICE_ID + "=" + deviceId;
return checked_guard(m_clientWrapper.lock(), &IClientWrapper::DeleteResource,
OCDevAddr(), uri, HeaderOptions(),
m_connType, cloudConnectHandler, m_defaultQos);
}
-OCStackResult OCAccountManager::createGroup(AclGroupType groupType,
+OCStackResult OCAccountManager::createGroup(PostCallback cloudConnectHandler)
+{
+ return result_guard(createGroup(QueryParamsMap(), cloudConnectHandler));
+}
+
+OCStackResult OCAccountManager::createGroup(const QueryParamsMap& queryParams,
PostCallback cloudConnectHandler)
{
+ VERIFY_NON_EMPTY(m_userUuid, "Need to sign-in first.", OC_STACK_ERROR);
+
std::string uri = m_host + OC_RSRVD_ACL_GROUP_URI;
- std::string gtype;
- switch (groupType)
+ std::vector<std::string> members{m_userUuid};
+
+ OCRepresentation rep;
+ rep.setValue<std::string>(OC_RSRVD_OWNER, m_userUuid);
+ rep.setValue<std::vector<std::string>>(OC_RSRVD_MEMBERS, members);
+
+ if (!queryParams.empty())
{
- case AclGroupType::PUBLIC:
- gtype = OC_RSRVD_PUBLIC;
- break;
- case AclGroupType::PRIVATE:
- gtype = OC_RSRVD_PRIVATE;
- break;
- default:
- return result_guard(OC_STACK_INVALID_PARAM);
+ for (auto iter : queryParams)
+ {
+ rep.setValue(iter.first, iter.second);
+ }
}
- OCRepresentation rep;
- rep.setValue(OC_RSRVD_GROUP_TYPE, gtype);
return checked_guard(m_clientWrapper.lock(), &IClientWrapper::PostResourceRepresentation,
OCDevAddr(), uri, rep, QueryParamsMap(), HeaderOptions(),
m_connType, cloudConnectHandler, m_defaultQos);
}
-OCStackResult OCAccountManager::getGroupList(GetCallback cloudConnectHandler)
-{
- std::string uri = m_host + OC_RSRVD_ACL_GROUP_URI;
-
- return checked_guard(m_clientWrapper.lock(), &IClientWrapper::GetResourceRepresentation,
- OCDevAddr(), uri, QueryParamsMap(), HeaderOptions(),
- m_connType, cloudConnectHandler, m_defaultQos);
-}
-
OCStackResult OCAccountManager::deleteGroup(const std::string& groupId,
DeleteCallback cloudConnectHandler)
{
- if (groupId.empty())
- {
- return result_guard(OC_STACK_INVALID_PARAM);
- }
+ VERIFY_NON_EMPTY(m_userUuid, "Need to sign-in first.", OC_STACK_ERROR);
+ VERIFY_NON_EMPTY(groupId, "groupId cannot be empty.", OC_STACK_INVALID_PARAM);
- std::string uri = m_host + OC_RSRVD_ACL_GROUP_URI
- + "?" + OC_RSRVD_GROUP_ID + "=" + groupId;
+ std::string uri = m_host + OC_RSRVD_ACL_GROUP_URI + "/" + groupId
+ + "?" + OC_RSRVD_OWNER + "=" + m_userUuid;
return checked_guard(m_clientWrapper.lock(), &IClientWrapper::DeleteResource,
OCDevAddr(), uri, HeaderOptions(),
m_connType, cloudConnectHandler, m_defaultQos);
}
-OCStackResult OCAccountManager::joinGroup(const std::string& groupId,
- PostCallback cloudConnectHandler)
-{
- if (groupId.empty())
- {
- return result_guard(OC_STACK_INVALID_PARAM);
- }
-
- std::string uri = m_host + OC_RSRVD_ACL_GROUP_URI + "/" + groupId;
-
- return checked_guard(m_clientWrapper.lock(), &IClientWrapper::PostResourceRepresentation,
- OCDevAddr(), uri, OCRepresentation(), QueryParamsMap(), HeaderOptions(),
- m_connType, cloudConnectHandler, m_defaultQos);
-}
-
-OCStackResult OCAccountManager::addDeviceToGroup(const std::string& groupId,
- const std::vector<std::string>& deviceId,
- PostCallback cloudConnectHandler)
+OCStackResult OCAccountManager::getGroupInfoAll(GetCallback cloudConnectHandler)
{
- if (groupId.empty() || deviceId.empty())
- {
- return result_guard(OC_STACK_INVALID_PARAM);
- }
+ VERIFY_NON_EMPTY(m_userUuid, "Need to sign-in first.", OC_STACK_ERROR);
- std::string uri = m_host + OC_RSRVD_ACL_GROUP_URI + "/" + groupId;
+ std::string uri = m_host + OC_RSRVD_ACL_GROUP_URI;
- OCRepresentation rep;
- rep.setValue<std::vector<std::string>>(std::string(OC_RSRVD_DEVICE_ID_LIST), deviceId);
+ QueryParamsMap query = {};
+ query.insert(std::make_pair(OC_RSRVD_MEMBERS, m_userUuid));
- return checked_guard(m_clientWrapper.lock(), &IClientWrapper::PostResourceRepresentation,
- OCDevAddr(), uri, rep, QueryParamsMap(), HeaderOptions(),
- m_connType, cloudConnectHandler, m_defaultQos);
+ return checked_guard(m_clientWrapper.lock(), &IClientWrapper::GetResourceRepresentation,
+ OCDevAddr(), uri, query, HeaderOptions(), m_connType,
+ cloudConnectHandler, m_defaultQos);
}
OCStackResult OCAccountManager::getGroupInfo(const std::string& groupId,
GetCallback cloudConnectHandler)
{
- if (groupId.empty())
- {
- return result_guard(OC_STACK_INVALID_PARAM);
- }
+ VERIFY_NON_EMPTY(m_userUuid, "Need to sign-in first.", OC_STACK_ERROR);
+ VERIFY_NON_EMPTY(groupId, "groupId cannot be empty.", OC_STACK_INVALID_PARAM);
std::string uri = m_host + OC_RSRVD_ACL_GROUP_URI + "/" + groupId;
+ QueryParamsMap query = {};
+ query.insert(std::make_pair(OC_RSRVD_MEMBERS, m_userUuid));
+
return checked_guard(m_clientWrapper.lock(), &IClientWrapper::GetResourceRepresentation,
- OCDevAddr(), uri, QueryParamsMap(), HeaderOptions(),
+ OCDevAddr(), uri, query, HeaderOptions(),
m_connType, cloudConnectHandler, m_defaultQos);
}
-OCStackResult OCAccountManager::leaveGroup(const std::string& groupId,
- DeleteCallback cloudConnectHandler)
+OCStackResult OCAccountManager::addPropertyValueToGroup(const std::string& groupId,
+ const OCRepresentation propertyValue,
+ PostCallback cloudConnectHandler)
{
- if (groupId.empty())
- {
- return result_guard(OC_STACK_INVALID_PARAM);
- }
+ VERIFY_NON_EMPTY(groupId, "groupId cannot be empty.", OC_STACK_INVALID_PARAM);
std::string uri = m_host + OC_RSRVD_ACL_GROUP_URI + "/" + groupId;
- return checked_guard(m_clientWrapper.lock(), &IClientWrapper::DeleteResource,
- OCDevAddr(), uri, HeaderOptions(),
+ QueryParamsMap query = {};
+ query.insert(std::make_pair(OC_RSRVD_OPERATION, OC_RSRVD_ADD));
+
+ return checked_guard(m_clientWrapper.lock(), &IClientWrapper::PostResourceRepresentation,
+ OCDevAddr(), uri, propertyValue, query, HeaderOptions(),
m_connType, cloudConnectHandler, m_defaultQos);
}
-OCStackResult OCAccountManager::deleteDeviceFromGroup(const std::string& groupId,
- const std::vector<std::string>& deviceId,
- DeleteCallback cloudConnectHandler)
+OCStackResult OCAccountManager::deletePropertyValueFromGroup(const std::string& groupId,
+ const OCRepresentation propertyValue,
+ PostCallback cloudConnectHandler)
{
- if (groupId.empty() || deviceId.empty())
- {
- return result_guard(OC_STACK_INVALID_PARAM);
- }
+ VERIFY_NON_EMPTY(groupId, "groupId cannot be empty.", OC_STACK_INVALID_PARAM);
std::string uri = m_host + OC_RSRVD_ACL_GROUP_URI + "/" + groupId;
+ QueryParamsMap query = {};
+ query.insert(std::make_pair(OC_RSRVD_OPERATION, OC_RSRVD_DELETE));
- uri.append("?");
- for (auto iter : deviceId)
- {
- uri.append((std::string)OC_RSRVD_DEVICE_ID_LIST + "=" + iter + ";");
- }
- uri.resize(uri.size() - 1);
-
- return checked_guard(m_clientWrapper.lock(), &IClientWrapper::DeleteResource,
- OCDevAddr(), uri, HeaderOptions(),
+ return checked_guard(m_clientWrapper.lock(), &IClientWrapper::PostResourceRepresentation,
+ OCDevAddr(), uri, propertyValue, query, HeaderOptions(),
m_connType, cloudConnectHandler, m_defaultQos);
}
-OCStackResult OCAccountManager::observeGroup(const std::string& groupId,
- ObserveCallback cloudConnectHandler)
+OCStackResult OCAccountManager::updatePropertyValueOnGroup(const std::string& groupId,
+ const OCRepresentation propertyValue,
+ PostCallback cloudConnectHandler)
{
- if (groupId.empty())
- {
- return result_guard(OC_STACK_INVALID_PARAM);
- }
+ VERIFY_NON_EMPTY(groupId, "groupId cannot be empty.", OC_STACK_INVALID_PARAM);
std::string uri = m_host + OC_RSRVD_ACL_GROUP_URI + "/" + groupId;
- OCDoHandle handle = nullptr;
+ return checked_guard(m_clientWrapper.lock(), &IClientWrapper::PostResourceRepresentation,
+ OCDevAddr(), uri, propertyValue, QueryParamsMap(), HeaderOptions(),
+ m_connType, cloudConnectHandler, m_defaultQos);
+}
- OCStackResult result = checked_guard(m_clientWrapper.lock(), &IClientWrapper::ObserveResource,
- ObserveType::Observe, &handle, OCDevAddr(), uri,
- QueryParamsMap(), HeaderOptions(), cloudConnectHandler,
- m_defaultQos);
+OCStackResult OCAccountManager::observeGroup(ObserveCallback cloudConnectHandler)
+{
+ VERIFY_NON_EMPTY(m_userUuid, "Need to sign-in first.", OC_STACK_ERROR);
- if (OC_STACK_OK == result)
- {
- m_groupObserveHandles.insert(std::pair<std::string, OCDoHandle>(groupId, handle));
- }
+ std::string uri = m_host + OC_RSRVD_ACL_GROUP_URI;
- return result;
+ QueryParamsMap query = {};
+ query.insert(std::make_pair(OC_RSRVD_MEMBERS, m_userUuid));
+ return checked_guard(m_clientWrapper.lock(), &IClientWrapper::ObserveResource,
+ ObserveType::Observe, &m_groupObserveHandle, OCDevAddr(), uri,
+ query, HeaderOptions(), cloudConnectHandler, m_defaultQos);
}
-OCStackResult OCAccountManager::cancelObserveGroup(const std::string& groupId)
+OCStackResult OCAccountManager::cancelObserveGroup()
{
- if (groupId.empty())
- {
- return result_guard(OC_STACK_INVALID_PARAM);
- }
+ VERIFY_NON_EMPTY(m_userUuid, "Need to sign-in first.", OC_STACK_ERROR);
- auto found = m_groupObserveHandles.find(groupId);
- if (m_groupObserveHandles.end() == found)
+ if (nullptr == m_groupObserveHandle)
{
+ oclog() << "observeGroup() has not been done." << std::flush;
return result_guard(OC_STACK_INVALID_PARAM);
}
- OCDoHandle handle = found->second;
-
- std::string uri = m_host + OC_RSRVD_ACL_GROUP_URI + "/" + groupId;
+ std::string uri = m_host + OC_RSRVD_ACL_GROUP_URI
+ + "?" + OC_RSRVD_MEMBERS + "=" + m_userUuid;
OCStackResult result = checked_guard(m_clientWrapper.lock(),
- &IClientWrapper::CancelObserveResource, handle,
- (const char*)"", uri, HeaderOptions(), m_defaultQos);
-
+ &IClientWrapper::CancelObserveResource,
+ m_groupObserveHandle, (const char*)"", uri,
+ HeaderOptions(), m_defaultQos);
if (OC_STACK_OK == result)
{
- m_groupObserveHandles.erase(groupId);
- handle = nullptr;
+ m_groupObserveHandle = nullptr;
}
return result;
{
if (nullptr == m_invitationObserveHandle)
{
+ oclog() << "observeInvitation() has not been done." << std::flush;
return result_guard(OC_STACK_INVALID_PARAM);
}
&IClientWrapper::CancelObserveResource,
m_invitationObserveHandle,
(const char*)"", uri, HeaderOptions(), m_defaultQos);
-
if (OC_STACK_OK == result)
{
m_invitationObserveHandle = nullptr;
const std::string& userUuid,
PostCallback cloudConnectHandler)
{
- if (groupId.empty() || userUuid.empty())
- {
- return result_guard(OC_STACK_INVALID_PARAM);
- }
+ VERIFY_NON_EMPTY(m_userUuid, "Need to sign-in first.", OC_STACK_ERROR);
+ VERIFY_NON_EMPTY(groupId, "groupId cannot be empty.", OC_STACK_INVALID_PARAM);
+ VERIFY_NON_EMPTY(userUuid, "userUuid cannot be empty.", OC_STACK_INVALID_PARAM);
std::string uri = m_host + OC_RSRVD_ACL_INVITE_URI;
OCRepresentation invitation;
- invitation.setValue(OC_RSRVD_GROUP_ID, groupId);
- invitation.setValue(OC_RSRVD_MEMBER_ID, userUuid);
+ invitation.setValue<std::string>(OC_RSRVD_GROUP_ID, groupId);
+ invitation.setValue<std::string>(OC_RSRVD_MEMBER_ID, userUuid);
std::vector<OCRepresentation> invite{invitation};
OCRepresentation rep;
- rep.setValue(OC_RSRVD_INVITE, invite);
+ rep.setValue<std::string>(OC_RSRVD_USER_UUID, m_userUuid);
+ rep.setValue<std::vector<OCRepresentation>>(OC_RSRVD_INVITE, invite);
return checked_guard(m_clientWrapper.lock(), &IClientWrapper::PostResourceRepresentation,
OCDevAddr(), uri, rep, QueryParamsMap(), HeaderOptions(),
const std::string& userUuid,
DeleteCallback cloudConnectHandler)
{
- if (groupId.empty() || userUuid.empty())
- {
- return result_guard(OC_STACK_INVALID_PARAM);
- }
+ VERIFY_NON_EMPTY(groupId, "groupId cannot be empty.", OC_STACK_INVALID_PARAM);
+ VERIFY_NON_EMPTY(userUuid, "userUuid cannot be empty.", OC_STACK_INVALID_PARAM);
std::string uri = m_host + OC_RSRVD_ACL_INVITE_URI + "?" + OC_RSRVD_GROUP_ID + "=" + groupId
+ ";" + OC_RSRVD_MEMBER_ID + "=" + userUuid;
m_connType, cloudConnectHandler, m_defaultQos);
}
-OCStackResult OCAccountManager::deleteInvitation(const std::string& groupId,
- DeleteCallback cloudConnectHandler)
+OCStackResult OCAccountManager::replyToInvitation(const std::string& groupId,
+ const bool accept,
+ DeleteCallback cloudConnectHandler)
{
- if (groupId.empty())
- {
- return result_guard(OC_STACK_INVALID_PARAM);
- }
+ VERIFY_NON_EMPTY(groupId, "groupId cannot be empty.", OC_STACK_INVALID_PARAM);
- std::string uri = m_host + OC_RSRVD_ACL_INVITE_URI + "?" + OC_RSRVD_GROUP_ID + "=" + groupId;
+ std::string isAccept = accept ? "1" : "0";
+
+ std::string uri = m_host + OC_RSRVD_ACL_INVITE_URI + "?" + OC_RSRVD_GROUP_ID + "=" + groupId
+ + ";" + OC_RSRVD_ACCEPT + "=" + isAccept;
return checked_guard(m_clientWrapper.lock(), &IClientWrapper::DeleteResource,
OCDevAddr(), uri, HeaderOptions(),
TEST(SignOutTest, DISABLED_SignOutForValid)
{
std::string host("coap://192.168.1.2:5000");
+ std::string accessToken("AnyAccessToken");
OCAccountManager::Ptr accountManager = ConstructAccountManagerObject(host);
EXPECT_TRUE(NULL != accountManager);
- EXPECT_EQ(OC_STACK_OK, accountManager->signOut(&accountHandler));
+ EXPECT_EQ(OC_STACK_OK, accountManager->signOut(accessToken, &accountHandler));
}
TEST(SignOutTest, SignOutWithNullCallback)
{
std::string host("coap://192.168.1.2:5000");
+ std::string accessToken("AnyAccessToken");
OCAccountManager::Ptr accountManager = ConstructAccountManagerObject(host);
EXPECT_TRUE(NULL != accountManager);
- EXPECT_ANY_THROW(accountManager->signOut(nullptr));
+ EXPECT_ANY_THROW(accountManager->signOut(accessToken, nullptr));
}
// RefreshAccessToken Test
TEST(DeleteDeviceTest, DISABLED_DeleteDeviceForValid)
{
std::string host("coap://192.168.1.2:5000");
+ std::string accessToken("AnyAccessToken");
std::string deviceId("AnyDeviceId");
OCAccountManager::Ptr accountManager = ConstructAccountManagerObject(host);
EXPECT_TRUE(NULL != accountManager);
- EXPECT_EQ(OC_STACK_OK, accountManager->deleteDevice(deviceId, &deleteHandler));
+ EXPECT_EQ(OC_STACK_OK, accountManager->deleteDevice(accessToken, deviceId,
+ &deleteHandler));
}
TEST(DeleteDeviceTest, DeleteDeviceWithNullCallback)
{
std::string host("coap://192.168.1.2:5000");
+ std::string accessToken("AnyAccessToken");
std::string deviceId("AnyDeviceId");
OCAccountManager::Ptr accountManager = ConstructAccountManagerObject(host);
EXPECT_TRUE(NULL != accountManager);
- EXPECT_ANY_THROW(accountManager->deleteDevice(deviceId, nullptr));
+ EXPECT_ANY_THROW(accountManager->deleteDevice(accessToken, deviceId, nullptr));
}
// CreateGroup Test
std::string host("coap://192.168.1.2:5000");
OCAccountManager::Ptr accountManager = ConstructAccountManagerObject(host);
EXPECT_TRUE(NULL != accountManager);
- EXPECT_EQ(OC_STACK_OK, accountManager->createGroup(AclGroupType::PUBLIC, &accountHandler));
- }
-
- TEST(CreateGroupTest, CreateGroupWithNullCallback)
- {
- std::string host("coap://192.168.1.2:5000");
- OCAccountManager::Ptr accountManager = ConstructAccountManagerObject(host);
- EXPECT_TRUE(NULL != accountManager);
- EXPECT_ANY_THROW(accountManager->createGroup(AclGroupType::PUBLIC, nullptr));
+ EXPECT_EQ(OC_STACK_OK, accountManager->createGroup(&accountHandler));
}
- // GetGroupList Test
- TEST(GetGroupListTest, DISABLED_GetGroupListForValid)
+ TEST(CreateGroupTest, DISABLED_CreateGroupWithOptionForValid)
{
std::string host("coap://192.168.1.2:5000");
OCAccountManager::Ptr accountManager = ConstructAccountManagerObject(host);
EXPECT_TRUE(NULL != accountManager);
- EXPECT_EQ(OC_STACK_OK, accountManager->getGroupList(&accountHandler));
+ std::string property("AnyProperty");
+ std::string value("AnyValue");
+ QueryParamsMap query = {};
+ query.insert(std::pair<std::string, std::string>(property, value));
+ EXPECT_EQ(OC_STACK_OK, accountManager->createGroup(query, &accountHandler));
}
- TEST(GetGroupListTest, GetGroupListWithNullCallback)
+ TEST(CreateGroupTest, CreateGroupWithNullCallback)
{
std::string host("coap://192.168.1.2:5000");
OCAccountManager::Ptr accountManager = ConstructAccountManagerObject(host);
EXPECT_TRUE(NULL != accountManager);
- EXPECT_ANY_THROW(accountManager->getGroupList(nullptr));
+ EXPECT_ANY_THROW(accountManager->createGroup(nullptr));
}
// DeleteGroup Test
EXPECT_ANY_THROW(accountManager->deleteGroup(groupId, nullptr));
}
- // JoinGroup Test
- TEST(JoinGroupTest, DISABLED_JoinGroupForValid)
+ // GetGroupInfoAll Test
+ TEST(GetGroupInfoAllTest, DISABLED_GetGroupInfoAllForValid)
{
std::string host("coap://192.168.1.2:5000");
- std::string groupId("AnyGroupId");
OCAccountManager::Ptr accountManager = ConstructAccountManagerObject(host);
EXPECT_TRUE(NULL != accountManager);
- EXPECT_EQ(OC_STACK_OK, accountManager->joinGroup(groupId, &accountHandler));
+ EXPECT_EQ(OC_STACK_OK, accountManager->getGroupInfoAll(&accountHandler));
}
- TEST(JoinGroupTest, JoinGroupWithNullCallback)
+ TEST(GetGroupInfoAllTest, GetGroupInfoAllWithNullCallback)
{
std::string host("coap://192.168.1.2:5000");
- std::string groupId("AnyGroupId");
OCAccountManager::Ptr accountManager = ConstructAccountManagerObject(host);
EXPECT_TRUE(NULL != accountManager);
- EXPECT_ANY_THROW(accountManager->joinGroup(groupId, nullptr));
+ EXPECT_ANY_THROW(accountManager->getGroupInfoAll(nullptr));
}
- // AddDeviceToGroup Test
- TEST(AddDeviceToGroupTest, DISABLED_AddDeviceToGroupForValid)
- {
- std::string host("coap://192.168.1.2:5000");
- std::string groupId("AnyGroupId");
- std::vector<std::string> deviceId = {"AnyDevideId"};
- OCAccountManager::Ptr accountManager = ConstructAccountManagerObject(host);
- EXPECT_TRUE(NULL != accountManager);
- EXPECT_EQ(OC_STACK_OK, accountManager->addDeviceToGroup(groupId, deviceId,
- &accountHandler));
- }
-
- TEST(AddDeviceToGroupTest, AddDeviceToGroupWithNullCallback)
- {
- std::string host("coap://192.168.1.2:5000");
- std::string groupId("AnyGroupId");
- std::vector<std::string> deviceId = {"AnyDevideId"};
- OCAccountManager::Ptr accountManager = ConstructAccountManagerObject(host);
- EXPECT_TRUE(NULL != accountManager);
- EXPECT_ANY_THROW(accountManager->addDeviceToGroup(groupId, deviceId, nullptr));
- }
-
- TEST(AddDeviceToGroupTest, AddDeviceToGroupWithEmptyDeviceID)
+ // GetGroupInfo Test
+ TEST(GetGroupInfoTest, DISABLED_GetGroupInfoForValid)
{
std::string host("coap://192.168.1.2:5000");
std::string groupId("AnyGroupId");
- std::vector<std::string> deviceId = {};
OCAccountManager::Ptr accountManager = ConstructAccountManagerObject(host);
EXPECT_TRUE(NULL != accountManager);
- EXPECT_ANY_THROW(accountManager->addDeviceToGroup(groupId, deviceId, &accountHandler));
+ EXPECT_EQ(OC_STACK_OK, accountManager->getGroupInfo(groupId, &accountHandler));
}
- // GetGroupInfo Test
- TEST(GetGroupInfoTest, DISABLED_GetGroupInfoForValid)
+ TEST(GetGroupInfoTest, GetGroupInfoWithNullCallback)
{
std::string host("coap://192.168.1.2:5000");
std::string groupId("AnyGroupId");
OCAccountManager::Ptr accountManager = ConstructAccountManagerObject(host);
EXPECT_TRUE(NULL != accountManager);
- EXPECT_EQ(OC_STACK_OK, accountManager->getGroupInfo(groupId, &accountHandler));
+ EXPECT_ANY_THROW(accountManager->getGroupInfo(groupId, nullptr));
}
- TEST(GetGroupInfoTest, GetGroupInfoWithNullCallback)
+ // AddPropertyValueToGroup Test
+ TEST(AddPropertyValueToGroupTest, DISABLED_AddPropertyValueToGroupForValid)
{
std::string host("coap://192.168.1.2:5000");
std::string groupId("AnyGroupId");
+ OCRepresentation propertyValue;
+ propertyValue.setValue("AnyProperty", "AnyValue");
OCAccountManager::Ptr accountManager = ConstructAccountManagerObject(host);
EXPECT_TRUE(NULL != accountManager);
- EXPECT_ANY_THROW(accountManager->getGroupInfo(groupId, nullptr));
+ EXPECT_EQ(OC_STACK_OK, accountManager->addPropertyValueToGroup(groupId, propertyValue,
+ &accountHandler));
}
- // LeaveGroup Test
- TEST(LeaveGroupTest, DISABLED_LeaveGroupForValid)
+ TEST(AddPropertyValueToGroupTest, AddPropertyValueToGroupWithNullCallback)
{
std::string host("coap://192.168.1.2:5000");
std::string groupId("AnyGroupId");
+ OCRepresentation propertyValue;
+ propertyValue.setValue("AnyProperty", "AnyValue");
OCAccountManager::Ptr accountManager = ConstructAccountManagerObject(host);
EXPECT_TRUE(NULL != accountManager);
- EXPECT_EQ(OC_STACK_OK, accountManager->leaveGroup(groupId, &deleteHandler));
+ EXPECT_ANY_THROW(accountManager->addPropertyValueToGroup(groupId, propertyValue,
+ nullptr));
}
- TEST(LeaveGroupTest, LeaveGroupWithNullCallback)
+ // DeletePropertyValueFromGroup Test
+ TEST(DeletePropertyValueFromGroupTest, DISABLED_DeletePropertyValueFromGroupForValid)
{
std::string host("coap://192.168.1.2:5000");
std::string groupId("AnyGroupId");
+ OCRepresentation propertyValue;
+ propertyValue.setValue("AnyProperty", "AnyValue");
OCAccountManager::Ptr accountManager = ConstructAccountManagerObject(host);
EXPECT_TRUE(NULL != accountManager);
- EXPECT_ANY_THROW(accountManager->leaveGroup(groupId, nullptr));
+ EXPECT_EQ(OC_STACK_OK, accountManager->deletePropertyValueFromGroup(groupId, propertyValue,
+ &accountHandler));
}
- // DeleteDeviceFromGroup Test
- TEST(DeleteDeviceFromGroupTest, DISABLED_DeleteDeviceFromGroupForValid)
+ TEST(DeletePropertyValueFromGroupTest, DeletePropertyValueFromGroupWithNullCallback)
{
std::string host("coap://192.168.1.2:5000");
std::string groupId("AnyGroupId");
- std::vector<std::string> deviceId = {"AnyDevideId"};
+ OCRepresentation propertyValue;
+ propertyValue.setValue("AnyProperty", "AnyValue");
OCAccountManager::Ptr accountManager = ConstructAccountManagerObject(host);
EXPECT_TRUE(NULL != accountManager);
- EXPECT_EQ(OC_STACK_OK, accountManager->deleteDeviceFromGroup(groupId, deviceId,
- &deleteHandler));
+ EXPECT_ANY_THROW(accountManager->deletePropertyValueFromGroup(groupId, propertyValue,
+ nullptr));
}
- TEST(DeleteDeviceFromGroupTest, DeleteDeviceFromGroupWithNullCallback)
+ // UpdatePropertyValueOnGroup Test
+ TEST(UpdatePropertyValueOnGroupTest, DISABLED_UpdatePropertyValueOnGroupForValid)
{
std::string host("coap://192.168.1.2:5000");
std::string groupId("AnyGroupId");
- std::vector<std::string> deviceId = {"AnyDevideId"};
+ OCRepresentation propertyValue;
+ propertyValue.setValue("AnyProperty", "AnyValue");
OCAccountManager::Ptr accountManager = ConstructAccountManagerObject(host);
EXPECT_TRUE(NULL != accountManager);
- EXPECT_ANY_THROW(accountManager->deleteDeviceFromGroup(groupId, deviceId, nullptr));
+ EXPECT_EQ(OC_STACK_OK, accountManager->updatePropertyValueOnGroup(groupId, propertyValue,
+ &accountHandler));
}
- TEST(DeleteDeviceFromGroupTest, DeleteDeviceFromGroupEmptyDeviceID)
+ TEST(UpdatePropertyValueOnGroupTest, UpdatePropertyValueOnGroupWithNullCallback)
{
std::string host("coap://192.168.1.2:5000");
std::string groupId("AnyGroupId");
- std::vector<std::string> deviceId = {};
+ OCRepresentation propertyValue;
+ propertyValue.setValue("AnyProperty", "AnyValue");
OCAccountManager::Ptr accountManager = ConstructAccountManagerObject(host);
EXPECT_TRUE(NULL != accountManager);
- EXPECT_ANY_THROW(accountManager->deleteDeviceFromGroup(groupId, deviceId,
- &deleteHandler));
+ EXPECT_ANY_THROW(accountManager->updatePropertyValueOnGroup(groupId, propertyValue,
+ nullptr));
}
// ObserveGroup Test
TEST(ObserveGroupTest, DISABLED_ObserveGroupForValid)
{
std::string host("coap://192.168.1.2:5000");
- std::string groupId("AnyGroupId");
OCAccountManager::Ptr accountManager = ConstructAccountManagerObject(host);
EXPECT_TRUE(NULL != accountManager);
- EXPECT_EQ(OC_STACK_OK, accountManager->observeGroup(groupId, &onObserve));
+ EXPECT_EQ(OC_STACK_OK, accountManager->observeGroup(&onObserve));
}
TEST(ObserveGroupTest, ObserveGroupWithNullCallback)
std::string groupId("AnyGroupId");
OCAccountManager::Ptr accountManager = ConstructAccountManagerObject(host);
EXPECT_TRUE(NULL != accountManager);
- EXPECT_ANY_THROW(accountManager->observeGroup(groupId, nullptr));
+ EXPECT_ANY_THROW(accountManager->observeGroup(nullptr));
}
// CancelObserveGroup Test
std::string groupId("AnyGroupId");
OCAccountManager::Ptr accountManager = ConstructAccountManagerObject(host);
EXPECT_TRUE(NULL != accountManager);
- EXPECT_EQ(OC_STACK_OK, accountManager->observeGroup(groupId, &onObserve));
- EXPECT_EQ(OC_STACK_OK, accountManager->cancelObserveGroup(groupId));
+ EXPECT_EQ(OC_STACK_OK, accountManager->observeGroup(&onObserve));
+ EXPECT_EQ(OC_STACK_OK, accountManager->cancelObserveGroup());
}
TEST(CancelObserveGroupTest, CancelObserveGroupWithoutObserve)
std::string groupId("AnyGroupId");
OCAccountManager::Ptr accountManager = ConstructAccountManagerObject(host);
EXPECT_TRUE(NULL != accountManager);
- EXPECT_ANY_THROW(accountManager->cancelObserveGroup(groupId));
+ EXPECT_ANY_THROW(accountManager->cancelObserveGroup());
}
// ObserveInvitation Test
EXPECT_ANY_THROW(accountManager->cancelInvitation(groupId, userId, nullptr));
}
- // DeleteInvitation Test
- TEST(DeleteInvitationTest, DISABLED_DeleteInvitationForValid)
+ // ReplyToInvitation Test
+ TEST(ReplyToInvitationTest, DISABLED_ReplyToInvitationForValid)
{
std::string host("coap://192.168.1.2:5000");
std::string groupId("AnyGroupId");
OCAccountManager::Ptr accountManager = ConstructAccountManagerObject(host);
EXPECT_TRUE(NULL != accountManager);
- EXPECT_EQ(OC_STACK_OK, accountManager->deleteInvitation(groupId, &deleteHandler));
+ EXPECT_EQ(OC_STACK_OK, accountManager->replyToInvitation(groupId, true, &deleteHandler));
}
- TEST(DeleteInvitationTest, DeleteInvitationWithNullCallback)
+ TEST(ReplyToInvitationTest, ReplyToInvitationWithNullCallback)
{
std::string host("coap://192.168.1.2:5000");
std::string groupId("AnyGroupId");
OCAccountManager::Ptr accountManager = ConstructAccountManagerObject(host);
EXPECT_TRUE(NULL != accountManager);
- EXPECT_ANY_THROW(accountManager->deleteInvitation(groupId, nullptr));
+ EXPECT_ANY_THROW(accountManager->replyToInvitation(groupId, true, nullptr));
}
}