author | zautrix <zautrix> | 2004-09-19 20:14:28 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-19 20:14:28 (UTC) |
commit | afa28a62314117555d6b32291188eedd1a576284 (patch) (side-by-side diff) | |
tree | ea97a247de30a7a34480bc395e1996ab99247361 /kabc/plugins | |
parent | e0d8e062c9d8092e47dcadd88b30614ebff43c0c (diff) | |
download | kdepimpi-afa28a62314117555d6b32291188eedd1a576284.zip kdepimpi-afa28a62314117555d6b32291188eedd1a576284.tar.gz kdepimpi-afa28a62314117555d6b32291188eedd1a576284.tar.bz2 |
more AB sync
-rw-r--r-- | kabc/plugins/qtopia/qtopiaE.pro | 2 | ||||
-rw-r--r-- | kabc/plugins/qtopia/qtopiaconverter.cpp | 7 | ||||
-rw-r--r-- | kabc/plugins/qtopia/qtopiaconverter.h | 1 | ||||
-rw-r--r-- | kabc/plugins/qtopia/resourceqtopia.cpp | 78 |
4 files changed, 60 insertions, 28 deletions
diff --git a/kabc/plugins/qtopia/qtopiaE.pro b/kabc/plugins/qtopia/qtopiaE.pro index 148da2a..c0aa960 100644 --- a/kabc/plugins/qtopia/qtopiaE.pro +++ b/kabc/plugins/qtopia/qtopiaE.pro @@ -1,12 +1,12 @@ TEMPLATE = lib CONFIG += qt warn_on TARGET = microkabc_qtopia -INCLUDEPATH += $(KDEPIMDIR)/kabc $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/qtcompat $(QPEDIR)/include +INCLUDEPATH += $(KDEPIMDIR) $(KDEPIMDIR)/kabc $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/qtcompat $(QPEDIR)/include OBJECTS_DIR = obj/$(PLATFORM) MOC_DIR = moc/$(PLATFORM) DESTDIR = $(QPEDIR)/lib LIBS += -lmicrokde LIBS += -lmicrokabc diff --git a/kabc/plugins/qtopia/qtopiaconverter.cpp b/kabc/plugins/qtopia/qtopiaconverter.cpp index 7d00a3f..de45e63 100644 --- a/kabc/plugins/qtopia/qtopiaconverter.cpp +++ b/kabc/plugins/qtopia/qtopiaconverter.cpp @@ -29,12 +29,13 @@ $Id$ #include "kglobal.h" #include "qtopiaconverter.h" #include <qpe/categories.h> +#include <libkdepim/ksyncprofile.h> //US #include <qpe/categoryselect.h> using namespace KABC; QtopiaConverter::QtopiaConverter() : catDB(0) @@ -72,13 +73,16 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a addr.setFormattedName(contact.fileAs()); addr.setFamilyName( contact.lastName() ); addr.setGivenName( contact.firstName() ); addr.setAdditionalName( contact.middleName() ); addr.setPrefix( contact.nameTitle() ); addr.setSuffix( contact.suffix() ); + + addr.setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); QString exuid = contact.uid().toString(); + addr.setOriginalExternalUID( exuid ); int ente = exuid.find( "-0000"); if ( exuid.left(1) == "{" ) exuid = exuid.mid(1); if ( ente > -1 ) exuid = exuid.left( ente-1 ); addr.setExternalUID( exuid ); @@ -248,12 +252,15 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a return true; } bool QtopiaConverter::addresseeToQtopia( const Addressee &addr, PimContact &contact ) { + + + // name contact.setLastName(addr.familyName()); contact.setFirstName(addr.givenName()); contact.setMiddleName(addr.additionalName()); contact.setNameTitle(addr.prefix()); contact.setSuffix(addr.suffix()); diff --git a/kabc/plugins/qtopia/qtopiaconverter.h b/kabc/plugins/qtopia/qtopiaconverter.h index 8f4c698..012a6e2 100644 --- a/kabc/plugins/qtopia/qtopiaconverter.h +++ b/kabc/plugins/qtopia/qtopiaconverter.h @@ -28,12 +28,13 @@ $Id$ #define KABC_QTOPIACONVERTER_H #include <qstring.h> #include "addressee.h" #include <qpe/pim/contact.h> +#include <qpe/quuid.h> class Categories; namespace KABC { class QtopiaConverter diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp index 48a9f22..935a1cf 100644 --- a/kabc/plugins/qtopia/resourceqtopia.cpp +++ b/kabc/plugins/qtopia/resourceqtopia.cpp @@ -49,12 +49,14 @@ $Id$ #include "stdaddressbook.h" #include "qtopiaconverter.h" #include "syncprefwidget.h" #include "resourceqtopia.h" +#include <libkdepim/ksyncprofile.h> +#include <qpe/quuid.h> using namespace KABC; extern "C" { void *init_microkabc_qtopia() { @@ -186,44 +188,66 @@ bool ResourceQtopia::load() return true; } bool ResourceQtopia::save( Ticket *ticket ) { - qDebug("ResourceQtopia::save: %s", fileName().latin1()); - - mDirWatch.stopScan(); - - KABC::AddressBook::Iterator it; - bool res; - - for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { - PimContact c; - KABC::Addressee addressee = (*it); - - res = mConverter->addresseeToQtopia( *it, c ); - if (res == true) - { - mAccess->addContact(c); -// if (res == false) -// qDebug("Unable to append Contact %s", c.fullName().latin1()); + qDebug("ResourceQtopia::save: %s", fileName().latin1()); + + mDirWatch.stopScan(); + + KABC::AddressBook::Iterator it; + bool res; + + for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { + //KABC::Addressee addressee = (*it); + if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { + QUuid uid( (*it).originalExternalUID() ); + bool ok; + PimContact c = mAccess->contactForId( uid, &ok ); + res = mConverter->addresseeToQtopia( *it, c ); + if (res == true) { + if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) { + mAccess->addContact(c); + KABC::Addressee addressee; + mConverter->qtopiaToAddressee( c, addressee ); + addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); + addressBook()->insertAddressee( addressee ); + + } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { + if ( ok ) + mAccess->removeContact(c); + else + qDebug("Error revoe contact from qtopia "); + } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { + if ( ok ) { + mAccess->updateContact(c); + KABC::Addressee addressee; + mConverter->qtopiaToAddressee( c, addressee ); + addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); + addressBook()->insertAddressee( addressee ); + } + else + qDebug("Error update contact from qtopia "); + + } + + } else { + qDebug("Unable to convert Addressee %s", (*it).formattedName().latin1()); + } + } } - else - { - qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1()); - } - } -// mAccess->addressBookUpdated(); + // mAccess->addressBookUpdated(); - mDirWatch.startScan(); + mDirWatch.startScan(); - delete ticket; - unlock( fileName() ); + delete ticket; + unlock( fileName() ); - return true; + return true; } bool ResourceQtopia::lock( const QString &lockfileName ) { qDebug("ResourceQtopia::lock: %s", fileName().latin1()); |