libnm/modem: add network id getter
This commit is contained in:
@@ -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;
|
||||
|
@@ -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));
|
||||
|
||||
}
|
||||
|
@@ -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__ */
|
||||
|
Reference in New Issue
Block a user