summaryrefslogtreecommitdiff
path: root/libnm-util
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2014-10-16 20:09:38 -0500
committerDan Williams <dcbw@redhat.com>2014-11-06 21:16:57 -0600
commit2b9e442013fad40d289982c4ac48f28f9801b12c (patch)
tree2cce5c163b42cca5771caf92be16a9443f275313 /libnm-util
parent4b2935b9b8e165e6baa435b6335196637f725815 (diff)
downloadNetworkManager-2b9e442013fad40d289982c4ac48f28f9801b12c.tar.gz
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.
Diffstat (limited to 'libnm-util')
-rw-r--r--libnm-util/nm-setting-vpn.c40
-rw-r--r--libnm-util/nm-setting-vpn.h2
2 files changed, 42 insertions, 0 deletions
diff --git a/libnm-util/nm-setting-vpn.c b/libnm-util/nm-setting-vpn.c
index 70f955b010..77c64ce48f 100644
--- a/libnm-util/nm-setting-vpn.c
+++ b/libnm-util/nm-setting-vpn.c
@@ -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,
@@ -155,6 +161,20 @@ nm_setting_vpn_get_user_name (NMSettingVPN *setting)
}
/**
+ * 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;
@@ -844,6 +870,20 @@ nm_setting_vpn_class_init (NMSettingVPNClass *setting_class)
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:
*
* Dictionary of key/value pairs of VPN plugin specific data. Both keys and
diff --git a/libnm-util/nm-setting-vpn.h b/libnm-util/nm-setting-vpn.h
index 3eb51ee9d6..fbc9fe34f0 100644
--- a/libnm-util/nm-setting-vpn.h
+++ b/libnm-util/nm-setting-vpn.h
@@ -54,6 +54,7 @@ GQuark nm_setting_vpn_error_quark (void);
#define NM_SETTING_VPN_SERVICE_TYPE "service-type"
#define NM_SETTING_VPN_USER_NAME "user-name"
+#define NM_SETTING_VPN_PERSISTENT "persistent"
#define NM_SETTING_VPN_DATA "data"
#define NM_SETTING_VPN_SECRETS "secrets"
@@ -85,6 +86,7 @@ GType nm_setting_vpn_get_type (void);
NMSetting *nm_setting_vpn_new (void);
const char *nm_setting_vpn_get_service_type (NMSettingVPN *setting);
const char *nm_setting_vpn_get_user_name (NMSettingVPN *setting);
+gboolean nm_setting_vpn_get_persistent (NMSettingVPN *setting);
guint32 nm_setting_vpn_get_num_data_items (NMSettingVPN *setting);
void nm_setting_vpn_add_data_item (NMSettingVPN *setting,