From c22811d11414872fc0525350a8a1afdae61be346 Mon Sep 17 00:00:00 2001 From: zautrix Date: Mon, 04 Oct 2004 22:10:20 +0000 Subject: many sync fixes --- (limited to 'korganizer') diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index bce2a54..fe7e6d3 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -872,9 +872,6 @@ void MainWindow::fillSyncMenu() syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); } syncMenu->insertSeparator(); - syncMenu->insertItem( i18n("New Pi-Sync!"), 4 ); - syncMenu->insertItem( i18n("Quick Pi-Sync!"), 5 ); - syncMenu->insertSeparator(); syncMenu->insertItem( i18n("Multiple sync"), 1 ); syncMenu->insertSeparator(); KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); @@ -952,7 +949,12 @@ int MainWindow::ringSync() KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); syncPhone(); - } else + } else if ( temp->getIsPiSync() ) { + mPassWordPiSync = temp->getRemotePw(); + KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); + KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); + syncPi(); + } else syncRemote( temp, false ); } @@ -1036,14 +1038,6 @@ void MainWindow::slotSyncMenu( int action ) QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); return; } - if ( action == 4 ) { - performQuick(); - return; - } - if ( action == 5 ) { - performQuickQuick(); - return; - } if (mBlockSaveFlag) return; @@ -1082,7 +1076,12 @@ void MainWindow::slotSyncMenu( int action ) KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); syncPhone(); - } else + } else if ( temp->getIsPiSync() ) { + mPassWordPiSync = temp->getRemotePw(); + KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); + KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); + syncPi(); + } else syncRemote( temp ); } @@ -1955,47 +1954,8 @@ void MainWindow::getFile( bool success ) } -void MainWindow::performQuick() +void MainWindow::syncPi() { - - setCaption( i18n("Please input connection settings") ); - QString retfile = ""; - QDialog dia ( this, "input-dialog", true ); - QLineEdit lab ( &dia ); - QVBoxLayout lay( &dia ); - QLabel label ( i18n("IP address\n(Example: 192.168.0.40)"), &dia ); - lay.addWidget( &label); - lab.setText( KOPrefs::instance()->mActiveSyncIP ); - lay.setMargin(7); - lay.setSpacing(7); - lay.addWidget( &lab); - QLabel label2 ( i18n("Port number (Default: 9197)"), &dia ); - lay.addWidget( &label2); - QLineEdit lab2 ( &dia ); - lab2.setText( KOPrefs::instance()->mActiveSyncPort ); - lay.addWidget( &lab2); - - QLineEdit lepw ( &dia ); - lepw.setText( mPassWordPiSync ); - QLabel label3 ( i18n("Password to enable\naccess to remote:"), &dia ); - lay.addWidget( &label3); - lay.addWidget( &lepw); - - dia.setFixedSize( 230,200 ); - dia.setCaption( i18n("Enter port for Pi-Sync ") ); - QPushButton pb ( "OK", &dia); - lay.addWidget( &pb ); - connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); - dia.show(); - int res = dia.exec(); - if ( !res ) { - setCaption( i18n("Syncing cancelled!") ); - return; - } - mPassWordPiSync = lepw.text(); - dia.hide(); - KOPrefs::instance()->mActiveSyncPort = lab2.text(); - KOPrefs::instance()->mActiveSyncIP = lab.text(); qApp->processEvents(); performQuickQuick(); } @@ -2377,7 +2337,7 @@ KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject void KServerSocket::newConnection ( int socket ) { - qDebug("KServerSocket:New connection %d ", socket); + // qDebug("KServerSocket:New connection %d ", socket); if ( mSocket ) { qDebug("KServerSocket::newConnection Socket deleted! "); delete mSocket; @@ -2391,9 +2351,8 @@ void KServerSocket::newConnection ( int socket ) void KServerSocket::discardClient() { - qDebug(" KServerSocket::discardClient()"); + //qDebug(" KServerSocket::discardClient()"); if ( mSocket ) { - qDebug("delete "); delete mSocket; mSocket = 0; } @@ -2405,10 +2364,9 @@ void KServerSocket::readClient() qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); return; } - qDebug("KServerSocket readClient()"); + //qDebug("KServerSocket readClient()"); if ( mSocket->canReadLine() ) { QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), mSocket->readLine() ); - qDebug("KServerSocket socket->canReadLine()"); if ( tokens[0] == "GET" ) { if ( tokens[1] == mPassWord ) //emit sendFile( mSocket ); @@ -2440,7 +2398,7 @@ void KServerSocket::end_connect() } void KServerSocket::send_file() { - qDebug("MainWindow::sendFile(QSocket* s) "); + //qDebug("MainWindow::sendFile(QSocket* s) "); if ( mSyncActionDialog ) delete mSyncActionDialog; mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); @@ -2478,8 +2436,7 @@ void KServerSocket::send_file() } //os << ts.read(); file.close(); - mSyncActionDialog->setCaption( i18n("Waiting to get back synced file") ); - qDebug("file sent "); + mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); mSocket->close(); if ( mSocket->state() == QSocket::Idle ) QTimer::singleShot( 10, this , SLOT ( discardClient())); @@ -2496,18 +2453,18 @@ void KServerSocket::get_file() void KServerSocket::readBackFileFromSocket() { - qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); + //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); while ( mSocket->canReadLine () ) { piTime.restart(); QString line = mSocket->readLine (); piFileString += line; - qDebug("readline: %s ", line.latin1()); + //qDebug("readline: %s ", line.latin1()); mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); } if ( piTime.elapsed () < 3000 ) { // wait for more - qDebug("waitformore "); + //qDebug("waitformore "); QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); return; } @@ -2526,7 +2483,6 @@ void KServerSocket::readBackFileFromSocket() // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); QTextStream ts ( &file ); ts.setCodec( QTextCodec::codecForName("utf8") ); - qDebug("finish "); mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); ts << piFileString; mSocket->close(); @@ -2581,6 +2537,7 @@ void KCommandSocket::writeFile( QString fileName ) mSocket = new QSocket( this ); connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); } + mSocket->connectToHost( mHost, mPort ); QTextStream ts2( &file2 ); ts2.setCodec( QTextCodec::codecForName("utf8") ); QTextStream os2( mSocket ); @@ -2589,6 +2546,7 @@ void KCommandSocket::writeFile( QString fileName ) while ( ! ts2.atEnd() ) { os2 << ts2.readLine() << "\n"; } + mRetVal= true; mSocket->close(); if ( mSocket->state() == QSocket::Idle ) QTimer::singleShot( 10, this , SLOT ( deleteSocket())); @@ -2601,6 +2559,7 @@ void KCommandSocket::sendStop() mSocket = new QSocket( this ); connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); } + mSocket->connectToHost( mHost, mPort ); QTextStream os2( mSocket ); os2.setCodec( QTextCodec::codecForName("utf8") ); os2 << "STOP\r\n"; @@ -2623,16 +2582,16 @@ void KCommandSocket::startReadFileFromSocket() } void KCommandSocket::readFileFromSocket() { - qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); + //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); while ( mSocket->canReadLine () ) { mTime.restart(); QString line = mSocket->readLine (); mFileString += line; - qDebug("readline: %s ", line.latin1()); + //qDebug("readline: %s ", line.latin1()); } if ( mTime.elapsed () < 3000 ) { // wait for more - qDebug("waitformore "); + //qDebug("waitformore "); QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); return; } @@ -2649,7 +2608,6 @@ void KCommandSocket::readFileFromSocket() // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); QTextStream ts ( &file ); ts.setCodec( QTextCodec::codecForName("utf8") ); - qDebug("finish "); ts << mFileString; file.close(); mFileString = ""; @@ -2668,7 +2626,7 @@ void KCommandSocket::deleteSocket() KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? ")); mRetVal = false; } - qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); + //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); if ( mSocket) delete mSocket; mSocket = 0; diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index 5a67765..f8b2334 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h @@ -147,6 +147,7 @@ class MainWindow : public QMainWindow void confSync(); void syncSharp(); void syncPhone(); + void syncPi(); void syncLocalFile(); bool syncWithFile( QString, bool ); void quickSyncLocalFile(); @@ -175,7 +176,6 @@ class MainWindow : public QMainWindow void saveOnClose(); int mCurrentSyncProfile; void enableQuick(); - void performQuick(); void performQuickQuick(); void syncRemote( KSyncProfile* , bool ask = true); bool mFlagKeyPressed; -- cgit v0.9.0.2