apply life option in Rule
authorYoungjae Shin <yj99.shin@samsung.com>
Tue, 31 Mar 2020 03:36:54 +0000 (12:36 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Thu, 2 Apr 2020 04:34:15 +0000 (13:34 +0900)
schema/tizen_action_rule.xsd
supervisor/Action.cpp
supervisor/Action.h
supervisor/ActionRule.cpp
supervisor/ActionRule.h
supervisor/RuleManager.cpp
supervisor/RuleManager.h
supervisor/TActionRule.h
supervisor/XMLGenerator.cpp

index 71defcfbaeb192aa5887cdccc58a7668e9f8be93..2f2158734e6a9e192b1a0ceb9d758be22176bfa4 100644 (file)
                   <xs:attribute name="type" type="o:basicTypeT" use="required" />
                   <xs:attribute name="since" type="o:versionT" use="required" />
                   <xs:attribute name="plugin" type="xs:string" use="optional" />
+                  <xs:attribute name="life" use="optional">
+                    <xs:simpleType>
+                      <xs:restriction base="xs:string">
+                        <xs:enumeration value="permanent"/>
+                        <xs:enumeration value="volatile"/>
+                      </xs:restriction>
+                    </xs:simpleType>
+                  </xs:attribute>
                 </xs:complexType>
               </xs:element>
             </xs:sequence>
index fa6c00961f8536e68d973789c7de59128e9cc2dd..3581f4b5fdb24819a752fdd05fe5a0374c512855 100644 (file)
@@ -87,6 +87,16 @@ Action::ActionType Action::getType()
        return type;
 }
 
+void Action::setLife(ActionRuleLife val)
+{
+       life = val;
+}
+
+Action::ActionRuleLife Action::getLife()
+{
+       return life;
+}
+
 Action::ActionRestrict Action::getRestrict()
 {
        return restriction;
index 480d9b08952e9f30c2971b5ad86654474fb6549a..fd79812b94dc70f164f57f65f20241bfcf92f1d0 100644 (file)
@@ -37,6 +37,11 @@ public:
                ASYNC
        } ActionType;
 
+       typedef enum {
+               PERMANENT,
+               VOLATILE
+       } ActionRuleLife;
+
        Action();
        Action(const std::string &ruleName);
        virtual ~Action();
@@ -54,6 +59,8 @@ public:
        bool getStopOnErr();
        void setType(ActionType val);
        ActionType getType();
+       void setLife(ActionRuleLife val);
+       ActionRuleLife getLife();
        void setPlugin(Plugin *pi);
        void setPrivilege(const std::string &val);
        std::string getPrivilege();
@@ -71,6 +78,7 @@ protected:
        std::string ruleName;
        bool isChanged;
        ActionType type;
+       ActionRuleLife life;
        Plugin *plugin;
        PluginAction *piAction;
 private:
index cc40766dbfc3cc5869f56f17f1d441aee22f032a..f16ce16ccba6c6b9a1f957a022a986f2af65434d 100644 (file)
 
 MODES_NAMESPACE_USE;
 
+ActionRule::ActionRule()
+       : plugin(nullptr), life(Action::PERMANENT)
+{
+}
+
 std::string ActionRule::getName()
 {
        return ruleName;
@@ -39,3 +44,8 @@ void ActionRule::setPrivilege(const std::string &priv)
 {
        privilege = priv;
 }
+
+void ActionRule::setLife(Action::ActionRuleLife val)
+{
+       life = val;
+}
index 68af6635738ce488880b4936c9763bc1d7c07cbc..17528a74d66919a8735e2c7b2d1ca003cd557eab 100644 (file)
@@ -23,18 +23,21 @@ MODES_NAMESPACE_BEGIN
 
 class ActionRule {
 public:
+       ActionRule();
        virtual ~ActionRule() = default;
 
        std::string getName();
        Plugin* getPlugin();
        void setPlugin(Plugin *pi);
        void setPrivilege(const std::string &priv);
+       void setLife(Action::ActionRuleLife val);
        virtual Action* makeAction() = 0;
        virtual int addAlias(const std::string &alias, const std::string &value) = 0;
 protected:
        std::string ruleName;
        std::string privilege;
        Plugin *plugin;
+       Action::ActionRuleLife life;
 private:
        // TODO:: handle conflict List, since, description, version
        //std::list<std::string> conflictActionList;
index 62053da058cf146242148d3635c71cd3d55e2cce..1a4faecdb53083a2717ac69b23be4cb20daec593 100644 (file)
@@ -30,6 +30,7 @@ const xmlChar* const RuleManager::RULE_TAGS[] = {
        (xmlChar*)"name",
        (xmlChar*)"type",
        (xmlChar*)"plugin",
+       (xmlChar*)"life",
        (xmlChar*)"alias",
        (xmlChar*)"conflict",
        (xmlChar*)"privilege",
@@ -157,11 +158,14 @@ ActionRule* RuleManager::makeRule(xmlNodePtr node)
 {
        string type, name, pluginName;
        ActionRule *actionRule = NULL;
+       Action::ActionRuleLife life = Action::PERMANENT;
 
        try {
                name = XMLParser::extractValueOfTag(node, RULE_TAGS[TagAttName]);
                type = XMLParser::extractValueOfTag(node, RULE_TAGS[TagAttType]);
                pluginName = XMLParser::extractValueOfTag(node, RULE_TAGS[TagAttPlugin]);
+               if (XMLParser::extractValueOfTag(node, RULE_TAGS[TagAttLife]) == "")
+                       life = Action::VOLATILE;
        } catch (ModesEx &e) {
                ERR("extractValueOfTag() Fail(%s)", e.what());
                throw;
@@ -188,6 +192,7 @@ ActionRule* RuleManager::makeRule(xmlNodePtr node)
        }
 
        actionRule->setPlugin(plugin);
+       actionRule->setLife(life);
        for (xmlNode *cur = node->children; cur; cur = cur->next) {
                if (xmlIsBlankNode(cur))
                        continue;
index 7b210c092b346bd07381ea55dbb529b27f6a7918..0eb5e5dfc5136ba57ddf66ca7bdf2bb3f45ca4f8 100644 (file)
@@ -32,6 +32,7 @@ public:
                TagAttName,
                TagAttType,
                TagAttPlugin,
+               TagAttLife,
                TagElemAlias,
                TagElemConflict,
                TagElemPrivilege,
index f59c57dcf6f088dd4838e3e20f5315b74a8e2a2c..8be927f0cbd7680f7a805bcce73b3990d6e6f25a 100644 (file)
@@ -39,6 +39,7 @@ public:
                action->setValueAliases(valueAliasList);
                action->setPrivilege(privilege);
                action->setPlugin(plugin);
+               action->setLife(life);
 
                return action;
        }
index 9d7ae97d48e2609528554552caf82eaacef372f4..d4e2298acc3a6906655aa4439bd6939ab9e25b8c 100644 (file)
@@ -128,7 +128,7 @@ void XMLGenerator::makeUndoInfoXML(const std::string &filename, const Mode &mode
 
        std::list<std::shared_ptr<Action>> actionList = mode.getActionList();
        for (auto it = actionList.begin(); it != actionList.end(); it++) {
-               if ((*it)->backupUndoInfo().empty())
+               if ((*it)->getLife() == Action::VOLATILE || (*it)->backupUndoInfo().empty())
                        continue;
 
                xmlNodePtr infoNode = xmlNewNode(NULL, ModesXMLTag::INFO);