author | zautrix <zautrix> | 2004-10-29 14:01:58 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-29 14:01:58 (UTC) |
commit | 102cc4a711e303372efea9797623ee2d9f27f63c (patch) (unidiff) | |
tree | 32e56b436e52b5b1bab701839a24fc175288d57c /kaddressbook | |
parent | 8c55eb6afe84ef69bb284d384a0c9f1ef1484ad8 (diff) | |
download | kdepimpi-102cc4a711e303372efea9797623ee2d9f27f63c.zip kdepimpi-102cc4a711e303372efea9797623ee2d9f27f63c.tar.gz kdepimpi-102cc4a711e303372efea9797623ee2d9f27f63c.tar.bz2 |
removed debug output
-rw-r--r-- | kaddressbook/kabcore.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 6e482b5..e6bdde9 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2221,96 +2221,96 @@ void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString | |||
2221 | { | 2221 | { |
2222 | if ( ! bar.isVisible() ) | 2222 | if ( ! bar.isVisible() ) |
2223 | return; | 2223 | return; |
2224 | bar.setProgress( count++ ); | 2224 | bar.setProgress( count++ ); |
2225 | qApp->processEvents(); | 2225 | qApp->processEvents(); |
2226 | bday = (*it).birthday().date(); | 2226 | bday = (*it).birthday().date(); |
2227 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2227 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2228 | 2228 | ||
2229 | if ( bday.isValid() || !anni.isEmpty()) | 2229 | if ( bday.isValid() || !anni.isEmpty()) |
2230 | { | 2230 | { |
2231 | if (bday.isValid()) | 2231 | if (bday.isValid()) |
2232 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2232 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2233 | else | 2233 | else |
2234 | formattedbday = "NOTVALID"; | 2234 | formattedbday = "NOTVALID"; |
2235 | if (anni.isEmpty()) | 2235 | if (anni.isEmpty()) |
2236 | anni = "INVALID"; | 2236 | anni = "INVALID"; |
2237 | 2237 | ||
2238 | birthdayList.append(formattedbday); | 2238 | birthdayList.append(formattedbday); |
2239 | anniversaryList.append(anni); //should be ISODate | 2239 | anniversaryList.append(anni); //should be ISODate |
2240 | realNameList.append((*it).realName()); | 2240 | realNameList.append((*it).realName()); |
2241 | preferredEmailList.append((*it).preferredEmail()); | 2241 | preferredEmailList.append((*it).preferredEmail()); |
2242 | assembledNameList.append((*it).assembledName()); | 2242 | assembledNameList.append((*it).assembledName()); |
2243 | uidList.append((*it).uid()); | 2243 | uidList.append((*it).uid()); |
2244 | 2244 | ||
2245 | qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); | 2245 | //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); |
2246 | } | 2246 | } |
2247 | } | 2247 | } |
2248 | 2248 | ||
2249 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2249 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2250 | 2250 | ||
2251 | } | 2251 | } |
2252 | 2252 | ||
2253 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2253 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2254 | */ | 2254 | */ |
2255 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2255 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2256 | { | 2256 | { |
2257 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2257 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2258 | 2258 | ||
2259 | QString foundUid = QString::null; | 2259 | QString foundUid = QString::null; |
2260 | if ( ! uid.isEmpty() ) { | 2260 | if ( ! uid.isEmpty() ) { |
2261 | Addressee adrr = mAddressBook->findByUid( uid ); | 2261 | Addressee adrr = mAddressBook->findByUid( uid ); |
2262 | if ( !adrr.isEmpty() ) { | 2262 | if ( !adrr.isEmpty() ) { |
2263 | foundUid = uid; | 2263 | foundUid = uid; |
2264 | } | 2264 | } |
2265 | if ( email == "sendbacklist" ) { | 2265 | if ( email == "sendbacklist" ) { |
2266 | //qDebug("ssssssssssssssssssssssend "); | 2266 | //qDebug("ssssssssssssssssssssssend "); |
2267 | QStringList nameList; | 2267 | QStringList nameList; |
2268 | QStringList emailList; | 2268 | QStringList emailList; |
2269 | QStringList uidList; | 2269 | QStringList uidList; |
2270 | nameList.append(adrr.realName()); | 2270 | nameList.append(adrr.realName()); |
2271 | emailList = adrr.emails(); | 2271 | emailList = adrr.emails(); |
2272 | uidList.append( adrr.preferredEmail()); | 2272 | uidList.append( adrr.preferredEmail()); |
2273 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2273 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2274 | return; | 2274 | return; |
2275 | } | 2275 | } |
2276 | 2276 | ||
2277 | } | 2277 | } |
2278 | 2278 | ||
2279 | if ( email == "sendbacklist" ) | 2279 | if ( email == "sendbacklist" ) |
2280 | return; | 2280 | return; |
2281 | if (foundUid.isEmpty()) | 2281 | if (foundUid.isEmpty()) |
2282 | { | 2282 | { |
2283 | //find the uid of the person first | 2283 | //find the uid of the person first |
2284 | Addressee::List namelist; | 2284 | Addressee::List namelist; |
2285 | Addressee::List emaillist; | 2285 | Addressee::List emaillist; |
2286 | 2286 | ||
2287 | if (!name.isEmpty()) | 2287 | if (!name.isEmpty()) |
2288 | namelist = mAddressBook->findByName( name ); | 2288 | namelist = mAddressBook->findByName( name ); |
2289 | 2289 | ||
2290 | if (!email.isEmpty()) | 2290 | if (!email.isEmpty()) |
2291 | emaillist = mAddressBook->findByEmail( email ); | 2291 | emaillist = mAddressBook->findByEmail( email ); |
2292 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2292 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2293 | //check if we have a match in Namelist and Emaillist | 2293 | //check if we have a match in Namelist and Emaillist |
2294 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2294 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2295 | foundUid = emaillist[0].uid(); | 2295 | foundUid = emaillist[0].uid(); |
2296 | } | 2296 | } |
2297 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2297 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2298 | foundUid = namelist[0].uid(); | 2298 | foundUid = namelist[0].uid(); |
2299 | else | 2299 | else |
2300 | { | 2300 | { |
2301 | for (int i = 0; i < namelist.count(); i++) | 2301 | for (int i = 0; i < namelist.count(); i++) |
2302 | { | 2302 | { |
2303 | for (int j = 0; j < emaillist.count(); j++) | 2303 | for (int j = 0; j < emaillist.count(); j++) |
2304 | { | 2304 | { |
2305 | if (namelist[i] == emaillist[j]) | 2305 | if (namelist[i] == emaillist[j]) |
2306 | { | 2306 | { |
2307 | foundUid = namelist[i].uid(); | 2307 | foundUid = namelist[i].uid(); |
2308 | } | 2308 | } |
2309 | } | 2309 | } |
2310 | } | 2310 | } |
2311 | } | 2311 | } |
2312 | } | 2312 | } |
2313 | else | 2313 | else |
2314 | { | 2314 | { |
2315 | foundUid = uid; | 2315 | foundUid = uid; |
2316 | } | 2316 | } |
@@ -2385,86 +2385,86 @@ KABC::Addressee KABCore::getLastSyncAddressee() | |||
2385 | return lse; | 2385 | return lse; |
2386 | } | 2386 | } |
2387 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2387 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2388 | { | 2388 | { |
2389 | 2389 | ||
2390 | //void setZaurusId(int id); | 2390 | //void setZaurusId(int id); |
2391 | // int zaurusId() const; | 2391 | // int zaurusId() const; |
2392 | // void setZaurusUid(int id); | 2392 | // void setZaurusUid(int id); |
2393 | // int zaurusUid() const; | 2393 | // int zaurusUid() const; |
2394 | // void setZaurusStat(int id); | 2394 | // void setZaurusStat(int id); |
2395 | // int zaurusStat() const; | 2395 | // int zaurusStat() const; |
2396 | // 0 equal | 2396 | // 0 equal |
2397 | // 1 take local | 2397 | // 1 take local |
2398 | // 2 take remote | 2398 | // 2 take remote |
2399 | // 3 cancel | 2399 | // 3 cancel |
2400 | QDateTime lastSync = mLastAddressbookSync; | 2400 | QDateTime lastSync = mLastAddressbookSync; |
2401 | QDateTime localMod = local->revision(); | 2401 | QDateTime localMod = local->revision(); |
2402 | QDateTime remoteMod = remote->revision(); | 2402 | QDateTime remoteMod = remote->revision(); |
2403 | 2403 | ||
2404 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2404 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2405 | 2405 | ||
2406 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2406 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2407 | bool remCh, locCh; | 2407 | bool remCh, locCh; |
2408 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2408 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2409 | qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2409 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2410 | locCh = ( localMod > mLastAddressbookSync ); | 2410 | locCh = ( localMod > mLastAddressbookSync ); |
2411 | if ( !remCh && ! locCh ) { | 2411 | if ( !remCh && ! locCh ) { |
2412 | qDebug("both not changed "); | 2412 | //qDebug("both not changed "); |
2413 | lastSync = localMod.addDays(1); | 2413 | lastSync = localMod.addDays(1); |
2414 | if ( mode <= SYNC_PREF_ASK ) | 2414 | if ( mode <= SYNC_PREF_ASK ) |
2415 | return 0; | 2415 | return 0; |
2416 | } else { | 2416 | } else { |
2417 | if ( locCh ) { | 2417 | if ( locCh ) { |
2418 | qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2418 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2419 | lastSync = localMod.addDays( -1 ); | 2419 | lastSync = localMod.addDays( -1 ); |
2420 | if ( !remCh ) | 2420 | if ( !remCh ) |
2421 | remoteMod =( lastSync.addDays( -1 ) ); | 2421 | remoteMod =( lastSync.addDays( -1 ) ); |
2422 | } else { | 2422 | } else { |
2423 | qDebug(" not loc changed "); | 2423 | //qDebug(" not loc changed "); |
2424 | lastSync = localMod.addDays( 1 ); | 2424 | lastSync = localMod.addDays( 1 ); |
2425 | if ( remCh ) { | 2425 | if ( remCh ) { |
2426 | qDebug("rem changed "); | 2426 | //qDebug("rem changed "); |
2427 | remoteMod =( lastSync.addDays( 1 ) ); | 2427 | remoteMod =( lastSync.addDays( 1 ) ); |
2428 | } | 2428 | } |
2429 | 2429 | ||
2430 | } | 2430 | } |
2431 | } | 2431 | } |
2432 | full = true; | 2432 | full = true; |
2433 | if ( mode < SYNC_PREF_ASK ) | 2433 | if ( mode < SYNC_PREF_ASK ) |
2434 | mode = SYNC_PREF_ASK; | 2434 | mode = SYNC_PREF_ASK; |
2435 | } else { | 2435 | } else { |
2436 | if ( localMod == remoteMod ) | 2436 | if ( localMod == remoteMod ) |
2437 | return 0; | 2437 | return 0; |
2438 | 2438 | ||
2439 | } | 2439 | } |
2440 | qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); | 2440 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); |
2441 | qDebug("lastsync %s ", lastSync.toString().latin1() ); | 2441 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); |
2442 | //full = true; //debug only | 2442 | //full = true; //debug only |
2443 | if ( full ) { | 2443 | if ( full ) { |
2444 | bool equ = ( (*local) == (*remote) ); | 2444 | bool equ = ( (*local) == (*remote) ); |
2445 | if ( equ ) { | 2445 | if ( equ ) { |
2446 | qDebug("equal "); | 2446 | //qDebug("equal "); |
2447 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2447 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2448 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2448 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2449 | } | 2449 | } |
2450 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2450 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2451 | return 0; | 2451 | return 0; |
2452 | 2452 | ||
2453 | }//else //debug only | 2453 | }//else //debug only |
2454 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2454 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2455 | } | 2455 | } |
2456 | int result; | 2456 | int result; |
2457 | bool localIsNew; | 2457 | bool localIsNew; |
2458 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); | 2458 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); |
2459 | 2459 | ||
2460 | if ( full && mode < SYNC_PREF_NEWEST ) | 2460 | if ( full && mode < SYNC_PREF_NEWEST ) |
2461 | mode = SYNC_PREF_ASK; | 2461 | mode = SYNC_PREF_ASK; |
2462 | 2462 | ||
2463 | switch( mode ) { | 2463 | switch( mode ) { |
2464 | case SYNC_PREF_LOCAL: | 2464 | case SYNC_PREF_LOCAL: |
2465 | if ( lastSync > remoteMod ) | 2465 | if ( lastSync > remoteMod ) |
2466 | return 1; | 2466 | return 1; |
2467 | if ( lastSync > localMod ) | 2467 | if ( lastSync > localMod ) |
2468 | return 2; | 2468 | return 2; |
2469 | return 1; | 2469 | return 1; |
2470 | break; | 2470 | break; |
@@ -2535,69 +2535,69 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2535 | bool fullDateRange = false; | 2535 | bool fullDateRange = false; |
2536 | local->resetTempSyncStat(); | 2536 | local->resetTempSyncStat(); |
2537 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2537 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2538 | if ( syncManager->syncWithDesktop() ) { | 2538 | if ( syncManager->syncWithDesktop() ) { |
2539 | // remote->removeSyncInfo( QString());//remove all info | 2539 | // remote->removeSyncInfo( QString());//remove all info |
2540 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 2540 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
2541 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; | 2541 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; |
2542 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); | 2542 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); |
2543 | } else { | 2543 | } else { |
2544 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 2544 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
2545 | } | 2545 | } |
2546 | } | 2546 | } |
2547 | QDateTime modifiedCalendar = mLastAddressbookSync; | 2547 | QDateTime modifiedCalendar = mLastAddressbookSync; |
2548 | addresseeLSync = getLastSyncAddressee(); | 2548 | addresseeLSync = getLastSyncAddressee(); |
2549 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2549 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2550 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2550 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2551 | if ( !addresseeR.isEmpty() ) { | 2551 | if ( !addresseeR.isEmpty() ) { |
2552 | addresseeRSync = addresseeR; | 2552 | addresseeRSync = addresseeR; |
2553 | remote->removeAddressee(addresseeR ); | 2553 | remote->removeAddressee(addresseeR ); |
2554 | 2554 | ||
2555 | } else { | 2555 | } else { |
2556 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2556 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2557 | addresseeRSync = addresseeLSync ; | 2557 | addresseeRSync = addresseeLSync ; |
2558 | } else { | 2558 | } else { |
2559 | qDebug("FULLDATE 1"); | 2559 | //qDebug("FULLDATE 1"); |
2560 | fullDateRange = true; | 2560 | fullDateRange = true; |
2561 | Addressee newAdd; | 2561 | Addressee newAdd; |
2562 | addresseeRSync = newAdd; | 2562 | addresseeRSync = newAdd; |
2563 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2563 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2564 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2564 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2565 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2565 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2566 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2566 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2567 | } | 2567 | } |
2568 | } | 2568 | } |
2569 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2569 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2570 | qDebug("FULLDATE 2"); | 2570 | // qDebug("FULLDATE 2"); |
2571 | fullDateRange = true; | 2571 | fullDateRange = true; |
2572 | } | 2572 | } |
2573 | if ( ! fullDateRange ) { | 2573 | if ( ! fullDateRange ) { |
2574 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2574 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2575 | 2575 | ||
2576 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2576 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2577 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2577 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2578 | fullDateRange = true; | 2578 | fullDateRange = true; |
2579 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2579 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2580 | } | 2580 | } |
2581 | } | 2581 | } |
2582 | // fullDateRange = true; // debug only! | 2582 | // fullDateRange = true; // debug only! |
2583 | if ( fullDateRange ) | 2583 | if ( fullDateRange ) |
2584 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2584 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2585 | else | 2585 | else |
2586 | mLastAddressbookSync = addresseeLSync.revision(); | 2586 | mLastAddressbookSync = addresseeLSync.revision(); |
2587 | // for resyncing if own file has changed | 2587 | // for resyncing if own file has changed |
2588 | // PENDING fixme later when implemented | 2588 | // PENDING fixme later when implemented |
2589 | #if 0 | 2589 | #if 0 |
2590 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2590 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2591 | mLastAddressbookSync = loadedFileVersion; | 2591 | mLastAddressbookSync = loadedFileVersion; |
2592 | qDebug("setting mLastAddressbookSync "); | 2592 | qDebug("setting mLastAddressbookSync "); |
2593 | } | 2593 | } |
2594 | #endif | 2594 | #endif |
2595 | 2595 | ||
2596 | //qDebug("*************************** "); | 2596 | //qDebug("*************************** "); |
2597 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2597 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2598 | QStringList er = remote->uidList(); | 2598 | QStringList er = remote->uidList(); |
2599 | Addressee inR ;//= er.first(); | 2599 | Addressee inR ;//= er.first(); |
2600 | Addressee inL; | 2600 | Addressee inL; |
2601 | 2601 | ||
2602 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2602 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2603 | 2603 | ||
@@ -2835,125 +2835,128 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | |||
2835 | } | 2835 | } |
2836 | //AddressBook::Iterator it; | 2836 | //AddressBook::Iterator it; |
2837 | //QStringList vcards; | 2837 | //QStringList vcards; |
2838 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2838 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2839 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2839 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2840 | //} | 2840 | //} |
2841 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2841 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2842 | if ( syncOK ) { | 2842 | if ( syncOK ) { |
2843 | if ( syncManager->mWriteBackFile ) | 2843 | if ( syncManager->mWriteBackFile ) |
2844 | { | 2844 | { |
2845 | if ( external ) | 2845 | if ( external ) |
2846 | abLocal.removeSyncAddressees( !isXML); | 2846 | abLocal.removeSyncAddressees( !isXML); |
2847 | qDebug("Saving remote AB "); | 2847 | qDebug("Saving remote AB "); |
2848 | if ( ! abLocal.saveAB()) | 2848 | if ( ! abLocal.saveAB()) |
2849 | qDebug("Error writing back AB to file "); | 2849 | qDebug("Error writing back AB to file "); |
2850 | if ( external ) { | 2850 | if ( external ) { |
2851 | // afterwrite processing | 2851 | // afterwrite processing |
2852 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); | 2852 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); |
2853 | } | 2853 | } |
2854 | } | 2854 | } |
2855 | } | 2855 | } |
2856 | setModified(); | 2856 | setModified(); |
2857 | 2857 | ||
2858 | } | 2858 | } |
2859 | abLocal.removeResources(); | ||
2859 | if ( syncOK ) | 2860 | if ( syncOK ) |
2860 | mViewManager->refreshView(); | 2861 | mViewManager->refreshView(); |
2861 | return syncOK; | 2862 | return syncOK; |
2862 | 2863 | ||
2863 | } | 2864 | } |
2864 | void KABCore::removeSyncInfo( QString syncProfile) | 2865 | void KABCore::removeSyncInfo( QString syncProfile) |
2865 | { | 2866 | { |
2866 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); | 2867 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); |
2867 | mAddressBook->removeSyncInfo( syncProfile ); | 2868 | mAddressBook->removeSyncInfo( syncProfile ); |
2868 | setModified(); | 2869 | setModified(); |
2869 | } | 2870 | } |
2870 | 2871 | ||
2871 | 2872 | ||
2872 | //this is a overwritten callbackmethods from the syncinterface | 2873 | //this is a overwritten callbackmethods from the syncinterface |
2873 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2874 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
2874 | { | 2875 | { |
2875 | if ( resource == "phone" ) | 2876 | if ( resource == "phone" ) |
2876 | return syncPhone(); | 2877 | return syncPhone(); |
2877 | disableBR( true ); | 2878 | disableBR( true ); |
2878 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2879 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2879 | 2880 | ||
2880 | AddressBook abLocal( resource,"syncContact"); | 2881 | AddressBook abLocal( resource,"syncContact"); |
2881 | bool syncOK = false; | 2882 | bool syncOK = false; |
2882 | if ( abLocal.load() ) { | 2883 | if ( abLocal.load() ) { |
2883 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2884 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2884 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2885 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2885 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 2886 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
2886 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2887 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2887 | if ( syncOK ) { | 2888 | if ( syncOK ) { |
2888 | if ( syncManager->mWriteBackFile ) { | 2889 | if ( syncManager->mWriteBackFile ) { |
2889 | abLocal.removeSyncAddressees( false ); | 2890 | abLocal.removeSyncAddressees( false ); |
2890 | abLocal.saveAB(); | 2891 | abLocal.saveAB(); |
2891 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 2892 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
2892 | } | 2893 | } |
2893 | } else | 2894 | } else |
2894 | message( i18n("Sync cancelled or failed.") ); | 2895 | message( i18n("Sync cancelled or failed.") ); |
2895 | setModified(); | 2896 | setModified(); |
2896 | } | 2897 | } |
2898 | abLocal.removeResources(); | ||
2897 | if ( syncOK ) | 2899 | if ( syncOK ) |
2898 | mViewManager->refreshView(); | 2900 | mViewManager->refreshView(); |
2899 | disableBR( false ); | 2901 | disableBR( false ); |
2900 | return syncOK; | 2902 | return syncOK; |
2901 | 2903 | ||
2902 | } | 2904 | } |
2903 | void KABCore::message( QString m ) | 2905 | void KABCore::message( QString m ) |
2904 | { | 2906 | { |
2905 | topLevelWidget()->setCaption( m ); | 2907 | topLevelWidget()->setCaption( m ); |
2906 | mMessageTimer->start( 15000, true ); | 2908 | mMessageTimer->start( 15000, true ); |
2907 | } | 2909 | } |
2908 | bool KABCore::syncPhone() | 2910 | bool KABCore::syncPhone() |
2909 | { | 2911 | { |
2910 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2912 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2911 | QString fileName = getPhoneFile(); | 2913 | QString fileName = getPhoneFile(); |
2912 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 2914 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
2913 | message(i18n("Phone access failed!")); | 2915 | message(i18n("Phone access failed!")); |
2914 | return false; | 2916 | return false; |
2915 | } | 2917 | } |
2916 | AddressBook abLocal( fileName,"syncContact"); | 2918 | AddressBook abLocal( fileName,"syncContact"); |
2917 | bool syncOK = false; | 2919 | bool syncOK = false; |
2918 | { | 2920 | { |
2919 | abLocal.importFromFile( fileName ); | 2921 | abLocal.importFromFile( fileName ); |
2920 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2922 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2921 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2923 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2922 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 2924 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
2923 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 2925 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2924 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2926 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2925 | if ( syncOK ) { | 2927 | if ( syncOK ) { |
2926 | if ( syncManager->mWriteBackFile ) { | 2928 | if ( syncManager->mWriteBackFile ) { |
2927 | abLocal.removeSyncAddressees( true ); | 2929 | abLocal.removeSyncAddressees( true ); |
2928 | abLocal.saveABphone( fileName ); | 2930 | abLocal.saveABphone( fileName ); |
2929 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 2931 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
2930 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 2932 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
2931 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 2933 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
2932 | } | 2934 | } |
2933 | } | 2935 | } |
2934 | setModified(); | 2936 | setModified(); |
2935 | } | 2937 | } |
2938 | abLocal.removeResources(); | ||
2936 | if ( syncOK ) | 2939 | if ( syncOK ) |
2937 | mViewManager->refreshView(); | 2940 | mViewManager->refreshView(); |
2938 | return syncOK; | 2941 | return syncOK; |
2939 | } | 2942 | } |
2940 | void KABCore::getFile( bool success ) | 2943 | void KABCore::getFile( bool success ) |
2941 | { | 2944 | { |
2942 | if ( ! success ) { | 2945 | if ( ! success ) { |
2943 | message( i18n("Error receiving file. Nothing changed!") ); | 2946 | message( i18n("Error receiving file. Nothing changed!") ); |
2944 | return; | 2947 | return; |
2945 | } | 2948 | } |
2946 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); | 2949 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); |
2947 | if ( count ) | 2950 | if ( count ) |
2948 | setModified( true ); | 2951 | setModified( true ); |
2949 | message( i18n("Pi-Sync successful!") ); | 2952 | message( i18n("Pi-Sync successful!") ); |
2950 | mViewManager->refreshView(); | 2953 | mViewManager->refreshView(); |
2951 | } | 2954 | } |
2952 | void KABCore::syncFileRequest() | 2955 | void KABCore::syncFileRequest() |
2953 | { | 2956 | { |
2954 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { | 2957 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { |
2955 | syncManager->slotSyncMenu( 999 ); | 2958 | syncManager->slotSyncMenu( 999 ); |
2956 | } | 2959 | } |
2957 | mAddressBook->export2File( sentSyncFile() ); | 2960 | mAddressBook->export2File( sentSyncFile() ); |
2958 | } | 2961 | } |
2959 | QString KABCore::sentSyncFile() | 2962 | QString KABCore::sentSyncFile() |