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_id(UNDEFINED_ITEM_ID),
28 m_parentId(UNDEFINED_PARENT_ID),
29 m_calendarId(UNDEFINED_CALENDAR_ID),
30 m_startTime(UNDEFINED_TIME),
31 m_endTime(UNDEFINED_TIME),
32 m_recurrence(new EventRecurrenceRule()),
33 m_status(UNDEFINED_STATUS),
34 m_alarms(new EventAlarmList()),
35 m_categories(new StringArray()),
37 m_lastModifiedDate(UNDEFINED_TIME),
38 m_visibility(PUBLIC_VISIBILITY),
39 m_availability(BUSY_FB),
41 m_recurrenceId(UNDEFINED_TIME),
42 m_attendees(new EventAttendeeList()),
44 m_attributesOfInterest(new AttributeList()),
45 m_latitude(UNDEFINED_GEO),
46 m_longitude(UNDEFINED_GEO),
47 m_timeZone(DEFAULT_TIMEZONE),
48 m_priority(LOW_PRIORITY),
49 m_createdDate(UNDEFINED_TIME),
50 m_completedDate(UNDEFINED_TIME),
52 m_calendarType(EVENT_TYPE)
56 CalendarEvent::CalendarEvent(const CalendarEvent &original)
58 LogDebug("Copy constructor called.");
60 m_id = original.getId();
61 m_parentId = original.getParentId();
62 m_calendarId = original.getCalendarId();
63 m_description = original.getDescription();
64 m_subject = original.getSubject();
65 m_startTime = original.getStartTime();
66 m_endTime = original.getEndTime();
67 m_location = original.getLocation();
69 EventRecurrenceRulePtr recurrenceRulePtr( new EventRecurrenceRule() );
70 m_recurrence = recurrenceRulePtr;
71 m_recurrence->setFrequency(original.getRecurrenceRule()->getFrequency());
72 m_recurrence->setInterval(original.getRecurrenceRule()->getInterval());
73 m_recurrence->setEndDate(original.getRecurrenceRule()->getEndDate());
74 m_recurrence->setOccurrenceCount(original.getRecurrenceRule()->getOccurrenceCount());
75 m_recurrence->setDaysOfTheMonth(original.getRecurrenceRule()->getDaysOfTheMonth());
76 m_recurrence->setDaysOfTheWeek(original.getRecurrenceRule()->getDaysOfTheWeek());
77 m_recurrence->setDaysOfTheYear(original.getRecurrenceRule()->getDaysOfTheYear());
78 m_recurrence->setWeeksOfTheYear(original.getRecurrenceRule()->getWeeksOfTheYear());
79 m_recurrence->setSetPosition(original.getRecurrenceRule()->getSetPosition());
80 m_recurrence->setExceptions(original.getRecurrenceRule()->getExceptions());
81 m_recurrence->setTimeZone(original.getRecurrenceRule()->getTimeZone());
83 m_status = original.getStatus();
85 LogDebug("Copying alarms...");
86 EventAlarmListPtr alarmsPtr( new EventAlarmList() );
88 for( unsigned int i=0; i<original.getAlarms()->size(); i++) {
89 EventAlarmPtr alarmPtr( new EventAlarm() );
90 alarmPtr->setAbsoluteDate(original.getAlarms()->at(i)->getAbsoluteDate());
91 alarmPtr->setDuration(original.getAlarms()->at(i)->getDuration());
92 alarmPtr->setMethods(original.getAlarms()->at(i)->getMethods());
93 alarmPtr->setTimeZone(original.getAlarms()->at(i)->getTimeZone());
94 alarmPtr->setDescription(original.getAlarms()->at(i)->getDescription());
95 m_alarms->push_back(alarmPtr);
98 StringArrayPtr categoriesPtr( new StringArray() );
99 m_categories = categoriesPtr;
100 *m_categories = *(original.getCategories());
102 m_isAllDay = original.getIsAllDay();
103 m_organizer = original.getOrganizer();
104 m_lastModifiedDate = original.getLastModifiedDate();
105 m_visibility = original.getVisibility();
106 m_availability = original.getAvailability();
107 m_uid = original.getUId();
108 m_recurrenceId = original.getRecurrenceId();
110 LogDebug("Copying attendees...");
111 EventAttendeeListPtr attendeesPtr( new EventAttendeeList() );
112 m_attendees = attendeesPtr;
113 for( unsigned int i=0; i<original.getAttendees()->size(); i++) {
114 EventAttendeePtr attendeePtr( new EventAttendee() );
115 attendeePtr->setName(original.getAttendees()->at(i)->getName());
116 attendeePtr->setURI(original.getAttendees()->at(i)->getURI());
117 attendeePtr->setRole(original.getAttendees()->at(i)->getRole());
118 attendeePtr->setStatus(original.getAttendees()->at(i)->getStatus());
119 attendeePtr->setRSVP(original.getAttendees()->at(i)->getRSVP());
120 attendeePtr->setType(original.getAttendees()->at(i)->getType());
121 attendeePtr->setGroup(original.getAttendees()->at(i)->getGroup());
122 attendeePtr->setDelegatorURI(original.getAttendees()->at(i)->getDelegatorURI());
123 attendeePtr->setDelegateURI(original.getAttendees()->at(i)->getDelegateURI());
124 attendeePtr->setAddressBookId(original.getAttendees()->at(i)->getAddressBookId());
125 attendeePtr->setContactId(original.getAttendees()->at(i)->getContactId());
126 m_attendees->push_back(attendeePtr);
129 m_isDetached = original.getIsDetached();
131 AttributeListPtr attributesPtr( new AttributeList() );
132 m_attributesOfInterest = attributesPtr;
133 *m_attributesOfInterest = *(original.getAttributesOfInterest());
135 m_latitude = original.getLatitude();
136 m_longitude = original.getLongitude();
138 m_timeZone = original.getTimeZone();
139 m_priority = original.getPriority();
140 m_createdDate = original.getCreatedDate();
141 m_completedDate = original.getCompletedDate();
142 m_progress = original.getProgress();
143 m_calendarType = original.getCalendarType();
145 LogDebug("Copying done.");
148 CalendarEvent::~CalendarEvent()
152 int CalendarEvent::getId() const
157 void CalendarEvent::setId(int value)
162 std::stringstream ss;
165 LogDebug("m_id: "<<m_id<<", m_uid: "<<m_uid);
168 void CalendarEvent::resetId()
170 m_id = UNDEFINED_ITEM_ID;
174 bool CalendarEvent::getIdIsSet() const
176 return !(m_id==UNDEFINED_ITEM_ID);
179 int CalendarEvent::getParentId() const
184 void CalendarEvent::setParentId(int value)
189 int CalendarEvent::getCalendarId() const
194 void CalendarEvent::setCalendarId(int value)
196 m_calendarId = value;
199 std::string CalendarEvent::getDescription() const
201 return m_description;
204 void CalendarEvent::setDescription(const std::string &value)
206 m_description = value;
209 std::string CalendarEvent::getSubject() const
214 void CalendarEvent::setSubject(const std::string &value)
219 long long int CalendarEvent::getStartTime() const
224 void CalendarEvent::setStartTime(long long int value)
229 long long int CalendarEvent::getEndTime() const
234 void CalendarEvent::setEndTime(long long int value)
239 std::string CalendarEvent::getLocation() const
244 void CalendarEvent::setLocation(const std::string &value)
249 EventRecurrenceRulePtr CalendarEvent::getRecurrenceRule() const
254 void CalendarEvent::setRecurrenceRule(EventRecurrenceRulePtr value)
256 m_recurrence = value;
259 CalendarEvent::EventStatus CalendarEvent::getStatus() const
261 return m_status == UNDEFINED_STATUS ? TENTATIVE_STATUS : m_status;
264 void CalendarEvent::setStatus(EventStatus value)
269 EventAlarmListPtr CalendarEvent::getAlarms() const
273 void CalendarEvent::setAlarms(const EventAlarmListPtr value)
278 StringArrayPtr CalendarEvent::getCategories() const
282 void CalendarEvent::setCategories(const StringArrayPtr value)
284 m_categories = value;
287 void CalendarEvent::display() const
289 LogDebug("m_id " << m_id);
290 LogDebug("m_parentId " << m_parentId);
291 LogDebug("m_calendarId " << m_calendarId);
292 LogDebug("m_calendarType " << m_calendarType);
293 LogDebug("m_description " << m_description);
294 LogDebug("m_subject " << m_subject);
296 LogDebug("m_startTime " << m_startTime);
298 LogDebug("m_endTime " << m_endTime);
299 LogDebug("m_location " << m_location);
300 LogDebug("m_recurrence " << m_recurrence);
301 LogDebug("m_status " << m_status);
302 LogDebug("m_isAllDay " << m_isAllDay);
303 LogDebug("m_organizer " << m_organizer);
304 LogDebug("m_lastModifiedDate " << m_lastModifiedDate);
305 LogDebug("m_visibility " << m_visibility);
306 LogDebug("m_availability " << m_availability);
308 if(m_recurrence->getFrequency()!=EventRecurrenceRule::NO_RECURRENCE) {
309 LogDebug("recurrence frequency " << m_recurrence->getFrequency());
310 LogDebug("recurrence interval " << m_recurrence->getInterval());
311 LogDebug("recurrence recurrenceCount " << m_recurrence->getOccurrenceCount());
312 LogDebug("recurrence endDate " << m_recurrence->getEndDate());
316 bool CalendarEvent::validate() const
318 LogInfo("Nothing to validate.");
322 bool CalendarEvent::getIsAllDay() const
327 void CalendarEvent::setIsAllDay(bool value)
332 std::string CalendarEvent::getOrganizer() const
337 void CalendarEvent::setOrganizer(const std::string &value)
342 long long int CalendarEvent::getLastModifiedDate() const
344 return m_lastModifiedDate;
347 void CalendarEvent::setLastModifiedDate(long long int value)
349 m_lastModifiedDate = value;
352 CalendarEvent::EventVisibility CalendarEvent::getVisibility() const
354 return m_visibility == UNDEFINED_VISIBILITY ? PUBLIC_VISIBILITY : m_visibility;
357 void CalendarEvent::setVisibility(EventVisibility value)
359 m_visibility = value;
362 CalendarEvent::EventAvailability CalendarEvent::getAvailability() const
364 return m_availability == UNDEFINED_AVAILABILITY ? FREE_FB : m_availability;
367 void CalendarEvent::setAvailability(EventAvailability value)
369 m_availability = value;
372 std::string CalendarEvent::getUId() const
377 void CalendarEvent::setUId(const std::string &value)
382 long long int CalendarEvent::getRecurrenceId() const
384 return m_recurrenceId;
387 void CalendarEvent::setRecurrenceId(long long int value)
389 m_recurrenceId = value;
392 EventAttendeeListPtr CalendarEvent::getAttendees() const
397 void CalendarEvent::setAttendees(const EventAttendeeListPtr value)
402 bool CalendarEvent::getIsDetached() const
407 void CalendarEvent::setIsDetached(bool value)
409 m_isDetached = value;
412 AttributeListPtr CalendarEvent::getAttributesOfInterest() const
414 return m_attributesOfInterest;
417 void CalendarEvent::setAttributesOfInterest(AttributeListPtr value)
419 m_attributesOfInterest = value;
422 double CalendarEvent::getLatitude() const
427 void CalendarEvent::setLatitude(double value)
432 double CalendarEvent::getLongitude() const
437 void CalendarEvent::setLongitude(double value)
442 std::string CalendarEvent::getTimeZone() const
447 void CalendarEvent::setTimeZone(std::string value)
452 CalendarEvent::TaskPriority CalendarEvent::getPriority() const
457 void CalendarEvent::setPriority(TaskPriority value)
462 long long int CalendarEvent::getCreatedDate() const
464 return m_createdDate;
467 void CalendarEvent::setCreatedDate(long long int value)
469 m_createdDate = value;
472 long long int CalendarEvent::getCompletedDate() const
474 return m_completedDate;
477 void CalendarEvent::setCompletedDate(long long int value)
479 m_completedDate = value;
482 int CalendarEvent::getProgress() const
487 void CalendarEvent::setProgress(int value)
492 CalendarEvent::CalendarType CalendarEvent::getCalendarType() const
494 return m_calendarType;
497 void CalendarEvent::setCalendarType(CalendarType type)
499 m_calendarType = type;