summary refs log tree commit diff
path: root/libnm/nm-vpn-plugin-old.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2016-03-30 00:56:30 +0200
committerMichael Biebl <biebl@debian.org>2016-03-30 00:56:30 +0200
commitd9c99a29a0d3384c9c3d2adce430f5cb1134ab6a (patch)
treefa41baf72753961e71dd8d5bdbe2b89c9109e4f1 /libnm/nm-vpn-plugin-old.c
parentc2de0d98ba39e0a1a970d066fd19be786092f376 (diff)
Imported Upstream version 1.1.92 upstream/1.1.92
Diffstat (limited to 'libnm/nm-vpn-plugin-old.c')
-rw-r--r--libnm/nm-vpn-plugin-old.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/libnm/nm-vpn-plugin-old.c b/libnm/nm-vpn-plugin-old.c
index 9bbac414..634e61a2 100644
--- a/libnm/nm-vpn-plugin-old.c
+++ b/libnm/nm-vpn-plugin-old.c
@@ -293,12 +293,15 @@ fail_stop (gpointer data)
 }
 
 static void
-schedule_fail_stop (NMVpnPluginOld *plugin)
+schedule_fail_stop (NMVpnPluginOld *plugin, guint timeout_secs)
 {
 	NMVpnPluginOldPrivate *priv = NM_VPN_PLUGIN_OLD_GET_PRIVATE (plugin);
 
 	nm_clear_g_source (&priv->fail_stop_id);
-	priv->fail_stop_id = g_idle_add (fail_stop, plugin);
+	if (timeout_secs)
+		priv->fail_stop_id = g_timeout_add_seconds (timeout_secs, fail_stop, plugin);
+	else
+		priv->fail_stop_id = g_idle_add (fail_stop, plugin);
 }
 
 /**
@@ -450,6 +453,7 @@ _connect_generic (NMVpnPluginOld *plugin,
 	NMConnection *connection;
 	gboolean success = FALSE;
 	GError *error = NULL;
+	guint fail_stop_timeout = 0;
 
 	if (priv->state != NM_VPN_SERVICE_STATE_STOPPED &&
 	    priv->state != NM_VPN_SERVICE_STATE_INIT) {
@@ -461,13 +465,13 @@ _connect_generic (NMVpnPluginOld *plugin,
 		return;
 	}
 
-	connection = nm_simple_connection_new_from_dbus (properties, &error);
+	connection = _nm_simple_connection_new_from_dbus (properties, NM_SETTING_PARSE_FLAGS_BEST_EFFORT, &error);
 	if (!connection) {
 		g_dbus_method_invocation_return_error (context,
 		                                       NM_VPN_PLUGIN_ERROR,
 		                                       NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
-		                                       "Invalid connection: (%d) %s",
-		                                       error->code, error->message);
+		                                       "Invalid connection: %s",
+		                                       error->message);
 		g_clear_error (&error);
 	}
 
@@ -480,15 +484,21 @@ _connect_generic (NMVpnPluginOld *plugin,
 		return;
 	}
 
-	nm_vpn_plugin_old_set_state (plugin, NM_VPN_SERVICE_STATE_STARTING);
+	nm_clear_g_source (&priv->fail_stop_id);
 
 	if (details) {
 		priv->interactive = TRUE;
 		success = vpn_class->connect_interactive (plugin, connection, details, &error);
+		if (g_error_matches (error, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_INTERACTIVE_NOT_SUPPORTED)) {
+			/* Give NetworkManager a bit of time to fall back to Connect() */
+			fail_stop_timeout = 5;
+		}
 	} else
 		success = vpn_class->connect (plugin, connection, &error);
 
 	if (success) {
+		nm_vpn_plugin_old_set_state (plugin, NM_VPN_SERVICE_STATE_STARTING);
+
 		g_dbus_method_invocation_return_value (context, NULL);
 
 		/* Add a timer to make sure we do not wait indefinitely for the successful connect. */
@@ -499,7 +509,7 @@ _connect_generic (NMVpnPluginOld *plugin,
 		/* Stop the plugin from an idle handler so that the Connect
 		 * method return gets sent before the STOP StateChanged signal.
 		 */
-		schedule_fail_stop (plugin);
+		schedule_fail_stop (plugin, fail_stop_timeout);
 	}
 
 	g_object_unref (connection);
@@ -537,7 +547,7 @@ impl_vpn_plugin_old_need_secrets (NMVpnPluginOld *plugin,
 	gboolean needed;
 	GError *error = NULL;
 
-	connection = nm_simple_connection_new_from_dbus (properties, &error);
+	connection = _nm_simple_connection_new_from_dbus (properties, NM_SETTING_PARSE_FLAGS_BEST_EFFORT, &error);
 	if (!connection) {
 		g_dbus_method_invocation_return_error (context,
 		                                       NM_VPN_PLUGIN_ERROR,
@@ -596,13 +606,13 @@ impl_vpn_plugin_old_new_secrets (NMVpnPluginOld *plugin,
 		return;
 	}
 
-	connection = nm_simple_connection_new_from_dbus (properties, &error);
+	connection = _nm_simple_connection_new_from_dbus (properties, NM_SETTING_PARSE_FLAGS_BEST_EFFORT, &error);
 	if (!connection) {
 		g_dbus_method_invocation_return_error (context,
 		                                       NM_VPN_PLUGIN_ERROR,
 		                                       NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
-		                                       "Invalid connection: (%d) %s",
-		                                       error->code, error->message);
+		                                       "Invalid connection: %s",
+		                                       error->message);
 		g_clear_error (&error);
 		return;
 	}
@@ -628,7 +638,7 @@ impl_vpn_plugin_old_new_secrets (NMVpnPluginOld *plugin,
 		/* Stop the plugin from and idle handler so that the NewSecrets
 		 * method return gets sent before the STOP StateChanged signal.
 		 */
-		schedule_fail_stop (plugin);
+		schedule_fail_stop (plugin, 0);
 	}
 
 	g_object_unref (connection);