diff options
author | Dan Williams <dcbw@redhat.com> | 2007-09-27 02:20:53 +0000 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2007-09-27 02:20:53 +0000 |
commit | d7696ae51000e0438f4b390fc7ec627aef566694 (patch) | |
tree | 1d5fa7c7be977b310e09d48866609c22accb951b | |
parent | 1451b90417902b0ec5ff3548f53a3db650490e63 (diff) | |
download | NetworkManager-d7696ae51000e0438f4b390fc7ec627aef566694.tar.gz |
2007-09-26 Dan Williams <dcbw@redhat.com>
* 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
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2892 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | introspection/nm-vpn-plugin.xml | 6 | ||||
-rw-r--r-- | libnm-glib/nm-vpn-plugin.c | 55 | ||||
-rw-r--r-- | libnm-glib/nm-vpn-plugin.h | 6 |
4 files changed, 76 insertions, 0 deletions
@@ -1,5 +1,14 @@ 2007-09-26 Dan Williams <dcbw@redhat.com> + * 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 <dcbw@redhat.com> + * src/nm-manager.c src/nm-manager.h - (nm_manager_get_connection_secrets): make static, unused outside 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 @@ <arg name="connection" type="a{sa{sv}}" direction="in"/> </method> + <method name="NeedSecrets"> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_vpn_plugin_need_secrets"/> + <arg name="settings" type="a{sa{sv}}" direction="in"/> + <arg name="setting_name" type="s" direction="out"/> + </method> + <method name="Disconnect"> <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_vpn_plugin_disconnect"/> </method> 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 <signal.h> #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; } @@ -322,6 +333,50 @@ impl_vpn_plugin_connect (NMVPNPlugin *plugin, } 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); |