NetworkManager r3435 - in trunk: . system-settings/plugins/ifcfg-fedora
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: NetworkManager r3435 - in trunk: . system-settings/plugins/ifcfg-fedora
- Date: Wed, 12 Mar 2008 18:32:46 +0000 (GMT)
Author: dcbw
Date: Wed Mar 12 18:32:46 2008
New Revision: 3435
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=3435&view=rev
Log:
2008-03-12 Dan Williams <dcbw redhat com>
* system-settings/plugins/ifcfg-fedora/plugin.c
- (write_auto_wired_connection): new function; write out an auto
wired connection file since the applet isn't doing it any more
- (reload_all_connections): write out the auto wired connection file
if there aren't any wired connections already
- (init): don't leak a GError
Modified:
trunk/ChangeLog
trunk/system-settings/plugins/ifcfg-fedora/plugin.c
Modified: trunk/system-settings/plugins/ifcfg-fedora/plugin.c
==============================================================================
--- trunk/system-settings/plugins/ifcfg-fedora/plugin.c (original)
+++ trunk/system-settings/plugins/ifcfg-fedora/plugin.c Wed Mar 12 18:32:46 2008
@@ -28,6 +28,7 @@
#include <errno.h>
#include <nm-setting-connection.h>
+#include <nm-setting-wired.h>
#include <nm-setting-wireless-security.h>
#include "plugin.h"
@@ -89,6 +90,32 @@
return path;
}
+#define AUTO_WIRED_STAMP_FILE SYSCONFDIR"/NetworkManager/auto-wired-stamp"
+#define AUTO_WIRED_FILE_NAME _("ifcfg-Auto Wired")
+static void
+write_auto_wired_connection (const char *profile_path)
+{
+ GError *error = NULL;
+ char *path;
+ const char *contents = "# Written by nm-system-settings\nTYPE=Ethernet\nBOOTPROTO=dhcp\nONBOOT=yes\nUSERCTL=yes\nPEERDNS=yes\n";
+
+ /* Write out a default autoconnect ethernet connection */
+ if (g_file_test (AUTO_WIRED_STAMP_FILE, G_FILE_TEST_EXISTS) || !profile_path)
+ return;
+
+ path = g_strdup_printf ("%s/%s", profile_path, AUTO_WIRED_FILE_NAME);
+ if (g_file_test (path, G_FILE_TEST_EXISTS))
+ return;
+
+ PLUGIN_PRINT (IFCFG_PLUGIN_NAME, "writing default Auto Wired connection");
+ if (!g_file_set_contents (path, contents, -1, &error)) {
+ PLUGIN_WARN (IFCFG_PLUGIN_NAME, "could not write default wired connection: %s (%d).", error->message, error->code);
+ g_error_free (error);
+ } else {
+ g_file_set_contents (AUTO_WIRED_STAMP_FILE, "", -1, NULL);
+ }
+}
+
struct FindInfo {
const char *path;
gboolean found;
@@ -287,6 +314,8 @@
reload_all_connections (SCPluginIfcfg *plugin)
{
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin);
+ GSList *iter;
+ gboolean have_wired = FALSE;
clear_all_connections (plugin);
@@ -294,6 +323,19 @@
/* Add connections from the current profile */
priv->connections = get_connections_for_profile (priv->profile, priv->ifd, priv->watch_table);
+
+ /* Check if we need to write out the auto wired connection */
+ for (iter = priv->connections; iter; iter = g_slist_next (iter)) {
+ NMConnection *connection = NM_CONNECTION (iter->data);
+ NMSettingConnection *s_con;
+
+ s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+ if (!strcmp (s_con->type, NM_SETTING_WIRED_SETTING_NAME))
+ have_wired = TRUE;
+ }
+
+ if (!have_wired)
+ write_auto_wired_connection (priv->profile);
}
static GSList *
@@ -716,6 +758,7 @@
if (!sc_plugin_inotify_init (plugin, &error)) {
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, " inotify error: %s",
error->message ? error->message : "(unknown)");
+ g_error_free (error);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]