author | zautrix <zautrix> | 2005-02-24 00:28:59 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-24 00:28:59 (UTC) |
commit | 513496c67403deb04339cfc87143ed5554720e32 (patch) (side-by-side diff) | |
tree | 87a0195e9875c539061ff70d18b05e4d50e96150 /libkdepim/ksyncmanager.cpp | |
parent | fd1e112db9e9d3dc656a540c05a87cbb4679939c (diff) | |
download | kdepimpi-513496c67403deb04339cfc87143ed5554720e32.zip kdepimpi-513496c67403deb04339cfc87143ed5554720e32.tar.gz kdepimpi-513496c67403deb04339cfc87143ed5554720e32.tar.bz2 |
fix
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 5214fe7..d8ca3ba 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp @@ -1138,107 +1138,110 @@ void KServerSocket::newConnection ( int socket ) { // qDebug("KServerSocket:New connection %d ", socket); if ( mSocket ) { qDebug("KSS::newConnection Socket deleted! "); delete mSocket; mSocket = 0; } mSocket = new QSocket( this ); connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); mSocket->setSocket( socket ); } void KServerSocket::discardClient() { //qDebug(" KServerSocket::discardClient()"); if ( mSocket ) { delete mSocket; mSocket = 0; } //emit endConnect(); } void KServerSocket::readClient() { if ( blockRC ) return; if ( mSocket == 0 ) { qDebug("ERROR::KSS::readClient(): mSocket == 0 "); return; } //qDebug("KServerSocket::readClient()"); if ( mSocket->canReadLine() ) { 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 ); bool ok = false; QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); if ( ok ) { KSyncManager::mRequestedSyncEvent = dt; } else KSyncManager::mRequestedSyncEvent = QDateTime(); send_file(); } else { + error_connect(); KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); } } if ( tokens[0] == "PUT" ) { if ( tokens[1] == mPassWord ) { //emit getFile( mSocket ); blockRC = true; get_file(); } else { + error_connect(); + end_connect(); KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); } } if ( tokens[0] == "STOP" ) { //emit endConnect(); end_connect(); } } } void KServerSocket::error_connect() { QTextStream os( mSocket ); os.setEncoding( QTextStream::Latin1 ); os << "ERROR_PW\r\n\r\n"; mSocket->close(); if ( mSocket->state() == QSocket::Idle ) QTimer::singleShot( 10, this , SLOT ( discardClient())); } void KServerSocket::end_connect() { delete mSyncActionDialog; mSyncActionDialog = 0; } 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 ); lay->addWidget( label); lay->setMargin(7); lay->setSpacing(7); if ( KSyncManager::mRequestedSyncEvent.isValid() ) { int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); if ( secs < 0 ) secs = secs * (-1); if ( secs > 30 ) //if ( true ) { QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); QLabel* label = new QLabel( warning, mSyncActionDialog ); label->setAlignment ( Qt::AlignHCenter ); lay->addWidget( label); |