revise piAction life cycle and returning undo()
authorYoungjae Shin <yj99.shin@samsung.com>
Wed, 13 Nov 2019 02:00:52 +0000 (11:00 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Thu, 19 Mar 2020 04:30:37 +0000 (13:30 +0900)
36 files changed:
app/AppActionLaunch.cpp
app/AppActionLaunch.h
app/AppPlugin.cpp
bluetooth/BtActionPower.cpp
bluetooth/BtActionPower.h
bluetooth/BtPlugin.cpp
display/DisplayAllowPalmTouch.cpp
display/DisplayAllowPalmTouch.h
display/DisplayBrightness.cpp
display/DisplayBrightness.h
display/DisplayPlugin.cpp
display/DisplayTimeout.cpp
display/DisplayTimeout.h
media/MediaPlayer.cpp
media/MediaPlayer.h
pkg/PkgEnableSupportMode.cpp
pkg/PkgEnableSupportMode.h
pkg/PkgPlugin.cpp
unittests/mdsp_test_app.cpp
unittests/mdsp_test_display.cpp
unittests/mdsp_test_media.cpp
unittests/mdsp_test_pkg.cpp
unittests/mdsp_test_vconf.cpp
vconf/VconfAction.cpp
vconf/VconfAction.h
vconf/VconfActionBool.cpp
vconf/VconfActionBool.h
vconf/VconfActionDbl.cpp
vconf/VconfActionDbl.h
vconf/VconfActionInt.cpp
vconf/VconfActionInt.h
vconf/VconfActionStr.cpp
vconf/VconfActionStr.h
wifi/WifiActionPower.cpp
wifi/WifiActionPower.h
wifi/WifiPlugin.cpp

index a6ff7c2..b9ea121 100644 (file)
@@ -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()
index 818457d..2e8516b 100644 (file)
@@ -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);
index 9204ca8..3961da4 100644 (file)
@@ -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<AppAction*>(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)
index 0c87332..900b639 100644 (file)
@@ -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()
index dba36ef..8c2762f 100644 (file)
@@ -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:
index ab57774..f3fd2a7 100644 (file)
@@ -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<BtAction*>(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)
index b527591..24f0962 100644 (file)
@@ -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()
index a3cf5c7..8c29b3e 100644 (file)
@@ -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;
 
index d3ccf15..536c651 100644 (file)
@@ -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()
index ac36a19..eeb841b 100644 (file)
@@ -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;
 
index a6e53f2..c58e975 100644 (file)
@@ -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<DisplayAction*>(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;
 }
 
index c4dbc23..f45cc6c 100644 (file)
@@ -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()
index d29d2dc..153fdb3 100644 (file)
@@ -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;
 
index 7f4a4f6..99d4943 100644 (file)
@@ -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;
 }
index 78f5922..ebf3ee5 100644 (file)
@@ -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);
index 7675b5d..ba2aaac 100644 (file)
@@ -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()
index b5ccc98..53dd129 100644 (file)
@@ -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:
index 5fdcc6b..939ec79 100644 (file)
@@ -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<PkgAction*>(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)
index 0afdd37..3ef3f71 100644 (file)
@@ -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;
        }
index 690c6fa..22d6cff 100644 (file)
@@ -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);
 
index 119986f..f598274 100644 (file)
@@ -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;
        }
index 054ddb4..a272974 100644 (file)
@@ -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);
index 9f80af0..a94d544 100644 (file)
@@ -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);
 }
 
index 66a080a..b93b2a2 100644 (file)
@@ -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);
 }
index fe374c2..19198cc 100644 (file)
@@ -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;
index 6062db2..16297c2 100644 (file)
@@ -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()
index 4d74dc2..57eae7a 100644 (file)
@@ -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:
index 1d7cc3c..7135d49 100644 (file)
@@ -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()
index f83cf51..9841386 100644 (file)
@@ -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:
index 05f6d24..d717a7f 100644 (file)
@@ -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()
index 66b0b8a..1a747e9 100644 (file)
@@ -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:
index cfa2715..ace2fe9 100644 (file)
@@ -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()
index e6a5ec0..0273ad5 100644 (file)
@@ -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:
index 0af2edd..68cfdaf 100644 (file)
@@ -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);
 }
index 7132f01..4fa8e57 100644 (file)
@@ -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;
index cdb0245..e8b88b1 100644 (file)
@@ -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<WifiAction*>(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)