summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kabcore.cpp
Unidiff
Diffstat (limited to 'kaddressbook/kabcore.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp33
1 files changed, 27 insertions, 6 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index d393660..42e147f 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1329,98 +1329,98 @@ void KABCore::editContact( const QString &uid )
1329 1329
1330 if ( mExtensionManager->isQuickEditVisible() ) 1330 if ( mExtensionManager->isQuickEditVisible() )
1331 return; 1331 return;
1332 1332
1333 // First, locate the contact entry 1333 // First, locate the contact entry
1334 QString localUID = uid; 1334 QString localUID = uid;
1335 if ( localUID.isNull() ) { 1335 if ( localUID.isNull() ) {
1336 QStringList uidList = mViewManager->selectedUids(); 1336 QStringList uidList = mViewManager->selectedUids();
1337 if ( uidList.count() > 0 ) 1337 if ( uidList.count() > 0 )
1338 localUID = *( uidList.at( 0 ) ); 1338 localUID = *( uidList.at( 0 ) );
1339 } 1339 }
1340 1340
1341 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1341 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1342 if ( !addr.isEmpty() ) { 1342 if ( !addr.isEmpty() ) {
1343 mEditorDialog->setAddressee( addr ); 1343 mEditorDialog->setAddressee( addr );
1344 KApplication::execDialog ( mEditorDialog ); 1344 KApplication::execDialog ( mEditorDialog );
1345 } 1345 }
1346} 1346}
1347 1347
1348/** 1348/**
1349 Shows or edits the detail view for the given uid. If the uid is QString::null, 1349 Shows or edits the detail view for the given uid. If the uid is QString::null,
1350 the method will try to find a selected addressee in the view. 1350 the method will try to find a selected addressee in the view.
1351 */ 1351 */
1352void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1352void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1353{ 1353{
1354 if ( mMultipleViewsAtOnce ) 1354 if ( mMultipleViewsAtOnce )
1355 { 1355 {
1356 editContact( uid ); 1356 editContact( uid );
1357 } 1357 }
1358 else 1358 else
1359 { 1359 {
1360 setDetailsVisible( true ); 1360 setDetailsVisible( true );
1361 mActionDetails->setChecked(true); 1361 mActionDetails->setChecked(true);
1362 } 1362 }
1363 1363
1364} 1364}
1365 1365
1366void KABCore::save() 1366void KABCore::save()
1367{ 1367{
1368 if (syncManager->blockSave()) 1368 if (syncManager->blockSave())
1369 return; 1369 return;
1370 if ( !mModified ) 1370 if ( !mModified )
1371 return; 1371 return;
1372 1372
1373 syncManager->setBlockSave(true); 1373 syncManager->setBlockSave(true);
1374 QString text = i18n( "There was an error while attempting to save\n the " 1374 QString text = i18n( "There was an error while attempting to save\n the "
1375 "address book. Please check that some \nother application is " 1375 "address book. Please check that some \nother application is "
1376 "not using it. " ); 1376 "not using it. " );
1377 message(i18n("Saving ... please wait! ")); 1377 message(i18n("Saving ... please wait! "), false);
1378 qApp->processEvents(); 1378 //qApp->processEvents();
1379#ifndef KAB_EMBEDDED 1379#ifndef KAB_EMBEDDED
1380 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1380 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1381 if ( !b || !b->save() ) { 1381 if ( !b || !b->save() ) {
1382 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1382 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1383 } 1383 }
1384#else //KAB_EMBEDDED 1384#else //KAB_EMBEDDED
1385 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1385 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1386 if ( !b || !b->save() ) { 1386 if ( !b || !b->save() ) {
1387 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1387 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1388 } 1388 }
1389#endif //KAB_EMBEDDED 1389#endif //KAB_EMBEDDED
1390 1390
1391 message(i18n("Addressbook saved!")); 1391 message(i18n("Addressbook saved!"));
1392 setModified( false ); 1392 setModified( false );
1393 syncManager->setBlockSave(false); 1393 syncManager->setBlockSave(false);
1394} 1394}
1395 1395
1396 1396
1397void KABCore::undo() 1397void KABCore::undo()
1398{ 1398{
1399 UndoStack::instance()->undo(); 1399 UndoStack::instance()->undo();
1400 1400
1401 // Refresh the view 1401 // Refresh the view
1402 mViewManager->refreshView(); 1402 mViewManager->refreshView();
1403} 1403}
1404 1404
1405void KABCore::redo() 1405void KABCore::redo()
1406{ 1406{
1407 RedoStack::instance()->redo(); 1407 RedoStack::instance()->redo();
1408 1408
1409 // Refresh the view 1409 // Refresh the view
1410 mViewManager->refreshView(); 1410 mViewManager->refreshView();
1411} 1411}
1412 1412
1413void KABCore::setJumpButtonBarVisible( bool visible ) 1413void KABCore::setJumpButtonBarVisible( bool visible )
1414{ 1414{
1415 if (mMultipleViewsAtOnce) 1415 if (mMultipleViewsAtOnce)
1416 { 1416 {
1417 if ( visible ) 1417 if ( visible )
1418 mJumpButtonBar->show(); 1418 mJumpButtonBar->show();
1419 else 1419 else
1420 mJumpButtonBar->hide(); 1420 mJumpButtonBar->hide();
1421 } 1421 }
1422 else 1422 else
1423 { 1423 {
1424 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1424 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1425 if (mViewManager->isVisible()) 1425 if (mViewManager->isVisible())
1426 { 1426 {
@@ -2252,191 +2252,201 @@ void KABCore::addActionsManually()
2252 } else { 2252 } else {
2253 mActionSave->plug( tb ); 2253 mActionSave->plug( tb );
2254 tb->enableMoving(false); 2254 tb->enableMoving(false);
2255 } 2255 }
2256 //mActionQuit->plug ( tb ); 2256 //mActionQuit->plug ( tb );
2257 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2257 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2258 2258
2259 //US link the searchwidget first to this. 2259 //US link the searchwidget first to this.
2260 // The real linkage to the toolbar happens later. 2260 // The real linkage to the toolbar happens later.
2261//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2261//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2262//US tb->insertItem( mIncSearchWidget ); 2262//US tb->insertItem( mIncSearchWidget );
2263/*US 2263/*US
2264 mIncSearchWidget = new IncSearchWidget( tb ); 2264 mIncSearchWidget = new IncSearchWidget( tb );
2265 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2265 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2266 SLOT( incrementalSearch( const QString& ) ) ); 2266 SLOT( incrementalSearch( const QString& ) ) );
2267 2267
2268 mJumpButtonBar = new JumpButtonBar( this, this ); 2268 mJumpButtonBar = new JumpButtonBar( this, this );
2269 2269
2270//US topLayout->addWidget( mJumpButtonBar ); 2270//US topLayout->addWidget( mJumpButtonBar );
2271 this->layout()->add( mJumpButtonBar ); 2271 this->layout()->add( mJumpButtonBar );
2272*/ 2272*/
2273 2273
2274#endif //KAB_EMBEDDED 2274#endif //KAB_EMBEDDED
2275 2275
2276 mActionExport2phone->plug( ExportMenu ); 2276 mActionExport2phone->plug( ExportMenu );
2277 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2277 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2278 syncManager->fillSyncMenu(); 2278 syncManager->fillSyncMenu();
2279 2279
2280} 2280}
2281void KABCore::showLicence() 2281void KABCore::showLicence()
2282{ 2282{
2283 KApplication::showLicence(); 2283 KApplication::showLicence();
2284} 2284}
2285 2285
2286void KABCore::manageCategories( ) 2286void KABCore::manageCategories( )
2287{ 2287{
2288 KABCatPrefs* cp = new KABCatPrefs(); 2288 KABCatPrefs* cp = new KABCatPrefs();
2289 cp->show(); 2289 cp->show();
2290 int w =cp->sizeHint().width() ; 2290 int w =cp->sizeHint().width() ;
2291 int h = cp->sizeHint().height() ; 2291 int h = cp->sizeHint().height() ;
2292 int dw = QApplication::desktop()->width(); 2292 int dw = QApplication::desktop()->width();
2293 int dh = QApplication::desktop()->height(); 2293 int dh = QApplication::desktop()->height();
2294 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2294 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2295 if ( !cp->exec() ) { 2295 if ( !cp->exec() ) {
2296 delete cp; 2296 delete cp;
2297 return; 2297 return;
2298 } 2298 }
2299 int count = 0; 2299 int count = 0;
2300 int cc = 0;
2300 message( i18n("Please wait, processing categories...")); 2301 message( i18n("Please wait, processing categories..."));
2301 if ( cp->addCat() ) { 2302 if ( cp->addCat() ) {
2302 KABC::AddressBook::Iterator it; 2303 KABC::AddressBook::Iterator it;
2303 QStringList catList = KABPrefs::instance()->mCustomCategories; 2304 QStringList catList = KABPrefs::instance()->mCustomCategories;
2304 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2305 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2306 ++cc;
2307 if ( cc %10 == 0)
2308 message(i18n("Processing contact #%1").arg(cc));
2305 QStringList catIncList = (*it).categories(); 2309 QStringList catIncList = (*it).categories();
2306 int i; 2310 int i;
2307 for( i = 0; i< catIncList.count(); ++i ) { 2311 for( i = 0; i< catIncList.count(); ++i ) {
2308 if ( !catList.contains (catIncList[i])) { 2312 if ( !catList.contains (catIncList[i])) {
2309 catList.append( catIncList[i] ); 2313 catList.append( catIncList[i] );
2310 //qDebug("add cat %s ", catIncList[i].latin1()); 2314 //qDebug("add cat %s ", catIncList[i].latin1());
2311 ++count; 2315 ++count;
2312 } 2316 }
2313 } 2317 }
2314 } 2318 }
2315 catList.sort(); 2319 catList.sort();
2316 KABPrefs::instance()->mCustomCategories = catList; 2320 KABPrefs::instance()->mCustomCategories = catList;
2317 KABPrefs::instance()->writeConfig(); 2321 KABPrefs::instance()->writeConfig();
2318 message(QString::number( count )+ i18n(" categories added to list! ")); 2322 message(QString::number( count )+ i18n(" categories added to list! "));
2319 } else { 2323 } else {
2320 QStringList catList = KABPrefs::instance()->mCustomCategories; 2324 QStringList catList = KABPrefs::instance()->mCustomCategories;
2321 QStringList catIncList; 2325 QStringList catIncList;
2322 QStringList newCatList; 2326 QStringList newCatList;
2323 KABC::AddressBook::Iterator it; 2327 KABC::AddressBook::Iterator it;
2324 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2328 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2329 ++cc;
2330 if ( cc %10 == 0)
2331 message(i18n("Processing contact #%1").arg(cc));
2325 QStringList catIncList = (*it).categories(); 2332 QStringList catIncList = (*it).categories();
2326 int i; 2333 int i;
2327 if ( catIncList.count() ) { 2334 if ( catIncList.count() ) {
2328 newCatList.clear(); 2335 newCatList.clear();
2329 for( i = 0; i< catIncList.count(); ++i ) { 2336 for( i = 0; i< catIncList.count(); ++i ) {
2330 if ( catList.contains (catIncList[i])) { 2337 if ( catList.contains (catIncList[i])) {
2331 newCatList.append( catIncList[i] ); 2338 newCatList.append( catIncList[i] );
2332 } 2339 }
2333 } 2340 }
2334 newCatList.sort(); 2341 newCatList.sort();
2335 (*it).setCategories( newCatList ); 2342 (*it).setCategories( newCatList );
2336 mAddressBook->insertAddressee( (*it) ); 2343 mAddressBook->insertAddressee( (*it) );
2337 } 2344 }
2338 } 2345 }
2339 setModified( true ); 2346 setModified( true );
2340 mViewManager->refreshView(); 2347 mViewManager->refreshView();
2341 message( i18n("Removing categories done!")); 2348 message( i18n("Removing categories done!"));
2342 } 2349 }
2343 delete cp; 2350 delete cp;
2344} 2351}
2345void KABCore::removeVoice() 2352void KABCore::removeVoice()
2346{ 2353{
2347 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) 2354 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No )
2348 return; 2355 return;
2349 KABC::Addressee::List list; 2356 KABC::Addressee::List list;
2350 XXPortSelectDialog dlg( this, false, this ); 2357 XXPortSelectDialog dlg( this, false, this );
2351 if ( dlg.exec() ) 2358 if ( dlg.exec() )
2352 list = dlg.contacts(); 2359 list = dlg.contacts();
2353 else 2360 else
2354 return; 2361 return;
2355 KABC::Addressee::List::Iterator it; 2362 KABC::Addressee::List::Iterator it;
2356 for ( it = list.begin(); it != list.end(); ++it ) { 2363 for ( it = list.begin(); it != list.end(); ++it ) {
2357 if ( (*it).removeVoice() ) 2364 if ( (*it).removeVoice() )
2358 addrModified((*it), false ); 2365 addrModified((*it), false );
2359 } 2366 }
2360} 2367}
2361 2368
2362void KABCore::setFormattedName() 2369void KABCore::setFormattedName()
2363{ 2370{
2364 KABFormatPrefs setpref; 2371 KABFormatPrefs setpref;
2365 if ( !setpref.exec() ) { 2372 if ( !setpref.exec() ) {
2366 return; 2373 return;
2367 } 2374 }
2368 XXPortSelectDialog dlg( this, false, this ); 2375 XXPortSelectDialog dlg( this, false, this );
2369 if ( !dlg.exec() ) 2376 if ( !dlg.exec() )
2370 return; 2377 return;
2371 mAddressBook->setUntagged(); 2378 mAddressBook->setUntagged();
2372 dlg.tagSelected(); 2379 dlg.tagSelected();
2373 int count = 0; 2380 int count = 0;
2374 KABC::AddressBook::Iterator it; 2381 KABC::AddressBook::Iterator it;
2375 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2382 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2376 if ( (*it).tagged() ) { 2383 if ( (*it).tagged() ) {
2377 message(i18n("Changing contact #%1").arg( ++count ) ); 2384 ++count;
2385 if ( count %10 == 0 )
2386 message(i18n("Changing contact #%1").arg( count ) );
2378 qApp->processEvents(); 2387 qApp->processEvents();
2379 QString fName; 2388 QString fName;
2380 if ( setpref.simple->isChecked() ) 2389 if ( setpref.simple->isChecked() )
2381 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); 2390 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName );
2382 else if ( setpref.full->isChecked() ) 2391 else if ( setpref.full->isChecked() )
2383 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); 2392 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName );
2384 else if ( setpref.reverse->isChecked() ) 2393 else if ( setpref.reverse->isChecked() )
2385 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); 2394 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName );
2386 else 2395 else
2387 fName = (*it).organization(); 2396 fName = (*it).organization();
2388 if ( setpref.setCompany->isChecked() ) 2397 if ( setpref.setCompany->isChecked() )
2389 if ( fName.isEmpty() || fName =="," ) 2398 if ( fName.isEmpty() || fName =="," )
2390 fName = (*it).organization(); 2399 fName = (*it).organization();
2391 (*it).setFormattedName( fName ); 2400 (*it).setFormattedName( fName );
2392 } 2401 }
2393 } 2402 }
2394 message(i18n("Refreshing view...") ); 2403 message(i18n("Refreshing view...") );
2404 qApp->processEvents();
2395 mViewManager->refreshView( "" ); 2405 mViewManager->refreshView( "" );
2396 Addressee add; 2406 Addressee add;
2397 mDetails->setAddressee( add ); 2407 mDetails->setAddressee( add );
2398 message(i18n("Setting formatted name completed!") ); 2408 message(i18n("Setting formatted name completed!") );
2399} 2409}
2400 2410
2401void KABCore::clipboardDataChanged() 2411void KABCore::clipboardDataChanged()
2402{ 2412{
2403 2413
2404 if ( mReadWrite ) 2414 if ( mReadWrite )
2405 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2415 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2406 2416
2407} 2417}
2408 2418
2409void KABCore::updateActionMenu() 2419void KABCore::updateActionMenu()
2410{ 2420{
2411 UndoStack *undo = UndoStack::instance(); 2421 UndoStack *undo = UndoStack::instance();
2412 RedoStack *redo = RedoStack::instance(); 2422 RedoStack *redo = RedoStack::instance();
2413 2423
2414 if ( undo->isEmpty() ) 2424 if ( undo->isEmpty() )
2415 mActionUndo->setText( i18n( "Undo" ) ); 2425 mActionUndo->setText( i18n( "Undo" ) );
2416 else 2426 else
2417 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2427 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2418 2428
2419 mActionUndo->setEnabled( !undo->isEmpty() ); 2429 mActionUndo->setEnabled( !undo->isEmpty() );
2420 2430
2421 if ( !redo->top() ) 2431 if ( !redo->top() )
2422 mActionRedo->setText( i18n( "Redo" ) ); 2432 mActionRedo->setText( i18n( "Redo" ) );
2423 else 2433 else
2424 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2434 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2425 2435
2426 mActionRedo->setEnabled( !redo->isEmpty() ); 2436 mActionRedo->setEnabled( !redo->isEmpty() );
2427} 2437}
2428 2438
2429void KABCore::configureKeyBindings() 2439void KABCore::configureKeyBindings()
2430{ 2440{
2431#ifndef KAB_EMBEDDED 2441#ifndef KAB_EMBEDDED
2432 KKeyDialog::configure( actionCollection(), true ); 2442 KKeyDialog::configure( actionCollection(), true );
2433#else //KAB_EMBEDDED 2443#else //KAB_EMBEDDED
2434 qDebug("KABCore::configureKeyBindings() not implemented"); 2444 qDebug("KABCore::configureKeyBindings() not implemented");
2435#endif //KAB_EMBEDDED 2445#endif //KAB_EMBEDDED
2436} 2446}
2437 2447
2438#ifdef KAB_EMBEDDED 2448#ifdef KAB_EMBEDDED
2439void KABCore::configureResources() 2449void KABCore::configureResources()
2440{ 2450{
2441 KRES::KCMKResources dlg( this, "" , 0 ); 2451 KRES::KCMKResources dlg( this, "" , 0 );
2442 2452
@@ -3144,122 +3154,133 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
3144 //QStringList vcards; 3154 //QStringList vcards;
3145 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3155 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3146 // qDebug("Name %s ", (*it).familyName().latin1()); 3156 // qDebug("Name %s ", (*it).familyName().latin1());
3147 //} 3157 //}
3148 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 3158 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
3149 if ( syncOK ) { 3159 if ( syncOK ) {
3150 if ( syncManager->mWriteBackFile ) 3160 if ( syncManager->mWriteBackFile )
3151 { 3161 {
3152 if ( external ) 3162 if ( external )
3153 abLocal.removeSyncAddressees( !isXML); 3163 abLocal.removeSyncAddressees( !isXML);
3154 qDebug("Saving remote AB "); 3164 qDebug("Saving remote AB ");
3155 if ( ! abLocal.saveAB()) 3165 if ( ! abLocal.saveAB())
3156 qDebug("Error writing back AB to file "); 3166 qDebug("Error writing back AB to file ");
3157 if ( external ) { 3167 if ( external ) {
3158 // afterwrite processing 3168 // afterwrite processing
3159 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 3169 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
3160 } 3170 }
3161 } 3171 }
3162 } 3172 }
3163 setModified(); 3173 setModified();
3164 3174
3165 } 3175 }
3166 abLocal.removeResources(); 3176 abLocal.removeResources();
3167 if ( syncOK ) 3177 if ( syncOK )
3168 mViewManager->refreshView(); 3178 mViewManager->refreshView();
3169 return syncOK; 3179 return syncOK;
3170 3180
3171} 3181}
3172void KABCore::removeSyncInfo( QString syncProfile) 3182void KABCore::removeSyncInfo( QString syncProfile)
3173{ 3183{
3174 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 3184 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1());
3175 mAddressBook->removeSyncInfo( syncProfile ); 3185 mAddressBook->removeSyncInfo( syncProfile );
3176 setModified(); 3186 setModified();
3177} 3187}
3178 3188
3179 3189
3180//this is a overwritten callbackmethods from the syncinterface 3190//this is a overwritten callbackmethods from the syncinterface
3181bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3191bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3182{ 3192{
3183 if ( resource == "phone" ) 3193 if ( resource == "phone" )
3184 return syncPhone(); 3194 return syncPhone();
3185 disableBR( true ); 3195 disableBR( true );
3186 if ( manager != syncManager ) 3196 if ( manager != syncManager )
3187 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); 3197 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3188 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3198 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3189 3199
3190 AddressBook abLocal( resource,"syncContact"); 3200 AddressBook abLocal( resource,"syncContact");
3191 bool syncOK = false; 3201 bool syncOK = false;
3202 message(i18n("Loading DTM address data..."), false);
3192 if ( abLocal.load() ) { 3203 if ( abLocal.load() ) {
3193 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3204 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3194 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3205 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3206 message(i18n("Sync preprocessing..."),false);
3195 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3207 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3208 message(i18n("Synchronizing..."),false);
3196 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3209 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3197 if ( syncOK ) { 3210 if ( syncOK ) {
3198 if ( syncManager->mWriteBackFile ) { 3211 if ( syncManager->mWriteBackFile ) {
3199 abLocal.removeSyncAddressees( false ); 3212 abLocal.removeSyncAddressees( false );
3213 message(i18n("Saving DTM address data..."),false);
3200 abLocal.saveAB(); 3214 abLocal.saveAB();
3215 message(i18n("Sync postprocessing..."),false);
3201 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3216 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3202 } 3217 }
3203 } else 3218 } else
3204 message( i18n("Sync cancelled or failed.") ); 3219 message( i18n("Sync cancelled or failed.") );
3205 setModified(); 3220 setModified();
3206 } 3221 }
3207 abLocal.removeResources(); 3222 abLocal.removeResources();
3208 if ( syncOK ) 3223 if ( syncOK ) {
3209 mViewManager->refreshView(); 3224 mViewManager->refreshView();
3225 message(i18n("DTM syncing finished."));
3226 }
3210 disableBR( false ); 3227 disableBR( false );
3211 return syncOK; 3228 return syncOK;
3212 3229
3213} 3230}
3214void KABCore::message( QString m ) 3231void KABCore::message( QString m, bool startTimer)
3215{ 3232{
3216 topLevelWidget()->setCaption( m ); 3233 topLevelWidget()->setCaption( m );
3217 mMessageTimer->start( 20000, true ); 3234 qApp->processEvents();
3235 if ( startTimer )
3236 mMessageTimer->start( 15000, true );
3237 else
3238 mMessageTimer->stop();
3218} 3239}
3219bool KABCore::syncPhone() 3240bool KABCore::syncPhone()
3220{ 3241{
3221 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3242 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3222 QString fileName = getPhoneFile(); 3243 QString fileName = getPhoneFile();
3223 if ( !PhoneAccess::readFromPhone( fileName) ) { 3244 if ( !PhoneAccess::readFromPhone( fileName) ) {
3224 message(i18n("Phone access failed!")); 3245 message(i18n("Phone access failed!"));
3225 return false; 3246 return false;
3226 } 3247 }
3227 AddressBook abLocal( fileName,"syncContact"); 3248 AddressBook abLocal( fileName,"syncContact");
3228 bool syncOK = false; 3249 bool syncOK = false;
3229 { 3250 {
3230 abLocal.importFromFile( fileName ); 3251 abLocal.importFromFile( fileName );
3231 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3252 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
3232 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3253 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3233 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 3254 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
3234 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3255 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3235 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3256 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3236 if ( syncOK ) { 3257 if ( syncOK ) {
3237 if ( syncManager->mWriteBackFile ) { 3258 if ( syncManager->mWriteBackFile ) {
3238 abLocal.removeSyncAddressees( true ); 3259 abLocal.removeSyncAddressees( true );
3239 abLocal.saveABphone( fileName ); 3260 abLocal.saveABphone( fileName );
3240 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 3261 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
3241 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 3262 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
3242 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3263 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3243 } 3264 }
3244 } 3265 }
3245 setModified(); 3266 setModified();
3246 } 3267 }
3247 abLocal.removeResources(); 3268 abLocal.removeResources();
3248 if ( syncOK ) 3269 if ( syncOK )
3249 mViewManager->refreshView(); 3270 mViewManager->refreshView();
3250 return syncOK; 3271 return syncOK;
3251} 3272}
3252void KABCore::getFile( bool success ) 3273void KABCore::getFile( bool success )
3253{ 3274{
3254 if ( ! success ) { 3275 if ( ! success ) {
3255 message( i18n("Error receiving file. Nothing changed!") ); 3276 message( i18n("Error receiving file. Nothing changed!") );
3256 return; 3277 return;
3257 } 3278 }
3258 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 3279 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
3259 if ( count ) 3280 if ( count )
3260 setModified( true ); 3281 setModified( true );
3261 message( i18n("Pi-Sync successful!") ); 3282 message( i18n("Pi-Sync successful!") );
3262 mViewManager->refreshView(); 3283 mViewManager->refreshView();
3263} 3284}
3264void KABCore::syncFileRequest() 3285void KABCore::syncFileRequest()
3265{ 3286{