Added new dbus to check is softap enabled 58/145458/1 accepted/tizen/unified/20170829.053204 submit/tizen/20170828.230131
authorsaerome kim <saerome.kim@samsung.com>
Tue, 22 Aug 2017 10:14:01 +0000 (19:14 +0900)
committersaerome kim <saerome.kim@samsung.com>
Tue, 22 Aug 2017 10:14:01 +0000 (19:14 +0900)
Change-Id: Ia00b1aab5d4d46012372f2cbe53eb67fedfa8a59
Signed-off-by: Saurav Babu <saurav.babu@samsung.com>
include/wmesh-request.h
include/wmesh-softap.h
introspection/wmesh.xml
src/wmesh-request.c
src/wmesh-service-interface.c
src/wmesh-softap.c

index 3c625c0..61c30b4 100644 (file)
@@ -66,6 +66,7 @@ int wmesh_request_enable_softap(
                const char* bridge_interface, const char* softap_interface);
 int wmesh_request_disable_softap(
                const char* bridge_interface, const char* softap_interface);
+bool wmesh_request_check_softap_status();
 
 /* Mesh Station & path */
 int wmesh_request_get_station_info(const char* mesh_interface, GList **station_list);
index cb62828..bd86df7 100644 (file)
@@ -31,6 +31,7 @@ int wmesh_softap_get_configuration(char **softap_interface, char **ssid,
                int *max_sta, int *security, char **passphrase);
 int wmesh_softap_enable_softap();
 int wmesh_softap_disable_softap();
+bool wmesh_softap_check_softap_status();
 
 #ifdef __cplusplus
 }
index c3391b3..a91ba7e 100644 (file)
@@ -85,6 +85,9 @@
                <method name="disable_softap">\r
                        <arg type="i" name="result" direction="out"/>\r
                </method>\r
+               <method name="is_softap_enabled">\r
+                       <arg type="b" name="status" direction="out"/>\r
+               </method>\r
                <method name="create_mesh_network">\r
                        <arg type="s" name="mesh_id" direction="in"/>\r
                        <arg type="i" name="channel" direction="in"/>\r
index 854b372..c4126dd 100644 (file)
@@ -235,6 +235,13 @@ int wmesh_request_disable_softap(
        return ret;
 }
 
+bool wmesh_request_check_softap_status()
+{
+       WMESH_LOGD("Check softAp status");
+
+       return  wmesh_softap_check_softap_status();
+}
+
 int wmesh_request_get_station_info(const char* mesh_interface, GList **station_list)
 {
        int ret = WMESHD_ERROR_NONE;
index 6e52253..7eac245 100644 (file)
@@ -721,6 +721,21 @@ static gboolean _wmeshd_dbus_handle_disable_softap(NetWmesh *object,
        return TRUE;
 }
 
+static gboolean _wmeshd_dbus_handle_is_softap_enabled(NetWmesh *object,
+               GDBusMethodInvocation *invocation, gpointer user_data)
+{
+       bool status;
+       (void) user_data;
+
+       /* Check SoftAP status */
+       status = wmesh_request_check_softap_status();
+       WMESH_LOGD("SoftAP is %s", status ? "enabled" : "disabled");
+
+       net_wmesh_complete_is_softap_enabled(object, invocation, status);
+
+       return TRUE;
+}
+
 static gboolean _wmeshd_dbus_handle_create_mesh_network(NetWmesh *object,
                GDBusMethodInvocation *invocation,
                gchar *mesh_id, gint channel, gint security,
@@ -1166,6 +1181,8 @@ static void _wmeshd_dbus_on_bus_acquired(GDBusConnection *conn, const gchar *nam
                        G_CALLBACK(_wmeshd_dbus_handle_enable_softap), service);
        g_signal_connect(meshd_dbus_object, "handle-disable-softap",
                        G_CALLBACK(_wmeshd_dbus_handle_disable_softap), service);
+       g_signal_connect(meshd_dbus_object, "handle-is-softap-enabled",
+                       G_CALLBACK(_wmeshd_dbus_handle_is_softap_enabled), NULL);
        g_signal_connect(meshd_dbus_object, "handle-create-mesh-network",
                        G_CALLBACK(_wmeshd_dbus_handle_create_mesh_network), service);
        g_signal_connect(meshd_dbus_object, "handle-connect-mesh-network",
index 194ef7b..eb8198a 100644 (file)
@@ -475,3 +475,22 @@ int wmesh_softap_disable_softap()
 
        return ret;
 }
+
+bool wmesh_softap_check_softap_status()
+{
+       int ret = WMESHD_ERROR_NONE;
+       pid_t hostapd_pid = 0;
+
+       ret = __get_pid_of_hostapd(&hostapd_pid);
+       if (ret != WMESHD_ERROR_NONE) {
+               WMESH_LOGE("hostapd is not running");
+               return false;
+       }
+
+       if (hostapd_pid == 0) {
+               WMESH_LOGD("hostapd is not running");
+               return false;
+       }
+
+       return true;
+}