On Wed, 2014-01-22 at 11:41 +0100, Lukas Zeller wrote:
> So I see no easy way to run the preflight earlier :-(

Perhaps we don't have to. What about adding the NumberOfChanges later
on? That should be SyncML compliant, shouldn't it?

Below is a patch which achieves that. It results in a sync where the
first Sync command of the client has no NumberOfChanges yet. Then in the
second message, the Sync command gets continued, but this time with a
NumberOfChanges value.

That's good enough for my purposes. If the sync is so short that all
items fit into one message, there's only a short period of time without
information about the total number of changes, which is okay.

diff --git a/src/sysync/synccommand.cpp b/src/sysync/synccommand.cpp
index 3b27d63..c37e9d3 100755
--- a/src/sysync/synccommand.cpp
+++ b/src/sysync/synccommand.cpp
@@ -742,7 +742,8 @@ TSyncCommand::TSyncCommand(
   fSyncElementP->meta=NULL; // %%% no search grammar for now
   // add number of changes for SyncML 1.1 if remote supports it
   fSyncElementP->noc=NULL; // default to none
-  if (aSessionP->fRemoteWantsNOC) {
+  fRemoteWantsNOC=aSessionP->fRemoteWantsNOC;
+  if (fRemoteWantsNOC) {
     sInt32 noc = fLocalDataStoreP->getNumberOfChanges();
     if (noc>=0) {
       // we have a valid NOC value, add it
@@ -954,6 +955,17 @@ bool TSyncCommand::generateOpen(void)
   // issue command Start <Sync> with SyncML toolkit
   fPrepared=false; // force re-preparing in all cases (as this might be 
continuing a command)
   PrepareIssue(&fSyncElementP->cmdID,&fSyncElementP->flags);
+
+  // (re-)check NumberOfChanges, because in a SyncML client that number might 
not
+  // have been available right away when constructing the TSyncCommand.
+  if (!fSyncElementP->noc &&
+      fRemoteWantsNOC) {
+    sInt32 noc = fLocalDataStoreP->getNumberOfChanges();
+    if (noc>=0) {
+      fSyncElementP->noc=newPCDataLong(noc);
+    }
+  }
+
   if (!fEvalMode) {
     #ifdef SYDEBUG
     if (fSessionP->fXMLtranslate && fSessionP->fOutgoingXMLInstance)
diff --git a/src/sysync/synccommand.h b/src/sysync/synccommand.h
index 8d9e41d..dc12877 100755
--- a/src/sysync/synccommand.h
+++ b/src/sysync/synccommand.h
@@ -365,6 +365,7 @@ private:
   // involved datastores and mode
   TLocalEngineDS *fLocalDataStoreP;
   TRemoteDataStore *fRemoteDataStoreP;
+  bool fRemoteWantsNOC;
 }; // TSyncCommand
 
 

-- 
Best Regards, Patrick Ohly

The content of this message is my personal opinion only and although
I am an employee of Intel, the statements I make here in no way
represent Intel's position on the issue, nor am I authorized to speak
on behalf of Intel on this matter.



_______________________________________________
os-libsynthesis mailing list
os-libsynthesis@synthesis.ch
http://lists.synthesis.ch/mailman/listinfo/os-libsynthesis

Reply via email to