replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / service / notification / cpp-wrapper / provider / inc / NSProviderService.h
index 75ca9a2..575ea93 100755 (executable)
@@ -38,32 +38,34 @@ namespace OIC
 {\r
     namespace Service\r
     {\r
+        class NSAcceptedConsumers;\r
         /**\r
          * @class   NSProviderService\r
          * @brief   This class provides a set of C++APIs for Notification Provider.\r
          */\r
         class NSProviderService\r
         {\r
-\r
             public:\r
                 /**\r
                       * Provider uses this callback function to receive subscription request of consumer\r
-                      * @param[in] consumer        Consumer who subscribes the resource\r
+                      * @param[in] consumer  Consumer who subscribes the notification message resource\r
                       */\r
-                typedef void (*ConsumerSubscribedCallback)(NSConsumer *);\r
+                typedef void (*ConsumerSubscribedCallback)(std::shared_ptr<NSConsumer> );\r
 \r
                 /**\r
                       * Provider use this callback function to receive the status of the message\r
                       * synchronization\r
-                      * @param[in] sync        Synchronization information of the notification message\r
+                      * @param[in] sync Synchronization information of the notification message\r
                       */\r
-                typedef void (*MessageSynchronizedCallback)(NSSyncInfo *);\r
+                typedef void (*MessageSynchronizedCallback)(NSSyncInfo );\r
 \r
 \r
                 /**\r
                       * @struct   ProviderConfig\r
                       * @brief Provider sets this following configuration for registering callbacks and configs\r
-                      *\r
+                      *  Set the subControllability, for notification servcie refering to following\r
+                      *  if subControllability, is true, provider decides to allow or deny for all the subscribing consumers.\r
+                      *  Otherwise(subControllability, is false) consumer decides to request subscription to discovered providers.\r
                       */\r
                 typedef struct\r
                 {\r
@@ -72,13 +74,12 @@ namespace OIC
                     /** m_syncInfoCb - MessageSynchronizedCallback callback listener.*/\r
                     MessageSynchronizedCallback m_syncInfoCb;\r
 \r
-                    /* Set the policy for notification servcie refering to following\r
-                                 * if policy is true, provider decides to allow or deny for all the subscribing consumers.\r
-                                 * Otherwise(policy is false) consumer decides to request subscription to discovered providers.\r
-                                 */\r
-                    bool policy;\r
-                    /* User Information */\r
+                    /** subControllability - for setting the subscription controllability for Consumer */\r
+                    bool subControllability;\r
+                    /** userInfo - user defined information such as device friendly name */\r
                     std::string userInfo;\r
+                    /* Set on/off for secure resource channel setting */\r
+                    bool resourceSecurity;\r
                 } ProviderConfig;\r
 \r
                 /**\r
@@ -90,81 +91,81 @@ namespace OIC
 \r
                 /**\r
                       * Initialize notification service for provider\r
-                      * @param[in]  policy   Accepter\r
                       * @param[in]  config   ProviderConfig Callback function pointers to onConsumerSubscribed,\r
                       * and onMessageSynchronized function listeners\r
                       * @return :: result code of Provider Service\r
                       */\r
-                NSResult Start(ProviderConfig config);\r
+                NSResult start(ProviderConfig config);\r
 \r
                 /**\r
                       * Terminate notification service for provider\r
                       * @return :: result code of Provider Service\r
                       */\r
-                NSResult Stop();\r
+                NSResult stop();\r
 \r
                 /**\r
                       * Request to publish resource to cloud server\r
-                      * @param[in]  server address combined with IP address and port number using delimiter :\r
+                      * @param[in]  serverAddress combined with IP address and port number using delimiter :\r
                       * @return  result code of Provider Service\r
                       */\r
-                NSResult EnableRemoteService(const std::string &serverAddress);\r
+                NSResult enableRemoteService(const std::string &serverAddress);\r
 \r
                 /**\r
                       * Request to cancel remote service using cloud server\r
-                      * @param[in]  server address combined with IP address and port number using delimiter :\r
+                      * @param[in]  serverAddress combined with IP address and port number using delimiter :\r
                       * @return  result code of Provider Service\r
                       */\r
-                NSResult DisableRemoteService(const std::string &serverAddress);\r
+                NSResult disableRemoteService(const std::string &serverAddress);\r
+\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 subscribeMQService(const std::string &serverAddress, const std::string &topicName);\r
 \r
                 /**\r
                       * Send notification message to all subscribers\r
                       * @param[in]  msg  Notification message including id, title, contentText\r
                       * @return :: result code of Provider Service\r
                       */\r
-                NSResult SendMessage(NSMessage *msg);\r
+                NSResult sendMessage(const NSMessage &msg);\r
 \r
 \r
                 /**\r
                       * Send read-check to provider in order to synchronize notification status with other consumers\r
-                      * @param[in]  messageId  Notification message to synchronize the status\r
+                      * @param[in]  messageId  ID of Notification message to synchronize the status\r
                       * @param[in]  type  NotificationSyncType of the SyncInfo message\r
+                      * @return :: OK or result code of NSResult\r
                       */\r
-                void SendSyncInfo(uint64_t messageId, NSSyncInfo::NSSyncType type);\r
+                NSResult sendSyncInfo(uint64_t messageId, NSSyncInfo::NSSyncType type);\r
 \r
                 /**\r
-                     * Initialize NSMessage class, service sets message id and provider(device) id\r
-                     * @return ::NSMessage *\r
+                     * Initialize NSMessage class, This function is valid only when subControllability is set true.\r
+                     * @return NSMessage *\r
                      */\r
-                NSMessage *CreateMessage();\r
-\r
-                /**\r
-                      *  request to get NSConsumer pointer\r
-                      * @param id -id as string\r
-                      *\r
-                      * @return pointer to NSConsumer\r
-                      */\r
-                NSConsumer *getConsumer(const std::string &id);\r
+                NSMessage createMessage();\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 :: OK or result code of NSResult\r
                      */\r
-                NSResult AddTopic(const std::string &topicName);\r
+                NSResult registerTopic(const std::string &topicName);\r
 \r
                 /**\r
                      * Delete topic from topic list\r
                      * @param[in]  topicName Topic name to delete\r
                      * @return :: OK or result code of NSResult\r
                      */\r
-                NSResult DeleteTopic(const std::string &topicName);\r
+                NSResult unregisterTopic(const std::string &topicName);\r
 \r
                 /**\r
                      * Request topics list already registered by provider user\r
                      * @return :: Topic list\r
                      */\r
-                NSTopicsList *GetTopics();\r
+                std::shared_ptr<NSTopicsList> getRegisteredTopicList();\r
 \r
                 /**\r
                       *  get Provider config values\r
@@ -173,28 +174,34 @@ namespace OIC
                 ProviderConfig getProviderConfig();\r
 \r
                 /**\r
-                      *  get list of Consumers accepted.\r
-                      * @return m_acceptedConsumers -list of accepted Consumers\r
+                      *  request to get NSConsumer pointer\r
+                      * @param id -id as string\r
+                      *\r
+                      * @return shared pointer to NSConsumer\r
                       */\r
-                std::list<NSConsumer *> getAcceptedConsumers();\r
+                std::shared_ptr<NSConsumer> getConsumer(const std::string &id);\r
+\r
+                /**\r
+                      *  get handle of Consumers accepted.\r
+                      * @return m_acceptedConsumers -accepted Consumers\r
+                      */\r
+                NSAcceptedConsumers *getAcceptedConsumers();\r
 \r
             private :\r
                 ProviderConfig m_config;\r
-                std::list<NSConsumer *> m_acceptedConsumers;\r
+                NSAcceptedConsumers *m_acceptedConsumers;\r
 \r
             private:\r
-                NSProviderService()\r
-                {\r
-                    m_config.m_subscribeRequestCb = NULL;\r
-                    m_config.m_syncInfoCb = NULL;\r
-                }\r
+                NSProviderService();\r
                 ~NSProviderService();\r
                 NSProviderService(const NSProviderService &) = delete;\r
                 NSProviderService &operator=(const NSProviderService &) = delete;\r
                 NSProviderService(const NSProviderService &&) = delete;\r
                 NSProviderService &operator=(const NSProviderService && ) = delete;\r
 \r
-                ::NSMessage *getNSMessage(NSMessage *msg);\r
+                ::NSMessage *getNSMessage(const NSMessage &msg);\r
+                static void onConsumerSubscribedCallback(::NSConsumer *consumer);\r
+                static void onMessageSynchronizedCallback(::NSSyncInfo *syncInfo);\r
         };\r
     }\r
 }\r