+2008-10-11 Dan Williams <dcbw@redhat.com>
+
+ * include/NetworkManager.h
+ introspection/nm-device.xml
+ include/NetworkManagerVPN.h
+ - Add a few more state reasons for the device deactivated state
+
+ * src/nm-device-interface.c
+ src/nm-device-interface.h
+ - (nm_device_interface_deactivate): add a 'reason' argument
+
+ * src/nm-device.c
+ src/nm-device.h
+ - (nm_device_deactivate, nm_device_take_down): add a 'reason' argument
+ - (nm_device_state_changed): pass the state change reason to
+ nm_device_take_down()
+ - (nm_device_set_managed): take a 'reason' argument, and pass it along
+ to the state change function
+
+ * src/nm-manager.c
+ src/nm-manager.h
+ - (remove_one_device, handle_unmanaged_devices, sync_devices,
+ impl_manager_sleep): pass a reason code to nm_device_set_managed()
+ - (nm_manager_deactivate_connection): add a 'reason' argument and pass
+ something reasonable along to VPN deactivation
+
+ * src/vpn-manager/nm-vpn-manager.c
+ src/vpn-manager/nm-vpn-manager.h
+ - (nm_vpn_manager_deactivate_connection): add a 'reason' argument and
+ pass that along to nm_vpn_connection_disconnect()
+
2008-10-11 Dan Williams <dcbw@redhat.com>
* src/nm-device-wifi.c
/* Necessary firmware for the device may be missing */
NM_DEVICE_STATE_REASON_FIRMWARE_MISSING,
+ /* The device was removed */
+ NM_DEVICE_STATE_REASON_REMOVED,
+
+ /* NetworkManager went to sleep */
+ NM_DEVICE_STATE_REASON_SLEEPING,
+
+ /* The device's active connection disappeared */
+ NM_DEVICE_STATE_REASON_CONNECTION_REMOVED,
+
+ /* Device disconnected by user or client */
+ NM_DEVICE_STATE_REASON_USER_REQUESTED,
+
/* Unused */
NM_DEVICE_STATE_REASON_LAST = 0xFFFF
} NMDeviceStateReason;
NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_TIMEOUT,
NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_FAILED,
NM_VPN_CONNECTION_STATE_REASON_NO_SECRETS,
- NM_VPN_CONNECTION_STATE_REASON_LOGIN_FAILED
+ NM_VPN_CONNECTION_STATE_REASON_LOGIN_FAILED,
+ NM_VPN_CONNECTION_STATE_REASON_CONNECTION_REMOVED
} NMVPNConnectionStateReason;
typedef enum {
<tp:docstring>
Necessary firmware for the device may be missing.
</tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="REMOVED" value="36">
+ <tp:docstring>
+ The device was removed.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="SLEEPING" value="37">
+ <tp:docstring>
+ NetworkManager went to sleep.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="CONNECTION_REMOVED" value="38">
+ <tp:docstring>
+ The device's active connection was removed or disappeared.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="USER_REQUESTED" value="39">
+ <tp:docstring>
+ A user or client requested the disconnection.
+ </tp:docstring>
</tp:enumvalue>
</tp:enum>
char *path = g_ptr_array_index (list, i);
GError *error = NULL;
- if (!nm_manager_deactivate_connection (manager, path, &error)) {
+ if (!nm_manager_deactivate_connection (manager, path, NM_DEVICE_STATE_REASON_CONNECTION_REMOVED, &error)) {
nm_warning ("Connection '%s' disappeared, but error deactivating it: (%d) %s",
s_con->id, error->code, error->message);
g_error_free (error);
-/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
#include "nm-marshal.h"
#include "nm-setting-connection.h"
}
void
-nm_device_interface_deactivate (NMDeviceInterface *device)
+nm_device_interface_deactivate (NMDeviceInterface *device, NMDeviceStateReason reason)
{
g_return_if_fail (NM_IS_DEVICE_INTERFACE (device));
- NM_DEVICE_INTERFACE_GET_INTERFACE (device)->deactivate (device);
+ NM_DEVICE_INTERFACE_GET_INTERFACE (device)->deactivate (device, reason);
}
NMDeviceState
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
#ifndef NM_DEVICE_INTERFACE_H
#define NM_DEVICE_INTERFACE_H
NMActRequest *req,
GError **error);
- void (*deactivate) (NMDeviceInterface *device);
+ void (*deactivate) (NMDeviceInterface *device, NMDeviceStateReason reason);
/* Signals */
void (*state_changed) (NMDeviceInterface *device,
NMActRequest *req,
GError **error);
-void nm_device_interface_deactivate (NMDeviceInterface *device);
+void nm_device_interface_deactivate (NMDeviceInterface *device, NMDeviceStateReason reason);
NMDeviceState nm_device_interface_get_state (NMDeviceInterface *device);
GError **error);
static void nm_device_activate_schedule_stage5_ip_config_commit (NMDevice *self);
-static void nm_device_deactivate (NMDeviceInterface *device);
+static void nm_device_deactivate (NMDeviceInterface *device, NMDeviceStateReason reason);
+
+static void nm_device_take_down (NMDevice *dev, gboolean wait, NMDeviceStateReason reason);
static gboolean nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware);
static gboolean nm_device_is_up (NMDevice *self);
*
*/
static void
-nm_device_deactivate (NMDeviceInterface *device)
+nm_device_deactivate (NMDeviceInterface *device, NMDeviceStateReason reason)
{
NMDevice *self = NM_DEVICE (device);
- NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
+ NMDeviceStateReason ignored = NM_DEVICE_STATE_REASON_NONE;
g_return_if_fail (self != NULL);
- nm_info ("(%s): deactivating device.", nm_device_get_iface (self));
+ nm_info ("(%s): deactivating device (reason: %d).",
+ nm_device_get_iface (self),
+ reason);
nm_device_deactivate_quickly (self);
/* Clean up nameservers and addresses */
- nm_device_set_ip4_config (self, NULL, &reason);
+ nm_device_set_ip4_config (self, NULL, &ignored);
/* Take out any entries in the routing table and any IP address the device had. */
nm_system_device_flush_ip4_routes (self);
return success;
}
-void
-nm_device_take_down (NMDevice *self, gboolean block)
+static void
+nm_device_take_down (NMDevice *self, gboolean block, NMDeviceStateReason reason)
{
g_return_if_fail (NM_IS_DEVICE (self));
if (nm_device_get_act_request (self))
- nm_device_interface_deactivate (NM_DEVICE_INTERFACE (self));
+ nm_device_interface_deactivate (NM_DEVICE_INTERFACE (self), reason);
if (nm_device_is_up (self)) {
nm_info ("(%s): cleaning up...", nm_device_get_iface (self));
*/
if (self->priv->managed) {
- NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
+ NMDeviceStateReason ignored = NM_DEVICE_STATE_REASON_NONE;
- nm_device_take_down (self, FALSE);
- nm_device_set_ip4_config (self, NULL, &reason);
+ nm_device_take_down (self, FALSE, NM_DEVICE_STATE_REASON_REMOVED);
+ nm_device_set_ip4_config (self, NULL, &ignored);
}
clear_act_request (self);
switch (state) {
case NM_DEVICE_STATE_UNMANAGED:
if (old_state > NM_DEVICE_STATE_UNMANAGED)
- nm_device_take_down (device, TRUE);
+ nm_device_take_down (device, TRUE, reason);
break;
case NM_DEVICE_STATE_UNAVAILABLE:
if (old_state == NM_DEVICE_STATE_UNMANAGED) {
* eg carrier changes we actually deactivate it */
case NM_DEVICE_STATE_DISCONNECTED:
if (old_state != NM_DEVICE_STATE_UNAVAILABLE)
- nm_device_interface_deactivate (NM_DEVICE_INTERFACE (device));
+ nm_device_interface_deactivate (NM_DEVICE_INTERFACE (device), reason);
break;
default:
break;
}
void
-nm_device_set_managed (NMDevice *device, gboolean managed)
+nm_device_set_managed (NMDevice *device,
+ gboolean managed,
+ NMDeviceStateReason reason)
{
NMDevicePrivate *priv;
/* If now managed, jump to unavailable */
if (managed)
- nm_device_state_changed (device, NM_DEVICE_STATE_UNAVAILABLE, NM_DEVICE_STATE_REASON_NOW_MANAGED);
+ nm_device_state_changed (device, NM_DEVICE_STATE_UNAVAILABLE, reason);
else
- nm_device_state_changed (device, NM_DEVICE_STATE_UNMANAGED, NM_DEVICE_STATE_REASON_NOW_UNMANAGED);
+ nm_device_state_changed (device, NM_DEVICE_STATE_UNMANAGED, reason);
}
NMIP4Config *config,
NMDeviceStateReason *reason);
-void nm_device_take_down (NMDevice *dev, gboolean wait);
-
void * nm_device_get_system_config_data (NMDevice *dev);
NMActRequest * nm_device_get_act_request (NMDevice *dev);
NMDeviceState nm_device_get_state (NMDevice *device);
gboolean nm_device_get_managed (NMDevice *device);
-void nm_device_set_managed (NMDevice *device, gboolean managed);
+void nm_device_set_managed (NMDevice *device,
+ gboolean managed,
+ NMDeviceStateReason reason);
G_END_DECLS
remove_one_device (NMManager *manager, NMDevice *device)
{
if (nm_device_get_managed (device))
- nm_device_set_managed (device, FALSE);
+ nm_device_set_managed (device, FALSE, NM_DEVICE_STATE_REASON_REMOVED);
g_signal_handlers_disconnect_by_func (device, manager_device_state_changed, manager);
device = nm_manager_get_device_by_udi (manager, udi);
if (device) {
unmanaged = g_slist_prepend (unmanaged, device);
- nm_device_set_managed (device, FALSE);
+ nm_device_set_managed (device, FALSE, NM_DEVICE_STATE_REASON_NOW_UNMANAGED);
}
}
NMDevice *device = NM_DEVICE (iter->data);
if (!g_slist_find (unmanaged, device))
- nm_device_set_managed (device, TRUE);
+ nm_device_set_managed (device, TRUE, NM_DEVICE_STATE_REASON_NOW_MANAGED);
}
g_slist_free (unmanaged);
const char *udi = nm_device_get_udi (device);
if (nm_hal_manager_udi_exists (priv->hal_mgr, udi)) {
- nm_device_set_managed (device, nm_manager_udi_is_managed (self, udi));
+ if (nm_manager_udi_is_managed (self, udi))
+ nm_device_set_managed (device, TRUE, NM_DEVICE_STATE_REASON_NOW_MANAGED);
+ else
+ nm_device_set_managed (device, FALSE, NM_DEVICE_STATE_REASON_NOW_UNMANAGED);
} else {
priv->devices = g_slist_delete_link (priv->devices, iter);
remove_one_device (self, device);
gboolean
nm_manager_deactivate_connection (NMManager *manager,
const char *connection_path,
+ NMDeviceStateReason reason,
GError **error)
{
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
NMVPNManager *vpn_manager;
GSList *iter;
gboolean success = FALSE;
+ NMVPNConnectionStateReason vpn_reason = NM_VPN_CONNECTION_STATE_REASON_USER_DISCONNECTED;
/* Check for device connections first */
for (iter = priv->devices; iter; iter = g_slist_next (iter)) {
if (!strcmp (connection_path, nm_act_request_get_active_connection_path (req))) {
nm_device_state_changed (device,
NM_DEVICE_STATE_DISCONNECTED,
- NM_DEVICE_STATE_REASON_NONE);
+ reason);
success = TRUE;
goto done;
}
/* Check for VPN connections next */
vpn_manager = nm_vpn_manager_get ();
- if (nm_vpn_manager_deactivate_connection (vpn_manager, connection_path)) {
+ if (reason == NM_DEVICE_STATE_REASON_CONNECTION_REMOVED)
+ vpn_reason = NM_VPN_CONNECTION_STATE_REASON_CONNECTION_REMOVED;
+ if (nm_vpn_manager_deactivate_connection (vpn_manager, connection_path, vpn_reason)) {
success = TRUE;
} else {
g_set_error (error,
const char *connection_path,
GError **error)
{
- return nm_manager_deactivate_connection (manager, connection_path, error);
+ return nm_manager_deactivate_connection (manager,
+ connection_path,
+ NM_DEVICE_STATE_REASON_USER_REQUESTED,
+ error);
}
static gboolean
* we'll remove them in 'wake' for speed's sake.
*/
for (iter = priv->devices; iter; iter = iter->next)
- nm_device_set_managed (NM_DEVICE (iter->data), FALSE);
+ nm_device_set_managed (NM_DEVICE (iter->data), FALSE, NM_DEVICE_STATE_REASON_SLEEPING);
} else {
nm_info ("Waking up...");
gboolean nm_manager_deactivate_connection (NMManager *manager,
const char *connection_path,
+ NMDeviceStateReason reason,
GError **error);
/* State handling */
}
gboolean
-nm_vpn_manager_deactivate_connection (NMVPNManager *manager, const char *path)
+nm_vpn_manager_deactivate_connection (NMVPNManager *manager,
+ const char *path,
+ NMVPNConnectionStateReason reason)
{
NMVPNManagerPrivate *priv;
GSList *iter;
vpn_path = nm_vpn_connection_get_active_connection_path (vpn);
if (!strcmp (path, vpn_path)) {
- nm_vpn_connection_disconnect (vpn, NM_VPN_CONNECTION_STATE_REASON_USER_DISCONNECTED);
+ nm_vpn_connection_disconnect (vpn, reason);
found = TRUE;
}
}
GError **error);
gboolean nm_vpn_manager_deactivate_connection (NMVPNManager *manager,
- const char *path);
+ const char *path,
+ NMVPNConnectionStateReason reason);
void nm_vpn_manager_add_active_connections (NMVPNManager *manager,
NMConnection *filter,