summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp509
-rw-r--r--kaddressbook/kabcore.h38
-rw-r--r--kaddressbook/kabprefs.h18
-rw-r--r--libkdepim/kpimprefs.h21
-rw-r--r--libkdepim/ksyncmanager.cpp274
-rw-r--r--libkdepim/ksyncmanager.h79
-rw-r--r--libkdepim/libkdepimE.pro2
7 files changed, 335 insertions, 606 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index df634d0..f222234 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -160,3 +160,3 @@ bool pasteWithNewUid = true;
KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
- : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
+ : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
@@ -165,3 +165,3 @@ KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, con
KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
- : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
+ : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
@@ -170,4 +170,4 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const
{
-
- mBlockSaveFlag = false;
+ // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
+ // syncManager->setBlockSave(false);
mExtensionBarSplitter = 0;
@@ -271,2 +271,4 @@ KABCore::~KABCore()
KABC::StdAddressBook::close();
+
+ delete syncManager;
}
@@ -1076,5 +1078,5 @@ void KABCore::save()
{
- if (mBlockSaveFlag)
+ if (syncManager->blockSave())
return;
- mBlockSaveFlag = true;
+ syncManager->setBlockSave(true);
if ( !mModified )
@@ -1099,3 +1101,3 @@ void KABCore::save()
setModified( false );
- mBlockSaveFlag = false;
+ syncManager->setBlockSave(false);
}
@@ -1538,2 +1540,5 @@ void KABCore::initGUI()
+ syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
+ syncManager->setBlockSave(false);
+
@@ -1900,4 +1905,4 @@ void KABCore::addActionsManually()
- connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) );
- fillSyncMenu();
+ connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
+ syncManager->fillSyncMenu();
@@ -2103,412 +2108,2 @@ void KABCore::faq()
-
-void KABCore::fillSyncMenu()
-{
- if ( syncMenu->count() )
- syncMenu->clear();
- syncMenu->insertItem( i18n("Configure..."), 0 );
- syncMenu->insertSeparator();
- syncMenu->insertItem( i18n("Multiple sync"), 1 );
- syncMenu->insertSeparator();
- KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
- config.setGroup("General");
- QStringList prof = config.readListEntry("SyncProfileNames");
- KABPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
- if ( prof.count() < 3 ) {
- 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();
- delete temp;
- }
- KABPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
- KABPrefs::instance()->mSyncProfileNames = prof;
- int i;
- for ( i = 0; i < prof.count(); ++i ) {
-
- syncMenu->insertItem( prof[i], 1000+i );
- if ( i == 2 )
- syncMenu->insertSeparator();
- }
- QDir app_dir;
- if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
- syncMenu->setItemEnabled( false , 1000 );
- }
- //probaly useless
- //mView->setupExternSyncProfiles();
-}
-void KABCore::slotSyncMenu( int action )
-{
- //qDebug("syncaction %d ", action);
- if ( action == 0 ) {
-
- // seems to be a Qt2 event handling bug
- // syncmenu.clear causes a segfault at first time
- // when we call it after the main event loop, it is ok
- // same behaviour when calling OM/Pi via QCOP for the first time
- QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
- //confSync();
-
- return;
- }
- if ( action == 1 ) {
- multiSync( true );
- return;
- }
-
- if (mBlockSaveFlag)
- return;
- mBlockSaveFlag = true;
- mCurrentSyncProfile = action - 1000 ;
- mCurrentSyncDevice = KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ;
- mCurrentSyncName = KABPrefs::instance()->mLocalMachineName ;
- KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
- KSyncProfile* temp = new KSyncProfile ();
- temp->setName(KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
- temp->readConfig(&config);
- KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
- KABPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
- KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
- KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
- KABPrefs::instance()->mWriteBackInFuture = 0;
- if ( temp->getWriteBackFuture() )
- KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
- KABPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
- if ( action == 1000 ) {
- syncSharp();
-
- } else if ( action == 1001 ) {
- syncLocalFile();
-
- } else if ( action == 1002 ) {
- quickSyncLocalFile();
-
- } else if ( action >= 1003 ) {
- if ( temp->getIsLocalFileSync() ) {
- if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
- KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
- } else {
- if ( temp->getIsPhoneSync() ) {
- KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
- KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
- KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
- syncPhone();
- } else
- syncRemote( temp );
-
- }
- }
- delete temp;
- mBlockSaveFlag = false;
-}
-
-void KABCore::syncLocalFile()
-{
-
- QString fn =KABPrefs::instance()->mLastSyncedLocalFile;
-
- fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
- if ( fn == "" )
- return;
- if ( syncWithFile( fn, false ) ) {
- qDebug("syncLocalFile() successful ");
- }
-
-}
-bool KABCore::syncWithFile( QString fn , bool quick )
-{
- bool ret = false;
- QFileInfo info;
- info.setFile( fn );
- QString mess;
- bool loadbup = true;
- if ( !info. exists() ) {
- mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
- int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
- mess );
- return ret;
- }
- int result = 0;
- if ( !quick ) {
- mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
- result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
- mess,
- i18n("Sync"), i18n("Cancel"), 0,
- 0, 1 );
- if ( result )
- return false;
- }
- if ( KABPrefs::instance()->mAskForPreferences )
- edit_sync_options();
- if ( result == 0 ) {
- //qDebug("Now sycing ... ");
- if ( ret = syncAB( fn, KABPrefs::instance()->mSyncAlgoPrefs ) )
- setCaption( i18n("Synchronization successful") );
- else
- setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
- if ( ! quick )
- KABPrefs::instance()->mLastSyncedLocalFile = fn;
- setModified();
- }
- return ret;
-}
-void KABCore::quickSyncLocalFile()
-{
-
- if ( syncWithFile( KABPrefs::instance()->mLastSyncedLocalFile, false ) ) {
- qDebug("quick syncLocalFile() successful ");
-
- }
-}
-void KABCore::multiSync( bool askforPrefs )
-{
- if (mBlockSaveFlag)
- return;
- mBlockSaveFlag = 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( this, i18n("KO/Pi Sync"),
- question,
- i18n("Yes"), i18n("No"),
- 0, 0 ) != 0 ) {
- mBlockSaveFlag = false;
- setCaption(i18n("Aborted! Nothing synced!"));
- return;
- }
- mCurrentSyncDevice = i18n("Multiple profiles") ;
- KABPrefs::instance()->mSyncAlgoPrefs = KABPrefs::instance()->mRingSyncAlgoPrefs;
- if ( askforPrefs ) {
- edit_sync_options();
- KABPrefs::instance()->mRingSyncAlgoPrefs = KABPrefs::instance()->mSyncAlgoPrefs;
- }
- setCaption(i18n("Multiple sync started.") );
- qApp->processEvents();
- int num = ringSync() ;
- if ( num > 1 )
- ringSync();
- mBlockSaveFlag = false;
- if ( num )
- save();
- if ( num )
- setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
- else
- setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
- return;
-}
-int KABCore::ringSync()
-{
- int syncedProfiles = 0;
- int i;
- QTime timer;
- KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
- QStringList syncProfileNames = KABPrefs::instance()->mSyncProfileNames;
- KSyncProfile* temp = new KSyncProfile ();
- KABPrefs::instance()->mAskForPreferences = false;
- for ( i = 0; i < syncProfileNames.count(); ++i ) {
- mCurrentSyncProfile = i;
- temp->setName(syncProfileNames[mCurrentSyncProfile]);
- temp->readConfig(&config);
- if ( temp->getIncludeInRingSyncAB() && ( i < 1 || i > 2 )) {
- setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
- ++syncedProfiles;
- // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
- KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
- KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
- KABPrefs::instance()->mWriteBackInFuture = 0;
- if ( temp->getWriteBackFuture() )
- KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
- KABPrefs::instance()->mShowSyncSummary = false;
- mCurrentSyncDevice = syncProfileNames[i] ;
- mCurrentSyncName = KABPrefs::instance()->mLocalMachineName;
- if ( i == 0 ) {
- syncSharp();
- } else {
- if ( temp->getIsLocalFileSync() ) {
- if ( syncWithFile( temp->getRemoteFileNameAB( ), true ) )
- KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
- } else {
- if ( temp->getIsPhoneSync() ) {
- KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
- KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
- KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
- syncPhone();
- } else
- syncRemote( temp, false );
-
- }
- }
- timer.start();
- setCaption(i18n("Multiple sync in progress ... please wait!") );
- while ( timer.elapsed () < 2000 ) {
- qApp->processEvents();
-#ifndef _WIN32_
- sleep (1);
-#endif
- }
-
- }
-
- }
- delete temp;
- return syncedProfiles;
-}
-
-void KABCore::syncRemote( KSyncProfile* prof, bool ask)
-{
- QString question;
- if ( ask ) {
- question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
- if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
- question,
- i18n("Yes"), i18n("No"),
- 0, 0 ) != 0 )
- return;
- }
- QString command = prof->getPreSyncCommandAB();
- int fi;
- if ( (fi = command.find("$PWD$")) > 0 ) {
- QString pwd = getPassword();
- command = command.left( fi )+ pwd + command.mid( fi+5 );
-
- }
- int maxlen = 30;
- if ( QApplication::desktop()->width() > 320 )
- maxlen += 25;
- setCaption ( i18n( "Copy remote file to local machine..." ) );
- int fileSize = 0;
- int result = system ( command );
- // 0 : okay
- // 256: no such file or dir
- //
- qDebug("KO: Remote copy result(0 = okay): %d ",result );
- if ( result != 0 ) {
- int len = maxlen;
- while ( len < command.length() ) {
- command.insert( len , "\n" );
- len += maxlen +2;
- }
- 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 (command) ;
- QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
- question,
- i18n("Okay!")) ;
- setCaption ("KO/Pi");
- return;
- }
- setCaption ( i18n( "Copying succeed." ) );
- //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
- if ( syncWithFile( prof->getLocalTempFileAB(), true ) ) {
-// Event* e = mView->getLastSyncEvent();
-// e->setReadOnly( false );
-// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
-// e->setReadOnly( true );
- if ( KABPrefs::instance()->mWriteBackFile ) {
- command = prof->getPostSyncCommandAB();
- int fi;
- if ( (fi = command.find("$PWD$")) > 0 ) {
- QString pwd = getPassword();
- command = command.left( fi )+ pwd + command.mid( fi+5 );
-
- }
- setCaption ( i18n( "Writing back file ..." ) );
- result = system ( command );
- qDebug("KO: Writing back file result: %d ", result);
- if ( result != 0 ) {
- setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
- return;
- } else {
- setCaption ( i18n( "Syncronization sucessfully completed" ) );
- }
- }
- }
- return;
-}
-#include <qpushbutton.h>
-#include <qradiobutton.h>
-#include <qbuttongroup.h>
-void KABCore::edit_sync_options()
-{
- //mDialogManager->showSyncOptions();
- //KABPrefs::instance()->mSyncAlgoPrefs
- QDialog dia( this, "dia", true );
- dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
- QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
- QVBoxLayout lay ( &dia );
- lay.setSpacing( 2 );
- lay.setMargin( 3 );
- lay.addWidget(&gr);
- QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
- QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
- QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
- QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
- QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
- QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
- //QRadioButton both( i18n("Take both on conflict"), &gr );
- QPushButton pb ( "OK", &dia);
- lay.addWidget( &pb );
- connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
- switch ( KABPrefs::instance()->mSyncAlgoPrefs ) {
- case 0:
- loc.setChecked( true);
- break;
- case 1:
- rem.setChecked( true );
- break;
- case 2:
- newest.setChecked( true);
- break;
- case 3:
- ask.setChecked( true);
- break;
- case 4:
- f_loc.setChecked( true);
- break;
- case 5:
- f_rem.setChecked( true);
- break;
- case 6:
- // both.setChecked( true);
- break;
- default:
- break;
- }
- if ( dia.exec() ) {
- KABPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
- }
-
-
-}
-QString KABCore::getPassword( )
-{
- QString retfile = "";
- QDialog dia ( this, "input-dialog", true );
- QLineEdit lab ( &dia );
- lab.setEchoMode( QLineEdit::Password );
- QVBoxLayout lay( &dia );
- lay.setMargin(7);
- lay.setSpacing(7);
- lay.addWidget( &lab);
- dia.setFixedSize( 230,50 );
- dia.setCaption( i18n("Enter password") );
- QPushButton pb ( "OK", &dia);
- lay.addWidget( &pb );
- connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
- dia.show();
- int res = dia.exec();
- if ( res )
- retfile = lab.text();
- dia.hide();
- qApp->processEvents();
- return retfile;
-
-}
#include <libkcal/syncdefines.h>
@@ -2518,2 +2113,4 @@ KABC::Addressee KABCore::getLastSyncAddressee()
Addressee lse;
+ QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
+
//qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
@@ -2549,2 +2146,5 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i
QDateTime remoteMod = remote->revision();
+
+ QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
+
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
@@ -2655,2 +2255,4 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i
}
+
+
bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
@@ -2664,2 +2266,6 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
int changedRemote = 0;
+
+ QString mCurrentSyncName = syncManager->getCurrentSyncName();
+ QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
+
//QPtrList<Addressee> el = local->rawAddressees();
@@ -2923,3 +2529,5 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
-bool KABCore::syncAB(QString filename, int mode)
+
+//this is a overwritten callbackmethods from the syncinterface
+bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
{
@@ -2929,2 +2537,4 @@ bool KABCore::syncAB(QString filename, int mode)
mGlobalSyncMode = SYNC_MODE_NORMAL;
+ QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
+
AddressBook abLocal(filename,"syncContact");
@@ -3010,31 +2620,8 @@ bool KABCore::syncAB(QString filename, int mode)
-void KABCore::confSync()
-{
- static KSyncPrefsDialog* sp = 0;
- if ( ! sp ) {
- sp = new KSyncPrefsDialog( this, "syncprefs", true );
- }
- sp->usrReadConfig();
-#ifndef DESKTOP_VERSION
- sp->showMaximized();
-#else
- sp->show();
-#endif
- sp->exec();
- KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames();
- KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName ();
- fillSyncMenu();
-}
-void KABCore::syncSharp()
-{
- if ( ! syncExternal("sharp") )
- qDebug("ERROR sync sharp ");;
-}
-bool KABCore::syncExternal(QString resource)
+
+//this is a overwritten callbackmethods from the syncinterface
+bool KABCore::syncExternal(KSyncManager* manager, QString resource)
{
- if ( mModified )
- save();
- if ( KABPrefs::instance()->mAskForPreferences )
- edit_sync_options();
- qDebug("syncSharp() ");
+ QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
+
AddressBook abLocal( resource,"syncContact");
@@ -3045,2 +2632,3 @@ bool KABCore::syncExternal(QString resource)
abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
+ qDebug("KABCore::syncExternal: why do we acces here KABPrefs and not somehow KSyncProfile? ");
syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, KABPrefs::instance()->mSyncAlgoPrefs );
@@ -3059,10 +2647,23 @@ bool KABCore::syncExternal(QString resource)
}
-void KABCore::syncPhone()
+
+//called by the syncmanager to indicate that the work has to marked as dirty.
+void KABCore::sync_setModified()
{
- if ( mModified )
- save();
- qDebug("pending syncPhone(); ");
- //mView->syncPhone();
- setModified();
+ setModified();
+}
+//called by the syncmanager to ask if the dirty flag is set.
+bool KABCore::sync_isModified()
+{
+ return mModified;
}
+
+
+//called by the syncmanager to indicate that the work has to be saved.
+void KABCore::sync_save()
+{
+ save();
+}
+
+
+
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index e89bf41..ef61d6d 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -34,2 +34,3 @@
#include <qpopupmenu.h>
+#include <ksyncmanager.h>
@@ -69,3 +70,3 @@ class Ir;
-class KABCore : public QWidget
+class KABCore : public QWidget, public KSyncInterface
{
@@ -343,3 +344,3 @@ class KABCore : public QWidget
void setDetailsToState();
- void slotSyncMenu( int );
+ // void slotSyncMenu( int );
private slots:
@@ -449,3 +450,3 @@ class KABCore : public QWidget
KABCorePrivate *d;
- bool mBlockSaveFlag;
+ //US bool mBlockSaveFlag;
@@ -454,2 +455,14 @@ class KABCore : public QWidget
#endif //KAB_EMBEDDED
+
+ //this are the overwritten callbackmethods from the syncinterface
+ virtual bool sync(KSyncManager* manager, QString filename, int mode);
+ virtual bool syncExternal(KSyncManager* manager, QString resource);
+
+ //called by the syncmanager to indicate that the work has to marked as dirty.
+ virtual void sync_setModified();
+ //called by the syncmanager to ask if the dirty flag is set.
+ virtual bool KABCore::sync_isModified();
+ //called by the syncmanager to indicate that the work has to be saved.
+ virtual void sync_save();
+
// LR *******************************
@@ -457,18 +470,3 @@ class KABCore : public QWidget
QPopupMenu *syncMenu;
- void fillSyncMenu();
- QString mCurrentSyncDevice;
- QString mCurrentSyncName;
- void quickSyncLocalFile();
- bool syncWithFile( QString fn , bool quick );
- void syncLocalFile();
- void syncPhone();
- void syncSharp();
- bool syncExternal(QString);
- void multiSync( bool askforPrefs );
- int mCurrentSyncProfile ;
- void syncRemote( KSyncProfile* prof, bool ask = true);
- void edit_sync_options();
- bool syncAB(QString filename, int mode);
- int ringSync();
- QString getPassword( );
+ KSyncManager* syncManager;
int mGlobalSyncMode;
@@ -478,4 +476,2 @@ class KABCore : public QWidget
int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full );
- public slots:
- void confSync();
// *********************
diff --git a/kaddressbook/kabprefs.h b/kaddressbook/kabprefs.h
index 9926aa0..e4f359c 100644
--- a/kaddressbook/kabprefs.h
+++ b/kaddressbook/kabprefs.h
@@ -84,19 +84,3 @@ class KABPrefs : public KPimPrefs
void setCategoryDefaults();
- // sync stuff
- QString mLocalMachineName;
- QStringList mExternSyncProfiles;
- QStringList mSyncProfileNames;
- bool mAskForPreferences;
- bool mShowSyncSummary;
- bool mShowSyncEvents;
- bool mShowTodoInAgenda;
- bool mWriteBackExistingOnly;
- int mSyncAlgoPrefs;
- int mRingSyncAlgoPrefs;
- bool mWriteBackFile;
- int mWriteBackInFuture;
- QString mPhoneDevice;
- QString mPhoneConnection;
- QString mPhoneModel;
- QString mLastSyncedLocalFile; // save!
+
private:
diff --git a/libkdepim/kpimprefs.h b/libkdepim/kpimprefs.h
index 860665b..01c57a3 100644
--- a/libkdepim/kpimprefs.h
+++ b/libkdepim/kpimprefs.h
@@ -58,2 +58,20 @@ class KPimPrefs : public KPrefs
+ // sync stuff
+ QString mLocalMachineName;
+ QStringList mExternSyncProfiles;
+ QStringList mSyncProfileNames;
+ bool mAskForPreferences;
+ bool mShowSyncSummary;
+ bool mShowSyncEvents;
+ bool mShowTodoInAgenda;
+ bool mWriteBackExistingOnly;
+ int mSyncAlgoPrefs;
+ int mRingSyncAlgoPrefs;
+ bool mWriteBackFile;
+ int mWriteBackInFuture;
+ QString mPhoneDevice;
+ QString mPhoneConnection;
+ QString mPhoneModel;
+ QString mLastSyncedLocalFile; // save!
+
@@ -61,2 +79,5 @@ class KPimPrefs : public KPrefs
virtual void setCategoryDefaults();
+
+
+
};
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 52e3bd9..87f200a 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -24,5 +24,32 @@
+#include <stdlib.h>
-KSyncManager::KSyncManager(TargetApp ta, QPopupMenu* syncmenu)
- : mSyncMenu(syncmenu), mTargetApp(ta)
+#ifndef _WIN32_
+#include <unistd.h>
+#endif
+
+
+#include "ksyncprofile.h"
+#include "ksyncprefsdialog.h"
+#include "kpimprefs.h"
+
+#include <qdir.h>
+#include <qpopupmenu.h>
+#include <qpushbutton.h>
+#include <qradiobutton.h>
+#include <qbuttongroup.h>
+#include <qtimer.h>
+#include <qmessagebox.h>
+#include <qapplication.h>
+#include <qlineedit.h>
+#include <qdialog.h>
+#include <qlayout.h>
+
+#include <klocale.h>
+#include <kglobal.h>
+#include <kconfig.h>
+#include <kfiledialog.h>
+
+KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu)
+ : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs), mSyncMenu(syncmenu)
{
@@ -37,6 +64,6 @@ KSyncManager::~KSyncManager()
-void KABCore::fillSyncMenu()
+void KSyncManager::fillSyncMenu()
{
if ( mSyncMenu->count() )
- msyncMenu->clear();
+ mSyncMenu->clear();
@@ -50,3 +77,3 @@ void KABCore::fillSyncMenu()
QStringList prof = config.readListEntry("SyncProfileNames");
- //US KABPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
+ mPrefs->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
if ( prof.count() < 3 ) {
@@ -69,7 +96,5 @@ void KABCore::fillSyncMenu()
}
- /*US
- KABPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
- KABPrefs::instance()->mSyncProfileNames = prof;
- */
- int i;
+ mPrefs->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
+ mPrefs->mSyncProfileNames = prof;
+ unsigned int i;
for ( i = 0; i < prof.count(); ++i ) {
@@ -87,3 +112,4 @@ void KABCore::fillSyncMenu()
}
-void KABCore::slotSyncMenu( int action )
+
+void KSyncManager::slotSyncMenu( int action )
{
@@ -106,22 +132,22 @@ void KABCore::slotSyncMenu( int action )
- if (mBlockSaveFlag)
+ if (blockSave())
return;
- mBlockSaveFlag = true;
+
+ setBlockSave(true);
+
mCurrentSyncProfile = action - 1000 ;
- //US mCurrentSyncDevice = KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ;
- //US mCurrentSyncName = KABPrefs::instance()->mLocalMachineName ;
+ mCurrentSyncDevice = mPrefs->mSyncProfileNames[mCurrentSyncProfile] ;
+ mCurrentSyncName = mPrefs->mLocalMachineName ;
KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
KSyncProfile* temp = new KSyncProfile ();
- //US temp->setName(KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
+ temp->setName(mPrefs->mSyncProfileNames[mCurrentSyncProfile]);
temp->readConfig(&config);
- /*US
- KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
- KABPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
- KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
- KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
- KABPrefs::instance()->mWriteBackInFuture = 0;
+ mPrefs->mAskForPreferences = temp->getAskForPreferences();
+ mPrefs->mSyncAlgoPrefs = temp->getSyncPrefs();
+ mPrefs->mWriteBackFile = temp->getWriteBackFile();
+ mPrefs->mWriteBackExistingOnly = temp->getWriteBackExisting();
+ mPrefs->mWriteBackInFuture = 0;
if ( temp->getWriteBackFuture() )
- KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
- KABPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
- */
+ mPrefs->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
+ mPrefs->mShowSyncSummary = temp->getShowSummaryAfterSync();
if ( action == 1000 ) {
@@ -137,12 +163,10 @@ void KABCore::slotSyncMenu( int action )
if ( temp->getIsLocalFileSync() ) {
- /*US if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
- KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
- */
+ if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
+ mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
+
} else {
if ( temp->getIsPhoneSync() ) {
- /*
- KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
- KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
- KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
- */
+ mPrefs->mPhoneDevice = temp->getPhoneDevice( ) ;
+ mPrefs->mPhoneConnection = temp->getPhoneConnection( );
+ mPrefs->mPhoneModel = temp->getPhoneModel( );
syncPhone();
@@ -154,11 +178,11 @@ void KABCore::slotSyncMenu( int action )
delete temp;
- mBlockSaveFlag = false;
+ setBlockSave(false);
}
-void KABCore::syncLocalFile()
+void KSyncManager::syncLocalFile()
{
- QString fn =KABPrefs::instance()->mLastSyncedLocalFile;
+ QString fn =mPrefs->mLastSyncedLocalFile;
- fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
+ fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), mParent );
if ( fn == "" )
@@ -170,3 +194,3 @@ void KABCore::syncLocalFile()
}
-bool KABCore::syncWithFile( QString fn , bool quick )
+bool KSyncManager::syncWithFile( QString fn , bool quick )
{
@@ -179,3 +203,3 @@ bool KABCore::syncWithFile( QString fn , bool quick )
mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
- int result = QMessageBox::warning( this, i18n("Warning!"),
+ int result = QMessageBox::warning( mParent, i18n("Warning!"),
mess );
@@ -186,3 +210,3 @@ bool KABCore::syncWithFile( QString fn , bool quick )
mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
- result = QMessageBox::warning( this, i18n("Warning!"),
+ result = QMessageBox::warning( mParent, i18n("Warning!"),
mess,
@@ -193,3 +217,3 @@ bool KABCore::syncWithFile( QString fn , bool quick )
}
- if ( KABPrefs::instance()->mAskForPreferences )
+ if ( mPrefs->mAskForPreferences )
edit_sync_options();
@@ -197,9 +221,9 @@ bool KABCore::syncWithFile( QString fn , bool quick )
//qDebug("Now sycing ... ");
- if ( ret = syncAB( fn, KABPrefs::instance()->mSyncAlgoPrefs ) )
- setCaption( i18n("Synchronization successful") );
+ if ( ret = mImplementation->sync( this, fn, mPrefs->mSyncAlgoPrefs ) )
+ mParent->setCaption( i18n("Synchronization successful") );
else
- setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
+ mParent->setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
if ( ! quick )
- KABPrefs::instance()->mLastSyncedLocalFile = fn;
- setModified();
+ mPrefs->mLastSyncedLocalFile = fn;
+ mImplementation->sync_setModified();
}
@@ -207,6 +231,6 @@ bool KABCore::syncWithFile( QString fn , bool quick )
}
-void KABCore::quickSyncLocalFile()
+void KSyncManager::quickSyncLocalFile()
{
- if ( syncWithFile( KABPrefs::instance()->mLastSyncedLocalFile, false ) ) {
+ if ( syncWithFile( mPrefs->mLastSyncedLocalFile, false ) ) {
qDebug("quick syncLocalFile() successful ");
@@ -215,9 +239,9 @@ void KABCore::quickSyncLocalFile()
}
-void KABCore::multiSync( bool askforPrefs )
+void KSyncManager::multiSync( bool askforPrefs )
{
- if (mBlockSaveFlag)
+ if (blockSave())
return;
- mBlockSaveFlag = true;
+ 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( this, i18n("KO/Pi Sync"),
+ if ( QMessageBox::information( mParent, i18n("Sync"),
question,
@@ -225,4 +249,4 @@ void KABCore::multiSync( bool askforPrefs )
0, 0 ) != 0 ) {
- mBlockSaveFlag = false;
- setCaption(i18n("Aborted! Nothing synced!"));
+ setBlockSave(false);
+ mParent->setCaption(i18n("Aborted! Nothing synced!"));
return;
@@ -230,8 +254,8 @@ void KABCore::multiSync( bool askforPrefs )
mCurrentSyncDevice = i18n("Multiple profiles") ;
- KABPrefs::instance()->mSyncAlgoPrefs = KABPrefs::instance()->mRingSyncAlgoPrefs;
+ mPrefs->mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
if ( askforPrefs ) {
edit_sync_options();
- KABPrefs::instance()->mRingSyncAlgoPrefs = KABPrefs::instance()->mSyncAlgoPrefs;
+ mPrefs->mRingSyncAlgoPrefs = mPrefs->mSyncAlgoPrefs;
}
- setCaption(i18n("Multiple sync started.") );
+ mParent->setCaption(i18n("Multiple sync started.") );
qApp->processEvents();
@@ -240,20 +264,20 @@ void KABCore::multiSync( bool askforPrefs )
ringSync();
- mBlockSaveFlag = false;
+ setBlockSave(false);
if ( num )
- save();
+ mImplementation->sync_save();
if ( num )
- setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
+ mParent->setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
else
- setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
+ mParent->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
return;
}
-int KABCore::ringSync()
+int KSyncManager::ringSync()
{
int syncedProfiles = 0;
- int i;
+ unsigned int i;
QTime timer;
KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
- QStringList syncProfileNames = KABPrefs::instance()->mSyncProfileNames;
+ QStringList syncProfileNames = mPrefs->mSyncProfileNames;
KSyncProfile* temp = new KSyncProfile ();
- KABPrefs::instance()->mAskForPreferences = false;
+ mPrefs->mAskForPreferences = false;
for ( i = 0; i < syncProfileNames.count(); ++i ) {
@@ -263,13 +287,13 @@ int KABCore::ringSync()
if ( temp->getIncludeInRingSyncAB() && ( i < 1 || i > 2 )) {
- setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
+ mParent->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
++syncedProfiles;
- // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
- KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
- KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
- KABPrefs::instance()->mWriteBackInFuture = 0;
+ // mPrefs->mAskForPreferences = temp->getAskForPreferences();
+ mPrefs->mWriteBackFile = temp->getWriteBackFile();
+ mPrefs->mWriteBackExistingOnly = temp->getWriteBackExisting();
+ mPrefs->mWriteBackInFuture = 0;
if ( temp->getWriteBackFuture() )
- KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
- KABPrefs::instance()->mShowSyncSummary = false;
+ mPrefs->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
+ mPrefs->mShowSyncSummary = false;
mCurrentSyncDevice = syncProfileNames[i] ;
- mCurrentSyncName = KABPrefs::instance()->mLocalMachineName;
+ mCurrentSyncName = mPrefs->mLocalMachineName;
if ( i == 0 ) {
@@ -279,8 +303,8 @@ int KABCore::ringSync()
if ( syncWithFile( temp->getRemoteFileNameAB( ), true ) )
- KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
+ mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
} else {
if ( temp->getIsPhoneSync() ) {
- KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
- KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
- KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
+ mPrefs->mPhoneDevice = temp->getPhoneDevice( ) ;
+ mPrefs->mPhoneConnection = temp->getPhoneConnection( );
+ mPrefs->mPhoneModel = temp->getPhoneModel( );
syncPhone();
@@ -292,3 +316,3 @@ int KABCore::ringSync()
timer.start();
- setCaption(i18n("Multiple sync in progress ... please wait!") );
+ mParent->setCaption(i18n("Multiple sync in progress ... please wait!") );
while ( timer.elapsed () < 2000 ) {
@@ -307,3 +331,3 @@ int KABCore::ringSync()
-void KABCore::syncRemote( KSyncProfile* prof, bool ask)
+void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
{
@@ -312,3 +336,3 @@ void KABCore::syncRemote( KSyncProfile* prof, bool ask)
question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
- if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
+ if ( QMessageBox::information( mParent, i18n("Sync"),
question,
@@ -328,3 +352,3 @@ void KABCore::syncRemote( KSyncProfile* prof, bool ask)
maxlen += 25;
- setCaption ( i18n( "Copy remote file to local machine..." ) );
+ mParent->setCaption ( i18n( "Copy remote file to local machine..." ) );
int fileSize = 0;
@@ -336,3 +360,3 @@ void KABCore::syncRemote( KSyncProfile* prof, bool ask)
if ( result != 0 ) {
- int len = maxlen;
+ unsigned int len = maxlen;
while ( len < command.length() ) {
@@ -342,9 +366,9 @@ void KABCore::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 (command) ;
- QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
+ QMessageBox::information( mParent, i18n("Sync - ERROR"),
question,
i18n("Okay!")) ;
- setCaption ("KO/Pi");
+ mParent->setCaption ("");
return;
}
- setCaption ( i18n( "Copying succeed." ) );
+ mParent->setCaption ( i18n( "Copying succeed." ) );
//qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
@@ -355,3 +379,3 @@ void KABCore::syncRemote( KSyncProfile* prof, bool ask)
// e->setReadOnly( true );
- if ( KABPrefs::instance()->mWriteBackFile ) {
+ if ( mPrefs->mWriteBackFile ) {
command = prof->getPostSyncCommandAB();
@@ -363,10 +387,10 @@ void KABCore::syncRemote( KSyncProfile* prof, bool ask)
}
- setCaption ( i18n( "Writing back file ..." ) );
+ mParent->setCaption ( i18n( "Writing back file ..." ) );
result = system ( command );
- qDebug("KO: Writing back file result: %d ", result);
+ qDebug("Writing back file result: %d ", result);
if ( result != 0 ) {
- setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
+ mParent->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
return;
} else {
- setCaption ( i18n( "Syncronization sucessfully completed" ) );
+ mParent->setCaption ( i18n( "Syncronization sucessfully completed" ) );
}
@@ -376,10 +400,8 @@ void KABCore::syncRemote( KSyncProfile* prof, bool ask)
}
-#include <qpushbutton.h>
-#include <qradiobutton.h>
-#include <qbuttongroup.h>
-void KABCore::edit_sync_options()
+
+void KSyncManager::edit_sync_options()
{
//mDialogManager->showSyncOptions();
- //KABPrefs::instance()->mSyncAlgoPrefs
- QDialog dia( this, "dia", true );
+ //mPrefs->mSyncAlgoPrefs
+ QDialog dia( mParent, "dia", true );
dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
@@ -400,3 +422,3 @@ void KABCore::edit_sync_options()
connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
- switch ( KABPrefs::instance()->mSyncAlgoPrefs ) {
+ switch ( mPrefs->mSyncAlgoPrefs ) {
case 0:
@@ -426,3 +448,3 @@ void KABCore::edit_sync_options()
if ( dia.exec() ) {
- KABPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
+ mPrefs->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
}
@@ -431,6 +453,6 @@ void KABCore::edit_sync_options()
}
-QString KABCore::getPassword( )
+QString KSyncManager::getPassword( )
{
QString retfile = "";
- QDialog dia ( this, "input-dialog", true );
+ QDialog dia ( mParent, "input-dialog", true );
QLineEdit lab ( &dia );
@@ -455 +477,53 @@ QString KABCore::getPassword( )
}
+
+
+void KSyncManager::confSync()
+{
+ static KSyncPrefsDialog* sp = 0;
+ if ( ! sp ) {
+ sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
+ }
+ sp->usrReadConfig();
+#ifndef DESKTOP_VERSION
+ sp->showMaximized();
+#else
+ sp->show();
+#endif
+ sp->exec();
+ mPrefs->mSyncProfileNames = sp->getSyncProfileNames();
+ mPrefs->mLocalMachineName = sp->getLocalMachineName ();
+ fillSyncMenu();
+}
+
+void KSyncManager::syncSharp()
+{
+ if ( ! syncExternalApplication("sharp") )
+ qDebug("ERROR sync sharp ");;
+}
+
+bool KSyncManager::syncExternalApplication(QString resource)
+{
+ if ( mImplementation->sync_isModified() )
+ mImplementation->sync_save();
+
+ if ( mPrefs->mAskForPreferences )
+ edit_sync_options();
+
+ qDebug("sync %s", resource.latin1());
+
+ bool syncOK = mImplementation->syncExternal(this, resource);
+
+ return syncOK;
+
+}
+
+void KSyncManager::syncPhone()
+{
+ if ( mImplementation->sync_isModified() )
+ mImplementation->sync_save();
+
+ qDebug("pending syncPhone(); ");
+ //mView->syncPhone();
+ mImplementation->sync_setModified();
+
+}
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index d7c2a02..389a005 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -24,2 +24,3 @@ $Id$
+#include <qobject.h>
#include <qstring.h>
@@ -28,12 +29,12 @@ class QPopupMenu;
class KSyncProfile;
+class KPimPrefs;
+class QWidget;
+class KSyncManager;
+class KSyncInterface;
-
-
-class KSyncManager
+class KSyncManager : public QObject
{
-
- public:
- KSyncManager(TargetApp ta, QPopupMenu* syncmenu);
- ~KSyncManager() ;
+ Q_OBJECT
+ public:
enum TargetApp {
@@ -43,16 +44,49 @@ class KSyncManager
- private:
+
+ KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu);
+ ~KSyncManager() ;
+
+ bool blockSave() { return mBlockSaveFlag; }
+ void setBlockSave(bool sa) { mBlockSaveFlag = sa; }
+
void fillSyncMenu();
- void syncLocalFile();
- bool syncWithFile( QString fn , bool quick );
+
+ QString getCurrentSyncDevice() { return mCurrentSyncDevice; }
+ QString getCurrentSyncName() { return mCurrentSyncName; }
+
+ public slots:
+ void slotSyncMenu( int );
+
+ private:
+ // LR *******************************
+ // sync stuff!
+ QString mCurrentSyncDevice;
+ QString mCurrentSyncName;
void quickSyncLocalFile();
+ bool syncWithFile( QString fn , bool quick );
+ void syncLocalFile();
+ void syncPhone();
+ void syncSharp();
+ bool syncExternalApplication(QString);
void multiSync( bool askforPrefs );
- int ringSync();
- void syncRemote( KSyncProfile* prof, bool ask);
+ int mCurrentSyncProfile ;
+ void syncRemote( KSyncProfile* prof, bool ask = true);
void edit_sync_options();
- QString getPassword();
+ int ringSync();
+ QString getPassword( );
+
+ private slots:
+ void confSync();
+ // *********************
private:
- QPopupMenu* mSyncMenu;
+ bool mBlockSaveFlag;
+
+
+ QWidget* mParent;
+ KSyncInterface* mImplementation;
TargetApp mTargetApp;
+ KPimPrefs* mPrefs;
+ QPopupMenu* mSyncMenu;
+
@@ -63,6 +97,23 @@ class KSyncManager
+};
+
+
+class KSyncInterface
+{
+ public:
+ virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0;
+ virtual bool syncExternal(KSyncManager* manager, QString resource) = 0;
+ //called by the syncmanager to indicate that the work has to be marked as dirty.
+ virtual void sync_setModified() = 0;
+
+ //called by the syncmanager to ask if the dirty flag is set.
+ virtual bool sync_isModified() = 0;
+
+ //called by the syncmanager to indicate that the work has to be saved.
+ virtual void sync_save() = 0;
};
+
#endif
diff --git a/libkdepim/libkdepimE.pro b/libkdepim/libkdepimE.pro
index 2a30ee8..156e247 100644
--- a/libkdepim/libkdepimE.pro
+++ b/libkdepim/libkdepimE.pro
@@ -27,2 +27,3 @@ HEADERS = \
kprefswidget.h \
+ ksyncmanager.h \
ksyncprofile.h \
@@ -47,2 +48,3 @@ SOURCES = \
kprefswidget.cpp \
+ ksyncmanager.cpp \
ksyncprofile.cpp \