Replace pcf_file_* functions by the corresponding functions in glib.
Signed-off-by: Murilo Opsfelder Araujo
---
properties/Makefile.am |2 -
properties/nm-vpnc.c | 201 --
properties/pcf-file.c | 287
properties/pcf-file.h | 56 --
4 files changed, 95 insertions(+), 451 deletions(-)
delete mode 100644 properties/pcf-file.c
delete mode 100644 properties/pcf-file.h
diff --git a/properties/Makefile.am b/properties/Makefile.am
index c7d17ad..3d83a55 100644
--- a/properties/Makefile.am
+++ b/properties/Makefile.am
@@ -6,8 +6,6 @@ plugindir = $(libdir)/NetworkManager
plugin_LTLIBRARIES = libnm-vpnc-properties.la
libnm_vpnc_properties_la_SOURCES = \
- pcf-file.c \
- pcf-file.h \
nm-vpnc.c \
nm-vpnc.h
diff --git a/properties/nm-vpnc.c b/properties/nm-vpnc.c
index 34f4fc0..81025d8 100644
--- a/properties/nm-vpnc.c
+++ b/properties/nm-vpnc.c
@@ -48,7 +48,6 @@
#include
#include "src/nm-vpnc-service.h"
-#include "pcf-file.h"
#include "nm-vpnc.h"
#define VPNC_PLUGIN_NAME_("Cisco Compatible VPN (vpnc)")
@@ -1161,15 +1160,17 @@ import (NMVpnPluginUiInterface *iface, const char
*path, GError **error)
NMConnection *connection;
NMSettingConnection *s_con;
NMSettingVPN *s_vpn;
- GHashTable *pcf;
- const char *buf;
+ NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE;
+ GKeyFile *keyfile;
+ GKeyFileFlags keyfile_flags;
+ char *buf;
gboolean bool_value;
NMSettingIP4Config *s_ip4;
gint val;
- gboolean found;
- pcf = pcf_file_load (path);
- if (!pcf) {
+ keyfile = g_key_file_new ();
+ keyfile_flags = G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS;
+ if (!g_key_file_load_from_file (keyfile, path, keyfile_flags, error)) {
g_set_error (error, 0, 0, "does not look like a %s VPN
connection (parse failed)",
VPNC_PLUGIN_NAME);
return NULL;
@@ -1187,7 +1188,8 @@ import (NMVpnPluginUiInterface *iface, const char *path,
GError **error)
nm_connection_add_setting (connection, NM_SETTING (s_ip4));
/* Gateway */
- if (pcf_file_lookup_string (pcf, "main", "Host", &buf))
+ buf = g_key_file_get_string (keyfile, "main", "Host", error);
+ if (buf)
nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_GATEWAY, buf);
else {
g_set_error (error, 0, 0, "does not look like a %s VPN
connection (no Host)",
@@ -1197,7 +1199,8 @@ import (NMVpnPluginUiInterface *iface, const char *path,
GError **error)
}
/* Group name */
- if (pcf_file_lookup_string (pcf, "main", "GroupName", &buf))
+ buf = g_key_file_get_string (keyfile, "main", "GroupName", error);
+ if (buf)
nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_ID, buf);
else {
g_set_error (error, 0, 0, "does not look like a %s VPN
connection (no GroupName)",
@@ -1209,13 +1212,16 @@ import (NMVpnPluginUiInterface *iface, const char
*path, GError **error)
/* Optional settings */
/* Connection name */
- if (pcf_file_lookup_string (pcf, "main", "Description", &buf))
+ buf = g_key_file_get_string (keyfile, "main", "Description", NULL);
+ if (buf)
g_object_set (s_con, NM_SETTING_CONNECTION_ID, buf, NULL);
- if (pcf_file_lookup_string (pcf, "main", "UserName", &buf))
+ buf = g_key_file_get_string (keyfile, "main", "Username", NULL);
+ if (buf)
nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_XAUTH_USER,
buf);
- if (pcf_file_lookup_string (pcf, "main", "UserPassword", &buf)) {
+ buf = g_key_file_get_string (keyfile, "main", "UserPassword", NULL);
+ if (buf) {
nm_setting_vpn_add_secret (s_vpn, NM_VPNC_KEY_XAUTH_PASSWORD,
buf);
nm_setting_set_secret_flags (NM_SETTING (s_vpn),
NM_VPNC_KEY_XAUTH_PASSWORD,
@@ -1223,23 +1229,21 @@ import (NMVpnPluginUiInterface *iface, const char
*path, GError **error)
NULL);
}
- if (pcf_file_lookup_bool (pcf, "main", "SaveUserPassword",
&bool_value)) {
- NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_AGENT_OWNED;
-
- if (bool_value) {
- nm_setting_vpn_add_data_item (s_vpn,
-
NM_VPNC_KEY_XAUTH_PASSWORD_TYPE,
- NM_VPNC_PW_TYPE_SAVE);
- } else
- flags |= NM_SETTING_SECRET_FLAG_NOT_SAVED;
-
- nm_setting_set_secret_flags (NM_SETTING (s_vpn),
-NM_VPNC_KEY_XAUTH_PASSWORD,
-