summaryrefslogtreecommitdiffabout
path: root/libkdepim/ksyncmanager.cpp
Unidiff
Diffstat (limited to 'libkdepim/ksyncmanager.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp97
1 files changed, 50 insertions, 47 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 5708dfc..c844627 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -32,41 +32,44 @@
32#include "ksyncprofile.h" 32#include "ksyncprofile.h"
33#include "ksyncprefsdialog.h" 33#include "ksyncprefsdialog.h"
34#include "kpimprefs.h" 34#include "kpimprefs.h"
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36 36
37#include <qdir.h> 37#include <qdir.h>
38#include <qprogressbar.h> 38#include <q3progressbar.h>
39#include <qpopupmenu.h> 39#include <q3popupmenu.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qradiobutton.h> 41#include <qradiobutton.h>
42#include <qbuttongroup.h> 42#include <q3buttongroup.h>
43#include <qtimer.h> 43#include <qtimer.h>
44#include <qmessagebox.h> 44#include <qmessagebox.h>
45#include <qapplication.h> 45#include <qapplication.h>
46#include <qlineedit.h> 46#include <qlineedit.h>
47#include <qdialog.h> 47#include <qdialog.h>
48#include <qlayout.h> 48#include <qlayout.h>
49#include <qtextcodec.h> 49#include <qtextcodec.h>
50#include <qlabel.h> 50#include <qlabel.h>
51#include <qcheckbox.h> 51#include <qcheckbox.h>
52#include <qapplication.h> 52#include <qapplication.h>
53#include <QDesktopWidget>
54//Added by qt3to4:
55#include <Q3VBoxLayout>
53 56
54#include <klocale.h> 57#include <klocale.h>
55#include <kglobal.h> 58#include <kglobal.h>
56#include <kconfig.h> 59#include <kconfig.h>
57#include <kfiledialog.h> 60#include <kfiledialog.h>
58 61
59QDateTime KSyncManager::mRequestedSyncEvent; 62QDateTime KSyncManager::mRequestedSyncEvent;
60 63
61 64
62KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) 65KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, Q3PopupMenu* syncmenu)
63 : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) 66 : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu)
64{ 67{
65 mServerSocket = 0; 68 mServerSocket = 0;
66 bar = new QProgressBar ( 1, 0 ); 69 bar = new Q3ProgressBar ( 1, 0 );
67 bar->setCaption (""); 70 bar->setCaption ("");
68 mWriteBackInPast = 2; 71 mWriteBackInPast = 2;
69 72
70 73
71} 74}
72 75
@@ -86,13 +89,13 @@ void KSyncManager::fillSyncMenu()
86{ 89{
87 if ( mSyncMenu->count() ) 90 if ( mSyncMenu->count() )
88 mSyncMenu->clear(); 91 mSyncMenu->clear();
89 92
90 mSyncMenu->insertItem( i18n("Configure..."), 0 ); 93 mSyncMenu->insertItem( i18n("Configure..."), 0 );
91 mSyncMenu->insertSeparator(); 94 mSyncMenu->insertSeparator();
92 QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); 95 Q3PopupMenu *clearMenu = new Q3PopupMenu ( mSyncMenu );
93 mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); 96 mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 );
94 clearMenu->insertItem( i18n("For all profiles"), 1 ); 97 clearMenu->insertItem( i18n("For all profiles"), 1 );
95 clearMenu->insertSeparator(); 98 clearMenu->insertSeparator();
96 connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); 99 connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) );
97 mSyncMenu->insertSeparator(); 100 mSyncMenu->insertSeparator();
98 if ( mServerSocket == 0 ) { 101 if ( mServerSocket == 0 ) {
@@ -352,13 +355,13 @@ void KSyncManager::enableQuick( bool ask )
352{ 355{
353 bool autoStart; 356 bool autoStart;
354 bool changed = false; 357 bool changed = false;
355 if ( ask ) { 358 if ( ask ) {
356 QDialog dia ( 0, "input-dialog", true ); 359 QDialog dia ( 0, "input-dialog", true );
357 QLineEdit lab ( &dia ); 360 QLineEdit lab ( &dia );
358 QVBoxLayout lay( &dia ); 361 Q3VBoxLayout lay( &dia );
359 lab.setText( mPrefs->mPassiveSyncPort ); 362 lab.setText( mPrefs->mPassiveSyncPort );
360 lay.setMargin(7); 363 lay.setMargin(7);
361 lay.setSpacing(7); 364 lay.setSpacing(7);
362 int po = 9197+mTargetApp; 365 int po = 9197+mTargetApp;
363 QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia ); 366 QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia );
364 lay.addWidget( &label); 367 lay.addWidget( &label);
@@ -801,13 +804,13 @@ void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
801 return; 804 return;
802} 805}
803bool KSyncManager::edit_pisync_options() 806bool KSyncManager::edit_pisync_options()
804{ 807{
805 QDialog dia( mParent, "dia", true ); 808 QDialog dia( mParent, "dia", true );
806 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); 809 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice );
807 QVBoxLayout lay ( &dia ); 810 Q3VBoxLayout lay ( &dia );
808 lay.setSpacing( 5 ); 811 lay.setSpacing( 5 );
809 lay.setMargin( 3 ); 812 lay.setMargin( 3 );
810 QLabel lab1 ( i18n("Password for remote access:"), &dia); 813 QLabel lab1 ( i18n("Password for remote access:"), &dia);
811 lay.addWidget( &lab1 ); 814 lay.addWidget( &lab1 );
812 QLineEdit le1 (&dia ); 815 QLineEdit le1 (&dia );
813 lay.addWidget( &le1 ); 816 lay.addWidget( &le1 );
@@ -835,14 +838,14 @@ bool KSyncManager::edit_pisync_options()
835} 838}
836bool KSyncManager::edit_sync_options() 839bool KSyncManager::edit_sync_options()
837{ 840{
838 841
839 QDialog dia( mParent, "dia", true ); 842 QDialog dia( mParent, "dia", true );
840 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 843 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
841 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 844 Q3ButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
842 QVBoxLayout lay ( &dia ); 845 Q3VBoxLayout lay ( &dia );
843 lay.setSpacing( 2 ); 846 lay.setSpacing( 2 );
844 lay.setMargin( 3 ); 847 lay.setMargin( 3 );
845 lay.addWidget(&gr); 848 lay.addWidget(&gr);
846 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 849 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
847 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 850 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
848 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 851 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
@@ -888,13 +891,13 @@ bool KSyncManager::edit_sync_options()
888QString KSyncManager::getPassword( ) 891QString KSyncManager::getPassword( )
889{ 892{
890 QString retfile = ""; 893 QString retfile = "";
891 QDialog dia ( mParent, "input-dialog", true ); 894 QDialog dia ( mParent, "input-dialog", true );
892 QLineEdit lab ( &dia ); 895 QLineEdit lab ( &dia );
893 lab.setEchoMode( QLineEdit::Password ); 896 lab.setEchoMode( QLineEdit::Password );
894 QVBoxLayout lay( &dia ); 897 Q3VBoxLayout lay( &dia );
895 lay.setMargin(7); 898 lay.setMargin(7);
896 lay.setSpacing(7); 899 lay.setSpacing(7);
897 lay.addWidget( &lab); 900 lay.addWidget( &lab);
898 dia.setFixedSize( 230,50 ); 901 dia.setFixedSize( 230,50 );
899 dia.setCaption( i18n("Enter password") ); 902 dia.setCaption( i18n("Enter password") );
900 QPushButton pb ( "OK", &dia); 903 QPushButton pb ( "OK", &dia);
@@ -1331,13 +1334,13 @@ void KSyncManager::readFileFromSocket()
1331 if ( syncOK ) 1334 if ( syncOK )
1332 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 1335 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
1333 mPisyncFinished = true; 1336 mPisyncFinished = true;
1334 } 1337 }
1335} 1338}
1336 1339
1337KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 1340KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : Q3ServerSocket( port, backlog, parent, name )
1338{ 1341{
1339 mPendingConnect = 0; 1342 mPendingConnect = 0;
1340 mPassWord = pw; 1343 mPassWord = pw;
1341 mSocket = 0; 1344 mSocket = 0;
1342 mSyncActionDialog = 0; 1345 mSyncActionDialog = 0;
1343 blockRC = false; 1346 blockRC = false;
@@ -1347,13 +1350,13 @@ void KServerSocket::waitForSocketFinish()
1347{ 1350{
1348 if ( mSocket ) { 1351 if ( mSocket ) {
1349 //qDebug("KSS:: waiting for finish operation"); 1352 //qDebug("KSS:: waiting for finish operation");
1350 QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish())); 1353 QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish()));
1351 return; 1354 return;
1352 } 1355 }
1353 mSocket = new QSocket( this ); 1356 mSocket = new Q3Socket( this );
1354 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 1357 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
1355 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 1358 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
1356 mSocket->setSocket( mPendingConnect ); 1359 mSocket->setSocket( mPendingConnect );
1357 mPendingConnect = 0; 1360 mPendingConnect = 0;
1358} 1361}
1359void KServerSocket::newConnection ( int socket ) 1362void KServerSocket::newConnection ( int socket )
@@ -1369,13 +1372,13 @@ void KServerSocket::newConnection ( int socket )
1369 return; 1372 return;
1370 qDebug("KSS::newConnection Socket deleted! "); 1373 qDebug("KSS::newConnection Socket deleted! ");
1371 delete mSocket; 1374 delete mSocket;
1372 mSocket = 0; 1375 mSocket = 0;
1373 } 1376 }
1374 mPendingConnect = 0; 1377 mPendingConnect = 0;
1375 mSocket = new QSocket( this ); 1378 mSocket = new Q3Socket( this );
1376 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 1379 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
1377 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 1380 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
1378 mSocket->setSocket( socket ); 1381 mSocket->setSocket( socket );
1379} 1382}
1380 1383
1381void KServerSocket::discardClient() 1384void KServerSocket::discardClient()
@@ -1459,17 +1462,17 @@ void KServerSocket::displayErrorMessage()
1459 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error")); 1462 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error"));
1460 mErrorMessage = 0; 1463 mErrorMessage = 0;
1461 } 1464 }
1462} 1465}
1463void KServerSocket::error_connect( QString errmess ) 1466void KServerSocket::error_connect( QString errmess )
1464{ 1467{
1465 QTextStream os( mSocket ); 1468 Q3TextStream os( mSocket );
1466 os.setEncoding( QTextStream::Latin1 ); 1469 os.setEncoding( Q3TextStream::Latin1 );
1467 os << errmess ; 1470 os << errmess ;
1468 mSocket->close(); 1471 mSocket->close();
1469 if ( mSocket->state() == QSocket::Idle ) { 1472 if ( mSocket->state() == Q3Socket::Idle ) {
1470 QTimer::singleShot( 0, this , SLOT ( discardClient())); 1473 QTimer::singleShot( 0, this , SLOT ( discardClient()));
1471 } 1474 }
1472} 1475}
1473void KServerSocket::end_connect() 1476void KServerSocket::end_connect()
1474{ 1477{
1475 delete mSyncActionDialog; 1478 delete mSyncActionDialog;
@@ -1481,13 +1484,13 @@ void KServerSocket::send_file()
1481 if ( mSyncActionDialog ) 1484 if ( mSyncActionDialog )
1482 delete mSyncActionDialog; 1485 delete mSyncActionDialog;
1483 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 1486 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
1484 mSyncActionDialog->setCaption(i18n("Received sync request")); 1487 mSyncActionDialog->setCaption(i18n("Received sync request"));
1485 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); 1488 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
1486 label->setAlignment ( Qt::AlignHCenter ); 1489 label->setAlignment ( Qt::AlignHCenter );
1487 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 1490 Q3VBoxLayout* lay = new Q3VBoxLayout( mSyncActionDialog );
1488 lay->addWidget( label); 1491 lay->addWidget( label);
1489 lay->setMargin(7); 1492 lay->setMargin(7);
1490 lay->setSpacing(7); 1493 lay->setSpacing(7);
1491 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1494 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1492 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); 1495 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent );
1493 //secs = 333; 1496 //secs = 333;
@@ -1533,33 +1536,33 @@ void KServerSocket::send_file()
1533 mSyncActionDialog->raise(); 1536 mSyncActionDialog->raise();
1534 emit request_file(mResource); 1537 emit request_file(mResource);
1535 //emit request_file(); 1538 //emit request_file();
1536 qApp->processEvents(); 1539 qApp->processEvents();
1537 QString fileName = mFileName; 1540 QString fileName = mFileName;
1538 QFile file( fileName ); 1541 QFile file( fileName );
1539 if (!file.open( IO_ReadOnly ) ) { 1542 if (!file.open( QIODevice::ReadOnly ) ) {
1540 mErrorMessage = 0; 1543 mErrorMessage = 0;
1541 end_connect(); 1544 end_connect();
1542 error_connect("ERROR_FI\r\n\r\n"); 1545 error_connect("ERROR_FI\r\n\r\n");
1543 return ; 1546 return ;
1544 } 1547 }
1545 mSyncActionDialog->setCaption( i18n("Sending file...") ); 1548 mSyncActionDialog->setCaption( i18n("Sending file...") );
1546 QTextStream ts( &file ); 1549 Q3TextStream ts( &file );
1547 ts.setEncoding( QTextStream::Latin1 ); 1550 ts.setEncoding( Q3TextStream::Latin1 );
1548 1551
1549 QTextStream os( mSocket ); 1552 Q3TextStream os( mSocket );
1550 os.setEncoding( QTextStream::Latin1 ); 1553 os.setEncoding( Q3TextStream::Latin1 );
1551 while ( ! ts.atEnd() ) { 1554 while ( ! ts.atEnd() ) {
1552 os << ts.readLine() << "\r\n"; 1555 os << ts.readLine() << "\r\n";
1553 } 1556 }
1554 os << "\r\n"; 1557 os << "\r\n";
1555 //os << ts.read(); 1558 //os << ts.read();
1556 file.close(); 1559 file.close();
1557 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); 1560 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
1558 mSocket->close(); 1561 mSocket->close();
1559 if ( mSocket->state() == QSocket::Idle ) 1562 if ( mSocket->state() == Q3Socket::Idle )
1560 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1563 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1561} 1564}
1562void KServerSocket::get_file() 1565void KServerSocket::get_file()
1563{ 1566{
1564 mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); 1567 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
1565 1568
@@ -1585,31 +1588,31 @@ void KServerSocket::readBackFileFromSocket()
1585 //qDebug("waitformore "); 1588 //qDebug("waitformore ");
1586 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); 1589 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
1587 return; 1590 return;
1588 } 1591 }
1589 QString fileName = mFileName; 1592 QString fileName = mFileName;
1590 QFile file ( fileName ); 1593 QFile file ( fileName );
1591 if (!file.open( IO_WriteOnly ) ) { 1594 if (!file.open( QIODevice::WriteOnly ) ) {
1592 delete mSyncActionDialog; 1595 delete mSyncActionDialog;
1593 mSyncActionDialog = 0; 1596 mSyncActionDialog = 0;
1594 qDebug("KSS:Error open read back file "); 1597 qDebug("KSS:Error open read back file ");
1595 piFileString = ""; 1598 piFileString = "";
1596 emit file_received( false, mResource); 1599 emit file_received( false, mResource);
1597 emit file_received( false); 1600 emit file_received( false);
1598 blockRC = false; 1601 blockRC = false;
1599 return ; 1602 return ;
1600 1603
1601 } 1604 }
1602 1605
1603 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1606 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1604 QTextStream ts ( &file ); 1607 Q3TextStream ts ( &file );
1605 ts.setEncoding( QTextStream::Latin1 ); 1608 ts.setEncoding( Q3TextStream::Latin1 );
1606 mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); 1609 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
1607 ts << piFileString; 1610 ts << piFileString;
1608 mSocket->close(); 1611 mSocket->close();
1609 if ( mSocket->state() == QSocket::Idle ) 1612 if ( mSocket->state() == Q3Socket::Idle )
1610 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1613 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1611 file.close(); 1614 file.close();
1612 piFileString = ""; 1615 piFileString = "";
1613 emit file_received( true, mResource ); 1616 emit file_received( true, mResource );
1614 emit file_received( true); 1617 emit file_received( true);
1615 delete mSyncActionDialog; 1618 delete mSyncActionDialog;
@@ -1645,23 +1648,23 @@ void KCommandSocket::sendFileRequest()
1645 tlw->setCaption( i18n("Connected! Sending request for remote file ...") ); 1648 tlw->setCaption( i18n("Connected! Sending request for remote file ...") );
1646 mConnectProgress.hide(); 1649 mConnectProgress.hide();
1647 mConnectCount = 300;mConnectMax = 300; 1650 mConnectCount = 300;mConnectMax = 300;
1648 mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") ); 1651 mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") );
1649 mConnectProgress.setLabelText( i18n("Waiting for remote file...") ); 1652 mConnectProgress.setLabelText( i18n("Waiting for remote file...") );
1650 mTimerSocket->start( 100, true ); 1653 mTimerSocket->start( 100, true );
1651 QTextStream os( mSocket ); 1654 Q3TextStream os( mSocket );
1652 os.setEncoding( QTextStream::Latin1 ); 1655 os.setEncoding( Q3TextStream::Latin1 );
1653 1656
1654 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); 1657 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate );
1655 os << "GET " << mPassWord << curDt << " " << mRemoteResource << "\r\n\r\n"; 1658 os << "GET " << mPassWord << curDt << " " << mRemoteResource << "\r\n\r\n";
1656} 1659}
1657 1660
1658void KCommandSocket::readFile( QString fn ) 1661void KCommandSocket::readFile( QString fn )
1659{ 1662{
1660 if ( !mSocket ) { 1663 if ( !mSocket ) {
1661 mSocket = new QSocket( this ); 1664 mSocket = new Q3Socket( this );
1662 //qDebug("KCS: read file - new socket"); 1665 //qDebug("KCS: read file - new socket");
1663 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); 1666 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
1664 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1667 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1665 connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() )); 1668 connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() ));
1666 } 1669 }
1667 mFileString = ""; 1670 mFileString = "";
@@ -1693,44 +1696,44 @@ void KCommandSocket::updateConnectDialog()
1693 deleteSocket(); 1696 deleteSocket();
1694 1697
1695} 1698}
1696void KCommandSocket::writeFile( QString fileName ) 1699void KCommandSocket::writeFile( QString fileName )
1697{ 1700{
1698 if ( !mSocket ) { 1701 if ( !mSocket ) {
1699 mSocket = new QSocket( this ); 1702 mSocket = new Q3Socket( this );
1700 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1703 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1701 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); 1704 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
1702 } 1705 }
1703 mFileName = fileName ; 1706 mFileName = fileName ;
1704 mConnectCount = 30;mConnectMax = 30; 1707 mConnectCount = 30;mConnectMax = 30;
1705 mTimerSocket->start( 1000, true ); 1708 mTimerSocket->start( 1000, true );
1706 mSocket->connectToHost( mHost, mPort ); 1709 mSocket->connectToHost( mHost, mPort );
1707} 1710}
1708void KCommandSocket::writeFileToSocket() 1711void KCommandSocket::writeFileToSocket()
1709{ 1712{
1710 mTimerSocket->stop(); 1713 mTimerSocket->stop();
1711 QFile file2( mFileName ); 1714 QFile file2( mFileName );
1712 if (!file2.open( IO_ReadOnly ) ) { 1715 if (!file2.open( QIODevice::ReadOnly ) ) {
1713 mConnectProgress.hide(); 1716 mConnectProgress.hide();
1714 mConnectCount = -1; 1717 mConnectCount = -1;
1715 mRetVal= errorW; 1718 mRetVal= errorW;
1716 mSocket->close(); 1719 mSocket->close();
1717 if ( mSocket->state() == QSocket::Idle ) 1720 if ( mSocket->state() == Q3Socket::Idle )
1718 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1721 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1719 return ; 1722 return ;
1720 } 1723 }
1721 mConnectProgress.setTotalSteps ( file2.size() ); 1724 mConnectProgress.setTotalSteps ( file2.size() );
1722 mConnectProgress.show(); 1725 mConnectProgress.show();
1723 int count = 0; 1726 int count = 0;
1724 mConnectProgress.setLabelText( i18n("Sending back synced file...") ); 1727 mConnectProgress.setLabelText( i18n("Sending back synced file...") );
1725 mConnectProgress.setProgress( count ); 1728 mConnectProgress.setProgress( count );
1726 mConnectProgress.blockSignals( true ); 1729 mConnectProgress.blockSignals( true );
1727 QTextStream ts2( &file2 ); 1730 Q3TextStream ts2( &file2 );
1728 ts2.setEncoding( QTextStream::Latin1 ); 1731 ts2.setEncoding( Q3TextStream::Latin1 );
1729 QTextStream os2( mSocket ); 1732 Q3TextStream os2( mSocket );
1730 os2.setEncoding( QTextStream::Latin1 ); 1733 os2.setEncoding( Q3TextStream::Latin1 );
1731 os2 << "PUT " << mPassWord << " " << mRemoteResource << "\r\n\r\n";; 1734 os2 << "PUT " << mPassWord << " " << mRemoteResource << "\r\n\r\n";;
1732 int byteCount = 0; 1735 int byteCount = 0;
1733 int byteMax = file2.size()/53; 1736 int byteMax = file2.size()/53;
1734 while ( ! ts2.atEnd() ) { 1737 while ( ! ts2.atEnd() ) {
1735 qApp->processEvents(); 1738 qApp->processEvents();
1736 if ( byteCount > byteMax ) { 1739 if ( byteCount > byteMax ) {
@@ -1745,28 +1748,28 @@ void KCommandSocket::writeFileToSocket()
1745 file2.close(); 1748 file2.close();
1746 mConnectProgress.hide(); 1749 mConnectProgress.hide();
1747 mConnectCount = -1; 1750 mConnectCount = -1;
1748 os2 << "\r\n"; 1751 os2 << "\r\n";
1749 mRetVal= successW; 1752 mRetVal= successW;
1750 mSocket->close(); 1753 mSocket->close();
1751 if ( mSocket->state() == QSocket::Idle ) 1754 if ( mSocket->state() == Q3Socket::Idle )
1752 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1755 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1753 mConnectProgress.blockSignals( false ); 1756 mConnectProgress.blockSignals( false );
1754} 1757}
1755void KCommandSocket::sendStop() 1758void KCommandSocket::sendStop()
1756{ 1759{
1757 if ( !mSocket ) { 1760 if ( !mSocket ) {
1758 mSocket = new QSocket( this ); 1761 mSocket = new Q3Socket( this );
1759 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1762 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1760 } 1763 }
1761 mSocket->connectToHost( mHost, mPort ); 1764 mSocket->connectToHost( mHost, mPort );
1762 QTextStream os2( mSocket ); 1765 Q3TextStream os2( mSocket );
1763 os2.setEncoding( QTextStream::Latin1 ); 1766 os2.setEncoding( Q3TextStream::Latin1 );
1764 os2 << "STOP\r\n\r\n"; 1767 os2 << "STOP\r\n\r\n";
1765 mSocket->close(); 1768 mSocket->close();
1766 if ( mSocket->state() == QSocket::Idle ) 1769 if ( mSocket->state() == Q3Socket::Idle )
1767 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1770 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1768} 1771}
1769 1772
1770void KCommandSocket::startReadFileFromSocket() 1773void KCommandSocket::startReadFileFromSocket()
1771{ 1774{
1772 if ( ! mFirst ) 1775 if ( ! mFirst )
@@ -1826,31 +1829,31 @@ void KCommandSocket::readFileFromSocket()
1826 } 1829 }
1827 mTimerSocket->stop(); 1830 mTimerSocket->stop();
1828 mConnectCount = -1; 1831 mConnectCount = -1;
1829 mConnectProgress.hide(); 1832 mConnectProgress.hide();
1830 QString fileName = mFileName; 1833 QString fileName = mFileName;
1831 QFile file ( fileName ); 1834 QFile file ( fileName );
1832 if (!file.open( IO_WriteOnly ) ) { 1835 if (!file.open( QIODevice::WriteOnly ) ) {
1833 mFileString = ""; 1836 mFileString = "";
1834 mRetVal = errorR; 1837 mRetVal = errorR;
1835 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); 1838 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() );
1836 deleteSocket(); 1839 deleteSocket();
1837 return ; 1840 return ;
1838 1841
1839 } 1842 }
1840 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1843 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1841 QTextStream ts ( &file ); 1844 Q3TextStream ts ( &file );
1842 ts.setEncoding( QTextStream::Latin1 ); 1845 ts.setEncoding( Q3TextStream::Latin1 );
1843 ts << mFileString; 1846 ts << mFileString;
1844 file.close(); 1847 file.close();
1845 mFileString = ""; 1848 mFileString = "";
1846 mRetVal = successR; 1849 mRetVal = successR;
1847 mSocket->close(); 1850 mSocket->close();
1848 // if state is not idle, deleteSocket(); is called via 1851 // if state is not idle, deleteSocket(); is called via
1849 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1852 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1850 if ( mSocket->state() == QSocket::Idle ) 1853 if ( mSocket->state() == Q3Socket::Idle )
1851 deleteSocket(); 1854 deleteSocket();
1852} 1855}
1853 1856
1854void KCommandSocket::deleteSocket() 1857void KCommandSocket::deleteSocket()
1855{ 1858{
1856 //qDebug("KCommandSocket::deleteSocket() "); 1859 //qDebug("KCommandSocket::deleteSocket() ");