[PATCH 1/5 v2] Allow vpn plugin to report error to user.

Mohamed Abbas mabbas at linux.intel.com
Thu Jan 27 12:25:53 PST 2011


If vpm client failed for auth or login problem, allow vpn plugin
to report this error to user.
---
 plugins/vpn.c |   21 ++++++++++++++++-----
 plugins/vpn.h |    1 +
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/plugins/vpn.c b/plugins/vpn.c
index 278e0ea..4685b51 100644
--- a/plugins/vpn.c
+++ b/plugins/vpn.c
@@ -102,11 +102,12 @@ static int kill_tun(char *tun_name)
 	return 0;
 }
 
-void vpn_died(struct connman_task *task, void *user_data)
+void vpn_died(struct connman_task *task, int exit_code, void *user_data)
 {
 	struct connman_provider *provider = user_data;
 	struct vpn_data *data = connman_provider_get_data(provider);
 	int state = data->state;
+	enum connman_provider_error ret;
 
 	DBG("provider %p data %p", provider, data);
 
@@ -118,10 +119,20 @@ void vpn_died(struct connman_task *task, void *user_data)
 	connman_rtnl_remove_watch(data->watch);
 
 vpn_exit:
-	if (state != VPN_STATE_READY && state != VPN_STATE_DISCONNECT)
-		connman_provider_set_state(provider,
-						CONNMAN_PROVIDER_STATE_FAILURE);
-	else
+	if (state != VPN_STATE_READY && state != VPN_STATE_DISCONNECT) {
+		const char *name;
+		struct vpn_driver_data *vpn_data;
+
+		name = connman_provider_get_driver_name(provider);
+		vpn_data = g_hash_table_lookup(driver_hash, name);
+		if (vpn_data != NULL &&
+				vpn_data->vpn_driver->error_code != NULL)
+			ret = vpn_data->vpn_driver->error_code(exit_code);
+		else
+			ret = CONNMAN_PROVIDER_ERROR_UNKNOWN;
+
+		connman_provider_indicate_error(provider, ret);
+	} else
 		connman_provider_set_state(provider,
 						CONNMAN_PROVIDER_STATE_IDLE);
 
diff --git a/plugins/vpn.h b/plugins/vpn.h
index 7f10150..88eb718 100644
--- a/plugins/vpn.h
+++ b/plugins/vpn.h
@@ -33,6 +33,7 @@ struct vpn_driver {
 	int (*connect) (struct connman_provider *provider,
 			struct connman_task *task, const char *if_name);
 	void (*disconnect) (void);
+	int (*error_code) (int exit_code);
 };
 
 int vpn_register(const char *name, struct vpn_driver *driver,
-- 
1.7.3.4




More information about the connman mailing list