From 6d6f7d3d909a69999c33e9caa3abac3eca725498 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 22 Apr 2010 12:27:31 -0700 Subject: [PATCH 1/3] core: ensure errors are dbus-glib accessible (rh #581794) Errors that can possibly be returned from D-Bus method calls need to be registered with dbus-glib. --- libnm-glib/libnm-glib.ver | 1 + src/system-settings/nm-sysconfig-settings.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/libnm-glib/libnm-glib.ver b/libnm-glib/libnm-glib.ver index 1caa2d42b..dfe4fe502 100644 --- a/libnm-glib/libnm-glib.ver +++ b/libnm-glib/libnm-glib.ver @@ -129,6 +129,7 @@ global: nm_settings_connection_interface_get_type; nm_settings_connection_interface_update; nm_settings_interface_add_connection; + nm_settings_interface_error_get_type; nm_settings_interface_error_quark; nm_settings_interface_get_connection_by_path; nm_settings_interface_get_type; diff --git a/src/system-settings/nm-sysconfig-settings.c b/src/system-settings/nm-sysconfig-settings.c index b120953a3..0054a9990 100644 --- a/src/system-settings/nm-sysconfig-settings.c +++ b/src/system-settings/nm-sysconfig-settings.c @@ -1475,7 +1475,12 @@ nm_sysconfig_settings_class_init (NMSysconfigSettingsClass *class) NM_DBUS_IFACE_SETTINGS_SYSTEM, NM_TYPE_SYSCONFIG_SETTINGS_ERROR); + dbus_g_error_domain_register (NM_SETTINGS_INTERFACE_ERROR, + NM_DBUS_IFACE_SETTINGS, + NM_TYPE_SETTINGS_INTERFACE_ERROR); + /* And register all the settings errors with D-Bus */ + dbus_g_error_domain_register (NM_CONNECTION_ERROR, NULL, NM_TYPE_CONNECTION_ERROR); dbus_g_error_domain_register (NM_SETTING_802_1X_ERROR, NULL, NM_TYPE_SETTING_802_1X_ERROR); dbus_g_error_domain_register (NM_SETTING_BLUETOOTH_ERROR, NULL, NM_TYPE_SETTING_BLUETOOTH_ERROR); dbus_g_error_domain_register (NM_SETTING_CDMA_ERROR, NULL, NM_TYPE_SETTING_CDMA_ERROR); From eeca251a27530f7e9cae020df57a47ef10c8e673 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 22 Apr 2010 12:39:48 -0700 Subject: [PATCH 2/3] core: return valid error to dbus-glib (rh #581794) --- libnm-glib/nm-exported-connection.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libnm-glib/nm-exported-connection.c b/libnm-glib/nm-exported-connection.c index 8ca64e797..3a8e51ce7 100644 --- a/libnm-glib/nm-exported-connection.c +++ b/libnm-glib/nm-exported-connection.c @@ -228,7 +228,9 @@ impl_exported_connection_get_secrets (NMExportedConnection *self, if (NM_EXPORTED_CONNECTION_GET_CLASS (self)->get_secrets) NM_EXPORTED_CONNECTION_GET_CLASS (self)->get_secrets (self, setting_name, hints, request_new, context); else { - error = g_error_new (0, 0, "%s: %s:%d get_secrets() unimplemented", __func__, __FILE__, __LINE__); + error = g_error_new (NM_SETTINGS_INTERFACE_ERROR, + NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR, + "%s: %s:%d get_secrets() unimplemented", __func__, __FILE__, __LINE__); dbus_g_method_return_error (context, error); g_error_free (error); } From 5a9b7b42d176c2340e146a3e76adfb7d142e02c4 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 22 Apr 2010 14:19:50 -0700 Subject: [PATCH 3/3] ifcfg-rh: return valid errors to dbus-glib (rh #581794) --- system-settings/plugins/ifcfg-rh/plugin.c | 26 ++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/system-settings/plugins/ifcfg-rh/plugin.c b/system-settings/plugins/ifcfg-rh/plugin.c index a27272862..47ce0075f 100644 --- a/system-settings/plugins/ifcfg-rh/plugin.c +++ b/system-settings/plugins/ifcfg-rh/plugin.c @@ -38,6 +38,7 @@ #include #include +#include #include "common.h" #include "nm-dbus-glib-types.h" @@ -535,31 +536,46 @@ impl_ifcfgrh_get_ifcfg_details (SCPluginIfcfg *plugin, const char *path; if (!g_path_is_absolute (in_ifcfg)) { - g_set_error (error, 0, 0, "ifcfg path '%s' is not absolute", in_ifcfg); + g_set_error (error, + NM_SETTINGS_INTERFACE_ERROR, + NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION, + "ifcfg path '%s' is not absolute", in_ifcfg); return FALSE; } connection = g_hash_table_lookup (priv->connections, in_ifcfg); if (!connection) { - g_set_error (error, 0, 0, "ifcfg file '%s' unknown", in_ifcfg); + g_set_error (error, + NM_SETTINGS_INTERFACE_ERROR, + NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION, + "ifcfg file '%s' unknown", in_ifcfg); return FALSE; } s_con = (NMSettingConnection *) nm_connection_get_setting (NM_CONNECTION (connection), NM_TYPE_SETTING_CONNECTION); if (!s_con) { - g_set_error_literal (error, 0, 0, "unable to retrieve the connection setting"); + g_set_error (error, + NM_SETTINGS_INTERFACE_ERROR, + NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR, + "unable to retrieve the connection setting"); return FALSE; } uuid = nm_setting_connection_get_uuid (s_con); if (!uuid) { - g_set_error_literal (error, 0, 0, "unable to get the UUID"); + g_set_error (error, + NM_SETTINGS_INTERFACE_ERROR, + NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR, + "unable to get the UUID"); return FALSE; } path = nm_connection_get_path (NM_CONNECTION (connection)); if (!path) { - g_set_error_literal (error, 0, 0, "unable to get the connection D-Bus path"); + g_set_error (error, + NM_SETTINGS_INTERFACE_ERROR, + NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR, + "unable to get the connection D-Bus path"); return FALSE; }