From bcd251672e04b4229b296777bcbaed1034de0a5f Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 12 Dec 2006 03:27:35 +0000 Subject: [PATCH] 2006-12-11 Dan Williams * src/supplicant-manager/nm-supplicant-interface.c - (iface_state_cb, wpas_iface_get_state): new functions; query initial wpa_supplicant interface state - (nm_supplicant_interface_add_cb): query initial wpa_supplicant interface state before transitioning to READY state git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2181 4912f4e0-d625-0410-9fb7-b9a5a253dbdc --- ChangeLog | 8 ++ .../nm-supplicant-interface.c | 89 ++++++++++++++++++- 2 files changed, 95 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b6e4f2388e..88f3937476 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-12-11 Dan Williams + + * src/supplicant-manager/nm-supplicant-interface.c + - (iface_state_cb, wpas_iface_get_state): new functions; query initial + wpa_supplicant interface state + - (nm_supplicant_interface_add_cb): query initial wpa_supplicant interface + state before transitioning to READY state + 2006-12-04 Dan Williams * src/nm-device-802-11-wireless.c diff --git a/src/supplicant-manager/nm-supplicant-interface.c b/src/supplicant-manager/nm-supplicant-interface.c index 73c6dc3795..f39311cc22 100644 --- a/src/supplicant-manager/nm-supplicant-interface.c +++ b/src/supplicant-manager/nm-supplicant-interface.c @@ -815,6 +815,91 @@ wpas_iface_signal_handler (DBusConnection * connection, return handled; } +static void +iface_state_cb (DBusPendingCall * pcall, + NMSupplicantInterface * self) +{ + DBusError error; + DBusMessage * reply = NULL; + char * state_str = NULL; + + g_return_if_fail (pcall != NULL); + g_return_if_fail (self != NULL); + + dbus_error_init (&error); + + nm_dbus_send_with_callback_replied (pcall, __func__); + + if (!dbus_pending_call_get_completed (pcall)) + goto out; + + if (!(reply = dbus_pending_call_steal_reply (pcall))) + goto out; + + if (!dbus_message_get_args (reply, + &error, + DBUS_TYPE_STRING, &state_str, + DBUS_TYPE_INVALID)) { + nm_warning ("could not get scan results: %s - %s.", + error.name, + error.message); + goto out; + } + + self->priv->con_state = wpas_state_string_to_enum (state_str); + nm_supplicant_interface_set_state (self, NM_SUPPLICANT_INTERFACE_STATE_READY); + +out: + if (reply) + dbus_message_unref (reply); + if (dbus_error_is_set (&error)) + dbus_error_free (&error); + remove_pcall (self, pcall); +} + +static void +wpas_iface_get_state (NMSupplicantInterface *self) +{ + DBusMessage * message = NULL; + DBusPendingCall * pcall; + DBusConnection * connection; + + if (!self || !self->priv->wpas_iface_op) { + nm_warning ("Invalid user_data or bad supplicant interface object path."); + goto out; + } + + connection = nm_dbus_manager_get_dbus_connection (self->priv->dbus_mgr); + if (!connection) { + nm_warning ("could not get dbus connection."); + goto out; + } + + message = dbus_message_new_method_call (WPAS_DBUS_SERVICE, + self->priv->wpas_iface_op, + WPAS_DBUS_IFACE_INTERFACE, + "state"); + if (!message) { + nm_warning ("could not allocate dbus message."); + goto out; + } + + pcall = nm_dbus_send_with_callback (connection, + message, + (DBusPendingCallNotifyFunction) iface_state_cb, + self, + NULL, + __func__); + if (!pcall) { + nm_warning ("could not send dbus message."); + goto out; + } + add_pcall (self, pcall); + +out: + if (message) + dbus_message_unref (message); +} #define WPAS_ERROR_INVALID_IFACE \ WPAS_DBUS_INTERFACE ".InvalidInterface" @@ -868,8 +953,8 @@ nm_supplicant_interface_add_cb (DBusPendingCall * pcall, self); self->priv->wpas_sig_handler_id = id; - /* Interface added to the supplicant; transition to the READY state. */ - nm_supplicant_interface_set_state (self, NM_SUPPLICANT_INTERFACE_STATE_READY); + /* Interface added to the supplicant; get its initial state. */ + wpas_iface_get_state (self); } out: