[N_SE-32914, 33582] Fixed priority converting codes
[framework/osp/social.git] / src / FSclCalTodo.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 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                FSclCalTodo.cpp
19  * @brief               This is the implementation for CalTodo class.
20  *
21  * This file contains definitions of @e CalTodo class.
22  */
23
24 #include <new>
25 #include <FSysSystemTime.h>
26 #include <FSclCalTodo.h>
27 #include <FBaseSysLog.h>
28 #include "FScl_CalTodoImpl.h"
29
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Collection;
32
33 namespace Tizen { namespace Social
34 {
35
36 CalTodo::CalTodo(void)
37         : Record(RECORD_TYPE_TODO)
38 {
39         __pCalTodoImpl = new (std::nothrow) _CalTodoImpl();
40         SysTryReturnVoidResult(NID_SCL, __pCalTodoImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
41 }
42
43 CalTodo::CalTodo(const CalTodo& rhs)
44         : Record(rhs)
45         , __pCalTodoImpl(null)
46 {
47         __pCalTodoImpl = new (std::nothrow) _CalTodoImpl(*rhs.__pCalTodoImpl);
48         SysTryReturnVoidResult(NID_SCL, __pCalTodoImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
49 }
50
51 CalTodo::~CalTodo(void)
52 {
53         delete __pCalTodoImpl;
54 }
55
56 CalTodo&
57 CalTodo::operator =(const CalTodo& rhs)
58 {
59         if (this == &rhs)
60         {
61                 return *this;
62         }
63
64         Record::operator=(rhs);
65
66         *__pCalTodoImpl = *rhs.__pCalTodoImpl;
67
68         return *this;
69 }
70
71 bool
72 CalTodo::Equals(const Object& rhs) const
73 {
74         const CalTodo* pCalTodo = dynamic_cast<const CalTodo*>(&rhs);
75
76         if (pCalTodo == null)
77         {
78                 return false;
79         }
80
81         return (Record::GetRecordId() == pCalTodo->GetRecordId());
82 }
83
84 int
85 CalTodo::GetHashCode(void) const
86 {
87         int hashCode = 17;
88
89         hashCode = static_cast<int>(( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ Record::GetRecordId());
90
91         return hashCode;
92 }
93
94 String
95 CalTodo::GetSubject(void) const
96 {
97         return __pCalTodoImpl->GetSubject();
98 }
99
100 String
101 CalTodo::GetDescription(void) const
102 {
103         return __pCalTodoImpl->GetDescription();
104 }
105
106 DateTime
107 CalTodo::GetStartDate(void) const
108 {
109         const DateTime& startDate = __pCalTodoImpl->GetStartDate();
110         result r = GetLastResult();
111         SysTryReturn(NID_SCL, r == E_SUCCESS, DateTime(), r, "[%s] Propagating.", GetErrorMessage(r));
112
113         return startDate;
114 }
115
116 DateTime
117 CalTodo::GetDueDate(void) const
118 {
119         const DateTime& dueDate = __pCalTodoImpl->GetDueDate();
120         result r = GetLastResult();
121         SysTryReturn(NID_SCL, r == E_SUCCESS, DateTime(), r, "[%s] Propagating.", GetErrorMessage(r));
122
123         return dueDate;
124 }
125
126 TodoPriority
127 CalTodo::GetPriority(void) const
128 {
129         return __pCalTodoImpl->GetPriority();
130 }
131
132 TodoStatus
133 CalTodo::GetStatus(void) const
134 {
135         return __pCalTodoImpl->GetStatus();
136 }
137
138 RecordSensitivity
139 CalTodo::GetSensitivity(void) const
140 {
141         return __pCalTodoImpl->GetSensitivity();
142 }
143
144 DateTime
145 CalTodo::GetLastRevisedTime(void) const
146 {
147         return __pCalTodoImpl->GetLastRevisedTime();
148 }
149
150 result
151 CalTodo::SetSubject(const String& subject)
152 {
153         result r = __pCalTodoImpl->SetSubject(subject);
154         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
155
156         return E_SUCCESS;
157 }
158
159 result
160 CalTodo::SetDescription(const String& description)
161 {
162         result r = __pCalTodoImpl->SetDescription(description);
163         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
164
165         return E_SUCCESS;
166 }
167
168 result
169 CalTodo::SetStartAndDueDate(const DateTime& start, const DateTime& end)
170 {
171         result r = __pCalTodoImpl->SetStartAndDueDate(start, end);
172         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
173
174         return E_SUCCESS;
175 }
176
177 result
178 CalTodo::SetStartDate(const DateTime& startDate)
179 {
180         result r = __pCalTodoImpl->SetStartDate(startDate);
181         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
182
183         return E_SUCCESS;
184 }
185
186 result
187 CalTodo::SetDueDate(const DateTime& dueDate)
188 {
189         result r = __pCalTodoImpl->SetDueDate(dueDate);
190         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
191
192         return E_SUCCESS;
193 }
194
195 void
196 CalTodo::SetPriority(TodoPriority priority)
197 {
198         __pCalTodoImpl->SetPriority(priority);
199 }
200
201 void
202 CalTodo::SetStatus(TodoStatus status)
203 {
204         __pCalTodoImpl->SetStatus(status);
205 }
206
207 void
208 CalTodo::SetSensitivity(RecordSensitivity sensitivity)
209 {
210         __pCalTodoImpl->SetSensitivity(sensitivity);
211 }
212
213 void
214 CalTodo::SetLocation(const String& location)
215 {
216         __pCalTodoImpl->SetLocation(location);
217 }
218
219 String
220 CalTodo::GetLocation(void) const
221 {
222         return __pCalTodoImpl->GetLocation();
223 }
224
225 result
226 CalTodo::SetCoordinates(double latitude, double longitude)
227 {
228         result r = __pCalTodoImpl->SetCoordinates(latitude, longitude);
229         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
230
231         return E_SUCCESS;
232 }
233
234 void
235 CalTodo::GetCoordinates(double& latitude, double& longitude) const
236 {
237         __pCalTodoImpl->GetCoordinates(latitude, longitude);
238 }
239
240 result
241 CalTodo::AddReminder(const Reminder& reminder)
242 {
243         result r = __pCalTodoImpl->AddReminder(reminder);
244         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
245
246         return E_SUCCESS;
247 }
248
249 result
250 CalTodo::RemoveReminderAt(int index)
251 {
252         result r = __pCalTodoImpl->RemoveReminderAt(index);
253         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
254
255         return E_SUCCESS;
256 }
257
258 const IList&
259 CalTodo::GetAllReminders(void) const
260 {
261         return __pCalTodoImpl->GetAllReminders();
262 }
263
264 RecordId
265 CalTodo::GetCalendarId(void) const
266 {
267         return __pCalTodoImpl->GetCalendarId();
268 }
269
270 }}      // Tizen::Social