Indications for Wi-Fi tethering setting change are added
authorSeungyoun Ju <sy39.ju@samsung.com>
Thu, 24 Jan 2013 03:30:40 +0000 (12:30 +0900)
committerSeungyoun Ju <sy39.ju@samsung.com>
Thu, 24 Jan 2013 05:50:09 +0000 (14:50 +0900)
- Issues
  There is no way to know Wi-Fi tethering setting change by other applications.

- Fix description
  When there is change of Wi-Fi tethering settings, signal for that change is sent.

Change-Id: I896d90c41576bda6429b2cc988f161a229a60252

include/mobileap-dbus-interface.xml
include/mobileap.h
src/mobileap_main.c
src/mobileap_wifi.c

index dbba8e1..654b854 100644 (file)
                        <arg type="s" name="name" direction="out"/>
                </signal>
 
+               <signal name="security_type_changed">
+                       <arg type="s" name="arg1" direction="out"/>
+               </signal>
+
+               <signal name="ssid_visibility_changed">
+                       <arg type="s" name="arg1" direction="out"/>
+               </signal>
+
+               <signal name="passphrase_changed">
+                       <arg type="s" name="arg1" direction="out"/>
+               </signal>
+
        </interface>
 </node>
 
index 907d41d..c24d82b 100644 (file)
@@ -56,9 +56,14 @@ extern "C" {
 #define SIGNAL_NAME_LOW_BATTERY_MODE   "low_batt_mode"
 #define SIGNAL_NAME_FLIGHT_MODE                "flight_mode"
 #define SIGNAL_NAME_DHCP_STATUS                "dhcp_status"
+#define SIGNAL_NAME_SECURITY_TYPE_CHANGED      "security_type_changed"
+#define SIGNAL_NAME_SSID_VISIBILITY_CHANGED    "ssid_visibility_changed"
+#define SIGNAL_NAME_PASSPHRASE_CHANGED         "passphrase_changed"
 
 #define SIGNAL_MSG_NOT_AVAIL_INTERFACE "Interface is not available"
 #define SIGNAL_MSG_TIMEOUT             "There is no connection for a while"
+#define SIGNAL_MSG_SSID_VISIBLE                "ssid_visible"
+#define SIGNAL_MSG_SSID_HIDE           "ssid_hide"
 
 #define DNSMASQ_LEASES_FILE            "/var/lib/misc/dnsmasq.leases"
 #define IP_USB_SUBNET                  "192.168.129"
@@ -76,6 +81,9 @@ typedef enum {
        E_SIGNAL_NO_DATA_TIMEOUT,
        E_SIGNAL_LOW_BATTERY_MODE,
        E_SIGNAL_FLIGHT_MODE,
+       E_SIGNAL_SECURITY_TYPE_CHANGED,
+       E_SIGNAL_SSID_VISIBILITY_CHANGED,
+       E_SIGNAL_PASSPHRASE_CHANGED,
        E_SIGNAL_MAX
 } mobile_ap_sig_e;
 
index 118839d..7219e20 100644 (file)
@@ -85,7 +85,10 @@ static void mobileap_object_class_init(MobileAPObjectClass *klass)
                SIGNAL_NAME_BT_TETHER_OFF,
                SIGNAL_NAME_NO_DATA_TIMEOUT,
                SIGNAL_NAME_LOW_BATTERY_MODE,
-               SIGNAL_NAME_FLIGHT_MODE
+               SIGNAL_NAME_FLIGHT_MODE,
+               SIGNAL_NAME_SECURITY_TYPE_CHANGED,
+               SIGNAL_NAME_SSID_VISIBILITY_CHANGED,
+               SIGNAL_NAME_PASSPHRASE_CHANGED
        };
 
        int i = 0;
