summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp11
-rw-r--r--korganizer/filteredit_base.cpp73
-rw-r--r--korganizer/filteredit_base.h18
-rw-r--r--korganizer/filteredit_base.ui123
-rw-r--r--korganizer/korganizer.pro4
-rw-r--r--libkcal/calfilter.h2
-rw-r--r--libkdepim/ksyncmanager.cpp10
-rw-r--r--libkdepim/ksyncmanager.h4
8 files changed, 170 insertions, 75 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 378c7d4..8258c74 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -231,1536 +231,1547 @@ CalendarView::CalendarView( Calendar *calendar,
231 mTodoEditor = 0; 231 mTodoEditor = 0;
232 init();} 232 init();}
233 233
234void CalendarView::init() 234void CalendarView::init()
235{ 235{
236 beamDialog = new KOBeamPrefs(); 236 beamDialog = new KOBeamPrefs();
237 mDatePickerMode = 0; 237 mDatePickerMode = 0;
238 mCurrentSyncDevice = ""; 238 mCurrentSyncDevice = "";
239 writeLocale(); 239 writeLocale();
240 mViewManager = new KOViewManager( this ); 240 mViewManager = new KOViewManager( this );
241 mDialogManager = new KODialogManager( this ); 241 mDialogManager = new KODialogManager( this );
242 mEventViewerDialog = 0; 242 mEventViewerDialog = 0;
243 mModified = false; 243 mModified = false;
244 mReadOnly = false; 244 mReadOnly = false;
245 mSelectedIncidence = 0; 245 mSelectedIncidence = 0;
246 mCalPrinter = 0; 246 mCalPrinter = 0;
247 mFilters.setAutoDelete(true); 247 mFilters.setAutoDelete(true);
248 248
249 mCalendar->registerObserver( this ); 249 mCalendar->registerObserver( this );
250 // TODO: Make sure that view is updated, when calendar is changed. 250 // TODO: Make sure that view is updated, when calendar is changed.
251 251
252 mStorage = new FileStorage( mCalendar ); 252 mStorage = new FileStorage( mCalendar );
253 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 253 mNavigator = new DateNavigator( this, "datevav", mViewManager );
254 254
255 QBoxLayout *topLayout = (QBoxLayout*)layout(); 255 QBoxLayout *topLayout = (QBoxLayout*)layout();
256#ifndef KORG_NOSPLITTER 256#ifndef KORG_NOSPLITTER
257 // create the main layout frames. 257 // create the main layout frames.
258 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 258 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
259 topLayout->addWidget(mPanner); 259 topLayout->addWidget(mPanner);
260 260
261 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 261 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
262 "CalendarView::LeftFrame"); 262 "CalendarView::LeftFrame");
263 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 263 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
264 264
265 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 265 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
266 "CalendarView::DateNavigator", QDate::currentDate() ); 266 "CalendarView::DateNavigator", QDate::currentDate() );
267 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 267 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
268 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 268 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
269 mTodoList->setNavigator( mNavigator ); 269 mTodoList->setNavigator( mNavigator );
270 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 270 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
271 271
272#ifdef KORG_NORESOURCEVIEW 272#ifdef KORG_NORESOURCEVIEW
273 mResourceView = 0; 273 mResourceView = 0;
274#else 274#else
275 if ( mResourceManager ) { 275 if ( mResourceManager ) {
276 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 276 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
277 mResourceView->updateView(); 277 mResourceView->updateView();
278 connect( mResourceView, SIGNAL( resourcesChanged() ), 278 connect( mResourceView, SIGNAL( resourcesChanged() ),
279 SLOT( updateView() ) ); 279 SLOT( updateView() ) );
280 } else { 280 } else {
281 mResourceView = 0; 281 mResourceView = 0;
282 } 282 }
283#endif 283#endif
284 QWidget *rightBox = new QWidget( mPanner ); 284 QWidget *rightBox = new QWidget( mPanner );
285 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 285 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
286 286
287 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 287 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
288 rightLayout->addWidget( mNavigatorBar ); 288 rightLayout->addWidget( mNavigatorBar );
289 289
290 mRightFrame = new QWidgetStack( rightBox ); 290 mRightFrame = new QWidgetStack( rightBox );
291 rightLayout->addWidget( mRightFrame, 1 ); 291 rightLayout->addWidget( mRightFrame, 1 );
292 292
293 mLeftFrame = mLeftSplitter; 293 mLeftFrame = mLeftSplitter;
294#else 294#else
295 QWidget *mainBox = new QWidget( this ); 295 QWidget *mainBox = new QWidget( this );
296 QWidget *leftFrame = new QWidget( mainBox ); 296 QWidget *leftFrame = new QWidget( mainBox );
297 297
298 QBoxLayout * mainBoxLayout; 298 QBoxLayout * mainBoxLayout;
299 QBoxLayout * leftFrameLayout; 299 QBoxLayout * leftFrameLayout;
300 if ( KOPrefs::instance()->mVerticalScreen ) { 300 if ( KOPrefs::instance()->mVerticalScreen ) {
301 mainBoxLayout = new QVBoxLayout(mainBox); 301 mainBoxLayout = new QVBoxLayout(mainBox);
302 leftFrameLayout = new QHBoxLayout(leftFrame ); 302 leftFrameLayout = new QHBoxLayout(leftFrame );
303 } else { 303 } else {
304 mainBoxLayout = new QHBoxLayout(mainBox); 304 mainBoxLayout = new QHBoxLayout(mainBox);
305 leftFrameLayout = new QVBoxLayout(leftFrame ); 305 leftFrameLayout = new QVBoxLayout(leftFrame );
306 } 306 }
307 topLayout->addWidget( mainBox ); 307 topLayout->addWidget( mainBox );
308 mainBoxLayout->addWidget (leftFrame); 308 mainBoxLayout->addWidget (leftFrame);
309 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 309 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
310 "CalendarView::DateNavigator", QDate::currentDate()); 310 "CalendarView::DateNavigator", QDate::currentDate());
311 // mDateNavigator->blockSignals( true ); 311 // mDateNavigator->blockSignals( true );
312 leftFrameLayout->addWidget( mDateNavigator ); 312 leftFrameLayout->addWidget( mDateNavigator );
313 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 313 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
314 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); 314 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall");
315 mTodoList->setNavigator( mNavigator ); 315 mTodoList->setNavigator( mNavigator );
316 316
317 if ( QApplication::desktop()->width() < 480 ) { 317 if ( QApplication::desktop()->width() < 480 ) {
318 leftFrameLayout->addWidget(mFilterView); 318 leftFrameLayout->addWidget(mFilterView);
319 leftFrameLayout->addWidget(mTodoList, 2 ); 319 leftFrameLayout->addWidget(mTodoList, 2 );
320 320
321 } else { 321 } else {
322 leftFrameLayout->addWidget(mTodoList,2 ); 322 leftFrameLayout->addWidget(mTodoList,2 );
323 leftFrameLayout->addWidget(mFilterView ); 323 leftFrameLayout->addWidget(mFilterView );
324 } 324 }
325 mFilterView->hide(); 325 mFilterView->hide();
326 QWidget *rightBox = new QWidget( mainBox ); 326 QWidget *rightBox = new QWidget( mainBox );
327 mainBoxLayout->addWidget ( rightBox, 10 ); 327 mainBoxLayout->addWidget ( rightBox, 10 );
328 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 328 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
329 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 329 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
330 mRightFrame = new QWidgetStack( rightBox ); 330 mRightFrame = new QWidgetStack( rightBox );
331 rightLayout->addWidget( mNavigatorBar ); 331 rightLayout->addWidget( mNavigatorBar );
332 rightLayout->addWidget( mRightFrame, 10 ); 332 rightLayout->addWidget( mRightFrame, 10 );
333 333
334 mLeftFrame = leftFrame; 334 mLeftFrame = leftFrame;
335 if ( KOPrefs::instance()->mVerticalScreen ) { 335 if ( KOPrefs::instance()->mVerticalScreen ) {
336 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 336 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
337 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 337 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
338 } else { 338 } else {
339 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 339 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
340 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 340 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
341 } 341 }
342 342
343 //qDebug("Calendarview Size %d %d ", width(), height()); 343 //qDebug("Calendarview Size %d %d ", width(), height());
344#endif 344#endif
345 345
346 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 346 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
347 SLOT( showDates( const KCal::DateList & ) ) ); 347 SLOT( showDates( const KCal::DateList & ) ) );
348 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 348 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
349 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 349 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
350 350
351 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 351 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
352 mNavigator, SLOT( selectPreviousYear() ) ); 352 mNavigator, SLOT( selectPreviousYear() ) );
353 connect( mNavigatorBar, SIGNAL( goNextYear() ), 353 connect( mNavigatorBar, SIGNAL( goNextYear() ),
354 mNavigator, SLOT( selectNextYear() ) ); 354 mNavigator, SLOT( selectNextYear() ) );
355 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 355 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
356 mNavigator, SLOT( selectPreviousMonth() ) ); 356 mNavigator, SLOT( selectPreviousMonth() ) );
357 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 357 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
358 mNavigator, SLOT( selectNextMonth() ) ); 358 mNavigator, SLOT( selectNextMonth() ) );
359 359
360 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 360 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
361 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 361 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
362 362
363 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 363 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
364 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 364 mNavigator, SLOT( selectWeek( const QDate & ) ) );
365 365
366 connect( mDateNavigator, SIGNAL( goPrevYear() ), 366 connect( mDateNavigator, SIGNAL( goPrevYear() ),
367 mNavigator, SLOT( selectPreviousYear() ) ); 367 mNavigator, SLOT( selectPreviousYear() ) );
368 connect( mDateNavigator, SIGNAL( goNextYear() ), 368 connect( mDateNavigator, SIGNAL( goNextYear() ),
369 mNavigator, SLOT( selectNextYear() ) ); 369 mNavigator, SLOT( selectNextYear() ) );
370 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 370 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
371 mNavigator, SLOT( selectPreviousMonth() ) ); 371 mNavigator, SLOT( selectPreviousMonth() ) );
372 connect( mDateNavigator, SIGNAL( goNextMonth() ), 372 connect( mDateNavigator, SIGNAL( goNextMonth() ),
373 mNavigator, SLOT( selectNextMonth() ) ); 373 mNavigator, SLOT( selectNextMonth() ) );
374 374
375 connect( mDateNavigator, SIGNAL( goPrevious() ), 375 connect( mDateNavigator, SIGNAL( goPrevious() ),
376 mNavigator, SLOT( selectPrevious() ) ); 376 mNavigator, SLOT( selectPrevious() ) );
377 connect( mDateNavigator, SIGNAL( goNext() ), 377 connect( mDateNavigator, SIGNAL( goNext() ),
378 mNavigator, SLOT( selectNext() ) ); 378 mNavigator, SLOT( selectNext() ) );
379 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 379 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
380 mNavigator, SLOT( slotMonthSelect( int ) ) ); 380 mNavigator, SLOT( slotMonthSelect( int ) ) );
381 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 381 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
382 mNavigator, SLOT( slotMonthSelect( int ) ) ); 382 mNavigator, SLOT( slotMonthSelect( int ) ) );
383 383
384 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 384 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
385 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 385 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
386 386
387 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 387 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
388 SLOT( eventAdded( Event *) ) ); 388 SLOT( eventAdded( Event *) ) );
389 389
390 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 390 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
391 391
392 connect( this, SIGNAL( configChanged() ), 392 connect( this, SIGNAL( configChanged() ),
393 mDateNavigator, SLOT( updateConfig() ) ); 393 mDateNavigator, SLOT( updateConfig() ) );
394 394
395 connect( mTodoList, SIGNAL( newTodoSignal() ), 395 connect( mTodoList, SIGNAL( newTodoSignal() ),
396 SLOT( newTodo() ) ); 396 SLOT( newTodo() ) );
397 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 397 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
398 SLOT( newSubTodo( Todo * ) ) ); 398 SLOT( newSubTodo( Todo * ) ) );
399 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 399 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
400 SLOT( editTodo( Todo * ) ) ); 400 SLOT( editTodo( Todo * ) ) );
401 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 401 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
402 SLOT( showTodo( Todo *) ) ); 402 SLOT( showTodo( Todo *) ) );
403 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 403 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
404 SLOT( deleteTodo( Todo *) ) ); 404 SLOT( deleteTodo( Todo *) ) );
405 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 405 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
406 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 406 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
407 SLOT( purgeCompleted() ) ); 407 SLOT( purgeCompleted() ) );
408 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 408 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
409 SIGNAL( todoModified( Todo *, int ) ) ); 409 SIGNAL( todoModified( Todo *, int ) ) );
410 410
411 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 411 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
412 this, SLOT ( cloneIncidence( Incidence * ) ) ); 412 this, SLOT ( cloneIncidence( Incidence * ) ) );
413 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 413 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
414 this, SLOT (cancelIncidence( Incidence * ) ) ); 414 this, SLOT (cancelIncidence( Incidence * ) ) );
415 415
416 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 416 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
417 this, SLOT ( moveIncidence( Incidence * ) ) ); 417 this, SLOT ( moveIncidence( Incidence * ) ) );
418 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 418 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
419 this, SLOT ( beamIncidence( Incidence * ) ) ); 419 this, SLOT ( beamIncidence( Incidence * ) ) );
420 420
421 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 421 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
422 this, SLOT ( todo_unsub( Todo * ) ) ); 422 this, SLOT ( todo_unsub( Todo * ) ) );
423 423
424 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 424 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
425 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 425 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
426 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 426 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
427 SLOT( updateTodo( Todo *, int ) ) ); 427 SLOT( updateTodo( Todo *, int ) ) );
428 connect( this, SIGNAL( todoModified( Todo *, int )), this, 428 connect( this, SIGNAL( todoModified( Todo *, int )), this,
429 SLOT( changeTodoDisplay( Todo *, int ) ) ); 429 SLOT( changeTodoDisplay( Todo *, int ) ) );
430 430
431 431
432 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 432 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
433 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 433 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
434 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 434 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
435 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 435 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
436 436
437 437
438 438
439 439
440 440
441 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 441 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
442 SLOT(checkClipboard())); 442 SLOT(checkClipboard()));
443 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 443 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
444 SLOT( processTodoListSelection( Incidence * ) ) ); 444 SLOT( processTodoListSelection( Incidence * ) ) );
445 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 445 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
446 446
447 // kdDebug() << "CalendarView::CalendarView() done" << endl; 447 // kdDebug() << "CalendarView::CalendarView() done" << endl;
448 448
449 mDateFrame = new QVBox(0,0,WType_Popup); 449 mDateFrame = new QVBox(0,0,WType_Popup);
450 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 450 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
451 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 451 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
452 mDateFrame->setLineWidth(3); 452 mDateFrame->setLineWidth(3);
453 mDateFrame->hide(); 453 mDateFrame->hide();
454 mDateFrame->setCaption( i18n( "Pick a date to display")); 454 mDateFrame->setCaption( i18n( "Pick a date to display"));
455 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 455 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
456 456
457 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 457 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
458 458
459 mEventEditor = mDialogManager->getEventEditor(); 459 mEventEditor = mDialogManager->getEventEditor();
460 mTodoEditor = mDialogManager->getTodoEditor(); 460 mTodoEditor = mDialogManager->getTodoEditor();
461 461
462 mFlagEditDescription = false; 462 mFlagEditDescription = false;
463 463
464 mSuspendTimer = new QTimer( this ); 464 mSuspendTimer = new QTimer( this );
465 mAlarmTimer = new QTimer( this ); 465 mAlarmTimer = new QTimer( this );
466 mRecheckAlarmTimer = new QTimer( this ); 466 mRecheckAlarmTimer = new QTimer( this );
467 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 467 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
468 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 468 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
469 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 469 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
470 mAlarmDialog = new AlarmDialog( this ); 470 mAlarmDialog = new AlarmDialog( this );
471 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 471 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
472 mAlarmDialog->setServerNotification( false ); 472 mAlarmDialog->setServerNotification( false );
473 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 473 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
474 474
475 475
476#ifndef DESKTOP_VERSION 476#ifndef DESKTOP_VERSION
477//US listen for arriving address resultsets 477//US listen for arriving address resultsets
478 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 478 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
479 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 479 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
480#endif 480#endif
481 481
482} 482}
483 483
484 484
485CalendarView::~CalendarView() 485CalendarView::~CalendarView()
486{ 486{
487 // kdDebug() << "~CalendarView()" << endl; 487 // kdDebug() << "~CalendarView()" << endl;
488 //qDebug("CalendarView::~CalendarView() "); 488 //qDebug("CalendarView::~CalendarView() ");
489 delete mDialogManager; 489 delete mDialogManager;
490 delete mViewManager; 490 delete mViewManager;
491 delete mStorage; 491 delete mStorage;
492 delete mDateFrame ; 492 delete mDateFrame ;
493 delete beamDialog; 493 delete beamDialog;
494 //kdDebug() << "~CalendarView() done" << endl; 494 //kdDebug() << "~CalendarView() done" << endl;
495} 495}
496 496
497void CalendarView::showDay( QDate d ) 497void CalendarView::showDay( QDate d )
498{ 498{
499 dateNavigator()->selectDate( d ); 499 dateNavigator()->selectDate( d );
500 mViewManager->showWeekView(); 500 mViewManager->showWeekView();
501 dateNavigator()->selectDate( d ); 501 dateNavigator()->selectDate( d );
502} 502}
503void CalendarView::timerAlarm() 503void CalendarView::timerAlarm()
504{ 504{
505 //qDebug("CalendarView::timerAlarm() "); 505 //qDebug("CalendarView::timerAlarm() ");
506 computeAlarm(mAlarmNotification ); 506 computeAlarm(mAlarmNotification );
507} 507}
508 508
509void CalendarView::suspendAlarm() 509void CalendarView::suspendAlarm()
510{ 510{
511 //qDebug(" CalendarView::suspendAlarm() "); 511 //qDebug(" CalendarView::suspendAlarm() ");
512 computeAlarm(mSuspendAlarmNotification ); 512 computeAlarm(mSuspendAlarmNotification );
513 513
514} 514}
515 515
516void CalendarView::startAlarm( QString mess , QString filename) 516void CalendarView::startAlarm( QString mess , QString filename)
517{ 517{
518 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 518 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
519 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 519 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
520 520
521} 521}
522 522
523void CalendarView::checkNextTimerAlarm() 523void CalendarView::checkNextTimerAlarm()
524{ 524{
525 mCalendar->checkAlarmForIncidence( 0, true ); 525 mCalendar->checkAlarmForIncidence( 0, true );
526} 526}
527 527
528void CalendarView::computeAlarm( QString msg ) 528void CalendarView::computeAlarm( QString msg )
529{ 529{
530 530
531 QString mess = msg; 531 QString mess = msg;
532 QString mAlarmMessage = mess.mid( 9 ); 532 QString mAlarmMessage = mess.mid( 9 );
533 QString filename = MainWindow::resourcePath(); 533 QString filename = MainWindow::resourcePath();
534 filename += "koalarm.wav"; 534 filename += "koalarm.wav";
535 QString tempfilename; 535 QString tempfilename;
536 if ( mess.left( 13 ) == "suspend_alarm") { 536 if ( mess.left( 13 ) == "suspend_alarm") {
537 bool error = false; 537 bool error = false;
538 int len = mess.mid( 13 ).find("+++"); 538 int len = mess.mid( 13 ).find("+++");
539 if ( len < 2 ) 539 if ( len < 2 )
540 error = true; 540 error = true;
541 else { 541 else {
542 tempfilename = mess.mid( 13, len ); 542 tempfilename = mess.mid( 13, len );
543 if ( !QFile::exists( tempfilename ) ) 543 if ( !QFile::exists( tempfilename ) )
544 error = true; 544 error = true;
545 } 545 }
546 if ( ! error ) { 546 if ( ! error ) {
547 filename = tempfilename; 547 filename = tempfilename;
548 } 548 }
549 mAlarmMessage = mess.mid( 13+len+3 ); 549 mAlarmMessage = mess.mid( 13+len+3 );
550 //qDebug("suspend file %s ",tempfilename.latin1() ); 550 //qDebug("suspend file %s ",tempfilename.latin1() );
551 startAlarm( mAlarmMessage, filename); 551 startAlarm( mAlarmMessage, filename);
552 return; 552 return;
553 } 553 }
554 if ( mess.left( 11 ) == "timer_alarm") { 554 if ( mess.left( 11 ) == "timer_alarm") {
555 //mTimerTime = 0; 555 //mTimerTime = 0;
556 startAlarm( mess.mid( 11 ), filename ); 556 startAlarm( mess.mid( 11 ), filename );
557 return; 557 return;
558 } 558 }
559 if ( mess.left( 10 ) == "proc_alarm") { 559 if ( mess.left( 10 ) == "proc_alarm") {
560 bool error = false; 560 bool error = false;
561 int len = mess.mid( 10 ).find("+++"); 561 int len = mess.mid( 10 ).find("+++");
562 if ( len < 2 ) 562 if ( len < 2 )
563 error = true; 563 error = true;
564 else { 564 else {
565 tempfilename = mess.mid( 10, len ); 565 tempfilename = mess.mid( 10, len );
566 if ( !QFile::exists( tempfilename ) ) 566 if ( !QFile::exists( tempfilename ) )
567 error = true; 567 error = true;
568 } 568 }
569 if ( error ) { 569 if ( error ) {
570 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 570 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
571 mAlarmMessage += mess.mid( 10+len+3+9 ); 571 mAlarmMessage += mess.mid( 10+len+3+9 );
572 } else { 572 } else {
573 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 573 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
574 //qDebug("-----system command %s ",tempfilename.latin1() ); 574 //qDebug("-----system command %s ",tempfilename.latin1() );
575#ifndef _WIN32_ 575#ifndef _WIN32_
576 if ( vfork () == 0 ) { 576 if ( vfork () == 0 ) {
577 execl ( tempfilename.latin1(), 0 ); 577 execl ( tempfilename.latin1(), 0 );
578 return; 578 return;
579 } 579 }
580#else 580#else
581 QProcess* p = new QProcess(); 581 QProcess* p = new QProcess();
582 p->addArgument( tempfilename.latin1() ); 582 p->addArgument( tempfilename.latin1() );
583 p->start(); 583 p->start();
584 return; 584 return;
585#endif 585#endif
586 586
587 return; 587 return;
588 } 588 }
589 589
590 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 590 //qDebug("+++++++system command %s ",tempfilename.latin1() );
591 } 591 }
592 if ( mess.left( 11 ) == "audio_alarm") { 592 if ( mess.left( 11 ) == "audio_alarm") {
593 bool error = false; 593 bool error = false;
594 int len = mess.mid( 11 ).find("+++"); 594 int len = mess.mid( 11 ).find("+++");
595 if ( len < 2 ) 595 if ( len < 2 )
596 error = true; 596 error = true;
597 else { 597 else {
598 tempfilename = mess.mid( 11, len ); 598 tempfilename = mess.mid( 11, len );
599 if ( !QFile::exists( tempfilename ) ) 599 if ( !QFile::exists( tempfilename ) )
600 error = true; 600 error = true;
601 } 601 }
602 if ( ! error ) { 602 if ( ! error ) {
603 filename = tempfilename; 603 filename = tempfilename;
604 } 604 }
605 mAlarmMessage = mess.mid( 11+len+3+9 ); 605 mAlarmMessage = mess.mid( 11+len+3+9 );
606 //qDebug("audio file command %s ",tempfilename.latin1() ); 606 //qDebug("audio file command %s ",tempfilename.latin1() );
607 } 607 }
608 if ( mess.left( 9 ) == "cal_alarm") { 608 if ( mess.left( 9 ) == "cal_alarm") {
609 mAlarmMessage = mess.mid( 9 ) ; 609 mAlarmMessage = mess.mid( 9 ) ;
610 } 610 }
611 611
612 startAlarm( mAlarmMessage, filename ); 612 startAlarm( mAlarmMessage, filename );
613 613
614 614
615} 615}
616 616
617void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 617void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
618{ 618{
619 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 619 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
620 620
621 mSuspendAlarmNotification = noti; 621 mSuspendAlarmNotification = noti;
622 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 622 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
623 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 623 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
624 mSuspendTimer->start( ms , true ); 624 mSuspendTimer->start( ms , true );
625 625
626} 626}
627 627
628void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 628void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
629{ 629{
630 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 630 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
631 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 631 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
632#ifndef DESKTOP_VERSION 632#ifndef DESKTOP_VERSION
633 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 633 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
634#endif 634#endif
635 return; 635 return;
636 } 636 }
637 int maxSec; 637 int maxSec;
638 //maxSec = 5; //testing only 638 //maxSec = 5; //testing only
639 maxSec = 86400+3600; // one day+1hour 639 maxSec = 86400+3600; // one day+1hour
640 mAlarmNotification = noti; 640 mAlarmNotification = noti;
641 int sec = QDateTime::currentDateTime().secsTo( qdt ); 641 int sec = QDateTime::currentDateTime().secsTo( qdt );
642 if ( sec > maxSec ) { 642 if ( sec > maxSec ) {
643 mRecheckAlarmTimer->start( maxSec * 1000 ); 643 mRecheckAlarmTimer->start( maxSec * 1000 );
644 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 644 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
645 return; 645 return;
646 } else { 646 } else {
647 mRecheckAlarmTimer->stop(); 647 mRecheckAlarmTimer->stop();
648 } 648 }
649 //qDebug("Alarm timer started with secs: %d ", sec); 649 //qDebug("Alarm timer started with secs: %d ", sec);
650 mAlarmTimer->start( sec *1000 , true ); 650 mAlarmTimer->start( sec *1000 , true );
651 651
652} 652}
653// called by mRecheckAlarmTimer to get next alarm 653// called by mRecheckAlarmTimer to get next alarm
654// we need this, because a QTimer has only a max range of 25 days 654// we need this, because a QTimer has only a max range of 25 days
655void CalendarView::recheckTimerAlarm() 655void CalendarView::recheckTimerAlarm()
656{ 656{
657 mAlarmTimer->stop(); 657 mAlarmTimer->stop();
658 mRecheckAlarmTimer->stop(); 658 mRecheckAlarmTimer->stop();
659 mCalendar->checkAlarmForIncidence( 0, true ); 659 mCalendar->checkAlarmForIncidence( 0, true );
660} 660}
661void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 661void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
662{ 662{
663 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 663 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
664 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 664 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
665#ifndef DESKTOP_VERSION 665#ifndef DESKTOP_VERSION
666 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 666 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
667#endif 667#endif
668 return; 668 return;
669 } 669 }
670 mAlarmTimer->stop(); 670 mAlarmTimer->stop();
671} 671}
672void CalendarView::selectWeekNum ( int num ) 672void CalendarView::selectWeekNum ( int num )
673{ 673{
674 dateNavigator()->selectWeek( num ); 674 dateNavigator()->selectWeek( num );
675 mViewManager->showWeekView(); 675 mViewManager->showWeekView();
676} 676}
677KOViewManager *CalendarView::viewManager() 677KOViewManager *CalendarView::viewManager()
678{ 678{
679 return mViewManager; 679 return mViewManager;
680} 680}
681 681
682KODialogManager *CalendarView::dialogManager() 682KODialogManager *CalendarView::dialogManager()
683{ 683{
684 return mDialogManager; 684 return mDialogManager;
685} 685}
686 686
687QDate CalendarView::startDate() 687QDate CalendarView::startDate()
688{ 688{
689 DateList dates = mNavigator->selectedDates(); 689 DateList dates = mNavigator->selectedDates();
690 690
691 return dates.first(); 691 return dates.first();
692} 692}
693 693
694QDate CalendarView::endDate() 694QDate CalendarView::endDate()
695{ 695{
696 DateList dates = mNavigator->selectedDates(); 696 DateList dates = mNavigator->selectedDates();
697 697
698 return dates.last(); 698 return dates.last();
699} 699}
700 700
701 701
702void CalendarView::createPrinter() 702void CalendarView::createPrinter()
703{ 703{
704#ifndef KORG_NOPRINTER 704#ifndef KORG_NOPRINTER
705 if (!mCalPrinter) { 705 if (!mCalPrinter) {
706 mCalPrinter = new CalPrinter(this, mCalendar); 706 mCalPrinter = new CalPrinter(this, mCalendar);
707 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 707 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
708 } 708 }
709#endif 709#endif
710} 710}
711 711
712 712
713//KOPrefs::instance()->mWriteBackFile 713//KOPrefs::instance()->mWriteBackFile
714//KOPrefs::instance()->mWriteBackExistingOnly 714//KOPrefs::instance()->mWriteBackExistingOnly
715 715
716// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 716// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
717// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 717// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
718// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 718// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
719// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 719// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
720// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 720// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
721// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 721// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
722 722
723int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 723int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
724{ 724{
725 725
726 // 0 equal 726 // 0 equal
727 // 1 take local 727 // 1 take local
728 // 2 take remote 728 // 2 take remote
729 // 3 cancel 729 // 3 cancel
730 QDateTime lastSync = mLastCalendarSync; 730 QDateTime lastSync = mLastCalendarSync;
731 QDateTime localMod = local->lastModified(); 731 QDateTime localMod = local->lastModified();
732 QDateTime remoteMod = remote->lastModified(); 732 QDateTime remoteMod = remote->lastModified();
733 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 733 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
734 bool remCh, locCh; 734 bool remCh, locCh;
735 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 735 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
736 //if ( remCh ) 736 //if ( remCh )
737 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 737 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
738 locCh = ( localMod > mLastCalendarSync ); 738 locCh = ( localMod > mLastCalendarSync );
739 if ( !remCh && ! locCh ) { 739 if ( !remCh && ! locCh ) {
740 //qDebug("both not changed "); 740 //qDebug("both not changed ");
741 lastSync = localMod.addDays(1); 741 lastSync = localMod.addDays(1);
742 if ( mode <= SYNC_PREF_ASK ) 742 if ( mode <= SYNC_PREF_ASK )
743 return 0; 743 return 0;
744 } else { 744 } else {
745 if ( locCh ) { 745 if ( locCh ) {
746 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 746 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
747 lastSync = localMod.addDays( -1 ); 747 lastSync = localMod.addDays( -1 );
748 if ( !remCh ) 748 if ( !remCh )
749 remoteMod = ( lastSync.addDays( -1 ) ); 749 remoteMod = ( lastSync.addDays( -1 ) );
750 } else { 750 } else {
751 //qDebug(" not loc changed "); 751 //qDebug(" not loc changed ");
752 lastSync = localMod.addDays( 1 ); 752 lastSync = localMod.addDays( 1 );
753 if ( remCh ) 753 if ( remCh )
754 remoteMod =( lastSync.addDays( 1 ) ); 754 remoteMod =( lastSync.addDays( 1 ) );
755 755
756 } 756 }
757 } 757 }
758 full = true; 758 full = true;
759 if ( mode < SYNC_PREF_ASK ) 759 if ( mode < SYNC_PREF_ASK )
760 mode = SYNC_PREF_ASK; 760 mode = SYNC_PREF_ASK;
761 } else { 761 } else {
762 if ( localMod == remoteMod ) 762 if ( localMod == remoteMod )
763 // if ( local->revision() == remote->revision() ) 763 // if ( local->revision() == remote->revision() )
764 return 0; 764 return 0;
765 765
766 } 766 }
767 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 767 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
768 768
769 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 769 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
770 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 770 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
771 //full = true; //debug only 771 //full = true; //debug only
772 if ( full ) { 772 if ( full ) {
773 bool equ = false; 773 bool equ = false;
774 if ( local->type() == "Event" ) { 774 if ( local->type() == "Event" ) {
775 equ = (*((Event*) local) == *((Event*) remote)); 775 equ = (*((Event*) local) == *((Event*) remote));
776 } 776 }
777 else if ( local->type() =="Todo" ) 777 else if ( local->type() =="Todo" )
778 equ = (*((Todo*) local) == (*(Todo*) remote)); 778 equ = (*((Todo*) local) == (*(Todo*) remote));
779 else if ( local->type() =="Journal" ) 779 else if ( local->type() =="Journal" )
780 equ = (*((Journal*) local) == *((Journal*) remote)); 780 equ = (*((Journal*) local) == *((Journal*) remote));
781 if ( equ ) { 781 if ( equ ) {
782 //qDebug("equal "); 782 //qDebug("equal ");
783 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 783 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
784 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 784 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
785 } 785 }
786 if ( mode < SYNC_PREF_FORCE_LOCAL ) 786 if ( mode < SYNC_PREF_FORCE_LOCAL )
787 return 0; 787 return 0;
788 788
789 }//else //debug only 789 }//else //debug only
790 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 790 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
791 } 791 }
792 int result; 792 int result;
793 bool localIsNew; 793 bool localIsNew;
794 //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() ); 794 //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() );
795 795
796 if ( full && mode < SYNC_PREF_NEWEST ) 796 if ( full && mode < SYNC_PREF_NEWEST )
797 mode = SYNC_PREF_ASK; 797 mode = SYNC_PREF_ASK;
798 798
799 switch( mode ) { 799 switch( mode ) {
800 case SYNC_PREF_LOCAL: 800 case SYNC_PREF_LOCAL:
801 if ( lastSync > remoteMod ) 801 if ( lastSync > remoteMod )
802 return 1; 802 return 1;
803 if ( lastSync > localMod ) 803 if ( lastSync > localMod )
804 return 2; 804 return 2;
805 return 1; 805 return 1;
806 break; 806 break;
807 case SYNC_PREF_REMOTE: 807 case SYNC_PREF_REMOTE:
808 if ( lastSync > remoteMod ) 808 if ( lastSync > remoteMod )
809 return 1; 809 return 1;
810 if ( lastSync > localMod ) 810 if ( lastSync > localMod )
811 return 2; 811 return 2;
812 return 2; 812 return 2;
813 break; 813 break;
814 case SYNC_PREF_NEWEST: 814 case SYNC_PREF_NEWEST:
815 if ( localMod > remoteMod ) 815 if ( localMod > remoteMod )
816 return 1; 816 return 1;
817 else 817 else
818 return 2; 818 return 2;
819 break; 819 break;
820 case SYNC_PREF_ASK: 820 case SYNC_PREF_ASK:
821 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 821 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
822 if ( lastSync > remoteMod ) 822 if ( lastSync > remoteMod )
823 return 1; 823 return 1;
824 if ( lastSync > localMod ) 824 if ( lastSync > localMod )
825 return 2; 825 return 2;
826 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 826 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
827 localIsNew = localMod >= remoteMod; 827 localIsNew = localMod >= remoteMod;
828 if ( localIsNew ) 828 if ( localIsNew )
829 getEventViewerDialog()->setColorMode( 1 ); 829 getEventViewerDialog()->setColorMode( 1 );
830 else 830 else
831 getEventViewerDialog()->setColorMode( 2 ); 831 getEventViewerDialog()->setColorMode( 2 );
832 getEventViewerDialog()->setIncidence(local); 832 getEventViewerDialog()->setIncidence(local);
833 if ( localIsNew ) 833 if ( localIsNew )
834 getEventViewerDialog()->setColorMode( 2 ); 834 getEventViewerDialog()->setColorMode( 2 );
835 else 835 else
836 getEventViewerDialog()->setColorMode( 1 ); 836 getEventViewerDialog()->setColorMode( 1 );
837 getEventViewerDialog()->addIncidence(remote); 837 getEventViewerDialog()->addIncidence(remote);
838 getEventViewerDialog()->setColorMode( 0 ); 838 getEventViewerDialog()->setColorMode( 0 );
839 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 839 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
840 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 840 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
841 getEventViewerDialog()->showMe(); 841 getEventViewerDialog()->showMe();
842 result = getEventViewerDialog()->executeS( localIsNew ); 842 result = getEventViewerDialog()->executeS( localIsNew );
843 return result; 843 return result;
844 844
845 break; 845 break;
846 case SYNC_PREF_FORCE_LOCAL: 846 case SYNC_PREF_FORCE_LOCAL:
847 return 1; 847 return 1;
848 break; 848 break;
849 case SYNC_PREF_FORCE_REMOTE: 849 case SYNC_PREF_FORCE_REMOTE:
850 return 2; 850 return 2;
851 break; 851 break;
852 852
853 default: 853 default:
854 // SYNC_PREF_TAKE_BOTH not implemented 854 // SYNC_PREF_TAKE_BOTH not implemented
855 break; 855 break;
856 } 856 }
857 return 0; 857 return 0;
858} 858}
859Event* CalendarView::getLastSyncEvent() 859Event* CalendarView::getLastSyncEvent()
860{ 860{
861 Event* lse; 861 Event* lse;
862 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 862 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
863 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 863 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
864 if (!lse) { 864 if (!lse) {
865 lse = new Event(); 865 lse = new Event();
866 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 866 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
867 QString sum = ""; 867 QString sum = "";
868 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 868 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
869 sum = "E: "; 869 sum = "E: ";
870 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 870 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
871 lse->setDtStart( mLastCalendarSync ); 871 lse->setDtStart( mLastCalendarSync );
872 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 872 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
873 lse->setCategories( i18n("SyncEvent") ); 873 lse->setCategories( i18n("SyncEvent") );
874 lse->setReadOnly( true ); 874 lse->setReadOnly( true );
875 mCalendar->addEvent( lse ); 875 mCalendar->addEvent( lse );
876 } 876 }
877 877
878 return lse; 878 return lse;
879 879
880} 880}
881 881
882// we check, if the to delete event has a id for a profile 882// we check, if the to delete event has a id for a profile
883// if yes, we set this id in the profile to delete 883// if yes, we set this id in the profile to delete
884void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 884void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
885{ 885{
886 if ( lastSync.count() == 0 ) { 886 if ( lastSync.count() == 0 ) {
887 //qDebug(" lastSync.count() == 0"); 887 //qDebug(" lastSync.count() == 0");
888 return; 888 return;
889 } 889 }
890 if ( toDelete->type() == "Journal" ) 890 if ( toDelete->type() == "Journal" )
891 return; 891 return;
892 892
893 Event* eve = lastSync.first(); 893 Event* eve = lastSync.first();
894 894
895 while ( eve ) { 895 while ( eve ) {
896 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 896 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
897 if ( !id.isEmpty() ) { 897 if ( !id.isEmpty() ) {
898 QString des = eve->description(); 898 QString des = eve->description();
899 QString pref = "e"; 899 QString pref = "e";
900 if ( toDelete->type() == "Todo" ) 900 if ( toDelete->type() == "Todo" )
901 pref = "t"; 901 pref = "t";
902 des += pref+ id + ","; 902 des += pref+ id + ",";
903 eve->setReadOnly( false ); 903 eve->setReadOnly( false );
904 eve->setDescription( des ); 904 eve->setDescription( des );
905 //qDebug("setdes %s ", des.latin1()); 905 //qDebug("setdes %s ", des.latin1());
906 eve->setReadOnly( true ); 906 eve->setReadOnly( true );
907 } 907 }
908 eve = lastSync.next(); 908 eve = lastSync.next();
909 } 909 }
910 910
911} 911}
912void CalendarView::checkExternalId( Incidence * inc ) 912void CalendarView::checkExternalId( Incidence * inc )
913{ 913{
914 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 914 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
915 checkExternSyncEvent( lastSync, inc ); 915 checkExternSyncEvent( lastSync, inc );
916 916
917} 917}
918bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 918bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
919{ 919{
920 bool syncOK = true; 920 bool syncOK = true;
921 int addedEvent = 0; 921 int addedEvent = 0;
922 int addedEventR = 0; 922 int addedEventR = 0;
923 int deletedEventR = 0; 923 int deletedEventR = 0;
924 int deletedEventL = 0; 924 int deletedEventL = 0;
925 int changedLocal = 0; 925 int changedLocal = 0;
926 int changedRemote = 0; 926 int changedRemote = 0;
927 //QPtrList<Event> el = local->rawEvents(); 927 //QPtrList<Event> el = local->rawEvents();
928 Event* eventR; 928 Event* eventR;
929 QString uid; 929 QString uid;
930 int take; 930 int take;
931 Event* eventL; 931 Event* eventL;
932 Event* eventRSync; 932 Event* eventRSync;
933 Event* eventLSync; 933 Event* eventLSync;
934 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 934 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
935 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 935 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
936 bool fullDateRange = false; 936 bool fullDateRange = false;
937 local->resetTempSyncStat(); 937 local->resetTempSyncStat();
938 mLastCalendarSync = QDateTime::currentDateTime(); 938 mLastCalendarSync = QDateTime::currentDateTime();
939 if ( mSyncManager->syncWithDesktop() ) { 939 if ( mSyncManager->syncWithDesktop() ) {
940 remote->resetPilotStat(1); 940 remote->resetPilotStat(1);
941 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 941 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
942 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 942 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
943 qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 943 qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
944 } else { 944 } else {
945 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 945 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
946 } 946 }
947 } 947 }
948 QDateTime modifiedCalendar = mLastCalendarSync; 948 QDateTime modifiedCalendar = mLastCalendarSync;
949 eventLSync = getLastSyncEvent(); 949 eventLSync = getLastSyncEvent();
950 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 950 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
951 if ( eventR ) { 951 if ( eventR ) {
952 eventRSync = (Event*) eventR->clone(); 952 eventRSync = (Event*) eventR->clone();
953 remote->deleteEvent(eventR ); 953 remote->deleteEvent(eventR );
954 954
955 } else { 955 } else {
956 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 956 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
957 eventRSync = (Event*)eventLSync->clone(); 957 eventRSync = (Event*)eventLSync->clone();
958 } else { 958 } else {
959 fullDateRange = true; 959 fullDateRange = true;
960 eventRSync = new Event(); 960 eventRSync = new Event();
961 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 961 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
962 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 962 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
963 eventRSync->setDtStart( mLastCalendarSync ); 963 eventRSync->setDtStart( mLastCalendarSync );
964 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 964 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
965 eventRSync->setCategories( i18n("SyncEvent") ); 965 eventRSync->setCategories( i18n("SyncEvent") );
966 } 966 }
967 } 967 }
968 if ( eventLSync->dtStart() == mLastCalendarSync ) 968 if ( eventLSync->dtStart() == mLastCalendarSync )
969 fullDateRange = true; 969 fullDateRange = true;
970 970
971 if ( ! fullDateRange ) { 971 if ( ! fullDateRange ) {
972 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 972 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
973 973
974 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 974 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
975 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 975 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
976 fullDateRange = true; 976 fullDateRange = true;
977 } 977 }
978 } 978 }
979 if ( mSyncManager->syncWithDesktop() ) { 979 if ( mSyncManager->syncWithDesktop() ) {
980 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 980 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
981 } 981 }
982 if ( fullDateRange ) 982 if ( fullDateRange )
983 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 983 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
984 else 984 else
985 mLastCalendarSync = eventLSync->dtStart(); 985 mLastCalendarSync = eventLSync->dtStart();
986 // for resyncing if own file has changed 986 // for resyncing if own file has changed
987 if ( mCurrentSyncDevice == "deleteaftersync" ) { 987 if ( mCurrentSyncDevice == "deleteaftersync" ) {
988 mLastCalendarSync = loadedFileVersion; 988 mLastCalendarSync = loadedFileVersion;
989 //qDebug("setting mLastCalendarSync "); 989 //qDebug("setting mLastCalendarSync ");
990 } 990 }
991 //qDebug("*************************** "); 991 //qDebug("*************************** ");
992 qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 992 qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
993 QPtrList<Incidence> er = remote->rawIncidences(); 993 QPtrList<Incidence> er = remote->rawIncidences();
994 Incidence* inR = er.first(); 994 Incidence* inR = er.first();
995 Incidence* inL; 995 Incidence* inL;
996 QProgressBar bar( er.count(),0 ); 996 QProgressBar bar( er.count(),0 );
997 bar.setCaption (i18n("Syncing - close to abort!") ); 997 bar.setCaption (i18n("Syncing - close to abort!") );
998 998
999 // ************** setting up filter *************
1000 CalFilter *filterIN = 0;
1001 CalFilter *filterOUT = 0;
1002 CalFilter *filter = mFilters.first();
1003 while(filter) {
1004 if ( filter->name() == mSyncManager->mFilterInCal )
1005 filterIN = filter;
1006 if ( filter->name() == mSyncManager->mFilterOutCal )
1007 filterOUT = filter;
1008 filter = mFilters.next();
1009 }
999 int w = 300; 1010 int w = 300;
1000 if ( QApplication::desktop()->width() < 320 ) 1011 if ( QApplication::desktop()->width() < 320 )
1001 w = 220; 1012 w = 220;
1002 int h = bar.sizeHint().height() ; 1013 int h = bar.sizeHint().height() ;
1003 int dw = QApplication::desktop()->width(); 1014 int dw = QApplication::desktop()->width();
1004 int dh = QApplication::desktop()->height(); 1015 int dh = QApplication::desktop()->height();
1005 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1016 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1006 bar.show(); 1017 bar.show();
1007 int modulo = (er.count()/10)+1; 1018 int modulo = (er.count()/10)+1;
1008 int incCounter = 0; 1019 int incCounter = 0;
1009 while ( inR ) { 1020 while ( inR ) {
1010 if ( ! bar.isVisible() ) 1021 if ( ! bar.isVisible() )
1011 return false; 1022 return false;
1012 if ( incCounter % modulo == 0 ) 1023 if ( incCounter % modulo == 0 )
1013 bar.setProgress( incCounter ); 1024 bar.setProgress( incCounter );
1014 ++incCounter; 1025 ++incCounter;
1015 uid = inR->uid(); 1026 uid = inR->uid();
1016 bool skipIncidence = false; 1027 bool skipIncidence = false;
1017 if ( uid.left(15) == QString("last-syncEvent-") ) 1028 if ( uid.left(15) == QString("last-syncEvent-") )
1018 skipIncidence = true; 1029 skipIncidence = true;
1019 QString idS; 1030 QString idS;
1020 qApp->processEvents(); 1031 qApp->processEvents();
1021 if ( !skipIncidence ) { 1032 if ( !skipIncidence ) {
1022 inL = local->incidence( uid ); 1033 inL = local->incidence( uid );
1023 if ( inL ) { // maybe conflict - same uid in both calendars 1034 if ( inL ) { // maybe conflict - same uid in both calendars
1024 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1035 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1025 //qDebug("take %d %s ", take, inL->summary().latin1()); 1036 //qDebug("take %d %s ", take, inL->summary().latin1());
1026 if ( take == 3 ) 1037 if ( take == 3 )
1027 return false; 1038 return false;
1028 if ( take == 1 ) {// take local ********************** 1039 if ( take == 1 ) {// take local **********************
1029 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1040 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1030 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1041 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1031 else 1042 else
1032 idS = inR->IDStr(); 1043 idS = inR->IDStr();
1033 remote->deleteIncidence( inR ); 1044 remote->deleteIncidence( inR );
1034 inR = inL->clone(); 1045 inR = inL->clone();
1035 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1046 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1036 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1047 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1037 inR->setIDStr( idS ); 1048 inR->setIDStr( idS );
1038 remote->addIncidence( inR ); 1049 remote->addIncidence( inR );
1039 if ( mSyncManager->syncWithDesktop() ) 1050 if ( mSyncManager->syncWithDesktop() )
1040 inR->setPilotId( 2 ); 1051 inR->setPilotId( 2 );
1041 ++changedRemote; 1052 ++changedRemote;
1042 } else {// take remote ********************** 1053 } else {// take remote **********************
1043 idS = inL->IDStr(); 1054 idS = inL->IDStr();
1044 int pid = inL->pilotId(); 1055 int pid = inL->pilotId();
1045 local->deleteIncidence( inL ); 1056 local->deleteIncidence( inL );
1046 inL = inR->clone(); 1057 inL = inR->clone();
1047 if ( mSyncManager->syncWithDesktop() ) 1058 if ( mSyncManager->syncWithDesktop() )
1048 inL->setPilotId( pid ); 1059 inL->setPilotId( pid );
1049 inL->setIDStr( idS ); 1060 inL->setIDStr( idS );
1050 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1061 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1051 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1062 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1052 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1063 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1053 } 1064 }
1054 local->addIncidence( inL ); 1065 local->addIncidence( inL );
1055 ++changedLocal; 1066 ++changedLocal;
1056 } 1067 }
1057 } 1068 }
1058 } else { // no conflict ********** add or delete remote 1069 } else { // no conflict ********** add or delete remote
1059 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1070 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1060 QString des = eventLSync->description(); 1071 QString des = eventLSync->description();
1061 QString pref = "e"; 1072 QString pref = "e";
1062 if ( inR->type() == "Todo" ) 1073 if ( inR->type() == "Todo" )
1063 pref = "t"; 1074 pref = "t";
1064 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1075 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1065 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1076 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1066 //remote->deleteIncidence( inR ); 1077 //remote->deleteIncidence( inR );
1067 ++deletedEventR; 1078 ++deletedEventR;
1068 } else { 1079 } else {
1069 inR->setLastModified( modifiedCalendar ); 1080 inR->setLastModified( modifiedCalendar );
1070 inL = inR->clone(); 1081 inL = inR->clone();
1071 inL->setIDStr( ":" ); 1082 inL->setIDStr( ":" );
1072 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1083 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1073 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1084 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1074 local->addIncidence( inL ); 1085 local->addIncidence( inL );
1075 ++addedEvent; 1086 ++addedEvent;
1076 } 1087 }
1077 } else { 1088 } else {
1078 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1089 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1079 inR->setLastModified( modifiedCalendar ); 1090 inR->setLastModified( modifiedCalendar );
1080 inL = inR->clone(); 1091 inL = inR->clone();
1081 inL->setIDStr( ":" ); 1092 inL->setIDStr( ":" );
1082 local->addIncidence( inL ); 1093 local->addIncidence( inL );
1083 ++addedEvent; 1094 ++addedEvent;
1084 } else { 1095 } else {
1085 checkExternSyncEvent(eventRSyncSharp, inR); 1096 checkExternSyncEvent(eventRSyncSharp, inR);
1086 remote->deleteIncidence( inR ); 1097 remote->deleteIncidence( inR );
1087 ++deletedEventR; 1098 ++deletedEventR;
1088 } 1099 }
1089 } 1100 }
1090 } 1101 }
1091 } 1102 }
1092 inR = er.next(); 1103 inR = er.next();
1093 } 1104 }
1094 QPtrList<Incidence> el = local->rawIncidences(); 1105 QPtrList<Incidence> el = local->rawIncidences();
1095 inL = el.first(); 1106 inL = el.first();
1096 modulo = (el.count()/10)+1; 1107 modulo = (el.count()/10)+1;
1097 bar.setCaption (i18n("Add / remove events") ); 1108 bar.setCaption (i18n("Add / remove events") );
1098 bar.setTotalSteps ( el.count() ) ; 1109 bar.setTotalSteps ( el.count() ) ;
1099 bar.show(); 1110 bar.show();
1100 incCounter = 0; 1111 incCounter = 0;
1101 1112
1102 while ( inL ) { 1113 while ( inL ) {
1103 1114
1104 qApp->processEvents(); 1115 qApp->processEvents();
1105 if ( ! bar.isVisible() ) 1116 if ( ! bar.isVisible() )
1106 return false; 1117 return false;
1107 if ( incCounter % modulo == 0 ) 1118 if ( incCounter % modulo == 0 )
1108 bar.setProgress( incCounter ); 1119 bar.setProgress( incCounter );
1109 ++incCounter; 1120 ++incCounter;
1110 uid = inL->uid(); 1121 uid = inL->uid();
1111 bool skipIncidence = false; 1122 bool skipIncidence = false;
1112 if ( uid.left(15) == QString("last-syncEvent-") ) 1123 if ( uid.left(15) == QString("last-syncEvent-") )
1113 skipIncidence = true; 1124 skipIncidence = true;
1114 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1125 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1115 skipIncidence = true; 1126 skipIncidence = true;
1116 if ( !skipIncidence ) { 1127 if ( !skipIncidence ) {
1117 inR = remote->incidence( uid ); 1128 inR = remote->incidence( uid );
1118 if ( ! inR ) { // no conflict ********** add or delete local 1129 if ( ! inR ) { // no conflict ********** add or delete local
1119 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1130 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1120 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1131 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1121 checkExternSyncEvent(eventLSyncSharp, inL); 1132 checkExternSyncEvent(eventLSyncSharp, inL);
1122 local->deleteIncidence( inL ); 1133 local->deleteIncidence( inL );
1123 ++deletedEventL; 1134 ++deletedEventL;
1124 } else { 1135 } else {
1125 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1136 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1126 inL->removeID(mCurrentSyncDevice ); 1137 inL->removeID(mCurrentSyncDevice );
1127 ++addedEventR; 1138 ++addedEventR;
1128 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1139 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1129 inL->setLastModified( modifiedCalendar ); 1140 inL->setLastModified( modifiedCalendar );
1130 inR = inL->clone(); 1141 inR = inL->clone();
1131 inR->setIDStr( ":" ); 1142 inR->setIDStr( ":" );
1132 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1143 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1133 remote->addIncidence( inR ); 1144 remote->addIncidence( inR );
1134 } 1145 }
1135 } 1146 }
1136 } else { 1147 } else {
1137 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1148 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1138 checkExternSyncEvent(eventLSyncSharp, inL); 1149 checkExternSyncEvent(eventLSyncSharp, inL);
1139 local->deleteIncidence( inL ); 1150 local->deleteIncidence( inL );
1140 ++deletedEventL; 1151 ++deletedEventL;
1141 } else { 1152 } else {
1142 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1153 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1143 ++addedEventR; 1154 ++addedEventR;
1144 inL->setLastModified( modifiedCalendar ); 1155 inL->setLastModified( modifiedCalendar );
1145 inR = inL->clone(); 1156 inR = inL->clone();
1146 inR->setIDStr( ":" ); 1157 inR->setIDStr( ":" );
1147 remote->addIncidence( inR ); 1158 remote->addIncidence( inR );
1148 } 1159 }
1149 } 1160 }
1150 } 1161 }
1151 } 1162 }
1152 } 1163 }
1153 inL = el.next(); 1164 inL = el.next();
1154 } 1165 }
1155 int delFut = 0; 1166 int delFut = 0;
1156 int remRem = 0; 1167 int remRem = 0;
1157 if ( mSyncManager->mWriteBackInFuture ) { 1168 if ( mSyncManager->mWriteBackInFuture ) {
1158 er = remote->rawIncidences(); 1169 er = remote->rawIncidences();
1159 remRem = er.count(); 1170 remRem = er.count();
1160 inR = er.first(); 1171 inR = er.first();
1161 QDateTime dt; 1172 QDateTime dt;
1162 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1173 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1163 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1174 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1164 while ( inR ) { 1175 while ( inR ) {
1165 if ( inR->type() == "Todo" ) { 1176 if ( inR->type() == "Todo" ) {
1166 Todo * t = (Todo*)inR; 1177 Todo * t = (Todo*)inR;
1167 if ( t->hasDueDate() ) 1178 if ( t->hasDueDate() )
1168 dt = t->dtDue(); 1179 dt = t->dtDue();
1169 else 1180 else
1170 dt = cur.addSecs( 62 ); 1181 dt = cur.addSecs( 62 );
1171 } 1182 }
1172 else if (inR->type() == "Event" ) { 1183 else if (inR->type() == "Event" ) {
1173 bool ok; 1184 bool ok;
1174 dt = inR->getNextOccurence( cur, &ok ); 1185 dt = inR->getNextOccurence( cur, &ok );
1175 if ( !ok ) 1186 if ( !ok )
1176 dt = cur.addSecs( -62 ); 1187 dt = cur.addSecs( -62 );
1177 } 1188 }
1178 else 1189 else
1179 dt = inR->dtStart(); 1190 dt = inR->dtStart();
1180 if ( dt < cur || dt > end ) { 1191 if ( dt < cur || dt > end ) {
1181 remote->deleteIncidence( inR ); 1192 remote->deleteIncidence( inR );
1182 ++delFut; 1193 ++delFut;
1183 } 1194 }
1184 inR = er.next(); 1195 inR = er.next();
1185 } 1196 }
1186 } 1197 }
1187 bar.hide(); 1198 bar.hide();
1188 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1199 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1189 eventLSync->setReadOnly( false ); 1200 eventLSync->setReadOnly( false );
1190 eventLSync->setDtStart( mLastCalendarSync ); 1201 eventLSync->setDtStart( mLastCalendarSync );
1191 eventRSync->setDtStart( mLastCalendarSync ); 1202 eventRSync->setDtStart( mLastCalendarSync );
1192 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1203 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1193 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1204 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1194 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1205 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1195 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1206 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1196 eventLSync->setReadOnly( true ); 1207 eventLSync->setReadOnly( true );
1197 qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() ); 1208 qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() );
1198 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1209 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1199 remote->addEvent( eventRSync ); 1210 remote->addEvent( eventRSync );
1200 else 1211 else
1201 delete eventRSync; 1212 delete eventRSync;
1202 QString mes; 1213 QString mes;
1203 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 ); 1214 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 );
1204 QString delmess; 1215 QString delmess;
1205 if ( delFut ) { 1216 if ( delFut ) {
1206 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); 1217 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut);
1207 mes += delmess; 1218 mes += delmess;
1208 } 1219 }
1209 mes = i18n("Local calendar changed!\n") +mes; 1220 mes = i18n("Local calendar changed!\n") +mes;
1210 mCalendar->checkAlarmForIncidence( 0, true ); 1221 mCalendar->checkAlarmForIncidence( 0, true );
1211 qDebug( mes ); 1222 qDebug( mes );
1212 if ( mSyncManager->mShowSyncSummary ) { 1223 if ( mSyncManager->mShowSyncSummary ) {
1213 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1224 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1214 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1225 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1215 qDebug("cancelled "); 1226 qDebug("cancelled ");
1216 return false; 1227 return false;
1217 } 1228 }
1218 } 1229 }
1219 return syncOK; 1230 return syncOK;
1220} 1231}
1221 1232
1222void CalendarView::setSyncDevice( QString s ) 1233void CalendarView::setSyncDevice( QString s )
1223{ 1234{
1224 mCurrentSyncDevice= s; 1235 mCurrentSyncDevice= s;
1225} 1236}
1226void CalendarView::setSyncName( QString s ) 1237void CalendarView::setSyncName( QString s )
1227{ 1238{
1228 mCurrentSyncName= s; 1239 mCurrentSyncName= s;
1229} 1240}
1230bool CalendarView::syncCalendar(QString filename, int mode) 1241bool CalendarView::syncCalendar(QString filename, int mode)
1231{ 1242{
1232 //qDebug("syncCalendar %s ", filename.latin1()); 1243 //qDebug("syncCalendar %s ", filename.latin1());
1233 mGlobalSyncMode = SYNC_MODE_NORMAL; 1244 mGlobalSyncMode = SYNC_MODE_NORMAL;
1234 CalendarLocal* calendar = new CalendarLocal(); 1245 CalendarLocal* calendar = new CalendarLocal();
1235 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1246 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1236 FileStorage* storage = new FileStorage( calendar ); 1247 FileStorage* storage = new FileStorage( calendar );
1237 bool syncOK = false; 1248 bool syncOK = false;
1238 storage->setFileName( filename ); 1249 storage->setFileName( filename );
1239 // qDebug("loading ... "); 1250 // qDebug("loading ... ");
1240 if ( storage->load() ) { 1251 if ( storage->load() ) {
1241 getEventViewerDialog()->setSyncMode( true ); 1252 getEventViewerDialog()->setSyncMode( true );
1242 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1253 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1243 getEventViewerDialog()->setSyncMode( false ); 1254 getEventViewerDialog()->setSyncMode( false );
1244 if ( syncOK ) { 1255 if ( syncOK ) {
1245 if ( mSyncManager->mWriteBackFile ) 1256 if ( mSyncManager->mWriteBackFile )
1246 { 1257 {
1247 storage->setSaveFormat( new ICalFormat() ); 1258 storage->setSaveFormat( new ICalFormat() );
1248 storage->save(); 1259 storage->save();
1249 } 1260 }
1250 } 1261 }
1251 setModified( true ); 1262 setModified( true );
1252 } 1263 }
1253 delete storage; 1264 delete storage;
1254 delete calendar; 1265 delete calendar;
1255 if ( syncOK ) 1266 if ( syncOK )
1256 updateView(); 1267 updateView();
1257 return syncOK; 1268 return syncOK;
1258} 1269}
1259 1270
1260void CalendarView::syncExternal( int mode ) 1271void CalendarView::syncExternal( int mode )
1261{ 1272{
1262 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1273 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1263 1274
1264 qApp->processEvents(); 1275 qApp->processEvents();
1265 CalendarLocal* calendar = new CalendarLocal(); 1276 CalendarLocal* calendar = new CalendarLocal();
1266 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1277 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1267 bool syncOK = false; 1278 bool syncOK = false;
1268 bool loadSuccess = false; 1279 bool loadSuccess = false;
1269 PhoneFormat* phoneFormat = 0; 1280 PhoneFormat* phoneFormat = 0;
1270 emit tempDisableBR(true); 1281 emit tempDisableBR(true);
1271#ifndef DESKTOP_VERSION 1282#ifndef DESKTOP_VERSION
1272 SharpFormat* sharpFormat = 0; 1283 SharpFormat* sharpFormat = 0;
1273 if ( mode == 0 ) { // sharp 1284 if ( mode == 0 ) { // sharp
1274 sharpFormat = new SharpFormat () ; 1285 sharpFormat = new SharpFormat () ;
1275 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1286 loadSuccess = sharpFormat->load( calendar, mCalendar );
1276 1287
1277 } else 1288 } else
1278#endif 1289#endif
1279 if ( mode == 1 ) { // phone 1290 if ( mode == 1 ) { // phone
1280 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1291 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1281 mSyncManager->mPhoneDevice, 1292 mSyncManager->mPhoneDevice,
1282 mSyncManager->mPhoneConnection, 1293 mSyncManager->mPhoneConnection,
1283 mSyncManager->mPhoneModel); 1294 mSyncManager->mPhoneModel);
1284 loadSuccess = phoneFormat->load( calendar,mCalendar); 1295 loadSuccess = phoneFormat->load( calendar,mCalendar);
1285 1296
1286 } else { 1297 } else {
1287 emit tempDisableBR(false); 1298 emit tempDisableBR(false);
1288 return; 1299 return;
1289 } 1300 }
1290 if ( loadSuccess ) { 1301 if ( loadSuccess ) {
1291 getEventViewerDialog()->setSyncMode( true ); 1302 getEventViewerDialog()->setSyncMode( true );
1292 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1303 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1293 getEventViewerDialog()->setSyncMode( false ); 1304 getEventViewerDialog()->setSyncMode( false );
1294 qApp->processEvents(); 1305 qApp->processEvents();
1295 if ( syncOK ) { 1306 if ( syncOK ) {
1296 if ( mSyncManager->mWriteBackFile ) 1307 if ( mSyncManager->mWriteBackFile )
1297 { 1308 {
1298 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1309 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1299 Incidence* inc = iL.first(); 1310 Incidence* inc = iL.first();
1300 if ( phoneFormat ) { 1311 if ( phoneFormat ) {
1301 while ( inc ) { 1312 while ( inc ) {
1302 inc->removeID(mCurrentSyncDevice); 1313 inc->removeID(mCurrentSyncDevice);
1303 inc = iL.next(); 1314 inc = iL.next();
1304 } 1315 }
1305 } 1316 }
1306#ifndef DESKTOP_VERSION 1317#ifndef DESKTOP_VERSION
1307 if ( sharpFormat ) 1318 if ( sharpFormat )
1308 sharpFormat->save(calendar); 1319 sharpFormat->save(calendar);
1309#endif 1320#endif
1310 if ( phoneFormat ) 1321 if ( phoneFormat )
1311 phoneFormat->save(calendar); 1322 phoneFormat->save(calendar);
1312 iL = calendar->rawIncidences(); 1323 iL = calendar->rawIncidences();
1313 inc = iL.first(); 1324 inc = iL.first();
1314 Incidence* loc; 1325 Incidence* loc;
1315 while ( inc ) { 1326 while ( inc ) {
1316 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1327 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1317 loc = mCalendar->incidence(inc->uid() ); 1328 loc = mCalendar->incidence(inc->uid() );
1318 if ( loc ) { 1329 if ( loc ) {
1319 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1330 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1320 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1331 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1321 } 1332 }
1322 } 1333 }
1323 inc = iL.next(); 1334 inc = iL.next();
1324 } 1335 }
1325 Incidence* lse = getLastSyncEvent(); 1336 Incidence* lse = getLastSyncEvent();
1326 if ( lse ) { 1337 if ( lse ) {
1327 lse->setReadOnly( false ); 1338 lse->setReadOnly( false );
1328 lse->setDescription( "" ); 1339 lse->setDescription( "" );
1329 lse->setReadOnly( true ); 1340 lse->setReadOnly( true );
1330 } 1341 }
1331 } 1342 }
1332 } else { 1343 } else {
1333 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1344 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1334 } 1345 }
1335 setModified( true ); 1346 setModified( true );
1336 } else { 1347 } else {
1337 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1348 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1338 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1349 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1339 question, i18n("Ok")) ; 1350 question, i18n("Ok")) ;
1340 1351
1341 } 1352 }
1342 delete calendar; 1353 delete calendar;
1343 updateView(); 1354 updateView();
1344 emit tempDisableBR(false); 1355 emit tempDisableBR(false);
1345 return ;//syncOK; 1356 return ;//syncOK;
1346 1357
1347} 1358}
1348 1359
1349bool CalendarView::importBday() 1360bool CalendarView::importBday()
1350{ 1361{
1351#ifndef KORG_NOKABC 1362#ifndef KORG_NOKABC
1352 1363
1353#ifdef DESKTOP_VERSION 1364#ifdef DESKTOP_VERSION
1354 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1365 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1355 KABC::AddressBook::Iterator it; 1366 KABC::AddressBook::Iterator it;
1356 int count = 0; 1367 int count = 0;
1357 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1368 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1358 ++count; 1369 ++count;
1359 } 1370 }
1360 QProgressBar bar(count,0 ); 1371 QProgressBar bar(count,0 );
1361 int w = 300; 1372 int w = 300;
1362 if ( QApplication::desktop()->width() < 320 ) 1373 if ( QApplication::desktop()->width() < 320 )
1363 w = 220; 1374 w = 220;
1364 int h = bar.sizeHint().height() ; 1375 int h = bar.sizeHint().height() ;
1365 int dw = QApplication::desktop()->width(); 1376 int dw = QApplication::desktop()->width();
1366 int dh = QApplication::desktop()->height(); 1377 int dh = QApplication::desktop()->height();
1367 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1378 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1368 bar.show(); 1379 bar.show();
1369 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1380 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1370 qApp->processEvents(); 1381 qApp->processEvents();
1371 count = 0; 1382 count = 0;
1372 int addCount = 0; 1383 int addCount = 0;
1373 KCal::Attendee* a = 0; 1384 KCal::Attendee* a = 0;
1374 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1385 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1375 if ( ! bar.isVisible() ) 1386 if ( ! bar.isVisible() )
1376 return false; 1387 return false;
1377 bar.setProgress( count++ ); 1388 bar.setProgress( count++ );
1378 qApp->processEvents(); 1389 qApp->processEvents();
1379 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1390 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1380 if ( (*it).birthday().date().isValid() ){ 1391 if ( (*it).birthday().date().isValid() ){
1381 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1392 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1382 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1393 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1383 ++addCount; 1394 ++addCount;
1384 } 1395 }
1385 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1396 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1386 if ( anni.isValid() ){ 1397 if ( anni.isValid() ){
1387 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1398 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1388 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1399 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1389 ++addCount; 1400 ++addCount;
1390 } 1401 }
1391 } 1402 }
1392 updateView(); 1403 updateView();
1393 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1404 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1394#else //DESKTOP_VERSION 1405#else //DESKTOP_VERSION
1395 1406
1396 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1407 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1397 // the result should now arrive through method insertBirthdays 1408 // the result should now arrive through method insertBirthdays
1398 1409
1399#endif //DESKTOP_VERSION 1410#endif //DESKTOP_VERSION
1400 1411
1401#endif //KORG_NOKABC 1412#endif //KORG_NOKABC
1402 1413
1403 1414
1404 return true; 1415 return true;
1405} 1416}
1406 1417
1407// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1418// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1408void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1419void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1409 const QStringList& anniversaryList, const QStringList& realNameList, 1420 const QStringList& anniversaryList, const QStringList& realNameList,
1410 const QStringList& emailList, const QStringList& assembledNameList, 1421 const QStringList& emailList, const QStringList& assembledNameList,
1411 const QStringList& uidList) 1422 const QStringList& uidList)
1412{ 1423{
1413 qDebug("CalendarView::insertBirthdays"); 1424 qDebug("CalendarView::insertBirthdays");
1414 if (uid == this->name()) 1425 if (uid == this->name())
1415 { 1426 {
1416 int count = birthdayList.count(); 1427 int count = birthdayList.count();
1417 int addCount = 0; 1428 int addCount = 0;
1418 KCal::Attendee* a = 0; 1429 KCal::Attendee* a = 0;
1419 1430
1420 qDebug("CalView 1 %i", count); 1431 qDebug("CalView 1 %i", count);
1421 1432
1422 QProgressBar bar(count,0 ); 1433 QProgressBar bar(count,0 );
1423 int w = 300; 1434 int w = 300;
1424 if ( QApplication::desktop()->width() < 320 ) 1435 if ( QApplication::desktop()->width() < 320 )
1425 w = 220; 1436 w = 220;
1426 int h = bar.sizeHint().height() ; 1437 int h = bar.sizeHint().height() ;
1427 int dw = QApplication::desktop()->width(); 1438 int dw = QApplication::desktop()->width();
1428 int dh = QApplication::desktop()->height(); 1439 int dh = QApplication::desktop()->height();
1429 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1440 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1430 bar.show(); 1441 bar.show();
1431 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1442 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1432 qApp->processEvents(); 1443 qApp->processEvents();
1433 1444
1434 QDate birthday; 1445 QDate birthday;
1435 QDate anniversary; 1446 QDate anniversary;
1436 QString realName; 1447 QString realName;
1437 QString email; 1448 QString email;
1438 QString assembledName; 1449 QString assembledName;
1439 QString uid; 1450 QString uid;
1440 bool ok = true; 1451 bool ok = true;
1441 for ( int i = 0; i < count; i++) 1452 for ( int i = 0; i < count; i++)
1442 { 1453 {
1443 if ( ! bar.isVisible() ) 1454 if ( ! bar.isVisible() )
1444 return; 1455 return;
1445 bar.setProgress( i ); 1456 bar.setProgress( i );
1446 qApp->processEvents(); 1457 qApp->processEvents();
1447 1458
1448 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1459 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1449 if (!ok) { 1460 if (!ok) {
1450 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1461 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1451 } 1462 }
1452 1463
1453 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1464 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1454 if (!ok) { 1465 if (!ok) {
1455 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1466 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1456 } 1467 }
1457 realName = realNameList[i]; 1468 realName = realNameList[i];
1458 email = emailList[i]; 1469 email = emailList[i];
1459 assembledName = assembledNameList[i]; 1470 assembledName = assembledNameList[i];
1460 uid = uidList[i]; 1471 uid = uidList[i];
1461 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); 1472 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() );
1462 1473
1463 if ( birthday.isValid() ){ 1474 if ( birthday.isValid() ){
1464 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1475 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1465 KCal::Attendee::ReqParticipant,uid) ; 1476 KCal::Attendee::ReqParticipant,uid) ;
1466 if ( addAnniversary( birthday, assembledName, a, true ) ) 1477 if ( addAnniversary( birthday, assembledName, a, true ) )
1467 ++addCount; 1478 ++addCount;
1468 } 1479 }
1469 1480
1470 if ( anniversary.isValid() ){ 1481 if ( anniversary.isValid() ){
1471 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1482 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1472 KCal::Attendee::ReqParticipant,uid) ; 1483 KCal::Attendee::ReqParticipant,uid) ;
1473 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1484 if ( addAnniversary( anniversary, assembledName, a, false ) )
1474 ++addCount; 1485 ++addCount;
1475 } 1486 }
1476 } 1487 }
1477 1488
1478 updateView(); 1489 updateView();
1479 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1490 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1480 1491
1481 } 1492 }
1482 1493
1483} 1494}
1484 1495
1485 1496
1486 1497
1487bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1498bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1488{ 1499{
1489 //qDebug("addAnni "); 1500 //qDebug("addAnni ");
1490 Event * ev = new Event(); 1501 Event * ev = new Event();
1491 if ( a ) { 1502 if ( a ) {
1492 ev->addAttendee( a ); 1503 ev->addAttendee( a );
1493 } 1504 }
1494 QString kind; 1505 QString kind;
1495 if ( birthday ) 1506 if ( birthday )
1496 kind = i18n( "Birthday" ); 1507 kind = i18n( "Birthday" );
1497 else 1508 else
1498 kind = i18n( "Anniversary" ); 1509 kind = i18n( "Anniversary" );
1499 ev->setSummary( name + " - " + kind ); 1510 ev->setSummary( name + " - " + kind );
1500 ev->setOrganizer(a->email()); 1511 ev->setOrganizer(a->email());
1501 ev->setCategories( kind ); 1512 ev->setCategories( kind );
1502 ev->setDtStart( QDateTime(date) ); 1513 ev->setDtStart( QDateTime(date) );
1503 ev->setDtEnd( QDateTime(date) ); 1514 ev->setDtEnd( QDateTime(date) );
1504 ev->setFloats( true ); 1515 ev->setFloats( true );
1505 Recurrence * rec = ev->recurrence(); 1516 Recurrence * rec = ev->recurrence();
1506 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1517 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1507 rec->addYearlyNum( date.month() ); 1518 rec->addYearlyNum( date.month() );
1508 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1519 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1509 delete ev; 1520 delete ev;
1510 return false; 1521 return false;
1511 } 1522 }
1512 return true; 1523 return true;
1513 1524
1514} 1525}
1515bool CalendarView::importQtopia( const QString &categories, 1526bool CalendarView::importQtopia( const QString &categories,
1516 const QString &datebook, 1527 const QString &datebook,
1517 const QString &todolist ) 1528 const QString &todolist )
1518{ 1529{
1519 1530
1520 QtopiaFormat qtopiaFormat; 1531 QtopiaFormat qtopiaFormat;
1521 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1532 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1522 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1533 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1523 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1534 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1524 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1535 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1525 1536
1526 updateView(); 1537 updateView();
1527 return true; 1538 return true;
1528 1539
1529#if 0 1540#if 0
1530 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1541 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1531 mCurrentSyncDevice = "qtopia-XML"; 1542 mCurrentSyncDevice = "qtopia-XML";
1532 if ( mSyncManager->mAskForPreferences ) 1543 if ( mSyncManager->mAskForPreferences )
1533 edit_sync_options(); 1544 edit_sync_options();
1534 qApp->processEvents(); 1545 qApp->processEvents();
1535 CalendarLocal* calendar = new CalendarLocal(); 1546 CalendarLocal* calendar = new CalendarLocal();
1536 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1547 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1537 bool syncOK = false; 1548 bool syncOK = false;
1538 QtopiaFormat qtopiaFormat; 1549 QtopiaFormat qtopiaFormat;
1539 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1550 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1540 bool loadOk = true; 1551 bool loadOk = true;
1541 if ( !categories.isEmpty() ) 1552 if ( !categories.isEmpty() )
1542 loadOk = qtopiaFormat.load( calendar, categories ); 1553 loadOk = qtopiaFormat.load( calendar, categories );
1543 if ( loadOk && !datebook.isEmpty() ) 1554 if ( loadOk && !datebook.isEmpty() )
1544 loadOk = qtopiaFormat.load( calendar, datebook ); 1555 loadOk = qtopiaFormat.load( calendar, datebook );
1545 if ( loadOk && !todolist.isEmpty() ) 1556 if ( loadOk && !todolist.isEmpty() )
1546 loadOk = qtopiaFormat.load( calendar, todolist ); 1557 loadOk = qtopiaFormat.load( calendar, todolist );
1547 1558
1548 if ( loadOk ) { 1559 if ( loadOk ) {
1549 getEventViewerDialog()->setSyncMode( true ); 1560 getEventViewerDialog()->setSyncMode( true );
1550 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1561 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1551 getEventViewerDialog()->setSyncMode( false ); 1562 getEventViewerDialog()->setSyncMode( false );
1552 qApp->processEvents(); 1563 qApp->processEvents();
1553 if ( syncOK ) { 1564 if ( syncOK ) {
1554 if ( mSyncManager->mWriteBackFile ) 1565 if ( mSyncManager->mWriteBackFile )
1555 { 1566 {
1556 // write back XML file 1567 // write back XML file
1557 1568
1558 } 1569 }
1559 setModified( true ); 1570 setModified( true );
1560 } 1571 }
1561 } else { 1572 } else {
1562 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1573 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1563 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1574 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1564 question, i18n("Ok")) ; 1575 question, i18n("Ok")) ;
1565 } 1576 }
1566 delete calendar; 1577 delete calendar;
1567 updateView(); 1578 updateView();
1568 return syncOK; 1579 return syncOK;
1569 1580
1570 1581
1571#endif 1582#endif
1572 1583
1573} 1584}
1574 1585
1575void CalendarView::setSyncEventsReadOnly() 1586void CalendarView::setSyncEventsReadOnly()
1576{ 1587{
1577 Event * ev; 1588 Event * ev;
1578 QPtrList<Event> eL = mCalendar->rawEvents(); 1589 QPtrList<Event> eL = mCalendar->rawEvents();
1579 ev = eL.first(); 1590 ev = eL.first();
1580 while ( ev ) { 1591 while ( ev ) {
1581 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1592 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1582 ev->setReadOnly( true ); 1593 ev->setReadOnly( true );
1583 ev = eL.next(); 1594 ev = eL.next();
1584 } 1595 }
1585} 1596}
1586bool CalendarView::openCalendar(QString filename, bool merge) 1597bool CalendarView::openCalendar(QString filename, bool merge)
1587{ 1598{
1588 1599
1589 if (filename.isEmpty()) { 1600 if (filename.isEmpty()) {
1590 return false; 1601 return false;
1591 } 1602 }
1592 1603
1593 if (!QFile::exists(filename)) { 1604 if (!QFile::exists(filename)) {
1594 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1605 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1595 return false; 1606 return false;
1596 } 1607 }
1597 1608
1598 globalFlagBlockAgenda = 1; 1609 globalFlagBlockAgenda = 1;
1599 if (!merge) mCalendar->close(); 1610 if (!merge) mCalendar->close();
1600 1611
1601 mStorage->setFileName( filename ); 1612 mStorage->setFileName( filename );
1602 1613
1603 if ( mStorage->load() ) { 1614 if ( mStorage->load() ) {
1604 if ( merge ) ;//setModified( true ); 1615 if ( merge ) ;//setModified( true );
1605 else { 1616 else {
1606 //setModified( true ); 1617 //setModified( true );
1607 mViewManager->setDocumentId( filename ); 1618 mViewManager->setDocumentId( filename );
1608 mDialogManager->setDocumentId( filename ); 1619 mDialogManager->setDocumentId( filename );
1609 mTodoList->setDocumentId( filename ); 1620 mTodoList->setDocumentId( filename );
1610 } 1621 }
1611 globalFlagBlockAgenda = 2; 1622 globalFlagBlockAgenda = 2;
1612 // if ( getLastSyncEvent() ) 1623 // if ( getLastSyncEvent() )
1613 // getLastSyncEvent()->setReadOnly( true ); 1624 // getLastSyncEvent()->setReadOnly( true );
1614 mCalendar->reInitAlarmSettings(); 1625 mCalendar->reInitAlarmSettings();
1615 setSyncEventsReadOnly(); 1626 setSyncEventsReadOnly();
1616 updateUnmanagedViews(); 1627 updateUnmanagedViews();
1617 updateView(); 1628 updateView();
1618 if ( filename != MainWindow::defaultFileName() ) { 1629 if ( filename != MainWindow::defaultFileName() ) {
1619 saveCalendar( MainWindow::defaultFileName() ); 1630 saveCalendar( MainWindow::defaultFileName() );
1620 } else { 1631 } else {
1621 QFileInfo finf ( MainWindow::defaultFileName()); 1632 QFileInfo finf ( MainWindow::defaultFileName());
1622 if ( finf.exists() ) { 1633 if ( finf.exists() ) {
1623 setLoadedFileVersion( finf.lastModified () ); 1634 setLoadedFileVersion( finf.lastModified () );
1624 } 1635 }
1625 } 1636 }
1626 return true; 1637 return true;
1627 } else { 1638 } else {
1628 // while failing to load, the calendar object could 1639 // while failing to load, the calendar object could
1629 // have become partially populated. Clear it out. 1640 // have become partially populated. Clear it out.
1630 if ( !merge ) { 1641 if ( !merge ) {
1631 mCalendar->close(); 1642 mCalendar->close();
1632 mViewManager->setDocumentId( filename ); 1643 mViewManager->setDocumentId( filename );
1633 mDialogManager->setDocumentId( filename ); 1644 mDialogManager->setDocumentId( filename );
1634 mTodoList->setDocumentId( filename ); 1645 mTodoList->setDocumentId( filename );
1635 } 1646 }
1636 1647
1637 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1648 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1638 1649
1639 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1650 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1640 globalFlagBlockAgenda = 2; 1651 globalFlagBlockAgenda = 2;
1641 mCalendar->reInitAlarmSettings(); 1652 mCalendar->reInitAlarmSettings();
1642 setSyncEventsReadOnly(); 1653 setSyncEventsReadOnly();
1643 updateUnmanagedViews(); 1654 updateUnmanagedViews();
1644 updateView(); 1655 updateView();
1645 } 1656 }
1646 return false; 1657 return false;
1647} 1658}
1648void CalendarView::showOpenError() 1659void CalendarView::showOpenError()
1649{ 1660{
1650 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1661 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1651} 1662}
1652void CalendarView::setLoadedFileVersion(QDateTime dt) 1663void CalendarView::setLoadedFileVersion(QDateTime dt)
1653{ 1664{
1654 loadedFileVersion = dt; 1665 loadedFileVersion = dt;
1655} 1666}
1656bool CalendarView::checkFileChanged(QString fn) 1667bool CalendarView::checkFileChanged(QString fn)
1657{ 1668{
1658 QFileInfo finf ( fn ); 1669 QFileInfo finf ( fn );
1659 if ( !finf.exists() ) 1670 if ( !finf.exists() )
1660 return true; 1671 return true;
1661 QDateTime dt = finf.lastModified (); 1672 QDateTime dt = finf.lastModified ();
1662 if ( dt <= loadedFileVersion ) 1673 if ( dt <= loadedFileVersion )
1663 return false; 1674 return false;
1664 return true; 1675 return true;
1665 1676
1666} 1677}
1667void CalendarView::watchSavedFile() 1678void CalendarView::watchSavedFile()
1668{ 1679{
1669 QFileInfo finf ( MainWindow::defaultFileName()); 1680 QFileInfo finf ( MainWindow::defaultFileName());
1670 if ( !finf.exists() ) 1681 if ( !finf.exists() )
1671 return; 1682 return;
1672 QDateTime dt = finf.lastModified (); 1683 QDateTime dt = finf.lastModified ();
1673 if ( dt < loadedFileVersion ) { 1684 if ( dt < loadedFileVersion ) {
1674 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1685 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1675 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1686 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1676 return; 1687 return;
1677 } 1688 }
1678 loadedFileVersion = dt; 1689 loadedFileVersion = dt;
1679} 1690}
1680 1691
1681bool CalendarView::checkFileVersion(QString fn) 1692bool CalendarView::checkFileVersion(QString fn)
1682{ 1693{
1683 QFileInfo finf ( fn ); 1694 QFileInfo finf ( fn );
1684 if ( !finf.exists() ) 1695 if ( !finf.exists() )
1685 return true; 1696 return true;
1686 QDateTime dt = finf.lastModified (); 1697 QDateTime dt = finf.lastModified ();
1687 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1698 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1688 //qDebug("file on disk version %s",dt.toString().latin1()); 1699 //qDebug("file on disk version %s",dt.toString().latin1());
1689 if ( dt <= loadedFileVersion ) 1700 if ( dt <= loadedFileVersion )
1690 return true; 1701 return true;
1691 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 1702 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
1692 i18n("KO/Pi Warning"),i18n("Overwrite"), 1703 i18n("KO/Pi Warning"),i18n("Overwrite"),
1693 i18n("Sync+save")); 1704 i18n("Sync+save"));
1694 1705
1695 if ( km == KMessageBox::Cancel ) 1706 if ( km == KMessageBox::Cancel )
1696 return false; 1707 return false;
1697 if ( km == KMessageBox::Yes ) 1708 if ( km == KMessageBox::Yes )
1698 return true; 1709 return true;
1699 1710
1700 setSyncDevice("deleteaftersync" ); 1711 setSyncDevice("deleteaftersync" );
1701 mSyncManager->mAskForPreferences = true; 1712 mSyncManager->mAskForPreferences = true;
1702 mSyncManager->mSyncAlgoPrefs = 3; 1713 mSyncManager->mSyncAlgoPrefs = 3;
1703 mSyncManager->mWriteBackFile = false; 1714 mSyncManager->mWriteBackFile = false;
1704 mSyncManager->mWriteBackExistingOnly = false; 1715 mSyncManager->mWriteBackExistingOnly = false;
1705 mSyncManager->mShowSyncSummary = false; 1716 mSyncManager->mShowSyncSummary = false;
1706 syncCalendar( fn, 3 ); 1717 syncCalendar( fn, 3 );
1707 Event * e = getLastSyncEvent(); 1718 Event * e = getLastSyncEvent();
1708 mCalendar->deleteEvent ( e ); 1719 mCalendar->deleteEvent ( e );
1709 updateView(); 1720 updateView();
1710 return true; 1721 return true;
1711} 1722}
1712 1723
1713bool CalendarView::saveCalendar( QString filename ) 1724bool CalendarView::saveCalendar( QString filename )
1714{ 1725{
1715 1726
1716 // Store back all unsaved data into calendar object 1727 // Store back all unsaved data into calendar object
1717 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1728 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1718 if ( mViewManager->currentView() ) 1729 if ( mViewManager->currentView() )
1719 mViewManager->currentView()->flushView(); 1730 mViewManager->currentView()->flushView();
1720 1731
1721 1732
1722 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1733 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1723 mStorage->setSaveFormat( new ICalFormat() ); 1734 mStorage->setSaveFormat( new ICalFormat() );
1724 mStorage->setFileName( filename ); 1735 mStorage->setFileName( filename );
1725 bool success; 1736 bool success;
1726 success = mStorage->save(); 1737 success = mStorage->save();
1727 if ( !success ) { 1738 if ( !success ) {
1728 return false; 1739 return false;
1729 } 1740 }
1730 if ( filename == MainWindow::defaultFileName() ) { 1741 if ( filename == MainWindow::defaultFileName() ) {
1731 setLoadedFileVersion( lfv ); 1742 setLoadedFileVersion( lfv );
1732 watchSavedFile(); 1743 watchSavedFile();
1733 } 1744 }
1734 return true; 1745 return true;
1735} 1746}
1736 1747
1737void CalendarView::closeCalendar() 1748void CalendarView::closeCalendar()
1738{ 1749{
1739 1750
1740 // child windows no longer valid 1751 // child windows no longer valid
1741 emit closingDown(); 1752 emit closingDown();
1742 1753
1743 mCalendar->close(); 1754 mCalendar->close();
1744 setModified(false); 1755 setModified(false);
1745 updateView(); 1756 updateView();
1746} 1757}
1747 1758
1748void CalendarView::archiveCalendar() 1759void CalendarView::archiveCalendar()
1749{ 1760{
1750 mDialogManager->showArchiveDialog(); 1761 mDialogManager->showArchiveDialog();
1751} 1762}
1752 1763
1753 1764
1754void CalendarView::readSettings() 1765void CalendarView::readSettings()
1755{ 1766{
1756 1767
1757 1768
1758 // mViewManager->showAgendaView(); 1769 // mViewManager->showAgendaView();
1759 QString str; 1770 QString str;
1760 //qDebug("CalendarView::readSettings() "); 1771 //qDebug("CalendarView::readSettings() ");
1761 // read settings from the KConfig, supplying reasonable 1772 // read settings from the KConfig, supplying reasonable
1762 // defaults where none are to be found 1773 // defaults where none are to be found
1763 KConfig *config = KOGlobals::config(); 1774 KConfig *config = KOGlobals::config();
1764#ifndef KORG_NOSPLITTER 1775#ifndef KORG_NOSPLITTER
1765 config->setGroup("KOrganizer Geometry"); 1776 config->setGroup("KOrganizer Geometry");
1766 1777
diff --git a/korganizer/filteredit_base.cpp b/korganizer/filteredit_base.cpp
index 21a0954..e724da4 100644
--- a/korganizer/filteredit_base.cpp
+++ b/korganizer/filteredit_base.cpp
@@ -1,128 +1,145 @@
1/**************************************************************************** 1/****************************************************************************
2** Form implementation generated from reading ui file 'filteredit_base.ui' 2** Form implementation generated from reading ui file 'filteredit_base.ui'
3** 3**
4** Created: Di Mai 4 15:30:31 2004 4** Created: So Jan 16 11:23:21 2005
5** by: The User Interface Compiler ($Id$) 5** by: The User Interface Compiler ($Id$)
6** 6**
7** WARNING! All changes made in this file will be lost! 7** WARNING! All changes made in this file will be lost!
8****************************************************************************/ 8****************************************************************************/
9 9
10#include "filteredit_base.h" 10#include "filteredit_base.h"
11 11
12#include <qvariant.h> 12#include <qvariant.h>
13#include <qpushbutton.h> 13#include <qpushbutton.h>
14#include <qframe.h> 14#include <qframe.h>
15#include <qbuttongroup.h> 15#include <qbuttongroup.h>
16#include <qradiobutton.h> 16#include <qradiobutton.h>
17#include <qlistbox.h> 17#include <qlistbox.h>
18#include <qlabel.h> 18#include <qlabel.h>
19#include <qcheckbox.h> 19#include <qcheckbox.h>
20#include <qlayout.h> 20#include <qlayout.h>
21#include <qtooltip.h> 21#include <qtooltip.h>
22#include <qwhatsthis.h> 22#include <qwhatsthis.h>
23#include "filteredit_base.ui.h"
23 24
24/* 25/*
25 * Constructs a FilterEdit_base as a child of 'parent', with the 26 * Constructs a FilterEdit_base as a child of 'parent', with the
26 * name 'name' and widget flags set to 'f'. 27 * name 'name' and widget flags set to 'f'.
27 */ 28 */
28FilterEdit_base::FilterEdit_base( QWidget* parent, const char* name, WFlags fl ) 29FilterEdit_base::FilterEdit_base( QWidget* parent, const char* name, WFlags fl )
29 : QWidget( parent, name, fl ) 30 : QWidget( parent, name, fl )
30{ 31{
31 if ( !name ) 32 if ( !name )
32 setName( "FilterEdit_base" ); 33 setName( "FilterEdit_base" );
33 FilterEdit_baseLayout = new QVBoxLayout( this, 0, 0, "FilterEdit_baseLayout"); 34 FilterEdit_baseLayout = new QVBoxLayout( this, 0, 0, "FilterEdit_baseLayout");
34 35
35 mCriteriaFrame = new QFrame( this, "mCriteriaFrame" ); 36 mCriteriaFrame = new QFrame( this, "mCriteriaFrame" );
36 mCriteriaFrame->setFrameShape( QFrame::StyledPanel ); 37 mCriteriaFrame->setFrameShape( QFrame::StyledPanel );
37 mCriteriaFrame->setFrameShadow( QFrame::Raised ); 38 mCriteriaFrame->setFrameShadow( QFrame::Raised );
38 mCriteriaFrameLayout = new QGridLayout( mCriteriaFrame, 1, 1, 3, 2, "mCriteriaFrameLayout"); 39 mCriteriaFrameLayout = new QVBoxLayout( mCriteriaFrame, 3, 2, "mCriteriaFrameLayout");
39 40
40 ButtonGroup1 = new QButtonGroup( mCriteriaFrame, "ButtonGroup1" ); 41 ButtonGroup1 = new QButtonGroup( mCriteriaFrame, "ButtonGroup1" );
41 ButtonGroup1->setColumnLayout(0, Qt::Vertical ); 42 ButtonGroup1->setColumnLayout(0, Qt::Vertical );
42 ButtonGroup1->layout()->setSpacing( 6 ); 43 ButtonGroup1->layout()->setSpacing( 6 );
43 ButtonGroup1->layout()->setMargin( 11 ); 44 ButtonGroup1->layout()->setMargin( 6 );
44 ButtonGroup1Layout = new QVBoxLayout( ButtonGroup1->layout() ); 45 ButtonGroup1Layout = new QGridLayout( ButtonGroup1->layout() );
45 ButtonGroup1Layout->setAlignment( Qt::AlignTop ); 46 ButtonGroup1Layout->setAlignment( Qt::AlignTop );
46 47
48 layout4 = new QHBoxLayout( 0, 0, 6, "layout4");
49
47 mCatShowCheck = new QRadioButton( ButtonGroup1, "mCatShowCheck" ); 50 mCatShowCheck = new QRadioButton( ButtonGroup1, "mCatShowCheck" );
48 ButtonGroup1Layout->addWidget( mCatShowCheck ); 51 layout4->addWidget( mCatShowCheck );
49 52
50 mCatHideCheck = new QRadioButton( ButtonGroup1, "mCatHideCheck" ); 53 mCatHideCheck = new QRadioButton( ButtonGroup1, "mCatHideCheck" );
51 ButtonGroup1Layout->addWidget( mCatHideCheck ); 54 layout4->addWidget( mCatHideCheck );
52
53 mCatList = new QListBox( ButtonGroup1, "mCatList" );
54 ButtonGroup1Layout->addWidget( mCatList );
55 55
56 mCatEditButton = new QPushButton( ButtonGroup1, "mCatEditButton" ); 56 mCatEditButton = new QPushButton( ButtonGroup1, "mCatEditButton" );
57 ButtonGroup1Layout->addWidget( mCatEditButton ); 57 layout4->addWidget( mCatEditButton );
58 58
59 mCriteriaFrameLayout->addWidget( ButtonGroup1, 0, 0 ); 59 ButtonGroup1Layout->addLayout( layout4, 0, 0 );
60 60
61 layout1 = new QHBoxLayout( 0, 0, 0, "layout1"); 61 mCatList = new QListBox( ButtonGroup1, "mCatList" );
62
63 ButtonGroup1Layout->addWidget( mCatList, 1, 0 );
64 mCriteriaFrameLayout->addWidget( ButtonGroup1 );
65
66 layout7 = new QHBoxLayout( 0, 0, 6, "layout7");
62 67
63 textLabel1 = new QLabel( mCriteriaFrame, "textLabel1" ); 68 textLabel1 = new QLabel( mCriteriaFrame, "textLabel1" );
64 layout1->addWidget( textLabel1 ); 69 layout7->addWidget( textLabel1 );
65 70
66 mRecurringCheck = new QCheckBox( mCriteriaFrame, "mRecurringCheck" ); 71 mRecurringCheck = new QCheckBox( mCriteriaFrame, "mRecurringCheck" );
67 layout1->addWidget( mRecurringCheck ); 72 layout7->addWidget( mRecurringCheck );
68 73
69 mCompletedCheck = new QCheckBox( mCriteriaFrame, "mCompletedCheck" ); 74 mCompletedCheck = new QCheckBox( mCriteriaFrame, "mCompletedCheck" );
70 layout1->addWidget( mCompletedCheck ); 75 layout7->addWidget( mCompletedCheck );
76 mCriteriaFrameLayout->addLayout( layout7 );
77
78 layout9 = new QHBoxLayout( 0, 0, 6, "layout9");
71 79
72 mCriteriaFrameLayout->addLayout( layout1, 1, 0 ); 80 textLabel1_2 = new QLabel( mCriteriaFrame, "textLabel1_2" );
81 layout9->addWidget( textLabel1_2 );
82
83 mEventCheck = new QCheckBox( mCriteriaFrame, "mEventCheck" );
84 layout9->addWidget( mEventCheck );
85
86 mTodoCheck = new QCheckBox( mCriteriaFrame, "mTodoCheck" );
87 layout9->addWidget( mTodoCheck );
88
89 mJournalCheck = new QCheckBox( mCriteriaFrame, "mJournalCheck" );
90 layout9->addWidget( mJournalCheck );
91 mCriteriaFrameLayout->addLayout( layout9 );
73 92
74 layout2 = new QHBoxLayout( 0, 0, 0, "layout2"); 93 layout2 = new QHBoxLayout( 0, 0, 0, "layout2");
75 94
76 textLabel2 = new QLabel( mCriteriaFrame, "textLabel2" ); 95 textLabel2 = new QLabel( mCriteriaFrame, "textLabel2" );
77 layout2->addWidget( textLabel2 ); 96 layout2->addWidget( textLabel2 );
78 97
79 mPublicCheck = new QCheckBox( mCriteriaFrame, "mPublicCheck" ); 98 mPublicCheck = new QCheckBox( mCriteriaFrame, "mPublicCheck" );
80 layout2->addWidget( mPublicCheck ); 99 layout2->addWidget( mPublicCheck );
81 100
82 mPrivateCheck = new QCheckBox( mCriteriaFrame, "mPrivateCheck" ); 101 mPrivateCheck = new QCheckBox( mCriteriaFrame, "mPrivateCheck" );
83 layout2->addWidget( mPrivateCheck ); 102 layout2->addWidget( mPrivateCheck );
84 103
85 mConfidentialCheck = new QCheckBox( mCriteriaFrame, "mConfidentialCheck" ); 104 mConfidentialCheck = new QCheckBox( mCriteriaFrame, "mConfidentialCheck" );
86 mConfidentialCheck->setChecked( FALSE ); 105 mConfidentialCheck->setChecked( FALSE );
87 layout2->addWidget( mConfidentialCheck ); 106 layout2->addWidget( mConfidentialCheck );
88 107 mCriteriaFrameLayout->addLayout( layout2 );
89 mCriteriaFrameLayout->addLayout( layout2, 2, 0 );
90 FilterEdit_baseLayout->addWidget( mCriteriaFrame ); 108 FilterEdit_baseLayout->addWidget( mCriteriaFrame );
91 languageChange(); 109 languageChange();
92 resize( QSize(284, 241).expandedTo(minimumSizeHint()) ); 110 resize( QSize(351, 275).expandedTo(minimumSizeHint()) );
93 clearWState( WState_Polished ); 111 clearWState( WState_Polished );
94} 112}
95 113
96/* 114/*
97 * Destroys the object and frees any allocated resources 115 * Destroys the object and frees any allocated resources
98 */ 116 */
99FilterEdit_base::~FilterEdit_base() 117FilterEdit_base::~FilterEdit_base()
100{ 118{
101 // no need to delete child widgets, Qt does it all for us 119 // no need to delete child widgets, Qt does it all for us
102} 120}
103 121
104/* 122/*
105 * Sets the strings of the subwidgets using the current 123 * Sets the strings of the subwidgets using the current
106 * language. 124 * language.
107 */ 125 */
108void FilterEdit_base::languageChange() 126void FilterEdit_base::languageChange()
109{ 127{
110 setCaption( tr( "FilterEditor" ) ); 128 setCaption( tr( "FilterEditor" ) );
111 ButtonGroup1->setTitle( tr( "Categories" ) ); 129 ButtonGroup1->setTitle( tr( "Categories" ) );
112 mCatShowCheck->setText( tr( "Show only selected" ) ); 130 mCatShowCheck->setText( tr( "Include" ) );
113 mCatHideCheck->setText( tr( "Show all but selected" ) ); 131 mCatHideCheck->setText( tr( "Exclude" ) );
114 mCatEditButton->setText( tr( "Edit Selection..." ) ); 132 mCatEditButton->setText( tr( "Edit Selection..." ) );
115 textLabel1->setText( tr( "Hide" ) ); 133 textLabel1->setText( tr( "Exclude" ) );
116 mRecurringCheck->setText( tr( "recurring events" ) ); 134 mRecurringCheck->setText( tr( "recurring events" ) );
117 mCompletedCheck->setText( tr( "completed to-dos" ) ); 135 mCompletedCheck->setText( tr( "completed to-dos" ) );
118 textLabel2->setText( tr( "Show" ) ); 136 textLabel1_2->setText( tr( "Exclude" ) );
137 mEventCheck->setText( tr( "events" ) );
138 mTodoCheck->setText( tr( "todos" ) );
139 mJournalCheck->setText( tr( "journals" ) );
140 textLabel2->setText( tr( "Include" ) );
119 mPublicCheck->setText( tr( "public" ) ); 141 mPublicCheck->setText( tr( "public" ) );
120 mPrivateCheck->setText( tr( "private" ) ); 142 mPrivateCheck->setText( tr( "private" ) );
121 mConfidentialCheck->setText( tr( "confidential" ) ); 143 mConfidentialCheck->setText( tr( "confidential" ) );
122} 144}
123 145
124void FilterEdit_base::updateFilter()
125{
126 qWarning( "FilterEdit_base::updateFilter(): Not implemented yet" );
127}
128
diff --git a/korganizer/filteredit_base.h b/korganizer/filteredit_base.h
index 664598a..0c2988a 100644
--- a/korganizer/filteredit_base.h
+++ b/korganizer/filteredit_base.h
@@ -1,66 +1,72 @@
1/**************************************************************************** 1/****************************************************************************
2** Form interface generated from reading ui file 'filteredit_base.ui' 2** Form interface generated from reading ui file 'filteredit_base.ui'
3** 3**
4** Created: Di Mai 4 15:24:50 2004 4** Created: So Jan 16 11:23:21 2005
5** by: The User Interface Compiler ($Id$) 5** by: The User Interface Compiler ($Id$)
6** 6**
7** WARNING! All changes made in this file will be lost! 7** WARNING! All changes made in this file will be lost!
8****************************************************************************/ 8****************************************************************************/
9 9
10#ifndef FILTEREDIT_BASE_H 10#ifndef FILTEREDIT_BASE_H
11#define FILTEREDIT_BASE_H 11#define FILTEREDIT_BASE_H
12 12
13#include <qvariant.h> 13#include <qvariant.h>
14#include <qwidget.h> 14#include <qwidget.h>
15 15
16class QVBoxLayout; 16class QVBoxLayout;
17class QHBoxLayout; 17class QHBoxLayout;
18class QGridLayout; 18class QGridLayout;
19class QSpacerItem; 19class QSpacerItem;
20class QFrame; 20class QFrame;
21class QButtonGroup; 21class QButtonGroup;
22class QRadioButton; 22class QRadioButton;
23class QPushButton;
23class QListBox; 24class QListBox;
24class QListBoxItem; 25class QListBoxItem;
25class QPushButton;
26class QLabel; 26class QLabel;
27class QCheckBox; 27class QCheckBox;
28 28
29class FilterEdit_base : public QWidget 29class FilterEdit_base : public QWidget
30{ 30{
31 Q_OBJECT 31 Q_OBJECT
32 32
33public: 33public:
34 FilterEdit_base( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 34 FilterEdit_base( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
35 ~FilterEdit_base(); 35 ~FilterEdit_base();
36 36
37 QFrame* mCriteriaFrame; 37 QFrame* mCriteriaFrame;
38 QButtonGroup* ButtonGroup1; 38 QButtonGroup* ButtonGroup1;
39 QRadioButton* mCatShowCheck; 39 QRadioButton* mCatShowCheck;
40 QRadioButton* mCatHideCheck; 40 QRadioButton* mCatHideCheck;
41 QListBox* mCatList;
42 QPushButton* mCatEditButton; 41 QPushButton* mCatEditButton;
42 QListBox* mCatList;
43 QLabel* textLabel1; 43 QLabel* textLabel1;
44 QCheckBox* mRecurringCheck; 44 QCheckBox* mRecurringCheck;
45 QCheckBox* mCompletedCheck; 45 QCheckBox* mCompletedCheck;
46 QLabel* textLabel1_2;
47 QCheckBox* mEventCheck;
48 QCheckBox* mTodoCheck;
49 QCheckBox* mJournalCheck;
46 QLabel* textLabel2; 50 QLabel* textLabel2;
47 QCheckBox* mPublicCheck; 51 QCheckBox* mPublicCheck;
48 QCheckBox* mPrivateCheck; 52 QCheckBox* mPrivateCheck;
49 QCheckBox* mConfidentialCheck; 53 QCheckBox* mConfidentialCheck;
50 54
51public slots: 55public slots:
52 virtual void updateFilter(); 56 virtual void updateFilter();
53 57
54protected: 58protected:
55 QVBoxLayout* FilterEdit_baseLayout; 59 QVBoxLayout* FilterEdit_baseLayout;
56 QGridLayout* mCriteriaFrameLayout; 60 QVBoxLayout* mCriteriaFrameLayout;
57 QVBoxLayout* ButtonGroup1Layout; 61 QGridLayout* ButtonGroup1Layout;
58 QHBoxLayout* layout1; 62 QHBoxLayout* layout4;
63 QHBoxLayout* layout7;
64 QHBoxLayout* layout9;
59 QHBoxLayout* layout2; 65 QHBoxLayout* layout2;
60 66
61protected slots: 67protected slots:
62 virtual void languageChange(); 68 virtual void languageChange();
63 69
64}; 70};
65 71
66#endif // FILTEREDIT_BASE_H 72#endif // FILTEREDIT_BASE_H
diff --git a/korganizer/filteredit_base.ui b/korganizer/filteredit_base.ui
index b7cbb59..2436f57 100644
--- a/korganizer/filteredit_base.ui
+++ b/korganizer/filteredit_base.ui
@@ -1,201 +1,250 @@
1<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> 1<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
2<class>FilterEdit_base</class> 2<class>FilterEdit_base</class>
3<widget class="QWidget"> 3<widget class="QWidget">
4 <property name="name"> 4 <property name="name">
5 <cstring>FilterEdit_base</cstring> 5 <cstring>FilterEdit_base</cstring>
6 </property> 6 </property>
7 <property name="geometry"> 7 <property name="geometry">
8 <rect> 8 <rect>
9 <x>0</x> 9 <x>0</x>
10 <y>0</y> 10 <y>0</y>
11 <width>284</width> 11 <width>351</width>
12 <height>241</height> 12 <height>275</height>
13 </rect> 13 </rect>
14 </property> 14 </property>
15 <property name="caption"> 15 <property name="caption">
16 <string>FilterEditor</string> 16 <string>FilterEditor</string>
17 </property> 17 </property>
18 <property name="layoutMargin" stdset="0"> 18 <property name="layoutMargin" stdset="0">
19 </property> 19 </property>
20 <property name="layoutSpacing" stdset="0"> 20 <property name="layoutSpacing" stdset="0">
21 </property> 21 </property>
22 <vbox> 22 <vbox>
23 <property name="name"> 23 <property name="name">
24 <cstring>unnamed</cstring> 24 <cstring>unnamed</cstring>
25 </property> 25 </property>
26 <property name="margin"> 26 <property name="margin">
27 <number>0</number> 27 <number>0</number>
28 </property> 28 </property>
29 <property name="spacing"> 29 <property name="spacing">
30 <number>0</number> 30 <number>0</number>
31 </property> 31 </property>
32 <widget class="QFrame"> 32 <widget class="QFrame">
33 <property name="name"> 33 <property name="name">
34 <cstring>mCriteriaFrame</cstring> 34 <cstring>mCriteriaFrame</cstring>
35 </property> 35 </property>
36 <property name="frameShape"> 36 <property name="frameShape">
37 <enum>StyledPanel</enum> 37 <enum>StyledPanel</enum>
38 </property> 38 </property>
39 <property name="frameShadow"> 39 <property name="frameShadow">
40 <enum>Raised</enum> 40 <enum>Raised</enum>
41 </property> 41 </property>
42 <property name="layoutMargin" stdset="0"> 42 <property name="layoutMargin" stdset="0">
43 </property> 43 </property>
44 <grid> 44 <vbox>
45 <property name="name"> 45 <property name="name">
46 <cstring>unnamed</cstring> 46 <cstring>unnamed</cstring>
47 </property> 47 </property>
48 <property name="margin"> 48 <property name="margin">
49 <number>3</number> 49 <number>3</number>
50 </property> 50 </property>
51 <property name="spacing"> 51 <property name="spacing">
52 <number>2</number> 52 <number>2</number>
53 </property> 53 </property>
54 <widget class="QButtonGroup" row="0" column="0"> 54 <widget class="QButtonGroup">
55 <property name="name"> 55 <property name="name">
56 <cstring>ButtonGroup1</cstring> 56 <cstring>ButtonGroup1</cstring>
57 </property> 57 </property>
58 <property name="title"> 58 <property name="title">
59 <string>Categories</string> 59 <string>Categories</string>
60 </property> 60 </property>
61 <vbox> 61 <grid>
62 <property name="name"> 62 <property name="name">
63 <cstring>unnamed</cstring> 63 <cstring>unnamed</cstring>
64 </property> 64 </property>
65 <property name="margin"> 65 <property name="margin">
66 <number>11</number> 66 <number>6</number>
67 </property> 67 </property>
68 <property name="spacing"> 68 <property name="spacing">
69 <number>6</number> 69 <number>6</number>
70 </property> 70 </property>
71 <widget class="QRadioButton"> 71 <widget class="QLayoutWidget" row="0" column="0">
72 <property name="name"> 72 <property name="name">
73 <cstring>mCatShowCheck</cstring> 73 <cstring>layout4</cstring>
74 </property> 74 </property>
75 <property name="text"> 75 <hbox>
76 <string>Show only selected</string> 76 <property name="name">
77 <cstring>unnamed</cstring>
78 </property>
79 <widget class="QRadioButton">
80 <property name="name">
81 <cstring>mCatShowCheck</cstring>
82 </property>
83 <property name="text">
84 <string>Include</string>
85 </property>
86 </widget>
87 <widget class="QRadioButton">
88 <property name="name">
89 <cstring>mCatHideCheck</cstring>
90 </property>
91 <property name="text">
92 <string>Exclude</string>
93 </property>
94 </widget>
95 <widget class="QPushButton">
96 <property name="name">
97 <cstring>mCatEditButton</cstring>
98 </property>
99 <property name="text">
100 <string>Edit Selection...</string>
101 </property>
102 </widget>
103 </hbox>
104 </widget>
105 <widget class="QListBox" row="1" column="0">
106 <property name="name">
107 <cstring>mCatList</cstring>
77 </property> 108 </property>
78 </widget> 109 </widget>
79 <widget class="QRadioButton"> 110 </grid>
111 </widget>
112 <widget class="QLayoutWidget">
113 <property name="name">
114 <cstring>layout7</cstring>
115 </property>
116 <hbox>
117 <property name="name">
118 <cstring>unnamed</cstring>
119 </property>
120 <widget class="QLabel">
80 <property name="name"> 121 <property name="name">
81 <cstring>mCatHideCheck</cstring> 122 <cstring>textLabel1</cstring>
82 </property> 123 </property>
83 <property name="text"> 124 <property name="text">
84 <string>Show all but selected</string> 125 <string>Exclude</string>
85 </property> 126 </property>
86 </widget> 127 </widget>
87 <widget class="QListBox"> 128 <widget class="QCheckBox">
88 <property name="name"> 129 <property name="name">
89 <cstring>mCatList</cstring> 130 <cstring>mRecurringCheck</cstring>
131 </property>
132 <property name="text">
133 <string>recurring events</string>
90 </property> 134 </property>
91 </widget> 135 </widget>
92 <widget class="QPushButton"> 136 <widget class="QCheckBox">
93 <property name="name"> 137 <property name="name">
94 <cstring>mCatEditButton</cstring> 138 <cstring>mCompletedCheck</cstring>
95 </property> 139 </property>
96 <property name="text"> 140 <property name="text">
97 <string>Edit Selection...</string> 141 <string>completed to-dos</string>
98 </property> 142 </property>
99 </widget> 143 </widget>
100 </vbox> 144 </hbox>
101 </widget> 145 </widget>
102 <widget class="QLayoutWidget" row="1" column="0"> 146 <widget class="QLayoutWidget">
103 <property name="name"> 147 <property name="name">
104 <cstring>layout1</cstring> 148 <cstring>layout9</cstring>
105 </property> 149 </property>
106 <hbox> 150 <hbox>
107 <property name="name"> 151 <property name="name">
108 <cstring>unnamed</cstring> 152 <cstring>unnamed</cstring>
109 </property> 153 </property>
110 <property name="margin">
111 <number>0</number>
112 </property>
113 <property name="spacing">
114 <number>0</number>
115 </property>
116 <widget class="QLabel"> 154 <widget class="QLabel">
117 <property name="name"> 155 <property name="name">
118 <cstring>textLabel1</cstring> 156 <cstring>textLabel1_2</cstring>
119 </property> 157 </property>
120 <property name="text"> 158 <property name="text">
121 <string>Hide</string> 159 <string>Exclude</string>
122 </property> 160 </property>
123 </widget> 161 </widget>
124 <widget class="QCheckBox"> 162 <widget class="QCheckBox">
125 <property name="name"> 163 <property name="name">
126 <cstring>mRecurringCheck</cstring> 164 <cstring>mEventCheck</cstring>
127 </property> 165 </property>
128 <property name="text"> 166 <property name="text">
129 <string>recurring events</string> 167 <string>events</string>
130 </property> 168 </property>
131 </widget> 169 </widget>
132 <widget class="QCheckBox"> 170 <widget class="QCheckBox">
133 <property name="name"> 171 <property name="name">
134 <cstring>mCompletedCheck</cstring> 172 <cstring>mTodoCheck</cstring>
135 </property> 173 </property>
136 <property name="text"> 174 <property name="text">
137 <string>completed to-dos</string> 175 <string>todos</string>
176 </property>
177 </widget>
178 <widget class="QCheckBox">
179 <property name="name">
180 <cstring>mJournalCheck</cstring>
181 </property>
182 <property name="text">
183 <string>journals</string>
138 </property> 184 </property>
139 </widget> 185 </widget>
140 </hbox> 186 </hbox>
141 </widget> 187 </widget>
142 <widget class="QLayoutWidget" row="2" column="0"> 188 <widget class="QLayoutWidget">
143 <property name="name"> 189 <property name="name">
144 <cstring>layout2</cstring> 190 <cstring>layout2</cstring>
145 </property> 191 </property>
146 <hbox> 192 <hbox>
147 <property name="name"> 193 <property name="name">
148 <cstring>unnamed</cstring> 194 <cstring>unnamed</cstring>
149 </property> 195 </property>
150 <property name="margin"> 196 <property name="margin">
151 <number>0</number> 197 <number>0</number>
152 </property> 198 </property>
153 <property name="spacing"> 199 <property name="spacing">
154 <number>0</number> 200 <number>0</number>
155 </property> 201 </property>
156 <widget class="QLabel"> 202 <widget class="QLabel">
157 <property name="name"> 203 <property name="name">
158 <cstring>textLabel2</cstring> 204 <cstring>textLabel2</cstring>
159 </property> 205 </property>
160 <property name="text"> 206 <property name="text">
161 <string>Show</string> 207 <string>Include</string>
162 </property> 208 </property>
163 </widget> 209 </widget>
164 <widget class="QCheckBox"> 210 <widget class="QCheckBox">
165 <property name="name"> 211 <property name="name">
166 <cstring>mPublicCheck</cstring> 212 <cstring>mPublicCheck</cstring>
167 </property> 213 </property>
168 <property name="text"> 214 <property name="text">
169 <string>public</string> 215 <string>public</string>
170 </property> 216 </property>
171 </widget> 217 </widget>
172 <widget class="QCheckBox"> 218 <widget class="QCheckBox">
173 <property name="name"> 219 <property name="name">
174 <cstring>mPrivateCheck</cstring> 220 <cstring>mPrivateCheck</cstring>
175 </property> 221 </property>
176 <property name="text"> 222 <property name="text">
177 <string>private</string> 223 <string>private</string>
178 </property> 224 </property>
179 </widget> 225 </widget>
180 <widget class="QCheckBox"> 226 <widget class="QCheckBox">
181 <property name="name"> 227 <property name="name">
182 <cstring>mConfidentialCheck</cstring> 228 <cstring>mConfidentialCheck</cstring>
183 </property> 229 </property>
184 <property name="text"> 230 <property name="text">
185 <string>confidential</string> 231 <string>confidential</string>
186 </property> 232 </property>
187 <property name="checked"> 233 <property name="checked">
188 <bool>false</bool> 234 <bool>false</bool>
189 </property> 235 </property>
190 </widget> 236 </widget>
191 </hbox> 237 </hbox>
192 </widget> 238 </widget>
193 </grid> 239 </vbox>
194 </widget> 240 </widget>
195 </vbox> 241 </vbox>
196</widget> 242</widget>
243<includes>
244 <include location="local" impldecl="in implementation">filteredit_base.ui.h</include>
245</includes>
197<slots> 246<slots>
198 <slot>updateFilter()</slot> 247 <slot>updateFilter()</slot>
199</slots> 248</slots>
200<layoutdefaults spacing="6" margin="11"/> 249<layoutdefaults spacing="6" margin="11"/>
201</UI> 250</UI>
diff --git a/korganizer/korganizer.pro b/korganizer/korganizer.pro
index 2816c6e..628d84e 100644
--- a/korganizer/korganizer.pro
+++ b/korganizer/korganizer.pro
@@ -1,193 +1,193 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on 2 CONFIG = qt warn_on
3 TARGET = kopi 3 TARGET = kopi
4OBJECTS_DIR = _obj/ 4OBJECTS_DIR = _obj/
5MOC_DIR = _moc 5MOC_DIR = _moc
6DESTDIR= ../bin 6DESTDIR= ../bin
7 7
8include( ../variables.pri ) 8include( ../variables.pri )
9 9
10INCLUDEPATH += ../microkde ../ interfaces ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim 10INCLUDEPATH += ../microkde ../ interfaces ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim
11#../qtcompat 11#../qtcompat
12DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL 12DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL
13DEFINES += KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER 13DEFINES += KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER
14#KORG_NOPRINTER KORG_NOKABC 14#KORG_NOPRINTER KORG_NOKABC
15DEFINES += KORG_NOLVALTERNATION 15DEFINES += KORG_NOLVALTERNATION
16DEFINES += DESKTOP_VERSION 16DEFINES += DESKTOP_VERSION
17unix : { 17unix : {
18LIBS += ../bin/libmicrokdepim.so 18LIBS += ../bin/libmicrokdepim.so
19LIBS += ../bin/libmicrokcal.so 19LIBS += ../bin/libmicrokcal.so
20LIBS += ../bin/libmicrokde.so 20LIBS += ../bin/libmicrokde.so
21LIBS += ../bin/libmicrokabc.so 21LIBS += ../bin/libmicrokabc.so
22#LIBS += -lbluetooth 22#LIBS += -lbluetooth
23#LIBS += -lsdp 23#LIBS += -lsdp
24 24
25#LIBS += -lldap 25#LIBS += -lldap
26OBJECTS_DIR = obj/unix 26OBJECTS_DIR = obj/unix
27MOC_DIR = moc/unix 27MOC_DIR = moc/unix
28} 28}
29win32: { 29win32: {
30RC_FILE = winicons.rc 30RC_FILE = winicons.rc
31DEFINES += _WIN32_ 31DEFINES += _WIN32_
32LIBS += ../bin/microkdepim.lib 32LIBS += ../bin/microkdepim.lib
33LIBS += ../bin/microkcal.lib 33LIBS += ../bin/microkcal.lib
34LIBS += ../bin/microkde.lib 34LIBS += ../bin/microkde.lib
35LIBS += ../bin/microkabc.lib 35LIBS += ../bin/microkabc.lib
36LIBS += ../libical/lib/ical.lib 36LIBS += ../libical/lib/ical.lib
37LIBS += ../libical/lib/icalss.lib 37LIBS += ../libical/lib/icalss.lib
38#LIBS += atls.lib 38#LIBS += atls.lib
39LIBS += mfc71u.lib 39LIBS += mfc71u.lib
40QMAKE_LINK += /NODEFAULTLIB:LIBC 40QMAKE_LINK += /NODEFAULTLIB:LIBC
41#QMAKE_LINK += /NODEFAULTLIB:MSVCRT 41#QMAKE_LINK += /NODEFAULTLIB:MSVCRT
42#QMAKE_LINK += /NODEFAULTLIB:uafxcw.lib 42#QMAKE_LINK += /NODEFAULTLIB:uafxcw.lib
43OBJECTS_DIR = obj/win 43OBJECTS_DIR = obj/win
44MOC_DIR = moc/win 44MOC_DIR = moc/win
45} 45}
46 46
47 47
48INTERFACES = kofilterview_base.ui 48INTERFACES = kofilterview_base.ui
49# filteredit_base.ui 49# filteredit_base.ui
50 50
51# kdateedit.h \ 51# kdateedit.h \
52 52
53HEADERS = \ 53HEADERS = \
54 filteredit_base.h \ 54 filteredit_base.h \
55 alarmclient.h \ 55 alarmclient.h \
56 calendarview.h \ 56 calendarview.h \
57 customlistviewitem.h \ 57 customlistviewitem.h \
58 datenavigator.h \ 58 datenavigator.h \
59 docprefs.h \ 59 docprefs.h \
60 filtereditdialog.h \ 60 filtereditdialog.h \
61 incomingdialog.h \ 61 incomingdialog.h \
62 incomingdialog_base.h \ 62 incomingdialog_base.h \
63 interfaces/korganizer/baseview.h \ 63 interfaces/korganizer/baseview.h \
64 interfaces/korganizer/calendarviewbase.h \ 64 interfaces/korganizer/calendarviewbase.h \
65 journalentry.h \ 65 journalentry.h \
66 kdatenavigator.h \ 66 kdatenavigator.h \
67 koagenda.h \ 67 koagenda.h \
68 koagendaitem.h \ 68 koagendaitem.h \
69 koagendaview.h \ 69 koagendaview.h \
70 kocounterdialog.h \ 70 kocounterdialog.h \
71 kodaymatrix.h \ 71 kodaymatrix.h \
72 kodialogmanager.h \ 72 kodialogmanager.h \
73 koeditordetails.h \ 73 koeditordetails.h \
74 koeditorgeneral.h \ 74 koeditorgeneral.h \
75 koeditorgeneralevent.h \ 75 koeditorgeneralevent.h \
76 koeditorgeneraltodo.h \ 76 koeditorgeneraltodo.h \
77 koeditorrecurrence.h \ 77 koeditorrecurrence.h \
78 koeventeditor.h \ 78 koeventeditor.h \
79 koeventpopupmenu.h \ 79 koeventpopupmenu.h \
80 koeventview.h \ 80 koeventview.h \
81 koeventviewer.h \ 81 koeventviewer.h \
82 koeventviewerdialog.h \ 82 koeventviewerdialog.h \
83 kofilterview.h \ 83 kofilterview.h \
84 koglobals.h \ 84 koglobals.h \
85 koincidenceeditor.h \ 85 koincidenceeditor.h \
86 kojournalview.h \ 86 kojournalview.h \
87 kolistview.h \ 87 kolistview.h \
88 kolocationbox.h \ 88 kolocationbox.h \
89 komonthview.h \ 89 komonthview.h \
90 koprefs.h \ 90 koprefs.h \
91 koprefsdialog.h \ 91 koprefsdialog.h \
92 kotimespanview.h \ 92 kotimespanview.h \
93 kotodoeditor.h \ 93 kotodoeditor.h \
94 kotodoview.h \ 94 kotodoview.h \
95 kotodoviewitem.h \ 95 kotodoviewitem.h \
96 koviewmanager.h \ 96 koviewmanager.h \
97 kowhatsnextview.h \ 97 kowhatsnextview.h \
98 ktimeedit.h \ 98 ktimeedit.h \
99 lineview.h \ 99 lineview.h \
100 mainwindow.h \ 100 mainwindow.h \
101 navigatorbar.h \ 101 navigatorbar.h \
102 outgoingdialog.h \ 102 outgoingdialog.h \
103 outgoingdialog_base.h \ 103 outgoingdialog_base.h \
104 publishdialog.h \ 104 publishdialog.h \
105 publishdialog_base.h \ 105 publishdialog_base.h \
106 savetemplatedialog.h \ 106 savetemplatedialog.h \
107 searchdialog.h \ 107 searchdialog.h \
108 simplealarmclient.h \ 108 simplealarmclient.h \
109 statusdialog.h \ 109 statusdialog.h \
110 timeline.h \ 110 timeline.h \
111 timespanview.h \ 111 timespanview.h \
112 version.h \ 112 version.h \
113 ../kalarmd/alarmdialog.h \ 113 ../kalarmd/alarmdialog.h \
114 114
115 115
116SOURCES = \ 116SOURCES = \
117filteredit_base.cpp \ 117filteredit_base.cpp \
118 calendarview.cpp \ 118 calendarview.cpp \
119 datenavigator.cpp \ 119 datenavigator.cpp \
120 docprefs.cpp \ 120 docprefs.cpp \
121 filtereditdialog.cpp \ 121 filtereditdialog.cpp \
122 incomingdialog.cpp \ 122 incomingdialog.cpp \
123 incomingdialog_base.cpp \ 123 incomingdialog_base.cpp \
124 journalentry.cpp \ 124 journalentry.cpp \
125 kdatenavigator.cpp \ 125 kdatenavigator.cpp \
126 koagenda.cpp \ 126 koagenda.cpp \
127 koagendaitem.cpp \ 127 koagendaitem.cpp \
128 koagendaview.cpp \ 128 koagendaview.cpp \
129 kocounterdialog.cpp \ 129 kocounterdialog.cpp \
130 kodaymatrix.cpp \ 130 kodaymatrix.cpp \
131 kodialogmanager.cpp \ 131 kodialogmanager.cpp \
132 koeditordetails.cpp \ 132 koeditordetails.cpp \
133 koeditorgeneral.cpp \ 133 koeditorgeneral.cpp \
134 koeditorgeneralevent.cpp \ 134 koeditorgeneralevent.cpp \
135 koeditorgeneraltodo.cpp \ 135 koeditorgeneraltodo.cpp \
136 koeditorrecurrence.cpp \ 136 koeditorrecurrence.cpp \
137 koeventeditor.cpp \ 137 koeventeditor.cpp \
138 koeventpopupmenu.cpp \ 138 koeventpopupmenu.cpp \
139 koeventview.cpp \ 139 koeventview.cpp \
140 koeventviewer.cpp \ 140 koeventviewer.cpp \
141 koeventviewerdialog.cpp \ 141 koeventviewerdialog.cpp \
142 kofilterview.cpp \ 142 kofilterview.cpp \
143 koglobals.cpp \ 143 koglobals.cpp \
144 koincidenceeditor.cpp \ 144 koincidenceeditor.cpp \
145 kojournalview.cpp \ 145 kojournalview.cpp \
146 kolistview.cpp \ 146 kolistview.cpp \
147 kolocationbox.cpp \ 147 kolocationbox.cpp \
148 komonthview.cpp \ 148 komonthview.cpp \
149 koprefs.cpp \ 149 koprefs.cpp \
150 koprefsdialog.cpp \ 150 koprefsdialog.cpp \
151 kotimespanview.cpp \ 151 kotimespanview.cpp \
152 kotodoeditor.cpp \ 152 kotodoeditor.cpp \
153 kotodoview.cpp \ 153 kotodoview.cpp \
154 kotodoviewitem.cpp \ 154 kotodoviewitem.cpp \
155 koviewmanager.cpp \ 155 koviewmanager.cpp \
156 kowhatsnextview.cpp \ 156 kowhatsnextview.cpp \
157 ktimeedit.cpp \ 157 ktimeedit.cpp \
158 lineview.cpp \ 158 lineview.cpp \
159 main.cpp \ 159 main.cpp \
160 mainwindow.cpp \ 160 mainwindow.cpp \
161 navigatorbar.cpp \ 161 navigatorbar.cpp \
162 outgoingdialog.cpp \ 162 outgoingdialog.cpp \
163 outgoingdialog_base.cpp \ 163 outgoingdialog_base.cpp \
164 publishdialog.cpp \ 164 publishdialog.cpp \
165 publishdialog_base.cpp \ 165 publishdialog_base.cpp \
166 savetemplatedialog.cpp \ 166 savetemplatedialog.cpp \
167 searchdialog.cpp \ 167 searchdialog.cpp \
168 simplealarmclient.cpp \ 168 simplealarmclient.cpp \
169 statusdialog.cpp \ 169 statusdialog.cpp \
170 timeline.cpp \ 170 timeline.cpp \
171 timespanview.cpp \ 171 timespanview.cpp \
172 ../kalarmd/alarmdialog.cpp 172 ../kalarmd/alarmdialog.cpp
173 173
174HEADERS += calprintbase.h calprinter.h calprintplugins.h cellitem.h 174HEADERS += calprintbase.h calprinter.h calprintplugins.h cellitem.h
175INTERFACES += calprintdayconfig_base.ui \ 175INTERFACES += calprintdayconfig_base.ui \
176 calprintmonthconfig_base.ui \ 176 calprintmonthconfig_base.ui \
177 calprinttodoconfig_base.ui \ 177 calprinttodoconfig_base.ui \
178 calprintweekconfig_base.ui 178 calprintweekconfig_base.ui
179SOURCES += calprintbase.cpp calprinter.cpp calprintplugins.cpp cellitem.cpp 179SOURCES += calprintbase.cpp calprinter.cpp calprintplugins.cpp cellitem.cpp
180 180
181 181
182 182
183win32: { 183win32: {
184HEADERS += ../outport/msoutl9.h \ 184HEADERS += ../outport/msoutl9.h \
185 koimportoldialog.h 185 koimportoldialog.h
186 186
187 187
188SOURCES += ../outport/msoutl9.cpp \ 188SOURCES += ../outport/msoutl9.cpp \
189 koimportoldialog.cpp 189 koimportoldialog.cpp
190 190
191 191
192} 192}
193 193
diff --git a/libkcal/calfilter.h b/libkcal/calfilter.h
index d6d4717..5ad0064 100644
--- a/libkcal/calfilter.h
+++ b/libkcal/calfilter.h
@@ -1,128 +1,128 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#ifndef _CALFILTER_H 21#ifndef _CALFILTER_H
22#define _CALFILTER_H 22#define _CALFILTER_H
23 23
24#include <qstring.h> 24#include <qstring.h>
25#include <qptrlist.h> 25#include <qptrlist.h>
26 26
27#include "event.h" 27#include "event.h"
28#include "todo.h" 28#include "todo.h"
29 29
30namespace KCal { 30namespace KCal {
31 31
32/** 32/**
33 Filter for calendar objects. 33 Filter for calendar objects.
34*/ 34*/
35class CalFilter { 35class CalFilter {
36 public: 36 public:
37 /** Construct filter. */ 37 /** Construct filter. */
38 CalFilter(); 38 CalFilter();
39 /** Construct filter with name */ 39 /** Construct filter with name */
40 CalFilter(const QString &name); 40 CalFilter(const QString &name);
41 /** Destruct filter. */ 41 /** Destruct filter. */
42 ~CalFilter(); 42 ~CalFilter();
43 43
44 /** 44 /**
45 Set name of filter. 45 Set name of filter.
46 */ 46 */
47 void setName(const QString &name) { mName = name; } 47 void setName(const QString &name) { mName = name; }
48 /** 48 /**
49 Return name of filter. 49 Return name of filter.
50 */ 50 */
51 QString name() const { return mName; } 51 QString name() const { return mName; }
52 52
53 /** 53 /**
54 Apply filter to eventlist, all events not matching filter criterias are 54 Apply filter to eventlist, all events not matching filter criterias are
55 removed from the list. 55 removed from the list.
56 */ 56 */
57 void apply(QPtrList<Event> *eventlist); 57 void apply(QPtrList<Event> *eventlist);
58 58
59 /** 59 /**
60 Apply filter to todolist, all todos not matching filter criterias are 60 Apply filter to todolist, all todos not matching filter criterias are
61 removed from the list. 61 removed from the list.
62 */ 62 */
63 void apply(QPtrList<Todo> *todolist); 63 void apply(QPtrList<Todo> *todolist);
64 64
65 /** 65 /**
66 Apply filter criteria on the specified event. Return true, if event passes 66 Apply filter criteria on the specified event. Return true, if event passes
67 criteria, otherwise return false. 67 criteria, otherwise return false.
68 */ 68 */
69 bool filterEvent(Event *); 69 bool filterEvent(Event *);
70 70
71 /** 71 /**
72 Apply filter criteria on the specified todo. Return true, if event passes 72 Apply filter criteria on the specified todo. Return true, if event passes
73 criteria, otherwise return false. 73 criteria, otherwise return false.
74 */ 74 */
75 bool filterTodo(Todo *); 75 bool filterTodo(Todo *);
76 76
77 /** 77 /**
78 Apply filter criteria on the specified incidence. Return true, if event passes 78 Apply filter criteria on the specified incidence. Return true, if event passes
79 criteria, otherwise return false. 79 criteria, otherwise return false.
80 */ 80 */
81 bool filterIncidence(Incidence *); 81 bool filterIncidence(Incidence *);
82 82
83 /** 83 /**
84 Enable or disable filter. 84 Enable or disable filter.
85 */ 85 */
86 void setEnabled(bool); 86 void setEnabled(bool);
87 /** 87 /**
88 Return wheter the filter is enabled or not. 88 Return wheter the filter is enabled or not.
89 */ 89 */
90 bool isEnabled(); 90 bool isEnabled();
91 bool showCategories(); 91 bool showCategories();
92 int getSecrecy(); 92 int getSecrecy();
93 /** 93 /**
94 Set list of categories, which is used for showing/hiding categories of 94 Set list of categories, which is used for showing/hiding categories of
95 events. 95 events.
96 See related functions. 96 See related functions.
97 */ 97 */
98 void setCategoryList(const QStringList &); 98 void setCategoryList(const QStringList &);
99 /** 99 /**
100 Return category list, used for showing/hiding categories of events. 100 Return category list, used for showing/hiding categories of events.
101 See related functions. 101 See related functions.
102 */ 102 */
103 QStringList categoryList(); 103 QStringList categoryList();
104 104
105 enum { HideRecurring = 1, HideCompleted = 2, ShowCategories = 4 ,ShowPublic = 8, ShowPrivate = 16, ShowConfidential = 32 }; 105 enum { HideRecurring = 1, HideCompleted = 2, ShowCategories = 4 ,ShowPublic = 8, ShowPrivate = 16, ShowConfidential = 32, HideEvents = 64, HideTodos = 128, HideJournals = 256 };
106 106
107 /** 107 /**
108 Set criteria, which have to be fulfilled by events passing the filter. 108 Set criteria, which have to be fulfilled by events passing the filter.
109 */ 109 */
110 void setCriteria(int); 110 void setCriteria(int);
111 /** 111 /**
112 Get inclusive filter criteria. 112 Get inclusive filter criteria.
113 */ 113 */
114 int criteria(); 114 int criteria();
115 115
116 private: 116 private:
117 QString mName; 117 QString mName;
118 118
119 int mCriteria; 119 int mCriteria;
120 120
121 bool mEnabled; 121 bool mEnabled;
122 122
123 QStringList mCategoryList; 123 QStringList mCategoryList;
124}; 124};
125 125
126} 126}
127 127
128#endif /* _CALFILTER_H */ 128#endif /* _CALFILTER_H */
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 33b4a65..6c1f444 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1,1354 +1,1362 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21// $Id$ 21// $Id$
22 22
23#include "ksyncmanager.h" 23#include "ksyncmanager.h"
24 24
25#include <stdlib.h> 25#include <stdlib.h>
26 26
27#ifndef _WIN32_ 27#ifndef _WIN32_
28#include <unistd.h> 28#include <unistd.h>
29#endif 29#endif
30 30
31 31
32#include "ksyncprofile.h" 32#include "ksyncprofile.h"
33#include "ksyncprefsdialog.h" 33#include "ksyncprefsdialog.h"
34#include "kpimprefs.h" 34#include "kpimprefs.h"
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36 36
37#include <qdir.h> 37#include <qdir.h>
38#include <qprogressbar.h> 38#include <qprogressbar.h>
39#include <qpopupmenu.h> 39#include <qpopupmenu.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qradiobutton.h> 41#include <qradiobutton.h>
42#include <qbuttongroup.h> 42#include <qbuttongroup.h>
43#include <qtimer.h> 43#include <qtimer.h>
44#include <qmessagebox.h> 44#include <qmessagebox.h>
45#include <qapplication.h> 45#include <qapplication.h>
46#include <qlineedit.h> 46#include <qlineedit.h>
47#include <qdialog.h> 47#include <qdialog.h>
48#include <qlayout.h> 48#include <qlayout.h>
49#include <qtextcodec.h> 49#include <qtextcodec.h>
50#include <qlabel.h> 50#include <qlabel.h>
51#include <qcheckbox.h> 51#include <qcheckbox.h>
52 52
53#include <klocale.h> 53#include <klocale.h>
54#include <kglobal.h> 54#include <kglobal.h>
55#include <kconfig.h> 55#include <kconfig.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57 57
58QDateTime KSyncManager::mRequestedSyncEvent; 58QDateTime KSyncManager::mRequestedSyncEvent;
59 59
60 60
61KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) 61KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu)
62 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu) 62 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu)
63{ 63{
64 mServerSocket = 0; 64 mServerSocket = 0;
65 bar = new QProgressBar ( 1, 0 ); 65 bar = new QProgressBar ( 1, 0 );
66 bar->setCaption (""); 66 bar->setCaption ("");
67 mWriteBackInPast = 2; 67 mWriteBackInPast = 2;
68 int w = 300; 68 int w = 300;
69 if ( QApplication::desktop()->width() < 320 ) 69 if ( QApplication::desktop()->width() < 320 )
70 w = 220; 70 w = 220;
71 int h = bar->sizeHint().height() ; 71 int h = bar->sizeHint().height() ;
72 int dw = QApplication::desktop()->width(); 72 int dw = QApplication::desktop()->width();
73 int dh = QApplication::desktop()->height(); 73 int dh = QApplication::desktop()->height();
74 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 74 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
75 if ( mPrefs->mPassiveSyncAutoStart ) 75 if ( mPrefs->mPassiveSyncAutoStart )
76 enableQuick( false ); 76 enableQuick( false );
77 77
78} 78}
79 79
80KSyncManager::~KSyncManager() 80KSyncManager::~KSyncManager()
81{ 81{
82 delete bar; 82 delete bar;
83} 83}
84 84
85 85
86void KSyncManager::fillSyncMenu() 86void KSyncManager::fillSyncMenu()
87{ 87{
88 if ( mSyncMenu->count() ) 88 if ( mSyncMenu->count() )
89 mSyncMenu->clear(); 89 mSyncMenu->clear();
90 90
91 mSyncMenu->insertItem( i18n("Configure..."), 0 ); 91 mSyncMenu->insertItem( i18n("Configure..."), 0 );
92 mSyncMenu->insertSeparator(); 92 mSyncMenu->insertSeparator();
93 QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); 93 QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu );
94 mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); 94 mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 );
95 clearMenu->insertItem( i18n("For all profiles"), 1 ); 95 clearMenu->insertItem( i18n("For all profiles"), 1 );
96 clearMenu->insertSeparator(); 96 clearMenu->insertSeparator();
97 connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); 97 connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) );
98 mSyncMenu->insertSeparator(); 98 mSyncMenu->insertSeparator();
99 if ( mServerSocket == 0 ) { 99 if ( mServerSocket == 0 ) {
100 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); 100 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
101 } else { 101 } else {
102 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); 102 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
103 } 103 }
104 mSyncMenu->insertSeparator(); 104 mSyncMenu->insertSeparator();
105 mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); 105 mSyncMenu->insertItem( i18n("Multiple sync"), 1 );
106 mSyncMenu->insertSeparator(); 106 mSyncMenu->insertSeparator();
107 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 107 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
108 config.setGroup("General"); 108 config.setGroup("General");
109 QStringList prof = config.readListEntry("SyncProfileNames"); 109 QStringList prof = config.readListEntry("SyncProfileNames");
110 mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 110 mLocalMachineName = config.readEntry("LocalMachineName","undefined");
111 if ( prof.count() < 2 ) { 111 if ( prof.count() < 2 ) {
112 prof.clear(); 112 prof.clear();
113 QString externalName; 113 QString externalName;
114#ifdef DESKTOP_VERSION 114#ifdef DESKTOP_VERSION
115#ifdef _WIN32_ 115#ifdef _WIN32_
116 externalName = "OutLook(not_implemented)"; 116 externalName = "OutLook(not_implemented)";
117#else 117#else
118 externalName = "KDE_Desktop"; 118 externalName = "KDE_Desktop";
119#endif 119#endif
120#else 120#else
121 externalName = "Sharp_DTM"; 121 externalName = "Sharp_DTM";
122#endif 122#endif
123 prof << externalName; 123 prof << externalName;
124 prof << i18n("Local_file"); 124 prof << i18n("Local_file");
125 prof << i18n("Last_file"); 125 prof << i18n("Last_file");
126 KSyncProfile* temp = new KSyncProfile (); 126 KSyncProfile* temp = new KSyncProfile ();
127 temp->setName( prof[0] ); 127 temp->setName( prof[0] );
128 temp->writeConfig(&config); 128 temp->writeConfig(&config);
129 temp->setName( prof[1] ); 129 temp->setName( prof[1] );
130 temp->writeConfig(&config); 130 temp->writeConfig(&config);
131 temp->setName( prof[2] ); 131 temp->setName( prof[2] );
132 temp->writeConfig(&config); 132 temp->writeConfig(&config);
133 config.setGroup("General"); 133 config.setGroup("General");
134 config.writeEntry("SyncProfileNames",prof); 134 config.writeEntry("SyncProfileNames",prof);
135 config.writeEntry("ExternSyncProfiles",externalName); 135 config.writeEntry("ExternSyncProfiles",externalName);
136 config.sync(); 136 config.sync();
137 delete temp; 137 delete temp;
138 } 138 }
139 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 139 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
140 mSyncProfileNames = prof; 140 mSyncProfileNames = prof;
141 unsigned int i; 141 unsigned int i;
142 for ( i = 0; i < prof.count(); ++i ) { 142 for ( i = 0; i < prof.count(); ++i ) {
143 mSyncMenu->insertItem( prof[i], 1000+i ); 143 mSyncMenu->insertItem( prof[i], 1000+i );
144 clearMenu->insertItem( prof[i], 1000+i ); 144 clearMenu->insertItem( prof[i], 1000+i );
145 if ( i == 2 ) 145 if ( i == 2 )
146 mSyncMenu->insertSeparator(); 146 mSyncMenu->insertSeparator();
147 } 147 }
148 QDir app_dir; 148 QDir app_dir;
149 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available 149 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available
150 if ( mTargetApp == PWMPI) { 150 if ( mTargetApp == PWMPI) {
151 mSyncMenu->removeItem( 1000 ); 151 mSyncMenu->removeItem( 1000 );
152 clearMenu->removeItem( 1000 ); 152 clearMenu->removeItem( 1000 );
153 } 153 }
154#ifndef DESKTOP_VERSION 154#ifndef DESKTOP_VERSION
155 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 155 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
156 mSyncMenu->removeItem( 1000 ); 156 mSyncMenu->removeItem( 1000 );
157 clearMenu->removeItem( 1000 ); 157 clearMenu->removeItem( 1000 );
158 } 158 }
159#endif 159#endif
160 mSyncMenu->removeItem( 1002 ); 160 mSyncMenu->removeItem( 1002 );
161 clearMenu->removeItem( 1002 ); 161 clearMenu->removeItem( 1002 );
162} 162}
163void KSyncManager::slotClearMenu( int action ) 163void KSyncManager::slotClearMenu( int action )
164{ 164{
165 QString syncDevice; 165 QString syncDevice;
166 if ( action > 999 ) { 166 if ( action > 999 ) {
167 syncDevice = mSyncProfileNames[action - 1000] ; 167 syncDevice = mSyncProfileNames[action - 1000] ;
168 } 168 }
169 169
170 170
171 171
172 int result = 0; 172 int result = 0;
173 QString sd; 173 QString sd;
174 if ( syncDevice.isEmpty() ) 174 if ( syncDevice.isEmpty() )
175 sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); 175 sd = i18n("Do you want to\nclear all sync info\nof all profiles?");
176 else 176 else
177 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); 177 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice );
178 178
179 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, 179 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0,
180 0, 1 ); 180 0, 1 );
181 if ( result ) 181 if ( result )
182 return; 182 return;
183 mImplementation->removeSyncInfo( syncDevice ); 183 mImplementation->removeSyncInfo( syncDevice );
184} 184}
185void KSyncManager::slotSyncMenu( int action ) 185void KSyncManager::slotSyncMenu( int action )
186{ 186{
187 qDebug("syncaction %d ", action); 187 qDebug("syncaction %d ", action);
188 if ( action == 5000 ) 188 if ( action == 5000 )
189 return; 189 return;
190 mSyncWithDesktop = false; 190 mSyncWithDesktop = false;
191 if ( action == 0 ) { 191 if ( action == 0 ) {
192 192
193 // seems to be a Qt2 event handling bug 193 // seems to be a Qt2 event handling bug
194 // syncmenu.clear causes a segfault at first time 194 // syncmenu.clear causes a segfault at first time
195 // when we call it after the main event loop, it is ok 195 // when we call it after the main event loop, it is ok
196 // same behaviour when calling OM/Pi via QCOP for the first time 196 // same behaviour when calling OM/Pi via QCOP for the first time
197 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 197 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
198 //confSync(); 198 //confSync();
199 199
200 return; 200 return;
201 } 201 }
202 if ( action == 1 ) { 202 if ( action == 1 ) {
203 multiSync( true ); 203 multiSync( true );
204 return; 204 return;
205 } 205 }
206 if ( action == 2 ) { 206 if ( action == 2 ) {
207 enableQuick(); 207 enableQuick();
208 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 208 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
209 return; 209 return;
210 } 210 }
211 if ( action == 3 ) { 211 if ( action == 3 ) {
212 delete mServerSocket; 212 delete mServerSocket;
213 mServerSocket = 0; 213 mServerSocket = 0;
214 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 214 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
215 return; 215 return;
216 } 216 }
217 217
218 if (blockSave()) 218 if (blockSave())
219 return; 219 return;
220 220
221 setBlockSave(true); 221 setBlockSave(true);
222 bool silent = false; 222 bool silent = false;
223 if ( action == 999 ) { 223 if ( action == 999 ) {
224 //special mode for silent syncing 224 //special mode for silent syncing
225 action = 1000; 225 action = 1000;
226 silent = true; 226 silent = true;
227 } 227 }
228 228
229 mCurrentSyncProfile = action - 1000 ; 229 mCurrentSyncProfile = action - 1000 ;
230 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; 230 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
231 mCurrentSyncName = mLocalMachineName ; 231 mCurrentSyncName = mLocalMachineName ;
232 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 232 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
233 KSyncProfile* temp = new KSyncProfile (); 233 KSyncProfile* temp = new KSyncProfile ();
234 temp->setName(mSyncProfileNames[mCurrentSyncProfile]); 234 temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
235 temp->readConfig(&config); 235 temp->readConfig(&config);
236 if (silent) { 236 if (silent) {
237 mAskForPreferences = false; 237 mAskForPreferences = false;
238 mShowSyncSummary = false; 238 mShowSyncSummary = false;
239 mWriteBackFile = true; 239 mWriteBackFile = true;
240 mSyncAlgoPrefs = 2;// take newest 240 mSyncAlgoPrefs = 2;// take newest
241 } 241 }
242 else { 242 else {
243 mAskForPreferences = temp->getAskForPreferences(); 243 mAskForPreferences = temp->getAskForPreferences();
244 mShowSyncSummary = temp->getShowSummaryAfterSync(); 244 mShowSyncSummary = temp->getShowSummaryAfterSync();
245 mWriteBackFile = temp->getWriteBackFile(); 245 mWriteBackFile = temp->getWriteBackFile();
246 mSyncAlgoPrefs = temp->getSyncPrefs(); 246 mSyncAlgoPrefs = temp->getSyncPrefs();
247 } 247 }
248 mWriteBackExistingOnly = temp->getWriteBackExisting(); 248 mWriteBackExistingOnly = temp->getWriteBackExisting();
249 mIsKapiFile = temp->getIsKapiFile(); 249 mIsKapiFile = temp->getIsKapiFile();
250 mWriteBackInFuture = 0; 250 mWriteBackInFuture = 0;
251 if ( temp->getWriteBackFuture() ) { 251 if ( temp->getWriteBackFuture() ) {
252 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 252 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
253 mWriteBackInPast = temp->getWriteBackPastWeeks( ); 253 mWriteBackInPast = temp->getWriteBackPastWeeks( );
254 } 254 }
255 255 mFilterInCal = temp->getFilterInCal();
256 mFilterOutCal = temp->getFilterOutCal();
257 mFilterInAB = temp->getFilterInAB();
258 mFilterOutAB = temp->getFilterOutAB();
259
256 if ( action == 1000 ) { 260 if ( action == 1000 ) {
257 mIsKapiFile = false; 261 mIsKapiFile = false;
258#ifdef DESKTOP_VERSION 262#ifdef DESKTOP_VERSION
259 syncKDE(); 263 syncKDE();
260#else 264#else
261 syncSharp(); 265 syncSharp();
262#endif 266#endif
263 267
264 } else if ( action == 1001 ) { 268 } else if ( action == 1001 ) {
265 syncLocalFile(); 269 syncLocalFile();
266 270
267 } else if ( action == 1002 ) { 271 } else if ( action == 1002 ) {
268 mWriteBackFile = false; 272 mWriteBackFile = false;
269 mAskForPreferences = false; 273 mAskForPreferences = false;
270 mShowSyncSummary = false; 274 mShowSyncSummary = false;
271 mSyncAlgoPrefs = 3; 275 mSyncAlgoPrefs = 3;
272 quickSyncLocalFile(); 276 quickSyncLocalFile();
273 277
274 } else if ( action >= 1003 ) { 278 } else if ( action >= 1003 ) {
275 if ( temp->getIsLocalFileSync() ) { 279 if ( temp->getIsLocalFileSync() ) {
276 switch(mTargetApp) 280 switch(mTargetApp)
277 { 281 {
278 case (KAPI): 282 case (KAPI):
279 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 283 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
280 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 284 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
281 break; 285 break;
282 case (KOPI): 286 case (KOPI):
283 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 287 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
284 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 288 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
285 break; 289 break;
286 case (PWMPI): 290 case (PWMPI):
287 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 291 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
288 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 292 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
289 break; 293 break;
290 default: 294 default:
291 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 295 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
292 break; 296 break;
293 297
294 } 298 }
295 } else { 299 } else {
296 if ( temp->getIsPhoneSync() ) { 300 if ( temp->getIsPhoneSync() ) {
297 mPhoneDevice = temp->getPhoneDevice( ) ; 301 mPhoneDevice = temp->getPhoneDevice( ) ;
298 mPhoneConnection = temp->getPhoneConnection( ); 302 mPhoneConnection = temp->getPhoneConnection( );
299 mPhoneModel = temp->getPhoneModel( ); 303 mPhoneModel = temp->getPhoneModel( );
300 syncPhone(); 304 syncPhone();
301 } else if ( temp->getIsPiSync() ) { 305 } else if ( temp->getIsPiSync() ) {
302 if ( mTargetApp == KAPI ) { 306 if ( mTargetApp == KAPI ) {
303 mPassWordPiSync = temp->getRemotePwAB(); 307 mPassWordPiSync = temp->getRemotePwAB();
304 mActiveSyncPort = temp->getRemotePortAB(); 308 mActiveSyncPort = temp->getRemotePortAB();
305 mActiveSyncIP = temp->getRemoteIPAB(); 309 mActiveSyncIP = temp->getRemoteIPAB();
306 } else if ( mTargetApp == KOPI ) { 310 } else if ( mTargetApp == KOPI ) {
307 mPassWordPiSync = temp->getRemotePw(); 311 mPassWordPiSync = temp->getRemotePw();
308 mActiveSyncPort = temp->getRemotePort(); 312 mActiveSyncPort = temp->getRemotePort();
309 mActiveSyncIP = temp->getRemoteIP(); 313 mActiveSyncIP = temp->getRemoteIP();
310 } else { 314 } else {
311 mPassWordPiSync = temp->getRemotePwPWM(); 315 mPassWordPiSync = temp->getRemotePwPWM();
312 mActiveSyncPort = temp->getRemotePortPWM(); 316 mActiveSyncPort = temp->getRemotePortPWM();
313 mActiveSyncIP = temp->getRemoteIPPWM(); 317 mActiveSyncIP = temp->getRemoteIPPWM();
314 } 318 }
315 syncPi(); 319 syncPi();
316 while ( !mPisyncFinished ) { 320 while ( !mPisyncFinished ) {
317 //qDebug("waiting "); 321 //qDebug("waiting ");
318 qApp->processEvents(); 322 qApp->processEvents();
319 } 323 }
320 } else 324 } else
321 syncRemote( temp ); 325 syncRemote( temp );
322 326
323 } 327 }
324 } 328 }
325 delete temp; 329 delete temp;
326 setBlockSave(false); 330 setBlockSave(false);
327} 331}
328 332
329void KSyncManager::enableQuick( bool ask ) 333void KSyncManager::enableQuick( bool ask )
330{ 334{
331 bool autoStart; 335 bool autoStart;
332 bool changed = false; 336 bool changed = false;
333 if ( ask ) { 337 if ( ask ) {
334 QDialog dia ( 0, "input-dialog", true ); 338 QDialog dia ( 0, "input-dialog", true );
335 QLineEdit lab ( &dia ); 339 QLineEdit lab ( &dia );
336 QVBoxLayout lay( &dia ); 340 QVBoxLayout lay( &dia );
337 lab.setText( mPrefs->mPassiveSyncPort ); 341 lab.setText( mPrefs->mPassiveSyncPort );
338 lay.setMargin(7); 342 lay.setMargin(7);
339 lay.setSpacing(7); 343 lay.setSpacing(7);
340 int po = 9197+mTargetApp; 344 int po = 9197+mTargetApp;
341 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); 345 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia );
342 lay.addWidget( &label); 346 lay.addWidget( &label);
343 lay.addWidget( &lab); 347 lay.addWidget( &lab);
344 348
345 QLineEdit lepw ( &dia ); 349 QLineEdit lepw ( &dia );
346 lepw.setText( mPrefs->mPassiveSyncPw ); 350 lepw.setText( mPrefs->mPassiveSyncPw );
347 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 351 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
348 lay.addWidget( &label2); 352 lay.addWidget( &label2);
349 lay.addWidget( &lepw); 353 lay.addWidget( &lepw);
350 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); 354 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia );
351 lay.addWidget( &autostart); 355 lay.addWidget( &autostart);
352 autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); 356 autostart.setChecked( mPrefs->mPassiveSyncAutoStart );
353#ifdef DESKTOP_VERSION 357#ifdef DESKTOP_VERSION
354#ifdef _WIN32_ 358#ifdef _WIN32_
355 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); 359 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia );
356 syncdesktop.hide();// not implemented! 360 syncdesktop.hide();// not implemented!
357#else 361#else
358 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); 362 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia );
359#endif 363#endif
360 lay.addWidget( &syncdesktop); 364 lay.addWidget( &syncdesktop);
361#else 365#else
362 mPrefs->mPassiveSyncWithDesktop = false; 366 mPrefs->mPassiveSyncWithDesktop = false;
363 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); 367 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia );
364 syncdesktop.hide(); 368 syncdesktop.hide();
365#endif 369#endif
366 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); 370 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop );
367 371
368 dia.setFixedSize( 230,120 ); 372 dia.setFixedSize( 230,120 );
369 dia.setCaption( i18n("Enter port for Pi-Sync") ); 373 dia.setCaption( i18n("Enter port for Pi-Sync") );
370 QPushButton pb ( "OK", &dia); 374 QPushButton pb ( "OK", &dia);
371 lay.addWidget( &pb ); 375 lay.addWidget( &pb );
372 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 376 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
373 dia.show(); 377 dia.show();
374 if ( ! dia.exec() ) 378 if ( ! dia.exec() )
375 return; 379 return;
376 dia.hide(); 380 dia.hide();
377 qApp->processEvents(); 381 qApp->processEvents();
378 if ( mPrefs->mPassiveSyncPw != lepw.text() ) { 382 if ( mPrefs->mPassiveSyncPw != lepw.text() ) {
379 changed = true; 383 changed = true;
380 mPrefs->mPassiveSyncPw = lepw.text(); 384 mPrefs->mPassiveSyncPw = lepw.text();
381 } 385 }
382 if ( mPrefs->mPassiveSyncPort != lab.text() ) { 386 if ( mPrefs->mPassiveSyncPort != lab.text() ) {
383 mPrefs->mPassiveSyncPort = lab.text(); 387 mPrefs->mPassiveSyncPort = lab.text();
384 changed = true; 388 changed = true;
385 } 389 }
386 autoStart = autostart.isChecked(); 390 autoStart = autostart.isChecked();
387 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { 391 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) {
388 changed = true; 392 changed = true;
389 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); 393 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked();
390 } 394 }
391 } 395 }
392 else 396 else
393 autoStart = mPrefs->mPassiveSyncAutoStart; 397 autoStart = mPrefs->mPassiveSyncAutoStart;
394 if ( autoStart != mPrefs->mPassiveSyncAutoStart ) 398 if ( autoStart != mPrefs->mPassiveSyncAutoStart )
395 changed = true; 399 changed = true;
396 bool ok; 400 bool ok;
397 mPrefs->mPassiveSyncAutoStart = false; 401 mPrefs->mPassiveSyncAutoStart = false;
398 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); 402 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok);
399 if ( ! ok ) { 403 if ( ! ok ) {
400 KMessageBox::information( 0, i18n("No valid port")); 404 KMessageBox::information( 0, i18n("No valid port"));
401 return; 405 return;
402 } 406 }
403 //qDebug("port %d ", port); 407 //qDebug("port %d ", port);
404 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 408 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
405 mServerSocket->setFileName( defaultFileName() );//bbb 409 mServerSocket->setFileName( defaultFileName() );//bbb
406 //qDebug("connected "); 410 //qDebug("connected ");
407 if ( !mServerSocket->ok() ) { 411 if ( !mServerSocket->ok() ) {
408 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); 412 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!"));
409 delete mServerSocket; 413 delete mServerSocket;
410 mServerSocket = 0; 414 mServerSocket = 0;
411 return; 415 return;
412 } 416 }
413 mPrefs->mPassiveSyncAutoStart = autoStart; 417 mPrefs->mPassiveSyncAutoStart = autoStart;
414 if ( changed ) { 418 if ( changed ) {
415 mPrefs->writeConfig(); 419 mPrefs->writeConfig();
416 } 420 }
417 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 421 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
418 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 422 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
419} 423}
420 424
421void KSyncManager::syncLocalFile() 425void KSyncManager::syncLocalFile()
422{ 426{
423 427
424 QString fn =mPrefs->mLastSyncedLocalFile; 428 QString fn =mPrefs->mLastSyncedLocalFile;
425 QString ext; 429 QString ext;
426 430
427 switch(mTargetApp) 431 switch(mTargetApp)
428 { 432 {
429 case (KAPI): 433 case (KAPI):
430 ext = "(*.vcf)"; 434 ext = "(*.vcf)";
431 break; 435 break;
432 case (KOPI): 436 case (KOPI):
433 ext = "(*.ics/*.vcs)"; 437 ext = "(*.ics/*.vcs)";
434 break; 438 break;
435 case (PWMPI): 439 case (PWMPI):
436 ext = "(*.pwm)"; 440 ext = "(*.pwm)";
437 break; 441 break;
438 default: 442 default:
439 qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); 443 qDebug("KSyncManager::syncLocalFile: invalid apptype selected");
440 break; 444 break;
441 445
442 } 446 }
443 447
444 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 448 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
445 if ( fn == "" ) 449 if ( fn == "" )
446 return; 450 return;
447 if ( syncWithFile( fn, false ) ) { 451 if ( syncWithFile( fn, false ) ) {
448 qDebug("syncLocalFile() successful "); 452 qDebug("syncLocalFile() successful ");
449 } 453 }
450 454
451} 455}
452 456
453bool KSyncManager::syncWithFile( QString fn , bool quick ) 457bool KSyncManager::syncWithFile( QString fn , bool quick )
454{ 458{
455 bool ret = false; 459 bool ret = false;
456 QFileInfo info; 460 QFileInfo info;
457 info.setFile( fn ); 461 info.setFile( fn );
458 QString mess; 462 QString mess;
459 bool loadbup = true; 463 bool loadbup = true;
460 if ( !info. exists() ) { 464 if ( !info. exists() ) {
461 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 465 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
462 int result = QMessageBox::warning( mParent, i18n("Warning!"), 466 int result = QMessageBox::warning( mParent, i18n("Warning!"),
463 mess ); 467 mess );
464 return ret; 468 return ret;
465 } 469 }
466 int result = 0; 470 int result = 0;
467 if ( !quick ) { 471 if ( !quick ) {
468 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 472 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
469 result = QMessageBox::warning( mParent, i18n("Warning!"), 473 result = QMessageBox::warning( mParent, i18n("Warning!"),
470 mess, 474 mess,
471 i18n("Sync"), i18n("Cancel"), 0, 475 i18n("Sync"), i18n("Cancel"), 0,
472 0, 1 ); 476 0, 1 );
473 if ( result ) 477 if ( result )
474 return false; 478 return false;
475 } 479 }
476 if ( mAskForPreferences ) 480 if ( mAskForPreferences )
477 if ( !edit_sync_options()) { 481 if ( !edit_sync_options()) {
478 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 482 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
479 return false; 483 return false;
480 } 484 }
481 if ( result == 0 ) { 485 if ( result == 0 ) {
482 //qDebug("Now sycing ... "); 486 //qDebug("Now sycing ... ");
483 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) 487 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) )
484 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); 488 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
485 else 489 else
486 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 490 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
487 if ( ! quick ) 491 if ( ! quick )
488 mPrefs->mLastSyncedLocalFile = fn; 492 mPrefs->mLastSyncedLocalFile = fn;
489 } 493 }
490 return ret; 494 return ret;
491} 495}
492 496
493void KSyncManager::quickSyncLocalFile() 497void KSyncManager::quickSyncLocalFile()
494{ 498{
495 499
496 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { 500 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) {
497 qDebug("quick syncLocalFile() successful "); 501 qDebug("quick syncLocalFile() successful ");
498 502
499 } 503 }
500} 504}
501 505
502void KSyncManager::multiSync( bool askforPrefs ) 506void KSyncManager::multiSync( bool askforPrefs )
503{ 507{
504 if (blockSave()) 508 if (blockSave())
505 return; 509 return;
506 setBlockSave(true); 510 setBlockSave(true);
507 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 511 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
508 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), 512 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"),
509 question, 513 question,
510 i18n("Yes"), i18n("No"), 514 i18n("Yes"), i18n("No"),
511 0, 0 ) != 0 ) { 515 0, 0 ) != 0 ) {
512 setBlockSave(false); 516 setBlockSave(false);
513 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); 517 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!"));
514 return; 518 return;
515 } 519 }
516 mCurrentSyncDevice = i18n("Multiple profiles") ; 520 mCurrentSyncDevice = i18n("Multiple profiles") ;
517 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; 521 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
518 if ( askforPrefs ) { 522 if ( askforPrefs ) {
519 if ( !edit_sync_options()) { 523 if ( !edit_sync_options()) {
520 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); 524 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") );
521 return; 525 return;
522 } 526 }
523 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; 527 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs;
524 } 528 }
525 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); 529 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") );
526 qApp->processEvents(); 530 qApp->processEvents();
527 int num = ringSync() ; 531 int num = ringSync() ;
528 if ( num > 1 ) 532 if ( num > 1 )
529 ringSync(); 533 ringSync();
530 setBlockSave(false); 534 setBlockSave(false);
531 if ( num ) 535 if ( num )
532 emit save(); 536 emit save();
533 if ( num ) 537 if ( num )
534 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); 538 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) );
535 else 539 else
536 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 540 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
537 return; 541 return;
538} 542}
539 543
540int KSyncManager::ringSync() 544int KSyncManager::ringSync()
541{ 545{
542 546
543 int syncedProfiles = 0; 547 int syncedProfiles = 0;
544 unsigned int i; 548 unsigned int i;
545 QTime timer; 549 QTime timer;
546 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 550 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
547 QStringList syncProfileNames = mSyncProfileNames; 551 QStringList syncProfileNames = mSyncProfileNames;
548 KSyncProfile* temp = new KSyncProfile (); 552 KSyncProfile* temp = new KSyncProfile ();
549 mAskForPreferences = false; 553 mAskForPreferences = false;
550 for ( i = 0; i < syncProfileNames.count(); ++i ) { 554 for ( i = 0; i < syncProfileNames.count(); ++i ) {
551 mCurrentSyncProfile = i; 555 mCurrentSyncProfile = i;
552 temp->setName(syncProfileNames[mCurrentSyncProfile]); 556 temp->setName(syncProfileNames[mCurrentSyncProfile]);
553 temp->readConfig(&config); 557 temp->readConfig(&config);
554 558
555 bool includeInRingSync; 559 bool includeInRingSync;
556 switch(mTargetApp) 560 switch(mTargetApp)
557 { 561 {
558 case (KAPI): 562 case (KAPI):
559 includeInRingSync = temp->getIncludeInRingSyncAB(); 563 includeInRingSync = temp->getIncludeInRingSyncAB();
560 break; 564 break;
561 case (KOPI): 565 case (KOPI):
562 includeInRingSync = temp->getIncludeInRingSync(); 566 includeInRingSync = temp->getIncludeInRingSync();
563 break; 567 break;
564 case (PWMPI): 568 case (PWMPI):
565 includeInRingSync = temp->getIncludeInRingSyncPWM(); 569 includeInRingSync = temp->getIncludeInRingSyncPWM();
566 break; 570 break;
567 default: 571 default:
568 qDebug("KSyncManager::ringSync: invalid apptype selected"); 572 qDebug("KSyncManager::ringSync: invalid apptype selected");
569 break; 573 break;
570 574
571 } 575 }
572 576
573 577
574 if ( includeInRingSync && ( i < 1 || i > 2 )) { 578 if ( includeInRingSync && ( i < 1 || i > 2 )) {
575 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 579 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
576 ++syncedProfiles; 580 ++syncedProfiles;
577 mSyncWithDesktop = false; 581 mSyncWithDesktop = false;
578 // mAskForPreferences = temp->getAskForPreferences(); 582 // mAskForPreferences = temp->getAskForPreferences();
579 mWriteBackFile = temp->getWriteBackFile(); 583 mWriteBackFile = temp->getWriteBackFile();
580 mWriteBackExistingOnly = temp->getWriteBackExisting(); 584 mWriteBackExistingOnly = temp->getWriteBackExisting();
581 mIsKapiFile = temp->getIsKapiFile(); 585 mIsKapiFile = temp->getIsKapiFile();
582 mWriteBackInFuture = 0; 586 mWriteBackInFuture = 0;
583 if ( temp->getWriteBackFuture() ) { 587 if ( temp->getWriteBackFuture() ) {
584 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 588 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
585 mWriteBackInPast = temp->getWriteBackPastWeeks( ); 589 mWriteBackInPast = temp->getWriteBackPastWeeks( );
586 } 590 }
591 mFilterInCal = temp->getFilterInCal();
592 mFilterOutCal = temp->getFilterOutCal();
593 mFilterInAB = temp->getFilterInAB();
594 mFilterOutAB = temp->getFilterOutAB();
587 mShowSyncSummary = false; 595 mShowSyncSummary = false;
588 mCurrentSyncDevice = syncProfileNames[i] ; 596 mCurrentSyncDevice = syncProfileNames[i] ;
589 mCurrentSyncName = mLocalMachineName; 597 mCurrentSyncName = mLocalMachineName;
590 if ( i == 0 ) { 598 if ( i == 0 ) {
591 mIsKapiFile = false; 599 mIsKapiFile = false;
592#ifdef DESKTOP_VERSION 600#ifdef DESKTOP_VERSION
593 syncKDE(); 601 syncKDE();
594#else 602#else
595 syncSharp(); 603 syncSharp();
596#endif 604#endif
597 } else { 605 } else {
598 if ( temp->getIsLocalFileSync() ) { 606 if ( temp->getIsLocalFileSync() ) {
599 switch(mTargetApp) 607 switch(mTargetApp)
600 { 608 {
601 case (KAPI): 609 case (KAPI):
602 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 610 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
603 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 611 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
604 break; 612 break;
605 case (KOPI): 613 case (KOPI):
606 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 614 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
607 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 615 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
608 break; 616 break;
609 case (PWMPI): 617 case (PWMPI):
610 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 618 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
611 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 619 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
612 break; 620 break;
613 default: 621 default:
614 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 622 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
615 break; 623 break;
616 } 624 }
617 } else { 625 } else {
618 if ( temp->getIsPhoneSync() ) { 626 if ( temp->getIsPhoneSync() ) {
619 mPhoneDevice = temp->getPhoneDevice( ) ; 627 mPhoneDevice = temp->getPhoneDevice( ) ;
620 mPhoneConnection = temp->getPhoneConnection( ); 628 mPhoneConnection = temp->getPhoneConnection( );
621 mPhoneModel = temp->getPhoneModel( ); 629 mPhoneModel = temp->getPhoneModel( );
622 syncPhone(); 630 syncPhone();
623 } else if ( temp->getIsPiSync() ) { 631 } else if ( temp->getIsPiSync() ) {
624 if ( mTargetApp == KAPI ) { 632 if ( mTargetApp == KAPI ) {
625 mPassWordPiSync = temp->getRemotePwAB(); 633 mPassWordPiSync = temp->getRemotePwAB();
626 mActiveSyncPort = temp->getRemotePortAB(); 634 mActiveSyncPort = temp->getRemotePortAB();
627 mActiveSyncIP = temp->getRemoteIPAB(); 635 mActiveSyncIP = temp->getRemoteIPAB();
628 } else if ( mTargetApp == KOPI ) { 636 } else if ( mTargetApp == KOPI ) {
629 mPassWordPiSync = temp->getRemotePw(); 637 mPassWordPiSync = temp->getRemotePw();
630 mActiveSyncPort = temp->getRemotePort(); 638 mActiveSyncPort = temp->getRemotePort();
631 mActiveSyncIP = temp->getRemoteIP(); 639 mActiveSyncIP = temp->getRemoteIP();
632 } else { 640 } else {
633 mPassWordPiSync = temp->getRemotePwPWM(); 641 mPassWordPiSync = temp->getRemotePwPWM();
634 mActiveSyncPort = temp->getRemotePortPWM(); 642 mActiveSyncPort = temp->getRemotePortPWM();
635 mActiveSyncIP = temp->getRemoteIPPWM(); 643 mActiveSyncIP = temp->getRemoteIPPWM();
636 } 644 }
637 syncPi(); 645 syncPi();
638 while ( !mPisyncFinished ) { 646 while ( !mPisyncFinished ) {
639 //qDebug("waiting "); 647 //qDebug("waiting ");
640 qApp->processEvents(); 648 qApp->processEvents();
641 } 649 }
642 timer.start(); 650 timer.start();
643 while ( timer.elapsed () < 2000 ) { 651 while ( timer.elapsed () < 2000 ) {
644 qApp->processEvents(); 652 qApp->processEvents();
645 } 653 }
646 } else 654 } else
647 syncRemote( temp, false ); 655 syncRemote( temp, false );
648 656
649 } 657 }
650 } 658 }
651 timer.start(); 659 timer.start();
652 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); 660 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") );
653 while ( timer.elapsed () < 2000 ) { 661 while ( timer.elapsed () < 2000 ) {
654 qApp->processEvents(); 662 qApp->processEvents();
655#ifndef _WIN32_ 663#ifndef _WIN32_
656 sleep (1); 664 sleep (1);
657#endif 665#endif
658 } 666 }
659 667
660 } 668 }
661 669
662 } 670 }
663 delete temp; 671 delete temp;
664 return syncedProfiles; 672 return syncedProfiles;
665} 673}
666 674
667void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) 675void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
668{ 676{
669 QString question; 677 QString question;
670 if ( ask ) { 678 if ( ask ) {
671 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 679 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
672 if ( QMessageBox::information( mParent, i18n("Sync"), 680 if ( QMessageBox::information( mParent, i18n("Sync"),
673 question, 681 question,
674 i18n("Yes"), i18n("No"), 682 i18n("Yes"), i18n("No"),
675 0, 0 ) != 0 ) 683 0, 0 ) != 0 )
676 return; 684 return;
677 } 685 }
678 686
679 QString preCommand; 687 QString preCommand;
680 QString localTempFile; 688 QString localTempFile;
681 QString postCommand; 689 QString postCommand;
682 690
683 switch(mTargetApp) 691 switch(mTargetApp)
684 { 692 {
685 case (KAPI): 693 case (KAPI):
686 preCommand = prof->getPreSyncCommandAB(); 694 preCommand = prof->getPreSyncCommandAB();
687 postCommand = prof->getPostSyncCommandAB(); 695 postCommand = prof->getPostSyncCommandAB();
688 localTempFile = prof->getLocalTempFileAB(); 696 localTempFile = prof->getLocalTempFileAB();
689 break; 697 break;
690 case (KOPI): 698 case (KOPI):
691 preCommand = prof->getPreSyncCommand(); 699 preCommand = prof->getPreSyncCommand();
692 postCommand = prof->getPostSyncCommand(); 700 postCommand = prof->getPostSyncCommand();
693 localTempFile = prof->getLocalTempFile(); 701 localTempFile = prof->getLocalTempFile();
694 break; 702 break;
695 case (PWMPI): 703 case (PWMPI):
696 preCommand = prof->getPreSyncCommandPWM(); 704 preCommand = prof->getPreSyncCommandPWM();
697 postCommand = prof->getPostSyncCommandPWM(); 705 postCommand = prof->getPostSyncCommandPWM();
698 localTempFile = prof->getLocalTempFilePWM(); 706 localTempFile = prof->getLocalTempFilePWM();
699 break; 707 break;
700 default: 708 default:
701 qDebug("KSyncManager::syncRemote: invalid apptype selected"); 709 qDebug("KSyncManager::syncRemote: invalid apptype selected");
702 break; 710 break;
703 } 711 }
704 712
705 713
706 int fi; 714 int fi;
707 if ( (fi = preCommand.find("$PWD$")) > 0 ) { 715 if ( (fi = preCommand.find("$PWD$")) > 0 ) {
708 QString pwd = getPassword(); 716 QString pwd = getPassword();
709 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); 717 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
710 718
711 } 719 }
712 int maxlen = 30; 720 int maxlen = 30;
713 if ( QApplication::desktop()->width() > 320 ) 721 if ( QApplication::desktop()->width() > 320 )
714 maxlen += 25; 722 maxlen += 25;
715 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); 723 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) );
716 int fileSize = 0; 724 int fileSize = 0;
717 int result = system ( preCommand ); 725 int result = system ( preCommand );
718 // 0 : okay 726 // 0 : okay
719 // 256: no such file or dir 727 // 256: no such file or dir
720 // 728 //
721 qDebug("Sync: Remote copy result(0 = okay): %d ",result ); 729 qDebug("Sync: Remote copy result(0 = okay): %d ",result );
722 if ( result != 0 ) { 730 if ( result != 0 ) {
723 unsigned int len = maxlen; 731 unsigned int len = maxlen;
724 while ( len < preCommand.length() ) { 732 while ( len < preCommand.length() ) {
725 preCommand.insert( len , "\n" ); 733 preCommand.insert( len , "\n" );
726 len += maxlen +2; 734 len += maxlen +2;
727 } 735 }
728 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; 736 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ;
729 QMessageBox::information( mParent, i18n("Sync - ERROR"), 737 QMessageBox::information( mParent, i18n("Sync - ERROR"),
730 question, 738 question,
731 i18n("Okay!")) ; 739 i18n("Okay!")) ;
732 mParent->topLevelWidget()->setCaption ("KDE-Pim"); 740 mParent->topLevelWidget()->setCaption ("KDE-Pim");
733 return; 741 return;
734 } 742 }
735 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); 743 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) );
736 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 744 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
737 745
738 if ( syncWithFile( localTempFile, true ) ) { 746 if ( syncWithFile( localTempFile, true ) ) {
739 747
740 if ( mWriteBackFile ) { 748 if ( mWriteBackFile ) {
741 int fi; 749 int fi;
742 if ( (fi = postCommand.find("$PWD$")) > 0 ) { 750 if ( (fi = postCommand.find("$PWD$")) > 0 ) {
743 QString pwd = getPassword(); 751 QString pwd = getPassword();
744 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); 752 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
745 753
746 } 754 }
747 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); 755 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) );
748 result = system ( postCommand ); 756 result = system ( postCommand );
749 qDebug("Sync:Writing back file result: %d ", result); 757 qDebug("Sync:Writing back file result: %d ", result);
750 if ( result != 0 ) { 758 if ( result != 0 ) {
751 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 759 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
752 return; 760 return;
753 } else { 761 } else {
754 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); 762 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) );
755 } 763 }
756 } 764 }
757 } 765 }
758 return; 766 return;
759} 767}
760bool KSyncManager::edit_pisync_options() 768bool KSyncManager::edit_pisync_options()
761{ 769{
762 QDialog dia( mParent, "dia", true ); 770 QDialog dia( mParent, "dia", true );
763 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); 771 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice );
764 QVBoxLayout lay ( &dia ); 772 QVBoxLayout lay ( &dia );
765 lay.setSpacing( 5 ); 773 lay.setSpacing( 5 );
766 lay.setMargin( 3 ); 774 lay.setMargin( 3 );
767 QLabel lab1 ( i18n("Password for remote access:"), &dia); 775 QLabel lab1 ( i18n("Password for remote access:"), &dia);
768 lay.addWidget( &lab1 ); 776 lay.addWidget( &lab1 );
769 QLineEdit le1 (&dia ); 777 QLineEdit le1 (&dia );
770 lay.addWidget( &le1 ); 778 lay.addWidget( &le1 );
771 QLabel lab2 ( i18n("Remote IP address:"), &dia); 779 QLabel lab2 ( i18n("Remote IP address:"), &dia);
772 lay.addWidget( &lab2 ); 780 lay.addWidget( &lab2 );
773 QLineEdit le2 (&dia ); 781 QLineEdit le2 (&dia );
774 lay.addWidget( &le2 ); 782 lay.addWidget( &le2 );
775 QLabel lab3 ( i18n("Remote port number:"), &dia); 783 QLabel lab3 ( i18n("Remote port number:"), &dia);
776 lay.addWidget( &lab3 ); 784 lay.addWidget( &lab3 );
777 QLineEdit le3 (&dia ); 785 QLineEdit le3 (&dia );
778 lay.addWidget( &le3 ); 786 lay.addWidget( &le3 );
779 QPushButton pb ( "OK", &dia); 787 QPushButton pb ( "OK", &dia);
780 lay.addWidget( &pb ); 788 lay.addWidget( &pb );
781 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 789 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
782 le1.setText( mPassWordPiSync ); 790 le1.setText( mPassWordPiSync );
783 le2.setText( mActiveSyncIP ); 791 le2.setText( mActiveSyncIP );
784 le3.setText( mActiveSyncPort ); 792 le3.setText( mActiveSyncPort );
785 if ( dia.exec() ) { 793 if ( dia.exec() ) {
786 mPassWordPiSync = le1.text(); 794 mPassWordPiSync = le1.text();
787 mActiveSyncPort = le3.text(); 795 mActiveSyncPort = le3.text();
788 mActiveSyncIP = le2.text(); 796 mActiveSyncIP = le2.text();
789 return true; 797 return true;
790 } 798 }
791 return false; 799 return false;
792} 800}
793bool KSyncManager::edit_sync_options() 801bool KSyncManager::edit_sync_options()
794{ 802{
795 803
796 QDialog dia( mParent, "dia", true ); 804 QDialog dia( mParent, "dia", true );
797 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 805 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
798 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 806 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
799 QVBoxLayout lay ( &dia ); 807 QVBoxLayout lay ( &dia );
800 lay.setSpacing( 2 ); 808 lay.setSpacing( 2 );
801 lay.setMargin( 3 ); 809 lay.setMargin( 3 );
802 lay.addWidget(&gr); 810 lay.addWidget(&gr);
803 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 811 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
804 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 812 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
805 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 813 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
806 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 814 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
807 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 815 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
808 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 816 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
809 //QRadioButton both( i18n("Take both on conflict"), &gr ); 817 //QRadioButton both( i18n("Take both on conflict"), &gr );
810 QPushButton pb ( "OK", &dia); 818 QPushButton pb ( "OK", &dia);
811 lay.addWidget( &pb ); 819 lay.addWidget( &pb );
812 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 820 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
813 switch ( mSyncAlgoPrefs ) { 821 switch ( mSyncAlgoPrefs ) {
814 case 0: 822 case 0:
815 loc.setChecked( true); 823 loc.setChecked( true);
816 break; 824 break;
817 case 1: 825 case 1:
818 rem.setChecked( true ); 826 rem.setChecked( true );
819 break; 827 break;
820 case 2: 828 case 2:
821 newest.setChecked( true); 829 newest.setChecked( true);
822 break; 830 break;
823 case 3: 831 case 3:
824 ask.setChecked( true); 832 ask.setChecked( true);
825 break; 833 break;
826 case 4: 834 case 4:
827 f_loc.setChecked( true); 835 f_loc.setChecked( true);
828 break; 836 break;
829 case 5: 837 case 5:
830 f_rem.setChecked( true); 838 f_rem.setChecked( true);
831 break; 839 break;
832 case 6: 840 case 6:
833 // both.setChecked( true); 841 // both.setChecked( true);
834 break; 842 break;
835 default: 843 default:
836 break; 844 break;
837 } 845 }
838 if ( dia.exec() ) { 846 if ( dia.exec() ) {
839 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 847 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
840 return true; 848 return true;
841 } 849 }
842 return false; 850 return false;
843} 851}
844 852
845QString KSyncManager::getPassword( ) 853QString KSyncManager::getPassword( )
846{ 854{
847 QString retfile = ""; 855 QString retfile = "";
848 QDialog dia ( mParent, "input-dialog", true ); 856 QDialog dia ( mParent, "input-dialog", true );
849 QLineEdit lab ( &dia ); 857 QLineEdit lab ( &dia );
850 lab.setEchoMode( QLineEdit::Password ); 858 lab.setEchoMode( QLineEdit::Password );
851 QVBoxLayout lay( &dia ); 859 QVBoxLayout lay( &dia );
852 lay.setMargin(7); 860 lay.setMargin(7);
853 lay.setSpacing(7); 861 lay.setSpacing(7);
854 lay.addWidget( &lab); 862 lay.addWidget( &lab);
855 dia.setFixedSize( 230,50 ); 863 dia.setFixedSize( 230,50 );
856 dia.setCaption( i18n("Enter password") ); 864 dia.setCaption( i18n("Enter password") );
857 QPushButton pb ( "OK", &dia); 865 QPushButton pb ( "OK", &dia);
858 lay.addWidget( &pb ); 866 lay.addWidget( &pb );
859 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 867 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
860 dia.show(); 868 dia.show();
861 int res = dia.exec(); 869 int res = dia.exec();
862 if ( res ) 870 if ( res )
863 retfile = lab.text(); 871 retfile = lab.text();
864 dia.hide(); 872 dia.hide();
865 qApp->processEvents(); 873 qApp->processEvents();
866 return retfile; 874 return retfile;
867 875
868} 876}
869 877
870 878
871void KSyncManager::confSync() 879void KSyncManager::confSync()
872{ 880{
873 static KSyncPrefsDialog* sp = 0; 881 static KSyncPrefsDialog* sp = 0;
874 if ( ! sp ) { 882 if ( ! sp ) {
875 sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); 883 sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
876 } 884 }
877 sp->usrReadConfig(); 885 sp->usrReadConfig();
878#ifndef DESKTOP_VERSION 886#ifndef DESKTOP_VERSION
879 sp->showMaximized(); 887 sp->showMaximized();
880#else 888#else
881 sp->show(); 889 sp->show();
882#endif 890#endif
883 sp->exec(); 891 sp->exec();
884 QStringList oldSyncProfileNames = mSyncProfileNames; 892 QStringList oldSyncProfileNames = mSyncProfileNames;
885 mSyncProfileNames = sp->getSyncProfileNames(); 893 mSyncProfileNames = sp->getSyncProfileNames();
886 mLocalMachineName = sp->getLocalMachineName (); 894 mLocalMachineName = sp->getLocalMachineName ();
887 int ii; 895 int ii;
888 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { 896 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) {
889 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) 897 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) )
890 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); 898 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] );
891 } 899 }
892 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 900 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
893} 901}
894void KSyncManager::syncKDE() 902void KSyncManager::syncKDE()
895{ 903{
896 mSyncWithDesktop = true; 904 mSyncWithDesktop = true;
897 emit save(); 905 emit save();
898 switch(mTargetApp) 906 switch(mTargetApp)
899 { 907 {
900 case (KAPI): 908 case (KAPI):
901 { 909 {
902#ifdef DESKTOP_VERSION 910#ifdef DESKTOP_VERSION
903 QString command = qApp->applicationDirPath () + "/kdeabdump"; 911 QString command = qApp->applicationDirPath () + "/kdeabdump";
904#else 912#else
905 QString command = "kdeabdump"; 913 QString command = "kdeabdump";
906#endif 914#endif
907 if ( ! QFile::exists ( command ) ) 915 if ( ! QFile::exists ( command ) )
908 command = "kdeabdump"; 916 command = "kdeabdump";
909 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; 917 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf";
910 system ( command.latin1()); 918 system ( command.latin1());
911 if ( syncWithFile( fileName,true ) ) { 919 if ( syncWithFile( fileName,true ) ) {
912 if ( mWriteBackFile ) { 920 if ( mWriteBackFile ) {
913 command += " --read"; 921 command += " --read";
914 system ( command.latin1()); 922 system ( command.latin1());
915 } 923 }
916 } 924 }
917 925
918 } 926 }
919 break; 927 break;
920 case (KOPI): 928 case (KOPI):
921 { 929 {
922#ifdef DESKTOP_VERSION 930#ifdef DESKTOP_VERSION
923 QString command = qApp->applicationDirPath () + "/kdecaldump"; 931 QString command = qApp->applicationDirPath () + "/kdecaldump";
924#else 932#else
925 QString command = "kdecaldump"; 933 QString command = "kdecaldump";
926#endif 934#endif
927 if ( ! QFile::exists ( command ) ) 935 if ( ! QFile::exists ( command ) )
928 command = "kdecaldump"; 936 command = "kdecaldump";
929 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; 937 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics";
930 system ( command.latin1()); 938 system ( command.latin1());
931 if ( syncWithFile( fileName,true ) ) { 939 if ( syncWithFile( fileName,true ) ) {
932 if ( mWriteBackFile ) { 940 if ( mWriteBackFile ) {
933 command += " --read"; 941 command += " --read";
934 system ( command.latin1()); 942 system ( command.latin1());
935 } 943 }
936 } 944 }
937 945
938 } 946 }
939 break; 947 break;
940 case (PWMPI): 948 case (PWMPI):
941 949
942 break; 950 break;
943 default: 951 default:
944 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 952 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
945 break; 953 break;
946 954
947 } 955 }
948} 956}
949 957
950void KSyncManager::syncSharp() 958void KSyncManager::syncSharp()
951{ 959{
952 960
953 if ( ! syncExternalApplication("sharp") ) 961 if ( ! syncExternalApplication("sharp") )
954 qDebug("ERROR sync sharp "); 962 qDebug("ERROR sync sharp ");
955} 963}
956 964
957bool KSyncManager::syncExternalApplication(QString resource) 965bool KSyncManager::syncExternalApplication(QString resource)
958{ 966{
959 967
960 emit save(); 968 emit save();
961 969
962 if ( mAskForPreferences ) 970 if ( mAskForPreferences )
963 if ( !edit_sync_options()) { 971 if ( !edit_sync_options()) {
964 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 972 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
965 return false; 973 return false;
966 } 974 }
967 975
968 qDebug("Sync extern %s", resource.latin1()); 976 qDebug("Sync extern %s", resource.latin1());
969 977
970 bool syncOK = mImplementation->syncExternal(this, resource); 978 bool syncOK = mImplementation->syncExternal(this, resource);
971 979
972 return syncOK; 980 return syncOK;
973 981
974} 982}
975 983
976void KSyncManager::syncPhone() 984void KSyncManager::syncPhone()
977{ 985{
978 986
979 syncExternalApplication("phone"); 987 syncExternalApplication("phone");
980 988
981} 989}
982 990
983void KSyncManager::showProgressBar(int percentage, QString caption, int total) 991void KSyncManager::showProgressBar(int percentage, QString caption, int total)
984{ 992{
985 if (!bar->isVisible()) 993 if (!bar->isVisible())
986 { 994 {
987 bar->setCaption (caption); 995 bar->setCaption (caption);
988 bar->setTotalSteps ( total ) ; 996 bar->setTotalSteps ( total ) ;
989 997
990 bar->show(); 998 bar->show();
991 } 999 }
992 1000
993 bar->setProgress( percentage ); 1001 bar->setProgress( percentage );
994} 1002}
995 1003
996void KSyncManager::hideProgressBar() 1004void KSyncManager::hideProgressBar()
997{ 1005{
998 bar->hide(); 1006 bar->hide();
999} 1007}
1000 1008
1001bool KSyncManager::isProgressBarCanceled() 1009bool KSyncManager::isProgressBarCanceled()
1002{ 1010{
1003 return !bar->isVisible(); 1011 return !bar->isVisible();
1004} 1012}
1005 1013
1006QString KSyncManager::syncFileName() 1014QString KSyncManager::syncFileName()
1007{ 1015{
1008 1016
1009 QString fn = "tempfile"; 1017 QString fn = "tempfile";
1010 switch(mTargetApp) 1018 switch(mTargetApp)
1011 { 1019 {
1012 case (KAPI): 1020 case (KAPI):
1013 fn = "tempsyncab.vcf"; 1021 fn = "tempsyncab.vcf";
1014 break; 1022 break;
1015 case (KOPI): 1023 case (KOPI):
1016 fn = "tempsynccal.ics"; 1024 fn = "tempsynccal.ics";
1017 break; 1025 break;
1018 case (PWMPI): 1026 case (PWMPI):
1019 fn = "tempsyncpw.pwm"; 1027 fn = "tempsyncpw.pwm";
1020 break; 1028 break;
1021 default: 1029 default:
1022 break; 1030 break;
1023 } 1031 }
1024#ifdef _WIN32_ 1032#ifdef _WIN32_
1025 return locateLocal( "tmp", fn ); 1033 return locateLocal( "tmp", fn );
1026#else 1034#else
1027 return (QString( "/tmp/" )+ fn ); 1035 return (QString( "/tmp/" )+ fn );
1028#endif 1036#endif
1029} 1037}
1030 1038
1031void KSyncManager::syncPi() 1039void KSyncManager::syncPi()
1032{ 1040{
1033 mIsKapiFile = true; 1041 mIsKapiFile = true;
1034 mPisyncFinished = false; 1042 mPisyncFinished = false;
1035 qApp->processEvents(); 1043 qApp->processEvents();
1036 if ( mAskForPreferences ) 1044 if ( mAskForPreferences )
1037 if ( !edit_pisync_options()) { 1045 if ( !edit_pisync_options()) {
1038 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 1046 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
1039 return; 1047 return;
1040 } 1048 }
1041 bool ok; 1049 bool ok;
1042 Q_UINT16 port = mActiveSyncPort.toUInt(&ok); 1050 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
1043 if ( ! ok ) { 1051 if ( ! ok ) {
1044 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 1052 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
1045 return; 1053 return;
1046 } 1054 }
1047 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); 1055 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this );
1048 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1056 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1049 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); 1057 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") );
1050 commandSocket->readFile( syncFileName() ); 1058 commandSocket->readFile( syncFileName() );
1051} 1059}
1052 1060
1053void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 1061void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
1054{ 1062{
1055 //enum { success, errorW, errorR, quiet }; 1063 //enum { success, errorW, errorR, quiet };
1056 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { 1064 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) {
1057 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); 1065 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
1058 delete s; 1066 delete s;
1059 if ( state == KCommandSocket::errorR ) { 1067 if ( state == KCommandSocket::errorR ) {
1060 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 1068 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
1061 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1069 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1062 commandSocket->sendStop(); 1070 commandSocket->sendStop();
1063 } 1071 }
1064 mPisyncFinished = true; 1072 mPisyncFinished = true;
1065 return; 1073 return;
1066 1074
1067 } else if ( state == KCommandSocket::errorW ) { 1075 } else if ( state == KCommandSocket::errorW ) {
1068 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); 1076 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
1069 mPisyncFinished = true; 1077 mPisyncFinished = true;
1070 1078
1071 } else if ( state == KCommandSocket::successR ) { 1079 } else if ( state == KCommandSocket::successR ) {
1072 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 1080 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
1073 1081
1074 } else if ( state == KCommandSocket::successW ) { 1082 } else if ( state == KCommandSocket::successW ) {
1075 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 1083 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
1076 mPisyncFinished = true; 1084 mPisyncFinished = true;
1077 } 1085 }
1078 1086
1079 delete s; 1087 delete s;
1080} 1088}
1081 1089
1082void KSyncManager::readFileFromSocket() 1090void KSyncManager::readFileFromSocket()
1083{ 1091{
1084 QString fileName = syncFileName(); 1092 QString fileName = syncFileName();
1085 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); 1093 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
1086 if ( ! syncWithFile( fileName , true ) ) { 1094 if ( ! syncWithFile( fileName , true ) ) {
1087 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); 1095 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
1088 mPisyncFinished = true; 1096 mPisyncFinished = true;
1089 return; 1097 return;
1090 } 1098 }
1091 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 1099 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
1092 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1100 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1093 if ( mWriteBackFile ) 1101 if ( mWriteBackFile )
1094 commandSocket->writeFile( fileName ); 1102 commandSocket->writeFile( fileName );
1095 else { 1103 else {
1096 commandSocket->sendStop(); 1104 commandSocket->sendStop();
1097 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 1105 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
1098 mPisyncFinished = true; 1106 mPisyncFinished = true;
1099 } 1107 }
1100} 1108}
1101 1109
1102KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 1110KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
1103{ 1111{
1104 mPassWord = pw; 1112 mPassWord = pw;
1105 mSocket = 0; 1113 mSocket = 0;
1106 mSyncActionDialog = 0; 1114 mSyncActionDialog = 0;
1107 blockRC = false; 1115 blockRC = false;
1108}; 1116};
1109 1117
1110void KServerSocket::newConnection ( int socket ) 1118void KServerSocket::newConnection ( int socket )
1111{ 1119{
1112 // qDebug("KServerSocket:New connection %d ", socket); 1120 // qDebug("KServerSocket:New connection %d ", socket);
1113 if ( mSocket ) { 1121 if ( mSocket ) {
1114 qDebug("KServerSocket::newConnection Socket deleted! "); 1122 qDebug("KServerSocket::newConnection Socket deleted! ");
1115 delete mSocket; 1123 delete mSocket;
1116 mSocket = 0; 1124 mSocket = 0;
1117 } 1125 }
1118 mSocket = new QSocket( this ); 1126 mSocket = new QSocket( this );
1119 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 1127 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
1120 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 1128 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
1121 mSocket->setSocket( socket ); 1129 mSocket->setSocket( socket );
1122} 1130}
1123 1131
1124void KServerSocket::discardClient() 1132void KServerSocket::discardClient()
1125{ 1133{
1126 //qDebug(" KServerSocket::discardClient()"); 1134 //qDebug(" KServerSocket::discardClient()");
1127 if ( mSocket ) { 1135 if ( mSocket ) {
1128 delete mSocket; 1136 delete mSocket;
1129 mSocket = 0; 1137 mSocket = 0;
1130 } 1138 }
1131 //emit endConnect(); 1139 //emit endConnect();
1132} 1140}
1133void KServerSocket::readClient() 1141void KServerSocket::readClient()
1134{ 1142{
1135 if ( blockRC ) 1143 if ( blockRC )
1136 return; 1144 return;
1137 if ( mSocket == 0 ) { 1145 if ( mSocket == 0 ) {
1138 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); 1146 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
1139 return; 1147 return;
1140 } 1148 }
1141 //qDebug("KServerSocket::readClient()"); 1149 //qDebug("KServerSocket::readClient()");
1142 if ( mSocket->canReadLine() ) { 1150 if ( mSocket->canReadLine() ) {
1143 QString line = mSocket->readLine(); 1151 QString line = mSocket->readLine();
1144 //qDebug("KServerSocket readline: %s ", line.latin1()); 1152 //qDebug("KServerSocket readline: %s ", line.latin1());
1145 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); 1153 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
1146 if ( tokens[0] == "GET" ) { 1154 if ( tokens[0] == "GET" ) {
1147 if ( tokens[1] == mPassWord ) { 1155 if ( tokens[1] == mPassWord ) {
1148 //emit sendFile( mSocket ); 1156 //emit sendFile( mSocket );
1149 bool ok = false; 1157 bool ok = false;
1150 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); 1158 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok);
1151 if ( ok ) { 1159 if ( ok ) {
1152 KSyncManager::mRequestedSyncEvent = dt; 1160 KSyncManager::mRequestedSyncEvent = dt;
1153 } 1161 }
1154 else 1162 else
1155 KSyncManager::mRequestedSyncEvent = QDateTime(); 1163 KSyncManager::mRequestedSyncEvent = QDateTime();
1156 send_file(); 1164 send_file();
1157 } 1165 }
1158 else { 1166 else {
1159 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); 1167 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"));
1160 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 1168 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
1161 } 1169 }
1162 } 1170 }
1163 if ( tokens[0] == "PUT" ) { 1171 if ( tokens[0] == "PUT" ) {
1164 if ( tokens[1] == mPassWord ) { 1172 if ( tokens[1] == mPassWord ) {
1165 //emit getFile( mSocket ); 1173 //emit getFile( mSocket );
1166 blockRC = true; 1174 blockRC = true;
1167 get_file(); 1175 get_file();
1168 } 1176 }
1169 else { 1177 else {
1170 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); 1178 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"));
1171 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 1179 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
1172 } 1180 }
1173 } 1181 }
1174 if ( tokens[0] == "STOP" ) { 1182 if ( tokens[0] == "STOP" ) {
1175 //emit endConnect(); 1183 //emit endConnect();
1176 end_connect(); 1184 end_connect();
1177 } 1185 }
1178 } 1186 }
1179} 1187}
1180void KServerSocket::end_connect() 1188void KServerSocket::end_connect()
1181{ 1189{
1182 delete mSyncActionDialog; 1190 delete mSyncActionDialog;
1183 mSyncActionDialog = 0; 1191 mSyncActionDialog = 0;
1184} 1192}
1185void KServerSocket::send_file() 1193void KServerSocket::send_file()
1186{ 1194{
1187 //qDebug("MainWindow::sendFile(QSocket* s) "); 1195 //qDebug("MainWindow::sendFile(QSocket* s) ");
1188 if ( mSyncActionDialog ) 1196 if ( mSyncActionDialog )
1189 delete mSyncActionDialog; 1197 delete mSyncActionDialog;
1190 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 1198 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
1191 mSyncActionDialog->setCaption(i18n("Received sync request")); 1199 mSyncActionDialog->setCaption(i18n("Received sync request"));
1192 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); 1200 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
1193 label->setAlignment ( Qt::AlignHCenter ); 1201 label->setAlignment ( Qt::AlignHCenter );
1194 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 1202 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
1195 lay->addWidget( label); 1203 lay->addWidget( label);
1196 lay->setMargin(7); 1204 lay->setMargin(7);
1197 lay->setSpacing(7); 1205 lay->setSpacing(7);
1198 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1206 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1199 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); 1207 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent );
1200 if ( secs < 0 ) 1208 if ( secs < 0 )
1201 secs = secs * (-1); 1209 secs = secs * (-1);
1202 if ( secs > 30 ) 1210 if ( secs > 30 )
1203 //if ( true ) 1211 //if ( true )
1204 { 1212 {
1205 QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); 1213 QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs );
1206 QLabel* label = new QLabel( warning, mSyncActionDialog ); 1214 QLabel* label = new QLabel( warning, mSyncActionDialog );
1207 label->setAlignment ( Qt::AlignHCenter ); 1215 label->setAlignment ( Qt::AlignHCenter );
1208 lay->addWidget( label); 1216 lay->addWidget( label);
1209 if ( secs > 180 ) 1217 if ( secs > 180 )
1210 { 1218 {
1211 if ( secs > 300 ) { 1219 if ( secs > 300 ) {
1212 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\n of more than 5 minutes.\nPlease adjust your clocks.\n<b>You may get wrong syncing results!<\b>\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { 1220 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\n of more than 5 minutes.\nPlease adjust your clocks.\n<b>You may get wrong syncing results!<\b>\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) {
1213 qDebug("cancelled "); 1221 qDebug("cancelled ");
1214 return ; 1222 return ;
1215 } 1223 }
1216 } 1224 }
1217 QFont f = label->font(); 1225 QFont f = label->font();
1218 f.setPointSize ( f.pointSize() *2 ); 1226 f.setPointSize ( f.pointSize() *2 );
1219 f. setBold (true ); 1227 f. setBold (true );
1220 QLabel* label = new QLabel( warning, mSyncActionDialog ); 1228 QLabel* label = new QLabel( warning, mSyncActionDialog );
1221 label->setFont( f ); 1229 label->setFont( f );
1222 warning = i18n("ADJUST\nYOUR\nCLOCKS!"); 1230 warning = i18n("ADJUST\nYOUR\nCLOCKS!");
1223 label->setText( warning ); 1231 label->setText( warning );
1224 label->setAlignment ( Qt::AlignHCenter ); 1232 label->setAlignment ( Qt::AlignHCenter );
1225 lay->addWidget( label); 1233 lay->addWidget( label);
1226 mSyncActionDialog->setFixedSize( 230, 300); 1234 mSyncActionDialog->setFixedSize( 230, 300);
1227 } else { 1235 } else {
1228 mSyncActionDialog->setFixedSize( 230, 200); 1236 mSyncActionDialog->setFixedSize( 230, 200);
1229 } 1237 }
1230 } else { 1238 } else {
1231 mSyncActionDialog->setFixedSize( 230, 120); 1239 mSyncActionDialog->setFixedSize( 230, 120);
1232 } 1240 }
1233 } else 1241 } else
1234 mSyncActionDialog->setFixedSize( 230, 120); 1242 mSyncActionDialog->setFixedSize( 230, 120);
1235 mSyncActionDialog->show(); 1243 mSyncActionDialog->show();
1236 mSyncActionDialog->raise(); 1244 mSyncActionDialog->raise();
1237 emit request_file(); 1245 emit request_file();
1238 qApp->processEvents(); 1246 qApp->processEvents();
1239 QString fileName = mFileName; 1247 QString fileName = mFileName;
1240 QFile file( fileName ); 1248 QFile file( fileName );
1241 if (!file.open( IO_ReadOnly ) ) { 1249 if (!file.open( IO_ReadOnly ) ) {
1242 delete mSyncActionDialog; 1250 delete mSyncActionDialog;
1243 mSyncActionDialog = 0; 1251 mSyncActionDialog = 0;
1244 qDebug("KSS::error open sync file: %s ", fileName.latin1()); 1252 qDebug("KSS::error open sync file: %s ", fileName.latin1());
1245 mSocket->close(); 1253 mSocket->close();
1246 if ( mSocket->state() == QSocket::Idle ) 1254 if ( mSocket->state() == QSocket::Idle )
1247 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1255 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1248 return ; 1256 return ;
1249 1257
1250 } 1258 }
1251 mSyncActionDialog->setCaption( i18n("Sending file...") ); 1259 mSyncActionDialog->setCaption( i18n("Sending file...") );
1252 QTextStream ts( &file ); 1260 QTextStream ts( &file );
1253 ts.setEncoding( QTextStream::Latin1 ); 1261 ts.setEncoding( QTextStream::Latin1 );
1254 1262
1255 QTextStream os( mSocket ); 1263 QTextStream os( mSocket );
1256 os.setEncoding( QTextStream::Latin1 ); 1264 os.setEncoding( QTextStream::Latin1 );
1257 while ( ! ts.atEnd() ) { 1265 while ( ! ts.atEnd() ) {
1258 os << ts.readLine() << "\r\n"; 1266 os << ts.readLine() << "\r\n";
1259 } 1267 }
1260 //os << ts.read(); 1268 //os << ts.read();
1261 file.close(); 1269 file.close();
1262 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); 1270 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
1263 mSocket->close(); 1271 mSocket->close();
1264 if ( mSocket->state() == QSocket::Idle ) 1272 if ( mSocket->state() == QSocket::Idle )
1265 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1273 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1266} 1274}
1267void KServerSocket::get_file() 1275void KServerSocket::get_file()
1268{ 1276{
1269 mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); 1277 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
1270 1278
1271 piTime.start(); 1279 piTime.start();
1272 piFileString = ""; 1280 piFileString = "";
1273 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); 1281 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
1274} 1282}
1275 1283
1276 1284
1277void KServerSocket::readBackFileFromSocket() 1285void KServerSocket::readBackFileFromSocket()
1278{ 1286{
1279 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); 1287 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
1280 while ( mSocket->canReadLine () ) { 1288 while ( mSocket->canReadLine () ) {
1281 piTime.restart(); 1289 piTime.restart();
1282 QString line = mSocket->readLine (); 1290 QString line = mSocket->readLine ();
1283 piFileString += line; 1291 piFileString += line;
1284 //qDebug("readline: %s ", line.latin1()); 1292 //qDebug("readline: %s ", line.latin1());
1285 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); 1293 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
1286 1294
1287 } 1295 }
1288 if ( piTime.elapsed () < 3000 ) { 1296 if ( piTime.elapsed () < 3000 ) {
1289 // wait for more 1297 // wait for more
1290 //qDebug("waitformore "); 1298 //qDebug("waitformore ");
1291 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); 1299 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
1292 return; 1300 return;
1293 } 1301 }
1294 QString fileName = mFileName; 1302 QString fileName = mFileName;
1295 QFile file ( fileName ); 1303 QFile file ( fileName );
1296 if (!file.open( IO_WriteOnly ) ) { 1304 if (!file.open( IO_WriteOnly ) ) {
1297 delete mSyncActionDialog; 1305 delete mSyncActionDialog;
1298 mSyncActionDialog = 0; 1306 mSyncActionDialog = 0;
1299 qDebug("KSS:Error open read back file "); 1307 qDebug("KSS:Error open read back file ");
1300 piFileString = ""; 1308 piFileString = "";
1301 emit file_received( false ); 1309 emit file_received( false );
1302 blockRC = false; 1310 blockRC = false;
1303 return ; 1311 return ;
1304 1312
1305 } 1313 }
1306 1314
1307 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1315 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1308 QTextStream ts ( &file ); 1316 QTextStream ts ( &file );
1309 ts.setEncoding( QTextStream::Latin1 ); 1317 ts.setEncoding( QTextStream::Latin1 );
1310 mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); 1318 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
1311 ts << piFileString; 1319 ts << piFileString;
1312 mSocket->close(); 1320 mSocket->close();
1313 if ( mSocket->state() == QSocket::Idle ) 1321 if ( mSocket->state() == QSocket::Idle )
1314 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1322 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1315 file.close(); 1323 file.close();
1316 piFileString = ""; 1324 piFileString = "";
1317 emit file_received( true ); 1325 emit file_received( true );
1318 delete mSyncActionDialog; 1326 delete mSyncActionDialog;
1319 mSyncActionDialog = 0; 1327 mSyncActionDialog = 0;
1320 blockRC = false; 1328 blockRC = false;
1321 1329
1322} 1330}
1323 1331
1324KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) 1332KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name )
1325{ 1333{
1326 mPassWord = password; 1334 mPassWord = password;
1327 mSocket = 0; 1335 mSocket = 0;
1328 mPort = port; 1336 mPort = port;
1329 mHost = host; 1337 mHost = host;
1330 1338
1331 mRetVal = quiet; 1339 mRetVal = quiet;
1332 mTimerSocket = new QTimer ( this ); 1340 mTimerSocket = new QTimer ( this );
1333 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); 1341 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) );
1334} 1342}
1335void KCommandSocket::readFile( QString fn ) 1343void KCommandSocket::readFile( QString fn )
1336{ 1344{
1337 if ( !mSocket ) { 1345 if ( !mSocket ) {
1338 mSocket = new QSocket( this ); 1346 mSocket = new QSocket( this );
1339 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); 1347 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
1340 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1348 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1341 } 1349 }
1342 mFileString = ""; 1350 mFileString = "";
1343 mFileName = fn; 1351 mFileName = fn;
1344 mFirst = true; 1352 mFirst = true;
1345 mSocket->connectToHost( mHost, mPort ); 1353 mSocket->connectToHost( mHost, mPort );
1346 QTextStream os( mSocket ); 1354 QTextStream os( mSocket );
1347 os.setEncoding( QTextStream::Latin1 ); 1355 os.setEncoding( QTextStream::Latin1 );
1348 1356
1349 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); 1357 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate );
1350 os << "GET " << mPassWord << curDt <<"\r\n"; 1358 os << "GET " << mPassWord << curDt <<"\r\n";
1351 mTimerSocket->start( 300000 ); 1359 mTimerSocket->start( 300000 );
1352} 1360}
1353 1361
1354void KCommandSocket::writeFile( QString fileName ) 1362void KCommandSocket::writeFile( QString fileName )
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 2d0a4ab..6d89950 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -1,217 +1,221 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19 19
20 $Id$ 20 $Id$
21*/ 21*/
22#ifndef _KSYNCMANAGER_H 22#ifndef _KSYNCMANAGER_H
23#define _KSYNCMANAGER_H 23#define _KSYNCMANAGER_H
24 24
25#include <qobject.h> 25#include <qobject.h>
26#include <qstring.h> 26#include <qstring.h>
27#include <qsocket.h> 27#include <qsocket.h>
28#include <qdatetime.h> 28#include <qdatetime.h>
29#include <qserversocket.h> 29#include <qserversocket.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31#include <qregexp.h> 31#include <qregexp.h>
32 32
33class QPopupMenu; 33class QPopupMenu;
34class KSyncProfile; 34class KSyncProfile;
35class KPimPrefs; 35class KPimPrefs;
36class QWidget; 36class QWidget;
37class KSyncManager; 37class KSyncManager;
38class KSyncInterface; 38class KSyncInterface;
39class QProgressBar; 39class QProgressBar;
40 40
41 41
42class KServerSocket : public QServerSocket 42class KServerSocket : public QServerSocket
43{ 43{
44 Q_OBJECT 44 Q_OBJECT
45 45
46 public: 46 public:
47 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); 47 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 );
48 48
49 void newConnection ( int socket ) ; 49 void newConnection ( int socket ) ;
50 void setFileName( QString fn ) {mFileName = fn;}; 50 void setFileName( QString fn ) {mFileName = fn;};
51 signals: 51 signals:
52 void file_received( bool ); 52 void file_received( bool );
53 void request_file(); 53 void request_file();
54 void saveFile(); 54 void saveFile();
55 void endConnect(); 55 void endConnect();
56 private slots: 56 private slots:
57 void discardClient(); 57 void discardClient();
58 void readClient(); 58 void readClient();
59 void readBackFileFromSocket(); 59 void readBackFileFromSocket();
60 private : 60 private :
61 bool blockRC; 61 bool blockRC;
62 void send_file(); 62 void send_file();
63 void get_file(); 63 void get_file();
64 void end_connect(); 64 void end_connect();
65 QDialog* mSyncActionDialog; 65 QDialog* mSyncActionDialog;
66 QSocket* mSocket; 66 QSocket* mSocket;
67 QString mPassWord; 67 QString mPassWord;
68 QString mFileName; 68 QString mFileName;
69 QTime piTime; 69 QTime piTime;
70 QString piFileString; 70 QString piFileString;
71}; 71};
72 72
73class KCommandSocket : public QObject 73class KCommandSocket : public QObject
74{ 74{
75 Q_OBJECT 75 Q_OBJECT
76 public: 76 public:
77 enum state { successR, errorR, successW, errorW, errorTO, quiet }; 77 enum state { successR, errorR, successW, errorW, errorTO, quiet };
78 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); 78 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 );
79 void readFile( QString ); 79 void readFile( QString );
80 void writeFile( QString ); 80 void writeFile( QString );
81 void sendStop(); 81 void sendStop();
82 82
83 signals: 83 signals:
84 void commandFinished( KCommandSocket*, int ); 84 void commandFinished( KCommandSocket*, int );
85 private slots: 85 private slots:
86 void startReadFileFromSocket(); 86 void startReadFileFromSocket();
87 void readFileFromSocket(); 87 void readFileFromSocket();
88 void deleteSocket(); 88 void deleteSocket();
89 void writeFileToSocket(); 89 void writeFileToSocket();
90 private : 90 private :
91 QSocket* mSocket; 91 QSocket* mSocket;
92 QString mPassWord; 92 QString mPassWord;
93 Q_UINT16 mPort; 93 Q_UINT16 mPort;
94 QString mHost; 94 QString mHost;
95 QString mFileName; 95 QString mFileName;
96 QTimer* mTimerSocket; 96 QTimer* mTimerSocket;
97 int mRetVal; 97 int mRetVal;
98 QTime mTime; 98 QTime mTime;
99 QString mFileString; 99 QString mFileString;
100 bool mFirst; 100 bool mFirst;
101}; 101};
102 102
103 103
104class KSyncManager : public QObject 104class KSyncManager : public QObject
105{ 105{
106 Q_OBJECT 106 Q_OBJECT
107 107
108 public: 108 public:
109 enum TargetApp { 109 enum TargetApp {
110 KOPI = 0, 110 KOPI = 0,
111 KAPI = 1, 111 KAPI = 1,
112 PWMPI = 2 }; 112 PWMPI = 2 };
113 113
114 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); 114 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu);
115 ~KSyncManager() ; 115 ~KSyncManager() ;
116 116
117 void multiSync( bool askforPrefs ); 117 void multiSync( bool askforPrefs );
118 bool blockSave() { return mBlockSaveFlag; } 118 bool blockSave() { return mBlockSaveFlag; }
119 void setBlockSave(bool sa) { mBlockSaveFlag = sa; } 119 void setBlockSave(bool sa) { mBlockSaveFlag = sa; }
120 void setDefaultFileName( QString s) { mDefFileName = s ;} 120 void setDefaultFileName( QString s) { mDefFileName = s ;}
121 QString defaultFileName() { return mDefFileName ;} 121 QString defaultFileName() { return mDefFileName ;}
122 QString syncFileName(); 122 QString syncFileName();
123 void enableQuick( bool ask = true); 123 void enableQuick( bool ask = true);
124 124
125 bool syncWithDesktop () { return mSyncWithDesktop;} 125 bool syncWithDesktop () { return mSyncWithDesktop;}
126 QString getCurrentSyncDevice() { return mCurrentSyncDevice; } 126 QString getCurrentSyncDevice() { return mCurrentSyncDevice; }
127 QString getCurrentSyncName() { return mCurrentSyncName; } 127 QString getCurrentSyncName() { return mCurrentSyncName; }
128 128
129 void showProgressBar(int percentage, QString caption = QString::null, int total=100); 129 void showProgressBar(int percentage, QString caption = QString::null, int total=100);
130 void hideProgressBar(); 130 void hideProgressBar();
131 bool isProgressBarCanceled(); 131 bool isProgressBarCanceled();
132 132
133 // sync stuff 133 // sync stuff
134 QString mLocalMachineName; 134 QString mLocalMachineName;
135 QStringList mExternSyncProfiles; 135 QStringList mExternSyncProfiles;
136 QStringList mSyncProfileNames; 136 QStringList mSyncProfileNames;
137 bool mAskForPreferences; 137 bool mAskForPreferences;
138 bool mShowSyncSummary; 138 bool mShowSyncSummary;
139 bool mIsKapiFile; 139 bool mIsKapiFile;
140 bool mWriteBackExistingOnly; 140 bool mWriteBackExistingOnly;
141 int mSyncAlgoPrefs; 141 int mSyncAlgoPrefs;
142 bool mWriteBackFile; 142 bool mWriteBackFile;
143 int mWriteBackInFuture; 143 int mWriteBackInFuture;
144 int mWriteBackInPast; 144 int mWriteBackInPast;
145 QString mPhoneDevice; 145 QString mPhoneDevice;
146 QString mPhoneConnection; 146 QString mPhoneConnection;
147 QString mPhoneModel; 147 QString mPhoneModel;
148 QString mPassWordPiSync; 148 QString mPassWordPiSync;
149 QString mActiveSyncPort; 149 QString mActiveSyncPort;
150 QString mActiveSyncIP ; 150 QString mActiveSyncIP ;
151 QString mFilterInCal;
152 QString mFilterOutCal;
153 QString mFilterInAB;
154 QString mFilterOutAB;
151 static QDateTime mRequestedSyncEvent; 155 static QDateTime mRequestedSyncEvent;
152 156
153 signals: 157 signals:
154 void save(); 158 void save();
155 void request_file(); 159 void request_file();
156 void getFile( bool ); 160 void getFile( bool );
157 161
158 public slots: 162 public slots:
159 void slotSyncMenu( int ); 163 void slotSyncMenu( int );
160 void slotClearMenu( int action ); 164 void slotClearMenu( int action );
161 void deleteCommandSocket(KCommandSocket*s, int state); 165 void deleteCommandSocket(KCommandSocket*s, int state);
162 void readFileFromSocket(); 166 void readFileFromSocket();
163 void fillSyncMenu(); 167 void fillSyncMenu();
164 168
165 private: 169 private:
166 void syncPi(); 170 void syncPi();
167 KServerSocket * mServerSocket; 171 KServerSocket * mServerSocket;
168 KPimPrefs* mPrefs; 172 KPimPrefs* mPrefs;
169 QString mDefFileName; 173 QString mDefFileName;
170 QString mCurrentSyncDevice; 174 QString mCurrentSyncDevice;
171 QString mCurrentSyncName; 175 QString mCurrentSyncName;
172 void quickSyncLocalFile(); 176 void quickSyncLocalFile();
173 bool syncWithFile( QString fn , bool quick ); 177 bool syncWithFile( QString fn , bool quick );
174 void syncLocalFile(); 178 void syncLocalFile();
175 void syncPhone(); 179 void syncPhone();
176 void syncSharp(); 180 void syncSharp();
177 void syncKDE(); 181 void syncKDE();
178 bool syncExternalApplication(QString); 182 bool syncExternalApplication(QString);
179 int mCurrentSyncProfile ; 183 int mCurrentSyncProfile ;
180 void syncRemote( KSyncProfile* prof, bool ask = true); 184 void syncRemote( KSyncProfile* prof, bool ask = true);
181 bool edit_sync_options(); 185 bool edit_sync_options();
182 bool edit_pisync_options(); 186 bool edit_pisync_options();
183 int ringSync(); 187 int ringSync();
184 QString getPassword( ); 188 QString getPassword( );
185 bool mPisyncFinished; 189 bool mPisyncFinished;
186 bool mBlockSaveFlag; 190 bool mBlockSaveFlag;
187 QWidget* mParent; 191 QWidget* mParent;
188 KSyncInterface* mImplementation; 192 KSyncInterface* mImplementation;
189 TargetApp mTargetApp; 193 TargetApp mTargetApp;
190 QPopupMenu* mSyncMenu; 194 QPopupMenu* mSyncMenu;
191 QProgressBar* bar; 195 QProgressBar* bar;
192 bool mSyncWithDesktop; 196 bool mSyncWithDesktop;
193 197
194private slots: 198private slots:
195 void confSync(); 199 void confSync();
196 200
197 201
198}; 202};
199 203
200 204
201class KSyncInterface 205class KSyncInterface
202{ 206{
203 public : 207 public :
204 virtual void removeSyncInfo( QString syncProfile) = 0; 208 virtual void removeSyncInfo( QString syncProfile) = 0;
205 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; 209 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0;
206 virtual bool syncExternal(KSyncManager* manager, QString resource) 210 virtual bool syncExternal(KSyncManager* manager, QString resource)
207 { 211 {
208 // empty implementation, because some syncable applications do not 212 // empty implementation, because some syncable applications do not
209 // have an external(sharpdtm) syncmode, like pwmanager. 213 // have an external(sharpdtm) syncmode, like pwmanager.
210 return false; 214 return false;
211 } 215 }
212 216
213 217
214}; 218};
215 219
216 220
217#endif 221#endif