GDBusConnection *connection = NULL;
gboolean created = FALSE;
- if (network_info == NULL || network_info->connection == NULL) {
+ if ((network_info == NULL || network_info->connection == NULL) &&
+ access(CONTAINER_FILE, F_OK) == 0) {
+
+ connection = g_dbus_connection_new_for_address_sync(
+ DBUS_HOST_SYSTEM_BUS_ADDRESS,
+ G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT | G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION,
+ NULL, NULL, &error);
+ created = TRUE;
+ } else if (network_info == NULL || network_info->connection == NULL) {
connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
- /* LCOV_EXCL_START */
- if (connection == NULL) {
- if (error != NULL) {
- WIFI_LOG(WIFI_ERROR,
- "Failed to connect to the D-BUS daemon [%s]", error->message);
- g_error_free(error);
- }
- return NULL;
- }
- /* LCOV_EXCL_STOP */
created = TRUE;
} else {
connection = network_info->connection;
created = FALSE;
}
+ /* LCOV_EXCL_START */
+ if (connection == NULL) {
+ if (error != NULL) {
+ WIFI_LOG(WIFI_ERROR,
+ "Failed to connect to the D-BUS daemon [%s]", error->message);
+ g_error_free(error);
+ }
+ return NULL;
+ }
+ /* LCOV_EXCL_STOP */
+
reply = g_dbus_connection_call_sync(connection,
dest,
path,
*dbus_error = NET_ERR_UNKNOWN; //LCOV_EXCL_LINE
}
+ if (created)
+ g_object_unref(connection);
__NETWORK_FUNC_EXIT__;
return NULL;
}
__NETWORK_FUNC_EXIT__;
return Error;
}
+
+int _net_dbus_get_vconf_value(network_info_s *network_info,
+ const char *key, const char *type, int *ret, int *int_value, char **str_value)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e ret_error = NET_ERR_NONE;
+ GVariant *message = NULL;
+ GVariant *params = NULL;
+
+ params = g_variant_new("(ss)", key, type);
+ message = _net_invoke_dbus_method(network_info,
+ NETCONFIG_SERVICE, NETCONFIG_NETWORK_PATH,
+ NETCONFIG_NETWORK_INTERFACE, "RequestVconfValue",
+ params, &ret_error);
+
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get vconf value, key: %s", key);
+ __NETWORK_FUNC_EXIT__;
+ return ret_error;
+ }
+
+ g_variant_get(message, "(iis)", ret, int_value, str_value);
+
+ WIFI_LOG(WIFI_INFO, "Vconf key: %s, type: %s, ret: %d, int_value: %d, str_value: %s",
+ key, type, *ret, *int_value, *str_value);
+
+ g_variant_unref(message);
+
+ __NETWORK_FUNC_EXIT__;
+ return ret_error;
+}
int _net_dbus_set_country_code(network_info_s *network_info, const char *country);
int _net_dbus_get_country_code(network_info_s *network_info, char **country);
+int _net_dbus_get_vconf_value(network_info_s *network_info,
+ const char *key, const char *type, int *ret, int *int_value, char **str_value);
#ifdef __cplusplus
}
}
/* TODO */
- if (vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_MODE, &hotspot_state) != 0) {
+ if (_net_vconf_get_int(network_info, VCONFKEY_MOBILE_HOTSPOT_MODE, &hotspot_state) != 0) {
WIFI_LOG(WIFI_ERROR, "Failed to get vconf key of hotspot mode"); //LCOV_EXCL_LINE
__NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE
#include "network_internal.h"
#include "network_dbus.h"
+static gboolean in_container = FALSE;
+
//LCOV_EXCL_START
static char *__convert_eap_type_to_string(gchar eap_type)
{
}
}
+char *_net_vconf_get_str(network_info_s *network_info, const char *key)
+{
+ int ret = 0;
+ int int_value = 0;
+ char *str_value = NULL;
+
+ if (!in_container) {
+ str_value = vconf_get_str(key);
+ if (!str_value)
+ WIFI_LOG(WIFI_ERROR, "Failed to get vconfkey [%s] value", key);
+
+ return str_value;
+ }
+
+ if (_net_dbus_get_vconf_value(network_info, key, "string", &ret, &int_value, &str_value) != NET_ERR_NONE)
+ return NULL;
+
+ return str_value;
+}
+
+int _net_vconf_get_int(network_info_s *network_info, const char *key, int *value)
+{
+ int ret = 0;
+ int int_value = 0;
+ char *str_value = NULL;
+
+ if (!in_container) {
+ ret = vconf_get_int(key, value);
+ if (ret != VCONF_OK)
+ WIFI_LOG(WIFI_ERROR, "Failed to get vconfkey [%s] value", key);
+
+ return ret;
+ }
+
+ if (_net_dbus_get_vconf_value(network_info, key, "int", &ret, &int_value, &str_value) != NET_ERR_NONE)
+ return VCONF_ERROR;
+
+ *value = int_value;
+
+ if (str_value)
+ g_free(str_value);
+
+ return ret;
+}
+
+int _net_vconf_get_bool(network_info_s *network_info, const char *key, int *value)
+{
+ int ret = 0;
+ int int_value = 0;
+ char *str_value = NULL;
+
+ if (!in_container) {
+ ret = vconf_get_bool(key, value);
+ if (ret != VCONF_OK)
+ WIFI_LOG(WIFI_ERROR, "Failed to get vconfkey [%s] value", key);
+
+ return ret;
+ }
+
+ if (_net_dbus_get_vconf_value(network_info, key, "bool", &ret, &int_value, &str_value) != NET_ERR_NONE)
+ return VCONF_ERROR;
+
+ *value = int_value;
+
+ if (str_value)
+ g_free(str_value);
+
+ return ret;
+}
+
char* _net_print_error(net_err_e error)
{
switch (error) {
DBUS_HOST_SYSTEM_BUS_ADDRESS,
G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT | G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION,
NULL, NULL, &error);
+
+ if (!in_container)
+ in_container = TRUE;
} else
network_info->connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
int _net_get_tech_state(network_info_s *network_info,
GVariant *iter, network_tech_state_info_s* tech_state);
+
+char *_net_vconf_get_str(network_info_s *network_info, const char *key);
+int _net_vconf_get_int(network_info_s *network_info, const char *key, int *value);
+int _net_vconf_get_bool(network_info_s *network_info, const char *key, int *value);
+
char* _net_print_error(net_err_e error);
int _net_open_connection_with_wifi_info(network_info_s *network_info,
const net_wifi_connection_info_s* wifi_info);
*mac_address = g_strdup(buf);
fclose(fp);
} else {
- *mac_address = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
+ *mac_address = _net_vconf_get_str(wifi_handle->network_info, VCONFKEY_WIFI_BSSID_ADDRESS);
if (*mac_address == NULL) {
WIFI_LOG(WIFI_ERROR, "Failed to get vconf" //LCOV_EXCL_LINE
int activated = -1;
int flight_mode = -1;
- if (vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &flight_mode) != 0) {
+ if (_net_vconf_get_bool(wifi_handle->network_info, VCONFKEY_TELEPHONY_FLIGHT_MODE, &flight_mode) != 0) {
WIFI_LOG(WIFI_ERROR, "Failed to get vconf key of flight mode"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
}
/** When softap mode is enabled wifi device is in deactivated state,
so to search APs wifi_manager_netlink_scan() API is used.
When wifi device is in activated state use wifi_manager_scan() API instead. */
- if (vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_MODE, &is_on) != 0) {
+ if (_net_vconf_get_int(wifi_handle->network_info, VCONFKEY_MOBILE_HOTSPOT_MODE, &is_on) != 0) {
WIFI_LOG(WIFI_ERROR, "Failed to get vconf key of hotspot mode");
return WIFI_MANAGER_ERROR_OPERATION_FAILED;
}