core,libnm: add 'metered' property to NMDevice
This commit is contained in:
@@ -145,6 +145,12 @@
|
|||||||
The device MTU (maximum transmission unit).
|
The device MTU (maximum transmission unit).
|
||||||
</tp:docstring>
|
</tp:docstring>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="Metered" type="u" access="read" tp:type="NM_METERED">
|
||||||
|
<tp:docstring>
|
||||||
|
Whether the amount of traffic flowing through the device is
|
||||||
|
subject to limitations, for example set by service providers.
|
||||||
|
</tp:docstring>
|
||||||
|
</property>
|
||||||
|
|
||||||
<method name="Disconnect">
|
<method name="Disconnect">
|
||||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_device_disconnect"/>
|
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_device_disconnect"/>
|
||||||
@@ -660,6 +666,34 @@
|
|||||||
</tp:enumvalue>
|
</tp:enumvalue>
|
||||||
</tp:enum>
|
</tp:enum>
|
||||||
|
|
||||||
|
<tp:enum name="NM_METERED" type="u">
|
||||||
|
<tp:enumvalue suffix="UNKNOWN" value="0">
|
||||||
|
<tp:docstring>
|
||||||
|
The device metered status is unknown.
|
||||||
|
</tp:docstring>
|
||||||
|
</tp:enumvalue>
|
||||||
|
<tp:enumvalue suffix="YES" value="1">
|
||||||
|
<tp:docstring>
|
||||||
|
The device is metered and the value was statically set.
|
||||||
|
</tp:docstring>
|
||||||
|
</tp:enumvalue>
|
||||||
|
<tp:enumvalue suffix="NO" value="2">
|
||||||
|
<tp:docstring>
|
||||||
|
The device is not metered and the value was statically set.
|
||||||
|
</tp:docstring>
|
||||||
|
</tp:enumvalue>
|
||||||
|
<tp:enumvalue suffix="GUESS_YES" value="3">
|
||||||
|
<tp:docstring>
|
||||||
|
The device is metered and the value was guessed.
|
||||||
|
</tp:docstring>
|
||||||
|
</tp:enumvalue>
|
||||||
|
<tp:enumvalue suffix="GUESS_NO" value="4">
|
||||||
|
<tp:docstring>
|
||||||
|
The device is not metered and the value was guessed.
|
||||||
|
</tp:docstring>
|
||||||
|
</tp:enumvalue>
|
||||||
|
</tp:enum>
|
||||||
|
|
||||||
<tp:struct name="NM_DEVICE_STATE_REASON_STRUCT">
|
<tp:struct name="NM_DEVICE_STATE_REASON_STRUCT">
|
||||||
<tp:member type="u" name="state" tp:type="NM_DEVICE_STATE">
|
<tp:member type="u" name="state" tp:type="NM_DEVICE_STATE">
|
||||||
<tp:docstring>
|
<tp:docstring>
|
||||||
|
@@ -403,7 +403,6 @@ typedef enum {
|
|||||||
NM_DEVICE_STATE_FAILED = 120
|
NM_DEVICE_STATE_FAILED = 120
|
||||||
} NMDeviceState;
|
} NMDeviceState;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NMDeviceStateReason:
|
* NMDeviceStateReason:
|
||||||
* @NM_DEVICE_STATE_REASON_NONE: No reason given
|
* @NM_DEVICE_STATE_REASON_NONE: No reason given
|
||||||
@@ -540,6 +539,25 @@ typedef enum {
|
|||||||
NM_DEVICE_STATE_REASON_PARENT_MANAGED_CHANGED = 62,
|
NM_DEVICE_STATE_REASON_PARENT_MANAGED_CHANGED = 62,
|
||||||
} NMDeviceStateReason;
|
} NMDeviceStateReason;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NMMetered:
|
||||||
|
* @NM_METERED_UNKNOWN: The metered status is unknown
|
||||||
|
* @NM_METERED_YES: Metered, the value was statically set
|
||||||
|
* @NM_METERED_NO: Not metered, the value was statically set
|
||||||
|
* @NM_METERED_GUESS_YES: Metered, the value was guessed
|
||||||
|
* @NM_METERED_GUESS_NO: Not metered, the value was guessed
|
||||||
|
*
|
||||||
|
* (Corresponds to the NM_METERED type in nm-device.xml.)
|
||||||
|
*
|
||||||
|
* Since: 1.2
|
||||||
|
**/
|
||||||
|
typedef enum {
|
||||||
|
NM_METERED_UNKNOWN = 0,
|
||||||
|
NM_METERED_YES = 1,
|
||||||
|
NM_METERED_NO = 2,
|
||||||
|
NM_METERED_GUESS_YES = 3,
|
||||||
|
NM_METERED_GUESS_NO = 4,
|
||||||
|
} NMMetered;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NMActiveConnectionState:
|
* NMActiveConnectionState:
|
||||||
|
@@ -848,7 +848,9 @@ local:
|
|||||||
libnm_1_2_0 {
|
libnm_1_2_0 {
|
||||||
global:
|
global:
|
||||||
nm_access_point_get_last_seen;
|
nm_access_point_get_last_seen;
|
||||||
|
nm_device_get_metered;
|
||||||
nm_device_get_nm_plugin_missing;
|
nm_device_get_nm_plugin_missing;
|
||||||
|
nm_metered_get_type;
|
||||||
nm_setting_802_1x_check_cert_scheme;
|
nm_setting_802_1x_check_cert_scheme;
|
||||||
nm_setting_bridge_get_multicast_snooping;
|
nm_setting_bridge_get_multicast_snooping;
|
||||||
nm_setting_ip_config_add_dns_option;
|
nm_setting_ip_config_add_dns_option;
|
||||||
|
@@ -81,6 +81,7 @@ typedef struct {
|
|||||||
char *driver_version;
|
char *driver_version;
|
||||||
char *firmware_version;
|
char *firmware_version;
|
||||||
char *type_description;
|
char *type_description;
|
||||||
|
NMMetered metered;
|
||||||
NMDeviceCapabilities capabilities;
|
NMDeviceCapabilities capabilities;
|
||||||
gboolean managed;
|
gboolean managed;
|
||||||
gboolean firmware_missing;
|
gboolean firmware_missing;
|
||||||
@@ -132,6 +133,7 @@ enum {
|
|||||||
PROP_AVAILABLE_CONNECTIONS,
|
PROP_AVAILABLE_CONNECTIONS,
|
||||||
PROP_PHYSICAL_PORT_ID,
|
PROP_PHYSICAL_PORT_ID,
|
||||||
PROP_MTU,
|
PROP_MTU,
|
||||||
|
PROP_METERED,
|
||||||
|
|
||||||
LAST_PROP
|
LAST_PROP
|
||||||
};
|
};
|
||||||
@@ -196,6 +198,7 @@ init_dbus (NMObject *object)
|
|||||||
{ NM_DEVICE_AVAILABLE_CONNECTIONS, &priv->available_connections, NULL, NM_TYPE_REMOTE_CONNECTION },
|
{ NM_DEVICE_AVAILABLE_CONNECTIONS, &priv->available_connections, NULL, NM_TYPE_REMOTE_CONNECTION },
|
||||||
{ NM_DEVICE_PHYSICAL_PORT_ID, &priv->physical_port_id },
|
{ NM_DEVICE_PHYSICAL_PORT_ID, &priv->physical_port_id },
|
||||||
{ NM_DEVICE_MTU, &priv->mtu },
|
{ NM_DEVICE_MTU, &priv->mtu },
|
||||||
|
{ NM_DEVICE_METERED, &priv->metered },
|
||||||
|
|
||||||
/* Properties that exist in D-Bus but that we don't track */
|
/* Properties that exist in D-Bus but that we don't track */
|
||||||
{ "ip4-address", NULL },
|
{ "ip4-address", NULL },
|
||||||
@@ -455,6 +458,9 @@ get_property (GObject *object,
|
|||||||
case PROP_MTU:
|
case PROP_MTU:
|
||||||
g_value_set_uint (value, nm_device_get_mtu (device));
|
g_value_set_uint (value, nm_device_get_mtu (device));
|
||||||
break;
|
break;
|
||||||
|
case PROP_METERED:
|
||||||
|
g_value_set_uint (value, nm_device_get_metered (device));
|
||||||
|
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;
|
||||||
@@ -814,6 +820,20 @@ nm_device_class_init (NMDeviceClass *device_class)
|
|||||||
G_PARAM_READABLE |
|
G_PARAM_READABLE |
|
||||||
G_PARAM_STATIC_STRINGS));
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NMDevice:metered:
|
||||||
|
*
|
||||||
|
* Whether the device is metered.
|
||||||
|
*
|
||||||
|
* Since: 1.2
|
||||||
|
**/
|
||||||
|
g_object_class_install_property
|
||||||
|
(object_class, PROP_METERED,
|
||||||
|
g_param_spec_uint (NM_DEVICE_METERED, "", "",
|
||||||
|
0, G_MAXUINT32, NM_METERED_UNKNOWN,
|
||||||
|
G_PARAM_READABLE |
|
||||||
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
/* signals */
|
/* signals */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1941,6 +1961,24 @@ nm_device_get_mtu (NMDevice *device)
|
|||||||
return NM_DEVICE_GET_PRIVATE (device)->mtu;
|
return NM_DEVICE_GET_PRIVATE (device)->mtu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nm_device_get_metered:
|
||||||
|
* @device: a #NMDevice
|
||||||
|
*
|
||||||
|
* Gets the metered setting of a #NMDevice.
|
||||||
|
*
|
||||||
|
* Returns: the metered setting.
|
||||||
|
*
|
||||||
|
* Since: 1.2
|
||||||
|
**/
|
||||||
|
NMMetered
|
||||||
|
nm_device_get_metered (NMDevice *device)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (NM_IS_DEVICE (device), NM_METERED_UNKNOWN);
|
||||||
|
|
||||||
|
return NM_DEVICE_GET_PRIVATE (device)->metered;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nm_device_is_software:
|
* nm_device_is_software:
|
||||||
* @device: a #NMDevice
|
* @device: a #NMDevice
|
||||||
|
@@ -61,6 +61,7 @@ G_BEGIN_DECLS
|
|||||||
#define NM_DEVICE_PRODUCT "product"
|
#define NM_DEVICE_PRODUCT "product"
|
||||||
#define NM_DEVICE_PHYSICAL_PORT_ID "physical-port-id"
|
#define NM_DEVICE_PHYSICAL_PORT_ID "physical-port-id"
|
||||||
#define NM_DEVICE_MTU "mtu"
|
#define NM_DEVICE_MTU "mtu"
|
||||||
|
#define NM_DEVICE_METERED "metered"
|
||||||
|
|
||||||
struct _NMDevice {
|
struct _NMDevice {
|
||||||
NMObject parent;
|
NMObject parent;
|
||||||
@@ -122,6 +123,8 @@ gboolean nm_device_is_software (NMDevice *device);
|
|||||||
const char * nm_device_get_product (NMDevice *device);
|
const char * nm_device_get_product (NMDevice *device);
|
||||||
const char * nm_device_get_vendor (NMDevice *device);
|
const char * nm_device_get_vendor (NMDevice *device);
|
||||||
const char * nm_device_get_description (NMDevice *device);
|
const char * nm_device_get_description (NMDevice *device);
|
||||||
|
NM_AVAILABLE_IN_1_2
|
||||||
|
NMMetered nm_device_get_metered (NMDevice *device);
|
||||||
char ** nm_device_disambiguate_names (NMDevice **devices,
|
char ** nm_device_disambiguate_names (NMDevice **devices,
|
||||||
int num_devices);
|
int num_devices);
|
||||||
|
|
||||||
|
@@ -129,6 +129,7 @@ enum {
|
|||||||
PROP_MASTER,
|
PROP_MASTER,
|
||||||
PROP_HW_ADDRESS,
|
PROP_HW_ADDRESS,
|
||||||
PROP_HAS_PENDING_ACTION,
|
PROP_HAS_PENDING_ACTION,
|
||||||
|
PROP_METERED,
|
||||||
LAST_PROP
|
LAST_PROP
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -326,6 +327,8 @@ typedef struct {
|
|||||||
gboolean is_master;
|
gboolean is_master;
|
||||||
GSList * slaves; /* list of SlaveInfo */
|
GSList * slaves; /* list of SlaveInfo */
|
||||||
|
|
||||||
|
NMMetered metered;
|
||||||
|
|
||||||
NMConnectionProvider *con_provider;
|
NMConnectionProvider *con_provider;
|
||||||
} NMDevicePrivate;
|
} NMDevicePrivate;
|
||||||
|
|
||||||
@@ -673,6 +676,21 @@ nm_device_get_device_type (NMDevice *self)
|
|||||||
return NM_DEVICE_GET_PRIVATE (self)->type;
|
return NM_DEVICE_GET_PRIVATE (self)->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nm_device_get_metered:
|
||||||
|
* @setting: the #NMDevice
|
||||||
|
*
|
||||||
|
* Returns: the #NMDevice:metered property of the device.
|
||||||
|
*
|
||||||
|
* Since: 1.2
|
||||||
|
**/
|
||||||
|
NMMetered
|
||||||
|
nm_device_get_metered (NMDevice *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (NM_IS_DEVICE (self), NM_METERED_UNKNOWN);
|
||||||
|
|
||||||
|
return NM_DEVICE_GET_PRIVATE (self)->metered;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nm_device_get_priority():
|
* nm_device_get_priority():
|
||||||
@@ -9092,6 +9110,9 @@ get_property (GObject *object, guint prop_id,
|
|||||||
case PROP_HAS_PENDING_ACTION:
|
case PROP_HAS_PENDING_ACTION:
|
||||||
g_value_set_boolean (value, nm_device_has_pending_action (self));
|
g_value_set_boolean (value, nm_device_has_pending_action (self));
|
||||||
break;
|
break;
|
||||||
|
case PROP_METERED:
|
||||||
|
g_value_set_uint (value, priv->metered);
|
||||||
|
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;
|
||||||
@@ -9362,6 +9383,20 @@ nm_device_class_init (NMDeviceClass *klass)
|
|||||||
G_PARAM_READABLE |
|
G_PARAM_READABLE |
|
||||||
G_PARAM_STATIC_STRINGS));
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NMDevice:metered:
|
||||||
|
*
|
||||||
|
* Whether the connection is metered.
|
||||||
|
*
|
||||||
|
* Since: 1.2
|
||||||
|
**/
|
||||||
|
g_object_class_install_property
|
||||||
|
(object_class, PROP_METERED,
|
||||||
|
g_param_spec_uint (NM_DEVICE_METERED, "", "",
|
||||||
|
0, G_MAXUINT32, NM_METERED_UNKNOWN,
|
||||||
|
G_PARAM_READABLE |
|
||||||
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
/* Signals */
|
/* Signals */
|
||||||
signals[STATE_CHANGED] =
|
signals[STATE_CHANGED] =
|
||||||
g_signal_new ("state-changed",
|
g_signal_new ("state-changed",
|
||||||
|
@@ -59,6 +59,7 @@
|
|||||||
#define NM_DEVICE_PHYSICAL_PORT_ID "physical-port-id"
|
#define NM_DEVICE_PHYSICAL_PORT_ID "physical-port-id"
|
||||||
#define NM_DEVICE_MTU "mtu"
|
#define NM_DEVICE_MTU "mtu"
|
||||||
#define NM_DEVICE_HW_ADDRESS "hw-address"
|
#define NM_DEVICE_HW_ADDRESS "hw-address"
|
||||||
|
#define NM_DEVICE_METERED "metered"
|
||||||
|
|
||||||
#define NM_DEVICE_TYPE_DESC "type-desc" /* Internal only */
|
#define NM_DEVICE_TYPE_DESC "type-desc" /* Internal only */
|
||||||
#define NM_DEVICE_RFKILL_TYPE "rfkill-type" /* Internal only */
|
#define NM_DEVICE_RFKILL_TYPE "rfkill-type" /* Internal only */
|
||||||
@@ -75,7 +76,6 @@
|
|||||||
#define NM_DEVICE_RECHECK_AUTO_ACTIVATE "recheck-auto-activate"
|
#define NM_DEVICE_RECHECK_AUTO_ACTIVATE "recheck-auto-activate"
|
||||||
#define NM_DEVICE_RECHECK_ASSUME "recheck-assume"
|
#define NM_DEVICE_RECHECK_ASSUME "recheck-assume"
|
||||||
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define NM_TYPE_DEVICE (nm_device_get_type ())
|
#define NM_TYPE_DEVICE (nm_device_get_type ())
|
||||||
@@ -282,6 +282,7 @@ const char * nm_device_get_driver_version (NMDevice *dev);
|
|||||||
const char * nm_device_get_type_desc (NMDevice *dev);
|
const char * nm_device_get_type_desc (NMDevice *dev);
|
||||||
const char * nm_device_get_type_description (NMDevice *dev);
|
const char * nm_device_get_type_description (NMDevice *dev);
|
||||||
NMDeviceType nm_device_get_device_type (NMDevice *dev);
|
NMDeviceType nm_device_get_device_type (NMDevice *dev);
|
||||||
|
NMMetered nm_device_get_metered (NMDevice *dev);
|
||||||
|
|
||||||
int nm_device_get_priority (NMDevice *dev);
|
int nm_device_get_priority (NMDevice *dev);
|
||||||
guint32 nm_device_get_ip4_route_metric (NMDevice *dev);
|
guint32 nm_device_get_ip4_route_metric (NMDevice *dev);
|
||||||
|
Reference in New Issue
Block a user