X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=service%2Fnotification%2Fandroid%2Fnotification-service%2Fsrc%2Fmain%2Fjava%2Forg%2Fiotivity%2Fservice%2Fns%2Fprovider%2FProviderService.java;h=b7ae317de3208c73606e43b57a61758766a6d7a8;hb=8229635f6d207516ccbbdf23b13be164e0fc1787;hp=428b02270295b4d7b0073fcf9a816b6d3b9177ff;hpb=d75d150acc45cf4c8bb556a4dd24d36e2f3c0c41;p=platform%2Fupstream%2Fiotivity.git 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 old mode 100644 new mode 100755 index 428b022..b7ae317 --- 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 @@ -18,17 +18,18 @@ // //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= package org.iotivity.service.ns.provider; + import org.iotivity.service.ns.common.*; import java.util.Vector; + /** - * @class ProviderService - * @brief This class provides a set of Java APIs for Notification ProviderService. - */ -public class ProviderService -{ - - static - { + * + * This class provides a set of Java APIs for Notification ProviderService. + * + */ +public class ProviderService { + + static { System.loadLibrary("gnustl_shared"); System.loadLibrary("oc_logger"); System.loadLibrary("connectivity_abstraction"); @@ -43,88 +44,228 @@ public class ProviderService private static ProviderService instance; - static - { + static { instance = new ProviderService(); } - public static ProviderService getInstance() - { + /** + * API for getting instance of ProviderService + * + * @return ProviderService singleton instance created + */ + public static ProviderService getInstance() { return instance; } - public int start(OnConsumerSubscribedListener subscribedListener, - OnMessageSynchronizedListener messageSynchronized, - boolean subControllability, String userInfo) throws NSException - { - return nativeStart(subscribedListener, messageSynchronized,subControllability,userInfo); + /** + * 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 + * + * @throws NSException + * if any callback parameter passed is null + */ + public void start(OnConsumerSubscribedListener subscribedListener, + OnMessageSynchronizedListener messageSynchronized, + boolean subControllability, String userInfo, + boolean resourceSecurity) throws NSException { + nativeStart(subscribedListener, messageSynchronized, + subControllability, userInfo, resourceSecurity); } - public int stop() throws NSException - { - return nativeStop(); + /** + * Stop ProviderService + * + * @throws NSException failed to stop ProviderService + */ + public void stop() throws NSException { + nativeStop(); } - public int sendMessage(Message message) throws NSException - { - return nativeSendMessage(message); + /** + * Send notification message to all subscribers + * + * @param message + * Notification message including id, title, contentText + * + * @throws NSException failed to send notification message + */ + public void sendMessage(Message message) throws NSException { + nativeSendMessage(message); } - public void sendSyncInfo ( long messageId , SyncInfo.SyncType syncType) throws NSException - { + /** + * Send read-check to provider in order to synchronize notification status + * with other consumers + * + * @param messageId + * unique 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()); } - public Message createMessage () throws NSException - { + /** + * 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(); } - public int enableRemoteService(String servAdd) throws NSException - { - return nativeEnableRemoteService(servAdd); + /** + * Request to publish resource to cloud server + * + * @param servAdd + * servAdd combined with IP address and port number using + * delimiter + * + * @throws NSException failed to publish resource + */ + public void enableRemoteService(String servAdd) throws NSException { + nativeEnableRemoteService(servAdd); + } + + /** + * Request to cancel remote service using cloud server + * + * @param servAdd + * servAdd combined with IP address and port number using + * delimiter + * + * @throws NSException failed to publish resource + */ + public void disableRemoteService(String servAdd) throws NSException { + nativeDisableRemoteService(servAdd); } - public int disableRemoteService(String servAdd) throws NSException - { - return nativeDisableRemoteService(servAdd); + /** + * Request to subscribe to MQ server + * + * @param servAdd + * servAdd combined with IP address and port number and MQ broker + * uri using delimiter + * @param topicName + * the interest Topic name for subscription + * + * @throws NSException failed to subscribe to MQ server + */ + public void subscribeMQService(String servAdd, String topicName) + throws NSException { + nativeSubscribeMQService(servAdd, topicName); } - public int registerTopic(String topicName) throws NSException - { - return nativeRegisterTopic(topicName); + /** + * Add topic to topic list + * + * @param topicName + * Topic name to add + * + * @throws NSException failed to add topic + */ + public void registerTopic(String topicName) throws NSException { + nativeRegisterTopic(topicName); } - public int unregisterTopic(String topicName) throws NSException - { - return nativeUnregisterTopic(topicName); + /** + * Delete topic from topic list + * + * @param topicName + * Topic name to add + * + * @throws NSException failed to delete topic + */ + public void unregisterTopic(String topicName) throws NSException { + nativeUnregisterTopic(topicName); } - public TopicsList getRegisteredTopicList() throws NSException - { + /** + * Request topics list already registered by provider user + * + * @throws NSException failed to get topics list + */ + public TopicsList getRegisteredTopicList() throws NSException { return nativeGetRegisteredTopicList(); } - public interface OnConsumerSubscribedListener - { + /** + * 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); } - public interface OnMessageSynchronizedListener - { + /** + * 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) throws NSException; - public native int nativeStop() throws NSException; - public native int 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) throws NSException; - public native int nativeDisableRemoteService(String servAdd) throws NSException; - public native int nativeRegisterTopic(String topicName) throws NSException; - public native int nativeUnregisterTopic(String topicName) throws NSException; - public native TopicsList nativeGetRegisteredTopicList() throws NSException; + private native void nativeStart( + OnConsumerSubscribedListener subscribedListener, + OnMessageSynchronizedListener messageSynchronized, + boolean subControllability, String userInfo, + boolean resourceSecurity) throws NSException; + + private native void nativeStop() throws NSException; + + private native void nativeSendMessage(Message message) throws NSException; + + private native void nativeSendSyncInfo(long messageId, int type) + throws NSException; + + private native Message nativeCreateMessage() throws NSException; + + private native void nativeEnableRemoteService(String servAdd) + throws NSException; + + private native void nativeDisableRemoteService(String servAdd) + throws NSException; + + private native void nativeSubscribeMQService(String servAdd, String topicName) + throws NSException; + + private native void nativeRegisterTopic(String topicName) throws NSException; + + private native void nativeUnregisterTopic(String topicName) + throws NSException; + + private native TopicsList nativeGetRegisteredTopicList() throws NSException; }