summaryrefslogtreecommitdiffabout
path: root/kabc/plugins/qtopia
authorzautrix <zautrix>2004-09-20 00:12:42 (UTC)
committer zautrix <zautrix>2004-09-20 00:12:42 (UTC)
commitb01b669d88fa195261d29ecf73b1c69e608a5ebc (patch) (unidiff)
treec0e79d45242a764b49470d07a9c95be156c121cc /kabc/plugins/qtopia
parent3da2cfeab2edbe64a17251662e56668fe143f7a3 (diff)
downloadkdepimpi-b01b669d88fa195261d29ecf73b1c69e608a5ebc.zip
kdepimpi-b01b669d88fa195261d29ecf73b1c69e608a5ebc.tar.gz
kdepimpi-b01b669d88fa195261d29ecf73b1c69e608a5ebc.tar.bz2
more AB sync
Diffstat (limited to 'kabc/plugins/qtopia') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/qtopia/qtopiaconverter.cpp2
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.cpp79
2 files changed, 70 insertions, 11 deletions
diff --git a/kabc/plugins/qtopia/qtopiaconverter.cpp b/kabc/plugins/qtopia/qtopiaconverter.cpp
index de45e63..430c7b3 100644
--- a/kabc/plugins/qtopia/qtopiaconverter.cpp
+++ b/kabc/plugins/qtopia/qtopiaconverter.cpp
@@ -86,7 +86,7 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a
86 if ( ente > -1 ) 86 if ( ente > -1 )
87 exuid = exuid.left( ente-1 ); 87 exuid = exuid.left( ente-1 );
88 addr.setExternalUID( exuid ); 88 addr.setExternalUID( exuid );
89 //qDebug("QtopiaConverter:set uid %s ",addr.externalUID().latin1() ); 89 qDebug("QtopiaConverter:set %s uid %s ",addr.originalExternalUID().latin1(),addr.externalUID().latin1() );
90 90
91 // email 91 // email
92 QStringList emails = contact.emailList(); 92 QStringList emails = contact.emailList();
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp
index 935a1cf..1f90fcb 100644
--- a/kabc/plugins/qtopia/resourceqtopia.cpp
+++ b/kabc/plugins/qtopia/resourceqtopia.cpp
@@ -197,34 +197,89 @@ bool ResourceQtopia::save( Ticket *ticket )
197 197
198 KABC::AddressBook::Iterator it; 198 KABC::AddressBook::Iterator it;
199 bool res; 199 bool res;
200 200 KABC::Addressee::List changedAddressees;
201 QStringList addedUID;
201 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { 202 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) {
202 //KABC::Addressee addressee = (*it); 203 //KABC::Addressee addressee = (*it);
204 // qDebug("AAAfor uid %s ", (*it).originalExternalUID().latin1() );
203 if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { 205 if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
204 QUuid uid( (*it).originalExternalUID() ); 206 QUuid uid( (*it).originalExternalUID() );
205 bool ok; 207 bool ok;
206 PimContact c = mAccess->contactForId( uid, &ok ); 208 PimContact c = mAccess->contactForId( uid, &ok );
209 qDebug("ResourceQtopia::save:Found %d for uid %s ", ok,(*it).originalExternalUID().latin1() );
207 res = mConverter->addresseeToQtopia( *it, c ); 210 res = mConverter->addresseeToQtopia( *it, c );
208 if (res == true) { 211 if (res == true) {
209 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) { 212 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) {
210 mAccess->addContact(c); 213 qDebug("skipping adding of contact ");
211 KABC::Addressee addressee; 214 continue;
212 mConverter->qtopiaToAddressee( c, addressee ); 215 PimContact e;
213 addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 216 AddressBookAccess Access2;
214 addressBook()->insertAddressee( addressee ); 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 {
224 contact = itt.current();
225 QString exuid = contact->uid().toString();
226 Ouid =exuid;
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 }
247 else
248 qDebug("ADD uid detected ");
249
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
215 266
216 } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { 267 } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
268 qDebug("Remove contact ");
217 if ( ok ) 269 if ( ok )
218 mAccess->removeContact(c); 270 mAccess->removeContact(c);
219 else 271 else
220 qDebug("Error revoe contact from qtopia "); 272 qDebug("Error remove contact from qtopia ");
221 } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { 273 } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
222 if ( ok ) { 274 if ( ok ) {
275 qDebug("Update contact ");
223 mAccess->updateContact(c); 276 mAccess->updateContact(c);
277 PimContact g = mAccess->contactForId( c.uid(), &ok );
224 KABC::Addressee addressee; 278 KABC::Addressee addressee;
225 mConverter->qtopiaToAddressee( c, addressee ); 279 mConverter->qtopiaToAddressee( g, addressee );
280 addressee.setUid((*it).uid() );
226 addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); 281 addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM );
227 addressBook()->insertAddressee( addressee ); 282 changedAddressees.append( addressee );
228 } 283 }
229 else 284 else
230 qDebug("Error update contact from qtopia "); 285 qDebug("Error update contact from qtopia ");
@@ -237,7 +292,11 @@ bool ResourceQtopia::save( Ticket *ticket )
237 } 292 }
238 } 293 }
239 294
240 // mAccess->addressBookUpdated(); 295 KABC::Addressee::List::Iterator it2;
296 for ( it2 = changedAddressees.begin(); it2 != changedAddressees.end(); ++it2 )
297 addressBook()->insertAddressee((*it2));
298
299
241 300
242 mDirWatch.startScan(); 301 mDirWatch.startScan();
243 302