From: Seonah Moon Date: Tue, 19 Dec 2017 02:00:50 +0000 (+0900) Subject: Add feature check code to remove the build macro X-Git-Tag: accepted/tizen/unified/20171227.062310~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F75%2F164375%2F3;p=platform%2Fcore%2Fconnectivity%2Fnet-config.git Add feature check code to remove the build macro Change-Id: Ief06e3449b330e31191291044078b588b55fe098 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index c7e44a0..293111c 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,14 +57,6 @@ IF(TIZEN_WLAN_USE_P2P_INTERFACE) ADD_DEFINITIONS(-DTIZEN_WLAN_USE_P2P_INTERFACE) ENDIF(TIZEN_WLAN_USE_P2P_INTERFACE) -IF(TIZEN_P2P_ENABLE) - ADD_DEFINITIONS(-DTIZEN_P2P_ENABLE) -ENDIF(TIZEN_P2P_ENABLE) - -IF(TIZEN_TETHERING_ENABLE) - ADD_DEFINITIONS(-DTIZEN_TETHERING_ENABLE) -ENDIF(TIZEN_TETHERING_ENABLE) - IF(TIZEN_CAPTIVE_PORTAL) ADD_DEFINITIONS(-DTIZEN_CAPTIVE_PORTAL) SET(SRCS ${SRCS} src/utils/network-accessibility.c) diff --git a/include/util.h b/include/util.h index c017276..bf74a1a 100755 --- a/include/util.h +++ b/include/util.h @@ -25,6 +25,7 @@ extern "C" { #endif #include +#include #include "wifi.h" #include "plugin.h" @@ -33,6 +34,10 @@ extern "C" { #define MAX_SIZE_ERROR_BUFFER 256 +#define ETHERNET_FEATURE "http://tizen.org/feature/network.ethernet" +#define TETHERING_FEATURE "http://tizen.org/feature/network.tethering" +#define WIFI_DIRECT_FEATURE "http://tizen.org/feature/network.wifi.direct" + gboolean netconfig_check_passphrase(const gchar *service, const char *passphrase); GKeyFile *netconfig_keyfile_load(const char *pathname); void netconfig_keyfile_save(GKeyFile *keyfile, const char *pathname); @@ -94,6 +99,7 @@ gboolean __netconfig_wifi_get_aka_authdata(Wifi *wifi, gboolean __netconfig_wifi_get_sim_authdata(Wifi *wifi, GDBusMethodInvocation *context, struct wifi_authentication_data **data); +bool netconfig_check_feature_supported(const char *feature); void netconfig_plugin_init(); void netconfig_plugin_deinit(); gboolean netconfig_get_headed_plugin_flag(); diff --git a/packaging/net-config.spec b/packaging/net-config.spec index ea37156..bfb3fac 100755 --- a/packaging/net-config.spec +++ b/packaging/net-config.spec @@ -1,6 +1,6 @@ Name: net-config Summary: TIZEN Network Configuration service -Version: 1.1.119 +Version: 1.1.120 Release: 2 Group: System/Network License: Apache-2.0 @@ -78,12 +78,6 @@ cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} \ %if 0%{?model_build_feature_wlan_concurrent_mode} -DWLAN_CONCURRENT_MODE=1 \ %endif -%if ! 0%{?model_build_feature_wlan_p2p_disable} - -DTIZEN_P2P_ENABLE=1 \ -%endif -%if ! 0%{?model_build_feature_network_tethering_disable} - -DTIZEN_TETHERING_ENABLE=1 \ -%endif %if 0%{?model_build_feature_wlan_wearable} == 1 -DTIZEN_WEARABLE=1 \ -DTIZEN_CAPTIVE_PORTAL=1 \ diff --git a/src/main.c b/src/main.c index 26451f6..c19c3b1 100755 --- a/src/main.c +++ b/src/main.c @@ -42,8 +42,6 @@ static GMainLoop *main_loop = NULL; -#define ETHERNET_FEATURE "http://tizen.org/feature/network.ethernet" - /*Poll the ethernet Cable Plug-in /Plug-out status at every 1000 ms*/ #define ETH_POLLING_TIME 1000 @@ -81,7 +79,6 @@ int main(int argc, char *argv[]) { int ret; int check_ethernet_monitor_timer = 0; - bool ethernet_feature_supported = FALSE; umask(0077); @@ -135,15 +132,11 @@ int main(int argc, char *argv[]) if (TIZEN_TV && emulator_is_emulated() == FALSE) __netconfig_set_ether_macaddr(); - if (!system_info_get_platform_bool(ETHERNET_FEATURE, ðernet_feature_supported)) { - if (ethernet_feature_supported == TRUE) { - /* Register the callback to check the ethernet Plug-in /Plug-out Status */ - check_ethernet_monitor_timer = g_timeout_add(ETH_POLLING_TIME, - __net_ethernet_cable_status_polling_callback, - &check_ethernet_monitor_timer); - } - } else { - ERR("Error - Feature getting from System Info"); + if (netconfig_check_feature_supported(ETHERNET_FEATURE)) { + /* Register the callback to check the ethernet Plug-in /Plug-out Status */ + check_ethernet_monitor_timer = g_timeout_add(ETH_POLLING_TIME, + __net_ethernet_cable_status_polling_callback, + &check_ethernet_monitor_timer); } netconfig_plugin_init(); diff --git a/src/utils/util.c b/src/utils/util.c index dc41472..bec7fc2 100755 --- a/src/utils/util.c +++ b/src/utils/util.c @@ -317,31 +317,31 @@ void netconfig_wifi_device_picker_service_stop(void) gboolean netconfig_is_wifi_direct_on(void) { -#if defined TIZEN_P2P_ENABLE + if (!netconfig_check_feature_supported(WIFI_DIRECT_FEATURE)) + return FALSE; + int wifi_direct_state = 0; netconfig_vconf_get_int(VCONFKEY_WIFI_DIRECT_STATE, &wifi_direct_state); DBG("Wi-Fi direct mode %d", wifi_direct_state); return (wifi_direct_state != 0) ? TRUE : FALSE; -#else - return FALSE; -#endif } gboolean netconfig_is_wifi_tethering_on(void) { -#if defined TIZEN_TETHERING_ENABLE - int wifi_tethering_state = 0; - - netconfig_vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_MODE, &wifi_tethering_state); - DBG("Wi-Ti tethering mode %d", wifi_tethering_state); - if ((wifi_tethering_state & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI) - || (wifi_tethering_state & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI_AP)) { - DBG("Mobile AP is on"); - return TRUE; + if (netconfig_check_feature_supported(TETHERING_FEATURE)) { + int wifi_tethering_state = 0; + + netconfig_vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_MODE, &wifi_tethering_state); + DBG("Wi-Ti tethering mode %d", wifi_tethering_state); + if ((wifi_tethering_state & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI) + || (wifi_tethering_state & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI_AP)) { + DBG("Mobile AP is on"); + return TRUE; + } } -#endif + DBG("Mobile AP is off"); return FALSE; } @@ -870,7 +870,11 @@ int netconfig_del_route_ipv6(gchar *ip_addr, gchar *interface, gchar *gateway, u gboolean handle_launch_direct(Wifi *wifi, GDBusMethodInvocation *context) { -#if defined TIZEN_P2P_ENABLE + if (!netconfig_check_feature_supported(WIFI_DIRECT_FEATURE)) { + wifi_complete_launch_direct(wifi, context); + return FALSE; + } + int ret = 0; DBG("Launch Wi-Fi direct daemon"); @@ -887,10 +891,6 @@ gboolean handle_launch_direct(Wifi *wifi, GDBusMethodInvocation *context) wifi_complete_launch_direct(wifi, context); return TRUE; -#else - wifi_complete_launch_direct(wifi, context); - return FALSE; -#endif } int execute_mdnsd_script(char* op) @@ -1274,6 +1274,22 @@ tizen_profile_t _get_tizen_profile() return profile; } +bool netconfig_check_feature_supported(const char *feature) +{ + bool is_supported = false; + + if (!system_info_get_platform_bool(feature, &is_supported)) { + if (is_supported != TRUE) + DBG("%s is not supported", feature); + else + DBG("%s is supported", feature); + } else { + ERR("Error - Feature getting from System Info"); + } + + return is_supported; +} + void netconfig_plugin_init() { handle_headed = dlopen(HEADED_PLUGIN_FILEPATH, RTLD_NOW); diff --git a/src/wifi-firmware.c b/src/wifi-firmware.c index d9a41f9..34fe649 100755 --- a/src/wifi-firmware.c +++ b/src/wifi-firmware.c @@ -80,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(WIFI_DIRECT_FEATURE)) + return -ENODEV; + int rv = 0; const char *path = WLAN_DRIVER_SCRIPT; char *const args[] = { "/usr/bin/wlan.sh", "p2p", NULL }; @@ -98,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(WIFI_DIRECT_FEATURE)) + return -ENODEV; + int rv = 0; const char *path = WLAN_DRIVER_SCRIPT; char *const args[] = { "/usr/bin/wlan.sh", "stop", NULL }; @@ -121,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(TETHERING_FEATURE)) + return -ENODEV; + int rv = 0; const char *path = WLAN_DRIVER_SCRIPT; char *const args[] = { "/usr/bin/wlan.sh", "softap", NULL }; @@ -143,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(TETHERING_FEATURE)) + return -ENODEV; + int rv = 0; const char *path = WLAN_DRIVER_SCRIPT; char *const args[] = { "/usr/bin/wlan.sh", "stop", NULL }; @@ -166,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) @@ -263,11 +259,10 @@ int netconfig_wifi_firmware(enum netconfig_wifi_firmware type, gboolean enable) #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) + else if (netconfig_check_feature_supported(WIFI_DIRECT_FEATURE) + && type == NETCONFIG_WIFI_P2P) netconfig_interface_up(WLAN_P2P_IFACE_NAME); #endif -#endif return -EALREADY; }