From 46ea2933c9f67e77fb5c6cd93237efc755f28b62 Mon Sep 17 00:00:00 2001 From: zautrix Date: Wed, 20 Oct 2004 16:27:05 +0000 Subject: made KDE sync perfect --- (limited to 'libkdepim') diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 7ca3ee0..554c6e5 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp @@ -181,6 +181,12 @@ void KSyncManager::slotSyncMenu( int action ) return; setBlockSave(true); + bool silent = false; + if ( action == 999 ) { + //special mode for silent syncing + action = 1000; + silent = true; + } mCurrentSyncProfile = action - 1000 ; mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; @@ -189,15 +195,24 @@ void KSyncManager::slotSyncMenu( int action ) KSyncProfile* temp = new KSyncProfile (); temp->setName(mSyncProfileNames[mCurrentSyncProfile]); temp->readConfig(&config); - mAskForPreferences = temp->getAskForPreferences(); - mSyncAlgoPrefs = temp->getSyncPrefs(); - mWriteBackFile = temp->getWriteBackFile(); + if (silent) { + mAskForPreferences = false; + mShowSyncSummary = false; + mWriteBackFile = true; + mSyncAlgoPrefs = 2;// take newest + } + else { + mAskForPreferences = temp->getAskForPreferences(); + mShowSyncSummary = temp->getShowSummaryAfterSync(); + mWriteBackFile = temp->getWriteBackFile(); + mSyncAlgoPrefs = temp->getSyncPrefs(); + } mWriteBackExistingOnly = temp->getWriteBackExisting(); mIsKapiFile = temp->getIsKapiFile(); mWriteBackInFuture = 0; if ( temp->getWriteBackFuture() ) mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); - mShowSyncSummary = temp->getShowSummaryAfterSync(); + if ( action == 1000 ) { #ifdef DESKTOP_VERSION syncKDE(); @@ -302,6 +317,7 @@ void KSyncManager::enableQuick( bool ask ) #endif lay.addWidget( &syncdesktop); #else + mPrefs->mPassiveSyncWithDesktop = false; QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); syncdesktop.hide(); #endif @@ -416,7 +432,10 @@ bool KSyncManager::syncWithFile( QString fn , bool quick ) return false; } if ( mAskForPreferences ) - edit_sync_options(); + if ( !edit_sync_options()) { + mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); + return false; + } if ( result == 0 ) { //qDebug("Now sycing ... "); if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) @@ -455,7 +474,10 @@ void KSyncManager::multiSync( bool askforPrefs ) mCurrentSyncDevice = i18n("Multiple profiles") ; mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; if ( askforPrefs ) { - edit_sync_options(); + if ( !edit_sync_options()) { + mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); + return; + } mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; } mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); @@ -687,7 +709,7 @@ void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) } return; } -void KSyncManager::edit_pisync_options() +bool KSyncManager::edit_pisync_options() { QDialog dia( mParent, "dia", true ); dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); @@ -716,10 +738,11 @@ void KSyncManager::edit_pisync_options() mPassWordPiSync = le1.text(); mActiveSyncPort = le3.text(); mActiveSyncIP = le2.text(); + return true; } - + return false; } -void KSyncManager::edit_sync_options() +bool KSyncManager::edit_sync_options() { QDialog dia( mParent, "dia", true ); @@ -766,9 +789,9 @@ void KSyncManager::edit_sync_options() } if ( dia.exec() ) { mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; + return true; } - - + return false; } QString KSyncManager::getPassword( ) @@ -864,8 +887,11 @@ bool KSyncManager::syncExternalApplication(QString resource) emit save(); - if ( mAskForPreferences ) - edit_sync_options(); + if ( mAskForPreferences ) + if ( !edit_sync_options()) { + mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); + return false; + } qDebug("Sync extern %s", resource.latin1()); @@ -935,7 +961,10 @@ void KSyncManager::syncPi() mPisyncFinished = false; qApp->processEvents(); if ( mAskForPreferences ) - edit_pisync_options(); + if ( !edit_pisync_options()) { + mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); + return; + } bool ok; Q_UINT16 port = mActiveSyncPort.toUInt(&ok); if ( ! ok ) { @@ -1166,11 +1195,11 @@ void KServerSocket::readBackFileFromSocket() if ( mSocket->state() == QSocket::Idle ) QTimer::singleShot( 10, this , SLOT ( discardClient())); file.close(); + piFileString = ""; + emit file_received( true ); delete mSyncActionDialog; mSyncActionDialog = 0; - piFileString = ""; blockRC = false; - emit file_received( true ); } @@ -1199,7 +1228,7 @@ void KCommandSocket::readFile( QString fn ) QTextStream os( mSocket ); os.setEncoding( QTextStream::Latin1 ); os << "GET " << mPassWord << "\r\n"; - mTimerSocket->start( 10000 ); + mTimerSocket->start( 20000 ); } void KCommandSocket::writeFile( QString fileName ) diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index 7b9c499..4a610fa 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h @@ -174,8 +174,8 @@ class KSyncManager : public QObject bool syncExternalApplication(QString); int mCurrentSyncProfile ; void syncRemote( KSyncProfile* prof, bool ask = true); - void edit_sync_options(); - void edit_pisync_options(); + bool edit_sync_options(); + bool edit_pisync_options(); int ringSync(); QString getPassword( ); bool mPisyncFinished; -- cgit v0.9.0.2