diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2017-08-10 10:38:22 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2017-08-10 11:37:18 +0200 |
commit | 73de9d3e375ca0f7a8ad9be905b1449a6be0b457 (patch) | |
tree | 585ea2fdd5c069eb79a0a77dc06f2c438efbc359 | |
parent | af74b4a86801c3cc93b9b6e266f980e801125e51 (diff) | |
download | NetworkManager-73de9d3e375ca0f7a8ad9be905b1449a6be0b457.tar.gz |
libnm: add nm_vpn_service_plugin_secrets_required_with_flags()
The new function can be used to requests secrets from NM passing
flags.
-rw-r--r-- | libnm/libnm.ver | 1 | ||||
-rw-r--r-- | libnm/nm-vpn-service-plugin.c | 52 | ||||
-rw-r--r-- | libnm/nm-vpn-service-plugin.h | 6 |
3 files changed, 59 insertions, 0 deletions
diff --git a/libnm/libnm.ver b/libnm/libnm.ver index d75d74ea55..3341270c55 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -1189,4 +1189,5 @@ global: nm_setting_wireless_security_pmf_get_type; nm_setting_wireless_security_wps_method_get_type; nm_vpn_plugin_secrets_flags_get_type; + nm_vpn_service_plugin_secrets_required_with_flags; } libnm_1_8_0; diff --git a/libnm/nm-vpn-service-plugin.c b/libnm/nm-vpn-service-plugin.c index 31e1295488..e7f03dac6e 100644 --- a/libnm/nm-vpn-service-plugin.c +++ b/libnm/nm-vpn-service-plugin.c @@ -79,6 +79,7 @@ enum { FAILURE, QUIT, SECRETS_REQUIRED, + SECRETS_REQUIRED_WITH_FLAGS, LAST_SIGNAL }; @@ -703,6 +704,49 @@ nm_vpn_service_plugin_secrets_required (NMVpnServicePlugin *plugin, nmdbus_vpn_plugin_emit_secrets_required (priv->dbus_vpn_service_plugin, message, hints); } +/** + * nm_vpn_service_plugin_secrets_required_with_flags: + * @plugin: the #NMVpnServicePlugin + * @message: an information message about why secrets are required, if any + * @hints: VPN specific secret names for required new secrets + * @flags: flags which modify the behavior of the secrets request. + * + * Called by VPN plugin implementations to signal to NetworkManager that secrets + * are required during the connection process. This signal may be used to + * request new secrets when the secrets originally provided by NetworkManager + * are insufficient, or the VPN process indicates that it needs additional + * information to complete the request. + * + * Since: 1.10 + */ +void +nm_vpn_service_plugin_secrets_required_with_flags (NMVpnServicePlugin *plugin, + const char *message, + const char **hints, + NMVpnPluginSecretsFlags flags) +{ + NMVpnServicePluginPrivate *priv = NM_VPN_SERVICE_PLUGIN_GET_PRIVATE (plugin); + + /* Plugin must be able to accept the new secrets if it calls this method */ + g_return_if_fail (NM_VPN_SERVICE_PLUGIN_GET_CLASS (plugin)->new_secrets); + + /* Plugin cannot call this method if NetworkManager didn't originally call + * ConnectInteractive(). + */ + g_return_if_fail (priv->interactive == TRUE); + + /* Cancel the connect timer since secrets might take a while. It'll + * get restarted when the secrets come back via NewSecrets(). + */ + nm_clear_g_source (&priv->connect_timer); + + g_signal_emit (plugin, signals[SECRETS_REQUIRED_WITH_FLAGS], 0, message, hints, flags); + nmdbus_vpn_plugin_emit_secrets_required_with_flags (priv->dbus_vpn_service_plugin, + message, + hints, + flags); +} + /*****************************************************************************/ #define DATA_KEY_TAG "DATA_KEY=" @@ -1239,6 +1283,14 @@ nm_vpn_service_plugin_class_init (NMVpnServicePluginClass *plugin_class) NULL, G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRV); + signals[SECRETS_REQUIRED_WITH_FLAGS] = + g_signal_new ("secrets-required-with-flags", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, + NULL, + G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_STRV, G_TYPE_UINT); + signals[CONFIG] = g_signal_new ("config", G_OBJECT_CLASS_TYPE (object_class), diff --git a/libnm/nm-vpn-service-plugin.h b/libnm/nm-vpn-service-plugin.h index 329345ea19..c18c392916 100644 --- a/libnm/nm-vpn-service-plugin.h +++ b/libnm/nm-vpn-service-plugin.h @@ -126,6 +126,12 @@ void nm_vpn_service_plugin_secrets_required (NMVpnServicePlugin *p const char *message, const char **hints); +NM_AVAILABLE_IN_1_10 +void nm_vpn_service_plugin_secrets_required_with_flags (NMVpnServicePlugin *plugin, + const char *message, + const char **hints, + NMVpnPluginSecretsFlags flags); + NM_AVAILABLE_IN_1_2 void nm_vpn_service_plugin_set_login_banner (NMVpnServicePlugin *plugin, const char *banner); |