Fix dbus method return value
[platform/core/connectivity/net-config.git] / src / wifi-firmware.c
index 1c940df..2195913 100755 (executable)
@@ -44,11 +44,9 @@ static int __netconfig_sta_firmware_start(void)
        char *const args[] = { "/usr/bin/wlan.sh", "start", NULL };
        char *const envs[] = { NULL };
 
-       if (TIZEN_WLAN_BOARD_SPRD) {
-               rv = netconfig_execute_file(path, args, envs);
-               if (rv < 0)
-                       return -EIO;
-       }
+       rv = netconfig_execute_file(path, args, envs);
+       if (rv < 0)
+               return -EIO;
 
        rv = netconfig_interface_up(WLAN_IFACE_NAME);
        if (rv != TRUE)
@@ -72,11 +70,9 @@ static int __netconfig_sta_firmware_stop(void)
        if (rv != TRUE)
                return -EIO;
 
-       if (TIZEN_WLAN_BOARD_SPRD) {
-               rv = netconfig_execute_file(path, args, envs);
-               if (rv < 0)
-                       return -EIO;
-       }
+       rv = netconfig_execute_file(path, args, envs);
+       if (rv < 0)
+               return -EIO;
 
        DBG("Successfully removed wireless device driver");
        return 0;
@@ -84,7 +80,9 @@ static int __netconfig_sta_firmware_stop(void)
 
 static int __netconfig_p2p_firmware_start(void)
 {
-#if defined TIZEN_P2P_ENABLE
+       if (!netconfig_check_feature_supported(NETCONFIG_SUPPORTED_FEATURE_WIFI_DIRECT))
+               return -ENODEV;
+
        int rv = 0;
        const char *path = WLAN_DRIVER_SCRIPT;
        char *const args[] = { "/usr/bin/wlan.sh", "p2p", NULL };
@@ -102,14 +100,13 @@ static int __netconfig_p2p_firmware_start(void)
 
        DBG("Successfully loaded p2p device driver");
        return 0;
-#else
-       return -ENODEV;
-#endif
 }
 
 static int __netconfig_p2p_firmware_stop(void)
 {
-#if defined TIZEN_P2P_ENABLE
+       if (!netconfig_check_feature_supported(NETCONFIG_SUPPORTED_FEATURE_WIFI_DIRECT))
+               return -ENODEV;
+
        int rv = 0;
        const char *path = WLAN_DRIVER_SCRIPT;
        char *const args[] = { "/usr/bin/wlan.sh", "stop", NULL };
@@ -125,14 +122,13 @@ static int __netconfig_p2p_firmware_stop(void)
 
        DBG("Successfully removed p2p device driver");
        return 0;
-#else
-       return -ENODEV;
-#endif
 }
 
 static int __netconfig_softap_firmware_start(void)
 {
-#if defined TIZEN_TETHERING_ENABLE
+       if (!netconfig_check_feature_supported(NETCONFIG_SUPPORTED_FEATURE_TETHERING))
+               return -ENODEV;
+
        int rv = 0;
        const char *path = WLAN_DRIVER_SCRIPT;
        char *const args[] = { "/usr/bin/wlan.sh", "softap", NULL };
@@ -147,14 +143,13 @@ static int __netconfig_softap_firmware_start(void)
 
        DBG("Successfully loaded softap device driver");
        return 0;
-#else
-       return -ENODEV;
-#endif
 }
 
 static int __netconfig_softap_firmware_stop(void)
 {
-#if defined TIZEN_TETHERING_ENABLE
+       if (!netconfig_check_feature_supported(NETCONFIG_SUPPORTED_FEATURE_TETHERING))
+               return -ENODEV;
+
        int rv = 0;
        const char *path = WLAN_DRIVER_SCRIPT;
        char *const args[] = { "/usr/bin/wlan.sh", "stop", NULL };
@@ -170,9 +165,6 @@ static int __netconfig_softap_firmware_stop(void)
 
        DBG("Successfully removed softap device driver");
        return 0;
-#else
-       return -ENODEV;
-#endif
 }
 
 static int __netconfig_wifi_firmware_start(enum netconfig_wifi_firmware type)
