ENDIF(NOT DEFINED MODES_CUSTOM_MODE_DEFAULT_DIR)
ADD_DEFINITIONS("-DMODES_CUSTOM_MODE_DEFAULT_DIR=\"${MODES_CUSTOM_MODE_DEFAULT_DIR}\"")
-IF(NOT DEFINED MODES_ACTIONSCHEMA_DEFAULT_DIR)
- MESSAGE("No MODES_ACTIONSCHEMA_DEFAULT_DIR. Check build system")
- SET(MODES_ACTIONSCHEMA_DEFAULT_DIR "/usr/share/modes/action")
-ENDIF(NOT DEFINED MODES_ACTIONSCHEMA_DEFAULT_DIR)
-ADD_DEFINITIONS("-DMODES_ACTIONSCHEMA_DEFAULT_DIR=\"${MODES_ACTIONSCHEMA_DEFAULT_DIR}\"")
+IF(NOT DEFINED MODES_ACTIONRULE_DEFAULT_DIR)
+ MESSAGE("No MODES_ACTIONRULE_DEFAULT_DIR. Check build system")
+ SET(MODES_ACTIONRULE_DEFAULT_DIR "/usr/share/modes/rule")
+ENDIF(NOT DEFINED MODES_ACTIONRULE_DEFAULT_DIR)
+ADD_DEFINITIONS("-DMODES_ACTIONRULE_DEFAULT_DIR=\"${MODES_ACTIONRULE_DEFAULT_DIR}\"")
IF(NOT DEFINED MODES_XSD_DEFAULT_DIR)
MESSAGE("No MODES_XSD_DEFAULT_DIR. Check build system")
#warning "MODES_CUSTOM_MODE_DEFAULT_DIR is redefined"
#endif
-#ifndef MODES_ACTIONSCHEMA_DEFAULT_DIR
-#define MODES_ACTIONSCHEMA_DEFAULT_DIR "/usr/share/modes/action"
-#warning "MODES_ACTIONSCHEMA_DEFAULT_DIR is redefined"
+#ifndef MODES_ACTIONRULE_DEFAULT_DIR
+#define MODES_ACTIONRULE_DEFAULT_DIR "/usr/share/modes/rule"
+#warning "MODES_ACTIONRULE_DEFAULT_DIR is redefined"
#endif
#ifndef MODES_PLUGIN_DEFAULT_DIR
#endif
#define MODES_MODE_DEFAULT_XSD_FILE "tizen_mode.xsd"
-#define MODES_ACTIONSCHEMA_DEFAULT_XSD_FILE "tizen_action_schema.xsd"
+#define MODES_ACTIONRULE_DEFAULT_XSD_FILE "tizen_action_rule.xsd"
#define MODES_MODE_DEFAULT_XSD MODES_XSD_DEFAULT_DIR "/" MODES_MODE_DEFAULT_XSD_FILE
-#define MODES_ACTIONSCHEMA_DEFAULT_XSD MODES_XSD_DEFAULT_DIR "/" MODES_ACTIONSCHEMA_DEFAULT_XSD_FILE
+#define MODES_ACTIONRULE_DEFAULT_XSD MODES_XSD_DEFAULT_DIR "/" MODES_ACTIONRULE_DEFAULT_XSD_FILE
#define MODES_PLUGIN_LIB_PREFIX "libmodes-plugin"
-#define MODES_ACTIONSCHEMA_FILE_SUFFIX "_schema.xml"
+#define MODES_ACTIONRULE_FILE_SUFFIX "_rule.xml"
#define MODES_MODE_FILE_SUFFIX "_mode.xml"
<?xml version="1.0" encoding="UTF-8"?>
<tizenModes xmlns="http://www.tizen.org" version="5.5">
- <actionSchema>
- <action name="wifi.power" type="bool" since="5.5" plugin="wifi-manager">
+ <actionRule>
+ <rule name="wifi.power" type="bool" since="5.5" plugin="wifi-manager">
<alias name="on">1</alias>
<alias name="off">0</alias>
<defaultVal>0</defaultVal>
<desc>wifi On/Off</desc>
<domain>Network & Connectivity</domain>
- </action>
- <action name="bluetooth.power" type="bool" since="5.5" plugin="bluetooth">
+ </rule>
+ <rule name="bluetooth.power" type="bool" since="5.5" plugin="bluetooth">
<alias name="on">1</alias>
<alias name="off">0</alias>
<defaultVal>0</defaultVal>
<desc>bluetooth On/Off</desc>
<domain>Network & Connectivity</domain>
- </action>
- <action name="bluetooth.audioConnect" type="string" since="5.5" plugin="bluetooth">
+ </rule>
+ <rule name="bluetooth.audioConnect" type="string" since="5.5" plugin="bluetooth">
<defaultVal>0:0:0:0:0:0</defaultVal>
<desc>bluetooth Audio Connect</desc>
<domain>Network & Connectivity</domain>
- </action>
- <action name="sensord.changeAccuracy" type="int" since="5.5" plugin="sensor-fw">
+ </rule>
+ <rule name="sensord.changeAccuracy" type="int" since="5.5" plugin="sensor-fw">
<defaultVal>100</defaultVal>
<conflict>sensord.exactness</conflict>
<desc>Sensor Accuracy</desc>
<domain>System</domain>
- </action>
- <action name="sensord.exactness" type="int" since="5.5" plugin="sensor-fw">
+ </rule>
+ <rule name="sensord.exactness" type="int" since="5.5" plugin="sensor-fw">
<defaultVal>100</defaultVal>
<conflict>sensord.changeAccuracy</conflict>
<desc>Sensor Exactness</desc>
<domain>System</domain>
- </action>
- <action name="vconf.db.setting.psmode" type="int" since="5.5" plugin="vconf">
+ </rule>
+ <rule name="vconf.db.setting.psmode" type="int" since="5.5" plugin="vconf">
<alias name="SETTING_PSMODE_NORMAL">0</alias>
<alias name="SETTING_PSMODE_POWERFUL">1</alias>
<alias name="SETTING_PSMODE_ADVISOR">1</alias>
<conflict>sensord.changeAccuracy</conflict>
<desc>test</desc>
<domain>System</domain>
- </action>
- <action name="vconf.db.bluetooth.status" type="int" since="5.5" plugin="vconf">
+ </rule>
+ <rule name="vconf.db.bluetooth.status" type="int" since="5.5" plugin="vconf">
<alias name="VCONFKEY_BT_STATUS_OFF">0</alias>
<alias name="VCONFKEY_BT_STATUS_ON">1</alias>
<alias name="VCONFKEY_BT_STATUS_BT_VISIBLE">2</alias>
<defaultVal>0</defaultVal>
<desc>test</desc>
<domain>Network & Connectivity</domain>
- </action>
- <action name="browser.url" type="string" since="5.5" plugin="web">
+ </rule>
+ <rule name="browser.url" type="string" since="5.5" plugin="web">
<defaultVal>about:blank</defaultVal>
<desc>browser</desc>
<domain>Web Framework</domain>
- </action>
- <action name="display.nightLight" type="int" since="5.5" plugin="display">
+ </rule>
+ <rule name="display.nightLight" type="int" since="5.5" plugin="display">
<defaultVal>70</defaultVal>
<conflict>display.autoLight</conflict>
<desc>It makes the screen color warmer.</desc>
<domain>System</domain>
- </action>
- </actionSchema>
+ </rule>
+ </actionRule>
</tizenModes>
<xs:element name="tizenModes">
<xs:complexType>
<xs:sequence>
- <xs:element maxOccurs="1" name="actionSchema">
+ <xs:element maxOccurs="1" name="actionRule">
<xs:complexType>
<xs:sequence>
- <xs:element maxOccurs="unbounded" name="action">
+ <xs:element maxOccurs="unbounded" name="rule">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="alias">
<?xml version="1.0" encoding="utf-8"?>
<tizenModes xmlns="http://www.tizen.org" version="5.5">
<mode name="btAudioConnect" type="exclusive">
- <req action="bluetooth.power">on</req>
- <req action="bluetooth.audioConnect">08:AE:D6:5E:AE:16</req>
+ <action rule="bluetooth.power">on</action>
+ <action rule="bluetooth.audioConnect">08:AE:D6:5E:AE:16</action>
</mode>
</tizenModes>
<?xml version="1.0" encoding="utf-8"?>
<tizenModes xmlns="http://www.tizen.org" version="5.5">
<mode name="btOff" type="exclusive">
- <req action="bluetooth.power">off</req>
+ <action rule="bluetooth.power">off</action>
</mode>
</tizenModes>
<?xml version="1.0" encoding="utf-8"?>
<tizenModes xmlns="http://www.tizen.org" version="5.5">
<mode name="btOn" type="exclusive">
- <req action="bluetooth.power">on</req>
+ <action rule="bluetooth.power">on</action>
</mode>
</tizenModes>
<?xml version="1.0" encoding="utf-8"?>
<tizenModes xmlns="http://www.tizen.org" version="5.5">
<mode name="ex1" type="normal">
- <req ID="wifiOn" action="wifi.power" restrict="lock" type="sync" priority="-100">on</req>
- <req action="notification.donotdisturb">on</req>
- <req action="application.launch" before="GoPbsKids">com.vpn.usa123</req>
- <req ID="GoPbsKids" action="browser.url" after="wifiOn">https://pbskids.org/</req>
- <req ID="BMJ" action="bluetooth.connet" type="sync">Modes-JBL</req>
- <req action="media.music.player" type="async" after="BMJ">beatles-yesterday.mp3</req>
- <req ID="1" action="vconf.db.setting.psmode" type="async" priority="-100"
- >SETTING_PSMODE_NORMAL</req>
+ <action ID="wifiOn" rule="wifi.power" restrict="lock" type="sync" priority="-100">on</action>
+ <action rule="notification.donotdisturb">on</action>
+ <action rule="application.launch" before="GoPbsKids">com.vpn.usa123</action>
+ <action ID="GoPbsKids" rule="browser.url" after="wifiOn">https://pbskids.org/</action>
+ <action ID="BMJ" rule="bluetooth.connet" type="sync">Modes-JBL</action>
+ <action rule="media.music.player" type="async" after="BMJ">beatles-yesterday.mp3</action>
+ <action ID="1" rule="vconf.db.setting.psmode" type="async" priority="-100"
+ >SETTING_PSMODE_NORMAL</action>
</mode>
</tizenModes>
<?xml version="1.0" encoding="utf-8"?>
<tizenModes xmlns="http://www.tizen.org" version="5.5">
<mode name="ex2" type="exclusive">
- <req ID="1" action="vconf.db.setting.psmode" type="async" restrict="lock" priority="-100">SETTING_PSMODE_WEARABLE</req>
- <req ID="wifiOff" action="wifi.power" restrict="lock" type="sync" priority="-100">off</req>
+ <action ID="1" rule="vconf.db.setting.psmode" type="async" restrict="lock" priority="-100">SETTING_PSMODE_WEARABLE</action>
+ <action ID="wifiOff" rule="wifi.power" restrict="lock" type="sync" priority="-100">off</action>
</mode>
</tizenModes>
<xs:element name="mode">
<xs:complexType>
<xs:sequence>
- <xs:element maxOccurs="unbounded" name="req">
+ <xs:element maxOccurs="unbounded" name="action">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="o:valueT">
<xs:attribute name="ID" type="xs:string" use="optional" />
- <xs:attribute name="action" type="xs:string" use="required" />
+ <xs:attribute name="rule" type="xs:string" use="required" />
<xs:attribute name="type" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<?xml version="1.0" encoding="utf-8"?>
<tizenModes xmlns="http://www.tizen.org" version="5.5">
<mode name="powerSave" type="exclusive">
- <req action="vconf.db.setting.psmode">SETTING_PSMODE_WEARABLE_ENHANCED</req>
- <req action="vconf.db.bluetooth.status">VCONFKEY_BT_STATUS_OFF</req>
+ <action rule="vconf.db.setting.psmode">SETTING_PSMODE_WEARABLE_ENHANCED</action>
+ <action rule="vconf.db.bluetooth.status">VCONFKEY_BT_STATUS_OFF</action>
</mode>
</tizenModes>
<?xml version="1.0" encoding="utf-8"?>
<tizenModes xmlns="http://www.tizen.org" version="5.5">
<mode name="wifiOn" type="exclusive">
- <req action="wifi.power">on</req>
+ <action rule="wifi.power">on</action>
</mode>
</tizenModes>
-DSYSCONF_DIR:PATH=%{_sysconfdir} \
-DMODES_MODE_DEFAULT_DIR:PATH=%{modes_data_dir}/mode \
-DMODES_CUSTOM_MODE_DEFAULT_DIR:PATH=%{modes_data_dir}/custom-mode \
- -DMODES_ACTIONSCHEMA_DEFAULT_DIR:PATH=%{modes_data_dir}/action \
+ -DMODES_ACTIONRULE_DEFAULT_DIR:PATH=%{modes_data_dir}/rule \
-DMODES_XSD_DEFAULT_DIR:PATH=%{modes_data_dir}/xsd \
-DMODES_PLUGIN_DEFAULT_DIR:PATH=%{modes_plugin_dir} \
-DDBUS_INTERFACE=%{_dbus_interface} \
%make_install
install -d -m 755 %{buildroot}%{modes_data_dir}/mode
install -d -m 755 %{buildroot}%{modes_data_dir}/custom-mode
-install -d -m 755 %{buildroot}%{modes_data_dir}/action
+install -d -m 755 %{buildroot}%{modes_data_dir}/rule
install -d -m 755 %{buildroot}%{modes_data_dir}/xsd
install -m 0644 example/*_mode.xml %{buildroot}%{modes_data_dir}/mode/
-install -m 0644 example/*_schema.xml %{buildroot}%{modes_data_dir}/action/
+install -m 0644 example/*_rule.xml %{buildroot}%{modes_data_dir}/rule/
install -m 0644 example/*.xsd %{buildroot}%{modes_data_dir}/xsd/
install -m 0755 unittest/modes-gtest-run.sh %{buildroot}%{modes_test_dir}/
%check
pushd example
-xmllint --noout --schema tizen_action_schema.xsd tizen_action_schema.xml
+xmllint --noout --schema tizen_action_rule.xsd tizen_action_rule.xml
xmllint --noout --schema tizen_mode.xsd tizen_*_mode.xml
bash ../unittest/modes-gtest-run.sh ./ ../unittest
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include "Req.h"
+#include "Action.h"
#include "mdss.h"
#include "ModesEx.h"
MODES_NAMESPACE_USE;
-Req::Req()
+Action::Action()
:plugin(nullptr), restriction(REQ_NONE)
{
}
-Req::Req(const std::string &name)
- :actionName(name), plugin(nullptr), restriction(REQ_NONE)
+Action::Action(const std::string &name)
+ :ruleName(name), plugin(nullptr), restriction(REQ_NONE)
{
}
-void Req::printInfo()
+void Action::printInfo()
{
- DBG("Req(%s):ID(%s), Restrict(%d)", getName().c_str(), getID().c_str(), getRestrict());
+ DBG("Action(%s):ID(%s), Restrict(%d)", getRuleName().c_str(), getID().c_str(), getRestrict());
}
-void Req::setName(const std::string &data)
+void Action::setRuleName(const std::string &data)
{
- actionName = data;
+ ruleName = data;
}
-std::string Req::getName()
+std::string Action::getRuleName()
{
- return actionName;
+ return ruleName;
}
-void Req::setID(const std::string &actionId)
+void Action::setID(const std::string &actionId)
{
id = actionId;
}
-std::string Req::getID()
+std::string Action::getID()
{
return id;
}
-void Req::setRestrict(const ReqRestrict &data)
+void Action::setRestrict(const ActionRestrict &data)
{
restriction = data;
}
-Req::ReqRestrict Req::getRestrict()
+Action::ActionRestrict Action::getRestrict()
{
return restriction;
}
-void Req::setPlugin(Plugin *pi)
+void Action::setPlugin(Plugin *pi)
{
plugin = pi;
}
MODES_NAMESPACE_BEGIN
-class Req {
+class Action {
public:
typedef enum {
REQ_NONE,
REQ_LOCK
- }ReqRestrict;
+ }ActionRestrict;
- virtual ~Req() = default;
- Req();
- Req(const std::string &actionName);
+ virtual ~Action() = default;
+ Action();
+ Action(const std::string &ruleName);
void printInfo();
- void setName(const std::string &data);
- std::string getName();
+ void setRuleName(const std::string &data);
+ std::string getRuleName();
void setID(const std::string &actionId);
std::string getID();
- void setRestrict(const ReqRestrict &data);
- ReqRestrict getRestrict();
+ void setRestrict(const ActionRestrict &data);
+ ActionRestrict getRestrict();
void setPlugin(Plugin *pi);
virtual void setValue(const std::string &val) = 0;
virtual std::string getStringOfValue() = 0;
virtual void apply() = 0;
protected:
- std::string actionName;
+ std::string ruleName;
Plugin *plugin;
private:
std::string id;
- ReqRestrict restriction;
+ ActionRestrict restriction;
};
MODES_NAMESPACE_END
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include "ActionSchema.h"
+#include "ActionRule.h"
#include <string>
#include "mdss.h"
MODES_NAMESPACE_USE;
-std::string ActionSchema::getName()
+std::string ActionRule::getName()
{
- return actionName;
+ return ruleName;
}
-void ActionSchema::setPlugin(const std::string &pi)
+void ActionRule::setPlugin(const std::string &pi)
{
plugin = pi;
}
-std::string ActionSchema::getPlugin()
+std::string ActionRule::getPlugin()
{
return plugin;
}
#include <string>
#include "mdss.h"
-#include "Req.h"
+#include "Action.h"
MODES_NAMESPACE_BEGIN
-class ActionSchema {
+class ActionRule {
public:
- virtual ~ActionSchema() = default;
+ virtual ~ActionRule() = default;
std::string getName();
std::string getPlugin();
void setPlugin(const std::string &pi);
- virtual Req* makeRequirement() = 0;
+ virtual Action* makeAction() = 0;
virtual void addDefaultValue(const std::string &val) = 0;
virtual void addAlias(const std::string &alias, const std::string &value) = 0;
protected:
- std::string actionName;
+ std::string ruleName;
private:
std::string plugin;
// TODO:: handle conflict List, since, description, version
+++ /dev/null
-/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "ActionSchemaManager.h"
-
-#include <dirent.h>
-#include <cstring>
-#include "mdss.h"
-#include "TActionSchema.h"
-#include "ModesEx.h"
-
-using std::string;
-MODES_NAMESPACE_USE;
-
-const xmlChar* const ActionSchemaManager::ACTION_SCHEMA_TAG = (xmlChar*)"actionSchema";
-const xmlChar* const ActionSchemaManager::ACTION_SCHEMA_TAG_ACTION = (xmlChar*)"action";
-const xmlChar* const ActionSchemaManager::ACTION_TAGS[] = {
- (xmlChar*)"name",
- (xmlChar*)"type",
- (xmlChar*)"plugin",
- (xmlChar*)"alias",
- (xmlChar*)"conflict",
- (xmlChar*)"defaultVal"
-};
-
-void ActionSchemaManager::makeActionSchemaMap()
-{
- if (actSchemaDir.empty()) {
- ERR("No actSchemaDir");
- actSchemaDir = MODES_ACTIONSCHEMA_DEFAULT_DIR;
- }
-
- DIR *dir;
- if ((dir = opendir(actSchemaDir.c_str())) == NULL)
- ERR("opendir(%s) Fail(%s)", actSchemaDir.c_str(), strerror(errno));
-
- struct dirent *entry;
- while ((entry = readdir(dir)) != NULL) {
- string file(entry->d_name);
- size_t pos = file.find_last_of("_");
- if (string::npos == pos
- || file.compare(pos, sizeof(MODES_ACTIONSCHEMA_FILE_SUFFIX) - 1, MODES_ACTIONSCHEMA_FILE_SUFFIX)) {
- continue;
- }
-
- string fileFullPath = actSchemaDir + "/" + string(entry->d_name);
- try {
- parseActionSchema(fileFullPath);
- DBG("Action Schema(size=%d) Load", schemaMap.size());
- }
- catch (ModesEx &e) {
- ERR("parseActionSchema(%s) Fail(%s)", fileFullPath.c_str(), e.what());
- }
- }
- closedir(dir);
-}
-
-void ActionSchemaManager::freeActionSchemaMap()
-{
- for (auto it = schemaMap.begin(); it != schemaMap.end(); ++it)
- delete it->second;
-}
-
-
-void ActionSchemaManager::parseElement(xmlNodePtr cur, ActionSchema *actionSchema)
-{
- RET_IF(NULL == actionSchema);
-
- if (MDS_EQUAL == xmlStrcmp(cur->name, ACTION_TAGS[TagElemAlias])) {
- char *alias = (char*)xmlGetProp(cur, ACTION_TAGS[TagAttName]);
- if (NULL == alias) {
- ERR("%s : No %s", ACTION_TAGS[TagElemAlias], ACTION_TAGS[TagAttName]);
- return;
- }
-
- char *value = (char*)xmlNodeGetContent(cur);
- if (NULL == value) {
- ERR("%s(%s) : No value", ACTION_TAGS[TagElemAlias], alias);
- xmlFree(alias);
- return;
- }
-
- actionSchema->addAlias(alias, value);
- xmlFree(value);
- xmlFree(alias);
- } else if (MDS_EQUAL == xmlStrcmp(cur->name, ACTION_TAGS[TagElemDefValue])) {
- char *value = (char*)xmlNodeGetContent(cur);
- if (NULL == value) {
- ERR("%s : No value", ACTION_TAGS[TagElemDefValue]);
- return;
- }
- actionSchema->addDefaultValue(value);
- } else if (MDS_EQUAL == xmlStrcmp(cur->name, ACTION_TAGS[TagElemConflict])) {
- // TODO: enhanced feature
- DBG("TBD(%s)", cur->name);
- } else {
- DBG("Invalid node(%s)", cur->name);
- }
-}
-
-Req* ActionSchemaManager::createAction(const string &actionName)
-{
- std::map<std::string, ActionSchema*>::iterator it = schemaMap.find(actionName);
- if (schemaMap.end() != it) {
- ActionSchema *schema = it->second;
- return schema->makeRequirement();
- } else {
- ERR("No schema(%s)", actionName.c_str());
- return nullptr;
- }
-}
-
-void ActionSchemaManager::setOptions(const string &actionSchemaDir, const string &actionSchemaXsd)
-{
- actSchemaDir = actionSchemaDir;
- actSchemaXsd = actionSchemaXsd;
-}
-
-string ActionSchemaManager::getProp(xmlNodePtr node, int att)
-{
- char *tmp;
- string returnStr;
-
- tmp = (char*)xmlGetProp(node, ACTION_TAGS[att]);
- if (tmp) {
- returnStr = tmp;
- xmlFree(tmp);
- } else {
- ERR("Action : No %s", ACTION_TAGS[att]);
- throw ModesEx(ModesEx::NO_DATA);
- }
-
- return returnStr;
-}
-
-ActionSchema* ActionSchemaManager::makeActionSchema(xmlNodePtr node)
-{
- string type, name, plugin;
- ActionSchema *actionSchema = NULL;
-
- try {
- name = getProp(node, TagAttName);
- type = getProp(node, TagAttType);
- plugin = getProp(node, TagAttPlugin);
- }
- catch (ModesEx &e) {
- ERR("getProp() Fail(%s)", e.what());
- return nullptr;
- }
-
- DBG("Action(%s, %s) Added", name.c_str(), type.c_str());
-
- if (MDS_EQUAL == type.compare("int"))
- actionSchema = new TActionSchema<int>(name);
- else if (MDS_EQUAL == type.compare("float"))
- actionSchema = new TActionSchema<float>(name);
- else if (MDS_EQUAL == type.compare("bool"))
- actionSchema = new TActionSchema<bool>(name);
- else
- actionSchema = new TActionSchema<string>(name);
-
- actionSchema->setPlugin(plugin);
- for (xmlNode *cur = node->children; cur; cur = cur->next) {
- if (xmlIsBlankNode(cur))
- continue;
- parseElement(cur, actionSchema);
- }
-
- return actionSchema;
-}
-
-void ActionSchemaManager::parseAction(xmlNodePtr node)
-{
- for (xmlNodePtr cur = node; cur; cur = cur->next) {
- if (xmlIsBlankNode(cur))
- continue;
-
- if (MDS_EQUAL == xmlStrcmp(cur->name, ACTION_SCHEMA_TAG_ACTION)) {
- ActionSchema *schema = makeActionSchema(cur);
- schemaMap.insert(std::pair<string, ActionSchema*>(schema->getName(), schema));
- } else {
- DBG("Invalid node(%s)", cur->name);
- parseAction(cur->children);
- }
- }
-}
-
-void ActionSchemaManager::parseActionSchema(const string &xmlFile)
-{
- if (actSchemaXsd.empty()) {
- ERR("No actSchemaXsd");
- actSchemaXsd = MODES_ACTIONSCHEMA_DEFAULT_XSD;
- }
-
- try {
- XMLParser parser(xmlFile);
- parser.validate(actSchemaXsd);
-
- xmlNodePtr root = parser.getRoot();
- if (MDS_EQUAL != xmlStrcmp(root->name, (xmlChar*)MODES_XML_ROOT)) {
- ERR("Invalid root element(%s, %s)", root->name, xmlFile.c_str());
- throw ModesEx(ModesEx::PARSER_ERROR, "Invalid file");
- }
-
- parseAction(root);
- }
- catch (ModesEx &e) {
- ERR("parser Fail(%s)", e.what());
- }
-}
char ArgumentParser::args_doc[] =
"modeXMLDirPath1 [modeXMLDirPath2] [--pluginDir=../plugin]"
- " [--modeXsdFilePath=..example/tizen_mode.xsd] [--actionXsdFilePath=..example/tizen_schema.xsd]"
- " [--actionSchema=../example] [--[--help]";
+ " [--modeXsdFilePath=..example/tizen_mode.xsd] [--ruleXsdFilePath=..example/tizen_rule.xsd]"
+ " [--ruleDir=../example] [--[--help]";
struct argp_option ArgumentParser::options[] = {
{"pluginDir", 'p', "pluginDirPath", OPTION_ARG_OPTIONAL, "Set directory of plugin"},
{"modeXsdFilePath", 'm', "modeXsdFilePath", OPTION_ARG_OPTIONAL, "Set mode xsd(schema) file path"},
- {"actionXsdFilePath", 'a', "actionXsdFilePath", OPTION_ARG_OPTIONAL, "Set action xsd(schema) file path"},
- {"actionSchema", 's', "actionSchemaDirPath", OPTION_ARG_OPTIONAL, "Set directory of Action schema file"},
+ {"ruleXsdFilePath", 'a', "actionRuleXsdFilePath", OPTION_ARG_OPTIONAL, "Set action rule xsd(schema) file path"},
+ {"ruleDir", 's', "actionRuleDirPath", OPTION_ARG_OPTIONAL, "Set directory of Action Rule file"},
{ 0 }
};
case 'a':
nextArg = state->argv[state->next];
if (nextArg && *nextArg != '-') {
- parser->actionSchemaXsdFile = nextArg;
+ parser->actionRuleXsdFile = nextArg;
state->next++;
}
break;
case 's':
nextArg = state->argv[state->next];
if (nextArg && *nextArg != '-') {
- parser->actionSchemaDir = nextArg;
+ parser->actionRuleDir = nextArg;
state->next++;
}
break;
ArgumentParser::ArgumentParser()
:modeDirCount(0), modeXMLDirList(NULL), modeXsdFile(NULL),
- actionSchemaDir(NULL), actionSchemaXsdFile(NULL), pluginDir(NULL)
+ actionRuleDir(NULL), actionRuleXsdFile(NULL), pluginDir(NULL)
{
}
config.modeXMLDirs.insert(MODES_MODE_DEFAULT_DIR);
}
- if (this->actionSchemaDir) {
- DBG("action schema dir path: %s", this->actionSchemaDir);
- config.actionSchemaDir = this->actionSchemaDir;
+ if (this->actionRuleDir) {
+ DBG("Action Rule dir path: %s", this->actionRuleDir);
+ config.actionRuleDir = this->actionRuleDir;
} else {
- config.actionSchemaDir = MODES_ACTIONSCHEMA_DEFAULT_DIR;
+ config.actionRuleDir = MODES_ACTIONRULE_DEFAULT_DIR;
}
if (this->modeXsdFile) {
config.modeXsdFile = MODES_MODE_DEFAULT_XSD;
}
- if (this->actionSchemaXsdFile) {
- DBG("action schema xsd file path: %s", this->actionSchemaXsdFile);
- config.actionSchemaXsdFile = this->actionSchemaXsdFile;
+ if (this->actionRuleXsdFile) {
+ DBG("Action Rule xsd file path: %s", this->actionRuleXsdFile);
+ config.actionRuleXsdFile = this->actionRuleXsdFile;
} else {
- config.actionSchemaXsdFile = MODES_ACTIONSCHEMA_DEFAULT_XSD;
+ config.actionRuleXsdFile = MODES_ACTIONRULE_DEFAULT_XSD;
}
if (this->pluginDir) {
int modeDirCount;
char **modeXMLDirList;
char *modeXsdFile;
- char *actionSchemaDir;
- char *actionSchemaXsdFile;
+ char *actionRuleDir;
+ char *actionRuleXsdFile;
char *pluginDir;
static char argp_doc[];
{
}
-void Mode::addRequirement(Req *req)
+void Mode::addAction(Action *action)
{
- reqList.push_back(std::shared_ptr<Req>(req));
+ actionList.push_back(std::shared_ptr<Action>(action));
}
void Mode::setName(const std::string &data)
void Mode::apply()
{
- std::list<std::shared_ptr<Req>>::iterator it;
- for (it = reqList.begin(); it != reqList.end(); it++)
+ std::list<std::shared_ptr<Action>>::iterator it;
+ for (it = actionList.begin(); it != actionList.end(); it++)
(*it)->apply();
}
-std::list<std::shared_ptr<Req>> Mode::getReqList() const
+std::list<std::shared_ptr<Action>> Mode::getActionList() const
{
- return reqList;
+ return actionList;
}
#include <string>
#include <memory>
#include "mdss.h"
-#include "Req.h"
+#include "Action.h"
MODES_NAMESPACE_BEGIN
void setCustomized(bool data);
bool getCustomized() const;
- void addRequirement(Req *req);
- std::list<std::shared_ptr<Req>> getReqList() const;
+ void addAction(Action *action);
+ std::list<std::shared_ptr<Action>> getActionList() const;
void apply();
private:
bool customized;
std::string name;
std::string type;
- std::list<std::shared_ptr<Req>> reqList;
+ std::list<std::shared_ptr<Action>> actionList;
#ifdef MDS_TEST
friend class TestParser;
#endif
using std::string;
MODES_NAMESPACE_USE;
-ModeManager::ModeManager(ActionSchemaManager &asMgr, PluginManager &piMgr)
- : actSchemaMgr(asMgr), pluginMgr(piMgr)
+ModeManager::ModeManager(RuleManager &rMgr, PluginManager &pMgr)
+ : ruleMgr(rMgr), pluginMgr(pMgr)
{
}
{
int pos = path.find_last_of(".");
if (MDS_EQUAL == path.substr(pos + 1).compare("xml")) {
- return new ModeXMLParser(path, actSchemaMgr, pluginMgr);
+ return new ModeXMLParser(path, ruleMgr, pluginMgr);
} else {
ERR("Wrong path(%s)", path.c_str());
throw std::invalid_argument("Wrong path");
#include "mdss.h"
#include "ModeParser.h"
#include "PluginManager.h"
-#include "ActionSchemaManager.h"
+#include "RuleManager.h"
#ifndef MODES_MODE_DEFAULT_DIR
#define MODES_MODE_DEFAULT_DIR "/usr/share/modes/mode"
class ModeManager {
public:
- ModeManager(ActionSchemaManager &asMgr, PluginManager &piMgr);
+ ModeManager(RuleManager &rMgr, PluginManager &pMgr);
void setOptions(const std::set<std::string> &modeDirs, const std::string &xsdFile);
void init();
std::map<std::string, std::string> modeMap;
std::set<std::string> modeDirList;
std::string modeSyntaxFile;
- ActionSchemaManager &actSchemaMgr;
+ RuleManager &ruleMgr;
PluginManager &pluginMgr;
#ifdef MDS_TEST
#include "mdss.h"
#include "Mode.h"
-#include "ActionSchemaManager.h"
+#include "RuleManager.h"
MODES_NAMESPACE_BEGIN
virtual std::string getModeName() = 0;
virtual void validateMode(const std::string &syntaxFile) = 0;
protected:
- ModeParser(ActionSchemaManager &mgr) :schemaMgr(mgr)
+ ModeParser(RuleManager &rMgr) :ruleMgr(rMgr)
{
}
- ActionSchemaManager &schemaMgr;
+ RuleManager &ruleMgr;
};
MODES_NAMESPACE_END
const xmlChar* const ModeTag::NAME = (xmlChar*)"name";
const xmlChar* const ModeTag::TYPE = (xmlChar*)"type";
const xmlChar* const ModeTag::CUSTOM = (xmlChar*)"custom";
-const xmlChar* const ModeTag::REQ = (xmlChar*)"req";
const xmlChar* const ModeTag::ACTION = (xmlChar*)"action";
+const xmlChar* const ModeTag::RULE = (xmlChar*)"rule";
const xmlChar* const ModeTag::RESTICT = (xmlChar*)"restrict";
const xmlChar* const ModeTag::ID = (xmlChar*)"ID";
-const xmlChar* const ModeTag::PRIORITY = (xmlChar*)"priority";
-const xmlChar* const ModeTag::BEFORE = (xmlChar*)"before";
-const xmlChar* const ModeTag::AFTER = (xmlChar*)"after";
const char* const ModeTag::RESTICT_LOCK = "lock";
static const xmlChar* const NAME;
static const xmlChar* const TYPE;
static const xmlChar* const CUSTOM;
- static const xmlChar* const REQ;
static const xmlChar* const ACTION;
+ static const xmlChar* const RULE;
static const xmlChar* const RESTICT;
static const xmlChar* const ID;
static const xmlChar* const PRIORITY;
#include "mdss.h"
#include "Mode.h"
#include "ModesEx.h"
-#include "TReq.h"
+#include "TAction.h"
#include "XMLParser.h"
#include "ModeTag.h"
MODES_NAMESPACE_USE;
-ModeXMLParser::ModeXMLParser(const std::string &modeFile, ActionSchemaManager &asMgr, PluginManager &piMgr)
- : ModeParser(asMgr), pluginManager(piMgr)
+ModeXMLParser::ModeXMLParser(const std::string &modeFile, RuleManager &rMgr, PluginManager &pMgr)
+ : ModeParser(rMgr), pluginManager(pMgr)
{
this->modeFile = modeFile;
}
{
if (MDS_EQUAL == xmlStrcmp(node->name, ModeTag::MODE)) {
parseMode(node);
- } else if (MDS_EQUAL == xmlStrcmp(node->name, ModeTag::REQ)) {
- parseReq(node);
+ } else if (MDS_EQUAL == xmlStrcmp(node->name, ModeTag::ACTION)) {
+ parseAction(node);
} else {
DBG("Unhandled node : %s", node->name);
}
xmlTagValue = (char*)xmlGetProp(node, tag);
if (xmlTagValue == NULL) {
- ERR("XML Value is NULL. Tag[%s]", tag);
+ ERR("attribute(%s) is NULL. ", tag);
xmlTagString = "";
return xmlTagString;
}
return xmlTagString;
}
-void ModeXMLParser::parseReq(xmlNodePtr node)
+void ModeXMLParser::parseAction(xmlNodePtr node)
{
- char *actionProp = (char*)xmlGetProp(node, ModeTag::ACTION);
- if (actionProp == NULL) {
- ERR("ACTION TAG Value is null! [%s]", ModeTag::ACTION);
- throw ModesEx(ModesEx::PARSER_ERROR, "ACTION TAG Value is null!");
+ char *ruleProp = (char*)xmlGetProp(node, ModeTag::RULE);
+ if (ruleProp == NULL) {
+ ERR("rule attribute is null! [%s]", ModeTag::RULE);
+ throw ModesEx(ModesEx::PARSER_ERROR, "rule attribute is null!");
}
- Req *req = schemaMgr.createAction(actionProp);
- if (req == nullptr) {
- WARN("schemaMgr createAction(%s) Fail", actionProp);
- req = new TReq<std::string>(actionProp);
- if (req == NULL) {
- ERR("Req is null");
- throw ModesEx(ModesEx::PARSER_ERROR, "Req is null!");
+ Action *action = ruleMgr.createAction(ruleProp);
+ if (action == nullptr) {
+ WARN("ruleMgr createAction(%s) Fail", ruleProp);
+ action = new TAction<std::string>(ruleProp);
+ if (action == NULL) {
+ ERR("Action is null");
+ throw ModesEx(ModesEx::PARSER_ERROR, "Action is null!");
}
}
- bindPlugin(actionProp, req);
- xmlFree(actionProp);
+ bindPlugin(ruleProp, action);
+ xmlFree(ruleProp);
char *restictProp = (char*)xmlGetProp(node, ModeTag::RESTICT);
if (restictProp && MDS_EQUAL == strcmp(restictProp, ModeTag::RESTICT_LOCK)) {
- req->setRestrict(Req::REQ_LOCK);
+ action->setRestrict(Action::REQ_LOCK);
} else {
- req->setRestrict(Req::REQ_NONE);
+ action->setRestrict(Action::REQ_NONE);
}
xmlFree(restictProp);
ERR("Node Content is null!");
}
- req->setValue(nodeContent ? nodeContent : "");
+ action->setValue(nodeContent ? nodeContent : "");
xmlFree(nodeContent);
- req->printInfo();
+ action->printInfo();
- mode.addRequirement(req);
+ mode.addAction(action);
}
-void ModeXMLParser::bindPlugin(const std::string &name, Req *req)
+void ModeXMLParser::bindPlugin(const std::string &name, Action *action)
{
std::string pluginName;
int pos = name.find_first_of(".");
pluginName = name.substr(0, pos);
- req->setPlugin(pluginManager.getPlugin(pluginName));
+ action->setPlugin(pluginManager.getPlugin(pluginName));
}
class ModeXMLParser : public ModeParser {
public:
- ModeXMLParser(const std::string &modeFile, ActionSchemaManager &mgr, PluginManager &pluginMgr);
+ ModeXMLParser(const std::string &modeFile, RuleManager &mgr, PluginManager &pluginMgr);
~ModeXMLParser();
Mode getMode() override;
std::string getModeType(xmlNodePtr node);
bool getModeCustom(xmlNodePtr node);
std::string getXmlTagStringValue(xmlNodePtr node, const xmlChar *tag);
- void parseReq(xmlNodePtr node);
- void bindPlugin(const std::string &name, Req *req);
+ void parseAction(xmlNodePtr node);
+ void bindPlugin(const std::string &name, Action *action);
PluginManager &pluginManager;
Mode mode;
std::string pluginDir;
std::set<std::string> modeXMLDirs;
std::string modeXsdFile;
- std::string actionSchemaXsdFile;
- std::string actionSchemaDir;
+ std::string actionRuleXsdFile;
+ std::string actionRuleDir;
};
MODES_NAMESPACE_END
MODES_NAMESPACE_USE;
ModeManager* RequestHandler::modeMgr = NULL;
-ActionSchemaManager *RequestHandler::actSchemaMgr = NULL;
+RuleManager *RequestHandler::ruleMgr = NULL;
PluginManager *RequestHandler::pluginMgr = NULL;
void RequestHandler::setModeManager(ModeManager *mgr)
modeMgr = mgr;
}
-void RequestHandler::setActionSchemaManager(ActionSchemaManager *mgr)
+void RequestHandler::setRuleManager(RuleManager *mgr)
{
- actSchemaMgr = mgr;
+ ruleMgr = mgr;
}
void RequestHandler::setPluginManager(PluginManager *mgr)
DBG("id : %s action_name : %s value : %s restiction : %d",
id[0] != '\0' ? id : "NULL", act_name, value, restriction);
- Req *req = createReq(id, act_name, value, restriction);
+ Action *action = createAction(id, act_name, value, restriction);
- mode.addRequirement(req);
+ mode.addAction(action);
}
} catch (ModesEx &e) {
- ERR("createReq(%s, %s, %s, %d) Fail(%s)", id, act_name, value, restriction, e.what());
+ ERR("createAction(%s, %s, %s, %d) Fail(%s)", id, act_name, value, restriction, e.what());
g_variant_iter_free(iter);
g_variant_unref(actionList);
- throw ModesEx(ModesEx::INVALID_ARG, "Req is null!");
+ throw ModesEx(ModesEx::INVALID_ARG, "Action is null!");
}
g_variant_iter_free(iter);
g_variant_unref(actionList);
return mode;
}
-Req *RequestHandler::createReq(char *id, char *act_name, char *contents, int restriction)
+Action* RequestHandler::createAction(char *id, char *ruleName, char *contents, int restriction)
{
std::string pluginName;
- Req *req = actSchemaMgr->createAction(act_name);
- if (req == nullptr) {
- ERR("Req is null");
- throw ModesEx(ModesEx::PARSER_ERROR, "Req is null!");
+ Action *action = ruleMgr->createAction(ruleName);
+ if (action == nullptr) {
+ ERR("Action is null");
+ throw ModesEx(ModesEx::PARSER_ERROR, "Action is null!");
}
- std::string actionName = act_name;
+ std::string actionName = ruleName;
int pos = actionName.find_first_of(".");
pluginName = actionName.substr(0, pos);
- req->setPlugin(pluginMgr->getPlugin(pluginName));
+ action->setPlugin(pluginMgr->getPlugin(pluginName));
if (restriction)
- req->setRestrict(Req::REQ_LOCK);
+ action->setRestrict(Action::REQ_LOCK);
else
- req->setRestrict(Req::REQ_NONE);
+ action->setRestrict(Action::REQ_NONE);
- req->setID(id);
- req->setValue(contents);
- req->printInfo();
+ action->setID(id);
+ action->setValue(contents);
+ action->printInfo();
- return req;
+ return action;
}
#include "common/dbus.h"
#include "ModeManager.h"
#include "PluginManager.h"
-#include "ActionSchemaManager.h"
+#include "RuleManager.h"
MODES_NAMESPACE_BEGIN
GVariant *arg_modeData, gpointer userData);
static void setModeManager(ModeManager *mgr);
- static void setActionSchemaManager(ActionSchemaManager *mgr);
+ static void setRuleManager(RuleManager *mgr);
static void setPluginManager(PluginManager *mgr);
private:
static Mode getModefromData(GVariant *inData);
- static Req *createReq(char *id, char *act_name, char *contents, int restriction);
+ static Action* createAction(char *id, char *act_name, char *contents, int restriction);
static ModeManager *modeMgr;
- static ActionSchemaManager *actSchemaMgr;
+ static RuleManager *ruleMgr;
static PluginManager *pluginMgr;
};
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "RuleManager.h"
+
+#include <dirent.h>
+#include <cstring>
+#include "mdss.h"
+#include "TActionRule.h"
+#include "ModesEx.h"
+
+using std::string;
+MODES_NAMESPACE_USE;
+
+const xmlChar* const RuleManager::ACTION_RULE_TAG = (xmlChar*)"actionRule";
+const xmlChar* const RuleManager::ACTION_RULE_TAG_RULE = (xmlChar*)"rule";
+const xmlChar* const RuleManager::RULE_TAGS[] = {
+ (xmlChar*)"name",
+ (xmlChar*)"type",
+ (xmlChar*)"plugin",
+ (xmlChar*)"alias",
+ (xmlChar*)"conflict",
+ (xmlChar*)"defaultVal"
+};
+
+void RuleManager::makeRuleMap()
+{
+ if (ruleDir.empty()) {
+ ERR("No ruleDir");
+ ruleDir = MODES_ACTIONRULE_DEFAULT_DIR;
+ }
+
+ DIR *dir;
+ if ((dir = opendir(ruleDir.c_str())) == NULL)
+ ERR("opendir(%s) Fail(%s)", ruleDir.c_str(), strerror(errno));
+
+ struct dirent *entry;
+ while ((entry = readdir(dir)) != NULL) {
+ string file(entry->d_name);
+ size_t pos = file.find_last_of("_");
+ if (string::npos == pos
+ || file.compare(pos, sizeof(MODES_ACTIONRULE_FILE_SUFFIX) - 1, MODES_ACTIONRULE_FILE_SUFFIX)) {
+ continue;
+ }
+
+ string fileFullPath = ruleDir + "/" + string(entry->d_name);
+ try {
+ parseActionRule(fileFullPath);
+ DBG("Action Rule(size=%d) Load", ruleMap.size());
+ }
+ catch (ModesEx &e) {
+ ERR("parseActionRule(%s) Fail(%s)", fileFullPath.c_str(), e.what());
+ }
+ }
+ closedir(dir);
+}
+
+void RuleManager::freeRuleMap()
+{
+ for (auto it = ruleMap.begin(); it != ruleMap.end(); ++it)
+ delete it->second;
+}
+
+
+void RuleManager::parseElement(xmlNodePtr cur, ActionRule *actionRule)
+{
+ RET_IF(NULL == actionRule);
+
+ if (MDS_EQUAL == xmlStrcmp(cur->name, RULE_TAGS[TagElemAlias])) {
+ char *alias = (char*)xmlGetProp(cur, RULE_TAGS[TagAttName]);
+ if (NULL == alias) {
+ ERR("%s : No %s", RULE_TAGS[TagElemAlias], RULE_TAGS[TagAttName]);
+ return;
+ }
+
+ char *value = (char*)xmlNodeGetContent(cur);
+ if (NULL == value) {
+ ERR("%s(%s) : No value", RULE_TAGS[TagElemAlias], alias);
+ xmlFree(alias);
+ return;
+ }
+
+ actionRule->addAlias(alias, value);
+ xmlFree(value);
+ xmlFree(alias);
+ } else if (MDS_EQUAL == xmlStrcmp(cur->name, RULE_TAGS[TagElemDefValue])) {
+ char *value = (char*)xmlNodeGetContent(cur);
+ if (NULL == value) {
+ ERR("%s : No value", RULE_TAGS[TagElemDefValue]);
+ return;
+ }
+ actionRule->addDefaultValue(value);
+ } else if (MDS_EQUAL == xmlStrcmp(cur->name, RULE_TAGS[TagElemConflict])) {
+ // TODO: enhanced feature
+ DBG("TBD(%s)", cur->name);
+ } else {
+ DBG("Invalid node(%s)", cur->name);
+ }
+}
+
+Action* RuleManager::createAction(const string &ruleName)
+{
+ std::map<std::string, ActionRule*>::iterator it = ruleMap.find(ruleName);
+ if (ruleMap.end() != it) {
+ ActionRule *rule = it->second;
+ return rule->makeAction();
+ } else {
+ ERR("No rule(%s)", ruleName.c_str());
+ return nullptr;
+ }
+}
+
+void RuleManager::setOptions(const string &actionRuleDir, const string &actionRuleXsd)
+{
+ ruleDir = actionRuleDir;
+ ruleXsd = actionRuleXsd;
+}
+
+string RuleManager::getProp(xmlNodePtr node, int att)
+{
+ char *tmp;
+ string returnStr;
+
+ tmp = (char*)xmlGetProp(node, RULE_TAGS[att]);
+ if (tmp) {
+ returnStr = tmp;
+ xmlFree(tmp);
+ } else {
+ ERR("Rule : No %s", RULE_TAGS[att]);
+ throw ModesEx(ModesEx::NO_DATA);
+ }
+
+ return returnStr;
+}
+
+ActionRule* RuleManager::makeRule(xmlNodePtr node)
+{
+ string type, name, plugin;
+ ActionRule *actionRule = NULL;
+
+ try {
+ name = getProp(node, TagAttName);
+ type = getProp(node, TagAttType);
+ plugin = getProp(node, TagAttPlugin);
+ }
+ catch (ModesEx &e) {
+ ERR("getProp() Fail(%s)", e.what());
+ return nullptr;
+ }
+
+ DBG("Action(%s, %s) Added", name.c_str(), type.c_str());
+
+ if (MDS_EQUAL == type.compare("int"))
+ actionRule = new TActionRule<int>(name);
+ else if (MDS_EQUAL == type.compare("float"))
+ actionRule = new TActionRule<float>(name);
+ else if (MDS_EQUAL == type.compare("bool"))
+ actionRule = new TActionRule<bool>(name);
+ else
+ actionRule = new TActionRule<string>(name);
+
+ actionRule->setPlugin(plugin);
+ for (xmlNode *cur = node->children; cur; cur = cur->next) {
+ if (xmlIsBlankNode(cur))
+ continue;
+ parseElement(cur, actionRule);
+ }
+
+ return actionRule;
+}
+
+void RuleManager::parseRule(xmlNodePtr node)
+{
+ for (xmlNodePtr cur = node; cur; cur = cur->next) {
+ if (xmlIsBlankNode(cur))
+ continue;
+
+ if (MDS_EQUAL == xmlStrcmp(cur->name, ACTION_RULE_TAG_RULE)) {
+ ActionRule *rule = makeRule(cur);
+ ruleMap.insert(std::pair<string, ActionRule*>(rule->getName(), rule));
+ } else {
+ DBG("Invalid node(%s)", cur->name);
+ parseRule(cur->children);
+ }
+ }
+}
+
+void RuleManager::parseActionRule(const string &xmlFile)
+{
+ if (ruleXsd.empty()) {
+ ERR("No ruleXsd");
+ ruleXsd = MODES_ACTIONRULE_DEFAULT_XSD;
+ }
+
+ try {
+ XMLParser parser(xmlFile);
+ parser.validate(ruleXsd);
+
+ xmlNodePtr root = parser.getRoot();
+ if (MDS_EQUAL != xmlStrcmp(root->name, (xmlChar*)MODES_XML_ROOT)) {
+ ERR("Invalid root element(%s, %s)", root->name, xmlFile.c_str());
+ throw ModesEx(ModesEx::PARSER_ERROR, "Invalid file");
+ }
+
+ parseRule(root);
+ }
+ catch (ModesEx &e) {
+ ERR("parser Fail(%s)", e.what());
+ }
+}
#include <string>
#include <libxml/tree.h>
#include "mdss.h"
-#include "ActionSchema.h"
-#include "Req.h"
+#include "ActionRule.h"
+#include "Action.h"
#include "XMLParser.h"
MODES_NAMESPACE_BEGIN
-class ActionSchemaManager {
+class RuleManager {
public:
enum {
TagAttName,
TagMax
};
- void setOptions(const std::string &actionSchemaDir, const std::string &actionSchemaXsd);
- void makeActionSchemaMap();
- void freeActionSchemaMap();
- Req* createAction(const std::string &actionName);
+ void setOptions(const std::string &actionRuleDir, const std::string &actionRuleXsd);
+ void makeRuleMap();
+ void freeRuleMap();
+ Action* createAction(const std::string &actionName);
private:
- static const xmlChar* const ACTION_SCHEMA_TAG;
- static const xmlChar* const ACTION_SCHEMA_TAG_ACTION;
- static const xmlChar* const ACTION_TAGS[];
+ static const xmlChar* const ACTION_RULE_TAG;
+ static const xmlChar* const ACTION_RULE_TAG_RULE;
+ static const xmlChar* const RULE_TAGS[];
- ActionSchema* makeActionSchema(xmlNodePtr node);
- void parseAction(xmlNodePtr node);
+ ActionRule* makeRule(xmlNodePtr node);
+ void parseRule(xmlNodePtr node);
std::string getProp(xmlNodePtr node, int att);
- void parseActionSchema(const std::string &xmlFile);
- void parseElement(xmlNodePtr node, ActionSchema *actionSchema);
+ void parseActionRule(const std::string &xmlFile);
+ void parseElement(xmlNodePtr node, ActionRule *actionRule);
- std::map<std::string, ActionSchema*> schemaMap;
- std::string actSchemaDir;
- std::string actSchemaXsd;
+ std::map<std::string, ActionRule*> ruleMap;
+ std::string ruleDir;
+ std::string ruleXsd;
};
MODES_NAMESPACE_END
MODES_NAMESPACE_USE;
ModeSupervisorNamespace::Supervisor::Supervisor()
- :modeMgr(actSchemaMgr, pluginMgr)
+ :modeMgr(ruleMgr, pluginMgr)
{
}
void Supervisor::init()
{
RequestHandler::setModeManager(&modeMgr);
- RequestHandler::setActionSchemaManager(&actSchemaMgr);
+ RequestHandler::setRuleManager(&ruleMgr);
RequestHandler::setPluginManager(&pluginMgr);
try {
clientConn.startDbus();
- actSchemaMgr.makeActionSchemaMap();
+ ruleMgr.makeRuleMap();
pluginMgr.loadPlugins();
modeMgr.init();
}
void Supervisor::deInit()
{
pluginMgr.unloadPlugins();
- actSchemaMgr.freeActionSchemaMap();
+ ruleMgr.freeRuleMap();
clientConn.stopDbus();
RequestHandler::setModeManager(NULL);
- RequestHandler::setActionSchemaManager(NULL);
+ RequestHandler::setRuleManager(NULL);
RequestHandler::setPluginManager(NULL);
}
{
modeMgr.setOptions(config.modeXMLDirs, config.modeXsdFile);
pluginMgr.setPluginDir(config.pluginDir);
- actSchemaMgr.setOptions(config.actionSchemaDir, config.actionSchemaXsdFile);
+ ruleMgr.setOptions(config.actionRuleDir, config.actionRuleXsdFile);
}
void Supervisor::registerHandler()
#include "ModesConfig.h"
#include "PluginManager.h"
#include "ClientConnection.h"
-#include "ActionSchemaManager.h"
+#include "RuleManager.h"
MODES_NAMESPACE_BEGIN
void registerHandler();
private:
ClientConnection clientConn;
- ActionSchemaManager actSchemaMgr;
+ RuleManager ruleMgr;
PluginManager pluginMgr;
ModeManager modeMgr;
};
#include <string>
#include <sstream>
#include "mdss.h"
-#include "Req.h"
+#include "Action.h"
MODES_NAMESPACE_BEGIN
template <typename T>
-class TReq : public Req {
+class TAction : public Action {
public:
- TReq(const std::string &name)
- :Req(name)
+ TAction(const std::string &name)
+ :Action(name)
{
}
void apply() override
{
- int pos = actionName.find_first_of(".");
+ int pos = ruleName.find_first_of(".");
if (plugin) {
- plugin->set(actionName.substr(pos + 1), value);
+ plugin->set(ruleName.substr(pos + 1), value);
} else {
- ERR("Action(%s) : No plugin", actionName.c_str());
+ ERR("Action(%s) : No plugin", ruleName.c_str());
}
}
private:
#include <string>
#include <sstream>
#include "mdss.h"
-#include "TReq.h"
-#include "ActionSchema.h"
+#include "TAction.h"
+#include "ActionRule.h"
MODES_NAMESPACE_BEGIN
template <typename T>
-class TActionSchema : public ActionSchema {
+class TActionRule : public ActionRule {
public:
- TActionSchema(const std::string &name)
+ TActionRule(const std::string &name)
{
- actionName = name;
+ ruleName = name;
}
- Req* makeRequirement() override
+ Action* makeAction() override
{
- TReq<T> *req = new TReq<T>(actionName);
- req->setValueAliases(valueAliasList);
+ TAction<T> *action = new TAction<T>(ruleName);
+ action->setValueAliases(valueAliasList);
- return req;
+ return action;
}
void addDefaultValue(const std::string &val) override
*/
#include <libxml/tree.h>
#include <libxml/xmlschemas.h>
-#include "Req.h"
+#include "Action.h"
#include "ModeTag.h"
#include "ModesEx.h"
#include "XMLGenerator.h"
xmlSetProp(modeNode, ModeTag::CUSTOM, (xmlChar*)((mode.getCustomized())? "yes": "no"));
xmlAddChild(rootNode, modeNode);
- std::list<std::shared_ptr<Req>> reqList = mode.getReqList();
- std::list<std::shared_ptr<Req>>::iterator it;
- for (it = reqList.begin(); it != reqList.end(); it++) {
+ std::list<std::shared_ptr<Action>> actionList = mode.getActionList();
+ std::list<std::shared_ptr<Action>>::iterator it;
+ for (it = actionList.begin(); it != actionList.end(); it++) {
xmlNodePtr reqNode;
- Req::ReqRestrict restriction = (*it)->getRestrict();
+ Action::ActionRestrict restriction = (*it)->getRestrict();
- reqNode = xmlNewNode(NULL, ModeTag::REQ);
+ reqNode = xmlNewNode(NULL, ModeTag::ACTION);
if (!(*it)->getID().empty())
xmlSetProp(reqNode, ModeTag::ID, (xmlChar*)(*it)->getID().c_str());
- xmlSetProp(reqNode, ModeTag::ACTION, (xmlChar*)(*it)->getName().c_str());
+ xmlSetProp(reqNode, ModeTag::RULE, (xmlChar*)(*it)->getRuleName().c_str());
- if (restriction == Req::ReqRestrict::REQ_LOCK)
+ if (restriction == Action::ActionRestrict::REQ_LOCK)
xmlSetProp(reqNode, ModeTag::RESTICT, (xmlChar*)ModeTag::RESTICT_LOCK);
xmlNodeSetContent(reqNode, (xmlChar*)(*it)->getStringOfValue().c_str());
${SUPERVISOR_DIR}/XMLGenerator.cpp
${SUPERVISOR_DIR}/ModeManager.cpp
${SUPERVISOR_DIR}/ModeXMLParser.cpp
- ${SUPERVISOR_DIR}/Req.cpp
- ${SUPERVISOR_DIR}/ActionSchema.cpp
- ${SUPERVISOR_DIR}/ActionSchemaManager.cpp
+ ${SUPERVISOR_DIR}/Action.cpp
+ ${SUPERVISOR_DIR}/ActionRule.cpp
+ ${SUPERVISOR_DIR}/RuleManager.cpp
${SUPERVISOR_DIR}/Mode.cpp
${SUPERVISOR_DIR}/ModesEx.cpp
${SUPERVISOR_DIR}/PluginManager.cpp
FILE(GLOB GTEST_PARSER_SRCS
${SUPERVISOR_DIR}/XMLParser.cpp
${SUPERVISOR_DIR}/PluginManager.cpp
- ${SUPERVISOR_DIR}/Req.cpp
- ${SUPERVISOR_DIR}/ActionSchema.cpp
- ${SUPERVISOR_DIR}/ActionSchemaManager.cpp
+ ${SUPERVISOR_DIR}/Action.cpp
+ ${SUPERVISOR_DIR}/ActionRule.cpp
+ ${SUPERVISOR_DIR}/RuleManager.cpp
${SUPERVISOR_DIR}/ModeXMLParser.cpp
${SUPERVISOR_DIR}/ModesEx.cpp
- ${SUPERVISOR_DIR}/Action.cpp
${SUPERVISOR_DIR}/Mode.cpp
${SUPERVISOR_DIR}/ModeTag.cpp
"modes_test_parser.cpp"
${SUPERVISOR_DIR}/ModeTag.cpp
${SUPERVISOR_DIR}/XMLParser.cpp
${SUPERVISOR_DIR}/PluginManager.cpp
- ${SUPERVISOR_DIR}/Req.cpp
- ${SUPERVISOR_DIR}/ActionSchema.cpp
- ${SUPERVISOR_DIR}/ActionSchemaManager.cpp
+ ${SUPERVISOR_DIR}/Action.cpp
+ ${SUPERVISOR_DIR}/ActionRule.cpp
+ ${SUPERVISOR_DIR}/RuleManager.cpp
${SUPERVISOR_DIR}/ModeXMLParser.cpp
${SUPERVISOR_DIR}/ModesEx.cpp
- ${SUPERVISOR_DIR}/Action.cpp
${SUPERVISOR_DIR}/Mode.cpp
${SUPERVISOR_DIR}/XMLGenerator.cpp
"modes_test_generator.cpp"
$WORKING_DIR/modes-gtest-generator
else
cp $DATA_DIR/mode/*_mode.xml $WORKING_DIR
- cp $DATA_DIR/action/*_schema.xml $WORKING_DIR
+ cp $DATA_DIR/rule/*_rule.xml $WORKING_DIR
cp $DATA_DIR/xsd/*.xsd $WORKING_DIR
mkdir -p $WORKING_DIR/extra
sed s/ex1/ex3/g $WORKING_DIR/tizen_ex1_mode.xml > $WORKING_DIR/extra/tizen_ex3_mode.xml
#include "supervisor/ModesEx.h"
#include "supervisor/ModeXMLParser.h"
#include "supervisor/XMLGenerator.h"
-#include "supervisor/ActionSchemaManager.h"
+#include "supervisor/RuleManager.h"
MODES_NAMESPACE_USE;
using namespace std;
TEST(XMLGenerator, makeModeXML)
{
PluginManager pluginManager;
- ActionSchemaManager schemaMgr;
+ RuleManager ruleMgr;
- ModeXMLParser modeparser("tizen_ex1_mode.xml", schemaMgr, pluginManager);
+ ModeXMLParser modeparser("tizen_ex1_mode.xml", ruleMgr, pluginManager);
Mode mode = modeparser.getMode();
try {
FAIL();
}
- ModeXMLParser genmodeparser("tizen_gen_ex1_mode.xml", schemaMgr, pluginManager);
+ ModeXMLParser genmodeparser("tizen_gen_ex1_mode.xml", ruleMgr, pluginManager);
Mode genMode = genmodeparser.getMode();
EXPECT_EQ("ex1", genmodeparser.getModeName());
- std::list<std::shared_ptr<Req>> reqList = mode.getReqList();
- EXPECT_FALSE(reqList.empty());
+ std::list<std::shared_ptr<Action>> actionList = mode.getActionList();
+ EXPECT_FALSE(actionList.empty());
- for (std::list<std::shared_ptr<Req>>::iterator it = reqList.begin(); it != reqList.end(); ++it) {
- cout << "* Req : " << (*it)->getName() << endl;
+ for (std::list<std::shared_ptr<Action>>::iterator it = actionList.begin(); it != actionList.end(); ++it) {
+ cout << "* Action : " << (*it)->getRuleName() << endl;
cout << "\t\t- Restrict : " << (*it)->getRestrict() << endl;
cout << "\t\t- Content : " << (*it)->getStringOfValue() << endl;
}
{
EXPECT_THROW({
PluginManager pluginManager;
- ActionSchemaManager schemaMgr;
+ RuleManager ruleMgr;
- ModeXMLParser modeparser("tizen_ex1_mode.xml", schemaMgr, pluginManager);
+ ModeXMLParser modeparser("tizen_ex1_mode.xml", ruleMgr, pluginManager);
Mode mode = modeparser.getMode();
XMLGenerator xmlGenerator;
class ModeManagerTest {
public:
ModeManagerTest();
- ActionSchemaManager asMgr;
- PluginManager piMgr;
+ RuleManager rMgr;
+ PluginManager pMgr;
ModeManager mdMgr;
set<string> getDirectories();
MODES_NAMESPACE_USE;
ModeManagerTest::ModeManagerTest()
- :mdMgr(asMgr, piMgr)
+ :mdMgr(rMgr, pMgr)
{
std::set<std::string> modeDirs;
modeDirs.insert(".");
#include <gtest/gtest.h>
#include "supervisor/Mode.h"
#include "supervisor/ModeXMLParser.h"
-#include "supervisor/ActionSchemaManager.h"
+#include "supervisor/RuleManager.h"
MODES_NAMESPACE_USE;
using namespace std;
class TestParser {
public:
void parserTest(const string &fileName);
- list<std::shared_ptr<Req>> getActionList(Mode& m);
+ list<std::shared_ptr<Action>> getActionList(Mode& m);
private:
};
MODES_NAMESPACE_END
-list<std::shared_ptr<Req>> TestParser::getActionList(Mode& m)
+list<std::shared_ptr<Action>> TestParser::getActionList(Mode& m)
{
- return m.reqList;
+ return m.actionList;
}
TEST(XMLParser, getModeName)
{
PluginManager pluginManager;
- ActionSchemaManager schemaMgr;
- ModeXMLParser modeparser("tizen_ex1_mode.xml", schemaMgr, pluginManager);
+ RuleManager ruleMgr;
+ ModeXMLParser modeparser("tizen_ex1_mode.xml", ruleMgr, pluginManager);
string modename = modeparser.getModeName();
EXPECT_EQ("ex1", modeparser.getModeName());
TEST(XMLParser, getMode)
{
PluginManager pluginManager;
- ActionSchemaManager schemaMgr;
- ModeXMLParser modeparser("tizen_ex2_mode.xml", schemaMgr, pluginManager);
+ RuleManager ruleMgr;
+ ModeXMLParser modeparser("tizen_ex2_mode.xml", ruleMgr, pluginManager);
Mode mode = modeparser.getMode();
//EXPECT_TRUE(mode.empty());
TEST(Mode, getModeName)
{
PluginManager pluginManager;
- ActionSchemaManager schemaMgr;
- ModeXMLParser modeparser("tizen_ex2_mode.xml", schemaMgr, pluginManager);
+ RuleManager ruleMgr;
+ ModeXMLParser modeparser("tizen_ex2_mode.xml", ruleMgr, pluginManager);
Mode mode = modeparser.getMode();
EXPECT_EQ("ex2", mode.getName());
}
TEST(Mode, getModeType)
{
PluginManager pluginManager;
- ActionSchemaManager schemaMgr;
- ModeXMLParser modeparser("tizen_ex1_mode.xml", schemaMgr, pluginManager);
+ RuleManager ruleMgr;
+ ModeXMLParser modeparser("tizen_ex1_mode.xml", ruleMgr, pluginManager);
Mode mode = modeparser.getMode();
EXPECT_EQ("normal", mode.getModeType());
}
TEST(Mode, printAction)
{
PluginManager pluginManager;
- ActionSchemaManager schemaMgr;
- ModeXMLParser modeparser("tizen_ex1_mode.xml", schemaMgr, pluginManager);
+ RuleManager ruleMgr;
+ ModeXMLParser modeparser("tizen_ex1_mode.xml", ruleMgr, pluginManager);
Mode mode = modeparser.getMode();
TestParser parserT;
- list<std::shared_ptr<Req>> reqList = parserT.getActionList(mode);
- EXPECT_FALSE(reqList.empty());
+ list<std::shared_ptr<Action>> actionList = parserT.getActionList(mode);
+ EXPECT_FALSE(actionList.empty());
- for (list<std::shared_ptr<Req>>::iterator it = reqList.begin(); it != reqList.end(); ++it) {
- cout << "* Req : " << (*it)->getName() << endl;
+ for (list<std::shared_ptr<Action>>::iterator it = actionList.begin(); it != actionList.end(); ++it) {
+ cout << "* Action : " << (*it)->getRuleName() << endl;
cout << "\t\t- Restrict : " << (*it)->getRestrict() << endl;
//cout << "\t\t- Content : " << (*it)->getValue() << endl;
}
bool emptyPluginMap();
string getpluginDir();
- PluginManager piMgr;
+ PluginManager pMgr;
};
MODES_NAMESPACE_END
bool TestPluginBroker::emptyPluginMap()
{
- return piMgr.pluginMap.empty();
+ return pMgr.pluginMap.empty();
}
string TestPluginBroker::getpluginDir()
{
- return piMgr.pluginDir;
+ return pMgr.pluginDir;
}
TEST(PluginManager, readLibraryList)
{
TestPluginBroker broker;
- broker.piMgr.setPluginDir(MODES_PLUGIN_DEFAULT_DIR);
+ broker.pMgr.setPluginDir(MODES_PLUGIN_DEFAULT_DIR);
try {
- broker.piMgr.loadPlugins();
+ broker.pMgr.loadPlugins();
}
catch (ModesEx &e) {
- broker.piMgr.setPluginDir("../plugin");
- EXPECT_NO_THROW(broker.piMgr.loadPlugins());
+ broker.pMgr.setPluginDir("../plugin");
+ EXPECT_NO_THROW(broker.pMgr.loadPlugins());
}
EXPECT_FALSE(broker.emptyPluginMap());
- list<string> pluginList = broker.piMgr.getPluginList();
+ list<string> pluginList = broker.pMgr.getPluginList();
if (pluginList.empty()) {
FAIL() << "getPluginList() Fail:This should never be reached";
} else {
TestPluginBroker broker;
string path = "../plugin";
- broker.piMgr.setPluginDir(path);
+ broker.pMgr.setPluginDir(path);
EXPECT_EQ(path, broker.getpluginDir());
}
{
TestPluginBroker broker;
- int ret = broker.piMgr.unloadPlugins();
+ int ret = broker.pMgr.unloadPlugins();
EXPECT_EQ(ret, MODES_ERROR_NONE);
EXPECT_TRUE(broker.emptyPluginMap());
}
int ret;
TestPluginBroker broker;
- broker.piMgr.setPluginDir(MODES_PLUGIN_DEFAULT_DIR);
+ broker.pMgr.setPluginDir(MODES_PLUGIN_DEFAULT_DIR);
try {
- broker.piMgr.loadPlugins();
+ broker.pMgr.loadPlugins();
}
catch (ModesEx &e) {
- broker.piMgr.setPluginDir("../plugin");
- EXPECT_NO_THROW(broker.piMgr.loadPlugins());
+ broker.pMgr.setPluginDir("../plugin");
+ EXPECT_NO_THROW(broker.pMgr.loadPlugins());
}
EXPECT_FALSE(broker.emptyPluginMap());
- Plugin *plugin = broker.piMgr.getPlugin("test");
+ Plugin *plugin = broker.pMgr.getPlugin("test");
ASSERT_TRUE(plugin != NULL);
ret = plugin->set("testSetInt", 0);
string strVal = plugin->getString("testGetString");
EXPECT_EQ(strVal, "test");
- ret = broker.piMgr.unloadPlugins();
+ ret = broker.pMgr.unloadPlugins();
EXPECT_EQ(ret, MODES_ERROR_NONE);
EXPECT_TRUE(broker.emptyPluginMap());
}
int ret;
TestPluginBroker broker;
- broker.piMgr.setPluginDir(MODES_PLUGIN_DEFAULT_DIR);
+ broker.pMgr.setPluginDir(MODES_PLUGIN_DEFAULT_DIR);
try {
- broker.piMgr.loadPlugins();
+ broker.pMgr.loadPlugins();
}
catch (ModesEx &e) {
- broker.piMgr.setPluginDir("../plugin");
- EXPECT_NO_THROW(broker.piMgr.loadPlugins());
+ broker.pMgr.setPluginDir("../plugin");
+ EXPECT_NO_THROW(broker.pMgr.loadPlugins());
- ret = broker.piMgr.unloadPlugins();
+ ret = broker.pMgr.unloadPlugins();
EXPECT_EQ(ret, MODES_ERROR_NONE);
return;
}
EXPECT_FALSE(broker.emptyPluginMap());
- Plugin *plugin = broker.piMgr.getPlugin("wifi");
+ Plugin *plugin = broker.pMgr.getPlugin("wifi");
ASSERT_TRUE(plugin != NULL);
ret = plugin->set("power", false);
ret = plugin->set("abcdefg", true);
EXPECT_EQ(ret, MODES_ERROR_INVALID_PARAMETER);
- ret = broker.piMgr.unloadPlugins();
+ ret = broker.pMgr.unloadPlugins();
EXPECT_EQ(ret, MODES_ERROR_NONE);
EXPECT_TRUE(broker.emptyPluginMap());
}
int ret;
TestPluginBroker broker;
- broker.piMgr.setPluginDir(MODES_PLUGIN_DEFAULT_DIR);
+ broker.pMgr.setPluginDir(MODES_PLUGIN_DEFAULT_DIR);
try {
- broker.piMgr.loadPlugins();
+ broker.pMgr.loadPlugins();
}
catch (ModesEx &e) {
- broker.piMgr.setPluginDir("../plugin");
- EXPECT_NO_THROW(broker.piMgr.loadPlugins());
+ broker.pMgr.setPluginDir("../plugin");
+ EXPECT_NO_THROW(broker.pMgr.loadPlugins());
- ret = broker.piMgr.unloadPlugins();
+ ret = broker.pMgr.unloadPlugins();
EXPECT_EQ(ret, MODES_ERROR_NONE);
return;
}
bool boolRet;
- Plugin *plugin = broker.piMgr.getPlugin("vconf");
+ Plugin *plugin = broker.pMgr.getPlugin("vconf");
ASSERT_TRUE(plugin != NULL);
ret = plugin->set("db/setting/auto_display_adjustment", true);
ret = plugin->getInt("db/setting/lcd_backlight_normal");
EXPECT_EQ(ret, 11);
- ret = broker.piMgr.unloadPlugins();
+ ret = broker.pMgr.unloadPlugins();
EXPECT_EQ(ret, MODES_ERROR_NONE);
EXPECT_TRUE(broker.emptyPluginMap());
}
int ret;
TestPluginBroker broker;
- broker.piMgr.setPluginDir(MODES_PLUGIN_DEFAULT_DIR);
+ broker.pMgr.setPluginDir(MODES_PLUGIN_DEFAULT_DIR);
try {
- broker.piMgr.loadPlugins();
+ broker.pMgr.loadPlugins();
}
catch (ModesEx &e) {
- broker.piMgr.setPluginDir("../plugin");
- EXPECT_NO_THROW(broker.piMgr.loadPlugins());
+ broker.pMgr.setPluginDir("../plugin");
+ EXPECT_NO_THROW(broker.pMgr.loadPlugins());
- ret = broker.piMgr.unloadPlugins();
+ ret = broker.pMgr.unloadPlugins();
EXPECT_EQ(ret, MODES_ERROR_NONE);
return;
}
EXPECT_FALSE(broker.emptyPluginMap());
- Plugin *plugin = broker.piMgr.getPlugin("bluetooth");
+ Plugin *plugin = broker.pMgr.getPlugin("bluetooth");
ASSERT_TRUE(plugin != NULL);
ret = plugin->set("power", false);
ret = plugin->set("abcdefg", true);
EXPECT_EQ(ret, MODES_ERROR_INVALID_PARAMETER);
- ret = broker.piMgr.unloadPlugins();
+ ret = broker.pMgr.unloadPlugins();
EXPECT_EQ(ret, MODES_ERROR_NONE);
EXPECT_TRUE(broker.emptyPluginMap());
}