replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / service / notification / include / NSProviderInterface.h
index a85c521..260c554 100644 (file)
@@ -35,83 +35,154 @@ extern "C"
 #include "NSCommon.h"\r
 #include <stdbool.h>\r
 #include <stdint.h>\r
-\r
 /**\r
- * Invoked the subscription request from consumer is received\r
- * @param[in] consumer  Consumer who subscribes the resource\r
+ * Invoked when provider receives the subscription request of consumer.\r
+ * @param[in] consumer  Consumer who subscribes the notification message resource\r
  */\r
 typedef void (*NSSubscribeRequestCallback)(NSConsumer *);\r
 \r
 /**\r
- * Invoked when the synchronization data which has notification message \r
- * read/delete event from consumer is received\r
- * synchronization\r
- * @param[in] syncinfo  Synchronization information of the notification message\r
+ * Invoked when synchronization data which has notification message\r
+ * read/deleted event from consumer is received.\r
+ * @param[in] sync  Synchronization information of the notification message\r
  */\r
 typedef void (*NSProviderSyncInfoCallback)(NSSyncInfo *);\r
 \r
 /**\r
+ *  Set provider service with the following configuration\r
+ */\r
+typedef struct\r
+{\r
+    /* Invoked when the subscription request from consumer is received */\r
+    NSSubscribeRequestCallback subRequestCallback;\r
+    /* Invoked when the synchronization data, read and deleted, is sent by consumer is received */\r
+    NSProviderSyncInfoCallback syncInfoCallback;\r
+    /* Set the policy for notification servcie which checks whether provider is capable of \r
+     * denying the subscription of notification message from consumer\r
+     * and getting controllabliity to set consumer topic list.\r
+     * If true, provider is able to control subscription request and consumer topic list.\r
+     * Otherwise(policy is false), consumer can do the same.\r
+     */\r
+    bool subControllability;\r
+    /* User defined information such as device friendly name */\r
+    char * userInfo;\r
+    /* Set on/off for secure resource channel setting */\r
+    bool resourceSecurity;\r
+\r
+} NSProviderConfig;\r
+\r
+/**\r
  * Initialize notification service for provider\r
- * @param[in]  policy   Accepter\r
- * @param[in]  subscribeRequestCallback   Callback function to register for receiving\r
- * subscription request from consumer\r
- * @param[in]  syncCallback   Callback function to register for receiving  sync data\r
- * @return ::NS_OK or result code of NSResult\r
+ * @param[in]  config   Refer to NSProviderConfig\r
+ * @return ::NS_OK if the action is requested succesfully\r
  */\r
-NSResult NSStartProvider(bool policy, NSSubscribeRequestCallback subscribeRequestCb,\r
-        NSProviderSyncInfoCallback syncCb);\r
+NSResult NSStartProvider(NSProviderConfig config);\r
 \r
 /**\r
  * Terminate notification service for provider\r
- * @return ::NS_OK or result code of NSResult\r
+ * @return ::NS_OK if the action is requested succesfully\r
  */\r
 NSResult NSStopProvider();\r
 \r
 /**\r
- * Request to publish resource to cloud server\r
+ * Request to publish resource using remote relay server\r
  * @param[in]  server address combined with IP address and port number using delimiter :\r
- * @return ::NS_OK or result code of NSResult\r
+ * @return ::NS_OK if the action is requested succesfully or NS_FAIL if wrong parameter is set.\r
  */\r
-NSResult NSProviderEnableRemoteService(char *serverAddress);\r
+NSResult NSProviderEnableRemoteService(char * serverAddress);\r
 \r
 /**\r
- * Request to cancel remote service using cloud server\r
+ * Request to terminate remote service from relay server\r
  * @param[in]  server address combined with IP address and port number using delimiter :\r
+ * @return ::NS_OK if the action is requested succesfully or NS_FAIL if wrong parameter is set.\r
+ */\r
+NSResult NSProviderDisableRemoteService(char * serverAddress);\r
+\r
+#ifdef WITH_MQ\r
+/**\r
+ * Request to subscribe to remote MQ address as parameter.\r
+ * @param[in] server address combined with IP address and port number and MQ broker uri using delimiter :\r
+ * @param[in] topicName the interest Topic name for subscription.\r
  * @return ::NS_OK or result code of NSResult\r
  */\r
