-rw-r--r-- | kabc/addressee.cpp | 13 | ||||
-rw-r--r-- | kabc/addressee.h | 2 | ||||
-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 | 42 |
6 files changed, 57 insertions, 10 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 3a2dc5f..fda62f1 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp @@ -62,16 +62,17 @@ struct Addressee::AddresseeData : public KShared QString title; QString role; QString organization; QString note; QString productId; QDateTime revision; QString sortString; QString externalUID; + QString originalExternalUID; KURL url; Secrecy secrecy; Picture logo; Picture photo; Sound sound; Agent agent; QString mExternalId; PhoneNumber::List phoneNumbers; @@ -368,16 +369,28 @@ void Addressee::setExternalUID( const QString &id ) mData->empty = false; mData->externalUID = id; } QString Addressee::externalUID() const { return mData->externalUID; } +void Addressee::setOriginalExternalUID( const QString &id ) +{ + if ( id == mData->originalExternalUID ) return; + detach(); + mData->empty = false; + mData->originalExternalUID = id; +} + +QString Addressee::originalExternalUID() const +{ + return mData->originalExternalUID; +} void Addressee::setUid( const QString &id ) { if ( id == mData->uid ) return; detach(); mData->empty = false; mData->uid = id; } diff --git a/kabc/addressee.h b/kabc/addressee.h index 3ba7777..8baa888 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h @@ -109,16 +109,18 @@ class Addressee void computeCsum(const QString &dev); ulong getCsum4List( const QStringList & attList); /** Return, if the address book entry is empty. */ bool isEmpty() const; void setExternalUID( const QString &id ); QString externalUID() const; + void setOriginalExternalUID( const QString &id ); + QString originalExternalUID() const; void mergeContact( const Addressee& ad ); /** Set unique identifier. */ void setUid( const QString &uid ); /** Return unique identifier. */ 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,14 +1,14 @@ 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 LIBS += -L$(QPEDIR)/lib LIBS += -lqpepim 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 @@ -27,16 +27,17 @@ $Id$ //US #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) { } @@ -70,17 +71,20 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a { // name 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 ); //qDebug("QtopiaConverter:set uid %s ",addr.externalUID().latin1() ); @@ -246,16 +250,19 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a addr.insertCategory( cat ); } 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()); contact.setFileAs(); 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 @@ -26,16 +26,17 @@ $Id$ #ifndef KABC_QTOPIACONVERTER_H #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 { public: 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 @@ -47,16 +47,18 @@ $Id$ #include "resourceqtopiaconfig.h" #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() { return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig, SyncPrefWidgetContainer>(); } @@ -192,29 +194,51 @@ 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); - + //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 (res == true) { + if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) { mAccess->addContact(c); -// if (res == false) -// qDebug("Unable to append Contact %s", c.fullName().latin1()); + 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("Unable to convert Addressee %s", addressee.formattedName().latin1()); + qDebug("Error update contact from qtopia "); + + } + + } else { + qDebug("Unable to convert Addressee %s", (*it).formattedName().latin1()); + } } } // mAccess->addressBookUpdated(); mDirWatch.startScan(); delete ticket; |