Merge "Using updated clatd's Dbus interface and Path values" into tizen
[platform/core/connectivity/net-config.git] / src / signal-handler.c
index 9a57730..93373ff 100755 (executable)
@@ -39,6 +39,7 @@
 #include "signal-handler.h"
 #include "wifi-background-scan.h"
 #include "wifi-tdls.h"
+#include "wifi-dpp.h"
 #include "ip-conflict-detect.h"
 #include "wifi-key-encryption.h"
 #include "clatd-handler.h"
 #define SIGNAL_TDLS_DISCONNECTED                       "TDLSDisconnected"
 #define SIGNAL_TDLS_PEER_FOUND                         "TDLSPeerFound"
 
+#define SIGNAL_DPP_AUTH_SUCCESS "DPPAuthSuccess"
+#define SIGNAL_DPP_AUTH_FAILED "DPPAuthFailed"
+#define SIGNAL_DPP_NOT_COMPATIBLE "DPPNotCompatible"
+#define SIGNAL_DPP_CONF_FAILED "DPPConfFailed"
+#define SIGNAL_DPP_SCAN_PEER_QR "DPPScanPeerQrCode"
+#define SIGNAL_DPP_NETWORK_ID "DPPNetworkID"
+#define SIGNAL_DPP_CONF_SENT "DPPConfSent"
+#define SIGNAL_DPP_CONF_RECEIVED "DPPConfReceived"
+#define SIGNAL_DPP_CONF_OBJ "DPPConfObj"
+
 #define SIGNAL_WPS_CONNECTED                           "WPSConnected"
 #define SIGNAL_WPS_EVENT                                       "Event"
 #define SIGNAL_WPS_CREDENTIALS                         "Credentials"
 
 #define CONNMAN_SIGNAL_SERVICES_CHANGED                "ServicesChanged"
 #define CONNMAN_SIGNAL_PROPERTY_CHANGED                "PropertyChanged"
-#define CONNMAN_SIGNAL_NAME_CHANGED            "NameOwnerChanged"
+#define SIGNAL_NAME_OWNER_CHANGED              "NameOwnerChanged"
 
 #define MAX_SIG_LEN 64
