-rw-r--r-- | libkdepim/ksyncmanager.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index f80c2a6..e615cbe 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -1211,513 +1211,513 @@ void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) | |||
1211 | mParent->topLevelWidget()->setCaption( i18n("File error on remote.") ); | 1211 | mParent->topLevelWidget()->setCaption( i18n("File error on remote.") ); |
1212 | else if ( state == KCommandSocket::errorED ) | 1212 | else if ( state == KCommandSocket::errorED ) |
1213 | mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") ); | 1213 | mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") ); |
1214 | else if ( state == KCommandSocket::errorUN ) | 1214 | else if ( state == KCommandSocket::errorUN ) |
1215 | mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") ); | 1215 | mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") ); |
1216 | delete s; | 1216 | delete s; |
1217 | if ( state == KCommandSocket::errorR ) { | 1217 | if ( state == KCommandSocket::errorR ) { |
1218 | KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget()); | 1218 | KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget()); |
1219 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 1219 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
1220 | commandSocket->sendStop(); | 1220 | commandSocket->sendStop(); |
1221 | } | 1221 | } |
1222 | mPisyncFinished = true; | 1222 | mPisyncFinished = true; |
1223 | return; | 1223 | return; |
1224 | 1224 | ||
1225 | } else if ( state == KCommandSocket::errorW ) { | 1225 | } else if ( state == KCommandSocket::errorW ) { |
1226 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); | 1226 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); |
1227 | mPisyncFinished = true; | 1227 | mPisyncFinished = true; |
1228 | 1228 | ||
1229 | } else if ( state == KCommandSocket::successR ) { | 1229 | } else if ( state == KCommandSocket::successR ) { |
1230 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | 1230 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); |
1231 | 1231 | ||
1232 | } else if ( state == KCommandSocket::successW ) { | 1232 | } else if ( state == KCommandSocket::successW ) { |
1233 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); | 1233 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); |
1234 | mPisyncFinished = true; | 1234 | mPisyncFinished = true; |
1235 | } else if ( state == KCommandSocket::quiet ){ | 1235 | } else if ( state == KCommandSocket::quiet ){ |
1236 | qDebug("KSS: quiet "); | 1236 | qDebug("KSS: quiet "); |
1237 | mPisyncFinished = true; | 1237 | mPisyncFinished = true; |
1238 | } else { | 1238 | } else { |
1239 | qDebug("KSS: Error: unknown state: %d ", state); | 1239 | qDebug("KSS: Error: unknown state: %d ", state); |
1240 | mPisyncFinished = true; | 1240 | mPisyncFinished = true; |
1241 | } | 1241 | } |
1242 | 1242 | ||
1243 | delete s; | 1243 | delete s; |
1244 | } | 1244 | } |
1245 | 1245 | ||
1246 | void KSyncManager::readFileFromSocket() | 1246 | void KSyncManager::readFileFromSocket() |
1247 | { | 1247 | { |
1248 | QString fileName = syncFileName(); | 1248 | QString fileName = syncFileName(); |
1249 | bool syncOK = true; | 1249 | bool syncOK = true; |
1250 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); | 1250 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); |
1251 | if ( ! syncWithFile( fileName , true ) ) { | 1251 | if ( ! syncWithFile( fileName , true ) ) { |
1252 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); | 1252 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); |
1253 | syncOK = false; | 1253 | syncOK = false; |
1254 | } | 1254 | } |
1255 | KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote,mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); | 1255 | KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote,mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); |
1256 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 1256 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
1257 | if ( mWriteBackFile && syncOK ) { | 1257 | if ( mWriteBackFile && syncOK ) { |
1258 | mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") ); | 1258 | mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") ); |
1259 | commandSocket->writeFile( fileName ); | 1259 | commandSocket->writeFile( fileName ); |
1260 | } | 1260 | } |
1261 | else { | 1261 | else { |
1262 | commandSocket->sendStop(); | 1262 | commandSocket->sendStop(); |
1263 | if ( syncOK ) | 1263 | if ( syncOK ) |
1264 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 1264 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
1265 | mPisyncFinished = true; | 1265 | mPisyncFinished = true; |
1266 | } | 1266 | } |
1267 | } | 1267 | } |
1268 | 1268 | ||
1269 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) | 1269 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) |
1270 | { | 1270 | { |
1271 | mPendingConnect = 0; | 1271 | mPendingConnect = 0; |
1272 | mPassWord = pw; | 1272 | mPassWord = pw; |
1273 | mSocket = 0; | 1273 | mSocket = 0; |
1274 | mSyncActionDialog = 0; | 1274 | mSyncActionDialog = 0; |
1275 | blockRC = false; | 1275 | blockRC = false; |
1276 | mErrorMessage = 0; | 1276 | mErrorMessage = 0; |
1277 | } | 1277 | } |
1278 | void KServerSocket::waitForSocketFinish() | 1278 | void KServerSocket::waitForSocketFinish() |
1279 | { | 1279 | { |
1280 | if ( mSocket ) { | 1280 | if ( mSocket ) { |
1281 | //qDebug("KSS:: waiting for finish operation"); | 1281 | //qDebug("KSS:: waiting for finish operation"); |
1282 | QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish())); | 1282 | QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish())); |
1283 | return; | 1283 | return; |
1284 | } | 1284 | } |
1285 | mSocket = new QSocket( this ); | 1285 | mSocket = new QSocket( this ); |
1286 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | 1286 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); |
1287 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | 1287 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); |
1288 | mSocket->setSocket( mPendingConnect ); | 1288 | mSocket->setSocket( mPendingConnect ); |
1289 | mPendingConnect = 0; | 1289 | mPendingConnect = 0; |
1290 | } | 1290 | } |
1291 | void KServerSocket::newConnection ( int socket ) | 1291 | void KServerSocket::newConnection ( int socket ) |
1292 | { | 1292 | { |
1293 | // qDebug("KServerSocket:New connection %d ", socket); | 1293 | // qDebug("KServerSocket:New connection %d ", socket); |
1294 | if ( mPendingConnect ) { | 1294 | if ( mPendingConnect ) { |
1295 | qDebug("KSS::Error : new Connection"); | 1295 | qDebug("KSS::Error : new Connection"); |
1296 | return; | 1296 | return; |
1297 | } | 1297 | } |
1298 | if ( mSocket ) { | 1298 | if ( mSocket ) { |
1299 | mPendingConnect = socket; | 1299 | mPendingConnect = socket; |
1300 | QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish())); | 1300 | QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish())); |
1301 | return; | 1301 | return; |
1302 | qDebug("KSS::newConnection Socket deleted! "); | 1302 | qDebug("KSS::newConnection Socket deleted! "); |
1303 | delete mSocket; | 1303 | delete mSocket; |
1304 | mSocket = 0; | 1304 | mSocket = 0; |
1305 | } | 1305 | } |
1306 | mPendingConnect = 0; | 1306 | mPendingConnect = 0; |
1307 | mSocket = new QSocket( this ); | 1307 | mSocket = new QSocket( this ); |
1308 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | 1308 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); |
1309 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | 1309 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); |
1310 | mSocket->setSocket( socket ); | 1310 | mSocket->setSocket( socket ); |
1311 | } | 1311 | } |
1312 | 1312 | ||
1313 | void KServerSocket::discardClient() | 1313 | void KServerSocket::discardClient() |
1314 | { | 1314 | { |
1315 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1315 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1316 | } | 1316 | } |
1317 | void KServerSocket::deleteSocket() | 1317 | void KServerSocket::deleteSocket() |
1318 | { | 1318 | { |
1319 | //qDebug("KSS::deleteSocket"); | 1319 | //qDebug("KSS::deleteSocket"); |
1320 | if ( mSocket ) { | 1320 | if ( mSocket ) { |
1321 | delete mSocket; | 1321 | delete mSocket; |
1322 | mSocket = 0; | 1322 | mSocket = 0; |
1323 | } | 1323 | } |
1324 | if ( mErrorMessage ) | 1324 | if ( mErrorMessage ) |
1325 | QTimer::singleShot( 10, this , SLOT ( displayErrorMessage())); | 1325 | QTimer::singleShot( 10, this , SLOT ( displayErrorMessage())); |
1326 | } | 1326 | } |
1327 | void KServerSocket::readClient() | 1327 | void KServerSocket::readClient() |
1328 | { | 1328 | { |
1329 | if ( blockRC ) | 1329 | if ( blockRC ) |
1330 | return; | 1330 | return; |
1331 | if ( mSocket == 0 ) { | 1331 | if ( mSocket == 0 ) { |
1332 | qDebug("ERROR::KSS::readClient(): mSocket == 0 "); | 1332 | qDebug("ERROR::KSS::readClient(): mSocket == 0 "); |
1333 | return; | 1333 | return; |
1334 | } | 1334 | } |
1335 | if ( mErrorMessage ) { | 1335 | if ( mErrorMessage ) { |
1336 | mErrorMessage = 999; | 1336 | mErrorMessage = 999; |
1337 | error_connect("ERROR_ED\r\n\r\n"); | 1337 | error_connect("ERROR_ED\r\n\r\n"); |
1338 | return; | 1338 | return; |
1339 | } | 1339 | } |
1340 | mResource = ""; | 1340 | mResource = ""; |
1341 | mErrorMessage = 0; | 1341 | mErrorMessage = 0; |
1342 | //qDebug("KServerSocket::readClient()"); | 1342 | //qDebug("KServerSocket::readClient()"); |
1343 | if ( mSocket->canReadLine() ) { | 1343 | if ( mSocket->canReadLine() ) { |
1344 | QString line = mSocket->readLine(); | 1344 | QString line = mSocket->readLine(); |
1345 | //qDebug("KServerSocket readline: %s ", line.latin1()); | 1345 | //qDebug("KServerSocket readline: %s ", line.latin1()); |
1346 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); | 1346 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); |
1347 | if ( tokens[0] == "GET" ) { | 1347 | if ( tokens[0] == "GET" ) { |
1348 | if ( tokens[1] == mPassWord ) { | 1348 | if ( tokens[1] == mPassWord ) { |
1349 | //emit sendFile( mSocket ); | 1349 | //emit sendFile( mSocket ); |
1350 | bool ok = false; | 1350 | bool ok = false; |
1351 | QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); | 1351 | QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); |
1352 | if ( ok ) { | 1352 | if ( ok ) { |
1353 | KSyncManager::mRequestedSyncEvent = dt; | 1353 | KSyncManager::mRequestedSyncEvent = dt; |
1354 | } | 1354 | } |
1355 | else | 1355 | else |
1356 | KSyncManager::mRequestedSyncEvent = QDateTime(); | 1356 | KSyncManager::mRequestedSyncEvent = QDateTime(); |
1357 | mResource =tokens[3]; | 1357 | mResource =tokens[3]; |
1358 | send_file(); | 1358 | send_file(); |
1359 | } | 1359 | } |
1360 | else { | 1360 | else { |
1361 | mErrorMessage = 1; | 1361 | mErrorMessage = 1; |
1362 | error_connect("ERROR_PW\r\n\r\n"); | 1362 | error_connect("ERROR_PW\r\n\r\n"); |
1363 | } | 1363 | } |
1364 | } | 1364 | } |
1365 | if ( tokens[0] == "PUT" ) { | 1365 | if ( tokens[0] == "PUT" ) { |
1366 | if ( tokens[1] == mPassWord ) { | 1366 | if ( tokens[1] == mPassWord ) { |
1367 | //emit getFile( mSocket ); | 1367 | //emit getFile( mSocket ); |
1368 | blockRC = true; | 1368 | blockRC = true; |
1369 | mResource =tokens[2]; | 1369 | mResource =tokens[2]; |
1370 | get_file(); | 1370 | get_file(); |
1371 | } | 1371 | } |
1372 | else { | 1372 | else { |
1373 | mErrorMessage = 2; | 1373 | mErrorMessage = 2; |
1374 | error_connect("ERROR_PW\r\n\r\n"); | 1374 | error_connect("ERROR_PW\r\n\r\n"); |
1375 | end_connect(); | 1375 | end_connect(); |
1376 | } | 1376 | } |
1377 | } | 1377 | } |
1378 | if ( tokens[0] == "STOP" ) { | 1378 | if ( tokens[0] == "STOP" ) { |
1379 | //emit endConnect(); | 1379 | //emit endConnect(); |
1380 | end_connect(); | 1380 | end_connect(); |
1381 | } | 1381 | } |
1382 | } | 1382 | } |
1383 | } | 1383 | } |
1384 | void KServerSocket::displayErrorMessage() | 1384 | void KServerSocket::displayErrorMessage() |
1385 | { | 1385 | { |
1386 | if ( mErrorMessage == 1 ) { | 1386 | if ( mErrorMessage == 1 ) { |
1387 | KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"), i18n("Pi-Sync Error")); | 1387 | KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"), i18n("Pi-Sync Error")); |
1388 | mErrorMessage = 0; | 1388 | mErrorMessage = 0; |
1389 | } | 1389 | } |
1390 | else if ( mErrorMessage == 2 ) { | 1390 | else if ( mErrorMessage == 2 ) { |
1391 | KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error")); | 1391 | KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error")); |
1392 | mErrorMessage = 0; | 1392 | mErrorMessage = 0; |
1393 | } | 1393 | } |
1394 | } | 1394 | } |
1395 | void KServerSocket::error_connect( QString errmess ) | 1395 | void KServerSocket::error_connect( QString errmess ) |
1396 | { | 1396 | { |
1397 | QTextStream os( mSocket ); | 1397 | QTextStream os( mSocket ); |
1398 | os.setEncoding( QTextStream::Latin1 ); | 1398 | os.setEncoding( QTextStream::Latin1 ); |
1399 | os << errmess ; | 1399 | os << errmess ; |
1400 | mSocket->close(); | 1400 | mSocket->close(); |
1401 | if ( mSocket->state() == QSocket::Idle ) { | 1401 | if ( mSocket->state() == QSocket::Idle ) { |
1402 | QTimer::singleShot( 0, this , SLOT ( discardClient())); | 1402 | QTimer::singleShot( 0, this , SLOT ( discardClient())); |
1403 | } | 1403 | } |
1404 | } | 1404 | } |
1405 | void KServerSocket::end_connect() | 1405 | void KServerSocket::end_connect() |
1406 | { | 1406 | { |
1407 | delete mSyncActionDialog; | 1407 | delete mSyncActionDialog; |
1408 | mSyncActionDialog = 0; | 1408 | mSyncActionDialog = 0; |
1409 | } | 1409 | } |
1410 | void KServerSocket::send_file() | 1410 | void KServerSocket::send_file() |
1411 | { | 1411 | { |
1412 | //qDebug("MainWindow::sendFile(QSocket* s) "); | 1412 | //qDebug("MainWindow::sendFile(QSocket* s) "); |
1413 | if ( mSyncActionDialog ) | 1413 | if ( mSyncActionDialog ) |
1414 | delete mSyncActionDialog; | 1414 | delete mSyncActionDialog; |
1415 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); | 1415 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); |
1416 | mSyncActionDialog->setCaption(i18n("Received sync request")); | 1416 | mSyncActionDialog->setCaption(i18n("Received sync request")); |
1417 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); | 1417 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); |
1418 | label->setAlignment ( Qt::AlignHCenter ); | 1418 | label->setAlignment ( Qt::AlignHCenter ); |
1419 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); | 1419 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); |
1420 | lay->addWidget( label); | 1420 | lay->addWidget( label); |
1421 | lay->setMargin(7); | 1421 | lay->setMargin(7); |
1422 | lay->setSpacing(7); | 1422 | lay->setSpacing(7); |
1423 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1423 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1424 | int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); | 1424 | int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); |
1425 | //secs = 333; | 1425 | //secs = 333; |
1426 | if ( secs < 0 ) | 1426 | if ( secs < 0 ) |
1427 | secs = secs * (-1); | 1427 | secs = secs * (-1); |
1428 | if ( secs > 30 ) | 1428 | if ( secs > 30 ) |
1429 | //if ( true ) | 1429 | //if ( true ) |
1430 | { | 1430 | { |
1431 | QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); | 1431 | QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); |
1432 | QLabel* label = new QLabel( warning, mSyncActionDialog ); | 1432 | QLabel* label = new QLabel( warning, mSyncActionDialog ); |
1433 | label->setAlignment ( Qt::AlignHCenter ); | 1433 | label->setAlignment ( Qt::AlignHCenter ); |
1434 | lay->addWidget( label); | 1434 | lay->addWidget( label); |
1435 | if ( secs > 180 ) | 1435 | if ( secs > 180 ) |
1436 | { | 1436 | { |
1437 | if ( secs > 300 ) { | 1437 | if ( secs > 300 ) { |
1438 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { | 1438 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { |
1439 | qDebug("KSS::Sync cancelled ,cs"); | 1439 | qDebug("KSS::Sync cancelled ,cs"); |
1440 | mErrorMessage = 0; | 1440 | mErrorMessage = 0; |
1441 | end_connect(); | 1441 | end_connect(); |
1442 | error_connect("ERROR_CA\r\n\r\n"); | 1442 | error_connect("ERROR_CA\r\n\r\n"); |
1443 | return ; | 1443 | return ; |
1444 | } | 1444 | } |
1445 | } | 1445 | } |
1446 | QFont f = label->font(); | 1446 | QFont f = label->font(); |
1447 | f.setPointSize ( f.pointSize() *2 ); | 1447 | f.setPointSize ( f.pointSize() *2 ); |
1448 | f. setBold (true ); | 1448 | f. setBold (true ); |
1449 | QLabel* label = new QLabel( warning, mSyncActionDialog ); | 1449 | QLabel* label = new QLabel( warning, mSyncActionDialog ); |
1450 | label->setFont( f ); | 1450 | label->setFont( f ); |
1451 | warning = i18n("ADJUST\nYOUR\nCLOCKS!"); | 1451 | warning = i18n("ADJUST\nYOUR\nCLOCKS!"); |
1452 | label->setText( warning ); | 1452 | label->setText( warning ); |
1453 | label->setAlignment ( Qt::AlignHCenter ); | 1453 | label->setAlignment ( Qt::AlignHCenter ); |
1454 | lay->addWidget( label); | 1454 | lay->addWidget( label); |
1455 | mSyncActionDialog->setFixedSize( 230, 300); | 1455 | mSyncActionDialog->setFixedSize( 230, 300); |
1456 | } else { | 1456 | } else { |
1457 | mSyncActionDialog->setFixedSize( 230, 200); | 1457 | mSyncActionDialog->setFixedSize( 230, 200); |
1458 | } | 1458 | } |
1459 | } else { | 1459 | } else { |
1460 | mSyncActionDialog->setFixedSize( 230, 120); | 1460 | mSyncActionDialog->setFixedSize( 230, 120); |
1461 | } | 1461 | } |
1462 | } else | 1462 | } else |
1463 | mSyncActionDialog->setFixedSize( 230, 120); | 1463 | mSyncActionDialog->setFixedSize( 230, 120); |
1464 | mSyncActionDialog->show(); | 1464 | mSyncActionDialog->show(); |
1465 | mSyncActionDialog->raise(); | 1465 | mSyncActionDialog->raise(); |
1466 | emit request_file(mResource); | 1466 | emit request_file(mResource); |
1467 | emit request_file(); | 1467 | //emit request_file(); |
1468 | qApp->processEvents(); | 1468 | qApp->processEvents(); |
1469 | QString fileName = mFileName; | 1469 | QString fileName = mFileName; |
1470 | QFile file( fileName ); | 1470 | QFile file( fileName ); |
1471 | if (!file.open( IO_ReadOnly ) ) { | 1471 | if (!file.open( IO_ReadOnly ) ) { |
1472 | mErrorMessage = 0; | 1472 | mErrorMessage = 0; |
1473 | end_connect(); | 1473 | end_connect(); |
1474 | error_connect("ERROR_FI\r\n\r\n"); | 1474 | error_connect("ERROR_FI\r\n\r\n"); |
1475 | return ; | 1475 | return ; |
1476 | } | 1476 | } |
1477 | mSyncActionDialog->setCaption( i18n("Sending file...") ); | 1477 | mSyncActionDialog->setCaption( i18n("Sending file...") ); |
1478 | QTextStream ts( &file ); | 1478 | QTextStream ts( &file ); |
1479 | ts.setEncoding( QTextStream::Latin1 ); | 1479 | ts.setEncoding( QTextStream::Latin1 ); |
1480 | 1480 | ||
1481 | QTextStream os( mSocket ); | 1481 | QTextStream os( mSocket ); |
1482 | os.setEncoding( QTextStream::Latin1 ); | 1482 | os.setEncoding( QTextStream::Latin1 ); |
1483 | while ( ! ts.atEnd() ) { | 1483 | while ( ! ts.atEnd() ) { |
1484 | os << ts.readLine() << "\r\n"; | 1484 | os << ts.readLine() << "\r\n"; |
1485 | } | 1485 | } |
1486 | os << "\r\n"; | 1486 | os << "\r\n"; |
1487 | //os << ts.read(); | 1487 | //os << ts.read(); |
1488 | file.close(); | 1488 | file.close(); |
1489 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); | 1489 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); |
1490 | mSocket->close(); | 1490 | mSocket->close(); |
1491 | if ( mSocket->state() == QSocket::Idle ) | 1491 | if ( mSocket->state() == QSocket::Idle ) |
1492 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1492 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1493 | } | 1493 | } |
1494 | void KServerSocket::get_file() | 1494 | void KServerSocket::get_file() |
1495 | { | 1495 | { |
1496 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); | 1496 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); |
1497 | 1497 | ||
1498 | piTime.start(); | 1498 | piTime.start(); |
1499 | piFileString = ""; | 1499 | piFileString = ""; |
1500 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); | 1500 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); |
1501 | } | 1501 | } |
1502 | 1502 | ||
1503 | 1503 | ||
1504 | void KServerSocket::readBackFileFromSocket() | 1504 | void KServerSocket::readBackFileFromSocket() |
1505 | { | 1505 | { |
1506 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); | 1506 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); |
1507 | while ( mSocket->canReadLine () ) { | 1507 | while ( mSocket->canReadLine () ) { |
1508 | piTime.restart(); | 1508 | piTime.restart(); |
1509 | QString line = mSocket->readLine (); | 1509 | QString line = mSocket->readLine (); |
1510 | piFileString += line; | 1510 | piFileString += line; |
1511 | //qDebug("readline: %s ", line.latin1()); | 1511 | //qDebug("readline: %s ", line.latin1()); |
1512 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); | 1512 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); |
1513 | 1513 | ||
1514 | } | 1514 | } |
1515 | if ( piTime.elapsed () < 3000 ) { | 1515 | if ( piTime.elapsed () < 3000 ) { |
1516 | // wait for more | 1516 | // wait for more |
1517 | //qDebug("waitformore "); | 1517 | //qDebug("waitformore "); |
1518 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); | 1518 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); |
1519 | return; | 1519 | return; |
1520 | } | 1520 | } |
1521 | QString fileName = mFileName; | 1521 | QString fileName = mFileName; |
1522 | QFile file ( fileName ); | 1522 | QFile file ( fileName ); |
1523 | if (!file.open( IO_WriteOnly ) ) { | 1523 | if (!file.open( IO_WriteOnly ) ) { |
1524 | delete mSyncActionDialog; | 1524 | delete mSyncActionDialog; |
1525 | mSyncActionDialog = 0; | 1525 | mSyncActionDialog = 0; |
1526 | qDebug("KSS:Error open read back file "); | 1526 | qDebug("KSS:Error open read back file "); |
1527 | piFileString = ""; | 1527 | piFileString = ""; |
1528 | emit file_received( false, mResource); | 1528 | emit file_received( false, mResource); |
1529 | emit file_received( false); | 1529 | emit file_received( false); |
1530 | blockRC = false; | 1530 | blockRC = false; |
1531 | return ; | 1531 | return ; |
1532 | 1532 | ||
1533 | } | 1533 | } |
1534 | 1534 | ||
1535 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1535 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1536 | QTextStream ts ( &file ); | 1536 | QTextStream ts ( &file ); |
1537 | ts.setEncoding( QTextStream::Latin1 ); | 1537 | ts.setEncoding( QTextStream::Latin1 ); |
1538 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); | 1538 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); |
1539 | ts << piFileString; | 1539 | ts << piFileString; |
1540 | mSocket->close(); | 1540 | mSocket->close(); |
1541 | if ( mSocket->state() == QSocket::Idle ) | 1541 | if ( mSocket->state() == QSocket::Idle ) |
1542 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1542 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1543 | file.close(); | 1543 | file.close(); |
1544 | piFileString = ""; | 1544 | piFileString = ""; |
1545 | emit file_received( true, mResource ); | 1545 | emit file_received( true, mResource ); |
1546 | emit file_received( true); | 1546 | emit file_received( true); |
1547 | delete mSyncActionDialog; | 1547 | delete mSyncActionDialog; |
1548 | mSyncActionDialog = 0; | 1548 | mSyncActionDialog = 0; |
1549 | blockRC = false; | 1549 | blockRC = false; |
1550 | 1550 | ||
1551 | } | 1551 | } |
1552 | 1552 | ||
1553 | KCommandSocket::KCommandSocket ( QString remres, QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name ) | 1553 | KCommandSocket::KCommandSocket ( QString remres, QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name ) |
1554 | { | 1554 | { |
1555 | mRemoteResource = remres; | 1555 | mRemoteResource = remres; |
1556 | if ( mRemoteResource.isEmpty() ) | 1556 | if ( mRemoteResource.isEmpty() ) |
1557 | mRemoteResource = "ALL"; | 1557 | mRemoteResource = "ALL"; |
1558 | else | 1558 | else |
1559 | mRemoteResource.replace (QRegExp (" "),"_" ); | 1559 | mRemoteResource.replace (QRegExp (" "),"_" ); |
1560 | mPassWord = password; | 1560 | mPassWord = password; |
1561 | mSocket = 0; | 1561 | mSocket = 0; |
1562 | mFirst = false; | 1562 | mFirst = false; |
1563 | mFirstLine = true; | 1563 | mFirstLine = true; |
1564 | mPort = port; | 1564 | mPort = port; |
1565 | mHost = host; | 1565 | mHost = host; |
1566 | tlw = cap; | 1566 | tlw = cap; |
1567 | mRetVal = quiet; | 1567 | mRetVal = quiet; |
1568 | mTimerSocket = new QTimer ( this ); | 1568 | mTimerSocket = new QTimer ( this ); |
1569 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( updateConnectDialog() ) ); | 1569 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( updateConnectDialog() ) ); |
1570 | mConnectProgress.setCaption( i18n("Pi-Sync") ); | 1570 | mConnectProgress.setCaption( i18n("Pi-Sync") ); |
1571 | connect( &mConnectProgress, SIGNAL ( cancelled () ), this, SLOT ( deleteSocket() ) ); | 1571 | connect( &mConnectProgress, SIGNAL ( cancelled () ), this, SLOT ( deleteSocket() ) ); |
1572 | mConnectCount = -1; | 1572 | mConnectCount = -1; |
1573 | } | 1573 | } |
1574 | void KCommandSocket::sendFileRequest() | 1574 | void KCommandSocket::sendFileRequest() |
1575 | { | 1575 | { |
1576 | if ( tlw ) | 1576 | if ( tlw ) |
1577 | tlw->setCaption( i18n("Connected! Sending request for remote file ...") ); | 1577 | tlw->setCaption( i18n("Connected! Sending request for remote file ...") ); |
1578 | mConnectProgress.hide(); | 1578 | mConnectProgress.hide(); |
1579 | mConnectCount = 300;mConnectMax = 300; | 1579 | mConnectCount = 300;mConnectMax = 300; |
1580 | mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") ); | 1580 | mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") ); |
1581 | mConnectProgress.setLabelText( i18n("Waiting for remote file...") ); | 1581 | mConnectProgress.setLabelText( i18n("Waiting for remote file...") ); |
1582 | mTimerSocket->start( 100, true ); | 1582 | mTimerSocket->start( 100, true ); |
1583 | QTextStream os( mSocket ); | 1583 | QTextStream os( mSocket ); |
1584 | os.setEncoding( QTextStream::Latin1 ); | 1584 | os.setEncoding( QTextStream::Latin1 ); |
1585 | 1585 | ||
1586 | QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); | 1586 | QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); |
1587 | os << "GET " << mPassWord << curDt << " " << mRemoteResource << "\r\n\r\n"; | 1587 | os << "GET " << mPassWord << curDt << " " << mRemoteResource << "\r\n\r\n"; |
1588 | } | 1588 | } |
1589 | 1589 | ||
1590 | void KCommandSocket::readFile( QString fn ) | 1590 | void KCommandSocket::readFile( QString fn ) |
1591 | { | 1591 | { |
1592 | if ( !mSocket ) { | 1592 | if ( !mSocket ) { |
1593 | mSocket = new QSocket( this ); | 1593 | mSocket = new QSocket( this ); |
1594 | //qDebug("KCS: read file - new socket"); | 1594 | //qDebug("KCS: read file - new socket"); |
1595 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); | 1595 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); |
1596 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1596 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1597 | connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() )); | 1597 | connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() )); |
1598 | } | 1598 | } |
1599 | mFileString = ""; | 1599 | mFileString = ""; |
1600 | mFileName = fn; | 1600 | mFileName = fn; |
1601 | mFirst = true; | 1601 | mFirst = true; |
1602 | if ( tlw ) | 1602 | if ( tlw ) |
1603 | tlw->setCaption( i18n("Trying to connect to remote...") ); | 1603 | tlw->setCaption( i18n("Trying to connect to remote...") ); |
1604 | mConnectCount = 30;mConnectMax = 30; | 1604 | mConnectCount = 30;mConnectMax = 30; |
1605 | mTimerSocket->start( 1000, true ); | 1605 | mTimerSocket->start( 1000, true ); |
1606 | mSocket->connectToHost( mHost, mPort ); | 1606 | mSocket->connectToHost( mHost, mPort ); |
1607 | //qDebug("KCS: Waiting for connection"); | 1607 | //qDebug("KCS: Waiting for connection"); |
1608 | } | 1608 | } |
1609 | void KCommandSocket::updateConnectDialog() | 1609 | void KCommandSocket::updateConnectDialog() |
1610 | { | 1610 | { |
1611 | 1611 | ||
1612 | if ( mConnectCount == mConnectMax ) { | 1612 | if ( mConnectCount == mConnectMax ) { |
1613 | //qDebug("MAXX %d", mConnectMax); | 1613 | //qDebug("MAXX %d", mConnectMax); |
1614 | mConnectProgress.setTotalSteps ( 30 ); | 1614 | mConnectProgress.setTotalSteps ( 30 ); |
1615 | mConnectProgress.show(); | 1615 | mConnectProgress.show(); |
1616 | mConnectProgress.setLabelText( i18n("Trying to connect to remote...") ); | 1616 | mConnectProgress.setLabelText( i18n("Trying to connect to remote...") ); |
1617 | } | 1617 | } |
1618 | //qDebug("updateConnectDialog() %d", mConnectCount); | 1618 | //qDebug("updateConnectDialog() %d", mConnectCount); |
1619 | mConnectProgress.raise(); | 1619 | mConnectProgress.raise(); |
1620 | mConnectProgress.setProgress( (mConnectMax - mConnectCount)%30 ); | 1620 | mConnectProgress.setProgress( (mConnectMax - mConnectCount)%30 ); |
1621 | --mConnectCount; | 1621 | --mConnectCount; |
1622 | if ( mConnectCount > 0 ) | 1622 | if ( mConnectCount > 0 ) |
1623 | mTimerSocket->start( 1000, true ); | 1623 | mTimerSocket->start( 1000, true ); |
1624 | else | 1624 | else |
1625 | deleteSocket(); | 1625 | deleteSocket(); |
1626 | 1626 | ||
1627 | } | 1627 | } |
1628 | void KCommandSocket::writeFile( QString fileName ) | 1628 | void KCommandSocket::writeFile( QString fileName ) |
1629 | { | 1629 | { |
1630 | if ( !mSocket ) { | 1630 | if ( !mSocket ) { |
1631 | mSocket = new QSocket( this ); | 1631 | mSocket = new QSocket( this ); |
1632 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1632 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1633 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); | 1633 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); |
1634 | } | 1634 | } |
1635 | mFileName = fileName ; | 1635 | mFileName = fileName ; |
1636 | mConnectCount = 30;mConnectMax = 30; | 1636 | mConnectCount = 30;mConnectMax = 30; |
1637 | mTimerSocket->start( 1000, true ); | 1637 | mTimerSocket->start( 1000, true ); |
1638 | mSocket->connectToHost( mHost, mPort ); | 1638 | mSocket->connectToHost( mHost, mPort ); |
1639 | } | 1639 | } |
1640 | void KCommandSocket::writeFileToSocket() | 1640 | void KCommandSocket::writeFileToSocket() |
1641 | { | 1641 | { |
1642 | mTimerSocket->stop(); | 1642 | mTimerSocket->stop(); |
1643 | QFile file2( mFileName ); | 1643 | QFile file2( mFileName ); |
1644 | if (!file2.open( IO_ReadOnly ) ) { | 1644 | if (!file2.open( IO_ReadOnly ) ) { |
1645 | mConnectProgress.hide(); | 1645 | mConnectProgress.hide(); |
1646 | mConnectCount = -1; | 1646 | mConnectCount = -1; |
1647 | mRetVal= errorW; | 1647 | mRetVal= errorW; |
1648 | mSocket->close(); | 1648 | mSocket->close(); |
1649 | if ( mSocket->state() == QSocket::Idle ) | 1649 | if ( mSocket->state() == QSocket::Idle ) |
1650 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1650 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1651 | return ; | 1651 | return ; |
1652 | } | 1652 | } |
1653 | mConnectProgress.setTotalSteps ( file2.size() ); | 1653 | mConnectProgress.setTotalSteps ( file2.size() ); |
1654 | mConnectProgress.show(); | 1654 | mConnectProgress.show(); |
1655 | int count = 0; | 1655 | int count = 0; |
1656 | mConnectProgress.setLabelText( i18n("Sending back synced file...") ); | 1656 | mConnectProgress.setLabelText( i18n("Sending back synced file...") ); |
1657 | mConnectProgress.setProgress( count ); | 1657 | mConnectProgress.setProgress( count ); |
1658 | mConnectProgress.blockSignals( true ); | 1658 | mConnectProgress.blockSignals( true ); |
1659 | QTextStream ts2( &file2 ); | 1659 | QTextStream ts2( &file2 ); |
1660 | ts2.setEncoding( QTextStream::Latin1 ); | 1660 | ts2.setEncoding( QTextStream::Latin1 ); |
1661 | QTextStream os2( mSocket ); | 1661 | QTextStream os2( mSocket ); |
1662 | os2.setEncoding( QTextStream::Latin1 ); | 1662 | os2.setEncoding( QTextStream::Latin1 ); |
1663 | os2 << "PUT " << mPassWord << " " << mRemoteResource << "\r\n\r\n";; | 1663 | os2 << "PUT " << mPassWord << " " << mRemoteResource << "\r\n\r\n";; |
1664 | int byteCount = 0; | 1664 | int byteCount = 0; |
1665 | int byteMax = file2.size()/53; | 1665 | int byteMax = file2.size()/53; |
1666 | while ( ! ts2.atEnd() ) { | 1666 | while ( ! ts2.atEnd() ) { |
1667 | qApp->processEvents(); | 1667 | qApp->processEvents(); |
1668 | if ( byteCount > byteMax ) { | 1668 | if ( byteCount > byteMax ) { |
1669 | byteCount = 0; | 1669 | byteCount = 0; |
1670 | mConnectProgress.setProgress( count ); | 1670 | mConnectProgress.setProgress( count ); |
1671 | } | 1671 | } |
1672 | QString temp = ts2.readLine(); | 1672 | QString temp = ts2.readLine(); |
1673 | count += temp.length(); | 1673 | count += temp.length(); |
1674 | byteCount += temp.length(); | 1674 | byteCount += temp.length(); |
1675 | os2 << temp << "\r\n"; | 1675 | os2 << temp << "\r\n"; |
1676 | } | 1676 | } |
1677 | file2.close(); | 1677 | file2.close(); |
1678 | mConnectProgress.hide(); | 1678 | mConnectProgress.hide(); |
1679 | mConnectCount = -1; | 1679 | mConnectCount = -1; |
1680 | os2 << "\r\n"; | 1680 | os2 << "\r\n"; |
1681 | mRetVal= successW; | 1681 | mRetVal= successW; |
1682 | mSocket->close(); | 1682 | mSocket->close(); |
1683 | if ( mSocket->state() == QSocket::Idle ) | 1683 | if ( mSocket->state() == QSocket::Idle ) |
1684 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1684 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1685 | mConnectProgress.blockSignals( false ); | 1685 | mConnectProgress.blockSignals( false ); |
1686 | } | 1686 | } |
1687 | void KCommandSocket::sendStop() | 1687 | void KCommandSocket::sendStop() |
1688 | { | 1688 | { |
1689 | if ( !mSocket ) { | 1689 | if ( !mSocket ) { |
1690 | mSocket = new QSocket( this ); | 1690 | mSocket = new QSocket( this ); |
1691 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1691 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1692 | } | 1692 | } |
1693 | mSocket->connectToHost( mHost, mPort ); | 1693 | mSocket->connectToHost( mHost, mPort ); |
1694 | QTextStream os2( mSocket ); | 1694 | QTextStream os2( mSocket ); |
1695 | os2.setEncoding( QTextStream::Latin1 ); | 1695 | os2.setEncoding( QTextStream::Latin1 ); |
1696 | os2 << "STOP\r\n\r\n"; | 1696 | os2 << "STOP\r\n\r\n"; |
1697 | mSocket->close(); | 1697 | mSocket->close(); |
1698 | if ( mSocket->state() == QSocket::Idle ) | 1698 | if ( mSocket->state() == QSocket::Idle ) |
1699 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1699 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1700 | } | 1700 | } |
1701 | 1701 | ||
1702 | void KCommandSocket::startReadFileFromSocket() | 1702 | void KCommandSocket::startReadFileFromSocket() |
1703 | { | 1703 | { |
1704 | if ( ! mFirst ) | 1704 | if ( ! mFirst ) |
1705 | return; | 1705 | return; |
1706 | mConnectProgress.setLabelText( i18n("Receiving file from remote...") ); | 1706 | mConnectProgress.setLabelText( i18n("Receiving file from remote...") ); |
1707 | mFirst = false; | 1707 | mFirst = false; |
1708 | mFileString = ""; | 1708 | mFileString = ""; |
1709 | mTime.start(); | 1709 | mTime.start(); |
1710 | mFirstLine = true; | 1710 | mFirstLine = true; |
1711 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); | 1711 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); |
1712 | 1712 | ||
1713 | } | 1713 | } |
1714 | void KCommandSocket::readFileFromSocket() | 1714 | void KCommandSocket::readFileFromSocket() |
1715 | { | 1715 | { |
1716 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); | 1716 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); |
1717 | while ( mSocket->canReadLine () ) { | 1717 | while ( mSocket->canReadLine () ) { |
1718 | mTime.restart(); | 1718 | mTime.restart(); |
1719 | QString line = mSocket->readLine (); | 1719 | QString line = mSocket->readLine (); |
1720 | if ( mFirstLine ) { | 1720 | if ( mFirstLine ) { |
1721 | mFirstLine = false; | 1721 | mFirstLine = false; |
1722 | if ( line.left( 6 ) == "ERROR_" ) { | 1722 | if ( line.left( 6 ) == "ERROR_" ) { |
1723 | mTimerSocket->stop(); | 1723 | mTimerSocket->stop(); |