libnm/modem: add APN getter

This commit is contained in:
Lubomir Rintel
2019-05-06 17:47:01 +02:00
parent b5b8b23c4b
commit 8e270de05e
3 changed files with 41 additions and 0 deletions

View File

@@ -1607,6 +1607,7 @@ global:
libnm_1_20_0 {
global:
nm_device_modem_get_apn;
nm_device_modem_get_device_id;
nm_device_modem_get_operator_code;
} libnm_1_18_0;

View File

@@ -38,6 +38,7 @@ typedef struct {
NMDeviceModemCapabilities current_caps;
char *device_id;
char *operator_code;
char *apn;
} NMDeviceModemPrivate;
enum {
@@ -46,6 +47,7 @@ enum {
PROP_CURRENT_CAPS,
PROP_DEVICE_ID,
PROP_OPERATOR_CODE,
PROP_APN,
LAST_PROP
};
@@ -124,6 +126,24 @@ nm_device_modem_get_operator_code (NMDeviceModem *self)
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)
{
@@ -208,6 +228,7 @@ init_dbus (NMObject *object)
{ 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 },
};
@@ -225,6 +246,7 @@ finalize (GObject *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);
}
@@ -250,6 +272,9 @@ get_property (GObject *object,
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;
@@ -329,4 +354,15 @@ nm_device_modem_class_init (NMDeviceModemClass *modem_class)
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));
}

View File

@@ -41,6 +41,7 @@ G_BEGIN_DECLS
#define NM_DEVICE_MODEM_CURRENT_CAPABILITIES "current-capabilities"
#define NM_DEVICE_MODEM_DEVICE_ID "device-id"
#define NM_DEVICE_MODEM_OPERATOR_CODE "operator-code"
#define NM_DEVICE_MODEM_APN "apn"
/**
* NMDeviceModem:
@@ -67,6 +68,9 @@ 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);
NM_AVAILABLE_IN_1_20
const char *nm_device_modem_get_apn (NMDeviceModem *self);
G_END_DECLS
#endif /* __NM_DEVICE_MODEM_H__ */