summaryrefslogtreecommitdiffabout
path: root/kabc/plugins/qtopia/resourceqtopia.cpp
authorzautrix <zautrix>2004-09-19 20:14:28 (UTC)
committer zautrix <zautrix>2004-09-19 20:14:28 (UTC)
commitafa28a62314117555d6b32291188eedd1a576284 (patch) (side-by-side diff)
treeea97a247de30a7a34480bc395e1996ab99247361 /kabc/plugins/qtopia/resourceqtopia.cpp
parente0d8e062c9d8092e47dcadd88b30614ebff43c0c (diff)
downloadkdepimpi-afa28a62314117555d6b32291188eedd1a576284.zip
kdepimpi-afa28a62314117555d6b32291188eedd1a576284.tar.gz
kdepimpi-afa28a62314117555d6b32291188eedd1a576284.tar.bz2
more AB sync
Diffstat (limited to 'kabc/plugins/qtopia/resourceqtopia.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.cpp78
1 files changed, 51 insertions, 27 deletions
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
@@ -52,6 +52,8 @@ $Id$
#include "syncprefwidget.h"
#include "resourceqtopia.h"
+#include <libkdepim/ksyncprofile.h>
+#include <qpe/quuid.h>
using namespace KABC;
extern "C"
@@ -189,38 +191,60 @@ bool ResourceQtopia::load()
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 )