utils: inject platform into nm_utils_complete_generic()

This commit is contained in:
Thomas Haller 2016-03-08 13:57:20 +01:00
parent 56121fec83
commit 2eab5ed347
18 changed files with 45 additions and 23 deletions

View file

@ -127,7 +127,8 @@ get_new_connection_name (const GSList *existing,
}
static char *
get_new_connection_ifname (const GSList *existing,
get_new_connection_ifname (NMPlatform *platform,
const GSList *existing,
const char *prefix)
{
int i;
@ -138,7 +139,7 @@ get_new_connection_ifname (const GSList *existing,
for (i = 0; i < 500; i++) {
name = g_strdup_printf ("%s%d", prefix, i);
if (nm_platform_link_get_by_ifname (NM_PLATFORM_GET, name))
if (nm_platform_link_get_by_ifname (platform, name))
goto next;
for (iter = existing, found = FALSE; iter; iter = g_slist_next (iter)) {
@ -205,7 +206,8 @@ nm_utils_get_ip_config_method (NMConnection *connection,
}
void
nm_utils_complete_generic (NMConnection *connection,
nm_utils_complete_generic (NMPlatform *platform,
NMConnection *connection,
const char *ctype,
const GSList *existing,
const char *preferred_id,
@ -241,7 +243,7 @@ nm_utils_complete_generic (NMConnection *connection,
/* Add an interface name, if requested */
if (ifname_prefix && !nm_setting_connection_get_interface_name (s_con)) {
ifname = get_new_connection_ifname (existing, ifname_prefix);
ifname = get_new_connection_ifname (platform, existing, ifname_prefix);
g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_INTERFACE_NAME, ifname, NULL);
g_free (ifname);
}

View file

@ -28,7 +28,8 @@
const char *nm_utils_get_shared_wifi_permission (NMConnection *connection);
void nm_utils_complete_generic (NMConnection *connection,
void nm_utils_complete_generic (NMPlatform *platform,
NMConnection *connection,
const char *ctype,
const GSList *existing,
const char *preferred_id,

View file

@ -125,7 +125,8 @@ complete_connection (NMDevice *device,
if (s_adsl && !nm_setting_verify (NM_SETTING (s_adsl), NULL, error))
return FALSE;
nm_utils_complete_generic (connection,
nm_utils_complete_generic (NM_PLATFORM_GET,
connection,
NM_SETTING_ADSL_SETTING_NAME,
existing_connections,
NULL,

View file

@ -20,12 +20,13 @@
#include "nm-default.h"
#include "nm-device-bt.h"
#include <stdio.h>
#include <string.h>
#include "nm-bluez-common.h"
#include "nm-bluez-device.h"
#include "nm-device-bt.h"
#include "nm-device-private.h"
#include "ppp-manager/nm-ppp-manager.h"
#include "nm-setting-connection.h"
@ -39,6 +40,7 @@
#include "nm-utils.h"
#include "nm-bt-error.h"
#include "nm-bt-enum-types.h"
#include "nm-platform.h"
#include "nmdbus-device-bt.h"
@ -315,7 +317,8 @@ complete_connection (NMDevice *device,
return FALSE;
}
nm_utils_complete_generic (connection,
nm_utils_complete_generic (NM_PLATFORM_GET,
connection,
NM_SETTING_BLUETOOTH_SETTING_NAME,
existing_connections,
preferred,

View file

@ -97,7 +97,8 @@ complete_connection (NMDevice *device,
{
NMSettingBond *s_bond;
nm_utils_complete_generic (connection,
nm_utils_complete_generic (NM_PLATFORM_GET,
connection,
NM_SETTING_BOND_SETTING_NAME,
existing_connections,
NULL,

View file

@ -103,7 +103,8 @@ complete_connection (NMDevice *device,
{
NMSettingBridge *s_bridge;
nm_utils_complete_generic (connection,
nm_utils_complete_generic (NM_PLATFORM_GET,
connection,
NM_SETTING_BRIDGE_SETTING_NAME,
existing_connections,
NULL,

View file

@ -1388,7 +1388,8 @@ complete_connection (NMDevice *device,
/* Default to an ethernet-only connection, but if a PPPoE setting was given
* then PPPoE should be our connection type.
*/
nm_utils_complete_generic (connection,
nm_utils_complete_generic (NM_PLATFORM_GET,
connection,
s_pppoe ? NM_SETTING_PPPOE_SETTING_NAME : NM_SETTING_WIRED_SETTING_NAME,
existing_connections,
NULL,

View file

@ -166,7 +166,8 @@ complete_connection (NMDevice *device,
const char *setting_mac;
const char *hw_address;
nm_utils_complete_generic (connection,
nm_utils_complete_generic (NM_PLATFORM_GET,
connection,
NM_SETTING_INFINIBAND_SETTING_NAME,
existing_connections,
NULL,

View file

@ -338,7 +338,8 @@ complete_connection (NMDevice *device,
{
NMSettingIPTunnel *s_ip_tunnel;
nm_utils_complete_generic (connection,
nm_utils_complete_generic (NM_PLATFORM_GET,
connection,
NM_SETTING_IP_TUNNEL_SETTING_NAME,
existing_connections,
NULL,

View file

@ -420,7 +420,8 @@ complete_connection (NMDevice *device,
{
NMSettingMacvlan *s_macvlan;
nm_utils_complete_generic (connection,
nm_utils_complete_generic (NM_PLATFORM_GET,
connection,
NM_SETTING_MACVLAN_SETTING_NAME,
existing_connections,
NULL,

View file

@ -121,7 +121,8 @@ complete_connection (NMDevice *device,
{
NMSettingTun *s_tun;
nm_utils_complete_generic (connection,
nm_utils_complete_generic (NM_PLATFORM_GET,
connection,
NM_SETTING_TUN_SETTING_NAME,
existing_connections,
NULL,

View file

@ -439,7 +439,8 @@ complete_connection (NMDevice *device,
{
NMSettingVlan *s_vlan;
nm_utils_complete_generic (connection,
nm_utils_complete_generic (NM_PLATFORM_GET,
connection,
NM_SETTING_VLAN_SETTING_NAME,
existing_connections,
NULL,

View file

@ -365,7 +365,8 @@ complete_connection (NMDevice *device,
{
NMSettingVxlan *s_vxlan;
nm_utils_complete_generic (connection,
nm_utils_complete_generic (NM_PLATFORM_GET,
connection,
NM_SETTING_VXLAN_SETTING_NAME,
existing_connections,
NULL,

View file

@ -107,7 +107,8 @@ complete_connection (NMDevice *device,
{
NMSettingTeam *s_team;
nm_utils_complete_generic (connection,
nm_utils_complete_generic (NM_PLATFORM_GET,
connection,
NM_SETTING_TEAM_SETTING_NAME,
existing_connections,
NULL,

View file

@ -138,7 +138,8 @@ complete_connection (NMDevice *device,
}
nm_utils_complete_generic (connection,
nm_utils_complete_generic (NM_PLATFORM_GET,
connection,
NM_SETTING_OLPC_MESH_SETTING_NAME,
existing_connections,
NULL,

View file

@ -845,7 +845,8 @@ complete_connection (NMDevice *device,
str_ssid = nm_utils_ssid_to_utf8 (ssid->data, ssid->len);
nm_utils_complete_generic (connection,
nm_utils_complete_generic (NM_PLATFORM_GET,
connection,
NM_SETTING_WIRELESS_SETTING_NAME,
existing_connections,
str_ssid,

View file

@ -647,7 +647,8 @@ complete_connection (NMModem *_self,
if (!nm_setting_gsm_get_number (s_gsm))
g_object_set (G_OBJECT (s_gsm), NM_SETTING_GSM_NUMBER, "*99#", NULL);
nm_utils_complete_generic (connection,
nm_utils_complete_generic (NM_PLATFORM_GET,
connection,
NM_SETTING_GSM_SETTING_NAME,
existing_connections,
NULL,
@ -670,7 +671,8 @@ complete_connection (NMModem *_self,
if (!nm_setting_cdma_get_number (s_cdma))
g_object_set (G_OBJECT (s_cdma), NM_SETTING_CDMA_NUMBER, "#777", NULL);
nm_utils_complete_generic (connection,
nm_utils_complete_generic (NM_PLATFORM_GET,
connection,
NM_SETTING_CDMA_SETTING_NAME,
existing_connections,
NULL,

View file

@ -3569,7 +3569,8 @@ impl_manager_add_and_activate_connection (NMManager *self,
goto error;
}
nm_utils_complete_generic (connection,
nm_utils_complete_generic (NM_PLATFORM_GET,
connection,
NM_SETTING_VPN_SETTING_NAME,
all_connections,
NULL,