author | zautrix <zautrix> | 2004-09-21 07:09:09 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-21 07:09:09 (UTC) |
commit | 1cf4cc6e7bf25ee309852c7c97155de86917289f (patch) (unidiff) | |
tree | 721dd83559c3c7635d132b8a95cd6fdc4cdcc351 /kabc/plugins | |
parent | 434ddaa08e0a650422ef271332a1d11879028095 (diff) | |
download | kdepimpi-1cf4cc6e7bf25ee309852c7c97155de86917289f.zip kdepimpi-1cf4cc6e7bf25ee309852c7c97155de86917289f.tar.gz kdepimpi-1cf4cc6e7bf25ee309852c7c97155de86917289f.tar.bz2 |
qtopia format changes
-rw-r--r-- | kabc/plugins/qtopia/resourceqtopia.cpp | 105 |
1 files changed, 11 insertions, 94 deletions
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp index 1f90fcb..f9cabcb 100644 --- a/kabc/plugins/qtopia/resourceqtopia.cpp +++ b/kabc/plugins/qtopia/resourceqtopia.cpp | |||
@@ -52,8 +52,6 @@ $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> | ||
57 | 55 | ||
58 | using namespace KABC; | 56 | using namespace KABC; |
59 | extern "C" | 57 | extern "C" |
@@ -197,106 +195,25 @@ bool ResourceQtopia::save( Ticket *ticket ) | |||
197 | 195 | ||
198 | KABC::AddressBook::Iterator it; | 196 | KABC::AddressBook::Iterator it; |
199 | bool res; | 197 | bool res; |
200 | KABC::Addressee::List changedAddressees; | 198 | |
201 | QStringList addedUID; | ||
202 | for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { | 199 | for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { |
203 | //KABC::Addressee addressee = (*it); | 200 | PimContact c; |
204 | // qDebug("AAAfor uid %s ", (*it).originalExternalUID().latin1() ); | 201 | KABC::Addressee addressee = (*it); |
205 | if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | 202 | |
206 | QUuid uid( (*it).originalExternalUID() ); | ||
207 | bool ok; | ||
208 | PimContact c = mAccess->contactForId( uid, &ok ); | ||
209 | qDebug("ResourceQtopia::save:Found %d for uid %s ", ok,(*it).originalExternalUID().latin1() ); | ||
210 | res = mConverter->addresseeToQtopia( *it, c ); | 203 | res = mConverter->addresseeToQtopia( *it, c ); |
211 | if (res == true) { | 204 | if (res == true) |
212 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) { | ||
213 | qDebug("skipping adding of contact "); | ||
214 | continue; | ||
215 | PimContact e; | ||
216 | AddressBookAccess Access2; | ||
217 | Access2.addContact(e); | ||
218 | const PimContact* contact; | ||
219 | bool res; | ||
220 | QString uid2, Ouid; | ||
221 | AddressBookIterator itt(Access2); | ||
222 | for (contact=itt.toFirst(); itt.current(); ++itt) | ||
223 | { | 205 | { |
224 | contact = itt.current(); | 206 | mAccess->addContact(c); |
225 | QString exuid = contact->uid().toString(); | 207 | // if (res == false) |
226 | Ouid =exuid; | 208 | // qDebug("Unable to append Contact %s", c.fullName().latin1()); |
227 | int ente = exuid.find( "-0000"); | ||
228 | if ( exuid.left(1) == "{" ) | ||
229 | exuid = exuid.mid(1); | ||
230 | if ( ente > -1 ) | ||
231 | exuid = exuid.left( ente-1 ); | ||
232 | uid2 = exuid; | ||
233 | qDebug("trying find uid "); | ||
234 | if ( !addressBook()->containsExternalUid( uid2 ) ) { | ||
235 | qDebug("ab not contains "); | ||
236 | if ( !addedUID.contains( uid2 )) { | ||
237 | qDebug("list not contains "); | ||
238 | break; | ||
239 | } | ||
240 | } | ||
241 | |||
242 | } | ||
243 | if ( !itt.current()) { | ||
244 | qDebug("ERROR uid "); | ||
245 | continue; | ||
246 | } | 209 | } |
247 | else | 210 | else |
248 | qDebug("ADD uid detected "); | 211 | { |
249 | 212 | qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1()); | |
250 | |||
251 | QUuid uid3( Ouid); | ||
252 | PimContact d = Access2.contactForId( uid3, &ok ); | ||
253 | if ( ! ok ) { | ||
254 | qDebug("ADD: Error getting new uid "); | ||
255 | } else { | ||
256 | qDebug("NEW UID found "); | ||
257 | PimContact g = mAccess->contactForId( c.uid(), &ok ); | ||
258 | KABC::Addressee addressee; | ||
259 | mConverter->qtopiaToAddressee( g, addressee ); | ||
260 | addressee.setUid((*it).uid() ); | ||
261 | addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | ||
262 | changedAddressees.append( addressee ); | ||
263 | addedUID.append( uid2 ); | ||
264 | } | ||
265 | |||
266 | |||
267 | } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | ||
268 | qDebug("Remove contact "); | ||
269 | if ( ok ) | ||
270 | mAccess->removeContact(c); | ||
271 | else | ||
272 | qDebug("Error remove contact from qtopia "); | ||
273 | } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | ||
274 | if ( ok ) { | ||
275 | qDebug("Update contact "); | ||
276 | mAccess->updateContact(c); | ||
277 | PimContact g = mAccess->contactForId( c.uid(), &ok ); | ||
278 | KABC::Addressee addressee; | ||
279 | mConverter->qtopiaToAddressee( g, addressee ); | ||
280 | addressee.setUid((*it).uid() ); | ||
281 | addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); | ||
282 | changedAddressees.append( addressee ); | ||
283 | } | ||
284 | else | ||
285 | qDebug("Error update contact from qtopia "); | ||
286 | |||
287 | } | ||
288 | |||
289 | } else { | ||
290 | qDebug("Unable to convert Addressee %s", (*it).formattedName().latin1()); | ||
291 | } | ||
292 | } | 213 | } |
293 | } | 214 | } |
294 | 215 | ||
295 | KABC::Addressee::List::Iterator it2; | 216 | // mAccess->addressBookUpdated(); |
296 | for ( it2 = changedAddressees.begin(); it2 != changedAddressees.end(); ++it2 ) | ||
297 | addressBook()->insertAddressee((*it2)); | ||
298 | |||
299 | |||
300 | 217 | ||
301 | mDirWatch.startScan(); | 218 | mDirWatch.startScan(); |
302 | 219 | ||