From 537b30f99ef5bb6f2623dc227d39b435a58faeb6 Mon Sep 17 00:00:00 2001 From: Tambet Ingo Date: Tue, 20 Feb 2007 15:24:42 +0000 Subject: [PATCH] 2007-02-20 Tambet Ingo * libnm-glib/nm-device-802-11-wireless.c: Add "network-added" and "network-removed" signals. * libnm-glib/libnm-glib.pc.in: Require NetworkManager >= 0.7.0. * libnm-glib/nm-access-point.c: Add "strength-changed" signal, emit it when receiving the signal from dbus. * src/nm-device-802-11-wireless.c (get_property): Fix PROP_ACTIVE_NETWORK property. * src/NetworkManagerPolicy.c (state_changed): Fix a typo to make the deactivation of the previously activated device working again. * src/nm-activation-request.c: Remove NMActStage property and it's getter and setter. * src/nm-device.c (nm_device_is_activated): Remove. state == NM_DEVICE_STATE_ACTIVATED is just as easy to use. * include/NetworkManager.h: Remove NM_DBUS_NO_DEVICES_ERROR, NM_DBUS_NO_DIALUP_ERROR, NM_DBUS_NO_NETWORKS_ERROR, NM_DBUS_NO_ACTIVE_DEVICE_ERROR, NM_DBUS_NO_ACTIVE_NET_ERROR errors and NM_DBUS_SIGNAL_STATE_CHANGE signal. Remove NMNetworkStatus and NMActStage enums. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2345 4912f4e0-d625-0410-9fb7-b9a5a253dbdc --- ChangeLog | 28 ++++++++ include/NetworkManager.h | 44 ------------ libnm-glib/libnm-glib.pc.in | 2 +- libnm-glib/nm-access-point.c | 52 ++++++++++++-- libnm-glib/nm-access-point.h | 3 + libnm-glib/nm-client.c | 12 ++-- libnm-glib/nm-device-802-11-wireless.c | 97 ++++++++++++++++++++++++-- libnm-glib/nm-device-802-11-wireless.h | 4 ++ src/NetworkManagerDbus.c | 50 ------------- src/NetworkManagerDbus.h | 1 - src/NetworkManagerPolicy.c | 2 +- src/nm-activation-request.c | 52 -------------- src/nm-activation-request.h | 3 - src/nm-dbus-nmi.c | 1 - src/nm-device-802-11-wireless.c | 28 +++----- src/nm-device-private.h | 2 - src/nm-device.c | 52 +------------- 17 files changed, 191 insertions(+), 242 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4bc018a742..e8e7f9e00f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,31 @@ +2007-02-20 Tambet Ingo + + * libnm-glib/nm-device-802-11-wireless.c: Add "network-added" and + "network-removed" signals. + + * libnm-glib/libnm-glib.pc.in: Require NetworkManager >= 0.7.0. + + * libnm-glib/nm-access-point.c: Add "strength-changed" signal, emit it + when receiving the signal from dbus. + + * src/nm-device-802-11-wireless.c (get_property): Fix PROP_ACTIVE_NETWORK + property. + + * src/NetworkManagerPolicy.c (state_changed): Fix a typo to make the + deactivation of the previously activated device working again. + + * src/nm-activation-request.c: Remove NMActStage property and it's getter + and setter. + + * src/nm-device.c (nm_device_is_activated): Remove. + state == NM_DEVICE_STATE_ACTIVATED is just as easy to use. + + * include/NetworkManager.h: Remove NM_DBUS_NO_DEVICES_ERROR, + NM_DBUS_NO_DIALUP_ERROR, NM_DBUS_NO_NETWORKS_ERROR, + NM_DBUS_NO_ACTIVE_DEVICE_ERROR, NM_DBUS_NO_ACTIVE_NET_ERROR errors and + NM_DBUS_SIGNAL_STATE_CHANGE signal. + Remove NMNetworkStatus and NMActStage enums. + 2007-02-19 Tambet Ingo * src/vpn-manager/nm-vpn-manager.c: Handle the DBUS state changes itself. diff --git a/include/NetworkManager.h b/include/NetworkManager.h index da8c7e445f..dd7eb98c02 100644 --- a/include/NetworkManager.h +++ b/include/NetworkManager.h @@ -41,24 +41,9 @@ #define NMI_DBUS_INTERFACE "org.freedesktop.NetworkManagerInfo" -/* - * Some common errors - */ -#define NM_DBUS_NO_DEVICES_ERROR "org.freedesktop.NetworkManager.NoDevices" -#define NM_DBUS_NO_DIALUP_ERROR "org.freedesktop.NetworkManager.NoDialup" -#define NM_DBUS_NO_NETWORKS_ERROR "org.freedesktop.NetworkManager.NoNetworks" -#define NM_DBUS_NO_ACTIVE_DEVICE_ERROR "org.freedesktop.NetworkManager.NoActiveDevice" -#define NM_DBUS_NO_ACTIVE_NET_ERROR "org.freedesktop.NetworkManager.NoActiveNetwork" - #define NMI_DBUS_USER_KEY_CANCELED_ERROR "org.freedesktop.NetworkManagerInfo.CanceledError" -/* - * NetworkManager signals - */ -#define NM_DBUS_SIGNAL_STATE_CHANGE "StateChange" - - /* * Types of NetworkManager devices */ @@ -135,17 +120,6 @@ typedef enum NMDeviceType #define NM_EAP_METHOD_TLS 0x00000020 /* EAP-TLS */ #define NM_EAP_METHOD_TTLS 0x00000040 /* EAP-TTLS */ -/* - * Wireless network update types - */ -typedef enum -{ - NETWORK_STATUS_DISAPPEARED = 0, - NETWORK_STATUS_APPEARED, - NETWORK_STATUS_STRENGTH_CHANGED -} NMNetworkStatus; - - /* * Wireless network types */ @@ -158,24 +132,6 @@ typedef enum NMNetworkType } NMNetworkType; -/* - * Device activation stages - */ -typedef enum NMActStage -{ - NM_ACT_STAGE_UNKNOWN = 0, - NM_ACT_STAGE_DEVICE_PREPARE, - NM_ACT_STAGE_DEVICE_CONFIG, - NM_ACT_STAGE_NEED_USER_KEY, - NM_ACT_STAGE_IP_CONFIG_START, - NM_ACT_STAGE_IP_CONFIG_GET, - NM_ACT_STAGE_IP_CONFIG_COMMIT, - NM_ACT_STAGE_ACTIVATED, - NM_ACT_STAGE_FAILED, - NM_ACT_STAGE_CANCELLED -} NMActStage; - - /* * Device states. Will obsolete NMActStage soon. */ diff --git a/libnm-glib/libnm-glib.pc.in b/libnm-glib/libnm-glib.pc.in index 196c4c7dcc..c4de4b7363 100644 --- a/libnm-glib/libnm-glib.pc.in +++ b/libnm-glib/libnm-glib.pc.in @@ -6,7 +6,7 @@ includedir=@includedir@ Name: libnm_glib Description: Convenience library for clients of NetworkManager Version: @VERSION@ -Requires: glib-2.0 +Requires: NetworkManager >= 0.7.0 Cflags: -I${includedir}/libnm-glib Libs: -L${libdir} -lnm-glib diff --git a/libnm-glib/nm-access-point.c b/libnm-glib/nm-access-point.c index 7967195279..ef6c8e53ba 100644 --- a/libnm-glib/nm-access-point.c +++ b/libnm-glib/nm-access-point.c @@ -6,6 +6,16 @@ G_DEFINE_TYPE (NMAccessPoint, nm_access_point, DBUS_TYPE_G_PROXY) +enum { + STRENGTH_CHANGED, + + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + +static void strength_changed_proxy (NMAccessPoint *ap, guchar strength); + static void nm_access_point_init (NMAccessPoint *ap) { @@ -14,17 +24,47 @@ nm_access_point_init (NMAccessPoint *ap) static void nm_access_point_class_init (NMAccessPointClass *ap_class) { + GObjectClass *object_class = G_OBJECT_CLASS (ap_class); + + /* signals */ + signals[STRENGTH_CHANGED] = + g_signal_new ("strength-changed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (NMAccessPointClass, strength_changed), + NULL, NULL, + g_cclosure_marshal_VOID__UCHAR, + G_TYPE_NONE, 1, + G_TYPE_UCHAR); + } NMAccessPoint * nm_access_point_new (DBusGConnection *connection, const char *path) { - return (NMAccessPoint *) g_object_new (NM_TYPE_ACCESS_POINT, - "name", NM_DBUS_SERVICE, - "path", path, - "interface", NM_DBUS_INTERFACE_ACCESS_POINT, - "connection", connection, - NULL); + NMAccessPoint *ap; + + ap = (NMAccessPoint *) g_object_new (NM_TYPE_ACCESS_POINT, + "name", NM_DBUS_SERVICE, + "path", path, + "interface", NM_DBUS_INTERFACE_ACCESS_POINT, + "connection", connection, + NULL); + + dbus_g_proxy_add_signal (DBUS_G_PROXY (ap), "StrengthChanged", G_TYPE_UCHAR, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (DBUS_G_PROXY (ap), + "StrengthChanged", + G_CALLBACK (strength_changed_proxy), + NULL, + NULL); + + return ap; +} + +static void +strength_changed_proxy (NMAccessPoint *ap, guchar strength) +{ + g_signal_emit (ap, signals[STRENGTH_CHANGED], 0, strength); } guint32 diff --git a/libnm-glib/nm-access-point.h b/libnm-glib/nm-access-point.h index ac30cae405..8d0b620fb0 100644 --- a/libnm-glib/nm-access-point.h +++ b/libnm-glib/nm-access-point.h @@ -18,6 +18,9 @@ typedef struct { typedef struct { DBusGProxyClass parent; + + /* Signals */ + void (*strength_changed) (NMAccessPoint *ap, gint8 strength); } NMAccessPointClass; GType nm_access_point_get_type (void); diff --git a/libnm-glib/nm-client.c b/libnm-glib/nm-client.c index cd6f55f213..71a3bdc1a4 100644 --- a/libnm-glib/nm-client.c +++ b/libnm-glib/nm-client.c @@ -93,21 +93,21 @@ nm_client_new (void) dbus_g_proxy_connect_signal (proxy, "StateChange", G_CALLBACK (client_state_change_proxy), - client, + NULL, NULL); dbus_g_proxy_add_signal (proxy, "DeviceAdded", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID); dbus_g_proxy_connect_signal (proxy, "DeviceAdded", G_CALLBACK (client_device_added_proxy), - client, + NULL, NULL); dbus_g_proxy_add_signal (proxy, "DeviceRemoved", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID); dbus_g_proxy_connect_signal (proxy, "DeviceRemoved", G_CALLBACK (client_device_removed_proxy), - client, + NULL, NULL); return client; @@ -116,7 +116,7 @@ nm_client_new (void) static void client_state_change_proxy (DBusGProxy *proxy, guint state, gpointer user_data) { - NMClient *client = NM_CLIENT (user_data); + NMClient *client = NM_CLIENT (proxy); g_signal_emit (client, signals[STATE_CHANGE], 0, state); } @@ -124,7 +124,7 @@ client_state_change_proxy (DBusGProxy *proxy, guint state, gpointer user_data) static void client_device_added_proxy (DBusGProxy *proxy, char *path, gpointer user_data) { - NMClient *client = NM_CLIENT (user_data); + NMClient *client = NM_CLIENT (proxy); NMDevice *device; DBusGConnection *connection = NULL; @@ -137,7 +137,7 @@ client_device_added_proxy (DBusGProxy *proxy, char *path, gpointer user_data) static void client_device_removed_proxy (DBusGProxy *proxy, char *path, gpointer user_data) { - NMClient *client = NM_CLIENT (user_data); + NMClient *client = NM_CLIENT (proxy); NMDevice *device; DBusGConnection *connection = NULL; diff --git a/libnm-glib/nm-device-802-11-wireless.c b/libnm-glib/nm-device-802-11-wireless.c index dcd8085eeb..8e963cd4a2 100644 --- a/libnm-glib/nm-device-802-11-wireless.c +++ b/libnm-glib/nm-device-802-11-wireless.c @@ -6,6 +6,18 @@ G_DEFINE_TYPE (NMDevice80211Wireless, nm_device_802_11_wireless, NM_TYPE_DEVICE) +enum { + NETWORK_ADDED, + NETWORK_REMOVED, + + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + +static void network_added_proxy (DBusGProxy *proxy, char *path, gpointer user_data); +static void network_removed_proxy (DBusGProxy *proxy, char *path, gpointer user_data); + static void nm_device_802_11_wireless_init (NMDevice80211Wireless *device) { @@ -14,20 +26,63 @@ nm_device_802_11_wireless_init (NMDevice80211Wireless *device) static void nm_device_802_11_wireless_class_init (NMDevice80211WirelessClass *device_class) { + GObjectClass *object_class = G_OBJECT_CLASS (device_class); + + /* signals */ + signals[NETWORK_ADDED] = + g_signal_new ("network-added", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (NMDevice80211WirelessClass, network_added), + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + G_TYPE_OBJECT); + + signals[NETWORK_ADDED] = + g_signal_new ("network-removed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (NMDevice80211WirelessClass, network_removed), + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + G_TYPE_OBJECT); } NMDevice80211Wireless * nm_device_802_11_wireless_new (DBusGConnection *connection, const char *path) { + NMDevice80211Wireless *device; + DBusGProxy *proxy; + g_return_val_if_fail (connection != NULL, NULL); g_return_val_if_fail (path != NULL, NULL); - return (NMDevice80211Wireless *) g_object_new (NM_TYPE_DEVICE_802_11_WIRELESS, - "name", NM_DBUS_SERVICE, - "path", path, - "interface", NM_DBUS_INTERFACE_DEVICE_WIRELESS, - "connection", connection, - NULL); + device = (NMDevice80211Wireless *) g_object_new (NM_TYPE_DEVICE_802_11_WIRELESS, + "name", NM_DBUS_SERVICE, + "path", path, + "interface", NM_DBUS_INTERFACE_DEVICE_WIRELESS, + "connection", connection, + NULL); + + proxy = DBUS_G_PROXY (device); + + dbus_g_proxy_add_signal (proxy, "NetworkAdded", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (proxy, + "NetworkAdded", + G_CALLBACK (network_added_proxy), + NULL, + NULL); + + dbus_g_proxy_add_signal (proxy, "NetworkRemoved", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (proxy, + "NetworkRemoved", + G_CALLBACK (network_removed_proxy), + NULL, + NULL); + + return device; } char * @@ -95,8 +150,10 @@ nm_device_802_11_wireless_get_active_network (NMDevice80211Wireless *device) &value)) { DBusGConnection *connection = NULL; + g_assert (G_VALUE_TYPE (&value) == DBUS_TYPE_G_OBJECT_PATH); + g_object_get (device, "connection", &connection, NULL); - ap = nm_access_point_new (connection, g_value_get_string (&value)); + ap = nm_access_point_new (connection, (const char *) g_value_get_boxed (&value)); } return ap; @@ -149,3 +206,29 @@ nm_device_802_11_wireless_activate (NMDevice80211Wireless *device, g_error_free (err); } } + +static void +network_added_proxy (DBusGProxy *proxy, char *path, gpointer user_data) +{ + NMDevice80211Wireless *device = NM_DEVICE_802_11_WIRELESS (proxy); + NMAccessPoint *ap; + DBusGConnection *connection = NULL; + + g_object_get (proxy, "connection", &connection, NULL); + ap = nm_access_point_new (connection, path); + g_signal_emit (device, signals[NETWORK_ADDED], 0, ap); + g_object_unref (ap); +} + +static void +network_removed_proxy (DBusGProxy *proxy, char *path, gpointer user_data) +{ + NMDevice80211Wireless *device = NM_DEVICE_802_11_WIRELESS (proxy); + NMAccessPoint *ap; + DBusGConnection *connection = NULL; + + g_object_get (proxy, "connection", &connection, NULL); + ap = nm_access_point_new (connection, path); + g_signal_emit (device, signals[NETWORK_REMOVED], 0, ap); + g_object_unref (ap); +} diff --git a/libnm-glib/nm-device-802-11-wireless.h b/libnm-glib/nm-device-802-11-wireless.h index 0c36fb422a..cb1b5bcba0 100644 --- a/libnm-glib/nm-device-802-11-wireless.h +++ b/libnm-glib/nm-device-802-11-wireless.h @@ -17,6 +17,10 @@ typedef struct { typedef struct { NMDeviceClass parent; + + /* Signals */ + void (*network_added) (NMDevice80211Wireless *device, NMAccessPoint *ap); + void (*network_removed) (NMDevice80211Wireless *device, NMAccessPoint *ap); } NMDevice80211WirelessClass; GType nm_device_802_11_wireless_get_type (void); diff --git a/src/NetworkManagerDbus.c b/src/NetworkManagerDbus.c index 9bb0c82671..d5ad2fef02 100644 --- a/src/NetworkManagerDbus.c +++ b/src/NetworkManagerDbus.c @@ -41,12 +41,6 @@ #include "nm-dhcp-manager.h" #include "nm-dbus-manager.h" -#if 0 -static char *get_nmi_match_string (const char *owner); - -static gpointer nm_dbus_reinit (gpointer user_data); -#endif - /* * nm_dbus_create_error_message * @@ -132,50 +126,6 @@ char * nm_dbus_get_object_path_for_network (NMDevice *dev, NMAccessPoint *ap) } -/* - * nm_dbus_get_device_from_escaped_object_path - * - * Returns the device associated with an _escaped_ dbus object path - * - */ -NMDevice *nm_dbus_get_device_from_escaped_object_path (NMData *data, const char *path) -{ - NMDevice *dev = NULL; - GSList * elt; - - g_return_val_if_fail (path != NULL, NULL); - g_return_val_if_fail (data != NULL, NULL); - - /* Iterate over the device list looking for the device with the matching object path. */ - for (elt = data->dev_list; elt; elt = g_slist_next (elt)) { - char *compare_path; - char *escaped_compare_path; - int len; - - if (!(dev = NM_DEVICE (elt->data))) - continue; - - compare_path = g_strdup_printf ("%s/%s", NM_DBUS_PATH_DEVICE, nm_device_get_iface (dev)); - escaped_compare_path = nm_dbus_escape_object_path (compare_path); - g_free (compare_path); - len = strlen (escaped_compare_path); - - /* Compare against our constructed path, but ignore any trailing elements */ - if ( (strncmp (path, escaped_compare_path, len) == 0) - && ((path[len] == '\0' || path[len] == '/'))) - { - g_free (escaped_compare_path); - g_object_ref (G_OBJECT (dev)); - break; - } - g_free (escaped_compare_path); - dev = NULL; - } - - return dev; -} - - /*-------------------------------------------------------------*/ /* Handler code */ /*-------------------------------------------------------------*/ diff --git a/src/NetworkManagerDbus.h b/src/NetworkManagerDbus.h index 42a8713725..e0770b068b 100644 --- a/src/NetworkManagerDbus.h +++ b/src/NetworkManagerDbus.h @@ -41,7 +41,6 @@ static inline gboolean message_is_error (DBusMessage *msg) char * nm_dbus_get_object_path_for_device (NMDevice *dev); char * nm_dbus_get_object_path_for_network (NMDevice *dev, NMAccessPoint *ap); -NMDevice * nm_dbus_get_device_from_escaped_object_path (NMData *data, const char *path); DBusMessage * nm_dbus_create_error_message (DBusMessage *message, const char *exception_namespace, const char *exception, const char *format, ...); diff --git a/src/NetworkManagerPolicy.c b/src/NetworkManagerPolicy.c index 193f1f4e34..1a1f260d5c 100644 --- a/src/NetworkManagerPolicy.c +++ b/src/NetworkManagerPolicy.c @@ -539,7 +539,7 @@ state_changed (NMManager *manager, NMState state, gpointer user_data) { NMPolicy *policy = (NMPolicy *) user_data; - if (state == NM_ACT_STAGE_DEVICE_PREPARE) { + if (state == NM_STATE_CONNECTING) { /* A device starts activation, bring all devices down * Remove this when we support multiple active devices. */ diff --git a/src/nm-activation-request.c b/src/nm-activation-request.c index f5fc876b52..f79ef8b56a 100644 --- a/src/nm-activation-request.c +++ b/src/nm-activation-request.c @@ -40,7 +40,6 @@ struct NMActRequest gboolean user_requested; - NMActStage stage; DBusPendingCall * user_key_pcall; }; @@ -143,57 +142,6 @@ void nm_act_request_set_ip4_config (NMActRequest *req, NMIP4Config *ip4_config) req->ip4_config = g_object_ref (ip4_config); } -NMActStage nm_act_request_get_stage (NMActRequest *req) -{ - g_return_val_if_fail (req != NULL, NM_ACT_STAGE_UNKNOWN); - - return req->stage; -} - -void nm_act_request_set_stage (NMActRequest *req, NMActStage stage) -{ - DBusMessage * message; - char * dev_path = NULL; - NMDBusManager * dbus_mgr = NULL; - DBusConnection *dbus_connection; - - g_return_if_fail (req != NULL); - - req->stage = stage; - - g_return_if_fail (req->data); - g_return_if_fail (req->dev); - - dbus_mgr = nm_dbus_manager_get (); - dbus_connection = nm_dbus_manager_get_dbus_connection (dbus_mgr); - if (!dbus_connection) { - nm_warning ("couldn't get the dbus connection."); - goto out; - } - - if (!(dev_path = nm_dbus_get_object_path_for_device (req->dev))) - goto out; - - message = dbus_message_new_signal (NM_DBUS_PATH, - NM_DBUS_INTERFACE, - "DeviceActivationStage"); - if (!message) { - nm_warning ("couldn't allocate the dbus message."); - goto out; - } - - dbus_message_append_args (message, - DBUS_TYPE_OBJECT_PATH, &dev_path, - DBUS_TYPE_UINT32, &stage, - DBUS_TYPE_INVALID); - dbus_connection_send (dbus_connection, message, NULL); - dbus_message_unref (message); - -out: - g_free (dev_path); - g_object_unref (dbus_mgr); -} - DBusPendingCall * nm_act_request_get_user_key_pending_call (NMActRequest *req) { g_return_val_if_fail (req != NULL, NULL); diff --git a/src/nm-activation-request.h b/src/nm-activation-request.h index a58c383b3c..8e00879058 100644 --- a/src/nm-activation-request.h +++ b/src/nm-activation-request.h @@ -44,9 +44,6 @@ gboolean nm_act_request_get_user_requested (NMActRequest *req); NMIP4Config * nm_act_request_get_ip4_config (NMActRequest *req); void nm_act_request_set_ip4_config (NMActRequest *req, NMIP4Config *ip4_config); -NMActStage nm_act_request_get_stage (NMActRequest *req); -void nm_act_request_set_stage (NMActRequest *req, NMActStage stage); - DBusPendingCall * nm_act_request_get_user_key_pending_call (NMActRequest *req); void nm_act_request_set_user_key_pending_call (NMActRequest *req, DBusPendingCall *pcall); diff --git a/src/nm-dbus-nmi.c b/src/nm-dbus-nmi.c index 942e5aef42..59d19b581e 100644 --- a/src/nm-dbus-nmi.c +++ b/src/nm-dbus-nmi.c @@ -185,7 +185,6 @@ nm_dbus_get_user_key_for_network (NMActRequest *req, __func__); if (pcall) { nm_act_request_ref (req); - nm_act_request_set_stage (req, NM_ACT_STAGE_NEED_USER_KEY); nm_act_request_set_user_key_pending_call (req, pcall); } } else { diff --git a/src/nm-device-802-11-wireless.c b/src/nm-device-802-11-wireless.c index 62191d79b8..2b36c20181 100644 --- a/src/nm-device-802-11-wireless.c +++ b/src/nm-device-802-11-wireless.c @@ -1916,7 +1916,7 @@ request_wireless_scan (gpointer user_data) * for the case we lose this connection shortly, it will reach this point and then * nm_device_is_activated will return FALSE, letting the scan proceed. */ - if ((self->priv->num_freqs > 14) && nm_device_is_activated (NM_DEVICE (self)) == TRUE) + if (self->priv->num_freqs > 14 && nm_device_get_state (NM_DEVICE (self)) == NM_DEVICE_STATE_ACTIVATED) { nm_device_802_11_wireless_set_scan_interval (app_data, self, NM_WIRELESS_SCAN_INTERVAL_ACTIVE); schedule_scan (self); @@ -2471,7 +2471,7 @@ link_timeout_cb (gpointer user_data) * ARE checked - we are likely to have wrong key. Ask the user for * another one. */ - if ( (nm_act_request_get_stage (req) == NM_ACT_STAGE_DEVICE_CONFIG) + if ((nm_device_get_state (dev) == NM_DEVICE_STATE_CONFIG) && (ap_is_auth_required (ap, &has_key) && has_key)) { /* Association/authentication failed, we must have bad encryption key */ nm_info ("Activation (%s/wireless): disconnected during association," @@ -2607,7 +2607,7 @@ supplicant_iface_connection_state_cb_handler (gpointer user_data) /* If this is the initial association during device activation, * schedule the next activation stage. */ - if (nm_act_request_get_stage (req) == NM_ACT_STAGE_DEVICE_CONFIG) { + if (nm_device_get_state (dev) == NM_DEVICE_STATE_CONFIG) { NMAccessPoint * ap = nm_act_request_get_ap (req); nm_info ("Activation (%s/wireless) Stage 2 of 5 (Device Configure) " @@ -2617,7 +2617,7 @@ supplicant_iface_connection_state_cb_handler (gpointer user_data) nm_device_activate_schedule_stage3_ip_config_start (req); } } else if (new_state == NM_SUPPLICANT_INTERFACE_CON_STATE_DISCONNECTED) { - if (nm_device_is_activated (dev) || nm_device_is_activating (dev)) { + if (nm_device_get_state (dev) == NM_DEVICE_STATE_ACTIVATED || nm_device_is_activating (dev)) { gboolean has_link = nm_device_has_active_link (NM_DEVICE (self)); /* Start the link timeout so we allow some time for reauthentication */ @@ -3263,7 +3263,7 @@ real_activation_cancel_handler (NMDevice *dev, parent_class = NM_DEVICE_CLASS (g_type_class_peek_parent (klass)); parent_class->activation_cancel_handler (dev, req); - if (nm_act_request_get_stage (req) == NM_ACT_STAGE_NEED_USER_KEY) + if (nm_device_get_state (dev) == NM_DEVICE_STATE_NEED_AUTH) nm_dbus_cancel_get_user_key_for_network (req); cleanup_association_attempt (self, TRUE); @@ -3273,15 +3273,10 @@ real_activation_cancel_handler (NMDevice *dev, static gboolean real_can_interrupt_activation (NMDevice *dev) { - NMActRequest * req; - gboolean interrupt = FALSE; + if (nm_device_get_state (dev) == NM_DEVICE_STATE_NEED_AUTH) + return TRUE; - if ( (req = nm_device_get_act_request (dev)) - && (nm_act_request_get_stage (req) == NM_ACT_STAGE_NEED_USER_KEY)) - { - interrupt = TRUE; - } - return interrupt; + return FALSE; } @@ -3360,6 +3355,8 @@ get_property (GObject *object, guint prop_id, NMDevice80211Wireless *device = NM_DEVICE_802_11_WIRELESS (object); struct ether_addr hw_addr; char hw_addr_buf[20]; + NMAccessPoint *ap; + NMActRequest *req; switch (prop_id) { case PROP_HW_ADDRESS: @@ -3375,16 +3372,13 @@ get_property (GObject *object, guint prop_id, g_value_set_int (value, nm_device_802_11_wireless_get_bitrate (device)); break; case PROP_ACTIVE_NETWORK: - /* FIXME: */ -#if 0 req = nm_device_get_act_request (NM_DEVICE (device)); - if (req && ap = nm_act_request_get_ap (req)) { + if (req && (ap = nm_act_request_get_ap (req))) { NMAccessPoint *tmp_ap; if ((tmp_ap = nm_device_802_11_wireless_ap_list_get_ap_by_essid (device, nm_ap_get_essid (ap)))) g_value_set_object (value, tmp_ap); } -#endif break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); diff --git a/src/nm-device-private.h b/src/nm-device-private.h index 338780177e..7289fafa1f 100644 --- a/src/nm-device-private.h +++ b/src/nm-device-private.h @@ -34,8 +34,6 @@ typedef struct NMDbusCBData { void nm_device_set_device_type (NMDevice *dev, NMDeviceType type); -gboolean nm_device_is_activated (NMDevice *dev); - NMIP4Config * nm_device_new_ip4_autoip_config (NMDevice *self); void nm_device_activate_schedule_stage3_ip_config_start (struct NMActRequest *req); diff --git a/src/nm-device.c b/src/nm-device.c index a457494d5d..529c509409 100644 --- a/src/nm-device.c +++ b/src/nm-device.c @@ -402,7 +402,6 @@ nm_device_activate (NMDevice *device, nm_act_request_ref (req); priv->act_request = req; - nm_act_request_set_stage (req, NM_ACT_STAGE_DEVICE_PREPARE); nm_device_activate_schedule_stage1_device_prepare (req); } @@ -472,7 +471,6 @@ nm_device_activate_schedule_stage1_device_prepare (NMActRequest *req) self = nm_act_request_get_dev (req); g_assert (self); - nm_act_request_set_stage (req, NM_ACT_STAGE_DEVICE_PREPARE); id = g_idle_add (nm_device_activate_stage1_device_prepare, req); self->priv->act_source_id = id; @@ -567,7 +565,6 @@ nm_device_activate_schedule_stage2_device_config (NMActRequest *req) self = nm_act_request_get_dev (req); g_assert (self); - nm_act_request_set_stage (req, NM_ACT_STAGE_DEVICE_CONFIG); id = g_idle_add (nm_device_activate_stage2_device_config, req); self->priv->act_source_id = id; @@ -680,7 +677,6 @@ nm_device_activate_schedule_stage3_ip_config_start (NMActRequest *req) self = nm_act_request_get_dev (req); g_assert (self); - nm_act_request_set_stage (req, NM_ACT_STAGE_IP_CONFIG_START); id = g_idle_add (nm_device_activate_stage3_ip_config_start, req); self->priv->act_source_id = id; @@ -827,7 +823,6 @@ nm_device_activate_schedule_stage4_ip_config_get (NMActRequest *req) self = nm_act_request_get_dev (req); g_assert (self); - nm_act_request_set_stage (req, NM_ACT_STAGE_IP_CONFIG_GET); id = g_idle_add (nm_device_activate_stage4_ip_config_get, req); self->priv->act_source_id = id; @@ -921,7 +916,6 @@ nm_device_activate_schedule_stage4_ip_config_timeout (NMActRequest *req) self = nm_act_request_get_dev (req); g_assert (self); - nm_act_request_set_stage (req, NM_ACT_STAGE_IP_CONFIG_GET); id = g_idle_add (nm_device_activate_stage4_ip_config_timeout, req); self->priv->act_source_id = id; @@ -1003,7 +997,6 @@ nm_device_activate_schedule_stage5_ip_config_commit (NMActRequest *req) self = nm_act_request_get_dev (req); g_assert (self); - nm_act_request_set_stage (req, NM_ACT_STAGE_IP_CONFIG_COMMIT); id = g_idle_add (nm_device_activate_stage5_ip_config_commit, req); self->priv->act_source_id = id; @@ -1170,48 +1163,6 @@ nm_device_is_activating (NMDevice *device) } -/* - * nm_device_is_activated - * - * Return whether or not the device is successfully activated. - * - */ -gboolean -nm_device_is_activated (NMDevice *dev) -{ - NMActRequest * req; - NMActStage stage; - gboolean activated = FALSE; - - g_return_val_if_fail (dev != NULL, FALSE); - - if (!(req = nm_device_get_act_request (dev))) - return FALSE; - - stage = nm_act_request_get_stage (req); - switch (stage) - { - case NM_ACT_STAGE_ACTIVATED: - activated = TRUE; - break; - - case NM_ACT_STAGE_DEVICE_PREPARE: - case NM_ACT_STAGE_DEVICE_CONFIG: - case NM_ACT_STAGE_NEED_USER_KEY: - case NM_ACT_STAGE_IP_CONFIG_START: - case NM_ACT_STAGE_IP_CONFIG_GET: - case NM_ACT_STAGE_IP_CONFIG_COMMIT: - case NM_ACT_STAGE_FAILED: - case NM_ACT_STAGE_CANCELLED: - case NM_ACT_STAGE_UNKNOWN: - default: - break; - } - - return activated; -} - - gboolean nm_device_can_interrupt_activation (NMDevice *self) { @@ -1239,8 +1190,7 @@ dhcp_state_changed (NMDHCPManager *dhcp_manager, if (!req) return; - if (!strcmp (nm_device_get_iface (device), iface) && - nm_act_request_get_stage (req) == NM_ACT_STAGE_IP_CONFIG_START) { + if (!strcmp (nm_device_get_iface (device), iface) && nm_device_get_state (device) == NM_DEVICE_STATE_IP_CONFIG) { switch (state) { case DHCDBD_BOUND: /* lease obtained */ case DHCDBD_RENEW: /* lease renewed */