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.
22 #include <dpl/log/log.h>
23 #include <Commons/Exception.h>
24 #include "EventWrapper.h"
27 using namespace TizenApis::Api::Calendar;
28 using namespace WrtDeviceApis::Commons;
31 const char WEEKDAYS[] = "0111110";
32 const int NEW_EVENT_ID = -1;
39 EventWrapper::EventWrapper(CalendarEvent::CalendarType type) :
40 m_platformEvent(NULL),
41 m_abstractEvent(NULL),
45 m_abstractEvent = CalendarEventPtr(new CalendarEvent());
46 if (!m_abstractEvent) {
47 ThrowMsg(UnknownException, "abstract object is not created");
51 EventWrapper::EventWrapper(const CalendarEventPtr &event, CalendarEvent::CalendarType type) :
52 m_platformEvent(NULL),
53 m_abstractEvent(event),
59 EventWrapper::EventWrapper(cal_struct *event, CalendarEvent::CalendarType type) :
60 m_platformEvent(event),
61 m_abstractEvent(NULL),
65 m_abstractEvent = CalendarEventPtr(new CalendarEvent());
66 if (!m_abstractEvent) {
67 ThrowMsg(UnknownException, "abstract object is not created");
71 EventWrapper::~EventWrapper()
77 int EventWrapper::getIdFromPlatformEvent() const
80 if (m_platformEvent == NULL) {
81 ThrowMsg(NullPointerException, "m_platformEvent is not set");
84 return calendar_svc_struct_get_int(m_platformEvent, CAL_VALUE_INT_INDEX);
87 void EventWrapper::setCalendarId(const std::string &value)
89 LogInfo("calendar id "<<value);
91 std::istringstream stream(m_calendarId);
94 if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent,
95 CAL_VALUE_INT_CALENDAR_ID,
98 ThrowMsg(PlatformException, "Can't set calendar id.");
102 void EventWrapper::setCalendarAccountId(const int value)
104 LogInfo("account id "<<value);
105 m_calendarAccountId = value;
106 if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent,
107 CAL_VALUE_INT_ACCOUNT_ID,
108 m_calendarAccountId))
110 ThrowMsg(PlatformException, "Can't set calendar account id.");
114 void EventWrapper::saveEvent()
117 if (m_platformEvent == NULL) {
118 ThrowMsg(NullPointerException, "m_platformEvent is not set");
121 int eventId = getIdFromPlatformEvent();
122 LogDebug("Before saving/update eventId: " << eventId);
124 //displayPlatformEvent();
126 //insert new record or update existing one
128 int returnValue = calendar_svc_insert(m_platformEvent);
129 if (CAL_SUCCESS > returnValue) {
130 LogError("Can't insert new event, error code: " << returnValue);
131 ThrowMsg(PlatformException, "Can't insert new event.");
133 m_abstractEvent->setId(returnValue);
134 LogInfo("New calendar item inserted with id "<<returnValue);
136 int errorCode = calendar_svc_update(m_platformEvent);
137 if (CAL_SUCCESS != errorCode) {
138 ThrowMsg(PlatformException, "Can't update new event with error code: "<<errorCode);
140 LogDebug("Calendar event updated");
144 void EventWrapper::loadEvent(int id)
146 LogDebug("Item id to load: " << id);
149 const char *dataType;
150 if(getType() == CalendarEvent::TASK_TYPE) {
151 dataType = CAL_STRUCT_TODO;
153 dataType = CAL_STRUCT_SCHEDULE;
156 int errorCode = calendar_svc_get(dataType, id, NULL, &m_platformEvent);
157 if (CAL_SUCCESS!=errorCode) {
158 if (m_platformEvent) {
159 calendar_svc_struct_free(&m_platformEvent);
161 ThrowMsg(NotFoundException, "Can't get item with id = " << id << ", error code: " <<errorCode);
164 int isDeleted = calendar_svc_struct_get_int(m_platformEvent, CAL_VALUE_INT_IS_DELETED);
166 if (m_platformEvent) {
167 calendar_svc_struct_free(&m_platformEvent);
169 ThrowMsg(NotFoundException, "Item already deleted.");
172 convertPlatformEventToAbstractEvent();
173 m_abstractEvent->setCalendarType(m_calendarType);
174 //displayAbstractEvent();
177 void EventWrapper::deleteEvent()
179 if (m_platformEvent == NULL) {
180 ThrowMsg(NullPointerException, "Platform event is null.");
183 // If the recurrenceId is set, delete the instance of recurring event only.
184 int itemId = getIdFromPlatformEvent();
185 long long int recurrenceId = m_abstractEvent->getRecurrenceId();
186 LogDebug("itemId to delete: " << itemId << ", recurrenceId: " << recurrenceId << ", type: " << getType());
188 cal_struct *item = NULL;
189 const char *dataType;
190 if(getType() == CalendarEvent::TASK_TYPE) {
191 dataType = CAL_STRUCT_TODO;
193 dataType = CAL_STRUCT_SCHEDULE;
196 int error = calendar_svc_get(dataType, itemId, NULL, &item);
197 if (CAL_SUCCESS != error) {
199 calendar_svc_struct_free(&item);
201 ThrowMsg(NotFoundException, "Can't get calendar item. Error code: "<<error);
204 int isDeleted = calendar_svc_struct_get_int(item, CAL_VALUE_INT_IS_DELETED);
207 calendar_svc_struct_free(&item);
209 ThrowMsg(NotFoundException, "Item already deleted.");
213 calendar_svc_struct_free(&item);
216 if ( 0>=recurrenceId ||
217 !(EventRecurrenceRule::DAILY_RECURRENCE <= m_abstractEvent->getRecurrenceRule()->getFrequency()
218 && m_abstractEvent->getRecurrenceRule()->getFrequency() <= EventRecurrenceRule::YEARLY_RECURRENCE)) {
219 // Remove the parent and child instances by the given uid.
220 int parentId = itemId;
222 // First, the parent event.
223 error = calendar_svc_delete(dataType, parentId);
224 if (CAL_SUCCESS != error) {
225 if(CAL_ERR_NO_DATA==error) {
226 ThrowMsg(NotFoundException, "Item not found.");
228 ThrowMsg(PlatformException, "Can't delete calendar item. Error code " << error);
231 m_abstractEvent->resetId();
232 setIdToPlatformEvent();
234 if(CalendarEvent::EVENT_TYPE==getType()) {
235 LogDebug("The event parent item is deleted.");
237 // Next, all the detached instances.
238 cal_iter *iter = NULL;
239 cal_struct *platformEvent = NULL;
240 if(CAL_SUCCESS != calendar_svc_find_event_list(m_calendarAccountId, CAL_VALUE_INT_ORIGINAL_EVENT_ID, (void*) parentId, &iter)) {
241 LogInfo("Founding detached instances failed.");
244 while (CAL_SUCCESS == calendar_svc_iter_next(iter)) {
245 LogInfo("Deleting a detached instance...");
246 platformEvent = NULL;
247 if (CAL_SUCCESS != calendar_svc_iter_get_info(iter, &platformEvent)) {
249 calendar_svc_iter_remove(&iter);
251 ThrowMsg(PlatformException, "Can't get event info.");
254 int detachedEventId = calendar_svc_struct_get_int(platformEvent, CAL_VALUE_INT_INDEX);
255 LogDebug("detachedEventId "<<detachedEventId);
256 error = calendar_svc_delete(dataType, detachedEventId);
257 if (CAL_SUCCESS != error) {
259 calendar_svc_iter_remove(&iter);
262 if(CAL_ERR_NO_DATA==error) {
263 ThrowMsg(NotFoundException, "Item not found.");
265 ThrowMsg(PlatformException, "Can't delete calendar event. Error code " << error);
268 LogDebug("Deleted a detached event by id: "<<detachedEventId);
273 calendar_svc_iter_remove(&iter);
276 LogInfo("Deleting a task finished.");
279 error = calendar_svc_event_delete_normal_instance(itemId, recurrenceId);
280 if(error!=CAL_SUCCESS) {
281 ThrowMsg(PlatformException, "Can't delete the instance. Error code " << error);
284 (*m_abstractEvent->getRecurrenceRule()->getExceptions()).push_back(recurrenceId);
285 LogDebug("The recurring event is updated.");
289 void EventWrapper::createEventFromString(std::string value)
292 ThrowMsg(NullPointerException, "Failed to create an item from string.");
294 LogInfo("string to convert: "<<value);
300 returnValue = calendar_svc_read_schedules(value.c_str(), &items);
301 if (CAL_SUCCESS != returnValue) {
302 ThrowMsg(PlatformException, "Can't convert string. Error code: "<<returnValue);
305 ThrowMsg(PlatformException, "No items converted.");
309 m_platformEvent = (cal_struct*)items->data;
310 if (NULL==m_platformEvent) {
311 items = g_list_next(items);
314 // We only cover one event per string.
318 items = g_list_next(items);
321 //displayPlatformEvent();
324 std::string EventWrapper::exportEventToString()
326 char *vStrings = NULL;
329 std::string returnString;
331 items = g_list_append(items, m_platformEvent);
333 returnValue = calendar_svc_write_schedules(items, &vStrings);
334 if (CAL_SUCCESS != returnValue) {
335 ThrowMsg(PlatformException, "Can't convert item to string. Error code: "<<returnValue);
337 if (NULL==vStrings) {
338 ThrowMsg(PlatformException, "No items converted.");
341 returnString = std::string(vStrings);
346 cal_struct* EventWrapper::getPlatformEvent() const
348 return m_platformEvent;
351 CalendarEventPtr EventWrapper::getAbstractEvent() const
353 return m_abstractEvent;
356 void EventWrapper::freePlatformEvent()
359 if (m_platformEvent != NULL) {
360 if (CAL_SUCCESS != calendar_svc_struct_free(&m_platformEvent)) {
361 LogError("Can't free calendar event struct.");
363 m_platformEvent = NULL;
367 cal_struct* EventWrapper::convertAbstractEventToPlatformEvent()
371 const char *dataType;
373 if(getType() == CalendarEvent::TASK_TYPE) {
374 dataType = CAL_STRUCT_TODO;
376 dataType = CAL_STRUCT_SCHEDULE;
378 m_platformEvent = calendar_svc_struct_new(dataType);
379 if (!m_platformEvent) {
380 ThrowMsg(UnknownException, "cannot create platform event");
383 setDescriptionToPlatformEvent();
384 setSummaryToPlatformEvent();
385 setStartTimeToPlatformEvent();
386 setEndTimeToPlatformEvent(); // replacement for duration
387 setLocationToPlatformEvent();
388 setCategoriesToPlatformEvent();
389 setStatusToPlatformEvent();
390 setAlarmsToPlatformEvent();
391 setIsAllDayToPlatformEvent();
392 setOrganizerToPlatformEvent();
393 setAttendeesToPlatformEvent();
394 setPositionToPlatformEvent();
395 setVisibilityToPlatformEvent();
396 //setLastModifiedDateToPlatformEvent(); // read-only in platform.
397 setAvailabilityToPlatformEvent();
398 setRecurrenceRuleToPlatformEvent();
399 setIdToPlatformEvent();
400 //setUIdToPlatformEvent(); // We don't set uid but use id field instead.
401 setParentIdToPlatformEvent();
402 setPriorityToPlatformEvent();
403 setCreatedDateToPlatformEvent();
404 setCompletedDateToPlatformEvent();
405 setProgressToPlatformEvent();
407 return getPlatformEvent();
410 void EventWrapper::setDescriptionToPlatformEvent()
412 if (!m_platformEvent) {
413 ThrowMsg(UnknownException, "Null platform pointer.");
415 if (CAL_SUCCESS != calendar_svc_struct_set_str(m_platformEvent,
416 CAL_VALUE_TXT_DESCRIPTION,
418 getDescription().c_str()))
420 ThrowMsg(PlatformException, "Can't set event description.");
424 void EventWrapper::setSummaryToPlatformEvent()
426 if (!m_platformEvent) {
427 ThrowMsg(UnknownException, "Null platform pointer.");
429 if (CAL_SUCCESS != calendar_svc_struct_set_str(m_platformEvent,
430 CAL_VALUE_TXT_SUMMARY,
431 m_abstractEvent->getSubject()
433 ThrowMsg(PlatformException, "Can't set event subject.");
437 void EventWrapper::setStartTimeToPlatformEvent()
439 if (!m_platformEvent) {
440 ThrowMsg(UnknownException, "Null platform pointer.");
443 long long int time = m_abstractEvent->getStartTime();
445 time = m_abstractEvent->getEndTime();
448 if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent,
449 CALS_VALUE_INT_DTSTART_TYPE,
451 ThrowMsg(PlatformException, "Can't set start time type.");
454 if (CAL_SUCCESS != calendar_svc_struct_set_lli(m_platformEvent,
455 CALS_VALUE_LLI_DTSTART_UTIME,
457 ThrowMsg(PlatformException, "Can't set event start time.");
460 const char* timeZone = m_abstractEvent->getTimeZone().c_str();
461 if (CAL_SUCCESS != calendar_svc_struct_set_str(m_platformEvent,
462 CALS_VALUE_TXT_DTSTART_TZID,
464 ThrowMsg(PlatformException, "Can't set event time zone.");
468 void EventWrapper::setEndTimeToPlatformEvent()
470 if (!m_platformEvent) {
471 ThrowMsg(UnknownException, "Null platform pointer.");
474 long long int time = m_abstractEvent->getEndTime();
476 time = m_abstractEvent->getStartTime();
479 if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent,
480 CALS_VALUE_INT_DTEND_TYPE,
482 ThrowMsg(PlatformException, "Can't set end time type.");
485 if (CAL_SUCCESS != calendar_svc_struct_set_lli(m_platformEvent,
486 CALS_VALUE_LLI_DTEND_UTIME,
488 ThrowMsg(PlatformException, "Can't set event end time.");
492 void EventWrapper::setLocationToPlatformEvent()
494 if (!m_platformEvent) {
495 ThrowMsg(UnknownException, "Null platform pointer.");
497 if (CAL_SUCCESS != calendar_svc_struct_set_str(m_platformEvent,
498 CAL_VALUE_TXT_LOCATION,
499 m_abstractEvent->getLocation()
501 ThrowMsg(PlatformException, "Can't set event location.");
505 void EventWrapper::setRecurrenceRuleToPlatformEvent()
508 if (!m_platformEvent) {
509 ThrowMsg(UnknownException, "Null platform pointer.");
512 EventRecurrenceRulePtr rrule = m_abstractEvent->getRecurrenceRule();
514 LogInfo("rrule is not set.");
519 LogInfo("frequency "<<rrule->getFrequency());
520 switch (rrule->getFrequency()) {
521 case EventRecurrenceRule::NO_RECURRENCE:
522 if(CAL_SUCCESS!=calendar_svc_struct_set_int(m_platformEvent, CALS_VALUE_INT_RRULE_FREQ, CALS_FREQ_ONCE)) {
523 ThrowMsg(PlatformException, "Failed setting frequency.");
526 case EventRecurrenceRule::DAILY_RECURRENCE:
527 if(CAL_SUCCESS!=calendar_svc_struct_set_int(m_platformEvent, CALS_VALUE_INT_RRULE_FREQ, CALS_FREQ_DAILY)) {
528 ThrowMsg(PlatformException, "Failed setting frequency.");
531 case EventRecurrenceRule::WEEKLY_RECURRENCE:
533 if(CAL_SUCCESS!=calendar_svc_struct_set_int(m_platformEvent, CALS_VALUE_INT_RRULE_FREQ, CALS_FREQ_WEEKLY)) {
534 ThrowMsg(PlatformException, "Failed setting frequency.");
538 case EventRecurrenceRule::MONTHLY_RECURRENCE:
540 if(CAL_SUCCESS!=calendar_svc_struct_set_int(m_platformEvent, CALS_VALUE_INT_RRULE_FREQ, CALS_FREQ_MONTHLY)) {
541 ThrowMsg(PlatformException, "Failed setting frequency.");
545 case EventRecurrenceRule::YEARLY_RECURRENCE:
547 if(CAL_SUCCESS!=calendar_svc_struct_set_int(m_platformEvent, CALS_VALUE_INT_RRULE_FREQ, CALS_FREQ_YEARLY)) {
548 ThrowMsg(PlatformException, "Failed setting frequency.");
552 case EventRecurrenceRule::UNDEFINED_RECURRENCE:
554 ThrowMsg(UnknownException, "Invalid reccurence rule frequency "<<rrule->getFrequency());
559 StringArrayPtr daysOfTheWeek = rrule->getDaysOfTheWeek();
560 if( 0 != daysOfTheWeek->size() ) {
561 std::string byday = "";
562 for(unsigned int i=0; i<daysOfTheWeek->size(); i++) {
563 byday.append(daysOfTheWeek->at(i));
564 if(i!=daysOfTheWeek->size()-1) {
569 LogInfo("byday: "<<byday);
570 if (CAL_SUCCESS!=calendar_svc_struct_set_str(m_platformEvent, CALS_VALUE_TXT_RRULE_BYDAY, byday.c_str())) {
571 ThrowMsg(PlatformException, "Can't set byday.");
575 // set the ocurrence count
576 if (-1 != rrule->getOccurrenceCount()) {
577 LogInfo("Set the occurrence count: "<<rrule->getOccurrenceCount());
579 if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent, CALS_VALUE_INT_RRULE_RANGE_TYPE, CALS_RANGE_COUNT)) {
580 ThrowMsg(PlatformException, "Can't set rrule range type.");
583 if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent, CALS_VALUE_INT_RRULE_COUNT, rrule->getOccurrenceCount())) {
584 ThrowMsg(PlatformException, "Can't set occurrence count.");
588 // set the exceptions
589 if ( !rrule->getExceptions()->empty() )
591 LogInfo("Set the exceptions of length: "<<rrule->getExceptions()->size());
593 std::string exdate = "";
594 for( unsigned int i=0; i<rrule->getExceptions()->size(); i++ )
596 std::stringstream ss;
597 ss<<rrule->getExceptions()->at(i);
598 exdate.append(ss.str());
599 if(i!=rrule->getExceptions()->size()-1) {
603 if (CAL_SUCCESS!=calendar_svc_struct_set_str(m_platformEvent, CAL_VALUE_TXT_EXDATE, exdate.c_str())) {
604 ThrowMsg(PlatformException, "Can't save exceptions.");
608 // set the recurrence interval
609 if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent,
610 CALS_VALUE_INT_RRULE_INTERVAL,
611 rrule->getInterval()))
613 ThrowMsg(PlatformException, "Can't set interval.");
616 // set the recurrence end date. This is automatically calculated by platform if empty.
617 if (UNDEFINED_TIME!=rrule->getEndDate()) {
618 LogInfo("Setting the end date: "<<rrule->getEndDate());
620 if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent, CALS_VALUE_INT_RRULE_RANGE_TYPE, CALS_RANGE_UNTIL)) {
621 ThrowMsg(PlatformException, "Can't set rrule range type.");
624 if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent, CALS_VALUE_INT_RRULE_UNTIL_TYPE, CALS_TIME_UTIME)) {
625 ThrowMsg(PlatformException, "Can't set rrule until type.");
628 if (CAL_SUCCESS != calendar_svc_struct_set_lli(m_platformEvent, CALS_VALUE_LLI_RRULE_UNTIL_UTIME, m_abstractEvent->getRecurrenceRule()->getEndDate())) {
629 ThrowMsg(PlatformException, "Can't set recurrence end date.");
634 void EventWrapper::setAlarmsToPlatformEvent()
636 if (!m_platformEvent) {
637 ThrowMsg(UnknownException, "Null platform pointer.");
640 if( 0 != m_abstractEvent->getAlarms()->size() ) {
643 calendar_svc_struct_get_list(m_platformEvent, CAL_VALUE_LST_ALARM, &list);
645 for( unsigned int i=0; i<m_abstractEvent->getAlarms()->size(); i++ )
647 LogInfo("Set the alarms #"<<i);
648 EventAlarmPtr theAlarm = m_abstractEvent->getAlarms()->at(i);
650 cal_value *value = calendar_svc_value_new(CAL_VALUE_LST_ALARM);
652 cal_sch_remind_tick_unit_t tickUnit = CAL_SCH_TIME_UNIT_OFF;
654 if( UNDEFINED_TIME!=theAlarm->getAbsoluteDate() ) {
655 tickUnit = CAL_SCH_TIME_UNIT_SPECIFIC;
657 if( TizenApis::Api::TimeUtil::MSECS_UNIT==theAlarm->getDuration().unit ) {
658 tickUnit = CAL_SCH_TIME_UNIT_MIN; // minimum calendar time unit.
659 tick = theAlarm->getDuration().length / 60000;
660 } else if( TizenApis::Api::TimeUtil::SECONDS_UNIT==theAlarm->getDuration().unit ) {
661 tickUnit = CAL_SCH_TIME_UNIT_MIN;
662 tick = theAlarm->getDuration().length / 1000;
663 } else if( TizenApis::Api::TimeUtil::MINUTES_UNIT==theAlarm->getDuration().unit ) {
664 tickUnit = CAL_SCH_TIME_UNIT_MIN;
665 tick = theAlarm->getDuration().length;
666 } else if( TizenApis::Api::TimeUtil::HOURS_UNIT==theAlarm->getDuration().unit ) {
667 tickUnit = CAL_SCH_TIME_UNIT_HOUR;
668 tick = theAlarm->getDuration().length;
669 } else if( TizenApis::Api::TimeUtil::DAYS_UNIT==theAlarm->getDuration().unit ) {
670 tickUnit = CAL_SCH_TIME_UNIT_DAY;
671 tick = theAlarm->getDuration().length;
673 LogError("Wrong alarm time unit: "<<theAlarm->getDuration().unit);
677 if( CAL_SCH_TIME_UNIT_SPECIFIC==tickUnit ) {
678 long long int time = theAlarm->getAbsoluteDate();
679 LogInfo("Save absolute date: "<<time);
680 errorCode = calendar_svc_value_set_lli(value,
681 CAL_VALUE_LLI_ALARMS_TIME,
683 if (CAL_SUCCESS != errorCode) {
685 calendar_svc_value_free(&value);
687 ThrowMsg(PlatformException, "Can't set alarm time: "<<errorCode);
690 errorCode = calendar_svc_value_set_int(
692 CAL_VALUE_INT_ALARMS_TICK,
694 if (CAL_SUCCESS != errorCode) {
696 calendar_svc_value_free(&value);
698 ThrowMsg(PlatformException, "Can't set alarm tick: "<<errorCode);
702 errorCode = calendar_svc_value_set_int(
704 CAL_VALUE_INT_ALARMS_TICK_UNIT,
706 if (CAL_SUCCESS != errorCode) {
708 calendar_svc_value_free(&value);
710 ThrowMsg(PlatformException, "Can't set alarm tick unit: "<<errorCode);
713 // Set the alarm type.
714 cal_alert_type_t alarmType = CAL_ALERT_MELODY;
715 switch (theAlarm->getMethods().at(0)) {
716 case EventAlarm::NO_ALARM:
717 alarmType = CAL_ALERT_MUTE;
719 case EventAlarm::SOUND_ALARM:
720 alarmType = CAL_ALERT_MELODY;
722 case EventAlarm::SILENT_ALARM:
723 alarmType = CAL_ALERT_VIBRATION;
726 LogDebug("Use the default alarm type");
729 errorCode = calendar_svc_value_set_int(
731 CAL_VALUE_INT_ALARMS_TYPE,
733 if (CAL_SUCCESS != errorCode) {
735 calendar_svc_value_free(&value);
737 ThrowMsg(PlatformException, "Can't set alarm type: "<<errorCode);
740 // Set the display text
741 errorCode = calendar_svc_value_set_str(
743 CAL_VALUE_TXT_ALARMS_DESCRIPTION,
744 theAlarm->getDescription().c_str());
745 if (CAL_SUCCESS != errorCode) {
747 calendar_svc_value_free(&value);
749 ThrowMsg(PlatformException, "Can't set alarm description: "<<errorCode);
752 list = g_list_append(list, value);
755 if (CAL_SUCCESS!=calendar_svc_struct_store_list(m_platformEvent, CAL_VALUE_LST_ALARM, list)) {
756 ThrowMsg(PlatformException, "cannot save the alarms");
761 void EventWrapper::setStatusToPlatformEvent()
763 if (!m_platformEvent) {
764 ThrowMsg(UnknownException, "Null platform pointer.");
767 cals_status_t status;
769 switch (m_abstractEvent->getStatus()) {
770 case CalendarEvent::TENTATIVE_STATUS:
771 status = CALS_EVENT_STATUS_TENTATIVE;
773 case CalendarEvent::CONFIRMED_STATUS:
774 status = CALS_EVENT_STATUS_CONFIRMED;
776 case CalendarEvent::CANCELLED_STATUS:
777 status = CALS_EVENT_STATUS_CANCELLED;
779 case CalendarEvent::NEEDS_ACTION_STATUS:
780 status = CALS_TODO_STATUS_NEEDS_ACTION;
782 case CalendarEvent::COMPLETED_STATUS:
783 status = CALS_TODO_STATUS_COMPLETED;
785 case CalendarEvent::IN_PROCESS_STATUS:
786 status = CALS_TODO_STATUS_IN_PROCESS;
789 status = CALS_EVENT_STATUS_NONE;
793 if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent,
794 CAL_VALUE_INT_TASK_STATUS,
796 ThrowMsg(PlatformException, "Can't set event status.");
800 void EventWrapper::setCategoriesToPlatformEvent()
802 if (!m_platformEvent) {
803 ThrowMsg(UnknownException, "Null platform pointer.");
806 std::string categories = "";
807 // Need to concatenate all categories into one string separated by a comma.
808 for (size_t i = 0; i < m_abstractEvent->getCategories()->size(); ++i) {
810 categories.append(m_abstractEvent->getCategories()->at(i));
812 categories.append("," + m_abstractEvent->getCategories()->at(i));
816 LogInfo("Saving categories: "<<categories);
819 calendar_svc_struct_set_str(m_platformEvent, CAL_VALUE_TXT_CATEGORIES,
820 categories.c_str())) {
821 ThrowMsg(PlatformException, "Cannot save categories.");
825 void EventWrapper::setIdToPlatformEvent()
827 if (!m_platformEvent) {
828 ThrowMsg(UnknownException, "Null platform pointer.");
830 if (m_abstractEvent->getIdIsSet()) {
831 if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent,
833 m_abstractEvent->getId()))
835 ThrowMsg(PlatformException, "Can't set event Id.");
838 if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent,
841 ThrowMsg(PlatformException, "Can't set event Id.");
846 void EventWrapper::setParentIdToPlatformEvent()
848 if (!m_platformEvent) {
849 ThrowMsg(UnknownException, "Null platform pointer.");
852 if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent,
853 CAL_VALUE_INT_ORIGINAL_EVENT_ID,
854 m_abstractEvent->getParentId()))
856 ThrowMsg(PlatformException, "Can't set parent Id.");
860 void EventWrapper::setIsAllDayToPlatformEvent()
862 if (!m_platformEvent) {
863 ThrowMsg(UnknownException, "Null platform pointer.");
866 cals_time_type timeType = CALS_TIME_UTIME;
867 if(m_abstractEvent->getIsAllDay()) {
868 timeType = CALS_TIME_LOCALTIME;
871 if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent,
872 CALS_VALUE_INT_DTSTART_TYPE,
874 ThrowMsg(PlatformException, "Can't set event isAllDay.");
878 void EventWrapper::setOrganizerToPlatformEvent()
880 if (!m_platformEvent) {
881 ThrowMsg(UnknownException, "Null platform pointer.");
883 if (CAL_SUCCESS != calendar_svc_struct_set_str(m_platformEvent,
884 CAL_VALUE_TXT_ORGANIZER_NAME,
885 m_abstractEvent->getOrganizer().c_str())) {
886 ThrowMsg(PlatformException, "Can't set event organizer.");
890 void EventWrapper::setLastModifiedDateToPlatformEvent()
892 if (!m_platformEvent) {
893 ThrowMsg(UnknownException, "Null platform pointer.");
896 long long int time = m_abstractEvent->getLastModifiedDate();
898 if (CAL_SUCCESS!=calendar_svc_struct_set_lli(m_platformEvent,
899 CALS_VALUE_LLI_LASTMOD,
901 ThrowMsg(PlatformException, "Can't set event lastModifiedDate.");
905 void EventWrapper::setVisibilityToPlatformEvent()
907 if (!m_platformEvent) {
908 ThrowMsg(UnknownException, "Null platform pointer.");
911 int visibility = PUBLIC_VISIBILITY; // default value
912 switch (m_abstractEvent->getVisibility()) {
913 case CalendarEvent::PUBLIC_VISIBILITY:
914 visibility = PUBLIC_VISIBILITY;
916 case CalendarEvent::PRIVATE_VISIBILITY:
917 visibility = PRIVATE_VISIBILITY;
919 case CalendarEvent::CONFIDENTIAL_VISIBILITY:
920 visibility = CONFIDENTIAL_VISIBILITY;
923 LogDebug("Use the default visibility");
926 if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent,
927 CAL_VALUE_INT_SENSITIVITY,
929 ThrowMsg(PlatformException, "Can't set visibility.");
933 void EventWrapper::setAvailabilityToPlatformEvent()
935 if (!m_platformEvent) {
936 ThrowMsg(UnknownException, "Null platform pointer.");
939 cal_event_availability_type_t availability = EVENT_FREE_FB;
940 switch (m_abstractEvent->getAvailability()) {
941 case CalendarEvent::BUSY_FB:
942 availability = EVENT_BUSY_FB;
944 case CalendarEvent::BUSY_UNAVAILABLE_FB:
945 availability = EVENT_BUSY_UNAVAILABLE_FB;
947 case CalendarEvent::FREE_FB:
948 availability = EVENT_FREE_FB;
950 case CalendarEvent::BUSY_TENTATIVE_FB:
951 availability = EVENT_BUSY_TENTATIVE_FB;
954 LogDebug("Use the default availability");
957 if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent,
958 CAL_VALUE_INT_AVAILABILITY,
960 ThrowMsg(PlatformException, "Can't set availability.");
964 void EventWrapper::setUIdToPlatformEvent()
966 if (!m_platformEvent) {
967 ThrowMsg(UnknownException, "Null platform pointer.");
969 if (CAL_SUCCESS != calendar_svc_struct_set_str(m_platformEvent,
971 m_abstractEvent->getUId().c_str())) {
972 ThrowMsg(PlatformException, "Can't set event uid.");
976 void EventWrapper::setAttendeesToPlatformEvent()
978 if (!m_platformEvent) {
979 ThrowMsg(UnknownException, "Null platform pointer.");
982 EventAttendeeListPtr attendeeList = m_abstractEvent->getAttendees();
983 if (NULL==attendeeList) {
984 LogInfo("attendeeList is not set.");
988 GList *attendees = NULL;
989 cal_value* attendee = NULL;
992 for (size_t i = 0; i < attendeeList->size(); ++i) {
993 LogDebug("adding attendee " << i+1 << " over " <<
994 attendeeList->size());
996 attendee = calendar_svc_value_new(CAL_VALUE_LST_ATTENDEE_LIST);
997 if (NULL == attendee) {
998 LogError("error during creating attendee");
999 ThrowMsg(PlatformException,
1000 "Cannot create attendee object");
1005 calendar_svc_value_set_str(attendee, CAL_VALUE_TXT_ATTENDEE_DETAIL_NAME,
1006 attendeeList->at(i)->getName().c_str())) {
1007 LogError("error during setting attendee name");
1008 calendar_svc_value_free(&attendee);
1009 ThrowMsg(PlatformException, "Cannot set attendee name");
1014 calendar_svc_value_set_str(attendee, CAL_VALUE_TXT_ATTENDEE_DETAIL_EMAIL,
1015 attendeeList->at(i)->getURI().c_str())) {
1016 LogError("error during setting attendee URI");
1017 calendar_svc_value_free(&attendee);
1018 ThrowMsg(PlatformException, "Cannot set attendee URI");
1022 cal_event_attendee_role_type_t role = EVENT_ATTENDEE_CHAIR_ROLE;
1023 switch (attendeeList->at(i)->getRole()) {
1024 case EventAttendee::REQ_PARTICIPANT_ROLE:
1025 role = EVENT_ATTENDEE_REQ_PARTICIPANT_ROLE;
1027 case EventAttendee::OPT_PARTICIPANT_ROLE:
1028 role = EVENT_ATTENDEE_OPT_PARTICIPANT_ROLE;
1030 case EventAttendee::NON_PARTICIPANT_ROLE:
1031 role = EVENT_ATTENDEE_NON_PARTICIPANT_ROLE;
1033 case EventAttendee::CHAIR_ROLE:
1034 role = EVENT_ATTENDEE_CHAIR_ROLE;
1037 LogDebug("Use the default role");
1041 calendar_svc_value_set_int(attendee, CAL_VALUE_INT_ATTENDEE_ROLE,
1043 LogError("error during setting attendee role");
1044 calendar_svc_value_free(&attendee);
1045 ThrowMsg(PlatformException, "Cannot set attendee role");
1049 cal_event_attendee_status_type_t status = EVENT_ATTENDEE_NEEDS_ACTION_AT_STATUS;
1050 switch (attendeeList->at(i)->getStatus()) {
1051 case EventAttendee::PENDING_AT_STATUS:
1052 status = EVENT_ATTENDEE_NEEDS_ACTION_AT_STATUS;
1054 case EventAttendee::ACCEPTED_AT_STATUS:
1055 status = EVENT_ATTENDEE_ACCEPTED_AT_STATUS;
1057 case EventAttendee::DECLINED_AT_STATUS:
1058 status = EVENT_ATTENDEE_DECLINED_AT_STATUS;
1060 case EventAttendee::TENTATIVE_AT_STATUS:
1061 status = EVENT_ATTENDEE_TENTATIVE_AT_STATUS;
1063 case EventAttendee::DELEGATED_AT_STATUS:
1064 status = EVENT_ATTENDEE_DELEGATED_AT_STATUS;
1066 case EventAttendee::COMPLETED_AT_STATUS:
1067 status = EVENT_ATTENDEE_COMPLETED_AT_STATUS;
1069 case EventAttendee::IN_PROCESS_AT_STATUS:
1070 status = EVENT_ATTENDEE_IN_PROCESS_AT_STATUS;
1073 LogDebug("Use the default status");
1077 calendar_svc_value_set_int(attendee, CAL_VALUE_INT_ATTENDEE_DETAIL_STATUS,
1079 LogError("error during setting attendee status");
1080 calendar_svc_value_free(&attendee);
1081 ThrowMsg(PlatformException, "Cannot set attendee status");
1086 calendar_svc_value_set_int(attendee, CAL_VALUE_INT_ATTENDEE_RSVP,
1087 attendeeList->at(i)->getRSVP())) {
1088 LogError("error during setting attendee RSVP");
1089 calendar_svc_value_free(&attendee);
1090 ThrowMsg(PlatformException, "Cannot set attendee RSVP");
1094 cal_event_attendee_type_t type = EVENT_ATTENDEE_INDIVIDUAL_TYPE;
1095 switch (attendeeList->at(i)->getType()) {
1096 case EventAttendee::INDIVIDUAL_TYPE:
1097 type = EVENT_ATTENDEE_INDIVIDUAL_TYPE;
1099 case EventAttendee::GROUP_TYPE:
1100 type = EVENT_ATTENDEE_GROUP_TYPE;
1102 case EventAttendee::RESOURCE_TYPE:
1103 type = EVENT_ATTENDEE_RESOURCE_TYPE;
1105 case EventAttendee::ROOM_TYPE:
1106 type = EVENT_ATTENDEE_ROOM_TYPE;
1108 case EventAttendee::UNKNOWN_TYPE:
1109 type = EVENT_ATTENDEE_UNKNOWN_TYPE;
1112 LogDebug("Use the default type");
1116 calendar_svc_value_set_int(attendee, CAL_VALUE_INT_ATTENDEE_DETAIL_TYPE,
1118 LogError("error during setting attendee type");
1119 calendar_svc_value_free(&attendee);
1120 ThrowMsg(PlatformException, "Cannot set attendee type");
1125 calendar_svc_value_set_str(attendee, CAL_VALUE_TXT_ATTENDEE_GROUP,
1126 attendeeList->at(i)->getGroup().c_str())) {
1127 LogError("error during setting attendee group");
1128 calendar_svc_value_free(&attendee);
1129 ThrowMsg(PlatformException, "Cannot set attendee group");
1132 // save delegatorURI
1134 calendar_svc_value_set_str(attendee, CAL_VALUE_TXT_ATTENDEE_DELEGATOR_URI,
1135 attendeeList->at(i)->getDelegatorURI().c_str())) {
1136 LogError("error during setting attendee delegator uri");
1137 calendar_svc_value_free(&attendee);
1138 ThrowMsg(PlatformException, "Cannot set attendee delegator uri");
1143 calendar_svc_value_set_str(attendee, CAL_VALUE_TXT_ATTENDEE_DELEGATE_URI,
1144 attendeeList->at(i)->getDelegateURI().c_str())) {
1145 LogError("error during setting attendee delegate uri");
1146 calendar_svc_value_free(&attendee);
1147 ThrowMsg(PlatformException, "Cannot set attendee delegate uri");
1152 calendar_svc_value_set_str(attendee, CAL_VALUE_TXT_ATTENDEE_UID,
1153 attendeeList->at(i)->getContactId().c_str())) {
1154 LogError("error during setting attendee uid");
1155 calendar_svc_value_free(&attendee);
1156 ThrowMsg(PlatformException, "Cannot set attendee uid");
1159 // save addressBookId
1160 std::stringstream ss(attendeeList->at(i)->getAddressBookId());
1163 LogInfo("addressBookId: "<<addressBookId);
1165 calendar_svc_value_set_int(attendee, CAL_VALUE_INT_ATTENDEE_DETAIL_CT_INDEX,
1167 LogError("error during setting attendee address book id");
1168 calendar_svc_value_free(&attendee);
1169 ThrowMsg(PlatformException, "Cannot set attendee address book id");
1172 attendees = g_list_append(attendees, attendee);
1175 LogDebug("m_abstractEvent->getAttendees()->size() " << attendeeList->size());
1177 calendar_svc_struct_store_list(m_platformEvent,
1178 CAL_VALUE_LST_ATTENDEE_LIST,
1181 Catch(PlatformException)
1183 LogError("error during setting attendees");
1184 calendar_svc_struct_store_list(m_platformEvent,
1185 CAL_VALUE_LST_ATTENDEE_LIST,
1187 for (; attendees; attendees = g_list_next(attendees)) {
1188 attendee = static_cast<cal_value*>(attendees->data);
1189 calendar_svc_value_free(&attendee);
1191 g_list_free(attendees);
1192 ReThrow(PlatformException);
1196 void EventWrapper::setPositionToPlatformEvent()
1198 if (!m_platformEvent) {
1199 ThrowMsg(UnknownException, "Null platform pointer.");
1202 if (CAL_SUCCESS != calendar_svc_struct_set_double(m_platformEvent,
1203 CAL_VALUE_DBL_LATITUDE,
1204 m_abstractEvent->getLatitude())) {
1205 ThrowMsg(PlatformException, "Can't set latitude.");
1208 if (CAL_SUCCESS != calendar_svc_struct_set_double(m_platformEvent,
1209 CAL_VALUE_DBL_LONGITUDE,
1210 m_abstractEvent->getLongitude())) {
1211 ThrowMsg(PlatformException, "Can't set longitude.");
1215 void EventWrapper::setPriorityToPlatformEvent()
1217 if (!m_platformEvent) {
1218 ThrowMsg(UnknownException, "Null platform pointer.");
1221 cal_priority_type_t priority = (cal_priority_type_t)-1;
1223 switch (m_abstractEvent->getPriority()) {
1224 case CalendarEvent::HIGH_PRIORITY:
1225 priority = EVENT_PRIORITY_HIGH;
1227 case CalendarEvent::MEDIUM_PRIORITY:
1228 priority = EVENT_PRIORITY_NORMAL;
1230 case CalendarEvent::LOW_PRIORITY:
1231 priority = EVENT_PRIORITY_LOW;
1237 if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent,
1238 CAL_VALUE_INT_PRIORITY,
1241 ThrowMsg(PlatformException, "Can't set task priority.");
1245 void EventWrapper::setCreatedDateToPlatformEvent()
1247 if (!m_platformEvent) {
1248 ThrowMsg(UnknownException, "Null platform pointer.");
1251 long long int time = m_abstractEvent->getCreatedDate();
1252 if (CAL_SUCCESS != calendar_svc_struct_set_lli(m_platformEvent,
1253 CAL_VALUE_LLI_CREATED_TIME,
1255 ThrowMsg(PlatformException, "Can't set created time.");
1259 void EventWrapper::setCompletedDateToPlatformEvent()
1261 if (!m_platformEvent) {
1262 ThrowMsg(UnknownException, "Null platform pointer.");
1265 long long int time = m_abstractEvent->getCompletedDate();
1266 if (CAL_SUCCESS != calendar_svc_struct_set_lli(m_platformEvent,
1267 CAL_VALUE_LLI_COMPLETED_TIME,
1269 ThrowMsg(PlatformException, "Can't set completed time.");
1273 void EventWrapper::setProgressToPlatformEvent()
1275 if (!m_platformEvent) {
1276 ThrowMsg(UnknownException, "Null platform pointer.");
1279 int progress = m_abstractEvent->getProgress();
1280 if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent,
1281 CAL_VALUE_INT_PROGRESS,
1283 ThrowMsg(PlatformException, "Can't set visibility.");
1287 CalendarEventPtr EventWrapper::convertPlatformEventToAbstractEvent()
1289 LogDebug("entered");
1290 setDescriptionFromPlatformEvent();
1291 setSummaryFromPlatformEvent();
1292 setStartTimeFromPlatformEvent();
1293 setEndTimeFromPlatformEvent(); // replace for duration
1294 setLocationFromPlatformEvent();
1295 setCategoriesFromPlatformEvent();
1296 setStatusFromPlatformEvent();
1297 setAlarmsFromPlatformEvent();
1298 setIsAllDayFromPlatformEvent();
1299 setOrganizerFromPlatformEvent();
1300 setAttendeesFromPlatformEvent();
1301 setPositionFromPlatformEvent();
1302 setVisibilityFromPlatformEvent();
1303 setLastModifiedDateFromPlatformEvent();
1304 setAvailabilityFromPlatformEvent();
1305 setRecurrenceRuleFromPlatformEvent();
1306 setIdFromPlatformEvent();
1307 setParentIdFromPlatformEvent();
1308 //setUIdFromPlatformEvent(); // We set the uid value as the same with id.
1309 setPriorityFromPlatformEvent();
1310 setCreatedDateFromPlatformEvent();
1311 setCompletedDateFromPlatformEvent();
1312 setProgressFromPlatformEvent();
1313 setIsDetachedFromPlatformEvent();
1315 return getAbstractEvent();
1318 void EventWrapper::setDescriptionFromPlatformEvent()
1320 if (!m_platformEvent) {
1321 ThrowMsg(UnknownException, "Null platform pointer.");
1323 const char *description = calendar_svc_struct_get_str(
1325 CAL_VALUE_TXT_DESCRIPTION);
1327 m_abstractEvent->setDescription(description);
1331 void EventWrapper::setSummaryFromPlatformEvent()
1333 if (!m_platformEvent) {
1334 ThrowMsg(UnknownException, "Null platform pointer.");
1336 const char *summary = calendar_svc_struct_get_str(m_platformEvent,
1337 CAL_VALUE_TXT_SUMMARY);
1339 m_abstractEvent->setSubject(summary);
1343 void EventWrapper::setStartTimeFromPlatformEvent()
1345 if (!m_platformEvent) {
1346 ThrowMsg(UnknownException, "Null platform pointer.");
1348 long long int startTime = calendar_svc_struct_get_lli(
1350 CALS_VALUE_LLI_DTSTART_UTIME);
1351 m_abstractEvent->setStartTime(startTime);
1353 // Retrive the time zone info only when the start time is loaded.
1354 char* timeZone = calendar_svc_struct_get_str(
1356 CALS_VALUE_TXT_DTSTART_TZID);
1358 LogInfo("timeZone: "<<timeZone);
1359 m_abstractEvent->setTimeZone(std::string(timeZone));
1361 LogWarning("Cannot read timeZone from platform!");
1363 LogInfo("startTime: "<<startTime);
1366 void EventWrapper::setEndTimeFromPlatformEvent()
1368 if (!m_platformEvent) {
1369 ThrowMsg(UnknownException, "Null platform pointer.");
1371 long long int endTime = calendar_svc_struct_get_lli(m_platformEvent,
1372 CALS_VALUE_LLI_DTEND_UTIME);
1373 m_abstractEvent->setEndTime(endTime);
1376 void EventWrapper::setLocationFromPlatformEvent()
1378 if (!m_platformEvent) {
1379 ThrowMsg(UnknownException, "Null platform pointer.");
1381 const char* location = calendar_svc_struct_get_str(m_platformEvent,
1382 CAL_VALUE_TXT_LOCATION);
1384 m_abstractEvent->setLocation(location);
1388 void EventWrapper::setRecurrenceRuleFromPlatformEvent()
1390 LogDebug("entered");
1391 if (!m_platformEvent) {
1392 ThrowMsg(UnknownException, "Null platform pointer.");
1395 EventRecurrenceRulePtr rrule(new EventRecurrenceRule());
1397 // load the recurrence frequency
1398 int frequency = calendar_svc_struct_get_int(m_platformEvent, CALS_VALUE_INT_RRULE_FREQ);
1399 LogInfo("frequency "<<frequency);
1400 switch (frequency) {
1401 case CALS_FREQ_ONCE:
1402 rrule->setFrequency(EventRecurrenceRule::NO_RECURRENCE);
1404 case CALS_FREQ_DAILY:
1405 rrule->setFrequency(EventRecurrenceRule::DAILY_RECURRENCE);
1407 case CALS_FREQ_WEEKLY:
1408 rrule->setFrequency(EventRecurrenceRule::WEEKLY_RECURRENCE);
1410 case CALS_FREQ_MONTHLY:
1411 rrule->setFrequency(EventRecurrenceRule::MONTHLY_RECURRENCE);
1413 case CALS_FREQ_YEARLY:
1414 rrule->setFrequency(EventRecurrenceRule::YEARLY_RECURRENCE);
1417 LogWarning("Unknown recurrence frequency.");
1418 rrule->setFrequency(EventRecurrenceRule::NO_RECURRENCE);
1423 StringArrayPtr daysOfTheWeek(new StringArray());
1424 char* byday = calendar_svc_struct_get_str(m_platformEvent, CALS_VALUE_TXT_RRULE_BYDAY);
1425 LogInfo("Loaded byday: "<<byday);
1427 char *saveptr = NULL;
1428 char* pch = strtok_r(byday, ",", &saveptr);
1429 while (NULL != pch) {
1430 (*daysOfTheWeek).push_back(pch);
1431 pch = strtok_r(NULL, ",", &saveptr);
1434 rrule->setDaysOfTheWeek(daysOfTheWeek);
1435 LogInfo("Number of daysOfTheWeek: "<<rrule->getDaysOfTheWeek()->size());
1437 // load the recurrence interval
1438 int interval = calendar_svc_struct_get_int(m_platformEvent, CALS_VALUE_INT_RRULE_INTERVAL);
1439 rrule->setInterval(interval);
1441 // load the ocurrence count
1442 int occurrrenceCount = calendar_svc_struct_get_int(m_platformEvent, CALS_VALUE_INT_RRULE_COUNT);
1443 rrule->setOccurrenceCount(occurrrenceCount);
1445 // load the recurrence end date
1446 long long int endDate = calendar_svc_struct_get_lli(m_platformEvent, CALS_VALUE_LLI_RRULE_UNTIL_UTIME);
1447 rrule->setEndDate(endDate);
1448 LogDebug("endDate from platform = " << endDate);
1450 // load the exceptions
1451 NumberArrayPtr exceptions(new NumberArray());
1452 char* exdate = calendar_svc_struct_get_str(m_platformEvent, CAL_VALUE_TXT_EXDATE);
1453 LogInfo("Loaded exdate: "<<exdate);
1455 char *saveptr = NULL;
1456 char *pch = strtok_r(exdate, ",", &saveptr);
1457 while (NULL != pch) {
1458 std::stringstream ss(pch);
1459 long long int oneException;
1461 (*exceptions).push_back(oneException);
1462 pch = strtok_r(NULL, ",", &saveptr);
1465 rrule->setExceptions(exceptions);
1466 LogInfo("Number of exceptions: "<<rrule->getExceptions()->size());
1468 // set the loaded recurrence rule
1469 m_abstractEvent->setRecurrenceRule(rrule);
1472 void EventWrapper::setAlarmsFromPlatformEvent()
1474 if (!m_platformEvent) {
1475 ThrowMsg(UnknownException, "Null platform pointer.");
1478 GList* alarmList = NULL;
1479 calendar_svc_struct_get_list(m_platformEvent, CAL_VALUE_LST_ALARM, &alarmList);
1480 cal_value* alarmValue = NULL;
1482 for (; alarmList; alarmList = g_list_next(alarmList)) {
1483 LogDebug("Processing alarm...");
1484 alarmValue = static_cast<cal_value*>(alarmList->data);
1486 EventAlarmPtr theAlarm( new EventAlarm() );
1488 tickUnit = calendar_svc_value_get_int(alarmValue, CAL_VALUE_INT_ALARMS_TICK_UNIT);
1489 if (CAL_ERR_FAIL == tickUnit) {
1490 LogError("Cannot read alarm tick unit. Stop processing alarms.");
1494 if( CAL_SCH_TIME_UNIT_SPECIFIC==tickUnit ) {
1495 long long int absoluteDate = calendar_svc_value_get_lli(
1497 CAL_VALUE_LLI_ALARMS_TIME);
1498 if (CAL_ERR_FAIL == absoluteDate) {
1499 LogError("Cannot read alarm time. Stop processing alarms.");
1502 LogInfo("Load absolute date: "<<absoluteDate);
1503 theAlarm->setAbsoluteDate(absoluteDate);
1505 tick = calendar_svc_value_get_int(alarmValue, CAL_VALUE_INT_ALARMS_TICK);
1506 if (CAL_ERR_FAIL == tick) {
1507 LogError("Cannot read alarm tick. Stop processing alarms.");
1511 TizenApis::Api::TimeUtil::DurationProperties duration;
1512 if( CAL_SCH_TIME_UNIT_MIN==tickUnit ) {
1513 duration.unit = TizenApis::Api::TimeUtil::MINUTES_UNIT;
1514 duration.length = tick;
1515 } else if( CAL_SCH_TIME_UNIT_HOUR==tickUnit ) {
1516 duration.unit = TizenApis::Api::TimeUtil::HOURS_UNIT;
1517 duration.length = tick;
1518 } else if( CAL_SCH_TIME_UNIT_DAY==tickUnit ) {
1519 duration.unit = TizenApis::Api::TimeUtil::DAYS_UNIT;
1520 duration.length = tick;
1521 } else if( CAL_SCH_TIME_UNIT_WEEK==tickUnit) {
1522 duration.unit = TizenApis::Api::TimeUtil::DAYS_UNIT;
1523 duration.length = tick*7;
1525 LogWarning("Wrong tick unit: "<<tickUnit);
1528 theAlarm->setDuration(duration);
1531 std::vector<EventAlarm::EventAlarmType> methods;
1532 cal_alert_type_t type = static_cast<cal_alert_type_t>(calendar_svc_value_get_int(alarmValue, CAL_VALUE_INT_ALARMS_TYPE));
1534 LogError("Cannot read alarm type. Setting the default value.");
1537 case CAL_ALERT_VIBRATION:
1538 methods.push_back(EventAlarm::SILENT_ALARM);
1540 case CAL_ALERT_MELODY:
1541 case CAL_ALERT_INCREASING_MELODY:
1542 case CAL_ALERT_VIBRATION_THEN_MELODY:
1543 case CAL_ALERT_VIBMELODY:
1544 case CAL_ALERT_VIB_INCREASING_MELODY:
1545 methods.push_back(EventAlarm::SOUND_ALARM);
1547 case CAL_ALERT_MUTE:
1549 methods.push_back(EventAlarm::NO_ALARM);
1552 theAlarm->setMethods(methods);
1554 char* description = calendar_svc_value_get_str(alarmValue, CAL_VALUE_TXT_ALARMS_DESCRIPTION);
1555 if (NULL == description) {
1556 LogError("Cannot read alarm description. Setting empty string.");
1557 theAlarm->setDescription("");
1559 theAlarm->setDescription(description);
1563 m_abstractEvent->getAlarms()->push_back(theAlarm);
1565 LogInfo("Number of alarms: "<<m_abstractEvent->getAlarms()->size());
1568 void EventWrapper::setStatusFromPlatformEvent()
1570 if (!m_platformEvent) {
1571 ThrowMsg(UnknownException, "Null platform pointer.");
1574 cals_status_t status = static_cast<cals_status_t>(calendar_svc_struct_get_int(m_platformEvent,
1575 CAL_VALUE_INT_TASK_STATUS));
1577 case CALS_EVENT_STATUS_TENTATIVE:
1578 m_abstractEvent->setStatus(CalendarEvent::TENTATIVE_STATUS);
1580 case CALS_EVENT_STATUS_CONFIRMED:
1581 m_abstractEvent->setStatus(CalendarEvent::CONFIRMED_STATUS);
1583 case CALS_EVENT_STATUS_CANCELLED:
1584 case CALS_TODO_STATUS_CANCELLED:
1585 m_abstractEvent->setStatus(CalendarEvent::CANCELLED_STATUS);
1587 case CALS_TODO_STATUS_NEEDS_ACTION:
1588 m_abstractEvent->setStatus(CalendarEvent::NEEDS_ACTION_STATUS);
1590 case CALS_TODO_STATUS_COMPLETED:
1591 m_abstractEvent->setStatus(CalendarEvent::COMPLETED_STATUS);
1593 case CALS_TODO_STATUS_IN_PROCESS:
1594 m_abstractEvent->setStatus(CalendarEvent::IN_PROCESS_STATUS);
1597 m_abstractEvent->setStatus(CalendarEvent::UNDEFINED_STATUS);
1602 void EventWrapper::setCategoriesFromPlatformEvent()
1604 if (!m_platformEvent) {
1605 ThrowMsg(UnknownException, "Null platform pointer.");
1607 m_abstractEvent->getCategories()->clear();
1609 char *categories = calendar_svc_struct_get_str(
1611 CAL_VALUE_TXT_CATEGORIES);
1614 LogInfo("Loaded categories: "<<categories);
1616 char *saveptr = NULL;
1617 char* pch = strtok_r(categories, ",", &saveptr);
1618 while (NULL != pch) {
1619 m_abstractEvent->getCategories()->push_back(pch);
1620 pch = strtok_r(NULL, ",", &saveptr);
1624 LogInfo("Number of categories: "<<m_abstractEvent->getCategories()->size());
1627 void EventWrapper::setIdFromPlatformEvent()
1629 if (!m_platformEvent) {
1630 ThrowMsg(UnknownException, "Null platform pointer.");
1632 m_abstractEvent->setId(getIdFromPlatformEvent());
1634 // Set the uid also.
1635 std::stringstream ss;
1636 ss<<getIdFromPlatformEvent();
1637 m_abstractEvent->setUId(ss.str());
1640 void EventWrapper::setParentIdFromPlatformEvent()
1642 if (!m_platformEvent) {
1643 ThrowMsg(UnknownException, "Null platform pointer.");
1646 int parentId = calendar_svc_struct_get_int(m_platformEvent,
1647 CAL_VALUE_INT_ORIGINAL_EVENT_ID);
1649 m_abstractEvent->setParentId(parentId);
1652 void EventWrapper::setIsAllDayFromPlatformEvent()
1654 if (!m_platformEvent) {
1655 ThrowMsg(UnknownException, "Null platform pointer.");
1658 int timeType = calendar_svc_struct_get_int(m_platformEvent,
1659 CALS_VALUE_INT_DTSTART_TYPE);
1661 if(timeType==CALS_TIME_LOCALTIME) {
1662 m_abstractEvent->setIsAllDay(true);
1664 m_abstractEvent->setIsAllDay(false);
1668 void EventWrapper::setOrganizerFromPlatformEvent()
1670 if (!m_platformEvent) {
1671 ThrowMsg(UnknownException, "Null platform pointer.");
1673 const char* organizer = calendar_svc_struct_get_str(m_platformEvent,
1674 CAL_VALUE_TXT_ORGANIZER_NAME);
1676 m_abstractEvent->setOrganizer(organizer);
1680 void EventWrapper::setLastModifiedDateFromPlatformEvent()
1682 if (!m_platformEvent) {
1683 ThrowMsg(UnknownException, "Null platform pointer.");
1685 long long int lastModifiedDate = calendar_svc_struct_get_lli(
1687 CALS_VALUE_LLI_LASTMOD);
1688 m_abstractEvent->setLastModifiedDate(lastModifiedDate);
1691 void EventWrapper::setVisibilityFromPlatformEvent()
1693 if (!m_platformEvent) {
1694 ThrowMsg(UnknownException, "Null platform pointer.");
1697 int visibility = calendar_svc_struct_get_int(m_platformEvent,
1698 CAL_VALUE_INT_SENSITIVITY);
1699 switch (visibility) {
1700 case PUBLIC_VISIBILITY:
1701 m_abstractEvent->setVisibility(CalendarEvent::PUBLIC_VISIBILITY);
1703 case PRIVATE_VISIBILITY:
1704 m_abstractEvent->setVisibility(CalendarEvent::PRIVATE_VISIBILITY);
1706 case CONFIDENTIAL_VISIBILITY:
1707 m_abstractEvent->setVisibility(CalendarEvent::CONFIDENTIAL_VISIBILITY);
1710 m_abstractEvent->setVisibility(CalendarEvent::PUBLIC_VISIBILITY);
1715 void EventWrapper::setAvailabilityFromPlatformEvent()
1717 if (!m_platformEvent) {
1718 ThrowMsg(UnknownException, "Null platform pointer.");
1721 cal_status_type_t availability =
1722 static_cast<cal_status_type_t>(calendar_svc_struct_get_int(
1724 CAL_VALUE_INT_AVAILABILITY));
1725 switch (availability) {
1727 m_abstractEvent->setAvailability(CalendarEvent::BUSY_FB);
1729 case EVENT_BUSY_UNAVAILABLE_FB:
1730 m_abstractEvent->setAvailability(CalendarEvent::BUSY_UNAVAILABLE_FB);
1733 m_abstractEvent->setAvailability(CalendarEvent::FREE_FB);
1735 case EVENT_BUSY_TENTATIVE_FB:
1736 m_abstractEvent->setAvailability(CalendarEvent::BUSY_TENTATIVE_FB);
1739 m_abstractEvent->setAvailability(CalendarEvent::FREE_FB);
1744 void EventWrapper::setUIdFromPlatformEvent()
1746 if (!m_platformEvent) {
1747 ThrowMsg(UnknownException, "Null platform pointer.");
1749 const char* uid = calendar_svc_struct_get_str(m_platformEvent,
1752 m_abstractEvent->setUId(uid);
1756 void EventWrapper::setAttendeesFromPlatformEvent()
1758 LogDebug("entered");
1760 if (!m_platformEvent) {
1761 ThrowMsg(UnknownException, "Null platform pointer.");
1764 if ( NULL != m_abstractEvent->getAttendees() )
1765 m_abstractEvent->getAttendees()->clear();
1767 GList *attendees = NULL;
1769 calendar_svc_struct_get_list(m_platformEvent,
1770 CAL_VALUE_LST_ATTENDEE_LIST,
1772 LogError("Cannot read attendees list");
1775 cal_value* attendee = NULL;
1776 for (; attendees; attendees = g_list_next(attendees)) {
1777 LogDebug("Processing attendee...");
1778 attendee = static_cast<cal_value*>(attendees->data);
1779 EventAttendeePtr attendeePtr(new EventAttendee());
1782 char* attendeeName = calendar_svc_value_get_str(attendee, CAL_VALUE_TXT_ATTENDEE_DETAIL_NAME);
1783 if (NULL == attendeeName) {
1784 LogError("Cannot read attendee name. Setting an empty string.");
1785 attendeePtr->setName("");
1787 attendeePtr->setName(attendeeName);
1791 char* attendeeURI = calendar_svc_value_get_str(attendee, CAL_VALUE_TXT_ATTENDEE_DETAIL_EMAIL);
1792 if (NULL == attendeeURI) {
1793 LogError("Cannot read attendee URI. Setting an empty string.");
1794 attendeePtr->setURI("");
1796 attendeePtr->setURI(attendeeURI);
1800 cal_event_attendee_role_type_t attendeeRole =
1801 static_cast<cal_event_attendee_role_type_t>(calendar_svc_value_get_int(
1803 CAL_VALUE_INT_ATTENDEE_ROLE));
1804 if (0 > attendeeRole) {
1805 LogError("Cannot read attendee role. Setting the default value.");
1807 switch (attendeeRole) {
1808 case EVENT_ATTENDEE_REQ_PARTICIPANT_ROLE:
1809 attendeePtr->setRole(EventAttendee::REQ_PARTICIPANT_ROLE);
1811 case EVENT_ATTENDEE_OPT_PARTICIPANT_ROLE:
1812 attendeePtr->setRole(EventAttendee::OPT_PARTICIPANT_ROLE);
1814 case EVENT_ATTENDEE_NON_PARTICIPANT_ROLE:
1815 attendeePtr->setRole(EventAttendee::NON_PARTICIPANT_ROLE);
1817 case EVENT_ATTENDEE_CHAIR_ROLE:
1818 attendeePtr->setRole(EventAttendee::CHAIR_ROLE);
1821 attendeePtr->setRole(EventAttendee::REQ_PARTICIPANT_ROLE);
1826 cal_event_attendee_status_type_t attendeeStatus =
1827 static_cast<cal_event_attendee_status_type_t>(calendar_svc_value_get_int(
1829 CAL_VALUE_INT_ATTENDEE_DETAIL_STATUS));
1830 if (0 > attendeeStatus) {
1831 LogError("Cannot read attendee status. Setting the default value.");
1833 switch (attendeeStatus) {
1834 case EVENT_ATTENDEE_NEEDS_ACTION_AT_STATUS:
1835 attendeePtr->setStatus(EventAttendee::PENDING_AT_STATUS);
1837 case EVENT_ATTENDEE_ACCEPTED_AT_STATUS:
1838 attendeePtr->setStatus(EventAttendee::ACCEPTED_AT_STATUS);
1840 case EVENT_ATTENDEE_DECLINED_AT_STATUS:
1841 attendeePtr->setStatus(EventAttendee::DECLINED_AT_STATUS);
1843 case EVENT_ATTENDEE_TENTATIVE_AT_STATUS:
1844 attendeePtr->setStatus(EventAttendee::TENTATIVE_AT_STATUS);
1846 case EVENT_ATTENDEE_DELEGATED_AT_STATUS:
1847 attendeePtr->setStatus(EventAttendee::DELEGATED_AT_STATUS);
1849 case EVENT_ATTENDEE_COMPLETED_AT_STATUS:
1850 attendeePtr->setStatus(EventAttendee::COMPLETED_AT_STATUS);
1852 case EVENT_ATTENDEE_IN_PROCESS_AT_STATUS:
1853 attendeePtr->setStatus(EventAttendee::IN_PROCESS_AT_STATUS);
1856 attendeePtr->setStatus(EventAttendee::PENDING_AT_STATUS);
1861 int attendeeRSVP = calendar_svc_value_get_int(attendee, CAL_VALUE_INT_ATTENDEE_RSVP);
1862 if (0 > attendeeRSVP) {
1863 LogError("Cannot read attendee RSVP. Setting the default value.");
1865 attendeePtr->setRSVP(attendeeRSVP>0 ? true : false);
1868 cal_event_attendee_type_t attendeeType =
1869 static_cast<cal_event_attendee_type_t>(calendar_svc_value_get_int(
1871 CAL_VALUE_INT_ATTENDEE_DETAIL_TYPE));
1872 if (0 > attendeeType) {
1873 LogError("Cannot read attendee type. Setting the default value.");
1875 switch (attendeeType) {
1876 case EVENT_ATTENDEE_INDIVIDUAL_TYPE:
1877 attendeePtr->setType(EventAttendee::INDIVIDUAL_TYPE);
1879 case EVENT_ATTENDEE_GROUP_TYPE:
1880 attendeePtr->setType(EventAttendee::GROUP_TYPE);
1882 case EVENT_ATTENDEE_RESOURCE_TYPE:
1883 attendeePtr->setType(EventAttendee::RESOURCE_TYPE);
1885 case EVENT_ATTENDEE_ROOM_TYPE:
1886 attendeePtr->setType(EventAttendee::ROOM_TYPE);
1888 case EVENT_ATTENDEE_UNKNOWN_TYPE:
1889 attendeePtr->setType(EventAttendee::UNKNOWN_TYPE);
1892 attendeePtr->setType(EventAttendee::INDIVIDUAL_TYPE);
1897 char* attendeeGroup = calendar_svc_value_get_str(attendee, CAL_VALUE_TXT_ATTENDEE_GROUP);
1898 if (NULL == attendeeGroup) {
1899 LogError("Cannot read attendee group. Setting an empty string.");
1900 attendeePtr->setGroup("");
1902 attendeePtr->setGroup(attendeeGroup);
1905 // load delegatorURI
1906 char* attendeeDelegatorURI = calendar_svc_value_get_str(attendee, CAL_VALUE_TXT_ATTENDEE_DELEGATOR_URI);
1907 if (NULL == attendeeDelegatorURI) {
1908 LogError("Cannot read attendee delegatorURI. Setting an empty string.");
1909 attendeePtr->setDelegatorURI("");
1911 attendeePtr->setDelegatorURI(attendeeDelegatorURI);
1915 char* attendeeDelegateURI = calendar_svc_value_get_str(attendee, CAL_VALUE_TXT_ATTENDEE_DELEGATE_URI);
1916 if (NULL == attendeeDelegateURI) {
1917 LogError("Cannot read attendee delegateURI. Setting an empty string.");
1918 attendeePtr->setDelegateURI("");
1920 attendeePtr->setDelegateURI(attendeeDelegateURI);
1924 char* attendeeContactId = calendar_svc_value_get_str(attendee, CAL_VALUE_TXT_ATTENDEE_UID);
1925 if (NULL == attendeeContactId) {
1926 LogError("Cannot read attendee UId. Setting an empty string.");
1927 attendeePtr->setContactId("");
1929 attendeePtr->setContactId(attendeeContactId);
1932 // load addressBookId
1933 int attendeeAddressBookId = calendar_svc_value_get_int(attendee, CAL_VALUE_INT_ATTENDEE_DETAIL_CT_INDEX);
1934 LogInfo("attendeeAddressBookId: "<<attendeeAddressBookId);
1935 if ( 0>attendeeAddressBookId) {
1936 LogError("Cannot read attendee address book id. Setting an empty string.");
1937 attendeeAddressBookId = -1;
1939 std::stringstream ss;
1940 if (attendeeAddressBookId>=0) {
1941 ss<<attendeeAddressBookId;
1945 attendeePtr->setAddressBookId(ss.str());
1947 m_abstractEvent->getAttendees()->push_back(attendeePtr);
1951 void EventWrapper::setPositionFromPlatformEvent()
1953 if (!m_platformEvent) {
1954 ThrowMsg(UnknownException, "Null platform pointer.");
1957 double value = calendar_svc_struct_get_double(
1959 CAL_VALUE_DBL_LATITUDE);
1960 m_abstractEvent->setLatitude(value);
1962 value = calendar_svc_struct_get_double(
1964 CAL_VALUE_DBL_LONGITUDE);
1965 m_abstractEvent->setLongitude(value);
1968 void EventWrapper::setPriorityFromPlatformEvent()
1970 if (!m_platformEvent) {
1971 ThrowMsg(UnknownException, "Null platform pointer.");
1974 cal_priority_type_t priority = static_cast<cal_priority_type_t>(calendar_svc_struct_get_int(m_platformEvent,
1975 CAL_VALUE_INT_PRIORITY));
1977 case EVENT_PRIORITY_LOW:
1978 m_abstractEvent->setPriority(CalendarEvent::LOW_PRIORITY);
1980 case EVENT_PRIORITY_NORMAL:
1981 m_abstractEvent->setPriority(CalendarEvent::MEDIUM_PRIORITY);
1983 case EVENT_PRIORITY_HIGH:
1984 m_abstractEvent->setPriority(CalendarEvent::HIGH_PRIORITY);
1987 m_abstractEvent->setPriority(CalendarEvent::MEDIUM_PRIORITY);
1992 void EventWrapper::setCreatedDateFromPlatformEvent()
1994 if (!m_platformEvent) {
1995 ThrowMsg(UnknownException, "Null platform pointer.");
1998 long long int createdDate = 0;
1999 createdDate = calendar_svc_struct_get_lli(m_platformEvent,
2000 CALS_VALUE_LLI_LASTMOD);
2002 m_abstractEvent->setCreatedDate(createdDate);
2005 void EventWrapper::setCompletedDateFromPlatformEvent()
2007 if (!m_platformEvent) {
2008 ThrowMsg(UnknownException, "Null platform pointer.");
2011 long long int completedDate = 0;
2012 completedDate = calendar_svc_struct_get_lli(m_platformEvent,
2013 CAL_VALUE_LLI_COMPLETED_TIME);
2015 LogInfo("completedDate: "<<completedDate);
2016 m_abstractEvent->setCompletedDate(completedDate);
2019 void EventWrapper::setProgressFromPlatformEvent()
2021 if (!m_platformEvent) {
2022 ThrowMsg(UnknownException, "Null platform pointer.");
2026 progress = calendar_svc_struct_get_int(m_platformEvent, CAL_VALUE_INT_PROGRESS);
2028 LogInfo("progress: "<<progress);
2029 m_abstractEvent->setProgress(progress);
2032 void EventWrapper::setIsDetachedFromPlatformEvent()
2034 if (!m_platformEvent) {
2035 ThrowMsg(UnknownException, "Null platform pointer.");
2038 int isDetached = calendar_svc_struct_get_int(m_platformEvent, CAL_VALUE_INT_ORIGINAL_EVENT_ID);
2040 m_abstractEvent->setIsDetached(true);
2041 LogInfo("This is a detached event.");
2043 m_abstractEvent->setIsDetached(false);
2047 void EventWrapper::displayAbstractEvent()
2049 m_abstractEvent->display();
2052 void EventWrapper::displayPlatformEvent()
2054 LogDebug("event id: " << calendar_svc_struct_get_int(m_platformEvent,
2055 CAL_VALUE_INT_INDEX));
2057 long long int startTime = calendar_svc_struct_get_lli(
2058 m_platformEvent, CALS_VALUE_LLI_DTSTART_UTIME);
2059 LogDebug("event start time: " << startTime);
2061 LogDebug("event end time: " << calendar_svc_struct_get_lli(m_platformEvent, CALS_VALUE_LLI_DTEND_UTIME));
2062 LogDebug("event location: " << calendar_svc_struct_get_str(m_platformEvent, CAL_VALUE_TXT_LOCATION));
2063 LogDebug("event summary: " << calendar_svc_struct_get_str(m_platformEvent, CAL_VALUE_TXT_SUMMARY));
2064 LogDebug("event description: " << calendar_svc_struct_get_str(m_platformEvent, CAL_VALUE_TXT_DESCRIPTION));
2065 LogDebug("event isAllDay: " << calendar_svc_struct_get_int(m_platformEvent, CALS_VALUE_INT_DTSTART_TYPE));
2066 LogDebug("event organizer: " << calendar_svc_struct_get_str(m_platformEvent, CAL_VALUE_TXT_ORGANIZER_NAME));
2067 LogDebug("event lastModifiedDate: " << calendar_svc_struct_get_lli(m_platformEvent, CALS_VALUE_LLI_LASTMOD));
2068 LogDebug("event visibility: " << calendar_svc_struct_get_int(m_platformEvent, CAL_VALUE_INT_SENSITIVITY));
2069 LogDebug("event availability: " << calendar_svc_struct_get_int(m_platformEvent, CAL_VALUE_INT_BUSY_STATUS));
2070 LogDebug("event categories: " << calendar_svc_struct_get_str(m_platformEvent, CAL_VALUE_TXT_CATEGORIES));
2071 LogDebug("event uid: " << calendar_svc_struct_get_str(m_platformEvent, CAL_VALUE_TXT_UID));
2073 GList *attendees = NULL;
2074 if (CAL_SUCCESS != calendar_svc_struct_get_list(m_platformEvent, CAL_VALUE_LST_ATTENDEE_LIST, &attendees)) {
2075 LogError("cannot read attendee list");
2078 cal_value* attendee = NULL;
2079 for (; attendees; attendees = g_list_next(attendees)) {
2080 attendee = static_cast<cal_value*>(attendees->data);
2081 char* attendeeName = calendar_svc_value_get_str(attendee, CAL_VALUE_TXT_ATTENDEE_DETAIL_NAME);
2082 if (NULL == attendeeName) {
2083 LogError("cannot read attendee name");
2086 LogDebug("event attendees: " << attendeeName);
2089 LogDebug("event repeat frequency: " << calendar_svc_struct_get_int(m_platformEvent, CALS_VALUE_INT_RRULE_FREQ));
2090 LogDebug("event repeat interval: " << calendar_svc_struct_get_int(m_platformEvent, CALS_VALUE_INT_RRULE_INTERVAL));
2091 LogDebug("event repeat occurrence count: " << calendar_svc_struct_get_int(m_platformEvent, CALS_VALUE_INT_RRULE_COUNT));
2092 LogDebug("event repeat end date: " << calendar_svc_struct_get_lli(m_platformEvent, CALS_VALUE_LLI_RRULE_UNTIL_UTIME));
2093 LogDebug("event exceptions: " << calendar_svc_struct_get_str(m_platformEvent, CAL_VALUE_TXT_EXDATE));
2096 CalendarEvent::CalendarType EventWrapper::getType()
2098 return m_calendarType;