1 //******************************************************************
\r
3 // Copyright 2016 Samsung Electronics All Rights Reserved.
\r
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
\r
7 // Licensed under the Apache License, Version 2.0 (the "License");
\r
8 // you may not use this file except in compliance with the License.
\r
9 // You may obtain a copy of the License at
\r
11 // http://www.apache.org/licenses/LICENSE-2.0
\r
13 // Unless required by applicable law or agreed to in writing, software
\r
14 // distributed under the License is distributed on an "AS IS" BASIS,
\r
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 // See the License for the specific language governing permissions and
\r
17 // limitations under the License.
\r
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
\r
24 * This file provides APIs of Notification Service for Provider.
\r
27 #ifndef _NS_PROVIDER_INTERFACE_H_
\r
28 #define _NS_PROVIDER_INTERFACE_H_
\r
33 #endif // __cplusplus
\r
35 #include "NSCommon.h"
\r
36 #include <stdbool.h>
\r
39 * Invoked when provider receives the subscription request of consumer.
\r
40 * @param[in] consumer Consumer who subscribes the notification message resource
\r
42 typedef void (*NSSubscribeRequestCallback)(NSConsumer *);
\r
45 * Invoked when synchronization data which has notification message
\r
46 * read/deleted event from consumer is received.
\r
47 * @param[in] sync Synchronization information of the notification message
\r
49 typedef void (*NSProviderSyncInfoCallback)(NSSyncInfo *);
\r
52 * Set provider service with the following configuration
\r
56 /* Invoked when the subscription request from consumer is received */
\r
57 NSSubscribeRequestCallback subRequestCallback;
\r
58 /* Invoked when the synchronization data, read and deleted, is sent by consumer is received */
\r
59 NSProviderSyncInfoCallback syncInfoCallback;
\r
60 /* Set the policy for notification servcie which checks whether provider is capable of
\r
61 * denying the subscription of notification message from consumer
\r
62 * and getting controllabliity to set consumer topic list.
\r
63 * If true, provider is able to control subscription request and consumer topic list.
\r
64 * Otherwise(policy is false), consumer can do the same.
\r
66 bool subControllability;
\r
67 /* User defined information such as device friendly name */
\r
69 /* Set on/off for secure resource channel setting */
\r
70 bool resourceSecurity;
\r
75 * Initialize notification service for provider
\r
76 * @param[in] config Refer to NSProviderConfig
\r
77 * @return ::NS_OK if the action is requested succesfully
\r
79 NSResult NSStartProvider(NSProviderConfig config);
\r
82 * Terminate notification service for provider
\r
83 * @return ::NS_OK if the action is requested succesfully
\r
85 NSResult NSStopProvider();
\r
88 * Request to publish resource using remote relay server
\r
89 * @param[in] server address combined with IP address and port number using delimiter :
\r
90 * @return ::NS_OK if the action is requested succesfully or NS_FAIL if wrong parameter is set.
\r
92 NSResult NSProviderEnableRemoteService(char * serverAddress);
\r
95 * Request to terminate remote service from relay server
\r
96 * @param[in] server address combined with IP address and port number using delimiter :
\r
97 * @return ::NS_OK if the action is requested succesfully or NS_FAIL if wrong parameter is set.
\r
99 NSResult NSProviderDisableRemoteService(char * serverAddress);
\r
103 * Request to subscribe to remote MQ address as parameter.
\r
104 * @param[in] server address combined with IP address and port number and MQ broker uri using delimiter :
\r
105 * @param[in] topicName the interest Topic name for subscription.
\r
106 * @return ::NS_OK or result code of NSResult
\r
108 NSResult NSProviderSubscribeMQService(const char * serverAddress, const char * topicName);
\r
112 * Send notification message to all subscribers
\r
113 * @param[in] message Notification message including id, title, contentText
\r
114 * @return ::NS_OK if the action is requested succesfully or NS_FAIL if wrong parameter is set.
\r
116 NSResult NSSendMessage(NSMessage * msg);
\r
119 * Send acceptance to consumer who subscribes the resource of notification message
\r
120 * This function is valid only when subControllability is set true.
\r
121 * @param[in] consumer Consumer who subscribes the resource
\r
122 * @param[in] accepted the result of acceptance; ALLOW or DENY
\r
123 * @return ::NS_OK if this function is requested succesfully
\r
124 * or NS_FAIL if subContollability is false.
\r
126 NSResult NSAcceptSubscription(const char * consumerId, bool accepted);
\r
129 * Send synchronizad state of notificaion message to consumers
\r
130 * @param[in] messageiId ID of notification message
\r
131 * @param[in] type SyncType of the syncInfo message
\r
132 * @return ::NS_OK if the action is requested succesfully or NS_FAIL if wrong parameter is set.
\r
134 NSResult NSProviderSendSyncInfo(uint64_t messageId, NSSyncType type);
\r
137 * Initialize NSMessage struct.
\r
138 * Service sets mandatory fields which message id and provider(device) id are filled with.
\r
139 * @return ::NSMessage *
\r
141 NSMessage * NSCreateMessage();
\r
144 * Add topic to topic list which is located in provider service storage
\r
145 * @param[in] topicName Topic name to add
\r
146 * @return ::NS_OK if the action is requested succesfully or NS_FAIL if wrong parameter is set.
\r
148 NSResult NSProviderRegisterTopic(const char * topicName);
\r
151 * Delete topic from topic list
\r
152 * @param[in] topicName Topic name to delete
\r
153 * @return ::NS_OK if the action is requested succesfully or NS_FAIL if wrong parameter is set.
\r
155 NSResult NSProviderUnregisterTopic(const char * topicName);
\r
158 * Select a topic name for a consumer
\r
159 * @param[in] consumerId consumer id for which the user on provider selects a topic
\r
160 * @param[in] topicName Topic name to select
\r
161 * @return ::NS_OK if the action is requested succesfully or NS_FAIL if subContollability is false
\r
163 NSResult NSProviderSetConsumerTopic(const char * consumerId, const char * topicName);
\r
166 * Unselect a topic from the topic list for consumer
\r
167 * @param[in] consumerId consumer id for which the user on provider unselects a topic
\r
168 * @param[in] topicName Topic name to unselect
\r
169 * @return ::NS_OK if the action is requested succesfully or NS_FAIL if subContollability is false
\r
171 NSResult NSProviderUnsetConsumerTopic(const char * consumerId, const char * topicName);
\r
174 * Request topic list with selection state for the consumer
\r
175 * @param[in] consumerid the id of consumer which topic list is subscribed for
\r
176 * @return :: Topic list
\r
178 NSTopicLL * NSProviderGetConsumerTopics(const char * consumerId);
\r
181 * Request topics list already registered by provider user
\r
182 * @return :: Topic list
\r
184 NSTopicLL * NSProviderGetTopics();
\r
188 #endif // __cplusplus
\r
190 #endif /* _NS_PROVIDER_INTERFACE_H_ */
\r