Initialize Tizen 2.3
[framework/osp/messaging.git] / src / FMsgPushMessage.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 /**
18 * @file                 FMsgPushMessage.cpp
19 * @brief                This is the implementation file for the %PushMessage class.
20 *
21 * This file contains the implementation of the %PushMessage class.
22 */
23
24 #include <FMsgPushMessage.h>
25 #include <FBaseSysLog.h>
26 #include "FMsg_PushMessageImpl.h"
27
28 using namespace Tizen::Base;
29 using namespace Tizen::Shell;
30
31 namespace Tizen { namespace Messaging
32 {
33
34 PushMessage::PushMessage(void)
35 {
36         __pPushMessageImpl = new (std::nothrow) _PushMessageImpl();
37     SysTryReturnVoidResult(NID_MSG, __pPushMessageImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
38 }
39
40 PushMessage::PushMessage(const DateTime& dateTime, const String& text)
41 {
42         __pPushMessageImpl = new (std::nothrow) _PushMessageImpl(dateTime, text);
43     SysTryReturnVoidResult(NID_MSG, __pPushMessageImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
44 }
45
46 PushMessage::~PushMessage(void)
47 {
48         delete __pPushMessageImpl;
49         __pPushMessageImpl = null;
50 }
51
52 PushMessage::PushMessage(const PushMessage& rhs)
53 {
54         __pPushMessageImpl = new (std::nothrow) _PushMessageImpl(*(rhs.__pPushMessageImpl));
55     SysTryReturnVoidResult(NID_MSG, __pPushMessageImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
56 }
57
58 PushMessage&
59 PushMessage::operator =(const PushMessage& rhs)
60 {
61         if (this == &rhs)
62         {
63                 return *this;
64         }
65
66         *__pPushMessageImpl = *rhs.__pPushMessageImpl;
67
68         return *this;
69 }
70
71 bool
72 PushMessage::Equals(const Object& obj) const
73 {
74         const PushMessage* pRhs = dynamic_cast<const PushMessage*>(&obj);
75         if (pRhs == null)
76         {
77                 return false;
78         }
79
80         const _PushMessageImpl* pRhsImpl = _PushMessageImpl::GetInstance(*pRhs);
81         if (pRhsImpl == null)
82         {
83                 return false;
84         }
85
86         return __pPushMessageImpl->Equals(*pRhsImpl);
87 }
88
89 int
90 PushMessage::GetHashCode(void) const
91 {
92         return __pPushMessageImpl->GetHashCode();
93 }
94
95 DateTime
96 PushMessage::GetReceivedTime(void) const
97 {
98         return __pPushMessageImpl->GetReceivedTime();
99 }
100
101 String
102 PushMessage::GetText(void) const
103 {
104         return __pPushMessageImpl->GetText();
105 }
106
107 result
108 PushMessage::SetAction(PushAction action)
109 {
110         return __pPushMessageImpl->SetAction(action);
111 }
112
113 PushAction
114 PushMessage::GetAction(void) const
115 {
116         return __pPushMessageImpl->GetAction();
117 }
118
119 result
120 PushMessage::SetNotification(const NotificationRequest& notificationRequest)
121 {
122         return __pPushMessageImpl->SetNotification(notificationRequest);
123 }
124
125 NotificationRequest
126 PushMessage::GetNotification(void) const
127 {
128         return __pPushMessageImpl->GetNotification();
129 }
130
131 } } // Tizen::Messaging