summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-01-16 14:54:11 +0100
committerThomas Haller <thaller@redhat.com>2015-02-24 17:44:04 +0100
commit3a5cee2a99495179b303cfafc28d756cc6002b9b (patch)
tree9ddec3672d1c024a6e6f01506cf29e487951935c
parent2799d502a1d437ed9f9f51ef1ada2ea893f1b1af (diff)
downloadNetworkManager-3a5cee2a99495179b303cfafc28d756cc6002b9b.tar.gz
device: add flags argument to check_connection_available()
(cherry picked from commit e96af59444eb2f449271bd3896c47c68ebb33a5c)
-rw-r--r--src/devices/bluetooth/nm-device-bt.c2
-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.h24
-rw-r--r--src/devices/team/nm-device-team.c2
-rw-r--r--src/devices/wifi/nm-device-wifi.c7
-rw-r--r--src/devices/wimax/nm-device-wimax.c5
-rw-r--r--src/devices/wwan/nm-device-modem.c2
9 files changed, 38 insertions, 18 deletions
diff --git a/src/devices/bluetooth/nm-device-bt.c b/src/devices/bluetooth/nm-device-bt.c
index 7b1b3fde5e..8a89cc83da 100644
--- a/src/devices/bluetooth/nm-device-bt.c
+++ b/src/devices/bluetooth/nm-device-bt.c
@@ -187,7 +187,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
static gboolean
check_connection_available (NMDevice *device,
NMConnection *connection,
- gboolean for_user_activation_request,
+ NMDeviceCheckConAvailableFlags flags,
const char *specific_object)
{
NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device);
diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c
index 50793f6268..2637f5c7b9 100644
--- a/src/devices/nm-device-bond.c
+++ b/src/devices/nm-device-bond.c
@@ -77,7 +77,7 @@ is_available (NMDevice *dev)
static gboolean
check_connection_available (NMDevice *device,
NMConnection *connection,
- gboolean for_user_activation_request,
+ NMDeviceCheckConAvailableFlags flags,
const char *specific_object)
{
/* Connections are always available because the carrier state is determined
diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c
index 53d5bef33b..92c29387c4 100644
--- a/src/devices/nm-device-bridge.c
+++ b/src/devices/nm-device-bridge.c
@@ -76,7 +76,7 @@ is_available (NMDevice *dev)
static gboolean
check_connection_available (NMDevice *device,
NMConnection *connection,
- gboolean for_user_activation_request,
+ NMDeviceCheckConAvailableFlags flags,
const char *specific_object)
{
/* Connections are always available because the carrier state is determined
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index fc9ac1b18e..860c81add9 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -6845,7 +6845,7 @@ nm_device_connection_is_available (NMDevice *self,
}
if ( is_default_unmanaged
- && NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, FALSE, NULL)) {
+ && NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, NM_DEVICE_CHECK_CON_AVAILABLE_NONE, NULL)) {
/* default-unmanaged devices in UNMANAGED state have no available connections
* so we must manually check whether the connection is available here. */
return TRUE;
@@ -6853,7 +6853,7 @@ nm_device_connection_is_available (NMDevice *self,
if ( for_user_activation_request
&& NM_DEVICE_GET_CLASS (self)->check_connection_available_has_user_override
- && NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, TRUE, NULL)) {
+ && NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST, NULL)) {
/* Connections for an explicit user activation request might only be available after
* additional checking.
*
@@ -6888,7 +6888,7 @@ _try_add_available_connection (NMDevice *self, NMConnection *connection)
return FALSE;
if (nm_device_check_connection_compatible (self, connection)) {
- if (NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, FALSE, NULL)) {
+ if (NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, NM_DEVICE_CHECK_CON_AVAILABLE_NONE, NULL)) {
g_hash_table_add (NM_DEVICE_GET_PRIVATE (self)->available_connections,
g_object_ref (connection));
return TRUE;
@@ -6906,7 +6906,7 @@ _del_available_connection (NMDevice *self, NMConnection *connection)
static gboolean
check_connection_available (NMDevice *self,
NMConnection *connection,
- gboolean for_user_activation_request,
+ NMDeviceCheckConAvailableFlags flags,
const char *specific_object)
{
/* Connections which require a network connection are not available when
@@ -6968,7 +6968,7 @@ nm_device_get_available_connections (NMDevice *self, const char *specific_object
* compatible with it.
*/
if ( !specific_object
- || NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, FALSE, specific_object))
+ || NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, NM_DEVICE_CHECK_CON_AVAILABLE_NONE, specific_object))
g_ptr_array_add (array, connection);
}
}
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index 631345fdf5..5ba79d0042 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -85,6 +85,19 @@ G_BEGIN_DECLS
typedef enum NMActStageReturn NMActStageReturn;
+/* These flags affect whether a connection is considered available on a device
+ * (check_connection_available()). The flags should have the meaning of relaxing
+ * a condition, so that adding a flag might make a connection available that would
+ * not be available otherwise. Adding a flag should never make a connection
+ * not available if it would be available otherwise. */
+typedef enum {
+ NM_DEVICE_CHECK_CON_AVAILABLE_NONE = 0,
+ NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST = (1L << 0),
+
+ __NM_DEVICE_CHECK_CON_AVAILABLE_ALL,
+ NM_DEVICE_CHECK_CON_AVAILABLE_ALL = (((__NM_DEVICE_CHECK_CON_AVAILABLE_ALL - 1) << 1) - 1),
+} NMDeviceCheckConAvailableFlags;
+
struct _NMDevice {
GObject parent;
};
@@ -137,14 +150,15 @@ typedef struct {
* is checked against the object defined by @specific_object, if given.
* Returns TRUE if the connection is available; FALSE if not.
*
- * If @for_user_activation_request, a connection might be considered
- * available under additional circumstances. That means, if a connection
- * is available for an internal, non-user request, it also must be available
- * for an external, user request.
+ * The passed @flags affect whether a connection is considered
+ * available or not. Adding more flags, means the connection is
+ * *more* available.
+ *
+ * Specifying @specific_object can only reduce the availability of a connection.
*/
gboolean (* check_connection_available) (NMDevice *self,
NMConnection *connection,
- gboolean for_user_activation_request,
+ NMDeviceCheckConAvailableFlags flags,
const char *specific_object);
gboolean check_connection_available_has_user_override;
diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c
index 8cda5a85b2..29a6401646 100644
--- a/src/devices/team/nm-device-team.c
+++ b/src/devices/team/nm-device-team.c
@@ -85,7 +85,7 @@ is_available (NMDevice *device)
static gboolean
check_connection_available (NMDevice *device,
NMConnection *connection,
- gboolean for_user_activation_request,
+ NMDeviceCheckConAvailableFlags flags,
const char *specific_object)
{
/* Connections are always available because the carrier state is determined
diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c
index 9fdf53968f..5c57a60086 100644
--- a/src/devices/wifi/nm-device-wifi.c
+++ b/src/devices/wifi/nm-device-wifi.c
@@ -865,7 +865,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
static gboolean
check_connection_available (NMDevice *device,
NMConnection *connection,
- gboolean for_user_activation_request,
+ NMDeviceCheckConAvailableFlags flags,
const char *specific_object)
{
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (device);
@@ -876,6 +876,9 @@ check_connection_available (NMDevice *device,
s_wifi = nm_connection_get_setting_wireless (connection);
g_return_val_if_fail (s_wifi, FALSE);
+ /* a connection that is available for a certain @specific_object, MUST
+ * also be available in general (without @specific_object). */
+
if (specific_object) {
NMAccessPoint *ap;
@@ -899,7 +902,7 @@ check_connection_available (NMDevice *device,
* activating but the network isn't available let the device recheck
* availability.
*/
- if (nm_setting_wireless_get_hidden (s_wifi) || for_user_activation_request)
+ if (nm_setting_wireless_get_hidden (s_wifi) || NM_FLAGS_HAS (flags, NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST))
return TRUE;
/* check if its visible */
diff --git a/src/devices/wimax/nm-device-wimax.c b/src/devices/wimax/nm-device-wimax.c
index a7f63fdc97..2611186964 100644
--- a/src/devices/wimax/nm-device-wimax.c
+++ b/src/devices/wimax/nm-device-wimax.c
@@ -334,13 +334,16 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
static gboolean
check_connection_available (NMDevice *device,
NMConnection *connection,
- gboolean for_user_activation_request,
+ NMDeviceCheckConAvailableFlags flags,
const char *specific_object)
{
NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (device);
const GSList *ns_iter = NULL;
NMWimaxNsp *nsp;
+ /* a connection that is available for a certain @specific_object, MUST
+ * also be available in general (without @specific_object). */
+
if (specific_object) {
nsp = get_nsp_by_path (NM_DEVICE_WIMAX (device), specific_object);
return nsp ? nm_wimax_nsp_check_compatible (nsp, connection) : FALSE;
diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c
index 4cf7901320..c3175566ef 100644
--- a/src/devices/wwan/nm-device-modem.c
+++ b/src/devices/wwan/nm-device-modem.c
@@ -394,7 +394,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
static gboolean
check_connection_available (NMDevice *device,
NMConnection *connection,
- gboolean for_user_activation_request,
+ NMDeviceCheckConAvailableFlags flags,
const char *specific_object)
{
NMDeviceModem *self = NM_DEVICE_MODEM (device);