Diffstat (limited to 'kabc/plugins/qtopia/resourceqtopia.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | kabc/plugins/qtopia/resourceqtopia.cpp | 42 |
1 files changed, 33 insertions, 9 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" |
@@ -197,19 +199,41 @@ bool ResourceQtopia::save( Ticket *ticket ) | |||
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() ); | |
205 | bool ok; | ||
206 | PimContact c = mAccess->contactForId( uid, &ok ); | ||
203 | res = mConverter->addresseeToQtopia( *it, c ); | 207 | res = mConverter->addresseeToQtopia( *it, c ); |
204 | if (res == true) | 208 | if (res == true) { |
205 | { | 209 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) { |
206 | mAccess->addContact(c); | 210 | mAccess->addContact(c); |
207 | // if (res == false) | 211 | KABC::Addressee addressee; |
208 | // qDebug("Unable to append Contact %s", c.fullName().latin1()); | 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 ); | ||
209 | } | 228 | } |
210 | else | 229 | else |
211 | { | 230 | qDebug("Error update contact from qtopia "); |
212 | qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1()); | 231 | |
232 | } | ||
233 | |||
234 | } else { | ||
235 | qDebug("Unable to convert Addressee %s", (*it).formattedName().latin1()); | ||
236 | } | ||
213 | } | 237 | } |
214 | } | 238 | } |
215 | 239 | ||