Beta merge 2
[profile/ivi/wrt-plugins-tizen.git] / src / platform / API / Calendar / CalendarEvent.cpp
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17
18 #include <dpl/log/log.h>
19 #include <Commons/Exception.h>
20 #include "CalendarEvent.h"
21
22 namespace TizenApis {
23 namespace Api {
24 namespace Calendar {
25
26 CalendarEvent::CalendarEvent() :
27     m_calendarId(UNDEFINED_CALENDAR_ID),
28     m_recurrence(new EventRecurrenceRule()),
29     m_status(UNDEFINED_STATUS),
30     m_categories(new CategoryList()),
31     m_isAllDay(false),
32     m_recurrenceId(0),
33     m_attendees(new EventAttendeeList()),
34     m_isDetached(false),
35     m_attributesOfInterest(new AttributeList()),
36     m_geolocation(new CalendarItemGeo()),
37     m_calendarType(EVENT_TYPE)
38 {
39 }
40
41 CalendarEvent::CalendarEvent(const CalendarEvent &original)
42 {
43     LogDebug("Copy constructor called.");
44
45     m_id = original.getId();
46     m_calendarId = original.getCalendarId();
47     m_description = original.getDescription();
48     m_subject = original.getSubject();
49     m_startTime = original.getStartTime();
50     m_endTime = original.getEndTime();
51     m_location = original.getLocation();
52
53     EventRecurrenceRulePtr recurrenceRulePtr( new EventRecurrenceRule() );
54     m_recurrence = recurrenceRulePtr;
55     m_recurrence->setFrequency(original.getRecurrenceRule()->getFrequency());
56     m_recurrence->setInterval(original.getRecurrenceRule()->getInterval());
57     m_recurrence->setEndDate(original.getRecurrenceRule()->getEndDate());
58     m_recurrence->setOccurrenceCount(original.getRecurrenceRule()->getOccurrenceCount());
59     m_recurrence->setDaysOfTheMonth(original.getRecurrenceRule()->getDaysOfTheMonth());
60     m_recurrence->setDaysOfTheWeek(original.getRecurrenceRule()->getDaysOfTheWeek());
61     m_recurrence->setDaysOfTheYear(original.getRecurrenceRule()->getDaysOfTheYear());
62     m_recurrence->setWeeksOfTheYear(original.getRecurrenceRule()->getWeeksOfTheYear());
63     m_recurrence->setSetPosition(original.getRecurrenceRule()->getSetPosition());
64     m_recurrence->setExceptions(original.getRecurrenceRule()->getExceptions());
65     m_recurrence->setTimeZone(original.getRecurrenceRule()->getTimeZone());
66
67     m_status = original.getStatus();
68     m_alarmsTick = original.getAlarmsTick();
69     m_alarmsType = original.getAlarmsType();
70     m_alarmsDescription = original.getAlarmsDescription();
71
72     CategoryListPtr categoriesPtr( new CategoryList() );
73     m_categories = categoriesPtr;
74     *m_categories = *(original.getCategories());
75
76     m_isAllDay = original.getIsAllDay();
77     m_organizer = original.getOrganizer();
78     m_lastModifiedDate = original.getLastModifiedDate();
79     m_visibility = original.getVisibility();
80     m_availability = original.getAvailability();
81     m_uid = original.getUId();
82     m_recurrenceId = original.getRecurrenceId();
83
84     LogDebug("Copying attendees...");
85     EventAttendeeListPtr attendeesPtr( new EventAttendeeList() );
86     m_attendees = attendeesPtr;
87     for( unsigned int i=0; i<original.getAttendees()->size(); i++) {
88         EventAttendeePtr attendeePtr( new EventAttendee() );
89         attendeePtr->setName(original.getAttendees()->at(i)->getName());
90         attendeePtr->setURI(original.getAttendees()->at(i)->getURI());
91         attendeePtr->setRole(original.getAttendees()->at(i)->getRole());
92         attendeePtr->setStatus(original.getAttendees()->at(i)->getStatus());
93         attendeePtr->setRSVP(original.getAttendees()->at(i)->getRSVP());
94         attendeePtr->setType(original.getAttendees()->at(i)->getType());
95         attendeePtr->setGroup(original.getAttendees()->at(i)->getGroup());
96         attendeePtr->setDelegatorURI(original.getAttendees()->at(i)->getDelegatorURI());
97         attendeePtr->setDelegateURI(original.getAttendees()->at(i)->getDelegateURI());
98         attendeePtr->setPersonId(original.getAttendees()->at(i)->getPersonId());
99         m_attendees->push_back(attendeePtr);
100     }
101
102     m_isDetached = original.getIsDetached();
103
104     AttributeListPtr attributesPtr( new AttributeList() );
105     m_attributesOfInterest = attributesPtr;
106     *m_attributesOfInterest = *(original.getAttributesOfInterest());
107
108     CalendarItemGeoPtr geoPtr( new CalendarItemGeo() );
109     m_geolocation = geoPtr;
110     m_geolocation->setLatitude(original.getGeolocation()->getLatitude());
111     m_geolocation->setLongitude(original.getGeolocation()->getLongitude());
112
113     m_timeZone = original.getTimeZone();
114     m_priority = original.getPriority();
115     m_createdDate = original.getCreatedDate();
116     m_completedDate = original.getCompletedDate();
117     m_progress = original.getProgress();
118     m_calendarType = original.getCalendarType();
119
120     LogDebug("Copying done.");
121 }
122
123 CalendarEvent::~CalendarEvent()
124 {
125 }
126
127 bool CalendarEvent::getIdIsSet() const
128 {
129     return !m_id.IsNull();
130 }
131
132 int CalendarEvent::getCalendarId() const
133 {
134     return m_calendarId;
135 }
136
137 void CalendarEvent::setCalendarId(int value)
138 {
139     m_calendarId = value;
140 }
141
142 int CalendarEvent::getId() const
143 {
144     return *m_id;
145 }
146
147 void CalendarEvent::setId(int value)
148 {
149     m_id = value;
150 }
151
152 void CalendarEvent::resetId()
153 {
154     m_id = DPL::Optional<int>();
155 }
156
157 std::string CalendarEvent::getDescription() const
158 {
159     return m_description;
160 }
161
162 void CalendarEvent::setDescription(const std::string &value)
163 {
164     m_description = value;
165 }
166
167 std::string CalendarEvent::getSubject() const
168 {
169     return m_subject;
170 }
171
172 void CalendarEvent::setSubject(const std::string &value)
173 {
174     m_subject = value;
175 }
176
177 std::time_t CalendarEvent::getStartTime() const
178 {
179     return m_startTime;
180 }
181
182 void CalendarEvent::setStartTime(std::time_t value)
183 {
184     m_startTime = value;
185 }
186
187 std::time_t CalendarEvent::getEndTime() const
188 {
189     return m_endTime;
190 }
191
192 void CalendarEvent::setEndTime(std::time_t value)
193 {
194     m_endTime = value;
195 }
196
197 std::string CalendarEvent::getLocation() const
198 {
199     return m_location;
200 }
201
202 void CalendarEvent::setLocation(const std::string &value)
203 {
204     m_location = value;
205 }
206
207 EventRecurrenceRulePtr CalendarEvent::getRecurrenceRule() const
208 {
209     return m_recurrence;
210 }
211
212 void CalendarEvent::setRecurrenceRule(EventRecurrenceRulePtr value)
213 {
214     m_recurrence = value;
215 }
216
217 CalendarEvent::EventStatus CalendarEvent::getStatus() const
218 {
219     return m_status == UNDEFINED_STATUS ? TENTATIVE_STATUS : m_status;
220 }
221
222 void CalendarEvent::setStatus(EventStatus value)
223 {
224     m_status = value;
225 }
226
227 std::vector<long> CalendarEvent::getAlarmsTick() const
228 {
229     return m_alarmsTick;
230 }
231
232 void CalendarEvent::setAlarmsTick(std::vector<long> &value)
233 {
234     m_alarmsTick = value;
235 }
236
237 std::vector<CalendarEvent::EventAlarmType> CalendarEvent::getAlarmsType() const
238 {
239     return m_alarmsType;
240 }
241
242 void CalendarEvent::setAlarmsType(std::vector<EventAlarmType> &value)
243 {
244     m_alarmsType = value;
245 }
246
247 std::vector<std::string> CalendarEvent::getAlarmsDescription() const
248 {
249     return m_alarmsDescription;
250 }
251
252 void CalendarEvent::setAlarmsDescription(std::vector<std::string> &value)
253 {
254     m_alarmsDescription = value;
255 }
256
257 CategoryListPtr CalendarEvent::getCategories() const
258 {
259     return m_categories;
260 }
261 void CalendarEvent::setCategories(const CategoryListPtr &value)
262 {
263     m_categories = value;
264 }
265
266 void CalendarEvent::display() const
267 {
268     LogDebug("m_id " << m_id);
269     LogDebug("m_calendarId " << m_calendarId);
270     LogDebug("m_calendarType " << m_calendarType);
271     LogDebug("m_description " << m_description);
272     LogDebug("m_subject " << m_subject);
273     LogDebug("m_startTime " << m_startTime);
274     LogDebug("m_endTime " << m_endTime);
275     LogDebug("m_location " << m_location);
276     LogDebug("m_recurrence " << m_recurrence);
277     LogDebug("m_status " << m_status);
278     LogDebug("m_isAllDay " << m_isAllDay);
279     LogDebug("m_organizer " << m_organizer);
280     LogDebug("m_lastModifiedDate " << m_lastModifiedDate);
281     LogDebug("m_visibility " << m_visibility);
282     LogDebug("m_availability " << m_availability);
283 }
284
285 bool CalendarEvent::validate() const
286 {
287     if (m_status == INVALID_STATUS) {
288         LogError("Incorrect status value detected");
289         return false;
290     }
291     return true;
292 }
293
294 bool CalendarEvent::getIsAllDay() const
295 {
296     return m_isAllDay;
297 }
298
299 void CalendarEvent::setIsAllDay(bool value)
300 {
301     m_isAllDay = value;
302 }
303
304 std::string CalendarEvent::getOrganizer() const
305 {
306     return m_organizer;
307 }
308
309 void CalendarEvent::setOrganizer(const std::string &value)
310 {
311     m_organizer = value;
312 }
313
314 std::time_t CalendarEvent::getLastModifiedDate() const
315 {
316     return m_lastModifiedDate;
317 }
318
319 void CalendarEvent::setLastModifiedDate(std::time_t value)
320 {
321     m_lastModifiedDate = value;
322 }
323
324 CalendarEvent::EventVisibility CalendarEvent::getVisibility() const
325 {
326     return m_visibility == UNDEFINED_VISIBILITY ? PUBLIC_VISIBILITY : m_visibility;
327 }
328
329 void CalendarEvent::setVisibility(EventVisibility value)
330 {
331     m_visibility = value;
332 }
333
334 CalendarEvent::EventAvailability CalendarEvent::getAvailability() const
335 {
336     return m_availability == UNDEFINED_AVAILABILITY ? FREE_FB : m_availability;
337 }
338
339 void CalendarEvent::setAvailability(EventAvailability value)
340 {
341     m_availability = value;
342 }
343
344 std::string CalendarEvent::getUId() const
345 {
346     return m_uid;
347 }
348
349 void CalendarEvent::setUId(const std::string &value)
350 {
351     m_uid = value;
352 }
353
354 std::time_t CalendarEvent::getRecurrenceId() const
355 {
356     return m_recurrenceId;
357 }
358
359 void CalendarEvent::setRecurrenceId(std::time_t value)
360 {
361     m_recurrenceId = value;
362 }
363
364 EventAttendeeListPtr CalendarEvent::getAttendees() const
365 {
366     return m_attendees;
367 }
368
369 void CalendarEvent::setAttendees(const EventAttendeeListPtr &value)
370 {
371     m_attendees = value;
372 }
373
374 bool CalendarEvent::getIsDetached() const
375 {
376     return m_isDetached;
377 }
378
379 void CalendarEvent::setIsDetached(bool value)
380 {
381     m_isDetached = value;
382 }
383
384 AttributeListPtr CalendarEvent::getAttributesOfInterest() const
385 {
386     return m_attributesOfInterest;
387 }
388
389 void CalendarEvent::setAttributesOfInterest(AttributeListPtr value)
390 {
391     m_attributesOfInterest = value;
392 }
393
394 CalendarItemGeoPtr CalendarEvent::getGeolocation() const
395 {
396     return m_geolocation;
397 }
398
399 void CalendarEvent::setGeolocation(CalendarItemGeoPtr value)
400 {
401     m_geolocation = value;
402 }
403
404 std::string CalendarEvent::getTimeZone() const
405 {
406     return m_timeZone;
407 }
408
409 void CalendarEvent::setTimeZone(std::string value)
410 {
411     m_timeZone = value;
412 }
413
414 CalendarEvent::TaskPriority CalendarEvent::getPriority() const
415 {
416     return m_priority;
417 }
418
419 void CalendarEvent::setPriority(TaskPriority value)
420 {
421     m_priority = value;
422 }
423
424 std::time_t CalendarEvent::getCreatedDate() const
425 {
426     return m_createdDate;
427 }
428
429 void CalendarEvent::setCreatedDate(std::time_t value)
430 {
431     m_createdDate = value;
432 }
433
434 std::time_t CalendarEvent::getCompletedDate() const
435 {
436     return m_completedDate;
437 }
438
439 void CalendarEvent::setCompletedDate(std::time_t value)
440 {
441     m_completedDate = value;
442 }
443
444 int CalendarEvent::getProgress() const
445 {
446     return m_progress;
447 }
448
449 void CalendarEvent::setProgress(int value)
450 {
451     m_progress = value;
452 }
453
454 CalendarEvent::CalendarType CalendarEvent::getCalendarType() const
455 {
456     return m_calendarType;
457 }
458
459 void CalendarEvent::setCalendarType(CalendarType type)
460 {
461     m_calendarType = type;
462 }
463
464 }
465 }
466 }