libnm/libnm-util: add VPN 'persistent' property

This property will indicate that the user wishes the VPN connection
to stay active until explicitly disconnected, even across link changes
or other interruptions.
This commit is contained in:
Dan Williams
2014-10-16 20:09:38 -05:00
parent 4b2935b9b8
commit 2b9e442013
5 changed files with 87 additions and 1 deletions

View File

@@ -81,6 +81,11 @@ typedef struct {
*/
char *user_name;
/* Whether the VPN stays up across link changes, until the user
* explicitly disconnects it.
*/
gboolean persistent;
/* The hash table is created at setting object
* init time and should not be replaced. It is
* a char * -> char * mapping, and both the key
@@ -104,6 +109,7 @@ enum {
PROP_0,
PROP_SERVICE_TYPE,
PROP_USER_NAME,
PROP_PERSISTENT,
PROP_DATA,
PROP_SECRETS,
@@ -154,6 +160,20 @@ nm_setting_vpn_get_user_name (NMSettingVPN *setting)
return NM_SETTING_VPN_GET_PRIVATE (setting)->user_name;
}
/**
* nm_setting_vpn_get_persistent:
* @setting: the #NMSettingVPN
*
* Returns: the #NMSettingVPN:persistent property of the setting
**/
gboolean
nm_setting_vpn_get_persistent (NMSettingVPN *setting)
{
g_return_val_if_fail (NM_IS_SETTING_VPN (setting), FALSE);
return NM_SETTING_VPN_GET_PRIVATE (setting)->persistent;
}
/**
* nm_setting_vpn_get_num_data_items:
* @setting: the #NMSettingVPN
@@ -744,6 +764,9 @@ set_property (GObject *object, guint prop_id,
g_free (priv->user_name);
priv->user_name = g_value_dup_string (value);
break;
case PROP_PERSISTENT:
priv->persistent = g_value_get_boolean (value);
break;
case PROP_DATA:
/* Must make a deep copy of the hash table here... */
g_hash_table_remove_all (priv->data);
@@ -778,6 +801,9 @@ get_property (GObject *object, guint prop_id,
case PROP_USER_NAME:
g_value_set_string (value, nm_setting_vpn_get_user_name (setting));
break;
case PROP_PERSISTENT:
g_value_set_boolean (value, priv->persistent);
break;
case PROP_DATA:
g_value_set_boxed (value, priv->data);
break;
@@ -843,6 +869,20 @@ nm_setting_vpn_class_init (NMSettingVPNClass *setting_class)
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
/**
* NMSettingVPN:persistent:
*
* If the VPN service supports persistence, and this property is %TRUE,
* the VPN will attempt to stay connected across link changes and outages,
* until explicitly disconnected.
**/
g_object_class_install_property
(object_class, PROP_PERSISTENT,
g_param_spec_boolean (NM_SETTING_VPN_PERSISTENT, "", "",
FALSE,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
/**
* NMSettingVPN:data:
*