summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-05 07:22:35 (UTC)
committer zautrix <zautrix>2004-10-05 07:22:35 (UTC)
commitfc2c103f45a6d4e4105259436266538c645f2c87 (patch) (side-by-side diff)
tree7cab481e080b7db555129a17735152051882a31c
parent0dd4cb1ff2bbd47788a5220363758226e5639edf (diff)
downloadkdepimpi-fc2c103f45a6d4e4105259436266538c645f2c87.zip
kdepimpi-fc2c103f45a6d4e4105259436266538c645f2c87.tar.gz
kdepimpi-fc2c103f45a6d4e4105259436266538c645f2c87.tar.bz2
sync fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp113
-rw-r--r--korganizer/mainwindow.h10
2 files changed, 48 insertions, 75 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index b7176a1..5aa75f5 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1285,2 +1285,10 @@ QString MainWindow::defaultFileName()
}
+QString MainWindow::syncFileName()
+{
+#ifdef _WIN32_
+ return locateLocal( "tmp", "synccalendar.ics" );
+#else
+ return QString( "/tmp/kopitempfile.ics" );
+#endif
+}
@@ -1926,6 +1934,6 @@ void MainWindow::enableQuick()
}
- qDebug("port %d ", port);
+ //qDebug("port %d ", port);
mServerSocket = new KServerSocket ( passWordPiSync, port ,1 );
mServerSocket->setFileName( defaultFileName() );
- qDebug("connected ");
+ //qDebug("connected ");
if ( !mServerSocket->ok() ) {
@@ -1936,6 +1944,4 @@ void MainWindow::enableQuick()
}
- connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) );
+ connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) );
connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) );
- // connect( mServerSocket, SIGNAL ( sendFile(QSocket*) ), this, SLOT ( sendFile(QSocket*) ) );
- //connect( mServerSocket, SIGNAL ( getFile(QSocket*) ), this, SLOT ( getFile(QSocket*) ) );
}
@@ -1964,4 +1970,2 @@ void MainWindow::performQuickQuick()
{
- // setCaption( i18n("") );
-
bool ok;
@@ -1972,67 +1976,36 @@ void MainWindow::performQuickQuick()
}
- KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this );
- connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, bool )), this, SLOT(deleteCommandSocket(KCommandSocket*,bool)) );
+ KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this );
+ connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
setCaption( i18n("Sending request for remote file ...") );
- QString fileName;
-#ifdef _WIN32_
- fileName = defaultFileName() +"sync";
-#else
- fileName = "/tmp/kopitempfile.ics";
-#endif
- commandSocket->readFile( fileName );
+ commandSocket->readFile( syncFileName() );
}
-void MainWindow::deleteCommandSocket(KCommandSocket*s, bool success)
+void MainWindow::deleteCommandSocket(KCommandSocket*s, int state)
{
- if ( ! success ) {
- setCaption( i18n("ERROR:Receiving remote file failed.") );
+ qDebug("MainWindow::deleteCommandSocket %d", state);
+
+ //enum { success, errorW, errorR, quiet };
+ if ( state == KCommandSocket::errorR ) {
+ setCaption( i18n("ERROR: Receiving remote file failed.") );
delete s;
- // pending : send stop
+ KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this );
+ connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
+ commandSocket->sendStop();
return;
-
- }
- QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
- qDebug("MainWindow::deleteCommandSocket ");
- delete s;
-}
-void MainWindow::deleteCommandSocketFinish(KCommandSocket* s, bool success )
-{
- if ( ! success ) {
+
+ } else if ( state == KCommandSocket::errorW ) {
setCaption( i18n("ERROR:Writing back file failed.") );
- } else {
- qDebug("Syncing succesful! ");
+
+ } else if ( state == KCommandSocket::successR ) {
+ QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
+
+ } else if ( state == KCommandSocket::successW ) {
setCaption( i18n("Pi-Sync succesful!") );
}
- qDebug("MainWindow::deleteCommandSocketFinish ");
+
delete s;
}
+
void MainWindow::readFileFromSocket()
{
- // mTimerCommandSocket->stop();
- setCaption( i18n("Receiving remote file ...") );
- qDebug("MainWindow::readFileFromSocket() ");
- QString fileName;
-#ifdef _WIN32_
- fileName = defaultFileName() +"sync";
-#else
- fileName = "/tmp/kopitempfile.ics";
-#endif
-
- setCaption( i18n("Remote file saved to temp file.") );
- //mCommandSocket = 0;
- mCurrentSyncProfile = 2 ; // last file
- mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
- mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
- KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
- KSyncProfile* temp = new KSyncProfile ();
- temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
- temp->readConfig(&config);
- KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
- KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
- KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
- KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
- KOPrefs::instance()->mWriteBackInFuture = 0;
- if ( temp->getWriteBackFuture() )
- KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
- KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
- delete temp;
+ QString fileName = syncFileName();
setCaption( i18n("Remote file saved to temp file.") );
@@ -2043,9 +2016,10 @@ void MainWindow::readFileFromSocket()
}
-
KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this );
- connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, bool )), this, SLOT(deleteCommandSocketFinish(KCommandSocket*,bool)) );
+ connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
if ( KOPrefs::instance()->mWriteBackFile )
commandSocket->writeFile( fileName );
- else
+ else {
commandSocket->sendStop();
+ setCaption( i18n("Pi-Sync succesful!") );
+ }
}
@@ -2505,3 +2479,3 @@ KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host,
- mRetVal = false;
+ mRetVal = quiet;
mTimerSocket = new QTimer ( this );
@@ -2540,3 +2514,3 @@ void KCommandSocket::writeFileToSocket()
if (!file2.open( IO_ReadOnly ) ) {
- mRetVal= false;
+ mRetVal= errorW;
mSocket->close();
@@ -2554,3 +2528,3 @@ void KCommandSocket::writeFileToSocket()
}
- mRetVal= true;
+ mRetVal= successW;
file2.close();
@@ -2570,3 +2544,2 @@ void KCommandSocket::sendStop()
os2 << "STOP\r\n";
- mRetVal= true;
mSocket->close();
@@ -2606,3 +2579,3 @@ void KCommandSocket::readFileFromSocket()
mFileString = "";
- mRetVal = false;
+ mRetVal = errorR;
qDebug("Error open temp calender file for writing: %s",fileName.latin1() );
@@ -2618,3 +2591,3 @@ void KCommandSocket::readFileFromSocket()
mFileString = "";
- mRetVal = true;
+ mRetVal = successR;
mSocket->close();
@@ -2631,3 +2604,3 @@ void KCommandSocket::deleteSocket()
KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? "));
- mRetVal = false;
+ mRetVal = errorR;
}
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 90b3a88..4da371e 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -63,4 +63,4 @@ class KCommandSocket : public QObject
Q_OBJECT
-
public:
+ enum state { successR, errorR, successW, errorW, quiet };
KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 );
@@ -72,3 +72,3 @@ public:
signals:
- void commandFinished( KCommandSocket*, bool );
+ void commandFinished( KCommandSocket*, int );
private slots:
@@ -85,3 +85,3 @@ private slots:
QTimer* mTimerSocket;
- bool mRetVal;
+ int mRetVal;
QTime mTime;
@@ -108,2 +108,3 @@ class MainWindow : public QMainWindow
static QString defaultFileName();
+ static QString syncFileName();
static QString resourcePath();
@@ -166,4 +167,3 @@ class MainWindow : public QMainWindow
QTime piTime;
- void deleteCommandSocket(KCommandSocket* s, bool success);
- void deleteCommandSocketFinish(KCommandSocket* s, bool success);
+ void deleteCommandSocket(KCommandSocket* s, int state );
void fillSyncMenu();