libnm/vpn: lookup nm_vpn_plugin_info_supports_multiple() from cached values

Instead of looking into the keyfile, lookup the "supports-multiple-connections" setting
in the "keys" hash. This has some behavioral difference:

  - g_key_file_get_boolean() first does g_key_file_get_value(), and then
    converts the string using the private g_key_file_parse_value_as_boolean()
    function -- which is case-sensitive, accepts "true|false|0|1" and
    considers only the text until the first whitespace.

  - now, we put g_key_file_get_string() into the cache "keys" and
    parse it with _nm_utils_ascii_str_to_bool(). The latter is
    case insensitive, allows also "yes|no|on|off", strips whitespaces.

However, the difference is subtle and shouldn't matter.

The point of this change is to free "keyfile" after construction.

(cherry picked from commit 6878999ca3)
This commit is contained in:
Thomas Haller 2016-04-18 17:14:00 +02:00
parent 7e41c15ace
commit f25a8fee7e

View file

@ -620,12 +620,12 @@ nm_vpn_plugin_info_get_program (NMVpnPluginInfo *self)
gboolean
nm_vpn_plugin_info_supports_multiple (NMVpnPluginInfo *self)
{
const char *s;
g_return_val_if_fail (NM_IS_VPN_PLUGIN_INFO (self), FALSE);
return g_key_file_get_boolean (NM_VPN_PLUGIN_INFO_GET_PRIVATE (self)->keyfile,
NM_VPN_PLUGIN_INFO_KF_GROUP_CONNECTION,
"supports-multiple-connections",
NULL);
s = nm_vpn_plugin_info_lookup_property (self, NM_VPN_PLUGIN_INFO_KF_GROUP_CONNECTION, "supports-multiple-connections");
return _nm_utils_ascii_str_to_bool (s, FALSE);
}