diff options
author | Dan Williams <dcbw@redhat.com> | 2006-12-12 03:27:35 +0000 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2006-12-12 03:27:35 +0000 |
commit | bcd251672e04b4229b296777bcbaed1034de0a5f (patch) | |
tree | f07d34aca2a91c68a3dc9a294a2e5a20a228de07 /src/supplicant-manager/nm-supplicant-interface.c | |
parent | a1a2c81bd965a3c26fd288358d8fce76df53c932 (diff) | |
download | NetworkManager-bcd251672e04b4229b296777bcbaed1034de0a5f.tar.gz |
2006-12-11 Dan Williams <dcbw@redhat.com>
* 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
Diffstat (limited to 'src/supplicant-manager/nm-supplicant-interface.c')
-rw-r--r-- | src/supplicant-manager/nm-supplicant-interface.c | 89 |
1 files changed, 87 insertions, 2 deletions
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: |