From: Mohamed Abbas Date: Fri, 28 Jan 2011 11:36:53 +0000 (+0100) Subject: vpn: Allow plugins to report error code X-Git-Tag: accepted/2.0alpha-wayland/20121110.002834~1808 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c1d9897d3fedd611fb0091d60787aebf8b7b1cda;p=profile%2Fivi%2Fconnman.git vpn: Allow plugins to report error code --- diff --git a/plugins/vpn.c b/plugins/vpn.c index e1b6404..4685b51 100644 --- a/plugins/vpn.c +++ b/plugins/vpn.c @@ -107,6 +107,7 @@ 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, int exit_code, 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 86e1f73..a45c718 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,