9397e03721b9da0290c9a1fac9fa854153696552
[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_MESSAGE_ID "MESSAGE_ID"
39 #define NS_ATTRIBUTE_PROVIDER_ID "PROVIDER_ID"
40 #define NS_ATTRIBUTE_CONSUMER_ID "CONSUMER_ID"
41 #define NS_ATTRIBUTE_TOPIC_LIST "TOPIC_LIST"
42 #define NS_ATTRIBUTE_TOPIC_NAME "TOPIC_NAME"
43 #define NS_ATTRIBUTE_TOPIC_SELECTION "TOPIC_STATE"
44 #define NS_ATTRIBUTE_TITLE "TITLE"
45 #define NS_ATTRIBUTE_TEXT "CONTENTTEXT"
46 #define NS_ATTRIBUTE_SOURCE "SOURCE"
47 #define NS_ATTRIBUTE_STATE "STATE"
48 #define NS_ATTRIBUTE_DEVICE "DEVICE"
49 #define NS_ATTRIBUTE_TYPE "TYPE"
50 #define NS_ATTRIBUTE_DATETIME "DATE_TIME"
51 #define NS_ATTRIBUTE_TTL "TTL"
52
53 /**
54  * Result code of notification service
55  */
56 typedef enum eResult
57 {
58     NS_OK = 100,
59     NS_ERROR = 200,
60     NS_SUCCESS = 300,
61     NS_FAIL = 400,
62
63 } NSResult;
64
65 /**
66  * Provider state of notification consumer service
67  */
68 typedef enum
69 {
70     NS_ALLOW = 1,
71     NS_DENY = 2,
72     NS_TOPIC = 3,
73     NS_DISCOVERED = 11,
74     NS_STOPPED = 12
75 } NSProviderState;
76
77 /**
78  * Notification message status to synchronize
79  */
80 typedef enum
81 {
82     NS_SYNC_UNREAD = 0,
83     NS_SYNC_READ = 1,
84     NS_SYNC_DELETED = 2,
85 } NSSyncType;
86
87 /**
88  * Notification Message Type
89  * Alert mean is High / critical
90  * Notice mean is low / critical
91  * Event mean is High / Normal
92  * Information mean is Low / Normal
93  */
94 typedef enum
95 {
96     NS_MESSAGE_ALERT = 1,
97     NS_MESSAGE_NOTICE = 2,
98     NS_MESSAGE_EVENT = 3,
99     NS_MESSAGE_INFO = 4,
100
101 } NSMessageType;
102
103 /**
104  *  Notification topic
105  */
106 typedef enum
107 {
108     NS_TOPIC_UNSUBSCRIBED = 0,
109     NS_TOPIC_SUBSCRIBED = 1,
110
111 } NSTopicState;
112
113 typedef struct _nsTopic
114 {
115     char * topicName;
116     NSTopicState state;
117     struct _nsTopic * next;
118
119 } NSTopicLL;
120
121 typedef struct
122 {
123     NSTopicLL * head;
124     NSTopicLL * tail;
125     //TODO: decide struct fields
126     char consumerId[NS_UUID_STRING_SIZE];
127     NSTopicLL ** topics;
128
129 } NSTopicList;
130
131 /**
132  *  Consumer information
133  */
134 typedef struct
135 {
136     char consumerId[NS_UUID_STRING_SIZE];
137
138 } NSConsumer;
139
140 /**
141  *  Provider information
142  */
143 typedef struct
144 {
145     char providerId[NS_UUID_STRING_SIZE];
146     NSTopicLL * topicLL;
147
148 } NSProvider;
149
150 /**
151  *  Media Contents of Notification Message (Optional)
152  */
153 typedef struct
154 {
155     char * iconImage;
156
157 } NSMediaContents;
158
159 /**
160  *  Notification Message
161  */
162 typedef struct
163 {
164     //Mandatory
165     uint64_t messageId;
166     char providerId[NS_UUID_STRING_SIZE];
167
168     //optional
169     NSMessageType type;
170     char * dateTime;
171     uint64_t ttl;
172     char * title;
173     char * contentText;
174     char * sourceName;
175     NSMediaContents * mediaContents;
176     char * topic;
177
178 } NSMessage;
179
180 /**
181  *  Synchronization information of the notification message
182  */
183 typedef struct
184 {
185     uint64_t messageId;
186     char providerId[NS_UUID_STRING_SIZE];
187     NSSyncType state;
188
189 } NSSyncInfo;
190
191 #endif /* _NS_COMMON_H_ */
192