diff --git a/ChangeLog b/ChangeLog index a8635682f7..38bad3542f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +2007-03-15 Tambet Ingo + + * src/nm-device-802-11-wireless.c (constructor): Initialize the iw_ext structures + with zeroes before passing them to functions - the functions never do that and + reading the values back may produce wrong values. + (real_bring_up): Store the signal handler id ... + (real_bring_down): ... So that it can be removed here. + Disconnect the supplicant interface here as well. + (nm_device_802_11_wireless_ap_list_get_ap_by_obj_path): Use the dbus object path + from the access point instead of old $device/Networks/$essid. + + * src/nm-manager.c (nm_manager_get_state): Return NM_STATE_CONNECTED when the + device state is connected (instead of just having link/carrier). + + * src/nm-activation-request.c: Don't store NMData in activation request, it's + already easily accessible through the device. + + * src/NetworkManagerAP.c (nm_ap_init): Construct the dbus object path here and + store it within the object. + (nm_ap_get_dbus_path): Export it to public as well. + + * src/dhcp-manager/nm-dhcp-manager.c (nm_dhcp_manager_get): Keep the ownership + of the singleton. + 2007-03-12 Dan Williams Get rid of 2 second poll of sysfs 'carrier' file for wired devices. Useless diff --git a/src/NetworkManagerAP.c b/src/NetworkManagerAP.c index 9cb605b650..6459cf1992 100644 --- a/src/NetworkManagerAP.c +++ b/src/NetworkManagerAP.c @@ -46,6 +46,8 @@ static const char * default_essid_list[] = */ typedef struct { + char *dbus_path; + /* Scanned or cached values */ char * essid; char * orig_essid; @@ -104,6 +106,10 @@ enum { static void nm_ap_init (NMAccessPoint *ap) { + NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE (ap); + static guint32 counter = 0; + + priv->dbus_path = g_strdup_printf (NM_DBUS_PATH_ACCESS_POINT "/%d", counter++); } static void @@ -111,6 +117,7 @@ finalize (GObject *object) { NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE (object); + g_free (priv->dbus_path); g_free (priv->essid); g_free (priv->orig_essid); g_slist_foreach (priv->user_addresses, (GFunc)g_free, NULL); @@ -314,19 +321,15 @@ nm_ap_class_init (NMAccessPointClass *ap_class) */ NMAccessPoint *nm_ap_new (void) { - NMDBusManager *manager; GObject *object; - char *path; - static guint32 counter = 0; object = g_object_new (NM_TYPE_AP, NULL); + if (!object) + return NULL; - manager = nm_dbus_manager_get (); - - path = g_strdup_printf (NM_DBUS_PATH_ACCESS_POINT "/%d", counter++); - dbus_g_connection_register_g_object (nm_dbus_manager_get_connection (manager), - path, object); - g_free (path); + dbus_g_connection_register_g_object (nm_dbus_manager_get_connection (nm_dbus_manager_get ()), + nm_ap_get_dbus_path (NM_AP (object)), + object); return (NMAccessPoint *) object; } @@ -474,6 +477,14 @@ nm_ap_new_from_properties (GHashTable *properties) return ap; } +const char * +nm_ap_get_dbus_path (NMAccessPoint *ap) +{ + g_return_val_if_fail (NM_IS_AP (ap), NULL); + + return NM_AP_GET_PRIVATE (ap)->dbus_path; +} + /* * Get/set functions for timestamp diff --git a/src/NetworkManagerAP.h b/src/NetworkManagerAP.h index 1a3159bd13..e9cd16811f 100644 --- a/src/NetworkManagerAP.h +++ b/src/NetworkManagerAP.h @@ -62,6 +62,7 @@ NMAccessPoint * nm_ap_new (void); NMAccessPoint * nm_ap_new_from_ap (NMAccessPoint *ap); NMAccessPoint * nm_ap_new_from_properties (GHashTable *properties); +const char * nm_ap_get_dbus_path (NMAccessPoint *ap); const GTimeVal * nm_ap_get_timestamp (const NMAccessPoint *ap); void nm_ap_set_timestamp (NMAccessPoint *ap, glong sec, glong usec); void nm_ap_set_timestamp_via_timestamp (NMAccessPoint *ap, const GTimeVal *timestamp); diff --git a/src/dhcp-manager/nm-dhcp-manager.c b/src/dhcp-manager/nm-dhcp-manager.c index 06a526333e..f68bc282e8 100644 --- a/src/dhcp-manager/nm-dhcp-manager.c +++ b/src/dhcp-manager/nm-dhcp-manager.c @@ -89,10 +89,8 @@ nm_dhcp_manager_get (void) if (!singleton) singleton = nm_dhcp_manager_new (); - else - g_object_ref (singleton); - return singleton; + return g_object_ref (singleton); } static void diff --git a/src/nm-activation-request.c b/src/nm-activation-request.c index f79ef8b56a..ef40e3ab3f 100644 --- a/src/nm-activation-request.c +++ b/src/nm-activation-request.c @@ -33,7 +33,6 @@ struct NMActRequest { int refcount; - NMData * data; NMDevice * dev; NMAccessPoint * ap; NMIP4Config * ip4_config; @@ -44,11 +43,10 @@ struct NMActRequest }; -NMActRequest * nm_act_request_new (NMData *data, NMDevice *dev, NMAccessPoint *ap, gboolean user_requested) +NMActRequest * nm_act_request_new (NMDevice *dev, NMAccessPoint *ap, gboolean user_requested) { NMActRequest * req; - g_return_val_if_fail (data != NULL, NULL); g_return_val_if_fail (dev != NULL, NULL); if (NM_IS_DEVICE_802_11_WIRELESS (dev)) @@ -56,7 +54,6 @@ NMActRequest * nm_act_request_new (NMData *data, NMDevice *dev, NMAccessPoint *a req = g_malloc0 (sizeof (NMActRequest)); req->refcount = 1; - req->data = data; g_object_ref (G_OBJECT (dev)); req->dev = dev; @@ -97,14 +94,6 @@ NMDevice * nm_act_request_get_dev (NMActRequest *req) } -NMData * nm_act_request_get_data (NMActRequest *req) -{ - g_return_val_if_fail (req != NULL, NULL); - - return req->data; -} - - NMAccessPoint * nm_act_request_get_ap (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 8e00879058..e5f94b85fd 100644 --- a/src/nm-activation-request.h +++ b/src/nm-activation-request.h @@ -32,12 +32,11 @@ -NMActRequest * nm_act_request_new (NMData *data, NMDevice *dev, NMAccessPoint *ap, gboolean user_requested); +NMActRequest * nm_act_request_new (NMDevice *dev, NMAccessPoint *ap, gboolean user_requested); void nm_act_request_ref (NMActRequest *req); void nm_act_request_unref (NMActRequest *req); NMDevice * nm_act_request_get_dev (NMActRequest *req); -NMData * nm_act_request_get_data (NMActRequest *req); NMAccessPoint * nm_act_request_get_ap (NMActRequest *req); gboolean nm_act_request_get_user_requested (NMActRequest *req); diff --git a/src/nm-dbus-nmi.c b/src/nm-dbus-nmi.c index 59d19b581e..7f2f0b2373 100644 --- a/src/nm-dbus-nmi.c +++ b/src/nm-dbus-nmi.c @@ -52,12 +52,12 @@ nm_dbus_get_user_key_for_network_cb (DBusPendingCall *pcall, g_return_if_fail (pcall != NULL); g_return_if_fail (req != NULL); - data = nm_act_request_get_data (req); - g_assert (data); - dev = nm_act_request_get_dev (req); g_assert (dev); + data = nm_device_get_app_data (dev); + g_assert (data); + ap = nm_act_request_get_ap (req); g_assert (ap); diff --git a/src/nm-device-802-11-wireless.c b/src/nm-device-802-11-wireless.c index 3f474e007f..39b60fb871 100644 --- a/src/nm-device-802-11-wireless.c +++ b/src/nm-device-802-11-wireless.c @@ -98,6 +98,7 @@ typedef struct Supplicant { NMSupplicantInterface * iface; /* signal handler ids */ + guint mgr_state_id; guint iface_error_id; guint iface_state_id; guint iface_scanned_ap_id; @@ -426,7 +427,8 @@ constructor (GType type, struct iw_range range; struct iwreq wrq; - memset (&wrq, 0, sizeof (wrq)); + memset (&wrq, 0, sizeof (struct iwreq)); + memset (&range, 0, sizeof (struct iw_range)); strncpy (wrq.ifr_name, iface, IFNAMSIZ); wrq.u.data.pointer = (caddr_t) ⦥ wrq.u.data.length = sizeof (struct iw_range); @@ -579,10 +581,10 @@ real_bring_up (NMDevice *dev) nm_device_802_11_wireless_set_mode (self, IW_MODE_INFRA); priv->supplicant.mgr = nm_supplicant_manager_get (); - g_signal_connect (priv->supplicant.mgr, - "state", - G_CALLBACK (supplicant_mgr_state_cb), - self); + priv->supplicant.mgr_state_id = g_signal_connect (priv->supplicant.mgr, + "state", + G_CALLBACK (supplicant_mgr_state_cb), + self); if (nm_supplicant_manager_get_state (priv->supplicant.mgr) == NM_SUPPLICANT_MANAGER_STATE_IDLE) { init_supplicant_interface (self); } @@ -608,11 +610,20 @@ real_bring_down (NMDevice *dev) cleanup_supplicant_interface (self); + if (priv->supplicant.iface) { + nm_supplicant_interface_disconnect (priv->supplicant.iface); + priv->supplicant.iface = NULL; + } + + if (priv->supplicant.mgr_state_id) { + g_signal_handler_disconnect (priv->supplicant.mgr, priv->supplicant.mgr_state_id); + priv->supplicant.mgr_state_id = 0; + } + if (priv->supplicant.mgr) { g_object_unref (priv->supplicant.mgr); priv->supplicant.mgr = NULL; } - } static void @@ -651,8 +662,7 @@ nm_device_802_11_wireless_activate (NMDevice80211Wireless *self, g_return_if_fail (ap != NULL); device = NM_DEVICE (self); - req = nm_act_request_new (nm_device_get_app_data (device), - device, + req = nm_act_request_new (device, ap, user_requested); @@ -1117,31 +1127,28 @@ NMAccessPoint * nm_device_802_11_wireless_ap_list_get_ap_by_obj_path (NMDevice80211Wireless *self, const char *obj_path) { - NMAccessPoint * ret_ap = NULL; - char * built_path; - char * dev_path; + NMAccessPointList *ap_list; + NMAccessPoint *ap = NULL; - g_return_val_if_fail (self != NULL, NULL); - g_return_val_if_fail (obj_path != NULL, NULL); + ap_list = nm_device_802_11_wireless_ap_list_get (self); + if (ap_list) { + NMAPListIter *list_iter; - if (!self->priv->ap_list) - return NULL; + if ((list_iter = nm_ap_list_iter_new (ap_list))) { + gboolean found = FALSE; - dev_path = nm_dbus_get_object_path_for_device (NM_DEVICE (self)); - dev_path = nm_dbus_unescape_object_path (dev_path); - built_path = g_strdup_printf ("%s/Networks/", dev_path); - g_free (dev_path); + while (!found && (ap = nm_ap_list_iter_next (list_iter))) { + if (!strcmp (obj_path, nm_ap_get_dbus_path (ap))) + found = TRUE; + } + nm_ap_list_iter_free (list_iter); - if (strncmp (built_path, obj_path, strlen (built_path)) == 0) - { - char *essid = g_strdup (obj_path + strlen (built_path)); - - ret_ap = nm_ap_list_get_ap_by_essid (self->priv->ap_list, essid); - g_free (essid); + if (!found) + ap = NULL; + } } - g_free (built_path); - return ret_ap; + return ap; } @@ -2957,7 +2964,7 @@ activation_failure_handler (NMDevice *dev) NMAccessPoint * ap; req = nm_device_get_act_request (dev); - app_data = nm_act_request_get_data (req); + app_data = nm_device_get_app_data (dev); g_assert (app_data); if ((ap = nm_act_request_get_ap (req))) diff --git a/src/nm-device-802-3-ethernet.c b/src/nm-device-802-3-ethernet.c index 617ab3516f..c225ea4357 100644 --- a/src/nm-device-802-3-ethernet.c +++ b/src/nm-device-802-3-ethernet.c @@ -268,8 +268,7 @@ nm_device_802_3_ethernet_activate (NMDevice8023Ethernet *self, g_return_if_fail (NM_IS_DEVICE_802_3_ETHERNET (self)); device = NM_DEVICE (self); - req = nm_act_request_new (nm_device_get_app_data (device), - device, + req = nm_act_request_new (device, NULL, user_requested); diff --git a/src/nm-device.h b/src/nm-device.h index 990941a5d9..03e608a11d 100644 --- a/src/nm-device.h +++ b/src/nm-device.h @@ -78,8 +78,6 @@ struct _NMDeviceClass { GObjectClass parent; - const char * (* has_active_link) (NMDevice *self); - void (* set_active_link) (NMDevice *self, gboolean active); void (* update_link) (NMDevice *self); gboolean (* is_up) (NMDevice *self); diff --git a/src/nm-manager.c b/src/nm-manager.c index bcefaeb14a..313d031b90 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -354,7 +354,7 @@ nm_manager_get_state (NMManager *manager) for (iter = priv->devices; iter; iter = iter->next) { NMDevice *dev = NM_DEVICE (iter->data); - if (nm_device_has_active_link (dev)) + if (nm_device_get_state (dev) == NM_DEVICE_STATE_ACTIVATED) return NM_STATE_CONNECTED; if (nm_device_is_activating (dev))