Merge "Merge branch 'master' into notification-service" into notification-service
[platform/upstream/iotivity.git] / service / notification / src / common / NSConstants.h
1 //******************************************************************
2 //
3 // Copyright 2016 Samsung Electronics All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
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
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
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.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 #ifndef _NS_CONSTANTS_H_
22 #define _NS_CONSTANTS_H_
23
24 #define __NS_FILE__ ( strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__ )
25
26 #ifdef TB_LOG
27 #include "logger.h"
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)))
30 #else
31 #include "logger.h"
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, ...) \
38     { \
39         printf("%s: %s ", NS_CONVERT_LEVEL(level), __NS_FILE__); \
40         printf((format), __VA_ARGS__); \
41         printf("\n"); \
42     }
43 #define NS_LOG(level, msg) \
44     { \
45         printf("%s: %s ", NS_CONVERT_LEVEL(level), __NS_FILE__); \
46         printf((msg)); \
47         printf("\n"); \
48     }
49 #endif
50
51 #define NS_TAG                     "IOT_NOTI"
52
53 // SCHEDULE //
54 #define THREAD_COUNT               4
55
56 // NOTIOBJ // 
57 #define NOTIOBJ_TITLE_KEY          "title"
58 #define NOTIOBJ_ID_KEY             "id"
59 #define NOTOOBJ_CONTENT_KEY        "contentText"
60
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
69 #define NS_ROOT_TYPE               "oic.r.notification"
70 #define NS_COLLECTION_MESSAGE_TYPE "oic.r.notification.message"
71 #define NS_COLLECTION_SYNC_TYPE    "oic.r.notification.sync"
72
73 #define NS_DEFAULT_INTERFACE       "oic.if.baseline"
74
75 #define NS_ROOT_URI                "/notification"
76 #define NS_COLLECTION_MESSAGE_URI  "/notification/message"
77 #define NS_COLLECTION_SYNC_URI     "/notification/sync"
78
79 #define NS_QUERY_SEPARATOR         "&;"
80 #define NS_KEY_VALUE_DELIMITER     "="
81
82 #define NS_QUERY_CONSUMER_ID       "consumerid"
83 #define NS_QUERY_PROVIDER_ID       "providerid"
84
85 #define NS_QUERY_ID_SIZE           10
86
87 typedef enum eConnectionState
88 {
89     DISCONNECTED = 0,
90     CONNECTED = 1,
91
92 } NSConnectionState;
93
94 typedef enum eSchedulerType
95 {
96     INTERFACE_SCHEDULER = 0,
97     DISCOVERY_SCHEDULER = 1,
98     SUBSCRIPTION_SCHEDULER = 2,
99     NOTIFICATION_SCHEDULER = 3,
100 } NSSchedulerType;
101
102 typedef enum eTaskType
103 {
104     TASK_REGISTER_RESOURCE = 1000,
105
106     TASK_START_PRESENCE = 2000,
107     TASK_STOP_PRESENCE = 2001,
108
109     TASK_RECV_SUBSCRIPTION = 3000,
110     TASK_RECV_UNSUBSCRIPTION = 3001,
111     TASK_SEND_POLICY = 3002,
112     TASK_SEND_ALLOW = 3003,
113     TASK_SEND_DENY = 3004,
114     TASK_SYNC_SUBSCRIPTION = 3005,
115
116     TASK_SEND_NOTIFICATION = 4000,
117     TASK_SEND_PENDING_NOTI = 4001,
118
119     TASK_RECV_SYNCINFO = 5000,
120     TASK_RECV_READ = 5001,
121     TASK_RECV_DISMISS = 5003,
122     TASK_SEND_READ = 5101,
123     TASK_SEND_DISMISS = 5102,
124
125     TASK_CONSUMER_REQ_DISCOVER = 8001,
126     TASK_CONSUMER_REQ_SUBSCRIBE = 8002,
127     TASK_CONSUMER_REQ_SUBSCRIBE_CANCEL = 8003,
128     TASK_CONSUMER_RECV_SUBSCRIBE_CONFIRMED = 8004,
129     TASK_CONSUMER_RECV_MESSAGE = 8101,
130
131     TASK_CONSUMER_PROVIDER_DISCOVERED = 8201,
132     TASK_CONSUMER_PROVIDER_DELETED = 8202,
133     TASK_CONSUMER_RECV_CONFIRM = 8206,
134
135     TASK_EVENT_CONNECTED = 9000,
136     TASK_EVENT_DISCONNECTED = 9001,
137
138     TASK_CB_SUBSCRIPTION = 10000,
139     TASK_CB_SYNC = 10001,
140
141 } NSTaskType;
142
143 typedef enum eCache
144 {
145     NS_CONSUMER_BLACKLIST = 0,
146     NS_CONSUMER_WHITELIST = 1,
147
148 } NSCache;
149
150 typedef enum eCacheType
151 {
152     NS_PROVIDER_CACHE_SUBSCRIBER = 1000,
153     NS_PROVIDER_CACHE_MESSAGE = 1001,
154
155     NS_CONSUMER_CACHE_MESSAGE = 2001,
156 } NSCacheType;
157
158 typedef enum eResourceType
159 {
160     NS_RESOURCE_MESSAGE = 1000,
161     NS_RESOURCE_SYNC = 1001,
162 } NSResourceType;
163
164 #endif /* _NS_CONSTANTS_H_ */