Merge branch 'master' into notification-service
[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 <ocstack.h>
31
32 #define NS_ATTRIBUTE_POLICY "ACCEPTER"
33 #define NS_ATTRIBUTE_MESSAGE "MESSAGE_URI"
34 #define NS_ATTRIBUTE_SYNC "SYNC_URI"
35 #define NS_ATTRIBUTE_ACCPETANCE "ACCEPTANCE"
36 #define NS_ATTRIBUTE_MESSAGE_ID "MESSAGE_ID"
37 #define NS_ATTRIBUTE_PROVIDER_ID "PROVIDER_ID"
38 #define NS_ATTRIBUTE_TITLE "TITLE"
39 #define NS_ATTRIBUTE_TEXT "CONTENTTEXT"
40 #define NS_ATTRIBUTE_SOURCE "SOURCE"
41 #define NS_ATTRIBUTE_STATE "STATE"
42 #define NS_ATTRIBUTE_DEVICE "DEVICE"
43 #define NS_ATTRIBUTE_TYPE "TYPE"
44 #define NS_ATTRIBUTE_DATETIME "DATE_TIME"
45 #define NS_ATTRIBUTE_TTL "TTL"
46
47 /**
48  * Result code of notification service
49  */
50 typedef enum eResult
51 {
52     NS_OK = 100,
53     NS_ERROR = 200,
54     NS_SUCCESS = 300,
55     NS_FAIL = 400,
56     NS_ALLOW = 500,
57     NS_DENY = 600,
58
59 } NSResult;
60
61 /**
62  * Access policy exchanged between provider and consumer during subscription process
63  */
64 typedef enum eAccessPolicy
65 {
66     NS_ACCESS_ALLOW = 0,
67     NS_ACCESS_DENY = 1,
68 } NSAccessPolicy;
69
70 /**
71  * Notification message status to synchronize
72  */
73 typedef enum
74 {
75     NS_SYNC_UNREAD = 0,
76     NS_SYNC_READ = 1,
77     NS_SYNC_DELETED = 2,
78 } NSSyncType;
79
80 /**
81  * Notification Message Type
82  * Alert mean is High / critical
83  * Notice mean is low / critical
84  * Event mean is High / Normal
85  * Information mean is Low / Normal
86  */
87 typedef enum
88 {
89     NS_MESSAGE_ALERT = 0,
90     NS_MESSAGE_NOTICE = 1,
91     NS_MESSAGE_EVENT = 2,
92     NS_MESSAGE_INFO = 3,
93
94 } NSMessageType;
95
96 /**
97  *  Consumer information
98  */
99 typedef struct
100 {
101     char * mDeviceId;
102     char * mAddress;
103
104 } NSConsumer;
105
106 /**
107  *  Provider information
108  */
109 typedef struct
110 {
111     char * mId;
112     char * mUserData;
113     char * messageUri;
114     char * syncUri;
115     OCDoHandle messageHandle;
116     OCDoHandle syncHandle;
117
118 } NSProvider;
119
120 /**
121  *  Media Contents of Notification Message (Optional)
122  */
123 typedef struct
124 {
125     char * iconImage;
126
127 } NSMediaContents;
128
129 /**
130  *  Notification Message
131  */
132 typedef struct
133 {
134     //Mandatory
135     uint64_t messageId;
136     char * providerId;
137
138     //optional
139     NSMessageType type;
140     char * dateTime;
141     uint64_t ttl;
142     char * title;
143     char * contentText;
144     char * sourceName;
145     NSMediaContents mediaContents;
146
147 } NSMessage;
148
149 /**
150  *  Synchronization information of the notification message
151  */
152 typedef struct
153 {
154     uint64_t messageId;
155     char * providerId;
156     NSSyncType state;
157
158 } NSSyncInfo;
159
160 #endif /* _NS_COMMON_H_ */
161