-rw-r--r-- | korganizer/mainwindow.cpp | 94 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 2 | ||||
-rw-r--r-- | libkdepim/ksyncprefsdialog.cpp | 6 |
3 files changed, 31 insertions, 71 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index bce2a54..fe7e6d3 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -869,15 +869,12 @@ void MainWindow::fillSyncMenu() if ( mServerSocket == 0 ) { syncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); } else { 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" ) ); config.setGroup("General"); QStringList prof = config.readListEntry("SyncProfileNames"); KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); @@ -949,12 +946,17 @@ int MainWindow::ringSync() } else { if ( temp->getIsPhoneSync() ) { KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); syncPhone(); + } else if ( temp->getIsPiSync() ) { + mPassWordPiSync = temp->getRemotePw(); + KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); + KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); + syncPi(); } else syncRemote( temp, false ); } } timer.start(); @@ -1033,20 +1035,12 @@ void MainWindow::slotSyncMenu( int action ) if ( action == 3 ) { delete mServerSocket; mServerSocket = 0; QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); return; } - if ( action == 4 ) { - performQuick(); - return; - } - if ( action == 5 ) { - performQuickQuick(); - return; - } if (mBlockSaveFlag) return; mBlockSaveFlag = true; mCurrentSyncProfile = action - 1000 ; mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); @@ -1079,12 +1073,17 @@ void MainWindow::slotSyncMenu( int action ) } else { if ( temp->getIsPhoneSync() ) { KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); syncPhone(); + } else if ( temp->getIsPiSync() ) { + mPassWordPiSync = temp->getRemotePw(); + KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); + KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); + syncPi(); } else syncRemote( temp ); } } delete temp; @@ -1952,53 +1951,14 @@ void MainWindow::getFile( bool success ) mView->openCalendar( defaultFileName() ); setCaption( i18n("Pi-Sync successful!") ); } -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(); } void MainWindow::performQuickQuick() { @@ -2374,13 +2334,13 @@ KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject mSocket = 0; mSyncActionDialog = 0; }; 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; mSocket = 0; } mSocket = new QSocket( this ); @@ -2388,30 +2348,28 @@ void KServerSocket::newConnection ( int socket ) connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); mSocket->setSocket( socket ); } void KServerSocket::discardClient() { - qDebug(" KServerSocket::discardClient()"); + //qDebug(" KServerSocket::discardClient()"); if ( mSocket ) { - qDebug("delete "); delete mSocket; mSocket = 0; } //emit endConnect(); } void KServerSocket::readClient() { if ( mSocket == 0 ) { 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 ); send_file(); else { KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password")); @@ -2437,13 +2395,13 @@ void KServerSocket::end_connect() { delete mSyncActionDialog; mSyncActionDialog = 0; } 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 ); mSyncActionDialog->setCaption(i18n("Received sync request")); QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use this application!\n\nIf syncing fails you can close this dialog."), mSyncActionDialog ); QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); @@ -2475,14 +2433,13 @@ void KServerSocket::send_file() //os.setEncoding( QTextStream::UnicodeUTF8 ); while ( ! ts.atEnd() ) { os << ts.readLine() << "\n"; } //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())); } void KServerSocket::get_file() { @@ -2493,24 +2450,24 @@ void KServerSocket::get_file() QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); } 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; } QString fileName = mFileName; QFile file ( fileName ); if (!file.open( IO_WriteOnly ) ) { @@ -2523,13 +2480,12 @@ 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(); if ( mSocket->state() == QSocket::Idle ) QTimer::singleShot( 10, this , SLOT ( discardClient())); file.close(); @@ -2578,32 +2534,35 @@ void KCommandSocket::writeFile( QString fileName ) } if ( !mSocket ) { 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 ); os2.setCodec( QTextCodec::codecForName("utf8") ); os2 << "PUT " << mPassWord << "\r\n";; while ( ! ts2.atEnd() ) { os2 << ts2.readLine() << "\n"; } + mRetVal= true; mSocket->close(); if ( mSocket->state() == QSocket::Idle ) QTimer::singleShot( 10, this , SLOT ( deleteSocket())); file2.close(); } void KCommandSocket::sendStop() { if ( !mSocket ) { 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"; mRetVal= true; mSocket->close(); if ( mSocket->state() == QSocket::Idle ) @@ -2620,22 +2579,22 @@ void KCommandSocket::startReadFileFromSocket() mTime.start(); QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); } 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; } QString fileName = mFileName; QFile file ( fileName ); if (!file.open( IO_WriteOnly ) ) { @@ -2646,13 +2605,12 @@ void KCommandSocket::readFileFromSocket() return ; } // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); QTextStream ts ( &file ); ts.setCodec( QTextCodec::codecForName("utf8") ); - qDebug("finish "); ts << mFileString; file.close(); mFileString = ""; mRetVal = true; mSocket->close(); // if state is not idle, deleteSocket(); is called via @@ -2665,13 +2623,13 @@ void KCommandSocket::deleteSocket() { if ( mTimerSocket->isActive () ) { mTimerSocket->stop(); 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; emit commandFinished( this, mRetVal ); } diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index 5a67765..f8b2334 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h @@ -144,12 +144,13 @@ class MainWindow : public QMainWindow void slotSyncMenu( int ); void syncSSH(); void confSync(); void syncSharp(); void syncPhone(); + void syncPi(); void syncLocalFile(); bool syncWithFile( QString, bool ); void quickSyncLocalFile(); protected: @@ -172,13 +173,12 @@ class MainWindow : public QMainWindow QString mPassWordPiSync; KServerSocket * mServerSocket; bool mClosed; void saveOnClose(); int mCurrentSyncProfile; void enableQuick(); - void performQuick(); void performQuickQuick(); void syncRemote( KSyncProfile* , bool ask = true); bool mFlagKeyPressed; bool mBlockAtStartup; QPEToolBar *iconToolBar; void initActions(); diff --git a/libkdepim/ksyncprefsdialog.cpp b/libkdepim/ksyncprefsdialog.cpp index f05c846..0caa27e 100644 --- a/libkdepim/ksyncprefsdialog.cpp +++ b/libkdepim/ksyncprefsdialog.cpp @@ -187,13 +187,13 @@ void KSyncPrefsDialog::setupSyncAlgTab() proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame); gr = proGr; topLayout->addMultiCellWidget(gr, iii,iii,0,1); ++iii; mIsLocal = new QRadioButton ( i18n("Local file"), gr ); - mIsPi = new QRadioButton ( i18n("Quick Pi-Sync"), gr ); + mIsPi = new QRadioButton ( i18n("Pi-Sync ( direct Kx/Pi to Kx/Pi sync )"), gr ); connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr ); connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr ); connect (mIsPhone, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); @@ -453,13 +453,14 @@ void KSyncPrefsDialog::profileChanged( int item ) break; default: break; } mIsLocal->setChecked(prof->getIsLocalFileSync()) ; mIsPhone->setChecked(prof->getIsPhoneSync()) ; - mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() ); + mIsPi->setChecked(prof->getIsPiSync()) ; + mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() ); proGr->setEnabled( item > 2 ); if ( item < 3 ) { localFileWidget->hide(); remoteFileWidget->hide(); phoneWidget->hide(); piWidget->hide(); @@ -574,12 +575,13 @@ void KSyncPrefsDialog::saveProfile() prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() ); prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() ); int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; prof->setSyncPrefs( syncprefs); prof->setIsLocalFileSync( mIsLocal->isChecked() ); prof->setIsPhoneSync( mIsPhone->isChecked() ); + prof->setIsPiSync( mIsPi->isChecked() ); prof->setWriteBackFuture(mWriteBackFuture->isChecked()); prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value()); prof->setWriteContactToSIM(mWriteContactToSIM->isChecked()); prof->setPhoneDevice( mPhoneDevice->text() ); prof->setPhoneConnection( mPhoneConnection->text() ); |