diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2019-05-06 17:45:30 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2019-06-05 18:36:11 +0200 |
commit | f18b09b3f6957c798bb826df159a5f6b591bacf6 (patch) | |
tree | 3fc28fc0bb49853d4c57ec47cfe7732aa549e669 /libnm/nm-device-modem.c | |
parent | 03a91270b87d80e187dddfea17e50a04638169b5 (diff) | |
download | NetworkManager-f18b09b3f6957c798bb826df159a5f6b591bacf6.tar.gz |
libnm/modem: add device id getter
Diffstat (limited to 'libnm/nm-device-modem.c')
-rw-r--r-- | libnm/nm-device-modem.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/libnm/nm-device-modem.c b/libnm/nm-device-modem.c index 0373b3c08a..8fd54b8ca4 100644 --- a/libnm/nm-device-modem.c +++ b/libnm/nm-device-modem.c @@ -36,12 +36,14 @@ G_DEFINE_TYPE (NMDeviceModem, nm_device_modem, NM_TYPE_DEVICE) typedef struct { NMDeviceModemCapabilities caps; NMDeviceModemCapabilities current_caps; + char *device_id; } NMDeviceModemPrivate; enum { PROP_0, PROP_MODEM_CAPS, PROP_CURRENT_CAPS, + PROP_DEVICE_ID, LAST_PROP }; @@ -82,6 +84,26 @@ nm_device_modem_get_current_capabilities (NMDeviceModem *self) return NM_DEVICE_MODEM_GET_PRIVATE (self)->current_caps; } +/** + * nm_device_modem_get_device_id: + * @self: a #NMDeviceModem + * + * An identifier used by the modem backend (ModemManager) that aims to + * uniquely identify the a device. Can be used to match a connection to a + * particular device. + * + * Returns: a device-id string + * + * Since: 1.20 + **/ +const char * +nm_device_modem_get_device_id (NMDeviceModem *self) +{ + g_return_val_if_fail (NM_IS_DEVICE_MODEM (self), NULL); + + return NM_DEVICE_MODEM_GET_PRIVATE (self)->device_id; +} + static const char * get_type_description (NMDevice *device) { @@ -164,6 +186,7 @@ init_dbus (NMObject *object) const NMPropertiesInfo property_info[] = { { NM_DEVICE_MODEM_MODEM_CAPABILITIES, &priv->caps }, { NM_DEVICE_MODEM_CURRENT_CAPABILITIES, &priv->current_caps }, + { NM_DEVICE_MODEM_DEVICE_ID, &priv->device_id }, { NULL }, }; @@ -175,6 +198,16 @@ init_dbus (NMObject *object) } static void +finalize (GObject *object) +{ + NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (object); + + g_free (priv->device_id); + + G_OBJECT_CLASS (nm_device_modem_parent_class)->finalize (object); +} + +static void get_property (GObject *object, guint prop_id, GValue *value, @@ -189,6 +222,9 @@ get_property (GObject *object, case PROP_CURRENT_CAPS: g_value_set_flags (value, nm_device_modem_get_current_capabilities (self)); break; + case PROP_DEVICE_ID: + g_value_set_string (value, nm_device_modem_get_device_id (self)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -205,6 +241,7 @@ nm_device_modem_class_init (NMDeviceModemClass *modem_class) g_type_class_add_private (modem_class, sizeof (NMDeviceModemPrivate)); /* virtual methods */ + object_class->finalize = finalize; object_class->get_property = get_property; nm_object_class->init_dbus = init_dbus; @@ -242,4 +279,17 @@ nm_device_modem_class_init (NMDeviceModemClass *modem_class) NM_DEVICE_MODEM_CAPABILITY_NONE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + + /** + * NMDeviceModem:device-id: + * + * Since: 1.20 + **/ + g_object_class_install_property + (object_class, PROP_CURRENT_CAPS, + g_param_spec_string (NM_DEVICE_MODEM_DEVICE_ID, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); + } |