From 81de5cb011cb41b20bf4560d964ba2493730e2be Mon Sep 17 00:00:00 2001 From: Shuhrat Dehkanov Date: Thu, 11 Jun 2015 17:10:06 +0900 Subject: [PATCH] Do not fail if proxy method has never been setup Currently, the UI fails if no proxy method was setup previously i.e., if vconf_get_int(VCONF_PROXY_METHOD, value) returns non-zero value. However, we think, that should not be the case as user has to be able to get to the proxy settings UI in order to setup proxy in the first place. This fix that issue and enables the UI even if vconf_get_int() fails. Change-Id: Ie7308f75d75ec252ebab931550c48482476a94ab Signed-off-by: Shuhrat Dehkanov --- ug/proxy/include/vconf_mgr.h | 4 ++-- ug/proxy/src/main_view.c | 30 +++++++++--------------------- ug/proxy/src/vconf_mgr.c | 44 +++++++++++++------------------------------- 3 files changed, 24 insertions(+), 54 deletions(-) diff --git a/ug/proxy/include/vconf_mgr.h b/ug/proxy/include/vconf_mgr.h index 363a73a..cd354aa 100644 --- a/ug/proxy/include/vconf_mgr.h +++ b/ug/proxy/include/vconf_mgr.h @@ -22,7 +22,7 @@ char *vconf_mgr_get_string_value(const char *key); int vconf_mgr_set_string_value(const char *key, const char *value); -int vconf_mgr_get_int_value(const char *key, int *value); -int vconf_mgr_set_int_value(const char *key, const int value); +void vconf_mgr_get_proxy_method(int *value); +int vconf_mgr_set_proxy_method(const int value); #endif /* __VCONF_MGR_H__ */ diff --git a/ug/proxy/src/main_view.c b/ug/proxy/src/main_view.c index 156f23c..2135982 100644 --- a/ug/proxy/src/main_view.c +++ b/ug/proxy/src/main_view.c @@ -36,7 +36,6 @@ #define IP_VALUE4 "value4" static const char *VCONF_NETWORK_TYPE = "db/menu/network/network_type"; -static const char *VCONF_PROXY_METHOD = "db/menu/proxy/method"; static const char *VCONF_PROXY_IP = "db/menu/proxy/ip"; static const char *VCONF_PROXY_URL = "db/menu/proxy/url"; @@ -426,7 +425,6 @@ static void _get_man_saved_value(char *des_ip, static int _get_proxy_method(struct _priv *priv) { int value; - int ret; char *str; if (!priv) { @@ -440,26 +438,12 @@ static int _get_proxy_method(struct _priv *priv) else priv->net_type = TYPE_WIRELESS; - value = 0; - ret = vconf_mgr_get_int_value(VCONF_PROXY_METHOD, &value); - if (ret != RET_SUCCESS) { - _ERR("vconf_mgr_get_int_value() failed."); - return RET_FAILED; - } - - switch (value) { - case 0: - priv->method = METHOD_NONE; - break; - case 1: - priv->method = METHOD_MAN; - break; - case 2: - priv->method = METHOD_AUTO; - break; - default: + vconf_mgr_get_proxy_method(&value); + if (value < METHOD_NONE || value > METHOD_AUTO) { + _ERR("Unsupported method is returned from vconf"); return RET_FAILED; } + priv->method = value; _get_man_saved_value(priv->ip, VCONF_PROXY_IP); @@ -1697,12 +1681,16 @@ static void _show_invalid_info_ctxpopup(struct _priv *priv, int ret) */ static int _save_to_vconf(struct _priv *priv) { + int ret; + if (!priv) { _ERR("The param is invalid.\n"); return RET_SUCCESS; } - vconf_mgr_set_int_value(VCONF_PROXY_METHOD, priv->method); + ret = vconf_mgr_set_proxy_method(priv->method); + if (ret != RET_SUCCESS) + return RET_FAILED; switch (priv->method) { case METHOD_NONE: diff --git a/ug/proxy/src/vconf_mgr.c b/ug/proxy/src/vconf_mgr.c index d018549..27ac3f3 100644 --- a/ug/proxy/src/vconf_mgr.c +++ b/ug/proxy/src/vconf_mgr.c @@ -19,6 +19,8 @@ #include "vconf_mgr.h" #include "i18n.h" +static const char *VCONF_PROXY_METHOD = "db/menu/proxy/method"; + /** * Gets the string value from vconf. * @@ -61,49 +63,29 @@ int vconf_mgr_set_string_value(const char *key, const char *value) } /** - * Gets the integer value from vconf. + * Gets the current proxy method value from vconf. * - * @param[in] key Vconf key - * @param[out] value The value - * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed; + * @param[out]: value : 0 - none; 1 - manual; 2 - auto. + * @return void. */ -int vconf_mgr_get_int_value(const char *key, int *value) +void vconf_mgr_get_proxy_method(int *value) { - int ret; - - if (!key || !value) { - _ERR("the param is invalid."); - return RET_FAILED; - } - - ret = vconf_get_int(key, value); - if (ret != 0) { - _ERR("vconf get int failed"); - return RET_FAILED; + if (vconf_get_int(VCONF_PROXY_METHOD, value) != 0) { + /* failed to get value from vconf, assume none set */ + *value = METHOD_NONE; } - - return RET_SUCCESS; } /** - * Sets the integer value to vconf. + * Sets the user selected proxy method value to vconf. * - * @param[in] key Vconf key * @param[in] value The value * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed; */ -int vconf_mgr_set_int_value(const char *key, const int value) +int vconf_mgr_set_proxy_method(const int value) { - int ret; - - if (!key) { - _ERR("the param is invalid."); - return RET_FAILED; - } - - ret = vconf_set_int(key, value); - if (ret != 0) { - _ERR("vconf set int failed."); + if (vconf_set_int(VCONF_PROXY_METHOD, value) != 0) { + _ERR("Failed to set user selected proxy method to vconf"); return RET_FAILED; } -- 2.7.4