summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-07 23:26:31 (UTC)
committer zautrix <zautrix>2004-10-07 23:26:31 (UTC)
commit91e43b55a0ddf6a6f39f4ed3ae828ddad6ec89a5 (patch) (unidiff)
tree8fd8d34625e4e4f28dea34e4cb19612f49eca20d
parent9f1b282aa2a72f3118a89dfebbc3c8132197213a (diff)
downloadkdepimpi-91e43b55a0ddf6a6f39f4ed3ae828ddad6ec89a5.zip
kdepimpi-91e43b55a0ddf6a6f39f4ed3ae828ddad6ec89a5.tar.gz
kdepimpi-91e43b55a0ddf6a6f39f4ed3ae828ddad6ec89a5.tar.bz2
sync fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp1
-rw-r--r--libkdepim/ksyncmanager.cpp4
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
@@ -3633,101 +3633,102 @@ 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
3638void CalendarView::lookForIncomingMessages() 3638void CalendarView::lookForIncomingMessages()
3639{ 3639{
3640 IncomingDialog *icd = mDialogManager->incomingDialog(); 3640 IncomingDialog *icd = mDialogManager->incomingDialog();
3641 icd->retrieve(); 3641 icd->retrieve();
3642} 3642}
3643 3643
3644bool CalendarView::removeCompletedSubTodos( Todo* t ) 3644bool 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}
3666void CalendarView::purgeCompleted() 3666void 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
3693void CalendarView::slotCalendarChanged() 3693void CalendarView::slotCalendarChanged()
3694{ 3694{
3695 ; 3695 ;
3696} 3696}
3697 3697
3698NavigatorBar *CalendarView::navigatorBar() 3698NavigatorBar *CalendarView::navigatorBar()
3699{ 3699{
3700 return mNavigatorBar; 3700 return mNavigatorBar;
3701} 3701}
3702 3702
3703 3703
3704 3704
3705void CalendarView::keyPressEvent ( QKeyEvent *e) 3705void 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
3712bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 3712bool 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}
3719bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 3719bool 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}
3730void CalendarView::setSyncManager(KSyncManager* manager) 3731void 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
@@ -1064,111 +1064,113 @@ void KCommandSocket::writeFile( QString fileName )
1064 mFileName = fileName ; 1064 mFileName = fileName ;
1065 mSocket->connectToHost( mHost, mPort ); 1065 mSocket->connectToHost( mHost, mPort );
1066} 1066}
1067void KCommandSocket::writeFileToSocket() 1067void 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}
1091void KCommandSocket::sendStop() 1091void 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
1106void KCommandSocket::startReadFileFromSocket() 1106void 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}
1117void KCommandSocket::readFileFromSocket() 1117void 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
1156void KCommandSocket::deleteSocket() 1156void 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}