INCLUDE_DIRECTORIES(${INCLUDE_DIR})
INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED dlog dbus-glib-1 pmapi vconf notification libssl secure-storage capi-network-connection capi-network-bluetooth)
+pkg_check_modules(pkgs REQUIRED dlog dbus-glib-1 pmapi vconf notification libssl secure-storage capi-network-connection capi-network-bluetooth ${PRIVATE_REQUIRED_PKGS})
FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
#define DBUS_STRUCT_STATIONS (dbus_g_type_get_struct ("GValueArray", \
G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, \
- G_TYPE_STRING, G_TYPE_INVALID))
+ G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID))
#define DBUS_STRUCT_STATION (dbus_g_type_get_struct ("GValueArray", \
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, \
/**
* WiFi tethering configuration
*/
-#define MOBILE_AP_WIFI_CHANNEL 7 /**< Channel number */
+#define MOBILE_AP_WIFI_CHANNEL 6 /**< Channel number */
#define MOBILE_AP_WIFI_BSSID_LEN 6 /**< BSSID Length */
#define MOBILE_AP_WIFI_SSID_MAX_LEN 31 /**< Maximum length of ssid */
#define MOBILE_AP_WIFI_KEY_MIN_LEN 8 /**< Minimum length of wifi key */
char ip[MOBILE_AP_STR_INFO_LEN]; /**< assigned IP address */
char mac[MOBILE_AP_STR_INFO_LEN]; /**< MAC Address */
char hostname[MOBILE_AP_STR_HOSTNAME_LEN]; /**< alphanumeric name */
+ time_t tm; /**< connection time*/
} mobile_ap_station_info_t;
typedef struct {
"channel=%d\n" \
"ignore_broadcast_ssid=%d\n" \
"max_num_sta=%d\n" \
+ "ieee80211n=1\n" \
"%s\n"
#define HOSTAPD_DEBUG_FILE "/tmp/hostapd.log"
#define HOSTAPD_REQ_MAX_LEN 128
gboolean tethering_disable_bt_tethering(TetheringObject *obj,
DBusGMethodInvocation *context);
-#endif
+#endif /* __MOBILEAP_BLUETOOTH_H__ */
int _execute_command(const char *cmd);
int _get_tethering_type_from_ip(const char *ip, mobile_ap_type_e *type);
-#endif
+#endif /* __MOBILEAP_COMMON_H__ */
#include <glib.h>
gboolean _get_network_interface_name(char **if_name);
+gboolean _is_trying_network_operation(void);
gboolean _set_masquerade(void);
gboolean _unset_masquerade(void);
gboolean _open_network(void);
gboolean _init_network(void *user_data);
gboolean _deinit_network(void);
-#endif
+#endif /* __MOBILEAP_NETWORK_H__ */
int _create_timeout_noti(const char *content, const char *title,
const char *icon_path);
-
+int _delete_timeout_noti(void);
int _create_connected_noti(const char *content, const char *title,
const char *icon_path);
int _update_connected_noti(const char *content);
int _delete_connected_noti(void);
-
+int _create_status_noti(const char *content);
#endif
DBusGMethodInvocation *context);
gboolean tethering_get_usb_interface_info(TetheringObject *obj,
DBusGMethodInvocation *context);
-
-#endif
+#endif /* __MOBILEAP_USB_H__ */
<!-- Method definitions -->
+ <method name="init">
+ </method>
+
<method name="deinit">
</method>
<method name="get_station_info">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg type="u" name="type" direction="out"/>
- <arg type="a(usss)" name="station" direction="out"/>
+ <arg type="a(usssu)" name="station" direction="out"/>
</method>
<method name="get_usb_station_info">
<arg type="a(ssss)" name="interface" direction="out"/>
</method>
+ <method name="set_ip_forward_status">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg type="i" name="forward_status" direction="in"/>
+ <arg type="i" name="result" direction="out"/>
+ </method>
+
+ <method name="get_ip_forward_status">
+ <arg type="i" name="forward_status" direction="out"/>
+ </method>
+
<method name="get_wifi_tethering_hide_mode">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg type="i" name="hide_mode" direction="out"/>
<arg type="s" name="ip" direction="out"/>
<arg type="s" name="mac" direction="out"/>
<arg type="s" name="name" direction="out"/>
+ <arg type="u" name="time" direction="out"/>
</signal>
<signal name="security_type_changed">
#include "mobileap_common.h"
#include "mobileap_bluetooth.h"
#include "mobileap_handler.h"
+#include "mobileap_notification.h"
typedef struct {
bt_device_info_s *info;
return;
int ret;
+ int duration;
+ bt_adapter_visibility_mode_e mode;
TetheringObject *obj = (TetheringObject *)user_data;
DBusGMethodInvocation *context = obj->bt_context;
_emit_mobileap_dbus_signal(obj, E_SIGNAL_BT_TETHER_OFF,
SIGNAL_MSG_NOT_AVAIL_INTERFACE);
return;
+ } else {
+ ret = bt_adapter_get_visibility(&mode, &duration);
+ if (ret == BT_ERROR_NONE && mode == BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE)
+ _create_status_noti("Bluetooth visible time is off. You may not find your device.");
}
ret = __activate_bt_nap(obj);
return;
}
-mobile_ap_error_code_e _disable_bt_tethering(TetheringObject *obj)
-{
- int bt_ret;
-
- if (!_mobileap_is_enabled(MOBILE_AP_STATE_BT)) {
- ERR("BT tethering has not been enabled\n");
- return MOBILE_AP_ERROR_NOT_ENABLED;
- }
-
- __deactivate_bt_nap();
-
- bt_ret = bt_adapter_unset_state_changed_cb();
- if (bt_ret != BT_ERROR_NONE)
- ERR("bt_adapter_unset_state_changed_cb is failed : %d\n", bt_ret);
-
- bt_ret = bt_deinitialize();
- if (bt_ret != BT_ERROR_NONE)
- ERR("bt_deinitialize is failed : %d\n", bt_ret);
-
- _remove_station_info_all(MOBILE_AP_TYPE_BT);
- __del_bt_remote_all();
- _deinit_timeout_cb(MOBILE_AP_TYPE_BT);
-
- _deinit_tethering(obj);
- _mobileap_clear_state(MOBILE_AP_STATE_BT);
-
- return MOBILE_AP_ERROR_NONE;
-}
-
-gboolean tethering_enable_bt_tethering(TetheringObject *obj,
+mobile_ap_error_code_e _enable_bt_tethering(TetheringObject *obj,
DBusGMethodInvocation *context)
{
- int ret;
+ mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
int bt_ret;
+ int duration;
+ bt_adapter_visibility_mode_e mode;
bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED;
- DBG("+\n");
-
- g_assert(obj != NULL);
- g_assert(context != NULL);
-
-
if (_mobileap_is_enabled(MOBILE_AP_STATE_BT)) {
ERR("Bluetooth tethering is already enabled\n");
ret = MOBILE_AP_ERROR_ALREADY_ENABLED;
- dbus_g_method_return(context,
- MOBILE_AP_ENABLE_BT_TETHERING_CFM, ret);
- return FALSE;
+ return ret;
}
if (obj->bt_context != NULL) {
ERR("Bluetooth tethering request is progressing\n");
ret = MOBILE_AP_ERROR_IN_PROGRESS;
- dbus_g_method_return(context,
- MOBILE_AP_ENABLE_BT_TETHERING_CFM, ret);
- return FALSE;
+ return ret;
}
if (!_mobileap_set_state(MOBILE_AP_STATE_BT)) {
goto FAIL;
}
obj->bt_context = context;
- return TRUE;
+ return ret;
+ } else {
+ bt_ret = bt_adapter_get_visibility(&mode, &duration);
+ if (bt_ret == BT_ERROR_NONE && mode == BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE)
+ _create_status_noti("Bluetooth visible time is off. You may not find your device.");
+
}
ret = __activate_bt_nap(obj);
goto FAIL;
}
+ _delete_timeout_noti();
_init_timeout_cb(MOBILE_AP_TYPE_BT, (void *)obj);
_start_timeout_cb(MOBILE_AP_TYPE_BT);
- _emit_mobileap_dbus_signal(obj, E_SIGNAL_BT_TETHER_ON, NULL);
- dbus_g_method_return(context, MOBILE_AP_ENABLE_BT_TETHERING_CFM, ret);
- return TRUE;
+ return ret;
FAIL:
_mobileap_clear_state(MOBILE_AP_STATE_BT);
- dbus_g_method_return(context, MOBILE_AP_ENABLE_BT_TETHERING_CFM, ret);
- return FALSE;
+
+ return ret;
+}
+
+mobile_ap_error_code_e _disable_bt_tethering(TetheringObject *obj)
+{
+ int bt_ret;
+
+ if (!_mobileap_is_enabled(MOBILE_AP_STATE_BT)) {
+ ERR("BT tethering has not been enabled\n");
+ return MOBILE_AP_ERROR_NOT_ENABLED;
+ }
+
+ __deactivate_bt_nap();
+
+ bt_ret = bt_adapter_unset_state_changed_cb();
+ if (bt_ret != BT_ERROR_NONE)
+ ERR("bt_adapter_unset_state_changed_cb is failed : %d\n", bt_ret);
+
+ bt_ret = bt_deinitialize();
+ if (bt_ret != BT_ERROR_NONE)
+ ERR("bt_deinitialize is failed : %d\n", bt_ret);
+
+ _remove_station_info_all(MOBILE_AP_TYPE_BT);
+ __del_bt_remote_all();
+ _deinit_timeout_cb(MOBILE_AP_TYPE_BT);
+
+ _deinit_tethering(obj);
+ _mobileap_clear_state(MOBILE_AP_STATE_BT);
+
+ return MOBILE_AP_ERROR_NONE;
+}
+
+gboolean tethering_enable_bt_tethering(TetheringObject *obj,
+ DBusGMethodInvocation *context)
+{
+ mobile_ap_error_code_e ret;
+
+ DBG("+\n");
+
+ g_assert(obj != NULL);
+ g_assert(context != NULL);
+
+
+ ret = _enable_bt_tethering(obj, context);
+ if (ret != MOBILE_AP_ERROR_NONE) {
+ ERR("_enable_bt_tethering() is failed : %d\n", ret);
+ dbus_g_method_return(context,
+ MOBILE_AP_ENABLE_BT_TETHERING_CFM, ret);
+ return FALSE;
+ } else if (obj->bt_context == NULL) {
+ _emit_mobileap_dbus_signal(obj, E_SIGNAL_BT_TETHER_ON, NULL);
+ dbus_g_method_return(context,
+ MOBILE_AP_ENABLE_BT_TETHERING_CFM, ret);
+ }
+
+ return TRUE;
}
DBUS_TYPE_STRING, &ip,
DBUS_TYPE_STRING, &mac,
DBUS_TYPE_STRING, &hostname,
+ DBUS_TYPE_UINT32, &info->tm,
DBUS_TYPE_INVALID)) {
ERR("Event sending failed\n");
dbus_message_unref(msg);
DBG("[%d] station MAC : %s\n", i, si->mac);
DBG("[%d] station Hostname : %s\n", i, si->hostname);
DBG("[%d] station IP : %s\n", i, si->ip);
+ DBG("[%d] station connected time : %d\n", i, si->tm);
i++;
}
snprintf(cmd, sizeof(cmd),
"%s -L FORWARD -vx | %s \"%s[ ]*%s\" | %s '{ print $2 }' > %s",
IPTABLES, GREP, src, dest, AWK, DATA_USAGE_FILE);
- DBG("GET DATA USAGE : %s\n", cmd);
if (system(cmd) < 0) {
ERR("\"cmd\" is failed\n");
}
snprintf(cmd, sizeof(cmd),
"%s -L FORWARD -vx | %s \"%s[ ]*%s\" | %s '{ print $2 }' >> %s",
IPTABLES, GREP, dest, src, AWK, DATA_USAGE_FILE);
- DBG("GET DATA USAGE : %s\n", cmd);
if (system(cmd) < 0) {
ERR("\"cmd\" is failed\n");
}
*tx = 0LL;
else
*tx = atoll(buf);
- DBG("Tx(%s -> %s) : %llu\n", src, dest, *tx);
if (fgets(buf, sizeof(buf), fp) == NULL)
*rx = 0LL;
else
*rx = atoll(buf);
- DBG("Rx(%s -> %s) : %llu\n", dest, src, *rx);
fclose(fp);
unlink(DATA_USAGE_FILE);
* limitations under the License.
*/
+#include <fcntl.h>
+#include <unistd.h>
#include <glib.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>
int mobileap_state = MOBILE_AP_STATE_NONE;
DBusConnection *tethering_conn = NULL;
+gboolean tethering_init(TetheringObject *obj, GError **error);
gboolean tethering_deinit(TetheringObject *obj, GError **error);
gboolean tethering_disable(TetheringObject *obj, DBusGMethodInvocation *context);
gboolean tethering_get_station_info(TetheringObject *obj,
DBusGMethodInvocation *context);
gboolean tethering_get_data_packet_usage(TetheringObject *obj,
DBusGMethodInvocation *context);
+gboolean tethering_set_ip_forward_status(TetheringObject *obj,
+ gint forward_mode, DBusGMethodInvocation *context);
+gboolean tethering_get_ip_forward_status(TetheringObject *obj, gint *forward_mode);
+
#include "tethering-server-stub.h"
+int ref_agent = 0;
+
static void tethering_object_init(TetheringObject *obj)
{
DBG("+\n");
g_value_take_boxed(&value,
dbus_g_type_specialized_construct(DBUS_STRUCT_STATIONS));
dbus_g_type_struct_set(&value, 0, si->interface, 1, si->ip,
- 2, si->mac, 3, si->hostname, G_MAXUINT);
+ 2, si->mac, 3, si->hostname, 4, (guint)(si->tm), G_MAXUINT);
g_ptr_array_add(array, g_value_get_boxed(&value));
}
return TRUE;
}
+gboolean tethering_init(TetheringObject *obj, GError **error)
+{
+ DBG("There are [%d] references\n", ++ref_agent);
+
+ return TRUE;
+}
gboolean tethering_deinit(TetheringObject *obj, GError **error)
{
- DBG("+\n");
- g_assert(obj != NULL);
-
- if (_mobileap_is_disabled()) {
- DBG("Mobile AP is not activated, so we quit the mobileap-agent.\n");
+ if (--ref_agent <= 0 && _mobileap_is_disabled() &&
+ !_is_trying_network_operation()) {
+ DBG("Terminate mobileap-agent\n");
g_main_loop_quit(mainloop);
}
+ DBG("There are [%d] references\n", ref_agent);
+
return TRUE;
}
if (_get_network_interface_name(&if_name) == FALSE) {
ERR("No network interface\n");
dbus_g_method_return(context, MOBILE_AP_GET_DATA_PACKET_USAGE_CFM,
- 0, 0);
+ 0ULL, 0ULL);
return FALSE;
}
return TRUE;
}
+gboolean tethering_set_ip_forward_status(TetheringObject *obj,
+ gint forward_mode, DBusGMethodInvocation *context)
+{
+ g_assert(obj != NULL);
+
+ gboolean ret;
+
+ if (forward_mode == 0) {
+ ret = _unset_masquerade();
+ } else {
+ ret = _set_masquerade();
+ }
+
+ dbus_g_method_return(context, ret);
+
+ return TRUE;
+}
+
+gboolean tethering_get_ip_forward_status(TetheringObject *obj, gint *forward_mode)
+{
+ g_assert(obj != NULL);
+
+ int fd;
+ int ret;
+ char value[2] = {0, };
+
+ fd = open(IP_FORWARD, O_RDONLY);
+ if (fd < 0) {
+ ERR("open failed\n");
+ return FALSE;
+ }
+
+ ret = read(fd, value, sizeof(value));
+ if (ret < 0) {
+ ERR("read is failed\n");
+ close(fd);
+ return FALSE;
+ }
+ close(fd);
+
+ *forward_mode = atoi(value);
+
+ return TRUE;
+}
+
static DBusHandlerResult __dnsmasq_signal_filter(DBusConnection *conn,
DBusMessage *msg, void *user_data)
TetheringObject *obj = (TetheringObject *)user_data;
mobile_ap_station_info_t *info = NULL;
int n_station = 0;
+ time_t tm;
dbus_error_init(&error);
if (dbus_message_is_signal(msg, DNSMASQ_DBUS_INTERFACE,
free(bt_remote_device_name);
}
}
+ time(&tm);
+ info->tm = tm;
if (_add_station_info(info) != MOBILE_AP_ERROR_NONE) {
free(info);
#include "mobileap_common.h"
#include "mobileap_network.h"
+
+extern int ref_agent;
static connection_h connection = NULL;
static connection_profile_h cprof = NULL;
-static connection_profile_h old_prof = NULL;
static void __print_profile(connection_profile_h profile)
{
-#define __check_connection_return(conn_ret) \
- do { \
- if (conn_ret != CONNECTION_ERROR_NONE) \
- ERR("connection API fail : 0x%X\n", conn_ret); \
- } while(0)
-
if (profile == NULL)
return;
int conn_ret;
bool roaming;
- char *apn;
- char *home_url;
+ char *apn = NULL;
+ char *home_url = NULL;
connection_cellular_network_type_e network_type;
connection_cellular_service_type_e service_type;
conn_ret = connection_profile_get_cellular_network_type(profile, &network_type);
- __check_connection_return(conn_ret);
- DBG("Network type : %d\n", network_type);
+ if (conn_ret != CONNECTION_ERROR_NONE)
+ ERR("connection API fail : 0x%X\n", conn_ret);
+ else
+ DBG("Network type : %d\n", network_type);
conn_ret = connection_profile_get_cellular_service_type(profile, &service_type);
- __check_connection_return(conn_ret);
- DBG("Service type : %d\n", service_type);
+ if (conn_ret != CONNECTION_ERROR_NONE)
+ ERR("connection API fail : 0x%X\n", conn_ret);
+ else
+ DBG("Service type : %d\n", service_type);
conn_ret = connection_profile_get_cellular_apn(profile, &apn);
- __check_connection_return(conn_ret);
- DBG("APN : %s\n", apn);
- free(apn);
+ if (conn_ret != CONNECTION_ERROR_NONE)
+ ERR("connection API fail : 0x%X\n", conn_ret);
+ else {
+ DBG("APN : %s\n", apn);
+ free(apn);
+ }
conn_ret = connection_profile_get_cellular_home_url(profile, &home_url);
- __check_connection_return(conn_ret);
- DBG("Home url : %s\n", home_url);
- free(home_url);
+ if (conn_ret != CONNECTION_ERROR_NONE)
+ ERR("connection API fail : 0x%X\n", conn_ret);
+ else {
+ DBG("Home url : %s\n", home_url);
+ free(home_url);
+ }
conn_ret = connection_profile_is_cellular_roaming(profile, &roaming);
- __check_connection_return(conn_ret);
- DBG("Roaming : %d\n", roaming);
+ if (conn_ret != CONNECTION_ERROR_NONE)
+ ERR("connection API fail : 0x%X\n", conn_ret);
+ else
+ DBG("Roaming : %d\n", roaming);
-#undef __check_connection_return
return;
}
-static gboolean __is_connected_prof(connection_profile_h profile)
+static gboolean __is_connected_profile(connection_profile_h profile)
{
+ if (profile == NULL) {
+ ERR("profile is NULL\n");
+ return FALSE;
+ }
+
int conn_ret;
connection_profile_state_e pstat = CONNECTION_PROFILE_STATE_DISCONNECTED;
return TRUE;
}
-static gboolean __get_current_prof(connection_profile_h *r_prof, connection_profile_type_e *r_net_type)
+
+static gboolean __get_connected_profile(connection_profile_h *r_prof, connection_profile_type_e *r_net_type)
{
+ if (r_prof == NULL || r_net_type == NULL) {
+ ERR("Invalid param [%p] [%p]\n", r_prof, r_net_type);
+ return FALSE;
+ }
+
int conn_ret;
connection_profile_h profile = NULL;
connection_profile_type_e net_type = CONNECTION_PROFILE_TYPE_CELLULAR;
return TRUE;
}
-static gboolean __get_network_prof(connection_profile_h *r_prof)
+static gboolean __get_network_profile(connection_profile_h *r_prof)
{
+ if (r_prof == NULL) {
+ ERR("r_prof is NULL\n");
+ return FALSE;
+ }
+
connection_profile_h profile;
connection_profile_type_e net_type = CONNECTION_PROFILE_TYPE_CELLULAR;
- if (__get_current_prof(&profile, &net_type) != TRUE) {
+ if (__get_connected_profile(&profile, &net_type) == FALSE) {
ERR("There is no available network\n");
return FALSE;
}
DBG("Current connected net_type : %d\n", net_type);
- if (net_type == CONNECTION_PROFILE_TYPE_CELLULAR) {
- __print_profile(profile);
+ if (net_type == CONNECTION_PROFILE_TYPE_WIFI) {
+ *r_prof = profile;
+ return TRUE;
+ }
+
+ if (net_type != CONNECTION_PROFILE_TYPE_CELLULAR) {
+ ERR("Network type [%d] is not supported\n", net_type);
+ return FALSE;
}
+ __print_profile(profile);
*r_prof = profile;
return TRUE;
static void __connection_type_changed_cb(connection_type_e type, void *user_data)
{
- if (_mobileap_is_disabled()) {
- DBG("Tethering is not enabled\n");
- return;
- }
-
DBG("Changed connection type is %s\n",
type == CONNECTION_TYPE_DISCONNECTED ? "DISCONNECTED" :
- type == CONNECTION_TYPE_WIFI ? "Wi-FI" :
+ type == CONNECTION_TYPE_WIFI ? "Wi-Fi" :
type == CONNECTION_TYPE_CELLULAR ? "Cellular" :
type == CONNECTION_TYPE_ETHERNET ? "Ethernet" :
"Unknown");
- _close_network();
- if (type == CONNECTION_TYPE_DISCONNECTED)
+
+ if (_mobileap_is_disabled()) {
+ DBG("Tethering is not enabled\n");
+ return;
+ }
+
+ if (_unset_masquerade() == FALSE) {
+ ERR("_unset_masquerade is failed\n");
+ }
+
+ if (cprof) {
+ connection_profile_destroy(cprof);
+ cprof = NULL;
+ }
+
+ if (type == CONNECTION_TYPE_DISCONNECTED) {
return;
+ }
_open_network();
+
return;
}
+gboolean _is_trying_network_operation(void)
+{
+
+ return FALSE;
+}
+
gboolean _get_network_interface_name(char **if_name)
{
- int conn_ret = 0;
+ if (if_name == NULL) {
+ ERR("if_name is NULL\n");
+ return FALSE;
+ }
- if (cprof == NULL)
+ if (cprof == NULL) {
+ ERR("There is no connected profile\n");
return FALSE;
+ }
+
+ int conn_ret = 0;
conn_ret = connection_profile_get_network_interface_name(cprof, if_name);
if (conn_ret != CONNECTION_ERROR_NONE) {
gboolean _unset_masquerade(void)
{
+ if (cprof == NULL) {
+ DBG("There is nothing to unset masquerading\n");
+ return TRUE;
+ }
+
char *if_name = NULL;
if (_get_network_interface_name(&if_name) == FALSE) {
DBG("+\n");
- if (__get_network_prof(&profile) == FALSE) {
- ERR("__get_network_prof is failed\n");
+ if (__get_network_profile(&profile) == FALSE) {
+ ERR("__get_network_profile is failed\n");
return FALSE;
}
- cprof = profile;
- if (__is_connected_prof(cprof) == FALSE) {
- DBG("Connection is not yet opened\n");
+ if (!__is_connected_profile(profile)) {
+ connection_profile_destroy(profile);
return TRUE;
}
+ cprof = profile;
- DBG("Set masquerading\n");
if (_set_masquerade() == FALSE) {
ERR("_set_masquerade is failed\n");
_close_network();
DBG("+\n");
- if (cprof == NULL && old_prof == NULL) {
- ERR("There is nothing to handle\n");
- return TRUE;
- }
-
ret = _unset_masquerade();
if (ret == FALSE)
ERR("_unset_masquerade is failed\n");
cprof = NULL;
DBG("-\n");
+
return TRUE;
}
#include "mobileap_agent.h"
#define MH_NOTI_APP_NAME "org.tizen.tethering"
+#define MH_AGENT_PKG_NAME "mobileap-agent"
static int connected_noti_id = 0;
static int timeout_noti_id = 0;
timeout_noti_id = 0;
}
- noti = notification_new(NOTIFICATION_TYPE_NOTI,
- NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
+ noti = notification_create(NOTIFICATION_TYPE_NOTI);
if (!noti) {
- ERR("Fail to notification_new [%d]\n", ret);
+ ERR("Fail to notification_create\n");
return MOBILE_AP_ERROR_INTERNAL;
}
return MOBILE_AP_ERROR_INTERNAL;
}
+int _delete_timeout_noti(void)
+{
+ notification_error_e ret = NOTIFICATION_ERROR_NONE;
+ notification_list_h noti_list = NULL;
+ notification_h noti = NULL;
+
+ ret = notification_get_detail_list(MH_AGENT_PKG_NAME,
+ NOTIFICATION_GROUP_ID_NONE,
+ NOTIFICATION_PRIV_ID_NONE,
+ -1,
+ ¬i_list);
+ if (ret != NOTIFICATION_ERROR_NONE) {
+ ERR("Fail to notification_get_detail_list\n");
+ return MOBILE_AP_ERROR_INTERNAL;
+ }
+
+ if (noti_list) {
+ noti = notification_list_get_data(noti_list);
+ if (noti)
+ notification_delete(noti);
+
+ notification_free_list(noti_list);
+ }
+
+ return MOBILE_AP_ERROR_NONE;
+}
+
int _create_connected_noti(const char *content, const char *title,
const char *icon_path)
{
notification_h noti = NULL;
notification_error_e ret = NOTIFICATION_ERROR_NONE;
- noti = notification_new(NOTIFICATION_TYPE_ONGOING,
- NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
+ noti = notification_create(NOTIFICATION_TYPE_ONGOING);
if (!noti) {
- ERR("Fail to notification_new [%d]\n", ret);
+ ERR("Fail to notification_create\n");
return MOBILE_AP_ERROR_INTERNAL;
}
return MOBILE_AP_ERROR_NONE;
}
+int _create_status_noti(const char *content)
+{
+ if (content == NULL)
+ return MOBILE_AP_ERROR_INVALID_PARAM;
+
+ notification_error_e ret;
+
+ ret = notification_status_message_post(content);
+ if (ret != NOTIFICATION_ERROR_NONE) {
+ ERR("notification_status_message_post() is failed : %d\n", ret);
+ return MOBILE_AP_ERROR_INTERNAL;
+ }
+
+ return MOBILE_AP_ERROR_NONE;
+}
}
}
-mobile_ap_error_code_e _disable_usb_tethering(TetheringObject *obj)
+mobile_ap_error_code_e _enable_usb_tethering(TetheringObject *obj,
+ DBusGMethodInvocation *context)
{
mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
-
- if (!_mobileap_is_enabled(MOBILE_AP_STATE_USB)) {
- ERR("USB tethering has not been enabled\n");
- ret = MOBILE_AP_ERROR_NOT_ENABLED;
- return ret;
- }
-
- _deinit_tethering(obj);
-
- if (_remove_station_info_all(MOBILE_AP_TYPE_USB) != MOBILE_AP_ERROR_NONE) {
- ERR("_remove_station_info_all is failed. Ignore it\n");
- }
-
- vconf_ignore_key_changed(VCONFKEY_SETAPPL_USB_MODE_INT,
- __handle_usb_disconnect_cb);
- vconf_ignore_key_changed(VCONFKEY_SYSMAN_USB_STATUS,
- __handle_usb_disconnect_cb);
-
- _mobileap_clear_state(MOBILE_AP_STATE_USB);
-
- DBG("_disable_usb_tethering is done\n");
-
- return ret;
-}
-
-gboolean tethering_enable_usb_tethering(TetheringObject *obj,
- DBusGMethodInvocation *context)
-{
int vconf_ret;
int usb_mode = SETTING_USB_NONE_MODE;
- int ret = MOBILE_AP_ERROR_NONE;
-
- DBG("+\n");
-
- g_assert(obj != NULL);
- g_assert(context != NULL);
-
if (_mobileap_is_enabled(MOBILE_AP_STATE_USB)) {
ERR("USB tethering is already enabled\n");
ret = MOBILE_AP_ERROR_ALREADY_ENABLED;
- dbus_g_method_return(context,
- MOBILE_AP_ENABLE_USB_TETHERING_CFM, ret);
- return FALSE;
+ return ret;
}
if (obj->usb_context) {
ERR("USB request is progressing\n");
ret = MOBILE_AP_ERROR_IN_PROGRESS;
- dbus_g_method_return(context,
- MOBILE_AP_ENABLE_USB_TETHERING_CFM, ret);
- return FALSE;
+ return ret;
}
vconf_notify_key_changed(VCONFKEY_SYSMAN_USB_STATUS,
}
if (usb_mode == SETTING_USB_TETHERING_MODE) {
- DBG("Don't need to wait for usb-setting\n");
obj->usb_context = NULL;
vconf_ignore_key_changed(VCONFKEY_SETAPPL_USB_MODE_INT,
__handle_usb_mode_change);
- _emit_mobileap_dbus_signal(obj, E_SIGNAL_USB_TETHER_ON, NULL);
- dbus_g_method_return(context,
- MOBILE_AP_ENABLE_USB_TETHERING_CFM, ret);
- return TRUE;
}
DBG("-\n");
- return TRUE;
+ return MOBILE_AP_ERROR_NONE;
FAIL:
vconf_ignore_key_changed(VCONFKEY_SYSMAN_USB_STATUS,
__handle_usb_disconnect_cb);
_mobileap_clear_state(MOBILE_AP_STATE_USB);
- dbus_g_method_return(context,
- MOBILE_AP_ENABLE_USB_TETHERING_CFM, ret);
- return FALSE;
+
+ return ret;
}
+mobile_ap_error_code_e _disable_usb_tethering(TetheringObject *obj)
+{
+ mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
+
+ if (!_mobileap_is_enabled(MOBILE_AP_STATE_USB)) {
+ ERR("USB tethering has not been enabled\n");
+ ret = MOBILE_AP_ERROR_NOT_ENABLED;
+ return ret;
+ }
+
+ _deinit_tethering(obj);
+
+ if (_remove_station_info_all(MOBILE_AP_TYPE_USB) != MOBILE_AP_ERROR_NONE) {
+ ERR("_remove_station_info_all is failed. Ignore it\n");
+ }
+
+ vconf_ignore_key_changed(VCONFKEY_SETAPPL_USB_MODE_INT,
+ __handle_usb_disconnect_cb);
+ vconf_ignore_key_changed(VCONFKEY_SYSMAN_USB_STATUS,
+ __handle_usb_disconnect_cb);
+
+ _mobileap_clear_state(MOBILE_AP_STATE_USB);
+
+ DBG("_disable_usb_tethering is done\n");
+
+ return ret;
+}
+
+gboolean tethering_enable_usb_tethering(TetheringObject *obj,
+ DBusGMethodInvocation *context)
+{
+ mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
+
+ DBG("+\n");
+
+ g_assert(obj != NULL);
+ g_assert(context != NULL);
+
+
+ ret = _enable_usb_tethering(obj, context);
+ if (ret != MOBILE_AP_ERROR_NONE) {
+ ERR("_enable_usb_tethering() is failed : %d\n", ret);
+ dbus_g_method_return(context,
+ MOBILE_AP_ENABLE_USB_TETHERING_CFM, ret);
+ return FALSE;
+ } else if (obj->usb_context == NULL) {
+ DBG("Don't need to wait for usb-setting\n");
+ _emit_mobileap_dbus_signal(obj, E_SIGNAL_USB_TETHER_ON, NULL);
+ dbus_g_method_return(context,
+ MOBILE_AP_ENABLE_USB_TETHERING_CFM, ret);
+ } else {
+ DBG("dbus will be returned by vconf callback\n");
+ }
+
+ return TRUE;
+}
+
+
gboolean tethering_disable_usb_tethering(TetheringObject *obj,
DBusGMethodInvocation *context)
{
#include "mobileap_common.h"
#include "mobileap_wifi.h"
#include "mobileap_handler.h"
+#include "mobileap_notification.h"
static int __generate_initial_passphrase(char *passphrase_buf);
static mobile_ap_error_code_e __get_hide_mode(int *hide_mode);
}
}
+mobile_ap_error_code_e _enable_wifi_tethering(TetheringObject *obj, gchar *ssid)
+{
+ mobile_ap_error_code_e ret;
+
+ if (_mobileap_is_enabled(MOBILE_AP_STATE_WIFI)) {
+ ERR("Wi-Fi tethering is already enabled\n");
+ ret = MOBILE_AP_ERROR_ALREADY_ENABLED;
+ return ret;
+ }
+
+ /* Update global state */
+ if (!_mobileap_set_state(MOBILE_AP_STATE_WIFI)) {
+ ret = MOBILE_AP_ERROR_RESOURCE;
+ return ret;
+ }
+
+ /* Update Wi-Fi hotspot data to common object */
+ ret = __update_wifi_data(obj);
+ if (ret != MOBILE_AP_ERROR_NONE) {
+ _mobileap_clear_state(MOBILE_AP_STATE_WIFI);
+ return ret;
+ }
+
+ if (ssid != NULL && strlen(ssid) > 0) {
+ DBG("Private(Passed) SSID is used : %s\n", ssid);
+ g_strlcpy(obj->ssid, ssid, sizeof(obj->ssid));
+ }
+
+ /* Initialize tethering */
+ if (!_init_tethering(obj)) {
+ _mobileap_clear_state(MOBILE_AP_STATE_WIFI);
+ ret = MOBILE_AP_ERROR_RESOURCE;
+ return ret;
+ }
+
+ /* Upload driver */
+ ret = _mh_core_enable_softap(obj->ssid, obj->security_type,
+ obj->key, obj->hide_mode);
+ if (ret != MOBILE_AP_ERROR_NONE) {
+ _deinit_tethering(obj);
+ _mobileap_clear_state(MOBILE_AP_STATE_WIFI);
+ return ret;
+ }
+
+ _delete_timeout_noti();
+ _init_timeout_cb(MOBILE_AP_TYPE_WIFI, (void *)obj);
+ _start_timeout_cb(MOBILE_AP_TYPE_WIFI);
+
+ return MOBILE_AP_ERROR_NONE;
+}
+
mobile_ap_error_code_e _disable_wifi_tethering(TetheringObject *obj)
{
int ret = MOBILE_AP_ERROR_NONE;
gboolean tethering_enable_wifi_tethering(TetheringObject *obj, gchar *ssid,
gchar *key, gint hide_mode, DBusGMethodInvocation *context)
{
- int ret = MOBILE_AP_ERROR_NONE;
+ mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
+ gboolean ret_val = FALSE;
g_assert(obj != NULL);
g_assert(context != NULL);
- if (_mobileap_is_enabled(MOBILE_AP_STATE_WIFI)) {
- ERR("Wi-Fi tethering is already enabled\n");
- ret = MOBILE_AP_ERROR_ALREADY_ENABLED;
- dbus_g_method_return(context,
- MOBILE_AP_ENABLE_WIFI_TETHERING_CFM, ret);
- return FALSE;
- }
-
- /* Update global state */
- if (!_mobileap_set_state(MOBILE_AP_STATE_WIFI)) {
- ret = MOBILE_AP_ERROR_RESOURCE;
- goto FAIL;
- }
-
- /* Update Wi-Fi hotspot data to common object */
- ret = __update_wifi_data(obj);
- if (ret != MOBILE_AP_ERROR_NONE) {
- goto FAIL;
- }
-
- if (strlen(ssid) > 0) {
- DBG("Private(Passed) SSID is used : %s\n", ssid);
- g_strlcpy(obj->ssid, ssid, sizeof(obj->ssid));
- }
-
- /* Initialize tethering */
- if (!_init_tethering(obj)) {
- ret = MOBILE_AP_ERROR_RESOURCE;
- goto FAIL;
- }
-
- /* Upload driver */
- ret = _mh_core_enable_softap(obj->ssid, obj->security_type,
- obj->key, obj->hide_mode);
+ ret = _enable_wifi_tethering(obj, ssid);
if (ret != MOBILE_AP_ERROR_NONE) {
- _deinit_tethering(obj);
- goto FAIL;
+ ERR("_enable_wifi_tethering is failed\n");
+ } else {
+ _emit_mobileap_dbus_signal(obj, E_SIGNAL_WIFI_TETHER_ON, NULL);
+ ret_val = TRUE;
}
- _init_timeout_cb(MOBILE_AP_TYPE_WIFI, (void *)obj);
- _start_timeout_cb(MOBILE_AP_TYPE_WIFI);
-
- _emit_mobileap_dbus_signal(obj, E_SIGNAL_WIFI_TETHER_ON, NULL);
- dbus_g_method_return(context, MOBILE_AP_ENABLE_WIFI_TETHERING_CFM, ret);
-
- return TRUE;
-
-FAIL:
- _mobileap_clear_state(MOBILE_AP_STATE_WIFI);
dbus_g_method_return(context, MOBILE_AP_ENABLE_WIFI_TETHERING_CFM, ret);
- return FALSE;
+ return ret_val;
}
+
gboolean tethering_disable_wifi_tethering(TetheringObject *obj,
DBusGMethodInvocation *context)
{
if (ret != MOBILE_AP_ERROR_NONE)
return FALSE;
- else
- return TRUE;
+
+ return TRUE;
}
gboolean tethering_get_wifi_tethering_hide_mode(TetheringObject *obj,