revise interface for applying undo
authorYoungjae Shin <yj99.shin@samsung.com>
Fri, 19 Jul 2019 01:26:53 +0000 (10:26 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Thu, 19 Mar 2020 04:30:19 +0000 (13:30 +0900)
bluetooth/BtPlugin.cpp
vconf/VconfPlugin.cpp
wifi/WifiAction.cpp
wifi/WifiAction.h
wifi/WifiActionPower.cpp
wifi/WifiActionPower.h
wifi/WifiPlugin.cpp

index ac60e15..450e5a6 100644 (file)
@@ -29,10 +29,10 @@ public:
        BtPlugin();
        ~BtPlugin();
 
-       int set(const std::string &key, int val) override;
-       int set(const std::string &key, double val) override;
-       int set(const std::string &key, bool val) override;
-       int set(const std::string &key, const std::string &val) override;
+       int set(const std::string &key, int val, int *oldVal) override;
+       int set(const std::string &key, double val, double *oldVal) override;
+       int set(const std::string &key, bool val, bool *oldVal) override;
+       int set(const std::string &key, const std::string &val, std::string *oldVal) override;
 private:
        BtFactory btFactory;
 };
@@ -56,7 +56,7 @@ BtPlugin::~BtPlugin()
 {
 }
 
-int BtPlugin::set(const std::string &key, int val)
+int BtPlugin::set(const std::string &key, int val, int *oldVal)
 {
        BtAction *action = btFactory.createAction(key);
        RETVM_IF(nullptr == action, MODES_ERROR_INVALID_PARAMETER, "action(%s) is null", key.c_str());
@@ -68,7 +68,7 @@ int BtPlugin::set(const std::string &key, int val)
        return btRet;
 }
 
-int BtPlugin::set(const std::string &key, double val)
+int BtPlugin::set(const std::string &key, double val, double *oldVal)
 {
        BtAction *action = btFactory.createAction(key);
        RETVM_IF(nullptr == action, MODES_ERROR_INVALID_PARAMETER, "action(%s) is null", key.c_str());
@@ -80,7 +80,7 @@ int BtPlugin::set(const std::string &key, double val)
        return btRet;
 }
 
-int BtPlugin::set(const std::string &key, bool val)
+int BtPlugin::set(const std::string &key, bool val, bool *oldVal)
 {
        BtAction *action = btFactory.createAction(key);
        RETVM_IF(nullptr == action, MODES_ERROR_INVALID_PARAMETER, "action(%s) is null", key.c_str());
@@ -92,7 +92,7 @@ int BtPlugin::set(const std::string &key, bool val)
        return btRet;
 }
 
-int BtPlugin::set(const std::string &key, const std::string &val)
+int BtPlugin::set(const std::string &key, const std::string &val, std::string *oldVal)
 {
        BtAction *action = btFactory.createAction(key);
        RETVM_IF(nullptr == action, MODES_ERROR_INVALID_PARAMETER, "action(%s) is null", key.c_str());
index 86aa9d6..66559b2 100644 (file)
@@ -30,10 +30,10 @@ private:
 public:
        VconfPlugin();
 
-       int set(const std::string &key, int val) override;
-       int set(const std::string &key, double val) override;
-       int set(const std::string &key, bool val) override;
-       int set(const std::string &key, const std::string &val) override;
+       int set(const std::string &key, int val, int *oldVal) override;
+       int set(const std::string &key, double val, double *oldVal) override;
+       int set(const std::string &key, bool val, bool *oldVal) override;
+       int set(const std::string &key, const std::string &val, std::string *oldVal) override;
 
        int getInt(const std::string &key) override;
        double getDouble(const std::string &key) override;
@@ -56,7 +56,7 @@ VconfPlugin::VconfPlugin()
        setName("vconf");
 }
 
-int VconfPlugin::set(const std::string &key, int val)
+int VconfPlugin::set(const std::string &key, int val, int *oldVal)
 {
        DBG("set<int>(%s, %d)", key.c_str(), val);
 
@@ -71,7 +71,7 @@ int VconfPlugin::set(const std::string &key, int val)
        return MODES_ERROR_NONE;
 }
 
-int VconfPlugin::set(const std::string &key, double val)
+int VconfPlugin::set(const std::string &key, double val, double *oldVal)
 {
        DBG("set<double>(%s, %lf)", key.c_str(), val);
 
@@ -85,7 +85,7 @@ int VconfPlugin::set(const std::string &key, double val)
        }
        return MODES_ERROR_NONE;
 }
-int VconfPlugin::set(const std::string &key, bool val)
+int VconfPlugin::set(const std::string &key, bool val, bool *oldVal)
 {
        DBG("set<bool>(%s, %d)", key.c_str(), val);
 
@@ -100,7 +100,7 @@ int VconfPlugin::set(const std::string &key, bool val)
        return MODES_ERROR_NONE;
 }
 
-int VconfPlugin::set(const std::string &key, const std::string &val)
+int VconfPlugin::set(const std::string &key, const std::string &val, std::string *oldVal)
 {
        DBG("set<string>(%s, %s)", key.c_str(), val.c_str());
 
index 2a4d311..dcac333 100644 (file)
@@ -62,6 +62,26 @@ int WifiAction::set(const std::string &val)
        return MODES_ERROR_NOT_SUPPORTED;
 }
 
