author | zautrix <zautrix> | 2004-10-07 17:51:17 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-07 17:51:17 (UTC) |
commit | 1f1538e5707b59bfcff2014901f29a65589229e3 (patch) (side-by-side diff) | |
tree | 0d91a303524e6ac9f7c954f01a0e1d09d0e305e7 /libkdepim | |
parent | bb8293c794d82a57bc93af85ccd89b601356d577 (diff) | |
download | kdepimpi-1f1538e5707b59bfcff2014901f29a65589229e3.zip kdepimpi-1f1538e5707b59bfcff2014901f29a65589229e3.tar.gz kdepimpi-1f1538e5707b59bfcff2014901f29a65589229e3.tar.bz2 |
many cleanups
-rw-r--r-- | libkdepim/kpimprefs.cpp | 9 | ||||
-rw-r--r-- | libkdepim/kpimprefs.h | 3 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 72 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.h | 3 |
4 files changed, 56 insertions, 31 deletions
diff --git a/libkdepim/kpimprefs.cpp b/libkdepim/kpimprefs.cpp index 0a2f5f1..c21ebaa 100644 --- a/libkdepim/kpimprefs.cpp +++ b/libkdepim/kpimprefs.cpp @@ -38,9 +38,16 @@ $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 @@ -57,7 +57,8 @@ class KPimPrefs : public KPrefs QStringList mCustomCategories; QString mPassiveSyncPort; QString mPassiveSyncPw; - + int mRingSyncAlgoPrefs; + QString mLastSyncedLocalFile; protected: diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index fad9a76..568c2a9 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp @@ -76,7 +76,7 @@ KSyncManager::~KSyncManager() delete bar; } -//LR ok + void KSyncManager::fillSyncMenu() { if ( mSyncMenu->count() ) @@ -101,11 +101,14 @@ void KSyncManager::fillSyncMenu() 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"); @@ -126,8 +129,9 @@ void KSyncManager::fillSyncMenu() 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 ) @@ -195,15 +199,15 @@ void KSyncManager::slotSyncMenu( int action ) { case (KAPI): if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) - mLastSyncedLocalFile = temp->getRemoteFileNameAB(); + mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); break; case (KOPI): if ( syncWithFile( temp->getRemoteFileName( ), false ) ) - mLastSyncedLocalFile = temp->getRemoteFileName(); + mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); break; case (PWMPI): if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) - mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); + mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); break; default: qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); @@ -239,6 +243,7 @@ void KSyncManager::slotSyncMenu( int action ) delete temp; setBlockSave(false); } + void KSyncManager::enableQuick() { QDialog dia ( 0, "input-dialog", true ); @@ -285,7 +290,6 @@ void KSyncManager::enableQuick() 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 ) ) ); } @@ -293,7 +297,7 @@ void KSyncManager::enableQuick() void KSyncManager::syncLocalFile() { - QString fn =mLastSyncedLocalFile; + QString fn =mPrefs->mLastSyncedLocalFile; QString ext; switch(mTargetApp) @@ -321,6 +325,7 @@ void KSyncManager::syncLocalFile() } } + bool KSyncManager::syncWithFile( QString fn , bool quick ) { bool ret = false; @@ -353,25 +358,27 @@ bool KSyncManager::syncWithFile( QString fn , bool quick ) 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 ) { @@ -380,7 +387,7 @@ void KSyncManager::multiSync( bool askforPrefs ) return; } mCurrentSyncDevice = i18n("Multiple profiles") ; - mSyncAlgoPrefs = mRingSyncAlgoPrefs; + mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; if ( askforPrefs ) { edit_sync_options(); mRingSyncAlgoPrefs = mSyncAlgoPrefs; @@ -394,11 +401,12 @@ void KSyncManager::multiSync( bool askforPrefs ) 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; @@ -452,15 +460,15 @@ int KSyncManager::ringSync() { case (KAPI): if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) - mLastSyncedLocalFile = temp->getRemoteFileNameAB(); + mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); break; case (KOPI): if ( syncWithFile( temp->getRemoteFileName( ), false ) ) - mLastSyncedLocalFile = temp->getRemoteFileName(); + mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); break; case (PWMPI): if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) - mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); + mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); break; default: qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); @@ -472,6 +480,21 @@ int KSyncManager::ringSync() 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 ); @@ -558,19 +581,14 @@ void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) 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 ) { @@ -644,6 +662,7 @@ void KSyncManager::edit_sync_options() } + QString KSyncManager::getPassword( ) { QString retfile = ""; @@ -685,11 +704,12 @@ void KSyncManager::confSync() 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 ");; } @@ -712,10 +732,8 @@ bool KSyncManager::syncExternalApplication(QString resource) void KSyncManager::syncPhone() { - emit save(); - qDebug("pending syncPhone(); "); - //mView->syncPhone(); + syncExternalApplication("phone"); } @@ -767,6 +785,7 @@ QString KSyncManager::syncFileName() #endif } + void KSyncManager::syncPi() { qApp->processEvents(); @@ -1153,4 +1172,3 @@ void KCommandSocket::deleteSocket() 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 @@ -117,6 +117,7 @@ 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 ;} @@ -147,7 +148,6 @@ class KSyncManager : public QObject QString mPhoneDevice; QString mPhoneConnection; QString mPhoneModel; - QString mLastSyncedLocalFile; // save! QString mPassWordPiSync; QString mActiveSyncPort; QString mActiveSyncIP ; @@ -178,7 +178,6 @@ class KSyncManager : public QObject void syncPhone(); void syncSharp(); bool syncExternalApplication(QString); - void multiSync( bool askforPrefs ); int mCurrentSyncProfile ; void syncRemote( KSyncProfile* prof, bool ask = true); void edit_sync_options(); |