diff options
author | Patrick Ohly <patrick.ohly@intel.com> | 2011-10-12 10:11:04 +0200 |
---|---|---|
committer | Patrick Ohly <patrick.ohly@intel.com> | 2011-10-17 13:17:58 +0200 |
commit | b1b18eadb58295a5c010046283e91bde8bcca5dc (patch) | |
tree | 1017e538e93ab714c2051ae91625e35adc5862da | |
parent | 1421769db83968deaa5430d95e0adb3ca6b79950 (diff) |
ActiveSync: force slow sync when sync key is invalid (BMC #22881)bmc22881
The ActiveSync backend now detects the daemon's "Sync error: Invalid
synchronization key" and falls back to a slow sync. This is only done
if the sync key was already invalid when beginSync()
started. Otherwise something fishy must be going on and it seems
prudent to rather abort the sync with an error.
It would be nice if this special error could be detected without
having to resort to a string comparison, but this is not currently
supported by libeasclient because error codes are not yet part of the
API (BMC #23618).
-rw-r--r-- | src/backends/activesync/ActiveSyncSource.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/backends/activesync/ActiveSyncSource.cpp b/src/backends/activesync/ActiveSyncSource.cpp index c3108736..e0ef2633 100644 --- a/src/backends/activesync/ActiveSyncSource.cpp +++ b/src/backends/activesync/ActiveSyncSource.cpp @@ -29,6 +29,7 @@ #include <stdlib.h> #include <errno.h> +/* #include <eas-connection-errors.h> */ #include <syncevo/declarations.h> SE_BEGIN_CXX @@ -92,7 +93,10 @@ void ActiveSyncSource::beginSync(const std::string &lastToken, const std::string m_currentSyncKey = m_startSyncKey; - while (moreAvailable) { + bool slowSync = false; + for (bool firstIteration = true; + moreAvailable; + firstIteration = false) { gchar *buffer = NULL; EASItemsCXX created, updated; EASIdsCXX deleted; @@ -105,6 +109,20 @@ void ActiveSyncSource::beginSync(const std::string &lastToken, const std::string created, updated, deleted, &moreAvailable, gerror)) { + if (gerror.m_gerror && + /* + gerror.m_gerror->domain == EAS_TYPE_CONNECTION_ERROR && + gerror.m_gerror->code == EAS_CONNECTION_SYNC_ERROR_INVALIDSYNCKEY && */ + gerror.m_gerror->message && + !strcmp(gerror.m_gerror->message, "Sync error: Invalid synchronization key") && + firstIteration) { + // fall back to slow sync + slowSync = true; + m_currentSyncKey = ""; + m_ids->clear(); + continue; + } + gerror.throwError("reading ActiveSync changes"); } if (!buffer) { @@ -174,6 +192,13 @@ void ActiveSyncSource::beginSync(const std::string &lastToken, const std::string SE_LOG_DEBUG(this, NULL, "existing item %s", luid.c_str()); addItem(luid, ANY); } + + if (slowSync) { + // tell engine that we need a slow sync + SE_THROW_EXCEPTION_STATUS(StatusException, + "ActiveSync error: Invalid synchronization key", + STATUS_SLOW_SYNC_508); + } } std::string ActiveSyncSource::endSync(bool success) |