summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2011-10-20 15:18:48 +0200
committerPatrick Ohly <patrick.ohly@intel.com>2011-10-20 15:18:48 +0200
commitfbe71f0ef7f6c12f2417dc29258318730d055f26 (patch)
tree64edd1d32db1e7b4bd6d4e2eb81223c8567dbd41
parenta85bdee7c881096f15162b2e6aaafb6282e21b86 (diff)
engine: allow StartDataRead/beginSync to start early and late, as needed (BMC #22881)
The unconditional change of calling StartDataRead (aka beginSync) early enough so that ActiveSync can force a slow sync had negative consequences, because now it was called before the peer was contacted and credentials were accepted: - broke the "sync started successfully" logic, resulting in notifications for syncs which were supposed to be retried silently (showed up in TestSessionAPIsDummy.testAutoSyncNetworkFailure) - database dumps were done even if not needed because sync never starts Now all backends are called as before unless they explicitly ask for the early call. The ActiveSync backend does that. The downsides of that approach do not matter much because syncing will start okay and dumping of data is typically disable on that side of a local sync.
-rw-r--r--src/backends/activesync/ActiveSyncSource.h40
-rw-r--r--src/syncevo/SyncSource.cpp8
-rw-r--r--src/syncevo/SyncSource.h20
3 files changed, 45 insertions, 23 deletions
diff --git a/src/backends/activesync/ActiveSyncSource.h b/src/backends/activesync/ActiveSyncSource.h
index 52509045..ea262f81 100644
--- a/src/backends/activesync/ActiveSyncSource.h
+++ b/src/backends/activesync/ActiveSyncSource.h
@@ -171,6 +171,26 @@ class ActiveSyncSource :
virtual EasItemType getEasType() const = 0;
protected:
+
+ virtual void getSynthesisInfo(SynthesisInfo &info,
+ XMLConfigFragments &fragments)
+ {
+ TestingSyncSource::getSynthesisInfo(info, fragments);
+
+ /**
+ * no ActiveSync specific rules yet, use condensed format as
+ * if we were storing locally, with all extensions enabled
+ */
+ info.m_backendRule = "LOCALSTORAGE";
+
+ /**
+ * access to data must be done early so that a slow sync can be
+ * enforced when the ActiveSync sync key turns out to be
+ * invalid
+ */
+ info.m_earlyStartDataRead = true;
+ }
+
EasSyncHandler *getHandler() { return m_handler.get(); }
std::string getFolder() { return m_folder; }
std::string getStartSyncKey() { return m_startSyncKey; }
@@ -225,26 +245,6 @@ class ActiveSyncContactSource : public ActiveSyncSource
virtual std::string getMimeVersion() const { return "3.0"; }
EasItemType getEasType() const { return EAS_ITEM_CONTACT; }
-
-#if 0 // currently disabled, and thus using the same conversion as the Evolution backend
- void getSynthesisInfo(SynthesisInfo &info,
- XMLConfigFragments &fragments)
- {
- TrackingSyncSource::getSynthesisInfo(info, fragments);
-
- /** enable the ActiveSync X- extensions in the Synthesis<->backend conversion */
- info.m_backendRule = "ACTIVESYNC";
-
- /*
- * Disable the default VCARD_BEFOREWRITE_SCRIPT_EVOLUTION.
- * If any KDE-specific transformations via such a script
- * are needed, it can be named here and then defined by appending
- * to the fragments.
- */
- info.m_beforeWriteScript = ""; // "$VCARD_BEFOREWRITE_SCRIPT_KDE;";
- // fragments.m_datatypes["VCARD_BEFOREWRITE_SCRIPT_KDE"] = "<macro name=\"VCARD_BEFOREWRITE_SCRIPT_KDE\"><![DATA[ ... ]]></macro>";
- }
-#endif
};
/**
diff --git a/src/syncevo/SyncSource.cpp b/src/syncevo/SyncSource.cpp
index de3fd244..e5b63433 100644
--- a/src/syncevo/SyncSource.cpp
+++ b/src/syncevo/SyncSource.cpp
@@ -96,8 +96,12 @@ void SyncSourceBase::getDatastoreXML(string &xml, XMLConfigFragments &fragments)
getSynthesisInfo(info, fragments);
xmlstream <<
- " <plugin_module>SyncEvolution</plugin_module>\n"
- " <plugin_earlystartdataread>yes</plugin_earlystartdataread>\n"
+ " <plugin_module>SyncEvolution</plugin_module>\n";
+ if (info.m_earlyStartDataRead) {
+ xmlstream <<
+ " <plugin_earlystartdataread>yes</plugin_earlystartdataread>\n";
+ }
+ xmlstream <<
" <plugin_datastoreadmin>" <<
(serverModeEnabled() ? "yes" : "no") <<
"</plugin_datastoreadmin>\n"
diff --git a/src/syncevo/SyncSource.h b/src/syncevo/SyncSource.h
index e63bedeb..9b510360 100644
--- a/src/syncevo/SyncSource.h
+++ b/src/syncevo/SyncSource.h
@@ -1022,6 +1022,15 @@ class SyncSourceBase : public Logger {
* vCard 3.0 strings) from the engine.
*/
std::string m_datastoreOptions;
+
+ /**
+ * If true, then the StartDataRead call (aka SyncSourceSession::beginSync)
+ * is invoked before the first message exchange with the peer. Otherwise
+ * it is invoked only if the peer could be reached and accepts the credentials.
+ *
+ * See SyncSourceSession::beginSync for further comments.
+ */
+ Bool m_earlyStartDataRead;
};
/**
@@ -1322,11 +1331,20 @@ class SyncSourceSession : virtual public SyncSourceBase {
/**
* called before Synthesis engine starts to ask for changes and item data
*
- * May throw a STATUS_SLOW_SYNC_508 StatusException if an
+ * If SynthesisInfo::m_earlyStartDataRead is true, then this call is
+ * invoked before the first message exchange with a peer and it
+ * may throw a STATUS_SLOW_SYNC_508 StatusException if an
* incremental sync is not possible. In that case, preparations
* for a slow sync must have completed successfully inside the
* beginSync() call. It is not going to get called again.
*
+ * If SynthesisInfo::m_earlyStartDataRead is false (the default),
+ * then this is called only if the peer was reachable and accepted
+ * the credentials. This mode of operation is preferred if a fallback
+ * to slow sync is not needed, because it allows deferring expensive
+ * operations until really needed. For example, the engine does
+ * database dumps at the time when StartDataRead is called.
+ *
* See StartDataRead for details.
*
* @param lastToken identifies the last completed sync