summaryrefslogtreecommitdiff
path: root/src/devices/wwan/nm-device-modem.c
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2019-05-06 17:12:08 +0200
committerLubomir Rintel <lkundrak@v3.sk>2019-06-05 18:33:39 +0200
commit03a91270b87d80e187dddfea17e50a04638169b5 (patch)
tree881510f87e9260f212f676394334351cf2b4d0fd /src/devices/wwan/nm-device-modem.c
parent84539ce4cc9f466862314093de2f2ed9d0438921 (diff)
downloadNetworkManager-03a91270b87d80e187dddfea17e50a04638169b5.tar.gz
wwan: expose device id on the bus
The device id is useful to pinpoint the connection to a particular device. However, we don't expose it anywhere and it's sort of hard to guess.
Diffstat (limited to 'src/devices/wwan/nm-device-modem.c')
-rw-r--r--src/devices/wwan/nm-device-modem.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c
index ec7cabea9b..df7d1446d7 100644
--- a/src/devices/wwan/nm-device-modem.c
+++ b/src/devices/wwan/nm-device-modem.c
@@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Copyright (C) 2009 - 2011 Red Hat, Inc.
+ * Copyright (C) 2009 - 2019 Red Hat, Inc.
*/
#include "nm-default.h"
@@ -40,6 +40,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE (
PROP_MODEM,
PROP_CAPABILITIES,
PROP_CURRENT_CAPABILITIES,
+ PROP_DEVICE_ID,
);
typedef struct {
@@ -47,6 +48,7 @@ typedef struct {
NMDeviceModemCapabilities caps;
NMDeviceModemCapabilities current_caps;
gboolean rf_enabled;
+ char *device_id;
} NMDeviceModemPrivate;
struct _NMDeviceModem {
@@ -722,6 +724,9 @@ get_property (GObject *object, guint prop_id,
case PROP_CURRENT_CAPABILITIES:
g_value_set_uint (value, priv->current_caps);
break;
+ case PROP_DEVICE_ID:
+ g_value_set_string (value, priv->device_id);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -745,6 +750,10 @@ set_property (GObject *object, guint prop_id,
case PROP_CURRENT_CAPABILITIES:
priv->current_caps = g_value_get_uint (value);
break;
+ case PROP_DEVICE_ID:
+ /* construct-only */
+ priv->device_id = g_value_dup_string (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -779,6 +788,7 @@ nm_device_modem_new (NMModem *modem)
NM_DEVICE_MODEM_MODEM, modem,
NM_DEVICE_MODEM_CAPABILITIES, caps,
NM_DEVICE_MODEM_CURRENT_CAPABILITIES, current_caps,
+ NM_DEVICE_MODEM_DEVICE_ID, nm_modem_get_device_id (modem),
NULL);
}
@@ -792,6 +802,8 @@ dispose (GObject *object)
g_clear_object (&priv->modem);
}
+ g_clear_pointer (&priv->device_id, g_free);
+
G_OBJECT_CLASS (nm_device_modem_parent_class)->dispose (object);
}
@@ -804,6 +816,7 @@ static const NMDBusInterfaceInfoExtended interface_info_device_modem = {
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("ModemCapabilities", "u", NM_DEVICE_MODEM_CAPABILITIES),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("CurrentCapabilities", "u", NM_DEVICE_MODEM_CURRENT_CAPABILITIES),
+ NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE ("DeviceId", "s", NM_DEVICE_MODEM_DEVICE_ID),
),
),
.legacy_property_changed = TRUE,
@@ -861,5 +874,11 @@ nm_device_modem_class_init (NMDeviceModemClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
+ obj_properties[PROP_DEVICE_ID] =
+ g_param_spec_string (NM_DEVICE_MODEM_DEVICE_ID, "", "",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
}