summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-05 09:22:20 (UTC)
committer zautrix <zautrix>2004-10-05 09:22:20 (UTC)
commitaed6a774c2938b284d6cbc5026e3285c9c6ad24b (patch) (unidiff)
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
@@ -191,6 +191,7 @@ KOPrefs::KOPrefs() :
191// addItemBool("AskForPreferences",&mAskForPreferences,true); 191// addItemBool("AskForPreferences",&mAskForPreferences,true);
192// addItemBool("ShowSyncSummary",&mShowSyncSummary,true); 192// addItemBool("ShowSyncSummary",&mShowSyncSummary,true);
193 addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" ); 193 addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" );
194 addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" );
194 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); 195 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" );
195 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); 196 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" );
196 addItemBool("ShowSyncEvents",&mShowSyncEvents,false); 197 addItemBool("ShowSyncEvents",&mShowSyncEvents,false);
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index 7abd741..d9ac851 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -279,6 +279,7 @@ class KOPrefs : public KPimPrefs
279 int mAlarmBeepInterval; 279 int mAlarmBeepInterval;
280 280
281 QString mPassiveSyncPort; 281 QString mPassiveSyncPort;
282 QString mPassiveSyncPw;
282 QString mActiveSyncPort; 283 QString mActiveSyncPort;
283 QString mActiveSyncIP; 284 QString mActiveSyncIP;
284 285
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( )
1892 1892
1893void MainWindow::enableQuick() 1893void MainWindow::enableQuick()
1894{ 1894{
1895 QString passWordPiSync = "bhdrvmk";
1896 QString retfile = "";
1897 QDialog dia ( this, "input-dialog", true ); 1895 QDialog dia ( this, "input-dialog", true );
1898 QLineEdit lab ( &dia ); 1896 QLineEdit lab ( &dia );
1899 QVBoxLayout lay( &dia ); 1897 QVBoxLayout lay( &dia );
@@ -1905,7 +1903,7 @@ void MainWindow::enableQuick()
1905 lay.addWidget( &lab); 1903 lay.addWidget( &lab);
1906 1904
1907 QLineEdit lepw ( &dia ); 1905 QLineEdit lepw ( &dia );
1908 lepw.setText( "abc" ); 1906 lepw.setText( KOPrefs::instance()->mPassiveSyncPw );
1909 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 1907 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
1910 lay.addWidget( &label2); 1908 lay.addWidget( &label2);
1911 lay.addWidget( &lepw); 1909 lay.addWidget( &lepw);
@@ -1915,27 +1913,24 @@ void MainWindow::enableQuick()
1915 lay.addWidget( &pb ); 1913 lay.addWidget( &pb );
1916 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1914 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1917 dia.show(); 1915 dia.show();
1918 int res = dia.exec(); 1916 if ( ! dia.exec() )
1919 if ( res )
1920 retfile = lab.text();
1921 else
1922 return; 1917 return;
1923 dia.hide(); 1918 dia.hide();
1924 passWordPiSync = lepw.text();
1925 qApp->processEvents(); 1919 qApp->processEvents();
1926 KOPrefs::instance()->mPassiveSyncPort = retfile; 1920 KOPrefs::instance()->mPassiveSyncPw = lepw.text();
1921 KOPrefs::instance()->mPassiveSyncPort = lab.text();
1927 bool ok; 1922 bool ok;
1928 Q_UINT16 port = retfile.toUInt(&ok); 1923 Q_UINT16 port = KOPrefs::instance()->mPassiveSyncPort.toUInt(&ok);
1929 if ( ! ok ) { 1924 if ( ! ok ) {
1930 KMessageBox::information( this, i18n("No valid port")); 1925 KMessageBox::information( this, i18n("No valid port"));
1931 return; 1926 return;
1932 } 1927 }
1933 //qDebug("port %d ", port); 1928 //qDebug("port %d ", port);
1934 mServerSocket = new KServerSocket ( passWordPiSync, port ,1 ); 1929 mServerSocket = new KServerSocket ( KOPrefs::instance()->mPassiveSyncPw, port ,1 );
1935 mServerSocket->setFileName( defaultFileName() ); 1930 mServerSocket->setFileName( defaultFileName() );
1936 //qDebug("connected "); 1931 //qDebug("connected ");
1937 if ( !mServerSocket->ok() ) { 1932 if ( !mServerSocket->ok() ) {
1938 qWarning("Failed to bind to port %d", port); 1933 KMessageBox::information( this, i18n("Failed to bind or\nlisten to the port!"));
1939 delete mServerSocket; 1934 delete mServerSocket;
1940 mServerSocket = 0; 1935 mServerSocket = 0;
1941 return; 1936 return;
@@ -2194,6 +2189,7 @@ KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject
2194 mPassWord = pw; 2189 mPassWord = pw;
2195 mSocket = 0; 2190 mSocket = 0;
2196 mSyncActionDialog = 0; 2191 mSyncActionDialog = 0;
2192 blockRC = false;
2197}; 2193};
2198 2194
2199void KServerSocket::newConnection ( int socket ) 2195void KServerSocket::newConnection ( int socket )
@@ -2221,13 +2217,17 @@ void KServerSocket::discardClient()
2221} 2217}
2222void KServerSocket::readClient() 2218void KServerSocket::readClient()
2223{ 2219{
2220 if ( blockRC )
2221 return;
2224 if ( mSocket == 0 ) { 2222 if ( mSocket == 0 ) {
2225 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); 2223 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
2226 return; 2224 return;
2227 } 2225 }
2228 //qDebug("KServerSocket readClient()"); 2226 qDebug("KServerSocket readClient()");
2229 if ( mSocket->canReadLine() ) { 2227 if ( mSocket->canReadLine() ) {
2230 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), mSocket->readLine() ); 2228 QString line = mSocket->readLine();
2229 qDebug("KServerSocket readline: %s ", line.latin1());
2230 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
2231 if ( tokens[0] == "GET" ) { 2231 if ( tokens[0] == "GET" ) {
2232 if ( tokens[1] == mPassWord ) 2232 if ( tokens[1] == mPassWord )
2233 //emit sendFile( mSocket ); 2233 //emit sendFile( mSocket );
@@ -2238,9 +2238,11 @@ void KServerSocket::readClient()
2238 } 2238 }
2239 } 2239 }
2240 if ( tokens[0] == "PUT" ) { 2240 if ( tokens[0] == "PUT" ) {
2241 if ( tokens[1] == mPassWord ) 2241 if ( tokens[1] == mPassWord ) {
2242 //emit getFile( mSocket ); 2242 //emit getFile( mSocket );
2243 blockRC = true;
2243 get_file(); 2244 get_file();
2245 }
2244 else { 2246 else {
2245 KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); 2247 KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password"));
2246 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 2248 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
@@ -2264,7 +2266,7 @@ void KServerSocket::send_file()
2264 delete mSyncActionDialog; 2266 delete mSyncActionDialog;
2265 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 2267 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
2266 mSyncActionDialog->setCaption(i18n("Received sync request")); 2268 mSyncActionDialog->setCaption(i18n("Received sync request"));
2267 QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use this application!\n\nIf syncing fails you can close this dialog."), mSyncActionDialog ); 2269 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
2268 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 2270 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
2269 lay->addWidget( label); 2271 lay->addWidget( label);
2270 lay->setMargin(7); 2272 lay->setMargin(7);
@@ -2337,6 +2339,7 @@ void KServerSocket::readBackFileFromSocket()
2337 qDebug("error open cal file "); 2339 qDebug("error open cal file ");
2338 piFileString = ""; 2340 piFileString = "";
2339 emit file_received( false ); 2341 emit file_received( false );
2342 blockRC = false;
2340 return ; 2343 return ;
2341 2344
2342 } 2345 }
@@ -2353,6 +2356,7 @@ void KServerSocket::readBackFileFromSocket()
2353 delete mSyncActionDialog; 2356 delete mSyncActionDialog;
2354 mSyncActionDialog = 0; 2357 mSyncActionDialog = 0;
2355 piFileString = ""; 2358 piFileString = "";
2359 blockRC = false;
2356 emit file_received( true ); 2360 emit file_received( true );
2357 2361
2358} 2362}
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index ba627b9..7b24b88 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -47,6 +47,7 @@ private slots:
47 void readClient(); 47 void readClient();
48 void readBackFileFromSocket(); 48 void readBackFileFromSocket();
49 private : 49 private :
50 bool blockRC;
50 void send_file(); 51 void send_file();
51 void get_file(); 52 void get_file();
52 void end_connect(); 53 void end_connect();