-rw-r--r-- | libkdepim/ksyncmanager.cpp | 166 |
1 files changed, 92 insertions, 74 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index fad9a76..568c2a9 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp @@ -77,5 +77,5 @@ KSyncManager::~KSyncManager() } -//LR ok + void KSyncManager::fillSyncMenu() { @@ -102,4 +102,5 @@ void KSyncManager::fillSyncMenu() prof << i18n("Sharp_DTM"); prof << i18n("Local_file"); + prof << i18n("Last_file"); KSyncProfile* temp = new KSyncProfile (); temp->setName( prof[0] ); @@ -107,4 +108,6 @@ void KSyncManager::fillSyncMenu() temp->setName( prof[1] ); temp->writeConfig(&config); + temp->setName( prof[2] ); + temp->writeConfig(&config); config.setGroup("General"); config.writeEntry("SyncProfileNames",prof); @@ -127,6 +130,7 @@ void KSyncManager::fillSyncMenu() } else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { - mSyncMenu->setItemEnabled( 1000, false ); + mSyncMenu->removeItem( 1000 ); } + mSyncMenu->removeItem( 1002 ); } @@ -192,23 +196,23 @@ void KSyncManager::slotSyncMenu( int action ) } else if ( action >= 1003 ) { if ( temp->getIsLocalFileSync() ) { - switch(mTargetApp) - { - case (KAPI): - if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) - mLastSyncedLocalFile = temp->getRemoteFileNameAB(); - break; - case (KOPI): - if ( syncWithFile( temp->getRemoteFileName( ), false ) ) - mLastSyncedLocalFile = temp->getRemoteFileName(); - break; - case (PWMPI): - if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) - mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); - break; - default: - qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); - break; + switch(mTargetApp) + { + case (KAPI): + if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) + mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); + break; + case (KOPI): + if ( syncWithFile( temp->getRemoteFileName( ), false ) ) + mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); + break; + case (PWMPI): + if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) + mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); + break; + default: + qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); + break; - } + } } else { if ( temp->getIsPhoneSync() ) { @@ -240,4 +244,5 @@ void KSyncManager::slotSyncMenu( int action ) setBlockSave(false); } + void KSyncManager::enableQuick() { @@ -286,5 +291,4 @@ void KSyncManager::enableQuick() return; } - //connect( mServerSocket, SIGNAL ( saveFile() ),this, SIGNAL ( save() ) ); connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); @@ -294,5 +298,5 @@ void KSyncManager::syncLocalFile() { - QString fn =mLastSyncedLocalFile; + QString fn =mPrefs->mLastSyncedLocalFile; QString ext; @@ -322,4 +326,5 @@ void KSyncManager::syncLocalFile() } + bool KSyncManager::syncWithFile( QString fn , bool quick ) { @@ -354,16 +359,18 @@ bool KSyncManager::syncWithFile( QString fn , bool quick ) mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); if ( ! quick ) - mLastSyncedLocalFile = fn; + mPrefs->mLastSyncedLocalFile = fn; } return ret; } + void KSyncManager::quickSyncLocalFile() { - if ( syncWithFile( mLastSyncedLocalFile, false ) ) { + if ( syncWithFile( mPrefs->mLastSyncedLocalFile, false ) ) { qDebug("quick syncLocalFile() successful "); } } + void KSyncManager::multiSync( bool askforPrefs ) { @@ -372,5 +379,5 @@ void KSyncManager::multiSync( bool askforPrefs ) setBlockSave(true); QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); - if ( QMessageBox::information( mParent, i18n("Sync"), + if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), question, i18n("Yes"), i18n("No"), @@ -381,5 +388,5 @@ void KSyncManager::multiSync( bool askforPrefs ) } mCurrentSyncDevice = i18n("Multiple profiles") ; - mSyncAlgoPrefs = mRingSyncAlgoPrefs; + mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; if ( askforPrefs ) { edit_sync_options(); @@ -395,9 +402,10 @@ void KSyncManager::multiSync( bool askforPrefs ) emit save(); if ( num ) - mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); + mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); else mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); return; } + int KSyncManager::ringSync() { @@ -414,24 +422,24 @@ int KSyncManager::ringSync() temp->readConfig(&config); - QString includeInRingSync; - switch(mTargetApp) - { - case (KAPI): - includeInRingSync = temp->getIncludeInRingSyncAB(); - break; - case (KOPI): - includeInRingSync = temp->getIncludeInRingSync(); - break; - case (PWMPI): - includeInRingSync = temp->getIncludeInRingSyncPWM(); - break; - default: - qDebug("KSyncManager::ringSync: invalid apptype selected"); - break; + QString includeInRingSync; + switch(mTargetApp) + { + case (KAPI): + includeInRingSync = temp->getIncludeInRingSyncAB(); + break; + case (KOPI): + includeInRingSync = temp->getIncludeInRingSync(); + break; + case (PWMPI): + includeInRingSync = temp->getIncludeInRingSyncPWM(); + break; + default: + qDebug("KSyncManager::ringSync: invalid apptype selected"); + break; - } + } - if ( includeInRingSync && ( i < 1 || i > 2 )) { + if ( includeInRingSync && ( i < 1 || i > 2 )) { mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); ++syncedProfiles; @@ -449,22 +457,22 @@ int KSyncManager::ringSync() } else { if ( temp->getIsLocalFileSync() ) { - switch(mTargetApp) - { - case (KAPI): - if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) - mLastSyncedLocalFile = temp->getRemoteFileNameAB(); - break; - case (KOPI): - if ( syncWithFile( temp->getRemoteFileName( ), false ) ) - mLastSyncedLocalFile = temp->getRemoteFileName(); - break; - case (PWMPI): - if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) - mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); - break; - default: - qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); - break; - } + switch(mTargetApp) + { + case (KAPI): + if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) + mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); + break; + case (KOPI): + if ( syncWithFile( temp->getRemoteFileName( ), false ) ) + mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); + break; + case (PWMPI): + if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) + mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); + break; + default: + qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); + break; + } } else { if ( temp->getIsPhoneSync() ) { @@ -473,4 +481,19 @@ int KSyncManager::ringSync() mPhoneModel = temp->getPhoneModel( ); syncPhone(); + } else if ( temp->getIsPiSync() ) { + if ( mTargetApp == KAPI ) { + mPassWordPiSync = temp->getRemotePwAB(); + mActiveSyncPort = temp->getRemotePortAB(); + mActiveSyncIP = temp->getRemoteIPAB(); + } else if ( mTargetApp == KOPI ) { + mPassWordPiSync = temp->getRemotePw(); + mActiveSyncPort = temp->getRemotePort(); + mActiveSyncIP = temp->getRemoteIP(); + } else { + mPassWordPiSync = temp->getRemotePwPWM(); + mActiveSyncPort = temp->getRemotePortPWM(); + mActiveSyncIP = temp->getRemoteIPPWM(); + } + syncPi(); } else syncRemote( temp, false ); @@ -559,5 +582,5 @@ void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) question, i18n("Okay!")) ; - mParent->topLevelWidget()->setCaption (""); + mParent->topLevelWidget()->setCaption ("KDE-Pim"); return; } @@ -565,11 +588,6 @@ void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); - - if ( syncWithFile( localTempFile, true ) ) { -// Event* e = mView->getLastSyncEvent(); -// e->setReadOnly( false ); -// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); -// e->setReadOnly( true ); + if ( mWriteBackFile ) { int fi; @@ -645,4 +663,5 @@ void KSyncManager::edit_sync_options() } + QString KSyncManager::getPassword( ) { @@ -686,9 +705,10 @@ void KSyncManager::confSync() mSyncProfileNames = sp->getSyncProfileNames(); mLocalMachineName = sp->getLocalMachineName (); - fillSyncMenu(); + QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); } void KSyncManager::syncSharp() { + if ( ! syncExternalApplication("sharp") ) qDebug("ERROR sync sharp ");; @@ -713,8 +733,6 @@ bool KSyncManager::syncExternalApplication(QString resource) void KSyncManager::syncPhone() { - emit save(); - qDebug("pending syncPhone(); "); - //mView->syncPhone(); + syncExternalApplication("phone"); } @@ -768,4 +786,5 @@ QString KSyncManager::syncFileName() } + void KSyncManager::syncPi() { @@ -1154,3 +1173,2 @@ void KCommandSocket::deleteSocket() emit commandFinished( this, mRetVal ); } - |