Fix code for TDIS-5396
[framework/osp/social.git] / src / FSclCalEvent.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                FSclCalEvent.cpp
19  * @brief               This is the implementation for CalEvent class.
20  *
21  * This file contains definitions of @e CalEvent class.
22  */
23
24 #include <new>
25 #include <FSclCalEvent.h>
26 #include <FBaseSysLog.h>
27 #include "FScl_CalEventImpl.h"
28
29 using namespace Tizen::Base::Collection;
30 using namespace Tizen::Base;
31
32 namespace Tizen { namespace Social
33 {
34
35 CalEvent::CalEvent(void)
36         : Record(RECORD_TYPE_EVENT)
37         ,__pCalEventImpl(null)
38 {
39         __pCalEventImpl = new (std::nothrow) _CalEventImpl();
40         SysTryReturnVoidResult(NID_SCL, __pCalEventImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
41 }
42
43 CalEvent::CalEvent(const CalEvent& rhs)
44         : Record(rhs)
45         ,__pCalEventImpl(null)
46 {
47         __pCalEventImpl = new (std::nothrow) _CalEventImpl(*rhs.__pCalEventImpl);
48         SysTryReturnVoidResult(NID_SCL, __pCalEventImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
49 }
50
51 CalEvent::~CalEvent(void)
52 {
53         delete __pCalEventImpl;
54 }
55
56 CalEvent&
57 CalEvent::operator =(const CalEvent& rhs)
58 {
59         if (this == &rhs)
60         {
61                 return *this;
62         }
63
64         Record::operator=(rhs);
65
66         *__pCalEventImpl = *rhs.__pCalEventImpl;
67
68         return *this;
69 }
70
71 bool
72 CalEvent::Equals(const Object& rhs) const
73 {
74         const CalEvent* pCalEvent = dynamic_cast<const CalEvent*>(&rhs);
75
76         if (pCalEvent == null)
77         {
78                 return false;
79         }
80
81         return (Record::GetRecordId() == pCalEvent->GetRecordId());
82 }
83
84 int
85 CalEvent::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 bool
95 CalEvent::IsInstance(void) const
96 {
97         return __pCalEventImpl->IsInstance();
98 }
99
100 bool
101 CalEvent::IsRecurring(void) const
102 {
103         return __pCalEventImpl->IsRecurring();
104 }
105
106 RecordId
107 CalEvent::GetOriginalCalEventId(void)   const
108 {
109         return __pCalEventImpl->GetOriginalCalEventId();
110 }
111
112 bool
113 CalEvent::IsAllDayEvent(void)   const
114 {
115         return __pCalEventImpl->IsAllDayEvent();
116 }
117
118 void
119 CalEvent::SetAllDayEvent(bool isAllDayEvent)
120 {
121         __pCalEventImpl->SetAllDayEvent(isAllDayEvent);
122 }
123
124 ByteBuffer*
125 CalEvent::GetUIDN(void) const
126 {
127         ByteBuffer* pByteBuffer = __pCalEventImpl->GetUIDN();
128         result r = GetLastResult();
129         SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
130
131         return pByteBuffer;
132 }
133
134 result
135 CalEvent::SetUID(const ByteBuffer* pUID)
136 {
137         result r = __pCalEventImpl->SetUID(pUID);
138         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
139
140         return E_SUCCESS;
141 }
142
143 Tizen::Base::String
144 CalEvent::GetUid(void) const
145 {
146         ClearLastResult();
147         return __pCalEventImpl->GetUid();
148 }
149
150 void
151 CalEvent::SetUid(const Tizen::Base::String& uid)
152 {
153         ClearLastResult();
154         __pCalEventImpl->SetUid(uid);
155 }
156
157 EventStatus
158 CalEvent::GetStatus(void) const
159 {
160         return __pCalEventImpl->GetStatus();
161 }
162
163 void
164 CalEvent::SetStatus(EventStatus status)
165 {
166         __pCalEventImpl->SetStatus(status);
167 }
168
169 BusyStatus
170 CalEvent::GetBusyStatus(void) const
171 {
172         return __pCalEventImpl->GetBusyStatus();
173 }
174
175 void
176 CalEvent::SetBusyStatus(BusyStatus busyStatus)
177 {
178         __pCalEventImpl->SetBusyStatus(busyStatus);
179 }
180
181 EventPriority
182 CalEvent::GetPriority(void) const
183 {
184         return __pCalEventImpl->GetPriority();
185 }
186
187 void
188 CalEvent::SetPriority(EventPriority priority)
189 {
190         __pCalEventImpl->SetPriority(priority);
191 }
192
193 result
194 CalEvent::AddAttendee(const Attendee& attendee)
195 {
196         result r = __pCalEventImpl->AddAttendee(attendee);
197         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
198
199         return E_SUCCESS;
200 }
201
202 result
203 CalEvent::RemoveAttendee(const Attendee& attendee)
204 {
205         result r = __pCalEventImpl->RemoveAttendee(attendee);
206         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
207
208         return E_SUCCESS;
209 }
210
211 IList*
212 CalEvent::GetAllAttendeesN(void) const
213 {
214         IList* pList = __pCalEventImpl->GetAllAttendeesN();
215         result r = GetLastResult();
216         SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
217
218         return pList;
219 }
220
221 Tizen::Locales::TimeZone
222 CalEvent::GetTimeZone(void) const
223 {
224         return __pCalEventImpl->GetTimeZone();
225 }
226
227 result
228 CalEvent::SetTimeZone(const Tizen::Locales::TimeZone& timeZone)
229 {
230         return __pCalEventImpl->SetTimeZone(timeZone);
231 }
232
233 RecurrenceId
234 CalEvent::GetRecurrenceId(void) const
235 {
236         RecurrenceId recurrenceId = __pCalEventImpl->GetRecurrenceId();
237         result r = GetLastResult();
238         SysTryReturn(NID_SCL, r == E_SUCCESS, DateTime(), r, "[%s] Propagating.", GetErrorMessage(r));
239
240         return recurrenceId;
241 }
242
243 String
244 CalEvent::GetSubject(void) const
245 {
246         return __pCalEventImpl->GetSubject();
247 }
248
249 String
250 CalEvent::GetDescription(void) const
251 {
252         return __pCalEventImpl->GetDescription();
253 }
254
255
256 DateTime
257 CalEvent::GetStartTime(void) const
258 {
259         return __pCalEventImpl->GetStartTime();
260 }
261
262 DateTime
263 CalEvent::GetEndTime(void) const
264 {
265         return __pCalEventImpl->GetEndTime();
266 }
267
268 String
269 CalEvent::GetLocation(void) const
270 {
271         return __pCalEventImpl->GetLocation();
272 }
273
274 EventCategory
275 CalEvent::GetCategory(void) const
276 {
277         return __pCalEventImpl->GetCategory();
278 }
279
280 RecordSensitivity
281 CalEvent::GetSensitivity(void) const
282 {
283         return __pCalEventImpl->GetSensitivity();
284 }
285
286
287 const Reminder*
288 CalEvent::GetReminder(void) const
289 {
290         return __pCalEventImpl->GetReminder();
291 }
292
293 const Recurrence*
294 CalEvent::GetRecurrence(void) const
295 {
296         return __pCalEventImpl->GetRecurrence();
297 }
298
299 DateTime
300 CalEvent::GetLastRevisedTime(void) const
301 {
302         return __pCalEventImpl->GetLastRevisedTime();
303 }
304
305 result
306 CalEvent::SetSubject(const String& subject)
307 {
308         result r = __pCalEventImpl->SetSubject(subject);
309         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
310
311         return E_SUCCESS;
312 }
313
314 result
315 CalEvent::SetDescription(const String& description)
316 {
317         result r = __pCalEventImpl->SetDescription(description);
318         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
319
320         return E_SUCCESS;
321 }
322
323 result
324 CalEvent::SetStartAndEndTime(const DateTime& start, const DateTime& end)
325 {
326         result r = __pCalEventImpl->SetStartAndEndTime(start, end);
327         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
328
329         return E_SUCCESS;
330 }
331
332 result
333 CalEvent::SetLocation(const String& location)
334 {
335         result r = __pCalEventImpl->SetLocation(location);
336         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
337
338         return E_SUCCESS;
339 }
340
341 void
342 CalEvent::SetCategory(EventCategory category)
343 {
344         __pCalEventImpl->SetCategory(category);
345 }
346
347 void
348 CalEvent::SetSensitivity(RecordSensitivity sensitivity)
349 {
350         __pCalEventImpl->SetSensitivity(sensitivity);
351 }
352
353 result
354 CalEvent::SetCoordinates(double latitude, double longitude)
355 {
356         result r = __pCalEventImpl->SetCoordinates(latitude, longitude);
357         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
358
359         return E_SUCCESS;
360 }
361
362 void
363 CalEvent::GetCoordinates(double& latitude, double& longitude) const
364 {
365         __pCalEventImpl->GetCoordinates(latitude, longitude);
366 }
367
368 result
369 CalEvent::SetReminder(const Reminder* pReminder)
370 {
371         result r = __pCalEventImpl->SetReminder(pReminder);
372         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
373
374         return E_SUCCESS;
375 }
376
377 result
378 CalEvent::SetRecurrence(const Recurrence* pRecurrence)
379 {
380         result r = __pCalEventImpl->SetRecurrence(pRecurrence);
381         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
382
383         return E_SUCCESS;
384 }
385
386 result
387 CalEvent::AddReminder(const Reminder& reminder)
388 {
389         result r = __pCalEventImpl->AddReminder(reminder);
390         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
391
392         return E_SUCCESS;
393 }
394
395 result
396 CalEvent::RemoveReminderAt(int index)
397 {
398         result r = __pCalEventImpl->RemoveReminderAt(index);
399         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
400
401         return E_SUCCESS;
402 }
403
404 const IList&
405 CalEvent::GetAllReminders(void) const
406 {
407         return __pCalEventImpl->GetAllReminders();
408 }
409
410 RecordId
411 CalEvent::GetCalendarId(void) const
412 {
413         return __pCalEventImpl->GetCalendarId();
414 }
415
416 RecordId
417 CalEvent::GetBaseEventId(void) const
418 {
419         return __pCalEventImpl->GetBaseEventId();
420 }
421
422 }}      // Tizen::Social