diff --git a/ChangeLog b/ChangeLog index cdeea0bd3c..bb1f46f992 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-09-26 Dan Williams + + * introspection/nm-vpn-plugin.xml + libnm-glib/nm-vpn-plugin.c + libnm-glib/nm-vpn-plugin.h + - (impl_vpn_plugin_need_secrets): implement a call that should return + the name of the NMSetting in an NMConnection that may require + secrets specific to that VPN plugin + 2007-09-26 Dan Williams * src/nm-manager.c diff --git a/introspection/nm-vpn-plugin.xml b/introspection/nm-vpn-plugin.xml index db03bad185..941c9da4cb 100644 --- a/introspection/nm-vpn-plugin.xml +++ b/introspection/nm-vpn-plugin.xml @@ -7,6 +7,12 @@ + + + + + + diff --git a/libnm-glib/nm-vpn-plugin.c b/libnm-glib/nm-vpn-plugin.c index fa5285eccf..4bf705760b 100644 --- a/libnm-glib/nm-vpn-plugin.c +++ b/libnm-glib/nm-vpn-plugin.c @@ -3,11 +3,17 @@ #include #include "nm-vpn-plugin.h" #include "nm-utils.h" +#include "nm-connection.h" static gboolean impl_vpn_plugin_connect (NMVPNPlugin *plugin, GHashTable *connection, GError **err); +static gboolean impl_vpn_plugin_need_secrets (NMVPNPlugin *plugin, + GHashTable *connection, + char **service_name, + GError **err); + static gboolean impl_vpn_plugin_disconnect (NMVPNPlugin *plugin, GError **err); @@ -94,6 +100,7 @@ nm_vpn_plugin_error_get_type (void) ENUM_ENTRY (NM_VPN_PLUGIN_ERROR_WRONG_STATE, "WrongState"), ENUM_ENTRY (NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS, "BadArguments"), ENUM_ENTRY (NM_VPN_PLUGIN_ERROR_LAUNCH_FAILED, "LaunchFailed"), + ENUM_ENTRY (NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID, "ConnectionInvalid"), { 0, 0, 0 } }; @@ -203,8 +210,12 @@ nm_vpn_plugin_disconnect (NMVPNPlugin *plugin, GError **err) ret = NM_VPN_PLUGIN_GET_CLASS (plugin)->disconnect (plugin, err); nm_vpn_plugin_set_state (plugin, NM_VPN_SERVICE_STATE_STOPPED); break; + case NM_VPN_SERVICE_STATE_INIT: + ret = TRUE; + break; default: + g_warning ("Unhandled VPN service state %d", state); g_assert_not_reached (); break; } @@ -321,6 +332,50 @@ impl_vpn_plugin_connect (NMVPNPlugin *plugin, return success; } +static gboolean +impl_vpn_plugin_need_secrets (NMVPNPlugin *plugin, + GHashTable *properties, + char **setting_name, + GError **err) +{ + gboolean ret = FALSE; + NMConnection *connection; + char *sn = NULL; + GError *ns_err = NULL; + + g_return_val_if_fail (NM_IS_VPN_PLUGIN (plugin), FALSE); + g_return_val_if_fail (properties != NULL, FALSE); + + connection = nm_connection_new_from_hash (properties); + if (!connection) { + g_set_error (err, + NM_VPN_PLUGIN_ERROR, + NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID, + "%s", + "The connection information was invalid."); + return FALSE; + } + + if (!NM_VPN_PLUGIN_GET_CLASS (plugin)->need_secrets) { + *setting_name = ""; + ret = TRUE; + goto out; + } + + if (NM_VPN_PLUGIN_GET_CLASS (plugin)->need_secrets (plugin, connection, &sn, &ns_err)) { + g_assert (sn); + *setting_name = g_strdup (sn); + ret = TRUE; + } else { + g_assert (ns_err); + *err = g_error_copy (ns_err); + g_error_free (ns_err); + } + +out: + return ret; +} + static gboolean impl_vpn_plugin_disconnect (NMVPNPlugin *plugin, GError **err) diff --git a/libnm-glib/nm-vpn-plugin.h b/libnm-glib/nm-vpn-plugin.h index 76b934a856..dc69430ee3 100644 --- a/libnm-glib/nm-vpn-plugin.h +++ b/libnm-glib/nm-vpn-plugin.h @@ -30,6 +30,7 @@ typedef enum { NM_VPN_PLUGIN_ERROR_WRONG_STATE, NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS, NM_VPN_PLUGIN_ERROR_LAUNCH_FAILED, + NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID, } NMVPNPluginError; #define NM_VPN_PLUGIN_ERROR (nm_vpn_plugin_error_quark ()) @@ -53,6 +54,11 @@ typedef struct { NMConnection *connection, GError **err); + gboolean (*need_secrets) (NMVPNPlugin *plugin, + NMConnection *connection, + char **setting_name, + GError **error); + gboolean (*disconnect) (NMVPNPlugin *plugin, GError **err);