2 // Open Service Platform
\r
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
\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
9 // http://www.apache.org/licenses/LICENSE-2.0
\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
18 * @file FMsg_EtwsPrimaryNotificationImpl.cpp
\r
19 * @brief This is the implementation file for the %_EtwsPrimaryNotificationImpl class.
\r
21 * This file contains the implementation of the %_EtwsPrimaryNotificationImpl class.
\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
33 using namespace Tizen::Base;
\r
34 using namespace Tizen::Messaging;
\r
35 using namespace Tizen::Security;
\r
37 namespace Tizen { namespace Messaging
\r
40 _EtwsPrimaryNotificationImpl::_EtwsPrimaryNotificationImpl(void)
\r
42 , __pEtwsSerialNumber(null)
\r
43 , __pEtwsSecurityInfo(null)
\r
44 , __etwsMessageId(0)
\r
45 , __pEtwsWarningType(null)
\r
47 __pEtwsSerialNumber = new (std::nothrow) ByteBuffer();
\r
48 SysTryReturnVoidResult(NID_MSG, __pEtwsSerialNumber != null, E_OUT_OF_MEMORY, "memory allocation failed");
\r
49 __pEtwsSerialNumber->Construct(0);
\r
50 __pEtwsSerialNumber->SetPosition(0);
\r
52 __pEtwsSecurityInfo = new (std::nothrow) ByteBuffer();
\r
53 SysTryReturnVoidResult(NID_MSG, __pEtwsSecurityInfo != null, E_OUT_OF_MEMORY, "memory allocation failed");
\r
54 __pEtwsSecurityInfo->Construct(0);
\r
55 __pEtwsSecurityInfo->SetPosition(0);
\r
57 __pEtwsWarningType = new (std::nothrow) ByteBuffer();
\r
58 SysTryReturnVoidResult(NID_MSG, __pEtwsWarningType != null, E_OUT_OF_MEMORY, "memory allocation failed");
\r
59 __pEtwsWarningType->Construct(0);
\r
60 __pEtwsWarningType->SetPosition(0);
\r
63 _EtwsPrimaryNotificationImpl::_EtwsPrimaryNotificationImpl(const _EtwsPrimaryNotificationImpl& value)
\r
65 __etwsMsgTime = value.__etwsMsgTime;
\r
66 __etwsMessageId = value.__etwsMessageId;
\r
68 __pEtwsSerialNumber->SetArray(value.__pEtwsSerialNumber->GetPointer(), 0, value.__pEtwsSerialNumber->GetLimit());
\r
69 __pEtwsSerialNumber->SetPosition(0);
\r
71 __pEtwsSecurityInfo->SetArray(value.__pEtwsSecurityInfo->GetPointer(), 0, value.__pEtwsSecurityInfo->GetLimit());
\r
72 __pEtwsSecurityInfo->SetPosition(0);
\r
74 __pEtwsWarningType->SetArray(value.__pEtwsWarningType->GetPointer(), 0, value.__pEtwsWarningType->GetLimit());
\r
75 __pEtwsWarningType->SetPosition(0);
\r
79 _EtwsPrimaryNotificationImpl::SetEtwsMessageImpl(const Tizen::Base::DateTime& dateTime, const Tizen::Base::ByteBuffer& etwsSerialNumber, const Tizen::Base::ByteBuffer&
\r
80 etwsSecurityInfo, int etwsMessageId, const Tizen::Base::ByteBuffer& etwsWarningType)
\r
82 result r = E_SUCCESS;
\r
84 __etwsMsgTime = dateTime;
\r
85 __etwsMessageId = etwsMessageId;
\r
87 __pEtwsSerialNumber = new (std::nothrow) ByteBuffer();
\r
88 SysTryReturn(NID_MSG, __pEtwsSerialNumber != null, E_OUT_OF_MEMORY, r = E_OUT_OF_MEMORY, "memory allocation failed");
\r
89 r = __pEtwsSerialNumber->Construct(etwsSerialNumber);
\r
90 r = __pEtwsSerialNumber->SetPosition(0);
\r
92 __pEtwsSecurityInfo = new (std::nothrow) ByteBuffer();
\r
93 SysTryCatch(NID_MSG, __pEtwsSecurityInfo != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
\r
94 r = __pEtwsSecurityInfo->Construct(etwsSecurityInfo);
\r
95 r = __pEtwsSecurityInfo->SetPosition(0);
\r
97 __pEtwsWarningType = new (std::nothrow) ByteBuffer();
\r
98 SysTryCatch(NID_MSG, __pEtwsWarningType != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
\r
99 r = __pEtwsWarningType->Construct(etwsWarningType);
\r
100 r = __pEtwsWarningType->SetPosition(0);
\r
105 SetLastResult(GetLastResult());
\r
106 if (__pEtwsSerialNumber)
\r
108 delete __pEtwsSerialNumber;
\r
109 __pEtwsSerialNumber = null;
\r
112 if (__pEtwsSecurityInfo)
\r
114 delete __pEtwsSecurityInfo;
\r
115 __pEtwsSecurityInfo = null;
\r
120 _EtwsPrimaryNotificationImpl::~_EtwsPrimaryNotificationImpl(void)
\r
122 if (__pEtwsSerialNumber)
\r
124 delete __pEtwsSerialNumber;
\r
125 __pEtwsSerialNumber = null;
\r
128 if (__pEtwsSecurityInfo)
\r
130 delete __pEtwsSecurityInfo;
\r
131 __pEtwsSecurityInfo = null;
\r
134 if (__pEtwsWarningType)
\r
136 delete __pEtwsWarningType;
\r
137 __pEtwsWarningType = null;
\r
141 _EtwsPrimaryNotificationImpl&
\r
142 _EtwsPrimaryNotificationImpl::operator =(const _EtwsPrimaryNotificationImpl& rhs)
\r
146 __etwsMsgTime = rhs.__etwsMsgTime;
\r
147 __etwsMessageId = rhs.__etwsMessageId;
\r
149 __pEtwsSerialNumber->SetArray(rhs.__pEtwsSerialNumber->GetPointer(), 0, rhs.__pEtwsSerialNumber->GetLimit());
\r
150 __pEtwsSerialNumber->SetPosition(0);
\r
152 __pEtwsSecurityInfo->SetArray(rhs.__pEtwsSecurityInfo->GetPointer(), 0, rhs.__pEtwsSecurityInfo->GetLimit());
\r
153 __pEtwsSecurityInfo->SetPosition(0);
\r
155 __pEtwsWarningType->SetArray(rhs.__pEtwsWarningType->GetPointer(), 0, rhs.__pEtwsWarningType->GetLimit());
\r
156 __pEtwsWarningType->SetPosition(0);
\r
162 EtwsPrimaryNotification*
\r
163 _EtwsPrimaryNotificationImpl::CloneN() const
\r
165 EtwsPrimaryNotification* pEtwsMsg = null;
\r
166 result r = E_SUCCESS;
\r
168 pEtwsMsg = _EtwsPrimaryNotificationImpl::GetEtwsPrimaryNotificationN();
\r
169 SysTryCatch(NID_MSG, pEtwsMsg != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
\r
171 r = _EtwsPrimaryNotificationImpl::GetInstance(*pEtwsMsg)->SetEtwsMessageImpl(__etwsMsgTime, *(__pEtwsSerialNumber), *(__pEtwsSecurityInfo), __etwsMessageId, *(__pEtwsWarningType));
\r
172 SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "etwsimpl message construct failed");
\r
174 SetLastResult(GetLastResult());
\r
178 SetLastResult(GetLastResult());
\r
188 _EtwsPrimaryNotificationImpl::Equals(const Tizen::Base::Object& obj) const
\r
190 const _EtwsPrimaryNotificationImpl* pEtwsPrimaryNotificationImpl = dynamic_cast<const _EtwsPrimaryNotificationImpl*>(&obj);
\r
192 if (!pEtwsPrimaryNotificationImpl)
\r
194 SysLog(NID_MSG, "dynamic_cast is failed");
\r
199 if (__etwsMsgTime != pEtwsPrimaryNotificationImpl->__etwsMsgTime)
\r
204 // etws serial number
\r
205 if (__pEtwsSerialNumber != pEtwsPrimaryNotificationImpl->__pEtwsSerialNumber)
\r
210 // etws security info
\r
211 if (__pEtwsSecurityInfo != pEtwsPrimaryNotificationImpl->__pEtwsSecurityInfo)
\r
217 if (__etwsMessageId != pEtwsPrimaryNotificationImpl->__etwsMessageId)
\r
222 // Etws warning type
\r
223 if (__pEtwsWarningType != pEtwsPrimaryNotificationImpl->__pEtwsWarningType)
\r
232 _EtwsPrimaryNotificationImpl::GetHashCode(void) const
\r
236 hash = __etwsMsgTime.GetHashCode() + __pEtwsSerialNumber->GetHashCode() + __pEtwsSecurityInfo->GetHashCode() + __etwsMessageId + __pEtwsWarningType->GetHashCode();
\r
241 EtwsPrimaryNotification*
\r
242 _EtwsPrimaryNotificationImpl::GetEtwsPrimaryNotificationN()
\r
244 result r = E_SUCCESS;
\r
245 EtwsPrimaryNotification* pEtwsMsg = null;
\r
247 pEtwsMsg = new (std::nothrow) EtwsPrimaryNotification();
\r
248 SysTryCatch(NID_MSG, pEtwsMsg != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
\r
256 _EtwsPrimaryNotificationImpl*
\r
257 _EtwsPrimaryNotificationImpl::GetInstance(EtwsPrimaryNotification& etwsMessage)
\r
259 return etwsMessage.__pEtwsPrimaryNotificationImpl;
\r
263 Tizen::Base::ByteBuffer*
\r
264 _EtwsPrimaryNotificationImpl::GetSerialNumberN(void) const
\r
266 result r = E_SUCCESS;
\r
267 Tizen::Base::ByteBuffer* pEtwsSerialNumber = null;
\r
271 pEtwsSerialNumber = new (std::nothrow) ByteBuffer();
\r
272 SysTryCatch(NID_MSG, pEtwsSerialNumber != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
\r
274 r = pEtwsSerialNumber->Construct(*__pEtwsSerialNumber);
\r
275 r = pEtwsSerialNumber->SetPosition(0);
\r
279 return pEtwsSerialNumber;
\r
287 Tizen::Base::DateTime
\r
288 _EtwsPrimaryNotificationImpl::GetReceivedTime(void) const
\r
290 return __etwsMsgTime;
\r
293 Tizen::Base::ByteBuffer*
\r
294 _EtwsPrimaryNotificationImpl::GetWarningSecurityInfoN(void) const
\r
296 result r = E_SUCCESS;
\r
297 Tizen::Base::ByteBuffer* pEtwsSecurityInfo = null;
\r
301 pEtwsSecurityInfo = new (std::nothrow) ByteBuffer();
\r
302 SysTryCatch(NID_MSG, pEtwsSecurityInfo != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
\r
304 r = pEtwsSecurityInfo->Construct(*__pEtwsSecurityInfo);
\r
305 r = pEtwsSecurityInfo->SetPosition(0);
\r
309 return pEtwsSecurityInfo;
\r
318 _EtwsPrimaryNotificationImpl::GetMessageId(void) const
\r
320 return __etwsMessageId;
\r
323 Tizen::Base::ByteBuffer*
\r
324 _EtwsPrimaryNotificationImpl::GetWarningTypeN(void) const
\r
326 result r = E_SUCCESS;
\r
327 Tizen::Base::ByteBuffer* pEtwsWarningType = null;
\r
331 pEtwsWarningType = new (std::nothrow) ByteBuffer();
\r
332 SysTryCatch(NID_MSG, pEtwsWarningType != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
\r
334 r = pEtwsWarningType->Construct(*__pEtwsWarningType);
\r
335 r = pEtwsWarningType->SetPosition(0);
\r
339 return pEtwsWarningType;
\r
347 } } // Tizen::Messaging
\r