device: merge check_connection_available_wifi_hidden() into check_connection_available()

Only refactoring, no behavioral change.
This commit is contained in:
Thomas Haller 2014-12-08 12:39:45 +01:00
parent 364c4476e3
commit 5a04273715
9 changed files with 33 additions and 37 deletions

View file

@ -187,6 +187,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
static gboolean
check_connection_available (NMDevice *device,
NMConnection *connection,
gboolean for_user_activation_request,
const char *specific_object)
{
NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device);

View file

@ -78,6 +78,7 @@ is_available (NMDevice *dev)
static gboolean
check_connection_available (NMDevice *device,
NMConnection *connection,
gboolean for_user_activation_request,
const char *specific_object)
{
/* Connections are always available because the carrier state is determined

View file

@ -76,6 +76,7 @@ is_available (NMDevice *dev)
static gboolean
check_connection_available (NMDevice *device,
NMConnection *connection,
gboolean for_user_activation_request,
const char *specific_object)
{
/* Connections are always available because the carrier state is determined

View file

@ -6927,15 +6927,15 @@ nm_device_connection_is_available (NMDevice *self,
}
if ( is_default_unmanaged
&& NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, NULL)) {
&& NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, FALSE, NULL)) {
/* default-unmanaged devices in UNMANAGED state have no available connections
* so we must manually check whether the connection is available here. */
return TRUE;
}
if ( for_user_activation_request
&& NM_DEVICE_GET_CLASS (self)->check_connection_available_wifi_hidden
&& NM_DEVICE_GET_CLASS (self)->check_connection_available_wifi_hidden (self, connection)) {
&& NM_DEVICE_GET_CLASS (self)->check_connection_available_has_user_override
&& NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, TRUE, NULL)) {
/* Connections for an explicit user activation request might only be available after
* additional checking.
*
@ -6970,7 +6970,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, NULL)) {
if (NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, FALSE, NULL)) {
g_hash_table_add (NM_DEVICE_GET_PRIVATE (self)->available_connections,
g_object_ref (connection));
return TRUE;
@ -6988,6 +6988,7 @@ _del_available_connection (NMDevice *self, NMConnection *connection)
static gboolean
check_connection_available (NMDevice *self,
NMConnection *connection,
gboolean for_user_activation_request,
const char *specific_object)
{
/* Connections which require a network connection are not available when
@ -7049,7 +7050,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, specific_object))
|| NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, FALSE, specific_object))
g_ptr_array_add (array, connection);
}
}

View file

@ -137,18 +137,18 @@ typedef struct {
* including any live network information like scan lists. The connection
* 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.
*/
gboolean (* check_connection_available) (NMDevice *self,
NMConnection *connection,
gboolean for_user_activation_request,
const char *specific_object);
/* Same as check_connection_available() but called if the connection
* is not present in the activating-connections array during activation,
* to give the device a chance to allow/deny the activation. This is a
* hack only meant for hidden WiFi networks.
*/
gboolean (* check_connection_available_wifi_hidden) (NMDevice *self,
NMConnection *connection);
gboolean check_connection_available_has_user_override;
gboolean (* complete_connection) (NMDevice *self,
NMConnection *connection,

View file

@ -84,6 +84,7 @@ is_available (NMDevice *device)
static gboolean
check_connection_available (NMDevice *device,
NMConnection *connection,
gboolean for_user_activation_request,
const char *specific_object)
{
/* Connections are always available because the carrier state is determined

View file

@ -864,10 +864,10 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
static gboolean
_internal_check_connection_available (NMDevice *device,
NMConnection *connection,
const char *specific_object,
gboolean ignore_ap_list)
check_connection_available (NMDevice *device,
NMConnection *connection,
gboolean for_user_activation_request,
const char *specific_object)
{
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (device);
NMSettingWireless *s_wifi;
@ -892,8 +892,15 @@ _internal_check_connection_available (NMDevice *device,
|| g_strcmp0 (mode, NM_SETTING_WIRELESS_MODE_AP) == 0)
return TRUE;
/* Hidden SSIDs obviously don't always appear in the scan list either */
if (nm_setting_wireless_get_hidden (s_wifi) || ignore_ap_list)
/* Hidden SSIDs obviously don't always appear in the scan list either.
*
* For an explict user-activation-request, a connection is considered
* available because for hidden Wi-Fi, clients didn't consistently
* set the 'hidden' property to indicate hidden SSID networks. If
* activating but the network isn't available let the device recheck
* availability.
*/
if (nm_setting_wireless_get_hidden (s_wifi) || for_user_activation_request)
return TRUE;
/* check if its visible */
@ -905,24 +912,6 @@ _internal_check_connection_available (NMDevice *device,
return FALSE;
}
static gboolean
check_connection_available (NMDevice *device,
NMConnection *connection,
const char *specific_object)
{
return _internal_check_connection_available (device, connection, specific_object, FALSE);
}
/* FIXME: remove this function when we require the 'hidden' property to be
* set before a hidden connection can be activated.
*/
static gboolean
check_connection_available_wifi_hidden (NMDevice *device,
NMConnection *connection)
{
return _internal_check_connection_available (device, connection, NULL, TRUE);
}
/*
* List of manufacturer default SSIDs that are often unchanged by users.
*
@ -3341,7 +3330,7 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass)
parent_class->is_available = is_available;
parent_class->check_connection_compatible = check_connection_compatible;
parent_class->check_connection_available = check_connection_available;
parent_class->check_connection_available_wifi_hidden = check_connection_available_wifi_hidden;
parent_class->check_connection_available_has_user_override = TRUE;
parent_class->complete_connection = complete_connection;
parent_class->set_enabled = set_enabled;

View file

@ -334,6 +334,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
static gboolean
check_connection_available (NMDevice *device,
NMConnection *connection,
gboolean for_user_activation_request,
const char *specific_object)
{
NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (device);

View file

@ -394,6 +394,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
static gboolean
check_connection_available (NMDevice *device,
NMConnection *connection,
gboolean for_user_activation_request,
const char *specific_object)
{
NMDeviceModem *self = NM_DEVICE_MODEM (device);