summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2019-05-06 17:46:31 +0200
committerLubomir Rintel <lkundrak@v3.sk>2019-06-05 18:36:45 +0200
commit0b3dd18c2bb431755803259f09d0d4788fdf5c3f (patch)
treee3bfe8fb0eb07faf28505b5914699cfb524333b4
parentbba4a37a59d36ea68e16854c3cecc1c7f8b8fa68 (diff)
downloadNetworkManager-0b3dd18c2bb431755803259f09d0d4788fdf5c3f.tar.gz
libnm/modem: add network id getter
-rw-r--r--libnm/libnm.ver1
-rw-r--r--libnm/nm-device-modem.c37
-rw-r--r--libnm/nm-device-modem.h4
3 files changed, 42 insertions, 0 deletions
diff --git a/libnm/libnm.ver b/libnm/libnm.ver
index 2209452a6a..526ec0529d 100644
--- a/libnm/libnm.ver
+++ b/libnm/libnm.ver
@@ -1608,4 +1608,5 @@ global:
libnm_1_20_0 {
global:
nm_device_modem_get_device_id;
+ nm_device_modem_get_operator_code;
} libnm_1_18_0;
diff --git a/libnm/nm-device-modem.c b/libnm/nm-device-modem.c
index 8fd54b8ca4..4565d80228 100644
--- a/libnm/nm-device-modem.c
+++ b/libnm/nm-device-modem.c
@@ -37,6 +37,7 @@ typedef struct {
NMDeviceModemCapabilities caps;
NMDeviceModemCapabilities current_caps;
char *device_id;
+ char *operator_code;
} NMDeviceModemPrivate;
enum {
@@ -44,6 +45,7 @@ enum {
PROP_MODEM_CAPS,
PROP_CURRENT_CAPS,
PROP_DEVICE_ID,
+ PROP_OPERATOR_CODE,
LAST_PROP
};
@@ -104,6 +106,24 @@ nm_device_modem_get_device_id (NMDeviceModem *self)
return NM_DEVICE_MODEM_GET_PRIVATE (self)->device_id;
}
+/**
+ * nm_device_modem_get_operator_code:
+ * @self: a #NMDeviceModem
+ *
+ * The MCC and MNC (concatenated) of the network the modem is connected to.
+ *
+ * Returns: the operator code or %NULL if disconnected or not a 3GPP modem.
+ *
+ * Since: 1.20
+ **/
+const char *
+nm_device_modem_get_operator_code (NMDeviceModem *self)
+{
+ g_return_val_if_fail (NM_IS_DEVICE_MODEM (self), NULL);
+
+ return NM_DEVICE_MODEM_GET_PRIVATE (self)->operator_code;
+}
+
static const char *
get_type_description (NMDevice *device)
{
@@ -187,6 +207,7 @@ init_dbus (NMObject *object)
{ NM_DEVICE_MODEM_MODEM_CAPABILITIES, &priv->caps },
{ NM_DEVICE_MODEM_CURRENT_CAPABILITIES, &priv->current_caps },
{ NM_DEVICE_MODEM_DEVICE_ID, &priv->device_id },
+ { NM_DEVICE_MODEM_OPERATOR_CODE, &priv->operator_code },
{ NULL },
};
@@ -203,6 +224,7 @@ finalize (GObject *object)
NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (object);
g_free (priv->device_id);
+ g_free (priv->operator_code);
G_OBJECT_CLASS (nm_device_modem_parent_class)->finalize (object);
}
@@ -225,6 +247,9 @@ get_property (GObject *object,
case PROP_DEVICE_ID:
g_value_set_string (value, nm_device_modem_get_device_id (self));
break;
+ case PROP_OPERATOR_CODE:
+ g_value_set_string (value, nm_device_modem_get_operator_code (self));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -292,4 +317,16 @@ nm_device_modem_class_init (NMDeviceModemClass *modem_class)
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
+ /**
+ * NMDeviceModem:operator-code:
+ *
+ * Since: 1.20
+ **/
+ g_object_class_install_property
+ (object_class, PROP_CURRENT_CAPS,
+ g_param_spec_string (NM_DEVICE_MODEM_OPERATOR_CODE, "", "",
+ NULL,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
}
diff --git a/libnm/nm-device-modem.h b/libnm/nm-device-modem.h
index 588851fd71..c0f9886906 100644
--- a/libnm/nm-device-modem.h
+++ b/libnm/nm-device-modem.h
@@ -40,6 +40,7 @@ G_BEGIN_DECLS
#define NM_DEVICE_MODEM_MODEM_CAPABILITIES "modem-capabilities"
#define NM_DEVICE_MODEM_CURRENT_CAPABILITIES "current-capabilities"
#define NM_DEVICE_MODEM_DEVICE_ID "device-id"
+#define NM_DEVICE_MODEM_OPERATOR_CODE "operator-code"
/**
* NMDeviceModem:
@@ -63,6 +64,9 @@ NMDeviceModemCapabilities nm_device_modem_get_current_capabilities (NMDeviceMode
NM_AVAILABLE_IN_1_20
const char *nm_device_modem_get_device_id (NMDeviceModem *self);
+NM_AVAILABLE_IN_1_20
+const char *nm_device_modem_get_operator_code (NMDeviceModem *self);
+
G_END_DECLS
#endif /* __NM_DEVICE_MODEM_H__ */