X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=service%2Fnotification%2Fcpp-wrapper%2Fprovider%2Finc%2FNSProviderService.h;h=575ea93ddb16ca0a976a590ce9d486898af4a489;hb=7f00f942c39b7bc27c7eeecf213a239c3fe4173c;hp=d98d31e354b281aa0d8f79047e9f5148fd767e44;hpb=2d864f42ebbe784250d4d418cb7de7233f1886ac;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 d98d31e..575ea93 100755 --- a/service/notification/cpp-wrapper/provider/inc/NSProviderService.h +++ b/service/notification/cpp-wrapper/provider/inc/NSProviderService.h @@ -27,45 +27,45 @@ #ifndef _NS_PROVIDER_SERVICE_H_ #define _NS_PROVIDER_SERVICE_H_ -#include "NSCommon.h" -#include "NSProviderInterface.h" -#include "NSMessage.h" -#include "oic_string.h" +#include #include "NSConsumer.h" #include "NSSyncInfo.h" -#include "NSConstants.h" -#include +#include "NSMessage.h" +#include "NSUtils.h" +#include "NSTopicsList.h" 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 callback function configuration for registering callbacks - * + * @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 { @@ -73,16 +73,14 @@ namespace OIC ConsumerSubscribedCallback m_subscribeRequestCb; /** m_syncInfoCb - MessageSynchronizedCallback callback listener.*/ MessageSynchronizedCallback m_syncInfoCb; - } ProviderConfig; - /** - * Access policy exchanged between provider and consumer during subscription process - */ - enum class NSAccessPolicy - { - NS_ACCESS_ALLOW = 0, - NS_ACCESS_DENY = 1, - }; + /** 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; /** * API for starting the NS Provider @@ -93,48 +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 NSResult + * @return :: result code of Provider Service */ - NSResult Start(NSAccessPolicy policy, ProviderConfig config); + NSResult start(ProviderConfig config); /** * Terminate notification service for provider - * @return :: result code of NSResult + * @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 : - * @return result code of NSResult + * @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 : - * @return result code of NSResult + * @param[in] serverAddress combined with IP address and port number using delimiter : + * @return result code of Provider Service + */ + 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 DisableRemoteService(const std::string &serverAddress); + 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 NSResult + * @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 :: result code of NSResult + * @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, This function is valid only when subControllability is set true. + * @return NSMessage * + */ + 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 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 unregisterTopic(const std::string &topicName); + + /** + * Request topics list already registered by provider user + * @return :: Topic list + */ + std::shared_ptr getRegisteredTopicList(); /** * get Provider config values @@ -142,22 +173,35 @@ namespace OIC */ ProviderConfig getProviderConfig(); + /** + * request to get NSConsumer pointer + * @param id -id as string + * + * @return shared pointer to NSConsumer + */ + std::shared_ptr getConsumer(const std::string &id); + + /** + * get handle of Consumers accepted. + * @return m_acceptedConsumers -accepted Consumers + */ + NSAcceptedConsumers *getAcceptedConsumers(); + private : ProviderConfig m_config; + NSAcceptedConsumers *m_acceptedConsumers; private: - NSProviderService() - { - m_config.m_subscribeRequestCb = NULL; - m_config.m_syncInfoCb = NULL; - } - ~NSProviderService() = default; + 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); }; } }