summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiří Klimeš <jklimes@redhat.com>2015-09-16 09:34:33 +0200
committerJiří Klimeš <jklimes@redhat.com>2015-09-21 16:59:04 +0200
commitffe16c958f61b77583976b7b6a5c4793a389f461 (patch)
tree359de2995d0dd8e3ce4fa48df27fab336be3fc4d
parent5d36910d160a7ba37b13611b7563eadeac144c40 (diff)
downloadNetworkManager-ffe16c958f61b77583976b7b6a5c4793a389f461.tar.gz
libnm-core: add vpn.timeout property for establishing connections
[1] https://mail.gnome.org/archives/networkmanager-list/2015-April/msg00007.html
-rw-r--r--libnm-core/nm-setting-vpn.c44
-rw-r--r--libnm-core/nm-setting-vpn.h3
-rw-r--r--libnm/libnm.ver1
3 files changed, 48 insertions, 0 deletions
diff --git a/libnm-core/nm-setting-vpn.c b/libnm-core/nm-setting-vpn.c
index 50385112e9..aae8ae13b9 100644
--- a/libnm-core/nm-setting-vpn.c
+++ b/libnm-core/nm-setting-vpn.c
@@ -80,6 +80,9 @@ typedef struct {
* freed with g_free(). Should contain secrets only.
*/
GHashTable *secrets;
+
+ /* Timeout for the VPN service to establish the connection */
+ guint32 timeout;
} NMSettingVpnPrivate;
enum {
@@ -89,6 +92,7 @@ enum {
PROP_PERSISTENT,
PROP_DATA,
PROP_SECRETS,
+ PROP_TIMEOUT,
LAST_PROP
};
@@ -387,6 +391,22 @@ nm_setting_vpn_foreach_secret (NMSettingVpn *setting,
foreach_item_helper (NM_SETTING_VPN_GET_PRIVATE (setting)->secrets, func, user_data);
}
+/**
+ * nm_setting_vpn_get_timeout:
+ * @setting: the #NMSettingVpn
+ *
+ * Returns: the #NMSettingVpn:timeout property of the setting
+ *
+ * Since: 1.2
+ **/
+guint32
+nm_setting_vpn_get_timeout (NMSettingVpn *setting)
+{
+ g_return_val_if_fail (NM_IS_SETTING_VPN (setting), 0);
+
+ return NM_SETTING_VPN_GET_PRIVATE (setting)->timeout;
+}
+
static gboolean
verify (NMSetting *setting, NMConnection *connection, GError **error)
{
@@ -753,6 +773,9 @@ set_property (GObject *object, guint prop_id,
g_hash_table_unref (priv->secrets);
priv->secrets = _nm_utils_copy_strdict (g_value_get_boxed (value));
break;
+ case PROP_TIMEOUT:
+ priv->timeout = g_value_get_uint (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -782,6 +805,9 @@ get_property (GObject *object, guint prop_id,
case PROP_SECRETS:
g_value_take_boxed (value, _nm_utils_copy_strdict (priv->secrets));
break;
+ case PROP_TIMEOUT:
+ g_value_set_uint (value, nm_setting_vpn_get_timeout (setting));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -909,4 +935,22 @@ nm_setting_vpn_class_init (NMSettingVpnClass *setting_class)
G_VARIANT_TYPE ("a{ss}"),
_nm_utils_strdict_to_dbus,
_nm_utils_strdict_from_dbus);
+
+ /**
+ * NMSettingVpn:timeout:
+ *
+ * Timeout for the VPN service to establish the connection. Some services
+ * may take quite a long time to connect.
+ * Value of 0 means a default timeout, which is 60 seconds (unless overriden
+ * by vpn.timeout in configuration file). Values greater than zero mean
+ * timeout in seconds.
+ *
+ * Since: 1.2
+ **/
+ g_object_class_install_property
+ (object_class, PROP_TIMEOUT,
+ g_param_spec_uint (NM_SETTING_VPN_TIMEOUT, "", "",
+ 0, G_MAXUINT32, 0,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
}
diff --git a/libnm-core/nm-setting-vpn.h b/libnm-core/nm-setting-vpn.h
index 487549afaa..31f3c7b87a 100644
--- a/libnm-core/nm-setting-vpn.h
+++ b/libnm-core/nm-setting-vpn.h
@@ -45,6 +45,7 @@ G_BEGIN_DECLS
#define NM_SETTING_VPN_PERSISTENT "persistent"
#define NM_SETTING_VPN_DATA "data"
#define NM_SETTING_VPN_SECRETS "secrets"
+#define NM_SETTING_VPN_TIMEOUT "timeout"
struct _NMSettingVpn {
NMSetting parent;
@@ -96,6 +97,8 @@ gboolean nm_setting_vpn_remove_secret (NMSettingVpn *setting,
void nm_setting_vpn_foreach_secret (NMSettingVpn *setting,
NMVpnIterFunc func,
gpointer user_data);
+NM_AVAILABLE_IN_1_2
+guint32 nm_setting_vpn_get_timeout (NMSettingVpn *setting);
G_END_DECLS
diff --git a/libnm/libnm.ver b/libnm/libnm.ver
index efe182daeb..6551bc3863 100644
--- a/libnm/libnm.ver
+++ b/libnm/libnm.ver
@@ -876,6 +876,7 @@ global:
nm_setting_ip_config_has_dns_options;
nm_setting_ip_config_remove_dns_option;
nm_setting_ip_config_remove_dns_option_by_value;
+ nm_setting_vpn_get_timeout;
nm_setting_wired_get_wake_on_lan;
nm_setting_wired_get_wake_on_lan_password;
nm_setting_wired_wake_on_lan_get_type;