libnm-glib/libnm: add support for "real" NMDevice property

This commit is contained in:
Dan Williams 2014-10-06 11:34:02 -05:00 committed by Thomas Haller
parent d6f9230beb
commit deb6c5f714
6 changed files with 89 additions and 0 deletions

View file

@ -158,6 +158,7 @@ global:
nm_device_infiniband_get_hw_address;
nm_device_infiniband_get_type;
nm_device_infiniband_new;
nm_device_is_real;
nm_device_is_software;
nm_device_modem_error_get_type;
nm_device_modem_error_quark;

View file

@ -79,6 +79,7 @@ typedef struct {
char *firmware_version;
char *type_description;
NMDeviceCapabilities capabilities;
gboolean real;
gboolean managed;
gboolean firmware_missing;
gboolean autoconnect;
@ -110,6 +111,7 @@ enum {
PROP_DRIVER_VERSION,
PROP_FIRMWARE_VERSION,
PROP_CAPABILITIES,
PROP_REAL,
PROP_MANAGED,
PROP_AUTOCONNECT,
PROP_FIRMWARE_MISSING,
@ -196,6 +198,7 @@ register_properties (NMDevice *device)
{ NM_DEVICE_DRIVER_VERSION, &priv->driver_version },
{ NM_DEVICE_FIRMWARE_VERSION, &priv->firmware_version },
{ NM_DEVICE_CAPABILITIES, &priv->capabilities },
{ NM_DEVICE_REAL, &priv->real },
{ NM_DEVICE_MANAGED, &priv->managed },
{ NM_DEVICE_AUTOCONNECT, &priv->autoconnect },
{ NM_DEVICE_FIRMWARE_MISSING, &priv->firmware_missing },
@ -446,6 +449,9 @@ get_property (GObject *object,
case PROP_CAPABILITIES:
g_value_set_uint (value, nm_device_get_capabilities (device));
break;
case PROP_REAL:
g_value_set_boolean (value, nm_device_is_real (device));
break;
case PROP_MANAGED:
g_value_set_boolean (value, nm_device_get_managed (device));
break;
@ -652,6 +658,22 @@ nm_device_class_init (NMDeviceClass *device_class)
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMDevice:real:
*
* Whether the device is real or is a placeholder device that could
* be created automatically by NetworkManager if one of its
* #NMDevice:available-connections was activated.
*
* Since: 1.2
**/
g_object_class_install_property
(object_class, PROP_REAL,
g_param_spec_boolean (NM_DEVICE_REAL, "", "",
FALSE,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMDevice:managed:
*
@ -2105,6 +2127,25 @@ nm_device_get_mtu (NMDevice *device)
return NM_DEVICE_GET_PRIVATE (device)->mtu;
}
/**
* nm_device_is_real:
* @device: a #NMDevice
*
* Returns: %TRUE if the device exists, or %FALSE if it is a placeholder device
* that could be automatically created by NetworkManager if one of its
* #NMDevice:available-connections was activated.
*
* Since: 1.2
**/
gboolean
nm_device_is_real (NMDevice *device)
{
g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_GET_PRIVATE (device)->real;
}
/**
* nm_device_is_software:
* @device: a #NMDevice

View file

@ -66,6 +66,7 @@ GQuark nm_device_error_quark (void);
#define NM_DEVICE_DRIVER_VERSION "driver-version"
#define NM_DEVICE_FIRMWARE_VERSION "firmware-version"
#define NM_DEVICE_CAPABILITIES "capabilities"
#define NM_DEVICE_REAL "real"
#define NM_DEVICE_MANAGED "managed"
#define NM_DEVICE_AUTOCONNECT "autoconnect"
#define NM_DEVICE_FIRMWARE_MISSING "firmware-missing"
@ -146,6 +147,8 @@ NM_AVAILABLE_IN_0_9_10
guint32 nm_device_get_mtu (NMDevice *device);
NM_AVAILABLE_IN_1_0
gboolean nm_device_is_software (NMDevice *device);
NM_AVAILABLE_IN_1_2
gboolean nm_device_is_real (NMDevice *device);
const char * nm_device_get_product (NMDevice *device);
const char * nm_device_get_vendor (NMDevice *device);

View file

@ -876,6 +876,7 @@ global:
nm_device_ip_tunnel_get_ttl;
nm_device_ip_tunnel_get_type;
nm_device_get_nm_plugin_missing;
nm_device_is_real;
nm_device_set_managed;
nm_device_tun_get_group;
nm_device_tun_get_hw_address;

View file

@ -86,6 +86,7 @@ typedef struct {
char *type_description;
NMMetered metered;
NMDeviceCapabilities capabilities;
gboolean real;
gboolean managed;
gboolean firmware_missing;
gboolean nm_plugin_missing;
@ -119,6 +120,7 @@ enum {
PROP_DRIVER_VERSION,
PROP_FIRMWARE_VERSION,
PROP_CAPABILITIES,
PROP_REAL,
PROP_MANAGED,
PROP_AUTOCONNECT,
PROP_FIRMWARE_MISSING,
@ -229,6 +231,7 @@ init_dbus (NMObject *object)
{ NM_DEVICE_DRIVER_VERSION, &priv->driver_version },
{ NM_DEVICE_FIRMWARE_VERSION, &priv->firmware_version },
{ NM_DEVICE_CAPABILITIES, &priv->capabilities },
{ NM_DEVICE_REAL, &priv->real },
{ NM_DEVICE_MANAGED, &priv->managed },
{ NM_DEVICE_AUTOCONNECT, &priv->autoconnect },
{ NM_DEVICE_FIRMWARE_MISSING, &priv->firmware_missing },
@ -461,6 +464,9 @@ get_property (GObject *object,
case PROP_CAPABILITIES:
g_value_set_flags (value, nm_device_get_capabilities (device));
break;
case PROP_REAL:
g_value_set_boolean (value, nm_device_is_real (device));
break;
case PROP_MANAGED:
g_value_set_boolean (value, nm_device_get_managed (device));
break;
@ -679,6 +685,22 @@ nm_device_class_init (NMDeviceClass *device_class)
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMDevice:real:
*
* Whether the device is real or is a placeholder device that could
* be created automatically by NetworkManager if one of its
* #NMDevice:available-connections was activated.
*
* Since: 1.2
**/
g_object_class_install_property
(object_class, PROP_REAL,
g_param_spec_boolean (NM_DEVICE_REAL, "", "",
FALSE,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMDevice:managed:
*
@ -2097,6 +2119,24 @@ nm_device_get_lldp_neighbors (NMDevice *device)
return NM_DEVICE_GET_PRIVATE (device)->lldp_neighbors;
}
/**
* nm_device_is_real:
* @device: a #NMDevice
*
* Returns: %TRUE if the device exists, or %FALSE if it is a placeholder device
* that could be automatically created by NetworkManager if one of its
* #NMDevice:available-connections was activated.
*
* Since: 1.2
**/
gboolean
nm_device_is_real (NMDevice *device)
{
g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
return NM_DEVICE_GET_PRIVATE (device)->real;
}
/**
* nm_device_is_software:
* @device: a #NMDevice

View file

@ -45,6 +45,7 @@ G_BEGIN_DECLS
#define NM_DEVICE_DRIVER_VERSION "driver-version"
#define NM_DEVICE_FIRMWARE_VERSION "firmware-version"
#define NM_DEVICE_CAPABILITIES "capabilities"
#define NM_DEVICE_REAL "real"
#define NM_DEVICE_MANAGED "managed"
#define NM_DEVICE_AUTOCONNECT "autoconnect"
#define NM_DEVICE_FIRMWARE_MISSING "firmware-missing"
@ -123,6 +124,8 @@ NMActiveConnection * nm_device_get_active_connection(NMDevice *device);
const GPtrArray * nm_device_get_available_connections(NMDevice *device);
const char * nm_device_get_physical_port_id (NMDevice *device);
guint32 nm_device_get_mtu (NMDevice *device);
NM_AVAILABLE_IN_1_2
gboolean nm_device_is_real (NMDevice *device);
gboolean nm_device_is_software (NMDevice *device);
const char * nm_device_get_product (NMDevice *device);