summaryrefslogtreecommitdiffabout
path: root/libkdepim
Side-by-side diff
Diffstat (limited to 'libkdepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp63
-rw-r--r--libkdepim/ksyncmanager.h4
2 files changed, 48 insertions, 19 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 7ca3ee0..554c6e5 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -178,29 +178,44 @@ void KSyncManager::slotSyncMenu( int action )
}
if (blockSave())
return;
setBlockSave(true);
+ bool silent = false;
+ if ( action == 999 ) {
+ //special mode for silent syncing
+ action = 1000;
+ silent = true;
+ }
mCurrentSyncProfile = action - 1000 ;
mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
mCurrentSyncName = mLocalMachineName ;
KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
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();
#else
syncSharp();
#endif
@@ -299,12 +314,13 @@ void KSyncManager::enableQuick( bool ask )
QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia );
#else
QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia );
#endif
lay.addWidget( &syncdesktop);
#else
+ mPrefs->mPassiveSyncWithDesktop = false;
QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia );
syncdesktop.hide();
#endif
syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop );
dia.setFixedSize( 230,120 );
@@ -413,13 +429,16 @@ bool KSyncManager::syncWithFile( QString fn , bool quick )
i18n("Sync"), i18n("Cancel"), 0,
0, 1 );
if ( result )
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 ) )
mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
else
mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
@@ -452,13 +471,16 @@ void KSyncManager::multiSync( bool askforPrefs )
mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!"));
return;
}
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.") );
qApp->processEvents();
int num = ringSync() ;
if ( num > 1 )
@@ -684,13 +706,13 @@ void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) );
}
}
}
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 );
QVBoxLayout lay ( &dia );
lay.setSpacing( 5 );
lay.setMargin( 3 );
@@ -713,16 +735,17 @@ void KSyncManager::edit_pisync_options()
le2.setText( mActiveSyncIP );
le3.setText( mActiveSyncPort );
if ( dia.exec() ) {
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 );
dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
QVBoxLayout lay ( &dia );
@@ -763,15 +786,15 @@ void KSyncManager::edit_sync_options()
break;
default:
break;
}
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( )
{
QString retfile = "";
QDialog dia ( mParent, "input-dialog", true );
@@ -861,14 +884,17 @@ void KSyncManager::syncSharp()
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());
bool syncOK = mImplementation->syncExternal(this, resource);
return syncOK;
@@ -932,13 +958,16 @@ QString KSyncManager::syncFileName()
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 ) {
mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
return;
}
@@ -1163,17 +1192,17 @@ void KServerSocket::readBackFileFromSocket()
mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
ts << piFileString;
mSocket->close();
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 );
}
KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name )
{
mPassWord = password;
@@ -1196,13 +1225,13 @@ void KCommandSocket::readFile( QString fn )
mFileName = fn;
mFirst = true;
mSocket->connectToHost( mHost, mPort );
QTextStream os( mSocket );
os.setEncoding( QTextStream::Latin1 );
os << "GET " << mPassWord << "\r\n";
- mTimerSocket->start( 10000 );
+ mTimerSocket->start( 20000 );
}
void KCommandSocket::writeFile( QString fileName )
{
if ( !mSocket ) {
mSocket = new QSocket( this );
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 7b9c499..4a610fa 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -171,14 +171,14 @@ class KSyncManager : public QObject
void syncPhone();
void syncSharp();
void syncKDE();
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;
bool mBlockSaveFlag;
QWidget* mParent;
KSyncInterface* mImplementation;