merge with master
[framework/osp/messaging.git] / src / FMsgEtwsPrimaryNotification.cpp
1 //\r
2 // Open Service Platform\r
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.\r
4 //\r
5 // Licensed under the Apache License, Version 2.0 (the License);\r
6 // you may not use this file except in compliance with the License.\r
7 // You may obtain a copy of the License at\r
8 //\r
9 //     http://www.apache.org/licenses/LICENSE-2.0\r
10 //\r
11 // Unless required by applicable law or agreed to in writing, software\r
12 // distributed under the License is distributed on an "AS IS" BASIS,\r
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
14 // See the License for the specific language governing permissions and\r
15 // limitations under the License.\r
16 //\r
17 /**\r
18  * @file                FMsgEtwsPrimaryNotification.cpp\r
19  * @brief               This is the implementation file for the %EtwsPrimaryNotification class.\r
20  *\r
21  * This file contains the implementation of the %EtwsPrimaryNotification class.\r
22  */\r
23 \r
24 #include <msg.h>\r
25 #include <msg_transport.h>\r
26 #include <msg_storage.h>\r
27 #include <FMsgEtwsPrimaryNotification.h>\r
28 #include <FBaseSysLog.h>\r
29 #include <FSec_AccessController.h>\r
30 #include "FMsg_Types.h"\r
31 #include "FMsg_EtwsPrimaryNotificationImpl.h"\r
32 \r
33 using namespace Tizen::Base;\r
34 using namespace Tizen::Messaging;\r
35 using namespace Tizen::Security;\r
36 \r
37 namespace Tizen { namespace Messaging\r
38 {\r
39 \r
40 EtwsPrimaryNotification::EtwsPrimaryNotification(void)\r
41 {\r
42         __pEtwsPrimaryNotificationImpl = new (std::nothrow) _EtwsPrimaryNotificationImpl();\r
43         SysTryReturnVoidResult(NID_MSG, __pEtwsPrimaryNotificationImpl != null, E_OUT_OF_MEMORY, "memory allocation failed.");\r
44 }\r
45 \r
46 EtwsPrimaryNotification::EtwsPrimaryNotification(const EtwsPrimaryNotification& value)\r
47 {\r
48         __pEtwsPrimaryNotificationImpl = new (std::nothrow) _EtwsPrimaryNotificationImpl(*(value.__pEtwsPrimaryNotificationImpl));\r
49         SysTryReturnVoidResult(NID_MSG, __pEtwsPrimaryNotificationImpl != null, E_OUT_OF_MEMORY, "memory allocation failed.");\r
50 }\r
51 \r
52 EtwsPrimaryNotification::~EtwsPrimaryNotification(void)\r
53 {\r
54         if (__pEtwsPrimaryNotificationImpl)\r
55         {\r
56                 delete __pEtwsPrimaryNotificationImpl;\r
57         }\r
58         __pEtwsPrimaryNotificationImpl = null;\r
59 }\r
60 \r
61 EtwsPrimaryNotification&\r
62 EtwsPrimaryNotification::operator =(const EtwsPrimaryNotification& rhs)\r
63 {\r
64         if (this != &rhs)\r
65         {\r
66                 *__pEtwsPrimaryNotificationImpl = *(rhs.__pEtwsPrimaryNotificationImpl);\r
67         }\r
68 \r
69         return (*this);\r
70 }\r
71 \r
72 EtwsPrimaryNotification*\r
73 EtwsPrimaryNotification::CloneN() const\r
74 {\r
75         return __pEtwsPrimaryNotificationImpl->CloneN();\r
76 }\r
77 \r
78 bool\r
79 EtwsPrimaryNotification::Equals(const Tizen::Base::Object& obj) const\r
80 {\r
81         const EtwsPrimaryNotification* pEtwsPrimaryNotification = dynamic_cast<const EtwsPrimaryNotification*>(&obj);\r
82         if (!pEtwsPrimaryNotification)\r
83         {\r
84                 SysLog(NID_MSG, "dynamic_cast is failed");\r
85                 return false;\r
86         }\r
87 \r
88         return __pEtwsPrimaryNotificationImpl->Equals(*(pEtwsPrimaryNotification->__pEtwsPrimaryNotificationImpl));\r
89 }\r
90 \r
91 int\r
92 EtwsPrimaryNotification::GetHashCode(void) const\r
93 {\r
94         return __pEtwsPrimaryNotificationImpl->GetHashCode();\r
95 }\r
96 \r
97 Tizen::Base::ByteBuffer*\r
98 EtwsPrimaryNotification::GetSerialNumberN(void) const\r
99 {\r
100         result r = E_SUCCESS;\r
101         Tizen::Base::ByteBuffer* pSerialnumber = null;\r
102         ClearLastResult();\r
103 \r
104         SysAssertf(__pEtwsPrimaryNotificationImpl != null, "The CbsChannel instance is not constructed yet.");\r
105 \r
106         pSerialnumber = __pEtwsPrimaryNotificationImpl->GetSerialNumberN();\r
107 \r
108         r = GetLastResult();\r
109         SetLastResult(r);\r
110 \r
111         SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "failed to get cbs message SerialNumber .");\r
112 \r
113         return pSerialnumber;\r
114 \r
115 CATCH:\r
116         SetLastResult(GetLastResult());\r
117 \r
118         if (pSerialnumber)\r
119         {\r
120                 delete pSerialnumber;\r
121                 pSerialnumber = null;\r
122         }\r
123         return null;\r
124 }\r
125 \r
126 Tizen::Base::DateTime\r
127 EtwsPrimaryNotification::GetReceivedTime(void) const\r
128 {\r
129         SysAssertf(__pEtwsPrimaryNotificationImpl != null, "The CbsChannel instance is not constructed yet.");\r
130 \r
131         return (__pEtwsPrimaryNotificationImpl->GetReceivedTime());\r
132 }\r
133 \r
134 Tizen::Base::ByteBuffer*\r
135 EtwsPrimaryNotification::GetWarningSecurityInfoN(void) const\r
136 {\r
137         result r = E_SUCCESS;\r
138         Tizen::Base::ByteBuffer* pSecurityInfo = null;\r
139         ClearLastResult();\r
140 \r
141         SysAssertf(__pEtwsPrimaryNotificationImpl != null, "The CbsChannel instance is not constructed yet.");\r
142 \r
143         pSecurityInfo = __pEtwsPrimaryNotificationImpl->GetWarningSecurityInfoN();\r
144 \r
145         r = GetLastResult();\r
146         SetLastResult(r);\r
147 \r
148         SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "failed to get cbs message SerialNumber .");\r
149 \r
150         return pSecurityInfo;\r
151 \r
152 CATCH:\r
153         SetLastResult(GetLastResult());\r
154 \r
155         if (pSecurityInfo)\r
156         {\r
157                 delete pSecurityInfo;\r
158                 pSecurityInfo = null;\r
159         }\r
160         return null;\r
161 }\r
162 \r
163 int\r
164 EtwsPrimaryNotification::GetMessageId(void) const\r
165 {\r
166         SysAssertf(__pEtwsPrimaryNotificationImpl != null, "The CbsChannel instance is not constructed yet.");\r
167 \r
168         return (__pEtwsPrimaryNotificationImpl->GetMessageId());\r
169 }\r
170 \r
171 Tizen::Base::ByteBuffer*\r
172 EtwsPrimaryNotification::GetWarningTypeN(void) const\r
173 {\r
174         SysAssertf(__pEtwsPrimaryNotificationImpl != null, "The CbsChannel instance is not constructed yet.");\r
175 \r
176         result r = E_SUCCESS;\r
177         Tizen::Base::ByteBuffer* pWarningType = null;\r
178         ClearLastResult();\r
179 \r
180         SysAssertf(__pEtwsPrimaryNotificationImpl != null, "The CbsChannel instance is not constructed yet.");\r
181 \r
182         pWarningType = __pEtwsPrimaryNotificationImpl->GetWarningTypeN();\r
183 \r
184         r = GetLastResult();\r
185         SetLastResult(r);\r
186 \r
187         SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "failed to get cbs Warning type .");\r
188 \r
189         return pWarningType;\r
190 \r
191 CATCH:\r
192         SetLastResult(GetLastResult());\r
193 \r
194         if (pWarningType)\r
195         {\r
196                 delete pWarningType;\r
197                 pWarningType = null;\r
198         }\r
199         return null;\r
200 }\r
201 \r
202 } } // Tizen::Messaging\r