libnm/modem: add device id getter
This commit is contained in:
@@ -1604,3 +1604,8 @@ global:
|
|||||||
nm_tc_qdisc_get_attribute_names;
|
nm_tc_qdisc_get_attribute_names;
|
||||||
nm_tc_qdisc_set_attribute;
|
nm_tc_qdisc_set_attribute;
|
||||||
} libnm_1_16_0;
|
} libnm_1_16_0;
|
||||||
|
|
||||||
|
libnm_1_20_0 {
|
||||||
|
global:
|
||||||
|
nm_device_modem_get_device_id;
|
||||||
|
} libnm_1_18_0;
|
||||||
|
@@ -36,12 +36,14 @@ G_DEFINE_TYPE (NMDeviceModem, nm_device_modem, NM_TYPE_DEVICE)
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
NMDeviceModemCapabilities caps;
|
NMDeviceModemCapabilities caps;
|
||||||
NMDeviceModemCapabilities current_caps;
|
NMDeviceModemCapabilities current_caps;
|
||||||
|
char *device_id;
|
||||||
} NMDeviceModemPrivate;
|
} NMDeviceModemPrivate;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_MODEM_CAPS,
|
PROP_MODEM_CAPS,
|
||||||
PROP_CURRENT_CAPS,
|
PROP_CURRENT_CAPS,
|
||||||
|
PROP_DEVICE_ID,
|
||||||
LAST_PROP
|
LAST_PROP
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -82,6 +84,26 @@ nm_device_modem_get_current_capabilities (NMDeviceModem *self)
|
|||||||
return NM_DEVICE_MODEM_GET_PRIVATE (self)->current_caps;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
get_type_description (NMDevice *device)
|
get_type_description (NMDevice *device)
|
||||||
{
|
{
|
||||||
@@ -164,6 +186,7 @@ init_dbus (NMObject *object)
|
|||||||
const NMPropertiesInfo property_info[] = {
|
const NMPropertiesInfo property_info[] = {
|
||||||
{ NM_DEVICE_MODEM_MODEM_CAPABILITIES, &priv->caps },
|
{ NM_DEVICE_MODEM_MODEM_CAPABILITIES, &priv->caps },
|
||||||
{ NM_DEVICE_MODEM_CURRENT_CAPABILITIES, &priv->current_caps },
|
{ NM_DEVICE_MODEM_CURRENT_CAPABILITIES, &priv->current_caps },
|
||||||
|
{ NM_DEVICE_MODEM_DEVICE_ID, &priv->device_id },
|
||||||
{ NULL },
|
{ NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -174,6 +197,16 @@ init_dbus (NMObject *object)
|
|||||||
property_info);
|
property_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
finalize (GObject *object)
|
||||||
|
{
|
||||||
|
NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (object);
|
||||||
|
|
||||||
|
g_free (priv->device_id);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (nm_device_modem_parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
get_property (GObject *object,
|
get_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
@@ -189,6 +222,9 @@ get_property (GObject *object,
|
|||||||
case PROP_CURRENT_CAPS:
|
case PROP_CURRENT_CAPS:
|
||||||
g_value_set_flags (value, nm_device_modem_get_current_capabilities (self));
|
g_value_set_flags (value, nm_device_modem_get_current_capabilities (self));
|
||||||
break;
|
break;
|
||||||
|
case PROP_DEVICE_ID:
|
||||||
|
g_value_set_string (value, nm_device_modem_get_device_id (self));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@@ -205,6 +241,7 @@ nm_device_modem_class_init (NMDeviceModemClass *modem_class)
|
|||||||
g_type_class_add_private (modem_class, sizeof (NMDeviceModemPrivate));
|
g_type_class_add_private (modem_class, sizeof (NMDeviceModemPrivate));
|
||||||
|
|
||||||
/* virtual methods */
|
/* virtual methods */
|
||||||
|
object_class->finalize = finalize;
|
||||||
object_class->get_property = get_property;
|
object_class->get_property = get_property;
|
||||||
|
|
||||||
nm_object_class->init_dbus = init_dbus;
|
nm_object_class->init_dbus = init_dbus;
|
||||||
@@ -242,4 +279,17 @@ nm_device_modem_class_init (NMDeviceModemClass *modem_class)
|
|||||||
NM_DEVICE_MODEM_CAPABILITY_NONE,
|
NM_DEVICE_MODEM_CAPABILITY_NONE,
|
||||||
G_PARAM_READABLE |
|
G_PARAM_READABLE |
|
||||||
G_PARAM_STATIC_STRINGS));
|
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));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -39,6 +39,7 @@ G_BEGIN_DECLS
|
|||||||
|
|
||||||
#define NM_DEVICE_MODEM_MODEM_CAPABILITIES "modem-capabilities"
|
#define NM_DEVICE_MODEM_MODEM_CAPABILITIES "modem-capabilities"
|
||||||
#define NM_DEVICE_MODEM_CURRENT_CAPABILITIES "current-capabilities"
|
#define NM_DEVICE_MODEM_CURRENT_CAPABILITIES "current-capabilities"
|
||||||
|
#define NM_DEVICE_MODEM_DEVICE_ID "device-id"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NMDeviceModem:
|
* NMDeviceModem:
|
||||||
@@ -59,6 +60,9 @@ GType nm_device_modem_get_type (void);
|
|||||||
NMDeviceModemCapabilities nm_device_modem_get_modem_capabilities (NMDeviceModem *self);
|
NMDeviceModemCapabilities nm_device_modem_get_modem_capabilities (NMDeviceModem *self);
|
||||||
NMDeviceModemCapabilities nm_device_modem_get_current_capabilities (NMDeviceModem *self);
|
NMDeviceModemCapabilities nm_device_modem_get_current_capabilities (NMDeviceModem *self);
|
||||||
|
|
||||||
|
NM_AVAILABLE_IN_1_20
|
||||||
|
const char *nm_device_modem_get_device_id (NMDeviceModem *self);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __NM_DEVICE_MODEM_H__ */
|
#endif /* __NM_DEVICE_MODEM_H__ */
|
||||||
|
Reference in New Issue
Block a user