summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-01-20 20:25:25 +0100
committerThomas Haller <thaller@redhat.com>2015-02-24 11:49:04 +0100
commit52dbb2398a89134fe2c0bc19d032b985c7464c08 (patch)
treeec89e44f842908f60a1c2d52dee1fdf262b4f47d /src
parente96af59444eb2f449271bd3896c47c68ebb33a5c (diff)
downloadNetworkManager-52dbb2398a89134fe2c0bc19d032b985c7464c08.tar.gz
device: add flags to nm_device_is_available()
Diffstat (limited to 'src')
-rw-r--r--src/devices/bluetooth/nm-device-bt.c6
-rw-r--r--src/devices/nm-device-bond.c2
-rw-r--r--src/devices/nm-device-bridge.c2
-rw-r--r--src/devices/nm-device.c10
-rw-r--r--src/devices/nm-device.h13
-rw-r--r--src/devices/team/nm-device-team.c2
-rw-r--r--src/devices/wifi/nm-device-olpc-mesh.c2
-rw-r--r--src/devices/wifi/nm-device-wifi.c4
-rw-r--r--src/devices/wimax/nm-device-wimax.c10
-rw-r--r--src/devices/wwan/nm-device-modem.c6
-rw-r--r--src/nm-manager.c2
11 files changed, 35 insertions, 24 deletions
diff --git a/src/devices/bluetooth/nm-device-bt.c b/src/devices/bluetooth/nm-device-bt.c
index 8a89cc83da..61371dddec 100644
--- a/src/devices/bluetooth/nm-device-bt.c
+++ b/src/devices/bluetooth/nm-device-bt.c
@@ -930,7 +930,7 @@ bluez_device_removed (NMBluezDevice *bdev, gpointer user_data)
/*****************************************************************************/
static gboolean
-is_available (NMDevice *dev)
+is_available (NMDevice *dev, NMDeviceCheckDevAvailableFlags flags)
{
NMDeviceBt *self = NM_DEVICE_BT (dev);
NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (self);
@@ -958,7 +958,7 @@ handle_availability_change (NMDeviceBt *self,
return;
}
- available = nm_device_is_available (device);
+ available = nm_device_is_available (device, NM_DEVICE_CHECK_DEV_AVAILABLE_NONE);
if (available == old_available)
return;
@@ -988,7 +988,7 @@ set_mm_running (NMDeviceBt *self, gboolean running)
_LOGD (LOGD_BT, "ModemManager now %s",
running ? "available" : "unavailable");
- old_available = nm_device_is_available (NM_DEVICE (self));
+ old_available = nm_device_is_available (NM_DEVICE (self), NM_DEVICE_CHECK_DEV_AVAILABLE_NONE);
priv->mm_running = running;
handle_availability_change (self, old_available, NM_DEVICE_STATE_REASON_MODEM_MANAGER_UNAVAILABLE);
diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c
index ae3059de33..6b4581082b 100644
--- a/src/devices/nm-device-bond.c
+++ b/src/devices/nm-device-bond.c
@@ -68,7 +68,7 @@ get_generic_capabilities (NMDevice *dev)
}
static gboolean
-is_available (NMDevice *dev)
+is_available (NMDevice *dev, NMDeviceCheckDevAvailableFlags flags)
{
if (NM_DEVICE_GET_CLASS (dev)->is_up)
return NM_DEVICE_GET_CLASS (dev)->is_up (dev);
diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c
index 92c29387c4..a2ed4b4176 100644
--- a/src/devices/nm-device-bridge.c
+++ b/src/devices/nm-device-bridge.c
@@ -66,7 +66,7 @@ get_generic_capabilities (NMDevice *dev)
}
static gboolean
-is_available (NMDevice *dev)
+is_available (NMDevice *dev, NMDeviceCheckDevAvailableFlags flags)
{
if (NM_DEVICE_GET_CLASS (dev)->is_up)
return NM_DEVICE_GET_CLASS (dev)->is_up (dev);
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index af32e93796..79befb36db 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -1734,7 +1734,7 @@ nm_device_removed (NMDevice *self)
static gboolean
-is_available (NMDevice *self)
+is_available (NMDevice *self, NMDeviceCheckDevAvailableFlags flags)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
@@ -1744,6 +1744,8 @@ is_available (NMDevice *self)
/**
* nm_device_is_available:
* @self: the #NMDevice
+ * @flags: additional flags to influence the check. Flags have the
+ * meaning to increase the availability of a device.
*
* Checks if @self would currently be capable of activating a
* connection. In particular, it checks that the device is ready (eg,
@@ -1759,14 +1761,14 @@ is_available (NMDevice *self)
* Returns: %TRUE or %FALSE
*/
gboolean
-nm_device_is_available (NMDevice *self)
+nm_device_is_available (NMDevice *self, NMDeviceCheckDevAvailableFlags flags)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
if (priv->firmware_missing)
return FALSE;
- return NM_DEVICE_GET_CLASS (self)->is_available (self);
+ return NM_DEVICE_GET_CLASS (self)->is_available (self, flags);
}
gboolean
@@ -7755,7 +7757,7 @@ _set_state_full (NMDevice *self,
* we can't change states again from the state handler for a variety of
* reasons.
*/
- if (nm_device_is_available (self)) {
+ if (nm_device_is_available (self, NM_DEVICE_CHECK_DEV_AVAILABLE_NONE)) {
_LOGD (LOGD_DEVICE, "device is available, will transition to DISCONNECTED");
nm_device_queue_state (self, NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_NONE);
} else {
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index 98fc032f12..4c2d4f8c53 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -103,6 +103,15 @@ struct _NMDevice {
GObject parent;
};
+/* The flags have an relaxing meaning, that means, specifying more flags, can make
+ * a device appear more available. It can never make a device less available. */
+typedef enum {
+ NM_DEVICE_CHECK_DEV_AVAILABLE_NONE = 0,
+
+ __NM_DEVICE_CHECK_DEV_AVAILABLE_ALL,
+ NM_DEVICE_CHECK_DEV_AVAILABLE_ALL = (((__NM_DEVICE_CHECK_DEV_AVAILABLE_ALL - 1) << 1) - 1),
+} NMDeviceCheckDevAvailableFlags;
+
typedef struct {
GObjectClass parent;
@@ -130,7 +139,7 @@ typedef struct {
guint32 (* get_generic_capabilities) (NMDevice *self);
- gboolean (* is_available) (NMDevice *self);
+ gboolean (* is_available) (NMDevice *self, NMDeviceCheckDevAvailableFlags flags);
gboolean (* get_enabled) (NMDevice *self);
@@ -282,7 +291,7 @@ NMConnection * nm_device_get_connection (NMDevice *dev);
void nm_device_removed (NMDevice *dev);
-gboolean nm_device_is_available (NMDevice *dev);
+gboolean nm_device_is_available (NMDevice *dev, NMDeviceCheckDevAvailableFlags flags);
gboolean nm_device_has_carrier (NMDevice *dev);
NMConnection * nm_device_generate_connection (NMDevice *self, NMDevice *master);
diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c
index bddcdcc615..c8f510b9b5 100644
--- a/src/devices/team/nm-device-team.c
+++ b/src/devices/team/nm-device-team.c
@@ -74,7 +74,7 @@ get_generic_capabilities (NMDevice *device)
}
static gboolean
-is_available (NMDevice *device)
+is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags)
{
if (NM_DEVICE_GET_CLASS (device)->is_up)
return NM_DEVICE_GET_CLASS (device)->is_up (device);
diff --git a/src/devices/wifi/nm-device-olpc-mesh.c b/src/devices/wifi/nm-device-olpc-mesh.c
index 0f5aa16487..dc3dfbc659 100644
--- a/src/devices/wifi/nm-device-olpc-mesh.c
+++ b/src/devices/wifi/nm-device-olpc-mesh.c
@@ -235,7 +235,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
}
static gboolean
-is_available (NMDevice *device)
+is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags)
{
NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (device);
diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c
index a17fca991a..ea85e3e843 100644
--- a/src/devices/wifi/nm-device-wifi.c
+++ b/src/devices/wifi/nm-device-wifi.c
@@ -1136,7 +1136,7 @@ complete_connection (NMDevice *device,
}
static gboolean
-is_available (NMDevice *device)
+is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags)
{
NMDeviceWifi *self = NM_DEVICE_WIFI (device);
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
@@ -2162,7 +2162,7 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface,
/* If the interface can now be activated because the supplicant is now
* available, transition to DISCONNECTED.
*/
- if ((devstate == NM_DEVICE_STATE_UNAVAILABLE) && nm_device_is_available (device)) {
+ if ((devstate == NM_DEVICE_STATE_UNAVAILABLE) && nm_device_is_available (device, NM_DEVICE_CHECK_DEV_AVAILABLE_NONE)) {
nm_device_state_changed (device,
NM_DEVICE_STATE_DISCONNECTED,
NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE);
diff --git a/src/devices/wimax/nm-device-wimax.c b/src/devices/wimax/nm-device-wimax.c
index 2611186964..0394617589 100644
--- a/src/devices/wimax/nm-device-wimax.c
+++ b/src/devices/wimax/nm-device-wimax.c
@@ -239,7 +239,7 @@ update_availability (NMDeviceWimax *self, gboolean old_available)
NMDeviceState state;
gboolean new_available, changed = FALSE;
- new_available = nm_device_is_available (device);
+ new_available = nm_device_is_available (device, NM_DEVICE_CHECK_DEV_AVAILABLE_NONE);
if (new_available == old_available)
return FALSE;
@@ -281,7 +281,7 @@ set_enabled (NMDevice *device, gboolean enabled)
if (priv->enabled == enabled)
return;
- old_available = nm_device_is_available (NM_DEVICE (device));
+ old_available = nm_device_is_available (NM_DEVICE (device), NM_DEVICE_CHECK_DEV_AVAILABLE_NONE);
priv->enabled = enabled;
nm_log_dbg (LOGD_WIMAX, "(%s): radio now %s",
@@ -488,7 +488,7 @@ can_auto_connect (NMDevice *device,
}
static gboolean
-is_available (NMDevice *device)
+is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags)
{
NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (device);
const char *iface = nm_device_get_iface (device);
@@ -716,7 +716,7 @@ wmx_state_change_cb (struct wmxsdk *wmxsdk,
return;
state = nm_device_get_state (NM_DEVICE (self));
- old_available = nm_device_is_available (NM_DEVICE (self));
+ old_available = nm_device_is_available (NM_DEVICE (self), NM_DEVICE_CHECK_DEV_AVAILABLE_NONE);
priv->status = new_status;
if (priv->current_nsp)
@@ -1157,7 +1157,7 @@ static gboolean
sdk_action_defer_cb (gpointer user_data)
{
NMDeviceWimax *self = NM_DEVICE_WIMAX (user_data);
- gboolean old_available = nm_device_is_available (NM_DEVICE (self));
+ gboolean old_available = nm_device_is_available (NM_DEVICE (self), NM_DEVICE_CHECK_DEV_AVAILABLE_NONE);
NM_DEVICE_WIMAX_GET_PRIVATE (self)->sdk_action_defer_id = 0;
update_availability (self, old_available);
diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c
index f210240cdc..9fcfba6fd8 100644
--- a/src/devices/wwan/nm-device-modem.c
+++ b/src/devices/wwan/nm-device-modem.c
@@ -300,14 +300,14 @@ modem_state_cb (NMModem *modem,
nm_device_recheck_available_connections (device);
}
- if ((dev_state >= NM_DEVICE_STATE_DISCONNECTED) && !nm_device_is_available (device)) {
+ if ((dev_state >= NM_DEVICE_STATE_DISCONNECTED) && !nm_device_is_available (device, NM_DEVICE_CHECK_DEV_AVAILABLE_NONE)) {
nm_device_state_changed (device,
NM_DEVICE_STATE_UNAVAILABLE,
NM_DEVICE_STATE_REASON_MODEM_FAILED);
return;
}
- if ((dev_state == NM_DEVICE_STATE_UNAVAILABLE) && nm_device_is_available (device)) {
+ if ((dev_state == NM_DEVICE_STATE_UNAVAILABLE) && nm_device_is_available (device, NM_DEVICE_CHECK_DEV_AVAILABLE_NONE)) {
nm_device_state_changed (device,
NM_DEVICE_STATE_DISCONNECTED,
NM_DEVICE_STATE_REASON_MODEM_AVAILABLE);
@@ -584,7 +584,7 @@ set_enabled (NMDevice *device, gboolean enabled)
}
static gboolean
-is_available (NMDevice *device)
+is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags)
{
NMDeviceModem *self = NM_DEVICE_MODEM (device);
NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (device);
diff --git a/src/nm-manager.c b/src/nm-manager.c
index c6f87cb983..47e98a6206 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -2696,7 +2696,7 @@ _internal_activate_device (NMManager *self, NMActiveConnection *active, GError *
* in the UNAVAILABLE state here. To ensure it can be activated
* immediately, we transition it to DISCONNECTED.
*/
- if ( nm_device_is_available (device)
+ if ( nm_device_is_available (device, NM_DEVICE_CHECK_DEV_AVAILABLE_NONE)
&& (nm_device_get_state (device) == NM_DEVICE_STATE_UNAVAILABLE)) {
nm_device_state_changed (device,
NM_DEVICE_STATE_DISCONNECTED,