diff options
author | Antti Kaijanmäki <antti@kaijanmaki.net> | 2008-08-18 08:30:28 +0000 |
---|---|---|
committer | Antti Kaijanmäki <antti@kaijanmaki.net> | 2008-08-18 08:30:28 +0000 |
commit | 2c21a2fe6b0498585fba0beb003ac8aa6351803c (patch) | |
tree | 9544edfe2ed9a6c96eda933c35fb5110f1d666c6 /system-settings | |
parent | e04934d93efba622123809cc767488af673b2967 (diff) | |
download | NetworkManager-mbca.tar.gz |
keep up with trunkmbca
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/branches/mbca@3981 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
Diffstat (limited to 'system-settings')
-rw-r--r-- | system-settings/plugins/ifcfg-fedora/shvar.c | 17 | ||||
-rw-r--r-- | system-settings/plugins/ifcfg-fedora/shvar.h | 1 | ||||
-rw-r--r-- | system-settings/plugins/ifcfg-suse/parser.c | 2 | ||||
-rw-r--r-- | system-settings/plugins/keyfile/Makefile.am | 8 | ||||
-rw-r--r-- | system-settings/plugins/keyfile/nm-keyfile-connection.c | 7 | ||||
-rw-r--r-- | system-settings/plugins/keyfile/plugin.c | 8 | ||||
-rw-r--r-- | system-settings/plugins/keyfile/reader.c | 32 | ||||
-rw-r--r-- | system-settings/plugins/keyfile/writer.c | 44 | ||||
-rw-r--r-- | system-settings/plugins/keyfile/writer.h | 2 | ||||
-rw-r--r-- | system-settings/src/dbus-settings.c | 21 | ||||
-rw-r--r-- | system-settings/src/nm-system-config-interface.c | 7 | ||||
-rw-r--r-- | system-settings/src/nm-system-config-interface.h | 7 |
12 files changed, 118 insertions, 38 deletions
diff --git a/system-settings/plugins/ifcfg-fedora/shvar.c b/system-settings/plugins/ifcfg-fedora/shvar.c index 67b3019d48..5ecae90fcd 100644 --- a/system-settings/plugins/ifcfg-fedora/shvar.c +++ b/system-settings/plugins/ifcfg-fedora/shvar.c @@ -121,9 +121,13 @@ unescape(char *s) { len = strlen(s); if ((s[0] == '"' || s[0] == '\'') && s[0] == s[len-1]) { i = len - 2; - memmove(s, s+1, i); - s[i+1] = '\0'; - len = i; + if (i == 0) + s[0] = '\0'; + else { + memmove(s, s+1, i); + s[i+1] = '\0'; + len = i; + } } for (i = 0; i < len; i++) { if (s[i] == '\\') { @@ -291,7 +295,6 @@ svSetValue(shvarFile *s, const char *key, const char *value) /* change/append line to get key= */ if (s->current) s->current->data = keyValue; else s->lineList = g_list_append(s->lineList, keyValue); - s->freeList = g_list_append(s->freeList, keyValue); s->modified = 1; } else if (val1) { /* delete line */ @@ -307,7 +310,6 @@ svSetValue(shvarFile *s, const char *key, const char *value) if (val2 && !strcmp(val2, newval)) goto end; /* append line */ s->lineList = g_list_append(s->lineList, keyValue); - s->freeList = g_list_append(s->freeList, keyValue); s->modified = 1; goto end; } @@ -326,7 +328,6 @@ svSetValue(shvarFile *s, const char *key, const char *value) /* change line */ if (s->current) s->current->data = keyValue; else s->lineList = g_list_append(s->lineList, keyValue); - s->freeList = g_list_append(s->freeList, keyValue); s->modified = 1; } @@ -387,11 +388,7 @@ svCloseFile(shvarFile *s) if (s->fd != -1) close(s->fd); g_free(s->arena); - for (s->current = s->freeList; s->current; s->current = s->current->next) { - g_free(s->current->data); - } g_free(s->fileName); - g_list_free(s->freeList); g_list_foreach (s->lineList, (GFunc) g_free, NULL); g_list_free(s->lineList); /* implicitly frees s->current */ g_free(s); diff --git a/system-settings/plugins/ifcfg-fedora/shvar.h b/system-settings/plugins/ifcfg-fedora/shvar.h index 00e1a8e59f..e01b08d4ae 100644 --- a/system-settings/plugins/ifcfg-fedora/shvar.h +++ b/system-settings/plugins/ifcfg-fedora/shvar.h @@ -42,7 +42,6 @@ struct _shvarFile { int fd; /* read-only */ char *arena; /* ignore */ GList *lineList; /* read-only */ - GList *freeList; /* ignore */ GList *current; /* set implicitly or explicitly, points to element of lineList */ shvarFile *parent; /* set explicitly */ diff --git a/system-settings/plugins/ifcfg-suse/parser.c b/system-settings/plugins/ifcfg-suse/parser.c index 66deec4de8..56f5eccff4 100644 --- a/system-settings/plugins/ifcfg-suse/parser.c +++ b/system-settings/plugins/ifcfg-suse/parser.c @@ -118,7 +118,7 @@ make_ip4_setting (shvarFile *ifcfg) } if (!s_ip4->method) - s_ip4->method = g_strdup (NM_SETTING_IP4_CONFIG_METHOD_DHCP); + s_ip4->method = g_strdup (NM_SETTING_IP4_CONFIG_METHOD_AUTO); str = svGetValue (ifcfg, "IPADDR"); if (str) { diff --git a/system-settings/plugins/keyfile/Makefile.am b/system-settings/plugins/keyfile/Makefile.am index d4e4a4a40e..8a9f22264d 100644 --- a/system-settings/plugins/keyfile/Makefile.am +++ b/system-settings/plugins/keyfile/Makefile.am @@ -11,6 +11,8 @@ libnm_settings_plugin_keyfile_la_SOURCES = \ writer.c \ writer.h +keyfiledir=$(sysconfdir)/NetworkManager/system-connections + libnm_settings_plugin_keyfile_la_CPPFLAGS = \ $(GLIB_CFLAGS) \ $(GMODULE_CFLAGS) \ @@ -20,7 +22,7 @@ libnm_settings_plugin_keyfile_la_CPPFLAGS = \ -I$(top_srcdir)/include \ -I$(top_srcdir)/libnm-util \ -I${top_srcdir}/libnm-glib \ - -DKEYFILE_DIR=\""$(sysconfdir)/NetworkManager/system-connections"\" + -DKEYFILE_DIR=\""$(keyfiledir)"\" libnm_settings_plugin_keyfile_la_LDFLAGS = -module -avoid-version libnm_settings_plugin_keyfile_la_LIBADD = \ @@ -37,3 +39,7 @@ else libnm_settings_plugin_keyfile_la_LIBADD += \ $(GIO_LIBS) endif + +install-data-hook: + $(mkinstalldirs) -m 0755 $(DESTDIR)$(keyfiledir) + diff --git a/system-settings/plugins/keyfile/nm-keyfile-connection.c b/system-settings/plugins/keyfile/nm-keyfile-connection.c index b64f2c9146..3cdfe27d11 100644 --- a/system-settings/plugins/keyfile/nm-keyfile-connection.c +++ b/system-settings/plugins/keyfile/nm-keyfile-connection.c @@ -55,14 +55,13 @@ get_id (NMExportedConnection *exported) static gboolean update (NMExportedConnection *exported, GHashTable *new_settings, - GError **err) + GError **error) { gboolean success; - success = NM_EXPORTED_CONNECTION_CLASS (nm_keyfile_connection_parent_class)->update (exported, new_settings, err); - + success = NM_EXPORTED_CONNECTION_CLASS (nm_keyfile_connection_parent_class)->update (exported, new_settings, error); if (success) - write_connection (nm_exported_connection_get_connection (exported)); + success = write_connection (nm_exported_connection_get_connection (exported), error); return success; } diff --git a/system-settings/plugins/keyfile/plugin.c b/system-settings/plugins/keyfile/plugin.c index 4be851c1d3..eaf780e83e 100644 --- a/system-settings/plugins/keyfile/plugin.c +++ b/system-settings/plugins/keyfile/plugin.c @@ -1,4 +1,4 @@ -/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ #include <config.h> #include <sys/stat.h> @@ -182,9 +182,11 @@ get_connections (NMSystemConfigInterface *config) } static gboolean -add_connection (NMSystemConfigInterface *config, NMConnection *connection) +add_connection (NMSystemConfigInterface *config, + NMConnection *connection, + GError **error) { - return write_connection (connection); + return write_connection (connection, error); } /* GObject */ diff --git a/system-settings/plugins/keyfile/reader.c b/system-settings/plugins/keyfile/reader.c index 14b974ea7c..e43486a209 100644 --- a/system-settings/plugins/keyfile/reader.c +++ b/system-settings/plugins/keyfile/reader.c @@ -8,6 +8,7 @@ #include <dbus/dbus-glib.h> #include <nm-setting.h> #include <nm-setting-ip4-config.h> +#include <nm-setting-vpn.h> #include <arpa/inet.h> #include <string.h> @@ -289,6 +290,32 @@ read_array_of_array_of_uint (GKeyFile *file, } static void +read_hash_of_string (GKeyFile *file, NMSetting *setting, const char *key) +{ + char **keys, **iter; + char *value; + + keys = g_key_file_get_keys (file, setting->name, NULL, NULL); + if (!keys || !*keys) + return; + + for (iter = keys; *iter; iter++) { + value = g_key_file_get_string (file, setting->name, *iter, NULL); + if (!value) + continue; + + if (NM_IS_SETTING_VPN (setting)) { + NMSettingVPN *s_vpn = NM_SETTING_VPN (setting); + + if (strcmp (*iter, NM_SETTING_VPN_SERVICE_TYPE)) + g_hash_table_insert (s_vpn->data, g_strdup (*iter), g_strdup (value)); + } + g_free (value); + } + g_strfreev (keys); +} + +static void read_one_setting_value (NMSetting *setting, const char *key, const GValue *value, @@ -395,9 +422,8 @@ read_one_setting_value (NMSetting *setting, g_slist_free (list); g_strfreev (sa); - } else if (type == dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE)) { - /* FIXME */ - g_warning ("Implement me"); + } else if (type == dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING)) { + read_hash_of_string (file, setting, key); } else if (type == DBUS_TYPE_G_UINT_ARRAY) { if (!read_array_of_uint (file, setting, key)) { g_warning ("Unhandled setting property type (read): '%s/%s' : '%s'", diff --git a/system-settings/plugins/keyfile/writer.c b/system-settings/plugins/keyfile/writer.c index eb5508d5b8..ee229f6220 100644 --- a/system-settings/plugins/keyfile/writer.c +++ b/system-settings/plugins/keyfile/writer.c @@ -7,6 +7,7 @@ #include <nm-setting.h> #include <nm-setting-connection.h> #include <nm-setting-ip4-config.h> +#include <nm-setting-vpn.h> #include <nm-utils.h> #include <string.h> #include <arpa/inet.h> @@ -141,6 +142,42 @@ write_array_of_array_of_uint (GKeyFile *file, return TRUE; } +typedef struct { + GKeyFile *file; + const char *setting_name; +} WriteStringHashInfo; + +static void +write_hash_of_string_helper (gpointer key, gpointer data, gpointer user_data) +{ + WriteStringHashInfo *info = (WriteStringHashInfo *) user_data; + const char *property = (const char *) key; + const char *value = (const char *) data; + + if ( !strcmp (info->setting_name, NM_SETTING_VPN_SETTING_NAME) + && !strcmp (property, NM_SETTING_VPN_SERVICE_TYPE)) + return; + + g_key_file_set_string (info->file, + info->setting_name, + property, + value); +} + +static void +write_hash_of_string (GKeyFile *file, + NMSetting *setting, + const char *key, + const GValue *value) +{ + GHashTable *hash = g_value_get_boxed (value); + WriteStringHashInfo info; + + info.file = file; + info.setting_name = setting->name; + g_hash_table_foreach (hash, write_hash_of_string_helper, &info); +} + static void write_setting_value (NMSetting *setting, const char *key, @@ -208,9 +245,8 @@ write_setting_value (NMSetting *setting, g_key_file_set_string_list (file, setting->name, key, (const gchar **const) array, i); g_free (array); } - } else if (type == dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE)) { - /* FIXME */ - g_warning ("Implement me"); + } else if (type == dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING)) { + write_hash_of_string (file, setting, key, value); } else if (type == DBUS_TYPE_G_UINT_ARRAY) { if (!write_array_of_uint (file, setting, key, value)) { g_warning ("Unhandled setting property type (write) '%s/%s' : '%s'", @@ -228,7 +264,7 @@ write_setting_value (NMSetting *setting, } gboolean -write_connection (NMConnection *connection) +write_connection (NMConnection *connection, GError **error) { NMSettingConnection *s_con; GKeyFile *key_file; diff --git a/system-settings/plugins/keyfile/writer.h b/system-settings/plugins/keyfile/writer.h index 1e5726b9d9..38a20d4e44 100644 --- a/system-settings/plugins/keyfile/writer.h +++ b/system-settings/plugins/keyfile/writer.h @@ -6,6 +6,6 @@ #include <glib.h> #include <nm-connection.h> -gboolean write_connection (NMConnection *connection); +gboolean write_connection (NMConnection *connection, GError **error); #endif /* _KEYFILE_PLUGIN_WRITER_H */ diff --git a/system-settings/src/dbus-settings.c b/system-settings/src/dbus-settings.c index 21c0a448e1..0cb8abcb2c 100644 --- a/system-settings/src/dbus-settings.c +++ b/system-settings/src/dbus-settings.c @@ -1,8 +1,10 @@ -/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ /* NetworkManager system settings service * * Søren Sandmann <sandmann@daimi.au.dk> + * Dan Williams <dcbw@redhat.com> + * Tambet Ingo <tambet@gmail.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,7 +20,8 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * (C) Copyright 2007 Red Hat, Inc. + * (C) Copyright 2007 - 2008 Red Hat, Inc. + * (C) Copyright 2008 Novell, Inc. */ #include <NetworkManager.h> @@ -263,7 +266,9 @@ nm_sysconfig_settings_class_init (NMSysconfigSettingsClass *class) dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (settings_class), &dbus_glib_nm_settings_system_object_info); - dbus_g_error_domain_register (NM_SYSCONFIG_SETTINGS_ERROR, NULL, NM_TYPE_SYSCONFIG_SETTINGS_ERROR); + dbus_g_error_domain_register (NM_SYSCONFIG_SETTINGS_ERROR, + NM_DBUS_IFACE_SETTINGS_SYSTEM, + NM_TYPE_SYSCONFIG_SETTINGS_ERROR); } static void @@ -453,6 +458,8 @@ impl_settings_add_connection (NMSysconfigSettings *self, connection = nm_connection_new_from_hash (hash, &cnfh_error); if (connection) { + GError *add_error = NULL; + /* Here's how it works: 1) plugin writes a connection. 2) plugin notices that a new connection is available for reading. @@ -461,9 +468,12 @@ impl_settings_add_connection (NMSysconfigSettings *self, */ success = FALSE; - for (iter = priv->plugins; iter && success == FALSE; iter = iter->next) + for (iter = priv->plugins; iter && success == FALSE; iter = iter->next) { success = nm_system_config_interface_add_connection (NM_SYSTEM_CONFIG_INTERFACE (iter->data), - connection); + connection, &add_error); + if (!success && add_error) + g_error_free (add_error); + } g_object_unref (connection); @@ -491,3 +501,4 @@ impl_settings_add_connection (NMSysconfigSettings *self, return TRUE; } } + diff --git a/system-settings/src/nm-system-config-interface.c b/system-settings/src/nm-system-config-interface.c index e868bf7fac..3b73730601 100644 --- a/system-settings/src/nm-system-config-interface.c +++ b/system-settings/src/nm-system-config-interface.c @@ -1,4 +1,4 @@ -/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ /* NetworkManager -- Network link manager * * Dan Williams <dcbw@redhat.com> @@ -139,7 +139,8 @@ nm_system_config_interface_supports_add (NMSystemConfigInterface *config) gboolean nm_system_config_interface_add_connection (NMSystemConfigInterface *config, - NMConnection *connection) + NMConnection *connection, + GError **error) { gboolean success = FALSE; @@ -147,7 +148,7 @@ nm_system_config_interface_add_connection (NMSystemConfigInterface *config, g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE); if (NM_SYSTEM_CONFIG_INTERFACE_GET_INTERFACE (config)->add_connection) - success = NM_SYSTEM_CONFIG_INTERFACE_GET_INTERFACE (config)->add_connection (config, connection); + success = NM_SYSTEM_CONFIG_INTERFACE_GET_INTERFACE (config)->add_connection (config, connection, error); return success; } diff --git a/system-settings/src/nm-system-config-interface.h b/system-settings/src/nm-system-config-interface.h index 62306bcda6..4a258e3e99 100644 --- a/system-settings/src/nm-system-config-interface.h +++ b/system-settings/src/nm-system-config-interface.h @@ -60,12 +60,14 @@ GObject * nm_system_config_factory (void); #define NM_SYSTEM_CONFIG_INTERFACE_NAME "name" #define NM_SYSTEM_CONFIG_INTERFACE_INFO "info" +#define NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME "hostname" typedef enum { NM_SYSTEM_CONFIG_INTERFACE_PROP_FIRST = 0x1000, NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME = NM_SYSTEM_CONFIG_INTERFACE_PROP_FIRST, NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO, + NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME, } NMSystemConfigInterfaceProp; @@ -92,7 +94,7 @@ struct _NMSystemConfigInterface { /* * Add a new connection. */ - gboolean (*add_connection) (NMSystemConfigInterface *config, NMConnection *connection); + gboolean (*add_connection) (NMSystemConfigInterface *config, NMConnection *connection, GError **error); /* Signals */ @@ -115,7 +117,8 @@ GSList *nm_system_config_interface_get_unmanaged_devices (NMSystemConfigInterfac gboolean nm_system_config_interface_supports_add (NMSystemConfigInterface *config); gboolean nm_system_config_interface_add_connection (NMSystemConfigInterface *config, - NMConnection *connection); + NMConnection *connection, + GError **error); G_END_DECLS |