]> git.ipfire.org Git - thirdparty/hostap.git/blobdiff - wpa_supplicant/dbus/dbus_new.c
Export disconnect reason code to dbus
[thirdparty/hostap.git] / wpa_supplicant / dbus / dbus_new.c
index 0c89d145062bb0b58f0ea4653962552651980635..fcdf995e3b5635da1f223428a1a1398cb4cbb516 100644 (file)
@@ -840,6 +840,41 @@ nomem:
        dbus_message_unref(msg);
 }
 
+
+void wpas_dbus_signal_eap_status(struct wpa_supplicant *wpa_s,
+                                const char *status, const char *parameter)
+{
+       struct wpas_dbus_priv *iface;
+       DBusMessage *msg;
+       DBusMessageIter iter;
+
+       iface = wpa_s->global->dbus;
+
+       /* Do nothing if the control interface is not turned on */
+       if (iface == NULL)
+               return;
+
+       msg = dbus_message_new_signal(wpa_s->dbus_new_path,
+                                     WPAS_DBUS_NEW_IFACE_INTERFACE,
+                                     "EAP");
+       if (msg == NULL)
+               return;
+
+       dbus_message_iter_init_append(msg, &iter);
+
+       if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &status)
+           ||
+           !dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING,
+                                           &parameter))
+               goto nomem;
+
+       dbus_connection_send(iface->con, msg, NULL);
+
+nomem:
+       dbus_message_unref(msg);
+}
+
+
 #ifdef CONFIG_P2P
 
 /**
@@ -1700,10 +1735,12 @@ void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s,
                                   enum wpas_dbus_prop property)
 {
        char *prop;
+       dbus_bool_t flush;
 
        if (wpa_s->dbus_new_path == NULL)
                return; /* Skip signal since D-Bus setup is not yet ready */
 
+       flush = FALSE;
        switch (property) {
        case WPAS_DBUS_PROP_AP_SCAN:
                prop = "ApScan";
@@ -1726,6 +1763,10 @@ void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s,
        case WPAS_DBUS_PROP_CURRENT_AUTH_MODE:
                prop = "CurrentAuthMode";
                break;
+       case WPAS_DBUS_PROP_DISCONNECT_REASON:
+               prop = "DisconnectReason";
+               flush = TRUE;
+               break;
        default:
                wpa_printf(MSG_ERROR, "dbus: %s: Unknown Property value %d",
                           __func__, property);
@@ -1735,6 +1776,10 @@ void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s,
        wpa_dbus_mark_property_changed(wpa_s->global->dbus,
                                       wpa_s->dbus_new_path,
                                       WPAS_DBUS_NEW_IFACE_INTERFACE, prop);
+       if (flush) {
+               wpa_dbus_flush_object_changed_properties(
+                       wpa_s->global->dbus->con, wpa_s->dbus_new_path);
+       }
 }
 
 
@@ -1885,6 +1930,15 @@ static const struct wpa_dbus_method_desc wpas_dbus_global_methods[] = {
                  END_ARGS
          }
        },
+#ifdef CONFIG_AUTOSCAN
+       { "AutoScan", WPAS_DBUS_NEW_IFACE_INTERFACE,
+         (WPADBusMethodHandler) &wpas_dbus_handler_autoscan,
+         {
+                 { "arg", "s", ARG_IN },
+                 END_ARGS
+         }
+       },
+#endif /* CONFIG_AUTOSCAN */
        { NULL, NULL, NULL, { END_ARGS } }
 };
 
@@ -2122,11 +2176,11 @@ int wpas_dbus_unregister_network(struct wpa_supplicant *wpa_s, int nid)
        struct wpas_dbus_priv *ctrl_iface;
        char net_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
        int ret;
+#ifdef CONFIG_P2P
        struct wpa_ssid *ssid;
 
        ssid = wpa_config_get_network(wpa_s->conf, nid);
 
-#ifdef CONFIG_P2P
        /* If it is a persistent group unregister it as such */
        if (ssid && network_is_persistent_group(ssid))
                return wpas_dbus_unregister_persistent_group(wpa_s, nid);
@@ -2702,6 +2756,10 @@ static const struct wpa_dbus_property_desc wpas_dbus_interface_properties[] = {
          NULL
        },
 #endif /* CONFIG_P2P */
+       { "DisconnectReason", WPAS_DBUS_NEW_IFACE_INTERFACE, "i",
+         wpas_dbus_getter_disconnect_reason,
+         NULL
+       },
        { NULL, NULL, NULL, NULL, NULL }
 };
 
@@ -2934,6 +2992,13 @@ static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = {
                  END_ARGS
          }
        },
+       { "EAP", WPAS_DBUS_NEW_IFACE_INTERFACE,
+         {
+                 { "status", "s", ARG_OUT },
+                 { "parameter", "s", ARG_OUT },
+                 END_ARGS
+         }
+       },
        { NULL, NULL, { END_ARGS } }
 };