Diffstat (limited to 'kabc/plugins/qtopia/resourceqtopia.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | kabc/plugins/qtopia/resourceqtopia.cpp | 105 |
1 files changed, 11 insertions, 94 deletions
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp index 1f90fcb..f9cabcb 100644 --- a/kabc/plugins/qtopia/resourceqtopia.cpp +++ b/kabc/plugins/qtopia/resourceqtopia.cpp @@ -52,8 +52,6 @@ $Id$ #include "syncprefwidget.h" #include "resourceqtopia.h" -#include <libkdepim/ksyncprofile.h> -#include <qpe/quuid.h> using namespace KABC; extern "C" @@ -197,106 +195,25 @@ bool ResourceQtopia::save( Ticket *ticket ) KABC::AddressBook::Iterator it; bool res; - KABC::Addressee::List changedAddressees; - QStringList addedUID; + for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { - //KABC::Addressee addressee = (*it); - // qDebug("AAAfor uid %s ", (*it).originalExternalUID().latin1() ); - if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { - QUuid uid( (*it).originalExternalUID() ); - bool ok; - PimContact c = mAccess->contactForId( uid, &ok ); - qDebug("ResourceQtopia::save:Found %d for uid %s ", ok,(*it).originalExternalUID().latin1() ); + PimContact c; + KABC::Addressee addressee = (*it); + res = mConverter->addresseeToQtopia( *it, c ); - if (res == true) { - if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) { - qDebug("skipping adding of contact "); - continue; - PimContact e; - AddressBookAccess Access2; - Access2.addContact(e); - const PimContact* contact; - bool res; - QString uid2, Ouid; - AddressBookIterator itt(Access2); - for (contact=itt.toFirst(); itt.current(); ++itt) + if (res == true) { - contact = itt.current(); - QString exuid = contact->uid().toString(); - Ouid =exuid; - int ente = exuid.find( "-0000"); - if ( exuid.left(1) == "{" ) - exuid = exuid.mid(1); - if ( ente > -1 ) - exuid = exuid.left( ente-1 ); - uid2 = exuid; - qDebug("trying find uid "); - if ( !addressBook()->containsExternalUid( uid2 ) ) { - qDebug("ab not contains "); - if ( !addedUID.contains( uid2 )) { - qDebug("list not contains "); - break; - } - } - - } - if ( !itt.current()) { - qDebug("ERROR uid "); - continue; + mAccess->addContact(c); +// if (res == false) +// qDebug("Unable to append Contact %s", c.fullName().latin1()); } else - qDebug("ADD uid detected "); - - - QUuid uid3( Ouid); - PimContact d = Access2.contactForId( uid3, &ok ); - if ( ! ok ) { - qDebug("ADD: Error getting new uid "); - } else { - qDebug("NEW UID found "); - PimContact g = mAccess->contactForId( c.uid(), &ok ); - KABC::Addressee addressee; - mConverter->qtopiaToAddressee( g, addressee ); - addressee.setUid((*it).uid() ); - addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); - changedAddressees.append( addressee ); - addedUID.append( uid2 ); - } - - - } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { - qDebug("Remove contact "); - if ( ok ) - mAccess->removeContact(c); - else - qDebug("Error remove contact from qtopia "); - } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { - if ( ok ) { - qDebug("Update contact "); - mAccess->updateContact(c); - PimContact g = mAccess->contactForId( c.uid(), &ok ); - KABC::Addressee addressee; - mConverter->qtopiaToAddressee( g, addressee ); - addressee.setUid((*it).uid() ); - addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); - changedAddressees.append( addressee ); - } - else - qDebug("Error update contact from qtopia "); - - } - - } else { - qDebug("Unable to convert Addressee %s", (*it).formattedName().latin1()); - } + { + qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1()); } } - KABC::Addressee::List::Iterator it2; - for ( it2 = changedAddressees.begin(); it2 != changedAddressees.end(); ++it2 ) - addressBook()->insertAddressee((*it2)); - - +// mAccess->addressBookUpdated(); mDirWatch.startScan(); |