use wifi_get_mac_address-function to get MAC address
authorKalle Lampila <kalle.lampila@ixonos.com>
Mon, 18 Mar 2013 14:48:30 +0000 (16:48 +0200)
committerStanislav Radomskiy <Stanislavx.Radomskiy@intel.com>
Fri, 26 Apr 2013 07:48:28 +0000 (10:48 +0300)
fixing TDIS-4799

Use wifi_get_mac_address function to get MAC address istead read it from file.
Only some of kernel drivers writes MAC to file so is more generic solution
ask it via function.

Change-Id: I2694030acf7a12482d3a4d9e99afed607cbc344a
Signed-off-by: Kalle Lampila <kalle.lampila@ixonos.com>
setting-about/CMakeLists.txt
setting-about/include/setting-about-main.h
setting-about/src/setting-about-main.c

index 4ea3e20..e8cc88d 100755 (executable)
@@ -8,7 +8,7 @@ pkg_check_modules(pkgs_about REQUIRED
        elementary appcore-common appcore-efl
        ui-gadget-1
        capi-appfw-application capi-appfw-app-manager evas ecore
-       tapi bluetooth-api json-glib-1.0 capi-system-info capi-system-system-settings capi-network-bluetooth)
+       tapi bluetooth-api json-glib-1.0 capi-system-info capi-system-system-settings capi-network-bluetooth capi-network-wifi)
 
 FOREACH(flag ${pkgs_about_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index becb777..5c15c0d 100755 (executable)
@@ -21,7 +21,6 @@
 
 // #define SUPPORT_FOTA
 
-#define SETTING_ABOUT_MACINFO_PATH "/opt/etc/.mac.info"
 #define SETTING_ABOUT_POWER_SUPPLY_PATH "/sys/class/power_supply"
 #define SETTING_ABOUT_BD_ADDR_PATH "/opt/etc/.bd_addr"
 #define SETTING_ABOUT_STAT_PATH "/proc/stat"
index a2e5980..d71f8b0 100755 (executable)
@@ -23,6 +23,7 @@
 //#include <bluetooth-api.h>
 
 #include <bluetooth.h>
+#include <wifi.h>
 
 #include <app_manager.h>
 #include <system_info.h>
@@ -288,25 +289,17 @@ void setting_about_main_get_wifi_mac_address_string(char *str, int size)
        setting_retm_if(str == NULL, "str parameter is NULL");
        setting_retm_if(size < SETTING_ABOUT_WIFI_MAC_STR_LEN+1, "size parameter is wrong");
 
-       FILE *p = fopen(SETTING_ABOUT_MACINFO_PATH, "r");
+       char* mac_addr = NULL;
+       int status = wifi_get_mac_address(&mac_addr);
 
-       if (p) {
-               int size = fread(str, sizeof(char), SETTING_ABOUT_WIFI_MAC_STR_LEN, p);
-               if (size != SETTING_ABOUT_WIFI_MAC_STR_LEN) {
-                       SETTING_TRACE_ERROR("fail to call fread");
-               }
-               fclose(p);
-               p = NULL;
-       } else {
-               perror("open failed!");
+       if (mac_addr) {
+         safeCopyStr(str, mac_addr, SETTING_ABOUT_WIFI_MAC_STR_LEN);
+         free(mac_addr);
        }
 
        SETTING_TRACE_DEBUG("get_wifi_mac_address : %s", str);
 
-       int wifi_state = VCONFKEY_WIFI_OFF;
-       vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
-
-       if((safeStrLen(str) == 0) || (wifi_state == VCONFKEY_WIFI_OFF))
+       if ((status != WIFI_ERROR_NONE) || (safeStrLen(str) == 0))
                snprintf(str, size, "%s  (%s)", _("IDS_ST_HEADER_UNAVAILABLE"), _(SETTING_ABOUT_NEVER_TURN_WIFI_ON_STR));
 }