+int WifiAction::get(int *val)
+{
+       return MODES_ERROR_NOT_SUPPORTED;
+}
+
+int WifiAction::get(double *val)
+{
+       return MODES_ERROR_NOT_SUPPORTED;
+}
+
+int WifiAction::get(bool *val)
+{
+       return MODES_ERROR_NOT_SUPPORTED;
+}
+int WifiAction::get(std::string *val)
+{
+       return MODES_ERROR_NOT_SUPPORTED;
+}
+
+
 bool WifiAction::isWifiActivate()
 {
        RETV_IF(!isWifiManagerEnable(), false);
index 52d3691..4f0ef9a 100644 (file)
@@ -32,7 +32,10 @@ public:
        virtual int set(double val);
        virtual int set(bool val);
        virtual int set(const std::string &val);
-
+       virtual int get(int *val);
+       virtual int get(double *val);
+       virtual int get(bool *val);
+       virtual int get(std::string *val);
 protected:
        bool isWifiManagerEnable();
        const std::string& strErr(int err);
index 25ae6c0..da4c059 100644 (file)
@@ -68,3 +68,15 @@ int WifiActionPower::set(bool val)
        INFO("Wifi power [%s]", val ? "On" : "Off");
        return MODES_ERROR_NONE;
 }
+
+int WifiActionPower::get(bool *val)
+{
+       RETV_IF(!isWifiManagerEnable(), MODES_ERROR_NOT_SUPPORTED);
+
+       if (val)
+               *val = isWifiActivate();
+       else
+               return MODES_ERROR_INVALID_PARAMETER;
+
+       return MODES_ERROR_NONE;
+}
index d415ee0..9c76c12 100644 (file)
@@ -25,6 +25,7 @@ public:
        WifiActionPower();
 
        int set(bool val) override;
+       int get(bool *val) override;
 private:
        static void activate_cb(wifi_manager_error_e result, void *user_data);
        static void deactivate_cb(wifi_manager_error_e result, void *user_data);
index c56761c..f869917 100644 (file)
@@ -31,10 +31,10 @@ public:
        WifiPlugin();
        ~WifiPlugin();
 
-       int set(const std::string &key, int val) override;
-       int set(const std::string &key, double val) override;
-       int set(const std::string &key, bool val) override;
-       int set(const std::string &key, const std::string &val) override;
+       int set(const std::string &key, int val, int *oldVal) override;
+       int set(const std::string &key, double val, double *oldVal) override;
+       int set(const std::string &key, bool val, bool *oldVal) override;
+       int set(const std::string &key, const std::string &val, std::string *oldVal) override;
 private:
        WifiFactory wifiFactory;
 };
@@ -58,49 +58,62 @@ WifiPlugin::~WifiPlugin()
 {
 }
 
-int WifiPlugin::set(const std::string &key, int val)
+int WifiPlugin::set(const std::string &key, int val, int *oldVal)
 {
        WifiAction *action = wifiFactory.createAction(key);
        RETVM_IF(nullptr == action, MODES_ERROR_INVALID_PARAMETER, "action(%s) is null", key.c_str());
 
        DBG("set [%s, %d]", key.c_str(), val);
 
+       if (oldVal)
+               ERR("Not Supported");
+
        int ret = action->set(val);
        wifiFactory.destroyAction(action);
        return ret;
 }
 
-int WifiPlugin::set(const std::string &key, double val)
+int WifiPlugin::set(const std::string &key, double val, double *oldVal)
 {
        WifiAction *action = wifiFactory.createAction(key);
        RETVM_IF(nullptr == action, MODES_ERROR_INVALID_PARAMETER, "action(%s) is null", key.c_str());
 
        DBG("set [%s, %f]", key.c_str(), val);
 
+       if (oldVal)
+               ERR("Not Supported");
+
        int ret = action->set(val);
        wifiFactory.destroyAction(action);
        return ret;
 }
 
-int WifiPlugin::set(const std::string &key, bool val)
+int WifiPlugin::set(const std::string &key, bool val, bool *oldVal)
 {
        WifiAction *action = wifiFactory.createAction(key);
        RETVM_IF(nullptr == action, MODES_ERROR_INVALID_PARAMETER, "action(%s) is null", key.c_str());
 
        DBG("set [%s, %s]", key.c_str(), (val ? "on" : "off"));
 
+       if (oldVal)
+               action->get(oldVal);
        int ret = action->set(val);
+
        wifiFactory.destroyAction(action);
+
        return ret;
 }
 
-int WifiPlugin::set(const std::string &key, const std::string &val)
+int WifiPlugin::set(const std::string &key, const std::string &val, std::string *oldVal)
 {
        WifiAction *action = wifiFactory.createAction(key);
        RETVM_IF(nullptr == action, MODES_ERROR_INVALID_PARAMETER, "action(%s) is null", key.c_str());
 
        DBG("set [%s, %s]", key.c_str(), val.c_str());
 
+       if (oldVal)
+               ERR("Not Supported");
+
        int ret = action->set(val);
        wifiFactory.destroyAction(action);
        return ret;