-rw-r--r-- | kaddressbook/kabcore.cpp | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 42e147f..d970ff1 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2260,203 +2260,213 @@ void KABCore::addActionsManually() | |||
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 | } |
2281 | void KABCore::showLicence() | 2281 | void KABCore::showLicence() |
2282 | { | 2282 | { |
2283 | KApplication::showLicence(); | 2283 | KApplication::showLicence(); |
2284 | } | 2284 | } |
2285 | 2285 | ||
2286 | void KABCore::manageCategories( ) | 2286 | void 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 | int cc = 0; |
2301 | message( i18n("Please wait, processing categories...")); | 2301 | message( i18n("Please wait, processing categories...")); |
2302 | if ( cp->addCat() ) { | 2302 | if ( cp->addCat() ) { |
2303 | KABC::AddressBook::Iterator it; | 2303 | KABC::AddressBook::Iterator it; |
2304 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2304 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2305 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2305 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2306 | ++cc; | 2306 | ++cc; |
2307 | if ( cc %10 == 0) | 2307 | if ( cc %10 == 0) |
2308 | message(i18n("Processing contact #%1").arg(cc)); | 2308 | message(i18n("Processing contact #%1").arg(cc)); |
2309 | QStringList catIncList = (*it).categories(); | 2309 | QStringList catIncList = (*it).categories(); |
2310 | int i; | 2310 | int i; |
2311 | for( i = 0; i< catIncList.count(); ++i ) { | 2311 | for( i = 0; i< catIncList.count(); ++i ) { |
2312 | if ( !catList.contains (catIncList[i])) { | 2312 | if ( !catList.contains (catIncList[i])) { |
2313 | catList.append( catIncList[i] ); | 2313 | catList.append( catIncList[i] ); |
2314 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2314 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2315 | ++count; | 2315 | ++count; |
2316 | } | 2316 | } |
2317 | } | 2317 | } |
2318 | } | 2318 | } |
2319 | catList.sort(); | 2319 | catList.sort(); |
2320 | KABPrefs::instance()->mCustomCategories = catList; | 2320 | KABPrefs::instance()->mCustomCategories = catList; |
2321 | KABPrefs::instance()->writeConfig(); | 2321 | KABPrefs::instance()->writeConfig(); |
2322 | message(QString::number( count )+ i18n(" categories added to list! ")); | 2322 | message(QString::number( count )+ i18n(" categories added to list! ")); |
2323 | } else { | 2323 | } else { |
2324 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2324 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2325 | QStringList catIncList; | 2325 | QStringList catIncList; |
2326 | QStringList newCatList; | 2326 | QStringList newCatList; |
2327 | KABC::AddressBook::Iterator it; | 2327 | KABC::AddressBook::Iterator it; |
2328 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2328 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2329 | ++cc; | 2329 | ++cc; |
2330 | if ( cc %10 == 0) | 2330 | if ( cc %10 == 0) |
2331 | message(i18n("Processing contact #%1").arg(cc)); | 2331 | message(i18n("Processing contact #%1").arg(cc)); |
2332 | QStringList catIncList = (*it).categories(); | 2332 | QStringList catIncList = (*it).categories(); |
2333 | int i; | 2333 | int i; |
2334 | if ( catIncList.count() ) { | 2334 | if ( catIncList.count() ) { |
2335 | newCatList.clear(); | 2335 | newCatList.clear(); |
2336 | for( i = 0; i< catIncList.count(); ++i ) { | 2336 | for( i = 0; i< catIncList.count(); ++i ) { |
2337 | if ( catList.contains (catIncList[i])) { | 2337 | if ( catList.contains (catIncList[i])) { |
2338 | newCatList.append( catIncList[i] ); | 2338 | newCatList.append( catIncList[i] ); |
2339 | } | 2339 | } |
2340 | } | 2340 | } |
2341 | newCatList.sort(); | 2341 | newCatList.sort(); |
2342 | (*it).setCategories( newCatList ); | 2342 | (*it).setCategories( newCatList ); |
2343 | mAddressBook->insertAddressee( (*it) ); | 2343 | mAddressBook->insertAddressee( (*it) ); |
2344 | } | 2344 | } |
2345 | } | 2345 | } |
2346 | setModified( true ); | 2346 | setModified( true ); |
2347 | mViewManager->refreshView(); | 2347 | mViewManager->refreshView(); |
2348 | message( i18n("Removing categories done!")); | 2348 | message( i18n("Removing categories done!")); |
2349 | } | 2349 | } |
2350 | delete cp; | 2350 | delete cp; |
2351 | } | 2351 | } |
2352 | void KABCore::removeVoice() | 2352 | void KABCore::removeVoice() |
2353 | { | 2353 | { |
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 ) | 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 ) |
2355 | return; | 2355 | return; |
2356 | KABC::Addressee::List list; | ||
2357 | XXPortSelectDialog dlg( this, false, this ); | 2356 | XXPortSelectDialog dlg( this, false, this ); |
2358 | if ( dlg.exec() ) | 2357 | if ( !dlg.exec() ) |
2359 | list = dlg.contacts(); | ||
2360 | else | ||
2361 | return; | 2358 | return; |
2362 | KABC::Addressee::List::Iterator it; | 2359 | mAddressBook->setUntagged(); |
2363 | for ( it = list.begin(); it != list.end(); ++it ) { | 2360 | dlg.tagSelected(); |
2364 | if ( (*it).removeVoice() ) | 2361 | message(i18n("Removing voice..."), false ); |
2365 | addrModified((*it), false ); | 2362 | KABC::AddressBook::Iterator it; |
2363 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | ||
2364 | if ( (*it).tagged() ) { | ||
2365 | (*it).removeVoice(); | ||
2366 | } | ||
2366 | } | 2367 | } |
2368 | message(i18n("Refreshing view...") ); | ||
2369 | qApp->processEvents(); | ||
2370 | mViewManager->refreshView( "" ); | ||
2371 | Addressee add; | ||
2372 | mDetails->setAddressee( add ); | ||
2373 | message(i18n("Remove voice completed!") ); | ||
2374 | |||
2375 | |||
2376 | |||
2367 | } | 2377 | } |
2368 | 2378 | ||
2369 | void KABCore::setFormattedName() | 2379 | void KABCore::setFormattedName() |
2370 | { | 2380 | { |
2371 | KABFormatPrefs setpref; | 2381 | KABFormatPrefs setpref; |
2372 | if ( !setpref.exec() ) { | 2382 | if ( !setpref.exec() ) { |
2373 | return; | 2383 | return; |
2374 | } | 2384 | } |
2375 | XXPortSelectDialog dlg( this, false, this ); | 2385 | XXPortSelectDialog dlg( this, false, this ); |
2376 | if ( !dlg.exec() ) | 2386 | if ( !dlg.exec() ) |
2377 | return; | 2387 | return; |
2378 | mAddressBook->setUntagged(); | 2388 | mAddressBook->setUntagged(); |
2379 | dlg.tagSelected(); | 2389 | dlg.tagSelected(); |
2380 | int count = 0; | 2390 | int count = 0; |
2381 | KABC::AddressBook::Iterator it; | 2391 | KABC::AddressBook::Iterator it; |
2382 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2392 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2383 | if ( (*it).tagged() ) { | 2393 | if ( (*it).tagged() ) { |
2384 | ++count; | 2394 | ++count; |
2385 | if ( count %10 == 0 ) | 2395 | if ( count %10 == 0 ) |
2386 | message(i18n("Changing contact #%1").arg( count ) ); | 2396 | message(i18n("Changing contact #%1").arg( count ) ); |
2387 | qApp->processEvents(); | 2397 | qApp->processEvents(); |
2388 | QString fName; | 2398 | QString fName; |
2389 | if ( setpref.simple->isChecked() ) | 2399 | if ( setpref.simple->isChecked() ) |
2390 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); | 2400 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); |
2391 | else if ( setpref.full->isChecked() ) | 2401 | else if ( setpref.full->isChecked() ) |
2392 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); | 2402 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); |
2393 | else if ( setpref.reverse->isChecked() ) | 2403 | else if ( setpref.reverse->isChecked() ) |
2394 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); | 2404 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); |
2395 | else | 2405 | else |
2396 | fName = (*it).organization(); | 2406 | fName = (*it).organization(); |
2397 | if ( setpref.setCompany->isChecked() ) | 2407 | if ( setpref.setCompany->isChecked() ) |
2398 | if ( fName.isEmpty() || fName =="," ) | 2408 | if ( fName.isEmpty() || fName =="," ) |
2399 | fName = (*it).organization(); | 2409 | fName = (*it).organization(); |
2400 | (*it).setFormattedName( fName ); | 2410 | (*it).setFormattedName( fName ); |
2401 | } | 2411 | } |
2402 | } | 2412 | } |
2403 | message(i18n("Refreshing view...") ); | 2413 | message(i18n("Refreshing view...") ); |
2404 | qApp->processEvents(); | 2414 | qApp->processEvents(); |
2405 | mViewManager->refreshView( "" ); | 2415 | mViewManager->refreshView( "" ); |
2406 | Addressee add; | 2416 | Addressee add; |
2407 | mDetails->setAddressee( add ); | 2417 | mDetails->setAddressee( add ); |
2408 | message(i18n("Setting formatted name completed!") ); | 2418 | message(i18n("Setting formatted name completed!") ); |
2409 | } | 2419 | } |
2410 | 2420 | ||
2411 | void KABCore::clipboardDataChanged() | 2421 | void KABCore::clipboardDataChanged() |
2412 | { | 2422 | { |
2413 | 2423 | ||
2414 | if ( mReadWrite ) | 2424 | if ( mReadWrite ) |
2415 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2425 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2416 | 2426 | ||
2417 | } | 2427 | } |
2418 | 2428 | ||
2419 | void KABCore::updateActionMenu() | 2429 | void KABCore::updateActionMenu() |
2420 | { | 2430 | { |
2421 | UndoStack *undo = UndoStack::instance(); | 2431 | UndoStack *undo = UndoStack::instance(); |
2422 | RedoStack *redo = RedoStack::instance(); | 2432 | RedoStack *redo = RedoStack::instance(); |
2423 | 2433 | ||
2424 | if ( undo->isEmpty() ) | 2434 | if ( undo->isEmpty() ) |
2425 | mActionUndo->setText( i18n( "Undo" ) ); | 2435 | mActionUndo->setText( i18n( "Undo" ) ); |
2426 | else | 2436 | else |
2427 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2437 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2428 | 2438 | ||
2429 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2439 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2430 | 2440 | ||
2431 | if ( !redo->top() ) | 2441 | if ( !redo->top() ) |
2432 | mActionRedo->setText( i18n( "Redo" ) ); | 2442 | mActionRedo->setText( i18n( "Redo" ) ); |
2433 | else | 2443 | else |
2434 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2444 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2435 | 2445 | ||
2436 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2446 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2437 | } | 2447 | } |
2438 | 2448 | ||
2439 | void KABCore::configureKeyBindings() | 2449 | void KABCore::configureKeyBindings() |
2440 | { | 2450 | { |
2441 | #ifndef KAB_EMBEDDED | 2451 | #ifndef KAB_EMBEDDED |
2442 | KKeyDialog::configure( actionCollection(), true ); | 2452 | KKeyDialog::configure( actionCollection(), true ); |
2443 | #else //KAB_EMBEDDED | 2453 | #else //KAB_EMBEDDED |
2444 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2454 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2445 | #endif //KAB_EMBEDDED | 2455 | #endif //KAB_EMBEDDED |
2446 | } | 2456 | } |
2447 | 2457 | ||
2448 | #ifdef KAB_EMBEDDED | 2458 | #ifdef KAB_EMBEDDED |
2449 | void KABCore::configureResources() | 2459 | void KABCore::configureResources() |
2450 | { | 2460 | { |
2451 | KRES::KCMKResources dlg( this, "" , 0 ); | 2461 | KRES::KCMKResources dlg( this, "" , 0 ); |
2452 | 2462 | ||
2453 | if ( !dlg.exec() ) | 2463 | if ( !dlg.exec() ) |
2454 | return; | 2464 | return; |
2455 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2465 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2456 | } | 2466 | } |
2457 | #endif //KAB_EMBEDDED | 2467 | #endif //KAB_EMBEDDED |
2458 | 2468 | ||
2459 | 2469 | ||
2460 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2470 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2461 | * for the attendees list of an event. | 2471 | * for the attendees list of an event. |
2462 | */ | 2472 | */ |
@@ -3038,223 +3048,223 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
3038 | inR = remote->findByUid( uid ); | 3048 | inR = remote->findByUid( uid ); |
3039 | if ( inR.isEmpty() ){ | 3049 | if ( inR.isEmpty() ){ |
3040 | if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { | 3050 | if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { |
3041 | // no conflict ********** add or delete local | 3051 | // no conflict ********** add or delete local |
3042 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3052 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3043 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 3053 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
3044 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3054 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3045 | local->removeAddressee( inL ); | 3055 | local->removeAddressee( inL ); |
3046 | ++deletedAddresseeL; | 3056 | ++deletedAddresseeL; |
3047 | } else { | 3057 | } else { |
3048 | if ( ! syncManager->mWriteBackExistingOnly ) { | 3058 | if ( ! syncManager->mWriteBackExistingOnly ) { |
3049 | inL.removeID(mCurrentSyncDevice ); | 3059 | inL.removeID(mCurrentSyncDevice ); |
3050 | ++addedAddresseeR; | 3060 | ++addedAddresseeR; |
3051 | inL.setRevision( modifiedCalendar ); | 3061 | inL.setRevision( modifiedCalendar ); |
3052 | local->insertAddressee( inL, false ); | 3062 | local->insertAddressee( inL, false ); |
3053 | inR = inL; | 3063 | inR = inL; |
3054 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 3064 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
3055 | inR.setResource( 0 ); | 3065 | inR.setResource( 0 ); |
3056 | remote->insertAddressee( inR, false ); | 3066 | remote->insertAddressee( inR, false ); |
3057 | } | 3067 | } |
3058 | } | 3068 | } |
3059 | } else { | 3069 | } else { |
3060 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 3070 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
3061 | //qDebug("data %s ", inL.revision().toString().latin1()); | 3071 | //qDebug("data %s ", inL.revision().toString().latin1()); |
3062 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3072 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3063 | local->removeAddressee( inL ); | 3073 | local->removeAddressee( inL ); |
3064 | ++deletedAddresseeL; | 3074 | ++deletedAddresseeL; |
3065 | } else { | 3075 | } else { |
3066 | if ( ! syncManager->mWriteBackExistingOnly ) { | 3076 | if ( ! syncManager->mWriteBackExistingOnly ) { |
3067 | ++addedAddresseeR; | 3077 | ++addedAddresseeR; |
3068 | inL.setRevision( modifiedCalendar ); | 3078 | inL.setRevision( modifiedCalendar ); |
3069 | local->insertAddressee( inL, false ); | 3079 | local->insertAddressee( inL, false ); |
3070 | inR = inL; | 3080 | inR = inL; |
3071 | inR.setIDStr( ":" ); | 3081 | inR.setIDStr( ":" ); |
3072 | inR.setResource( 0 ); | 3082 | inR.setResource( 0 ); |
3073 | remote->insertAddressee( inR, false ); | 3083 | remote->insertAddressee( inR, false ); |
3074 | } | 3084 | } |
3075 | } | 3085 | } |
3076 | } | 3086 | } |
3077 | } else { | 3087 | } else { |
3078 | ++filteredOUT; | 3088 | ++filteredOUT; |
3079 | } | 3089 | } |
3080 | } | 3090 | } |
3081 | } | 3091 | } |
3082 | } | 3092 | } |
3083 | ++incCounter; | 3093 | ++incCounter; |
3084 | } | 3094 | } |
3085 | el.clear(); | 3095 | el.clear(); |
3086 | syncManager->hideProgressBar(); | 3096 | syncManager->hideProgressBar(); |
3087 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 3097 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
3088 | // get rid of micro seconds | 3098 | // get rid of micro seconds |
3089 | QTime t = mLastAddressbookSync.time(); | 3099 | QTime t = mLastAddressbookSync.time(); |
3090 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 3100 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
3091 | addresseeLSync.setRevision( mLastAddressbookSync ); | 3101 | addresseeLSync.setRevision( mLastAddressbookSync ); |
3092 | addresseeRSync.setRevision( mLastAddressbookSync ); | 3102 | addresseeRSync.setRevision( mLastAddressbookSync ); |
3093 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 3103 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
3094 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 3104 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
3095 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 3105 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
3096 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 3106 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
3097 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 3107 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
3098 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 3108 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
3099 | addresseeRSync.setNote( "" ) ; | 3109 | addresseeRSync.setNote( "" ) ; |
3100 | addresseeLSync.setNote( "" ); | 3110 | addresseeLSync.setNote( "" ); |
3101 | 3111 | ||
3102 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 3112 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
3103 | remote->insertAddressee( addresseeRSync, false ); | 3113 | remote->insertAddressee( addresseeRSync, false ); |
3104 | local->insertAddressee( addresseeLSync, false ); | 3114 | local->insertAddressee( addresseeLSync, false ); |
3105 | QString mes; | 3115 | QString mes; |
3106 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); | 3116 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); |
3107 | qDebug( mes ); | 3117 | qDebug( mes ); |
3108 | mes = i18n("Local addressbook changed!\n") +mes; | 3118 | mes = i18n("Local addressbook changed!\n") +mes; |
3109 | if ( syncManager->mShowSyncSummary ) { | 3119 | if ( syncManager->mShowSyncSummary ) { |
3110 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 3120 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
3111 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { | 3121 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { |
3112 | qDebug("cancelled "); | 3122 | qDebug("cancelled "); |
3113 | return false; | 3123 | return false; |
3114 | } | 3124 | } |
3115 | } | 3125 | } |
3116 | return syncOK; | 3126 | return syncOK; |
3117 | } | 3127 | } |
3118 | 3128 | ||
3119 | 3129 | ||
3120 | //this is a overwritten callbackmethods from the syncinterface | 3130 | //this is a overwritten callbackmethods from the syncinterface |
3121 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 3131 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
3122 | { | 3132 | { |
3123 | 3133 | ||
3124 | //pending prepare addresseeview for output | 3134 | //pending prepare addresseeview for output |
3125 | //pending detect, if remote file has REV field. if not switch to external sync | 3135 | //pending detect, if remote file has REV field. if not switch to external sync |
3126 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 3136 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
3127 | if ( manager != syncManager ) | 3137 | if ( manager != syncManager ) |
3128 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); | 3138 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); |
3129 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3139 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3130 | 3140 | ||
3131 | AddressBook abLocal(filename,"syncContact"); | 3141 | AddressBook abLocal(filename,"syncContact"); |
3132 | bool syncOK = false; | 3142 | bool syncOK = false; |
3133 | if ( abLocal.load() ) { | 3143 | if ( abLocal.load() ) { |
3134 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 3144 | qDebug("Sync:AB loaded %s,sync mode %d",filename.latin1(), mode ); |
3135 | bool external = false; | 3145 | bool external = false; |
3136 | bool isXML = false; | 3146 | bool isXML = false; |
3137 | if ( filename.right(4) == ".xml") { | 3147 | if ( filename.right(4) == ".xml") { |
3138 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3148 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3139 | isXML = true; | 3149 | isXML = true; |
3140 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3150 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3141 | } else { | 3151 | } else { |
3142 | external = !manager->mIsKapiFile; | 3152 | external = !manager->mIsKapiFile; |
3143 | if ( external ) { | 3153 | if ( external ) { |
3144 | qDebug("Setting vcf mode to external "); | 3154 | qDebug("Sync:Setting vcf mode to external "); |
3145 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3155 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3146 | AddressBook::Iterator it; | 3156 | AddressBook::Iterator it; |
3147 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3157 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3148 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 3158 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
3149 | (*it).computeCsum( mCurrentSyncDevice ); | 3159 | (*it).computeCsum( mCurrentSyncDevice ); |
3150 | } | 3160 | } |
3151 | } | 3161 | } |
3152 | } | 3162 | } |
3153 | //AddressBook::Iterator it; | 3163 | //AddressBook::Iterator it; |
3154 | //QStringList vcards; | 3164 | //QStringList vcards; |
3155 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3165 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3156 | // qDebug("Name %s ", (*it).familyName().latin1()); | 3166 | // qDebug("Name %s ", (*it).familyName().latin1()); |
3157 | //} | 3167 | //} |
3158 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 3168 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
3159 | if ( syncOK ) { | 3169 | if ( syncOK ) { |
3160 | if ( syncManager->mWriteBackFile ) | 3170 | if ( syncManager->mWriteBackFile ) |
3161 | { | 3171 | { |
3162 | if ( external ) | 3172 | if ( external ) |
3163 | abLocal.removeSyncAddressees( !isXML); | 3173 | abLocal.removeSyncAddressees( !isXML); |
3164 | qDebug("Saving remote AB "); | 3174 | qDebug("Sync:Saving remote AB "); |
3165 | if ( ! abLocal.saveAB()) | 3175 | if ( ! abLocal.saveAB()) |
3166 | qDebug("Error writing back AB to file "); | 3176 | qDebug("Error writing back AB to file "); |
3167 | if ( external ) { | 3177 | if ( external ) { |
3168 | // afterwrite processing | 3178 | // afterwrite processing |
3169 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); | 3179 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); |
3170 | } | 3180 | } |
3171 | } | 3181 | } |
3172 | } | 3182 | } |
3173 | setModified(); | 3183 | setModified(); |
3174 | 3184 | ||
3175 | } | 3185 | } |
3176 | abLocal.removeResources(); | 3186 | abLocal.removeResources(); |
3177 | if ( syncOK ) | 3187 | if ( syncOK ) |
3178 | mViewManager->refreshView(); | 3188 | mViewManager->refreshView(); |
3179 | return syncOK; | 3189 | return syncOK; |
3180 | 3190 | ||
3181 | } | 3191 | } |
3182 | void KABCore::removeSyncInfo( QString syncProfile) | 3192 | void KABCore::removeSyncInfo( QString syncProfile) |
3183 | { | 3193 | { |
3184 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); | 3194 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); |
3185 | mAddressBook->removeSyncInfo( syncProfile ); | 3195 | mAddressBook->removeSyncInfo( syncProfile ); |
3186 | setModified(); | 3196 | setModified(); |
3187 | } | 3197 | } |
3188 | 3198 | ||
3189 | 3199 | ||
3190 | //this is a overwritten callbackmethods from the syncinterface | 3200 | //this is a overwritten callbackmethods from the syncinterface |
3191 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 3201 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
3192 | { | 3202 | { |
3193 | if ( resource == "phone" ) | 3203 | if ( resource == "phone" ) |
3194 | return syncPhone(); | 3204 | return syncPhone(); |
3195 | disableBR( true ); | 3205 | disableBR( true ); |
3196 | if ( manager != syncManager ) | 3206 | if ( manager != syncManager ) |
3197 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); | 3207 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); |
3198 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3208 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3199 | 3209 | ||
3200 | AddressBook abLocal( resource,"syncContact"); | 3210 | AddressBook abLocal( resource,"syncContact"); |
3201 | bool syncOK = false; | 3211 | bool syncOK = false; |
3202 | message(i18n("Loading DTM address data..."), false); | 3212 | message(i18n("Loading DTM address data..."), false); |
3203 | if ( abLocal.load() ) { | 3213 | if ( abLocal.load() ) { |
3204 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3214 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3205 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3215 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3206 | message(i18n("Sync preprocessing..."),false); | 3216 | message(i18n("Sync preprocessing..."),false); |
3207 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 3217 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
3208 | message(i18n("Synchronizing..."),false); | 3218 | message(i18n("Synchronizing..."),false); |
3209 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3219 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3210 | if ( syncOK ) { | 3220 | if ( syncOK ) { |
3211 | if ( syncManager->mWriteBackFile ) { | 3221 | if ( syncManager->mWriteBackFile ) { |
3212 | abLocal.removeSyncAddressees( false ); | 3222 | abLocal.removeSyncAddressees( false ); |
3213 | message(i18n("Saving DTM address data..."),false); | 3223 | message(i18n("Saving DTM address data..."),false); |
3214 | abLocal.saveAB(); | 3224 | abLocal.saveAB(); |
3215 | message(i18n("Sync postprocessing..."),false); | 3225 | message(i18n("Sync postprocessing..."),false); |
3216 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3226 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3217 | } | 3227 | } |
3218 | } else | 3228 | } else |
3219 | message( i18n("Sync cancelled or failed.") ); | 3229 | message( i18n("Sync cancelled or failed.") ); |
3220 | setModified(); | 3230 | setModified(); |
3221 | } | 3231 | } |
3222 | abLocal.removeResources(); | 3232 | abLocal.removeResources(); |
3223 | if ( syncOK ) { | 3233 | if ( syncOK ) { |
3224 | mViewManager->refreshView(); | 3234 | mViewManager->refreshView(); |
3225 | message(i18n("DTM syncing finished.")); | 3235 | message(i18n("DTM syncing finished.")); |
3226 | } | 3236 | } |
3227 | disableBR( false ); | 3237 | disableBR( false ); |
3228 | return syncOK; | 3238 | return syncOK; |
3229 | 3239 | ||
3230 | } | 3240 | } |
3231 | void KABCore::message( QString m, bool startTimer) | 3241 | void KABCore::message( QString m, bool startTimer) |
3232 | { | 3242 | { |
3233 | topLevelWidget()->setCaption( m ); | 3243 | topLevelWidget()->setCaption( m ); |
3234 | qApp->processEvents(); | 3244 | qApp->processEvents(); |
3235 | if ( startTimer ) | 3245 | if ( startTimer ) |
3236 | mMessageTimer->start( 15000, true ); | 3246 | mMessageTimer->start( 15000, true ); |
3237 | else | 3247 | else |
3238 | mMessageTimer->stop(); | 3248 | mMessageTimer->stop(); |
3239 | } | 3249 | } |
3240 | bool KABCore::syncPhone() | 3250 | bool KABCore::syncPhone() |
3241 | { | 3251 | { |
3242 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 3252 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
3243 | QString fileName = getPhoneFile(); | 3253 | QString fileName = getPhoneFile(); |
3244 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 3254 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
3245 | message(i18n("Phone access failed!")); | 3255 | message(i18n("Phone access failed!")); |
3246 | return false; | 3256 | return false; |
3247 | } | 3257 | } |
3248 | AddressBook abLocal( fileName,"syncContact"); | 3258 | AddressBook abLocal( fileName,"syncContact"); |
3249 | bool syncOK = false; | 3259 | bool syncOK = false; |
3250 | { | 3260 | { |
3251 | abLocal.importFromFile( fileName ); | 3261 | abLocal.importFromFile( fileName ); |
3252 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3262 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3253 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3263 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3254 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 3264 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
3255 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3265 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3256 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3266 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3257 | if ( syncOK ) { | 3267 | if ( syncOK ) { |
3258 | if ( syncManager->mWriteBackFile ) { | 3268 | if ( syncManager->mWriteBackFile ) { |
3259 | abLocal.removeSyncAddressees( true ); | 3269 | abLocal.removeSyncAddressees( true ); |
3260 | abLocal.saveABphone( fileName ); | 3270 | abLocal.saveABphone( fileName ); |