summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-11-28 05:26:47 (UTC)
committer zautrix <zautrix>2005-11-28 05:26:47 (UTC)
commitc09ac6c4c77ee1ed50cd9d86a6798eebdede3991 (patch) (unidiff)
tree6cbd88eadaaaf2f31be90eaf11edceae5d81d89e
parent1267a02fc23575f82247f8bd8449dc70dab62d44 (diff)
downloadkdepimpi-c09ac6c4c77ee1ed50cd9d86a6798eebdede3991.zip
kdepimpi-c09ac6c4c77ee1ed50cd9d86a6798eebdede3991.tar.gz
kdepimpi-c09ac6c4c77ee1ed50cd9d86a6798eebdede3991.tar.bz2
sync
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 28c48fe..4d859ce 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -328,193 +328,192 @@ void KSyncManager::slotSyncMenu( int action )
328 mActiveSyncPort = temp->getRemotePort(); 328 mActiveSyncPort = temp->getRemotePort();
329 mActiveSyncIP = temp->getRemoteIP(); 329 mActiveSyncIP = temp->getRemoteIP();
330 } else { 330 } else {
331 mPassWordPiSync = temp->getRemotePwPWM(); 331 mPassWordPiSync = temp->getRemotePwPWM();
332 mActiveSyncPort = temp->getRemotePortPWM(); 332 mActiveSyncPort = temp->getRemotePortPWM();
333 mActiveSyncIP = temp->getRemoteIPPWM(); 333 mActiveSyncIP = temp->getRemoteIPPWM();
334 } 334 }
335 syncPi(); 335 syncPi();
336 while ( !mPisyncFinished ) { 336 while ( !mPisyncFinished ) {
337 //qDebug("waiting "); 337 //qDebug("waiting ");
338 qApp->processEvents(); 338 qApp->processEvents();
339 } 339 }
340 } else 340 } else
341 syncRemote( temp ); 341 syncRemote( temp );
342 342
343 } 343 }
344 } 344 }
345 delete temp; 345 delete temp;
346 setBlockSave(false); 346 setBlockSave(false);
347} 347}
348 348
349void KSyncManager::enableQuick( bool ask ) 349void KSyncManager::enableQuick( bool ask )
350{ 350{
351 bool autoStart; 351 bool autoStart;
352 bool changed = false; 352 bool changed = false;
353 if ( ask ) { 353 if ( ask ) {
354 QDialog dia ( 0, "input-dialog", true ); 354 QDialog dia ( 0, "input-dialog", true );
355 QLineEdit lab ( &dia ); 355 QLineEdit lab ( &dia );
356 QVBoxLayout lay( &dia ); 356 QVBoxLayout lay( &dia );
357 lab.setText( mPrefs->mPassiveSyncPort ); 357 lab.setText( mPrefs->mPassiveSyncPort );
358 lay.setMargin(7); 358 lay.setMargin(7);
359 lay.setSpacing(7); 359 lay.setSpacing(7);
360 int po = 9197+mTargetApp; 360 int po = 9197+mTargetApp;
361 QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia ); 361 QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia );
362 lay.addWidget( &label); 362 lay.addWidget( &label);
363 lay.addWidget( &lab); 363 lay.addWidget( &lab);
364 364
365 QLineEdit lepw ( &dia ); 365 QLineEdit lepw ( &dia );
366 lepw.setText( mPrefs->mPassiveSyncPw ); 366 lepw.setText( mPrefs->mPassiveSyncPw );
367 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 367 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
368 lay.addWidget( &label2); 368 lay.addWidget( &label2);
369 lay.addWidget( &lepw); 369 lay.addWidget( &lepw);
370 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); 370 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia );
371 lay.addWidget( &autostart); 371 lay.addWidget( &autostart);
372 autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); 372 autostart.setChecked( mPrefs->mPassiveSyncAutoStart );
373#ifdef DESKTOP_VERSION 373#ifdef DESKTOP_VERSION
374#ifdef _WIN32_ 374#ifdef _WIN32_
375 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); 375 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia );
376 syncdesktop.hide();// not implemented! 376 syncdesktop.hide();// not implemented!
377#else 377#else
378 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); 378 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia );
379#endif 379#endif
380 lay.addWidget( &syncdesktop); 380 lay.addWidget( &syncdesktop);
381#else 381#else
382 mPrefs->mPassiveSyncWithDesktop = false; 382 mPrefs->mPassiveSyncWithDesktop = false;
383 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); 383 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia );
384 syncdesktop.hide(); 384 syncdesktop.hide();
385#endif 385#endif
386 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); 386 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop );
387 387
388 QPushButton pb ( "OK", &dia); 388 QPushButton pb ( "OK", &dia);
389 lay.addWidget( &pb ); 389 lay.addWidget( &pb );
390 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 390 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
391 dia.resize( 230,120 ); 391 dia.resize( 230,120 );
392 dia.setCaption( i18n("Enter port for Pi-Sync") ); 392 dia.setCaption( i18n("Enter port for Pi-Sync") );
393 dia.show(); 393 dia.show();
394#ifndef DESKTOP_VERSION 394#ifndef DESKTOP_VERSION
395 int dw = QApplication::desktop()->width(); 395 int dw = QApplication::desktop()->width();
396 int dh = QApplication::desktop()->height(); 396 int dh = QApplication::desktop()->height();
397 dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 ); 397 dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 );
398#endif 398#endif
399 if ( ! dia.exec() ) 399 if ( ! dia.exec() )
400 return; 400 return;
401 dia.hide(); 401 dia.hide();
402 qApp->processEvents(); 402 qApp->processEvents();
403 if ( mPrefs->mPassiveSyncPw != lepw.text() ) { 403 if ( mPrefs->mPassiveSyncPw != lepw.text() ) {
404 changed = true; 404 changed = true;
405 mPrefs->mPassiveSyncPw = lepw.text(); 405 mPrefs->mPassiveSyncPw = lepw.text();
406 } 406 }
407 if ( mPrefs->mPassiveSyncPort != lab.text() ) { 407 if ( mPrefs->mPassiveSyncPort != lab.text() ) {
408 mPrefs->mPassiveSyncPort = lab.text(); 408 mPrefs->mPassiveSyncPort = lab.text();
409 changed = true; 409 changed = true;
410 } 410 }
411 autoStart = autostart.isChecked(); 411 autoStart = autostart.isChecked();
412 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { 412 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) {
413 changed = true; 413 changed = true;
414 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); 414 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked();
415 } 415 }
416 } 416 }
417 else 417 else
418 autoStart = mPrefs->mPassiveSyncAutoStart; 418 autoStart = mPrefs->mPassiveSyncAutoStart;
419 if ( autoStart != mPrefs->mPassiveSyncAutoStart ) 419 if ( autoStart != mPrefs->mPassiveSyncAutoStart )
420 changed = true; 420 changed = true;
421 bool ok; 421 bool ok;
422 mPrefs->mPassiveSyncAutoStart = false; 422 mPrefs->mPassiveSyncAutoStart = false;
423 Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok); 423 Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok);
424 qDebug("%d ", port_t);
425 if ( ! ok || port_t > 65535 ) { 424 if ( ! ok || port_t > 65535 ) {
426 KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error")); 425 KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error"));
427 return; 426 return;
428 } 427 }
429 Q_UINT16 port = port_t; 428 Q_UINT16 port = port_t;
430 //qDebug("port %d ", port); 429 //qDebug("port %d ", port);
431 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 430 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
432 mServerSocket->setFileName( defaultFileName() );//bbb 431 mServerSocket->setFileName( defaultFileName() );//bbb
433 if ( !mServerSocket->ok() ) { 432 if ( !mServerSocket->ok() ) {
434 QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) ); 433 QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) );
435 delete mServerSocket; 434 delete mServerSocket;
436 mServerSocket = 0; 435 mServerSocket = 0;
437 return; 436 return;
438 } 437 }
439 mPrefs->mPassiveSyncAutoStart = autoStart; 438 mPrefs->mPassiveSyncAutoStart = autoStart;
440 if ( changed ) { 439 if ( changed ) {
441 mPrefs->writeConfig(); 440 mPrefs->writeConfig();
442 } 441 }
443 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 442 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
444 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 443 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
445 connect( mServerSocket, SIGNAL ( request_file(const QString &) ),this, SIGNAL ( request_file(const QString &) ) ); 444 connect( mServerSocket, SIGNAL ( request_file(const QString &) ),this, SIGNAL ( request_file(const QString &) ) );
446 connect( mServerSocket, SIGNAL ( file_received( bool ,const QString &) ), this, SIGNAL ( getFile( bool,const QString & ) ) ); 445 connect( mServerSocket, SIGNAL ( file_received( bool ,const QString &) ), this, SIGNAL ( getFile( bool,const QString & ) ) );
447} 446}
448void KSyncManager::displayErrorPort() 447void KSyncManager::displayErrorPort()
449{ 448{
450 KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error")); 449 KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error"));
451} 450}
452void KSyncManager::syncLocalFile() 451void KSyncManager::syncLocalFile()
453{ 452{
454 453
455 QString fn =mPrefs->mLastSyncedLocalFile; 454 QString fn =mPrefs->mLastSyncedLocalFile;
456 QString ext; 455 QString ext;
457 456
458 switch(mTargetApp) 457 switch(mTargetApp)
459 { 458 {
460 case (KAPI): 459 case (KAPI):
461 ext = "(*.vcf)"; 460 ext = "(*.vcf)";
462 break; 461 break;
463 case (KOPI): 462 case (KOPI):
464 ext = "(*.ics/*.vcs)"; 463 ext = "(*.ics/*.vcs)";
465 break; 464 break;
466 case (PWMPI): 465 case (PWMPI):
467 ext = "(*.pwm)"; 466 ext = "(*.pwm)";
468 break; 467 break;
469 default: 468 default:
470 qDebug("KSM::syncLocalFile: invalid apptype selected"); 469 qDebug("KSM::syncLocalFile: invalid apptype selected");
471 break; 470 break;
472 471
473 } 472 }
474 473
475 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 474 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
476 if ( fn == "" ) 475 if ( fn == "" )
477 return; 476 return;
478 if ( syncWithFile( fn, false ) ) { 477 if ( syncWithFile( fn, false ) ) {
479 qDebug("KSM::syncLocalFile() successful "); 478 qDebug("KSM::syncLocalFile() successful ");
480 } 479 }
481 480
482} 481}
483 482
484bool KSyncManager::syncWithFile( QString fn , bool quick ) 483bool KSyncManager::syncWithFile( QString fn , bool quick )
485{ 484{
486 bool ret = false; 485 bool ret = false;
487 QFileInfo info; 486 QFileInfo info;
488 info.setFile( fn ); 487 info.setFile( fn );
489 QString mess; 488 QString mess;
490 if ( !info. exists() ) { 489 if ( !info. exists() ) {
491 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 490 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
492 QMessageBox::warning( mParent, i18n("Warning!"), 491 QMessageBox::warning( mParent, i18n("Warning!"),
493 mess ); 492 mess );
494 return ret; 493 return ret;
495 } 494 }
496 int result = 0; 495 int result = 0;
497 if ( !quick ) { 496 if ( !quick ) {
498 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 497 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
499 result = QMessageBox::warning( mParent, i18n("Warning!"), 498 result = QMessageBox::warning( mParent, i18n("Warning!"),
500 mess, 499 mess,
501 i18n("Sync"), i18n("Cancel"), 0, 500 i18n("Sync"), i18n("Cancel"), 0,
502 0, 1 ); 501 0, 1 );
503 if ( result ) 502 if ( result )
504 return false; 503 return false;
505 } 504 }
506 if ( mAskForPreferences ) 505 if ( mAskForPreferences )
507 if ( !edit_sync_options()) { 506 if ( !edit_sync_options()) {
508 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 507 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
509 return false; 508 return false;
510 } 509 }
511 if ( result == 0 ) { 510 if ( result == 0 ) {
512 //qDebug("Now sycing ... "); 511 //qDebug("Now sycing ... ");
513 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ,mCurrentResourceLocal ) ) 512 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ,mCurrentResourceLocal ) )
514 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); 513 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
515 else 514 else
516 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 515 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
517 if ( ! quick ) 516 if ( ! quick )
518 mPrefs->mLastSyncedLocalFile = fn; 517 mPrefs->mLastSyncedLocalFile = fn;
519 } 518 }
520 return ret; 519 return ret;
@@ -1219,193 +1218,193 @@ void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
1219 return; 1218 return;
1220 1219
1221 } else if ( state == KCommandSocket::errorW ) { 1220 } else if ( state == KCommandSocket::errorW ) {
1222 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); 1221 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
1223 mPisyncFinished = true; 1222 mPisyncFinished = true;
1224 1223
1225 } else if ( state == KCommandSocket::successR ) { 1224 } else if ( state == KCommandSocket::successR ) {
1226 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 1225 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
1227 1226
1228 } else if ( state == KCommandSocket::successW ) { 1227 } else if ( state == KCommandSocket::successW ) {
1229 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); 1228 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") );
1230 mPisyncFinished = true; 1229 mPisyncFinished = true;
1231 } else if ( state == KCommandSocket::quiet ){ 1230 } else if ( state == KCommandSocket::quiet ){
1232 qDebug("KSS: quiet "); 1231 qDebug("KSS: quiet ");
1233 mPisyncFinished = true; 1232 mPisyncFinished = true;
1234 } else { 1233 } else {
1235 qDebug("KSS: Error: unknown state: %d ", state); 1234 qDebug("KSS: Error: unknown state: %d ", state);
1236 mPisyncFinished = true; 1235 mPisyncFinished = true;
1237 } 1236 }
1238 1237
1239 delete s; 1238 delete s;
1240} 1239}
1241 1240
1242void KSyncManager::readFileFromSocket() 1241void KSyncManager::readFileFromSocket()
1243{ 1242{
1244 QString fileName = syncFileName(); 1243 QString fileName = syncFileName();
1245 bool syncOK = true; 1244 bool syncOK = true;
1246 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); 1245 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
1247 if ( ! syncWithFile( fileName , true ) ) { 1246 if ( ! syncWithFile( fileName , true ) ) {
1248 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); 1247 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
1249 syncOK = false; 1248 syncOK = false;
1250 } 1249 }
1251 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote,mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); 1250 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote,mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() );
1252 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1251 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1253 if ( mWriteBackFile && syncOK ) { 1252 if ( mWriteBackFile && syncOK ) {
1254 mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") ); 1253 mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") );
1255 commandSocket->writeFile( fileName ); 1254 commandSocket->writeFile( fileName );
1256 } 1255 }
1257 else { 1256 else {
1258 commandSocket->sendStop(); 1257 commandSocket->sendStop();
1259 if ( syncOK ) 1258 if ( syncOK )
1260 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 1259 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
1261 mPisyncFinished = true; 1260 mPisyncFinished = true;
1262 } 1261 }
1263} 1262}
1264 1263
1265KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 1264KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
1266{ 1265{
1267 mPendingConnect = 0; 1266 mPendingConnect = 0;
1268 mPassWord = pw; 1267 mPassWord = pw;
1269 mSocket = 0; 1268 mSocket = 0;
1270 mSyncActionDialog = 0; 1269 mSyncActionDialog = 0;
1271 blockRC = false; 1270 blockRC = false;
1272 mErrorMessage = 0; 1271 mErrorMessage = 0;
1273} 1272}
1274void KServerSocket::waitForSocketFinish() 1273void KServerSocket::waitForSocketFinish()
1275{ 1274{
1276 if ( mSocket ) { 1275 if ( mSocket ) {
1277 //qDebug("KSS:: waiting for finish operation"); 1276 //qDebug("KSS:: waiting for finish operation");
1278 QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish())); 1277 QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish()));
1279 return; 1278 return;
1280 } 1279 }
1281 mSocket = new QSocket( this ); 1280 mSocket = new QSocket( this );
1282 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 1281 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
1283 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 1282 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
1284 mSocket->setSocket( mPendingConnect ); 1283 mSocket->setSocket( mPendingConnect );
1285 mPendingConnect = 0; 1284 mPendingConnect = 0;
1286} 1285}
1287void KServerSocket::newConnection ( int socket ) 1286void KServerSocket::newConnection ( int socket )
1288{ 1287{
1289 // qDebug("KServerSocket:New connection %d ", socket); 1288 // qDebug("KServerSocket:New connection %d ", socket);
1290 if ( mPendingConnect ) { 1289 if ( mPendingConnect ) {
1291 qDebug("KSS::Error : new Connection"); 1290 qDebug("KSS::Error : new Connection");
1292 return; 1291 return;
1293 } 1292 }
1294 if ( mSocket ) { 1293 if ( mSocket ) {
1295 mPendingConnect = socket; 1294 mPendingConnect = socket;
1296 QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish())); 1295 QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish()));
1297 return; 1296 return;
1298 qDebug("KSS::newConnection Socket deleted! "); 1297 qDebug("KSS::newConnection Socket deleted! ");
1299 delete mSocket; 1298 delete mSocket;
1300 mSocket = 0; 1299 mSocket = 0;
1301 } 1300 }
1302 mPendingConnect = 0; 1301 mPendingConnect = 0;
1303 mSocket = new QSocket( this ); 1302 mSocket = new QSocket( this );
1304 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 1303 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
1305 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 1304 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
1306 mSocket->setSocket( socket ); 1305 mSocket->setSocket( socket );
1307} 1306}
1308 1307
1309void KServerSocket::discardClient() 1308void KServerSocket::discardClient()
1310{ 1309{
1311 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1310 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1312} 1311}
1313void KServerSocket::deleteSocket() 1312void KServerSocket::deleteSocket()
1314{ 1313{
1315 qDebug("KSS::deleteSocket"); 1314 //qDebug("KSS::deleteSocket");
1316 if ( mSocket ) { 1315 if ( mSocket ) {
1317 delete mSocket; 1316 delete mSocket;
1318 mSocket = 0; 1317 mSocket = 0;
1319 } 1318 }
1320 if ( mErrorMessage ) 1319 if ( mErrorMessage )
1321 QTimer::singleShot( 10, this , SLOT ( displayErrorMessage())); 1320 QTimer::singleShot( 10, this , SLOT ( displayErrorMessage()));
1322} 1321}
1323void KServerSocket::readClient() 1322void KServerSocket::readClient()
1324{ 1323{
1325 if ( blockRC ) 1324 if ( blockRC )
1326 return; 1325 return;
1327 if ( mSocket == 0 ) { 1326 if ( mSocket == 0 ) {
1328 qDebug("ERROR::KSS::readClient(): mSocket == 0 "); 1327 qDebug("ERROR::KSS::readClient(): mSocket == 0 ");
1329 return; 1328 return;
1330 } 1329 }
1331 if ( mErrorMessage ) { 1330 if ( mErrorMessage ) {
1332 mErrorMessage = 999; 1331 mErrorMessage = 999;
1333 error_connect("ERROR_ED\r\n\r\n"); 1332 error_connect("ERROR_ED\r\n\r\n");
1334 return; 1333 return;
1335 } 1334 }
1336 mResource = ""; 1335 mResource = "";
1337 mErrorMessage = 0; 1336 mErrorMessage = 0;
1338 //qDebug("KServerSocket::readClient()"); 1337 //qDebug("KServerSocket::readClient()");
1339 if ( mSocket->canReadLine() ) { 1338 if ( mSocket->canReadLine() ) {
1340 QString line = mSocket->readLine(); 1339 QString line = mSocket->readLine();
1341 //qDebug("KServerSocket readline: %s ", line.latin1()); 1340 //qDebug("KServerSocket readline: %s ", line.latin1());
1342 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); 1341 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
1343 if ( tokens[0] == "GET" ) { 1342 if ( tokens[0] == "GET" ) {
1344 if ( tokens[1] == mPassWord ) { 1343 if ( tokens[1] == mPassWord ) {
1345 //emit sendFile( mSocket ); 1344 //emit sendFile( mSocket );
1346 bool ok = false; 1345 bool ok = false;
1347 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); 1346 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok);
1348 if ( ok ) { 1347 if ( ok ) {
1349 KSyncManager::mRequestedSyncEvent = dt; 1348 KSyncManager::mRequestedSyncEvent = dt;
1350 } 1349 }
1351 else 1350 else
1352 KSyncManager::mRequestedSyncEvent = QDateTime(); 1351 KSyncManager::mRequestedSyncEvent = QDateTime();
1353 mResource =tokens[3]; 1352 mResource =tokens[3];
1354 send_file(); 1353 send_file();
1355 } 1354 }
1356 else { 1355 else {
1357 mErrorMessage = 1; 1356 mErrorMessage = 1;
1358 error_connect("ERROR_PW\r\n\r\n"); 1357 error_connect("ERROR_PW\r\n\r\n");
1359 } 1358 }
1360 } 1359 }
1361 if ( tokens[0] == "PUT" ) { 1360 if ( tokens[0] == "PUT" ) {
1362 if ( tokens[1] == mPassWord ) { 1361 if ( tokens[1] == mPassWord ) {
1363 //emit getFile( mSocket ); 1362 //emit getFile( mSocket );
1364 blockRC = true; 1363 blockRC = true;
1365 mResource =tokens[2]; 1364 mResource =tokens[2];
1366 get_file(); 1365 get_file();
1367 } 1366 }
1368 else { 1367 else {
1369 mErrorMessage = 2; 1368 mErrorMessage = 2;
1370 error_connect("ERROR_PW\r\n\r\n"); 1369 error_connect("ERROR_PW\r\n\r\n");
1371 end_connect(); 1370 end_connect();
1372 } 1371 }
1373 } 1372 }
1374 if ( tokens[0] == "STOP" ) { 1373 if ( tokens[0] == "STOP" ) {
1375 //emit endConnect(); 1374 //emit endConnect();
1376 end_connect(); 1375 end_connect();
1377 } 1376 }
1378 } 1377 }
1379} 1378}
1380void KServerSocket::displayErrorMessage() 1379void KServerSocket::displayErrorMessage()
1381{ 1380{
1382 if ( mErrorMessage == 1 ) { 1381 if ( mErrorMessage == 1 ) {
1383 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"), i18n("Pi-Sync Error")); 1382 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"), i18n("Pi-Sync Error"));
1384 mErrorMessage = 0; 1383 mErrorMessage = 0;
1385 } 1384 }
1386 else if ( mErrorMessage == 2 ) { 1385 else if ( mErrorMessage == 2 ) {
1387 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error")); 1386 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error"));
1388 mErrorMessage = 0; 1387 mErrorMessage = 0;
1389 } 1388 }
1390} 1389}
1391void KServerSocket::error_connect( QString errmess ) 1390void KServerSocket::error_connect( QString errmess )
1392{ 1391{
1393 QTextStream os( mSocket ); 1392 QTextStream os( mSocket );
1394 os.setEncoding( QTextStream::Latin1 ); 1393 os.setEncoding( QTextStream::Latin1 );
1395 os << errmess ; 1394 os << errmess ;
1396 mSocket->close(); 1395 mSocket->close();
1397 if ( mSocket->state() == QSocket::Idle ) { 1396 if ( mSocket->state() == QSocket::Idle ) {
1398 QTimer::singleShot( 0, this , SLOT ( discardClient())); 1397 QTimer::singleShot( 0, this , SLOT ( discardClient()));
1399 } 1398 }
1400} 1399}
1401void KServerSocket::end_connect() 1400void KServerSocket::end_connect()
1402{ 1401{
1403 delete mSyncActionDialog; 1402 delete mSyncActionDialog;
1404 mSyncActionDialog = 0; 1403 mSyncActionDialog = 0;
1405} 1404}
1406void KServerSocket::send_file() 1405void KServerSocket::send_file()
1407{ 1406{
1408 //qDebug("MainWindow::sendFile(QSocket* s) "); 1407 //qDebug("MainWindow::sendFile(QSocket* s) ");
1409 if ( mSyncActionDialog ) 1408 if ( mSyncActionDialog )
1410 delete mSyncActionDialog; 1409 delete mSyncActionDialog;
1411 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 1410 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
@@ -1507,193 +1506,193 @@ void KServerSocket::readBackFileFromSocket()
1507 //qDebug("readline: %s ", line.latin1()); 1506 //qDebug("readline: %s ", line.latin1());
1508 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); 1507 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
1509 1508
1510 } 1509 }
1511 if ( piTime.elapsed () < 3000 ) { 1510 if ( piTime.elapsed () < 3000 ) {
1512 // wait for more 1511 // wait for more
1513 //qDebug("waitformore "); 1512 //qDebug("waitformore ");
1514 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); 1513 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
1515 return; 1514 return;
1516 } 1515 }
1517 QString fileName = mFileName; 1516 QString fileName = mFileName;
1518 QFile file ( fileName ); 1517 QFile file ( fileName );
1519 if (!file.open( IO_WriteOnly ) ) { 1518 if (!file.open( IO_WriteOnly ) ) {
1520 delete mSyncActionDialog; 1519 delete mSyncActionDialog;
1521 mSyncActionDialog = 0; 1520 mSyncActionDialog = 0;
1522 qDebug("KSS:Error open read back file "); 1521 qDebug("KSS:Error open read back file ");
1523 piFileString = ""; 1522 piFileString = "";
1524 emit file_received( false, mResource); 1523 emit file_received( false, mResource);
1525 emit file_received( false); 1524 emit file_received( false);
1526 blockRC = false; 1525 blockRC = false;
1527 return ; 1526 return ;
1528 1527
1529 } 1528 }
1530 1529
1531 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1530 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1532 QTextStream ts ( &file ); 1531 QTextStream ts ( &file );
1533 ts.setEncoding( QTextStream::Latin1 ); 1532 ts.setEncoding( QTextStream::Latin1 );
1534 mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); 1533 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
1535 ts << piFileString; 1534 ts << piFileString;
1536 mSocket->close(); 1535 mSocket->close();
1537 if ( mSocket->state() == QSocket::Idle ) 1536 if ( mSocket->state() == QSocket::Idle )
1538 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1537 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1539 file.close(); 1538 file.close();
1540 piFileString = ""; 1539 piFileString = "";
1541 emit file_received( true, mResource ); 1540 emit file_received( true, mResource );
1542 emit file_received( true); 1541 emit file_received( true);
1543 delete mSyncActionDialog; 1542 delete mSyncActionDialog;
1544 mSyncActionDialog = 0; 1543 mSyncActionDialog = 0;
1545 blockRC = false; 1544 blockRC = false;
1546 1545
1547} 1546}
1548 1547
1549KCommandSocket::KCommandSocket ( QString remres, QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name ) 1548KCommandSocket::KCommandSocket ( QString remres, QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name )
1550{ 1549{
1551 mRemoteResource = remres; 1550 mRemoteResource = remres;
1552 if ( mRemoteResource.isEmpty() ) 1551 if ( mRemoteResource.isEmpty() )
1553 mRemoteResource = "ALL"; 1552 mRemoteResource = "ALL";
1554 else 1553 else
1555 mRemoteResource.replace (QRegExp (" "),"_" ); 1554 mRemoteResource.replace (QRegExp (" "),"_" );
1556 mPassWord = password; 1555 mPassWord = password;
1557 mSocket = 0; 1556 mSocket = 0;
1558 mFirst = false; 1557 mFirst = false;
1559 mFirstLine = true; 1558 mFirstLine = true;
1560 mPort = port; 1559 mPort = port;
1561 mHost = host; 1560 mHost = host;
1562 tlw = cap; 1561 tlw = cap;
1563 mRetVal = quiet; 1562 mRetVal = quiet;
1564 mTimerSocket = new QTimer ( this ); 1563 mTimerSocket = new QTimer ( this );
1565 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( updateConnectDialog() ) ); 1564 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( updateConnectDialog() ) );
1566 mConnectProgress.setCaption( i18n("Pi-Sync") ); 1565 mConnectProgress.setCaption( i18n("Pi-Sync") );
1567 connect( &mConnectProgress, SIGNAL ( cancelled () ), this, SLOT ( deleteSocket() ) ); 1566 connect( &mConnectProgress, SIGNAL ( cancelled () ), this, SLOT ( deleteSocket() ) );
1568 mConnectCount = -1; 1567 mConnectCount = -1;
1569} 1568}
1570void KCommandSocket::sendFileRequest() 1569void KCommandSocket::sendFileRequest()
1571{ 1570{
1572 if ( tlw ) 1571 if ( tlw )
1573 tlw->setCaption( i18n("Connected! Sending request for remote file ...") ); 1572 tlw->setCaption( i18n("Connected! Sending request for remote file ...") );
1574 mConnectProgress.hide(); 1573 mConnectProgress.hide();
1575 mConnectCount = 300;mConnectMax = 300; 1574 mConnectCount = 300;mConnectMax = 300;
1576 mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") ); 1575 mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") );
1577 mConnectProgress.setLabelText( i18n("Waiting for remote file...") ); 1576 mConnectProgress.setLabelText( i18n("Waiting for remote file...") );
1578 mTimerSocket->start( 100, true ); 1577 mTimerSocket->start( 100, true );
1579 QTextStream os( mSocket ); 1578 QTextStream os( mSocket );
1580 os.setEncoding( QTextStream::Latin1 ); 1579 os.setEncoding( QTextStream::Latin1 );
1581 1580
1582 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); 1581 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate );
1583 os << "GET " << mPassWord << curDt << " " << mRemoteResource << "\r\n\r\n"; 1582 os << "GET " << mPassWord << curDt << " " << mRemoteResource << "\r\n\r\n";
1584} 1583}
1585 1584
1586void KCommandSocket::readFile( QString fn ) 1585void KCommandSocket::readFile( QString fn )
1587{ 1586{
1588 if ( !mSocket ) { 1587 if ( !mSocket ) {
1589 mSocket = new QSocket( this ); 1588 mSocket = new QSocket( this );
1590 //qDebug("KCS: read file - new socket"); 1589 //qDebug("KCS: read file - new socket");
1591 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); 1590 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
1592 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1591 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1593 connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() )); 1592 connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() ));
1594 } 1593 }
1595 mFileString = ""; 1594 mFileString = "";
1596 mFileName = fn; 1595 mFileName = fn;
1597 mFirst = true; 1596 mFirst = true;
1598 if ( tlw ) 1597 if ( tlw )
1599 tlw->setCaption( i18n("Trying to connect to remote...") ); 1598 tlw->setCaption( i18n("Trying to connect to remote...") );
1600 mConnectCount = 30;mConnectMax = 30; 1599 mConnectCount = 30;mConnectMax = 30;
1601 mTimerSocket->start( 1000, true ); 1600 mTimerSocket->start( 1000, true );
1602 mSocket->connectToHost( mHost, mPort ); 1601 mSocket->connectToHost( mHost, mPort );
1603 qDebug("KCS: Waiting for connection"); 1602 //qDebug("KCS: Waiting for connection");
1604} 1603}
1605void KCommandSocket::updateConnectDialog() 1604void KCommandSocket::updateConnectDialog()
1606{ 1605{
1607 1606
1608 if ( mConnectCount == mConnectMax ) { 1607 if ( mConnectCount == mConnectMax ) {
1609 //qDebug("MAXX %d", mConnectMax); 1608 //qDebug("MAXX %d", mConnectMax);
1610 mConnectProgress.setTotalSteps ( 30 ); 1609 mConnectProgress.setTotalSteps ( 30 );
1611 mConnectProgress.show(); 1610 mConnectProgress.show();
1612 mConnectProgress.setLabelText( i18n("Trying to connect to remote...") ); 1611 mConnectProgress.setLabelText( i18n("Trying to connect to remote...") );
1613 } 1612 }
1614 //qDebug("updateConnectDialog() %d", mConnectCount); 1613 //qDebug("updateConnectDialog() %d", mConnectCount);
1615 mConnectProgress.raise(); 1614 mConnectProgress.raise();
1616 mConnectProgress.setProgress( (mConnectMax - mConnectCount)%30 ); 1615 mConnectProgress.setProgress( (mConnectMax - mConnectCount)%30 );
1617 --mConnectCount; 1616 --mConnectCount;
1618 if ( mConnectCount > 0 ) 1617 if ( mConnectCount > 0 )
1619 mTimerSocket->start( 1000, true ); 1618 mTimerSocket->start( 1000, true );
1620 else 1619 else
1621 deleteSocket(); 1620 deleteSocket();
1622 1621
1623} 1622}
1624void KCommandSocket::writeFile( QString fileName ) 1623void KCommandSocket::writeFile( QString fileName )
1625{ 1624{
1626 if ( !mSocket ) { 1625 if ( !mSocket ) {
1627 mSocket = new QSocket( this ); 1626 mSocket = new QSocket( this );
1628 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1627 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1629 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); 1628 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
1630 } 1629 }
1631 mFileName = fileName ; 1630 mFileName = fileName ;
1632 mConnectCount = 30;mConnectMax = 30; 1631 mConnectCount = 30;mConnectMax = 30;
1633 mTimerSocket->start( 1000, true ); 1632 mTimerSocket->start( 1000, true );
1634 mSocket->connectToHost( mHost, mPort ); 1633 mSocket->connectToHost( mHost, mPort );
1635} 1634}
1636void KCommandSocket::writeFileToSocket() 1635void KCommandSocket::writeFileToSocket()
1637{ 1636{
1638 mTimerSocket->stop(); 1637 mTimerSocket->stop();
1639 QFile file2( mFileName ); 1638 QFile file2( mFileName );
1640 if (!file2.open( IO_ReadOnly ) ) { 1639 if (!file2.open( IO_ReadOnly ) ) {
1641 mConnectProgress.hide(); 1640 mConnectProgress.hide();
1642 mConnectCount = -1; 1641 mConnectCount = -1;
1643 mRetVal= errorW; 1642 mRetVal= errorW;
1644 mSocket->close(); 1643 mSocket->close();
1645 if ( mSocket->state() == QSocket::Idle ) 1644 if ( mSocket->state() == QSocket::Idle )
1646 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1645 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1647 return ; 1646 return ;
1648 } 1647 }
1649 mConnectProgress.setTotalSteps ( file2.size() ); 1648 mConnectProgress.setTotalSteps ( file2.size() );
1650 mConnectProgress.show(); 1649 mConnectProgress.show();
1651 int count = 0; 1650 int count = 0;
1652 mConnectProgress.setLabelText( i18n("Sending back synced file...") ); 1651 mConnectProgress.setLabelText( i18n("Sending back synced file...") );
1653 mConnectProgress.setProgress( count ); 1652 mConnectProgress.setProgress( count );
1654 mConnectProgress.blockSignals( true ); 1653 mConnectProgress.blockSignals( true );
1655 QTextStream ts2( &file2 ); 1654 QTextStream ts2( &file2 );
1656 ts2.setEncoding( QTextStream::Latin1 ); 1655 ts2.setEncoding( QTextStream::Latin1 );
1657 QTextStream os2( mSocket ); 1656 QTextStream os2( mSocket );
1658 os2.setEncoding( QTextStream::Latin1 ); 1657 os2.setEncoding( QTextStream::Latin1 );
1659 os2 << "PUT " << mPassWord << " " << mRemoteResource << "\r\n\r\n";; 1658 os2 << "PUT " << mPassWord << " " << mRemoteResource << "\r\n\r\n";;
1660 int byteCount = 0; 1659 int byteCount = 0;
1661 int byteMax = file2.size()/53; 1660 int byteMax = file2.size()/53;
1662 while ( ! ts2.atEnd() ) { 1661 while ( ! ts2.atEnd() ) {
1663 qApp->processEvents(); 1662 qApp->processEvents();
1664 if ( byteCount > byteMax ) { 1663 if ( byteCount > byteMax ) {
1665 byteCount = 0; 1664 byteCount = 0;
1666 mConnectProgress.setProgress( count ); 1665 mConnectProgress.setProgress( count );
1667 } 1666 }
1668 QString temp = ts2.readLine(); 1667 QString temp = ts2.readLine();
1669 count += temp.length(); 1668 count += temp.length();
1670 byteCount += temp.length(); 1669 byteCount += temp.length();
1671 os2 << temp << "\r\n"; 1670 os2 << temp << "\r\n";
1672 } 1671 }
1673 file2.close(); 1672 file2.close();
1674 mConnectProgress.hide(); 1673 mConnectProgress.hide();
1675 mConnectCount = -1; 1674 mConnectCount = -1;
1676 os2 << "\r\n"; 1675 os2 << "\r\n";
1677 mRetVal= successW; 1676 mRetVal= successW;
1678 mSocket->close(); 1677 mSocket->close();
1679 if ( mSocket->state() == QSocket::Idle ) 1678 if ( mSocket->state() == QSocket::Idle )
1680 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1679 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1681 mConnectProgress.blockSignals( false ); 1680 mConnectProgress.blockSignals( false );
1682} 1681}
1683void KCommandSocket::sendStop() 1682void KCommandSocket::sendStop()
1684{ 1683{
1685 if ( !mSocket ) { 1684 if ( !mSocket ) {
1686 mSocket = new QSocket( this ); 1685 mSocket = new QSocket( this );
1687 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1686 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1688 } 1687 }
1689 mSocket->connectToHost( mHost, mPort ); 1688 mSocket->connectToHost( mHost, mPort );
1690 QTextStream os2( mSocket ); 1689 QTextStream os2( mSocket );
1691 os2.setEncoding( QTextStream::Latin1 ); 1690 os2.setEncoding( QTextStream::Latin1 );
1692 os2 << "STOP\r\n\r\n"; 1691 os2 << "STOP\r\n\r\n";
1693 mSocket->close(); 1692 mSocket->close();
1694 if ( mSocket->state() == QSocket::Idle ) 1693 if ( mSocket->state() == QSocket::Idle )
1695 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1694 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1696} 1695}
1697 1696
1698void KCommandSocket::startReadFileFromSocket() 1697void KCommandSocket::startReadFileFromSocket()
1699{ 1698{