#ifndef _NS_PROVIDER_SERVICE_H_\r
#define _NS_PROVIDER_SERVICE_H_\r
\r
-#include "NSCommon.h"\r
-#include "NSProviderInterface.h"\r
-#include "NSMessage.h"\r
-#include "oic_string.h"\r
+#include <string>\r
#include "NSConsumer.h"\r
#include "NSSyncInfo.h"\r
-#include "NSConstants.h"\r
-#include <cstring>\r
+#include "NSMessage.h"\r
+#include "NSUtils.h"\r
+#include "NSTopicsList.h"\r
\r
namespace OIC\r
{\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 callback function configuration for registering callbacks\r
- *\r
+ * @brief Provider sets this following configuration for registering callbacks and configs\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
ConsumerSubscribedCallback m_subscribeRequestCb;\r
/** m_syncInfoCb - MessageSynchronizedCallback callback listener.*/\r
MessageSynchronizedCallback m_syncInfoCb;\r
- } ProviderConfig;\r
\r
- /**\r
- * Access policy exchanged between provider and consumer during subscription process\r
- */\r
- enum class NSAccessPolicy\r
- {\r
- NS_ACCESS_ALLOW = 0,\r
- NS_ACCESS_DENY = 1,\r
- };\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
* API for starting the NS Provider\r
\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 NSResult\r
+ * @return :: result code of Provider Service\r
*/\r
- NSResult Start(NSAccessPolicy policy, ProviderConfig config);\r
+ NSResult start(ProviderConfig config);\r
\r
/**\r
* Terminate notification service for provider\r
- * @return :: result code of NSResult\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
- * @return result code of NSResult\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
- * @return result code of NSResult\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
+\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 DisableRemoteService(const std::string &serverAddress);\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 NSResult\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 :: result code of NSResult\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, This function is valid only when subControllability is set true.\r
+ * @return NSMessage *\r
+ */\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 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 unregisterTopic(const std::string &topicName);\r
+\r
+ /**\r
+ * Request topics list already registered by provider user\r
+ * @return :: Topic list\r
+ */\r
+ std::shared_ptr<NSTopicsList> getRegisteredTopicList();\r
\r
/**\r
* get Provider config values\r
*/\r
ProviderConfig getProviderConfig();\r
\r
+ /**\r
+ * request to get NSConsumer pointer\r
+ * @param id -id as string\r
+ *\r
+ * @return shared pointer to NSConsumer\r
+ */\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
+ NSAcceptedConsumers *m_acceptedConsumers;\r
\r
private:\r
- NSProviderService()\r
- {\r
- m_config.m_subscribeRequestCb = NULL;\r
- m_config.m_syncInfoCb = NULL;\r
- }\r
- ~NSProviderService() = default;\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