summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kabcore.cpp
Unidiff
Diffstat (limited to 'kaddressbook/kabcore.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index e8f6132..59aa5a5 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -3165,48 +3165,49 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
3165 bool external = false; 3165 bool external = false;
3166 bool isXML = false; 3166 bool isXML = false;
3167 if ( filename.right(4) == ".xml") { 3167 if ( filename.right(4) == ".xml") {
3168 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3168 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3169 isXML = true; 3169 isXML = true;
3170 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3170 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3171 } else { 3171 } else {
3172 external = !manager->mIsKapiFile; 3172 external = !manager->mIsKapiFile;
3173 if ( external ) { 3173 if ( external ) {
3174 qDebug("KA: Sync::Setting vcf mode to external "); 3174 qDebug("KA: Sync::Setting vcf mode to external ");
3175 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3175 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3176 AddressBook::Iterator it; 3176 AddressBook::Iterator it;
3177 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3177 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3178 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 3178 (*it).setID( mCurrentSyncDevice, (*it).uid() );
3179 (*it).computeCsum( mCurrentSyncDevice ); 3179 (*it).computeCsum( mCurrentSyncDevice );
3180 } 3180 }
3181 } 3181 }
3182 } 3182 }
3183 //AddressBook::Iterator it; 3183 //AddressBook::Iterator it;
3184 //QStringList vcards; 3184 //QStringList vcards;
3185 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3185 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3186 // qDebug("Name %s ", (*it).familyName().latin1()); 3186 // qDebug("Name %s ", (*it).familyName().latin1());
3187 //} 3187 //}
3188 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 3188 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
3189 syncManager->hideProgressBar();
3189 if ( syncOK ) { 3190 if ( syncOK ) {
3190 if ( syncManager->mWriteBackFile ) 3191 if ( syncManager->mWriteBackFile )
3191 { 3192 {
3192 if ( external ) 3193 if ( external )
3193 abLocal.removeSyncAddressees( !isXML); 3194 abLocal.removeSyncAddressees( !isXML);
3194 qDebug("KA: Sync::Saving remote AB "); 3195 qDebug("KA: Sync::Saving remote AB ");
3195 if ( ! abLocal.saveAB()) 3196 if ( ! abLocal.saveAB())
3196 qDebug("KA: sync::Error writing back AB to file "); 3197 qDebug("KA: sync::Error writing back AB to file ");
3197 if ( external ) { 3198 if ( external ) {
3198 // afterwrite processing 3199 // afterwrite processing
3199 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 3200 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
3200 } 3201 }
3201 } 3202 }
3202 } 3203 }
3203 setModified(); 3204 setModified();
3204 3205
3205 } 3206 }
3206 abLocal.removeResources(); 3207 abLocal.removeResources();
3207 if ( syncOK ) 3208 if ( syncOK )
3208 mViewManager->refreshView(); 3209 mViewManager->refreshView();
3209 return syncOK; 3210 return syncOK;
3210 3211
3211} 3212}
3212void KABCore::removeSyncInfo( QString syncProfile) 3213void KABCore::removeSyncInfo( QString syncProfile)
@@ -3216,95 +3217,97 @@ void KABCore::removeSyncInfo( QString syncProfile)
3216 setModified(); 3217 setModified();
3217} 3218}
3218 3219
3219 3220
3220//this is a overwritten callbackmethods from the syncinterface 3221//this is a overwritten callbackmethods from the syncinterface
3221bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3222bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3222{ 3223{
3223 if ( resource == "phone" ) 3224 if ( resource == "phone" )
3224 return syncPhone(); 3225 return syncPhone();
3225 disableBR( true ); 3226 disableBR( true );
3226 if ( manager != syncManager ) 3227 if ( manager != syncManager )
3227 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); 3228 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3228 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3229 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3229 3230
3230 AddressBook abLocal( resource,"syncContact"); 3231 AddressBook abLocal( resource,"syncContact");
3231 bool syncOK = false; 3232 bool syncOK = false;
3232 message(i18n("Loading DTM address data..."), false); 3233 message(i18n("Loading DTM address data..."), false);
3233 if ( abLocal.load() ) { 3234 if ( abLocal.load() ) {
3234 qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3235 qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3235 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3236 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3236 message(i18n("Sync preprocessing..."),false); 3237 message(i18n("Sync preprocessing..."),false);
3237 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3238 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3238 message(i18n("Synchronizing..."),false); 3239 message(i18n("Synchronizing..."),false);
3239 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3240 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3241 syncManager->hideProgressBar();
3240 if ( syncOK ) { 3242 if ( syncOK ) {
3241 if ( syncManager->mWriteBackFile ) { 3243 if ( syncManager->mWriteBackFile ) {
3242 abLocal.removeSyncAddressees( false ); 3244 abLocal.removeSyncAddressees( false );
3243 message(i18n("Saving DTM address data..."),false); 3245 message(i18n("Saving DTM address data..."),false);
3244 abLocal.saveAB(); 3246 abLocal.saveAB();
3245 message(i18n("Sync postprocessing..."),false); 3247 message(i18n("Sync postprocessing..."),false);
3246 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3248 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3247 } 3249 }
3248 } else 3250 } else
3249 message( i18n("Sync cancelled or failed.") ); 3251 message( i18n("Sync cancelled or failed.") );
3250 setModified(); 3252 setModified();
3251 } 3253 }
3252 abLocal.removeResources(); 3254 abLocal.removeResources();
3253 if ( syncOK ) { 3255 if ( syncOK ) {
3254 mViewManager->refreshView(); 3256 mViewManager->refreshView();
3255 message(i18n("DTM syncing finished.")); 3257 message(i18n("DTM syncing finished."));
3256 } 3258 }
3257 disableBR( false ); 3259 disableBR( false );
3258 return syncOK; 3260 return syncOK;
3259 3261
3260} 3262}
3261void KABCore::message( QString m, bool startTimer) 3263void KABCore::message( QString m, bool startTimer)
3262{ 3264{
3263 topLevelWidget()->setCaption( m ); 3265 topLevelWidget()->setCaption( m );
3264 qApp->processEvents(); 3266 qApp->processEvents();
3265 if ( startTimer ) 3267 if ( startTimer )
3266 mMessageTimer->start( 15000, true ); 3268 mMessageTimer->start( 15000, true );
3267 else 3269 else
3268 mMessageTimer->stop(); 3270 mMessageTimer->stop();
3269} 3271}
3270bool KABCore::syncPhone() 3272bool KABCore::syncPhone()
3271{ 3273{
3272 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3274 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3273 QString fileName = getPhoneFile(); 3275 QString fileName = getPhoneFile();
3274 if ( !PhoneAccess::readFromPhone( fileName) ) { 3276 if ( !PhoneAccess::readFromPhone( fileName) ) {
3275 message(i18n("Phone access failed!")); 3277 message(i18n("Phone access failed!"));
3276 return false; 3278 return false;
3277 } 3279 }
3278 AddressBook abLocal( fileName,"syncContact"); 3280 AddressBook abLocal( fileName,"syncContact");
3279 bool syncOK = false; 3281 bool syncOK = false;
3280 { 3282 {
3281 abLocal.importFromFile( fileName ); 3283 abLocal.importFromFile( fileName );
3282 qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3284 qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
3283 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3285 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3284 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 3286 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
3285 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3287 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3286 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3288 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3289 syncManager->hideProgressBar();
3287 if ( syncOK ) { 3290 if ( syncOK ) {
3288 if ( syncManager->mWriteBackFile ) { 3291 if ( syncManager->mWriteBackFile ) {
3289 abLocal.removeSyncAddressees( true ); 3292 abLocal.removeSyncAddressees( true );
3290 abLocal.saveABphone( fileName ); 3293 abLocal.saveABphone( fileName );
3291 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 3294 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
3292 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 3295 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
3293 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3296 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3294 } 3297 }
3295 } 3298 }
3296 setModified(); 3299 setModified();
3297 } 3300 }
3298 abLocal.removeResources(); 3301 abLocal.removeResources();
3299 if ( syncOK ) 3302 if ( syncOK )
3300 mViewManager->refreshView(); 3303 mViewManager->refreshView();
3301 return syncOK; 3304 return syncOK;
3302} 3305}
3303void KABCore::getFile( bool success ) 3306void KABCore::getFile( bool success )
3304{ 3307{
3305 if ( ! success ) { 3308 if ( ! success ) {
3306 message( i18n("Error receiving file. Nothing changed!") ); 3309 message( i18n("Error receiving file. Nothing changed!") );
3307 return; 3310 return;
3308 } 3311 }
3309 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 3312 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
3310 if ( count ) 3313 if ( count )