replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / service / notification / include / NSConsumerInterface.h
index 0353e95..a25675f 100644 (file)
@@ -35,36 +35,41 @@ extern "C"
 #include "NSCommon.h"
 
 /**
- * Provider and consumer use this callback function to receive the status of the message
- * synchronization
- * @param[in] provider    Provider who requests synchronization with the status
- * @param[in] sync        Synchronization information of the notification message
+ * 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 (*NSSyncCallback)(NSProvider *, NSSyncInfo *);
+typedef void (* NSProviderStateCallback)(NSProvider *, NSProviderState);
 
 /**
- * Consumer uses this callback function to receive the discovered providers
- * @param[in] provider        Provider who has the notification resource
+ * Invoked when the notification message from provider is received
+ * synchronization
+ * @param[in] message  Notification message
  */
-typedef void (*NSProviderDiscoveredCallback)(NSProvider *);
+typedef void (* NSMessageReceivedCallback)(NSMessage *);
 
 /**
- * Consumer use this callback function to receive notification message from provider
+ * Invoked when the synchronization data which has notification message
+ * read/delete event from provider/consumer is received
  * synchronization
- * @param[in] provider    Provider who sends notification message
- * @param[in] message     Notification message
+ * @param[in] syncInfo  Synchronization information of the notification message
  */
-typedef void (*NSNotificationReceivedCallback)(NSProvider *, NSMessage *);
+typedef void (* NSSyncInfoReceivedCallback)(NSSyncInfo *);
+
+typedef struct
+{
+    NSProviderStateCallback changedCb;
+    NSMessageReceivedCallback messageCb;
+    NSSyncInfoReceivedCallback syncInfoCb;
+
+} NSConsumerConfig;
 
 /**
  * Initialize notification service for consumer
- * @param[in]  providerDiscoveredCallback   Callback function to discover notification providers
- * @param[in]  notificationReceivedCallback   Callback function to receive notification messages
- * @param[in]  syncCallback   Callback function to receive synchronization status of notification
+ * @param[in] config  NSConsumerconfig structure of callback functions
  * @return ::NS_OK or result code of NSResult
  */
-NSResult NSStartConsumer(NSProviderDiscoveredCallback discoverCb,
-        NSNotificationReceivedCallback postCb, NSSyncCallback syncCb);
+NSResult NSStartConsumer(NSConsumerConfig config);
 
 /**
  * Terminate notification service for consumer
@@ -73,6 +78,23 @@ NSResult NSStartConsumer(NSProviderDiscoveredCallback discoverCb,
 NSResult NSStopConsumer();
 
 /**
+ * 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);
+
+#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
  */
@@ -80,25 +102,50 @@ NSResult NSRescanProvider();
 
 /**
  * Request to subscribe notification message resource of provider
- * @param[in]  provider  Provider who send the notification message
+ * @param[in] providerId the Id of Provider who send the notification message
  * @return ::NS_OK or result code of NSResult
  */
-NSResult NSSubscribe(NSProvider *provider);
+NSResult NSSubscribe(const char * providerId);
 
 /**
  * Request to unsubscribe in order not to receive notification message from provider
- * @param[in]  provider  Provider who send the notification message
+ * @param[in]  providerId  the Id of Provider who send the notification message
  * @return ::NS_OK or result code of NSResult
  */
-NSResult NSUnsubscribe(NSProvider *provider);
+NSResult NSUnsubscribe(const char * providerId);
 
-NSResult NSConsumerReadCheck(NSMessage *);
+/**
+ * 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);
 
-NSResult NSConsumerDismissCheck(NSMessage *);
+/**
+ * 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);
 
-//** Remove below functions **//
-NSResult NSDropNSObject(NSMessage *);
-//** end of functions to be removed **//
+/**
+ * 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
 }