@@ -219,13 +211,6 @@ int netconfig_wifi_firmware(enum netconfig_wifi_firmware type, gboolean enable)
        static enum netconfig_wifi_firmware current_driver = NETCONFIG_WIFI_OFF;
        enum netconfig_wifi_firmware alias = type;
 
-#if defined WLAN_CONCURRENT_MODE
-       int flight_mode = 0;
-
-       if (type == NETCONFIG_WIFI_P2P)
-               alias = NETCONFIG_WIFI_STA;
-#endif
-
        DBG("Wi-Fi current firmware %d (type: %d %s)", current_driver, type,
                                                        enable == TRUE ? "enable" : "disable");
 
@@ -234,21 +219,6 @@ int netconfig_wifi_firmware(enum netconfig_wifi_firmware type, gboolean enable)
                        return -EALREADY;
                } else if (current_driver == alias) {
 
-#if defined WLAN_CONCURRENT_MODE
-                       netconfig_vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &flight_mode);
-                       if (flight_mode == 0 && type == NETCONFIG_WIFI_STA &&
-                                       netconfig_is_wifi_direct_on() == TRUE) {
-                               netconfig_interface_down(WIFI_IFNAME);
-
-                               return -EALREADY;
-                       }
-
-                       if (type == NETCONFIG_WIFI_P2P && wifi_state_get_technology_state() > NETCONFIG_WIFI_TECH_OFF) {
-                               netconfig_interface_down(WLAN_P2P_IFACE_NAME);
-
-                               return -EALREADY;
-                       }
-#endif
                        err = __netconfig_wifi_firmware_stop(type);
                        if (err < 0 && err != -EALREADY)
                                return err;
@@ -262,18 +232,8 @@ int netconfig_wifi_firmware(enum netconfig_wifi_firmware type, gboolean enable)
        }
 
        if (current_driver > NETCONFIG_WIFI_OFF) {
-               if (current_driver == alias) {
-
-#if defined WLAN_CONCURRENT_MODE
-                       if (type == NETCONFIG_WIFI_STA)
-                               netconfig_interface_up(WIFI_IFNAME);
-#if defined TIZEN_P2P_ENABLE
-                       else if (type == NETCONFIG_WIFI_P2P)
-                               netconfig_interface_up(WLAN_P2P_IFACE_NAME);
-#endif
-#endif
+               if (current_driver == alias)
                        return -EALREADY;
-               }
 
                return -EIO;
        }
@@ -291,7 +251,7 @@ gboolean handle_start(WifiFirmware *firmware, GDBusMethodInvocation *context, co
 {
        int err;
 
-       g_return_val_if_fail(firmware != NULL, FALSE);
+       g_return_val_if_fail(firmware != NULL, TRUE);
 
        DBG("Wi-Fi firmware start %s", device != NULL ? device : "null");
 
@@ -314,7 +274,7 @@ gboolean handle_start(WifiFirmware *firmware, GDBusMethodInvocation *context, co
                } else
                        netconfig_error_wifi_driver_failed(context);
 
-               return FALSE;
+               return TRUE;
        }
 
        wifi_firmware_complete_start(firmware, context);
@@ -325,7 +285,7 @@ gboolean handle_stop(WifiFirmware *firmware, GDBusMethodInvocation *context, con
 {
        int err;
 
-       g_return_val_if_fail(firmware != NULL, FALSE);
+       g_return_val_if_fail(firmware != NULL, TRUE);
 
        DBG("Wi-Fi firmware stop %s", device != NULL ? device : "null");
 
@@ -342,7 +302,7 @@ gboolean handle_stop(WifiFirmware *firmware, GDBusMethodInvocation *context, con
                else
                        netconfig_error_wifi_driver_failed(context);
 
-               return FALSE;
+               return TRUE;
        }
 
        wifi_firmware_complete_stop(firmware, context);