diff options
author | Patrick Benavoli <patrickx.benavoli@intel.com> | 2011-11-29 11:10:27 +0100 |
---|---|---|
committer | David Wagner <david.wagner@intel.com> | 2014-02-10 17:15:01 +0100 |
commit | 0bd50546a8d06a6865d32c695adf8893fa71250a (patch) | |
tree | 966dc5c4c8143df983668db92db26129eafb1e3b /parameter/ConfigurableDomains.cpp | |
parent | e7a903ef0a5ee2b9d51e6f86d32c704b9ff16c21 (diff) | |
download | external_parameter-framework-0bd50546a8d06a6865d32c695adf8893fa71250a.zip external_parameter-framework-0bd50546a8d06a6865d32c695adf8893fa71250a.tar.gz external_parameter-framework-0bd50546a8d06a6865d32c695adf8893fa71250a.tar.bz2 |
PFW: Rule handling from CLI
BZ: 15689
These changes enable handling changing the rules for configuration application
from the command line interface.
It is possible to assign a new rule, to display the existing one or to clear
it.
Restriction: like in XML, root rule must be compound.
Syntax is the following:
- Criterion rule expression:
<criterion> <verb> <object>
- Compound rule expression
(All|Any){<content>}
where <content> is a comma separated list of any kind of rules.
Example:
All{Any{SelectedOutputDevice Includes Headphones, SelectedOutputDevice
Includes Headset}, Any{Mode Is Normal, Mode Is RingTone}}
means the pertaining configuration will be applied when Selected device
includes either Headphones or Headset, while, ate the same time, Mode is
either Normal or RingTone.
Added dumpDomains remote command to show a summary of domains, configurations
as well as their application conditions (tree view).
Removed not anymore necessary guard against deletion of domains or
configurations that contain rules, ad now they're controlled from the CLI.
Change-Id: Iad2c183271b077b8bbc8ac2fc5f37c266004070f
Signed-off-by: Patrick Benavoli <patrickx.benavoli@intel.com>
Reviewed-on: http://android.intel.com:8080/26100
Reviewed-by: De Chivre, RenaudX <renaudx.de.chivre@intel.com>
Tested-by: Barthes, FabienX <fabienx.barthes@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
Diffstat (limited to 'parameter/ConfigurableDomains.cpp')
-rw-r--r-- | parameter/ConfigurableDomains.cpp | 144 |
1 files changed, 87 insertions, 57 deletions
diff --git a/parameter/ConfigurableDomains.cpp b/parameter/ConfigurableDomains.cpp index d021d8c..28611d3 100644 --- a/parameter/ConfigurableDomains.cpp +++ b/parameter/ConfigurableDomains.cpp @@ -139,20 +139,10 @@ bool CConfigurableDomains::createDomain(const string& strName, string& strError) bool CConfigurableDomains::deleteDomain(const string& strName, string& strError) { - CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strName)); + CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strName, strError); if (!pConfigurableDomain) { - strError = "Configurable domain not found"; - - return false; - } - - // Check domain has no rule (prevent accidental loss of data) - if (pConfigurableDomain->hasRules()) { - - strError = "Deletion of domain containing configurations with application rules is not supported to prevent any accitental loss of data.\nPlease consider a direct modification of the XML file."; - return false; } @@ -169,12 +159,10 @@ bool CConfigurableDomains::deleteDomain(const string& strName, string& strError) bool CConfigurableDomains::renameDomain(const string& strName, const string& strNewName, string& strError) { - CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strName)); + CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strName, strError); if (!pConfigurableDomain) { - strError = "Configurable domain not found"; - return false; } @@ -186,12 +174,10 @@ bool CConfigurableDomains::renameDomain(const string& strName, const string& str bool CConfigurableDomains::setSequenceAwareness(const string& strDomain, bool bSequenceAware, string& strError) { - CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strError); if (!pConfigurableDomain) { - strError = "Configurable domain not found"; - return false; } @@ -202,12 +188,10 @@ bool CConfigurableDomains::setSequenceAwareness(const string& strDomain, bool bS bool CConfigurableDomains::getSequenceAwareness(const string& strDomain, bool& bSequenceAware, string& strError) const { - const CConfigurableDomain* pConfigurableDomain = static_cast<const CConfigurableDomain*>(findChild(strDomain)); + const CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strError); if (!pConfigurableDomain) { - strError = "Configurable domain not found"; - return false; } @@ -219,12 +203,10 @@ bool CConfigurableDomains::getSequenceAwareness(const string& strDomain, bool& b /// Configurations bool CConfigurableDomains::listConfigurations(const string& strDomain, string& strResult) const { - const CElement* pConfigurableDomain = findChild(strDomain); + const CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strResult); if (!pConfigurableDomain) { - strResult = "Configurable domain not found"; - return false; } // delegate @@ -236,12 +218,10 @@ bool CConfigurableDomains::listConfigurations(const string& strDomain, string& s bool CConfigurableDomains::createConfiguration(const string& strDomain, const string& strConfiguration, const CParameterBlackboard* pMainBlackboard, string& strError) { // Find domain - CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strError); if (!pConfigurableDomain) { - strError = "Configurable domain " + strDomain + " not found"; - return false; } // Delegate @@ -251,12 +231,10 @@ bool CConfigurableDomains::createConfiguration(const string& strDomain, const st bool CConfigurableDomains::deleteConfiguration(const string& strDomain, const string& strConfiguration, string& strError) { // Find domain - CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strError); if (!pConfigurableDomain) { - strError = "Configurable domain " + strDomain + " not found"; - return false; } // Delegate @@ -266,12 +244,10 @@ bool CConfigurableDomains::deleteConfiguration(const string& strDomain, const st bool CConfigurableDomains::renameConfiguration(const string& strDomain, const string& strConfigurationName, const string& strNewConfigurationName, string& strError) { // Find domain - CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strError); if (!pConfigurableDomain) { - strError = "Configurable domain " + strDomain + " not found"; - return false; } // Delegate @@ -281,12 +257,10 @@ bool CConfigurableDomains::renameConfiguration(const string& strDomain, const st bool CConfigurableDomains::listDomainElements(const string& strDomain, string& strResult) const { // Find domain - const CConfigurableDomain* pConfigurableDomain = static_cast<const CConfigurableDomain*>(findChild(strDomain)); + const CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strResult); if (!pConfigurableDomain) { - strResult = "Configurable domain " + strDomain + " not found"; - return false; } // Delegate @@ -298,12 +272,10 @@ bool CConfigurableDomains::listDomainElements(const string& strDomain, string& s bool CConfigurableDomains::split(const string& strDomain, CConfigurableElement* pConfigurableElement, string& strError) { // Find domain - CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strError); if (!pConfigurableDomain) { - strError = "Configurable domain " + strDomain + " not found"; - return false; } // Delegate @@ -403,15 +375,13 @@ void CConfigurableDomains::gatherAllOwnedConfigurableElements(set<const CConfigu } // Config restore -bool CConfigurableDomains::restoreConfiguration(const string& strDomain, const string& strConfiguration, CParameterBlackboard* pMainBlackboard, bool bAutoSync, string& strError) +bool CConfigurableDomains::restoreConfiguration(const string& strDomain, const string& strConfiguration, CParameterBlackboard* pMainBlackboard, bool bAutoSync, string& strError) const { // Find domain - CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + const CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strError); if (!pConfigurableDomain) { - strError = "Configurable domain " + strDomain + " not found"; - return false; } // Delegate @@ -422,12 +392,10 @@ bool CConfigurableDomains::restoreConfiguration(const string& strDomain, const s bool CConfigurableDomains::saveConfiguration(const string& strDomain, const string& strConfiguration, const CParameterBlackboard* pMainBlackboard, string& strError) { // Find domain - CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strError); if (!pConfigurableDomain) { - strError = "Configurable domain " + strDomain + " not found"; - return false; } // Delegate @@ -437,12 +405,10 @@ bool CConfigurableDomains::saveConfiguration(const string& strDomain, const stri bool CConfigurableDomains::setElementSequence(const string& strDomain, const string& strConfiguration, const vector<string>& astrNewElementSequence, string& strError) { // Find domain - CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strError); if (!pConfigurableDomain) { - strError = "Configurable domain " + strDomain + " not found"; - return false; } @@ -453,18 +419,55 @@ bool CConfigurableDomains::setElementSequence(const string& strDomain, const str bool CConfigurableDomains::getElementSequence(const string& strDomain, const string& strConfiguration, string& strResult) const { // Find domain - const CConfigurableDomain* pConfigurableDomain = static_cast<const CConfigurableDomain*>(findChild(strDomain)); + const CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strResult); if (!pConfigurableDomain) { - strResult = "Configurable domain " + strDomain + " not found"; - return false; } // Delegate to domain return pConfigurableDomain->getElementSequence(strConfiguration, strResult); } +bool CConfigurableDomains::setApplicationRule(const string& strDomain, const string& strConfiguration, const string& strApplicationRule, const CSelectionCriteriaDefinition* pSelectionCriteriaDefinition, string& strError) +{ + CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strError); + + if (!pConfigurableDomain) { + + return false; + } + + // Delegate to domain + return pConfigurableDomain->setApplicationRule(strConfiguration, strApplicationRule, pSelectionCriteriaDefinition, strError); +} + +bool CConfigurableDomains::clearApplicationRule(const string& strDomain, const string& strConfiguration, string& strError) +{ + CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strError); + + if (!pConfigurableDomain) { + + return false; + } + + // Delegate to domain + return pConfigurableDomain->clearApplicationRule(strConfiguration, strError); +} + +bool CConfigurableDomains::getApplicationRule(const string& strDomain, const string& strConfiguration, string& strResult) const +{ + const CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strResult); + + if (!pConfigurableDomain) { + + return false; + } + + // Delegate to domain + return pConfigurableDomain->getApplicationRule(strConfiguration, strResult); +} + // Last applied configurations void CConfigurableDomains::listLastAppliedConfigurations(string& strResult) const { @@ -484,12 +487,10 @@ void CConfigurableDomains::listLastAppliedConfigurations(string& strResult) cons bool CConfigurableDomains::addConfigurableElementToDomain(const string& strDomain, CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard, string& strError) { // Find domain - CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strError); if (!pConfigurableDomain) { - strError = "Configurable domain " + strDomain + " not found"; - return false; } // Delegate @@ -499,12 +500,10 @@ bool CConfigurableDomains::addConfigurableElementToDomain(const string& strDomai bool CConfigurableDomains::removeConfigurableElementFromDomain(const string& strDomain, CConfigurableElement* pConfigurableElement, string& strError) { // Find domain - CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strError); if (!pConfigurableDomain) { - strError = "Configurable domain " + strDomain + " not found"; - return false; } // Delegate @@ -533,3 +532,34 @@ bool CConfigurableDomains::serializeSettings(const string& strBinarySettingsFile return true; } + +// Domain retrieval +CConfigurableDomain* CConfigurableDomains::findConfigurableDomain(const string& strDomain, string& strError) +{ + // Find domain + CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + + if (!pConfigurableDomain) { + + strError = "Configurable domain " + strDomain + " not found"; + + return NULL; + } + + return pConfigurableDomain; +} + +const CConfigurableDomain* CConfigurableDomains::findConfigurableDomain(const string& strDomain, string& strError) const +{ + // Find domain + const CConfigurableDomain* pConfigurableDomain = static_cast<const CConfigurableDomain*>(findChild(strDomain)); + + if (!pConfigurableDomain) { + + strError = "Configurable domain " + strDomain + " not found"; + + return NULL; + } + + return pConfigurableDomain; +} |