Merge notification service from master branch
[platform/upstream/iotivity.git] / service / notification / cpp-wrapper / common / NSMessage.h
1 //******************************************************************\r
2 //\r
3 // Copyright 2016 Samsung Electronics All Rights Reserved.\r
4 //\r
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
6 //\r
7 // Licensed under the Apache License, Version 2.0 (the "License");\r
8 // you may not use this file except in compliance with the License.\r
9 // You may obtain a copy of the License at\r
10 //\r
11 //      http://www.apache.org/licenses/LICENSE-2.0\r
12 //\r
13 // Unless required by applicable law or agreed to in writing, software\r
14 // distributed under the License is distributed on an "AS IS" BASIS,\r
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16 // See the License for the specific language governing permissions and\r
17 // limitations under the License.\r
18 //\r
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
20 \r
21 /**\r
22  * @file\r
23  *\r
24  * This file contains Notification service Message representation.\r
25  */\r
26 \r
27 #ifndef _NS_MESSAGE_H_\r
28 #define _NS_MESSAGE_H_\r
29 \r
30 #include <string>\r
31 #include "NSMediaContents.h"\r
32 #include "OCRepresentation.h"\r
33 \r
34 namespace OIC\r
35 {\r
36     namespace Service\r
37     {\r
38         /**\r
39          * @class   NSMessage\r
40          * @brief   This class provides a set of APIs for Notification service Message .\r
41          */\r
42         class NSMessage\r
43         {\r
44             public:\r
45                 /** NSMessageType - enumeration for Notification service MessageType*/\r
46                 enum class NSMessageType\r
47                 {\r
48                     NS_MESSAGE_ALERT = 0,\r
49                     NS_MESSAGE_NOTICE = 1,\r
50                     NS_MESSAGE_EVENT = 2,\r
51                     NS_MESSAGE_INFO = 3,\r
52                 };\r
53 \r
54                 /**\r
55                         * Constructor of NSMessage.\r
56                         */\r
57                 NSMessage(): m_messageId(0), m_type(NSMessageType::NS_MESSAGE_ALERT), m_ttl(0),\r
58                     m_mediaContents(new NSMediaContents), m_extraInfo(OC::OCRepresentation())\r
59                 {\r
60                 }\r
61 \r
62                 /**\r
63                         * Constructor of NSMessage.\r
64                         *\r
65                         * @param msg - pointer to NSMessage struct to initialize.\r
66                         */\r
67                 NSMessage(::NSMessage *msg);\r
68 \r
69                 /**\r
70                      * Copy Constructor of NSMessage.\r
71                      *\r
72                      * @param msg - NSMessage to initialize.\r
73                      */\r
74                 NSMessage(const NSMessage &msg);\r
75 \r
76                 /**\r
77                      * Copy assignment operator of NSMessage.\r
78                      *\r
79                      * @param msg -  NSMessage to initialize.\r
80                      * @return NSMessage object reference\r
81                      */\r
82                 NSMessage &operator=(const NSMessage &msg);\r
83 \r
84                 /**\r
85                         * Destructor of NSMessage.\r
86                         */\r
87                 ~NSMessage();\r
88 \r
89                 /**\r
90                      * This method is for getting Message Id from the Notification service Message.\r
91                      *\r
92                      * @return Id as uint64_t.\r
93                      */\r
94                 uint64_t getMessageId() const;\r
95 \r
96                 /**\r
97                      * This method is for getting Provider Id from the Notification service Message.\r
98                      *\r
99                      * @return Id as string.\r
100                      */\r
101                 std::string getProviderId() const;\r
102 \r
103                 /**\r
104                      * This method is for getting type from the Notification service Message.\r
105                      *\r
106                      * @return type as NSMessageType.\r
107                      */\r
108                 NSMessageType getType() const;\r
109 \r
110                 /**\r
111                      * This method is for setting type from the Notification service Message.\r
112                      *\r
113                      * @param type as NSMessageType.\r
114                      */\r
115                 void setType(const NSMessageType &type);\r
116 \r
117                 /**\r
118                      * This method is for getting time from the Notification service Message.\r
119                      *\r
120                      * @return time as string.\r
121                      */\r
122                 std::string getTime() const;\r
123 \r
124                 /**\r
125                      * This method is for setting time from the Notification service Message.\r
126                      *\r
127                      * @param time as string.\r
128                      */\r
129                 void setTime(const std::string &time);\r
130 \r
131                 /**\r
132                      * This method is for getting time to live from the Notification service Message.\r
133                      *\r
134                      * @return ttl as uint64_t.\r
135                      */\r
136                 uint64_t getTTL() const;\r
137 \r
138                 /**\r
139                      * This method is for setting time to live from the Notification service Message.\r
140                      *\r
141                      * @param ttl as uint64_t.\r
142                      */\r
143                 void setTTL(const uint64_t &ttl);\r
144 \r
145                 /**\r
146                      * This method is for getting Title from the Notification service Message.\r
147                      *\r
148                      * @return Title as string.\r
149                      */\r
150                 std::string getTitle() const;\r
151 \r
152                 /**\r
153                      * This method is for setting Title from the Notification service Message.\r
154                      *\r
155                      * @param title as string.\r
156                      */\r
157                 void setTitle(const std::string &title);\r
158 \r
159                 /**\r
160                      * This method is for getting contentText from the Notification service Message.\r
161                      *\r
162                      * @return contentText as string.\r
163                      */\r
164                 std::string getContentText() const;\r
165 \r
166                 /**\r
167                      * This method is for setting contentText from the Notification service Message.\r
168                      *\r
169                      * @param contextText as string.\r
170                      */\r
171                 void setContentText(const std::string &contextText);\r
172 \r
173                 /**\r
174                      * This method is for getting sourceName from the Notification service Message.\r
175                      *\r
176                      * @return sourceName as string.\r
177                      */\r
178                 std::string getSourceName() const;\r
179 \r
180                 /**\r
181                      * This method is for setting sourceName from the Notification service Message.\r
182                      *\r
183                      * @param sourceName as string.\r
184                      */\r
185                 void setSourceName(const std::string &sourceName);\r
186 \r
187                 /**\r
188                      * This method is for getting mediaContents from the Notification service Message.\r
189                      *\r
190                      * @return mediaContents as NSMediaContents pointer.\r
191                      */\r
192                 NSMediaContents *getMediaContents() const;\r
193 \r
194                 /**\r
195                      * This method is for setting mediaContents from the Notification service Message.\r
196                      *\r
197                      * @param mediaContents as NSMediaContents pointer.\r
198                      */\r
199                 void setMediaContents(NSMediaContents *mediaContents);\r
200 \r
201                 /**\r
202                      * This method is for getting Topic from the Notification service Message.\r
203                      *\r
204                      * @return Topic as string.\r
205                      */\r
206                 std::string getTopic() const;\r
207 \r
208                 /**\r
209                      * This method is for setting Topic for the Notification service Message.\r
210                      *\r
211                      * @return Topic as string.\r
212                      */\r
213                 void setTopic(const std::string &topic);\r
214 \r
215                 /**\r
216                      * This method is for getting extraInfo from the Notification service Message.\r
217                      *\r
218                      * @return extraInfo as OCRepresentation.\r
219                      */\r
220                 OC::OCRepresentation getExtraInfo() const;\r
221 \r
222                 /**\r
223                      * This method is for setting extraInfo for the Notification service Message.\r
224                      *\r
225                      * @return extraInfo as OCRepresentation.\r
226                      */\r
227                 void setExtraInfo(const OC::OCRepresentation &extraInfo);\r
228 \r
229             private:\r
230                 uint64_t m_messageId;\r
231                 std::string m_providerId;\r
232 \r
233                 NSMessageType m_type;\r
234                 std::string m_time;\r
235                 uint64_t m_ttl;\r
236                 std::string m_title;\r
237                 std::string m_contentText;\r
238                 std::string m_sourceName;\r
239                 NSMediaContents *m_mediaContents;\r
240                 std::string m_topic;\r
241                 OC::OCRepresentation m_extraInfo;\r
242 \r
243         };\r
244     }\r
245 }\r
246 #endif /* _NS_MESSAGE_H_ */\r