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
This commit is contained in:
Dan Williams 2007-09-27 02:20:53 +00:00
parent 1451b90417
commit d7696ae510
4 changed files with 76 additions and 0 deletions

View file

@ -1,3 +1,12 @@
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

View file

@ -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>

View file

@ -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;
}
@ -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)

View file

@ -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);