summaryrefslogtreecommitdiffabout
path: root/libkdepim/ksyncmanager.cpp
Unidiff
Diffstat (limited to 'libkdepim/ksyncmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 7197b30..b7929ec 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1141,96 +1141,97 @@ void KSyncManager::syncPi()
1141 mPisyncFinished = true; 1141 mPisyncFinished = true;
1142 return; 1142 return;
1143 } 1143 }
1144 mCurrentResourceLocal = ""; 1144 mCurrentResourceLocal = "";
1145 mCurrentResourceRemote = ""; 1145 mCurrentResourceRemote = "";
1146 if ( mSpecificResources.count() ) { 1146 if ( mSpecificResources.count() ) {
1147 uint lastSyncRes = mSpecificResources.count()/2; 1147 uint lastSyncRes = mSpecificResources.count()/2;
1148 int ccc = mSpecificResources.count()-1; 1148 int ccc = mSpecificResources.count()-1;
1149 while ( lastSyncRes > 0 && ccc > 0 && mSpecificResources[ ccc ].isEmpty() ) { 1149 while ( lastSyncRes > 0 && ccc > 0 && mSpecificResources[ ccc ].isEmpty() ) {
1150 --ccc; 1150 --ccc;
1151 --lastSyncRes; 1151 --lastSyncRes;
1152 //qDebug ( "KSM: sync pi %d",ccc ); 1152 //qDebug ( "KSM: sync pi %d",ccc );
1153 } 1153 }
1154 uint startLocal = 0; 1154 uint startLocal = 0;
1155 uint startRemote = mSpecificResources.count()/2; 1155 uint startRemote = mSpecificResources.count()/2;
1156 emit multiResourceSyncStart( true ); 1156 emit multiResourceSyncStart( true );
1157 while ( startLocal < mSpecificResources.count()/2 ) { 1157 while ( startLocal < mSpecificResources.count()/2 ) {
1158 if ( startLocal+1 >= lastSyncRes ) 1158 if ( startLocal+1 >= lastSyncRes )
1159 emit multiResourceSyncStart( false ); 1159 emit multiResourceSyncStart( false );
1160 mPisyncFinished = false; 1160 mPisyncFinished = false;
1161 mCurrentResourceLocal = mSpecificResources[ startLocal ]; 1161 mCurrentResourceLocal = mSpecificResources[ startLocal ];
1162 mCurrentResourceRemote = mSpecificResources[ startRemote ]; 1162 mCurrentResourceRemote = mSpecificResources[ startRemote ];
1163 //qDebug ( "KSM: AAASyncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); 1163 //qDebug ( "KSM: AAASyncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() );
1164 if ( !mCurrentResourceRemote.isEmpty() ) { 1164 if ( !mCurrentResourceRemote.isEmpty() ) {
1165 qDebug ( "KSM: Syncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); 1165 qDebug ( "KSM: Syncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() );
1166 1166
1167 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); 1167 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
1168 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1168 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1169 commandSocket->readFile( syncFileName() ); 1169 commandSocket->readFile( syncFileName() );
1170 mParent->topLevelWidget()->setCaption( i18n("Syncing %1 <-> %2").arg( mCurrentResourceLocal ).arg( mCurrentResourceRemote ) ); 1170 mParent->topLevelWidget()->setCaption( i18n("Syncing %1 <-> %2").arg( mCurrentResourceLocal ).arg( mCurrentResourceRemote ) );
1171 while ( !mPisyncFinished ) { 1171 while ( !mPisyncFinished ) {
1172 //qDebug("waiting "); 1172 //qDebug("waiting ");
1173 qApp->processEvents(); 1173 qApp->processEvents();
1174 } 1174 }
1175 if ( startLocal+1 < mSpecificResources.count()/2 ) { 1175 if ( startLocal+1 < mSpecificResources.count()/2 ) {
1176 mParent->topLevelWidget()->setCaption( i18n("Waiting a second before syncing next resource...") ); 1176 mParent->topLevelWidget()->setCaption( i18n("Waiting a second before syncing next resource...") );
1177 QTime timer; 1177 QTime timer;
1178 timer.start(); 1178 timer.start();
1179 while ( timer.elapsed () < 1000 ) { 1179 while ( timer.elapsed () < 1000 ) {
1180 qApp->processEvents(); 1180 qApp->processEvents();
1181 } 1181 }
1182 } 1182 }
1183 } 1183 }
1184 ++startRemote; 1184 ++startRemote;
1185 ++startLocal; 1185 ++startLocal;
1186 mAskForPreferences = false; 1186 mAskForPreferences = false;
1187 } 1187 }
1188 mPisyncFinished = true; 1188 mPisyncFinished = true;
1189 mParent->topLevelWidget()->setCaption( i18n("Multi-resource Pi-sync finished") );
1189 } else { 1190 } else {
1190 KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); 1191 KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
1191 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1192 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1192 commandSocket->readFile( syncFileName() ); 1193 commandSocket->readFile( syncFileName() );
1193 } 1194 }
1194} 1195}
1195 1196
1196void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 1197void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
1197{ 1198{
1198 //enum { success, errorW, errorR, quiet }; 1199 //enum { success, errorW, errorR, quiet };
1199 1200
1200 1201
1201 1202
1202 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW || 1203 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW ||
1203 state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) { 1204 state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) {
1204 if ( state == KCommandSocket::errorPW ) 1205 if ( state == KCommandSocket::errorPW )
1205 mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") ); 1206 mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") );
1206 else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) 1207 else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO )
1207 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); 1208 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
1208 else if ( state == KCommandSocket::errorCA ) 1209 else if ( state == KCommandSocket::errorCA )
1209 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") ); 1210 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") );
1210 else if ( state == KCommandSocket::errorFI ) 1211 else if ( state == KCommandSocket::errorFI )
1211 mParent->topLevelWidget()->setCaption( i18n("File error on remote.") ); 1212 mParent->topLevelWidget()->setCaption( i18n("File error on remote.") );
1212 else if ( state == KCommandSocket::errorED ) 1213 else if ( state == KCommandSocket::errorED )
1213 mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") ); 1214 mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") );
1214 else if ( state == KCommandSocket::errorUN ) 1215 else if ( state == KCommandSocket::errorUN )
1215 mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") ); 1216 mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") );
1216 delete s; 1217 delete s;
1217 if ( state == KCommandSocket::errorR ) { 1218 if ( state == KCommandSocket::errorR ) {
1218 KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget()); 1219 KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget());
1219 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1220 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1220 commandSocket->sendStop(); 1221 commandSocket->sendStop();
1221 } 1222 }
1222 mPisyncFinished = true; 1223 mPisyncFinished = true;
1223 return; 1224 return;
1224 1225
1225 } else if ( state == KCommandSocket::errorW ) { 1226 } else if ( state == KCommandSocket::errorW ) {
1226 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); 1227 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
1227 mPisyncFinished = true; 1228 mPisyncFinished = true;
1228 1229
1229 } else if ( state == KCommandSocket::successR ) { 1230 } else if ( state == KCommandSocket::successR ) {
1230 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 1231 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
1231 1232
1232 } else if ( state == KCommandSocket::successW ) { 1233 } else if ( state == KCommandSocket::successW ) {
1233 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); 1234 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") );
1234 mPisyncFinished = true; 1235 mPisyncFinished = true;
1235 } else if ( state == KCommandSocket::quiet ){ 1236 } else if ( state == KCommandSocket::quiet ){
1236 qDebug("KSS: quiet "); 1237 qDebug("KSS: quiet ");