From aed6a774c2938b284d6cbc5026e3285c9c6ad24b Mon Sep 17 00:00:00 2001 From: zautrix Date: Tue, 05 Oct 2004 09:22:20 +0000 Subject: sync fixes --- (limited to 'korganizer/mainwindow.cpp') diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 7b666d1..de94b8c 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -1892,8 +1892,6 @@ QString MainWindow::getPassword( ) void MainWindow::enableQuick() { - QString passWordPiSync = "bhdrvmk"; - QString retfile = ""; QDialog dia ( this, "input-dialog", true ); QLineEdit lab ( &dia ); QVBoxLayout lay( &dia ); @@ -1905,7 +1903,7 @@ void MainWindow::enableQuick() lay.addWidget( &lab); QLineEdit lepw ( &dia ); - lepw.setText( "abc" ); + lepw.setText( KOPrefs::instance()->mPassiveSyncPw ); QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); lay.addWidget( &label2); lay.addWidget( &lepw); @@ -1915,27 +1913,24 @@ void MainWindow::enableQuick() lay.addWidget( &pb ); connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); dia.show(); - int res = dia.exec(); - if ( res ) - retfile = lab.text(); - else + if ( ! dia.exec() ) return; dia.hide(); - passWordPiSync = lepw.text(); qApp->processEvents(); - KOPrefs::instance()->mPassiveSyncPort = retfile; + KOPrefs::instance()->mPassiveSyncPw = lepw.text(); + KOPrefs::instance()->mPassiveSyncPort = lab.text(); bool ok; - Q_UINT16 port = retfile.toUInt(&ok); + Q_UINT16 port = KOPrefs::instance()->mPassiveSyncPort.toUInt(&ok); if ( ! ok ) { KMessageBox::information( this, i18n("No valid port")); return; } //qDebug("port %d ", port); - mServerSocket = new KServerSocket ( passWordPiSync, port ,1 ); + mServerSocket = new KServerSocket ( KOPrefs::instance()->mPassiveSyncPw, port ,1 ); mServerSocket->setFileName( defaultFileName() ); //qDebug("connected "); if ( !mServerSocket->ok() ) { - qWarning("Failed to bind to port %d", port); + KMessageBox::information( this, i18n("Failed to bind or\nlisten to the port!")); delete mServerSocket; mServerSocket = 0; return; @@ -2194,6 +2189,7 @@ KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject mPassWord = pw; mSocket = 0; mSyncActionDialog = 0; + blockRC = false; }; void KServerSocket::newConnection ( int socket ) @@ -2221,13 +2217,17 @@ void KServerSocket::discardClient() } void KServerSocket::readClient() { + if ( blockRC ) + return; 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() ); + QString line = mSocket->readLine(); + qDebug("KServerSocket readline: %s ", line.latin1()); + QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); if ( tokens[0] == "GET" ) { if ( tokens[1] == mPassWord ) //emit sendFile( mSocket ); @@ -2238,9 +2238,11 @@ void KServerSocket::readClient() } } if ( tokens[0] == "PUT" ) { - if ( tokens[1] == mPassWord ) + if ( tokens[1] == mPassWord ) { //emit getFile( mSocket ); + blockRC = true; get_file(); + } else { KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); @@ -2264,7 +2266,7 @@ void KServerSocket::send_file() 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 ); + QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); lay->addWidget( label); lay->setMargin(7); @@ -2337,6 +2339,7 @@ void KServerSocket::readBackFileFromSocket() qDebug("error open cal file "); piFileString = ""; emit file_received( false ); + blockRC = false; return ; } @@ -2353,6 +2356,7 @@ void KServerSocket::readBackFileFromSocket() delete mSyncActionDialog; mSyncActionDialog = 0; piFileString = ""; + blockRC = false; emit file_received( true ); } -- cgit v0.9.0.2