Commit 9e53dc83 authored by Dan Williams's avatar Dan Williams

2007-11-27 Dan Williams <dcbw@redhat.com>

	* system-settings/plugins/ifcfg/Makefile.am
	  system-settings/plugins/ifcfg/parser.c
	  system-settings/plugins/ifcfg/parser.h
	  system-settings/plugins/ifcfg/plugin.c
		- Parse wireless connections too

	* system-settings/src/dbus-settings.c
	  system-settings/src/dbus-settings.h
	  system-settings/src/main.c
		- Handle connection update/removal if the plugin supports it



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3112 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
parent 7f214762
2007-11-27 Dan Williams <dcbw@redhat.com>
* system-settings/plugins/ifcfg/Makefile.am
system-settings/plugins/ifcfg/parser.c
system-settings/plugins/ifcfg/parser.h
system-settings/plugins/ifcfg/plugin.c
- Parse wireless connections too
* system-settings/src/dbus-settings.c
system-settings/src/dbus-settings.h
system-settings/src/main.c
- Handle connection update/removal if the plugin supports it
2007-11-27 Dan Williams <dcbw@redhat.com>
* src/nm-dbus-manager.h
......
......@@ -12,6 +12,7 @@ libnm_settings_plugin_ifcfg_la_SOURCES = \
libnm_settings_plugin_ifcfg_la_CPPFLAGS = \
$(GLIB_CFLAGS) \
$(GMODULE_CFLAGS) \
$(DBUS_CFLAGS) \
-DG_DISABLE_DEPRECATED \
-I${top_srcdir}/system-settings/src \
-I$(top_srcdir)/include \
......
This diff is collapsed.
......@@ -28,7 +28,7 @@
#define BAK_TAG ".bak"
NMConnection * parser_parse_file (const char *file, char **err);
NMConnection * parser_parse_file (const char *file, GError **error);
char * parser_get_current_profile_name (void);
......
......@@ -76,7 +76,7 @@ parse_files (gpointer data)
while ((item = g_dir_read_name (dir))) {
NMConnection *connection;
char *err = NULL;
GError *error = NULL;
char *filename;
if (strncmp (item, IFCFG_TAG, strlen (IFCFG_TAG)))
......@@ -88,7 +88,7 @@ parse_files (gpointer data)
PLUGIN_PRINT (PLUGIN_NAME, "parsing %s ... ", filename);
if ((connection = parser_parse_file (filename, &err))) {
if ((connection = parser_parse_file (filename, &error))) {
NMSettingConnection *s_con;
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
......@@ -101,7 +101,9 @@ parse_files (gpointer data)
connection);
added = TRUE;
} else {
PLUGIN_PRINT (PLUGIN_NAME, " error: %s", err ? err : "(unknown)");
PLUGIN_PRINT (PLUGIN_NAME, " error: %s",
error->message ? error->message : "(unknown)");
g_clear_error (&error);
}
g_free (filename);
......
......@@ -182,13 +182,88 @@ nm_sysconfig_settings_new (DBusGConnection *g_conn)
void
nm_sysconfig_settings_add_connection (NMSysconfigSettings *settings,
NMSysconfigConnectionSettings *connection)
NMConnection *connection,
DBusGConnection *g_connection)
{
NMSysconfigConnectionSettings *exported;
g_return_if_fail (NM_IS_SYSCONFIG_SETTINGS (settings));
g_return_if_fail (NM_IS_SYSCONFIG_CONNECTION_SETTINGS (connection));
g_return_if_fail (NM_IS_CONNECTION (connection));
exported = nm_sysconfig_connection_settings_new (connection, g_connection);
if (!exported) {
g_warning ("%s: couldn't export the connection!", __func__);
return;
}
settings->connections = g_slist_append (settings->connections, connection);
settings->connections = g_slist_append (settings->connections, exported);
nm_settings_signal_new_connection (NM_SETTINGS (settings),
NM_CONNECTION_SETTINGS (connection));
NM_CONNECTION_SETTINGS (exported));
}
static void
remove_connection (NMSysconfigSettings *settings,
NMConnection *connection)
{
GSList *iter;
g_return_if_fail (NM_IS_SYSCONFIG_SETTINGS (settings));
g_return_if_fail (NM_IS_CONNECTION (connection));
for (iter = settings->connections; iter; iter = g_slist_next (iter)) {
NMSysconfigConnectionSettings *item = NM_SYSCONFIG_CONNECTION_SETTINGS (iter->data);
if (item->connection == connection) {
settings->connections = g_slist_remove (settings->connections, iter);
nm_connection_settings_signal_removed (NM_CONNECTION_SETTINGS (item));
g_object_unref (item);
g_slist_free (iter);
break;
}
}
}
void
nm_sysconfig_settings_remove_connection (NMSysconfigSettings *settings,
NMConnection *connection)
{
remove_connection (settings, connection);
}
void
nm_sysconfig_settings_update_connection (NMSysconfigSettings *settings,
NMConnection *connection)
{
GHashTable *hash;
GSList *iter;
NMSysconfigConnectionSettings *found = NULL;
g_return_if_fail (NM_IS_SYSCONFIG_SETTINGS (settings));
g_return_if_fail (NM_IS_CONNECTION (connection));
for (iter = settings->connections; iter; iter = g_slist_next (iter)) {
NMSysconfigConnectionSettings *item = NM_SYSCONFIG_CONNECTION_SETTINGS (iter->data);
if (item->connection == connection) {
found = item;
break;
}
}
if (!found) {
g_warning ("%s: cannot update unknown connection", __func__);
return;
}
/* If the connection is no longer valid, it gets removed */
if (!nm_connection_verify (connection)) {
remove_connection (settings, connection);
return;
}
hash = nm_connection_to_hash (connection);
nm_connection_settings_signal_updated (NM_CONNECTION_SETTINGS (found), hash);
g_hash_table_destroy (hash);
}
......@@ -79,6 +79,16 @@ struct _NMSysconfigSettingsClass
};
GType nm_sysconfig_settings_get_type (void);
NMSysconfigSettings *nm_sysconfig_settings_new (DBusGConnection *g_conn);
void nm_sysconfig_settings_add_connection (NMSysconfigSettings *settings,
NMSysconfigConnectionSettings *connection);
NMConnection *connection,
DBusGConnection *g_connection);
void nm_sysconfig_settings_remove_connection (NMSysconfigSettings *settings,
NMConnection *connection);
void nm_sysconfig_settings_update_connection (NMSysconfigSettings *settings,
NMConnection *connection);
......@@ -76,14 +76,7 @@ connection_added_cb (NMSystemConfigInterface *config,
NMConnection *connection,
Application *app)
{
NMSysconfigConnectionSettings *exported;
exported = nm_sysconfig_connection_settings_new (connection, app->g_connection);
if (!exported) {
g_warning ("%s: couldn't export the connection!", __func__);
return;
}
nm_sysconfig_settings_add_connection (app->settings, exported);
nm_sysconfig_settings_add_connection (app->settings, connection, app->g_connection);
}
static void
......@@ -91,6 +84,7 @@ connection_removed_cb (NMSystemConfigInterface *config,
NMConnection *connection,
Application *app)
{
nm_sysconfig_settings_remove_connection (app->settings, connection);
}
static void
......@@ -98,6 +92,7 @@ connection_updated_cb (NMSystemConfigInterface *config,
NMConnection *connection,
Application *app)
{
nm_sysconfig_settings_update_connection (app->settings, connection);
}
static void
......
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