-rw-r--r-- | korganizer/calendarview.cpp | 1 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 4 |
2 files changed, 4 insertions, 1 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index b56f1f9..04051a2 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -3473,261 +3473,262 @@ void CalendarView::showIntro() | |||
3473 | { | 3473 | { |
3474 | kdDebug() << "To be implemented." << endl; | 3474 | kdDebug() << "To be implemented." << endl; |
3475 | } | 3475 | } |
3476 | 3476 | ||
3477 | QWidgetStack *CalendarView::viewStack() | 3477 | QWidgetStack *CalendarView::viewStack() |
3478 | { | 3478 | { |
3479 | return mRightFrame; | 3479 | return mRightFrame; |
3480 | } | 3480 | } |
3481 | 3481 | ||
3482 | QWidget *CalendarView::leftFrame() | 3482 | QWidget *CalendarView::leftFrame() |
3483 | { | 3483 | { |
3484 | return mLeftFrame; | 3484 | return mLeftFrame; |
3485 | } | 3485 | } |
3486 | 3486 | ||
3487 | DateNavigator *CalendarView::dateNavigator() | 3487 | DateNavigator *CalendarView::dateNavigator() |
3488 | { | 3488 | { |
3489 | return mNavigator; | 3489 | return mNavigator; |
3490 | } | 3490 | } |
3491 | 3491 | ||
3492 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3492 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3493 | { | 3493 | { |
3494 | return mDateNavigator; | 3494 | return mDateNavigator; |
3495 | } | 3495 | } |
3496 | void CalendarView::toggleDateNavigatorWidget() | 3496 | void CalendarView::toggleDateNavigatorWidget() |
3497 | { | 3497 | { |
3498 | if (mDateNavigator->isVisible()) | 3498 | if (mDateNavigator->isVisible()) |
3499 | mDateNavigator->hide(); | 3499 | mDateNavigator->hide(); |
3500 | else | 3500 | else |
3501 | mDateNavigator->show(); | 3501 | mDateNavigator->show(); |
3502 | } | 3502 | } |
3503 | void CalendarView::addView(KOrg::BaseView *view) | 3503 | void CalendarView::addView(KOrg::BaseView *view) |
3504 | { | 3504 | { |
3505 | mViewManager->addView(view); | 3505 | mViewManager->addView(view); |
3506 | } | 3506 | } |
3507 | 3507 | ||
3508 | void CalendarView::showView(KOrg::BaseView *view) | 3508 | void CalendarView::showView(KOrg::BaseView *view) |
3509 | { | 3509 | { |
3510 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3510 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3511 | } | 3511 | } |
3512 | 3512 | ||
3513 | Incidence *CalendarView::currentSelection() | 3513 | Incidence *CalendarView::currentSelection() |
3514 | { | 3514 | { |
3515 | return mViewManager->currentSelection(); | 3515 | return mViewManager->currentSelection(); |
3516 | } | 3516 | } |
3517 | void CalendarView::toggleAllDaySize() | 3517 | void CalendarView::toggleAllDaySize() |
3518 | { | 3518 | { |
3519 | /* | 3519 | /* |
3520 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3520 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3521 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3521 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3522 | else | 3522 | else |
3523 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3523 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3524 | */ | 3524 | */ |
3525 | viewManager()->agendaView()->toggleAllDay(); | 3525 | viewManager()->agendaView()->toggleAllDay(); |
3526 | } | 3526 | } |
3527 | void CalendarView::toggleExpand() | 3527 | void CalendarView::toggleExpand() |
3528 | { | 3528 | { |
3529 | // if ( mLeftFrame->isHidden() ) { | 3529 | // if ( mLeftFrame->isHidden() ) { |
3530 | // mLeftFrame->show(); | 3530 | // mLeftFrame->show(); |
3531 | // emit calendarViewExpanded( false ); | 3531 | // emit calendarViewExpanded( false ); |
3532 | // } else { | 3532 | // } else { |
3533 | // mLeftFrame->hide(); | 3533 | // mLeftFrame->hide(); |
3534 | // emit calendarViewExpanded( true ); | 3534 | // emit calendarViewExpanded( true ); |
3535 | // } | 3535 | // } |
3536 | 3536 | ||
3537 | globalFlagBlockAgenda = 1; | 3537 | globalFlagBlockAgenda = 1; |
3538 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3538 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3539 | globalFlagBlockAgenda = 5; | 3539 | globalFlagBlockAgenda = 5; |
3540 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3540 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3541 | //mViewManager->showView( 0, true ); | 3541 | //mViewManager->showView( 0, true ); |
3542 | } | 3542 | } |
3543 | 3543 | ||
3544 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3544 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3545 | { | 3545 | { |
3546 | setModified( modified ); | 3546 | setModified( modified ); |
3547 | } | 3547 | } |
3548 | 3548 | ||
3549 | Todo *CalendarView::selectedTodo() | 3549 | Todo *CalendarView::selectedTodo() |
3550 | { | 3550 | { |
3551 | Incidence *incidence = currentSelection(); | 3551 | Incidence *incidence = currentSelection(); |
3552 | if ( incidence && incidence->type() == "Todo" ) { | 3552 | if ( incidence && incidence->type() == "Todo" ) { |
3553 | return static_cast<Todo *>( incidence ); | 3553 | return static_cast<Todo *>( incidence ); |
3554 | } | 3554 | } |
3555 | 3555 | ||
3556 | incidence = mTodoList->selectedIncidences().first(); | 3556 | incidence = mTodoList->selectedIncidences().first(); |
3557 | if ( incidence && incidence->type() == "Todo" ) { | 3557 | if ( incidence && incidence->type() == "Todo" ) { |
3558 | return static_cast<Todo *>( incidence ); | 3558 | return static_cast<Todo *>( incidence ); |
3559 | } | 3559 | } |
3560 | 3560 | ||
3561 | return 0; | 3561 | return 0; |
3562 | } | 3562 | } |
3563 | 3563 | ||
3564 | void CalendarView::dialogClosing(Incidence *in) | 3564 | void CalendarView::dialogClosing(Incidence *in) |
3565 | { | 3565 | { |
3566 | // mDialogList.remove(in); | 3566 | // mDialogList.remove(in); |
3567 | } | 3567 | } |
3568 | 3568 | ||
3569 | void CalendarView::showIncidence() | 3569 | void CalendarView::showIncidence() |
3570 | { | 3570 | { |
3571 | Incidence *incidence = currentSelection(); | 3571 | Incidence *incidence = currentSelection(); |
3572 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3572 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3573 | if ( incidence ) { | 3573 | if ( incidence ) { |
3574 | ShowIncidenceVisitor v; | 3574 | ShowIncidenceVisitor v; |
3575 | v.act( incidence, this ); | 3575 | v.act( incidence, this ); |
3576 | } | 3576 | } |
3577 | } | 3577 | } |
3578 | void CalendarView::editIncidenceDescription() | 3578 | void CalendarView::editIncidenceDescription() |
3579 | { | 3579 | { |
3580 | mFlagEditDescription = true; | 3580 | mFlagEditDescription = true; |
3581 | editIncidence(); | 3581 | editIncidence(); |
3582 | mFlagEditDescription = false; | 3582 | mFlagEditDescription = false; |
3583 | } | 3583 | } |
3584 | void CalendarView::editIncidence() | 3584 | void CalendarView::editIncidence() |
3585 | { | 3585 | { |
3586 | // qDebug("editIncidence() "); | 3586 | // qDebug("editIncidence() "); |
3587 | Incidence *incidence = currentSelection(); | 3587 | Incidence *incidence = currentSelection(); |
3588 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3588 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3589 | if ( incidence ) { | 3589 | if ( incidence ) { |
3590 | EditIncidenceVisitor v; | 3590 | EditIncidenceVisitor v; |
3591 | v.act( incidence, this ); | 3591 | v.act( incidence, this ); |
3592 | } | 3592 | } |
3593 | } | 3593 | } |
3594 | 3594 | ||
3595 | void CalendarView::deleteIncidence() | 3595 | void CalendarView::deleteIncidence() |
3596 | { | 3596 | { |
3597 | Incidence *incidence = currentSelection(); | 3597 | Incidence *incidence = currentSelection(); |
3598 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3598 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3599 | if ( incidence ) { | 3599 | if ( incidence ) { |
3600 | deleteIncidence(incidence); | 3600 | deleteIncidence(incidence); |
3601 | } | 3601 | } |
3602 | } | 3602 | } |
3603 | 3603 | ||
3604 | void CalendarView::showIncidence(Incidence *incidence) | 3604 | void CalendarView::showIncidence(Incidence *incidence) |
3605 | { | 3605 | { |
3606 | if ( incidence ) { | 3606 | if ( incidence ) { |
3607 | ShowIncidenceVisitor v; | 3607 | ShowIncidenceVisitor v; |
3608 | v.act( incidence, this ); | 3608 | v.act( incidence, this ); |
3609 | } | 3609 | } |
3610 | } | 3610 | } |
3611 | 3611 | ||
3612 | void CalendarView::editIncidence(Incidence *incidence) | 3612 | void CalendarView::editIncidence(Incidence *incidence) |
3613 | { | 3613 | { |
3614 | if ( incidence ) { | 3614 | if ( incidence ) { |
3615 | 3615 | ||
3616 | EditIncidenceVisitor v; | 3616 | EditIncidenceVisitor v; |
3617 | v.act( incidence, this ); | 3617 | v.act( incidence, this ); |
3618 | 3618 | ||
3619 | } | 3619 | } |
3620 | } | 3620 | } |
3621 | 3621 | ||
3622 | void CalendarView::deleteIncidence(Incidence *incidence) | 3622 | void CalendarView::deleteIncidence(Incidence *incidence) |
3623 | { | 3623 | { |
3624 | //qDebug(" CalendarView::deleteIncidence "); | 3624 | //qDebug(" CalendarView::deleteIncidence "); |
3625 | if ( incidence ) { | 3625 | if ( incidence ) { |
3626 | DeleteIncidenceVisitor v; | 3626 | DeleteIncidenceVisitor v; |
3627 | v.act( incidence, this ); | 3627 | v.act( incidence, this ); |
3628 | } | 3628 | } |
3629 | } | 3629 | } |
3630 | 3630 | ||
3631 | 3631 | ||
3632 | void CalendarView::lookForOutgoingMessages() | 3632 | void CalendarView::lookForOutgoingMessages() |
3633 | { | 3633 | { |
3634 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3634 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3635 | ogd->loadMessages(); | 3635 | ogd->loadMessages(); |
3636 | } | 3636 | } |
3637 | 3637 | ||
3638 | void CalendarView::lookForIncomingMessages() | 3638 | void CalendarView::lookForIncomingMessages() |
3639 | { | 3639 | { |
3640 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3640 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3641 | icd->retrieve(); | 3641 | icd->retrieve(); |
3642 | } | 3642 | } |
3643 | 3643 | ||
3644 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3644 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3645 | { | 3645 | { |
3646 | bool deleteTodo = true; | 3646 | bool deleteTodo = true; |
3647 | QPtrList<Incidence> subTodos; | 3647 | QPtrList<Incidence> subTodos; |
3648 | Incidence *aTodo; | 3648 | Incidence *aTodo; |
3649 | subTodos = t->relations(); | 3649 | subTodos = t->relations(); |
3650 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3650 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3651 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3651 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3652 | deleteTodo = false; | 3652 | deleteTodo = false; |
3653 | } | 3653 | } |
3654 | if ( deleteTodo ) { | 3654 | if ( deleteTodo ) { |
3655 | if ( t->isCompleted() ) { | 3655 | if ( t->isCompleted() ) { |
3656 | checkExternalId( t ); | 3656 | checkExternalId( t ); |
3657 | mCalendar->deleteTodo( t ); | 3657 | mCalendar->deleteTodo( t ); |
3658 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3658 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3659 | } | 3659 | } |
3660 | else | 3660 | else |
3661 | deleteTodo = false; | 3661 | deleteTodo = false; |
3662 | } | 3662 | } |
3663 | return deleteTodo; | 3663 | return deleteTodo; |
3664 | 3664 | ||
3665 | } | 3665 | } |
3666 | void CalendarView::purgeCompleted() | 3666 | void CalendarView::purgeCompleted() |
3667 | { | 3667 | { |
3668 | int result = KMessageBox::warningContinueCancel(this, | 3668 | int result = KMessageBox::warningContinueCancel(this, |
3669 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3669 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3670 | 3670 | ||
3671 | if (result == KMessageBox::Continue) { | 3671 | if (result == KMessageBox::Continue) { |
3672 | 3672 | ||
3673 | QPtrList<Todo> todoCal; | 3673 | QPtrList<Todo> todoCal; |
3674 | QPtrList<Todo> rootTodos; | 3674 | QPtrList<Todo> rootTodos; |
3675 | //QPtrList<Incidence> rel; | 3675 | //QPtrList<Incidence> rel; |
3676 | Todo *aTodo;//, *rTodo; | 3676 | Todo *aTodo;//, *rTodo; |
3677 | Incidence *rIncidence; | 3677 | Incidence *rIncidence; |
3678 | bool childDelete = false; | 3678 | bool childDelete = false; |
3679 | bool deletedOne = true; | 3679 | bool deletedOne = true; |
3680 | todoCal = calendar()->todos(); | 3680 | todoCal = calendar()->todos(); |
3681 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3681 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3682 | if ( !aTodo->relatedTo() ) | 3682 | if ( !aTodo->relatedTo() ) |
3683 | rootTodos.append( aTodo ); | 3683 | rootTodos.append( aTodo ); |
3684 | } | 3684 | } |
3685 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3685 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3686 | removeCompletedSubTodos( aTodo ); | 3686 | removeCompletedSubTodos( aTodo ); |
3687 | } | 3687 | } |
3688 | 3688 | ||
3689 | updateView(); | 3689 | updateView(); |
3690 | } | 3690 | } |
3691 | } | 3691 | } |
3692 | 3692 | ||
3693 | void CalendarView::slotCalendarChanged() | 3693 | void CalendarView::slotCalendarChanged() |
3694 | { | 3694 | { |
3695 | ; | 3695 | ; |
3696 | } | 3696 | } |
3697 | 3697 | ||
3698 | NavigatorBar *CalendarView::navigatorBar() | 3698 | NavigatorBar *CalendarView::navigatorBar() |
3699 | { | 3699 | { |
3700 | return mNavigatorBar; | 3700 | return mNavigatorBar; |
3701 | } | 3701 | } |
3702 | 3702 | ||
3703 | 3703 | ||
3704 | 3704 | ||
3705 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3705 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3706 | { | 3706 | { |
3707 | //qDebug(" alendarView::keyPressEvent "); | 3707 | //qDebug(" alendarView::keyPressEvent "); |
3708 | e->ignore(); | 3708 | e->ignore(); |
3709 | } | 3709 | } |
3710 | 3710 | ||
3711 | 3711 | ||
3712 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 3712 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3713 | { | 3713 | { |
3714 | // mSyncManager = manager; | 3714 | // mSyncManager = manager; |
3715 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3715 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3716 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3716 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3717 | return syncCalendar( filename, mode ); | 3717 | return syncCalendar( filename, mode ); |
3718 | } | 3718 | } |
3719 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 3719 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
3720 | { | 3720 | { |
3721 | //mSyncManager = manager; | 3721 | //mSyncManager = manager; |
3722 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3722 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3723 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3723 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3724 | if ( resource == "sharp" ) | 3724 | if ( resource == "sharp" ) |
3725 | syncExternal( 0 ); | 3725 | syncExternal( 0 ); |
3726 | if ( resource == "phone" ) | 3726 | if ( resource == "phone" ) |
3727 | syncExternal( 1 ); | 3727 | syncExternal( 1 ); |
3728 | // pending setmodified | 3728 | // pending setmodified |
3729 | return true; | ||
3729 | } | 3730 | } |
3730 | void CalendarView::setSyncManager(KSyncManager* manager) | 3731 | void CalendarView::setSyncManager(KSyncManager* manager) |
3731 | { | 3732 | { |
3732 | mSyncManager = manager; | 3733 | mSyncManager = manager; |
3733 | } | 3734 | } |
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 01309d5..b3e266a 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -904,271 +904,273 @@ void KServerSocket::readClient() | |||
904 | if ( tokens[0] == "PUT" ) { | 904 | if ( tokens[0] == "PUT" ) { |
905 | if ( tokens[1] == mPassWord ) { | 905 | if ( tokens[1] == mPassWord ) { |
906 | //emit getFile( mSocket ); | 906 | //emit getFile( mSocket ); |
907 | blockRC = true; | 907 | blockRC = true; |
908 | get_file(); | 908 | get_file(); |
909 | } | 909 | } |
910 | else { | 910 | else { |
911 | KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); | 911 | KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); |
912 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 912 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
913 | } | 913 | } |
914 | } | 914 | } |
915 | if ( tokens[0] == "STOP" ) { | 915 | if ( tokens[0] == "STOP" ) { |
916 | //emit endConnect(); | 916 | //emit endConnect(); |
917 | end_connect(); | 917 | end_connect(); |
918 | } | 918 | } |
919 | } | 919 | } |
920 | } | 920 | } |
921 | void KServerSocket::end_connect() | 921 | void KServerSocket::end_connect() |
922 | { | 922 | { |
923 | delete mSyncActionDialog; | 923 | delete mSyncActionDialog; |
924 | mSyncActionDialog = 0; | 924 | mSyncActionDialog = 0; |
925 | } | 925 | } |
926 | void KServerSocket::send_file() | 926 | void KServerSocket::send_file() |
927 | { | 927 | { |
928 | //qDebug("MainWindow::sendFile(QSocket* s) "); | 928 | //qDebug("MainWindow::sendFile(QSocket* s) "); |
929 | if ( mSyncActionDialog ) | 929 | if ( mSyncActionDialog ) |
930 | delete mSyncActionDialog; | 930 | delete mSyncActionDialog; |
931 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); | 931 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); |
932 | mSyncActionDialog->setCaption(i18n("Received sync request")); | 932 | mSyncActionDialog->setCaption(i18n("Received sync request")); |
933 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); | 933 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); |
934 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); | 934 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); |
935 | lay->addWidget( label); | 935 | lay->addWidget( label); |
936 | lay->setMargin(7); | 936 | lay->setMargin(7); |
937 | lay->setSpacing(7); | 937 | lay->setSpacing(7); |
938 | mSyncActionDialog->setFixedSize( 230, 120); | 938 | mSyncActionDialog->setFixedSize( 230, 120); |
939 | mSyncActionDialog->show(); | 939 | mSyncActionDialog->show(); |
940 | mSyncActionDialog->raise(); | 940 | mSyncActionDialog->raise(); |
941 | qDebug("KSS::saving ... "); | 941 | qDebug("KSS::saving ... "); |
942 | emit request_file(); | 942 | emit request_file(); |
943 | qApp->processEvents(); | 943 | qApp->processEvents(); |
944 | QString fileName = mFileName; | 944 | QString fileName = mFileName; |
945 | QFile file( fileName ); | 945 | QFile file( fileName ); |
946 | if (!file.open( IO_ReadOnly ) ) { | 946 | if (!file.open( IO_ReadOnly ) ) { |
947 | delete mSyncActionDialog; | 947 | delete mSyncActionDialog; |
948 | mSyncActionDialog = 0; | 948 | mSyncActionDialog = 0; |
949 | qDebug("KSS::error open file "); | 949 | qDebug("KSS::error open file "); |
950 | mSocket->close(); | 950 | mSocket->close(); |
951 | if ( mSocket->state() == QSocket::Idle ) | 951 | if ( mSocket->state() == QSocket::Idle ) |
952 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 952 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
953 | return ; | 953 | return ; |
954 | 954 | ||
955 | } | 955 | } |
956 | mSyncActionDialog->setCaption( i18n("Sending file...") ); | 956 | mSyncActionDialog->setCaption( i18n("Sending file...") ); |
957 | QTextStream ts( &file ); | 957 | QTextStream ts( &file ); |
958 | ts.setEncoding( QTextStream::Latin1 ); | 958 | ts.setEncoding( QTextStream::Latin1 ); |
959 | 959 | ||
960 | QTextStream os( mSocket ); | 960 | QTextStream os( mSocket ); |
961 | os.setEncoding( QTextStream::Latin1 ); | 961 | os.setEncoding( QTextStream::Latin1 ); |
962 | while ( ! ts.atEnd() ) { | 962 | while ( ! ts.atEnd() ) { |
963 | os << ts.readLine() << "\n"; | 963 | os << ts.readLine() << "\n"; |
964 | } | 964 | } |
965 | //os << ts.read(); | 965 | //os << ts.read(); |
966 | file.close(); | 966 | file.close(); |
967 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); | 967 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); |
968 | mSocket->close(); | 968 | mSocket->close(); |
969 | if ( mSocket->state() == QSocket::Idle ) | 969 | if ( mSocket->state() == QSocket::Idle ) |
970 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 970 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
971 | } | 971 | } |
972 | void KServerSocket::get_file() | 972 | void KServerSocket::get_file() |
973 | { | 973 | { |
974 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); | 974 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); |
975 | 975 | ||
976 | piTime.start(); | 976 | piTime.start(); |
977 | piFileString = ""; | 977 | piFileString = ""; |
978 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); | 978 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); |
979 | } | 979 | } |
980 | 980 | ||
981 | 981 | ||
982 | void KServerSocket::readBackFileFromSocket() | 982 | void KServerSocket::readBackFileFromSocket() |
983 | { | 983 | { |
984 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); | 984 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); |
985 | while ( mSocket->canReadLine () ) { | 985 | while ( mSocket->canReadLine () ) { |
986 | piTime.restart(); | 986 | piTime.restart(); |
987 | QString line = mSocket->readLine (); | 987 | QString line = mSocket->readLine (); |
988 | piFileString += line; | 988 | piFileString += line; |
989 | //qDebug("readline: %s ", line.latin1()); | 989 | //qDebug("readline: %s ", line.latin1()); |
990 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); | 990 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); |
991 | 991 | ||
992 | } | 992 | } |
993 | if ( piTime.elapsed () < 3000 ) { | 993 | if ( piTime.elapsed () < 3000 ) { |
994 | // wait for more | 994 | // wait for more |
995 | //qDebug("waitformore "); | 995 | //qDebug("waitformore "); |
996 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); | 996 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); |
997 | return; | 997 | return; |
998 | } | 998 | } |
999 | QString fileName = mFileName; | 999 | QString fileName = mFileName; |
1000 | QFile file ( fileName ); | 1000 | QFile file ( fileName ); |
1001 | if (!file.open( IO_WriteOnly ) ) { | 1001 | if (!file.open( IO_WriteOnly ) ) { |
1002 | delete mSyncActionDialog; | 1002 | delete mSyncActionDialog; |
1003 | mSyncActionDialog = 0; | 1003 | mSyncActionDialog = 0; |
1004 | qDebug("error open cal file "); | 1004 | qDebug("error open cal file "); |
1005 | piFileString = ""; | 1005 | piFileString = ""; |
1006 | emit file_received( false ); | 1006 | emit file_received( false ); |
1007 | blockRC = false; | 1007 | blockRC = false; |
1008 | return ; | 1008 | return ; |
1009 | 1009 | ||
1010 | } | 1010 | } |
1011 | 1011 | ||
1012 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1012 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1013 | QTextStream ts ( &file ); | 1013 | QTextStream ts ( &file ); |
1014 | ts.setEncoding( QTextStream::Latin1 ); | 1014 | ts.setEncoding( QTextStream::Latin1 ); |
1015 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); | 1015 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); |
1016 | ts << piFileString; | 1016 | ts << piFileString; |
1017 | mSocket->close(); | 1017 | mSocket->close(); |
1018 | if ( mSocket->state() == QSocket::Idle ) | 1018 | if ( mSocket->state() == QSocket::Idle ) |
1019 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1019 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1020 | file.close(); | 1020 | file.close(); |
1021 | delete mSyncActionDialog; | 1021 | delete mSyncActionDialog; |
1022 | mSyncActionDialog = 0; | 1022 | mSyncActionDialog = 0; |
1023 | piFileString = ""; | 1023 | piFileString = ""; |
1024 | blockRC = false; | 1024 | blockRC = false; |
1025 | emit file_received( true ); | 1025 | emit file_received( true ); |
1026 | 1026 | ||
1027 | } | 1027 | } |
1028 | 1028 | ||
1029 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) | 1029 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) |
1030 | { | 1030 | { |
1031 | mPassWord = password; | 1031 | mPassWord = password; |
1032 | mSocket = 0; | 1032 | mSocket = 0; |
1033 | mPort = port; | 1033 | mPort = port; |
1034 | mHost = host; | 1034 | mHost = host; |
1035 | 1035 | ||
1036 | mRetVal = quiet; | 1036 | mRetVal = quiet; |
1037 | mTimerSocket = new QTimer ( this ); | 1037 | mTimerSocket = new QTimer ( this ); |
1038 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); | 1038 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); |
1039 | } | 1039 | } |
1040 | void KCommandSocket::readFile( QString fn ) | 1040 | void KCommandSocket::readFile( QString fn ) |
1041 | { | 1041 | { |
1042 | if ( !mSocket ) { | 1042 | if ( !mSocket ) { |
1043 | mSocket = new QSocket( this ); | 1043 | mSocket = new QSocket( this ); |
1044 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); | 1044 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); |
1045 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1045 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1046 | } | 1046 | } |
1047 | mFileString = ""; | 1047 | mFileString = ""; |
1048 | mFileName = fn; | 1048 | mFileName = fn; |
1049 | mFirst = true; | 1049 | mFirst = true; |
1050 | mSocket->connectToHost( mHost, mPort ); | 1050 | mSocket->connectToHost( mHost, mPort ); |
1051 | QTextStream os( mSocket ); | 1051 | QTextStream os( mSocket ); |
1052 | os.setEncoding( QTextStream::Latin1 ); | 1052 | os.setEncoding( QTextStream::Latin1 ); |
1053 | os << "GET " << mPassWord << "\r\n"; | 1053 | os << "GET " << mPassWord << "\r\n"; |
1054 | mTimerSocket->start( 10000 ); | 1054 | mTimerSocket->start( 10000 ); |
1055 | } | 1055 | } |
1056 | 1056 | ||
1057 | void KCommandSocket::writeFile( QString fileName ) | 1057 | void KCommandSocket::writeFile( QString fileName ) |
1058 | { | 1058 | { |
1059 | if ( !mSocket ) { | 1059 | if ( !mSocket ) { |
1060 | mSocket = new QSocket( this ); | 1060 | mSocket = new QSocket( this ); |
1061 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1061 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1062 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); | 1062 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); |
1063 | } | 1063 | } |
1064 | mFileName = fileName ; | 1064 | mFileName = fileName ; |
1065 | mSocket->connectToHost( mHost, mPort ); | 1065 | mSocket->connectToHost( mHost, mPort ); |
1066 | } | 1066 | } |
1067 | void KCommandSocket::writeFileToSocket() | 1067 | void KCommandSocket::writeFileToSocket() |
1068 | { | 1068 | { |
1069 | QFile file2( mFileName ); | 1069 | QFile file2( mFileName ); |
1070 | if (!file2.open( IO_ReadOnly ) ) { | 1070 | if (!file2.open( IO_ReadOnly ) ) { |
1071 | mRetVal= errorW; | 1071 | mRetVal= errorW; |
1072 | mSocket->close(); | 1072 | mSocket->close(); |
1073 | if ( mSocket->state() == QSocket::Idle ) | 1073 | if ( mSocket->state() == QSocket::Idle ) |
1074 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1074 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1075 | return ; | 1075 | return ; |
1076 | } | 1076 | } |
1077 | QTextStream ts2( &file2 ); | 1077 | QTextStream ts2( &file2 ); |
1078 | ts2.setEncoding( QTextStream::Latin1 ); | 1078 | ts2.setEncoding( QTextStream::Latin1 ); |
1079 | QTextStream os2( mSocket ); | 1079 | QTextStream os2( mSocket ); |
1080 | os2.setEncoding( QTextStream::Latin1 ); | 1080 | os2.setEncoding( QTextStream::Latin1 ); |
1081 | os2 << "PUT " << mPassWord << "\r\n";; | 1081 | os2 << "PUT " << mPassWord << "\r\n";; |
1082 | while ( ! ts2.atEnd() ) { | 1082 | while ( ! ts2.atEnd() ) { |
1083 | os2 << ts2.readLine() << "\n"; | 1083 | os2 << ts2.readLine() << "\n"; |
1084 | } | 1084 | } |
1085 | mRetVal= successW; | 1085 | mRetVal= successW; |
1086 | file2.close(); | 1086 | file2.close(); |
1087 | mSocket->close(); | 1087 | mSocket->close(); |
1088 | if ( mSocket->state() == QSocket::Idle ) | 1088 | if ( mSocket->state() == QSocket::Idle ) |
1089 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1089 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1090 | } | 1090 | } |
1091 | void KCommandSocket::sendStop() | 1091 | void KCommandSocket::sendStop() |
1092 | { | 1092 | { |
1093 | if ( !mSocket ) { | 1093 | if ( !mSocket ) { |
1094 | mSocket = new QSocket( this ); | 1094 | mSocket = new QSocket( this ); |
1095 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1095 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1096 | } | 1096 | } |
1097 | mSocket->connectToHost( mHost, mPort ); | 1097 | mSocket->connectToHost( mHost, mPort ); |
1098 | QTextStream os2( mSocket ); | 1098 | QTextStream os2( mSocket ); |
1099 | os2.setEncoding( QTextStream::Latin1 ); | 1099 | os2.setEncoding( QTextStream::Latin1 ); |
1100 | os2 << "STOP\r\n"; | 1100 | os2 << "STOP\r\n"; |
1101 | mSocket->close(); | 1101 | mSocket->close(); |
1102 | if ( mSocket->state() == QSocket::Idle ) | 1102 | if ( mSocket->state() == QSocket::Idle ) |
1103 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1103 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1104 | } | 1104 | } |
1105 | 1105 | ||
1106 | void KCommandSocket::startReadFileFromSocket() | 1106 | void KCommandSocket::startReadFileFromSocket() |
1107 | { | 1107 | { |
1108 | if ( ! mFirst ) | 1108 | if ( ! mFirst ) |
1109 | return; | 1109 | return; |
1110 | mFirst = false; | 1110 | mFirst = false; |
1111 | mTimerSocket->stop(); | 1111 | mTimerSocket->stop(); |
1112 | mFileString = ""; | 1112 | mFileString = ""; |
1113 | mTime.start(); | 1113 | mTime.start(); |
1114 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); | 1114 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); |
1115 | 1115 | ||
1116 | } | 1116 | } |
1117 | void KCommandSocket::readFileFromSocket() | 1117 | void KCommandSocket::readFileFromSocket() |
1118 | { | 1118 | { |
1119 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); | 1119 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); |
1120 | while ( mSocket->canReadLine () ) { | 1120 | while ( mSocket->canReadLine () ) { |
1121 | mTime.restart(); | 1121 | mTime.restart(); |
1122 | QString line = mSocket->readLine (); | 1122 | QString line = mSocket->readLine (); |
1123 | mFileString += line; | 1123 | mFileString += line; |
1124 | //qDebug("readline: %s ", line.latin1()); | 1124 | //qDebug("readline: %s ", line.latin1()); |
1125 | } | 1125 | } |
1126 | if ( mTime.elapsed () < 3000 ) { | 1126 | if ( mTime.elapsed () < 3000 ) { |
1127 | // wait for more | 1127 | // wait for more |
1128 | //qDebug("waitformore "); | 1128 | //qDebug("waitformore "); |
1129 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); | 1129 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); |
1130 | return; | 1130 | return; |
1131 | } | 1131 | } |
1132 | QString fileName = mFileName; | 1132 | QString fileName = mFileName; |
1133 | QFile file ( fileName ); | 1133 | QFile file ( fileName ); |
1134 | if (!file.open( IO_WriteOnly ) ) { | 1134 | if (!file.open( IO_WriteOnly ) ) { |
1135 | mFileString = ""; | 1135 | mFileString = ""; |
1136 | mRetVal = errorR; | 1136 | mRetVal = errorR; |
1137 | qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); | 1137 | qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); |
1138 | deleteSocket(); | 1138 | deleteSocket(); |
1139 | return ; | 1139 | return ; |
1140 | 1140 | ||
1141 | } | 1141 | } |
1142 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1142 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1143 | QTextStream ts ( &file ); | 1143 | QTextStream ts ( &file ); |
1144 | ts.setEncoding( QTextStream::Latin1 ); | 1144 | ts.setEncoding( QTextStream::Latin1 ); |
1145 | ts << mFileString; | 1145 | ts << mFileString; |
1146 | file.close(); | 1146 | file.close(); |
1147 | mFileString = ""; | 1147 | mFileString = ""; |
1148 | mRetVal = successR; | 1148 | mRetVal = successR; |
1149 | mSocket->close(); | 1149 | mSocket->close(); |
1150 | // if state is not idle, deleteSocket(); is called via | 1150 | // if state is not idle, deleteSocket(); is called via |
1151 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1151 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1152 | if ( mSocket->state() == QSocket::Idle ) | 1152 | if ( mSocket->state() == QSocket::Idle ) |
1153 | deleteSocket(); | 1153 | deleteSocket(); |
1154 | } | 1154 | } |
1155 | 1155 | ||
1156 | void KCommandSocket::deleteSocket() | 1156 | void KCommandSocket::deleteSocket() |
1157 | { | 1157 | { |
1158 | if ( mTimerSocket->isActive () ) { | 1158 | if ( mTimerSocket->isActive () ) { |
1159 | mTimerSocket->stop(); | 1159 | mTimerSocket->stop(); |
1160 | KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? ")); | ||
1161 | mRetVal = errorTO; | 1160 | mRetVal = errorTO; |
1162 | if ( mSocket ) { | 1161 | if ( mSocket ) { |
1163 | mSocket->close(); | 1162 | mSocket->close(); |
1164 | if ( mSocket->state() == QSocket::Idle ) | 1163 | if ( mSocket->state() == QSocket::Idle ) |
1165 | deleteSocket(); | 1164 | deleteSocket(); |
1166 | return; | 1165 | return; |
1167 | } | 1166 | } |
1168 | } | 1167 | } |
1169 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); | 1168 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); |
1170 | if ( mSocket) | 1169 | if ( mSocket) |
1171 | delete mSocket; | 1170 | delete mSocket; |
1172 | mSocket = 0; | 1171 | mSocket = 0; |
1172 | if ( mRetVal == errorTO) | ||
1173 | KMessageBox::information( 0, i18n("ERROR:\nConnection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? ")); | ||
1174 | |||
1173 | emit commandFinished( this, mRetVal ); | 1175 | emit commandFinished( this, mRetVal ); |
1174 | } | 1176 | } |