summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp19
1 files changed, 3 insertions, 16 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index ff1db2c..290c0b9 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -333,1088 +333,1075 @@ void CalendarView::init()
333 if ( KOPrefs::instance()->mVerticalScreen ) { 333 if ( KOPrefs::instance()->mVerticalScreen ) {
334 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 334 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
335 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 335 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
336 } else { 336 } else {
337 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 337 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
338 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 338 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
339 } 339 }
340 340
341 //qDebug("Calendarview Size %d %d ", width(), height()); 341 //qDebug("Calendarview Size %d %d ", width(), height());
342#endif 342#endif
343 343
344 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 344 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
345 SLOT( showDates( const KCal::DateList & ) ) ); 345 SLOT( showDates( const KCal::DateList & ) ) );
346 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 346 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
347 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 347 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
348 348
349 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 349 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
350 mNavigator, SLOT( selectPreviousYear() ) ); 350 mNavigator, SLOT( selectPreviousYear() ) );
351 connect( mNavigatorBar, SIGNAL( goNextYear() ), 351 connect( mNavigatorBar, SIGNAL( goNextYear() ),
352 mNavigator, SLOT( selectNextYear() ) ); 352 mNavigator, SLOT( selectNextYear() ) );
353 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 353 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
354 mNavigator, SLOT( selectPreviousMonth() ) ); 354 mNavigator, SLOT( selectPreviousMonth() ) );
355 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 355 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
356 mNavigator, SLOT( selectNextMonth() ) ); 356 mNavigator, SLOT( selectNextMonth() ) );
357 357
358 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 358 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
359 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 359 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
360 360
361 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 361 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
362 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 362 mNavigator, SLOT( selectWeek( const QDate & ) ) );
363 363
364 connect( mDateNavigator, SIGNAL( goPrevYear() ), 364 connect( mDateNavigator, SIGNAL( goPrevYear() ),
365 mNavigator, SLOT( selectPreviousYear() ) ); 365 mNavigator, SLOT( selectPreviousYear() ) );
366 connect( mDateNavigator, SIGNAL( goNextYear() ), 366 connect( mDateNavigator, SIGNAL( goNextYear() ),
367 mNavigator, SLOT( selectNextYear() ) ); 367 mNavigator, SLOT( selectNextYear() ) );
368 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 368 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
369 mNavigator, SLOT( selectPreviousMonth() ) ); 369 mNavigator, SLOT( selectPreviousMonth() ) );
370 connect( mDateNavigator, SIGNAL( goNextMonth() ), 370 connect( mDateNavigator, SIGNAL( goNextMonth() ),
371 mNavigator, SLOT( selectNextMonth() ) ); 371 mNavigator, SLOT( selectNextMonth() ) );
372 372
373 connect( mDateNavigator, SIGNAL( goPrevious() ), 373 connect( mDateNavigator, SIGNAL( goPrevious() ),
374 mNavigator, SLOT( selectPrevious() ) ); 374 mNavigator, SLOT( selectPrevious() ) );
375 connect( mDateNavigator, SIGNAL( goNext() ), 375 connect( mDateNavigator, SIGNAL( goNext() ),
376 mNavigator, SLOT( selectNext() ) ); 376 mNavigator, SLOT( selectNext() ) );
377 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 377 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
378 mNavigator, SLOT( slotMonthSelect( int ) ) ); 378 mNavigator, SLOT( slotMonthSelect( int ) ) );
379 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 379 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
380 mNavigator, SLOT( slotMonthSelect( int ) ) ); 380 mNavigator, SLOT( slotMonthSelect( int ) ) );
381 381
382 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 382 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
383 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 383 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
384 384
385 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 385 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
386 SLOT( eventAdded( Event *) ) ); 386 SLOT( eventAdded( Event *) ) );
387 387
388 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 388 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
389 389
390 connect( this, SIGNAL( configChanged() ), 390 connect( this, SIGNAL( configChanged() ),
391 mDateNavigator, SLOT( updateConfig() ) ); 391 mDateNavigator, SLOT( updateConfig() ) );
392 392
393 connect( mTodoList, SIGNAL( newTodoSignal() ), 393 connect( mTodoList, SIGNAL( newTodoSignal() ),
394 SLOT( newTodo() ) ); 394 SLOT( newTodo() ) );
395 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 395 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
396 SLOT( newSubTodo( Todo * ) ) ); 396 SLOT( newSubTodo( Todo * ) ) );
397 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 397 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
398 SLOT( editTodo( Todo * ) ) ); 398 SLOT( editTodo( Todo * ) ) );
399 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 399 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
400 SLOT( showTodo( Todo *) ) ); 400 SLOT( showTodo( Todo *) ) );
401 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 401 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
402 SLOT( deleteTodo( Todo *) ) ); 402 SLOT( deleteTodo( Todo *) ) );
403 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 403 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
404 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 404 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
405 SLOT( purgeCompleted() ) ); 405 SLOT( purgeCompleted() ) );
406 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 406 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
407 SIGNAL( todoModified( Todo *, int ) ) ); 407 SIGNAL( todoModified( Todo *, int ) ) );
408 408
409 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 409 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
410 this, SLOT ( cloneIncidence( Incidence * ) ) ); 410 this, SLOT ( cloneIncidence( Incidence * ) ) );
411 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 411 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
412 this, SLOT (cancelIncidence( Incidence * ) ) ); 412 this, SLOT (cancelIncidence( Incidence * ) ) );
413 413
414 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 414 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
415 this, SLOT ( moveIncidence( Incidence * ) ) ); 415 this, SLOT ( moveIncidence( Incidence * ) ) );
416 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 416 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
417 this, SLOT ( beamIncidence( Incidence * ) ) ); 417 this, SLOT ( beamIncidence( Incidence * ) ) );
418 418
419 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 419 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
420 this, SLOT ( todo_unsub( Todo * ) ) ); 420 this, SLOT ( todo_unsub( Todo * ) ) );
421 421
422 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 422 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
423 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 423 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
424 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 424 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
425 SLOT( updateTodo( Todo *, int ) ) ); 425 SLOT( updateTodo( Todo *, int ) ) );
426 connect( this, SIGNAL( todoModified( Todo *, int )), this, 426 connect( this, SIGNAL( todoModified( Todo *, int )), this,
427 SLOT( changeTodoDisplay( Todo *, int ) ) ); 427 SLOT( changeTodoDisplay( Todo *, int ) ) );
428 428
429 429
430 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 430 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
431 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 431 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
432 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 432 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
433 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 433 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
434 434
435 435
436 436
437 437
438 438
439 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 439 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
440 SLOT(checkClipboard())); 440 SLOT(checkClipboard()));
441 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 441 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
442 SLOT( processTodoListSelection( Incidence * ) ) ); 442 SLOT( processTodoListSelection( Incidence * ) ) );
443 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 443 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
444 444
445 // kdDebug() << "CalendarView::CalendarView() done" << endl; 445 // kdDebug() << "CalendarView::CalendarView() done" << endl;
446 446
447 mDateFrame = new QVBox(0,0,WType_Popup); 447 mDateFrame = new QVBox(0,0,WType_Popup);
448 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 448 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
449 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 449 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
450 mDateFrame->setLineWidth(3); 450 mDateFrame->setLineWidth(3);
451 mDateFrame->hide(); 451 mDateFrame->hide();
452 mDateFrame->setCaption( i18n( "Pick a date to display")); 452 mDateFrame->setCaption( i18n( "Pick a date to display"));
453 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 453 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
454 454
455 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 455 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
456 456
457 mEventEditor = mDialogManager->getEventEditor(); 457 mEventEditor = mDialogManager->getEventEditor();
458 mTodoEditor = mDialogManager->getTodoEditor(); 458 mTodoEditor = mDialogManager->getTodoEditor();
459 459
460 mFlagEditDescription = false; 460 mFlagEditDescription = false;
461 461
462 mSuspendTimer = new QTimer( this ); 462 mSuspendTimer = new QTimer( this );
463 mAlarmTimer = new QTimer( this ); 463 mAlarmTimer = new QTimer( this );
464 mRecheckAlarmTimer = new QTimer( this ); 464 mRecheckAlarmTimer = new QTimer( this );
465 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 465 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
466 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 466 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
467 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 467 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
468 mAlarmDialog = new AlarmDialog( this ); 468 mAlarmDialog = new AlarmDialog( this );
469 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 469 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
470 mAlarmDialog->setServerNotification( false ); 470 mAlarmDialog->setServerNotification( false );
471 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 471 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
472 472
473 473
474#ifndef DESKTOP_VERSION 474#ifndef DESKTOP_VERSION
475//US listen for arriving address resultsets 475//US listen for arriving address resultsets
476 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 476 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
477 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 477 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
478#endif 478#endif
479 479
480} 480}
481 481
482 482
483CalendarView::~CalendarView() 483CalendarView::~CalendarView()
484{ 484{
485 // kdDebug() << "~CalendarView()" << endl; 485 // kdDebug() << "~CalendarView()" << endl;
486 //qDebug("CalendarView::~CalendarView() "); 486 //qDebug("CalendarView::~CalendarView() ");
487 delete mDialogManager; 487 delete mDialogManager;
488 delete mViewManager; 488 delete mViewManager;
489 delete mStorage; 489 delete mStorage;
490 delete mDateFrame ; 490 delete mDateFrame ;
491 delete beamDialog; 491 delete beamDialog;
492 //kdDebug() << "~CalendarView() done" << endl; 492 //kdDebug() << "~CalendarView() done" << endl;
493} 493}
494void CalendarView::timerAlarm() 494void CalendarView::timerAlarm()
495{ 495{
496 //qDebug("CalendarView::timerAlarm() "); 496 //qDebug("CalendarView::timerAlarm() ");
497 computeAlarm(mAlarmNotification ); 497 computeAlarm(mAlarmNotification );
498} 498}
499 499
500void CalendarView::suspendAlarm() 500void CalendarView::suspendAlarm()
501{ 501{
502 //qDebug(" CalendarView::suspendAlarm() "); 502 //qDebug(" CalendarView::suspendAlarm() ");
503 computeAlarm(mSuspendAlarmNotification ); 503 computeAlarm(mSuspendAlarmNotification );
504 504
505} 505}
506 506
507void CalendarView::startAlarm( QString mess , QString filename) 507void CalendarView::startAlarm( QString mess , QString filename)
508{ 508{
509 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 509 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
510 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 510 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
511 511
512} 512}
513 513
514void CalendarView::checkNextTimerAlarm() 514void CalendarView::checkNextTimerAlarm()
515{ 515{
516 mCalendar->checkAlarmForIncidence( 0, true ); 516 mCalendar->checkAlarmForIncidence( 0, true );
517} 517}
518 518
519void CalendarView::computeAlarm( QString msg ) 519void CalendarView::computeAlarm( QString msg )
520{ 520{
521 521
522 QString mess = msg; 522 QString mess = msg;
523 QString mAlarmMessage = mess.mid( 9 ); 523 QString mAlarmMessage = mess.mid( 9 );
524 QString filename = MainWindow::resourcePath(); 524 QString filename = MainWindow::resourcePath();
525 filename += "koalarm.wav"; 525 filename += "koalarm.wav";
526 QString tempfilename; 526 QString tempfilename;
527 if ( mess.left( 13 ) == "suspend_alarm") { 527 if ( mess.left( 13 ) == "suspend_alarm") {
528 bool error = false; 528 bool error = false;
529 int len = mess.mid( 13 ).find("+++"); 529 int len = mess.mid( 13 ).find("+++");
530 if ( len < 2 ) 530 if ( len < 2 )
531 error = true; 531 error = true;
532 else { 532 else {
533 tempfilename = mess.mid( 13, len ); 533 tempfilename = mess.mid( 13, len );
534 if ( !QFile::exists( tempfilename ) ) 534 if ( !QFile::exists( tempfilename ) )
535 error = true; 535 error = true;
536 } 536 }
537 if ( ! error ) { 537 if ( ! error ) {
538 filename = tempfilename; 538 filename = tempfilename;
539 } 539 }
540 mAlarmMessage = mess.mid( 13+len+3 ); 540 mAlarmMessage = mess.mid( 13+len+3 );
541 //qDebug("suspend file %s ",tempfilename.latin1() ); 541 //qDebug("suspend file %s ",tempfilename.latin1() );
542 startAlarm( mAlarmMessage, filename); 542 startAlarm( mAlarmMessage, filename);
543 return; 543 return;
544 } 544 }
545 if ( mess.left( 11 ) == "timer_alarm") { 545 if ( mess.left( 11 ) == "timer_alarm") {
546 //mTimerTime = 0; 546 //mTimerTime = 0;
547 startAlarm( mess.mid( 11 ), filename ); 547 startAlarm( mess.mid( 11 ), filename );
548 return; 548 return;
549 } 549 }
550 if ( mess.left( 10 ) == "proc_alarm") { 550 if ( mess.left( 10 ) == "proc_alarm") {
551 bool error = false; 551 bool error = false;
552 int len = mess.mid( 10 ).find("+++"); 552 int len = mess.mid( 10 ).find("+++");
553 if ( len < 2 ) 553 if ( len < 2 )
554 error = true; 554 error = true;
555 else { 555 else {
556 tempfilename = mess.mid( 10, len ); 556 tempfilename = mess.mid( 10, len );
557 if ( !QFile::exists( tempfilename ) ) 557 if ( !QFile::exists( tempfilename ) )
558 error = true; 558 error = true;
559 } 559 }
560 if ( error ) { 560 if ( error ) {
561 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 561 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
562 mAlarmMessage += mess.mid( 10+len+3+9 ); 562 mAlarmMessage += mess.mid( 10+len+3+9 );
563 } else { 563 } else {
564 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 564 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
565 //qDebug("-----system command %s ",tempfilename.latin1() ); 565 //qDebug("-----system command %s ",tempfilename.latin1() );
566#ifndef _WIN32_ 566#ifndef _WIN32_
567 if ( vfork () == 0 ) { 567 if ( vfork () == 0 ) {
568 execl ( tempfilename.latin1(), 0 ); 568 execl ( tempfilename.latin1(), 0 );
569 return; 569 return;
570 } 570 }
571#else 571#else
572 QProcess* p = new QProcess(); 572 QProcess* p = new QProcess();
573 p->addArgument( tempfilename.latin1() ); 573 p->addArgument( tempfilename.latin1() );
574 p->start(); 574 p->start();
575 return; 575 return;
576#endif 576#endif
577 577
578 return; 578 return;
579 } 579 }
580 580
581 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 581 //qDebug("+++++++system command %s ",tempfilename.latin1() );
582 } 582 }
583 if ( mess.left( 11 ) == "audio_alarm") { 583 if ( mess.left( 11 ) == "audio_alarm") {
584 bool error = false; 584 bool error = false;
585 int len = mess.mid( 11 ).find("+++"); 585 int len = mess.mid( 11 ).find("+++");
586 if ( len < 2 ) 586 if ( len < 2 )
587 error = true; 587 error = true;
588 else { 588 else {
589 tempfilename = mess.mid( 11, len ); 589 tempfilename = mess.mid( 11, len );
590 if ( !QFile::exists( tempfilename ) ) 590 if ( !QFile::exists( tempfilename ) )
591 error = true; 591 error = true;
592 } 592 }
593 if ( ! error ) { 593 if ( ! error ) {
594 filename = tempfilename; 594 filename = tempfilename;
595 } 595 }
596 mAlarmMessage = mess.mid( 11+len+3+9 ); 596 mAlarmMessage = mess.mid( 11+len+3+9 );
597 //qDebug("audio file command %s ",tempfilename.latin1() ); 597 //qDebug("audio file command %s ",tempfilename.latin1() );
598 } 598 }
599 if ( mess.left( 9 ) == "cal_alarm") { 599 if ( mess.left( 9 ) == "cal_alarm") {
600 mAlarmMessage = mess.mid( 9 ) ; 600 mAlarmMessage = mess.mid( 9 ) ;
601 } 601 }
602 602
603 startAlarm( mAlarmMessage, filename ); 603 startAlarm( mAlarmMessage, filename );
604 604
605 605
606} 606}
607 607
608void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 608void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
609{ 609{
610 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 610 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
611 611
612 mSuspendAlarmNotification = noti; 612 mSuspendAlarmNotification = noti;
613 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 613 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
614 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 614 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
615 mSuspendTimer->start( ms , true ); 615 mSuspendTimer->start( ms , true );
616 616
617} 617}
618 618
619void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 619void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
620{ 620{
621 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 621 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
622 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 622 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
623#ifndef DESKTOP_VERSION 623#ifndef DESKTOP_VERSION
624 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 624 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
625#endif 625#endif
626 return; 626 return;
627 } 627 }
628 int maxSec; 628 int maxSec;
629 //maxSec = 5; //testing only 629 //maxSec = 5; //testing only
630 maxSec = 86400+3600; // one day+1hour 630 maxSec = 86400+3600; // one day+1hour
631 mAlarmNotification = noti; 631 mAlarmNotification = noti;
632 int sec = QDateTime::currentDateTime().secsTo( qdt ); 632 int sec = QDateTime::currentDateTime().secsTo( qdt );
633 if ( sec > maxSec ) { 633 if ( sec > maxSec ) {
634 mRecheckAlarmTimer->start( maxSec * 1000 ); 634 mRecheckAlarmTimer->start( maxSec * 1000 );
635 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 635 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
636 return; 636 return;
637 } else { 637 } else {
638 mRecheckAlarmTimer->stop(); 638 mRecheckAlarmTimer->stop();
639 } 639 }
640 //qDebug("Alarm timer started with secs: %d ", sec); 640 //qDebug("Alarm timer started with secs: %d ", sec);
641 mAlarmTimer->start( sec *1000 , true ); 641 mAlarmTimer->start( sec *1000 , true );
642 642
643} 643}
644// called by mRecheckAlarmTimer to get next alarm 644// called by mRecheckAlarmTimer to get next alarm
645// we need this, because a QTimer has only a max range of 25 days 645// we need this, because a QTimer has only a max range of 25 days
646void CalendarView::recheckTimerAlarm() 646void CalendarView::recheckTimerAlarm()
647{ 647{
648 mAlarmTimer->stop(); 648 mAlarmTimer->stop();
649 mRecheckAlarmTimer->stop(); 649 mRecheckAlarmTimer->stop();
650 mCalendar->checkAlarmForIncidence( 0, true ); 650 mCalendar->checkAlarmForIncidence( 0, true );
651} 651}
652void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 652void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
653{ 653{
654 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 654 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
655 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 655 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
656#ifndef DESKTOP_VERSION 656#ifndef DESKTOP_VERSION
657 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 657 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
658#endif 658#endif
659 return; 659 return;
660 } 660 }
661 mAlarmTimer->stop(); 661 mAlarmTimer->stop();
662} 662}
663void CalendarView::selectWeekNum ( int num ) 663void CalendarView::selectWeekNum ( int num )
664{ 664{
665 dateNavigator()->selectWeek( num ); 665 dateNavigator()->selectWeek( num );
666 mViewManager->showWeekView(); 666 mViewManager->showWeekView();
667} 667}
668KOViewManager *CalendarView::viewManager() 668KOViewManager *CalendarView::viewManager()
669{ 669{
670 return mViewManager; 670 return mViewManager;
671} 671}
672 672
673KODialogManager *CalendarView::dialogManager() 673KODialogManager *CalendarView::dialogManager()
674{ 674{
675 return mDialogManager; 675 return mDialogManager;
676} 676}
677 677
678QDate CalendarView::startDate() 678QDate CalendarView::startDate()
679{ 679{
680 DateList dates = mNavigator->selectedDates(); 680 DateList dates = mNavigator->selectedDates();
681 681
682 return dates.first(); 682 return dates.first();
683} 683}
684 684
685QDate CalendarView::endDate() 685QDate CalendarView::endDate()
686{ 686{
687 DateList dates = mNavigator->selectedDates(); 687 DateList dates = mNavigator->selectedDates();
688 688
689 return dates.last(); 689 return dates.last();
690} 690}
691 691
692 692
693void CalendarView::createPrinter() 693void CalendarView::createPrinter()
694{ 694{
695#ifndef KORG_NOPRINTER 695#ifndef KORG_NOPRINTER
696 if (!mCalPrinter) { 696 if (!mCalPrinter) {
697 mCalPrinter = new CalPrinter(this, mCalendar); 697 mCalPrinter = new CalPrinter(this, mCalendar);
698 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 698 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
699 } 699 }
700#endif 700#endif
701} 701}
702 702
703 703
704//KOPrefs::instance()->mWriteBackFile 704//KOPrefs::instance()->mWriteBackFile
705//KOPrefs::instance()->mWriteBackExistingOnly 705//KOPrefs::instance()->mWriteBackExistingOnly
706 706
707// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 707// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
708// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 708// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
709// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 709// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
710// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 710// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
711// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 711// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
712// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 712// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
713 713
714int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 714int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
715{ 715{
716 716
717 //void setZaurusId(int id);
718 // int zaurusId() const;
719 // void setZaurusUid(int id);
720 // int zaurusUid() const;
721 // void setZaurusStat(int id);
722 // int zaurusStat() const;
723 // 0 equal 717 // 0 equal
724 // 1 take local 718 // 1 take local
725 // 2 take remote 719 // 2 take remote
726 // 3 cancel 720 // 3 cancel
727 QDateTime lastSync = mLastCalendarSync; 721 QDateTime lastSync = mLastCalendarSync;
728 QDateTime localMod = local->lastModified(); 722 QDateTime localMod = local->lastModified();
729 QDateTime remoteMod = remote->lastModified(); 723 QDateTime remoteMod = remote->lastModified();
730 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 724 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
731 bool remCh, locCh; 725 bool remCh, locCh;
732 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 726 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
733 //if ( remCh ) 727 //if ( remCh )
734 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 728 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
735 locCh = ( localMod > mLastCalendarSync ); 729 locCh = ( localMod > mLastCalendarSync );
736 if ( !remCh && ! locCh ) { 730 if ( !remCh && ! locCh ) {
737 //qDebug("both not changed "); 731 //qDebug("both not changed ");
738 lastSync = localMod.addDays(1); 732 lastSync = localMod.addDays(1);
739 if ( mode <= SYNC_PREF_ASK ) 733 if ( mode <= SYNC_PREF_ASK )
740 return 0; 734 return 0;
741 } else { 735 } else {
742 if ( locCh ) { 736 if ( locCh ) {
743 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 737 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
744 lastSync = localMod.addDays( -1 ); 738 lastSync = localMod.addDays( -1 );
745 if ( !remCh ) 739 if ( !remCh )
746 remoteMod = ( lastSync.addDays( -1 ) ); 740 remoteMod = ( lastSync.addDays( -1 ) );
747 } else { 741 } else {
748 //qDebug(" not loc changed "); 742 //qDebug(" not loc changed ");
749 lastSync = localMod.addDays( 1 ); 743 lastSync = localMod.addDays( 1 );
750 if ( remCh ) 744 if ( remCh )
751 remoteMod =( lastSync.addDays( 1 ) ); 745 remoteMod =( lastSync.addDays( 1 ) );
752 746
753 } 747 }
754 } 748 }
755 full = true; 749 full = true;
756 if ( mode < SYNC_PREF_ASK ) 750 if ( mode < SYNC_PREF_ASK )
757 mode = SYNC_PREF_ASK; 751 mode = SYNC_PREF_ASK;
758 } else { 752 } else {
759 if ( localMod == remoteMod ) 753 if ( localMod == remoteMod )
760 // if ( local->revision() == remote->revision() ) 754 // if ( local->revision() == remote->revision() )
761 return 0; 755 return 0;
762 756
763 } 757 }
764 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 758 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
765 759
766 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 760 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
767 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 761 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
768 //full = true; //debug only 762 //full = true; //debug only
769 if ( full ) { 763 if ( full ) {
770 bool equ = false; 764 bool equ = false;
771 if ( local->type() == "Event" ) { 765 if ( local->type() == "Event" ) {
772 equ = (*((Event*) local) == *((Event*) remote)); 766 equ = (*((Event*) local) == *((Event*) remote));
773 } 767 }
774 else if ( local->type() =="Todo" ) 768 else if ( local->type() =="Todo" )
775 equ = (*((Todo*) local) == (*(Todo*) remote)); 769 equ = (*((Todo*) local) == (*(Todo*) remote));
776 else if ( local->type() =="Journal" ) 770 else if ( local->type() =="Journal" )
777 equ = (*((Journal*) local) == *((Journal*) remote)); 771 equ = (*((Journal*) local) == *((Journal*) remote));
778 if ( equ ) { 772 if ( equ ) {
779 //qDebug("equal "); 773 //qDebug("equal ");
780 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 774 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
781 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 775 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
782 } 776 }
783 if ( mode < SYNC_PREF_FORCE_LOCAL ) 777 if ( mode < SYNC_PREF_FORCE_LOCAL )
784 return 0; 778 return 0;
785 779
786 }//else //debug only 780 }//else //debug only
787 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 781 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
788 } 782 }
789 int result; 783 int result;
790 bool localIsNew; 784 bool localIsNew;
791 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 785 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
792 786
793 if ( full && mode < SYNC_PREF_NEWEST ) 787 if ( full && mode < SYNC_PREF_NEWEST )
794 mode = SYNC_PREF_ASK; 788 mode = SYNC_PREF_ASK;
795 789
796 switch( mode ) { 790 switch( mode ) {
797 case SYNC_PREF_LOCAL: 791 case SYNC_PREF_LOCAL:
798 if ( lastSync > remoteMod ) 792 if ( lastSync > remoteMod )
799 return 1; 793 return 1;
800 if ( lastSync > localMod ) 794 if ( lastSync > localMod )
801 return 2; 795 return 2;
802 return 1; 796 return 1;
803 break; 797 break;
804 case SYNC_PREF_REMOTE: 798 case SYNC_PREF_REMOTE:
805 if ( lastSync > remoteMod ) 799 if ( lastSync > remoteMod )
806 return 1; 800 return 1;
807 if ( lastSync > localMod ) 801 if ( lastSync > localMod )
808 return 2; 802 return 2;
809 return 2; 803 return 2;
810 break; 804 break;
811 case SYNC_PREF_NEWEST: 805 case SYNC_PREF_NEWEST:
812 if ( localMod > remoteMod ) 806 if ( localMod > remoteMod )
813 return 1; 807 return 1;
814 else 808 else
815 return 2; 809 return 2;
816 break; 810 break;
817 case SYNC_PREF_ASK: 811 case SYNC_PREF_ASK:
818 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 812 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
819 if ( lastSync > remoteMod ) 813 if ( lastSync > remoteMod )
820 return 1; 814 return 1;
821 if ( lastSync > localMod ) 815 if ( lastSync > localMod )
822 return 2; 816 return 2;
823 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 817 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
824 localIsNew = localMod >= remoteMod; 818 localIsNew = localMod >= remoteMod;
825 if ( localIsNew ) 819 if ( localIsNew )
826 getEventViewerDialog()->setColorMode( 1 ); 820 getEventViewerDialog()->setColorMode( 1 );
827 else 821 else
828 getEventViewerDialog()->setColorMode( 2 ); 822 getEventViewerDialog()->setColorMode( 2 );
829 getEventViewerDialog()->setIncidence(local); 823 getEventViewerDialog()->setIncidence(local);
830 if ( localIsNew ) 824 if ( localIsNew )
831 getEventViewerDialog()->setColorMode( 2 ); 825 getEventViewerDialog()->setColorMode( 2 );
832 else 826 else
833 getEventViewerDialog()->setColorMode( 1 ); 827 getEventViewerDialog()->setColorMode( 1 );
834 getEventViewerDialog()->addIncidence(remote); 828 getEventViewerDialog()->addIncidence(remote);
835 getEventViewerDialog()->setColorMode( 0 ); 829 getEventViewerDialog()->setColorMode( 0 );
836 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 830 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
837 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 831 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
838 getEventViewerDialog()->showMe(); 832 getEventViewerDialog()->showMe();
839 result = getEventViewerDialog()->executeS( localIsNew ); 833 result = getEventViewerDialog()->executeS( localIsNew );
840 return result; 834 return result;
841 835
842 break; 836 break;
843 case SYNC_PREF_FORCE_LOCAL: 837 case SYNC_PREF_FORCE_LOCAL:
844 return 1; 838 return 1;
845 break; 839 break;
846 case SYNC_PREF_FORCE_REMOTE: 840 case SYNC_PREF_FORCE_REMOTE:
847 return 2; 841 return 2;
848 break; 842 break;
849 843
850 default: 844 default:
851 // SYNC_PREF_TAKE_BOTH not implemented 845 // SYNC_PREF_TAKE_BOTH not implemented
852 break; 846 break;
853 } 847 }
854 return 0; 848 return 0;
855} 849}
856Event* CalendarView::getLastSyncEvent() 850Event* CalendarView::getLastSyncEvent()
857{ 851{
858 Event* lse; 852 Event* lse;
859 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 853 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
860 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 854 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
861 if (!lse) { 855 if (!lse) {
862 lse = new Event(); 856 lse = new Event();
863 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 857 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
864 QString sum = ""; 858 QString sum = "";
865 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 859 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
866 sum = "E: "; 860 sum = "E: ";
867 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 861 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
868 lse->setDtStart( mLastCalendarSync ); 862 lse->setDtStart( mLastCalendarSync );
869 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 863 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
870 lse->setCategories( i18n("SyncEvent") ); 864 lse->setCategories( i18n("SyncEvent") );
871 lse->setReadOnly( true ); 865 lse->setReadOnly( true );
872 mCalendar->addEvent( lse ); 866 mCalendar->addEvent( lse );
873 } 867 }
874 868
875 return lse; 869 return lse;
876 870
877} 871}
878 872
879// we check, if the to delete event has a id for a profile 873// we check, if the to delete event has a id for a profile
880// if yes, we set this id in the profile to delete 874// if yes, we set this id in the profile to delete
881void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 875void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
882{ 876{
883 if ( lastSync.count() == 0 ) { 877 if ( lastSync.count() == 0 ) {
884 //qDebug(" lastSync.count() == 0"); 878 //qDebug(" lastSync.count() == 0");
885 return; 879 return;
886 } 880 }
887 if ( toDelete->type() == "Journal" ) 881 if ( toDelete->type() == "Journal" )
888 return; 882 return;
889 883
890 Event* eve = lastSync.first(); 884 Event* eve = lastSync.first();
891 885
892 while ( eve ) { 886 while ( eve ) {
893 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 887 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
894 if ( !id.isEmpty() ) { 888 if ( !id.isEmpty() ) {
895 QString des = eve->description(); 889 QString des = eve->description();
896 QString pref = "e"; 890 QString pref = "e";
897 if ( toDelete->type() == "Todo" ) 891 if ( toDelete->type() == "Todo" )
898 pref = "t"; 892 pref = "t";
899 des += pref+ id + ","; 893 des += pref+ id + ",";
900 eve->setReadOnly( false ); 894 eve->setReadOnly( false );
901 eve->setDescription( des ); 895 eve->setDescription( des );
902 //qDebug("setdes %s ", des.latin1()); 896 //qDebug("setdes %s ", des.latin1());
903 eve->setReadOnly( true ); 897 eve->setReadOnly( true );
904 } 898 }
905 eve = lastSync.next(); 899 eve = lastSync.next();
906 } 900 }
907 901
908} 902}
909void CalendarView::checkExternalId( Incidence * inc ) 903void CalendarView::checkExternalId( Incidence * inc )
910{ 904{
911 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 905 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
912 checkExternSyncEvent( lastSync, inc ); 906 checkExternSyncEvent( lastSync, inc );
913 907
914} 908}
915bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 909bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
916{ 910{
917 bool syncOK = true; 911 bool syncOK = true;
918 int addedEvent = 0; 912 int addedEvent = 0;
919 int addedEventR = 0; 913 int addedEventR = 0;
920 int deletedEventR = 0; 914 int deletedEventR = 0;
921 int deletedEventL = 0; 915 int deletedEventL = 0;
922 int changedLocal = 0; 916 int changedLocal = 0;
923 int changedRemote = 0; 917 int changedRemote = 0;
924 //QPtrList<Event> el = local->rawEvents(); 918 //QPtrList<Event> el = local->rawEvents();
925 Event* eventR; 919 Event* eventR;
926 QString uid; 920 QString uid;
927 int take; 921 int take;
928 Event* eventL; 922 Event* eventL;
929 Event* eventRSync; 923 Event* eventRSync;
930 Event* eventLSync; 924 Event* eventLSync;
931 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 925 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
932 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 926 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
933 bool fullDateRange = false; 927 bool fullDateRange = false;
934 local->resetTempSyncStat(); 928 local->resetTempSyncStat();
935 if ( mSyncKDE ) 929 if ( mSyncKDE )
936 remote->resetPilotStat(1); 930 remote->resetPilotStat(1);
937 mLastCalendarSync = QDateTime::currentDateTime(); 931 mLastCalendarSync = QDateTime::currentDateTime();
938 QDateTime modifiedCalendar = mLastCalendarSync;; 932 QDateTime modifiedCalendar = mLastCalendarSync;;
939 eventLSync = getLastSyncEvent(); 933 eventLSync = getLastSyncEvent();
940 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 934 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
941 if ( eventR ) { 935 if ( eventR ) {
942 eventRSync = (Event*) eventR->clone(); 936 eventRSync = (Event*) eventR->clone();
943 remote->deleteEvent(eventR ); 937 remote->deleteEvent(eventR );
944 938
945 } else { 939 } else {
946 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 940 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncKDE) {
947 eventRSync = (Event*)eventLSync->clone(); 941 eventRSync = (Event*)eventLSync->clone();
948 } else { 942 } else {
949 fullDateRange = true; 943 fullDateRange = true;
950 eventRSync = new Event(); 944 eventRSync = new Event();
951 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 945 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
952 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 946 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
953 eventRSync->setDtStart( mLastCalendarSync ); 947 eventRSync->setDtStart( mLastCalendarSync );
954 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 948 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
955 eventRSync->setCategories( i18n("SyncEvent") ); 949 eventRSync->setCategories( i18n("SyncEvent") );
956 } 950 }
957 } 951 }
958 if ( eventLSync->dtStart() == mLastCalendarSync ) 952 if ( eventLSync->dtStart() == mLastCalendarSync )
959 fullDateRange = true; 953 fullDateRange = true;
960 954
961 if ( ! fullDateRange ) { 955 if ( ! fullDateRange ) {
962 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 956 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
963 957
964 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 958 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
965 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 959 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
966 fullDateRange = true; 960 fullDateRange = true;
967 } 961 }
968 } 962 }
969 if ( fullDateRange && !mSyncKDE ) 963 if ( fullDateRange && !mSyncKDE )
970 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 964 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
971 else 965 else
972 mLastCalendarSync = eventLSync->dtStart(); 966 mLastCalendarSync = eventLSync->dtStart();
973 // for resyncing if own file has changed 967 // for resyncing if own file has changed
974 if ( mCurrentSyncDevice == "deleteaftersync" ) { 968 if ( mCurrentSyncDevice == "deleteaftersync" ) {
975 mLastCalendarSync = loadedFileVersion; 969 mLastCalendarSync = loadedFileVersion;
976 qDebug("setting mLastCalendarSync "); 970 //qDebug("setting mLastCalendarSync ");
977 } 971 }
978 //qDebug("*************************** "); 972 //qDebug("*************************** ");
979 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); 973 qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
980 QPtrList<Incidence> er = remote->rawIncidences(); 974 QPtrList<Incidence> er = remote->rawIncidences();
981 Incidence* inR = er.first(); 975 Incidence* inR = er.first();
982 Incidence* inL; 976 Incidence* inL;
983 QProgressBar bar( er.count(),0 ); 977 QProgressBar bar( er.count(),0 );
984 bar.setCaption (i18n("Syncing - close to abort!") ); 978 bar.setCaption (i18n("Syncing - close to abort!") );
985 979
986 int w = 300; 980 int w = 300;
987 if ( QApplication::desktop()->width() < 320 ) 981 if ( QApplication::desktop()->width() < 320 )
988 w = 220; 982 w = 220;
989 int h = bar.sizeHint().height() ; 983 int h = bar.sizeHint().height() ;
990 int dw = QApplication::desktop()->width(); 984 int dw = QApplication::desktop()->width();
991 int dh = QApplication::desktop()->height(); 985 int dh = QApplication::desktop()->height();
992 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 986 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
993 bar.show(); 987 bar.show();
994 int modulo = (er.count()/10)+1; 988 int modulo = (er.count()/10)+1;
995 int incCounter = 0; 989 int incCounter = 0;
996 while ( inR ) { 990 while ( inR ) {
997 if ( ! bar.isVisible() ) 991 if ( ! bar.isVisible() )
998 return false; 992 return false;
999 if ( incCounter % modulo == 0 ) 993 if ( incCounter % modulo == 0 )
1000 bar.setProgress( incCounter ); 994 bar.setProgress( incCounter );
1001 ++incCounter; 995 ++incCounter;
1002 uid = inR->uid(); 996 uid = inR->uid();
1003 bool skipIncidence = false; 997 bool skipIncidence = false;
1004 if ( uid.left(15) == QString("last-syncEvent-") ) 998 if ( uid.left(15) == QString("last-syncEvent-") )
1005 skipIncidence = true; 999 skipIncidence = true;
1006 QString idS; 1000 QString idS;
1007 qApp->processEvents(); 1001 qApp->processEvents();
1008 if ( !skipIncidence ) { 1002 if ( !skipIncidence ) {
1009 inL = local->incidence( uid ); 1003 inL = local->incidence( uid );
1010 if ( inL ) { // maybe conflict - same uid in both calendars 1004 if ( inL ) { // maybe conflict - same uid in both calendars
1011 int maxrev = inL->revision();
1012 if ( maxrev < inR->revision() )
1013 maxrev = inR->revision();
1014 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1005 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1015 //qDebug("take %d %s ", take, inL->summary().latin1()); 1006 //qDebug("take %d %s ", take, inL->summary().latin1());
1016 if ( take == 3 ) 1007 if ( take == 3 )
1017 return false; 1008 return false;
1018 if ( take == 1 ) {// take local 1009 if ( take == 1 ) {// take local
1019 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1010 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1020 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1011 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1021 else 1012 else
1022 idS = inR->IDStr(); 1013 idS = inR->IDStr();
1023 remote->deleteIncidence( inR ); 1014 remote->deleteIncidence( inR );
1024 if ( inL->revision() < maxrev )
1025 inL->setRevision( maxrev );
1026 inR = inL->clone(); 1015 inR = inL->clone();
1027 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1016 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1028 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1017 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1029 inR->setIDStr( idS ); 1018 inR->setIDStr( idS );
1030 remote->addIncidence( inR ); 1019 remote->addIncidence( inR );
1031 if ( mSyncKDE ) 1020 if ( mSyncKDE )
1032 inR->setPilotId( 2 ); 1021 inR->setPilotId( 2 );
1033 ++changedRemote; 1022 ++changedRemote;
1034 } else { 1023 } else {
1035 if ( inR->revision() < maxrev )
1036 inR->setRevision( maxrev );
1037 idS = inL->IDStr(); 1024 idS = inL->IDStr();
1038 int pid = inL->pilotId(); 1025 int pid = inL->pilotId();
1039 local->deleteIncidence( inL ); 1026 local->deleteIncidence( inL );
1040 inL = inR->clone(); 1027 inL = inR->clone();
1041 if ( mSyncKDE ) 1028 if ( mSyncKDE )
1042 inL->setPilotId( pid ); 1029 inL->setPilotId( pid );
1043 inL->setIDStr( idS ); 1030 inL->setIDStr( idS );
1044 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1031 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1045 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1032 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1046 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1033 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1047 } 1034 }
1048 local->addIncidence( inL ); 1035 local->addIncidence( inL );
1049 ++changedLocal; 1036 ++changedLocal;
1050 } 1037 }
1051 } 1038 }
1052 } else { // no conflict 1039 } else { // no conflict
1053 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1040 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1054 QString des = eventLSync->description(); 1041 QString des = eventLSync->description();
1055 QString pref = "e"; 1042 QString pref = "e";
1056 if ( inR->type() == "Todo" ) 1043 if ( inR->type() == "Todo" )
1057 pref = "t"; 1044 pref = "t";
1058 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1045 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1059 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1046 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1060 //remote->deleteIncidence( inR ); 1047 //remote->deleteIncidence( inR );
1061 ++deletedEventR; 1048 ++deletedEventR;
1062 } else { 1049 } else {
1063 inR->setLastModified( modifiedCalendar ); 1050 inR->setLastModified( modifiedCalendar );
1064 inL = inR->clone(); 1051 inL = inR->clone();
1065 local->addIncidence( inL ); 1052 local->addIncidence( inL );
1066 ++addedEvent; 1053 ++addedEvent;
1067 } 1054 }
1068 } else { 1055 } else {
1069 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1056 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1070 inR->setLastModified( modifiedCalendar ); 1057 inR->setLastModified( modifiedCalendar );
1071 local->addIncidence( inR->clone() ); 1058 local->addIncidence( inR->clone() );
1072 ++addedEvent; 1059 ++addedEvent;
1073 } else { 1060 } else {
1074 checkExternSyncEvent(eventRSyncSharp, inR); 1061 checkExternSyncEvent(eventRSyncSharp, inR);
1075 remote->deleteIncidence( inR ); 1062 remote->deleteIncidence( inR );
1076 ++deletedEventR; 1063 ++deletedEventR;
1077 } 1064 }
1078 } 1065 }
1079 } 1066 }
1080 } 1067 }
1081 inR = er.next(); 1068 inR = er.next();
1082 } 1069 }
1083 QPtrList<Incidence> el = local->rawIncidences(); 1070 QPtrList<Incidence> el = local->rawIncidences();
1084 inL = el.first(); 1071 inL = el.first();
1085 modulo = (el.count()/10)+1; 1072 modulo = (el.count()/10)+1;
1086 bar.setCaption (i18n("Add / remove events") ); 1073 bar.setCaption (i18n("Add / remove events") );
1087 bar.setTotalSteps ( el.count() ) ; 1074 bar.setTotalSteps ( el.count() ) ;
1088 bar.show(); 1075 bar.show();
1089 incCounter = 0; 1076 incCounter = 0;
1090 1077
1091 while ( inL ) { 1078 while ( inL ) {
1092 1079
1093 qApp->processEvents(); 1080 qApp->processEvents();
1094 if ( ! bar.isVisible() ) 1081 if ( ! bar.isVisible() )
1095 return false; 1082 return false;
1096 if ( incCounter % modulo == 0 ) 1083 if ( incCounter % modulo == 0 )
1097 bar.setProgress( incCounter ); 1084 bar.setProgress( incCounter );
1098 ++incCounter; 1085 ++incCounter;
1099 uid = inL->uid(); 1086 uid = inL->uid();
1100 bool skipIncidence = false; 1087 bool skipIncidence = false;
1101 if ( uid.left(15) == QString("last-syncEvent-") ) 1088 if ( uid.left(15) == QString("last-syncEvent-") )
1102 skipIncidence = true; 1089 skipIncidence = true;
1103 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1090 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1104 skipIncidence = true; 1091 skipIncidence = true;
1105 if ( !skipIncidence ) { 1092 if ( !skipIncidence ) {
1106 inR = remote->incidence( uid ); 1093 inR = remote->incidence( uid );
1107 if ( ! inR ) { 1094 if ( ! inR ) {
1108 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1095 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1109 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1096 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1110 checkExternSyncEvent(eventLSyncSharp, inL); 1097 checkExternSyncEvent(eventLSyncSharp, inL);
1111 local->deleteIncidence( inL ); 1098 local->deleteIncidence( inL );
1112 ++deletedEventL; 1099 ++deletedEventL;
1113 } else { 1100 } else {
1114 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1101 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1115 inL->removeID(mCurrentSyncDevice ); 1102 inL->removeID(mCurrentSyncDevice );
1116 ++addedEventR; 1103 ++addedEventR;
1117 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1104 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1118 inL->setLastModified( modifiedCalendar ); 1105 inL->setLastModified( modifiedCalendar );
1119 inR = inL->clone(); 1106 inR = inL->clone();
1120 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1107 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1121 remote->addIncidence( inR ); 1108 remote->addIncidence( inR );
1122 } 1109 }
1123 } 1110 }
1124 } else { 1111 } else {
1125 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1112 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1126 checkExternSyncEvent(eventLSyncSharp, inL); 1113 checkExternSyncEvent(eventLSyncSharp, inL);
1127 local->deleteIncidence( inL ); 1114 local->deleteIncidence( inL );
1128 ++deletedEventL; 1115 ++deletedEventL;
1129 } else { 1116 } else {
1130 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1117 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1131 ++addedEventR; 1118 ++addedEventR;
1132 inL->setLastModified( modifiedCalendar ); 1119 inL->setLastModified( modifiedCalendar );
1133 remote->addIncidence( inL->clone() ); 1120 remote->addIncidence( inL->clone() );
1134 } 1121 }
1135 } 1122 }
1136 } 1123 }
1137 } 1124 }
1138 } 1125 }
1139 inL = el.next(); 1126 inL = el.next();
1140 } 1127 }
1141 int delFut = 0; 1128 int delFut = 0;
1142 int remRem = 0; 1129 int remRem = 0;
1143 if ( mSyncManager->mWriteBackInFuture ) { 1130 if ( mSyncManager->mWriteBackInFuture ) {
1144 er = remote->rawIncidences(); 1131 er = remote->rawIncidences();
1145 remRem = er.count(); 1132 remRem = er.count();
1146 inR = er.first(); 1133 inR = er.first();
1147 QDateTime dt; 1134 QDateTime dt;
1148 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1135 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1149 QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); 1136 QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 );
1150 while ( inR ) { 1137 while ( inR ) {
1151 if ( inR->type() == "Todo" ) { 1138 if ( inR->type() == "Todo" ) {
1152 Todo * t = (Todo*)inR; 1139 Todo * t = (Todo*)inR;
1153 if ( t->hasDueDate() ) 1140 if ( t->hasDueDate() )
1154 dt = t->dtDue(); 1141 dt = t->dtDue();
1155 else 1142 else
1156 dt = cur.addSecs( 62 ); 1143 dt = cur.addSecs( 62 );
1157 } 1144 }
1158 else if (inR->type() == "Event" ) { 1145 else if (inR->type() == "Event" ) {
1159 bool ok; 1146 bool ok;
1160 dt = inR->getNextOccurence( cur, &ok ); 1147 dt = inR->getNextOccurence( cur, &ok );
1161 if ( !ok ) 1148 if ( !ok )
1162 dt = cur.addSecs( -62 ); 1149 dt = cur.addSecs( -62 );
1163 } 1150 }
1164 else 1151 else
1165 dt = inR->dtStart(); 1152 dt = inR->dtStart();
1166 if ( dt < cur || dt > end ) { 1153 if ( dt < cur || dt > end ) {
1167 remote->deleteIncidence( inR ); 1154 remote->deleteIncidence( inR );
1168 ++delFut; 1155 ++delFut;
1169 } 1156 }
1170 inR = er.next(); 1157 inR = er.next();
1171 } 1158 }
1172 } 1159 }
1173 bar.hide(); 1160 bar.hide();
1174 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1161 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1175 eventLSync->setReadOnly( false ); 1162 eventLSync->setReadOnly( false );
1176 eventLSync->setDtStart( mLastCalendarSync ); 1163 eventLSync->setDtStart( mLastCalendarSync );
1177 eventRSync->setDtStart( mLastCalendarSync ); 1164 eventRSync->setDtStart( mLastCalendarSync );
1178 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1165 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1179 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1166 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1180 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1167 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1181 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1168 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1182 eventLSync->setReadOnly( true ); 1169 eventLSync->setReadOnly( true );
1183 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncKDE) // kde is abnormal... 1170 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncKDE) // kde is abnormal...
1184 remote->addEvent( eventRSync ); 1171 remote->addEvent( eventRSync );
1185 else 1172 else
1186 delete eventRSync; 1173 delete eventRSync;
1187 QString mes; 1174 QString mes;
1188 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); 1175 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR );
1189 QString delmess; 1176 QString delmess;
1190 if ( delFut ) { 1177 if ( delFut ) {
1191 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); 1178 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut);
1192 mes += delmess; 1179 mes += delmess;
1193 } 1180 }
1194 if ( mSyncManager->mShowSyncSummary ) { 1181 if ( mSyncManager->mShowSyncSummary ) {
1195 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1182 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1196 } 1183 }
1197 qDebug( mes ); 1184 qDebug( mes );
1198 mCalendar->checkAlarmForIncidence( 0, true ); 1185 mCalendar->checkAlarmForIncidence( 0, true );
1199 return syncOK; 1186 return syncOK;
1200} 1187}
1201 1188
1202void CalendarView::setSyncDevice( QString s ) 1189void CalendarView::setSyncDevice( QString s )
1203{ 1190{
1204 mCurrentSyncDevice= s; 1191 mCurrentSyncDevice= s;
1205} 1192}
1206void CalendarView::setSyncName( QString s ) 1193void CalendarView::setSyncName( QString s )
1207{ 1194{
1208 mCurrentSyncName= s; 1195 mCurrentSyncName= s;
1209} 1196}
1210bool CalendarView::syncCalendar(QString filename, int mode) 1197bool CalendarView::syncCalendar(QString filename, int mode)
1211{ 1198{
1212 //qDebug("syncCalendar %s ", filename.latin1()); 1199 //qDebug("syncCalendar %s ", filename.latin1());
1213 mGlobalSyncMode = SYNC_MODE_NORMAL; 1200 mGlobalSyncMode = SYNC_MODE_NORMAL;
1214 CalendarLocal* calendar = new CalendarLocal(); 1201 CalendarLocal* calendar = new CalendarLocal();
1215 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1202 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1216 FileStorage* storage = new FileStorage( calendar ); 1203 FileStorage* storage = new FileStorage( calendar );
1217 bool syncOK = false; 1204 bool syncOK = false;
1218 storage->setFileName( filename ); 1205 storage->setFileName( filename );
1219 // qDebug("loading ... "); 1206 // qDebug("loading ... ");
1220 if ( storage->load() ) { 1207 if ( storage->load() ) {
1221 getEventViewerDialog()->setSyncMode( true ); 1208 getEventViewerDialog()->setSyncMode( true );
1222 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1209 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1223 getEventViewerDialog()->setSyncMode( false ); 1210 getEventViewerDialog()->setSyncMode( false );
1224 if ( syncOK ) { 1211 if ( syncOK ) {
1225 if ( mSyncManager->mWriteBackFile ) 1212 if ( mSyncManager->mWriteBackFile )
1226 { 1213 {
1227 storage->setSaveFormat( new ICalFormat() ); 1214 storage->setSaveFormat( new ICalFormat() );
1228 storage->save(); 1215 storage->save();
1229 } 1216 }
1230 } 1217 }
1231 setModified( true ); 1218 setModified( true );
1232 } 1219 }
1233 delete storage; 1220 delete storage;
1234 delete calendar; 1221 delete calendar;
1235 if ( syncOK ) 1222 if ( syncOK )
1236 updateView(); 1223 updateView();
1237 return syncOK; 1224 return syncOK;
1238} 1225}
1239 1226
1240void CalendarView::syncExternal( int mode ) 1227void CalendarView::syncExternal( int mode )
1241{ 1228{
1242 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1229 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1243 1230
1244 qApp->processEvents(); 1231 qApp->processEvents();
1245 CalendarLocal* calendar = new CalendarLocal(); 1232 CalendarLocal* calendar = new CalendarLocal();
1246 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1233 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1247 bool syncOK = false; 1234 bool syncOK = false;
1248 bool loadSuccess = false; 1235 bool loadSuccess = false;
1249 PhoneFormat* phoneFormat = 0; 1236 PhoneFormat* phoneFormat = 0;
1250#ifndef DESKTOP_VERSION 1237#ifndef DESKTOP_VERSION
1251 SharpFormat* sharpFormat = 0; 1238 SharpFormat* sharpFormat = 0;
1252 if ( mode == 0 ) { // sharp 1239 if ( mode == 0 ) { // sharp
1253 sharpFormat = new SharpFormat () ; 1240 sharpFormat = new SharpFormat () ;
1254 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1241 loadSuccess = sharpFormat->load( calendar, mCalendar );
1255 1242
1256 } else 1243 } else
1257#endif 1244#endif
1258 if ( mode == 1 ) { // phone 1245 if ( mode == 1 ) { // phone
1259 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1246 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1260 mSyncManager->mPhoneDevice, 1247 mSyncManager->mPhoneDevice,
1261 mSyncManager->mPhoneConnection, 1248 mSyncManager->mPhoneConnection,
1262 mSyncManager->mPhoneModel); 1249 mSyncManager->mPhoneModel);
1263 loadSuccess = phoneFormat->load( calendar,mCalendar); 1250 loadSuccess = phoneFormat->load( calendar,mCalendar);
1264 1251
1265 } else 1252 } else
1266 return; 1253 return;
1267 if ( loadSuccess ) { 1254 if ( loadSuccess ) {
1268 getEventViewerDialog()->setSyncMode( true ); 1255 getEventViewerDialog()->setSyncMode( true );
1269 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1256 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1270 getEventViewerDialog()->setSyncMode( false ); 1257 getEventViewerDialog()->setSyncMode( false );
1271 qApp->processEvents(); 1258 qApp->processEvents();
1272 if ( syncOK ) { 1259 if ( syncOK ) {
1273 if ( mSyncManager->mWriteBackFile ) 1260 if ( mSyncManager->mWriteBackFile )
1274 { 1261 {
1275 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1262 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1276 Incidence* inc = iL.first(); 1263 Incidence* inc = iL.first();
1277 if ( phoneFormat ) { 1264 if ( phoneFormat ) {
1278 while ( inc ) { 1265 while ( inc ) {
1279 inc->removeID(mCurrentSyncDevice); 1266 inc->removeID(mCurrentSyncDevice);
1280 inc = iL.next(); 1267 inc = iL.next();
1281 } 1268 }
1282 } 1269 }
1283#ifndef DESKTOP_VERSION 1270#ifndef DESKTOP_VERSION
1284 if ( sharpFormat ) 1271 if ( sharpFormat )
1285 sharpFormat->save(calendar); 1272 sharpFormat->save(calendar);
1286#endif 1273#endif
1287 if ( phoneFormat ) 1274 if ( phoneFormat )
1288 phoneFormat->save(calendar); 1275 phoneFormat->save(calendar);
1289 iL = calendar->rawIncidences(); 1276 iL = calendar->rawIncidences();
1290 inc = iL.first(); 1277 inc = iL.first();
1291 Incidence* loc; 1278 Incidence* loc;
1292 while ( inc ) { 1279 while ( inc ) {
1293 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1280 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1294 loc = mCalendar->incidence(inc->uid() ); 1281 loc = mCalendar->incidence(inc->uid() );
1295 if ( loc ) { 1282 if ( loc ) {
1296 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1283 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1297 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1284 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1298 } 1285 }
1299 } 1286 }
1300 inc = iL.next(); 1287 inc = iL.next();
1301 } 1288 }
1302 Incidence* lse = getLastSyncEvent(); 1289 Incidence* lse = getLastSyncEvent();
1303 if ( lse ) { 1290 if ( lse ) {
1304 lse->setReadOnly( false ); 1291 lse->setReadOnly( false );
1305 lse->setDescription( "" ); 1292 lse->setDescription( "" );
1306 lse->setReadOnly( true ); 1293 lse->setReadOnly( true );
1307 } 1294 }
1308 } 1295 }
1309 } 1296 }
1310 setModified( true ); 1297 setModified( true );
1311 } else { 1298 } else {
1312 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1299 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1313 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1300 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1314 question, i18n("Ok")) ; 1301 question, i18n("Ok")) ;
1315 1302
1316 } 1303 }
1317 delete calendar; 1304 delete calendar;
1318 updateView(); 1305 updateView();
1319 return ;//syncOK; 1306 return ;//syncOK;
1320 1307
1321} 1308}
1322 1309
1323bool CalendarView::importBday() 1310bool CalendarView::importBday()
1324{ 1311{
1325#ifndef KORG_NOKABC 1312#ifndef KORG_NOKABC
1326 1313
1327#ifdef DESKTOP_VERSION 1314#ifdef DESKTOP_VERSION
1328 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1315 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1329 KABC::AddressBook::Iterator it; 1316 KABC::AddressBook::Iterator it;
1330 int count = 0; 1317 int count = 0;
1331 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1318 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1332 ++count; 1319 ++count;
1333 } 1320 }
1334 QProgressBar bar(count,0 ); 1321 QProgressBar bar(count,0 );
1335 int w = 300; 1322 int w = 300;
1336 if ( QApplication::desktop()->width() < 320 ) 1323 if ( QApplication::desktop()->width() < 320 )
1337 w = 220; 1324 w = 220;
1338 int h = bar.sizeHint().height() ; 1325 int h = bar.sizeHint().height() ;
1339 int dw = QApplication::desktop()->width(); 1326 int dw = QApplication::desktop()->width();
1340 int dh = QApplication::desktop()->height(); 1327 int dh = QApplication::desktop()->height();
1341 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1328 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1342 bar.show(); 1329 bar.show();
1343 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1330 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1344 qApp->processEvents(); 1331 qApp->processEvents();
1345 count = 0; 1332 count = 0;
1346 int addCount = 0; 1333 int addCount = 0;
1347 KCal::Attendee* a = 0; 1334 KCal::Attendee* a = 0;
1348 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1335 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1349 if ( ! bar.isVisible() ) 1336 if ( ! bar.isVisible() )
1350 return false; 1337 return false;
1351 bar.setProgress( count++ ); 1338 bar.setProgress( count++ );
1352 qApp->processEvents(); 1339 qApp->processEvents();
1353 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1340 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1354 if ( (*it).birthday().date().isValid() ){ 1341 if ( (*it).birthday().date().isValid() ){
1355 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1342 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1356 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1343 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1357 ++addCount; 1344 ++addCount;
1358 } 1345 }
1359 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1346 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1360 if ( anni.isValid() ){ 1347 if ( anni.isValid() ){
1361 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1348 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1362 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1349 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1363 ++addCount; 1350 ++addCount;
1364 } 1351 }
1365 } 1352 }
1366 updateView(); 1353 updateView();
1367 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1354 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1368#else //DESKTOP_VERSION 1355#else //DESKTOP_VERSION
1369 1356
1370 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1357 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1371 // the result should now arrive through method insertBirthdays 1358 // the result should now arrive through method insertBirthdays
1372 1359
1373#endif //DESKTOP_VERSION 1360#endif //DESKTOP_VERSION
1374 1361
1375#endif //KORG_NOKABC 1362#endif //KORG_NOKABC
1376 1363
1377 1364
1378 return true; 1365 return true;
1379} 1366}
1380 1367
1381// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1368// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1382void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1369void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1383 const QStringList& anniversaryList, const QStringList& realNameList, 1370 const QStringList& anniversaryList, const QStringList& realNameList,
1384 const QStringList& emailList, const QStringList& assembledNameList, 1371 const QStringList& emailList, const QStringList& assembledNameList,
1385 const QStringList& uidList) 1372 const QStringList& uidList)
1386{ 1373{
1387 qDebug("CalendarView::insertBirthdays"); 1374 qDebug("CalendarView::insertBirthdays");
1388 if (uid == this->name()) 1375 if (uid == this->name())
1389 { 1376 {
1390 int count = birthdayList.count(); 1377 int count = birthdayList.count();
1391 int addCount = 0; 1378 int addCount = 0;
1392 KCal::Attendee* a = 0; 1379 KCal::Attendee* a = 0;
1393 1380
1394 qDebug("CalView 1 %i", count); 1381 qDebug("CalView 1 %i", count);
1395 1382
1396 QProgressBar bar(count,0 ); 1383 QProgressBar bar(count,0 );
1397 int w = 300; 1384 int w = 300;
1398 if ( QApplication::desktop()->width() < 320 ) 1385 if ( QApplication::desktop()->width() < 320 )
1399 w = 220; 1386 w = 220;
1400 int h = bar.sizeHint().height() ; 1387 int h = bar.sizeHint().height() ;
1401 int dw = QApplication::desktop()->width(); 1388 int dw = QApplication::desktop()->width();
1402 int dh = QApplication::desktop()->height(); 1389 int dh = QApplication::desktop()->height();
1403 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1390 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1404 bar.show(); 1391 bar.show();
1405 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1392 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1406 qApp->processEvents(); 1393 qApp->processEvents();
1407 1394
1408 QDate birthday; 1395 QDate birthday;
1409 QDate anniversary; 1396 QDate anniversary;
1410 QString realName; 1397 QString realName;
1411 QString email; 1398 QString email;
1412 QString assembledName; 1399 QString assembledName;
1413 QString uid; 1400 QString uid;
1414 bool ok = true; 1401 bool ok = true;
1415 for ( int i = 0; i < count; i++) 1402 for ( int i = 0; i < count; i++)
1416 { 1403 {
1417 if ( ! bar.isVisible() ) 1404 if ( ! bar.isVisible() )
1418 return; 1405 return;
1419 bar.setProgress( i ); 1406 bar.setProgress( i );
1420 qApp->processEvents(); 1407 qApp->processEvents();