aboutsummaryrefslogtreecommitdiffstats
path: root/parameter/ConfigurableDomain.cpp
diff options
context:
space:
mode:
authorPatrick Benavoli <patrickx.benavoli@intel.com>2011-11-29 11:10:27 +0100
committerDavid Wagner <david.wagner@intel.com>2014-02-10 17:15:01 +0100
commit0bd50546a8d06a6865d32c695adf8893fa71250a (patch)
tree966dc5c4c8143df983668db92db26129eafb1e3b /parameter/ConfigurableDomain.cpp
parente7a903ef0a5ee2b9d51e6f86d32c704b9ff16c21 (diff)
downloadexternal_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/ConfigurableDomain.cpp')
-rw-r--r--parameter/ConfigurableDomain.cpp149
1 files changed, 100 insertions, 49 deletions
diff --git a/parameter/ConfigurableDomain.cpp b/parameter/ConfigurableDomain.cpp
index 696bbd0..4c6541f 100644
--- a/parameter/ConfigurableDomain.cpp
+++ b/parameter/ConfigurableDomain.cpp
@@ -73,6 +73,24 @@ bool CConfigurableDomain::childrenAreDynamic() const
return true;
}
+// Content dumping
+void CConfigurableDomain::logValue(string& strValue, CErrorContext& errorContext) const
+{
+ (void)errorContext;
+
+ strValue = "{";
+
+ // Sequence awareness
+ strValue += "Sequence aware: ";
+ strValue += _bSequenceAware ? "yes" : "no";
+
+ // Last applied configuration
+ strValue += ", Last applied configuration: ";
+ strValue += _pLastAppliedConfiguration ? _pLastAppliedConfiguration->getName() : "<none>";
+
+ strValue += "}";
+}
+
// Sequence awareness
void CConfigurableDomain::setSequenceAwareness(bool bSequenceAware)
{
@@ -460,25 +478,6 @@ bool CConfigurableDomain::isApplicableConfigurationValid(const CConfigurableElem
return pApplicableDomainConfiguration && pApplicableDomainConfiguration->isValid(pConfigurableElement);
}
-// Presence of application condition on any configuration
-bool CConfigurableDomain::hasRules() const
-{
- // Delegate to configurations
- uint32_t uiNbConfigurations = getNbChildren();
- uint32_t uiChild;
-
- for (uiChild = 0; uiChild < uiNbConfigurations; uiChild++) {
-
- const CDomainConfiguration* pDomainConfiguration = static_cast<const CDomainConfiguration*>(getChild(uiChild));
-
- if (pDomainConfiguration->hasRule()) {
-
- return true;
- }
- }
- return false;
-}
-
// In case configurable element was removed
void CConfigurableDomain::computeSyncSet()
{
@@ -541,20 +540,10 @@ bool CConfigurableDomain::createConfiguration(const string& strName, const CPara
bool CConfigurableDomain::deleteConfiguration(const string& strName, string& strError)
{
- CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(findChild(strName));
+ CDomainConfiguration* pDomainConfiguration = findConfiguration(strName, strError);
if (!pDomainConfiguration) {
- strError = "Configuration not found";
-
- return false;
- }
-
- // Check configuration has no rule (prevent accidental loss of data)
- if (pDomainConfiguration->hasRule()) {
-
- strError = "Deletion of configuration containing application rules is not supported to prevent any accitental loss of data.\nPlease consider a direct modification of the XML file.";
-
return false;
}
@@ -593,12 +582,10 @@ void CConfigurableDomain::listAssociatedToElements(string& strResult) const
bool CConfigurableDomain::renameConfiguration(const string& strName, const string& strNewName, string& strError)
{
- CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(findChild(strName));
+ CDomainConfiguration* pDomainConfiguration = findConfiguration(strName, strError);
if (!pDomainConfiguration) {
- strError = "Configuration not found";
-
return false;
}
log("Renaming domain \"%s\"'s configuration \"%s\" to \"%s\"", getName().c_str(), strName.c_str(), strNewName.c_str());
@@ -607,15 +594,12 @@ bool CConfigurableDomain::renameConfiguration(const string& strName, const strin
return pDomainConfiguration->rename(strNewName, strError);
}
-bool CConfigurableDomain::restoreConfiguration(const string& strName, CParameterBlackboard* pMainBlackboard, bool bAutoSync, string& strError)
+bool CConfigurableDomain::restoreConfiguration(const string& strName, CParameterBlackboard* pMainBlackboard, bool bAutoSync, string& strError) const
{
- // Find Domain configuration
- const CDomainConfiguration* pDomainConfiguration = static_cast<const CDomainConfiguration*>(findChild(strName));
+ const CDomainConfiguration* pDomainConfiguration = findConfiguration(strName, strError);
if (!pDomainConfiguration) {
- strError = "Domain configuration " + strName + " not found";
-
return false;
}
log("Restoring domain \"%s\"'s configuration \"%s\" to parameter blackboard", getName().c_str(), pDomainConfiguration->getName().c_str());
@@ -636,12 +620,10 @@ bool CConfigurableDomain::restoreConfiguration(const string& strName, CParameter
bool CConfigurableDomain::saveConfiguration(const string& strName, const CParameterBlackboard* pMainBlackboard, string& strError)
{
// Find Domain configuration
- CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(findChild(strName));
+ CDomainConfiguration* pDomainConfiguration = findConfiguration(strName, strError);
if (!pDomainConfiguration) {
- strError = "Domain configuration " + strName + " not found";
-
return false;
}
log("Saving domain \"%s\"'s configuration \"%s\" from parameter blackboard", getName().c_str(), pDomainConfiguration->getName().c_str());
@@ -652,15 +634,13 @@ bool CConfigurableDomain::saveConfiguration(const string& strName, const CParame
return true;
}
-bool CConfigurableDomain::setElementSequence(const string& strName, const vector<string>& astrNewElementSequence, string& strError)
+bool CConfigurableDomain::setElementSequence(const string& strConfiguration, const vector<string>& astrNewElementSequence, string& strError)
{
// Find Domain configuration
- CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(findChild(strName));
+ CDomainConfiguration* pDomainConfiguration = findConfiguration(strConfiguration, strError);
if (!pDomainConfiguration) {
- strError = "Domain configuration " + strName + " not found";
-
return false;
}
@@ -668,15 +648,13 @@ bool CConfigurableDomain::setElementSequence(const string& strName, const vector
return pDomainConfiguration->setElementSequence(astrNewElementSequence, strError);
}
-bool CConfigurableDomain::getElementSequence(const string& strName, string& strResult) const
+bool CConfigurableDomain::getElementSequence(const string& strConfiguration, string& strResult) const
{
// Find Domain configuration
- const CDomainConfiguration* pDomainConfiguration = static_cast<const CDomainConfiguration*>(findChild(strName));
+ const CDomainConfiguration* pDomainConfiguration = findConfiguration(strConfiguration, strResult);
if (!pDomainConfiguration) {
- strResult = "Domain configuration " + strName + " not found";
-
return false;
}
@@ -686,6 +664,52 @@ bool CConfigurableDomain::getElementSequence(const string& strName, string& strR
return true;
}
+bool CConfigurableDomain::setApplicationRule(const string& strConfiguration, const string& strApplicationRule, const CSelectionCriteriaDefinition* pSelectionCriteriaDefinition, string& strError)
+{
+ // Find Domain configuration
+ CDomainConfiguration* pDomainConfiguration = findConfiguration(strConfiguration, strError);
+
+ if (!pDomainConfiguration) {
+
+ return false;
+ }
+
+ // Delegate to configuration
+ return pDomainConfiguration->setApplicationRule(strApplicationRule, pSelectionCriteriaDefinition, strError);
+}
+
+bool CConfigurableDomain::clearApplicationRule(const string& strConfiguration, string& strError)
+{
+ // Find Domain configuration
+ CDomainConfiguration* pDomainConfiguration = findConfiguration(strConfiguration, strError);
+
+ if (!pDomainConfiguration) {
+
+ return false;
+ }
+
+ // Delegate to configuration
+ pDomainConfiguration->clearApplicationRule();
+
+ return true;
+}
+
+bool CConfigurableDomain::getApplicationRule(const string& strConfiguration, string& strResult) const
+{
+ // Find Domain configuration
+ const CDomainConfiguration* pDomainConfiguration = findConfiguration(strConfiguration, strResult);
+
+ if (!pDomainConfiguration) {
+
+ return false;
+ }
+
+ // Delegate to configuration
+ pDomainConfiguration->getApplicationRule(strResult);
+
+ return true;
+}
+
// Last applied configuration
string CConfigurableDomain::getLastAppliedConfigurationName() const
{
@@ -983,3 +1007,30 @@ CSyncerSet* CConfigurableDomain::getSyncerSet(const CConfigurableElement* pConfi
return mapIt->second;
}
+
+// Configuration retrieval
+CDomainConfiguration* CConfigurableDomain::findConfiguration(const string& strConfiguration, string& strError)
+{
+ CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(findChild(strConfiguration));
+
+ if (!pDomainConfiguration) {
+
+ strError = "Domain configuration " + strConfiguration + " not found";
+
+ return NULL;
+ }
+ return pDomainConfiguration;
+}
+
+const CDomainConfiguration* CConfigurableDomain::findConfiguration(const string& strConfiguration, string& strError) const
+{
+ const CDomainConfiguration* pDomainConfiguration = static_cast<const CDomainConfiguration*>(findChild(strConfiguration));
+
+ if (!pDomainConfiguration) {
+
+ strError = "Domain configuration " + strConfiguration + " not found";
+
+ return NULL;
+ }
+ return pDomainConfiguration;
+}