device: add flags argument to check_connection_available()
This commit is contained in:
@@ -187,7 +187,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
|
|||||||
static gboolean
|
static gboolean
|
||||||
check_connection_available (NMDevice *device,
|
check_connection_available (NMDevice *device,
|
||||||
NMConnection *connection,
|
NMConnection *connection,
|
||||||
gboolean for_user_activation_request,
|
NMDeviceCheckConAvailableFlags flags,
|
||||||
const char *specific_object)
|
const char *specific_object)
|
||||||
{
|
{
|
||||||
NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device);
|
NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device);
|
||||||
|
@@ -78,7 +78,7 @@ is_available (NMDevice *dev)
|
|||||||
static gboolean
|
static gboolean
|
||||||
check_connection_available (NMDevice *device,
|
check_connection_available (NMDevice *device,
|
||||||
NMConnection *connection,
|
NMConnection *connection,
|
||||||
gboolean for_user_activation_request,
|
NMDeviceCheckConAvailableFlags flags,
|
||||||
const char *specific_object)
|
const char *specific_object)
|
||||||
{
|
{
|
||||||
/* Connections are always available because the carrier state is determined
|
/* Connections are always available because the carrier state is determined
|
||||||
|
@@ -76,7 +76,7 @@ is_available (NMDevice *dev)
|
|||||||
static gboolean
|
static gboolean
|
||||||
check_connection_available (NMDevice *device,
|
check_connection_available (NMDevice *device,
|
||||||
NMConnection *connection,
|
NMConnection *connection,
|
||||||
gboolean for_user_activation_request,
|
NMDeviceCheckConAvailableFlags flags,
|
||||||
const char *specific_object)
|
const char *specific_object)
|
||||||
{
|
{
|
||||||
/* Connections are always available because the carrier state is determined
|
/* Connections are always available because the carrier state is determined
|
||||||
|
@@ -6927,7 +6927,7 @@ nm_device_connection_is_available (NMDevice *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( is_default_unmanaged
|
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
|
/* default-unmanaged devices in UNMANAGED state have no available connections
|
||||||
* so we must manually check whether the connection is available here. */
|
* so we must manually check whether the connection is available here. */
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -6935,7 +6935,7 @@ nm_device_connection_is_available (NMDevice *self,
|
|||||||
|
|
||||||
if ( for_user_activation_request
|
if ( for_user_activation_request
|
||||||
&& NM_DEVICE_GET_CLASS (self)->check_connection_available_has_user_override
|
&& 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
|
/* Connections for an explicit user activation request might only be available after
|
||||||
* additional checking.
|
* additional checking.
|
||||||
*
|
*
|
||||||
@@ -6970,7 +6970,7 @@ _try_add_available_connection (NMDevice *self, NMConnection *connection)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (nm_device_check_connection_compatible (self, connection)) {
|
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_hash_table_add (NM_DEVICE_GET_PRIVATE (self)->available_connections,
|
||||||
g_object_ref (connection));
|
g_object_ref (connection));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -6988,7 +6988,7 @@ _del_available_connection (NMDevice *self, NMConnection *connection)
|
|||||||
static gboolean
|
static gboolean
|
||||||
check_connection_available (NMDevice *self,
|
check_connection_available (NMDevice *self,
|
||||||
NMConnection *connection,
|
NMConnection *connection,
|
||||||
gboolean for_user_activation_request,
|
NMDeviceCheckConAvailableFlags flags,
|
||||||
const char *specific_object)
|
const char *specific_object)
|
||||||
{
|
{
|
||||||
/* Connections which require a network connection are not available when
|
/* Connections which require a network connection are not available when
|
||||||
@@ -7050,7 +7050,7 @@ nm_device_get_available_connections (NMDevice *self, const char *specific_object
|
|||||||
* compatible with it.
|
* compatible with it.
|
||||||
*/
|
*/
|
||||||
if ( !specific_object
|
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);
|
g_ptr_array_add (array, connection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -86,6 +86,19 @@ G_BEGIN_DECLS
|
|||||||
|
|
||||||
typedef enum NMActStageReturn NMActStageReturn;
|
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 {
|
struct _NMDevice {
|
||||||
GObject parent;
|
GObject parent;
|
||||||
};
|
};
|
||||||
@@ -138,14 +151,15 @@ typedef struct {
|
|||||||
* is checked against the object defined by @specific_object, if given.
|
* is checked against the object defined by @specific_object, if given.
|
||||||
* Returns TRUE if the connection is available; FALSE if not.
|
* Returns TRUE if the connection is available; FALSE if not.
|
||||||
*
|
*
|
||||||
* If @for_user_activation_request, a connection might be considered
|
* The passed @flags affect whether a connection is considered
|
||||||
* available under additional circumstances. That means, if a connection
|
* available or not. Adding more flags, means the connection is
|
||||||
* is available for an internal, non-user request, it also must be available
|
* *more* available.
|
||||||
* for an external, user request.
|
*
|
||||||
|
* Specifying @specific_object can only reduce the availability of a connection.
|
||||||
*/
|
*/
|
||||||
gboolean (* check_connection_available) (NMDevice *self,
|
gboolean (* check_connection_available) (NMDevice *self,
|
||||||
NMConnection *connection,
|
NMConnection *connection,
|
||||||
gboolean for_user_activation_request,
|
NMDeviceCheckConAvailableFlags flags,
|
||||||
const char *specific_object);
|
const char *specific_object);
|
||||||
|
|
||||||
gboolean check_connection_available_has_user_override;
|
gboolean check_connection_available_has_user_override;
|
||||||
|
@@ -84,7 +84,7 @@ is_available (NMDevice *device)
|
|||||||
static gboolean
|
static gboolean
|
||||||
check_connection_available (NMDevice *device,
|
check_connection_available (NMDevice *device,
|
||||||
NMConnection *connection,
|
NMConnection *connection,
|
||||||
gboolean for_user_activation_request,
|
NMDeviceCheckConAvailableFlags flags,
|
||||||
const char *specific_object)
|
const char *specific_object)
|
||||||
{
|
{
|
||||||
/* Connections are always available because the carrier state is determined
|
/* Connections are always available because the carrier state is determined
|
||||||
|
@@ -866,7 +866,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
|
|||||||
static gboolean
|
static gboolean
|
||||||
check_connection_available (NMDevice *device,
|
check_connection_available (NMDevice *device,
|
||||||
NMConnection *connection,
|
NMConnection *connection,
|
||||||
gboolean for_user_activation_request,
|
NMDeviceCheckConAvailableFlags flags,
|
||||||
const char *specific_object)
|
const char *specific_object)
|
||||||
{
|
{
|
||||||
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (device);
|
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (device);
|
||||||
@@ -877,6 +877,9 @@ check_connection_available (NMDevice *device,
|
|||||||
s_wifi = nm_connection_get_setting_wireless (connection);
|
s_wifi = nm_connection_get_setting_wireless (connection);
|
||||||
g_return_val_if_fail (s_wifi, FALSE);
|
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) {
|
if (specific_object) {
|
||||||
NMAccessPoint *ap;
|
NMAccessPoint *ap;
|
||||||
|
|
||||||
@@ -900,7 +903,7 @@ check_connection_available (NMDevice *device,
|
|||||||
* activating but the network isn't available let the device recheck
|
* activating but the network isn't available let the device recheck
|
||||||
* availability.
|
* 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;
|
return TRUE;
|
||||||
|
|
||||||
/* check if its visible */
|
/* check if its visible */
|
||||||
|
@@ -334,13 +334,16 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
|
|||||||
static gboolean
|
static gboolean
|
||||||
check_connection_available (NMDevice *device,
|
check_connection_available (NMDevice *device,
|
||||||
NMConnection *connection,
|
NMConnection *connection,
|
||||||
gboolean for_user_activation_request,
|
NMDeviceCheckConAvailableFlags flags,
|
||||||
const char *specific_object)
|
const char *specific_object)
|
||||||
{
|
{
|
||||||
NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (device);
|
NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (device);
|
||||||
const GSList *ns_iter = NULL;
|
const GSList *ns_iter = NULL;
|
||||||
NMWimaxNsp *nsp;
|
NMWimaxNsp *nsp;
|
||||||
|
|
||||||
|
/* a connection that is available for a certain @specific_object, MUST
|
||||||
|
* also be available in general (without @specific_object). */
|
||||||
|
|
||||||
if (specific_object) {
|
if (specific_object) {
|
||||||
nsp = get_nsp_by_path (NM_DEVICE_WIMAX (device), specific_object);
|
nsp = get_nsp_by_path (NM_DEVICE_WIMAX (device), specific_object);
|
||||||
return nsp ? nm_wimax_nsp_check_compatible (nsp, connection) : FALSE;
|
return nsp ? nm_wimax_nsp_check_compatible (nsp, connection) : FALSE;
|
||||||
|
@@ -394,7 +394,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
|
|||||||
static gboolean
|
static gboolean
|
||||||
check_connection_available (NMDevice *device,
|
check_connection_available (NMDevice *device,
|
||||||
NMConnection *connection,
|
NMConnection *connection,
|
||||||
gboolean for_user_activation_request,
|
NMDeviceCheckConAvailableFlags flags,
|
||||||
const char *specific_object)
|
const char *specific_object)
|
||||||
{
|
{
|
||||||
NMDeviceModem *self = NM_DEVICE_MODEM (device);
|
NMDeviceModem *self = NM_DEVICE_MODEM (device);
|
||||||
|
Reference in New Issue
Block a user