1ab2e96e3783ff9369b28b74519627f715da1bb9
[platform/upstream/iotivity.git] / service / notification / include / NSCommon.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 /**
22  * @file
23  *
24  * This file provides APIs of Notification Service for common functions.
25  */
26
27 #ifndef _NS_COMMON_H_
28 #define _NS_COMMON_H_
29
30 #include <stdint.h>
31
32 #define NS_UUID_STRING_SIZE 37
33
34 #define NS_ATTRIBUTE_POLICY "ACCEPTER"
35 #define NS_ATTRIBUTE_MESSAGE "MESSAGE_URI"
36 #define NS_ATTRIBUTE_SYNC "SYNC_URI"
37 #define NS_ATTRIBUTE_TOPIC "TOPIC_URI"
38 #define NS_ATTRIBUTE_ACCPETANCE "ACCEPTANCE" // not used
39 #define NS_ATTRIBUTE_MESSAGE_ID "MESSAGE_ID"
40 #define NS_ATTRIBUTE_PROVIDER_ID "PROVIDER_ID"
41 #define NS_ATTRIBUTE_CONSUMER_ID "CONSUMER_ID"
42 #define NS_ATTRIBUTE_TOPIC_LIST "TOPIC_LIST"
43 #define NS_ATTRIBUTE_TOPIC_NAME "TOPIC_NAME"
44 #define NS_ATTRIBUTE_TOPIC_SELECTION "TOPIC_STATE"
45 #define NS_ATTRIBUTE_TITLE "TITLE"
46 #define NS_ATTRIBUTE_TEXT "CONTENTTEXT"
47 #define NS_ATTRIBUTE_SOURCE "SOURCE"
48 #define NS_ATTRIBUTE_STATE "STATE"
49 #define NS_ATTRIBUTE_DEVICE "DEVICE"
50 #define NS_ATTRIBUTE_TYPE "TYPE"
51 #define NS_ATTRIBUTE_DATETIME "DATE_TIME"
52 #define NS_ATTRIBUTE_TTL "TTL"
53
54 /**
55  * Result code of notification service
56  */
57 typedef enum eResult
58 {
59     NS_OK = 100,
60     NS_ERROR = 200,
61     NS_SUCCESS = 300,
62     NS_FAIL = 400,
63
64 } NSResult;
65
66 /**
67  * Response code of notification service
68  */
69 typedef enum eResponse
70 {
71     NS_ALLOW = 1,
72     NS_DENY = 2,
73     NS_TOPIC = 3,
74
75 } NSResponse;
76
77 /**
78  * Access policy exchanged between provider and consumer during subscription process
79  */
80 typedef enum eAccessPolicy
81 {
82     NS_ACCESS_ALLOW = 0,
83     NS_ACCESS_DENY = 1,
84 } NSAccessPolicy;  // not used , this structure will be deleted.
85
86 /**
87  * Notification message status to synchronize
88  */
89 typedef enum
90 {
91     NS_SYNC_UNREAD = 0,
92     NS_SYNC_READ = 1,
93     NS_SYNC_DELETED = 2,
94 } NSSyncType;
95
96 /**
97  * Notification Message Type
98  * Alert mean is High / critical
99  * Notice mean is low / critical
100  * Event mean is High / Normal
101  * Information mean is Low / Normal
102  */
103 typedef enum
104 {
105     NS_MESSAGE_ALERT = 1,
106     NS_MESSAGE_NOTICE = 2,
107     NS_MESSAGE_EVENT = 3,
108     NS_MESSAGE_INFO = 4,
109
110 } NSMessageType;
111
112 /**
113  *  Notification topic
114  */
115 typedef enum
116 {
117     NS_TOPIC_UNSUBSCRIBED = 0,
118     NS_TOPIC_SUBSCRIBED = 1,
119
120 } NSTopicState;
121
122 typedef struct _nsTopic
123 {
124     char * topicName;
125     NSTopicState state;
126     struct _nsTopic * next;
127
128 } NSTopic;
129
130 typedef struct
131 {
132     char consumerId[NS_UUID_STRING_SIZE];
133     NSTopic * head;
134     NSTopic * tail;
135
136 } NSTopicList;
137
138 /**
139  *  Consumer information
140  */
141 typedef struct
142 {
143     char consumerId[NS_UUID_STRING_SIZE];
144
145 } NSConsumer;
146
147 /**
148  *  Provider information
149  */
150 typedef struct
151 {
152     char providerId[NS_UUID_STRING_SIZE];
153     NSTopicList * topicList;
154
155 } NSProvider;
156
157 /**
158  *  Media Contents of Notification Message (Optional)
159  */
160 typedef struct
161 {
162     char * iconImage;
163
164 } NSMediaContents;
165
166 /**
167  *  Notification Message
168  */
169 typedef struct
170 {
171     //Mandatory
172     uint64_t messageId;
173     char providerId[NS_UUID_STRING_SIZE];
174
175     //optional
176     NSMessageType type;
177     char * dateTime;
178     uint64_t ttl;
179     char * title;
180     char * contentText;
181     char * sourceName;
182     NSMediaContents * mediaContents;
183     char * topic;
184
185 } NSMessage;
186
187 /**
188  *  Synchronization information of the notification message
189  */
190 typedef struct
191 {
192     uint64_t messageId;
193     char providerId[NS_UUID_STRING_SIZE];
194     NSSyncType state;
195
196 } NSSyncInfo;
197
198 #endif /* _NS_COMMON_H_ */
199