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