author | zautrix <zautrix> | 2004-09-22 23:36:37 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-22 23:36:37 (UTC) |
commit | e2bc785d2f98d2aeac6ab6a5e39ff4f6e679517b (patch) (side-by-side diff) | |
tree | f45771acfd61a0ddda6b253082f243acac473d33 /korganizer | |
parent | 772411a6c16f9b2299bd173116faeb4482325bcc (diff) | |
download | kdepimpi-e2bc785d2f98d2aeac6ab6a5e39ff4f6e679517b.zip kdepimpi-e2bc785d2f98d2aeac6ab6a5e39ff4f6e679517b.tar.gz kdepimpi-e2bc785d2f98d2aeac6ab6a5e39ff4f6e679517b.tar.bz2 |
bugfixes
-rw-r--r-- | korganizer/mainwindow.cpp | 28 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 1 |
2 files changed, 17 insertions, 12 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index ebe761a..2e6b5c8 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -64,24 +64,25 @@ using namespace KCal; #endif #include "mainwindow.h" int globalFlagBlockStartup; MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : QMainWindow( parent, name ) { #ifdef DESKTOP_VERSION setFont( QFont("Arial"), 14 ); #endif mCommandSocket = 0; + mCommandSocketFinish = 0; mSyncActionDialog = 0; mServerSocket = 0; mClosed = false; //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; QString confFile = locateLocal("config","korganizerrc"); QFileInfo finf ( confFile ); bool showWarning = !finf.exists(); setIcon(SmallIcon( "ko24" ) ); mBlockAtStartup = true; mFlagKeyPressed = false; setCaption("KOrganizer/Pi"); KOPrefs *p = KOPrefs::instance(); @@ -1972,25 +1973,24 @@ void MainWindow::sendFile(QSocket* socket) while ( ! ts.atEnd() ) { os << ts.readLine() << "\n"; } //os << ts.read(); socket->close(); file.close(); setCaption( i18n("File sent. Waiting to get back synced file") ); qDebug("file sent "); } void MainWindow::getFile(QSocket* socket) { setCaption( i18n("Receiving synced file...") ); - qDebug("MainWindow::sendFile(QSocket* s) "); QString fileName = defaultFileName(); QFile file( fileName ); if (!file.open( IO_WriteOnly ) ) { setCaption( i18n("Error open file") ); delete mSyncActionDialog; mSyncActionDialog = 0; qDebug("error open cal file "); return ; } @@ -2059,28 +2059,30 @@ void MainWindow::performQuick() } void MainWindow::performQuickQuick() { // setCaption( i18n("") ); bool ok; Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); if ( ! ok ) { setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); return; } - if ( mCommandSocket ) - delete mCommandSocket; + if ( !mCommandSocket ) { mCommandSocket = new QSocket( this ); + // delete mCommandSocket; + //mCommandSocket = new QSocket( this ); connect( mCommandSocket, SIGNAL(readyRead()), this, SLOT(readFileFromSocket()) ); + } QString host = KOPrefs::instance()->mActiveSyncIP; mCommandSocket->connectToHost( host, port ); QTextStream os( mCommandSocket ); os.setEncoding( QTextStream::UnicodeUTF8 ); os << "GET\r\n"; setCaption( i18n("Sending request for remote file ...") ); } void MainWindow::readFileFromSocket() { setCaption( i18n("Receiving remote file ...") ); qDebug("MainWindow::readFileFromSocket() "); @@ -2103,79 +2105,81 @@ QString fileName; QTextStream ts( &file ); ts.setCodec( QTextCodec::codecForName("utf8") ); bool first = true; while ( mCommandSocket->canReadLine () || first) { first = false; while ( mCommandSocket->canReadLine () ) { ts << mCommandSocket->readLine (); } mCommandSocket->waitForMore ( 5000 ); } file.close(); mCommandSocket->close(); - delete mCommandSocket; + //delete mCommandSocket; setCaption( i18n("Remote file saved to temp file.") ); - mCommandSocket = 0; + //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(); setCaption( i18n("Remote file saved to temp file.") ); if ( ! syncWithFile( fileName , true ) ) { setCaption( i18n("Syncing failed.") ); qDebug("Syncing failed "); return; } - mCommandSocket = new QSocket( this ); - QString host = KOPrefs::instance()->mActiveSyncIP; - mCommandSocket->connectToHost( KOPrefs::instance()->mActiveSyncIP, KOPrefs::instance()->mActiveSyncPort.toUInt() ); + if ( !mCommandSocketFinish ) { + mCommandSocketFinish = new QSocket( this ); + } + mCommandSocketFinish->connectToHost( KOPrefs::instance()->mActiveSyncIP, KOPrefs::instance()->mActiveSyncPort.toUInt() ); + QString host = KOPrefs::instance()->mActiveSyncIP; QFile file2( fileName ); if (!file2.open( IO_ReadOnly ) ) { setCaption( i18n("Error: Cannot open temp file for read.") ); qDebug("error open cal file "); return ; } setCaption( i18n("Sending back synced file...") ); QTextStream ts2( &file2 ); ts2.setCodec( QTextCodec::codecForName("utf8") ); - QTextStream os2( mCommandSocket ); + QTextStream os2( mCommandSocketFinish ); os2.setCodec( QTextCodec::codecForName("utf8") ); //os.setEncoding( QTextStream::UnicodeUTF8 ); if ( KOPrefs::instance()->mWriteBackFile ) { os2 << "PUT\r\n"; while ( ! ts2.atEnd() ) { os2 << ts2.readLine() << "\n"; } } else { os2 << "STOP\r\n"; } - mCommandSocket->close(); + mCommandSocketFinish->close(); file.close(); - delete mCommandSocket; - mCommandSocket = 0; + //delete ( mCommandSocket); + //mCommandSocket = 0; qDebug("Syncing succesful! "); setCaption( i18n("Easy-Pi-Sync succesful!") ); } void MainWindow::syncLocalFile() { QString fn =KOPrefs::instance()->mLastSyncedLocalFile; fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index 9bb2302..5985d56 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h @@ -138,24 +138,25 @@ class MainWindow : public QMainWindow void displayFile( QString, QString); void enableIncidenceActions( bool ); private slots: void fillSyncMenu(); void sendFile(QSocket* s); void getFile(QSocket* socket); void readFileFromSocket(); void endConnect(); private: QSocket* mCommandSocket; + QSocket* mCommandSocketFinish; KServerSocket * mServerSocket; bool mClosed; void saveOnClose(); int mCurrentSyncProfile; void enableQuick(); void performQuick(); void performQuickQuick(); void syncRemote( KSyncProfile* , bool ask = true); bool mFlagKeyPressed; bool mBlockAtStartup; QPEToolBar *iconToolBar; void initActions(); |