summary refs log tree commit diff
path: root/libnm/nm-device-modem.c
diff options
context:
space:
mode:
Diffstat (limited to 'libnm/nm-device-modem.c')
-rw-r--r--libnm/nm-device-modem.c124
1 files changed, 123 insertions, 1 deletions
diff --git a/libnm/nm-device-modem.c b/libnm/nm-device-modem.c
index 0373b3c0..60c707b8 100644
--- a/libnm/nm-device-modem.c
+++ b/libnm/nm-device-modem.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /*
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -36,12 +35,18 @@ G_DEFINE_TYPE (NMDeviceModem, nm_device_modem, NM_TYPE_DEVICE)
 typedef struct {
 	NMDeviceModemCapabilities caps;
 	NMDeviceModemCapabilities current_caps;
+	char *device_id;
+	char *operator_code;
+	char *apn;
 } NMDeviceModemPrivate;
 
 enum {
 	PROP_0,
 	PROP_MODEM_CAPS,
 	PROP_CURRENT_CAPS,
+	PROP_DEVICE_ID,
+	PROP_OPERATOR_CODE,
+	PROP_APN,
 	LAST_PROP
 };
 
@@ -82,6 +87,62 @@ 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;
+}
+
+/**
+ * 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;
+}
+
+/**
+ * nm_device_modem_get_apn:
+ * @self: a #NMDeviceModem
+ *
+ * The access point name the modem is connected to.
+ *
+ * Returns: the APN name or %NULL if disconnected
+ *
+ * Since: 1.20
+ **/
+const char *
+nm_device_modem_get_apn (NMDeviceModem *self)
+{
+	g_return_val_if_fail (NM_IS_DEVICE_MODEM (self), NULL);
+
+	return NM_DEVICE_MODEM_GET_PRIVATE (self)->apn;
+}
+
 static const char *
 get_type_description (NMDevice *device)
 {
@@ -164,6 +225,9 @@ 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 },
+		{ NM_DEVICE_MODEM_OPERATOR_CODE,        &priv->operator_code },
+		{ NM_DEVICE_MODEM_APN,                  &priv->apn },
 		{ NULL },
 	};
 
@@ -175,6 +239,18 @@ init_dbus (NMObject *object)
 }
 
 static void
+finalize (GObject *object)
+{
+	NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (object);
+
+	g_free (priv->device_id);
+	g_free (priv->operator_code);
+	g_free (priv->apn);
+
+	G_OBJECT_CLASS (nm_device_modem_parent_class)->finalize (object);
+}
+
+static void
 get_property (GObject *object,
               guint prop_id,
               GValue *value,
@@ -189,6 +265,15 @@ 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;
+	case PROP_OPERATOR_CODE:
+		g_value_set_string (value, nm_device_modem_get_operator_code (self));
+		break;
+	case PROP_APN:
+		g_value_set_string (value, nm_device_modem_get_apn (self));
+		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 		break;
@@ -205,6 +290,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 +328,40 @@ 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));
+
+	/**
+	 * 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));
+
+	/**
+	 * NMDeviceModem:apn:
+	 *
+	 * Since: 1.20
+	 **/
+	g_object_class_install_property
+		(object_class, PROP_CURRENT_CAPS,
+		 g_param_spec_string (NM_DEVICE_MODEM_APN, "", "",
+		                     NULL,
+		                     G_PARAM_READABLE |
+		                     G_PARAM_STATIC_STRINGS));
 }