private static final String LOG_TAG = "NotificationService_MediaContents";
- public String mIconImage = null;
+ private String mIconImage = null;
public MediaContents(String iconImage) {
Log.i(LOG_TAG, "MediaContents()");
}
};
- public long mMessageId = 0;
- public String mProviderId = null;
-
- public String mSourceName = null;
- public MessageType mType = MessageType.ALERT;
- public String mTime = null;
- public long mTTL = 0;
- public String mTitle = null;
- public String mContentText = null;
- public MediaContents mMediaContents = null;
- public String mTopic = null;
- public OcRepresentation mExtraInfo = null;
+ private long mMessageId = 0;
+ private String mProviderId = null;
+
+ private String mSourceName = null;
+ private MessageType mType = MessageType.ALERT;
+ private String mTime = null;
+ private long mTTL = 0;
+ private String mTitle = null;
+ private String mContentText = null;
+ private MediaContents mMediaContents = null;
+ private String mTopic = null;
+ private OcRepresentation mExtraInfo = null;
private long mNativeHandle = 0;
}
};
- public long mMessageId = 0;
- public String mProviderId = null;
- public SyncType mState = SyncType.UNREAD;
+ private long mMessageId = 0;
+ private String mProviderId = null;
+ private SyncType mState = SyncType.UNREAD;
public SyncInfo(long messageId, String providerId, SyncType state) {
Log.i(LOG_TAG, "SyncInfo()");
};
- public String mTopicName = null;
- public TopicState mState = TopicState.UNSUBSCRIBED;
+ private String mTopicName = null;
+ private TopicState mState = TopicState.UNSUBSCRIBED;
public Topic(String topicName, TopicState state) {
Log.i(LOG_TAG, "Topic()");
private static final String LOG_TAG = "NotificationService_TopicList";
- public Vector<Topic> mTopicsList = new Vector<Topic>();
+ private Vector<Topic> mTopicsList = new Vector<Topic>();
public void addTopic(String topicname, Topic.TopicState state) {
mTopicsList.add(new Topic(topicname, state));
* @param topicName
* the interest Topic name for subscription
*
- * @return result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
- *
* @throws NSException failed to subscribe to MQ server
*/
- public int subscribeMQService(String servAdd, String topicName)
+ public void subscribeMQService(String servAdd, String topicName)
throws NSException {
- return nativeSubscribeMQService(servAdd, topicName);
+ nativeSubscribeMQService(servAdd, topicName);
}
/**
private native void nativeEnableRemoteService(String serverAddress)
throws NSException;
- private native int nativeSubscribeMQService(String servAdd,
+ private native void nativeSubscribeMQService(String servAdd,
String topicName) throws NSException;
private native void nativeRescanProvider() throws NSException;
}
};
- public String mProviderId = null;
+ private String mProviderId = null;
private long mNativeHandle = 0;
/**
* @param topicsList
* TopicsList of interested Topics
*
- * @return result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
- *
* @throws NSException failure to update topic list.
*/
- public int updateTopicList(TopicsList topicsList) throws NSException {
- return nativeUpdateTopicList(topicsList);
+ public void updateTopicList(TopicsList topicsList) throws NSException {
+ nativeUpdateTopicList(topicsList);
}
/**
public native TopicsList nativeGetTopicList() throws NSException;
- private native int nativeUpdateTopicList(TopicsList topicsList)
+ private native void nativeUpdateTopicList(TopicsList topicsList)
throws NSException;
private native ProviderState nativeGetProviderState() throws NSException;
*/
public class Consumer {
- public String mConsumerId = null;
+ private String mConsumerId = null;
/**
* Constructor of Consumer
* boolean variable representing Subscription response as
* TRUE/FALSE.
*
- * @return result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
- *
* @throws NSException failure accepting subscription request
*/
- public int acceptSubscription(boolean accepted) throws NSException {
- return nativeAcceptSubscription(mConsumerId, accepted);
+ public void acceptSubscription(boolean accepted) throws NSException {
+ nativeAcceptSubscription(mConsumerId, accepted);
}
/**
* @param topicName
* Topic name to select
*
- * @return result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
- *
* @throws NSException failure selecting a topic
*/
- public int setTopic(String topicName) throws NSException {
- return nativeSetConsumerTopic(mConsumerId, topicName);
+ public void setTopic(String topicName) throws NSException {
+ nativeSetConsumerTopic(mConsumerId, topicName);
}
/**
* @param topicName
* Topic name to Unselect
*
- * @return result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
- *
* @throws NSException failure unselecting topic
*/
- public int unsetTopic(String topicName) throws NSException {
- return nativeUnsetConsumerTopic(mConsumerId, topicName);
+ public void unsetTopic(String topicName) throws NSException {
+ nativeUnsetConsumerTopic(mConsumerId, topicName);
}
/**
return nativeGetConsumerTopicList(mConsumerId);
}
- public native int nativeAcceptSubscription(String consumerId,
+ public native void nativeAcceptSubscription(String consumerId,
boolean accepted) throws NSException;
- public native int nativeSetConsumerTopic(String consumerId,
+ public native void nativeSetConsumerTopic(String consumerId,
String topicName) throws NSException;
- public native int nativeUnsetConsumerTopic(String consumerId,
+ public native void nativeUnsetConsumerTopic(String consumerId,
String topicName) throws NSException;
public native TopicsList nativeGetConsumerTopicList(String consumerId)
* @param resourceSecurity
* Set on/off for secure resource channel setting
*
- * @return result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
- *
* @throws NSException
* if any callback parameter passed is null
*/
- public int start(OnConsumerSubscribedListener subscribedListener,
+ public void start(OnConsumerSubscribedListener subscribedListener,
OnMessageSynchronizedListener messageSynchronized,
boolean subControllability, String userInfo,
boolean resourceSecurity) throws NSException {
- return nativeStart(subscribedListener, messageSynchronized,
+ nativeStart(subscribedListener, messageSynchronized,
subControllability, userInfo, resourceSecurity);
}
/**
* Stop ProviderService
*
- * @return result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
- *
* @throws NSException failed to stop ProviderService
*/
- public int stop() throws NSException {
- return nativeStop();
+ public void stop() throws NSException {
+ nativeStop();
}
/**
* @param message
* Notification message including id, title, contentText
*
- * @return result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
- *
* @throws NSException failed to send notification message
*/
- public int sendMessage(Message message) throws NSException {
- return nativeSendMessage(message);
+ public void sendMessage(Message message) throws NSException {
+ nativeSendMessage(message);
}
/**
* servAdd combined with IP address and port number using
* delimiter
*
- * @return result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
- *
* @throws NSException failed to publish resource
*/
- public int enableRemoteService(String servAdd) throws NSException {
- return nativeEnableRemoteService(servAdd);
+ public void enableRemoteService(String servAdd) throws NSException {
+ nativeEnableRemoteService(servAdd);
}
/**
* servAdd combined with IP address and port number using
* delimiter
*
- * @return result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
- *
* @throws NSException failed to publish resource
*/
- public int disableRemoteService(String servAdd) throws NSException {
- return nativeDisableRemoteService(servAdd);
+ public void disableRemoteService(String servAdd) throws NSException {
+ nativeDisableRemoteService(servAdd);
}
/**
* @param topicName
* the interest Topic name for subscription
*
- * @return result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
- *
* @throws NSException failed to subscribe to MQ server
*/
- public int subscribeMQService(String servAdd, String topicName)
+ public void subscribeMQService(String servAdd, String topicName)
throws NSException {
- return nativeSubscribeMQService(servAdd, topicName);
+ nativeSubscribeMQService(servAdd, topicName);
}
/**
* @param topicName
* Topic name to add
*
- * @return result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
- *
* @throws NSException failed to add topic
*/
- public int registerTopic(String topicName) throws NSException {
- return nativeRegisterTopic(topicName);
+ public void registerTopic(String topicName) throws NSException {
+ nativeRegisterTopic(topicName);
}
/**
* @param topicName
* Topic name to add
*
- * @return result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
- *
* @throws NSException failed to delete topic
*/
- public int unregisterTopic(String topicName) throws NSException {
- return nativeUnregisterTopic(topicName);
+ public void unregisterTopic(String topicName) throws NSException {
+ nativeUnregisterTopic(topicName);
}
/**
* Request topics list already registered by provider user
*
- *
- * @return result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
*
* @throws NSException failed to get topics list
*/
public void onMessageSynchronized(SyncInfo syncInfo);
}
- public native int nativeStart(
+ public native void nativeStart(
OnConsumerSubscribedListener subscribedListener,
OnMessageSynchronizedListener messageSynchronized,
boolean subControllability, String userInfo,
boolean resourceSecurity) throws NSException;
- public native int nativeStop() throws NSException;
+ public native void nativeStop() throws NSException;
- public native int nativeSendMessage(Message message) throws NSException;
+ public native void nativeSendMessage(Message message) throws NSException;
public native void nativeSendSyncInfo(long messageId, int type)
throws NSException;
public native Message nativeCreateMessage() throws NSException;
- public native int nativeEnableRemoteService(String servAdd)
+ public native void nativeEnableRemoteService(String servAdd)
throws NSException;
- public native int nativeDisableRemoteService(String servAdd)
+ public native void nativeDisableRemoteService(String servAdd)
throws NSException;
- public native int nativeSubscribeMQService(String servAdd, String topicName)
+ public native void nativeSubscribeMQService(String servAdd, String topicName)
throws NSException;
- public native int nativeRegisterTopic(String topicName) throws NSException;
+ public native void nativeRegisterTopic(String topicName) throws NSException;
- public native int nativeUnregisterTopic(String topicName)
+ public native void nativeUnregisterTopic(String topicName)
throws NSException;
public native TopicsList nativeGetRegisteredTopicList() throws NSException;
return;\r
}\r
\r
-JNIEXPORT jint JNICALL\r
+JNIEXPORT void JNICALL\r
Java_org_iotivity_service_ns_consumer_ConsumerService_nativeEnableRemoteService\r
(JNIEnv *env, jobject jObj, jstring jServerAddress)\r
{\r
if (!jServerAddress)\r
{\r
ThrowNSException(JNI_INVALID_VALUE, "EnableRemoteService server address NULL");\r
- return (jint) OIC::Service::NSResult::ERROR;\r
+ return;\r
}\r
const char *serverAddress = env->GetStringUTFChars(jServerAddress, 0);\r
OIC::Service::NSResult result =\r
if (result != OIC::Service::NSResult::OK)\r
{\r
ThrowNSException((int) result, "Fail to EnableRemoteService");\r
- return (jint) result;\r
+ return;\r
}\r
env->ReleaseStringUTFChars(jServerAddress, serverAddress);\r
LOGD (TAG,"ConsumerService_EnableRemoteService - OUT");\r
- return (jint) result;\r
+ return;\r
}\r
\r
-JNIEXPORT jint JNICALL\r
+JNIEXPORT void JNICALL\r
Java_org_iotivity_service_ns_consumer_ConsumerService_nativeSubscribeMQService\r
(JNIEnv *env, jobject jObj, jstring jserverAddress, jstring jTopicName)\r
{\r
if (!jserverAddress)\r
{\r
ThrowNSException(JNI_INVALID_VALUE, "Server Address Can't be NULL");\r
- return (jint) OIC::Service::NSResult::ERROR;\r
+ return;\r
}\r
if (!jTopicName)\r
{\r
ThrowNSException(JNI_INVALID_VALUE, "TopicName Can't be NULL");\r
- return (jint) OIC::Service::NSResult::ERROR;\r
+ return;\r
}\r
\r
const char *address = env->GetStringUTFChars( jserverAddress, NULL);\r
if (result != OIC::Service::NSResult::OK)\r
{\r
ThrowNSException((int) result, "Fail to Subscribe to MQ Service");\r
- return (jint) result;\r
+ return;\r
}\r
env->ReleaseStringUTFChars(jserverAddress, address);\r
env->ReleaseStringUTFChars(jTopicName, topic);\r
LOGD (TAG,"ConsumerService: nativeSubscribeMQService - OUT");\r
- return (jint) result;\r
+ return;\r
}\r
\r
JNIEXPORT void JNICALL Java_org_iotivity_service_ns_consumer_ConsumerService_nativeRescanProvider\r
return obj_topicList;\r
}\r
\r
-JNIEXPORT jint JNICALL Java_org_iotivity_service_ns_consumer_Provider_nativeUpdateTopicList\r
+JNIEXPORT void JNICALL Java_org_iotivity_service_ns_consumer_Provider_nativeUpdateTopicList\r
(JNIEnv *env, jobject jObj, jobject jTopicsList)\r
{\r
LOGD (TAG,"Provider_nativeUpdateTopicList -IN");\r
if (!jTopicsList)\r
{\r
ThrowNSException(JNI_INVALID_VALUE, "TopicList cannot be null");\r
- return (jint) OIC::Service::NSResult::ERROR;\r
+ return;\r
}\r
OIC::Service::NSTopicsList *nsTopicsList = getNativeTopicsList(env, jTopicsList);\r
if (nsTopicsList == nullptr)\r
{\r
ThrowNSException(JNI_INVALID_VALUE, "NSTopicList cannot be created ");\r
- return (jint) OIC::Service::NSResult::ERROR;\r
+ return;\r
}\r
\r
jclass providerClass = env->GetObjectClass(jObj);\r
if (!providerClass)\r
{\r
ThrowNSException(JNI_INVALID_VALUE, "Failed to Get ObjectClass for Provider");\r
- return (jint) OIC::Service::NSResult::ERROR;\r
+ return;\r
}\r
\r
jfieldID nativeHandle = env->GetFieldID(providerClass, "mNativeHandle", "J");\r
if (!nativeHandle)\r
{\r
ThrowNSException(JNI_INVALID_VALUE, "Failed to get nativeHandle for Provider");\r
- return (jint) OIC::Service::NSResult::ERROR;\r
+ return;\r
}\r
jlong jProvider = env->GetLongField(jObj, nativeHandle);\r
OIC::Service::NSResult result = OIC::Service::NSResult::ERROR;\r
if (provider == nullptr)\r
{\r
ThrowNSException(JNI_INVALID_VALUE, "Provider with Given Id doesn't exist");\r
- return (jint) OIC::Service::NSResult::ERROR;\r
+ return;\r
}\r
LOGD (TAG,"calling subscribe on ProviderID");\r
result = provider->updateTopicList(nsTopicsList);\r
if (result != OIC::Service::NSResult::OK)\r
{\r
ThrowNSException((int) result, "Fail to Update Interest Topics");\r
- return (jint) result;\r
+ return;\r
}\r
LOGD (TAG,"Provider_nativeUpdateTopicList -OUT");\r
- return (jint) result;\r
+ return;\r
}\r
\r
JNIEXPORT jobject JNICALL Java_org_iotivity_service_ns_consumer_Provider_nativeGetProviderState\r
/*\r
* Class: org_iotivity_service_ns_consumer_ConsumerService\r
* Method: nativeEnableRemoteService\r
- * Signature: (Ljava/lang/String;)I\r
+ * Signature: (Ljava/lang/String;)V\r
*/\r
-JNIEXPORT jint JNICALL\r
+JNIEXPORT void JNICALL\r
Java_org_iotivity_service_ns_consumer_ConsumerService_nativeEnableRemoteService\r
(JNIEnv *, jobject, jstring);\r
\r
/*\r
* Class: org_iotivity_service_ns_consumer_ConsumerService\r
* Method: nativeSubscribeMQService\r
- * Signature: (Ljava/lang/String;Ljava/lang/String;)I\r
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)V\r
*/\r
-JNIEXPORT jint JNICALL\r
+JNIEXPORT void JNICALL\r
Java_org_iotivity_service_ns_consumer_ConsumerService_nativeSubscribeMQService\r
(JNIEnv *, jobject, jstring, jstring);\r
\r
/*\r
* Class: org_iotivity_service_ns_consumer_Provider\r
* Method: nativeUpdateTopicList\r
- * Signature: (Lorg/iotivity/service/ns/common/TopicsList;)I\r
+ * Signature: (Lorg/iotivity/service/ns/common/TopicsList;)V\r
*/\r
-JNIEXPORT jint JNICALL Java_org_iotivity_service_ns_consumer_Provider_nativeUpdateTopicList\r
+JNIEXPORT void JNICALL Java_org_iotivity_service_ns_consumer_Provider_nativeUpdateTopicList\r
(JNIEnv *, jobject, jobject);\r
\r
/*\r
}
-JNIEXPORT jint JNICALL Java_org_iotivity_service_ns_provider_ProviderService_nativeStart
+JNIEXPORT void JNICALL Java_org_iotivity_service_ns_provider_ProviderService_nativeStart
(JNIEnv *env, jobject jObj, jobject jSubscriptionListener, jobject jSyncListener,
jboolean jPolicy, jstring jUserInfo, jboolean jResourceSecurity)
{
if (!jSubscriptionListener || !jSyncListener)
{
ThrowNSException(JNI_INVALID_VALUE, "Listener cannot be null");
- return (jint) OIC::Service::NSResult::ERROR;
+ return;
}
if (g_obj_subscriptionListener != NULL)
if (result != OIC::Service::NSResult::OK)
{
ThrowNSException((int) result, "Fail to start NSProviderService");
-
+ return;
}
LOGD (TAG,"JNIProviderService: nativeStart - OUT");
- return (jint) result;
+ return;
}
-JNIEXPORT jint JNICALL Java_org_iotivity_service_ns_provider_ProviderService_nativeStop
+JNIEXPORT void JNICALL Java_org_iotivity_service_ns_provider_ProviderService_nativeStop
(JNIEnv *env, jobject jObj)
{
LOGD (TAG,"JNIProviderService: nativeStop - IN");
if (result != OIC::Service::NSResult::OK)
{
ThrowNSException((int) result, "Fail to stop NSProviderService");
- return (jint) result;
+ return;
}
env->DeleteGlobalRef( g_obj_subscriptionListener);
g_obj_syncListener = NULL;
LOGD (TAG,"JNIProviderService: nativeStop - OUT");
- return (jint) result;
+ return;
}
-JNIEXPORT jint JNICALL Java_org_iotivity_service_ns_provider_ProviderService_nativeSendMessage
+JNIEXPORT void JNICALL Java_org_iotivity_service_ns_provider_ProviderService_nativeSendMessage
(JNIEnv *env, jobject jObj, jobject jMsg)
{
LOGD (TAG,"JNIProviderService: nativeSendMessage - IN");
if (!jMsg)
{
ThrowNSException(JNI_INVALID_VALUE, "Message cannot be null");
- return (jint) OIC::Service::NSResult::ERROR;
+ return;
}
OIC::Service::NSMessage *nsMsg = getNativeMessage(env, jMsg);
if (nsMsg == nullptr)
{
ThrowNSException(JNI_INVALID_VALUE, "Message didn't have a field ID ");
- return (jint) OIC::Service::NSResult::ERROR;
+ return;
}
OIC::Service::NSResult result = OIC::Service::NSProviderService::getInstance()->sendMessage(nsMsg);
if (result != OIC::Service::NSResult::OK)
{
ThrowNSException((int) result, "Fail to send NSProvider Message");
+ return;
}
LOGD (TAG,"JNIProviderService: nativeSendMessage - OUT");
- return (jint) result;
+ return;
}
JNIEXPORT void JNICALL Java_org_iotivity_service_ns_provider_ProviderService_nativeSendSyncInfo
return jMsg;
}
-JNIEXPORT jint JNICALL
+JNIEXPORT void JNICALL
Java_org_iotivity_service_ns_provider_ProviderService_nativeEnableRemoteService
(JNIEnv *env, jobject jObj, jstring jstr)
{
if (!jstr)
{
ThrowNSException(JNI_INVALID_VALUE, "Server Address Can't be NULL");
- return (jint) OIC::Service::NSResult::ERROR;
+ return;
}
const char *address = env->GetStringUTFChars( jstr, NULL);
if (result != OIC::Service::NSResult::OK)
{
ThrowNSException((int) result, "Fail to Enable Remote Service");
+ return;
}
env->ReleaseStringUTFChars(jstr, address);
LOGD (TAG,"JNIProviderService: nativeEnableRemoteService - OUT");
- return (jint) result;
+ return;
}
-JNIEXPORT jint JNICALL
+JNIEXPORT void JNICALL
Java_org_iotivity_service_ns_provider_ProviderService_nativeDisableRemoteService
(JNIEnv *env, jobject jObj, jstring jstr)
{
if (!jstr)
{
ThrowNSException(JNI_INVALID_VALUE, "Server Address Can't be NULL");
- return (jint) OIC::Service::NSResult::ERROR;
+ return;
}
const char *address = env->GetStringUTFChars( jstr, NULL);
if (result != OIC::Service::NSResult::OK)
{
ThrowNSException((int) result, "Fail to Disable Remote Service");
+ return;
}
env->ReleaseStringUTFChars(jstr, address);
LOGD (TAG,"JNIProviderService: nativeDisableRemoteService - OUT");
- return (jint) result;
+ return;
}
-JNIEXPORT jint JNICALL
+JNIEXPORT void JNICALL
Java_org_iotivity_service_ns_provider_ProviderService_nativeSubscribeMQService
(JNIEnv *env, jobject jObj, jstring jserverAddress, jstring jTopicName)
{
if (!jserverAddress)
{
ThrowNSException(JNI_INVALID_VALUE, "Server Address Can't be NULL");
- return (jint) OIC::Service::NSResult::ERROR;
+ return;
}
if (!jTopicName)
{
ThrowNSException(JNI_INVALID_VALUE, "TopicName Can't be NULL");
- return (jint) OIC::Service::NSResult::ERROR;
+ return;
}
const char *address = env->GetStringUTFChars( jserverAddress, NULL);
if (result != OIC::Service::NSResult::OK)
{
ThrowNSException((int) result, "Fail to Subscribe to MQ Service");
+ return;
}
env->ReleaseStringUTFChars(jserverAddress, address);
env->ReleaseStringUTFChars(jTopicName, topic);
LOGD (TAG,"JNIProviderService: nativeSubscribeMQService - OUT");
- return (jint) result;
+ return;
}
-JNIEXPORT jint JNICALL Java_org_iotivity_service_ns_provider_ProviderService_nativeRegisterTopic
+JNIEXPORT void JNICALL Java_org_iotivity_service_ns_provider_ProviderService_nativeRegisterTopic
(JNIEnv *env, jobject jObj, jstring jTopicName)
{
LOGD (TAG,"JNIProviderService: nativeRegisterTopic - IN");
if (!jTopicName)
{
ThrowNSException(JNI_INVALID_VALUE, "Topic Name Can't be NULL");
- return (jint) OIC::Service::NSResult::ERROR;
+ return;
}
const char *name = env->GetStringUTFChars( jTopicName, NULL);
std::string topicName(name);
if (result != OIC::Service::NSResult::OK)
{
ThrowNSException((int) result, "Fail to Register Topic");
+ return;
}
env->ReleaseStringUTFChars(jTopicName, name);
LOGD (TAG,"JNIProviderService: nativeRegisterTopic - OUT");
- return (jint) result;
+ return;
}
-JNIEXPORT jint JNICALL Java_org_iotivity_service_ns_provider_ProviderService_nativeUnregisterTopic
+JNIEXPORT void JNICALL Java_org_iotivity_service_ns_provider_ProviderService_nativeUnregisterTopic
(JNIEnv *env, jobject jObj, jstring jTopicName)
{
LOGD (TAG,"JNIProviderService: nativeUnregisterTopic - IN");
if (!jTopicName)
{
ThrowNSException(JNI_INVALID_VALUE, "Topic Name Can't be NULL");
- return (jint) OIC::Service::NSResult::ERROR;
+ return;
}
const char *name = env->GetStringUTFChars( jTopicName, NULL);
std::string topicName(name);
if (result != OIC::Service::NSResult::OK)
{
ThrowNSException((int) result, "Fail to Unregister Topic");
+ return;
}
env->ReleaseStringUTFChars(jTopicName, name);
LOGD (TAG,"JNIProviderService: nativeUnregisterTopic - OUT");
- return (jint) result;
+ return;
}
JNIEXPORT jobject JNICALL
return obj_topicList;
}
-JNIEXPORT jint JNICALL Java_org_iotivity_service_ns_provider_Consumer_nativeAcceptSubscription
+JNIEXPORT void JNICALL Java_org_iotivity_service_ns_provider_Consumer_nativeAcceptSubscription
(JNIEnv *env, jobject jObj, jstring jConsumerId, jboolean jAccepted)
{
LOGD (TAG,"JNIProviderService: nativeAcceptSubscription - IN");
if (!jConsumerId)
{
ThrowNSException(JNI_INVALID_VALUE, "ConsumerId Can't be NULL");
- return (jint) OIC::Service::NSResult::ERROR;
+ return;
}
const char *id = env->GetStringUTFChars( jConsumerId, NULL);
std::string consumerId(id);
if (result != OIC::Service::NSResult::OK)
{
ThrowNSException((int) result, "Fail to acceptSubscription");
- return (jint) result;
+ return;
}
}
LOGE (TAG,"Couldn't find consumer");
ThrowNSException(JNI_NO_NATIVE_POINTER, "Fail to find consumer");
- return (jint) OIC::Service::NSResult::ERROR;
+ return;
}
-JNIEXPORT jint JNICALL Java_org_iotivity_service_ns_provider_Consumer_nativeSetConsumerTopic
+JNIEXPORT void JNICALL Java_org_iotivity_service_ns_provider_Consumer_nativeSetConsumerTopic
(JNIEnv *env, jobject jObj, jstring jConsumerId, jstring jTopicName)
{
LOGD (TAG,"JNIProviderService: nativeSetConsumerTopic - IN");
if (!jConsumerId || !jTopicName)
{
ThrowNSException(JNI_INVALID_VALUE, "Topic Name or ConsumerId Can't be NULL");
- return (jint) OIC::Service::NSResult::ERROR;
+ return;
}
const char *name = env->GetStringUTFChars( jTopicName, NULL);
const char *id = env->GetStringUTFChars( jConsumerId, NULL);
if (!nsConsumer)
{
ThrowNSException(JNI_NO_NATIVE_POINTER, "Consumer does exists");
- return (jint) OIC::Service::NSResult::ERROR;
+ return;
}
OIC::Service::NSResult result = nsConsumer->setTopic(topicName);
if (result != OIC::Service::NSResult::OK)
{
ThrowNSException((int) result, "Fail to Select Topic");
+ return;
}
env->ReleaseStringUTFChars(jTopicName, name);
env->ReleaseStringUTFChars(jConsumerId, id);
LOGD (TAG,"JNIProviderService: nativeSetConsumerTopic - OUT");
- return (jint) result;
+ return;
}
-JNIEXPORT jint JNICALL Java_org_iotivity_service_ns_provider_Consumer_nativeUnsetConsumerTopic
+JNIEXPORT void JNICALL Java_org_iotivity_service_ns_provider_Consumer_nativeUnsetConsumerTopic
(JNIEnv *env, jobject jObj, jstring jConsumerId, jstring jTopicName)
{
LOGD (TAG,"JNIProviderService: nativeUnsetConsumerTopic - IN");
if (!jConsumerId || !jTopicName)
{
ThrowNSException(JNI_INVALID_VALUE, "Topic Name or ConsumerId Can't be NULL");
- return (jint) OIC::Service::NSResult::ERROR;
+ return;
}
const char *name = env->GetStringUTFChars( jTopicName, NULL);
const char *id = env->GetStringUTFChars( jConsumerId, NULL);
if (!nsConsumer)
{
ThrowNSException(JNI_NO_NATIVE_POINTER, "Consumer does exists");
- return (jint) OIC::Service::NSResult::ERROR;
+ return;
}
OIC::Service::NSResult result = nsConsumer->unsetTopic(topicName);
if (result != OIC::Service::NSResult::OK)
{
ThrowNSException((int) result, "Fail to Unselect Topic");
+ return;
}
env->ReleaseStringUTFChars(jTopicName, name);
env->ReleaseStringUTFChars(jConsumerId, id);
LOGD (TAG,"JNIProviderService: nativeUnsetConsumerTopic - OUT");
- return (jint) result;
+ return;
}
JNIEXPORT jobject JNICALL Java_org_iotivity_service_ns_provider_Consumer_nativeGetConsumerTopicList
/*
* Class: org_iotivity_service_ns_provider_ProviderService
* Method: nativeStart
- * Signature: (Lorg/iotivity/service/ns/provider/ProviderService/OnConsumerSubscribedListener;Lorg/iotivity/service/ns/provider/ProviderService/OnMessageSynchronizedListener;ZLjava/lang/String;Z)I
+ * Signature: (Lorg/iotivity/service/ns/provider/ProviderService/OnConsumerSubscribedListener;Lorg/iotivity/service/ns/provider/ProviderService/OnMessageSynchronizedListener;ZLjava/lang/String;Z)V
*/
-JNIEXPORT jint JNICALL Java_org_iotivity_service_ns_provider_ProviderService_nativeStart
+JNIEXPORT void JNICALL Java_org_iotivity_service_ns_provider_ProviderService_nativeStart
(JNIEnv *, jobject, jobject, jobject, jboolean, jstring, jboolean);
/*
* Class: org_iotivity_service_ns_provider_ProviderService
* Method: nativeStop
- * Signature: ()I
+ * Signature: ()V
*/
-JNIEXPORT jint JNICALL Java_org_iotivity_service_ns_provider_ProviderService_nativeStop
+JNIEXPORT void JNICALL Java_org_iotivity_service_ns_provider_ProviderService_nativeStop
(JNIEnv *, jobject);
/*
* Class: org_iotivity_service_ns_provider_ProviderService
* Method: nativeSendMessage
- * Signature: (Lorg/iotivity/service/ns/common/Message;)I
+ * Signature: (Lorg/iotivity/service/ns/common/Message;)V
*/
-JNIEXPORT jint JNICALL Java_org_iotivity_service_ns_provider_ProviderService_nativeSendMessage
+JNIEXPORT void JNICALL Java_org_iotivity_service_ns_provider_ProviderService_nativeSendMessage
(JNIEnv *, jobject, jobject);
/*
/*
* Class: org_iotivity_service_ns_provider_ProviderService
* Method: nativeEnableRemoteService
- * Signature: (Ljava/lang/String;)I
+ * Signature: (Ljava/lang/String;)V
*/
-JNIEXPORT jint JNICALL
+JNIEXPORT void JNICALL
Java_org_iotivity_service_ns_provider_ProviderService_nativeEnableRemoteService
(JNIEnv *, jobject, jstring);
/*
* Class: org_iotivity_service_ns_provider_ProviderService
* Method: nativeDisableRemoteService
- * Signature: (Ljava/lang/String;)I
+ * Signature: (Ljava/lang/String;)V
*/
-JNIEXPORT jint JNICALL
+JNIEXPORT void JNICALL
Java_org_iotivity_service_ns_provider_ProviderService_nativeDisableRemoteService
(JNIEnv *, jobject, jstring);
/*
* Class: org_iotivity_service_ns_provider_ProviderService
* Method: nativeSubscribeMQService
- * Signature: (Ljava/lang/String;Ljava/lang/String;)I
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)V
*/
-JNIEXPORT jint JNICALL
+JNIEXPORT void JNICALL
Java_org_iotivity_service_ns_provider_ProviderService_nativeSubscribeMQService
(JNIEnv *, jobject, jstring, jstring);
/*
* Class: org_iotivity_service_ns_provider_ProviderService
* Method: nativeRegisterTopic
- * Signature: (Ljava/lang/String;)I
+ * Signature: (Ljava/lang/String;)V
*/
-JNIEXPORT jint JNICALL Java_org_iotivity_service_ns_provider_ProviderService_nativeRegisterTopic
+JNIEXPORT void JNICALL Java_org_iotivity_service_ns_provider_ProviderService_nativeRegisterTopic
(JNIEnv *, jobject, jstring);
/*
* Class: org_iotivity_service_ns_provider_ProviderService
* Method: nativeUnregisterTopic
- * Signature: (Ljava/lang/String;)I
+ * Signature: (Ljava/lang/String;)V
*/
-JNIEXPORT jint JNICALL Java_org_iotivity_service_ns_provider_ProviderService_nativeUnregisterTopic
+JNIEXPORT void JNICALL Java_org_iotivity_service_ns_provider_ProviderService_nativeUnregisterTopic
(JNIEnv *, jobject, jstring);
/*
/*
* Class: org_iotivity_service_ns_provider_Consumer
* Method: nativeAcceptSubscription
- * Signature: (Ljava/lang/String;Z)I
+ * Signature: (Ljava/lang/String;Z)V
*/
-JNIEXPORT jint JNICALL Java_org_iotivity_service_ns_provider_Consumer_nativeAcceptSubscription
+JNIEXPORT void JNICALL Java_org_iotivity_service_ns_provider_Consumer_nativeAcceptSubscription
(JNIEnv *, jobject, jstring, jboolean);
/*
* Class: org_iotivity_service_ns_provider_Consumer
* Method: nativeSetConsumerTopic
- * Signature: (Ljava/lang/String;Ljava/lang/String;)I
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)V
*/
-JNIEXPORT jint JNICALL Java_org_iotivity_service_ns_provider_Consumer_nativeSetConsumerTopic
+JNIEXPORT void JNICALL Java_org_iotivity_service_ns_provider_Consumer_nativeSetConsumerTopic
(JNIEnv *, jobject, jstring, jstring);
/*
* Class: org_iotivity_service_ns_provider_Consumer
* Method: nativeUnsetConsumerTopic
- * Signature: (Ljava/lang/String;Ljava/lang/String;)I
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)V
*/
-JNIEXPORT jint JNICALL Java_org_iotivity_service_ns_provider_Consumer_nativeUnsetConsumerTopic
+JNIEXPORT void JNICALL Java_org_iotivity_service_ns_provider_Consumer_nativeUnsetConsumerTopic
(JNIEnv *, jobject, jstring, jstring);
/*
import org.iotivity.base.QualityOfService;
import org.iotivity.base.ServiceType;
import org.iotivity.service.ns.common.Message;
+import org.iotivity.service.ns.common.NSException;
+import org.iotivity.service.ns.common.NSErrorCode;
import org.iotivity.service.ns.common.Topic;
import org.iotivity.service.ns.common.TopicsList;
import org.iotivity.service.ns.common.SyncInfo;
registerTopic("OIC_TOPIC1");
assertEquals(true, response.get());
- int result = 0;
-
try {
TopicsList list = mProvider.getTopicList();
Iterator<Topic> it = list.getTopicsList().iterator();
Topic element = it.next();
element.setState(Topic.TopicState.SUBSCRIBED);
}
- result = mProvider.updateTopicList(list);
- } catch (Exception e) {
+ mProvider.updateTopicList(list);
+ } catch (NSException e) {
e.printStackTrace();
+ assertEquals(NSErrorCode.ERROR, e.getErrorCode());
}
- assertEquals(200, result);
}
@Test
public void onConsumerSubscribed(Consumer consumer) {
gConsumer = consumer;
try {
- int result = gConsumer.acceptSubscription(true);
- Log.i(TAG, "Notification AcceptSubscription: " + result);
+ gConsumer.acceptSubscription(true);
+ Log.i(TAG, "Notification AcceptSubscription" );
} catch (Exception e) {
-
+ e.printStackTrace();
}
}
return null;
}
-}
\ No newline at end of file
+}
}
}
- public int subscribeMQService(String servAdd, String topicName) {
+ public void subscribeMQService(String servAdd, String topicName) {
Log.i(TAG, "SubscribeMQService - IN");
- int result = 0;
try {
- result = consumerService.subscribeMQService(servAdd, topicName);
- Log.i(TAG, "Notification SubscribeMQService: " + result);
+ consumerService.subscribeMQService(servAdd, topicName);
} catch (Exception e) {
Log.e(TAG, "Exception: subscribeMQService : " + e);
}
Log.i(TAG, "SubscribeMQService - OUT");
- return result;
+ return;
}
public void rescanProvider() {
dialog.dismiss();
MQCloudAddress = ip.getText().toString();
MQCloudTopic = mqTopic.getText().toString();
- int result = mConsumerSample.subscribeMQService(
+ mConsumerSample.subscribeMQService(
MQCloudAddress, MQCloudTopic);
- TvLog.append("SubscribeMQService Result : " + result
- + "\n");
+ TvLog.append("SubscribeMQService success\n");
}
});
dialog.show();
import org.iotivity.base.PlatformConfig;
import org.iotivity.base.QualityOfService;
import org.iotivity.base.ServiceType;
+import org.iotivity.service.ns.common.NSException;
+import org.iotivity.service.ns.common.NSErrorCode;
import org.iotivity.service.ns.common.SyncInfo;
import org.iotivity.service.ns.common.Topic;
@Test
public void StartProviderPositiveWithPolicyTrue() {
- int result = 0;
try {
- result = gProviderRes.start(subCb, syncCb, true, "ok", false);
+ gProviderRes.start(subCb, syncCb, true, "ok", false);
gProviderRes.stop();
- } catch (Exception e) {
+ } catch (NSException e) {
e.printStackTrace();
+ assertEquals(NSErrorCode.OK, e.getErrorCode());
}
- assertEquals(100, result);
}
@Test
public void StartProviderPositiveWithPolicyFalse() {
- int result = 0;
try {
- result = gProviderRes.start(subCb, syncCb, false, "ok", false);
+ gProviderRes.start(subCb, syncCb, false, "ok", false);
gProviderRes.stop();
- } catch (Exception e) {
+ } catch (NSException e) {
e.printStackTrace();
+ assertEquals(NSErrorCode.OK, e.getErrorCode());
}
- assertEquals(100, result);
}
@Test
public void StopProviderPositive() {
- int result = 0;
try {
gProviderRes.start(subCb, syncCb, true, "ok", false);
- result = gProviderRes.stop();
- } catch (Exception e) {
+ gProviderRes.stop();
+ } catch (NSException e) {
e.printStackTrace();
+ assertEquals(NSErrorCode.OK, e.getErrorCode());
}
- assertEquals(100, result);
}
@Test
}
if (gRemoteService) {
TvLog.append("Enable Remote Service\n");
- int result = mProviderSample
- .enableRemoteService(RemoteAddress);
+ mProviderSample.enableRemoteService(RemoteAddress);
remoteService.setText(R.string.disableRemoteService);
gRemoteService = false;
remoteService.setEnabled(true);
- TvLog.append("EnableRemoteService Result : " + result
- + "\n");
+ TvLog.append("EnableRemoteService success \n");
} else {
TvLog.append("Disable Remote Service\n");
- int result = mProviderSample
- .disableRemoteService(RemoteAddress);
+ mProviderSample.disableRemoteService(RemoteAddress);
remoteService.setText(R.string.enableRemoteService);
gRemoteService = true;
remoteService.setEnabled(true);
- TvLog.append("DisableRemoteService Result : " + result
- + "\n");
+ TvLog.append("DisableRemoteService success\n");
}
}
break;
dialog.dismiss();
MQCloudAddress = ip.getText().toString();
MQCloudTopic = mqTopic.getText().toString();
- int result = mProviderSample.subscribeMQService(
+ mProviderSample.subscribeMQService(
MQCloudAddress, MQCloudTopic);
- TvLog.append("SubscribeMQService Result : " + result
- + "\n");
+ TvLog.append("SubscribeMQService success\n");
}
});
dialog.show();
configurePlatform();
gAcceptor = policy;
try {
- int result = ioTNotification.start(this, this, policy, "Info",
- false);
- Log.i(TAG, "Notification Start: " + result);
+ ioTNotification.start(this, this, policy, "Info", false);
} catch (Exception e) {
-
+ Log.e(TAG, "Exception: start : " + e);
}
-
Log.i(TAG, "Start ProviderService - OUT");
}
public void registerTopic() {
Log.i(TAG, "Register Topics -IN");
try {
- int result = ioTNotification.registerTopic("OCF_TOPIC1");
- Log.i(TAG, " RegisterTopic: " + result);
- result = ioTNotification.registerTopic("OCF_TOPIC2");
- Log.i(TAG, " RegisterTopic: " + result);
- result = ioTNotification.registerTopic("OCF_TOPIC3");
- Log.i(TAG, " RegisterTopic: " + result);
- result = ioTNotification.registerTopic("OCF_TOPIC4");
- Log.i(TAG, " RegisterTopic: " + result);
+ ioTNotification.registerTopic("OCF_TOPIC1");
+ ioTNotification.registerTopic("OCF_TOPIC2");
+ ioTNotification.registerTopic("OCF_TOPIC3");
+ ioTNotification.registerTopic("OCF_TOPIC4");
} catch (Exception e) {
-
+ Log.e(TAG, "Exception: registerTopic : "+ e);
}
Log.i(TAG, "Start ProviderService - OUT");
}
- public int setTopic() {
+ public void setTopic() {
Log.i(TAG, "Set Topic -IN");
if (gConsumer == null) {
- return 0;
+ return;
}
try {
- int result = gConsumer.setTopic("OCF_TOPIC1");
- Log.i(TAG, " Set Topic : " + result);
- result = gConsumer.setTopic("OCF_TOPIC2");
- Log.i(TAG, " Set Topic : " + result);
- result = gConsumer.setTopic("OCF_TOPIC3");
- Log.i(TAG, " Set Topic : " + result);
- result = gConsumer.setTopic("OCF_TOPIC4");
- Log.i(TAG, " Set Topic : " + result);
+ gConsumer.setTopic("OCF_TOPIC1");
+ gConsumer.setTopic("OCF_TOPIC2");
+ gConsumer.setTopic("OCF_TOPIC3");
+ gConsumer.setTopic("OCF_TOPIC4");
} catch (Exception e) {
-
+ Log.e(TAG, "Exception: setTopic : " + e);
}
- Log.i(TAG, "Start ProviderService - OUT");
- return 1;
+ Log.i(TAG, "setTopic ProviderService - OUT");
+ return;
}
public void stop() {
try {
OcPlatform.stopPresence();
} catch (Exception e) {
- Log.e(TAG,
- "Exception: stopping presence when terminating NS server: "
- + e);
+ Log.e(TAG,"Exception: stopping presence when terminating NS server: "+ e);
}
try {
- int result = ioTNotification.stop();
- Log.i(TAG, "Notification Stop: " + result);
+ ioTNotification.stop();
} catch (Exception e) {
-
+ Log.e(TAG, "Exception: stop : " + e);
}
Log.i(TAG, "Stop ProviderService - OUT");
Log.i(TAG, "SendMessage ProviderService - IN");
try {
- int result = ioTNotification.sendMessage(notiMessage);
- Log.i(TAG, "Notification Send Message: " + result);
+ ioTNotification.sendMessage(notiMessage);
} catch (Exception e) {
-
+ Log.e(TAG, "Exception: sendMessage : " + e);
}
Log.i(TAG, "SendMessage ProviderService - OUT");
ioTNotification.sendSyncInfo(messageId, syncType);
Log.i(TAG, "Notification Sync ");
} catch (Exception e) {
-
+ Log.e(TAG, "Exception: sendSyncInfo : " + e);
}
Log.i(TAG, "SendSyncInfo ProviderService - OUT");
msgMap.put("ID: " + messageId, SYNC_READ);
}
}
- public int enableRemoteService(String servAdd) {
+ public void enableRemoteService(String servAdd) {
Log.i(TAG, "EnableRemoteService ProviderService - IN");
- int result = 0;
try {
- result = ioTNotification.enableRemoteService(servAdd);
- Log.i(TAG, "Notification EnableRemoteService: " + result);
+ ioTNotification.enableRemoteService(servAdd);
} catch (Exception e) {
-
+ Log.e(TAG, "Exception: enableRemoteService : " + e);
}
Log.i(TAG, "EnableRemoteService ProviderService - OUT");
- return result;
+ return;
}
- public int disableRemoteService(String servAdd) {
+ public void disableRemoteService(String servAdd) {
Log.i(TAG, "DisableRemoteService ProviderService - IN");
- int result = 0;
try {
- result = ioTNotification.disableRemoteService(servAdd);
- Log.i(TAG, "Notification DisableRemoteService: " + result);
+ ioTNotification.disableRemoteService(servAdd);
} catch (Exception e) {
-
+ Log.e(TAG, "Exception: disableRemoteService : " + e);
}
Log.i(TAG, "DisableRemoteService ProviderService - OUT");
- return result;
+ return;
}
- public int subscribeMQService(String servAdd, String topicName) {
+ public void subscribeMQService(String servAdd, String topicName) {
Log.i(TAG, "SubscribeMQService ProviderService - IN");
- int result = 0;
try {
- result = ioTNotification.subscribeMQService(servAdd, topicName);
- Log.i(TAG, "Notification SubscribeMQService: " + result);
+ ioTNotification.subscribeMQService(servAdd, topicName);
} catch (Exception e) {
Log.e(TAG, "Exception: subscribeMQService : " + e);
}
Log.i(TAG, "SubscribeMQService ProviderService - OUT");
- return result;
+ return;
}
public void acceptSubscription(Consumer consumer, boolean accepted) {
Log.i(TAG, "AcceptSubscription ProviderService - IN");
try {
- int result = consumer.acceptSubscription(accepted);
- Log.i(TAG, "Notification AcceptSubscription: " + result);
+ consumer.acceptSubscription(accepted);
} catch (Exception e) {
-
+ Log.e(TAG, "Exception: acceptSubscription : " + e);
}
Log.i(TAG, "AcceptSubscription ProviderService - OUT");
}