diff options
author | Dan Winship <danw@gnome.org> | 2014-02-11 09:55:04 -0500 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2014-03-06 09:38:36 -0500 |
commit | 5cd37d250aa102883c9547c5edfb02b806c79454 (patch) | |
tree | 21b717a699a3fe409e06eacf4069dd56e23d5479 | |
parent | 4a5e2ced0854acc9008cdbd5322d61c30acee6b3 (diff) | |
download | NetworkManager-5cd37d250aa102883c9547c5edfb02b806c79454.tar.gz |
libnm-glib: add nm_device_get_setting_type()
Add a function mapping NMDevices to their corresponding base NMSetting
types.
-rw-r--r-- | libnm-glib/libnm-glib.ver | 1 | ||||
-rw-r--r-- | libnm-glib/nm-device-adsl.c | 7 | ||||
-rw-r--r-- | libnm-glib/nm-device-bond.c | 7 | ||||
-rw-r--r-- | libnm-glib/nm-device-bridge.c | 7 | ||||
-rw-r--r-- | libnm-glib/nm-device-bt.c | 7 | ||||
-rw-r--r-- | libnm-glib/nm-device-ethernet.c | 7 | ||||
-rw-r--r-- | libnm-glib/nm-device-generic.c | 7 | ||||
-rw-r--r-- | libnm-glib/nm-device-infiniband.c | 7 | ||||
-rw-r--r-- | libnm-glib/nm-device-modem.c | 15 | ||||
-rw-r--r-- | libnm-glib/nm-device-olpc-mesh.c | 7 | ||||
-rw-r--r-- | libnm-glib/nm-device-team.c | 7 | ||||
-rw-r--r-- | libnm-glib/nm-device-vlan.c | 7 | ||||
-rw-r--r-- | libnm-glib/nm-device-wifi.c | 7 | ||||
-rw-r--r-- | libnm-glib/nm-device-wimax.c | 7 | ||||
-rw-r--r-- | libnm-glib/nm-device.c | 19 | ||||
-rw-r--r-- | libnm-glib/nm-device.h | 6 |
16 files changed, 124 insertions, 1 deletions
diff --git a/libnm-glib/libnm-glib.ver b/libnm-glib/libnm-glib.ver index aa6f913d04..982288e50c 100644 --- a/libnm-glib/libnm-glib.ver +++ b/libnm-glib/libnm-glib.ver @@ -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; diff --git a/libnm-glib/nm-device-adsl.c b/libnm-glib/nm-device-adsl.c index e2db4da78f..b3f9691ee8 100644 --- a/libnm-glib/nm-device-adsl.c +++ b/libnm-glib/nm-device-adsl.c @@ -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 */ /** diff --git a/libnm-glib/nm-device-bond.c b/libnm-glib/nm-device-bond.c index 259f4dfcc0..b2af2ec349 100644 --- a/libnm-glib/nm-device-bond.c +++ b/libnm-glib/nm-device-bond.c @@ -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 */ diff --git a/libnm-glib/nm-device-bridge.c b/libnm-glib/nm-device-bridge.c index 3709814de0..c8967e2031 100644 --- a/libnm-glib/nm-device-bridge.c +++ b/libnm-glib/nm-device-bridge.c @@ -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 */ diff --git a/libnm-glib/nm-device-bt.c b/libnm-glib/nm-device-bt.c index 0de34b79d1..4c39ad049c 100644 --- a/libnm-glib/nm-device-bt.c +++ b/libnm-glib/nm-device-bt.c @@ -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 */ diff --git a/libnm-glib/nm-device-ethernet.c b/libnm-glib/nm-device-ethernet.c index 38424d2068..efdb3228c2 100644 --- a/libnm-glib/nm-device-ethernet.c +++ b/libnm-glib/nm-device-ethernet.c @@ -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 */ diff --git a/libnm-glib/nm-device-generic.c b/libnm-glib/nm-device-generic.c index fa4247be5c..2a45294f3c 100644 --- a/libnm-glib/nm-device-generic.c +++ b/libnm-glib/nm-device-generic.c @@ -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: diff --git a/libnm-glib/nm-device-infiniband.c b/libnm-glib/nm-device-infiniband.c index 678269d94b..b60b2d8215 100644 --- a/libnm-glib/nm-device-infiniband.c +++ b/libnm-glib/nm-device-infiniband.c @@ -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 */ diff --git a/libnm-glib/nm-device-modem.c b/libnm-glib/nm-device-modem.c index d20f4f28a6..b3b357cffa 100644 --- a/libnm-glib/nm-device-modem.c +++ b/libnm-glib/nm-device-modem.c @@ -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: diff --git a/libnm-glib/nm-device-olpc-mesh.c b/libnm-glib/nm-device-olpc-mesh.c index 058727f3ce..d1789eb943 100644 --- a/libnm-glib/nm-device-olpc-mesh.c +++ b/libnm-glib/nm-device-olpc-mesh.c @@ -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 */ diff --git a/libnm-glib/nm-device-team.c b/libnm-glib/nm-device-team.c index 0f0eb31e22..f739e1d842 100644 --- a/libnm-glib/nm-device-team.c +++ b/libnm-glib/nm-device-team.c @@ -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 */ diff --git a/libnm-glib/nm-device-vlan.c b/libnm-glib/nm-device-vlan.c index 07c7e1a4a9..2a84b94659 100644 --- a/libnm-glib/nm-device-vlan.c +++ b/libnm-glib/nm-device-vlan.c @@ -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 */ diff --git a/libnm-glib/nm-device-wifi.c b/libnm-glib/nm-device-wifi.c index a75495adcd..e89813ea54 100644 --- a/libnm-glib/nm-device-wifi.c +++ b/libnm-glib/nm-device-wifi.c @@ -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; diff --git a/libnm-glib/nm-device-wimax.c b/libnm-glib/nm-device-wimax.c index 39a9188c56..0b05280446 100644 --- a/libnm-glib/nm-device-wimax.c +++ b/libnm-glib/nm-device-wimax.c @@ -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; diff --git a/libnm-glib/nm-device.c b/libnm-glib/nm-device.c index ebb10eeeab..43c8dd29c8 100644 --- a/libnm-glib/nm-device.c +++ b/libnm-glib/nm-device.c @@ -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); +} diff --git a/libnm-glib/nm-device.h b/libnm-glib/nm-device.h index fa37e71710..ed0f687671 100644 --- a/libnm-glib/nm-device.h +++ b/libnm-glib/nm-device.h @@ -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 */ |