summaryrefslogtreecommitdiff
path: root/src/devices/wwan/nm-device-modem.c
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2019-05-06 17:15:31 +0200
committerLubomir Rintel <lkundrak@v3.sk>2019-06-05 18:36:15 +0200
commitbba4a37a59d36ea68e16854c3cecc1c7f8b8fa68 (patch)
tree81a8b376d57409d2d15ae055c0d9a261381f1ffb /src/devices/wwan/nm-device-modem.c
parentf18b09b3f6957c798bb826df159a5f6b591bacf6 (diff)
downloadNetworkManager-bba4a37a59d36ea68e16854c3cecc1c7f8b8fa68.tar.gz
wwan: expose the network id on the D-Bus
This is going to be useful for UIs to find out which network is the device actually registered with.
Diffstat (limited to 'src/devices/wwan/nm-device-modem.c')
-rw-r--r--src/devices/wwan/nm-device-modem.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c
index df7d1446d7..ad118b60c1 100644
--- a/src/devices/wwan/nm-device-modem.c
+++ b/src/devices/wwan/nm-device-modem.c
@@ -36,11 +36,12 @@ _LOG_DECLARE_SELF(NMDeviceModem);
/*****************************************************************************/
-NM_GOBJECT_PROPERTIES_DEFINE_BASE (
+NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceModem,
PROP_MODEM,
PROP_CAPABILITIES,
PROP_CURRENT_CAPABILITIES,
PROP_DEVICE_ID,
+ PROP_OPERATOR_CODE,
);
typedef struct {
@@ -49,6 +50,7 @@ typedef struct {
NMDeviceModemCapabilities current_caps;
gboolean rf_enabled;
char *device_id;
+ char *operator_code;
} NMDeviceModemPrivate;
struct _NMDeviceModem {
@@ -310,6 +312,20 @@ ip_ifindex_changed_cb (NMModem *modem, GParamSpec *pspec, gpointer user_data)
}
static void
+operator_code_changed_cb (NMModem *modem, GParamSpec *pspec, gpointer user_data)
+{
+ NMDeviceModem *self = NM_DEVICE_MODEM (user_data);
+ NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (self);
+ const char *operator_code = nm_modem_get_operator_code (modem);
+
+ if (g_strcmp0 (priv->operator_code, operator_code) != 0) {
+ g_free (priv->operator_code);
+ priv->operator_code = g_strdup (operator_code);
+ _notify (self, PROP_OPERATOR_CODE);
+ }
+}
+
+static void
ids_changed_cb (NMModem *modem, GParamSpec *pspec, gpointer user_data)
{
nm_device_recheck_available_connections (NM_DEVICE (user_data));
@@ -694,6 +710,7 @@ set_modem (NMDeviceModem *self, NMModem *modem)
g_signal_connect (modem, "notify::" NM_MODEM_DEVICE_ID, G_CALLBACK (ids_changed_cb), self);
g_signal_connect (modem, "notify::" NM_MODEM_SIM_ID, G_CALLBACK (ids_changed_cb), self);
g_signal_connect (modem, "notify::" NM_MODEM_SIM_OPERATOR_ID, G_CALLBACK (ids_changed_cb), self);
+ g_signal_connect (modem, "notify::" NM_MODEM_OPERATOR_CODE, G_CALLBACK (operator_code_changed_cb), self);
}
static guint32
@@ -727,6 +744,9 @@ get_property (GObject *object, guint prop_id,
case PROP_DEVICE_ID:
g_value_set_string (value, priv->device_id);
break;
+ case PROP_OPERATOR_CODE:
+ g_value_set_string (value, priv->operator_code);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -803,6 +823,7 @@ dispose (GObject *object)
}
g_clear_pointer (&priv->device_id, g_free);
+ g_clear_pointer (&priv->operator_code, g_free);
G_OBJECT_CLASS (nm_device_modem_parent_class)->dispose (object);
}
@@ -817,6 +838,7 @@ static const NMDBusInterfaceInfoExtended interface_info_device_modem = {
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),
+ NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE ("OperatorCode", "s", NM_DEVICE_MODEM_OPERATOR_CODE),
),
),
.legacy_property_changed = TRUE,
@@ -880,5 +902,10 @@ nm_device_modem_class_init (NMDeviceModemClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
+ obj_properties[PROP_OPERATOR_CODE] =
+ g_param_spec_string (NM_DEVICE_MODEM_OPERATOR_CODE, "", "",
+ NULL,
+ G_PARAM_STATIC_STRINGS);
+
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
}