static const char * get_type_description (NMDevice *device) { if (NM_DEVICE_GENERIC_GET_PRIVATE (device)->type_description) return NM_DEVICE_GENERIC_GET_PRIVATE (device)->type_description; return NM_DEVICE_CLASS (nm_device_generic_parent_class)->get_type_description (device); }
/** * nm_device_generic_get_hw_address: * @device: a #NMDeviceGeneric * * Gets the hardware address of the #NMDeviceGeneric * * Returns: the hardware address. This is the internal string used by the * device, and must not be modified. **/ const char * nm_device_generic_get_hw_address (NMDeviceGeneric *device) { g_return_val_if_fail (NM_IS_DEVICE_GENERIC (device), NULL); return nm_str_not_empty (NM_DEVICE_GENERIC_GET_PRIVATE (device)->hw_address); }
static const char * get_type_description (NMDevice *device) { NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (device); return nm_str_not_empty (priv->type_description); }
static const char * get_type_description (NMDevice *device) { NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (device); _nm_object_ensure_inited (NM_OBJECT (device)); return priv->type_description; }
/** * nm_device_generic_get_hw_address: * @device: a #NMDeviceGeneric * * Gets the hardware address of the #NMDeviceGeneric * * Returns: the hardware address. This is the internal string used by the * device, and must not be modified. * * Since: 0.9.10 **/ const char * nm_device_generic_get_hw_address (NMDeviceGeneric *device) { g_return_val_if_fail (NM_IS_DEVICE_GENERIC (device), NULL); _nm_object_ensure_inited (NM_OBJECT (device)); return NM_DEVICE_GENERIC_GET_PRIVATE (device)->hw_address; }
static void finalize (GObject *object) { NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (object); g_free (priv->hw_address); G_OBJECT_CLASS (nm_device_generic_parent_class)->finalize (object); }
static void dispose (GObject *object) { NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (object); g_clear_object (&priv->proxy); G_OBJECT_CLASS (nm_device_generic_parent_class)->dispose (object); }
static void dispose (GObject *object) { NMDeviceGeneric *self = NM_DEVICE_GENERIC (object); NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (self); g_clear_pointer (&priv->type_description, g_free); G_OBJECT_CLASS (nm_device_generic_parent_class)->dispose (object); }
static void constructed (GObject *object) { NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (object); G_OBJECT_CLASS (nm_device_generic_parent_class)->constructed (object); priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_GENERIC); register_properties (NM_DEVICE_GENERIC (object)); }
static void realize_start_notify (NMDevice *device, const NMPlatformLink *plink) { NMDeviceGeneric *self = NM_DEVICE_GENERIC (device); NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (self); int ifindex; NM_DEVICE_CLASS (nm_device_generic_parent_class)->realize_start_notify (device, plink); g_clear_pointer (&priv->type_description, g_free); ifindex = nm_device_get_ip_ifindex (NM_DEVICE (self)); if (ifindex > 0) priv->type_description = g_strdup (nm_platform_link_get_type_name (NM_PLATFORM_GET, ifindex)); }
static void register_properties (NMDeviceGeneric *device) { NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (device); const NMPropertiesInfo property_info[] = { { NM_DEVICE_GENERIC_HW_ADDRESS, &priv->hw_address }, { NM_DEVICE_GENERIC_TYPE_DESCRIPTION, &priv->type_description }, { NULL }, }; _nm_object_register_properties (NM_OBJECT (device), priv->proxy, property_info); }
static void constructed (GObject *object) { NMDeviceGeneric *self = NM_DEVICE_GENERIC (object); NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (self); if (!priv->type_description) { int ifindex = nm_device_get_ip_ifindex (NM_DEVICE (self)); if (ifindex != 0) priv->type_description = g_strdup (nm_platform_link_get_type_name (NM_PLATFORM_GET, ifindex)); } G_OBJECT_CLASS (nm_device_generic_parent_class)->constructed (object); }
static void set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { NMDeviceGeneric *self = NM_DEVICE_GENERIC (object); NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (self); switch (prop_id) { case PROP_TYPE_DESCRIPTION: priv->type_description = g_value_dup_string (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static void init_dbus (NMObject *object) { NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (object); const NMPropertiesInfo property_info[] = { { NM_DEVICE_GENERIC_HW_ADDRESS, &priv->hw_address }, { NM_DEVICE_GENERIC_TYPE_DESCRIPTION, &priv->type_description }, { NULL }, }; NM_OBJECT_CLASS (nm_device_generic_parent_class)->init_dbus (object); _nm_object_register_properties (object, NM_DBUS_INTERFACE_DEVICE_GENERIC, property_info); }
static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { NMDeviceGeneric *self = NM_DEVICE_GENERIC (object); NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (self); switch (prop_id) { case PROP_HW_ADDRESS: g_value_set_string (value, priv->hw_address); break; case PROP_TYPE_DESCRIPTION: g_value_set_string (value, get_type_description ((NMDevice *) self)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static void constructed (GObject *object) { NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (object); NMDeviceType type; DBusGConnection *connection; const char *path, *interface; G_OBJECT_CLASS (nm_device_generic_parent_class)->constructed (object); g_object_get (object, NM_OBJECT_DBUS_CONNECTION, &connection, NM_OBJECT_DBUS_PATH, &path, NULL); type = _nm_device_type_for_path (connection, path); interface = _device_type_to_interface (type); if (interface) { priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, interface); register_properties (NM_DEVICE_GENERIC (object)); } }