diff options
-rw-r--r-- | src/EvolutionContactSource.cpp | 27 | ||||
-rw-r--r-- | src/client-test-app.cpp | 2 |
2 files changed, 24 insertions, 5 deletions
diff --git a/src/EvolutionContactSource.cpp b/src/EvolutionContactSource.cpp index f5b78cba..d81d184f 100644 --- a/src/EvolutionContactSource.cpp +++ b/src/EvolutionContactSource.cpp @@ -169,6 +169,7 @@ void EvolutionContactSource::beginSyncThrow(bool needAll, bool deleteLocal) { GError *gerror = NULL; + bool removedSome = false; eptr<EBookQuery> deleteItemsQuery; if (deleteLocal) { @@ -176,7 +177,7 @@ void EvolutionContactSource::beginSyncThrow(bool needAll, } #ifdef ENABLE_MAEMO else { - deleteItemsQuery.set( e_book_query_field_test( E_CONTACT_OSSO_CONTACT_STATE, E_BOOK_QUERY_IS, "DELETED" ), "query" ); + deleteItemsQuery.set( e_book_query_vcard_field_exists("X-OSSO-CONTACT-STATE"), "query" ); } #endif @@ -186,21 +187,39 @@ void EvolutionContactSource::beginSyncThrow(bool needAll, if (!e_book_get_contacts( m_addressbook, deleteItemsQuery, &nextItem, &gerror )) { throwError( "reading items to be deleted", gerror ); } - while (nextItem) { + for (;nextItem; nextItem = nextItem->next) { const char *uid = (const char *)e_contact_get_const(E_CONTACT(nextItem->data), E_CONTACT_UID); +#ifdef ENABLE_MAEMO if (!deleteLocal) { + GList *nextState = (GList *)e_contact_get(E_CONTACT(nextItem->data), + E_CONTACT_OSSO_CONTACT_STATE); + bool deleted = false; + while (nextState) { + if (nextState->data && !strcmp((char *)nextState->data, "DELETED")) { + deleted = true; + } + nextState = nextState->next; + } + if (!deleted) { + continue; + } logItem(uid, "deleting item scheduled for removal", true); + if (needPartial) { + // the observation is that the deleted item is not listed again + // below; apparently only changes made by someone else are recorded + // in the list of changes ?! + m_deletedItems.addItem(uid); + } } +#endif if (!e_book_remove_contact( m_addressbook, uid, &gerror ) ) { throwError( string( "deleting contact " ) + uid, gerror ); } - nextItem = nextItem->next; } } - if (needAll) { eptr<EBookQuery> allItemsQuery( e_book_query_any_field_contains(""), "query" ); GList *nextItem; diff --git a/src/client-test-app.cpp b/src/client-test-app.cpp index 6ad3d3f5..a4c10543 100644 --- a/src/client-test-app.cpp +++ b/src/client-test-app.cpp @@ -91,7 +91,7 @@ private: comma ? comma - config.uniqueProperties : strlen(config.uniqueProperties)); CPPUNIT_ASSERT(offset != item.npos); item.insert(offset, "X-OSSO-CONTACT-STATE:DELETED\n"); - update(createSourceA, item.c_str()); + update(createSourceA, item.c_str(), false); // opening and preparing the source should delete the item std::auto_ptr<SyncSource> source; |