2006-01-03 Dan Williams <dcbw@redhat.com>

* src/NetworkManagerPolicy.c
	  src/nm-device.[ch]
	  src/nm-device-802-11-wireless.c
		- Move wireless-specific activation failure and success code
			into wireless device class


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1259 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams 2006-01-03 22:11:35 +00:00
parent ebe118b3ff
commit 7f07df2466
5 changed files with 109 additions and 49 deletions

View file

@ -1,3 +1,11 @@
2006-01-03 Dan Williams <dcbw@redhat.com>
* src/NetworkManagerPolicy.c
src/nm-device.[ch]
src/nm-device-802-11-wireless.c
- Move wireless-specific activation failure and success code
into wireless device class
2006-01-03 Robert Love <rml@novell.com>
Patch by Preggna S:

View file

@ -60,24 +60,7 @@ static gboolean nm_policy_activation_finish (NMActRequest *req)
dev = nm_act_request_get_dev (req);
g_assert (dev);
/* Tell NetworkManagerInfo to store the MAC address of the active device's AP */
if (nm_device_is_802_11_wireless (dev))
{
NMDevice80211Wireless * wdev = NM_DEVICE_802_11_WIRELESS (dev);
struct ether_addr addr;
NMAccessPoint * ap = nm_act_request_get_ap (req);
NMAccessPoint * tmp_ap;
gboolean automatic;
/* Cache details in the info-daemon since the connect was successful */
automatic = !nm_act_request_get_user_requested (req);
nm_device_802_11_wireless_get_bssid (wdev, &addr);
if (!nm_ap_get_address (ap) || !nm_ethernet_address_is_valid (nm_ap_get_address (ap)))
nm_ap_set_address (ap, &addr);
nm_dbus_update_network_info (data->dbus_connection, ap, automatic);
}
nm_device_activation_success_handler (dev, req);
nm_info ("Activation (%s) successful, device activated.", nm_device_get_iface (dev));
nm_dbus_schedule_device_status_change_signal (data, dev, NULL, DEVICE_NOW_ACTIVE);
@ -124,9 +107,8 @@ void nm_policy_schedule_activation_finish (NMActRequest *req)
*/
static gboolean nm_policy_activation_failed (NMActRequest *req)
{
NMDevice *dev = NULL;
NMAccessPoint *ap = NULL;
NMData *data = NULL;
NMDevice * dev = NULL;
NMData * data = NULL;
g_return_val_if_fail (req != NULL, FALSE);
@ -136,29 +118,10 @@ static gboolean nm_policy_activation_failed (NMActRequest *req)
dev = nm_act_request_get_dev (req);
g_assert (dev);
if (nm_device_is_802_11_wireless (dev))
{
if ((ap = nm_act_request_get_ap (req)))
{
/* Only pop up the Network Not Found dialog when its a user-requested access point
* that failed, not one that we've automatically found and connected to.
*/
if (nm_act_request_get_user_requested (req))
nm_dbus_schedule_device_status_change_signal (data, dev, ap, DEVICE_ACTIVATION_FAILED);
nm_device_activation_failure_handler (dev, req);
/* Add the AP to the invalid list and force a best ap update */
nm_ap_set_invalid (ap, TRUE);
nm_ap_list_append_ap (data->invalid_ap_list, ap);
}
nm_info ("Activation (%s) failed for access point (%s)", nm_device_get_iface (dev),
ap ? nm_ap_get_essid (ap) : "(none)");
}
else
{
nm_info ("Activation (%s) failed.", nm_device_get_iface (dev));
nm_dbus_schedule_device_status_change_signal (data, dev, NULL, DEVICE_ACTIVATION_FAILED);
}
nm_info ("Activation (%s) failed.", nm_device_get_iface (dev));
nm_dbus_schedule_device_status_change_signal (data, dev, NULL, DEVICE_ACTIVATION_FAILED);
nm_device_deactivate (dev);
nm_schedule_state_change_signal_broadcast (data);
@ -437,7 +400,6 @@ static gboolean nm_policy_device_change_check (NMData *data)
NMActRequest * act_req = NULL;
if ((act_req = nm_act_request_new (data, new_dev, ap, FALSE)))
{
nm_info ("Will activate connection '%s%s%s'.", nm_device_get_iface (new_dev), ap ? "/" : "", ap ? nm_ap_get_essid (ap) : "");
nm_policy_schedule_device_activation (act_req);

View file

@ -2377,6 +2377,8 @@ real_act_stage3_ip_config_start (NMDevice *dev,
parent_class = NM_DEVICE_CLASS (g_type_class_peek_parent (klass));
ret = parent_class->act_stage3_ip_config_start (dev, req);
}
else
ret = NM_ACT_STAGE_RETURN_SUCCESS;
return ret;
}
@ -2465,6 +2467,54 @@ real_act_stage4_ip_config_timeout (NMDevice *dev,
}
static void
real_activation_success_handler (NMDevice *dev,
NMActRequest *req)
{
NMDevice80211Wireless * self = NM_DEVICE_802_11_WIRELESS (dev);
struct ether_addr addr;
NMAccessPoint * ap = nm_act_request_get_ap (req);
NMAccessPoint * tmp_ap;
gboolean automatic;
NMData * app_data;
app_data = nm_act_request_get_data (req);
g_assert (app_data);
/* Cache details in the info-daemon since the connect was successful */
automatic = !nm_act_request_get_user_requested (req);
nm_device_802_11_wireless_get_bssid (self, &addr);
if (!nm_ap_get_address (ap) || !nm_ethernet_address_is_valid (nm_ap_get_address (ap)))
nm_ap_set_address (ap, &addr);
nm_dbus_update_network_info (app_data->dbus_connection, ap, automatic);
}
static void
real_activation_failure_handler (NMDevice *dev,
NMActRequest *req)
{
NMDevice80211Wireless * self = NM_DEVICE_802_11_WIRELESS (dev);
NMData * app_data;
NMAccessPoint * ap;
app_data = nm_act_request_get_data (req);
g_assert (app_data);
if ((ap = nm_act_request_get_ap (req)))
{
/* Add the AP to the invalid list and force a best ap update */
nm_ap_set_invalid (ap, TRUE);
nm_ap_list_append_ap (app_data->invalid_ap_list, ap);
}
nm_info ("Activation (%s) failed for access point (%s)", nm_device_get_iface (dev),
ap ? nm_ap_get_essid (ap) : "(none)");
}
static guint32
real_get_type_capabilities (NMDevice *dev)
{
@ -2539,6 +2589,9 @@ nm_device_802_11_wireless_class_init (NMDevice80211WirelessClass *klass)
parent_class->act_stage4_ip_config_timeout = real_act_stage4_ip_config_timeout;
parent_class->deactivate = real_deactivate;
parent_class->activation_failure_handler = real_activation_failure_handler;
parent_class->activation_success_handler = real_activation_success_handler;
g_type_class_add_private (object_class, sizeof (NMDevice80211WirelessPrivate));
}

View file

@ -542,9 +542,13 @@ void
nm_device_set_active_link (NMDevice *self,
const gboolean link_active)
{
NMData * app_data;
g_return_if_fail (self != NULL);
g_return_if_fail (self->priv->app_data != NULL);
app_data = self->priv->app_data;
if (self->priv->link_active != link_active)
{
self->priv->link_active = link_active;
@ -553,11 +557,11 @@ nm_device_set_active_link (NMDevice *self,
if (!link_active && self->priv->act_request)
{
nm_device_deactivate (self);
nm_policy_schedule_device_change_check (self->priv->app_data);
nm_policy_schedule_device_change_check (app_data);
}
else if (link_active && !self->priv->act_request)
{
NMDevice * act_dev = nm_get_active_device (self->priv->app_data);
NMDevice * act_dev = nm_get_active_device (app_data);
NMActRequest * act_dev_req = act_dev ? nm_device_get_act_request (act_dev) : NULL;
/* Should we switch to this device now that it has a link?
@ -578,14 +582,14 @@ nm_device_set_active_link (NMDevice *self,
if (act_dev && nm_device_is_802_11_wireless (act_dev) && act_dev_req && !nm_act_request_get_user_requested (act_dev_req))
do_switch = TRUE;
if (do_switch && (act_req = nm_act_request_new (self->priv->app_data, self, NULL, TRUE)))
if (do_switch && (act_req = nm_act_request_new (app_data, self, NULL, TRUE)))
{
nm_info ("Will activate wired connection '%s' because it now has a link.", nm_device_get_iface (self));
nm_policy_schedule_device_activation (act_req);
nm_policy_schedule_device_change_check (app_data);
}
}
}
nm_dbus_schedule_device_status_change_signal (self->priv->app_data, self, NULL, link_active ? DEVICE_CARRIER_ON : DEVICE_CARRIER_OFF);
nm_dbus_schedule_device_status_change_signal (app_data, self, NULL, link_active ? DEVICE_CARRIER_ON : DEVICE_CARRIER_OFF);
}
}
@ -1579,6 +1583,29 @@ nm_device_activation_should_cancel (NMDevice *self)
}
void
nm_device_activation_failure_handler (NMDevice *self,
struct NMActRequest *req)
{
g_return_if_fail (self != NULL);
g_return_if_fail (req != NULL);
if (NM_DEVICE_GET_CLASS (self)->activation_failure_handler)
NM_DEVICE_GET_CLASS (self)->activation_failure_handler (self, req);
}
void nm_device_activation_success_handler (NMDevice *self,
struct NMActRequest *req)
{
g_return_if_fail (self != NULL);
g_return_if_fail (req != NULL);
if (NM_DEVICE_GET_CLASS (self)->activation_success_handler)
NM_DEVICE_GET_CLASS (self)->activation_success_handler (self, req);
}
/* IP Configuration stuff */
gboolean

View file

@ -102,6 +102,11 @@ struct _NMDeviceClass
NMIP4Config **config);
void (* deactivate) (NMDevice *self);
void (* cancel_activation) (NMDevice *self);
void (* activation_failure_handler) (NMDevice *self,
struct NMActRequest *req);
void (* activation_success_handler) (NMDevice *self,
struct NMActRequest *req);
};
@ -179,6 +184,11 @@ gboolean nm_device_is_activating (NMDevice *dev);
void nm_device_activation_cancel (NMDevice *dev);
gboolean nm_device_activation_should_cancel (NMDevice *self);
void nm_device_activation_failure_handler (NMDevice *dev,
struct NMActRequest *req);
void nm_device_activation_success_handler (NMDevice *dev,
struct NMActRequest *req);
G_END_DECLS
#endif /* NM_DEVICE_H */