Commit 0474441e authored by Thomas Haller's avatar Thomas Haller

settings: drop unmaintained ifnet settings plugin of Gentoo

Even Gentoo disables this plugin since before 0.9.8 release
of NetworkManager. Time to say goodbye.

If somebody happens to show up to maintain it, we may resurrect it
later.

If "$distro_plugins=ifnet" was set, configure.ac would use that
to autodetect --with-hostname-persist=gentoo. Replace that autodetect
part by checking for /etc/gentoo-release file.
parent 298d156e
......@@ -256,7 +256,6 @@ test-*.trs
/src/settings/plugins/ibft/tests/test-ibft
/src/settings/plugins/ifcfg-rh/nmdbus-ifcfg-rh.[ch]
/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh
/src/settings/plugins/ifnet/tests/test-ifnet
/src/settings/plugins/ifupdown/tests/test-ifupdown
/src/settings/plugins/keyfile/tests/test-keyfile
/src/settings/plugins/ifcfg-rh/tests/network-scripts/tmp/
......@@ -300,7 +299,6 @@ test-*.trs
/src/dnsmasq-manager/tests/test-dnsmasq-utils
/src/rdisc/
/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh-utils
/src/settings/plugins/ifnet/tests/check_ifnet
/src/supplicant-manager/tests/test-supplicant-config
/introspection/nmdbus-*.c
/introspection/nmdbus-*.h
......@@ -313,3 +311,4 @@ test-*.trs
/libnm-core/tests/test-setting-8021x
/libnm-core/tests/test-setting-bond
/libnm-core/tests/test-setting-dcb
/src/settings/plugins/ifnet
......@@ -18,7 +18,7 @@ before_install:
- sudo apt-get install libnl-3-dev libndp-dev automake libcurl4-gnutls-dev
script: |
sh autogen.sh --with-systemd-logind=no --enable-more-warnings=no --enable-ifcfg-rh --enable-ifupdown --enable-ifnet --enable-tests &&
sh autogen.sh --with-systemd-logind=no --enable-more-warnings=no --enable-ifcfg-rh --enable-ifupdown --enable-tests &&
make -j4 &&
./contrib/travis/travis-check.sh
......
......@@ -123,7 +123,6 @@ DISTCHECK_CONFIGURE_FLAGS = \
--with-wext=no \
--enable-ifcfg-rh \
--enable-ifupdown \
--enable-ifnet \
--disable-dependency-tracking
dist-configure-check:
......@@ -2409,96 +2408,6 @@ EXTRA_DIST += \
src/settings/plugins/ifupdown/tests/test21-source-dir-stanza \
src/settings/plugins/ifupdown/tests/test21-source-dir-stanza.d
###############################################################################
# src/settings/plugins/ifnet
###############################################################################
if CONFIG_PLUGIN_IFNET
core_plugins += src/settings/plugins/ifnet/libnm-settings-plugin-ifnet.la
noinst_LTLIBRARIES += src/settings/plugins/ifnet/libnms-ifnet-core.la
src_settings_plugins_ifnet_cppflags = \
-I$(srcdir)/src \
-I$(srcdir)/shared \
-I$(builddir)/shared \
-I$(srcdir)/libnm-core \
-I$(builddir)/libnm-core \
-DG_LOG_DOMAIN=\""NetworkManager"\" \
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
$(GLIB_CFLAGS) \
-DSYSCONFDIR=\"$(sysconfdir)\" \
-DSBINDIR=\"$(sbindir)\"
src_settings_plugins_ifnet_libnms_ifnet_core_la_SOURCES = \
src/settings/plugins/ifnet/nms-ifnet-net-parser.c\
src/settings/plugins/ifnet/nms-ifnet-net-parser.h\
src/settings/plugins/ifnet/nms-ifnet-connection-parser.c \
src/settings/plugins/ifnet/nms-ifnet-connection-parser.h \
src/settings/plugins/ifnet/nms-ifnet-net-utils.h\
src/settings/plugins/ifnet/nms-ifnet-net-utils.c\
src/settings/plugins/ifnet/nms-ifnet-wpa-parser.h\
src/settings/plugins/ifnet/nms-ifnet-wpa-parser.c
src_settings_plugins_ifnet_libnms_ifnet_core_la_CPPFLAGS = $(src_settings_plugins_ifnet_cppflags)
src_settings_plugins_ifnet_libnm_settings_plugin_ifnet_la_SOURCES = \
src/settings/plugins/ifnet/nms-ifnet-connection.c \
src/settings/plugins/ifnet/nms-ifnet-connection.h \
src/settings/plugins/ifnet/nms-ifnet-plugin.c \
src/settings/plugins/ifnet/nms-ifnet-plugin.h
src_settings_plugins_ifnet_libnm_settings_plugin_ifnet_la_CPPFLAGS = $(src_settings_plugins_ifnet_cppflags)
src_settings_plugins_ifnet_libnm_settings_plugin_ifnet_la_LDFLAGS = \
-module -avoid-version \
-Wl,--version-script="$(srcdir)/linker-script-settings.ver"
src_settings_plugins_ifnet_libnm_settings_plugin_ifnet_la_LIBADD = \
src/settings/plugins/ifnet/libnms-ifnet-core.la
check-local-symbols-settings-ifnet: src/settings/plugins/ifnet/libnm-settings-plugin-ifnet.la
$(call check_so_symbols,$(builddir)/src/settings/plugins/ifnet/.libs/libnm-settings-plugin-ifnet.so)
check_local += check-local-symbols-settings-ifnet
###############################################################################
check_programs += src/settings/plugins/ifnet/tests/test-ifnet
src_settings_plugins_ifnet_tests_test_ifnet_CPPFLAGS = \
-I$(srcdir)/shared \
-I$(builddir)/shared \
-I$(srcdir)/libnm-core \
-I$(builddir)/libnm-core \
-I$(srcdir)/src \
-DG_LOG_DOMAIN=\""NetworkManager"\" \
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
$(GLIB_CFLAGS) \
$(CODE_COVERAGE_CFLAGS) \
-DTEST_IFNET_DIR=\"$(abs_srcdir)/src/settings/plugins/ifnet/tests\" \
-DTEST_SCRATCH_DIR=\"$(abs_builddir)/src/settings/plugins/ifnet/tests/\" \
-DTEST_WPA_SUPPLICANT_CONF='"$(srcdir)/src/settings/plugins/ifnet/tests/wpa_supplicant.conf"' \
-DSYSCONFDIR=\"nonexistent\"
src_settings_plugins_ifnet_tests_test_ifnet_LDFLAGS = \
$(GLIB_LDFLAGS)
$(CODE_COVERAGE_LDFLAGS)
src_settings_plugins_ifnet_tests_test_ifnet_LDADD = \
src/settings/plugins/ifnet/libnms-ifnet-core.la \
src/libNetworkManagerTest.la
endif
EXTRA_DIST += \
src/settings/plugins/ifnet/tests/net \
src/settings/plugins/ifnet/tests/net.all \
src/settings/plugins/ifnet/tests/nm-system-settings.conf \
src/settings/plugins/ifnet/tests/wpa_supplicant.conf \
src/settings/plugins/ifnet/tests/test_ca_cert.pem
###############################################################################
# src/devices/adsl
###############################################################################
......
......@@ -121,24 +121,20 @@ AC_CHECK_FUNCS([__secure_getenv secure_getenv])
AC_ARG_ENABLE(config-plugin-ibft, AS_HELP_STRING([--enable-config-plugin-ibft], [enable ibft configuration plugin]))
AC_ARG_ENABLE(ifcfg-rh, AS_HELP_STRING([--enable-ifcfg-rh], [enable ifcfg-rh configuration plugin (Fedora/RHEL)]))
AC_ARG_ENABLE(ifupdown, AS_HELP_STRING([--enable-ifupdown], [enable ifupdown configuration plugin (Debian/Ubuntu)]))
AC_ARG_ENABLE(ifnet, AS_HELP_STRING([--enable-ifnet], [enable ifnet configuration plugin (Gentoo)]))
# Default alternative plugins by distribution
AS_IF([test -z "$enable_ifcfg_rh"], AC_CHECK_FILE(/etc/redhat-release, enable_ifcfg_rh=yes))
AS_IF([test -z "$enable_ifcfg_rh"], AC_CHECK_FILE(/etc/fedora-release, enable_ifcfg_rh=yes))
AS_IF([test -z "$enable_ifcfg_rh"], AC_CHECK_FILE(/etc/mandriva-release, enable_ifcfg_rh=yes))
AS_IF([test -z "$enable_ifupdown"], AC_CHECK_FILE(/etc/debian_version, enable_ifupdown=yes))
AS_IF([test -z "$enable_ifnet"], AC_CHECK_FILE(/etc/gentoo-release, enable_ifnet=yes))
# Otherwise plugins default to "no"
AS_IF([test -z "$enable_ifcfg_rh"], enable_ifcfg_rh=no)
AS_IF([test -z "$enable_ifupdown"], enable_ifupdown=no)
AS_IF([test -z "$enable_ifnet"], enable_ifnet=no)
# Enable ibft by default
AS_IF([test -z "$enable_config_plugin_ibft"], enable_config_plugin_ibft="yes")
# Create automake conditionals
AM_CONDITIONAL(CONFIG_PLUGIN_IBFT, test "$enable_config_plugin_ibft" = "yes")
AM_CONDITIONAL(CONFIG_PLUGIN_IFCFG_RH, test "$enable_ifcfg_rh" = "yes")
AM_CONDITIONAL(CONFIG_PLUGIN_IFUPDOWN, test "$enable_ifupdown" = "yes")
AM_CONDITIONAL(CONFIG_PLUGIN_IFNET, test "$enable_ifnet" = "yes")
AC_ARG_WITH(config-plugins-default,
AS_HELP_STRING([--with-config-plugins-default=PLUGINS],
......@@ -148,14 +144,12 @@ if test -z "$config_plugins_default" -o "$config_plugins_default" = no; then
config_plugins_default=''
test "$enable_ifcfg_rh" = "yes" && config_plugins_default="$config_plugins_default,ifcfg-rh"
test "$enable_ifupdown" = "yes" && config_plugins_default="$config_plugins_default,ifupdown"
test "$enable_ifnet" = "yes" && config_plugins_default="$config_plugins_default,ifnet"
test "$enable_config_plugin_ibft" = "yes" && config_plugins_default="$config_plugins_default,ibft"
config_plugins_default="${config_plugins_default#,}"
fi
test "$enable_ifcfg_rh" = "yes" && distro_plugins="$distro_plugins,ifcfg-rh"
test "$enable_ifupdown" = "yes" && distro_plugins="$distro_plugins,ifupdown"
test "$enable_ifnet" = "yes" && distro_plugins="$distro_plugins,ifnet"
distro_plugins="${distro_plugins#,}"
AC_DEFINE_UNQUOTED(NM_CONFIG_DEFAULT_MAIN_PLUGINS, "$config_plugins_default", [Default configuration option for main.plugins setting])
......@@ -409,7 +403,7 @@ AS_IF([test "$with_hostname_persist" = "slackware"], hostname_persist=slackware)
AS_IF([test "$with_hostname_persist" = "default"], hostname_persist=default)
# if the method was not explicitly set, try to guess it from the enabled plugins
AS_IF([test -z "$hostname_persist" -a -f /etc/SuSE-release], hostname_persist=suse)
AS_IF([test -z "$hostname_persist" -a "$distro_plugins" = "ifnet"], hostname_persist=gentoo)
AS_IF([test -z "$hostname_persist" -a -f /etc/gentoo-release], hostname_persist=gentoo)
AS_IF([test -z "$hostname_persist" -a -f /etc/slackware-version], hostname_persist=slackware)
AS_IF([test -z "$hostname_persist"], hostname_persist=default)
......@@ -1417,7 +1411,6 @@ echo "Configuration plugins (main.plugins=${config_plugins_default})"
echo " ibft: ${enable_config_plugin_ibft}"
echo " ifcfg-rh: ${enable_ifcfg_rh}"
echo " ifupdown: ${enable_ifupdown}"
echo " ifnet: ${enable_ifnet}"
echo
echo "Handlers for /etc/resolv.conf:"
......
......@@ -131,7 +131,6 @@ if [[ $NO_DIST != 1 ]]; then
--enable-ifcfg-rh \
--enable-ifupdown \
--enable-ibft \
--enable-ifnet \
--with-config-logging-backend-default=syslog \
--with-libaudit=yes-disabled-by-default \
--enable-polkit=yes \
......
......@@ -1235,25 +1235,16 @@ enable=nm-version-min:1.3,nm-version-min:1.2.6,nm-version-min:1.0.16
</varlistentry>
<varlistentry>
<term><varname>ifcfg-suse</varname></term>
<term><varname>ifcfg-suse</varname>, <varname>ifnet</varname></term>
<listitem>
<para>
This plugin is deprecated and its selection has no effect.
These plugins are deprecated and their selection has no effect.
The <literal>keyfile</literal> plugin should be used
instead.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>ifnet</varname></term>
<listitem>
<para>
This plugin was used on Gentoo but is deprecated.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
......
......@@ -222,7 +222,6 @@ endif
enable_ifcfg_rh = get_option('ifcfg_rh') or (distro == 'redhat')
enable_ifupdown = get_option('ifupdown') or (distro == 'debian')
enable_ifnet = get_option('ifnet') or (distro == 'gentoo')
enable_config_plugin_ibft = get_option('config_plugin_ibft')
config_h.set10('WITH_SETTINGS_PLUGIN_IBFT', enable_config_plugin_ibft)
......@@ -239,10 +238,6 @@ if config_plugins_default == ''
config_plugins += ['ifupdown']
endif
if enable_ifnet
config_plugins += ['ifnet']
endif
if enable_config_plugin_ibft
config_plugins += ['ibft']
endif
......@@ -972,7 +967,6 @@ output += '\nConfiguration_plugins (main.plugins=' + config_plugins_default + ')
output += ' ibft: ' + enable_config_plugin_ibft.to_string() + '\n'
output += ' ifcfg-rh: ' + enable_ifcfg_rh.to_string() + '\n'
output += ' ifupdown: ' + enable_ifupdown.to_string() + '\n'
output += ' ifnet: ' + enable_ifnet.to_string() + '\n'
output += '\nHandlers for /etc/resolv.conf:\n'
output += ' resolvconf: ' + enable_resolvconf.to_string()
if enable_resolvconf
......
......@@ -47,7 +47,6 @@ option('config_plugins_default', type: 'string', value: '', description: 'Defaul
option('config_plugin_ibft', type: 'boolean', value: true, description: 'enable ibft configuration plugin')
option('ifcfg_rh', type: 'boolean', value: false, description: 'enable ifcfg-rh configuration plugin (Fedora/RHEL)')
option('ifupdown', type: 'boolean', value: false, description: 'enable ifupdown configuration plugin (Debian/Ubuntu)')
option('ifnet', type: 'boolean', value: false, description: 'enable ifnet configuration plugin (Gentoo)')
# handlers for resolv.conf
option('resolvconf', type: 'array', value: ['resolvconf', '/sbin/resolvconf', '/usr/sbin/resolvconf', '/usr/local/sbin/resolvconf'], description: 'Enable resolvconf support')
......
......@@ -57,7 +57,6 @@
#define NM_CONFIG_KEYFILE_GROUP_KEYFILE "keyfile"
#define NM_CONFIG_KEYFILE_GROUP_IFUPDOWN "ifupdown"
#define NM_CONFIG_KEYFILE_GROUP_IFNET "ifnet"
#define NM_CONFIG_KEYFILE_KEY_MAIN_AUTH_POLKIT "auth-polkit"
#define NM_CONFIG_KEYFILE_KEY_MAIN_AUTOCONNECT_RETRIES_DEFAULT "autoconnect-retries-default"
......
......@@ -677,8 +677,8 @@ load_plugins (NMSettings *self, const char **plugins, GError **error)
continue;
}
if (!strcmp (pname, "ifcfg-suse")) {
_LOGW ("skipping deprecated plugin ifcfg-suse");
if (NM_IN_STRSET (pname, "ifcfg-suse", "ifnet")) {
_LOGW ("skipping deprecated plugin %s", pname);
continue;
}
......
sources = files(
'nms-ifnet-connection-parser.c',
'nms-ifnet-net-parser.c',
'nms-ifnet-net-utils.c',
'nms-ifnet-wpa-parser.c'
)
cflags = [
'-DSBINDIR="@0@"'.format(nm_sbindir),
'-DSYSCONFDIR="@0@"'.format(nm_sysconfdir)
]
libnms_ifnet_core = static_library(
'nms-ifnet-core',
sources: sources,
dependencies: core_dep,
c_args: cflags
)
sources = files(
'nms-ifnet-connection.c',
'nms-ifnet-plugin.c'
)
ldflags = []
if have_version_script
ldflags += '-Wl,--version-script,@0@'.format(linker_script_settings)
endif
libnm_settings_plugin_ifnet = shared_module(
'nm-settings-plugin-ifnet',
sources: sources,
dependencies: core_dep,
c_args: cflags,
link_with: libnms_ifnet_core,
link_args: ldflags,
link_depends: linker_script_settings,
install: true,
install_dir: nm_pkglibdir
)
core_plugins += libnm_settings_plugin_ifnet
# FIXME: check_so_symbols replacement
'''
run_target(
'check-local-symbols-settings-ifnet',
command: [check_so_symbols, libnm_settings_plugin_ifnet.full_path()],
depends: libnm_settings_plugin_ifnet
)
check-local-symbols-settings-ifnet: src/settings/plugins/ifnet/libnm-settings-plugin-ifnet.la
$(call check_so_symbols,$(builddir)/src/settings/plugins/ifnet/.libs/libnm-settings-plugin-ifnet.so)
'''
if enable_tests
subdir('tests')
endif
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
* Mu Qiao <qiaomuf@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
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 1999-2010 Gentoo Foundation, Inc.
*/
#ifndef _CONNECTION_PARSER_H
#define _CONNECTION_PARSER_H
#include "nm-connection.h"
#include "nms-ifnet-net-parser.h"
gboolean ifnet_can_write_connection (NMConnection *connection, GError **error);
NMConnection *ifnet_update_connection_from_config_block (const char *conn_name,
const char *basepath,
GError **error);
/* nm_conn_name is used to update nm_ifnet_connection's priv data */
gboolean ifnet_update_parsers_by_connection (NMConnection *connection,
const char *conn_name,
const char *config_file,
const char *wpa_file,
gchar **out_new_name,
gchar **out_backup,
GError **error);
gboolean ifnet_delete_connection_in_parsers (const char *conn_name,
const char *config_file,
const char *wpa_file,
gchar **out_backup);
gboolean ifnet_add_new_connection (NMConnection *connection,
const char *config_file,
const char *wpa_file,
gchar **out_new_name,
gchar **out_backup,
GError ** error);
#endif
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
* Mu Qiao <qiaomuf@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
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 1999-2010 Gentoo Foundation, Inc.
*/
#include "nm-default.h"
#include "nms-ifnet-connection.h"
#include <string.h>
#include <glib/gstdio.h>
#include "nm-dbus-interface.h"
#include "nm-utils.h"
#include "nm-setting-wireless-security.h"
#include "settings/nm-settings-connection.h"
#include "settings/nm-settings-plugin.h"
#include "nms-ifnet-connection-parser.h"
#include "nms-ifnet-net-parser.h"
#include "nms-ifnet-net-utils.h"
#include "nms-ifnet-wpa-parser.h"
#include "nms-ifnet-plugin.h"
/*****************************************************************************/
enum {
IFNET_SETUP_MONITORS,
IFNET_CANCEL_MONITORS,
IFNET_LAST_SIGNAL
};
static guint signals[IFNET_LAST_SIGNAL] = { 0 };
typedef struct {
gchar *conn_name;
NMSettingsPlugin *config;
} NMIfnetConnectionPrivate;
struct _NMIfnetConnection {
NMSettingsConnection parent;
NMIfnetConnectionPrivate _priv;
};
struct _NMIfnetConnectionClass {
NMSettingsConnectionClass parent;
};
G_DEFINE_TYPE (NMIfnetConnection, nm_ifnet_connection, NM_TYPE_SETTINGS_CONNECTION)
#define NM_IFNET_CONNECTION_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMIfnetConnection, NM_IS_IFNET_CONNECTION)
/*****************************************************************************/
const char *
nm_ifnet_connection_get_conn_name (NMIfnetConnection *connection)
{
return NM_IFNET_CONNECTION_GET_PRIVATE (connection)->conn_name;
}
static gboolean
commit_changes (NMSettingsConnection *connection,
NMConnection *new_connection,
NMSettingsConnectionCommitReason commit_reason,
NMConnection **out_reread_connection,
char **out_logmsg_change,
GError **error)
{
NMIfnetConnectionPrivate *priv = NM_IFNET_CONNECTION_GET_PRIVATE ((NMIfnetConnection *) connection);
char *new_name = NULL;
gboolean success = FALSE;
gboolean added = FALSE;
nm_assert (out_reread_connection && !*out_reread_connection);
nm_assert (!out_logmsg_change || !*out_logmsg_change);
g_signal_emit (connection, signals[IFNET_CANCEL_MONITORS], 0);
if (priv->conn_name) {
success = ifnet_update_parsers_by_connection (new_connection,
priv->conn_name,
CONF_NET_FILE,
WPA_SUPPLICANT_CONF,
&new_name,
NULL,
error);
} else {
added = TRUE;
success = ifnet_add_new_connection (new_connection,
CONF_NET_FILE,
WPA_SUPPLICANT_CONF,
&new_name,
NULL,
error);
}
g_assert (!!success == (new_name != NULL));
if (success) {
g_free (priv->conn_name);
priv->conn_name = new_name;
}
reload_parsers ();
g_signal_emit (connection, signals[IFNET_SETUP_MONITORS], 0);
if (success) {
NM_SET_OUT (out_logmsg_change,
g_strdup_printf ("ifcfg-rh: %s %s",
added ? "persist" : "updated",
new_name));
}
return success;
}
static gboolean
delete (NMSettingsConnection *connection,
GError **error)
{
NMIfnetConnectionPrivate *priv = NM_IFNET_CONNECTION_GET_PRIVATE ((NMIfnetConnection *) connection);
/* Only connections which exist in /etc/conf.d/net will have a conn_name */
if (priv->conn_name) {
g_signal_emit (connection, signals[IFNET_CANCEL_MONITORS], 0);
if (!ifnet_delete_connection_in_parsers (priv->conn_name, CONF_NET_FILE, WPA_SUPPLICANT_CONF, NULL)) {
nm_log_warn (LOGD_SETTINGS, "Failed to delete %s", priv->conn_name);
reload_parsers ();
/* let's not return an error. */
}
g_signal_emit (connection, signals[IFNET_SETUP_MONITORS], 0);
}
return TRUE;
}
/*****************************************************************************/
static void
nm_ifnet_connection_init (NMIfnetConnection * connection)
{
}
NMIfnetConnection *
nm_ifnet_connection_new (NMConnection *source, const char *conn_name)
{
NMConnection *tmp;
GObject *object;
GError *error = NULL;
gboolean update_unsaved = TRUE;
g_return_val_if_fail (source || conn_name, NULL);
if (source)
tmp = g_object_ref (source);
else {
tmp = ifnet_update_connection_from_config_block (conn_name, NULL, &error);
if (!tmp) {
nm_log_warn (LOGD_SETTINGS, "Could not read connection '%s': %s",
conn_name, error->message);
g_error_free (error);
return NULL;
}
/* If we just read the connection from disk, it's clearly not Unsaved */
update_unsaved = FALSE;
}
object = (GObject *) g_object_new (NM_TYPE_IFNET_CONNECTION, NULL);
NM_IFNET_CONNECTION_GET_PRIVATE ((NMIfnetConnection *) object)->conn_name = g_strdup (conn_name);
if (!nm_settings_connection_update (NM_SETTINGS_CONNECTION (object),
tmp,
update_unsaved
? NM_SETTINGS_CONNECTION_PERSIST_MODE_UNSAVED
: NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP_SAVED,
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
NULL,
NULL)) {
g_object_unref (object);
return NULL;
}
g_object_unref (tmp);
return NM_IFNET_CONNECTION (object);
}
static void
finalize (GObject * object)
{
g_free (NM_IFNET_CONNECTION_GET_PRIVATE ((NMIfnetConnection *) object)->conn_name);
G_OBJECT_CLASS (nm_ifnet_connection_parent_class)->finalize (object);
}
static void
nm_ifnet_connection_class_init (NMIfnetConnectionClass * ifnet_connection_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (ifnet_connection_class);
NMSettingsConnectionClass *settings_class = NM_SETTINGS_CONNECTION_CLASS (ifnet_connection_class);
object_class->finalize = finalize;
settings_class->delete = delete;
settings_class->commit_changes = commit_changes;
signals[IFNET_SETUP_MONITORS] =
g_signal_new ("ifnet_setup_monitors",
G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST,
0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
signals[IFNET_CANCEL_MONITORS] =
g_signal_new ("ifnet_cancel_monitors",
G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST,
0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
}
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
* Mu Qiao <qiaomuf@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
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 1999-2010 Gentoo Foundation, Inc.
*/
#ifndef __NETWORKMANAGER_IFNET_CONNECTION_H__
#define __NETWORKMANAGER_IFNET_CONNECTION_H__
#include "settings/nm-settings-connection.h"
#include "nms-ifnet-net-parser.h"
#define NM_TYPE_IFNET_CONNECTION (nm_ifnet_connection_get_type ())
#define NM_IFNET_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IFNET_CONNECTION, NMIfnetConnection))
#define NM_IFNET_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_IFNET_CONNECTION, NMIfnetConnectionClass))
#define NM_IS_IFNET_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_IFNET_CONNECTION))
#define NM_IS_IFNET_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_IFNET_CONNECTION))
#define NM_IFNET_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_IFNET_CONNECTION, NMIfnetConnectionClass))
typedef struct _NMIfnetConnection NMIfnetConnection;
typedef struct _NMIfnetConnectionClass NMIfnetConnectionClass;
GType nm_ifnet_connection_get_type (void);
NMIfnetConnection *nm_ifnet_connection_new (NMConnection *source,
const char *conn_name);
const char *nm_ifnet_connection_get_conn_name (NMIfnetConnection *connection);
#endif /* __NETWORKMANAGER_IFNET_CONNECTION_H__ */
This diff is collapsed.
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
* Mu Qiao <qiaomuf@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
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 1999-2010 Gentoo Foundation, Inc.
*/
#ifndef _NET_PARSER_H
#define _NET_PARSER_H
#define CONF_NET_FILE SYSCONFDIR "/conf.d/net"
gboolean ifnet_init (gchar * config_file);
void ifnet_destroy (void);
/* Reader functions */
GList *ifnet_get_connection_names (void);
const char *ifnet_get_data (const char *conn_name, const char *key);
const char *ifnet_get_global_data (const char *key);
gboolean ifnet_has_network (const char *conn_name);
/* Writer functions */
gboolean ifnet_flush_to_file (const char *config_file, gchar **out_backup);
void ifnet_set_data (const char *conn_name, const char *key, const char *value);
gboolean ifnet_add_network (const char *name, const char *type);
gboolean ifnet_delete_network (const char *conn_name);
#endif
This diff is collapsed.
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
* Mu Qiao <qiaomuf@gmail.com>
</