static uint8_t exchange2ical_exception_from_ExceptionInfo(struct exchange2ical *exchange2ical, struct exchange2ical_check *exchange2ical_check) { uint32_t i; icalproperty *prop; icalparameter *param; icaltimetype icaltime; /*sanity checks*/ if(!exchange2ical->AppointmentRecurrencePattern) return 1; if(!exchange2ical->AppointmentRecurrencePattern->ExceptionInfo) return 1; if(!exchange2ical->AppointmentRecurrencePattern->ExceptionCount) return 1; for(i=0; i<exchange2ical->AppointmentRecurrencePattern->ExceptionCount; i++) { /*Check to see if event is acceptable*/ struct tm apptStart=get_tm_from_minutes_UTC(exchange2ical->AppointmentRecurrencePattern->ExceptionInfo->StartDateTime); if (!checkEvent(exchange2ical, exchange2ical_check, &apptStart)){ return 0; } /*Create a new vevent*/ exchange2ical->vevent = icalcomponent_new_vevent(); if ( ! (exchange2ical->vevent) ) { return 1; } icalcomponent_add_component(exchange2ical->vcalendar, exchange2ical->vevent); /*dtstart from StartDateTime*/ if (exchange2ical->apptSubType && (*exchange2ical->apptSubType == 0x1)) { struct tm tm; tm = get_tm_from_minutes_UTC(exchange2ical->AppointmentRecurrencePattern->ExceptionInfo->StartDateTime); icaltime= get_icaldate_from_tm(&tm); prop = icalproperty_new_dtstart(icaltime); icalcomponent_add_property(exchange2ical->vevent, prop); }else { if(exchange2ical->TimeZoneDesc){ struct tm tm; tm = get_tm_from_minutes(exchange2ical->AppointmentRecurrencePattern->ExceptionInfo->StartDateTime); icaltime= get_icaldate_from_tm(&tm); prop = icalproperty_new_dtstart(icaltime); icalcomponent_add_property(exchange2ical->vevent, prop); param = icalparameter_new_tzid(exchange2ical->TimeZoneDesc); icalproperty_add_parameter(prop, param); } else { struct tm tm; tm = get_tm_from_minutes_UTC(exchange2ical->AppointmentRecurrencePattern->ExceptionInfo->StartDateTime); icaltime= get_icaldate_from_tm(&tm); prop = icalproperty_new_dtstart(icaltime); icalcomponent_add_property(exchange2ical->vevent, prop); } } /*dtend from EndDateTime*/ if (exchange2ical->apptSubType && (*exchange2ical->apptSubType == 0x1)) { struct tm tm; tm = get_tm_from_minutes_UTC(exchange2ical->AppointmentRecurrencePattern->ExceptionInfo->EndDateTime); icaltime= get_icaldate_from_tm(&tm); prop = icalproperty_new_dtend(icaltime); icalcomponent_add_property(exchange2ical->vevent, prop); }else { if(exchange2ical->TimeZoneDesc){ struct tm tm; tm = get_tm_from_minutes(exchange2ical->AppointmentRecurrencePattern->ExceptionInfo->EndDateTime); icaltime= get_icaldate_from_tm(&tm); prop = icalproperty_new_dtend(icaltime); icalcomponent_add_property(exchange2ical->vevent, prop); param = icalparameter_new_tzid(exchange2ical->TimeZoneDesc); icalproperty_add_parameter(prop, param); } else { struct tm tm; tm = get_tm_from_minutes_UTC(exchange2ical->AppointmentRecurrencePattern->ExceptionInfo->EndDateTime); icaltime= get_icaldate_from_tm(&tm); prop = icalproperty_new_dtend(icaltime); icalcomponent_add_property(exchange2ical->vevent, prop); } } /*recurrence-id from OriginalStartDate*/ if (exchange2ical->apptSubType && (*exchange2ical->apptSubType == 0x1)) { struct tm tm; tm = get_tm_from_minutes_UTC(exchange2ical->AppointmentRecurrencePattern->ExceptionInfo->OriginalStartDate); icaltime= get_icaldate_from_tm(&tm); prop = icalproperty_new_recurrenceid(icaltime); icalcomponent_add_property(exchange2ical->vevent, prop); }else { if(exchange2ical->TimeZoneDesc){ struct tm tm; tm = get_tm_from_minutes(exchange2ical->AppointmentRecurrencePattern->ExceptionInfo->OriginalStartDate); icaltime= get_icaldate_from_tm(&tm); prop = icalproperty_new_recurrenceid(icaltime); icalcomponent_add_property(exchange2ical->vevent, prop); param = icalparameter_new_tzid(exchange2ical->TimeZoneDesc); icalproperty_add_parameter(prop, param); } else { struct tm tm; tm = get_tm_from_minutes_UTC(exchange2ical->AppointmentRecurrencePattern->ExceptionInfo->OriginalStartDate); icaltime= get_icaldate_from_tm(&tm); prop = icalproperty_new_recurrenceid(icaltime); icalcomponent_add_property(exchange2ical->vevent, prop); } } /*summary from Subject if subject is set*/ if (exchange2ical->AppointmentRecurrencePattern->ExceptionInfo->OverrideFlags & 0x0001) { exchange2ical->Subject=(const char *) &exchange2ical->AppointmentRecurrencePattern->ExceptionInfo->Subject.subjectMsg.msg; ical_property_SUMMARY(exchange2ical); } /*Valarm*/ /*ReminderSet*/ if(exchange2ical->AppointmentRecurrencePattern->ExceptionInfo->OverrideFlags & 0x0008){ exchange2ical->ReminderSet=(uint8_t *) &exchange2ical->AppointmentRecurrencePattern->ExceptionInfo->ReminderDelta.rSet; /*Reminder Delta*/ if(exchange2ical->AppointmentRecurrencePattern->ExceptionInfo->OverrideFlags & 0x0004){ exchange2ical->ReminderDelta=&exchange2ical->AppointmentRecurrencePattern->ExceptionInfo->ReminderDelta.rDelta; } else { exchange2ical->ReminderDelta=NULL; } ical_component_VALARM(exchange2ical); } /*Location*/ if(exchange2ical->AppointmentRecurrencePattern->ExceptionInfo->OverrideFlags & 0x0010){ exchange2ical->Location=(const char *) &exchange2ical->AppointmentRecurrencePattern->ExceptionInfo->Location.locationMsg.msg; ical_property_LOCATION(exchange2ical); } /*Busy Status*/ if(exchange2ical->AppointmentRecurrencePattern->ExceptionInfo->OverrideFlags & 0x0020){ exchange2ical->BusyStatus=&exchange2ical->AppointmentRecurrencePattern->ExceptionInfo->BusyStatus.bStatus; ical_property_X_MICROSOFT_CDO_BUSYSTATUS(exchange2ical); } } return 0; }
void ical_property_EXDATE(struct exchange2ical *exchange2ical) { uint32_t i; uint32_t j; uint8_t modified; struct icaltimetype icaltime; struct icaltimetype dttime; icalproperty *prop; struct RecurrencePattern *pat = exchange2ical->RecurrencePattern; /* Sanity check */ if (exchange2ical->Recurring && (*exchange2ical->Recurring == 0x0)) return; if (!pat) return; if (!pat->DeletedInstanceCount) return; for (i = 0; i < pat->DeletedInstanceCount; i++) { modified=0; if(pat->ModifiedInstanceDates && pat->ModifiedInstanceCount){ for(j=0; j < pat->ModifiedInstanceCount; j++){ if(pat->ModifiedInstanceDates[j]==pat->DeletedInstanceDates[i]){ modified=1; break; } } } /* If this is an all-day appointment */ if (!modified && exchange2ical->apptSubType && (*exchange2ical->apptSubType == 0x1)) { struct tm tm; tm = get_tm_from_minutes_UTC(pat->DeletedInstanceDates[i]); icaltime= get_icaldate_from_tm(&tm); prop = icalproperty_new_exdate(icaltime); icalcomponent_add_property(exchange2ical->vevent, prop); } else if (!modified){ /* number of minutes between midnight of the specified * day and midnight, January 1, 1601 */ struct tm tm; tm = get_tm_from_minutes_UTC(pat->DeletedInstanceDates[i]); icaltime= get_icaltimetype_from_tm(&tm); if (exchange2ical->TimeZoneDesc) { /*Get time from dtstart*/ if (exchange2ical->apptEndWhole){ dttime = get_icaltime_from_FILETIME(exchange2ical->apptStartWhole); icaltime.hour = dttime.hour; icaltime.minute = dttime.minute; } prop = icalproperty_new_exdate(icaltime); icalcomponent_add_property(exchange2ical->vevent, prop); icalparameter *tzid = icalparameter_new_tzid(exchange2ical->TimeZoneDesc); icalproperty_add_parameter(prop, tzid); } else { /*Get time from dtstart*/ icaltime.is_utc = 1; if (exchange2ical->apptEndWhole){ dttime = get_icaltime_from_FILETIME_UTC(exchange2ical->apptStartWhole); icaltime.hour = dttime.hour; icaltime.minute = dttime.minute; } prop = icalproperty_new_exdate(icaltime); icalcomponent_add_property(exchange2ical->vevent, prop); } } } }