82cf21ab48df4a0e5c6398e541b82a775f4cf7a6
[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 #include <octypes.h>
32
33 #define NS_UUID_STRING_SIZE 37
34
35 /**
36  * Result code of notification service
37  */
38 typedef enum eResult
39 {
40     NS_OK = 100,
41     NS_ERROR = 200,
42     NS_SUCCESS = 300,
43     NS_FAIL = 400,
44
45 } NSResult;
46
47 /**
48  * Provider state of notification consumer service
49  */
50 typedef enum
51 {
52     NS_ALLOW = 1,
53     NS_DENY = 2,
54     NS_TOPIC = 3,
55     NS_DISCOVERED = 11,
56     NS_STOPPED = 12
57 } NSProviderState;
58
59 /**
60  * Notification message status to synchronize
61  */
62 typedef enum
63 {
64     NS_SYNC_UNREAD = 0,
65     NS_SYNC_READ = 1,
66     NS_SYNC_DELETED = 2,
67
68 } NSSyncType;
69
70 /**
71  * Notification Message Type
72  * Alert mean is High / critical
73  * Notice mean is low / critical
74  * Event mean is High / Normal
75  * Information mean is Low / Normal
76  */
77 typedef enum
78 {
79     NS_MESSAGE_ALERT = 1,
80     NS_MESSAGE_NOTICE = 2,
81     NS_MESSAGE_EVENT = 3,
82     NS_MESSAGE_INFO = 4,
83     NS_MESSAGE_WARNING = 5,
84
85 } NSMessageType;
86
87 /**
88  *  Notification topic state
89  */
90 typedef enum
91 {
92     NS_TOPIC_UNSUBSCRIBED = 0,
93     NS_TOPIC_SUBSCRIBED = 1,
94
95 } NSTopicState;
96
97 /**
98  * Topic linked list
99  */
100 typedef struct _nsTopic
101 {
102     char * topicName;
103     NSTopicState state;
104     struct _nsTopic * next;
105
106 } NSTopicLL;
107
108 /**
109  *  Consumer information
110  */
111 typedef struct
112 {
113     char consumerId[NS_UUID_STRING_SIZE];
114
115 } NSConsumer;
116
117 /**
118  *  Provider information
119  */
120 typedef struct
121 {
122     char providerId[NS_UUID_STRING_SIZE];
123
124 } NSProvider;
125
126 /**
127  *  Media Contents of Notification Message (Optional)
128  */
129 typedef struct
130 {
131     char * iconImage;
132
133 } NSMediaContents;
134
135 /**
136  *  Notification Message
137  */
138 typedef struct
139 {
140     //Mandatory
141     uint64_t messageId;
142     char providerId[NS_UUID_STRING_SIZE];
143
144     //optional
145     NSMessageType type;
146     char * dateTime;
147     uint64_t ttl;
148     char * title;
149     char * contentText;
150     char * sourceName;
151     NSMediaContents * mediaContents;
152     char * topic;
153     OCRepPayload * extraInfo;
154
155 } NSMessage;
156
157 /**
158  *  Synchronization information of the notification message
159  */
160 typedef struct
161 {
162     uint64_t messageId;
163     char providerId[NS_UUID_STRING_SIZE];
164     NSSyncType state;
165
166 } NSSyncInfo;
167
168 #endif /* _NS_COMMON_H_ */
169