libnm-glib: add nm_device_get_setting_type()
Add a function mapping NMDevices to their corresponding base NMSetting types.
This commit is contained in:
@@ -143,6 +143,7 @@ global:
|
||||
nm_device_get_mtu;
|
||||
nm_device_get_physical_port_id;
|
||||
nm_device_get_product;
|
||||
nm_device_get_setting_type;
|
||||
nm_device_get_state;
|
||||
nm_device_get_state_reason;
|
||||
nm_device_get_type;
|
||||
|
@@ -133,6 +133,12 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
||||
return NM_DEVICE_CLASS (nm_device_adsl_parent_class)->connection_compatible (device, connection, error);
|
||||
}
|
||||
|
||||
static GType
|
||||
get_setting_type (NMDevice *device)
|
||||
{
|
||||
return NM_TYPE_SETTING_ADSL;
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
static void
|
||||
@@ -221,6 +227,7 @@ nm_device_adsl_class_init (NMDeviceAdslClass *adsl_class)
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = get_property;
|
||||
device_class->connection_compatible = connection_compatible;
|
||||
device_class->get_setting_type = get_setting_type;
|
||||
|
||||
/* properties */
|
||||
/**
|
||||
|
@@ -191,6 +191,12 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
||||
return NM_DEVICE_CLASS (nm_device_bond_parent_class)->connection_compatible (device, connection, error);
|
||||
}
|
||||
|
||||
static GType
|
||||
get_setting_type (NMDevice *device)
|
||||
{
|
||||
return NM_TYPE_SETTING_BOND;
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_hw_address (NMDevice *device)
|
||||
{
|
||||
@@ -298,6 +304,7 @@ nm_device_bond_class_init (NMDeviceBondClass *eth_class)
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = get_property;
|
||||
device_class->connection_compatible = connection_compatible;
|
||||
device_class->get_setting_type = get_setting_type;
|
||||
device_class->get_hw_address = get_hw_address;
|
||||
|
||||
/* properties */
|
||||
|
@@ -199,6 +199,12 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
||||
return NM_DEVICE_CLASS (nm_device_bridge_parent_class)->connection_compatible (device, connection, error);
|
||||
}
|
||||
|
||||
static GType
|
||||
get_setting_type (NMDevice *device)
|
||||
{
|
||||
return NM_TYPE_SETTING_BRIDGE;
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_hw_address (NMDevice *device)
|
||||
{
|
||||
@@ -306,6 +312,7 @@ nm_device_bridge_class_init (NMDeviceBridgeClass *bridge_class)
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = get_property;
|
||||
device_class->connection_compatible = connection_compatible;
|
||||
device_class->get_setting_type = get_setting_type;
|
||||
device_class->get_hw_address = get_hw_address;
|
||||
|
||||
/* properties */
|
||||
|
@@ -223,6 +223,12 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
||||
return NM_DEVICE_CLASS (nm_device_bt_parent_class)->connection_compatible (device, connection, error);
|
||||
}
|
||||
|
||||
static GType
|
||||
get_setting_type (NMDevice *device)
|
||||
{
|
||||
return NM_TYPE_SETTING_BLUETOOTH;
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_hw_address (NMDevice *device)
|
||||
{
|
||||
@@ -325,6 +331,7 @@ nm_device_bt_class_init (NMDeviceBtClass *bt_class)
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = get_property;
|
||||
device_class->connection_compatible = connection_compatible;
|
||||
device_class->get_setting_type = get_setting_type;
|
||||
device_class->get_hw_address = get_hw_address;
|
||||
|
||||
/* properties */
|
||||
|
@@ -226,6 +226,12 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
||||
return NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->connection_compatible (device, connection, error);
|
||||
}
|
||||
|
||||
static GType
|
||||
get_setting_type (NMDevice *device)
|
||||
{
|
||||
return NM_TYPE_SETTING_WIRED;
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_hw_address (NMDevice *device)
|
||||
{
|
||||
@@ -332,6 +338,7 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *eth_class)
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = get_property;
|
||||
device_class->connection_compatible = connection_compatible;
|
||||
device_class->get_setting_type = get_setting_type;
|
||||
device_class->get_hw_address = get_hw_address;
|
||||
|
||||
/* properties */
|
||||
|
@@ -157,6 +157,12 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
||||
return NM_DEVICE_CLASS (nm_device_generic_parent_class)->connection_compatible (device, connection, error);
|
||||
}
|
||||
|
||||
static GType
|
||||
get_setting_type (NMDevice *device)
|
||||
{
|
||||
return NM_TYPE_SETTING_GENERIC;
|
||||
}
|
||||
|
||||
/***********************************************************/
|
||||
|
||||
static void
|
||||
@@ -251,6 +257,7 @@ nm_device_generic_class_init (NMDeviceGenericClass *klass)
|
||||
device_class->get_type_description = get_type_description;
|
||||
device_class->get_hw_address = get_hw_address;
|
||||
device_class->connection_compatible = connection_compatible;
|
||||
device_class->get_setting_type = get_setting_type;
|
||||
|
||||
/**
|
||||
* NMDeviceGeneric:hw-address:
|
||||
|
@@ -178,6 +178,12 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
||||
return NM_DEVICE_CLASS (nm_device_infiniband_parent_class)->connection_compatible (device, connection, error);
|
||||
}
|
||||
|
||||
static GType
|
||||
get_setting_type (NMDevice *device)
|
||||
{
|
||||
return NM_TYPE_SETTING_INFINIBAND;
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_hw_address (NMDevice *device)
|
||||
{
|
||||
@@ -275,6 +281,7 @@ nm_device_infiniband_class_init (NMDeviceInfinibandClass *eth_class)
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = get_property;
|
||||
device_class->connection_compatible = connection_compatible;
|
||||
device_class->get_setting_type = get_setting_type;
|
||||
device_class->get_hw_address = get_hw_address;
|
||||
|
||||
/* properties */
|
||||
|
@@ -167,6 +167,20 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
||||
return NM_DEVICE_CLASS (nm_device_modem_parent_class)->connection_compatible (device, connection, error);
|
||||
}
|
||||
|
||||
static GType
|
||||
get_setting_type (NMDevice *device)
|
||||
{
|
||||
NMDeviceModemCapabilities caps;
|
||||
|
||||
caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device));
|
||||
if (caps & (NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS | NM_DEVICE_MODEM_CAPABILITY_LTE))
|
||||
return NM_TYPE_SETTING_GSM;
|
||||
else if (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)
|
||||
return NM_TYPE_SETTING_CDMA;
|
||||
else
|
||||
return G_TYPE_INVALID;
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
|
||||
static void
|
||||
@@ -249,6 +263,7 @@ nm_device_modem_class_init (NMDeviceModemClass *modem_class)
|
||||
|
||||
device_class->get_type_description = get_type_description;
|
||||
device_class->connection_compatible = connection_compatible;
|
||||
device_class->get_setting_type = get_setting_type;
|
||||
|
||||
/**
|
||||
* NMDeviceModem:modem-capabilities:
|
||||
|
@@ -183,6 +183,12 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
||||
return NM_DEVICE_CLASS (nm_device_olpc_mesh_parent_class)->connection_compatible (device, connection, error);
|
||||
}
|
||||
|
||||
static GType
|
||||
get_setting_type (NMDevice *device)
|
||||
{
|
||||
return NM_TYPE_SETTING_OLPC_MESH;
|
||||
}
|
||||
|
||||
/**************************************************************/
|
||||
|
||||
static void
|
||||
@@ -279,6 +285,7 @@ nm_device_olpc_mesh_class_init (NMDeviceOlpcMeshClass *olpc_mesh_class)
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = get_property;
|
||||
device_class->connection_compatible = connection_compatible;
|
||||
device_class->get_setting_type = get_setting_type;
|
||||
device_class->get_hw_address = get_hw_address;
|
||||
|
||||
/* properties */
|
||||
|
@@ -203,6 +203,12 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
||||
return NM_DEVICE_CLASS (nm_device_team_parent_class)->connection_compatible (device, connection, error);
|
||||
}
|
||||
|
||||
static GType
|
||||
get_setting_type (NMDevice *device)
|
||||
{
|
||||
return NM_TYPE_SETTING_TEAM;
|
||||
}
|
||||
|
||||
/***********************************************************/
|
||||
|
||||
static void
|
||||
@@ -304,6 +310,7 @@ nm_device_team_class_init (NMDeviceTeamClass *eth_class)
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = get_property;
|
||||
device_class->connection_compatible = connection_compatible;
|
||||
device_class->get_setting_type = get_setting_type;
|
||||
device_class->get_hw_address = get_hw_address;
|
||||
|
||||
/* properties */
|
||||
|
@@ -205,6 +205,12 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
||||
return NM_DEVICE_CLASS (nm_device_vlan_parent_class)->connection_compatible (device, connection, error);
|
||||
}
|
||||
|
||||
static GType
|
||||
get_setting_type (NMDevice *device)
|
||||
{
|
||||
return NM_TYPE_SETTING_VLAN;
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_hw_address (NMDevice *device)
|
||||
{
|
||||
@@ -306,6 +312,7 @@ nm_device_vlan_class_init (NMDeviceVlanClass *eth_class)
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = get_property;
|
||||
device_class->connection_compatible = connection_compatible;
|
||||
device_class->get_setting_type = get_setting_type;
|
||||
device_class->get_hw_address = get_hw_address;
|
||||
|
||||
/* properties */
|
||||
|
@@ -523,6 +523,12 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
||||
return NM_DEVICE_CLASS (nm_device_wifi_parent_class)->connection_compatible (device, connection, error);
|
||||
}
|
||||
|
||||
static GType
|
||||
get_setting_type (NMDevice *device)
|
||||
{
|
||||
return NM_TYPE_SETTING_WIRELESS;
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_hw_address (NMDevice *device)
|
||||
{
|
||||
@@ -704,6 +710,7 @@ nm_device_wifi_class_init (NMDeviceWifiClass *wifi_class)
|
||||
object_class->dispose = dispose;
|
||||
object_class->finalize = finalize;
|
||||
device_class->connection_compatible = connection_compatible;
|
||||
device_class->get_setting_type = get_setting_type;
|
||||
device_class->get_hw_address = get_hw_address;
|
||||
wifi_class->access_point_removed = access_point_removed;
|
||||
|
||||
|
@@ -397,6 +397,12 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
||||
return NM_DEVICE_CLASS (nm_device_wimax_parent_class)->connection_compatible (device, connection, error);
|
||||
}
|
||||
|
||||
static GType
|
||||
get_setting_type (NMDevice *device)
|
||||
{
|
||||
return NM_TYPE_SETTING_WIMAX;
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_hw_address (NMDevice *device)
|
||||
{
|
||||
@@ -599,6 +605,7 @@ nm_device_wimax_class_init (NMDeviceWimaxClass *wimax_class)
|
||||
object_class->get_property = get_property;
|
||||
object_class->dispose = dispose;
|
||||
device_class->connection_compatible = connection_compatible;
|
||||
device_class->get_setting_type = get_setting_type;
|
||||
device_class->get_hw_address = get_hw_address;
|
||||
wimax_class->nsp_removed = nsp_removed;
|
||||
|
||||
|
@@ -2260,3 +2260,22 @@ nm_device_filter_connections (NMDevice *device, const GSList *connections)
|
||||
return g_slist_reverse (filtered);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_device_get_setting_type:
|
||||
* @device: an #NMDevice
|
||||
*
|
||||
* Gets the (primary) #NMSetting subtype associated with connections
|
||||
* that can be used on @device.
|
||||
*
|
||||
* Returns: @device's associated #NMSetting type
|
||||
*
|
||||
* Since: 0.9.10
|
||||
*/
|
||||
GType
|
||||
nm_device_get_setting_type (NMDevice *device)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_DEVICE (device), G_TYPE_INVALID);
|
||||
g_return_val_if_fail (NM_DEVICE_GET_CLASS (device)->get_setting_type != NULL, G_TYPE_INVALID);
|
||||
|
||||
return NM_DEVICE_GET_CLASS (device)->get_setting_type (device);
|
||||
}
|
||||
|
@@ -104,11 +104,12 @@ typedef struct {
|
||||
const char * (*get_type_description) (NMDevice *device);
|
||||
const char * (*get_hw_address) (NMDevice *device);
|
||||
|
||||
GType (*get_setting_type) (NMDevice *device);
|
||||
|
||||
/* Padding for future expansion */
|
||||
void (*_reserved1) (void);
|
||||
void (*_reserved2) (void);
|
||||
void (*_reserved3) (void);
|
||||
void (*_reserved4) (void);
|
||||
} NMDeviceClass;
|
||||
|
||||
GType nm_device_get_type (void);
|
||||
@@ -168,6 +169,9 @@ gboolean nm_device_connection_compatible (NMDevice *device,
|
||||
NMConnection *connection,
|
||||
GError **error);
|
||||
|
||||
NM_AVAILABLE_IN_0_9_10
|
||||
GType nm_device_get_setting_type (NMDevice *device);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* NM_DEVICE_H */
|
||||
|
Reference in New Issue
Block a user