replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / service / notification / include / NSConsumerInterface.h
index 108f797..a25675f 100644 (file)
 //
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
+/**
+ * @file
+ *
+ * This file provides APIs of Notification Service for Consumer.
+ */
+
 #ifndef _NS_CONSUMER_INTERFACE_H_
 #define _NS_CONSUMER_INTERFACE_H_
 
 #ifdef __cplusplus
-extern "C" {
+extern "C"
+{
 #endif // __cplusplus
 
 #include "NSCommon.h"
 
-NSResult NSStartConsumer(
-        NSProviderDiscoveredCallback discoverCb,
-        NSNotificationReceivedCallback  postCb,
-        NSSyncCallback syncCb);
+/**
+ * Invoked when the provider state is changed
+ * @param[in] provider  Provider which has the notification resource
+ * @param[in] state  Response which has the provider state
+ */
+typedef void (* NSProviderStateCallback)(NSProvider *, NSProviderState);
 
-NSResult NSStopConsumer();
+/**
+ * Invoked when the notification message from provider is received
+ * synchronization
+ * @param[in] message  Notification message
+ */
+typedef void (* NSMessageReceivedCallback)(NSMessage *);
+
+/**
+ * Invoked when the synchronization data which has notification message
+ * read/delete event from provider/consumer is received
+ * synchronization
+ * @param[in] syncInfo  Synchronization information of the notification message
+ */
+typedef void (* NSSyncInfoReceivedCallback)(NSSyncInfo *);
 
-NSResult NSRead(NSMessage *);
+typedef struct
+{
+    NSProviderStateCallback changedCb;
+    NSMessageReceivedCallback messageCb;
+    NSSyncInfoReceivedCallback syncInfoCb;
 
-NSResult NSDismiss(NSMessage *);
+} NSConsumerConfig;
+
+/**
+ * Initialize notification service for consumer
+ * @param[in] config  NSConsumerconfig structure of callback functions
+ * @return ::NS_OK or result code of NSResult
+ */
+NSResult NSStartConsumer(NSConsumerConfig config);
+
+/**
+ * Terminate notification service for consumer
+ * @return ::NS_OK or result code of NSResult
+ */
+NSResult NSStopConsumer();
 
-NSResult NSSubscribeProvider(NSProvider *);
+/**
+ * Request to discover to remote address as parameter.
+ * @param[in] server address combined with IP address and port number using delimiter :
+ * @return ::NS_OK or result code of NSResult
+ */
+NSResult NSConsumerEnableRemoteService(const char * serverAddress);
 
-NSResult NSUnsubscribeProvider(NSProvider *);
+#ifdef WITH_MQ
+/**
+ * Request to subscribe to remote MQ address as parameter.
+ * @param[in] server address combined with IP address and port number and MQ broker uri using delimiter :
+ * @param[in] topicName the interest MQ Topic name for subscription.
+ * @return ::NS_OK or result code of NSResult
+ */
+NSResult NSConsumerSubscribeMQService(const char * serverAddress, const char * topicName);
+#endif
 
+/**
+ * Request discovery manually
+ * @return ::NS_OK or result code of NSResult
+ */
 NSResult NSRescanProvider();
 
-NSResult NSDropNSObject(NSMessage *);
+/**
+ * Request to subscribe notification message resource of provider
+ * @param[in] providerId the Id of Provider who send the notification message
+ * @return ::NS_OK or result code of NSResult
+ */
+NSResult NSSubscribe(const char * providerId);
+
+/**
+ * Request to unsubscribe in order not to receive notification message from provider
+ * @param[in]  providerId  the Id of Provider who send the notification message
+ * @return ::NS_OK or result code of NSResult
+ */
+NSResult NSUnsubscribe(const char * providerId);
+
+/**
+ * Send sync type to provider in order to synchronize notification status with other consumers
+ * when consumer consumes the notification such as READ, DELETE
+ * @param[in] providerId Provider id of the Notification message
+ * @param[in] messageId Notification message id to synchronize the status
+ * @param[in] type changed notification status from NSSyncType
+ * @return ::NS_OK or result code of NSResult
+ */
+NSResult NSConsumerSendSyncInfo(
+        const char * providerId, uint64_t messageId, NSSyncType type);
+
+/**
+ * Request NSProvider that is matched by provider id
+ * @param[in] providerId the id of provider that user wants to get
+ * @return NSProvider
+ */
+NSProvider * NSConsumerGetProvider(const char * providerId);
+
+/**
+ * Request NSTopic list that is subscribed from provider
+ * @param[in] providerId the Id of provider that user wants to get
+ * @return NSResult
+ */
+NSTopicLL * NSConsumerGetTopicList(const char * providerId);
+
+/**
+ * Select Topic list that is wanted to subscribe from provider
+ * @param[in] providerId the Id of provider that user wants to set
+ * @param[in] topics the topic list that user wants to set
+ * @return NSResult
+ */
+NSResult NSConsumerUpdateTopicList(const char * providerId, NSTopicLL * topics);
 
 #ifdef __cplusplus
 }