void IncidenceConverter::setRecurrence(KCal::Incidence *incidence, ngwt__CalendarItem *item) { kdDebug() << k_funcinfo << endl; ngwt__Frequency *freq = 0; const KCal::Recurrence *recur = incidence->recurrence(); if(incidence->doesRecur()) { item->rrule = soap_new_ngwt__RecurrenceRule(soap(), -1); item->rrule->frequency = 0; // item->rrule->count = 0; item->rrule->until = 0; // item->rrule->interval = 0; // item->rrule->byDay = 0; item->rrule->byYearDay = 0; item->rrule->byMonthDay = 0; item->rrule->byMonth = 0; freq = (ngwt__Frequency *)soap_malloc(soap(), sizeof(ngwt__Frequency)); // interval if(recur->frequency() > 1) { item->rrule->interval = (unsigned long *)soap_malloc(soap(), sizeof(unsigned long *)); *item->rrule->interval = recur->frequency(); } // end date if(recur->duration() > 0) // number of recurrences. If end date is set we don't use this. { item->rrule->count = (long unsigned int *)soap_malloc(soap(), sizeof(long unsigned int *)); *item->rrule->count = recur->duration(); } #if LIBKCAL_IS_VERSION( 1, 3, 0 ) else if(recur->endDateTime().isValid()) #else else if(recur->endDate().isValid()) #endif item->rrule->until = qDateToString(recur->endDate()); else // GROUPWISE doesn't accept infinite recurrence so end after GW_MAX_RECURRENCES recurrences { item->rrule->count = (long unsigned int *)soap_malloc(soap(), sizeof(long unsigned int *)); *item->rrule->count = GW_MAX_RECURRENCES; } // recurrence date - try setting it using the recurrence start date - didn't help /* std::string startDate; startDate.append( recur->recurStart().date().toString( Qt::ISODate ).utf8() ); item->rdate = soap_new_ngwt__RecurrenceDateType( soap(), -1 ); item->rdate->date.push_back( startDate );*/ // exceptions list - try sending empty list even if no exceptions #if LIBKCAL_IS_VERSION( 1, 3, 0 ) KCal::DateList exceptions = recur->exDates(); #else KCal::DateList exceptions = incidence->exDates(); #endif if(!exceptions.isEmpty()) { item->exdate = soap_new_ngwt__RecurrenceDateType(soap(), -1); for(KCal::DateList::ConstIterator it = exceptions.begin(); it != exceptions.end(); ++it) { std::string startDate; startDate.append((*it).toString(Qt::ISODate).utf8()); item->exdate->date.push_back(startDate); } } }
void IncidenceConverter::setRecurrence( KCal::Incidence * incidence, ngwt__CalendarItem * item ) { kDebug() ; ngwt__Frequency * freq = 0; const KCal::Recurrence * recur = incidence->recurrence(); if ( incidence->recurs() ) { item->rrule = soap_new_ngwt__RecurrenceRule( soap(), -1 ); item->rrule->frequency = 0; // item->rrule->count = 0; item->rrule->until = 0; // item->rrule->interval = 0; // item->rrule->byDay = 0; item->rrule->byYearDay = 0; item->rrule->byMonthDay = 0; item->rrule->byMonth = 0; freq = (ngwt__Frequency *)soap_malloc( soap(), sizeof( ngwt__Frequency ) ); // interval if ( recur->frequency() > 1 ) { item->rrule->interval = (unsigned long *)soap_malloc( soap(), sizeof( unsigned long * ) ); *item->rrule->interval = recur->frequency(); } // end date if ( recur->duration() > 0 ) // number of recurrences. If end date is set we don't use this. { item->rrule->count = (long unsigned int *)soap_malloc( soap(), sizeof( long unsigned int * ) ); *item->rrule->count = recur->duration(); } else if ( recur->endDateTime().isValid() ) item->rrule->until = qDateToString( recur->endDate() ); else // GROUPWISE doesn't accept infinite recurrence so end after GW_MAX_RECURRENCES recurrences { item->rrule->count = (long unsigned int *)soap_malloc( soap(), sizeof( long unsigned int * ) ); *item->rrule->count = GW_MAX_RECURRENCES; } // recurrence date - try setting it using the recurrence start date - didn't help /* std::string startDate; startDate.append( recur->recurStart().date().toString( Qt::ISODate ).toUtf8().data() ); item->rdate = soap_new_ngwt__RecurrenceDateType( soap(), -1 ); item->rdate->date.push_back( startDate );*/ // exceptions list - try sending empty list even if no exceptions KCal::DateList exceptions = recur->exDates(); if ( !exceptions.isEmpty() ) { item->exdate = soap_new_ngwt__RecurrenceDateType( soap(), -1 ); for ( KCal::DateList::ConstIterator it = exceptions.constBegin(); it != exceptions.constEnd(); ++it ) { std::string startDate; startDate.append( (*it).toString( Qt::ISODate ).toUtf8().data() ); item->exdate->date.push_back( startDate ); } } } if ( incidence->recurrenceType() == KCal::Recurrence::rDaily ) { kDebug() <<"incidence recurs daily"; *freq = Daily; item->rrule->frequency = freq; } else if ( incidence->recurrenceType() == KCal::Recurrence::rWeekly ) { kDebug() <<"incidence recurs weekly"; #if 1 //trying out byDay recurrence *freq = Weekly; item->rrule->frequency = freq; // now change the bitArray of the days of the week that it recurs on to a ngwt__DayOfWeekList * QBitArray ba = recur->days(); ngwt__DayOfYearWeekList * weeklyDays = soap_new_ngwt__DayOfYearWeekList( soap(), -1 ); for ( int i = 0; i < 7; ++i ) { if ( ba[i] ) { ngwt__DayOfYearWeek * day = soap_new_ngwt__DayOfYearWeek( soap(), -1 ); day->occurrence = 0; switch( i ) { case 0: day->__item = Monday; break; case 1: day->__item = Tuesday; break; case 2: day->__item = Wednesday; break; case 3: day->__item = Thursday; break; case 4: day->__item = Friday; break; case 5: day->__item = Saturday; break; case 6: day->__item = Sunday; break; } weeklyDays->day.push_back( day ); } } // add the list of days to the recurrence rule item->rrule->byDay = weeklyDays; #endif } else if ( incidence->recurrenceType() == KCal::Recurrence::rMonthlyDay ) { kDebug() <<"incidence recurs monthly"; ; *freq = Monthly; item->rrule->frequency = freq; // TODO: translate '3rd wednesday of month' etc into rdates } else if ( incidence->recurrenceType() == KCal::Recurrence::rYearlyDay ) { kDebug() <<"incidence recurs yearly on day #"; *freq = Yearly; item->rrule->frequency = freq; // TODO: translate '1st sunday in may' ngwt__DayOfYearList * daysOfYear = soap_new_ngwt__DayOfYearList( soap(), -1 ); QList<int> rmd; rmd = recur->yearMonths(); daysOfYear->day.push_back( rmd.first() ); item->rrule->byYearDay = daysOfYear; // no need to do MonthList recurrence as these will appear as separate instances when fetched from GW } else if ( incidence->recurrenceType() == KCal::Recurrence::rYearlyMonth ) { kDebug() <<"incidence recurs yearly on monthday"; *freq = Yearly; item->rrule->frequency = freq; } }