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
@@ -2824,21 +2824,5 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
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
}
@@ -2847,4 +2831,6 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
bool KABCore::syncExternal(KSyncManager* manager, QString resource)
{
+ if ( resource == "phone" )
+ return syncPhone();
QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
@@ -2869,14 +2855,53 @@ bool KABCore::syncExternal(KSyncManager* manager, QString resource)
}
-
-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();
}
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index 43c5f99..04ce33d 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -465,5 +465,6 @@ class KABCore : public QWidget, public KSyncInterface
virtual bool sync(KSyncManager* manager, QString filename, int mode);
virtual bool syncExternal(KSyncManager* manager, QString resource);
-
+ bool syncPhone();
+ void message( QString m );
// LR *******************************