summaryrefslogtreecommitdiff
path: root/libnm-core/nm-setting-vpn.c
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2014-10-20 13:52:23 -0400
committerDan Winship <danw@gnome.org>2014-10-22 08:29:07 -0400
commit2d8e7bd2476011e7b156d6365b28a78a3ecd84bf (patch)
tree72967281ffe2f06ad97c3d4f02425f2d1ab2e611 /libnm-core/nm-setting-vpn.c
parentaeb3d093f66aea3c5bf7e235226bdb0431cf9a9a (diff)
downloadNetworkManager-2d8e7bd2476011e7b156d6365b28a78a3ecd84bf.tar.gz
libnm-core: merge NMSetting*Error into NMConnectionError
Each setting type was defining its own error type, but most of them had exactly the same three errors ("unknown", "missing property", and "invalid property"), and none of the other values was of much use programmatically anyway. So, this commit merges NMSettingError, NMSettingAdslError, etc, all into NMConnectionError. (The reason for merging into NMConnectionError rather than NMSettingError is that we also already have "NMSettingsError", for errors related to the settings service, so "NMConnectionError" is a less-confusable name for settings/connection errors than "NMSettingError".) Also, make sure that all of the affected error messages are localized, and (where appropriate) prefix them with the relevant property name. Renamed error codes: NM_SETTING_ERROR_PROPERTY_NOT_FOUND -> NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND NM_SETTING_ERROR_PROPERTY_NOT_SECRET -> NM_CONNECTION_ERROR_PROPERTY_NOT_SECRET Remapped error codes: NM_SETTING_*_ERROR_MISSING_PROPERTY -> NM_CONNECTION_ERROR_MISSING_PROPERTY NM_SETTING_*_ERROR_INVALID_PROPERTY -> NM_CONNECTION_ERROR_INVALID_PROPERTY NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH -> NM_CONNECTION_ERROR_INVALID_PROPERTY NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_INVALID_SETTING NM_SETTING_BOND_ERROR_INVALID_OPTION -> NM_CONNECTION_ERROR_INVALID_PROPERTY NM_SETTING_BOND_ERROR_MISSING_OPTION -> NM_CONNECTION_ERROR_MISSING_PROPERTY NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING NM_SETTING_CONNECTION_ERROR_SLAVE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY NM_SETTING_VLAN_ERROR_INVALID_PARENT -> NM_CONNECTION_ERROR_INVALID_PROPERTY NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING -> NM_CONNECTION_ERROR_MISSING_SETTING NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X -> NM_CONNECTION_ERROR_INVALID_PROPERTY NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME -> NM_CONNECTION_ERROR_MISSING_PROPERTY NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP -> NM_CONNECTION_ERROR_INVALID_PROPERTY NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND -> NM_CONNECTION_ERROR_MISSING_PROPERTY Dropped error codes (were previously defined but unused): NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING
Diffstat (limited to 'libnm-core/nm-setting-vpn.c')
-rw-r--r--libnm-core/nm-setting-vpn.c82
1 files changed, 37 insertions, 45 deletions
diff --git a/libnm-core/nm-setting-vpn.c b/libnm-core/nm-setting-vpn.c
index 667b83d78b..07f815716e 100644
--- a/libnm-core/nm-setting-vpn.c
+++ b/libnm-core/nm-setting-vpn.c
@@ -42,24 +42,6 @@
* properties.
**/
-/**
- * nm_setting_vpn_error_quark:
- *
- * Registers an error quark for #NMSettingVpn if necessary.
- *
- * Returns: the error quark used for #NMSettingVpn errors.
- **/
-GQuark
-nm_setting_vpn_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-setting-vpn-error-quark");
- return quark;
-}
-
-
G_DEFINE_TYPE_WITH_CODE (NMSettingVpn, nm_setting_vpn, NM_TYPE_SETTING,
_nm_register_setting (VPN, 1))
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_VPN)
@@ -391,8 +373,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
if (!priv->service_type) {
g_set_error_literal (error,
- NM_SETTING_VPN_ERROR,
- NM_SETTING_VPN_ERROR_MISSING_PROPERTY,
+ NM_CONNECTION_ERROR,
+ NM_CONNECTION_ERROR_MISSING_PROPERTY,
_("property is missing"));
g_prefix_error (error, "%s.%s: ", NM_SETTING_VPN_SETTING_NAME, NM_SETTING_VPN_SERVICE_TYPE);
return FALSE;
@@ -400,8 +382,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
if (!strlen (priv->service_type)) {
g_set_error_literal (error,
- NM_SETTING_VPN_ERROR,
- NM_SETTING_VPN_ERROR_INVALID_PROPERTY,
+ NM_CONNECTION_ERROR,
+ NM_CONNECTION_ERROR_INVALID_PROPERTY,
_("property is empty"));
g_prefix_error (error, "%s.%s: ", NM_SETTING_VPN_SETTING_NAME, NM_SETTING_VPN_SERVICE_TYPE);
return FALSE;
@@ -410,8 +392,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
/* default username can be NULL, but can't be zero-length */
if (priv->user_name && !strlen (priv->user_name)) {
g_set_error_literal (error,
- NM_SETTING_VPN_ERROR,
- NM_SETTING_VPN_ERROR_INVALID_PROPERTY,
+ NM_CONNECTION_ERROR,
+ NM_CONNECTION_ERROR_INVALID_PROPERTY,
_("property is empty"));
g_prefix_error (error, "%s.%s: ", NM_SETTING_VPN_SETTING_NAME, NM_SETTING_VPN_USER_NAME);
return FALSE;
@@ -432,9 +414,10 @@ update_secret_string (NMSetting *setting,
g_return_val_if_fail (value != NULL, NM_SETTING_UPDATE_SECRET_ERROR);
if (!value || !strlen (value)) {
- g_set_error (error, NM_SETTING_ERROR,
- NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH,
- "Secret %s was empty", key);
+ g_set_error (error, NM_CONNECTION_ERROR,
+ NM_CONNECTION_ERROR_INVALID_PROPERTY,
+ _("secret was empty"));
+ g_prefix_error (error, "%s.%s: ", NM_SETTING_VPN_SETTING_NAME, key);
return NM_SETTING_UPDATE_SECRET_ERROR;
}
@@ -461,16 +444,18 @@ update_secret_dict (NMSetting *setting,
g_variant_iter_init (&iter, secrets);
while (g_variant_iter_next (&iter, "{&s&s}", &name, &value)) {
if (!name || !strlen (name)) {
- g_set_error_literal (error, NM_SETTING_ERROR,
- NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH,
- "Secret name was empty");
+ g_set_error_literal (error, NM_CONNECTION_ERROR,
+ NM_CONNECTION_ERROR_INVALID_SETTING,
+ _("setting contained a secret with an empty name"));
+ g_prefix_error (error, "%s: ", NM_SETTING_VPN_SETTING_NAME);
return NM_SETTING_UPDATE_SECRET_ERROR;
}
if (!value || !strlen (value)) {
- g_set_error (error, NM_SETTING_ERROR,
- NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH,
- "Secret %s value was empty", name);
+ g_set_error (error, NM_CONNECTION_ERROR,
+ NM_CONNECTION_ERROR_INVALID_PROPERTY,
+ _("secret value was empty"));
+ g_prefix_error (error, "%s.%s: ", NM_SETTING_VPN_SETTING_NAME, name);
return NM_SETTING_UPDATE_SECRET_ERROR;
}
}
@@ -514,12 +499,17 @@ update_one_secret (NMSetting *setting, const char *key, GVariant *value, GError
success = update_secret_string (setting, key, g_variant_get_string (value, NULL), error);
} else if (g_variant_is_of_type (value, G_VARIANT_TYPE ("a{ss}"))) {
if (strcmp (key, NM_SETTING_VPN_SECRETS) != 0) {
- g_set_error (error, NM_SETTING_ERROR, NM_SETTING_ERROR_PROPERTY_NOT_SECRET,
- "Property %s not a secret property", key);
+ g_set_error_literal (error, NM_CONNECTION_ERROR,
+ NM_CONNECTION_ERROR_PROPERTY_NOT_SECRET,
+ _("not a secret property"));
+ g_prefix_error (error, "%s.%s ", NM_SETTING_VPN_SETTING_NAME, key);
} else
success = update_secret_dict (setting, value, error);
- } else
- g_set_error_literal (error, NM_SETTING_ERROR, NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH, key);
+ } else {
+ g_set_error_literal (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY,
+ _("secret is not of correct type"));
+ g_prefix_error (error, "%s.%s: ", NM_SETTING_VPN_SETTING_NAME, key);
+ }
if (success == NM_SETTING_UPDATE_SECRET_SUCCESS_MODIFIED)
g_object_notify (G_OBJECT (setting), NM_SETTING_VPN_SECRETS);
@@ -550,16 +540,18 @@ get_secret_flags (NMSetting *setting,
success = TRUE;
} else {
g_set_error (error,
- NM_SETTING_ERROR,
- NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH,
- _("Failed to convert '%s' value '%s' to uint"),
- flags_key, (const char *) val);
+ NM_CONNECTION_ERROR,
+ NM_CONNECTION_ERROR_INVALID_PROPERTY,
+ _("failed to convert value '%s' to uint"),
+ (const char *) val);
+ g_prefix_error (error, "%s.%s: ", NM_SETTING_VPN_SETTING_NAME, flags_key);
}
} else {
- g_set_error (error,
- NM_SETTING_ERROR,
- NM_SETTING_ERROR_PROPERTY_NOT_FOUND,
- _("Secret flags property '%s' not found"), flags_key);
+ g_set_error_literal (error,
+ NM_CONNECTION_ERROR,
+ NM_CONNECTION_ERROR_MISSING_PROPERTY,
+ _("secret flags property not found"));
+ g_prefix_error (error, "%s.%s: ", NM_SETTING_VPN_SETTING_NAME, flags_key);
}
g_free (flags_key);
if (out_flags)