index 89e2b58..9749dfb 100644 (file)
@@ -510,11 +510,26 @@ gboolean mobileap_set_wifi_tethering_hide_mode(MobileAPObject *obj,
        g_assert(obj != NULL);
        g_assert(context != NULL);
 
+       int old_hide_mode;
+
+       ret = __get_hide_mode(&old_hide_mode);
+       if (ret != MOBILE_AP_ERROR_NONE) {
+               ERR("__get_hide_mode is failed : %d\n", ret);
+       } else if (old_hide_mode == hide_mode) {
+               DBG("old_hide_mode == hide_mode\n");
+               dbus_g_method_return(context);
+               return TRUE;
+       }
+
        ret = __set_hide_mode(hide_mode);
        if (ret < 0) {
                ERR("__set_hide_mode is failed : %d\n", ret);
        }
 
+       _emit_mobileap_dbus_signal(obj, E_SIGNAL_SSID_VISIBILITY_CHANGED,
+                       hide_mode == VCONFKEY_MOBILE_AP_HIDE_OFF ?
+                       SIGNAL_MSG_SSID_VISIBLE :
+                       SIGNAL_MSG_SSID_HIDE);
        dbus_g_method_return(context);
 
        return TRUE;
@@ -564,17 +579,29 @@ gboolean mobileap_get_wifi_tethering_security_type(MobileAPObject *obj,
 gboolean mobileap_set_wifi_tethering_security_type(MobileAPObject *obj,
                gchar *security_type, DBusGMethodInvocation *context)
 {
-       int ret = 0;
+       mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
+       char old_security_type[SECURITY_TYPE_LEN] = {0, };
 
        DBG("+\n");
        g_assert(obj != NULL);
        g_assert(context != NULL);
 
+       ret = __get_security_type(old_security_type, sizeof(old_security_type));
+       if (ret != MOBILE_AP_ERROR_NONE) {
+               ERR("__get_security_type is failed : %d\n", ret);
+       } else if (g_strcmp0(old_security_type, security_type) == 0) {
+               DBG("old_security_type == security_type\n");
+               dbus_g_method_return(context);
+               return TRUE;
+       }
+
        ret = __set_security_type(security_type);
        if (ret < 0) {
                ERR("__set_security_type is failed: %d\n", ret);
        }
 
+       _emit_mobileap_dbus_signal(obj, E_SIGNAL_SECURITY_TYPE_CHANGED,
+                       security_type);
        dbus_g_method_return(context);
 
        return TRUE;
@@ -583,7 +610,7 @@ gboolean mobileap_set_wifi_tethering_security_type(MobileAPObject *obj,
 gboolean mobileap_get_wifi_tethering_passphrase(MobileAPObject *obj,
                DBusGMethodInvocation *context)
 {
-       int ret = MOBILE_AP_ERROR_NONE;
+       mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
        char passphrase[MOBILE_AP_WIFI_KEY_MAX_LEN + 1] = {0, };
        unsigned int len = 0;
 
@@ -606,16 +633,27 @@ gboolean mobileap_set_wifi_tethering_passphrase(MobileAPObject *obj,
                gchar *passphrase, guint len, DBusGMethodInvocation *context)
 {
        mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
+       char old_passphrase[MOBILE_AP_WIFI_KEY_MAX_LEN + 1] = {0, };
+       unsigned int old_len = 0;
 
        DBG("+\n");
        g_assert(obj != NULL);
        g_assert(context != NULL);
 
+       ret = __get_passphrase(old_passphrase, sizeof(old_passphrase), &old_len);
+       if (ret != MOBILE_AP_ERROR_NONE) {
+               ERR("__get_passphrase is failed : %d\n", ret);
+       } else if (old_len == len && !g_strcmp0(old_passphrase, passphrase)) {
+               dbus_g_method_return(context);
+               return TRUE;
+       }
+
        ret = __set_passphrase(passphrase, len);
        if (ret != MOBILE_AP_ERROR_NONE) {
                ERR("__set_passphrase is failed : %d\n", ret);
        }
 
+       _emit_mobileap_dbus_signal(obj, E_SIGNAL_PASSPHRASE_CHANGED, NULL);
        dbus_g_method_return(context);
 
        return TRUE;