summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koimportoldialog.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/korganizer/koimportoldialog.cpp b/korganizer/koimportoldialog.cpp
index 16f2eca..0a3c2d5 100644
--- a/korganizer/koimportoldialog.cpp
+++ b/korganizer/koimportoldialog.cpp
@@ -250,228 +250,236 @@ void KOImportOLdialog::ol2kopiCalendar( _AppointmentItem * aItem, bool computeRe
250 } 250 }
251 event->setSummary( QString::fromUcs2( aItem->GetSubject().GetBuffer()) ); 251 event->setSummary( QString::fromUcs2( aItem->GetSubject().GetBuffer()) );
252 event->setLocation( QString::fromUcs2( aItem->GetLocation().GetBuffer()) ); 252 event->setLocation( QString::fromUcs2( aItem->GetLocation().GetBuffer()) );
253 event->setDescription( QString::fromUcs2( aItem->GetBody().GetBuffer()) ); 253 event->setDescription( QString::fromUcs2( aItem->GetBody().GetBuffer()) );
254 QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer()); 254 QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer());
255 event->setCategories( QStringList::split( ";", cat )); 255 event->setCategories( QStringList::split( ";", cat ));
256 if ( aItem->GetReminderSet() ) { 256 if ( aItem->GetReminderSet() ) {
257 event->clearAlarms(); 257 event->clearAlarms();
258 Alarm* alarm = event->newAlarm(); 258 Alarm* alarm = event->newAlarm();
259 alarm->setStartOffset( -aItem->GetReminderMinutesBeforeStart()*60 ); 259 alarm->setStartOffset( -aItem->GetReminderMinutesBeforeStart()*60 );
260 alarm->setEnabled( true ); 260 alarm->setEnabled( true );
261 if ( aItem->GetReminderPlaySound() ) { 261 if ( aItem->GetReminderPlaySound() ) {
262 alarm->setType( Alarm::Audio ); 262 alarm->setType( Alarm::Audio );
263 alarm->setAudioFile( QString::fromUcs2( aItem->GetReminderSoundFile().GetBuffer())); 263 alarm->setAudioFile( QString::fromUcs2( aItem->GetReminderSoundFile().GetBuffer()));
264 } 264 }
265 else 265 else
266 alarm->setType( Alarm::Display ); 266 alarm->setType( Alarm::Display );
267 alarm->setRepeatCount( aItem->GetReplyTime() ); 267 alarm->setRepeatCount( aItem->GetReplyTime() );
268 } 268 }
269 // OL :pub 0 - pers 1 - priv 2 - conf 3 269 // OL :pub 0 - pers 1 - priv 2 - conf 3
270 // KO : pub 0 - priv 1 - conf 2 270 // KO : pub 0 - priv 1 - conf 2
271 int sec = aItem->GetSensitivity() ; 271 int sec = aItem->GetSensitivity() ;
272 if ( sec > 1 )// mapping pers -> private 272 if ( sec > 1 )// mapping pers -> private
273 --sec; 273 --sec;
274 event->setSecrecy( sec ); 274 event->setSecrecy( sec );
275 if ( aItem->GetBusyStatus() == 0 ) 275 if ( aItem->GetBusyStatus() == 0 )
276 event->setTransparency( Event::Transparent);// OL free 276 event->setTransparency( Event::Transparent);// OL free
277 else 277 else
278 event->setTransparency( Event::Opaque);//OL all other 278 event->setTransparency( Event::Opaque);//OL all other
279 279
280 if ( aItem->GetIsRecurring() && computeRecurrence ) { //recur 280 if ( aItem->GetIsRecurring() && computeRecurrence ) { //recur
281 281
282 RecurrencePattern recpat = aItem->GetRecurrencePattern(); 282 RecurrencePattern recpat = aItem->GetRecurrencePattern();
283 283
284 QDate startDate = mDdate2Qdtr(recpat.GetPatternStartDate()).date(); 284 QDate startDate = mDdate2Qdtr(recpat.GetPatternStartDate()).date();
285 int freq = recpat.GetInterval(); 285 int freq = recpat.GetInterval();
286 286
287 bool hasEndDate = !recpat.GetNoEndDate(); 287 bool hasEndDate = !recpat.GetNoEndDate();
288 QDate endDate = mDdate2Qdtr(recpat.GetPatternEndDate()).date(); 288 QDate endDate = mDdate2Qdtr(recpat.GetPatternEndDate()).date();
289 QBitArray weekDays( 7 ); 289 QBitArray weekDays( 7 );
290 weekDays.fill(false ); 290 weekDays.fill(false );
291 uint weekDaysNum = recpat.GetDayOfWeekMask(); 291 uint weekDaysNum = recpat.GetDayOfWeekMask();
292 int i; 292 int i;
293 int bb = 2; 293 int bb = 2;
294 for( i = 1; i <= 6; ++i ) { 294 for( i = 1; i <= 6; ++i ) {
295 weekDays.setBit( i - 1, ( bb & weekDaysNum )); 295 weekDays.setBit( i - 1, ( bb & weekDaysNum ));
296 bb = 4 << (i-1); 296 bb = 4 << (i-1);
297 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); 297 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) );
298 } 298 }
299 if ( 1 & weekDaysNum) 299 if ( 1 & weekDaysNum)
300 weekDays.setBit( 6 ); 300 weekDays.setBit( 6 );
301 // int pos = 1;// pending 301 // int pos = 1;// pending
302 302
303 Recurrence *r = event->recurrence(); 303 Recurrence *r = event->recurrence();
304 int rtype = recpat.GetRecurrenceType(); 304 int rtype = recpat.GetRecurrenceType();
305 //recurrence types are: 305 //recurrence types are:
306 /* 306 /*
307 olRecursDaily(0) 307 olRecursDaily(0)
308 olRecursWeekly(1) 308 olRecursWeekly(1)
309 olRecursMonthly(2) 309 olRecursMonthly(2)
310 olRecursMonthNth(3) 310 olRecursMonthNth(3)
311 olRecursYearly(5) 311 olRecursYearly(5)
312 olRecursYearNth(6) 312 olRecursYearNth(6)
313 */ 313 */
314 314
315 int duration = recpat.GetOccurrences(); 315 int duration = recpat.GetOccurrences();
316 if ( !hasEndDate ) 316 if ( !hasEndDate )
317 duration = -1; 317 duration = -1;
318 318
319 //LPDISPATCH RecurrencePattern::GetExceptions() 319 //LPDISPATCH RecurrencePattern::GetExceptions()
320 //long RecurrencePattern::GetMonthOfYear() 320 //long RecurrencePattern::GetMonthOfYear()
321 if ( rtype == 0 ) { 321 if ( rtype == 0 ) {
322 if ( hasEndDate ) r->setDaily( freq, endDate ); 322 if ( hasEndDate ) r->setDaily( freq, endDate );
323 else r->setDaily( freq, duration ); 323 else r->setDaily( freq, duration );
324 } else if ( rtype == 1 ) { 324 } else if ( rtype == 1 ) {
325 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); 325 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate );
326 else r->setWeekly( freq, weekDays, duration ); 326 else r->setWeekly( freq, weekDays, duration );
327 } else if ( rtype == 2 ) { 327 } else if ( rtype == 2 ) {
328 if ( hasEndDate ) 328 if ( hasEndDate )
329 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); 329 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate );
330 else 330 else
331 r->setMonthly( Recurrence::rMonthlyDay, freq, duration ); 331 r->setMonthly( Recurrence::rMonthlyDay, freq, duration );
332 //r->addMonthlyDay( startDate.day() ); 332 //r->addMonthlyDay( startDate.day() );
333 r->addMonthlyDay( recpat.GetDayOfMonth() ); 333 r->addMonthlyDay( recpat.GetDayOfMonth() );
334 } else if ( rtype == 3 ) { 334 } else if ( rtype == 3 ) {
335 if ( hasEndDate ) 335 if ( hasEndDate )
336 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); 336 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
337 else 337 else
338 r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); 338 r->setMonthly( Recurrence::rMonthlyPos, freq, duration );
339 QBitArray days( 7 ); 339 QBitArray days( 7 );
340 days.fill( false ); 340 days.fill( false );
341 days.setBit( startDate.dayOfWeek() - 1 ); 341 days.setBit( startDate.dayOfWeek() - 1 );
342 int pos = (startDate.day()/7)+1; 342 int pos = (startDate.day()/7)+1;
343 r->addMonthlyPos( pos, days ); 343 r->addMonthlyPos( pos, days );
344 //QString mes = i18n("Importing monthlypos.\n\npos: %1 , day: %2").arg( pos).arg( startDate.dayOfWeek() - 1); 344 //QString mes = i18n("Importing monthlypos.\n\npos: %1 , day: %2").arg( pos).arg( startDate.dayOfWeek() - 1);
345 //KMessageBox::information(this,mes); 345 //KMessageBox::information(this,mes);
346 } else if ( rtype == 5 ) { 346 } else if ( rtype == 5 ) {
347 freq = 1; 347 freq = 1;
348 if ( hasEndDate ) 348 if ( hasEndDate )
349 r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); 349 r->setYearly( Recurrence::rYearlyMonth, freq, endDate );
350 else 350 else
351 r->setYearly( Recurrence::rYearlyMonth, freq, duration ); 351 r->setYearly( Recurrence::rYearlyMonth, freq, duration );
352 r->addYearlyNum( startDate.month() ); 352 r->addYearlyNum( startDate.month() );
353 } else if ( true /*rtype == 6*/ ) { 353 } else if ( true /*rtype == 6*/ ) {
354 // KOganizer cannot handle this in the GUI 354 // KOganizer cannot handle this in the GUI
355 // we are mapping this to monthly - every 12. month 355 // we are mapping this to monthly - every 12. month
356 freq = 12; 356 freq = 12;
357 if ( hasEndDate ) 357 if ( hasEndDate )
358 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); 358 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
359 else 359 else
360 r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); 360 r->setMonthly( Recurrence::rMonthlyPos, freq, duration );
361 QBitArray days( 7 ); 361 QBitArray days( 7 );
362 days.fill( false ); 362 days.fill( false );
363 days.setBit( startDate.dayOfWeek() - 1 ); 363 days.setBit( startDate.dayOfWeek() - 1 );
364 int pos = (startDate.day()/7)+1; 364 int pos = (startDate.day()/7)+1;
365 r->addMonthlyPos( pos, days ); 365 r->addMonthlyPos( pos, days );
366 } 366 }
367 // recurrence exceptions 367 // recurrence exceptions
368 LPDISPATCH dispItem = recpat.GetExceptions(); 368 LPDISPATCH dispItem = recpat.GetExceptions();
369 dispItem->AddRef(); 369 dispItem->AddRef();
370 Exceptions ex(dispItem); 370 Exceptions ex(dispItem);
371 _variant_t indx((long)0); 371 _variant_t indx((long)0);
372 LPDISPATCH itm; 372 LPDISPATCH itm;
373 for(i=1; i <= ex.GetCount(); ++i) { 373 for(i=1; i <= ex.GetCount(); ++i) {
374 indx = (long)i; 374 indx = (long)i;
375 itm = ex.Item( indx.Detach() ); 375 itm = ex.Item( indx.Detach() );
376 ::Exception * pItem = (::Exception *)&itm; 376 ::Exception * pItem = (::Exception *)&itm;
377 event->addExDate( QDateTime( mDdate2Qdtr( pItem->GetOriginalDate())).date() ); 377 event->addExDate( QDateTime( mDdate2Qdtr( pItem->GetOriginalDate())).date() );
378 if ( !pItem->GetDeleted() ) { 378 if ( !pItem->GetDeleted() ) {
379 LPDISPATCH appIt = pItem->GetAppointmentItem(); 379 LPDISPATCH appIt = pItem->GetAppointmentItem();
380 _AppointmentItem * paItem = (_AppointmentItem *)&appIt; 380 _AppointmentItem * paItem = (_AppointmentItem *)&appIt;
381 ol2kopiCalendar( paItem, false ); 381 ol2kopiCalendar( paItem, false );
382 } 382 }
383 itm->Release(); 383 itm->Release();
384 } 384 }
385 } 385 }
386 // recurrence ENTE 386 // recurrence ENTE
387 event->setOrganizer( QString::fromUcs2( aItem->GetOrganizer().GetBuffer())); 387 event->setOrganizer( QString::fromUcs2( aItem->GetOrganizer().GetBuffer()));
388 388
389 //GetOptionalAttendees() 389 //GetOptionalAttendees()
390 //GetRequiredAttendees() 390 //GetRequiredAttendees()
391 LPDISPATCH dispItem = aItem->GetRecipients(); 391 LPDISPATCH dispItem = aItem->GetRecipients();
392 dispItem->AddRef(); 392 dispItem->AddRef();
393 _Folders mf(dispItem); 393 _Folders mf(dispItem);
394 mf.m_lpDispatch->AddRef(); 394 mf.m_lpDispatch->AddRef();
395 _variant_t indx((long)0); 395 _variant_t indx((long)0);
396 LPDISPATCH itm; 396 LPDISPATCH itm;
397 int i; 397 int i;
398 QString optAtt = QString::fromUcs2( aItem->GetOptionalAttendees().GetBuffer()); 398 QString optAtt = QString::fromUcs2( aItem->GetOptionalAttendees().GetBuffer());
399 QString reqAtt = QString::fromUcs2( aItem->GetRequiredAttendees().GetBuffer()); 399 QString reqAtt = QString::fromUcs2( aItem->GetRequiredAttendees().GetBuffer());
400 //GetRequiredAttendees() 400 //GetRequiredAttendees()
401 for(i=1; i <= mf.GetCount(); ++i) { 401 for(i=1; i <= mf.GetCount(); ++i) {
402 indx = (long)i; 402 indx = (long)i;
403 itm = mf.Item( indx.Detach() ); 403 itm = mf.Item( indx.Detach() );
404 Recipient * pItem = (Recipient *)&itm; 404 Recipient * pItem = (Recipient *)&itm;
405 405
406 //a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 406 //a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
407 QString name = QString::fromUcs2( pItem->GetName().GetBuffer()); 407 QString name = QString::fromUcs2( pItem->GetName().GetBuffer());
408 KCal::Attendee::PartStat stat; 408 KCal::Attendee::PartStat stat;
409 bool rsvp = false; 409 bool rsvp = false;
410 switch ( pItem->GetMeetingResponseStatus() ) { 410 switch ( pItem->GetMeetingResponseStatus() ) {
411 case 0: //not answered 411 case 0: //not answered
412 rsvp = true; 412 rsvp = true;
413 case 5: //not answered 413 case 5: //not answered
414 stat = Attendee::NeedsAction; 414 stat = Attendee::NeedsAction;
415 break; 415 break;
416 case 1: //organizer 416 case 1: //organizer
417 stat = Attendee::Delegated ; 417 stat = Attendee::Delegated ;
418 break; 418 break;
419 case 2: //tentative 419 case 2: //tentative
420 stat = Attendee::Tentative ; 420 stat = Attendee::Tentative ;
421 break; 421 break;
422 case 3: //accepted 422 case 3: //accepted
423 stat = Attendee::Accepted; 423 stat = Attendee::Accepted;
424 break; 424 break;
425 case 4: //declined 425 case 4: //declined
426 stat =Attendee::Declined ; 426 stat =Attendee::Declined ;
427 break; 427 break;
428 default: 428 default:
429 stat = Attendee::NeedsAction ; 429 stat = Attendee::NeedsAction ;
430 430
431 } 431 }
432 KCal::Attendee::Role role; 432 KCal::Attendee::Role role;
433 if ( event->organizer() == name ) 433 if ( event->organizer() == name )
434 role = KCal::Attendee::Chair; 434 role = KCal::Attendee::Chair;
435 else if ( reqAtt.find( name ) >= 0 ) 435 else if ( reqAtt.find( name ) >= 0 )
436 role = KCal::Attendee::ReqParticipant; 436 role = KCal::Attendee::ReqParticipant;
437 else if ( optAtt.find( name ) >= 0 ) 437 else if ( optAtt.find( name ) >= 0 )
438 role = KCal::Attendee::OptParticipant; 438 role = KCal::Attendee::OptParticipant;
439 else 439 else
440 role = KCal::Attendee::NonParticipant; 440 role = KCal::Attendee::NonParticipant;
441 QString mail = QString::fromUcs2(pItem->GetAddress().GetBuffer()); 441 QString mail = QString::fromUcs2(pItem->GetAddress().GetBuffer());
442 if( mail.isEmpty() && name.find("@") > 0 ) 442 if( mail.isEmpty() && name.find("@") > 0 ) {
443 mail = name; 443 int kl = name.find("<");
444 int gr = name.find(">");
445 if ( kl >= 0 && gr >= 0) {
446 mail = name.mid (kl+1, gr - kl -1);
447 name = name.left( kl );
448 }
449 else
450 mail = name;
451 }
444 mail = mail.stripWhiteSpace(); 452 mail = mail.stripWhiteSpace();
445 453
446 QString uid = getUidByEmail( mail ); 454 QString uid = getUidByEmail( mail );
447 //uid = QString::fromUcs2( pItem->GetEntryID().GetBuffer()); 455 //uid = QString::fromUcs2( pItem->GetEntryID().GetBuffer());
448 KCal::Attendee * a = new KCal::Attendee( name, mail,rsvp,stat,role,uid) ; 456 KCal::Attendee * a = new KCal::Attendee( name, mail,rsvp,stat,role,uid) ;
449 event->addAttendee( a , false ); 457 event->addAttendee( a , false );
450 itm->Release(); 458 itm->Release();
451 } 459 }
452 460
453 461
454 if ( !mCalendar->addEventNoDup( event )) 462 if ( !mCalendar->addEventNoDup( event ))
455 delete event; 463 delete event;
456 else { 464 else {
457 // QString mes = i18n("Importing %1.\n date: %2 date: %3").arg( event->summary()).arg( event->dtStart().toString()).arg( event->dtEnd().toString()); 465 // QString mes = i18n("Importing %1.\n date: %2 date: %3").arg( event->summary()).arg( event->dtStart().toString()).arg( event->dtEnd().toString());
458 //KMessageBox::information(this,mes); 466 //KMessageBox::information(this,mes);
459 ++importedItems; 467 ++importedItems;
460 } 468 }
461} 469}
462void KOImportOLdialog::slotCancel() 470void KOImportOLdialog::slotCancel()
463{ 471{
464 reject(); 472 reject();
465} 473}
466 474
467QString KOImportOLdialog::getUidByEmail( QString email ) 475QString KOImportOLdialog::getUidByEmail( QString email )
468{ 476{
469 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 477 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
470 KABC::AddressBook::Iterator it; 478 KABC::AddressBook::Iterator it;
471 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 479 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
472 QStringList em = (*it).emails(); 480 QStringList em = (*it).emails();
473 if ( em.contains( email )) 481 if ( em.contains( email ))
474 return (*it).uid(); 482 return (*it).uid();
475 } 483 }
476 return ""; 484 return "";
477} 485}