-NSResult NSProviderDisableRemoteService(char *serverAddress);\r
+NSResult NSProviderSubscribeMQService(const char * serverAddress, const char * topicName);\r
+#endif\r
 \r
 /**\r
  * Send notification message to all subscribers\r
  * @param[in]  message  Notification message including id, title, contentText\r
- * @return ::NS_OK or result code of NSResult\r
+ * @return ::NS_OK if the action is requested succesfully or NS_FAIL if wrong parameter is set.\r
  */\r
-NSResult NSSendMessage(NSMessage *msg);\r
+NSResult NSSendMessage(NSMessage * msg);\r
 \r
 /**\r
  * Send acceptance to consumer who subscribes the resource of notification message\r
+ * This function is valid only when subControllability is set true.\r
  * @param[in]  consumer  Consumer who subscribes the resource\r
- * @param[in]  accepted  the result of acceptance; Allow or Deny\r
- * @return ::NS_OK or result code of NSResult\r
+ * @param[in]  accepted  the result of acceptance; ALLOW or DENY\r
+ * @return ::NS_OK if this function is requested succesfully\r
+ * or NS_FAIL if subContollability is false.\r
  */\r
-NSResult NSAcceptSubscription(NSConsumer *consumer, bool accepted);\r
+NSResult NSAcceptSubscription(const char * consumerId, bool accepted);\r
 \r
 /**\r
- * Send sync type in order to synchronize notification status with other consumers,\r
- * when provider consumes the notification such as READ, DELETE\r
- * @param[in]  messageId  Notification message if to synchronize the status\r
- * @param[in]  type  changed notification status from NSSyncType\r
- * @return ::NS_OK or result code of NSResult\r
+ * Send synchronizad state of notificaion message to consumers\r
+ * @param[in]  messageiId  ID of notification message\r
+ * @param[in]  type  SyncType of the syncInfo message\r
+ * @return ::NS_OK if the action is requested succesfully or NS_FAIL if wrong parameter is set.\r
  */\r
 NSResult NSProviderSendSyncInfo(uint64_t messageId, NSSyncType type);\r
 \r
-\r
 /**\r
- * Initialize NSMessage structure with message id and provider(device) id\r
+ * Initialize NSMessage struct.\r
+ * Service sets mandatory fields which message id and provider(device) id are filled with.\r
  * @return ::NSMessage *\r
  */\r
 NSMessage * NSCreateMessage();\r
 \r
+/**\r
+ * Add topic to topic list which is located in provider service storage\r
+ * @param[in]  topicName Topic name to add\r
+ * @return ::NS_OK if the action is requested succesfully or NS_FAIL if wrong parameter is set.\r
+ */\r
+NSResult NSProviderRegisterTopic(const char * topicName);\r
+\r
+/**\r
+ * Delete topic from topic list\r
+ * @param[in]  topicName Topic name to delete\r
+ * @return ::NS_OK if the action is requested succesfully or NS_FAIL if wrong parameter is set.\r
+ */\r
+NSResult NSProviderUnregisterTopic(const char * topicName);\r
+\r
+/**\r
+ * Select a topic name for a consumer\r
+ * @param[in]  consumerId  consumer id for which the user on provider selects a topic\r
+ * @param[in]  topicName Topic name to select\r
+ * @return ::NS_OK if the action is requested succesfully or NS_FAIL if subContollability is false\r
+ */\r
+NSResult NSProviderSetConsumerTopic(const char * consumerId, const char * topicName);\r
+\r
+/**\r
+ * Unselect a topic from the topic list for consumer\r
+ * @param[in]  consumerId  consumer id for which the user on provider unselects a topic\r
+ * @param[in]  topicName Topic name to unselect\r
+ * @return ::NS_OK if the action is requested succesfully or NS_FAIL if subContollability is false\r
+ */\r
+NSResult NSProviderUnsetConsumerTopic(const char * consumerId, const char * topicName);\r
+\r
+/**\r
+ * Request topic list with selection state for the consumer\r
+ * @param[in] consumerid  the id of consumer which topic list is subscribed for\r
+ * @return :: Topic list\r
+ */\r
+NSTopicLL * NSProviderGetConsumerTopics(const char * consumerId);\r
+\r
+/**\r
+ * Request topics list already registered by provider user\r
+ * @return :: Topic list\r
+ */\r
+NSTopicLL * NSProviderGetTopics();\r
+\r
 #ifdef __cplusplus\r
 }\r
 #endif // __cplusplus\r