summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kabc/addressbook.cpp5
-rw-r--r--kaddressbook/kabcore.cpp27
-rw-r--r--kaddressbook/kabcore.h7
3 files changed, 33 insertions, 6 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 17b9ba2..adb451f 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -241,34 +241,37 @@ void AddressBook::init(const QString &config, const QString &family )
if (config != 0) {
qDebug("config != 0 ");
if ( family == "syncContact" ) {
qDebug("creating sync config ");
fami = "contact";
KConfig* con = new KConfig( locateLocal("config", "syncContactrc") );
con->setGroup( "General" );
con->writeEntry( "ResourceKeys", QString("sync") );
con->writeEntry( "Standard", QString("sync") );
con->setGroup( "Resource_sync" );
con->writeEntry( "FileName", config );
con->writeEntry( "FileFormat", QString("vcard") );
con->writeEntry( "ResourceIdentifier", QString("sync") );
con->writeEntry( "ResourceName", QString("sync_res") );
if ( config.right(4) == ".xml" )
con->writeEntry( "ResourceType", QString("qtopia") );
- else
+ else if ( config == "sharp" ) {
+ con->writeEntry( "ResourceType", QString("sharp") );
+ } else {
con->writeEntry( "ResourceType", QString("file") );
+ }
//con->sync();
d->mConfig = con;
}
else
d->mConfig = new KConfig( locateLocal("config", config) );
// qDebug("AddressBook::init 1 config=%s",config.latin1() );
}
else {
d->mConfig = 0;
// qDebug("AddressBook::init 1 config=0");
}
//US d->mErrorHandler = 0;
d->mManager = new KRES::Manager<Resource>( fami, false );
d->mManager->readConfig( d->mConfig );
if ( family == "syncContact" ) {
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index f8683e7..c1ead9d 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -3013,32 +3013,55 @@ void KABCore::confSync()
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)
+{
if ( mModified )
save();
- qDebug("pending syncSharp() ");
- //mView->syncSharp();
+ if ( KABPrefs::instance()->mAskForPreferences )
+ edit_sync_options();
+ qDebug("syncSharp() ");
+ AddressBook abLocal( resource,"syncContact");
+ bool syncOK = false;
+ if ( abLocal.load() ) {
+ qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
+ mGlobalSyncMode = SYNC_MODE_EXTERNAL;
+ abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
+ syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, KABPrefs::instance()->mSyncAlgoPrefs );
+ if ( syncOK ) {
+ if ( KABPrefs::instance()->mWriteBackFile ) {
+ abLocal.saveAB();
+ abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
+ }
+ }
setModified();
+ }
+ if ( syncOK )
+ mViewManager->refreshView();
+ return syncOK;
}
void KABCore::syncPhone()
{
if ( mModified )
save();
qDebug("pending syncPhone(); ");
//mView->syncPhone();
setModified();
}
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index f01f306..e89bf41 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -447,35 +447,36 @@ class KABCore : public QWidget
class KABCorePrivate;
KABCorePrivate *d;
bool mBlockSaveFlag;
#ifdef KAB_EMBEDDED
KAddressBookMain *mMainWindow; // should be the same like mGUIClient
#endif //KAB_EMBEDDED
// LR *******************************
// sync stuff!
QPopupMenu *syncMenu;
void fillSyncMenu();
QString mCurrentSyncDevice;
QString mCurrentSyncName;
void quickSyncLocalFile();
bool syncWithFile( QString fn , bool quick );
- void KABCore::syncLocalFile();
- void KABCore::syncPhone();
- void KABCore::syncSharp();
+ 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( );
int mGlobalSyncMode;
bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode);
KABC::Addressee getLastSyncAddressee();
QDateTime mLastAddressbookSync;
int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full );
public slots:
void confSync();
// *********************