summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-05 09:22:20 (UTC)
committer zautrix <zautrix>2004-10-05 09:22:20 (UTC)
commitaed6a774c2938b284d6cbc5026e3285c9c6ad24b (patch) (side-by-side diff)
treef05eefae589ae58b1d07d62c0c3d216ffb8d4f95
parent701cd3c2b2b713c12797f5bda24c35d3a7889539 (diff)
downloadkdepimpi-aed6a774c2938b284d6cbc5026e3285c9c6ad24b.zip
kdepimpi-aed6a774c2938b284d6cbc5026e3285c9c6ad24b.tar.gz
kdepimpi-aed6a774c2938b284d6cbc5026e3285c9c6ad24b.tar.bz2
sync fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koprefs.cpp1
-rw-r--r--korganizer/koprefs.h1
-rw-r--r--korganizer/mainwindow.cpp36
-rw-r--r--korganizer/mainwindow.h1
4 files changed, 23 insertions, 16 deletions
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index e0623d5..c28da9a 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -188,12 +188,13 @@ KOPrefs::KOPrefs() :
// addItemBool("UsePasswd",&mUsePassWd,false);
// addItemBool("WriteBackFile",&mWriteBackFile,true);
// addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false);
// addItemBool("AskForPreferences",&mAskForPreferences,true);
// addItemBool("ShowSyncSummary",&mShowSyncSummary,true);
addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" );
+ addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" );
addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" );
addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" );
addItemBool("ShowSyncEvents",&mShowSyncEvents,false);
addItemInt("LastSyncTime",&mLastSyncTime,0);
addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3);
addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3);
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index 7abd741..d9ac851 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -276,12 +276,13 @@ class KOPrefs : public KPimPrefs
int mAlarmPlayBeeps;
int mAlarmSuspendTime;
int mAlarmSuspendCount;
int mAlarmBeepInterval;
QString mPassiveSyncPort;
+ QString mPassiveSyncPw;
QString mActiveSyncPort;
QString mActiveSyncIP;
//US I copied the following settings into KPimGlobalPrefs
// that allows us later to easily remove the settings from here.
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 7b666d1..de94b8c 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1889,56 +1889,51 @@ QString MainWindow::getPassword( )
return retfile;
}
void MainWindow::enableQuick()
{
- QString passWordPiSync = "bhdrvmk";
- QString retfile = "";
QDialog dia ( this, "input-dialog", true );
QLineEdit lab ( &dia );
QVBoxLayout lay( &dia );
lab.setText( KOPrefs::instance()->mPassiveSyncPort );
lay.setMargin(7);
lay.setSpacing(7);
QLabel label ( i18n("Port number (Default: 9197)"), &dia );
lay.addWidget( &label);
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);
dia.setFixedSize( 230,80 );
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 )
- 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;
}
connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) );
connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) );
@@ -2191,12 +2186,13 @@ void MainWindow::printCal()
KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
{
mPassWord = pw;
mSocket = 0;
mSyncActionDialog = 0;
+ blockRC = false;
};
void KServerSocket::newConnection ( int socket )
{
// qDebug("KServerSocket:New connection %d ", socket);
if ( mSocket ) {
@@ -2218,32 +2214,38 @@ void KServerSocket::discardClient()
mSocket = 0;
}
//emit endConnect();
}
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 );
send_file();
else {
KMessageBox::information( 0, i18n("ERROR:\nGot 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 )
+ 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() );
}
}
if ( tokens[0] == "STOP" ) {
@@ -2261,13 +2263,13 @@ 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...\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);
lay->setSpacing(7);
mSyncActionDialog->setFixedSize( 230, 120);
mSyncActionDialog->show();
@@ -2334,12 +2336,13 @@ void KServerSocket::readBackFileFromSocket()
if (!file.open( IO_WriteOnly ) ) {
delete mSyncActionDialog;
mSyncActionDialog = 0;
qDebug("error open cal file ");
piFileString = "";
emit file_received( false );
+ blockRC = false;
return ;
}
// mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
QTextStream ts ( &file );
@@ -2350,12 +2353,13 @@ void KServerSocket::readBackFileFromSocket()
if ( mSocket->state() == QSocket::Idle )
QTimer::singleShot( 10, this , SLOT ( discardClient()));
file.close();
delete mSyncActionDialog;
mSyncActionDialog = 0;
piFileString = "";
+ blockRC = false;
emit file_received( true );
}
KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name )
{
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index ba627b9..7b24b88 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -44,12 +44,13 @@ signals:
void endConnect();
private slots:
void discardClient();
void readClient();
void readBackFileFromSocket();
private :
+ bool blockRC;
void send_file();
void get_file();
void end_connect();
QDialog* mSyncActionDialog;
QSocket* mSocket;
QString mPassWord;