Revise Emulator support
authorDanny Jeongseok Seo <S.Seo@samsung.com>
Thu, 19 Jul 2012 04:33:07 +0000 (13:33 +0900)
committerDanny Jeongseok Seo <S.Seo@samsung.com>
Thu, 19 Jul 2012 04:33:07 +0000 (13:33 +0900)
debian/changelog
packaging/net-config.spec
src/emulator.c
src/network-state.c

index c516927..308e9f7 100644 (file)
@@ -1,3 +1,11 @@
+net-config (0.1.83) unstable; urgency=low
+
+  * Revise emulator support
+  * Git: slp/pkgs/n/net-config
+  * Tag: net-config_0.1.83
+
+ -- Danny Jeongseok Seo <s.seo@samsung.com>  Thu, 17 May 2012 17:55:47 +0900
+
 net-config (0.1.82) unstable; urgency=low
 
   * Check NULL: Wi-Fi technology state
index 3c4bba2..a72d288 100644 (file)
@@ -2,7 +2,7 @@
 
 Name:       net-config
 Summary:    TIZEN Network Configuration Module
-Version:    0.1.82
+Version:    0.1.83
 Release:    1
 Group:      System/Network
 License:    Apache License Version 2.0
index 3a1ed7e..1dda48b 100644 (file)
  *
  */
 
-#include <stdio.h>
-#include <string.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/ioctl.h>
 #include <arpa/inet.h>
 #include <net/if.h>
+#include <sys/utsname.h>
 #include <vconf.h>
 #include <vconf-keys.h>
 
@@ -36,39 +35,18 @@ static gboolean netconfig_is_emulated = FALSE;
 
 static gboolean __netconfig_emulator_test_emulation_env(void)
 {
-       /* TODO: this module contains exact keyword of Emulator virtual CPU.
-        *       It will be revised with emulator "uname" system information.
-        */
-       const char CPUINFO[] = "/proc/cpuinfo";
-       const char EMUL_VIRTUAL_CPU[] = "QEMU Virtual CPU";
-       const int BUF_LEN_MAX = 255;
-       char buf[BUF_LEN_MAX];
-       char *model_name = NULL;
-       gboolean ret = FALSE;
-       FILE* fp = NULL;
+       struct utsname buf;
+       const char *EMUL_UTSNAME_MACHINE_SUFFIX = "emulated";
 
        DBG("Test emulation environment");
 
-       if ((fp = fopen(CPUINFO, "r")) == NULL) {
-               ERR("Failed to open %s", CPUINFO);
-               return FALSE;
-       }
-
-       while (fgets(buf, BUF_LEN_MAX, fp)) {
-               if (g_ascii_strncasecmp(buf, "model name", 10) != 0)
-                       continue;
-
-               model_name = g_strstr_len(buf, BUF_LEN_MAX-1, EMUL_VIRTUAL_CPU);
-
-               if (model_name != NULL)
-                       ret = TRUE;
-
-               break;
-       }
+       uname(&buf);
 
-       fclose(fp);
+       if (buf.machine != NULL &&
+                       g_str_has_suffix(buf.machine, EMUL_UTSNAME_MACHINE_SUFFIX) == TRUE)
+               return TRUE;
 
-       return ret;
+       return FALSE;
 }
 
 static void __netconfig_emulator_set_ip(void)
index 7986f9b..4a81a5d 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "log.h"
 #include "neterror.h"
+#include "emulator.h"
 #include "network-state.h"
 
 #define NETCONFIG_NETWORK_STATE_PATH   "/net/netconfig/network"
@@ -163,6 +164,9 @@ gboolean netconfig_iface_network_state_update_default_connection_info(
        DBG("connection type (%s), connection state(%s), ip_addr(%s), proxy_addr(%s)",
                        connection_type, connection_state, ip_addr, proxy_addr);
 
+       if (netconfig_emulator_is_emulated() == TRUE)
+               return FALSE;
+
        vconf_get_int(VCONFKEY_NETWORK_WIFI_STATE, &wifi_state);
        vconf_get_int(VCONFKEY_NETWORK_STATUS, &previous_network_status);
 
@@ -179,6 +183,8 @@ gboolean netconfig_iface_network_state_update_default_connection_info(
                vconf_set_str(VCONFKEY_NETWORK_PROXY, "");
 
                vconf_set_int(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, 0);
+
+               DBG("Successfully clear IP and PROXY up");
        } else if (g_str_equal(connection_state, "ready") == TRUE ||
                        g_str_equal(connection_state, "online") == TRUE) {
                ip = vconf_get_str(VCONFKEY_NETWORK_IP);
@@ -212,6 +218,8 @@ gboolean netconfig_iface_network_state_update_default_connection_info(
                        vconf_set_str(VCONFKEY_NETWORK_PROXY, proxy_addr);
 
                vconf_set_int(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, 1);
+
+               DBG("Successfully update default network configuration");
        }
 
        return TRUE;