return MODES_ERROR_NONE;
}
-int AppActionLaunch::undo()
+void AppActionLaunch::undo()
{
bool running;
app_context_h runAppContext;
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());
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()
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);
~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;
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)
return MODES_ERROR_NONE;
}
-int BtActionPower::undo()
+void BtActionPower::undo()
{
- return set(undoVal);
+ set(undoVal);
}
std::string BtActionPower::serialize()
BtActionPower();
int set(bool val) override;
- int undo() override;
+ void undo() override;
std::string serialize() override;
int parse(const std::string & archive) override;
private:
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;
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)
return modesRet;
}
-int DisplayAllowPalmTouch::undo()
+void DisplayAllowPalmTouch::undo()
{
- return set(true);
+ set(true);
}
std::string DisplayAllowPalmTouch::serialize()
~DisplayAllowPalmTouch();
int set(bool val) override;
- int undo() override;
+ void undo() override;
std::string serialize() override;
int parse(const std::string &archive) override;
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()
~DisplayBrightness();
int set(int val) override;
- int undo() override;
+ void undo() override;
std::string serialize() override;
int parse(const std::string &archive) override;
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;
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;
}
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()
~DisplayTimeout();
int set(int val) override;
- int undo() override;
+ void undo() override;
std::string serialize() override;
int parse(const std::string &archive) override;
return MODES_ERROR_NONE;
}
-int MediaPlayer::undo()
+void MediaPlayer::undo()
{
destroyPlayer(NULL);
- return MODES_ERROR_NONE;
}
~MediaPlayer() = default;
int set(std::string val) override;
- int undo() override;
+ void undo() override;
private:
int createPlayer();
static void destroyPlayer(void *data);
}
-int PkgStartSupportMode::undo()
+void PkgStartSupportMode::undo()
{
//If the appList is empty, it will be ignored at subroutines.
//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()
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:
~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;
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)
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;
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;
}
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);
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);
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);
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;
}
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);
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);
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);
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);
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());
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);
}
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);
}
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()
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);
}
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;
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()
int set(bool val);
bool get();
- int undo() override;
+ void undo() override;
std::string serialize() override;
int parse(const std::string &archive) override;
private:
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()
int set(double val);
double get();
- int undo() override;
+ void undo() override;
std::string serialize() override;
int parse(const std::string &archive) override;
private:
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()
int set(int val);
int get();
- int undo() override;
+ void undo() override;
std::string serialize() override;
int parse(const std::string &archive) override;
private:
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()
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:
return MODES_ERROR_NONE;
}
-int WifiActionPower::undo()
+void WifiActionPower::undo()
{
- return set(oldVal);
+ set(oldVal);
}
std::string WifiActionPower::serialize()
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)
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);
}
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;
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;
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)