Commit ff0468d2 authored by Dan Williams's avatar Dan Williams

2008-05-11 Dan Williams <dcbw@redhat.com>

	Update Fedora system-settings plugin to support latest API and use
	GFileMonitor rather than home-rolled inotify code.

	* system-settings/plugins/ifcfg-fedora/Makefile.am
	  system-settings/plugins/ifcfg-fedora/common.h
	  system-settings/plugins/ifcfg-fedora/plugin.c
		- Update to latest system settings plugin API; use GIO instead of
			custom inotify code; use NMIfcfgConnection objects instead of
			ConnectionData structures tacked onto NMConnection objects

	* system-settings/plugins/ifcfg-fedora/nm-ifcfg-connection.c
	  system-settings/plugins/ifcfg-fedora/nm-ifcfg-connection.h
		- Implement an NMExportedConnection subclass mapping ifcfg files to
			connections

	* system-settings/plugins/ifcfg-fedora/reader.c
	  system-settings/plugins/ifcfg-fedora/reader.h
		- Move ifcfg parsing bits here from parser.c

	* system-settings/plugins/ifcfg-fedora/parser.c
	  system-settings/plugins/ifcfg-fedora/parser.h
		- Remove; most code moved to reader.c



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3656 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
parent e7e51418
2008-05-11 Dan Williams <dcbw@redhat.com>
Update Fedora system-settings plugin to support latest API and use
GFileMonitor rather than home-rolled inotify code.
* system-settings/plugins/ifcfg-fedora/Makefile.am
system-settings/plugins/ifcfg-fedora/common.h
system-settings/plugins/ifcfg-fedora/plugin.c
- Update to latest system settings plugin API; use GIO instead of
custom inotify code; use NMIfcfgConnection objects instead of
ConnectionData structures tacked onto NMConnection objects
* system-settings/plugins/ifcfg-fedora/nm-ifcfg-connection.c
system-settings/plugins/ifcfg-fedora/nm-ifcfg-connection.h
- Implement an NMExportedConnection subclass mapping ifcfg files to
connections
* system-settings/plugins/ifcfg-fedora/reader.c
system-settings/plugins/ifcfg-fedora/reader.h
- Move ifcfg parsing bits here from parser.c
* system-settings/plugins/ifcfg-fedora/parser.c
system-settings/plugins/ifcfg-fedora/parser.h
- Remove; most code moved to reader.c
2008-05-11 Dan Williams <dcbw@redhat.com>
* configure.in
......
......@@ -4,10 +4,13 @@ pkglib_LTLIBRARIES = libnm-settings-plugin-ifcfg-fedora.la
libnm_settings_plugin_ifcfg_fedora_la_SOURCES = \
shvar.c \
shvar.h \
parser.c \
parser.h \
plugin.c \
plugin.h
plugin.h \
nm-ifcfg-connection.c \
nm-ifcfg-connection.h \
reader.c \
reader.h \
common.h
libnm_settings_plugin_ifcfg_fedora_la_CPPFLAGS = \
$(GLIB_CFLAGS) \
......@@ -16,6 +19,7 @@ libnm_settings_plugin_ifcfg_fedora_la_CPPFLAGS = \
-DG_DISABLE_DEPRECATED \
-I${top_srcdir}/system-settings/src \
-I$(top_srcdir)/include \
-I$(top_srcdir)/libnm-glib \
-I$(top_srcdir)/libnm-util \
-DSYSCONFDIR=\"$(sysconfdir)\"
......@@ -23,5 +27,14 @@ libnm_settings_plugin_ifcfg_fedora_la_LDFLAGS = -module -avoid-version
libnm_settings_plugin_ifcfg_fedora_la_LIBADD = \
$(GLIB_LIBS) \
$(GMODULE_LIBS) \
$(top_builddir)/libnm-util/libnm-util.la
$(top_builddir)/libnm-util/libnm-util.la \
$(top_builddir)/libnm-glib/libnm_glib.la
if NO_GIO
libnm_settings_plugin_ifcfg_fedora_la_LIBADD += \
$(top_builddir)/gfilemonitor/libgfilemonitor.la
else
libnm_settings_plugin_ifcfg_fedora_la_LIBADD += \
$(GIO_LIBS)
endif
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager system settings service
*
* Søren Sandmann <sandmann@daimi.au.dk>
*
* 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
......@@ -16,15 +15,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* (C) Copyright 2007 Red Hat, Inc.
* (C) Copyright 2008 Red Hat, Inc.
*/
#ifndef _PARSER_H_
#define _PARSER_H_
#include <glib.h>
#include <nm-connection.h>
#include <nm-setting-ip4-config.h>
#ifndef __COMMON_H__
#define __COMMON_H__
#define IFCFG_TAG "ifcfg-"
#define KEYS_TAG "keys-"
......@@ -33,21 +28,10 @@
#define ORIG_TAG ".orig"
#define REJ_TAG ".rej"
typedef struct {
char *ifcfg_path;
char *udi;
gboolean ignored;
gboolean exported;
#include <glib.h>
GHashTable *wifi_secrets;
GHashTable *onex_secrets;
GHashTable *ppp_secrets;
} ConnectionData;
GQuark ifcfg_plugin_error_quark (void);
NMConnection * parser_parse_file (const char *file, GError **error);
ConnectionData *connection_data_get (NMConnection *connection);
ConnectionData *connection_data_add (NMConnection *connection, const char *ifcfg_path);
void connection_data_copy_secrets (ConnectionData *from, ConnectionData *to);
#endif /* __COMMON_H__ */
#endif /* _PARSER_H_ */
This diff is collapsed.
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager system settings service
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* (C) Copyright 2008 Red Hat, Inc.
*/
#ifndef NM_IFCFG_CONNECTION_H
#define NM_IFCFG_CONNECTION_H
G_BEGIN_DECLS
#include <nm-settings.h>
#include "nm-system-config-hal-manager.h"
#define NM_TYPE_IFCFG_CONNECTION (nm_ifcfg_connection_get_type ())
#define NM_IFCFG_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IFCFG_CONNECTION, NMIfcfgConnection))
#define NM_IFCFG_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_IFCFG_CONNECTION, NMIfcfgConnectionClass))
#define NM_IS_IFCFG_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_IFCFG_CONNECTION))
#define NM_IS_IFCFG_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_IFCFG_CONNECTION))
#define NM_IFCFG_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_IFCFG_CONNECTION, NMIfcfgConnectionClass))
#define NM_IFCFG_CONNECTION_FILENAME "filename"
#define NM_IFCFG_CONNECTION_UNMANAGED "unmanaged"
#define NM_IFCFG_CONNECTION_UDI "udi"
typedef struct {
NMExportedConnection parent;
} NMIfcfgConnection;
typedef struct {
NMExportedConnectionClass parent;
} NMIfcfgConnectionClass;
GType nm_ifcfg_connection_get_type (void);
NMIfcfgConnection *nm_ifcfg_connection_new (const char *filename,
DBusGConnection *g_connection,
NMSystemConfigHalManager *hal_mgr,
GError **error);
const char *nm_ifcfg_connection_get_filename (NMIfcfgConnection *self);
const char *nm_ifcfg_connection_get_udi (NMIfcfgConnection *self);
gboolean nm_ifcfg_connection_get_unmanaged (NMIfcfgConnection *self);
G_END_DECLS
#endif /* NM_IFCFG_CONNECTION_H */
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager system settings service
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* (C) Copyright 2008 Red Hat, Inc.
*/
#ifndef __READER_H__
#define __READER_H__
#include <glib.h>
#include <nm-connection.h>
NMConnection *connection_from_file (const char *filename, gboolean *ignored, GError **error);
#endif /* __READER_H__ */
......@@ -69,6 +69,38 @@ enum {
LAST_PROP
};
static void
load_connections (NMSysconfigSettings *self)
{
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
GSList *iter;
if (priv->connections_loaded)
return;
for (iter = priv->plugins; iter; iter = g_slist_next (iter)) {
NMSystemConfigInterface *plugin = NM_SYSTEM_CONFIG_INTERFACE (iter->data);
GSList *plugin_connections;
GSList *elt;
plugin_connections = nm_system_config_interface_get_connections (plugin);
// FIXME: ensure connections from plugins loaded with a lower priority
// get rejected when they conflict with connections from a higher
// priority plugin.
for (elt = plugin_connections; elt; elt = g_slist_next (elt))
nm_sysconfig_settings_add_connection (self, NM_EXPORTED_CONNECTION (elt->data));
g_slist_free (plugin_connections);
}
/* FIXME: Bad hack */
unmanaged_devices_changed (NULL, self);
priv->connections_loaded = TRUE;
}
static void
hash_keys_to_slist (gpointer key, gpointer val, gpointer user_data)
{
......@@ -84,31 +116,7 @@ list_connections (NMSettings *settings)
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
GSList *list = NULL;
if (!priv->connections_loaded) {
GSList *iter;
for (iter = priv->plugins; iter; iter = g_slist_next (iter)) {
NMSystemConfigInterface *plugin = NM_SYSTEM_CONFIG_INTERFACE (iter->data);
GSList *plugin_connections;
GSList *elt;
plugin_connections = nm_system_config_interface_get_connections (plugin);
// FIXME: ensure connections from plugins loaded with a lower priority
// get rejected when they conflict with connections from a higher
// priority plugin.
for (elt = plugin_connections; elt; elt = g_slist_next (elt))
nm_sysconfig_settings_add_connection (self, NM_EXPORTED_CONNECTION (elt->data));
g_slist_free (plugin_connections);
}
/* FIXME: Bad hack */
unmanaged_devices_changed (NULL, self);
priv->connections_loaded = TRUE;
}
load_connections (self);
g_hash_table_foreach (priv->connections, hash_keys_to_slist, &list);
......@@ -195,6 +203,8 @@ get_unmanaged_devices (NMSysconfigSettings *self)
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
GPtrArray *devices;
load_connections (self);
devices = g_ptr_array_sized_new (3);
g_hash_table_foreach (priv->unmanaged_devices, (GHFunc) add_one_unmanaged_device, devices);
return devices;
......@@ -406,6 +416,9 @@ nm_sysconfig_settings_is_device_managed (NMSysconfigSettings *self,
g_return_val_if_fail (NM_IS_SYSCONFIG_SETTINGS (self), FALSE);
priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
load_connections (self);
if (g_hash_table_lookup (priv->unmanaged_devices, udi))
return FALSE;
return TRUE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment