From fc6373bea918f359ebece75e500773c50f5375c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Tue, 14 Apr 2015 14:16:04 +0200 Subject: [PATCH] device: add nm-plugin-missing property indicating NM device plugin not available It is useful for indicating that the device type is supported but the required plugin is not installed. --- introspection/nm-device.xml | 6 ++++++ src/devices/nm-device.c | 35 +++++++++++++++++++++++++++++++++++ src/devices/nm-device.h | 4 ++++ 3 files changed, 45 insertions(+) diff --git a/introspection/nm-device.xml b/introspection/nm-device.xml index 9e78856cf..7aef2f35b 100644 --- a/introspection/nm-device.xml +++ b/introspection/nm-device.xml @@ -116,6 +116,12 @@ its operation. + + + If TRUE, indicates the NetworkManager plugin for the device is likely + missing or misconfigured. + + The general type of the network device; ie Ethernet, WiFi, etc. diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 85050154d..05392392c 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -120,6 +120,7 @@ enum { PROP_MANAGED, PROP_AUTOCONNECT, PROP_FIRMWARE_MISSING, + PROP_NM_PLUGIN_MISSING, PROP_TYPE_DESC, PROP_RFKILL_TYPE, PROP_IFINDEX, @@ -197,6 +198,7 @@ typedef struct { char * firmware_version; RfKillType rfkill_type; gboolean firmware_missing; + gboolean nm_plugin_missing; GHashTable * available_connections; char * hw_addr; guint hw_addr_len; @@ -6691,6 +6693,26 @@ nm_device_get_firmware_missing (NMDevice *self) return NM_DEVICE_GET_PRIVATE (self)->firmware_missing; } +void +nm_device_set_nm_plugin_missing (NMDevice *self, gboolean new_missing) +{ + NMDevicePrivate *priv; + + g_return_if_fail (NM_IS_DEVICE (self)); + + priv = NM_DEVICE_GET_PRIVATE (self); + if (priv->nm_plugin_missing != new_missing) { + priv->nm_plugin_missing = new_missing; + g_object_notify (G_OBJECT (self), NM_DEVICE_NM_PLUGIN_MISSING); + } +} + +gboolean +nm_device_get_nm_plugin_missing (NMDevice *self) +{ + return NM_DEVICE_GET_PRIVATE (self)->nm_plugin_missing; +} + static NMIP4Config * find_ip4_lease_config (NMDevice *self, NMConnection *connection, @@ -8690,6 +8712,9 @@ set_property (GObject *object, guint prop_id, case PROP_FIRMWARE_MISSING: priv->firmware_missing = g_value_get_boolean (value); break; + case PROP_NM_PLUGIN_MISSING: + priv->nm_plugin_missing = g_value_get_boolean (value); + break; case PROP_DEVICE_TYPE: g_return_if_fail (priv->type == NM_DEVICE_TYPE_UNKNOWN); priv->type = g_value_get_uint (value); @@ -8835,6 +8860,9 @@ get_property (GObject *object, guint prop_id, case PROP_FIRMWARE_MISSING: g_value_set_boolean (value, priv->firmware_missing); break; + case PROP_NM_PLUGIN_MISSING: + g_value_set_boolean (value, priv->nm_plugin_missing); + break; case PROP_TYPE_DESC: g_value_set_string (value, priv->type_desc); break; @@ -9060,6 +9088,13 @@ nm_device_class_init (NMDeviceClass *klass) G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property + (object_class, PROP_NM_PLUGIN_MISSING, + g_param_spec_boolean (NM_DEVICE_NM_PLUGIN_MISSING, "", "", + FALSE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (object_class, PROP_TYPE_DESC, g_param_spec_string (NM_DEVICE_TYPE_DESC, "", "", diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index fb46c80dc..ad6de877f 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -54,6 +54,7 @@ #define NM_DEVICE_MANAGED "managed" #define NM_DEVICE_AUTOCONNECT "autoconnect" #define NM_DEVICE_FIRMWARE_MISSING "firmware-missing" +#define NM_DEVICE_NM_PLUGIN_MISSING "nm-plugin-missing" #define NM_DEVICE_AVAILABLE_CONNECTIONS "available-connections" #define NM_DEVICE_PHYSICAL_PORT_ID "physical-port-id" #define NM_DEVICE_MTU "mtu" @@ -389,6 +390,9 @@ void nm_device_queue_state (NMDevice *self, NMDeviceStateReason reason); gboolean nm_device_get_firmware_missing (NMDevice *self); +gboolean nm_device_get_nm_plugin_missing (NMDevice *self); +void nm_device_set_nm_plugin_missing (NMDevice *self, + gboolean missing); void nm_device_steal_connection (NMDevice *device, NMConnection *connection);