summaryrefslogtreecommitdiffabout
path: root/libkdepim/ksyncmanager.cpp
Unidiff
Diffstat (limited to 'libkdepim/ksyncmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp2
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
@@ -1371,193 +1371,193 @@ void KServerSocket::readClient()
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}
1384void KServerSocket::displayErrorMessage() 1384void 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}
1395void KServerSocket::error_connect( QString errmess ) 1395void 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}
1405void KServerSocket::end_connect() 1405void KServerSocket::end_connect()
1406{ 1406{
1407 delete mSyncActionDialog; 1407 delete mSyncActionDialog;
1408 mSyncActionDialog = 0; 1408 mSyncActionDialog = 0;
1409} 1409}
1410void KServerSocket::send_file() 1410void 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}
1494void KServerSocket::get_file() 1494void 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
1504void KServerSocket::readBackFileFromSocket() 1504void 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
1553KCommandSocket::KCommandSocket ( QString remres, QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name ) 1553KCommandSocket::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;