2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include <dpl/log/log.h>
19 #include <Commons/Exception.h>
20 #include "CalendarEvent.h"
26 CalendarEvent::CalendarEvent() :
27 m_calendarId(UNDEFINED_CALENDAR_ID),
28 m_recurrence(new EventRecurrenceRule()),
29 m_status(UNDEFINED_STATUS),
30 m_categories(new CategoryList()),
33 m_attendees(new EventAttendeeList()),
35 m_attributesOfInterest(new AttributeList()),
36 m_geolocation(new CalendarItemGeo()),
37 m_calendarType(EVENT_TYPE)
41 CalendarEvent::CalendarEvent(const CalendarEvent &original)
43 LogDebug("Copy constructor called.");
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();
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());
67 m_status = original.getStatus();
68 m_alarmsTick = original.getAlarmsTick();
69 m_alarmsType = original.getAlarmsType();
70 m_alarmsDescription = original.getAlarmsDescription();
72 CategoryListPtr categoriesPtr( new CategoryList() );
73 m_categories = categoriesPtr;
74 *m_categories = *(original.getCategories());
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();
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);
102 m_isDetached = original.getIsDetached();
104 AttributeListPtr attributesPtr( new AttributeList() );
105 m_attributesOfInterest = attributesPtr;
106 *m_attributesOfInterest = *(original.getAttributesOfInterest());
108 CalendarItemGeoPtr geoPtr( new CalendarItemGeo() );
109 m_geolocation = geoPtr;
110 m_geolocation->setLatitude(original.getGeolocation()->getLatitude());
111 m_geolocation->setLongitude(original.getGeolocation()->getLongitude());
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();
120 LogDebug("Copying done.");
123 CalendarEvent::~CalendarEvent()
127 bool CalendarEvent::getIdIsSet() const
129 return !m_id.IsNull();
132 int CalendarEvent::getCalendarId() const
137 void CalendarEvent::setCalendarId(int value)
139 m_calendarId = value;
142 int CalendarEvent::getId() const
147 void CalendarEvent::setId(int value)
152 void CalendarEvent::resetId()
154 m_id = DPL::Optional<int>();
157 std::string CalendarEvent::getDescription() const
159 return m_description;
162 void CalendarEvent::setDescription(const std::string &value)
164 m_description = value;
167 std::string CalendarEvent::getSubject() const
172 void CalendarEvent::setSubject(const std::string &value)
177 std::time_t CalendarEvent::getStartTime() const
182 void CalendarEvent::setStartTime(std::time_t value)
187 std::time_t CalendarEvent::getEndTime() const
192 void CalendarEvent::setEndTime(std::time_t value)
197 std::string CalendarEvent::getLocation() const
202 void CalendarEvent::setLocation(const std::string &value)
207 EventRecurrenceRulePtr CalendarEvent::getRecurrenceRule() const
212 void CalendarEvent::setRecurrenceRule(EventRecurrenceRulePtr value)
214 m_recurrence = value;
217 CalendarEvent::EventStatus CalendarEvent::getStatus() const
219 return m_status == UNDEFINED_STATUS ? TENTATIVE_STATUS : m_status;
222 void CalendarEvent::setStatus(EventStatus value)
227 std::vector<long> CalendarEvent::getAlarmsTick() const
232 void CalendarEvent::setAlarmsTick(std::vector<long> &value)
234 m_alarmsTick = value;
237 std::vector<CalendarEvent::EventAlarmType> CalendarEvent::getAlarmsType() const
242 void CalendarEvent::setAlarmsType(std::vector<EventAlarmType> &value)
244 m_alarmsType = value;
247 std::vector<std::string> CalendarEvent::getAlarmsDescription() const
249 return m_alarmsDescription;
252 void CalendarEvent::setAlarmsDescription(std::vector<std::string> &value)
254 m_alarmsDescription = value;
257 CategoryListPtr CalendarEvent::getCategories() const
261 void CalendarEvent::setCategories(const CategoryListPtr &value)
263 m_categories = value;
266 void CalendarEvent::display() const
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);
285 bool CalendarEvent::validate() const
287 if (m_status == INVALID_STATUS) {
288 LogError("Incorrect status value detected");
294 bool CalendarEvent::getIsAllDay() const
299 void CalendarEvent::setIsAllDay(bool value)
304 std::string CalendarEvent::getOrganizer() const
309 void CalendarEvent::setOrganizer(const std::string &value)
314 std::time_t CalendarEvent::getLastModifiedDate() const
316 return m_lastModifiedDate;
319 void CalendarEvent::setLastModifiedDate(std::time_t value)
321 m_lastModifiedDate = value;
324 CalendarEvent::EventVisibility CalendarEvent::getVisibility() const
326 return m_visibility == UNDEFINED_VISIBILITY ? PUBLIC_VISIBILITY : m_visibility;
329 void CalendarEvent::setVisibility(EventVisibility value)
331 m_visibility = value;
334 CalendarEvent::EventAvailability CalendarEvent::getAvailability() const
336 return m_availability == UNDEFINED_AVAILABILITY ? FREE_FB : m_availability;
339 void CalendarEvent::setAvailability(EventAvailability value)
341 m_availability = value;
344 std::string CalendarEvent::getUId() const
349 void CalendarEvent::setUId(const std::string &value)
354 std::time_t CalendarEvent::getRecurrenceId() const
356 return m_recurrenceId;
359 void CalendarEvent::setRecurrenceId(std::time_t value)
361 m_recurrenceId = value;
364 EventAttendeeListPtr CalendarEvent::getAttendees() const
369 void CalendarEvent::setAttendees(const EventAttendeeListPtr &value)
374 bool CalendarEvent::getIsDetached() const
379 void CalendarEvent::setIsDetached(bool value)
381 m_isDetached = value;
384 AttributeListPtr CalendarEvent::getAttributesOfInterest() const
386 return m_attributesOfInterest;
389 void CalendarEvent::setAttributesOfInterest(AttributeListPtr value)
391 m_attributesOfInterest = value;
394 CalendarItemGeoPtr CalendarEvent::getGeolocation() const
396 return m_geolocation;
399 void CalendarEvent::setGeolocation(CalendarItemGeoPtr value)
401 m_geolocation = value;
404 std::string CalendarEvent::getTimeZone() const
409 void CalendarEvent::setTimeZone(std::string value)
414 CalendarEvent::TaskPriority CalendarEvent::getPriority() const
419 void CalendarEvent::setPriority(TaskPriority value)
424 std::time_t CalendarEvent::getCreatedDate() const
426 return m_createdDate;
429 void CalendarEvent::setCreatedDate(std::time_t value)
431 m_createdDate = value;
434 std::time_t CalendarEvent::getCompletedDate() const
436 return m_completedDate;
439 void CalendarEvent::setCompletedDate(std::time_t value)
441 m_completedDate = value;
444 int CalendarEvent::getProgress() const
449 void CalendarEvent::setProgress(int value)
454 CalendarEvent::CalendarType CalendarEvent::getCalendarType() const
456 return m_calendarType;
459 void CalendarEvent::setCalendarType(CalendarType type)
461 m_calendarType = type;