diff options
author | Thomas Haller <thaller@redhat.com> | 2014-08-25 20:39:40 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2014-08-25 22:12:32 +0200 |
commit | 4ebc314ef2fce6381cccfce723789e2b3b242682 (patch) | |
tree | 59e42286d542a94dd3f3e8d2d2b43586a64f8a81 | |
parent | fb7b08388e9de5440962337e20a823bbf9d019ae (diff) | |
download | NetworkManager-4ebc314ef2fce6381cccfce723789e2b3b242682.tar.gz |
libnm: add NMSettingConnection:autoconnect-priority setting
The autoconnect priority has (currently) only any relevance,
if the connection is autoconnect too.
The priority defaults to zero, with higher numbers meaning preferred.
Currently we limit the range from [0,1000], but still set the type
to int32. Later we might relax this restriction to allow for further
use.
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r-- | libnm-core/nm-setting-connection.c | 39 | ||||
-rw-r--r-- | libnm-core/nm-setting-connection.h | 2 | ||||
-rw-r--r-- | libnm/libnm.ver | 1 |
3 files changed, 42 insertions, 0 deletions
diff --git a/libnm-core/nm-setting-connection.c b/libnm-core/nm-setting-connection.c index 448e78d0e3..ac804547da 100644 --- a/libnm-core/nm-setting-connection.c +++ b/libnm-core/nm-setting-connection.c @@ -84,6 +84,7 @@ typedef struct { char *slave_type; GSList *permissions; /* list of Permission structs */ gboolean autoconnect; + gint autoconnect_priority; guint64 timestamp; gboolean read_only; char *zone; @@ -99,6 +100,7 @@ enum { PROP_TYPE, PROP_PERMISSIONS, PROP_AUTOCONNECT, + PROP_AUTOCONNECT_PRIORITY, PROP_TIMESTAMP, PROP_READ_ONLY, PROP_ZONE, @@ -502,6 +504,22 @@ nm_setting_connection_get_autoconnect (NMSettingConnection *setting) } /** + * nm_setting_connection_get_autoconnect_priority: + * @setting: the #NMSettingConnection + * + * Returns the #NMSettingConnection:autoconnect-priority property of the connection. + * + * Returns: the connection's autoconnect priority setting + **/ +gint +nm_setting_connection_get_autoconnect_priority (NMSettingConnection *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), FALSE); + + return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->autoconnect_priority; +} + +/** * nm_setting_connection_get_timestamp: * @setting: the #NMSettingConnection * @@ -1036,6 +1054,9 @@ set_property (GObject *object, guint prop_id, case PROP_AUTOCONNECT: priv->autoconnect = g_value_get_boolean (value); break; + case PROP_AUTOCONNECT_PRIORITY: + priv->autoconnect_priority = g_value_get_int (value); + break; case PROP_TIMESTAMP: priv->timestamp = g_value_get_uint64 (value); break; @@ -1103,6 +1124,9 @@ get_property (GObject *object, guint prop_id, case PROP_AUTOCONNECT: g_value_set_boolean (value, nm_setting_connection_get_autoconnect (setting)); break; + case PROP_AUTOCONNECT_PRIORITY: + g_value_set_int (value, nm_setting_connection_get_autoconnect_priority (setting)); + break; case PROP_TIMESTAMP: g_value_set_uint64 (value, nm_setting_connection_get_timestamp (setting)); break; @@ -1265,6 +1289,21 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class) G_PARAM_STATIC_STRINGS)); /** + * NMSettingConnection:autoconnect-priority: + * + * The autoconnect priority. If the connection is set to autoconnect, + * connections with higher priority will be preferred. Defaults to 0. + **/ + g_object_class_install_property + (object_class, PROP_AUTOCONNECT_PRIORITY, + g_param_spec_int (NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY, "", "", + 0, 1000, 0, /* for now, restrict the valid range to [0,1000]. Later we might have use for other values. */ + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT | + NM_SETTING_PARAM_FUZZY_IGNORE | + G_PARAM_STATIC_STRINGS)); + + /** * NMSettingConnection:timestamp: * * The time, in seconds since the Unix Epoch, that the connection was last diff --git a/libnm-core/nm-setting-connection.h b/libnm-core/nm-setting-connection.h index 169e2c18ee..b519015088 100644 --- a/libnm-core/nm-setting-connection.h +++ b/libnm-core/nm-setting-connection.h @@ -77,6 +77,7 @@ GQuark nm_setting_connection_error_quark (void); #define NM_SETTING_CONNECTION_INTERFACE_NAME "interface-name" #define NM_SETTING_CONNECTION_TYPE "type" #define NM_SETTING_CONNECTION_AUTOCONNECT "autoconnect" +#define NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY "autoconnect-priority" #define NM_SETTING_CONNECTION_TIMESTAMP "timestamp" #define NM_SETTING_CONNECTION_READ_ONLY "read-only" #define NM_SETTING_CONNECTION_PERMISSIONS "permissions" @@ -111,6 +112,7 @@ const char *nm_setting_connection_get_uuid (NMSettingConnection *set const char *nm_setting_connection_get_interface_name (NMSettingConnection *setting); const char *nm_setting_connection_get_connection_type (NMSettingConnection *setting); gboolean nm_setting_connection_get_autoconnect (NMSettingConnection *setting); +gint nm_setting_connection_get_autoconnect_priority (NMSettingConnection *setting); guint64 nm_setting_connection_get_timestamp (NMSettingConnection *setting); gboolean nm_setting_connection_get_read_only (NMSettingConnection *setting); diff --git a/libnm/libnm.ver b/libnm/libnm.ver index 760bb42748..7992aa4395 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -516,6 +516,7 @@ global: nm_setting_connection_error_get_type; nm_setting_connection_error_quark; nm_setting_connection_get_autoconnect; + nm_setting_connection_get_autoconnect_priority; nm_setting_connection_get_connection_type; nm_setting_connection_get_gateway_ping_timeout; nm_setting_connection_get_id; |