author | zautrix <zautrix> | 2004-09-19 20:14:28 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-19 20:14:28 (UTC) |
commit | afa28a62314117555d6b32291188eedd1a576284 (patch) (unidiff) | |
tree | ea97a247de30a7a34480bc395e1996ab99247361 /kabc/plugins/qtopia/resourceqtopia.cpp | |
parent | e0d8e062c9d8092e47dcadd88b30614ebff43c0c (diff) | |
download | kdepimpi-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.cpp | 78 |
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$ | |||
52 | #include "syncprefwidget.h" | 52 | #include "syncprefwidget.h" |
53 | 53 | ||
54 | #include "resourceqtopia.h" | 54 | #include "resourceqtopia.h" |
55 | #include <libkdepim/ksyncprofile.h> | ||
56 | #include <qpe/quuid.h> | ||
55 | 57 | ||
56 | using namespace KABC; | 58 | using namespace KABC; |
57 | extern "C" | 59 | extern "C" |
@@ -189,38 +191,60 @@ bool ResourceQtopia::load() | |||
189 | 191 | ||
190 | bool ResourceQtopia::save( Ticket *ticket ) | 192 | bool ResourceQtopia::save( Ticket *ticket ) |
191 | { | 193 | { |
192 | qDebug("ResourceQtopia::save: %s", fileName().latin1()); | 194 | qDebug("ResourceQtopia::save: %s", fileName().latin1()); |
193 | 195 | ||
194 | mDirWatch.stopScan(); | 196 | mDirWatch.stopScan(); |
195 | 197 | ||
196 | KABC::AddressBook::Iterator it; | 198 | KABC::AddressBook::Iterator it; |
197 | bool res; | 199 | bool res; |
198 | 200 | ||
199 | for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { | 201 | for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { |
200 | PimContact c; | 202 | //KABC::Addressee addressee = (*it); |
201 | KABC::Addressee addressee = (*it); | 203 | if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
202 | 204 | QUuid uid( (*it).originalExternalUID() ); | |
203 | res = mConverter->addresseeToQtopia( *it, c ); | 205 | bool ok; |
204 | if (res == true) | 206 | PimContact c = mAccess->contactForId( uid, &ok ); |
205 | { | 207 | res = mConverter->addresseeToQtopia( *it, c ); |
206 | mAccess->addContact(c); | 208 | if (res == true) { |
207 | // if (res == false) | 209 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) { |
208 | // qDebug("Unable to append Contact %s", c.fullName().latin1()); | 210 | mAccess->addContact(c); |
211 | KABC::Addressee addressee; | ||
212 | mConverter->qtopiaToAddressee( c, addressee ); | ||
213 | addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | ||
214 | addressBook()->insertAddressee( addressee ); | ||
215 | |||
216 | } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | ||
217 | if ( ok ) | ||
218 | mAccess->removeContact(c); | ||
219 | else | ||
220 | qDebug("Error revoe contact from qtopia "); | ||
221 | } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | ||
222 | if ( ok ) { | ||
223 | mAccess->updateContact(c); | ||
224 | KABC::Addressee addressee; | ||
225 | mConverter->qtopiaToAddressee( c, addressee ); | ||
226 | addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); | ||
227 | addressBook()->insertAddressee( addressee ); | ||
228 | } | ||
229 | else | ||
230 | qDebug("Error update contact from qtopia "); | ||
231 | |||
232 | } | ||
233 | |||
234 | } else { | ||
235 | qDebug("Unable to convert Addressee %s", (*it).formattedName().latin1()); | ||
236 | } | ||
237 | } | ||
209 | } | 238 | } |
210 | else | ||
211 | { | ||
212 | qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1()); | ||
213 | } | ||
214 | } | ||
215 | 239 | ||
216 | // mAccess->addressBookUpdated(); | 240 | // mAccess->addressBookUpdated(); |
217 | 241 | ||
218 | mDirWatch.startScan(); | 242 | mDirWatch.startScan(); |
219 | 243 | ||
220 | delete ticket; | 244 | delete ticket; |
221 | unlock( fileName() ); | 245 | unlock( fileName() ); |
222 | 246 | ||
223 | return true; | 247 | return true; |
224 | } | 248 | } |
225 | 249 | ||
226 | bool ResourceQtopia::lock( const QString &lockfileName ) | 250 | bool ResourceQtopia::lock( const QString &lockfileName ) |