author | zautrix <zautrix> | 2004-10-05 07:22:35 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-05 07:22:35 (UTC) |
commit | fc2c103f45a6d4e4105259436266538c645f2c87 (patch) (unidiff) | |
tree | 7cab481e080b7db555129a17735152051882a31c /korganizer | |
parent | 0dd4cb1ff2bbd47788a5220363758226e5639edf (diff) | |
download | kdepimpi-fc2c103f45a6d4e4105259436266538c645f2c87.zip kdepimpi-fc2c103f45a6d4e4105259436266538c645f2c87.tar.gz kdepimpi-fc2c103f45a6d4e4105259436266538c645f2c87.tar.bz2 |
sync fixes
-rw-r--r-- | korganizer/mainwindow.cpp | 113 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 10 |
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() | |||
1285 | } | 1285 | } |
1286 | QString MainWindow::syncFileName() | ||
1287 | { | ||
1288 | #ifdef _WIN32_ | ||
1289 | return locateLocal( "tmp", "synccalendar.ics" ); | ||
1290 | #else | ||
1291 | return QString( "/tmp/kopitempfile.ics" ); | ||
1292 | #endif | ||
1293 | } | ||
1286 | 1294 | ||
@@ -1926,6 +1934,6 @@ void MainWindow::enableQuick() | |||
1926 | } | 1934 | } |
1927 | qDebug("port %d ", port); | 1935 | //qDebug("port %d ", port); |
1928 | mServerSocket = new KServerSocket ( passWordPiSync, port ,1 ); | 1936 | mServerSocket = new KServerSocket ( passWordPiSync, port ,1 ); |
1929 | mServerSocket->setFileName( defaultFileName() ); | 1937 | mServerSocket->setFileName( defaultFileName() ); |
1930 | qDebug("connected "); | 1938 | //qDebug("connected "); |
1931 | if ( !mServerSocket->ok() ) { | 1939 | if ( !mServerSocket->ok() ) { |
@@ -1936,6 +1944,4 @@ void MainWindow::enableQuick() | |||
1936 | } | 1944 | } |
1937 | connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) ); | 1945 | connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) ); |
1938 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) ); | 1946 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) ); |
1939 | // connect( mServerSocket, SIGNAL ( sendFile(QSocket*) ), this, SLOT ( sendFile(QSocket*) ) ); | ||
1940 | //connect( mServerSocket, SIGNAL ( getFile(QSocket*) ), this, SLOT ( getFile(QSocket*) ) ); | ||
1941 | } | 1947 | } |
@@ -1964,4 +1970,2 @@ void MainWindow::performQuickQuick() | |||
1964 | { | 1970 | { |
1965 | // setCaption( i18n("") ); | ||
1966 | |||
1967 | bool ok; | 1971 | bool ok; |
@@ -1972,67 +1976,36 @@ void MainWindow::performQuickQuick() | |||
1972 | } | 1976 | } |
1973 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this ); | 1977 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this ); |
1974 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, bool )), this, SLOT(deleteCommandSocket(KCommandSocket*,bool)) ); | 1978 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
1975 | setCaption( i18n("Sending request for remote file ...") ); | 1979 | setCaption( i18n("Sending request for remote file ...") ); |
1976 | QString fileName; | 1980 | commandSocket->readFile( syncFileName() ); |
1977 | #ifdef _WIN32_ | ||
1978 | fileName = defaultFileName() +"sync"; | ||
1979 | #else | ||
1980 | fileName = "/tmp/kopitempfile.ics"; | ||
1981 | #endif | ||
1982 | commandSocket->readFile( fileName ); | ||
1983 | } | 1981 | } |
1984 | void MainWindow::deleteCommandSocket(KCommandSocket*s, bool success) | 1982 | void MainWindow::deleteCommandSocket(KCommandSocket*s, int state) |
1985 | { | 1983 | { |
1986 | if ( ! success ) { | 1984 | qDebug("MainWindow::deleteCommandSocket %d", state); |
1987 | setCaption( i18n("ERROR:Receiving remote file failed.") ); | 1985 | |
1986 | //enum { success, errorW, errorR, quiet }; | ||
1987 | if ( state == KCommandSocket::errorR ) { | ||
1988 | setCaption( i18n("ERROR: Receiving remote file failed.") ); | ||
1988 | delete s; | 1989 | delete s; |
1989 | // pending : send stop | 1990 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); |
1991 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | ||
1992 | commandSocket->sendStop(); | ||
1990 | return; | 1993 | return; |
1991 | 1994 | ||
1992 | } | 1995 | } else if ( state == KCommandSocket::errorW ) { |
1993 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | ||
1994 | qDebug("MainWindow::deleteCommandSocket "); | ||
1995 | delete s; | ||
1996 | } | ||
1997 | void MainWindow::deleteCommandSocketFinish(KCommandSocket* s, bool success ) | ||
1998 | { | ||
1999 | if ( ! success ) { | ||
2000 | setCaption( i18n("ERROR:Writing back file failed.") ); | 1996 | setCaption( i18n("ERROR:Writing back file failed.") ); |
2001 | } else { | 1997 | |
2002 | qDebug("Syncing succesful! "); | 1998 | } else if ( state == KCommandSocket::successR ) { |
1999 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | ||
2000 | |||
2001 | } else if ( state == KCommandSocket::successW ) { | ||
2003 | setCaption( i18n("Pi-Sync succesful!") ); | 2002 | setCaption( i18n("Pi-Sync succesful!") ); |
2004 | } | 2003 | } |
2005 | qDebug("MainWindow::deleteCommandSocketFinish "); | 2004 | |
2006 | delete s; | 2005 | delete s; |
2007 | } | 2006 | } |
2007 | |||
2008 | void MainWindow::readFileFromSocket() | 2008 | void MainWindow::readFileFromSocket() |
2009 | { | 2009 | { |
2010 | // mTimerCommandSocket->stop(); | 2010 | QString fileName = syncFileName(); |
2011 | setCaption( i18n("Receiving remote file ...") ); | ||
2012 | qDebug("MainWindow::readFileFromSocket() "); | ||
2013 | QString fileName; | ||
2014 | #ifdef _WIN32_ | ||
2015 | fileName = defaultFileName() +"sync"; | ||
2016 | #else | ||
2017 | fileName = "/tmp/kopitempfile.ics"; | ||
2018 | #endif | ||
2019 | |||
2020 | setCaption( i18n("Remote file saved to temp file.") ); | ||
2021 | //mCommandSocket = 0; | ||
2022 | mCurrentSyncProfile = 2 ; // last file | ||
2023 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); | ||
2024 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | ||
2025 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | ||
2026 | KSyncProfile* temp = new KSyncProfile (); | ||
2027 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | ||
2028 | temp->readConfig(&config); | ||
2029 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | ||
2030 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | ||
2031 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | ||
2032 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | ||
2033 | KOPrefs::instance()->mWriteBackInFuture = 0; | ||
2034 | if ( temp->getWriteBackFuture() ) | ||
2035 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | ||
2036 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | ||
2037 | delete temp; | ||
2038 | setCaption( i18n("Remote file saved to temp file.") ); | 2011 | setCaption( i18n("Remote file saved to temp file.") ); |
@@ -2043,9 +2016,10 @@ void MainWindow::readFileFromSocket() | |||
2043 | } | 2016 | } |
2044 | |||
2045 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); | 2017 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); |
2046 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, bool )), this, SLOT(deleteCommandSocketFinish(KCommandSocket*,bool)) ); | 2018 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
2047 | if ( KOPrefs::instance()->mWriteBackFile ) | 2019 | if ( KOPrefs::instance()->mWriteBackFile ) |
2048 | commandSocket->writeFile( fileName ); | 2020 | commandSocket->writeFile( fileName ); |
2049 | else | 2021 | else { |
2050 | commandSocket->sendStop(); | 2022 | commandSocket->sendStop(); |
2023 | setCaption( i18n("Pi-Sync succesful!") ); | ||
2024 | } | ||
2051 | } | 2025 | } |
@@ -2505,3 +2479,3 @@ KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, | |||
2505 | 2479 | ||
2506 | mRetVal = false; | 2480 | mRetVal = quiet; |
2507 | mTimerSocket = new QTimer ( this ); | 2481 | mTimerSocket = new QTimer ( this ); |
@@ -2540,3 +2514,3 @@ void KCommandSocket::writeFileToSocket() | |||
2540 | if (!file2.open( IO_ReadOnly ) ) { | 2514 | if (!file2.open( IO_ReadOnly ) ) { |
2541 | mRetVal= false; | 2515 | mRetVal= errorW; |
2542 | mSocket->close(); | 2516 | mSocket->close(); |
@@ -2554,3 +2528,3 @@ void KCommandSocket::writeFileToSocket() | |||
2554 | } | 2528 | } |
2555 | mRetVal= true; | 2529 | mRetVal= successW; |
2556 | file2.close(); | 2530 | file2.close(); |
@@ -2570,3 +2544,2 @@ void KCommandSocket::sendStop() | |||
2570 | os2 << "STOP\r\n"; | 2544 | os2 << "STOP\r\n"; |
2571 | mRetVal= true; | ||
2572 | mSocket->close(); | 2545 | mSocket->close(); |
@@ -2606,3 +2579,3 @@ void KCommandSocket::readFileFromSocket() | |||
2606 | mFileString = ""; | 2579 | mFileString = ""; |
2607 | mRetVal = false; | 2580 | mRetVal = errorR; |
2608 | qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); | 2581 | qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); |
@@ -2618,3 +2591,3 @@ void KCommandSocket::readFileFromSocket() | |||
2618 | mFileString = ""; | 2591 | mFileString = ""; |
2619 | mRetVal = true; | 2592 | mRetVal = successR; |
2620 | mSocket->close(); | 2593 | mSocket->close(); |
@@ -2631,3 +2604,3 @@ void KCommandSocket::deleteSocket() | |||
2631 | KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? ")); | 2604 | KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? ")); |
2632 | mRetVal = false; | 2605 | mRetVal = errorR; |
2633 | } | 2606 | } |
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 | |||
63 | Q_OBJECT | 63 | Q_OBJECT |
64 | |||
65 | public: | 64 | public: |
65 | enum state { successR, errorR, successW, errorW, quiet }; | ||
66 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); | 66 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); |
@@ -72,3 +72,3 @@ public: | |||
72 | signals: | 72 | signals: |
73 | void commandFinished( KCommandSocket*, bool ); | 73 | void commandFinished( KCommandSocket*, int ); |
74 | private slots: | 74 | private slots: |
@@ -85,3 +85,3 @@ private slots: | |||
85 | QTimer* mTimerSocket; | 85 | QTimer* mTimerSocket; |
86 | bool mRetVal; | 86 | int mRetVal; |
87 | QTime mTime; | 87 | QTime mTime; |
@@ -108,2 +108,3 @@ class MainWindow : public QMainWindow | |||
108 | static QString defaultFileName(); | 108 | static QString defaultFileName(); |
109 | static QString syncFileName(); | ||
109 | static QString resourcePath(); | 110 | static QString resourcePath(); |
@@ -166,4 +167,3 @@ class MainWindow : public QMainWindow | |||
166 | QTime piTime; | 167 | QTime piTime; |
167 | void deleteCommandSocket(KCommandSocket* s, bool success); | 168 | void deleteCommandSocket(KCommandSocket* s, int state ); |
168 | void deleteCommandSocketFinish(KCommandSocket* s, bool success); | ||
169 | void fillSyncMenu(); | 169 | void fillSyncMenu(); |