From: Youngjae Shin Date: Wed, 13 Nov 2019 02:00:52 +0000 (+0900) Subject: revise piAction life cycle and returning undo() X-Git-Tag: submit/tizen/20200406.072014~22 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d958bc7c07be992aaa357f7bbb266014ca1fffe8;p=platform%2Fcore%2Fsystem%2Fmodes-plugins.git revise piAction life cycle and returning undo() --- diff --git a/app/AppActionLaunch.cpp b/app/AppActionLaunch.cpp index a6ff7c2..b9ea121 100644 --- a/app/AppActionLaunch.cpp +++ b/app/AppActionLaunch.cpp @@ -103,7 +103,7 @@ int AppActionLaunch::get(std::string *val) return MODES_ERROR_NONE; } -int AppActionLaunch::undo() +void AppActionLaunch::undo() { bool running; app_context_h runAppContext; @@ -111,7 +111,7 @@ int AppActionLaunch::undo() app_manager_is_running(appID.c_str(), &running); if (!running) { DBG("It's NOT running"); - return MODES_ERROR_NONE; + return; } int ret = app_manager_unset_app_context_status_cb(appContextStatusCallback, appID.c_str()); @@ -123,14 +123,11 @@ int AppActionLaunch::undo() ret = app_manager_get_app_context(appID.c_str(), &runAppContext); if (APP_MANAGER_ERROR_NONE != ret) { ERR("app_manager_get_app_context(%s) Fail(%s)", appID.c_str(), get_error_message(ret)); - return MODES_ERROR_SYSTEM; + return; } ret = app_manager_terminate_app(runAppContext); - if (APP_MANAGER_ERROR_NONE != ret) { + if (APP_MANAGER_ERROR_NONE != ret) ERR("app_manager_terminate_app() Fail(%s)", get_error_message(ret)); - return MODES_ERROR_SYSTEM; - } - return MODES_ERROR_NONE; } std::string AppActionLaunch::serialize() diff --git a/app/AppActionLaunch.h b/app/AppActionLaunch.h index 818457d..2e8516b 100644 --- a/app/AppActionLaunch.h +++ b/app/AppActionLaunch.h @@ -30,7 +30,7 @@ public: int set(const std::string &val) override; int get(std::string *val) override; - int undo() override; + void undo() override; std::string serialize() override; int parse(const std::string &data) override; static void appContextStatusCallback(app_context_h app_context, app_context_status_e status, void *user_data); diff --git a/app/AppPlugin.cpp b/app/AppPlugin.cpp index 9204ca8..3961da4 100644 --- a/app/AppPlugin.cpp +++ b/app/AppPlugin.cpp @@ -27,7 +27,7 @@ public: ~AppPlugin(); int set(const std::string &key, const std::string &val, PluginAction **piAction) override; - int undo(PluginAction *piAction) override; + void undo(PluginAction *piAction) override; PluginAction* getUndoAction(const std::string &key, const std::string &info) override; private: AppFactory appFactory; @@ -68,17 +68,15 @@ int AppPlugin::set(const std::string &key, const std::string &val, PluginAction return ret; } -int AppPlugin::undo(PluginAction *piAction) +void AppPlugin::undo(PluginAction *piAction) { AppAction *action = static_cast(piAction); - RETV_IF(nullptr == action, MODES_ERROR_INVALID_PARAMETER); + RET_IF(nullptr == piAction); DBG("Action(%s) undo", action->getName().c_str()); - int ret = action->undo(); + action->undo(); appFactory.destroyAction(action); - - return ret; } PluginAction* AppPlugin::getUndoAction(const std::string &key, const std::string &info) diff --git a/bluetooth/BtActionPower.cpp b/bluetooth/BtActionPower.cpp index 0c87332..900b639 100644 --- a/bluetooth/BtActionPower.cpp +++ b/bluetooth/BtActionPower.cpp @@ -60,9 +60,9 @@ int BtActionPower::set(bool val) return MODES_ERROR_NONE; } -int BtActionPower::undo() +void BtActionPower::undo() { - return set(undoVal); + set(undoVal); } std::string BtActionPower::serialize() diff --git a/bluetooth/BtActionPower.h b/bluetooth/BtActionPower.h index dba36ef..8c2762f 100644 --- a/bluetooth/BtActionPower.h +++ b/bluetooth/BtActionPower.h @@ -26,7 +26,7 @@ public: BtActionPower(); int set(bool val) override; - int undo() override; + void undo() override; std::string serialize() override; int parse(const std::string & archive) override; private: diff --git a/bluetooth/BtPlugin.cpp b/bluetooth/BtPlugin.cpp index ab57774..f3fd2a7 100644 --- a/bluetooth/BtPlugin.cpp +++ b/bluetooth/BtPlugin.cpp @@ -31,7 +31,7 @@ public: int set(const std::string &key, double val, PluginAction **piAction) override; int set(const std::string &key, bool val, PluginAction **piAction) override; int set(const std::string &key, const std::string &val, PluginAction **piAction) override; - int undo(PluginAction *piAction) override; + void undo(PluginAction *piAction) override; PluginAction* getUndoAction(const std::string &key, const std::string &info) override; private: BtFactory btFactory; @@ -120,17 +120,15 @@ int BtPlugin::set(const std::string &key, const std::string &val, PluginAction * return ret; } -int BtPlugin::undo(PluginAction *piAction) +void BtPlugin::undo(PluginAction *piAction) { BtAction *action = static_cast(piAction); - RETV_IF(nullptr == action, MODES_ERROR_INVALID_PARAMETER); + RET_IF(nullptr == piAction); DBG("Action(%s) undo", action->getName().c_str()); - int ret = action->undo(); + action->undo(); btFactory.destroyAction(action); - - return ret; } PluginAction* BtPlugin::getUndoAction(const std::string &key, const std::string &info) diff --git a/display/DisplayAllowPalmTouch.cpp b/display/DisplayAllowPalmTouch.cpp index b527591..24f0962 100644 --- a/display/DisplayAllowPalmTouch.cpp +++ b/display/DisplayAllowPalmTouch.cpp @@ -77,9 +77,9 @@ int DisplayAllowPalmTouch::set(bool val) return modesRet; } -int DisplayAllowPalmTouch::undo() +void DisplayAllowPalmTouch::undo() { - return set(true); + set(true); } std::string DisplayAllowPalmTouch::serialize() diff --git a/display/DisplayAllowPalmTouch.h b/display/DisplayAllowPalmTouch.h index a3cf5c7..8c29b3e 100644 --- a/display/DisplayAllowPalmTouch.h +++ b/display/DisplayAllowPalmTouch.h @@ -27,7 +27,7 @@ public: ~DisplayAllowPalmTouch(); int set(bool val) override; - int undo() override; + void undo() override; std::string serialize() override; int parse(const std::string &archive) override; diff --git a/display/DisplayBrightness.cpp b/display/DisplayBrightness.cpp index d3ccf15..536c651 100644 --- a/display/DisplayBrightness.cpp +++ b/display/DisplayBrightness.cpp @@ -59,17 +59,14 @@ int DisplayBrightness::set(int val) return MODES_ERROR_NONE; } -int DisplayBrightness::undo() +void DisplayBrightness::undo() { int i = 0; for (auto it = oldValList.begin(); it != oldValList.end(); ++it, ++i) { int ret = device_display_set_brightness(i, *it); - if (DEVICE_ERROR_NONE != ret) { + if (DEVICE_ERROR_NONE != ret) ERR("device_display_set_brightness(%d, %d) Fail(%s)", i, *it, get_error_message(ret)); - return MODES_ERROR_SYSTEM; - } } - return MODES_ERROR_NONE; } std::string DisplayBrightness::serialize() diff --git a/display/DisplayBrightness.h b/display/DisplayBrightness.h index ac36a19..eeb841b 100644 --- a/display/DisplayBrightness.h +++ b/display/DisplayBrightness.h @@ -28,7 +28,7 @@ public: ~DisplayBrightness(); int set(int val) override; - int undo() override; + void undo() override; std::string serialize() override; int parse(const std::string &archive) override; diff --git a/display/DisplayPlugin.cpp b/display/DisplayPlugin.cpp index a6e53f2..c58e975 100644 --- a/display/DisplayPlugin.cpp +++ b/display/DisplayPlugin.cpp @@ -32,7 +32,7 @@ public: int set(const std::string &key, bool val, PluginAction **pluginAction) override; PluginAction* getUndoAction(const std::string &key, const std::string &info) override; - int undo(PluginAction *pluginAction) override; + void undo(PluginAction *pluginAction) override; private: DisplayFactory displayFactory; @@ -104,16 +104,14 @@ PluginAction* DisplayPlugin::getUndoAction(const std::string &key, const std::st return action; } -int DisplayPlugin::undo(PluginAction *pluginAction) +void DisplayPlugin::undo(PluginAction *pluginAction) { DisplayAction *action = static_cast(pluginAction); - RETV_IF(nullptr == action, MODES_ERROR_INVALID_PARAMETER); + RET_IF(nullptr == pluginAction); DBG("Action(%s) undo", action->getName().c_str()); - int ret = action->undo(); + action->undo(); displayFactory.destroyAction(action); - - return ret; } diff --git a/display/DisplayTimeout.cpp b/display/DisplayTimeout.cpp index c4dbc23..f45cc6c 100644 --- a/display/DisplayTimeout.cpp +++ b/display/DisplayTimeout.cpp @@ -48,16 +48,12 @@ int DisplayTimeout::set(int val) return MODES_ERROR_NONE; } -int DisplayTimeout::undo() +void DisplayTimeout::undo() { - DBG("undo Display Timeout(%s, %d)", - key, oldDisplayTimeout); + DBG("undo Display Timeout(%s, %d)", key, oldDisplayTimeout); int ret = vconf_set_int(key, oldDisplayTimeout); - if (0 != ret) { + if (0 != ret) ERR("vconf_set_int(%s, %d) Fail(%d)", key, oldDisplayTimeout, ret); - return MODES_ERROR_SYSTEM; - } - return MODES_ERROR_NONE; } std::string DisplayTimeout::serialize() diff --git a/display/DisplayTimeout.h b/display/DisplayTimeout.h index d29d2dc..153fdb3 100644 --- a/display/DisplayTimeout.h +++ b/display/DisplayTimeout.h @@ -27,7 +27,7 @@ public: ~DisplayTimeout(); int set(int val) override; - int undo() override; + void undo() override; std::string serialize() override; int parse(const std::string &archive) override; diff --git a/media/MediaPlayer.cpp b/media/MediaPlayer.cpp index 7f4a4f6..99d4943 100644 --- a/media/MediaPlayer.cpp +++ b/media/MediaPlayer.cpp @@ -105,8 +105,7 @@ int MediaPlayer::set(std::string val) return MODES_ERROR_NONE; } -int MediaPlayer::undo() +void MediaPlayer::undo() { destroyPlayer(NULL); - return MODES_ERROR_NONE; } diff --git a/media/MediaPlayer.h b/media/MediaPlayer.h index 78f5922..ebf3ee5 100644 --- a/media/MediaPlayer.h +++ b/media/MediaPlayer.h @@ -29,7 +29,7 @@ public: ~MediaPlayer() = default; int set(std::string val) override; - int undo() override; + void undo() override; private: int createPlayer(); static void destroyPlayer(void *data); diff --git a/pkg/PkgEnableSupportMode.cpp b/pkg/PkgEnableSupportMode.cpp index 7675b5d..ba2aaac 100644 --- a/pkg/PkgEnableSupportMode.cpp +++ b/pkg/PkgEnableSupportMode.cpp @@ -110,7 +110,7 @@ int PkgStartSupportMode::get(int *val) } -int PkgStartSupportMode::undo() +void PkgStartSupportMode::undo() { //If the appList is empty, it will be ignored at subroutines. @@ -130,8 +130,6 @@ int PkgStartSupportMode::undo() //The caller(Plugin undo function) includes destruction of this instance. //Therefore, appList will be cleared by the destructor. - - return MODES_ERROR_NONE; } std::string PkgStartSupportMode::serialize() diff --git a/pkg/PkgEnableSupportMode.h b/pkg/PkgEnableSupportMode.h index b5ccc98..53dd129 100644 --- a/pkg/PkgEnableSupportMode.h +++ b/pkg/PkgEnableSupportMode.h @@ -30,7 +30,7 @@ public: int set(int val) override; int get(int *val) override; - int undo() override; + void undo() override; std::string serialize() override; int parse(const std::string &data) override; private: diff --git a/pkg/PkgPlugin.cpp b/pkg/PkgPlugin.cpp index 5fdcc6b..939ec79 100644 --- a/pkg/PkgPlugin.cpp +++ b/pkg/PkgPlugin.cpp @@ -29,7 +29,7 @@ public: ~PkgPlugin(); int set(const std::string &key, int val, PluginAction **piAction) override; - int undo(PluginAction *piAction) override; + void undo(PluginAction *piAction) override; PluginAction* getUndoAction(const std::string &key, const std::string &info) override; private: PkgFactory pkgFactory; @@ -69,17 +69,15 @@ int PkgPlugin::set(const std::string &key, int val, PluginAction **piAction) return ret; } -int PkgPlugin::undo(PluginAction *piAction) +void PkgPlugin::undo(PluginAction *piAction) { PkgAction *action = static_cast(piAction); - RETV_IF(nullptr == action, MODES_ERROR_INVALID_PARAMETER); + RET_IF(nullptr == piAction); DBG("Action(%s) undo", action->getName().c_str()); - int ret = action->undo(); + action->undo(); pkgFactory.destroyAction(action); - - return ret; } PluginAction* PkgPlugin::getUndoAction(const std::string &key, const std::string &info) diff --git a/unittests/mdsp_test_app.cpp b/unittests/mdsp_test_app.cpp index 0afdd37..3ef3f71 100644 --- a/unittests/mdsp_test_app.cpp +++ b/unittests/mdsp_test_app.cpp @@ -52,8 +52,7 @@ protected: app_context_h runAppContext = NULL; app_manager_get_app_context("org.tizen.net-popup", &runAppContext); app_manager_terminate_app(runAppContext); - result = plugin->undo(action); - EXPECT_EQ(MODES_ERROR_NONE, result); + plugin->undo(action); g_main_loop_quit(loop); return G_SOURCE_REMOVE; @@ -62,8 +61,7 @@ protected: static gboolean appPluginSetUndoTimeout(gpointer data) { PluginAction *action = (PluginAction*)data; - result = plugin->undo(action); - EXPECT_EQ(MODES_ERROR_NONE, result); + plugin->undo(action); g_main_loop_quit(loop); return false; } diff --git a/unittests/mdsp_test_display.cpp b/unittests/mdsp_test_display.cpp index 690c6fa..22d6cff 100644 --- a/unittests/mdsp_test_display.cpp +++ b/unittests/mdsp_test_display.cpp @@ -46,8 +46,7 @@ protected: result = plugin->set("brightness", 100, &action); EXPECT_EQ(MODES_ERROR_NONE, result); - result = plugin->undo(action); - EXPECT_EQ(MODES_ERROR_NONE, result); + plugin->undo(action); g_main_loop_quit(loop); @@ -60,8 +59,7 @@ protected: result = plugin->set("allowPalmTouch", true, &action); EXPECT_EQ(MODES_ERROR_NONE, result); - result = plugin->undo(action); - EXPECT_EQ(MODES_ERROR_NONE, result); + plugin->undo(action); g_main_loop_quit(loop); @@ -74,8 +72,7 @@ protected: result = plugin->set("Timeout", 0, &action); EXPECT_EQ(MODES_ERROR_NONE, result); - result = plugin->undo(action); - EXPECT_EQ(MODES_ERROR_NONE, result); + plugin->undo(action); g_main_loop_quit(loop); diff --git a/unittests/mdsp_test_media.cpp b/unittests/mdsp_test_media.cpp index 119986f..f598274 100644 --- a/unittests/mdsp_test_media.cpp +++ b/unittests/mdsp_test_media.cpp @@ -44,8 +44,7 @@ protected: static gboolean mediaPluginSetUndoTimeout(gpointer data) { PluginAction *action = (PluginAction*)data; - result = plugin->undo(action); - EXPECT_EQ(MODES_ERROR_NONE, result); + plugin->undo(action); g_main_loop_quit(loop); return false; } diff --git a/unittests/mdsp_test_pkg.cpp b/unittests/mdsp_test_pkg.cpp index 054ddb4..a272974 100644 --- a/unittests/mdsp_test_pkg.cpp +++ b/unittests/mdsp_test_pkg.cpp @@ -63,8 +63,7 @@ TEST_F(PkgPluginTest, setUndoTest) g_idle_add(pkgPluginIdler, plugin); g_main_loop_run(loop); - ret = plugin->undo(action); - EXPECT_EQ(MODES_ERROR_NONE, ret); + plugin->undo(action); g_idle_add(pkgPluginIdler, plugin); g_main_loop_run(loop); diff --git a/unittests/mdsp_test_vconf.cpp b/unittests/mdsp_test_vconf.cpp index 9f80af0..a94d544 100644 --- a/unittests/mdsp_test_vconf.cpp +++ b/unittests/mdsp_test_vconf.cpp @@ -103,8 +103,7 @@ TEST_F(VconfPluginTest, VconfInt) ret = plugin->set(key, 1, &action); EXPECT_EQ(ret, MODES_ERROR_NONE); - ret = plugin->undo(action); - EXPECT_EQ(ret, MODES_ERROR_NONE); + plugin->undo(action); val = plugin->getInt(key); EXPECT_EQ(val, 0); @@ -125,8 +124,7 @@ TEST_F(VconfPluginTest, VconfDouble) ret = plugin->set(key, 1.0, &action); EXPECT_EQ(ret, MODES_ERROR_NONE); - ret = plugin->undo(action); - EXPECT_EQ(ret, MODES_ERROR_NONE); + plugin->undo(action); val = plugin->getDouble(key); EXPECT_EQ(val, 0.0); @@ -147,8 +145,7 @@ TEST_F(VconfPluginTest, VconfBool) ret = plugin->set(key, false, &action); EXPECT_EQ(ret, MODES_ERROR_NONE); - ret = plugin->undo(action); - EXPECT_EQ(ret, MODES_ERROR_NONE); + plugin->undo(action); val = plugin->getBool(key); EXPECT_EQ(val, true); @@ -171,8 +168,7 @@ TEST_F(VconfPluginTest, VconfStr) ret = plugin->set(key, tmpName, &action); EXPECT_EQ(ret, MODES_ERROR_NONE); - ret = plugin->undo(action); - EXPECT_EQ(ret, MODES_ERROR_NONE); + plugin->undo(action); val = plugin->getString(key); EXPECT_STREQ(val.c_str(), devName.c_str()); @@ -195,13 +191,11 @@ TEST_F(VconfPluginTest, callbackPluginVconf) g_main_loop_run(loop); // It should be removed by the changed callback procedure. - ret = action->unSetChangedCallback(valChangedCb, (void*)key); - EXPECT_EQ(ret, MODES_ERROR_NO_DATA); + action->unSetChangedCallback(valChangedCb, (void*)key); ret = action->setChangedCallback(shoudNotBeCalled, (void*)key); EXPECT_EQ(ret, MODES_ERROR_NONE); - ret = action->unSetChangedCallback(shoudNotBeCalled, (void*)key); - EXPECT_EQ(ret, MODES_ERROR_NONE); + action->unSetChangedCallback(shoudNotBeCalled, (void*)key); vconf_set_int("db/setting/psmode", oldVal); } @@ -226,8 +220,7 @@ TEST_F(VconfPluginTest, callbackPluginVconfReset) g_main_loop_run(loop); EXPECT_TRUE(cb2Called); - ret = action2->unSetChangedCallback(callback2, nullptr); - EXPECT_EQ(ret, MODES_ERROR_NO_DATA); + action2->unSetChangedCallback(callback2, nullptr); vconf_set_int("db/setting/psmode", 0); } diff --git a/vconf/VconfAction.cpp b/vconf/VconfAction.cpp index 66a080a..b93b2a2 100644 --- a/vconf/VconfAction.cpp +++ b/vconf/VconfAction.cpp @@ -44,23 +44,22 @@ int VconfAction::setChangedCallback(valueChangedCB callback, void *userData) return MODES_ERROR_NONE; } -int VconfAction::unSetChangedCallback(valueChangedCB callback, void * userData) +void VconfAction::unSetChangedCallback(valueChangedCB callback, void *userData) { auto found = callbackMap.find(key); if (found == callbackMap.end()) { ERR("No Changed Callback(%s)", key.c_str()); - return MODES_ERROR_NO_DATA; + return; } callbackMap.erase(found); int ret = vconf_ignore_key_changed(key.c_str(), vconfChangedCallback); if (0 != ret) { ERR("vconf_ignore_key_changed(%s) Fail(%d)", key.c_str(), ret); - return MODES_ERROR_SYSTEM; + return; } DBG("unSetChangedCallback(%s) Success", key.c_str()); - return MODES_ERROR_NONE; } int VconfAction::handleChange() @@ -92,13 +91,6 @@ void VconfAction::vconfChangedCallback(keynode_t *node, void *userData) return; } - std::string newKey(node->keyname); - std::replace(newKey.begin(), newKey.end(), '/', '.'); cbData->callback(cbData->userData); DBG("Action(%s) is Changed", node->keyname); - - callbackMap.erase(found); - int ret = vconf_ignore_key_changed(node->keyname, vconfChangedCallback); - if (0 != ret) - ERR("vconf_ignore_key_changed(%s) Fail(%d)", node->keyname, ret); } diff --git a/vconf/VconfAction.h b/vconf/VconfAction.h index fe374c2..19198cc 100644 --- a/vconf/VconfAction.h +++ b/vconf/VconfAction.h @@ -29,7 +29,7 @@ public: virtual ~VconfAction() = default; int setChangedCallback(valueChangedCB callback, void *userData) override; - int unSetChangedCallback(valueChangedCB callback, void *userData) override; + void unSetChangedCallback(valueChangedCB callback, void *userData) override; protected: int handleChange(); std::string key; diff --git a/vconf/VconfActionBool.cpp b/vconf/VconfActionBool.cpp index 6062db2..16297c2 100644 --- a/vconf/VconfActionBool.cpp +++ b/vconf/VconfActionBool.cpp @@ -65,18 +65,14 @@ bool VconfActionBool::get() return value ? true : false; } -int VconfActionBool::undo() +void VconfActionBool::undo() { int ret; DBG("undoBool(%s, %d)", key.c_str(), oldVal); ret = vconf_set_bool(key.c_str(), oldVal ? 1 : 0); - if (0 != ret) { + if (0 != ret) ERR("vconf_set_bool(%s, %d) Fail(%d)", key.c_str(), oldVal, ret); - return MODES_ERROR_SYSTEM; - } - - return MODES_ERROR_NONE; } std::string VconfActionBool::serialize() diff --git a/vconf/VconfActionBool.h b/vconf/VconfActionBool.h index 4d74dc2..57eae7a 100644 --- a/vconf/VconfActionBool.h +++ b/vconf/VconfActionBool.h @@ -28,7 +28,7 @@ public: int set(bool val); bool get(); - int undo() override; + void undo() override; std::string serialize() override; int parse(const std::string &archive) override; private: diff --git a/vconf/VconfActionDbl.cpp b/vconf/VconfActionDbl.cpp index 1d7cc3c..7135d49 100644 --- a/vconf/VconfActionDbl.cpp +++ b/vconf/VconfActionDbl.cpp @@ -63,18 +63,14 @@ double VconfActionDbl::get() return value; } -int VconfActionDbl::undo() +void VconfActionDbl::undo() { int ret; DBG("undoDbl(%s, %f)", key.c_str(), oldVal); ret = vconf_set_dbl(key.c_str(), oldVal); - if (0 != ret) { + if (0 != ret) ERR("vconf_set_dbl(%s, %f) Fail(%d)", key.c_str(), oldVal, ret); - return MODES_ERROR_SYSTEM; - } - - return MODES_ERROR_NONE; } std::string VconfActionDbl::serialize() diff --git a/vconf/VconfActionDbl.h b/vconf/VconfActionDbl.h index f83cf51..9841386 100644 --- a/vconf/VconfActionDbl.h +++ b/vconf/VconfActionDbl.h @@ -28,7 +28,7 @@ public: int set(double val); double get(); - int undo() override; + void undo() override; std::string serialize() override; int parse(const std::string &archive) override; private: diff --git a/vconf/VconfActionInt.cpp b/vconf/VconfActionInt.cpp index 05f6d24..d717a7f 100644 --- a/vconf/VconfActionInt.cpp +++ b/vconf/VconfActionInt.cpp @@ -63,18 +63,14 @@ int VconfActionInt::get() return value; } -int VconfActionInt::undo() +void VconfActionInt::undo() { int ret; DBG("undoInt(%s, %d)", key.c_str(), oldVal); ret = vconf_set_int(key.c_str(), oldVal); - if (0 != ret) { + if (0 != ret) ERR("vconf_set_int(%s, %d) Fail(%d)", key.c_str(), oldVal, ret); - return MODES_ERROR_SYSTEM; - } - - return MODES_ERROR_NONE; } std::string VconfActionInt::serialize() diff --git a/vconf/VconfActionInt.h b/vconf/VconfActionInt.h index 66b0b8a..1a747e9 100644 --- a/vconf/VconfActionInt.h +++ b/vconf/VconfActionInt.h @@ -28,7 +28,7 @@ public: int set(int val); int get(); - int undo() override; + void undo() override; std::string serialize() override; int parse(const std::string &archive) override; private: diff --git a/vconf/VconfActionStr.cpp b/vconf/VconfActionStr.cpp index cfa2715..ace2fe9 100644 --- a/vconf/VconfActionStr.cpp +++ b/vconf/VconfActionStr.cpp @@ -66,18 +66,14 @@ std::string VconfActionStr::get() return retStr; } -int VconfActionStr::undo() +void VconfActionStr::undo() { int ret; DBG("undoStr(%s, %s)", key.c_str(), oldVal.c_str()); ret = vconf_set_str(key.c_str(), oldVal.c_str()); - if (0 != ret) { + if (0 != ret) ERR("vconf_set_str(%s, %s) Fail(%d)", key.c_str(), oldVal.c_str(), ret); - return MODES_ERROR_SYSTEM; - } - - return MODES_ERROR_NONE; } std::string VconfActionStr::serialize() diff --git a/vconf/VconfActionStr.h b/vconf/VconfActionStr.h index e6a5ec0..0273ad5 100644 --- a/vconf/VconfActionStr.h +++ b/vconf/VconfActionStr.h @@ -28,7 +28,7 @@ public: int set(const std::string &val); std::string get(); - int undo() override; + void undo() override; std::string serialize() override; int parse(const std::string &archive) override; private: diff --git a/wifi/WifiActionPower.cpp b/wifi/WifiActionPower.cpp index 0af2edd..68cfdaf 100644 --- a/wifi/WifiActionPower.cpp +++ b/wifi/WifiActionPower.cpp @@ -55,9 +55,9 @@ int WifiActionPower::set(bool val) return MODES_ERROR_NONE; } -int WifiActionPower::undo() +void WifiActionPower::undo() { - return set(oldVal); + set(oldVal); } std::string WifiActionPower::serialize() @@ -92,21 +92,20 @@ int WifiActionPower::setChangedCallback(valueChangedCB callback, void *userData) DBG("WifiActionPower setChangedCallback() Success"); return MODES_ERROR_NONE; } -int WifiActionPower::unSetChangedCallback(valueChangedCB callback, void *userData) +void WifiActionPower::unSetChangedCallback(valueChangedCB callback, void *userData) { - RETV_IF(NULL == callback, MODES_ERROR_INVALID_PARAMETER); + RET_IF(NULL == callback); int ret = wifi_manager_unset_device_state_changed_cb(handle); if (WIFI_MANAGER_ERROR_NONE != ret) { - ERR("wifi_manager_unset_device_state_changed_cb() Fail(%s)", get_error_message(ret)); - return MODES_ERROR_SYSTEM; + ERR("wifi_manager_unset_device_state_changed_cb() Fail(%s)", + get_error_message(ret)); } cb = NULL; cbData = NULL; DBG("WifiActionPower unSetChangedCallback() Success"); - return MODES_ERROR_NONE; } void WifiActionPower::activateCB(wifi_manager_error_e result, void *user_data) @@ -141,11 +140,6 @@ void WifiActionPower::wifiStateChangedCB(wifi_manager_device_state_e state, void INFO("state:%d", state); - if (changedVal != action->requestVal) { - valueChangedCB cb = action->cb; - void *cbData = action->cbData; - //TODO: revise after revising the modes(because of piAction free) - action->unSetChangedCallback(action->cb, action->cbData); - cb(cbData); - } + if (changedVal != action->requestVal) + action->cb(action->cbData); } diff --git a/wifi/WifiActionPower.h b/wifi/WifiActionPower.h index 7132f01..4fa8e57 100644 --- a/wifi/WifiActionPower.h +++ b/wifi/WifiActionPower.h @@ -26,11 +26,11 @@ public: WifiActionPower(); int set(bool val) override; - int undo() override; + void undo() override; std::string serialize() override; int parse(const std::string &archive) override; - int setChangedCallback(valueChangedCB callback, void *userData); - int unSetChangedCallback(valueChangedCB callback, void *userData); + int setChangedCallback(valueChangedCB callback, void *userData) override; + void unSetChangedCallback(valueChangedCB callback, void *userData) override; valueChangedCB cb; void *cbData; diff --git a/wifi/WifiPlugin.cpp b/wifi/WifiPlugin.cpp index cdb0245..e8b88b1 100644 --- a/wifi/WifiPlugin.cpp +++ b/wifi/WifiPlugin.cpp @@ -27,7 +27,7 @@ public: WifiPlugin(); int set(const std::string &key, bool val, PluginAction **piAction) override; - int undo(PluginAction *piAction) override; + void undo(PluginAction *piAction) override; PluginAction* getUndoAction(const std::string &key, const std::string &info) override; private: WifiFactory wifiFactory; @@ -64,17 +64,15 @@ int WifiPlugin::set(const std::string &key, bool val, PluginAction **piAction) return ret; } -int WifiPlugin::undo(PluginAction *piAction) +void WifiPlugin::undo(PluginAction *piAction) { WifiAction *action = static_cast(piAction); - RETV_IF(nullptr == action, MODES_ERROR_INVALID_PARAMETER); + RET_IF(nullptr == piAction); DBG("Action(%s) undo", action->getName().c_str()); - int ret = action->undo(); + action->undo(); wifiFactory.destroyAction(action); - - return ret; } PluginAction* WifiPlugin::getUndoAction(const std::string &key, const std::string &info)