From: JinWang An Date: Fri, 20 Sep 2019 05:57:28 +0000 (+0900) Subject: Add action after undo mode. X-Git-Tag: submit/tizen/20200319.043412~54 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ca0e3426271ae7d93460e6332d0a65fbdccce25a;p=platform%2Fcore%2Fsystem%2Fmodes.git Add action after undo mode. --- diff --git a/example/mode/tizen_btAudioConnect_mode.xml b/example/mode/tizen_btAudioConnect_mode.xml index 9740431..d45e639 100644 --- a/example/mode/tizen_btAudioConnect_mode.xml +++ b/example/mode/tizen_btAudioConnect_mode.xml @@ -1,5 +1,5 @@ - + on 08:AE:D6:5E:AE:16 diff --git a/example/mode/tizen_btOff_mode.xml b/example/mode/tizen_btOff_mode.xml index fcb1c3f..0c29375 100644 --- a/example/mode/tizen_btOff_mode.xml +++ b/example/mode/tizen_btOff_mode.xml @@ -1,5 +1,5 @@ - + off diff --git a/example/mode/tizen_btOn_mode.xml b/example/mode/tizen_btOn_mode.xml index e1cf681..14ee9e2 100644 --- a/example/mode/tizen_btOn_mode.xml +++ b/example/mode/tizen_btOn_mode.xml @@ -1,5 +1,5 @@ - + on diff --git a/example/mode/tizen_conflict1_mode.xml b/example/mode/tizen_conflict1_mode.xml index 12a81ea..5da4429 100644 --- a/example/mode/tizen_conflict1_mode.xml +++ b/example/mode/tizen_conflict1_mode.xml @@ -1,5 +1,5 @@ - + 1 diff --git a/example/mode/tizen_conflict2_mode.xml b/example/mode/tizen_conflict2_mode.xml index 08b96bb..cb14161 100644 --- a/example/mode/tizen_conflict2_mode.xml +++ b/example/mode/tizen_conflict2_mode.xml @@ -1,5 +1,5 @@ - + 2 diff --git a/example/mode/tizen_conflict3_mode.xml b/example/mode/tizen_conflict3_mode.xml index 0bf3066..43cb35b 100644 --- a/example/mode/tizen_conflict3_mode.xml +++ b/example/mode/tizen_conflict3_mode.xml @@ -1,5 +1,5 @@ - + true diff --git a/example/mode/tizen_ex1_mode.xml b/example/mode/tizen_ex1_mode.xml index c906889..43ee7c1 100644 --- a/example/mode/tizen_ex1_mode.xml +++ b/example/mode/tizen_ex1_mode.xml @@ -1,5 +1,5 @@ - + on on diff --git a/example/mode/tizen_ex2_mode.xml b/example/mode/tizen_ex2_mode.xml index 6056c62..5f2277b 100644 --- a/example/mode/tizen_ex2_mode.xml +++ b/example/mode/tizen_ex2_mode.xml @@ -1,5 +1,5 @@ - + SETTING_PSMODE_WEARABLE off diff --git a/example/mode/tizen_powerSave_mode.xml b/example/mode/tizen_powerSave_mode.xml index 423488b..5ece2f8 100644 --- a/example/mode/tizen_powerSave_mode.xml +++ b/example/mode/tizen_powerSave_mode.xml @@ -1,5 +1,5 @@ - + SETTING_PSMODE_WEARABLE_ENHANCED VCONFKEY_BT_STATUS_OFF diff --git a/example/mode/tizen_waterlock_mode.xml b/example/mode/tizen_waterlock_mode.xml new file mode 100644 index 0000000..f4bac82 --- /dev/null +++ b/example/mode/tizen_waterlock_mode.xml @@ -0,0 +1,10 @@ + + + + off + off + SETTING_PSMODE_WEARABLE_ENHANCED + SETTING_PSMODE_WEARABLE + /opt/usr/data/settings/Alarms/Alarms_on_call.ogg + + diff --git a/example/mode/tizen_wifiOn_mode.xml b/example/mode/tizen_wifiOn_mode.xml index 0856629..0491aad 100644 --- a/example/mode/tizen_wifiOn_mode.xml +++ b/example/mode/tizen_wifiOn_mode.xml @@ -1,5 +1,5 @@ - + on diff --git a/example/rule/tizen_ex_rule.xml b/example/rule/tizen_ex_rule.xml index 8bea028..dfebdb7 100644 --- a/example/rule/tizen_ex_rule.xml +++ b/example/rule/tizen_ex_rule.xml @@ -1,30 +1,30 @@ - + - + sensord.exactness Sensor Accuracy System - + sensord.changeAccuracy Sensor Exactness System - + browser Web Framework - + display.autoLight It makes the screen color warmer. System - + It prints integerv value System - + It prints boolean value System diff --git a/example/rule/tizen_ex_rule_fail.xml b/example/rule/tizen_ex_rule_fail.xml index d48b25c..9d64a56 100644 --- a/example/rule/tizen_ex_rule_fail.xml +++ b/example/rule/tizen_ex_rule_fail.xml @@ -1,30 +1,30 @@ - + - + sensord.exactness Sensor Accuracy System - + sensord.changeAccuracy Sensor Exactness System - + browser Web Framework - + display.autoLight It makes the screen color warmer. System - + It prints integerv value System - + It prints boolean value System diff --git a/schema/tizen_mode.xsd b/schema/tizen_mode.xsd index e8be4b8..528e93d 100644 --- a/schema/tizen_mode.xsd +++ b/schema/tizen_mode.xsd @@ -10,22 +10,14 @@ - - - - - - - - - - - - - - - - + + + + + + + + @@ -54,6 +46,26 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/supervisor/Mode.cpp b/supervisor/Mode.cpp index 84b9d8c..875782a 100644 --- a/supervisor/Mode.cpp +++ b/supervisor/Mode.cpp @@ -33,6 +33,11 @@ void Mode::addAction(Action *action) actionList.push_back(std::shared_ptr(action)); } +void Mode::addUndo(Action *action) +{ + undoList.push_back(std::shared_ptr(action)); +} + void Mode::setName(const std::string &data) { name = data; @@ -115,9 +120,17 @@ void Mode::undo() std::list>::iterator it; for (it = actionList.begin(); it != actionList.end(); it++) (*it)->undo(); + + for (it = undoList.begin(); it != undoList.end(); it++) + (*it)->applyOneShot(); } std::list> Mode::getActionList() const { return actionList; } + +std::list> Mode::getUndoList() const +{ + return undoList; +} diff --git a/supervisor/Mode.h b/supervisor/Mode.h index be93091..104df15 100644 --- a/supervisor/Mode.h +++ b/supervisor/Mode.h @@ -45,6 +45,10 @@ public: void addAction(Action *action); std::list> getActionList() const; + + void addUndo(Action *action); + std::list> getUndoList() const; + int apply(); int applyOneShot(); void undo(); @@ -53,6 +57,7 @@ private: std::string name; ModeType type; std::list> actionList; + std::list> undoList; #ifdef MDS_TEST friend class TestParser; #endif diff --git a/supervisor/ModeTag.cpp b/supervisor/ModeTag.cpp index 6ce1a2f..4902a7d 100644 --- a/supervisor/ModeTag.cpp +++ b/supervisor/ModeTag.cpp @@ -30,6 +30,7 @@ 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::ACTION = (xmlChar*)"action"; +const xmlChar* const ModeTag::UNDO = (xmlChar*)"undo"; const xmlChar* const ModeTag::RULE = (xmlChar*)"rule"; const xmlChar* const ModeTag::STOP_ON_ERR = (xmlChar*)"stopOnErr"; const xmlChar* const ModeTag::RESTICT = (xmlChar*)"restrict"; diff --git a/supervisor/ModeTag.h b/supervisor/ModeTag.h index 77171d8..22b48b9 100644 --- a/supervisor/ModeTag.h +++ b/supervisor/ModeTag.h @@ -33,6 +33,7 @@ struct ModeTag { static const xmlChar* const TYPE; static const xmlChar* const CUSTOM; static const xmlChar* const ACTION; + static const xmlChar* const UNDO; static const xmlChar* const RULE; static const xmlChar* const STOP_ON_ERR; static const xmlChar* const RESTICT; diff --git a/supervisor/ModeXMLParser.cpp b/supervisor/ModeXMLParser.cpp index de32f35..9890c32 100644 --- a/supervisor/ModeXMLParser.cpp +++ b/supervisor/ModeXMLParser.cpp @@ -92,6 +92,8 @@ void ModeXMLParser::getDatafromNode(xmlNodePtr node) parseMode(node); } else if (MDS_EQUAL == xmlStrcmp(node->name, ModeTag::ACTION)) { parseAction(node); + } else if (MDS_EQUAL == xmlStrcmp(node->name, ModeTag::UNDO)) { + parseUndo(node); } else { DBG("Unhandled node : %s", node->name); } @@ -137,6 +139,12 @@ std::string ModeXMLParser::getXmlTagStringValue(xmlNodePtr node, const xmlChar* return xmlTagString; } +void ModeXMLParser::parseUndo(xmlNodePtr node) +{ + Action *action = parseActionInfo(node); + mode.addUndo(action); +} + void ModeXMLParser::parseActionAttr(xmlNodePtr node, Action *action) { char *restictProp = (char*)xmlGetProp(node, ModeTag::RESTICT); @@ -155,6 +163,12 @@ void ModeXMLParser::parseActionAttr(xmlNodePtr node, Action *action) } void ModeXMLParser::parseAction(xmlNodePtr node) +{ + Action *action = parseActionInfo(node); + mode.addAction(action); +} + +Action *ModeXMLParser::parseActionInfo(xmlNodePtr node) { char *ruleProp = (char*)xmlGetProp(node, ModeTag::RULE); if (ruleProp == NULL) { @@ -186,8 +200,7 @@ void ModeXMLParser::parseAction(xmlNodePtr node) xmlFree(nodeContent); action->printInfo(); - - mode.addAction(action); + return action; } void ModeXMLParser::bindPlugin(const std::string &name, Action *action) @@ -197,4 +210,3 @@ void ModeXMLParser::bindPlugin(const std::string &name, Action *action) pluginName = name.substr(0, pos); action->setPlugin(pluginManager.getPlugin(pluginName)); } - diff --git a/supervisor/ModeXMLParser.h b/supervisor/ModeXMLParser.h index 9613698..5ef9a77 100644 --- a/supervisor/ModeXMLParser.h +++ b/supervisor/ModeXMLParser.h @@ -41,6 +41,8 @@ private: std::string getXmlTagStringValue(xmlNodePtr node, const xmlChar *tag); void parseActionAttr(xmlNodePtr node, Action *action); void parseAction(xmlNodePtr node); + void parseUndo(xmlNodePtr node); + Action *parseActionInfo(xmlNodePtr node); void bindPlugin(const std::string &name, Action *action); PluginManager &pluginManager; diff --git a/unittest/modes_test_client.cpp b/unittest/modes_test_client.cpp index 4aa66c2..6a8de99 100644 --- a/unittest/modes_test_client.cpp +++ b/unittest/modes_test_client.cpp @@ -102,3 +102,10 @@ TEST_F(ClientTest, undoModeWifiOn) g_main_loop_run(loop); EXPECT_EQ(MODES_ERROR_NONE, result); } + +TEST_F(ClientTest, undoModePsMode) +{ + g_idle_add(undo_mode_idler, (gpointer)"waterlock"); + g_main_loop_run(loop); + EXPECT_EQ(MODES_ERROR_NONE, result); +}