-rw-r--r-- | libkdepim/ksyncmanager.cpp | 97 |
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 @@ -30,45 +30,48 @@ #include "ksyncprofile.h" #include "ksyncprefsdialog.h" #include "kpimprefs.h" #include <kmessagebox.h> #include <qdir.h> -#include <qprogressbar.h> -#include <qpopupmenu.h> +#include <q3progressbar.h> +#include <q3popupmenu.h> #include <qpushbutton.h> #include <qradiobutton.h> -#include <qbuttongroup.h> +#include <q3buttongroup.h> #include <qtimer.h> #include <qmessagebox.h> #include <qapplication.h> #include <qlineedit.h> #include <qdialog.h> #include <qlayout.h> #include <qtextcodec.h> #include <qlabel.h> #include <qcheckbox.h> #include <qapplication.h> +#include <QDesktopWidget> +//Added by qt3to4: +#include <Q3VBoxLayout> #include <klocale.h> #include <kglobal.h> #include <kconfig.h> #include <kfiledialog.h> QDateTime KSyncManager::mRequestedSyncEvent; -KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) +KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, Q3PopupMenu* syncmenu) : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) { mServerSocket = 0; - bar = new QProgressBar ( 1, 0 ); + bar = new Q3ProgressBar ( 1, 0 ); bar->setCaption (""); mWriteBackInPast = 2; } KSyncManager::~KSyncManager() { @@ -84,17 +87,17 @@ void KSyncManager::setDefaultFileName( QString s) void KSyncManager::fillSyncMenu() { if ( mSyncMenu->count() ) mSyncMenu->clear(); mSyncMenu->insertItem( i18n("Configure..."), 0 ); mSyncMenu->insertSeparator(); - QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); + Q3PopupMenu *clearMenu = new Q3PopupMenu ( mSyncMenu ); mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); clearMenu->insertItem( i18n("For all profiles"), 1 ); clearMenu->insertSeparator(); connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); mSyncMenu->insertSeparator(); if ( mServerSocket == 0 ) { mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); } else { @@ -350,17 +353,17 @@ void KSyncManager::slotSyncMenu( int action ) void KSyncManager::enableQuick( bool ask ) { bool autoStart; bool changed = false; if ( ask ) { QDialog dia ( 0, "input-dialog", true ); QLineEdit lab ( &dia ); - QVBoxLayout lay( &dia ); + Q3VBoxLayout lay( &dia ); lab.setText( mPrefs->mPassiveSyncPort ); lay.setMargin(7); lay.setSpacing(7); int po = 9197+mTargetApp; QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia ); lay.addWidget( &label); lay.addWidget( &lab); @@ -799,17 +802,17 @@ void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) } } return; } bool KSyncManager::edit_pisync_options() { QDialog dia( mParent, "dia", true ); dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); - QVBoxLayout lay ( &dia ); + Q3VBoxLayout lay ( &dia ); lay.setSpacing( 5 ); lay.setMargin( 3 ); QLabel lab1 ( i18n("Password for remote access:"), &dia); lay.addWidget( &lab1 ); QLineEdit le1 (&dia ); lay.addWidget( &le1 ); QLabel lab2 ( i18n("Remote IP address:"), &dia); lay.addWidget( &lab2 ); @@ -833,18 +836,18 @@ bool KSyncManager::edit_pisync_options() } return false; } bool KSyncManager::edit_sync_options() { QDialog dia( mParent, "dia", true ); dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); - QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); - QVBoxLayout lay ( &dia ); + Q3ButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); + Q3VBoxLayout lay ( &dia ); lay.setSpacing( 2 ); lay.setMargin( 3 ); lay.addWidget(&gr); QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); @@ -886,17 +889,17 @@ bool KSyncManager::edit_sync_options() } QString KSyncManager::getPassword( ) { QString retfile = ""; QDialog dia ( mParent, "input-dialog", true ); QLineEdit lab ( &dia ); lab.setEchoMode( QLineEdit::Password ); - QVBoxLayout lay( &dia ); + Q3VBoxLayout lay( &dia ); lay.setMargin(7); lay.setSpacing(7); lay.addWidget( &lab); dia.setFixedSize( 230,50 ); dia.setCaption( i18n("Enter password") ); QPushButton pb ( "OK", &dia); lay.addWidget( &pb ); connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); @@ -1329,33 +1332,33 @@ void KSyncManager::readFileFromSocket() else { commandSocket->sendStop(); if ( syncOK ) mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); mPisyncFinished = true; } } -KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) +KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : Q3ServerSocket( port, backlog, parent, name ) { mPendingConnect = 0; mPassWord = pw; mSocket = 0; mSyncActionDialog = 0; blockRC = false; mErrorMessage = 0; } void KServerSocket::waitForSocketFinish() { if ( mSocket ) { //qDebug("KSS:: waiting for finish operation"); QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish())); return; } - mSocket = new QSocket( this ); + mSocket = new Q3Socket( this ); connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); mSocket->setSocket( mPendingConnect ); mPendingConnect = 0; } void KServerSocket::newConnection ( int socket ) { // qDebug("KServerSocket:New connection %d ", socket); @@ -1367,17 +1370,17 @@ void KServerSocket::newConnection ( int socket ) mPendingConnect = socket; QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish())); return; qDebug("KSS::newConnection Socket deleted! "); delete mSocket; mSocket = 0; } mPendingConnect = 0; - mSocket = new QSocket( this ); + mSocket = new Q3Socket( this ); connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); mSocket->setSocket( socket ); } void KServerSocket::discardClient() { QTimer::singleShot( 10, this , SLOT ( deleteSocket())); @@ -1457,21 +1460,21 @@ void KServerSocket::displayErrorMessage() } else if ( mErrorMessage == 2 ) { KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error")); mErrorMessage = 0; } } void KServerSocket::error_connect( QString errmess ) { - QTextStream os( mSocket ); - os.setEncoding( QTextStream::Latin1 ); + Q3TextStream os( mSocket ); + os.setEncoding( Q3TextStream::Latin1 ); os << errmess ; mSocket->close(); - if ( mSocket->state() == QSocket::Idle ) { + if ( mSocket->state() == Q3Socket::Idle ) { QTimer::singleShot( 0, this , SLOT ( discardClient())); } } void KServerSocket::end_connect() { delete mSyncActionDialog; mSyncActionDialog = 0; } @@ -1479,17 +1482,17 @@ void KServerSocket::send_file() { //qDebug("MainWindow::sendFile(QSocket* s) "); if ( mSyncActionDialog ) delete mSyncActionDialog; mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); mSyncActionDialog->setCaption(i18n("Received sync request")); QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); label->setAlignment ( Qt::AlignHCenter ); - QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); + Q3VBoxLayout* lay = new Q3VBoxLayout( mSyncActionDialog ); lay->addWidget( label); lay->setMargin(7); lay->setSpacing(7); if ( KSyncManager::mRequestedSyncEvent.isValid() ) { int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); //secs = 333; if ( secs < 0 ) secs = secs * (-1); @@ -1531,37 +1534,37 @@ void KServerSocket::send_file() mSyncActionDialog->setFixedSize( 230, 120); mSyncActionDialog->show(); mSyncActionDialog->raise(); emit request_file(mResource); //emit request_file(); qApp->processEvents(); QString fileName = mFileName; QFile file( fileName ); - if (!file.open( IO_ReadOnly ) ) { + if (!file.open( QIODevice::ReadOnly ) ) { mErrorMessage = 0; end_connect(); error_connect("ERROR_FI\r\n\r\n"); return ; } mSyncActionDialog->setCaption( i18n("Sending file...") ); - QTextStream ts( &file ); - ts.setEncoding( QTextStream::Latin1 ); + Q3TextStream ts( &file ); + ts.setEncoding( Q3TextStream::Latin1 ); - QTextStream os( mSocket ); - os.setEncoding( QTextStream::Latin1 ); + Q3TextStream os( mSocket ); + os.setEncoding( Q3TextStream::Latin1 ); while ( ! ts.atEnd() ) { os << ts.readLine() << "\r\n"; } os << "\r\n"; //os << ts.read(); file.close(); mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); mSocket->close(); - if ( mSocket->state() == QSocket::Idle ) + if ( mSocket->state() == Q3Socket::Idle ) QTimer::singleShot( 10, this , SLOT ( discardClient())); } void KServerSocket::get_file() { mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); piTime.start(); piFileString = ""; @@ -1583,35 +1586,35 @@ void KServerSocket::readBackFileFromSocket() if ( piTime.elapsed () < 3000 ) { // wait for more //qDebug("waitformore "); QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); return; } QString fileName = mFileName; QFile file ( fileName ); - if (!file.open( IO_WriteOnly ) ) { + if (!file.open( QIODevice::WriteOnly ) ) { delete mSyncActionDialog; mSyncActionDialog = 0; qDebug("KSS:Error open read back file "); piFileString = ""; emit file_received( false, mResource); emit file_received( false); blockRC = false; return ; } // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); - QTextStream ts ( &file ); - ts.setEncoding( QTextStream::Latin1 ); + Q3TextStream ts ( &file ); + ts.setEncoding( Q3TextStream::Latin1 ); mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); ts << piFileString; mSocket->close(); - if ( mSocket->state() == QSocket::Idle ) + if ( mSocket->state() == Q3Socket::Idle ) QTimer::singleShot( 10, this , SLOT ( discardClient())); file.close(); piFileString = ""; emit file_received( true, mResource ); emit file_received( true); delete mSyncActionDialog; mSyncActionDialog = 0; blockRC = false; @@ -1643,27 +1646,27 @@ void KCommandSocket::sendFileRequest() { if ( tlw ) tlw->setCaption( i18n("Connected! Sending request for remote file ...") ); mConnectProgress.hide(); mConnectCount = 300;mConnectMax = 300; mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") ); mConnectProgress.setLabelText( i18n("Waiting for remote file...") ); mTimerSocket->start( 100, true ); - QTextStream os( mSocket ); - os.setEncoding( QTextStream::Latin1 ); + Q3TextStream os( mSocket ); + os.setEncoding( Q3TextStream::Latin1 ); QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); os << "GET " << mPassWord << curDt << " " << mRemoteResource << "\r\n\r\n"; } void KCommandSocket::readFile( QString fn ) { if ( !mSocket ) { - mSocket = new QSocket( this ); + mSocket = new Q3Socket( this ); //qDebug("KCS: read file - new socket"); connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() )); } mFileString = ""; mFileName = fn; mFirst = true; @@ -1691,48 +1694,48 @@ void KCommandSocket::updateConnectDialog() mTimerSocket->start( 1000, true ); else deleteSocket(); } void KCommandSocket::writeFile( QString fileName ) { if ( !mSocket ) { - mSocket = new QSocket( this ); + mSocket = new Q3Socket( this ); connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); } mFileName = fileName ; mConnectCount = 30;mConnectMax = 30; mTimerSocket->start( 1000, true ); mSocket->connectToHost( mHost, mPort ); } void KCommandSocket::writeFileToSocket() { mTimerSocket->stop(); QFile file2( mFileName ); - if (!file2.open( IO_ReadOnly ) ) { + if (!file2.open( QIODevice::ReadOnly ) ) { mConnectProgress.hide(); mConnectCount = -1; mRetVal= errorW; mSocket->close(); - if ( mSocket->state() == QSocket::Idle ) + if ( mSocket->state() == Q3Socket::Idle ) QTimer::singleShot( 10, this , SLOT ( deleteSocket())); return ; } mConnectProgress.setTotalSteps ( file2.size() ); mConnectProgress.show(); int count = 0; mConnectProgress.setLabelText( i18n("Sending back synced file...") ); mConnectProgress.setProgress( count ); mConnectProgress.blockSignals( true ); - QTextStream ts2( &file2 ); - ts2.setEncoding( QTextStream::Latin1 ); - QTextStream os2( mSocket ); - os2.setEncoding( QTextStream::Latin1 ); + Q3TextStream ts2( &file2 ); + ts2.setEncoding( Q3TextStream::Latin1 ); + Q3TextStream os2( mSocket ); + os2.setEncoding( Q3TextStream::Latin1 ); os2 << "PUT " << mPassWord << " " << mRemoteResource << "\r\n\r\n";; int byteCount = 0; int byteMax = file2.size()/53; while ( ! ts2.atEnd() ) { qApp->processEvents(); if ( byteCount > byteMax ) { byteCount = 0; mConnectProgress.setProgress( count ); @@ -1743,32 +1746,32 @@ void KCommandSocket::writeFileToSocket() os2 << temp << "\r\n"; } file2.close(); mConnectProgress.hide(); mConnectCount = -1; os2 << "\r\n"; mRetVal= successW; mSocket->close(); - if ( mSocket->state() == QSocket::Idle ) + if ( mSocket->state() == Q3Socket::Idle ) QTimer::singleShot( 10, this , SLOT ( deleteSocket())); mConnectProgress.blockSignals( false ); } void KCommandSocket::sendStop() { if ( !mSocket ) { - mSocket = new QSocket( this ); + mSocket = new Q3Socket( this ); connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); } mSocket->connectToHost( mHost, mPort ); - QTextStream os2( mSocket ); - os2.setEncoding( QTextStream::Latin1 ); + Q3TextStream os2( mSocket ); + os2.setEncoding( Q3TextStream::Latin1 ); os2 << "STOP\r\n\r\n"; mSocket->close(); - if ( mSocket->state() == QSocket::Idle ) + if ( mSocket->state() == Q3Socket::Idle ) QTimer::singleShot( 10, this , SLOT ( deleteSocket())); } void KCommandSocket::startReadFileFromSocket() { if ( ! mFirst ) return; mConnectProgress.setLabelText( i18n("Receiving file from remote...") ); @@ -1824,35 +1827,35 @@ void KCommandSocket::readFileFromSocket() QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); return; } mTimerSocket->stop(); mConnectCount = -1; mConnectProgress.hide(); QString fileName = mFileName; QFile file ( fileName ); - if (!file.open( IO_WriteOnly ) ) { + if (!file.open( QIODevice::WriteOnly ) ) { mFileString = ""; mRetVal = errorR; qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); deleteSocket(); return ; } // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); - QTextStream ts ( &file ); - ts.setEncoding( QTextStream::Latin1 ); + Q3TextStream ts ( &file ); + ts.setEncoding( Q3TextStream::Latin1 ); ts << mFileString; file.close(); mFileString = ""; mRetVal = successR; mSocket->close(); // if state is not idle, deleteSocket(); is called via // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); - if ( mSocket->state() == QSocket::Idle ) + if ( mSocket->state() == Q3Socket::Idle ) deleteSocket(); } void KCommandSocket::deleteSocket() { //qDebug("KCommandSocket::deleteSocket() "); mConnectProgress.hide(); |