1 //******************************************************************
3 // Copyright 2016 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #ifndef _NS_CONSTANTS_H_
22 #define _NS_CONSTANTS_H_
24 #define __NS_FILE__ ( strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__ )
28 #define NS_LOG_V(level, format, ...) (OIC_LOG_V((level), __NS_FILE__, (format), __VA_ARGS__))
29 #define NS_LOG(level, msg) (OIC_LOG((level), __NS_FILE__, (msg)))
32 #define NS_CONVERT_LEVEL(level) ( \
33 ((level) == 0) ? "DEBUG" : \
34 ((level) == 1) ? "INFO" : \
35 ((level) == 2) ? "WARNING" : \
36 ((level) == 3) ? "ERROR" : "FATAL")
37 #define NS_LOG_V(level, format, ...) \
39 printf("%s: %s ", NS_CONVERT_LEVEL(level), __NS_FILE__); \
40 printf((format), __VA_ARGS__); \
43 #define NS_LOG(level, msg) \
45 printf("%s: %s ", NS_CONVERT_LEVEL(level), __NS_FILE__); \
51 #define NS_TAG "IOT_NOTI"
54 #define THREAD_COUNT 5
57 #define NOTIOBJ_TITLE_KEY "title"
58 #define NOTIOBJ_ID_KEY "id"
59 #define NOTOOBJ_CONTENT_KEY "contentText"
61 #define DISCOVERY_TAG "NS_PROVIDER_DISCOVERY"
62 #define SUBSCRIPTION_TAG "NS_PROVIDER_SUBSCRIPTION"
63 #define INTERFACE_TAG "NS_PROVIDER_INTERFACE"
64 #define NOTIFICATION_TAG "NS_PROVIDER_NOTIFICATION"
65 #define SCHEDULER_TAG "NS_PROVIDER_SCHEDULER"
66 #define LISTENER_TAG "NS_PROVIDER_LISTENER"
67 #define RESOURCE_TAG "NS_PROVIDER_RESOURCE"
68 #define TOPIC_TAG "NS_PROVIDER_TOPIC"
70 #define NS_ROOT_TYPE "oic.r.notification"
71 #define NS_COLLECTION_MESSAGE_TYPE "oic.r.notification.message"
72 #define NS_COLLECTION_SYNC_TYPE "oic.r.notification.sync"
73 #define NS_COLLECTION_TOPIC_TYPE "oic.r.notification.topic"
75 #define NS_DEFAULT_INTERFACE "oic.if.baseline"
77 #define NS_ROOT_URI "/notification"
78 #define NS_COLLECTION_MESSAGE_URI "/notification/message"
79 #define NS_COLLECTION_SYNC_URI "/notification/sync"
80 #define NS_COLLECTION_TOPIC_URI "/notification/topic"
82 #define NS_QUERY_SEPARATOR "&;"
83 #define NS_KEY_VALUE_DELIMITER "="
85 #define NS_QUERY_CONSUMER_ID "consumerid"
86 #define NS_QUERY_PROVIDER_ID "providerid"
88 #define NS_QUERY_ID_SIZE 10
90 #define NS_POLICY_PROVIDER 1
91 #define NS_POLICY_CONSUMER 0
93 #define NS_RD_PUBLISH_QUERY "/oic/rd?rt=oic.wk.rdpub"
95 #define NS_VERIFY_NOT_NULL_V(obj) \
99 NS_LOG_V(ERROR, "%s : %s is null", __func__, #obj); \
104 #define NS_VERIFY_NOT_NULL(obj, retVal) \
108 NS_LOG_V(ERROR, "%s : %s is null", __func__, #obj); \
113 #define NS_VERIFY_NOT_NULL_WITH_POST_CLEANING_V(obj, func) \
117 NS_LOG_V(ERROR, "%s : %s is null", __func__, #obj); \
118 NS_LOG(ERROR, "execute deletion"); \
124 #define NS_VERIFY_NOT_NULL_WITH_POST_CLEANING(obj, retVal, func) \
128 NS_LOG_V(ERROR, "%s : %s is null", __func__, #obj); \
129 NS_LOG(ERROR, "execute deletion"); \
135 #define NS_VERIFY_STACK_SUCCESS_V(obj) \
140 NS_LOG_V(ERROR, "%s : %s is not OC_STACK_OK : %d", __func__, #obj, _ret); \
145 #define NS_VERIFY_STACK_SUCCESS(obj, retVal) \
150 NS_LOG_V(ERROR, "%s : %s is not OC_STACK_OK : %d", __func__, #obj, _ret); \
155 #define NS_VERIFY_STACK_SUCCESS_WITH_POST_CLEANING(obj, retVal, func) \
160 NS_LOG_V(ERROR, "%s : %s is not OC_STACK_OK : %d", __func__, #obj, _ret); \
166 #define NSOICFree(obj) \
172 NS_LOG_V(DEBUG, "%s : %s Removed", __func__, #obj); \
176 #define VERSION "1.2.0"
178 #define NS_ATTRIBUTE_VERSION "VERSION"
179 #define NS_ATTRIBUTE_POLICY "ACCEPTER"
180 #define NS_ATTRIBUTE_MESSAGE "MESSAGE_URI"
181 #define NS_ATTRIBUTE_SYNC "SYNC_URI"
182 #define NS_ATTRIBUTE_TOPIC "TOPIC_URI"
183 #define NS_ATTRIBUTE_MESSAGE_ID "MESSAGE_ID"
184 #define NS_ATTRIBUTE_PROVIDER_ID "PROVIDER_ID"
185 #define NS_ATTRIBUTE_CONSUMER_ID "CONSUMER_ID"
186 #define NS_ATTRIBUTE_TOPIC_LIST "TOPIC_LIST"
187 #define NS_ATTRIBUTE_TOPIC_NAME "TOPIC_NAME"
188 #define NS_ATTRIBUTE_TOPIC_SELECTION "TOPIC_STATE"
189 #define NS_ATTRIBUTE_TITLE "TITLE"
190 #define NS_ATTRIBUTE_TEXT "CONTENTTEXT"
191 #define NS_ATTRIBUTE_SOURCE "SOURCE"
192 #define NS_ATTRIBUTE_STATE "STATE"
193 #define NS_ATTRIBUTE_DEVICE "DEVICE"
194 #define NS_ATTRIBUTE_TYPE "TYPE"
195 #define NS_ATTRIBUTE_DATETIME "DATE_TIME"
196 #define NS_ATTRIBUTE_TTL "TTL"
197 #define NS_ATTRIBUTE_ICON_IMAGE "ICON_IMAGE"
199 typedef enum eConnectionState
206 typedef enum eSchedulerType
208 CALLBACK_RESPONSE_SCHEDULER = 0,
209 DISCOVERY_SCHEDULER = 1,
210 SUBSCRIPTION_SCHEDULER = 2,
211 NOTIFICATION_SCHEDULER = 3,
215 typedef enum eTaskType
217 TASK_REGISTER_RESOURCE = 1000,
218 TASK_PUBLISH_RESOURCE = 1001,
220 TASK_START_PRESENCE = 2000,
221 TASK_STOP_PRESENCE = 2001,
223 TASK_RECV_SUBSCRIPTION = 3000,
224 TASK_RECV_UNSUBSCRIPTION = 3001,
225 TASK_SEND_POLICY = 3002,
226 TASK_SEND_ALLOW = 3003,
227 TASK_SEND_DENY = 3004,
228 TASK_SYNC_SUBSCRIPTION = 3005,
230 TASK_SEND_NOTIFICATION = 4000,
231 TASK_SEND_PENDING_NOTI = 4001,
233 TASK_RECV_SYNCINFO = 5000,
234 TASK_RECV_READ = 5001,
235 TASK_RECV_DISMISS = 5003,
236 TASK_SEND_SYNCINFO = 5099,
237 TASK_MAKE_SYNCINFO = 5100,
238 TASK_SEND_READ = 5101,
239 TASK_SEND_DISMISS = 5102,
241 TASK_CONSUMER_REQ_DISCOVER = 8001,
242 TASK_CONSUMER_REQ_SUBSCRIBE = 8002,
243 TASK_CONSUMER_REQ_SUBSCRIBE_CANCEL = 8003,
244 TASK_CONSUMER_SENT_REQ_OBSERVE = 8004,
245 TASK_CONSUMER_RECV_PROVIDER_CHANGED = 8005,
246 TASK_CONSUMER_RECV_MESSAGE = 8101,
248 TASK_CONSUMER_PROVIDER_DISCOVERED = 8201,
249 TASK_CONSUMER_PROVIDER_DELETED = 8202,
250 TASK_CONSUMER_RECV_CONFIRM = 8206,
252 TASK_CONSUMER_REQ_TOPIC_URI = 8299,
253 TASK_CONSUMER_REQ_TOPIC_LIST = 8300,
254 TASK_CONSUMER_RECV_TOPIC_LIST = 8031,
255 TASK_CONSUMER_SELECT_TOPIC_LIST = 8303,
257 TASK_EVENT_CONNECTED = 9000,
258 TASK_EVENT_CONNECTED_TCP = 9001,
259 TASK_EVENT_DISCONNECTED = 9002,
261 TASK_CB_SUBSCRIPTION = 10000,
262 TASK_CB_SYNC = 10001,
264 TASK_SEND_TOPICS = 11000,
265 TASK_ADD_TOPIC = 11001,
266 TASK_DELETE_TOPIC = 11002,
267 TASK_SUBSCRIBE_TOPIC = 11003,
268 TASK_UNSUBSCRIBE_TOPIC = 11004,
269 TASK_POST_TOPIC = 11005,
270 TASK_GET_TOPICS = 11006,
271 TAST_GET_CONSUMER_TOPICS = 11007
277 NS_CONSUMER_BLACKLIST = 0,
278 NS_CONSUMER_WHITELIST = 1,
282 typedef enum eCacheType
284 NS_PROVIDER_CACHE_SUBSCRIBER = 1000,
285 NS_PROVIDER_CACHE_MESSAGE = 1001,
286 NS_PROVIDER_CACHE_CONSUMER_TOPIC_NAME = 1002,
287 NS_PROVIDER_CACHE_CONSUMER_TOPIC_CID = 1003,
288 NS_PROVIDER_CACHE_REGISTER_TOPIC = 1004,
289 NS_PROVIDER_CACHE_SUBSCRIBER_OBSERVE_ID = 1005,
291 NS_CONSUMER_CACHE_PROVIDER = 2000,
292 NS_CONSUMER_CACHE_MESSAGE = 2001,
295 typedef enum eResourceType
297 NS_RESOURCE_MESSAGE = 1000,
298 NS_RESOURCE_SYNC = 1001,
299 NS_RESOURCE_TOPIC = 1002,
302 #endif /* _NS_CONSTANTS_H_ */