int TestPluginAction::printIntVal = 0;
TestPluginAction::TestPluginAction(const std::string &actionKey)
- : PluginAction(actionKey), cb(nullptr), cbData(nullptr)
+ : PluginAction(actionKey), changeTimeVal(0), cb(nullptr), cbData(nullptr)
{
}
bool TestPluginAction::IsCurrentValue(int val)
{
- if (val == printIntVal)
- return true;
+ if ("changeTime" == key) {
+ if (val == changeTimeVal)
+ return true;
+ } else {
+ if (val == printIntVal)
+ return true;
+ }
return false;
}
} else if ("changeTime" == key) {
g_timeout_add_seconds(val, changeTimeout, this);
DBG("set(%s, %d)", key.c_str(), val);
+ changeTimeVal = val;
} else {
ERR("Unknown key(%s)", key.c_str());
return MODES_ERROR_NOT_SUPPORTED;
std::string backupUndoInfo();
int restoreUndoInfo(const std::string &info);
virtual int setValue(const std::string &val) = 0;
+ virtual bool checkChanged() = 0;
virtual std::string getStringOfValue() = 0;
virtual int apply() = 0;
virtual int applyOneShot() = 0;
if ((*it)->getRestrict() == Action::ESSENTIAL) {
DBG("Essential Action(%s)", (*it)->getRuleName().c_str());
essentialMap.insert(std::make_pair((*it).get(), mode.getName()));
+ if (true == (*it)->checkChanged()) {
+ EssentialHandler::undoHandler(mode.getName());
+ return;
+ }
(*it)->attachObserver(this);
}
}
return MODES_ERROR_NONE;
}
+ bool checkChanged() override
+ {
+ if (false == piAction->IsCurrentValue(value)) {
+ INFO("Action(%s) is changed", ruleName.c_str());
+ return true;
+ }
+ return false;
+ }
+
int apply() override
{
std::lock_guard<std::mutex> lock(actionMutex);