#include <glib.h>
#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
static mobile_ap_error_code_e __update_softap_settings(softap_settings_t *st,
gchar *ssid, gchar *passphrase, int hide_mode, softap_security_type_e security_type);
-static int __turn_off_wifi(TetheringObject *obj);
+static int __turn_off_wifi(Tethering *obj);
-static DBusGMethodInvocation *g_context = NULL;
+static GDBusMethodInvocation *g_context = NULL;
static guint wifi_recovery_timeout_id = 0;
static gboolean prev_wifi_on = FALSE;
static wifi_saved_settings wifi_settings = {0, NULL, NULL, 0};
+static softap_settings_t obj_softap_settings = {0, "", "", ""};
+softap_settings_t *_get_softap_settings()
+{
+ return &obj_softap_settings;
+}
static void _wifi_direct_state_cb(int error_code, wifi_direct_device_state_e state, void *user_data)
{
bool wifi_state = false;
return;
}
- TetheringObject *obj = (TetheringObject *)user_data;
+ Tethering *obj = (Tethering *)user_data;
int ret = 0;
if (state != WIFI_DIRECT_DEVICE_STATE_DEACTIVATED) {
if (ret != MOBILE_AP_ERROR_NONE) {
ERR("_enable_wifi_tethering is failed\n");
} else {
- _emit_mobileap_dbus_signal(obj, E_SIGNAL_WIFI_TETHER_ON, NULL);
+ tethering_emit_wifi_on(obj);
+ _create_tethering_active_noti();
}
DONE:
- dbus_g_method_return(g_context,
- MOBILE_AP_ENABLE_WIFI_TETHERING_CFM, ret);
+ tethering_complete_enable_wifi_tethering(obj, g_context, ret);
g_context = NULL;
g_free(wifi_settings.ssid);
return;
}
- TetheringObject *obj = (TetheringObject *)user_data;
+ Tethering *obj = (Tethering *)user_data;
int ret;
if (result != WIFI_ERROR_NONE) {
ERR("_enable_wifi_tethering is failed\n");
} else {
prev_wifi_on = TRUE;
- _emit_mobileap_dbus_signal(obj, E_SIGNAL_WIFI_TETHER_ON, NULL);
+ tethering_emit_wifi_on(obj);
+ _create_tethering_active_noti();
}
DONE:
- dbus_g_method_return(g_context,
- MOBILE_AP_ENABLE_WIFI_TETHERING_CFM, ret);
+ tethering_complete_enable_wifi_tethering(obj, g_context, ret);
+
g_context = NULL;
g_free(wifi_settings.ssid);
return;
}
-static int __turn_off_wifi(TetheringObject *obj)
+static int __turn_off_wifi(Tethering *obj)
{
int ret;
return wifi_direct_state != 0 ? TRUE : FALSE;
}
-static int __turn_off_wifi_direct(TetheringObject *obj)
+static int __turn_off_wifi_direct(Tethering *obj)
{
int ret;
return TRUE;
}
-mobile_ap_error_code_e _reload_softap_settings(TetheringObject *obj,
+mobile_ap_error_code_e _reload_softap_settings(Tethering *obj,
gchar *ssid, gchar *key, gint hide_mode, gint security_type)
{
gboolean backup_prev_wifi_on = prev_wifi_on;
mobile_ap_error_code_e ret;
- softap_settings_t *old_settings = &obj->softap_settings;
+ softap_settings_t *old_settings = _get_softap_settings();
softap_settings_t new_settings;
if (obj == NULL || ssid == NULL || !strlen(ssid)) {
ERR("_enable_wifi_tethering is failed : %d\n", ret);
return ret;
}
- _emit_mobileap_dbus_signal(obj, E_SIGNAL_WIFI_TETHER_ON, NULL);
+ tethering_emit_wifi_on(obj);
+ _create_tethering_active_noti();
return MOBILE_AP_ERROR_NONE;
}
-mobile_ap_error_code_e _reload_softap_settings_for_ap(TetheringObject *obj,
+mobile_ap_error_code_e _reload_softap_settings_for_ap(Tethering *obj,
gchar *ssid, gchar *key, gint hide_mode, gint security_type)
{
gboolean backup_prev_wifi_on = prev_wifi_on;
mobile_ap_error_code_e ret;
- softap_settings_t *old_settings = &obj->softap_settings;
+ softap_settings_t *old_settings = _get_softap_settings();
softap_settings_t new_settings;
if (obj == NULL || ssid == NULL || !strlen(ssid)) {
return MOBILE_AP_ERROR_NONE;
}
-void _add_wifi_device_to_array(softap_device_info_t *di, GPtrArray *array)
-{
- int i = 0;
- GIOChannel *io = NULL;
- gchar *line = NULL;
- gchar *device_name = NULL;
- gchar ip_addr[MOBILE_AP_STR_INFO_LEN] = {0, };
- gchar mac_addr[MOBILE_AP_STR_INFO_LEN] = {0, };
- gchar name[MOBILE_AP_STR_HOSTNAME_LEN] = {0, };
- gchar expire[MOBILE_AP_STR_INFO_LEN] = {0, };
- gchar extra[MOBILE_AP_STR_INFO_LEN] = {0, };
-
- int found = 0;
-
- for (i = 0; i < di->number; i++)
- SDBG("bssid[%d]:%s\n", i, di->bssid[i]);
-
- DBG("Number of connected device:%d\n", di->number);
-
- io = g_io_channel_new_file(DNSMASQ_LEASES_FILE, "r", NULL);
-
- while (g_io_channel_read_line(io, &line, NULL, NULL, NULL) ==
- G_IO_STATUS_NORMAL) {
- sscanf(line, "%19s %19s %19s %19s %19s", expire, mac_addr,
- ip_addr, name, extra);
- SDBG("mac_addr:%s ip_addr:%s name:%s expire:%s\n", mac_addr,
- ip_addr, name, expire);
-
- for (i = 0; i < di->number; i++) {
- if (g_ascii_strcasecmp(di->bssid[i], mac_addr) == 0) {
- if (!strcmp(name, "*"))
- device_name = MOBILE_AP_NAME_UNKNOWN;
- else
- device_name = name;
-
- _mh_core_add_data_to_array(array, MOBILE_AP_TYPE_WIFI,
- device_name);
-
- found++;
-
- break;
- }
- }
-
- g_free(line);
- }
- g_io_channel_unref(io);
-
- /* Set the name UNKNOWN unless we got the name. */
- for (i = found; i < di->number; i++) {
- _mh_core_add_data_to_array(array, MOBILE_AP_TYPE_WIFI,
- MOBILE_AP_NAME_UNKNOWN);
- }
-}
-
-mobile_ap_error_code_e _enable_wifi_tethering(TetheringObject *obj, gchar *ssid,
+mobile_ap_error_code_e _enable_wifi_tethering(Tethering *obj, gchar *ssid,
gchar *passphrase, int hide_mode, softap_security_type_e security_type)
{
mobile_ap_error_code_e ret;
return ret;
}
- /* Update Wi-Fi hotspot data to common object */
- ret = __update_softap_settings(&obj->softap_settings, ssid, passphrase,
+ /* Update Wi-Fi hotspot data to global settings pointer */
+ ret = __update_softap_settings(&obj_softap_settings, ssid, passphrase,
hide_mode, security_type);
if (ret != MOBILE_AP_ERROR_NONE) {
_mobileap_clear_state(MOBILE_AP_STATE_WIFI);
}
if (vconf_set_str(VCONFKEY_MOBILE_HOTSPOT_SSID,
- obj->softap_settings.ssid) < 0) {
+ obj_softap_settings.ssid) < 0) {
ERR("vconf_set_str is failed\n");
}
/* Initialize tethering */
_block_device_sleep();
- ret = _init_tethering(obj);
+ ret = _init_tethering();
if (ret != MOBILE_AP_ERROR_NONE) {
_mobileap_clear_state(MOBILE_AP_STATE_WIFI);
goto DONE;
/* Upload driver */
ret = _mh_core_enable_softap(MOBILE_AP_TYPE_WIFI,
- obj->softap_settings.ssid,
- obj->softap_settings.security_type,
- obj->softap_settings.key,
- obj->softap_settings.hide_mode);
+ obj_softap_settings.ssid,
+ obj_softap_settings.security_type,
+ obj_softap_settings.key,
+ obj_softap_settings.hide_mode);
if (ret != MOBILE_AP_ERROR_NONE) {
- _deinit_tethering(obj);
+ _deinit_tethering();
_mobileap_clear_state(MOBILE_AP_STATE_WIFI);
goto DONE;
}
return ret;
}
-mobile_ap_error_code_e _enable_wifi_ap(TetheringObject *obj,
- gchar *ssid, gchar *passphrase, int hide_mode,
- softap_security_type_e security_type)
+mobile_ap_error_code_e _enable_wifi_ap(Tethering *obj,
+ gchar *ssid, gchar *passphrase, int hide_mode,
+ softap_security_type_e security_type)
{
mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
if (!_mobileap_set_state(MOBILE_AP_STATE_WIFI_AP)) {
return MOBILE_AP_ERROR_RESOURCE;
}
-
- ret = __update_softap_settings(&obj->softap_settings, ssid, passphrase,
+ ret = __update_softap_settings(&obj_softap_settings, ssid, passphrase,
hide_mode, security_type);
if (ret != MOBILE_AP_ERROR_NONE) {
_mobileap_clear_state(MOBILE_AP_STATE_WIFI_AP);
_block_device_sleep();
- if (_init_tethering(obj) != MOBILE_AP_ERROR_NONE) {
+ if (_init_tethering() != MOBILE_AP_ERROR_NONE) {
_mobileap_clear_state(MOBILE_AP_STATE_WIFI_AP);
ret = MOBILE_AP_ERROR_RESOURCE;
goto DONE;
/* Upload driver */
ret = _mh_core_enable_softap(MOBILE_AP_TYPE_WIFI_AP,
- obj->softap_settings.ssid,
- obj->softap_settings.security_type,
- obj->softap_settings.key,
- obj->softap_settings.hide_mode);
+ obj_softap_settings.ssid,
+ obj_softap_settings.security_type,
+ obj_softap_settings.key,
+ obj_softap_settings.hide_mode);
if (ret != MOBILE_AP_ERROR_NONE) {
- _deinit_tethering(obj);
+ _deinit_tethering();
_mobileap_clear_state(MOBILE_AP_STATE_WIFI_AP);
goto DONE;
}
return ret;
}
-mobile_ap_error_code_e _disable_wifi_tethering(TetheringObject *obj)
+mobile_ap_error_code_e _disable_wifi_tethering(Tethering *obj)
{
int ret;
int state;
goto DONE;
}
- _deinit_tethering(obj);
+ _deinit_tethering();
_mobileap_clear_state(state);
if (prev_wifi_on == TRUE) {
return ret;
}
-mobile_ap_error_code_e _disable_wifi_ap(TetheringObject *obj)
+mobile_ap_error_code_e _disable_wifi_ap(Tethering *obj)
{
int ret;
int state;
goto DONE;
}
- _deinit_tethering(obj);
+ _deinit_tethering();
_mobileap_clear_state(state);
DBG("_disable_wifi_ap is done\n");
return ret;
}
-gboolean tethering_enable_wifi_tethering(TetheringObject *obj, gchar *ssid,
- gchar *key, gint visibility, gint security_type,
- DBusGMethodInvocation *context)
+gboolean tethering_enable_wifi_tethering(Tethering *obj,
+ GDBusMethodInvocation *context, gchar *ssid,
+ gchar *key, gint visibility, gint security_type)
{
+ DBG("+\n");
mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
gboolean ret_val = FALSE;
bool wifi_state = false;
-
- DBG("+\n");
g_assert(obj != NULL);
g_assert(context != NULL);
if (g_context) {
DBG("It is turnning on\n");
- dbus_g_method_return(context,
- MOBILE_AP_ENABLE_WIFI_TETHERING_CFM,
+ tethering_complete_enable_wifi_tethering(obj, g_context,
MOBILE_AP_ERROR_IN_PROGRESS);
return FALSE;
}
-
g_context = context;
wifi_settings.ssid = g_strdup(ssid);
if (ret != MOBILE_AP_ERROR_NONE) {
ERR("_enable_wifi_tethering is failed\n");
} else {
- _emit_mobileap_dbus_signal(obj, E_SIGNAL_WIFI_TETHER_ON, NULL);
+ tethering_emit_wifi_on(obj);
+ _create_tethering_active_noti();
ret_val = TRUE;
}
DONE:
- dbus_g_method_return(g_context,
- MOBILE_AP_ENABLE_WIFI_TETHERING_CFM, ret);
+ tethering_complete_enable_wifi_tethering(obj, g_context, ret);
g_context = NULL;
g_free(wifi_settings.ssid);
return ret_val;
}
-gboolean tethering_disable_wifi_tethering(TetheringObject *obj,
- DBusGMethodInvocation *context)
+gboolean tethering_disable_wifi_tethering(Tethering *obj,
+ GDBusMethodInvocation *context)
{
int ret = MOBILE_AP_ERROR_NONE;
ret = _disable_wifi_tethering(obj);
- _emit_mobileap_dbus_signal(obj, E_SIGNAL_WIFI_TETHER_OFF, NULL);
- dbus_g_method_return(context, MOBILE_AP_DISABLE_WIFI_TETHERING_CFM, ret);
+ tethering_emit_wifi_off(obj, NULL);
+ tethering_complete_disable_wifi_tethering(obj, context,
+ MOBILE_AP_DISABLE_WIFI_TETHERING_CFM, ret);
+
if (ret != MOBILE_AP_ERROR_NONE)
return FALSE;
return TRUE;
}
-gboolean tethering_enable_wifi_ap(TetheringObject *obj, gchar *ssid, gchar *key,
- gint visibility, gint security_type, DBusGMethodInvocation *context)
+gboolean tethering_enable_wifi_ap(Tethering *obj, GDBusMethodInvocation *context,
+ gchar *ssid, gchar *key, gint visibility, gint security_type)
{
mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
gboolean ret_val = FALSE;
if (ret != MOBILE_AP_ERROR_NONE) {
ERR("_enable_wifi_tethering is failed\n");
} else {
- _emit_mobileap_dbus_signal(obj, E_SIGNAL_WIFI_AP_ON, NULL);
+ tethering_emit_wifi_ap_on(obj);
ret_val = TRUE;
}
-
- dbus_g_method_return(context, MOBILE_AP_ENABLE_WIFI_AP_CFM, ret);
-
+ tethering_complete_enable_wifi_ap(obj, context, ret);
return ret_val;
}
-gboolean tethering_disable_wifi_ap(TetheringObject *obj,
- DBusGMethodInvocation *context)
+gboolean tethering_disable_wifi_ap(Tethering *obj,
+ GDBusMethodInvocation *context)
{
int ret = MOBILE_AP_ERROR_NONE;
g_assert(context != NULL);
ret = _disable_wifi_ap(obj);
-
- _emit_mobileap_dbus_signal(obj, E_SIGNAL_WIFI_AP_OFF, NULL);
- dbus_g_method_return(context, MOBILE_AP_DISABLE_WIFI_AP_CFM, ret);
+ tethering_emit_wifi_ap_off(obj, NULL);
+ tethering_complete_disable_wifi_ap(obj, g_context,
+ MOBILE_AP_ENABLE_WIFI_AP_CFM, ret);
if (ret != MOBILE_AP_ERROR_NONE)
return FALSE;
return TRUE;
}
-gboolean tethering_reload_wifi_settings(TetheringObject *obj, gchar *ssid,
- gchar *key, gint visibility, gint security_type,
- DBusGMethodInvocation *context)
+gboolean tethering_reload_wifi_settings(Tethering *obj,
+ GDBusMethodInvocation *context, gchar *ssid,
+ gchar *key, gint visibility, gint security_type)
{
mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
gboolean ret_val = TRUE;
ret_val = FALSE;
}
- dbus_g_method_return(context, ret);
+ tethering_complete_reload_wifi_settings(obj, context, ret);
return ret_val;
}
-gboolean tethering_reload_wifi_ap_settings(TetheringObject *obj, gchar *ssid,
- gchar *key, gint visibility, gint security, DBusGMethodInvocation *context)
+gboolean tethering_reload_wifi_ap_settings(Tethering *obj,
+ GDBusMethodInvocation *context, gchar *ssid,
+ gchar *key, gint visibility, gint security)
{
mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
ret_val = FALSE;
}
- dbus_g_method_return(context, ret);
+ tethering_complete_reload_wifi_ap_settings(obj, context, ret);
return ret_val;
}