summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Side-by-side diff
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp65
-rw-r--r--kaddressbook/kabcore.h3
2 files changed, 47 insertions, 21 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 452f1bc..a7967cb 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2822,31 +2822,17 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
}
if ( syncOK )
mViewManager->refreshView();
return syncOK;
-#if 0
- if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
- getEventViewerDialog()->setSyncMode( true );
- syncOK = synchronizeCalendar( mCalendar, calendar, mode );
- getEventViewerDialog()->setSyncMode( false );
- if ( syncOK ) {
- if ( KOPrefs::instance()->mWriteBackFile )
- {
- storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
- storage->save();
- }
- }
- setModified();
- }
-
-#endif
}
//this is a overwritten callbackmethods from the syncinterface
bool KABCore::syncExternal(KSyncManager* manager, QString resource)
{
+ if ( resource == "phone" )
+ return syncPhone();
QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
AddressBook abLocal( resource,"syncContact");
bool syncOK = false;
@@ -2867,18 +2853,57 @@ bool KABCore::syncExternal(KSyncManager* manager, QString resource)
mViewManager->refreshView();
return syncOK;
}
-
-void KABCore::getFile( bool success )
+void KABCore::message( QString m )
{
+
+ topLevelWidget()->setCaption( m );
QTimer::singleShot( 15000, this , SLOT ( setCaptionBack()));
+}
+bool KABCore::syncPhone()
+{
+ QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
+ QString fileName;
+#ifdef _WIN32_
+ fileName = locateLocal("tmp", "phonefile.vcf");
+#else
+ fileName = "/tmp/phonefile.vcf";
+#endif
+ if ( !PhoneAccess::readFromPhone( fileName) ) {
+ message(i18n("Phone access failed!"));
+ return false;
+ }
+ AddressBook abLocal( fileName,"syncContact");
+ bool syncOK = false;
+ if ( abLocal.load() ) {
+ qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
+ mGlobalSyncMode = SYNC_MODE_EXTERNAL;
+ abLocal.preparePhoneSync( mCurrentSyncDevice, true );
+ abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
+ syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
+ if ( syncOK ) {
+ if ( syncManager->mWriteBackFile ) {
+ abLocal.saveABphone( fileName );
+ abLocal.preparePhoneSync( mCurrentSyncDevice, false );
+ abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
+ abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
+ }
+ }
+ setModified();
+ }
+ if ( syncOK )
+ mViewManager->refreshView();
+ return syncOK;
+}
+void KABCore::getFile( bool success )
+{
if ( ! success ) {
- setCaption( i18n("Error receiving file. Nothing changed!") );
+ message( i18n("Error receiving file. Nothing changed!") );
return;
}
mAddressBook->importFromFile( sentSyncFile() , false, true );
- topLevelWidget()->setCaption( i18n("Pi-Sync successful!") );
+ message( i18n("Pi-Sync successful!") );
mViewManager->refreshView();
}
void KABCore::syncFileRequest()
{
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index 43c5f99..04ce33d 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -463,9 +463,10 @@ class KABCore : public QWidget, public KSyncInterface
//this are the overwritten callbackmethods from the syncinterface
virtual bool sync(KSyncManager* manager, QString filename, int mode);
virtual bool syncExternal(KSyncManager* manager, QString resource);
-
+ bool syncPhone();
+ void message( QString m );
// LR *******************************
// sync stuff!
QString sentSyncFile();