-#define TOTAL_CONN_SIGNALS 5
+#define TOTAL_CONN_SIGNALS 6
 #define MAX_SOCKET_OPEN_RETRY 5
 
 typedef enum {
@@ -82,6 +93,15 @@ typedef enum {
        SIG_TDLS_CONNECTED,
        SIG_TDLS_DISCONNECTED,
        SIG_TDLS_PEER_FOUND,
+       SIG_DPP_AUTH_SUCCESS,
+       SIG_DPP_AUTH_FAILED,
+       SIG_DPP_NOT_COMPATIBLE,
+       SIG_DPP_CONF_FAILED,
+       SIG_DPP_SCAN_PEER_QR,
+       SIG_DPP_NETWORK_ID,
+       SIG_DPP_CONF_SENT,
+       SIG_DPP_CONF_RECEIVED,
+       SIG_DPP_CONF_OBJ,
        SIG_MAX
 } SuppSigArrayIndex;
 
@@ -96,6 +116,35 @@ static const char supplicant_signals[SIG_MAX][MAX_SIG_LEN] = {
                SIGNAL_TDLS_CONNECTED,
                SIGNAL_TDLS_DISCONNECTED,
                SIGNAL_TDLS_PEER_FOUND,
+               SIGNAL_DPP_AUTH_SUCCESS,
+               SIGNAL_DPP_AUTH_FAILED,
+               SIGNAL_DPP_NOT_COMPATIBLE,
+               SIGNAL_DPP_CONF_FAILED,
+               SIGNAL_DPP_SCAN_PEER_QR,
+               SIGNAL_DPP_NETWORK_ID,
+               SIGNAL_DPP_CONF_SENT,
+               SIGNAL_DPP_CONF_RECEIVED,
+               SIGNAL_DPP_CONF_OBJ,
+};
+static const char *supplicant_iface_for_sig[SIG_MAX] = {
+               SUPPLICANT_INTERFACE,
+               SUPPLICANT_IFACE_INTERFACE,
+               SUPPLICANT_IFACE_INTERFACE,
+               SUPPLICANT_IFACE_INTERFACE,
+               SUPPLICANT_IFACE_INTERFACE,
+               SUPPLICANT_IFACE_INTERFACE,
+               SUPPLICANT_IFACE_INTERFACE,
+               SUPPLICANT_IFACE_INTERFACE,
+               SUPPLICANT_IFACE_INTERFACE,
+               SUPPLICANT_IFACE_DPP,
+               SUPPLICANT_IFACE_DPP,
+               SUPPLICANT_IFACE_DPP,
+               SUPPLICANT_IFACE_DPP,
+               SUPPLICANT_IFACE_DPP,
+               SUPPLICANT_IFACE_DPP,
+               SUPPLICANT_IFACE_DPP,
+               SUPPLICANT_IFACE_DPP,
+               SUPPLICANT_IFACE_DPP,
 };
 
 static int supp_subscription_ids[SIG_MAX] = {0};
@@ -583,6 +632,12 @@ static void _dbus_name_changed_cb(GDBusConnection *conn,
                DBG("ConnMan destroyed: name %s, old %s, new %s", name, old, new);
 
                connman_register_agent();
+       } else if (g_strcmp0(name, CLATD_SERVICE) == 0 && *new == '\0') {
+               DBG("Clat destroyed: name %s, old %s, new %s", name, old, new);
+
+               /* If clatd is terminated unexpectedly, reset and enable clat service. */
+               if (NETCONFIG_CELLULAR_ONLINE == cellular_state_get_service_state())
+                       netconfig_clatd_reset();
        }
        g_free(name);
        g_free(old);
@@ -856,6 +911,87 @@ static void _supplicant_tdls_peer_found(GDBusConnection *conn,
        return;
 }
 
+static void _supplicant_dpp_auth_success(GDBusConnection *conn,
+               const gchar *name, const gchar *path, const gchar *interface,
+               const gchar *sig, GVariant *param, gpointer user_data)
+{
+       DBG("Received DPP Auth Success Signal");
+       netconfig_wifi_dpp_auth_success_event(param);
+       return;
+}
+
+static void _supplicant_dpp_auth_failed(GDBusConnection *conn,
+               const gchar *name, const gchar *path, const gchar *interface,
+               const gchar *sig, GVariant *param, gpointer user_data)
+{
+       DBG("Received DPP Auth Failed Signal");
+       netconfig_wifi_dpp_auth_failed_event(param);
+       return;
+}
+
+static void _supplicant_dpp_not_compatible(GDBusConnection *conn,
+               const gchar *name, const gchar *path, const gchar *interface,
+               const gchar *sig, GVariant *param, gpointer user_data)
+{
+       DBG("Received DPP Not Compatible Signal");
+       netconfig_wifi_dpp_not_compatible_event(param);
+       return;
+}
+
+static void _supplicant_dpp_conf_failed(GDBusConnection *conn,
+               const gchar *name, const gchar *path, const gchar *interface,
+               const gchar *sig, GVariant *param, gpointer user_data)
+{
+       DBG("Received DPP Conf Failed Signal");
+       netconfig_wifi_dpp_conf_failed_event(param);
+       return;
+}
+
+static void _supplicant_dpp_scan_peer_qr(GDBusConnection *conn,
+               const gchar *name, const gchar *path, const gchar *interface,
+               const gchar *sig, GVariant *param, gpointer user_data)
+{
+       DBG("Received DPP Scan Peer QR Signal");
+       netconfig_wifi_dpp_scan_peer_qr_event(param);
+       return;
+}
+
+static void _supplicant_dpp_network_id(GDBusConnection *conn,
+               const gchar *name, const gchar *path, const gchar *interface,
+               const gchar *sig, GVariant *param, gpointer user_data)
+{
+       DBG("Received DPP Network Id Signal");
+       netconfig_wifi_dpp_network_id_event(param);
+       return;
+}
+
+static void _supplicant_dpp_conf_sent(GDBusConnection *conn,
+               const gchar *name, const gchar *path, const gchar *interface,
+               const gchar *sig, GVariant *param, gpointer user_data)
+{
+       DBG("Received DPP Conf Sent Signal");
+       netconfig_wifi_dpp_conf_sent_event(param);
+       return;
+}
+
+static void _supplicant_dpp_conf_received(GDBusConnection *conn,
+               const gchar *name, const gchar *path, const gchar *interface,
+               const gchar *sig, GVariant *param, gpointer user_data)
+{
+       DBG("Received DPP Conf Received Signal");
+       netconfig_wifi_dpp_conf_received_event(param);
+       return;
+}
+
+static void _supplicant_dpp_conf_obj(GDBusConnection *conn,
+               const gchar *name, const gchar *path, const gchar *interface,
+               const gchar *sig, GVariant *param, gpointer user_data)
+{
+       DBG("Received DPP Conf Obj Signal");
+       netconfig_wifi_dpp_conf_obj_event(param);
+       return;
+}
+
 static void _supplicant_wifi_wps_connected(GVariant *param)
 {
        gchar *key;
@@ -1161,13 +1297,21 @@ static supplicant_signal_cb supplicant_cbs[SIG_MAX] = {
                _supplicant_session_overlapped,
                _supplicant_tdls_connected,
                _supplicant_tdls_disconnected,
-               _supplicant_tdls_peer_found
+               _supplicant_tdls_peer_found,
+               _supplicant_dpp_auth_success,
+               _supplicant_dpp_auth_failed,
+               _supplicant_dpp_not_compatible,
+               _supplicant_dpp_conf_failed,
+               _supplicant_dpp_scan_peer_qr,
+               _supplicant_dpp_network_id,
+               _supplicant_dpp_conf_sent,
+               _supplicant_dpp_conf_received,
+               _supplicant_dpp_conf_obj,
 };
 
 void register_gdbus_signal(void)
 {
        GDBusConnection *connection = NULL;
-       const char *interface = NULL;
        SuppSigArrayIndex sig;
        connection = netdbus_get_connection();
 
@@ -1206,7 +1350,7 @@ void register_gdbus_signal(void)
                        connection,
                        DBUS_SERVICE_DBUS,
                        DBUS_INTERFACE_DBUS,
-                       CONNMAN_SIGNAL_NAME_CHANGED,
+                       SIGNAL_NAME_OWNER_CHANGED,
                        NULL,
                        CONNMAN_SERVICE,
                        G_DBUS_SIGNAL_FLAGS_NONE,
@@ -1242,17 +1386,25 @@ void register_gdbus_signal(void)
 
        INFO("Successfully register Supplicant WPS DBus signal filters");
 
-       for (sig = SIG_INTERFACE_REMOVED; sig < SIG_MAX; sig++) {
-               /*
-                * For SIG_INTERFACE_REMOVED INTERFACE_ADDED
-                */
-               interface = (sig == SIG_INTERFACE_REMOVED) ?
-                               SUPPLICANT_INTERFACE : SUPPLICANT_IFACE_INTERFACE;
+       conn_subscription_ids[5] = g_dbus_connection_signal_subscribe(
+                       connection,
+                       DBUS_SERVICE_DBUS,
+                       DBUS_INTERFACE_DBUS,
+                       SIGNAL_NAME_OWNER_CHANGED,
+                       NULL,
+                       CLATD_SERVICE,
+                       G_DBUS_SIGNAL_FLAGS_NONE,
+                       _dbus_name_changed_cb,
+                       NULL,
+                       NULL);
 
+       INFO("Successfully register clat DBus signal filters");
+
+       for (sig = SIG_INTERFACE_REMOVED; sig < SIG_MAX; sig++) {
                supp_subscription_ids[sig] = g_dbus_connection_signal_subscribe(
                                connection,
                                SUPPLICANT_SERVICE,
-                               interface,
+                               supplicant_iface_for_sig[sig],
                                supplicant_signals[sig],
                                NULL,
                                NULL,