summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2014-10-13 11:57:35 -0400
committerDan Winship <danw@gnome.org>2014-10-22 08:29:07 -0400
commita7b1ee77dbc74fa40864e292c75d764b958634b0 (patch)
treee3637575fd8552307493ed88168b6be83f9c799f
parent63957e0ed23e949ad24290f8f4c02f6925bb6bef (diff)
downloadNetworkManager-a7b1ee77dbc74fa40864e292c75d764b958634b0.tar.gz
libnm-core: drop nm_setting_lookup_type_by_quark()
nm_setting_lookup_type_by_quark() was only ever used in places that were still mistakenly assuming the old style of nm_connection_verify() errors, where the error message would contain only a property name and no further explanation. Fix those places to assume that the error will contain a real error message, and include both the setting name and the property name. Given that, there's no longer any need for nm_setting_lookup_type_by_quark(), so drop it.
-rw-r--r--libnm-core/nm-setting-private.h6
-rw-r--r--libnm-core/nm-setting.c34
-rw-r--r--libnm-core/nm-setting.h1
-rw-r--r--libnm/libnm.ver1
-rw-r--r--libnm/nm-vpn-plugin.c5
-rw-r--r--src/settings/nm-settings.c5
-rw-r--r--src/settings/plugins/example/plugin.c7
-rw-r--r--src/settings/plugins/keyfile/reader.c5
8 files changed, 11 insertions, 53 deletions
diff --git a/libnm-core/nm-setting-private.h b/libnm-core/nm-setting-private.h
index 9f0c51a983..e6e54983ed 100644
--- a/libnm-core/nm-setting-private.h
+++ b/libnm-core/nm-setting-private.h
@@ -46,13 +46,11 @@ typedef enum {
void _nm_register_setting (const char *name,
const GType type,
- const guint32 priority,
- const GQuark error_quark);
+ const guint32 priority);
#define _nm_register_setting(name, priority) \
G_STMT_START { \
- _nm_register_setting (NM_SETTING_ ## name ## _SETTING_NAME "", g_define_type_id, priority, NM_SETTING_ ## name ## _ERROR); \
- g_type_ensure (NM_TYPE_SETTING_ ## name ## _ERROR); \
+ _nm_register_setting (NM_SETTING_ ## name ## _SETTING_NAME "", g_define_type_id, priority); \
} G_STMT_END
gboolean _nm_setting_is_base_type (NMSetting *setting);
diff --git a/libnm-core/nm-setting.c b/libnm-core/nm-setting.c
index 14c5f404ce..8b2ebc925e 100644
--- a/libnm-core/nm-setting.c
+++ b/libnm-core/nm-setting.c
@@ -69,7 +69,6 @@ typedef struct {
const char *name;
GType type;
guint32 priority;
- GQuark error_quark;
} SettingInfo;
typedef struct {
@@ -127,7 +126,6 @@ _ensure_registered (void)
* @name: the name of the #NMSetting object to register
* @type: the #GType of the #NMSetting
* @priority: the sort priority of the setting, see below
- * @error_quark: the setting's error quark
*
* INTERNAL ONLY: registers a setting's internal properties, like its priority
* and its error quark type, with libnm.
@@ -158,22 +156,19 @@ _ensure_registered (void)
void
(_nm_register_setting) (const char *name,
const GType type,
- const guint32 priority,
- const GQuark error_quark)
+ const guint32 priority)
{
SettingInfo *info;
g_return_if_fail (name != NULL && *name);
g_return_if_fail (type != G_TYPE_INVALID);
g_return_if_fail (type != G_TYPE_NONE);
- g_return_if_fail (error_quark != 0);
g_return_if_fail (priority <= 4);
_ensure_registered ();
if (G_LIKELY ((info = g_hash_table_lookup (registered_settings, name)))) {
g_return_if_fail (info->type == type);
- g_return_if_fail (info->error_quark == error_quark);
g_return_if_fail (info->priority == priority);
g_return_if_fail (g_strcmp0 (info->name, name) == 0);
return;
@@ -186,7 +181,6 @@ void
info = g_slice_new0 (SettingInfo);
info->type = type;
info->priority = priority;
- info->error_quark = error_quark;
info->name = name;
g_hash_table_insert (registered_settings, (void *) info->name, info);
g_hash_table_insert (registered_settings_by_type, &info->type, info);
@@ -260,32 +254,6 @@ nm_setting_lookup_type (const char *name)
return info ? info->type : G_TYPE_INVALID;
}
-/**
- * nm_setting_lookup_type_by_quark:
- * @error_quark: a setting error quark
- *
- * Returns the #GType of the setting's class for a given setting error quark.
- * Useful for figuring out which setting a returned error is for.
- *
- * Returns: the #GType of the setting's class, or %G_TYPE_INVALID if
- * @error_quark is not recognized
- **/
-GType
-nm_setting_lookup_type_by_quark (GQuark error_quark)
-{
- SettingInfo *info;
- GHashTableIter iter;
-
- _ensure_registered ();
-
- g_hash_table_iter_init (&iter, registered_settings);
- while (g_hash_table_iter_next (&iter, NULL, (gpointer) &info)) {
- if (info->error_quark == error_quark)
- return info->type;
- }
- return G_TYPE_INVALID;
-}
-
gint
_nm_setting_compare_priority (gconstpointer a, gconstpointer b)
{
diff --git a/libnm-core/nm-setting.h b/libnm-core/nm-setting.h
index 8e179f2a4f..038d5bc53d 100644
--- a/libnm-core/nm-setting.h
+++ b/libnm-core/nm-setting.h
@@ -244,7 +244,6 @@ typedef void (*NMSettingValueIterFn) (NMSetting *setting,
GType nm_setting_get_type (void);
GType nm_setting_lookup_type (const char *name);
-GType nm_setting_lookup_type_by_quark (GQuark error_quark);
NMSetting *nm_setting_duplicate (NMSetting *setting);
diff --git a/libnm/libnm.ver b/libnm/libnm.ver
index e0c4795f9e..b8c7fdb5b3 100644
--- a/libnm/libnm.ver
+++ b/libnm/libnm.ver
@@ -686,7 +686,6 @@ global:
nm_setting_ip6_config_remove_route;
nm_setting_ip6_config_remove_route_by_value;
nm_setting_lookup_type;
- nm_setting_lookup_type_by_quark;
nm_setting_olpc_mesh_error_get_type;
nm_setting_olpc_mesh_error_quark;
nm_setting_olpc_mesh_get_channel;
diff --git a/libnm/nm-vpn-plugin.c b/libnm/nm-vpn-plugin.c
index 674c7a97f3..d3fe87bf0a 100644
--- a/libnm/nm-vpn-plugin.c
+++ b/libnm/nm-vpn-plugin.c
@@ -491,9 +491,8 @@ impl_vpn_plugin_need_secrets (NMVpnPlugin *plugin,
g_dbus_method_invocation_return_error (context,
NM_VPN_PLUGIN_ERROR,
NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID,
- "The connection was invalid: '%s' / '%s' invalid: %d.",
- g_type_name (nm_setting_lookup_type_by_quark (error->domain)),
- error->message, error->code);
+ "The connection was invalid: %s",
+ error->message);
g_error_free (error);
return;
}
diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c
index f4ab2839d4..87b7d2fa34 100644
--- a/src/settings/nm-settings.c
+++ b/src/settings/nm-settings.c
@@ -834,9 +834,8 @@ claim_connection (NMSettings *self,
}
if (!nm_connection_normalize (NM_CONNECTION (connection), NULL, NULL, &error)) {
- nm_log_warn (LOGD_SETTINGS, "plugin provided invalid connection: '%s' / '%s' invalid: %d",
- g_type_name (nm_setting_lookup_type_by_quark (error->domain)),
- error->message, error->code);
+ nm_log_warn (LOGD_SETTINGS, "plugin provided invalid connection: %s",
+ error->message);
g_error_free (error);
return;
}
diff --git a/src/settings/plugins/example/plugin.c b/src/settings/plugins/example/plugin.c
index 35fc4a0f63..bc5c06e99d 100644
--- a/src/settings/plugins/example/plugin.c
+++ b/src/settings/plugins/example/plugin.c
@@ -197,11 +197,8 @@ update_connection_settings_commit_cb (NMSettingsConnection *orig, GError *error,
* an error here.
*/
if (error) {
- nm_log_warn (LOGD_SETTINGS, "%s: '%s' / '%s' invalid: %d",
- __func__,
- error ? g_type_name (nm_setting_lookup_type_by_quark (error->domain)) : "(none)",
- (error && error->message) ? error->message : "(none)",
- error ? error->code : -1);
+ nm_log_warn (LOGD_SETTINGS, "%s: connection invalid: %s",
+ __func__, error->message);
g_clear_error (&error);
nm_settings_connection_signal_remove (orig);
diff --git a/src/settings/plugins/keyfile/reader.c b/src/settings/plugins/keyfile/reader.c
index 4c6ce24397..9ec6d94d24 100644
--- a/src/settings/plugins/keyfile/reader.c
+++ b/src/settings/plugins/keyfile/reader.c
@@ -1385,9 +1385,8 @@ nm_keyfile_plugin_connection_from_file (const char *filename, GError **error)
/* Normalize and verify the connection */
if (!nm_connection_normalize (connection, NULL, NULL, &verify_error)) {
g_set_error (error, KEYFILE_PLUGIN_ERROR, 0,
- "invalid or missing connection property '%s/%s'",
- verify_error ? g_type_name (nm_setting_lookup_type_by_quark (verify_error->domain)) : "(unknown)",
- (verify_error && verify_error->message) ? verify_error->message : "(unknown)");
+ "invalid connection: %s",
+ verify_error->message);
g_clear_error (&verify_error);
g_object_unref (connection);
connection = NULL;