Hi,
this patch to the activesync backend of syncevolution fixes BMC#22037.
Please review the attached diff.
commit e0ea886a1b4946a70948d29885d023aee5148a09
Author: Salvatore Iovene <[email protected]>
Date: Mon Aug 1 14:17:13 2011 +0300
ActiveSyncSource.cpp: allow retrieval of items beyond the
single-call window.
eas_sync_handler_get_items has a window (currently set at 100 items),
and a "more_available" value that's returned if there are more items
available than it's able to retrieve in one call. This patch uses this
value and loops the _get_items function as long as there are items.
Thanks,
Salvatore.
--
Salvatore Iovene <[email protected]>
Linux Software Engineer
Intel Open Source Technology Center, Finland
Tel.: +358504804026
diff --git a/syncevolution/ActiveSyncSource.cpp b/syncevolution/ActiveSyncSource.cpp
index 7ea0a13..bcf2872 100644
--- a/syncevolution/ActiveSyncSource.cpp
+++ b/syncevolution/ActiveSyncSource.cpp
@@ -98,43 +98,57 @@ void ActiveSyncSource::beginSync(const std::string &lastToken, const std::string
GErrorCXX gerror;
EASItemsCXX created, updated;
EASIdsCXX deleted;
- gchar *buffer;
- if (!eas_sync_handler_get_items(m_handler,
- m_startSyncKey.c_str(),
- &buffer,
- getEasType(),
- m_folder.c_str(),
- created, updated, deleted,
- 0,
- gerror)) {
- gerror.throwError("reading ActiveSync changes");
- }
+ gboolean moreAvailable = TRUE;
- // TODO: Test that we really get an empty token here for an unexpected slow
- // sync. If not, we'll start an incremental sync here and later the engine
- // will ask us for older, unmodified item content which we won't have.
+ m_currentSyncKey = m_startSyncKey;
+ while (moreAvailable) {
+ gchar *buffer = NULL;
- // populate ID lists and content cache
- BOOST_FOREACH(EasItemInfo *item, created) {
- string luid(item->server_id);
- SE_LOG_DEBUG(this, NULL, "new item %s", luid.c_str());
- addItem(luid, NEW);
- m_ids->setProperty(luid, "1");
- m_items[luid] = item->data;
- }
- BOOST_FOREACH(EasItemInfo *item, updated) {
- string luid(item->server_id);
- SE_LOG_DEBUG(this, NULL, "updated item %s", luid.c_str());
- addItem(luid, UPDATED);
- // m_ids.setProperty(luid, "1"); not necessary, should already exist (TODO: check?!)
- m_items[luid] = item->data;
- }
- BOOST_FOREACH(const char *serverID, deleted) {
- string luid(serverID);
- SE_LOG_DEBUG(this, NULL, "deleted item %s", luid.c_str());
- addItem(luid, DELETED);
- m_ids->removeProperty(luid);
+ // reset stuff in case we're after the first loop
+ created.clear();
+ updated.clear();
+ deleted.clear();
+
+ if (!eas_sync_handler_get_items(m_handler,
+ m_currentSyncKey.c_str(),
+ &buffer,
+ getEasType(),
+ m_folder.c_str(),
+ created, updated, deleted,
+ &moreAvailable,
+ gerror)) {
+ gerror.throwError("reading ActiveSync changes");
+ }
+
+ // TODO: Test that we really get an empty token here for an unexpected slow
+ // sync. If not, we'll start an incremental sync here and later the engine
+ // will ask us for older, unmodified item content which we won't have.
+
+ // populate ID lists and content cache
+ BOOST_FOREACH(EasItemInfo *item, created) {
+ string luid(item->server_id);
+ SE_LOG_DEBUG(this, NULL, "new item %s", luid.c_str());
+ addItem(luid, NEW);
+ m_ids->setProperty(luid, "1");
+ m_items[luid] = item->data;
+ }
+ BOOST_FOREACH(EasItemInfo *item, updated) {
+ string luid(item->server_id);
+ SE_LOG_DEBUG(this, NULL, "updated item %s", luid.c_str());
+ addItem(luid, UPDATED);
+ // m_ids.setProperty(luid, "1"); not necessary, should already exist (TODO: check?!)
+ m_items[luid] = item->data;
+ }
+ BOOST_FOREACH(const char *serverID, deleted) {
+ string luid(serverID);
+ SE_LOG_DEBUG(this, NULL, "deleted item %s", luid.c_str());
+ addItem(luid, DELETED);
+ m_ids->removeProperty(luid);
+ }
+
+ // update key
+ m_currentSyncKey = buffer;
}
// now also generate full list of all current items:
@@ -146,9 +160,6 @@ void ActiveSyncSource::beginSync(const std::string &lastToken, const std::string
SE_LOG_DEBUG(this, NULL, "existing item %s", luid.c_str());
addItem(luid, ANY);
}
-
- // update key
- m_currentSyncKey = buffer;
}
std::string ActiveSyncSource::endSync(bool success)
_______________________________________________
SyncEvolution mailing list
[email protected]
http://lists.syncevolution.org/listinfo/syncevolution