From a67cf3c8d047326de679b977e7eed721348e58f9 Mon Sep 17 00:00:00 2001 From: "nikhil.a" Date: Wed, 12 Oct 2016 12:45:01 +0530 Subject: [PATCH] Add doxygen comment for java api's of ProviderServicer and ConsumerService. Change-Id: I149a714258db8495473064c98f270b9b01fd2497 Signed-off-by: nikhil.a Reviewed-on: https://gerrit.iotivity.org/gerrit/13011 Tested-by: jenkins-iotivity Reviewed-by: Uze Choi --- .../service/ns/consumer/ConsumerService.java | 27 ++++++++ .../org/iotivity/service/ns/consumer/Provider.java | 62 +++++++++++++++++ .../org/iotivity/service/ns/provider/Consumer.java | 27 ++++++++ .../service/ns/provider/ProviderService.java | 79 +++++++++++++++++++++- 4 files changed, 193 insertions(+), 2 deletions(-) diff --git a/service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/consumer/ConsumerService.java b/service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/consumer/ConsumerService.java index 7641ccc..58bf57a 100755 --- a/service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/consumer/ConsumerService.java +++ b/service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/consumer/ConsumerService.java @@ -51,11 +51,20 @@ public class ConsumerService { instance = new ConsumerService(); } + + /** + * API for getting instance of ConsumerService + * @return ConsumerService singleton instance created + */ public static ConsumerService getInstance() { return instance; } + /** + * Start ConsumerService + * @param onProviderDiscoveredListener - OnProviderDiscoveredListener Callback Interface + */ public void start( OnProviderDiscoveredListener onProviderDiscoveredListener ) throws NSException @@ -63,23 +72,41 @@ public class ConsumerService nativeStart(onProviderDiscoveredListener); } + /** + * Stop ConsumerService + */ public void stop() throws NSException { nativeStop(); } + /** + * Request to publish resource to cloud server + * @param[in] serverAddress combined with IP address and port number using delimiter : + * @return result code + */ public void enableRemoteService(String serverAddress) throws NSException { nativeEnableRemoteService(serverAddress); } + /** + * Request discovery manually + */ public void rescanProvider() throws NSException { nativeRescanProvider(); } + /** + * Interface to implement callback function to receive provider on discovery + */ public interface OnProviderDiscoveredListener { + /** + * Callback function to receive provider on discovery + * @param provider - Provider object + */ public void onProviderDiscovered(Provider provider); } diff --git a/service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/consumer/Provider.java b/service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/consumer/Provider.java index 69e410e..3dda268 100755 --- a/service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/consumer/Provider.java +++ b/service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/consumer/Provider.java @@ -32,6 +32,9 @@ public class Provider { private static final String LOG_TAG = "ConsumerService_Provider"; + /** + * ProviderState of Notification resource + */ public enum ProviderState { ALLOW(1), @@ -54,6 +57,10 @@ public class Provider public String mProviderId = null; private long mNativeHandle = 0; + /** + * Constructor of Provider. + * @param providerId - providerId of Provider. + */ public Provider(String providerId) { Log.i (LOG_TAG, "Provider()"); @@ -61,36 +68,65 @@ public class Provider mProviderId = providerId; } + /** + * API for getting providerId. + * @return ConsumerId as string. + */ public String getProviderId() { return mProviderId ; } + /** + * API for getting for getting Topic List. + * @return TopicsList. + */ public TopicsList getTopicList() throws NSException { return nativeGetTopicList(); } + /** + * API for getting for getting ProviderState. + * @return ProviderState. + */ public ProviderState getProviderState() throws NSException { return nativeGetProviderState(); } + /** + * API for for requesting subscription of Notification service. + */ public void subscribe() throws NSException { nativeSubscribe(); } + /** + * API for for requesting subscription status from Provider of Notification service. + */ public boolean isSubscribed () throws NSException { return nativeIsSubscribed(); } + /** + * This method is for Sending SyncInfo of Notification service. + * @param messageId - id of message. + * @param syncType - SyncType of Notification service. + */ public void sendSyncInfo(long messageId, SyncInfo.SyncType syncType) throws NSException { nativeSendSyncInfo(messageId, syncType.ordinal()); } + /** + * This method is for registering for listeners of Notification . + * @param onProviderStateListener - OnProviderStateListener callback Interface. + * @param onMessageReceivedListner - OnMessageReceivedListner callback Interface. + * @param onSyncInfoReceivedListner - OnSyncInfoReceivedListner callback Interface. + */ public void setListener(OnProviderStateListener onProviderStateListener, OnMessageReceivedListner onMessageReceivedListner, OnSyncInfoReceivedListner onSyncInfoReceivedListner) throws NSException @@ -98,23 +134,49 @@ public class Provider nativeSetListener(onProviderStateListener, onMessageReceivedListner, onSyncInfoReceivedListner); } + /** + * Update Topic list that is wanted to be subscribed from provider + * @param topicsList - TopicsList of interested Topics. + * @return :: result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL + */ public int updateTopicList(TopicsList topicsList) throws NSException { return nativeUpdateTopicList(topicsList); } + /** + * Interface to implement callback function to receive provider state information + */ public interface OnProviderStateListener { + /** + * Callback function to receive provider state information + * @param state - ProviderState + */ public void onProviderStateReceived(ProviderState state); } + /** + * Interface to implement callback function to receive Notification Message + */ public interface OnMessageReceivedListner { + /** + * Callback function to receive Notification Message + * @param message - Notification Message + */ public void onMessageReceived(Message message); } + /** + * Interface to implement callback function to receive message read synchronization + */ public interface OnSyncInfoReceivedListner { + /** + * Callback function to receive message read synchronization + * @param sync - SyncInfo + */ public void onSyncInfoReceived(SyncInfo sync); } diff --git a/service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/provider/Consumer.java b/service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/provider/Consumer.java index a711b2c..5abf280 100644 --- a/service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/provider/Consumer.java +++ b/service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/provider/Consumer.java @@ -29,31 +29,58 @@ public class Consumer public String mConsumerId = null; + /** + * Constructor of Consumer. + */ public Consumer(final String consumerId) { mConsumerId = consumerId; } + /** + * API for getting consumerId + * @return ConsumerId as string + */ public String getConsumerId( ) { return mConsumerId; } + /** + * API for accepting Subscription request. + * This function is valid only when subControllability is set true. + * @param accepted - boolean variable representing Subscription response as TRUE/FALSE. + * @return :: result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL + */ public int acceptSubscription(boolean accepted) throws NSException { return nativeAcceptSubscription(mConsumerId, accepted); } + /** + * Select a topic for a consumer + * @param topicName - Topic name to select + * @return :: result code + */ public int setTopic(String topicName) throws NSException { return nativeSetConsumerTopic(mConsumerId, topicName); } + /** + * Unselect a topic for a consumer + * @param topicName - Topic name to Unselect + * @return :: result code + */ public int unsetTopic(String topicName) throws NSException { return nativeUnsetConsumerTopic(mConsumerId, topicName); } + /** + * Request topic list with selection state for the consumer + * @return :: Topic list + */ public TopicsList getConsumerTopicList() throws NSException { return nativeGetConsumerTopicList(mConsumerId); diff --git a/service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/provider/ProviderService.java b/service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/provider/ProviderService.java index 7f69d2f..b15ba46 100644 --- a/service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/provider/ProviderService.java +++ b/service/notification/android/notification-service/src/main/java/org/iotivity/service/ns/provider/ProviderService.java @@ -48,78 +48,153 @@ public class ProviderService instance = new ProviderService(); } + /** + * API for getting instance of ProviderService + * @return ProviderService singleton instance created + */ public static ProviderService getInstance() { return instance; } + /** + * Start ProviderService + * @param subscribedListener - OnConsumerSubscribedListener Callback + * @param messageSynchronized - OnMessageSynchronizedListener Callback + * @param subControllability - Set the policy for notification servcie which checks whether + * provider is capable of denying the subscription of notification message from consumer and + * getting controllabliity to set consumer topic list. + * If true, provider is able to control subscription request and consumer topic list. + * Otherwise(policy is false), consumer can do the same. + * @param userInfo - User defined information such as device friendly name + * @param resourceSecurity - Set on/off for secure resource channel setting + * @return :: result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL + */ public int start(OnConsumerSubscribedListener subscribedListener, OnMessageSynchronizedListener messageSynchronized, - boolean subControllability, String userInfo, + boolean subControllability, String userInfo, boolean resourceSecurity) throws NSException { return nativeStart(subscribedListener, messageSynchronized, subControllability, userInfo, resourceSecurity); } + /** + * Stop ProviderService + * @return :: result code + */ public int stop() throws NSException { return nativeStop(); } + /** + * Send notification message to all subscribers + * @param message - Notification message including id, title, contentText + * @return :: result code + */ public int sendMessage(Message message) throws NSException { return nativeSendMessage(message); } + /** + * Send read-check to provider in order to synchronize notification status with other consumers + * @param messageId - ID of Notification message to synchronize the status + * @param syncType - SyncType of the SyncInfo message + */ public void sendSyncInfo ( long messageId , SyncInfo.SyncType syncType) throws NSException { nativeSendSyncInfo(messageId, syncType.ordinal()); } + /** + * Initialize Message class, Mandatory fields which are messge id and provider(device) id are filled with. + * @return Message + */ public Message createMessage () throws NSException { return nativeCreateMessage(); } + /** + * Request to publish resource to cloud server + * @param[in] servAdd combined with IP address and port number using delimiter : + * @return result code + */ public int enableRemoteService(String servAdd) throws NSException { return nativeEnableRemoteService(servAdd); } + /** + * Request to cancel remote service using cloud server + * @param[in] servAdd combined with IP address and port number using delimiter : + * @return result code + */ public int disableRemoteService(String servAdd) throws NSException { return nativeDisableRemoteService(servAdd); } + /** + * Add topic to topic list + * @param topicName - Topic name to add + * @return :: result code + */ public int registerTopic(String topicName) throws NSException { return nativeRegisterTopic(topicName); } + /** + * Delete topic from topic list + * @param topicName - Topic name to add + * @return :: result code + */ public int unregisterTopic(String topicName) throws NSException { return nativeUnregisterTopic(topicName); } + /** + * Request topics list already registered by provider user + * @return :: Topic list + */ public TopicsList getRegisteredTopicList() throws NSException { return nativeGetRegisteredTopicList(); } + /** + * Interface to implement callback function to receive subscription request of consumer + */ public interface OnConsumerSubscribedListener { + + /** + * Callback function to receive subscription request of consumer + * @param consumer - Consumer who subscribes the notification message resource + */ public void onConsumerSubscribed(Consumer consumer); } + /** + * Interface to implement callback function to receive the status of the message synchronization + */ public interface OnMessageSynchronizedListener { + + /** + * Callback function to receive the status of the message synchronization + * @param syncInfo - Synchronization information of the notification message + */ public void onMessageSynchronized(SyncInfo syncInfo); } public native int nativeStart(OnConsumerSubscribedListener subscribedListener, OnMessageSynchronizedListener messageSynchronized, - boolean subControllability, String userInfo, + boolean subControllability, String userInfo, boolean resourceSecurity) throws NSException; public native int nativeStop() throws NSException; public native int nativeSendMessage(Message message) throws NSException; -- 2.7.4