Apply wifi_manager API to avoid of calling vconf func 47/185047/1
authorjinwang.an <jinwang.an@samsung.com>
Wed, 25 Jul 2018 12:14:28 +0000 (21:14 +0900)
committerjinwang.an <jinwang.an@samsung.com>
Wed, 25 Jul 2018 12:14:28 +0000 (21:14 +0900)
Change-Id: I4c11c6b3b35676aa500751f42237f8b551b44e31
Signed-off-by: jinwang.an <jinwang.an@samsung.com>
CMakeLists.txt
org.tizen.watch-setting.xml.in
packaging/org.tizen.watch-setting.spec
src/setting-connection.c

index dbfb0ea6b90a09700ad271f60203dee030ac52fc..3abd058ea38e3843486f95125b194d5dbaff2f0b 100755 (executable)
@@ -89,6 +89,7 @@ pkg_check_modules(pkgs REQUIRED elementary ecore-imf appcore-common appcore-efl
                                libtzplatform-config
                                efl-extension
                                capi-network-wifi
+                               capi-network-wifi-manager
                                capi-network-nfc
                                storage
                                capi-base-utils-i18n
index 694e5ba3ebe562165d9d6b8beec7dc64c56d5037..823288ad55bf986fcb4859985b371a40ad688c64 100755 (executable)
                <privilege>http://tizen.org/privilege/display</privilege>
                <privilege>http://tizen.org/privilege/telephony.admin</privilege>
                <privilege>http://tizen.org/privilege/telephony</privilege>
+               <privilege>http://tizen.org/privilege/network.get</privilege>
                <!--
                <privilege>http://tizen.org/privilege/appmanager.kill</privilege>
                <privilege>http://tizen.org/privilege/account.read</privilege>
index a7280f7a8d500b5874db95046ebfacbdd9c25782..28159eef5fc79f09e20739887bf2be4884d52be7 100644 (file)
@@ -57,6 +57,7 @@ BuildRequires: pkgconfig(libtzplatform-config)
 BuildRequires: pkgconfig(glib-2.0)
 BuildRequires: pkgconfig(efl-extension)
 BuildRequires: pkgconfig(capi-network-wifi)
+BuildRequires: pkgconfig(capi-network-wifi-manager)
 BuildRequires: pkgconfig(capi-network-nfc)
 BuildRequires: pkgconfig(storage)
 BuildRequires: pkgconfig(capi-base-utils-i18n)
index ac7a98a96471bf7d9f34fd8149ebb575717536dc..1667f7a9df42475713a5434b0887ce6f47126e5c 100644 (file)
@@ -24,6 +24,7 @@
 #include <ITapiSim.h>
 #include <bluetooth.h>
 #include <nfc.h>
+#include <wifi-manager.h>
 
 #include "setting-connection.h"
 #include "util.h"
@@ -43,6 +44,7 @@ static Elm_Object_Item *g_location_item = NULL;
 
 static int is_supported_telephony = 0;
 static TapiHandle *tel_handle = NULL;
+static wifi_manager_h wifi_handle = { 0 };
 
 void _bluetooth_cb(void *data, Evas_Object *obj, void *event_info);
 void _wifi_cb(void *data, Evas_Object *obj, void *event_info);
@@ -53,6 +55,7 @@ void _location_cb(void *data, Evas_Object *obj, void *event_info);
 
 static void bt_status_changed_cb(int result, bt_adapter_state_e adapter_state, void *user_data);
 static void wifi_status_vconf_changed_cb(keynode_t *key, void *data);
+static void wifi_status_changed_cb(wifi_manager_device_state_e state, void *user_data);
 static void nfc_status_vconf_changed_cb(bool activated, void *user_data);
 static void location_status_vconf_changed_cb(keynode_t *key, void *data);
 
@@ -104,7 +107,6 @@ void _clear_connection_resource()
 
        g_app_context = NULL;
 
-       unregister_vconf_changing(VCONFKEY_WIFI_STATE, wifi_status_vconf_changed_cb);
        unregister_vconf_changing(VCONFKEY_LOCATION_USE_MY_LOCATION, location_status_vconf_changed_cb);
 
        if (tel_handle) {
@@ -122,6 +124,9 @@ void _clear_connection_resource()
        if (nfc_ret != NFC_ERROR_NONE)
                ERR("ERROR NFC deinit %d", nfc_ret);
 
+       wifi_manager_unset_device_state_changed_cb(wifi_handle);
+       int wifi_ret = wifi_manager_deinitialize(wifi_handle);
+               ERR("ERROR WIFI deinit %d", wifi_ret);
 
 }
 
@@ -519,6 +524,7 @@ char *_gl_connection_title_get(void *data, Evas_Object *obj, const char *part)
        int ret = 0;
        bool is_on = 0;
        bt_adapter_state_e bt_val = 0;
+       bool is_activated = 0;
 
        if (!strcmp(part, "elm.text")) {
                snprintf(buf, sizeof(buf) - 1, "%s", _(connection_menu_its[id->menu_array_idx].name));
@@ -532,8 +538,10 @@ char *_gl_connection_title_get(void *data, Evas_Object *obj, const char *part)
                        snprintf(buf, sizeof(buf) - 1, text_color, bt_val ? _("IDS_COM_BODY_ON_ABB") : _("IDS_COM_BODY_OFF_ABB_M_STATUS"));
                        break;
                case SETTING_CONNECTION_WIFI:
-                       vconf_get_int(VCONFKEY_WIFI_STATE, &val);
-                       snprintf(buf, sizeof(buf) - 1, text_color, val ? _("IDS_COM_BODY_ON_ABB") : _("IDS_COM_BODY_OFF_ABB_M_STATUS"));
+                       ret = wifi_manager_is_activated(wifi_handle, &is_activated);
+                       if (ret != WIFI_MANAGER_ERROR_NONE)
+                               DBG("ERROR WIFI activated checker %d", ret);
+                       snprintf(buf, sizeof(buf) - 1, text_color, is_activated ? _("IDS_COM_BODY_ON_ABB") : _("IDS_COM_BODY_OFF_ABB_M_STATUS"));
                        break;
                case SETTING_CONNECTION_NFC:
                        is_on = nfc_manager_is_activated();
@@ -714,7 +722,6 @@ Evas_Object *_create_connection_list(void *data)
 
        g_connection_genlist = genlist;
 
-       register_vconf_changing(VCONFKEY_WIFI_STATE, wifi_status_vconf_changed_cb, ad);
        register_vconf_changing(VCONFKEY_LOCATION_USE_MY_LOCATION, location_status_vconf_changed_cb, ad);
 
 
@@ -735,6 +742,14 @@ Evas_Object *_create_connection_list(void *data)
        if (nfc_ret != NFC_ERROR_NONE)
                ERR("ERROR NFC register changed cb %d", nfc_ret);
 
+       int wifi_ret = wifi_manager_initialize(&wifi_handle);
+       if (wifi_ret != WIFI_MANAGER_ERROR_NONE)
+               DBG("ERROR WIFI init%d", wifi_ret);
+
+       wifi_ret = wifi_manager_set_device_state_changed_cb(wifi_handle, wifi_status_changed_cb, ad);
+       if (wifi_ret != WIFI_MANAGER_ERROR_NONE)
+               DBG("ERROR WIFI set changed cb%d", wifi_ret);
+
        return genlist;
 }
 
@@ -752,9 +767,9 @@ static void bt_status_changed_cb(int result, bt_adapter_state_e adapter_state, v
        _update_connection_list(g_BT_item);
 }
 
-static void wifi_status_vconf_changed_cb(keynode_t *key, void *data)
+static void wifi_status_changed_cb(wifi_manager_device_state_e state, void *user_data)
 {
-       DBG("Setting - wifi_status_vconf_changed_cb() is called!!");
+       DBG("Setting - wifi_status_changed_cb() is called!!");
        _update_connection_list(g_WIFI_item);
 }