-rw-r--r-- | libkdepim/kpimprefs.cpp | 9 | ||||
-rw-r--r-- | libkdepim/kpimprefs.h | 3 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 166 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.h | 3 |
4 files changed, 103 insertions, 78 deletions
diff --git a/libkdepim/kpimprefs.cpp b/libkdepim/kpimprefs.cpp index 0a2f5f1..c21ebaa 100644 --- a/libkdepim/kpimprefs.cpp +++ b/libkdepim/kpimprefs.cpp @@ -37,11 +37,18 @@ $Id$ KPimPrefs::KPimPrefs( const QString &name ) : KPrefs( name ) { - config()->setGroup("General"); +#ifdef _WIN32_ + QString hdp= locateLocal("data","korganizer")+"\\\\"; +#else + QString hdp= locateLocal("data","korganizer")+"/"; +#endif + config()->setGroup("SyncOptions"); addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" ); addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" ); + addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" ); + addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); } KPimPrefs::~KPimPrefs() { diff --git a/libkdepim/kpimprefs.h b/libkdepim/kpimprefs.h index fde8093..9346f7d 100644 --- a/libkdepim/kpimprefs.h +++ b/libkdepim/kpimprefs.h @@ -56,9 +56,10 @@ class KPimPrefs : public KPrefs public: QStringList mCustomCategories; QString mPassiveSyncPort; QString mPassiveSyncPw; - + int mRingSyncAlgoPrefs; + QString mLastSyncedLocalFile; protected: virtual void setCategoryDefaults(); diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index fad9a76..568c2a9 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp @@ -75,9 +75,9 @@ KSyncManager::~KSyncManager() { delete bar; } -//LR ok + void KSyncManager::fillSyncMenu() { if ( mSyncMenu->count() ) mSyncMenu->clear(); @@ -100,13 +100,16 @@ void KSyncManager::fillSyncMenu() if ( prof.count() < 2 ) { prof.clear(); prof << i18n("Sharp_DTM"); prof << i18n("Local_file"); + prof << i18n("Last_file"); KSyncProfile* temp = new KSyncProfile (); temp->setName( prof[0] ); temp->writeConfig(&config); temp->setName( prof[1] ); temp->writeConfig(&config); + temp->setName( prof[2] ); + temp->writeConfig(&config); config.setGroup("General"); config.writeEntry("SyncProfileNames",prof); config.writeEntry("ExternSyncProfiles","Sharp_DTM"); config.sync(); @@ -125,10 +128,11 @@ void KSyncManager::fillSyncMenu() if ( mTargetApp == PWMPI) { mSyncMenu->removeItem( 1000 ); } else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { - mSyncMenu->setItemEnabled( 1000, false ); + mSyncMenu->removeItem( 1000 ); } + mSyncMenu->removeItem( 1002 ); } void KSyncManager::slotSyncMenu( int action ) { @@ -190,27 +194,27 @@ void KSyncManager::slotSyncMenu( int action ) quickSyncLocalFile(); } 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() ) { mPhoneDevice = temp->getPhoneDevice( ) ; mPhoneConnection = temp->getPhoneConnection( ); @@ -238,8 +242,9 @@ void KSyncManager::slotSyncMenu( int action ) } delete temp; setBlockSave(false); } + void KSyncManager::enableQuick() { QDialog dia ( 0, "input-dialog", true ); QLineEdit lab ( &dia ); @@ -284,17 +289,16 @@ void KSyncManager::enableQuick() delete mServerSocket; mServerSocket = 0; 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 ) ) ); } void KSyncManager::syncLocalFile() { - QString fn =mLastSyncedLocalFile; + QString fn =mPrefs->mLastSyncedLocalFile; QString ext; switch(mTargetApp) { @@ -320,8 +324,9 @@ void KSyncManager::syncLocalFile() qDebug("syncLocalFile() successful "); } } + bool KSyncManager::syncWithFile( QString fn , bool quick ) { bool ret = false; QFileInfo info; @@ -352,36 +357,38 @@ bool KSyncManager::syncWithFile( QString fn , bool quick ) mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); else 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 ) { if (blockSave()) return; 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"), 0, 0 ) != 0 ) { setBlockSave(false); mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); return; } mCurrentSyncDevice = i18n("Multiple profiles") ; - mSyncAlgoPrefs = mRingSyncAlgoPrefs; + mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; if ( askforPrefs ) { edit_sync_options(); mRingSyncAlgoPrefs = mSyncAlgoPrefs; } @@ -393,13 +400,14 @@ void KSyncManager::multiSync( bool askforPrefs ) setBlockSave(false); if ( num ) 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() { int syncedProfiles = 0; unsigned int i; @@ -412,28 +420,28 @@ int KSyncManager::ringSync() mCurrentSyncProfile = i; temp->setName(syncProfileNames[mCurrentSyncProfile]); 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; // mAskForPreferences = temp->getAskForPreferences(); mWriteBackFile = temp->getWriteBackFile(); @@ -447,32 +455,47 @@ int KSyncManager::ringSync() if ( i == 0 ) { syncSharp(); } 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() ) { mPhoneDevice = temp->getPhoneDevice( ) ; mPhoneConnection = temp->getPhoneConnection( ); 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 ); } @@ -557,21 +580,16 @@ void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; QMessageBox::information( mParent, i18n("Sync - ERROR"), question, i18n("Okay!")) ; - mParent->topLevelWidget()->setCaption (""); + mParent->topLevelWidget()->setCaption ("KDE-Pim"); return; } mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); //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; if ( (fi = postCommand.find("$PWD$")) > 0 ) { QString pwd = getPassword(); @@ -643,8 +661,9 @@ void KSyncManager::edit_sync_options() } } + QString KSyncManager::getPassword( ) { QString retfile = ""; QDialog dia ( mParent, "input-dialog", true ); @@ -684,13 +703,14 @@ void KSyncManager::confSync() #endif sp->exec(); mSyncProfileNames = sp->getSyncProfileNames(); mLocalMachineName = sp->getLocalMachineName (); - fillSyncMenu(); + QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); } void KSyncManager::syncSharp() { + if ( ! syncExternalApplication("sharp") ) qDebug("ERROR sync sharp ");; } @@ -711,12 +731,10 @@ bool KSyncManager::syncExternalApplication(QString resource) } void KSyncManager::syncPhone() { - emit save(); - qDebug("pending syncPhone(); "); - //mView->syncPhone(); + syncExternalApplication("phone"); } void KSyncManager::showProgressBar(int percentage, QString caption, int total) @@ -766,8 +784,9 @@ QString KSyncManager::syncFileName() return (QString( "/tmp/" )+ fn ); #endif } + void KSyncManager::syncPi() { qApp->processEvents(); bool ok; @@ -1152,5 +1171,4 @@ void KCommandSocket::deleteSocket() delete mSocket; mSocket = 0; emit commandFinished( this, mRetVal ); } - diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index 25892d8..7027894 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h @@ -116,8 +116,9 @@ class KSyncManager : public QObject KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); ~KSyncManager() ; + void multiSync( bool askforPrefs ); bool blockSave() { return mBlockSaveFlag; } void setBlockSave(bool sa) { mBlockSaveFlag = sa; } void setDefaultFileName( QString s) { mDefFileName = s ;} QString defaultFileName() { return mDefFileName ;} @@ -146,9 +147,8 @@ class KSyncManager : public QObject int mWriteBackInFuture; QString mPhoneDevice; QString mPhoneConnection; QString mPhoneModel; - QString mLastSyncedLocalFile; // save! QString mPassWordPiSync; QString mActiveSyncPort; QString mActiveSyncIP ; @@ -177,9 +177,8 @@ class KSyncManager : public QObject void syncLocalFile(); void syncPhone(); void syncSharp(); bool syncExternalApplication(QString); - void multiSync( bool askforPrefs ); int mCurrentSyncProfile ; void syncRemote( KSyncProfile* prof, bool ask = true); void edit_sync_options(); int ringSync(); |