parameter-framework: Improvements & corrections 2

BZ: 9026

1. auto sync off now causes a global forward resynchronization
2. Added version info
3. Libxml2 cleanup correclty scheduled for process end
4. Changed criterion rule id / name association array to const
5. Nesting counter used for logs now mutable

Change-Id: I1f86ee9a56a501ded97706a1d6b877b80950a021
Orig-Change-Id: I5a852736f3c5dd592795a2a70eef42ed9d4695b7
Signed-off-by: Patrick Benavoli <patrickx.benavoli@intel.com>
Reviewed-on: http://android.intel.com:8080/20206
Reviewed-by: Barthes, FabienX <fabienx.barthes@intel.com>
Tested-by: Barthes, FabienX <fabienx.barthes@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
diff --git a/parameter/ParameterMgr.cpp b/parameter/ParameterMgr.cpp
index 87f6662..a8335c8 100644
--- a/parameter/ParameterMgr.cpp
+++ b/parameter/ParameterMgr.cpp
@@ -101,9 +101,11 @@
 
 
 // Remote command parser array
-const CParameterMgr::SRemoteCommandParserItem CParameterMgr::gaRemoteCommandParserItems[] = {
+const CParameterMgr::SRemoteCommandParserItem CParameterMgr::gastRemoteCommandParserItems[] = {
     /// Help
     { "help", &CParameterMgr::helpCommandProcess, 0, "", "Show commands description and usage" },
+    /// Version
+    { "version", &CParameterMgr::versionCommandProcess, 0, "", "Show version" },
     /// Status
     { "status", &CParameterMgr::statusCommandProcess, 0, "", "Show current status" },
     /// Tuning Mode
@@ -139,7 +141,7 @@
     { "restoreConfiguration", &CParameterMgr::restoreConfigurationCommmandProcess, 2, "<domain> <configuration>", "Restore current settings from configuration" },
     /// Elements/Parameters
     { "listElements", &CParameterMgr::listElementsCommmandProcess, 1, "<elem path>|/", "List elements under element at given path or root" },
-    { "listParameters", &CParameterMgr::listParametersCommmandProcess, 1, "<elem path>|/", "Recursively list elements under element at given path or root" },
+    { "listParameters", &CParameterMgr::listParametersCommmandProcess, 1, "<elem path>|/", "List parameters under element at given path or root" },
     { "dumpElement", &CParameterMgr::dumpElementCommmandProcess, 1, "<elem path>", "Dump structure and content of element at given path" },
     { "getElementSize", &CParameterMgr::getElementSizeCommmandProcess, 1, "<elem path>", "Show size of element at given path" },
     { "showProperties", &CParameterMgr::showPropertiesCommmandProcess, 1, "<elem path>", "Show properties of element at given path" },
@@ -160,7 +162,7 @@
     { "importSettings", &CParameterMgr::importSettingsCommmandProcess, 1, "<file path>", "Import settings from binary file" }
 };
 // Remote command parsers array Size
-const uint32_t CParameterMgr::guiNbRemoteCommandParserItems = sizeof(gaRemoteCommandParserItems) / sizeof(gaRemoteCommandParserItems[0]);
+const uint32_t CParameterMgr::guiNbRemoteCommandParserItems = sizeof(gastRemoteCommandParserItems) / sizeof(gastRemoteCommandParserItems[0]);
 
 CParameterMgr::CParameterMgr(const string& strParameterFrameworkConfigurationFolderPath, const string& strSystemClassName) :
     _bTuningModeIsOn(false),
@@ -237,12 +239,12 @@
 
 void CParameterMgr::nestLog() const
 {
-    ((uint32_t&)_uiLogDepth)++;
+    _uiLogDepth++;
 }
 
 void CParameterMgr::unnestLog() const
 {
-    ((uint32_t&)_uiLogDepth)--;
+    _uiLogDepth--;
 }
 
 bool CParameterMgr::load(string& strError)
@@ -582,7 +584,7 @@
 
     for (uiRemoteCommandParserItem = 0; uiRemoteCommandParserItem < guiNbRemoteCommandParserItems; uiRemoteCommandParserItem++) {
 
-        const SRemoteCommandParserItem* pRemoteCommandParserItem = &gaRemoteCommandParserItems[uiRemoteCommandParserItem];
+        const SRemoteCommandParserItem* pRemoteCommandParserItem = &gastRemoteCommandParserItems[uiRemoteCommandParserItem];
 
         if (string(pRemoteCommandParserItem->_pcCommandName) == remoteCommand.getCommand()) {
 
@@ -623,7 +625,7 @@
 
     for (uiRemoteCommandParserItem = 0; uiRemoteCommandParserItem < guiNbRemoteCommandParserItems; uiRemoteCommandParserItem++) {
 
-        const SRemoteCommandParserItem* pRemoteCommandParserItem = &gaRemoteCommandParserItems[uiRemoteCommandParserItem];
+        const SRemoteCommandParserItem* pRemoteCommandParserItem = &gastRemoteCommandParserItems[uiRemoteCommandParserItem];
 
         uint32_t uiRemoteCommandUsageLength = pRemoteCommandParserItem->usage().length();
 
@@ -647,7 +649,7 @@
 
     for (uiRemoteCommandParserItem = 0; uiRemoteCommandParserItem < guiNbRemoteCommandParserItems; uiRemoteCommandParserItem++) {
 
-        const SRemoteCommandParserItem* pRemoteCommandParserItem = &gaRemoteCommandParserItems[uiRemoteCommandParserItem];
+        const SRemoteCommandParserItem* pRemoteCommandParserItem = &gastRemoteCommandParserItems[uiRemoteCommandParserItem];
 
         string strUsage = pRemoteCommandParserItem->usage();
 
@@ -667,6 +669,22 @@
     return ESucceeded;
 }
 
+/// Version
+CParameterMgr::CommandStatus CParameterMgr::versionCommandProcess(const IRemoteCommand& remoteCommand, string& strResult)
+{
+    (void)remoteCommand;
+
+    // Show versions
+    // Major
+    strResult = toString(guiEditionMajor) + ".";
+    // Minor
+    strResult += toString(guiEditionMinor) + ".";
+    // Revision
+    strResult += toString(guiRevision);
+
+    return ESucceeded;
+}
+
 /// Status
 CParameterMgr::CommandStatus CParameterMgr::statusCommandProcess(const IRemoteCommand& remoteCommand, string& strResult)
 {
@@ -1327,9 +1345,8 @@
     // Warn domains about turning auto sync back on
     if (bAutoSyncOn && !_bAutoSyncOn) {
 
-        // Ensure application of currently selected configurations
-        // Force-apply configurations
-        if (!getConfigurableDomains()->apply(_pMainParameterBlackboard, true, strError)) {
+        // Do the synchronization at system class level (could be optimized by keeping track of all modified parameters)
+        if (!sync(strError)) {
 
             return false;
         }
diff --git a/parameter/ParameterMgr.h b/parameter/ParameterMgr.h
index 003a643..74440f8 100644
--- a/parameter/ParameterMgr.h
+++ b/parameter/ParameterMgr.h
@@ -40,6 +40,7 @@
 #include <map>
 #include <vector>
 
+
 class CElementLibrarySet;
 class CSubsystemLibrary;
 class CSystemClass;
@@ -90,6 +91,11 @@
             return string(_pcCommandName) + " " + _pcHelp;
         }
     };
+
+    // Version
+    static const uint32_t guiEditionMajor = 0x0;
+    static const uint32_t guiEditionMinor = 0x1;
+    static const uint32_t guiRevision = 0x1;
 public:
     // Logger interface
     class ILogger
@@ -179,6 +185,8 @@
     ////////////////:: Remote command parsers
     /// Help
     CommandStatus helpCommandProcess(const IRemoteCommand& remoteCommand, string& strResult);
+    /// Version
+    CommandStatus versionCommandProcess(const IRemoteCommand& remoteCommand, string& strResult);
     /// Status
     CommandStatus statusCommandProcess(const IRemoteCommand& remoteCommand, string& strResult);
     /// Tuning Mode
@@ -313,7 +321,7 @@
     IRemoteProcessorServerInterface* _pRemoteProcessorServer;
 
     // Parser description array
-    static const SRemoteCommandParserItem gaRemoteCommandParserItems[];
+    static const SRemoteCommandParserItem gastRemoteCommandParserItems[];
 
     // Parser description array size
     static const uint32_t guiNbRemoteCommandParserItems;
@@ -326,6 +334,6 @@
 
     // Logging
     ILogger* _pLogger;
-    uint32_t _uiLogDepth;
+    mutable uint32_t _uiLogDepth;
 };
 
diff --git a/parameter/SelectionCriterionRule.cpp b/parameter/SelectionCriterionRule.cpp
index e43c9e8..eec88be 100644
--- a/parameter/SelectionCriterionRule.cpp
+++ b/parameter/SelectionCriterionRule.cpp
@@ -37,7 +37,7 @@
 
 #define base CRule
 
-CSelectionCriterionRule::SMatchingRuleDescription CSelectionCriterionRule::_astMatchesWhen[CSelectionCriterionRule::ENbMatchesWhen] = {
+const CSelectionCriterionRule::SMatchingRuleDescription CSelectionCriterionRule::_astMatchesWhen[CSelectionCriterionRule::ENbMatchesWhen] = {
     { "Is", false },
     { "IsNot", false },
     { "Includes", true },
diff --git a/parameter/SelectionCriterionRule.h b/parameter/SelectionCriterionRule.h
index 528e584..51f22e7 100644
--- a/parameter/SelectionCriterionRule.h
+++ b/parameter/SelectionCriterionRule.h
@@ -80,6 +80,6 @@
     int32_t _iMatchValue;
 
     // Used for XML MatchesWhen attribute parsing
-    static SMatchingRuleDescription _astMatchesWhen[ENbMatchesWhen];
+    static const SMatchingRuleDescription _astMatchesWhen[ENbMatchesWhen];
 };
 
diff --git a/xmlserializer/XmlSerializer.cpp b/xmlserializer/XmlSerializer.cpp
index 73ae90c..0c4f5ff 100644
--- a/xmlserializer/XmlSerializer.cpp
+++ b/xmlserializer/XmlSerializer.cpp
@@ -38,7 +38,7 @@
 CXmlSerializer::CXmlSerializer(const string& strXmlInstanceFile, const string& strXmlSchemaFile, const string& strRootElementType, CXmlSerializingContext& serializingContext) :
     _strXmlInstanceFile(strXmlInstanceFile), _strXmlSchemaFile(strXmlSchemaFile), _strRootElementType(strRootElementType), _serializingContext(serializingContext), _pDoc(NULL), _pRootNode(NULL)
 {
-    if (_bLibXml2CleanupScheduled) {
+    if (!_bLibXml2CleanupScheduled) {
 
         // Schedule cleanup
         atexit(xmlCleanupParser);