diff options
69 files changed, 791 insertions, 1703 deletions
diff --git a/libnm-core/nm-connection.c b/libnm-core/nm-connection.c index 18a21c98c..0ccacace1 100644 --- a/libnm-core/nm-connection.c +++ b/libnm-core/nm-connection.c @@ -259,9 +259,10 @@ validate_permissions_type (GVariant *variant, GError **error) if (permissions) { if (!g_variant_is_of_type (permissions, G_VARIANT_TYPE_STRING_ARRAY)) { g_set_error_literal (error, - NM_SETTING_ERROR, - NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH, - "Wrong permissions property type; should be a list of strings."); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("wrong type; should be a list of strings.")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_PERMISSIONS); valid = FALSE; } g_variant_unref (permissions); diff --git a/libnm-core/nm-connection.h b/libnm-core/nm-connection.h index 93529af2c..d1cfff2ac 100644 --- a/libnm-core/nm-connection.h +++ b/libnm-core/nm-connection.h @@ -75,6 +75,10 @@ G_BEGIN_DECLS * @NM_CONNECTION_ERROR_FAILED: unknown or unclassified error * @NM_CONNECTION_ERROR_SETTING_NOT_FOUND: the #NMConnection object * did not contain the specified #NMSetting object + * @NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND: the #NMConnection did not contain the + * requested #NMSetting property + * @NM_CONNECTION_ERROR_PROPERTY_NOT_SECRET: an operation which requires a secret + * was attempted on a non-secret property * @NM_CONNECTION_ERROR_MISSING_SETTING: the #NMConnection object is missing an * #NMSetting which is required for its configuration. The error message will * always be prefixed with "<setting-name>: ", where "<setting-name>" is the @@ -83,14 +87,29 @@ G_BEGIN_DECLS * invalid or inappropriate #NMSetting. The error message will always be * prefixed with "<setting-name>: ", where "<setting-name>" is the name of the * setting that is invalid. + * @NM_CONNECTION_ERROR_MISSING_PROPERTY: the #NMConnection object is invalid + * because it is missing a required property. The error message will always be + * prefixed with "<setting-name>.<property-name>: ", where "<setting-name>" is + * the name of the setting with the missing property, and "<property-name>" is + * the property that is missing. + * @NM_CONNECTION_ERROR_INVALID_PROPERTY: the #NMConnection object is invalid + * because a property has an invalid value. The error message will always be + * prefixed with "<setting-name>.<property-name>: ", where "<setting-name>" is + * the name of the setting with the invalid property, and "<property-name>" is + * the property that is invalid. * - * Describes errors that may result from operations involving a #NMConnection. + * Describes errors that may result from operations involving a #NMConnection + * or its #NMSettings. */ typedef enum { NM_CONNECTION_ERROR_FAILED = 0, /*< nick=Failed >*/ NM_CONNECTION_ERROR_SETTING_NOT_FOUND, /*< nick=SettingNotFound >*/ + NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND, /*< nick=PropertyNotFound >*/ + NM_CONNECTION_ERROR_PROPERTY_NOT_SECRET, /*< nick=PropertyNotSecret >*/ NM_CONNECTION_ERROR_MISSING_SETTING, /*< nick=MissingSetting >*/ NM_CONNECTION_ERROR_INVALID_SETTING, /*< nick=InvalidSetting >*/ + NM_CONNECTION_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ + NM_CONNECTION_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ } NMConnectionError; /* diff --git a/libnm-core/nm-setting-8021x.c b/libnm-core/nm-setting-8021x.c index 352f84ef1..fc1b46fb6 100644 --- a/libnm-core/nm-setting-8021x.c +++ b/libnm-core/nm-setting-8021x.c @@ -60,23 +60,6 @@ #define SCHEME_PATH "file://" -/** - * nm_setting_802_1x_error_quark: - * - * Registers an error quark for #NMSetting8021x if necessary. - * - * Returns: the error quark used for #NMSetting8021x errors. - **/ -GQuark -nm_setting_802_1x_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-setting-802-1x-error-quark"); - return quark; -} - G_DEFINE_TYPE_WITH_CODE (NMSetting8021x, nm_setting_802_1x, NM_TYPE_SETTING, _nm_register_setting (802_1X, 2)) NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_802_1X) @@ -589,8 +572,8 @@ nm_setting_802_1x_set_ca_cert (NMSetting8021x *setting, g_assert_not_reached (); } else { g_set_error_literal (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("CA certificate must be in X.509 format")); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_CA_CERT); } @@ -904,8 +887,8 @@ nm_setting_802_1x_set_client_cert (NMSetting8021x *setting, break; default: g_set_error_literal (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("invalid certificate format")); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_CLIENT_CERT); break; @@ -1168,8 +1151,8 @@ nm_setting_802_1x_set_phase2_ca_cert (NMSetting8021x *setting, g_assert_not_reached (); } else { g_set_error_literal (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("invalid certificate format")); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_CA_CERT); } @@ -1488,8 +1471,8 @@ nm_setting_802_1x_set_phase2_client_cert (NMSetting8021x *setting, break; default: g_set_error_literal (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("invalid certificate format")); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_CLIENT_CERT); break; @@ -1770,8 +1753,8 @@ nm_setting_802_1x_set_private_key (NMSetting8021x *setting, format = crypto_verify_private_key (key_path, password, &local_err); if (format == NM_CRYPTO_FILE_FORMAT_UNKNOWN) { g_set_error_literal (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, local_err ? local_err->message : _("invalid private key")); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PRIVATE_KEY); g_clear_error (&local_err); @@ -2080,8 +2063,8 @@ nm_setting_802_1x_set_phase2_private_key (NMSetting8021x *setting, format = crypto_verify_private_key (key_path, password, &local_err); if (format == NM_CRYPTO_FILE_FORMAT_UNKNOWN) { g_set_error_literal (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, local_err ? local_err->message : _("invalid phase2 private key")); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY); g_clear_error (&local_err); @@ -2282,15 +2265,15 @@ verify_tls (NMSetting8021x *self, gboolean phase2, GError **error) if (phase2) { if (!priv->phase2_client_cert) { g_set_error_literal (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property is missing")); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_CLIENT_CERT); return FALSE; } else if (!g_bytes_get_size (priv->phase2_client_cert)) { g_set_error_literal (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is empty")); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_CLIENT_CERT); return FALSE; @@ -2299,15 +2282,15 @@ verify_tls (NMSetting8021x *self, gboolean phase2, GError **error) /* Private key is required for TLS */ if (!priv->phase2_private_key) { g_set_error_literal (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property is missing")); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY); return FALSE; } else if (!g_bytes_get_size (priv->phase2_private_key)) { g_set_error_literal (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is empty")); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY); return FALSE; @@ -2318,8 +2301,8 @@ verify_tls (NMSetting8021x *self, gboolean phase2, GError **error) g_bytes_get_size (priv->phase2_private_key))) { if (!g_bytes_equal (priv->phase2_private_key, priv->phase2_client_cert)) { g_set_error (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("has to match '%s' property for PKCS#12"), NM_SETTING_802_1X_PHASE2_PRIVATE_KEY); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_CLIENT_CERT); @@ -2329,15 +2312,15 @@ verify_tls (NMSetting8021x *self, gboolean phase2, GError **error) } else { if (!priv->client_cert) { g_set_error_literal (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property is missing")); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_CLIENT_CERT); return FALSE; } else if (!g_bytes_get_size (priv->client_cert)) { g_set_error_literal (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is empty")); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_CLIENT_CERT); return FALSE; @@ -2346,15 +2329,15 @@ verify_tls (NMSetting8021x *self, gboolean phase2, GError **error) /* Private key is required for TLS */ if (!priv->private_key) { g_set_error_literal (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property is missing")); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PRIVATE_KEY); return FALSE; } else if (!g_bytes_get_size (priv->private_key)) { g_set_error_literal (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is empty")); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PRIVATE_KEY); return FALSE; @@ -2365,8 +2348,8 @@ verify_tls (NMSetting8021x *self, gboolean phase2, GError **error) g_bytes_get_size (priv->private_key))) { if (!g_bytes_equal (priv->private_key, priv->client_cert)) { g_set_error (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("has to match '%s' property for PKCS#12"), NM_SETTING_802_1X_PRIVATE_KEY); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_CLIENT_CERT); @@ -2387,26 +2370,26 @@ verify_ttls (NMSetting8021x *self, gboolean phase2, GError **error) && (!priv->anonymous_identity || !strlen (priv->anonymous_identity))) { if (!priv->identity) { g_set_error_literal (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property is missing")); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_IDENTITY); } else if (!strlen (priv->identity)) { g_set_error_literal (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is empty")); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_IDENTITY); } else if (!priv->anonymous_identity) { g_set_error_literal (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property is missing")); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_ANONYMOUS_IDENTITY); } else { g_set_error_literal (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is empty")); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_ANONYMOUS_IDENTITY); } @@ -2417,26 +2400,26 @@ verify_ttls (NMSetting8021x *self, gboolean phase2, GError **error) && (!priv->phase2_autheap || !strlen (priv->phase2_autheap))) { if (!priv->phase2_auth) { g_set_error_literal (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property is missing")); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_AUTH); } else if (!strlen (priv->phase2_auth)) { g_set_error_literal (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is empty")); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_AUTH); } else if (!priv->phase2_autheap) { g_set_error_literal (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property is missing")); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_AUTHEAP); } else { g_set_error_literal (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is empty")); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_AUTHEAP); } @@ -2453,15 +2436,15 @@ verify_identity (NMSetting8021x *self, gboolean phase2, GError **error) if (!priv->identity) { g_set_error_literal (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property is missing")); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_IDENTITY); return FALSE; } else if (!strlen (priv->identity)) { g_set_error_literal (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is empty")); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_IDENTITY); return FALSE; @@ -2610,8 +2593,8 @@ verify_cert (GBytes *bytes, const char *prop_name, GError **error) } g_set_error_literal (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is invalid")); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, prop_name); return FALSE; @@ -2635,8 +2618,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!priv->eap) { g_set_error_literal (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property is missing")); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_EAP); return FALSE; @@ -2644,8 +2627,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!_nm_utils_string_slist_validate (priv->eap, valid_eap)) { g_set_error_literal (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is invalid")); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_EAP); return FALSE; @@ -2669,8 +2652,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->phase1_peapver && !_nm_utils_string_in_list (priv->phase1_peapver, valid_phase1_peapver)) { g_set_error (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' is not a valid value for the property"), priv->phase1_peapver); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE1_PEAPVER); @@ -2679,8 +2662,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->phase1_peaplabel && !_nm_utils_string_in_list (priv->phase1_peaplabel, valid_phase1_peaplabel)) { g_set_error (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' is not a valid value for the property"), priv->phase1_peaplabel); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE1_PEAPLABEL); @@ -2689,8 +2672,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->phase1_fast_provisioning && !_nm_utils_string_in_list (priv->phase1_fast_provisioning, valid_phase1_fast_pac)) { g_set_error (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' is not a valid value for the property"), priv->phase1_fast_provisioning); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING); @@ -2699,8 +2682,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->phase2_auth && !_nm_utils_string_in_list (priv->phase2_auth, valid_phase2_auth)) { g_set_error (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' is not a valid value for the property"), priv->phase2_auth); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_AUTH); @@ -2709,8 +2692,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->phase2_autheap && !_nm_utils_string_in_list (priv->phase2_autheap, valid_phase2_autheap)) { g_set_error (error, - NM_SETTING_802_1X_ERROR, - NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' is not a valid value for the property"), priv->phase2_autheap); g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_AUTHEAP); diff --git a/libnm-core/nm-setting-8021x.h b/libnm-core/nm-setting-8021x.h index d855df858..ab6cde440 100644 --- a/libnm-core/nm-setting-8021x.h +++ b/libnm-core/nm-setting-8021x.h @@ -79,23 +79,6 @@ typedef enum { /*< underscore_name=nm_setting_802_1x_ck_scheme >*/ #define NM_SETTING_802_1X_SETTING_NAME "802-1x" -/** - * NMSetting8021xError: - * @NM_SETTING_802_1X_ERROR_UNKNOWN: unknown or unclassified error - * @NM_SETTING_802_1X_ERROR_INVALID_PROPERTY: the property was invalid - * @NM_SETTING_802_1X_ERROR_MISSING_PROPERTY: the property was missing and is - * required - */ -typedef enum { /*< underscore_name=nm_setting_802_1x_error >*/ - NM_SETTING_802_1X_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_SETTING_802_1X_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ - NM_SETTING_802_1X_ERROR_MISSING_PROPERTY /*< nick=MissingProperty >*/ -} NMSetting8021xError; - -#define NM_SETTING_802_1X_ERROR nm_setting_802_1x_error_quark () -GQuark nm_setting_802_1x_error_quark (void); - - #define NM_SETTING_802_1X_EAP "eap" #define NM_SETTING_802_1X_IDENTITY "identity" #define NM_SETTING_802_1X_ANONYMOUS_IDENTITY "anonymous-identity" diff --git a/libnm-core/nm-setting-adsl.c b/libnm-core/nm-setting-adsl.c index 26b01070e..3ba569231 100644 --- a/libnm-core/nm-setting-adsl.c +++ b/libnm-core/nm-setting-adsl.c @@ -36,23 +36,6 @@ * properties of ADSL connections. */ -/** - * nm_setting_adsl_error_quark: - * - * Registers an error quark for #NMSettingAdsl if necessary. - * - * Returns: the error quark used for #NMSettingAdsl errors. - **/ -GQuark -nm_setting_adsl_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-setting-adsl-error-quark"); - return quark; -} - G_DEFINE_TYPE_WITH_CODE (NMSettingAdsl, nm_setting_adsl, NM_TYPE_SETTING, _nm_register_setting (ADSL, 1)) NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_ADSL) @@ -200,15 +183,15 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!priv->username) { g_set_error_literal (error, - NM_SETTING_ADSL_ERROR, - NM_SETTING_ADSL_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property is missing")); g_prefix_error (error, "%s.%s: ", NM_SETTING_ADSL_SETTING_NAME, NM_SETTING_ADSL_USERNAME); return FALSE; } else if (!strlen (priv->username)) { g_set_error_literal (error, - NM_SETTING_ADSL_ERROR, - NM_SETTING_ADSL_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is empty")); g_prefix_error (error, "%s.%s: ", NM_SETTING_ADSL_SETTING_NAME, NM_SETTING_ADSL_USERNAME); return FALSE; @@ -216,8 +199,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->password && !strlen (priv->password)) { g_set_error_literal (error, - NM_SETTING_ADSL_ERROR, - NM_SETTING_ADSL_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is empty")); g_prefix_error (error, "%s.%s: ", NM_SETTING_ADSL_SETTING_NAME, NM_SETTING_ADSL_PASSWORD); return FALSE; @@ -228,8 +211,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) && strcmp (priv->protocol, NM_SETTING_ADSL_PROTOCOL_PPPOE) && strcmp (priv->protocol, NM_SETTING_ADSL_PROTOCOL_IPOATM))){ g_set_error (error, - NM_SETTING_ADSL_ERROR, - NM_SETTING_ADSL_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' is not a valid value for the property"), priv->protocol ? priv->protocol : "(null)"); g_prefix_error (error, "%s.%s: ", NM_SETTING_ADSL_SETTING_NAME, NM_SETTING_ADSL_PROTOCOL); @@ -240,8 +223,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) && ( strcmp (priv->encapsulation, NM_SETTING_ADSL_ENCAPSULATION_VCMUX) && strcmp (priv->encapsulation, NM_SETTING_ADSL_ENCAPSULATION_LLC) )) { g_set_error (error, - NM_SETTING_ADSL_ERROR, - NM_SETTING_ADSL_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' is not a valid value for the property"), priv->encapsulation); g_prefix_error (error, "%s.%s: ", NM_SETTING_ADSL_SETTING_NAME, NM_SETTING_ADSL_ENCAPSULATION); diff --git a/libnm-core/nm-setting-adsl.h b/libnm-core/nm-setting-adsl.h index baa8b8d7f..57237f1e1 100644 --- a/libnm-core/nm-setting-adsl.h +++ b/libnm-core/nm-setting-adsl.h @@ -39,22 +39,6 @@ G_BEGIN_DECLS #define NM_SETTING_ADSL_SETTING_NAME "adsl" -/** - * NMSettingAdslError: - * @NM_SETTING_ADSL_ERROR_UNKNOWN: unknown or unclassified error - * @NM_SETTING_ADSL_ERROR_INVALID_PROPERTY: the property was invalid - * @NM_SETTING_ADSL_ERROR_MISSING_PROPERTY: the property was missing and is - * required - */ -typedef enum { - NM_SETTING_ADSL_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_SETTING_ADSL_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ - NM_SETTING_ADSL_ERROR_MISSING_PROPERTY /*< nick=MissingProperty >*/ -} NMSettingAdslError; - -#define NM_SETTING_ADSL_ERROR nm_setting_adsl_error_quark () -GQuark nm_setting_adsl_error_quark (void); - #define NM_SETTING_ADSL_USERNAME "username" #define NM_SETTING_ADSL_PASSWORD "password" #define NM_SETTING_ADSL_PASSWORD_FLAGS "password-flags" diff --git a/libnm-core/nm-setting-bluetooth.c b/libnm-core/nm-setting-bluetooth.c index 8791744a0..4bc7e156a 100644 --- a/libnm-core/nm-setting-bluetooth.c +++ b/libnm-core/nm-setting-bluetooth.c @@ -41,24 +41,6 @@ * Point (NAP) profiles. **/ -/** - * nm_setting_bluetooth_error_quark: - * - * Registers an error quark for #NMSettingBluetooth if necessary. - * - * Returns: the error quark used for #NMSettingBluetooth errors. - **/ -GQuark -nm_setting_bluetooth_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-setting-bluetooth-error-quark"); - return quark; -} - - G_DEFINE_TYPE_WITH_CODE (NMSettingBluetooth, nm_setting_bluetooth, NM_TYPE_SETTING, _nm_register_setting (BLUETOOTH, 1)) NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_BLUETOOTH) @@ -131,8 +113,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!priv->bdaddr) { g_set_error_literal (error, - NM_SETTING_BLUETOOTH_ERROR, - NM_SETTING_BLUETOOTH_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property is missing")); g_prefix_error (error, "%s.%s: ", NM_SETTING_BLUETOOTH_SETTING_NAME, NM_SETTING_BLUETOOTH_BDADDR); return FALSE; @@ -140,8 +122,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!nm_utils_hwaddr_valid (priv->bdaddr, ETH_ALEN)) { g_set_error_literal (error, - NM_SETTING_BLUETOOTH_ERROR, - NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is invalid")); g_prefix_error (error, "%s.%s: ", NM_SETTING_BLUETOOTH_SETTING_NAME, NM_SETTING_BLUETOOTH_BDADDR); return FALSE; @@ -149,16 +131,16 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!priv->type) { g_set_error_literal (error, - NM_SETTING_BLUETOOTH_ERROR, - NM_SETTING_BLUETOOTH_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property is missing")); g_prefix_error (error, "%s.%s: ", NM_SETTING_BLUETOOTH_SETTING_NAME, NM_SETTING_BLUETOOTH_TYPE); return FALSE; } else if (!g_str_equal (priv->type, NM_SETTING_BLUETOOTH_TYPE_DUN) && !g_str_equal (priv->type, NM_SETTING_BLUETOOTH_TYPE_PANU)) { g_set_error (error, - NM_SETTING_BLUETOOTH_ERROR, - NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' is not a valid value for the property"), priv->type); g_prefix_error (error, "%s.%s: ", NM_SETTING_BLUETOOTH_SETTING_NAME, NM_SETTING_BLUETOOTH_TYPE); @@ -174,12 +156,17 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) cdma = !!nm_setting_find_in_list (all_settings, NM_SETTING_CDMA_SETTING_NAME); if (!gsm && !cdma) { + /* We can't return MISSING_SETTING here, because we don't know + * whether to prefix the message with NM_SETTING_GSM_SETTING_NAME or + * NM_SETTING_CDMA_SETTING_NAME. + */ g_set_error (error, - NM_SETTING_BLUETOOTH_ERROR, - NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND, - _("requires '%s' or '%s' setting"), + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_SETTING, + _("'%s' connection requires '%s' or '%s' setting"), + NM_SETTING_BLUETOOTH_TYPE_DUN, NM_SETTING_GSM_SETTING_NAME, NM_SETTING_CDMA_SETTING_NAME); - g_prefix_error (error, "%s.%s: ", NM_SETTING_BLUETOOTH_SETTING_NAME, NM_SETTING_BLUETOOTH_TYPE); + g_prefix_error (error, "%s: ", NM_SETTING_BLUETOOTH_SETTING_NAME); return FALSE; } } diff --git a/libnm-core/nm-setting-bluetooth.h b/libnm-core/nm-setting-bluetooth.h index d030f9760..ca0c17110 100644 --- a/libnm-core/nm-setting-bluetooth.h +++ b/libnm-core/nm-setting-bluetooth.h @@ -40,26 +40,6 @@ G_BEGIN_DECLS #define NM_SETTING_BLUETOOTH_SETTING_NAME "bluetooth" -/** - * NMSettingBluetoothError: - * @NM_SETTING_BLUETOOTH_ERROR_UNKNOWN: unknown or unclassified error - * @NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY: the property was invalid - * @NM_SETTING_BLUETOOTH_ERROR_MISSING_PROPERTY: the property was missing and is - * required - * @NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND: the connection - * did not contain a required type setting, ie for DUN connections the connection - * must also contain an #NMSettingGsm or #NMSettingCdma as appropriate - */ -typedef enum { - NM_SETTING_BLUETOOTH_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ - NM_SETTING_BLUETOOTH_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ - NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND, /*< nick=TypeSettingNotFound >*/ -} NMSettingBluetoothError; - -#define NM_SETTING_BLUETOOTH_ERROR nm_setting_bluetooth_error_quark () -GQuark nm_setting_bluetooth_error_quark (void); - #define NM_SETTING_BLUETOOTH_BDADDR "bdaddr" #define NM_SETTING_BLUETOOTH_TYPE "type" diff --git a/libnm-core/nm-setting-bond.c b/libnm-core/nm-setting-bond.c index 3725553e1..19eee1edf 100644 --- a/libnm-core/nm-setting-bond.c +++ b/libnm-core/nm-setting-bond.c @@ -39,24 +39,6 @@ * necessary for bond connections. **/ -/** - * nm_setting_bond_error_quark: - * - * Registers an error quark for #NMSettingBond if necessary. - * - * Returns: the error quark used for #NMSettingBond errors. - **/ -GQuark -nm_setting_bond_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-setting-bond-error-quark"); - return quark; -} - - G_DEFINE_TYPE_WITH_CODE (NMSettingBond, nm_setting_bond, NM_TYPE_SETTING, _nm_register_setting (BOND, 1)) NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_BOND) @@ -471,8 +453,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &value)) { if (!value[0] || !nm_setting_bond_validate_option (key, value)) { g_set_error (error, - NM_SETTING_BOND_ERROR, - NM_SETTING_BOND_ERROR_INVALID_OPTION, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("invalid option '%s' or its value '%s'"), key, value); g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS); @@ -490,8 +472,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) /* Can only set one of miimon and arp_interval */ if (miimon > 0 && arp_interval > 0) { g_set_error (error, - NM_SETTING_BOND_ERROR, - NM_SETTING_BOND_ERROR_INVALID_OPTION, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("only one of '%s' and '%s' can be set"), NM_SETTING_BOND_OPTION_MIIMON, NM_SETTING_BOND_OPTION_ARP_INTERVAL); @@ -501,8 +483,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) value = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_MODE); if (!value) { g_set_error (error, - NM_SETTING_BOND_ERROR, - NM_SETTING_BOND_ERROR_MISSING_OPTION, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("mandatory option '%s' is missing"), NM_SETTING_BOND_OPTION_MODE); g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS); @@ -510,8 +492,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) } if (!_nm_utils_string_in_list (value, valid_modes)) { g_set_error (error, - NM_SETTING_BOND_ERROR, - NM_SETTING_BOND_ERROR_INVALID_OPTION, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' is not a valid value for '%s'"), value, NM_SETTING_BOND_OPTION_MODE); g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS); @@ -523,8 +505,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) || strcmp (value, "balance-tlb") == 0) { if (arp_interval > 0) { g_set_error (error, - NM_SETTING_BOND_ERROR, - NM_SETTING_BOND_ERROR_INVALID_OPTION, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s=%s' is incompatible with '%s > 0'"), NM_SETTING_BOND_OPTION_MODE, value, NM_SETTING_BOND_OPTION_ARP_INTERVAL); g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS); @@ -536,8 +518,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (strcmp (value, "active-backup") == 0) { if (primary && !nm_utils_iface_valid_name (primary)) { g_set_error (error, - NM_SETTING_BOND_ERROR, - NM_SETTING_BOND_ERROR_INVALID_OPTION, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' is not a valid interface name for '%s' option"), primary, NM_SETTING_BOND_OPTION_PRIMARY); g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS); @@ -546,8 +528,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) } else { if (primary) { g_set_error (error, - NM_SETTING_BOND_ERROR, - NM_SETTING_BOND_ERROR_INVALID_OPTION, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' option is only valid for '%s=%s'"), NM_SETTING_BOND_OPTION_PRIMARY, NM_SETTING_BOND_OPTION_MODE, "active-backup"); @@ -559,8 +541,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (nm_setting_find_in_list (all_settings, NM_SETTING_INFINIBAND_SETTING_NAME)) { if (strcmp (value, "active-backup") != 0) { g_set_error (error, - NM_SETTING_BOND_ERROR, - NM_SETTING_BOND_ERROR_INVALID_OPTION, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s=%s' is not a valid configuration for '%s'"), NM_SETTING_BOND_OPTION_MODE, value, NM_SETTING_INFINIBAND_SETTING_NAME); g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS); @@ -572,8 +554,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) /* updelay and downdelay can only be used with miimon */ if (g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_UPDELAY)) { g_set_error (error, - NM_SETTING_BOND_ERROR, - NM_SETTING_BOND_ERROR_INVALID_OPTION, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' option requires '%s' option to be set"), NM_SETTING_BOND_OPTION_UPDELAY, NM_SETTING_BOND_OPTION_MIIMON); g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS); @@ -581,8 +563,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) } if (g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_DOWNDELAY)) { g_set_error (error, - NM_SETTING_BOND_ERROR, - NM_SETTING_BOND_ERROR_INVALID_OPTION, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' option requires '%s' option to be set"), NM_SETTING_BOND_OPTION_DOWNDELAY, NM_SETTING_BOND_OPTION_MIIMON); g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS); @@ -601,8 +583,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!arp_ip_target) { g_set_error (error, - NM_SETTING_BOND_ERROR, - NM_SETTING_BOND_ERROR_MISSING_OPTION, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' option requires '%s' option to be set"), NM_SETTING_BOND_OPTION_ARP_INTERVAL, NM_SETTING_BOND_OPTION_ARP_IP_TARGET); g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS); @@ -612,8 +594,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) addrs = g_strsplit (arp_ip_target, ",", -1); if (!addrs[0]) { g_set_error (error, - NM_SETTING_BOND_ERROR, - NM_SETTING_BOND_ERROR_INVALID_OPTION, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' option is empty"), NM_SETTING_BOND_OPTION_ARP_IP_TARGET); g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS); @@ -624,8 +606,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) for (i = 0; addrs[i]; i++) { if (!inet_pton (AF_INET, addrs[i], &addr)) { g_set_error (error, - NM_SETTING_BOND_ERROR, - NM_SETTING_BOND_ERROR_INVALID_OPTION, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' is not a valid IPv4 address for '%s' option"), NM_SETTING_BOND_OPTION_ARP_IP_TARGET, addrs[i]); g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS); @@ -637,8 +619,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) } else { if (arp_ip_target) { g_set_error (error, - NM_SETTING_BOND_ERROR, - NM_SETTING_BOND_ERROR_INVALID_OPTION, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' option requires '%s' option to be set"), NM_SETTING_BOND_OPTION_ARP_IP_TARGET, NM_SETTING_BOND_OPTION_ARP_INTERVAL); g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS); @@ -651,8 +633,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) && (g_strcmp0 (value, "802.3ad") != 0 && g_strcmp0 (value, "4") != 0) && (strcmp (lacp_rate, "slow") != 0 && strcmp (lacp_rate, "0") != 0)) { g_set_error (error, - NM_SETTING_BOND_ERROR, - NM_SETTING_BOND_ERROR_INVALID_OPTION, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' option is only valid with mode '%s'"), NM_SETTING_BOND_OPTION_LACP_RATE, "802.3ad"); g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS); diff --git a/libnm-core/nm-setting-bond.h b/libnm-core/nm-setting-bond.h index 18f5e105f..e656ca887 100644 --- a/libnm-core/nm-setting-bond.h +++ b/libnm-core/nm-setting-bond.h @@ -39,24 +39,6 @@ G_BEGIN_DECLS #define NM_SETTING_BOND_SETTING_NAME "bond" -/** - * NMSettingBondError: - * @NM_SETTING_BOND_ERROR_UNKNOWN: unknown or unclassified error - * @NM_SETTING_BOND_ERROR_INVALID_PROPERTY: the property was invalid - * @NM_SETTING_BOND_ERROR_MISSING_PROPERTY: the property was missing and is - * required - */ -typedef enum { - NM_SETTING_BOND_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_SETTING_BOND_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ - NM_SETTING_BOND_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ - NM_SETTING_BOND_ERROR_INVALID_OPTION, /*< nick=InvalidOption >*/ - NM_SETTING_BOND_ERROR_MISSING_OPTION, /*< nick=MissingOption >*/ -} NMSettingBondError; - -#define NM_SETTING_BOND_ERROR nm_setting_bond_error_quark () -GQuark nm_setting_bond_error_quark (void); - #define NM_SETTING_BOND_OPTIONS "options" /* Valid options for the 'options' property */ diff --git a/libnm-core/nm-setting-bridge-port.c b/libnm-core/nm-setting-bridge-port.c index 7651adc23..05d394721 100644 --- a/libnm-core/nm-setting-bridge-port.c +++ b/libnm-core/nm-setting-bridge-port.c @@ -37,23 +37,6 @@ * optional properties that apply to bridge ports. **/ -/** - * nm_setting_bridge_port_error_quark: - * - * Registers an error quark for #NMSettingBridgePort if necessary. - * - * Returns: the error quark used for #NMSettingBridgePort errors. - **/ -GQuark -nm_setting_bridge_port_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-setting-bridge-port-error-quark"); - return quark; -} - G_DEFINE_TYPE_WITH_CODE (NMSettingBridgePort, nm_setting_bridge_port, NM_TYPE_SETTING, _nm_register_setting (BRIDGE_PORT, 3)) NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_BRIDGE_PORT) @@ -133,8 +116,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->priority > BR_MAX_PORT_PRIORITY) { g_set_error (error, - NM_SETTING_BRIDGE_PORT_ERROR, - NM_SETTING_BRIDGE_PORT_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%d' is not a valid value for the property (should be <= %d)"), priv->priority, BR_MAX_PORT_PRIORITY); g_prefix_error (error, "%s.%s: ", @@ -145,8 +128,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->path_cost > BR_MAX_PATH_COST) { g_set_error (error, - NM_SETTING_BRIDGE_PORT_ERROR, - NM_SETTING_BRIDGE_PORT_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%d' is not a valid value for the property (should be <= %d)"), priv->path_cost, BR_MAX_PATH_COST); g_prefix_error (error, "%s.%s: ", @@ -170,8 +153,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if ( slave_type && strcmp (slave_type, NM_SETTING_BRIDGE_SETTING_NAME)) { g_set_error (error, - NM_SETTING_CONNECTION_ERROR, - NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("A connection with a '%s' setting must have the slave-type set to '%s'. Instead it is '%s'"), NM_SETTING_BRIDGE_PORT_SETTING_NAME, NM_SETTING_BRIDGE_SETTING_NAME, diff --git a/libnm-core/nm-setting-bridge-port.h b/libnm-core/nm-setting-bridge-port.h index cf38d90e0..87fd898db 100644 --- a/libnm-core/nm-setting-bridge-port.h +++ b/libnm-core/nm-setting-bridge-port.h @@ -39,22 +39,6 @@ G_BEGIN_DECLS #define NM_SETTING_BRIDGE_PORT_SETTING_NAME "bridge-port" -/** - * NMSettingBridgePortError: - * @NM_SETTING_BRIDGE_PORT_ERROR_UNKNOWN: unknown or unclassified error - * @NM_SETTING_BRIDGE_PORT_ERROR_INVALID_PROPERTY: the property was invalid - * @NM_SETTING_BRIDGE_PORT_ERROR_MISSING_PROPERTY: the property was missing and - * is required - */ -typedef enum { - NM_SETTING_BRIDGE_PORT_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_SETTING_BRIDGE_PORT_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ - NM_SETTING_BRIDGE_PORT_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ -} NMSettingBridgePortError; - -#define NM_SETTING_BRIDGE_PORT_ERROR nm_setting_bridge_port_error_quark () -GQuark nm_setting_bridge_port_error_quark (void); - #define NM_SETTING_BRIDGE_PORT_PRIORITY "priority" #define NM_SETTING_BRIDGE_PORT_PATH_COST "path-cost" #define NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE "hairpin-mode" diff --git a/libnm-core/nm-setting-bridge.c b/libnm-core/nm-setting-bridge.c index 720f5cb27..082f8edb3 100644 --- a/libnm-core/nm-setting-bridge.c +++ b/libnm-core/nm-setting-bridge.c @@ -37,24 +37,6 @@ * necessary for bridging connections. **/ -/** - * nm_setting_bridge_error_quark: - * - * Registers an error quark for #NMSettingBridge if necessary. - * - * Returns: the error quark used for #NMSettingBridge errors. - **/ -GQuark -nm_setting_bridge_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-setting-bridge-error-quark"); - return quark; -} - - G_DEFINE_TYPE_WITH_CODE (NMSettingBridge, nm_setting_bridge, NM_TYPE_SETTING, _nm_register_setting (BRIDGE, 1)) NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_BRIDGE) @@ -217,8 +199,8 @@ check_range (guint32 val, { if ((val != 0) && (val < min || val > max)) { g_set_error (error, - NM_SETTING_BRIDGE_ERROR, - NM_SETTING_BRIDGE_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("value '%d' is out of range <%d-%d>"), val, min, max); g_prefix_error (error, "%s.%s: ", NM_SETTING_BRIDGE_SETTING_NAME, prop); @@ -234,8 +216,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->mac_address && !nm_utils_hwaddr_valid (priv->mac_address, ETH_ALEN)) { g_set_error_literal (error, - NM_SETTING_BRIDGE_ERROR, - NM_SETTING_BRIDGE_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("is not a valid MAC address")); g_prefix_error (error, "%s.%s: ", NM_SETTING_BRIDGE_SETTING_NAME, NM_SETTING_BRIDGE_MAC_ADDRESS); return FALSE; diff --git a/libnm-core/nm-setting-bridge.h b/libnm-core/nm-setting-bridge.h index 6fca58a3a..68eb10458 100644 --- a/libnm-core/nm-setting-bridge.h +++ b/libnm-core/nm-setting-bridge.h @@ -39,22 +39,6 @@ G_BEGIN_DECLS #define NM_SETTING_BRIDGE_SETTING_NAME "bridge" -/** - * NMSettingBridgeError: - * @NM_SETTING_BRIDGE_ERROR_UNKNOWN: unknown or unclassified error - * @NM_SETTING_BRIDGE_ERROR_INVALID_PROPERTY: the property was invalid - * @NM_SETTING_BRIDGE_ERROR_MISSING_PROPERTY: the property was missing and is - * required - */ -typedef enum { - NM_SETTING_BRIDGE_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_SETTING_BRIDGE_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ - NM_SETTING_BRIDGE_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ -} NMSettingBridgeError; - -#define NM_SETTING_BRIDGE_ERROR nm_setting_bridge_error_quark () -GQuark nm_setting_bridge_error_quark (void); - #define NM_SETTING_BRIDGE_MAC_ADDRESS "mac-address" #define NM_SETTING_BRIDGE_STP "stp" #define NM_SETTING_BRIDGE_PRIORITY "priority" diff --git a/libnm-core/nm-setting-cdma.c b/libnm-core/nm-setting-cdma.c index 88f1954db..02e7e2892 100644 --- a/libnm-core/nm-setting-cdma.c +++ b/libnm-core/nm-setting-cdma.c @@ -36,24 +36,6 @@ * networks, including those using CDMA2000/EVDO technology. */ -/** - * nm_setting_cdma_error_quark: - * - * Registers an error quark for #NMSettingCdma if necessary. - * - * Returns: the error quark used for #NMSettingCdma errors. - **/ -GQuark -nm_setting_cdma_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-setting-cdma-error-quark"); - return quark; -} - - G_DEFINE_TYPE_WITH_CODE (NMSettingCdma, nm_setting_cdma, NM_TYPE_SETTING, _nm_register_setting (CDMA, 1)) NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_CDMA) @@ -153,15 +135,15 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!priv->number) { g_set_error_literal (error, - NM_SETTING_CDMA_ERROR, - NM_SETTING_CDMA_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property is missing")); g_prefix_error (error, "%s.%s: ", NM_SETTING_CDMA_SETTING_NAME, NM_SETTING_CDMA_NUMBER); return FALSE; } else if (!strlen (priv->number)) { g_set_error_literal (error, - NM_SETTING_CDMA_ERROR, - NM_SETTING_CDMA_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is empty'")); g_prefix_error (error, "%s.%s: ", NM_SETTING_CDMA_SETTING_NAME, NM_SETTING_CDMA_NUMBER); return FALSE; @@ -169,8 +151,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->username && !strlen (priv->username)) { g_set_error_literal (error, - NM_SETTING_CDMA_ERROR, - NM_SETTING_CDMA_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is empty")); g_prefix_error (error, "%s.%s: ", NM_SETTING_CDMA_SETTING_NAME, NM_SETTING_CDMA_USERNAME); return FALSE; @@ -178,8 +160,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->password && !strlen (priv->password)) { g_set_error_literal (error, - NM_SETTING_CDMA_ERROR, - NM_SETTING_CDMA_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is empty")); g_prefix_error (error, "%s.%s: ", NM_SETTING_CDMA_SETTING_NAME, NM_SETTING_CDMA_PASSWORD); return FALSE; diff --git a/libnm-core/nm-setting-cdma.h b/libnm-core/nm-setting-cdma.h index 5c13d67f5..49f77a6ad 100644 --- a/libnm-core/nm-setting-cdma.h +++ b/libnm-core/nm-setting-cdma.h @@ -40,25 +40,6 @@ G_BEGIN_DECLS #define NM_SETTING_CDMA_SETTING_NAME "cdma" -/** - * NMSettingCdmaError: - * @NM_SETTING_CDMA_ERROR_UNKNOWN: unknown or unclassified error - * @NM_SETTING_CDMA_ERROR_INVALID_PROPERTY: the property was invalid - * @NM_SETTING_CDMA_ERROR_MISSING_PROPERTY: the property was missing and is - * required - * @NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING: the required #NMSettingSerial - * is missing in the connection - */ -typedef enum { - NM_SETTING_CDMA_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_SETTING_CDMA_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ - NM_SETTING_CDMA_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ - NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING /*< nick=MissingSerialSetting >*/ -} NMSettingCdmaError; - -#define NM_SETTING_CDMA_ERROR nm_setting_cdma_error_quark () -GQuark nm_setting_cdma_error_quark (void); - #define NM_SETTING_CDMA_NUMBER "number" #define NM_SETTING_CDMA_USERNAME "username" #define NM_SETTING_CDMA_PASSWORD "password" diff --git a/libnm-core/nm-setting-connection.c b/libnm-core/nm-setting-connection.c index c4edd8e02..b060345b6 100644 --- a/libnm-core/nm-setting-connection.c +++ b/libnm-core/nm-setting-connection.c @@ -38,24 +38,6 @@ * a #NMSettingConnection setting. **/ -/** - * nm_setting_connection_error_quark: - * - * Registers an error quark for #NMSettingConnection if necessary. - * - * Returns: the error quark used for #NMSettingConnection errors. - **/ -GQuark -nm_setting_connection_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-setting-connection-error-quark"); - return quark; -} - - G_DEFINE_TYPE_WITH_CODE (NMSettingConnection, nm_setting_connection, NM_TYPE_SETTING, _nm_register_setting (CONNECTION, 0)) NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_CONNECTION) @@ -754,11 +736,11 @@ static void _set_error_missing_base_setting (GError **error, const char *type) { g_set_error (error, - NM_SETTING_CONNECTION_ERROR, - NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND, - _("requires presence of '%s' setting in the connection"), + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_SETTING, + _("setting required for connection of type '%s'"), type); - g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_TYPE); + g_prefix_error (error, "%s: ", type); } static gboolean @@ -775,15 +757,15 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!priv->id) { g_set_error_literal (error, - NM_SETTING_CONNECTION_ERROR, - NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property is missing")); g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_ID); return FALSE; } else if (!priv->id[0]) { g_set_error_literal (error, - NM_SETTING_CONNECTION_ERROR, - NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is empty")); g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_ID); return FALSE; @@ -791,15 +773,15 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!priv->uuid) { g_set_error_literal (error, - NM_SETTING_CONNECTION_ERROR, - NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property is missing")); g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_UUID); return FALSE; } else if (!nm_utils_is_uuid (priv->uuid)) { g_set_error (error, - NM_SETTING_CONNECTION_ERROR, - NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' is not a valid UUID"), priv->uuid); g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_UUID); @@ -809,8 +791,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->interface_name) { if (!nm_utils_iface_valid_name (priv->interface_name)) { g_set_error (error, - NM_SETTING_CONNECTION_ERROR, - NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' is not a valid interface name"), priv->interface_name); g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_INTERFACE_NAME); @@ -821,8 +803,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!priv->type) { if (!(normerr_base_type = _nm_setting_find_in_list_base_type (all_settings))) { g_set_error_literal (error, - NM_SETTING_CONNECTION_ERROR, - NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property is missing")); g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_TYPE); return FALSE; @@ -832,8 +814,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!priv->type[0]) { g_set_error_literal (error, - NM_SETTING_CONNECTION_ERROR, - NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is empty")); g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_TYPE); return FALSE; @@ -842,8 +824,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) base_type = nm_setting_lookup_type (priv->type); if (base_type == G_TYPE_INVALID || !_nm_setting_type_is_base_type (base_type)) { g_set_error (error, - NM_SETTING_CONNECTION_ERROR, - NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("connection type '%s' is not valid"), priv->type); g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_TYPE); @@ -877,8 +859,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->slave_type && !is_slave) { g_set_error (error, - NM_SETTING_CONNECTION_ERROR, - NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("Unknown slave type '%s'"), priv->slave_type); g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_SLAVE_TYPE); return FALSE; @@ -887,8 +869,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (is_slave) { if (!priv->master) { g_set_error_literal (error, - NM_SETTING_CONNECTION_ERROR, - NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("Slave connections need a valid '" NM_SETTING_CONNECTION_MASTER "' property")); g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_MASTER); return FALSE; @@ -908,8 +890,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) normerr_missing_slave_type_port = nm_setting_get_name (s_port); } else { g_set_error_literal (error, - NM_SETTING_CONNECTION_ERROR, - NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("Cannot set '" NM_SETTING_CONNECTION_MASTER "' without '" NM_SETTING_CONNECTION_SLAVE_TYPE "'")); g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_SLAVE_TYPE); return FALSE; @@ -921,8 +903,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (normerr_base_type) { g_set_error (error, - NM_SETTING_CONNECTION_ERROR, - NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property type should be set to '%s'"), nm_setting_get_name (normerr_base_type)); g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_TYPE); @@ -936,18 +918,18 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (normerr_slave_setting_type) { g_set_error (error, - NM_SETTING_CONNECTION_ERROR, - NM_SETTING_CONNECTION_ERROR_SLAVE_SETTING_NOT_FOUND, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_SETTING, _("slave-type '%s' requires a '%s' setting in the connection"), priv->slave_type, normerr_slave_setting_type); - g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_SLAVE_TYPE); + g_prefix_error (error, "%s: ", normerr_slave_setting_type); return NM_SETTING_VERIFY_NORMALIZABLE_ERROR; } if (normerr_missing_slave_type) { g_set_error (error, - NM_SETTING_CONNECTION_ERROR, - NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("Detect a slave connection with '" NM_SETTING_CONNECTION_MASTER "' set and a port type '%s'. '" NM_SETTING_CONNECTION_SLAVE_TYPE "' should be set to '%s'"), normerr_missing_slave_type_port, normerr_missing_slave_type); g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_SLAVE_TYPE); diff --git a/libnm-core/nm-setting-connection.h b/libnm-core/nm-setting-connection.h index 4b40401d3..13890c32a 100644 --- a/libnm-core/nm-setting-connection.h +++ b/libnm-core/nm-setting-connection.h @@ -40,38 +40,6 @@ G_BEGIN_DECLS #define NM_SETTING_CONNECTION_SETTING_NAME "connection" -/** - * NMSettingConnectionError: - * @NM_SETTING_CONNECTION_ERROR_UNKNOWN: unknown or unclassified error - * @NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY: the property's value is - * invalid - * @NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY: a required property is not - * present - * @NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND: the #NMSetting object - * referenced by the setting name contained in the - * #NMSettingConnection:type property was not present in the #NMConnection - * @NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED: ip configuration is not - * allowed to be present. - * @NM_SETTING_CONNECTION_ERROR_SLAVE_SETTING_NOT_FOUND: the mandatory #NMSetting - * object for the slave is missing. The slave type depends on #NMSettingConnection:slave-type - * - * Describes errors that may result from operations involving a - * #NMSettingConnection. - * - **/ -typedef enum -{ - NM_SETTING_CONNECTION_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ - NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ - NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND, /*< nick=TypeSettingNotFound >*/ - NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED, /*< nick=IpConfigNotAllowed >*/ - NM_SETTING_CONNECTION_ERROR_SLAVE_SETTING_NOT_FOUND, /*< nick=SlaveSettingNotFound >*/ -} NMSettingConnectionError; - -#define NM_SETTING_CONNECTION_ERROR nm_setting_connection_error_quark () -GQuark nm_setting_connection_error_quark (void); - #define NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_MIN -999 #define NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_MAX 999 #define NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_DEFAULT 0 diff --git a/libnm-core/nm-setting-dcb.c b/libnm-core/nm-setting-dcb.c index b708098ca..e68be5e10 100644 --- a/libnm-core/nm-setting-dcb.c +++ b/libnm-core/nm-setting-dcb.c @@ -39,24 +39,6 @@ * of storage technologies like Fibre Channel over Ethernet (FCoE) and iSCSI. **/ -/** - * nm_setting_dcb_error_quark: - * - * Registers an error quark for #NMSettingDcb if necessary. - * - * Returns: the error quark used for #NMSettingDcb errors. - **/ -GQuark -nm_setting_dcb_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-setting-dcb-error-quark"); - return quark; -} - - G_DEFINE_TYPE_WITH_CODE (NMSettingDcb, nm_setting_dcb, NM_TYPE_SETTING, _nm_register_setting (DCB, 2)) NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_DCB) @@ -534,8 +516,8 @@ check_dcb_flags (NMSettingDcbFlags flags, const char *prop_name, GError **error) { if (flags & ~DCB_FLAGS_ALL) { g_set_error_literal (error, - NM_SETTING_DCB_ERROR, - NM_SETTING_DCB_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("flags invalid")); g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, prop_name); return FALSE; @@ -543,8 +525,8 @@ check_dcb_flags (NMSettingDcbFlags flags, const char *prop_name, GError **error) if (!(flags & NM_SETTING_DCB_FLAG_ENABLE) && (flags & ~NM_SETTING_DCB_FLAG_ENABLE)) { g_set_error_literal (error, - NM_SETTING_DCB_ERROR, - NM_SETTING_DCB_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("flags invalid - disabled")); g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, prop_name); return FALSE; @@ -569,8 +551,8 @@ check_uint_array (const guint *array, for (i = 0; i < len; i++) { if (!(flags & NM_SETTING_DCB_FLAG_ENABLE) && array[i]) { g_set_error_literal (error, - NM_SETTING_DCB_ERROR, - NM_SETTING_DCB_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property invalid (not enabled)")); g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, prop_name); return FALSE; @@ -578,8 +560,8 @@ check_uint_array (const guint *array, if ((array[i] > max) && (array[i] != extra)) { g_set_error_literal (error, - NM_SETTING_DCB_ERROR, - NM_SETTING_DCB_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("element invalid")); g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, prop_name); return FALSE; @@ -593,8 +575,8 @@ check_uint_array (const guint *array, /* If the feature is enabled, sum must equal 100% */ if (sum != 100) { g_set_error_literal (error, - NM_SETTING_DCB_ERROR, - NM_SETTING_DCB_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("sum not 100%")); g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, prop_name); return FALSE; @@ -618,8 +600,8 @@ check_priority (gint val, { if (!(flags & NM_SETTING_DCB_FLAG_ENABLE) && (val >= 0)) { g_set_error_literal (error, - NM_SETTING_DCB_ERROR, - NM_SETTING_DCB_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property invalid (not enabled)")); g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, prop_name); return FALSE; @@ -627,8 +609,8 @@ check_priority (gint val, if (val < -1 || val > 7) { g_set_error_literal (error, - NM_SETTING_DCB_ERROR, - NM_SETTING_DCB_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property invalid")); g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, prop_name); return FALSE; @@ -649,8 +631,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!priv->app_fcoe_mode) { g_set_error_literal (error, - NM_SETTING_DCB_ERROR, - NM_SETTING_DCB_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property missing")); g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, NM_SETTING_DCB_APP_FCOE_MODE); return FALSE; @@ -659,8 +641,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (strcmp (priv->app_fcoe_mode, NM_SETTING_DCB_FCOE_MODE_FABRIC) && strcmp (priv->app_fcoe_mode, NM_SETTING_DCB_FCOE_MODE_VN2VN)) { g_set_error_literal (error, - NM_SETTING_DCB_ERROR, - NM_SETTING_DCB_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property invalid")); g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, NM_SETTING_DCB_APP_FCOE_MODE); return FALSE; diff --git a/libnm-core/nm-setting-dcb.h b/libnm-core/nm-setting-dcb.h index ab3c6bc9d..089d266cf 100644 --- a/libnm-core/nm-setting-dcb.h +++ b/libnm-core/nm-setting-dcb.h @@ -40,22 +40,6 @@ G_BEGIN_DECLS #define NM_SETTING_DCB_SETTING_NAME "dcb" /** - * NMSettingDcbError: - * @NM_SETTING_DCB_ERROR_UNKNOWN: unknown or unclassified error - * @NM_SETTING_DCB_ERROR_INVALID_PROPERTY: the property was invalid - * @NM_SETTING_DCB_ERROR_MISSING_PROPERTY: the property was missing and is - * required - */ -typedef enum { - NM_SETTING_DCB_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_SETTING_DCB_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ - NM_SETTING_DCB_ERROR_MISSING_PROPERTY /*< nick=MissingProperty >*/ -} NMSettingDcbError; - -#define NM_SETTING_DCB_ERROR nm_setting_dcb_error_quark () -GQuark nm_setting_dcb_error_quark (void); - -/** * NMSettingDcbFlags: * @NM_SETTING_DCB_FLAG_NONE: no flag * @NM_SETTING_DCB_FLAG_ENABLE: the feature is enabled diff --git a/libnm-core/nm-setting-generic.c b/libnm-core/nm-setting-generic.c index 2c160b917..35deb2de0 100644 --- a/libnm-core/nm-setting-generic.c +++ b/libnm-core/nm-setting-generic.c @@ -36,23 +36,6 @@ * the "connection type" setting on #NMConnections for generic devices. **/ -/** - * nm_setting_generic_error_quark: - * - * Registers an error quark for #NMSettingGeneric if necessary. - * - * Returns: the error quark used for #NMSettingGeneric errors. - **/ -GQuark -nm_setting_generic_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-setting-generic-error-quark"); - return quark; -} - G_DEFINE_TYPE_WITH_CODE (NMSettingGeneric, nm_setting_generic, NM_TYPE_SETTING, _nm_register_setting (GENERIC, 1)) NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_GENERIC) diff --git a/libnm-core/nm-setting-generic.h b/libnm-core/nm-setting-generic.h index aa9efd17f..db12b8049 100644 --- a/libnm-core/nm-setting-generic.h +++ b/libnm-core/nm-setting-generic.h @@ -39,22 +39,6 @@ G_BEGIN_DECLS #define NM_SETTING_GENERIC_SETTING_NAME "generic" -/** - * NMSettingGenericError: - * @NM_SETTING_GENERIC_ERROR_UNKNOWN: unknown or unclassified error - * @NM_SETTING_GENERIC_ERROR_INVALID_PROPERTY: the property was invalid - * @NM_SETTING_GENERIC_ERROR_MISSING_PROPERTY: the property was missing and - * is required - */ -typedef enum { - NM_SETTING_GENERIC_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_SETTING_GENERIC_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ - NM_SETTING_GENERIC_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ -} NMSettingGenericError; - -#define NM_SETTING_GENERIC_ERROR nm_setting_generic_error_quark () -GQuark nm_setting_generic_error_quark (void); - typedef struct { NMSetting parent; } NMSettingGeneric; diff --git a/libnm-core/nm-setting-gsm.c b/libnm-core/nm-setting-gsm.c index 84ea468a9..7661db655 100644 --- a/libnm-core/nm-setting-gsm.c +++ b/libnm-core/nm-setting-gsm.c @@ -37,24 +37,6 @@ * networks, including those using GPRS/EDGE and UMTS/HSPA technology. */ -/** - * nm_setting_gsm_error_quark: - * - * Registers an error quark for #NMSettingGsm if necessary. - * - * Returns: the error quark used for #NMSettingGsm errors. - **/ -GQuark -nm_setting_gsm_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-setting-gsm-error-quark"); - return quark; -} - - G_DEFINE_TYPE_WITH_CODE (NMSettingGsm, nm_setting_gsm, NM_TYPE_SETTING, _nm_register_setting (GSM, 1)) NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_GSM) @@ -237,8 +219,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->number && !priv->number[0]) { g_set_error_literal (error, - NM_SETTING_GSM_ERROR, - NM_SETTING_GSM_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is empty")); g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_NUMBER); return FALSE; @@ -250,8 +232,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (apn_len < 1 || apn_len > 64) { g_set_error (error, - NM_SETTING_GSM_ERROR, - NM_SETTING_GSM_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property value '%s' is empty or too long (>64)"), priv->apn); g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_APN); @@ -282,8 +264,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) && (priv->apn[i] != '_') && (priv->apn[i] != '-')) { g_set_error (error, - NM_SETTING_GSM_ERROR, - NM_SETTING_GSM_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' contains invalid char(s) (use [A-Za-z._-])"), priv->apn); g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_APN); @@ -294,8 +276,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->username && !strlen (priv->username)) { g_set_error_literal (error, - NM_SETTING_GSM_ERROR, - NM_SETTING_GSM_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is empty")); g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_USERNAME); return FALSE; @@ -303,8 +285,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->password && !strlen (priv->password)) { g_set_error_literal (error, - NM_SETTING_GSM_ERROR, - NM_SETTING_GSM_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is empty")); g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_USERNAME); return FALSE; @@ -317,8 +299,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) /* Accept both 5 and 6 digit MCC/MNC codes */ if ((nid_len < 5) || (nid_len > 6)) { g_set_error (error, - NM_SETTING_GSM_ERROR, - NM_SETTING_GSM_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' length is invalid (should be 5 or 6 digits)"), priv->network_id); g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_NETWORK_ID); @@ -328,8 +310,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) for (i = 0; i < nid_len; i++) { if (!g_ascii_isdigit (priv->network_id[i])) { g_set_error (error, - NM_SETTING_GSM_ERROR, - NM_SETTING_GSM_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' is not a number"), priv->network_id); g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_NETWORK_ID); diff --git a/libnm-core/nm-setting-gsm.h b/libnm-core/nm-setting-gsm.h index c44a03486..21e3c92b6 100644 --- a/libnm-core/nm-setting-gsm.h +++ b/libnm-core/nm-setting-gsm.h @@ -40,25 +40,6 @@ G_BEGIN_DECLS #define NM_SETTING_GSM_SETTING_NAME "gsm" -/** - * NMSettingGsmError: - * @NM_SETTING_GSM_ERROR_UNKNOWN: unknown or unclassified error - * @NM_SETTING_GSM_ERROR_INVALID_PROPERTY: the property was invalid - * @NM_SETTING_GSM_ERROR_MISSING_PROPERTY: the property was missing and is - * required - * @NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING: the required #NMSettingSerial - * is missing in the connection - */ -typedef enum { - NM_SETTING_GSM_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_SETTING_GSM_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ - NM_SETTING_GSM_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ - NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING /*< nick=MissingSerialSetting >*/ -} NMSettingGsmError; - -#define NM_SETTING_GSM_ERROR nm_setting_gsm_error_quark () -GQuark nm_setting_gsm_error_quark (void); - #define NM_SETTING_GSM_NUMBER "number" #define NM_SETTING_GSM_USERNAME "username" #define NM_SETTING_GSM_PASSWORD "password" diff --git a/libnm-core/nm-setting-infiniband.c b/libnm-core/nm-setting-infiniband.c index 6c8d31e23..b7ae1a318 100644 --- a/libnm-core/nm-setting-infiniband.c +++ b/libnm-core/nm-setting-infiniband.c @@ -36,23 +36,6 @@ * necessary for connection to IP-over-InfiniBand networks. **/ -/** - * nm_setting_infiniband_error_quark: - * - * Registers an error quark for #NMSettingInfiniband if necessary. - * - * Returns: the error quark used for #NMSettingInfiniband errors. - **/ -GQuark -nm_setting_infiniband_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-setting-infiniband-error-quark"); - return quark; -} - G_DEFINE_TYPE_WITH_CODE (NMSettingInfiniband, nm_setting_infiniband, NM_TYPE_SETTING, _nm_register_setting (INFINIBAND, 1)) NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_INFINIBAND) @@ -203,8 +186,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->mac_address && !nm_utils_hwaddr_valid (priv->mac_address, INFINIBAND_ALEN)) { g_set_error_literal (error, - NM_SETTING_INFINIBAND_ERROR, - NM_SETTING_INFINIBAND_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is invalid")); g_prefix_error (error, "%s.%s: ", NM_SETTING_INFINIBAND_SETTING_NAME, NM_SETTING_INFINIBAND_MAC_ADDRESS); return FALSE; @@ -218,8 +201,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) normerr_max_mtu = 65520; } else { g_set_error_literal (error, - NM_SETTING_INFINIBAND_ERROR, - NM_SETTING_INFINIBAND_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is invalid")); g_prefix_error (error, "%s.%s: ", NM_SETTING_INFINIBAND_SETTING_NAME, NM_SETTING_INFINIBAND_TRANSPORT_MODE); return FALSE; @@ -228,16 +211,16 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->parent) { if (!nm_utils_iface_valid_name (priv->parent)) { g_set_error_literal (error, - NM_SETTING_INFINIBAND_ERROR, - NM_SETTING_INFINIBAND_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("not a valid interface name")); g_prefix_error (error, "%s: ", NM_SETTING_INFINIBAND_PARENT); return FALSE; } if (priv->p_key == -1) { g_set_error_literal (error, - NM_SETTING_INFINIBAND_ERROR, - NM_SETTING_INFINIBAND_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("Must specify a P_Key if specifying parent")); g_prefix_error (error, "%s: ", NM_SETTING_INFINIBAND_PARENT); } @@ -246,8 +229,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->p_key != -1) { if (!priv->mac_address && !priv->parent) { g_set_error_literal (error, - NM_SETTING_INFINIBAND_ERROR, - NM_SETTING_INFINIBAND_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("InfiniBand P_Key connection did not specify parent interface name")); g_prefix_error (error, "%s: ", NM_SETTING_INFINIBAND_PARENT); return FALSE; @@ -266,8 +249,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) * NMSettingInfiniband. **/ g_set_error (error, - NM_SETTING_CONNECTION_ERROR, - NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' is not a valid interface name"), interface_name); g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_INTERFACE_NAME); @@ -282,8 +265,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) * for now just reject such connections. **/ g_set_error (error, - NM_SETTING_CONNECTION_ERROR, - NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("interface name of software infiniband device must be '%s' or unset (instead it is '%s')"), priv->virtual_iface_name, interface_name); g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_INTERFACE_NAME); @@ -297,8 +280,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (normerr_max_mtu > 0) { g_set_error (error, - NM_SETTING_INFINIBAND_ERROR, - NM_SETTING_INFINIBAND_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("mtu for transport mode '%s' can be at most %d but it is %d"), priv->transport_mode, normerr_max_mtu, priv->mtu); g_prefix_error (error, "%s.%s: ", NM_SETTING_INFINIBAND_SETTING_NAME, NM_SETTING_INFINIBAND_MTU); diff --git a/libnm-core/nm-setting-infiniband.h b/libnm-core/nm-setting-infiniband.h index 2b8aabd10..35a576b3b 100644 --- a/libnm-core/nm-setting-infiniband.h +++ b/libnm-core/nm-setting-infiniband.h @@ -39,22 +39,6 @@ G_BEGIN_DECLS #define NM_SETTING_INFINIBAND_SETTING_NAME "infiniband" -/** - * NMSettingInfinibandError: - * @NM_SETTING_INFINIBAND_ERROR_UNKNOWN: unknown or unclassified error - * @NM_SETTING_INFINIBAND_ERROR_INVALID_PROPERTY: the property was invalid - * @NM_SETTING_INFINIBAND_ERROR_MISSING_PROPERTY: the property was missing and is - * required - */ -typedef enum { - NM_SETTING_INFINIBAND_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_SETTING_INFINIBAND_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ - NM_SETTING_INFINIBAND_ERROR_MISSING_PROPERTY /*< nick=MissingProperty >*/ -} NMSettingInfinibandError; - -#define NM_SETTING_INFINIBAND_ERROR nm_setting_infiniband_error_quark () -GQuark nm_setting_infiniband_error_quark (void); - #define NM_SETTING_INFINIBAND_MAC_ADDRESS "mac-address" #define NM_SETTING_INFINIBAND_MTU "mtu" #define NM_SETTING_INFINIBAND_TRANSPORT_MODE "transport-mode" diff --git a/libnm-core/nm-setting-ip4-config.c b/libnm-core/nm-setting-ip4-config.c index ba31bcedb..c1384bb54 100644 --- a/libnm-core/nm-setting-ip4-config.c +++ b/libnm-core/nm-setting-ip4-config.c @@ -38,23 +38,6 @@ * properties related to IPv4 addressing, routing, and Domain Name Service **/ -/** - * nm_setting_ip4_config_error_quark: - * - * Registers an error quark for #NMSettingIP4Config if necessary. - * - * Returns: the error quark used for #NMSettingIP4Config errors. - **/ -GQuark -nm_setting_ip4_config_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-setting-ip4-config-error-quark"); - return quark; -} - G_DEFINE_BOXED_TYPE (NMIP4Address, nm_ip4_address, nm_ip4_address_dup, nm_ip4_address_unref) G_DEFINE_BOXED_TYPE (NMIP4Route, nm_ip4_route, nm_ip4_route_dup, nm_ip4_route_unref) @@ -892,8 +875,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!priv->method) { g_set_error_literal (error, - NM_SETTING_IP4_CONFIG_ERROR, - NM_SETTING_IP4_CONFIG_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property is missing")); g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_METHOD); return FALSE; @@ -902,8 +885,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!strcmp (priv->method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) { if (!priv->addresses) { g_set_error (error, - NM_SETTING_IP4_CONFIG_ERROR, - NM_SETTING_IP4_CONFIG_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("this property cannot be empty for '%s=%s'"), NM_SETTING_IP4_CONFIG_METHOD, priv->method); g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_ADDRESSES); @@ -914,8 +897,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) || !strcmp (priv->method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED)) { if (priv->dns) { g_set_error (error, - NM_SETTING_IP4_CONFIG_ERROR, - NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("this property is not allowed for '%s=%s'"), NM_SETTING_IP4_CONFIG_METHOD, priv->method); g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_DNS); @@ -924,8 +907,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->dns_search) { g_set_error (error, - NM_SETTING_IP4_CONFIG_ERROR, - NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("this property is not allowed for '%s=%s'"), NM_SETTING_IP4_CONFIG_METHOD, priv->method); g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_DNS_SEARCH); @@ -936,8 +919,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (strcmp (priv->method, NM_SETTING_IP4_CONFIG_METHOD_SHARED) != 0) { if (priv->addresses) { g_set_error (error, - NM_SETTING_IP4_CONFIG_ERROR, - NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("this property is not allowed for '%s=%s'"), NM_SETTING_IP4_CONFIG_METHOD, priv->method); g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_ADDRESSES); @@ -948,8 +931,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) /* nothing to do */ } else { g_set_error_literal (error, - NM_SETTING_IP4_CONFIG_ERROR, - NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is invalid")); g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_METHOD); return FALSE; @@ -957,8 +940,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->dhcp_client_id && !strlen (priv->dhcp_client_id)) { g_set_error_literal (error, - NM_SETTING_IP4_CONFIG_ERROR, - NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is empty")); g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID); return FALSE; @@ -966,8 +949,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->dhcp_hostname && !strlen (priv->dhcp_hostname)) { g_set_error_literal (error, - NM_SETTING_IP4_CONFIG_ERROR, - NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is empty")); g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME); return FALSE; @@ -983,8 +966,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!nm_ip4_address_get_address (addr)) { g_set_error (error, - NM_SETTING_IP4_CONFIG_ERROR, - NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("%d. IPv4 address is invalid"), i+1); g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_ADDRESSES); @@ -993,8 +976,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!prefix || prefix > 32) { g_set_error (error, - NM_SETTING_IP4_CONFIG_ERROR, - NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("%d. IPv4 address has invalid prefix"), i+1); g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_ADDRESSES); @@ -1003,8 +986,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!verify_label (label)) { g_set_error (error, - NM_SETTING_IP4_CONFIG_ERROR, - NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("%d. IPv4 address has invalid label '%s'"), i+1, label); g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, "address-labels"); @@ -1014,8 +997,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (iter || l_iter) { g_set_error (error, - NM_SETTING_IP4_CONFIG_ERROR, - NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("IPv4 address / label count mismatch (%d vs %d)"), g_slist_length (priv->addresses), g_slist_length (priv->address_labels)); @@ -1030,8 +1013,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!nm_ip4_route_get_dest (route)) { g_set_error (error, - NM_SETTING_IP4_CONFIG_ERROR, - NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("%d. route is invalid"), i+1); g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_ROUTES); @@ -1040,8 +1023,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!prefix || prefix > 32) { g_set_error (error, - NM_SETTING_IP4_CONFIG_ERROR, - NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("%d. route has invalid prefix"), i+1); g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_ROUTES); @@ -1056,8 +1039,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (inet_pton (AF_INET, dns, &addr) != 1) { g_set_error (error, - NM_SETTING_IP4_CONFIG_ERROR, - NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("%d. DNS server address is invalid"), i+1); g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_DNS); diff --git a/libnm-core/nm-setting-ip4-config.h b/libnm-core/nm-setting-ip4-config.h index 489157113..004024113 100644 --- a/libnm-core/nm-setting-ip4-config.h +++ b/libnm-core/nm-setting-ip4-config.h @@ -40,25 +40,6 @@ G_BEGIN_DECLS #define NM_SETTING_IP4_CONFIG_SETTING_NAME "ipv4" -/** - * NMSettingIP4ConfigError: - * @NM_SETTING_IP4_CONFIG_ERROR_UNKNOWN: unknown or unclassified error - * @NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY: the property was invalid - * @NM_SETTING_IP4_CONFIG_ERROR_MISSING_PROPERTY: the property was missing and is - * required - * @NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD: the property's value is - * not valid with the given IP4 method - */ -typedef enum { - NM_SETTING_IP4_CONFIG_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ - NM_SETTING_IP4_CONFIG_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ - NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD /*< nick=NotAllowedForMethod >*/ -} NMSettingIP4ConfigError; - -#define NM_SETTING_IP4_CONFIG_ERROR nm_setting_ip4_config_error_quark () -GQuark nm_setting_ip4_config_error_quark (void); - #define NM_SETTING_IP4_CONFIG_METHOD "method" #define NM_SETTING_IP4_CONFIG_DNS "dns" #define NM_SETTING_IP4_CONFIG_DNS_SEARCH "dns-search" diff --git a/libnm-core/nm-setting-ip6-config.c b/libnm-core/nm-setting-ip6-config.c index 5e03e6891..ca08ad8bb 100644 --- a/libnm-core/nm-setting-ip6-config.c +++ b/libnm-core/nm-setting-ip6-config.c @@ -37,23 +37,6 @@ * properties related to IPv6 addressing, routing, and Domain Name Service **/ -/** - * nm_setting_ip6_config_error_quark: - * - * Registers an error quark for #NMSettingIP6Config if necessary. - * - * Returns: the error quark used for #NMSettingIP6Config errors. - **/ -GQuark -nm_setting_ip6_config_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-setting-ip6-config-error-quark"); - return quark; -} - G_DEFINE_BOXED_TYPE (NMIP6Address, nm_ip6_address, nm_ip6_address_dup, nm_ip6_address_unref) G_DEFINE_BOXED_TYPE (NMIP6Route, nm_ip6_route, nm_ip6_route_dup, nm_ip6_route_unref) @@ -811,8 +794,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!priv->method) { g_set_error_literal (error, - NM_SETTING_IP6_CONFIG_ERROR, - NM_SETTING_IP6_CONFIG_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property is missing")); g_prefix_error (error, "%s.%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP6_CONFIG_METHOD); return FALSE; @@ -821,8 +804,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!strcmp (priv->method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL)) { if (!priv->addresses) { g_set_error (error, - NM_SETTING_IP6_CONFIG_ERROR, - NM_SETTING_IP6_CONFIG_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("this property cannot be empty for '%s=%s'"), NM_SETTING_IP6_CONFIG_METHOD, priv->method); g_prefix_error (error, "%s.%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP6_CONFIG_ADDRESSES); @@ -833,8 +816,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) || !strcmp (priv->method, NM_SETTING_IP6_CONFIG_METHOD_SHARED)) { if (priv->dns) { g_set_error (error, - NM_SETTING_IP6_CONFIG_ERROR, - NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' not allowed for %s=%s"), _("this property is not allowed for '%s=%s'"), NM_SETTING_IP6_CONFIG_METHOD, priv->method); @@ -844,8 +827,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->dns_search) { g_set_error (error, - NM_SETTING_IP6_CONFIG_ERROR, - NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("this property is not allowed for '%s=%s'"), NM_SETTING_IP6_CONFIG_METHOD, priv->method); g_prefix_error (error, "%s.%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP6_CONFIG_DNS_SEARCH); @@ -854,8 +837,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->addresses) { g_set_error (error, - NM_SETTING_IP6_CONFIG_ERROR, - NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("this property is not allowed for '%s=%s'"), NM_SETTING_IP6_CONFIG_METHOD, priv->method); g_prefix_error (error, "%s.%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP6_CONFIG_ADDRESSES); @@ -866,8 +849,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) /* nothing to do */ } else { g_set_error_literal (error, - NM_SETTING_IP6_CONFIG_ERROR, - NM_SETTING_IP6_CONFIG_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is invalid")); g_prefix_error (error, "%s.%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP6_CONFIG_METHOD); return FALSE; @@ -875,8 +858,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->dhcp_hostname && !strlen (priv->dhcp_hostname)) { g_set_error_literal (error, - NM_SETTING_IP6_CONFIG_ERROR, - NM_SETTING_IP6_CONFIG_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is missing")); g_prefix_error (error, "%s.%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP6_CONFIG_DHCP_HOSTNAME); return FALSE; @@ -888,8 +871,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (inet_pton (AF_INET6, dns, &addr) != 1) { g_set_error (error, - NM_SETTING_IP6_CONFIG_ERROR, - NM_SETTING_IP6_CONFIG_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("%d. DNS server address is invalid"), i+1); g_prefix_error (error, "%s.%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP6_CONFIG_DNS); diff --git a/libnm-core/nm-setting-ip6-config.h b/libnm-core/nm-setting-ip6-config.h index 349cc36a4..ec6299f3f 100644 --- a/libnm-core/nm-setting-ip6-config.h +++ b/libnm-core/nm-setting-ip6-config.h @@ -41,25 +41,6 @@ G_BEGIN_DECLS #define NM_SETTING_IP6_CONFIG_SETTING_NAME "ipv6" -/** - * NMSettingIP6ConfigError: - * @NM_SETTING_IP6_CONFIG_ERROR_UNKNOWN: unknown or unclassified error - * @NM_SETTING_IP6_CONFIG_ERROR_INVALID_PROPERTY: the property was invalid - * @NM_SETTING_IP6_CONFIG_ERROR_MISSING_PROPERTY: the property was missing and is - * required - * @NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD: the property's value is - * not valid with the given IPv6 method - */ -typedef enum { - NM_SETTING_IP6_CONFIG_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_SETTING_IP6_CONFIG_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ - NM_SETTING_IP6_CONFIG_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ - NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD /*< nick=NotAllowedForMethod >*/ -} NMSettingIP6ConfigError; - -#define NM_SETTING_IP6_CONFIG_ERROR nm_setting_ip6_config_error_quark () -GQuark nm_setting_ip6_config_error_quark (void); - #define NM_SETTING_IP6_CONFIG_METHOD "method" #define NM_SETTING_IP6_CONFIG_DNS "dns" #define NM_SETTING_IP6_CONFIG_DNS_SEARCH "dns-search" diff --git a/libnm-core/nm-setting-olpc-mesh.c b/libnm-core/nm-setting-olpc-mesh.c index 2d5967c6d..92d104579 100644 --- a/libnm-core/nm-setting-olpc-mesh.c +++ b/libnm-core/nm-setting-olpc-mesh.c @@ -29,16 +29,6 @@ #include "nm-utils-private.h" #include "nm-setting-private.h" -GQuark -nm_setting_olpc_mesh_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-setting-olpc-mesh-error-quark"); - return quark; -} - static void nm_setting_olpc_mesh_init (NMSettingOlpcMesh *setting); G_DEFINE_TYPE_WITH_CODE (NMSettingOlpcMesh, nm_setting_olpc_mesh, NM_TYPE_SETTING, @@ -111,8 +101,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!priv->ssid) { g_set_error_literal (error, - NM_SETTING_OLPC_MESH_ERROR, - NM_SETTING_OLPC_MESH_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property is missing")); g_prefix_error (error, "%s.%s: ", NM_SETTING_OLPC_MESH_SETTING_NAME, NM_SETTING_OLPC_MESH_SSID); return FALSE; @@ -121,8 +111,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) length = g_bytes_get_size (priv->ssid); if (length == 0 || length > 32) { g_set_error_literal (error, - NM_SETTING_OLPC_MESH_ERROR, - NM_SETTING_OLPC_MESH_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("SSID length is out of range <1-32> bytes")); g_prefix_error (error, "%s.%s: ", NM_SETTING_OLPC_MESH_SETTING_NAME, NM_SETTING_OLPC_MESH_SSID); return FALSE; @@ -130,8 +120,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->channel == 0 || priv->channel > 13) { g_set_error (error, - NM_SETTING_OLPC_MESH_ERROR, - NM_SETTING_OLPC_MESH_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%d' is not a valid channel"), priv->channel); g_prefix_error (error, "%s.%s: ", NM_SETTING_OLPC_MESH_SETTING_NAME, NM_SETTING_OLPC_MESH_CHANNEL); @@ -140,8 +130,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->dhcp_anycast_addr && !nm_utils_hwaddr_valid (priv->dhcp_anycast_addr, ETH_ALEN)) { g_set_error_literal (error, - NM_SETTING_OLPC_MESH_ERROR, - NM_SETTING_OLPC_MESH_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is invalid")); g_prefix_error (error, "%s.%s: ", NM_SETTING_OLPC_MESH_SETTING_NAME, NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS); return FALSE; diff --git a/libnm-core/nm-setting-olpc-mesh.h b/libnm-core/nm-setting-olpc-mesh.h index c36389454..a3e202adf 100644 --- a/libnm-core/nm-setting-olpc-mesh.h +++ b/libnm-core/nm-setting-olpc-mesh.h @@ -40,22 +40,6 @@ G_BEGIN_DECLS #define NM_SETTING_OLPC_MESH_SETTING_NAME "802-11-olpc-mesh" -/** - * NMSettingOlpcMeshError: - * @NM_SETTING_OLPC_MESH_ERROR_UNKNOWN: unknown or unclassified error - * @NM_SETTING_OLPC_MESH_ERROR_INVALID_PROPERTY: the property was invalid - * @NM_SETTING_OLPC_MESH_ERROR_MISSING_PROPERTY: the property was missing and is - * required - */ -typedef enum { - NM_SETTING_OLPC_MESH_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_SETTING_OLPC_MESH_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ - NM_SETTING_OLPC_MESH_ERROR_MISSING_PROPERTY /*< nick=MissingProperty >*/ -} NMSettingOlpcMeshError; - -#define NM_SETTING_OLPC_MESH_ERROR nm_setting_olpc_mesh_error_quark () -GQuark nm_setting_olpc_mesh_error_quark (void); - #define NM_SETTING_OLPC_MESH_SSID "ssid" #define NM_SETTING_OLPC_MESH_CHANNEL "channel" #define NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS "dhcp-anycast-address" diff --git a/libnm-core/nm-setting-ppp.c b/libnm-core/nm-setting-ppp.c index 6431dc550..d150fe778 100644 --- a/libnm-core/nm-setting-ppp.c +++ b/libnm-core/nm-setting-ppp.c @@ -35,24 +35,6 @@ * cable and DSL modems and some mobile broadband devices. **/ -/** - * nm_setting_ppp_error_quark: - * - * Registers an error quark for #NMSettingPpp if necessary. - * - * Returns: the error quark used for #NMSettingPpp errors. - **/ -GQuark -nm_setting_ppp_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-setting-ppp-error-quark"); - return quark; -} - - G_DEFINE_TYPE_WITH_CODE (NMSettingPpp, nm_setting_ppp, NM_TYPE_SETTING, _nm_register_setting (PPP, 3)) NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_PPP) @@ -378,8 +360,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->mru > 0) { if (priv->mru < 128 || priv->mru > 16384) { g_set_error (error, - NM_SETTING_PPP_ERROR, - NM_SETTING_PPP_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%d' is out of valid range <128-16384>"), priv->mru); g_prefix_error (error, "%s.%s: ", NM_SETTING_PPP_SETTING_NAME, NM_SETTING_PPP_MRU); @@ -391,8 +373,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) /* lcp_echo_interval must also be non-zero */ if (priv->lcp_echo_interval == 0) { g_set_error (error, - NM_SETTING_PPP_ERROR, - NM_SETTING_PPP_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("setting this property requires non-zero '%s' property"), NM_SETTING_PPP_LCP_ECHO_INTERVAL); g_prefix_error (error, "%s.%s: ", NM_SETTING_PPP_SETTING_NAME, NM_SETTING_PPP_LCP_ECHO_FAILURE); diff --git a/libnm-core/nm-setting-ppp.h b/libnm-core/nm-setting-ppp.h index 34be5b26f..a1d2b6281 100644 --- a/libnm-core/nm-setting-ppp.h +++ b/libnm-core/nm-setting-ppp.h @@ -40,25 +40,6 @@ G_BEGIN_DECLS #define NM_SETTING_PPP_SETTING_NAME "ppp" -/** - * NMSettingPppError: - * @NM_SETTING_PPP_ERROR_UNKNOWN: unknown or unclassified error - * @NM_SETTING_PPP_ERROR_INVALID_PROPERTY: the property was invalid - * @NM_SETTING_PPP_ERROR_MISSING_PROPERTY: the property was missing and is - * required - * @NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED: requiring MPPE is not compatible - * with other setting configuration parameters - */ -typedef enum { - NM_SETTING_PPP_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_SETTING_PPP_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ - NM_SETTING_PPP_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ - NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED /*< nick=RequireMPPENotAllowed >*/ -} NMSettingPppError; - -#define NM_SETTING_PPP_ERROR nm_setting_ppp_error_quark () -GQuark nm_setting_ppp_error_quark (void); - #define NM_SETTING_PPP_NOAUTH "noauth" #define NM_SETTING_PPP_REFUSE_EAP "refuse-eap" #define NM_SETTING_PPP_REFUSE_PAP "refuse-pap" diff --git a/libnm-core/nm-setting-pppoe.c b/libnm-core/nm-setting-pppoe.c index dab6d942c..488e4ba40 100644 --- a/libnm-core/nm-setting-pppoe.c +++ b/libnm-core/nm-setting-pppoe.c @@ -37,24 +37,6 @@ * to provide IP transport, for example cable or DSL modems. **/ -/** - * nm_setting_pppoe_error_quark: - * - * Registers an error quark for #NMSettingPppoe if necessary. - * - * Returns: the error quark used for #NMSettingPppoe errors. - **/ -GQuark -nm_setting_pppoe_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-setting-pppoe-error-quark"); - return quark; -} - - G_DEFINE_TYPE_WITH_CODE (NMSettingPppoe, nm_setting_pppoe, NM_TYPE_SETTING, _nm_register_setting (PPPOE, 3)) NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_PPPOE) @@ -154,15 +136,15 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!priv->username) { g_set_error_literal (error, - NM_SETTING_PPPOE_ERROR, - NM_SETTING_PPPOE_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property is missing")); g_prefix_error (error, "%s.%s: ", NM_SETTING_PPPOE_SETTING_NAME, NM_SETTING_PPPOE_USERNAME); return FALSE; } else if (!strlen (priv->username)) { g_set_error_literal (error, - NM_SETTING_PPPOE_ERROR, - NM_SETTING_PPPOE_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is empty")); g_prefix_error (error, "%s.%s: ", NM_SETTING_PPPOE_SETTING_NAME, NM_SETTING_PPPOE_USERNAME); return FALSE; @@ -170,8 +152,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->service && !strlen (priv->service)) { g_set_error_literal (error, - NM_SETTING_PPPOE_ERROR, - NM_SETTING_PPPOE_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is empty")); g_prefix_error (error, "%s.%s: ", NM_SETTING_PPPOE_SETTING_NAME, NM_SETTING_PPPOE_SERVICE); return FALSE; diff --git a/libnm-core/nm-setting-pppoe.h b/libnm-core/nm-setting-pppoe.h index 652c9c9b0..8595baf14 100644 --- a/libnm-core/nm-setting-pppoe.h +++ b/libnm-core/nm-setting-pppoe.h @@ -40,25 +40,6 @@ G_BEGIN_DECLS #define NM_SETTING_PPPOE_SETTING_NAME "pppoe" -/** - * NMSettingPppoeError: - * @NM_SETTING_PPPOE_ERROR_UNKNOWN: unknown or unclassified error - * @NM_SETTING_PPPOE_ERROR_INVALID_PROPERTY: the property was invalid - * @NM_SETTING_PPPOE_ERROR_MISSING_PROPERTY: the property was missing and is - * required - * @NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING: the connection - * did not contain a required PPP setting for PPP related options - */ -typedef enum { - NM_SETTING_PPPOE_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_SETTING_PPPOE_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ - NM_SETTING_PPPOE_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ - NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING /*< nick=MissingPPPSetting >*/ -} NMSettingPppoeError; - -#define NM_SETTING_PPPOE_ERROR nm_setting_pppoe_error_quark () -GQuark nm_setting_pppoe_error_quark (void); - #define NM_SETTING_PPPOE_SERVICE "service" #define NM_SETTING_PPPOE_USERNAME "username" #define NM_SETTING_PPPOE_PASSWORD "password" diff --git a/libnm-core/nm-setting-serial.c b/libnm-core/nm-setting-serial.c index f2651a182..23a37fe86 100644 --- a/libnm-core/nm-setting-serial.c +++ b/libnm-core/nm-setting-serial.c @@ -36,24 +36,6 @@ * such as mobile broadband or analog telephone connections. **/ -/** - * nm_setting_serial_error_quark: - * - * Registers an error quark for #NMSettingSerial if necessary. - * - * Returns: the error quark used for #NMSettingSerial errors. - **/ -GQuark -nm_setting_serial_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-setting-serial-error-quark"); - return quark; -} - - G_DEFINE_TYPE_WITH_CODE (NMSettingSerial, nm_setting_serial, NM_TYPE_SETTING, _nm_register_setting (SERIAL, 2)) NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_SERIAL) diff --git a/libnm-core/nm-setting-serial.h b/libnm-core/nm-setting-serial.h index 80600ff80..15b18150b 100644 --- a/libnm-core/nm-setting-serial.h +++ b/libnm-core/nm-setting-serial.h @@ -41,25 +41,6 @@ G_BEGIN_DECLS #define NM_SETTING_SERIAL_SETTING_NAME "serial" /** - * NMSettingSerialError: - * @NM_SETTING_SERIAL_ERROR_UNKNOWN: unknown or unclassified error - * @NM_SETTING_SERIAL_ERROR_INVALID_PROPERTY: the property was invalid - * @NM_SETTING_SERIAL_ERROR_MISSING_PROPERTY: the property was missing and is - * required - * @NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING: one of the properties of the - * setting requires the connection to contain an #NMSettingPpp setting - */ -typedef enum { - NM_SETTING_SERIAL_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_SETTING_SERIAL_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ - NM_SETTING_SERIAL_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ - NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING /*< nick=MissingPPPSetting >*/ -} NMSettingSerialError; - -#define NM_SETTING_SERIAL_ERROR nm_setting_serial_error_quark () -GQuark nm_setting_serial_error_quark (void); - -/** * NMSettingSerialParity: * @NM_SETTING_SERIAL_PARITY_NONE: No parity bits (default) * @NM_SETTING_SERIAL_PARITY_EVEN: Even parity diff --git a/libnm-core/nm-setting-team-port.c b/libnm-core/nm-setting-team-port.c index ae50094c5..dceab5c74 100644 --- a/libnm-core/nm-setting-team-port.c +++ b/libnm-core/nm-setting-team-port.c @@ -36,23 +36,6 @@ * optional properties that apply to team ports. **/ -/** - * nm_setting_team_port_error_quark: - * - * Registers an error quark for #NMSettingTeamPort if necessary. - * - * Returns: the error quark used for #NMSettingTeamPort errors. - **/ -GQuark -nm_setting_team_port_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-setting-team-port-error-quark"); - return quark; -} - G_DEFINE_TYPE_WITH_CODE (NMSettingTeamPort, nm_setting_team_port, NM_TYPE_SETTING, _nm_register_setting (TEAM_PORT, 3)) NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_TEAM_PORT) @@ -113,8 +96,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if ( slave_type && strcmp (slave_type, NM_SETTING_TEAM_SETTING_NAME)) { g_set_error (error, - NM_SETTING_CONNECTION_ERROR, - NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("A connection with a '%s' setting must have the slave-type set to '%s'. Instead it is '%s'"), NM_SETTING_TEAM_PORT_SETTING_NAME, NM_SETTING_TEAM_SETTING_NAME, diff --git a/libnm-core/nm-setting-team-port.h b/libnm-core/nm-setting-team-port.h index f8ed805c6..644b0b5bd 100644 --- a/libnm-core/nm-setting-team-port.h +++ b/libnm-core/nm-setting-team-port.h @@ -38,22 +38,6 @@ G_BEGIN_DECLS #define NM_SETTING_TEAM_PORT_SETTING_NAME "team-port" -/** - * NMSettingTeamPortError: - * @NM_SETTING_TEAM_PORT_ERROR_UNKNOWN: unknown or unclassified error - * @NM_SETTING_TEAM_PORT_ERROR_INVALID_PROPERTY: the property was invalid - * @NM_SETTING_TEAM_PORT_ERROR_MISSING_PROPERTY: the property was missing and - * is required - */ -typedef enum { - NM_SETTING_TEAM_PORT_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_SETTING_TEAM_PORT_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ - NM_SETTING_TEAM_PORT_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ -} NMSettingTeamPortError; - -#define NM_SETTING_TEAM_PORT_ERROR nm_setting_team_port_error_quark () -GQuark nm_setting_team_port_error_quark (void); - #define NM_SETTING_TEAM_PORT_CONFIG "config" typedef struct { diff --git a/libnm-core/nm-setting-team.c b/libnm-core/nm-setting-team.c index cb41e6f0a..ab2d65eb6 100644 --- a/libnm-core/nm-setting-team.c +++ b/libnm-core/nm-setting-team.c @@ -35,24 +35,6 @@ * necessary for team connections. **/ -/** - * nm_setting_team_error_quark: - * - * Registers an error quark for #NMSettingTeam if necessary. - * - * Returns: the error quark used for #NMSettingTeam errors. - **/ -GQuark -nm_setting_team_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-setting-team-error-quark"); - return quark; -} - - G_DEFINE_TYPE_WITH_CODE (NMSettingTeam, nm_setting_team, NM_TYPE_SETTING, _nm_register_setting (TEAM, 1)) NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_TEAM) diff --git a/libnm-core/nm-setting-team.h b/libnm-core/nm-setting-team.h index 1e949ca66..0c7fd1f94 100644 --- a/libnm-core/nm-setting-team.h +++ b/libnm-core/nm-setting-team.h @@ -38,22 +38,6 @@ G_BEGIN_DECLS #define NM_SETTING_TEAM_SETTING_NAME "team" -/** - * NMSettingTeamError: - * @NM_SETTING_TEAM_ERROR_UNKNOWN: unknown or unclassified error - * @NM_SETTING_TEAM_ERROR_INVALID_PROPERTY: the property was invalid - * @NM_SETTING_TEAM_ERROR_MISSING_PROPERTY: the property was missing and is - * required - */ -typedef enum { - NM_SETTING_TEAM_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_SETTING_TEAM_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ - NM_SETTING_TEAM_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ -} NMSettingTeamError; - -#define NM_SETTING_TEAM_ERROR nm_setting_team_error_quark () -GQuark nm_setting_team_error_quark (void); - #define NM_SETTING_TEAM_CONFIG "config" typedef struct { diff --git a/libnm-core/nm-setting-vlan.c b/libnm-core/nm-setting-vlan.c index d797164f2..31fa51d85 100644 --- a/libnm-core/nm-setting-vlan.c +++ b/libnm-core/nm-setting-vlan.c @@ -37,23 +37,6 @@ * necessary for connection to VLAN interfaces. **/ -/** - * nm_setting_vlan_error_quark: - * - * Registers an error quark for #NMSettingVlan if necessary. - * - * Returns: the error quark used for #NMSettingVlan errors. - **/ -GQuark -nm_setting_vlan_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-setting-vlan-error-quark"); - return quark; -} - G_DEFINE_TYPE_WITH_CODE (NMSettingVlan, nm_setting_vlan, NM_TYPE_SETTING, _nm_register_setting (VLAN, 1)) NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_VLAN) @@ -524,8 +507,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (master && g_strcmp0 (priv->parent, master) != 0) { g_set_error (error, - NM_SETTING_VLAN_ERROR, - NM_SETTING_VLAN_ERROR_INVALID_PARENT, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' value doesn't match '%s=%s'"), priv->parent, NM_SETTING_CONNECTION_MASTER, master); g_prefix_error (error, "%s.%s: ", NM_SETTING_VLAN_SETTING_NAME, NM_SETTING_VLAN_PARENT); @@ -535,8 +518,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) } else if (!nm_utils_iface_valid_name (priv->parent)) { /* parent must be either a UUID or an interface name */ g_set_error (error, - NM_SETTING_VLAN_ERROR, - NM_SETTING_VLAN_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' is neither an UUID nor an interface name"), priv->parent); g_prefix_error (error, "%s.%s: ", NM_SETTING_VLAN_SETTING_NAME, NM_SETTING_VLAN_PARENT); @@ -549,8 +532,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if ( all_settings && (!s_wired || !nm_setting_wired_get_mac_address (s_wired))) { g_set_error (error, - NM_SETTING_VLAN_ERROR, - NM_SETTING_VLAN_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property is not specified and neither is '%s:%s'"), NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_MAC_ADDRESS); g_prefix_error (error, "%s.%s: ", NM_SETTING_VLAN_SETTING_NAME, NM_SETTING_VLAN_PARENT); @@ -562,8 +545,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) NM_VLAN_FLAG_GVRP | NM_VLAN_FLAG_LOOSE_BINDING)) { g_set_error_literal (error, - NM_SETTING_VLAN_ERROR, - NM_SETTING_VLAN_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("flags are invalid")); g_prefix_error (error, "%s.%s: ", NM_SETTING_VLAN_SETTING_NAME, NM_SETTING_VLAN_FLAGS); return FALSE; diff --git a/libnm-core/nm-setting-vlan.h b/libnm-core/nm-setting-vlan.h index 0ce5efbbd..68f73b815 100644 --- a/libnm-core/nm-setting-vlan.h +++ b/libnm-core/nm-setting-vlan.h @@ -40,25 +40,6 @@ G_BEGIN_DECLS #define NM_SETTING_VLAN_SETTING_NAME "vlan" -/** - * NMSettingVlanError: - * @NM_SETTING_VLAN_ERROR_UNKNOWN: unknown or unclassified error - * @NM_SETTING_VLAN_ERROR_INVALID_PROPERTY: the property was invalid - * @NM_SETTING_VLAN_ERROR_MISSING_PROPERTY: the property was missing and is - * required - * @NM_SETTING_VLAN_ERROR_INVALID_PARENT: the VLAN parent was specified - * inconsistently - */ -typedef enum { - NM_SETTING_VLAN_ERROR_UNKNOWN = 0, /*< nick=Unknown >*/ - NM_SETTING_VLAN_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ - NM_SETTING_VLAN_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ - NM_SETTING_VLAN_ERROR_INVALID_PARENT /*< nick=InvalidParent >*/ -} NMSettingVlanError; - -#define NM_SETTING_VLAN_ERROR nm_setting_vlan_error_quark () -GQuark nm_setting_vlan_error_quark (void); - #define NM_SETTING_VLAN_PARENT "parent" #define NM_SETTING_VLAN_ID "id" #define NM_SETTING_VLAN_FLAGS "flags" diff --git a/libnm-core/nm-setting-vpn.c b/libnm-core/nm-setting-vpn.c index 667b83d78..07f815716 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) diff --git a/libnm-core/nm-setting-vpn.h b/libnm-core/nm-setting-vpn.h index 059f8f99b..7a6fed86c 100644 --- a/libnm-core/nm-setting-vpn.h +++ b/libnm-core/nm-setting-vpn.h @@ -40,22 +40,6 @@ G_BEGIN_DECLS #define NM_SETTING_VPN_SETTING_NAME "vpn" -/** - * NMSettingVpnError: - * @NM_SETTING_VPN_ERROR_UNKNOWN: unknown or unclassified error - * @NM_SETTING_VPN_ERROR_INVALID_PROPERTY: the property was invalid - * @NM_SETTING_VPN_ERROR_MISSING_PROPERTY: the property was missing and is - * required - */ -typedef enum { - NM_SETTING_VPN_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_SETTING_VPN_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ - NM_SETTING_VPN_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ -} NMSettingVpnError; - -#define NM_SETTING_VPN_ERROR nm_setting_vpn_error_quark () -GQuark nm_setting_vpn_error_quark (void); - #define NM_SETTING_VPN_SERVICE_TYPE "service-type" #define NM_SETTING_VPN_USER_NAME "user-name" #define NM_SETTING_VPN_DATA "data" diff --git a/libnm-core/nm-setting-wimax.c b/libnm-core/nm-setting-wimax.c index bcb2458d4..113e27fc4 100644 --- a/libnm-core/nm-setting-wimax.c +++ b/libnm-core/nm-setting-wimax.c @@ -37,24 +37,6 @@ * necessary for connection to 802.16e Mobile WiMAX networks. **/ -/** - * nm_setting_wimax_error_quark: - * - * Registers an error quark for #NMSettingWimax if necessary. - * - * Returns: the error quark used for #NMSettingWimax errors. - **/ -GQuark -nm_setting_wimax_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-setting-wimax-error-quark"); - return quark; -} - - G_DEFINE_TYPE_WITH_CODE (NMSettingWimax, nm_setting_wimax, NM_TYPE_SETTING, _nm_register_setting (WIMAX, 1)) NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_WIMAX) @@ -128,8 +110,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!priv->network_name) { g_set_error_literal (error, - NM_SETTING_WIMAX_ERROR, - NM_SETTING_WIMAX_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property is missing")); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIMAX_SETTING_NAME, NM_SETTING_WIMAX_NETWORK_NAME); return FALSE; @@ -137,8 +119,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!strlen (priv->network_name)) { g_set_error_literal (error, - NM_SETTING_WIMAX_ERROR, - NM_SETTING_WIMAX_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is empty")); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIMAX_SETTING_NAME, NM_SETTING_WIMAX_NETWORK_NAME); return FALSE; @@ -146,8 +128,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->mac_address && !nm_utils_hwaddr_valid (priv->mac_address, ETH_ALEN)) { g_set_error_literal (error, - NM_SETTING_WIMAX_ERROR, - NM_SETTING_WIMAX_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is invalid")); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIMAX_SETTING_NAME, NM_SETTING_WIMAX_MAC_ADDRESS); return FALSE; diff --git a/libnm-core/nm-setting-wimax.h b/libnm-core/nm-setting-wimax.h index 68a7df93a..fe262a5a7 100644 --- a/libnm-core/nm-setting-wimax.h +++ b/libnm-core/nm-setting-wimax.h @@ -39,22 +39,6 @@ G_BEGIN_DECLS #define NM_SETTING_WIMAX_SETTING_NAME "wimax" -/** - * NMSettingWimaxError: - * @NM_SETTING_WIMAX_ERROR_UNKNOWN: unknown or unclassified error - * @NM_SETTING_WIMAX_ERROR_INVALID_PROPERTY: the property was invalid - * @NM_SETTING_WIMAX_ERROR_MISSING_PROPERTY: the property was missing and is - * required - */ -typedef enum { - NM_SETTING_WIMAX_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_SETTING_WIMAX_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ - NM_SETTING_WIMAX_ERROR_MISSING_PROPERTY /*< nick=MissingProperty >*/ -} NMSettingWimaxError; - -#define NM_SETTING_WIMAX_ERROR nm_setting_wimax_error_quark () -GQuark nm_setting_wimax_error_quark (void); - #define NM_SETTING_WIMAX_NETWORK_NAME "network-name" #define NM_SETTING_WIMAX_MAC_ADDRESS "mac-address" diff --git a/libnm-core/nm-setting-wired.c b/libnm-core/nm-setting-wired.c index 4338ab047..928dd628c 100644 --- a/libnm-core/nm-setting-wired.c +++ b/libnm-core/nm-setting-wired.c @@ -37,24 +37,6 @@ * necessary for connection to Ethernet networks. **/ -/** - * nm_setting_wired_error_quark: - * - * Registers an error quark for #NMSettingWired if necessary. - * - * Returns: the error quark used for #NMSettingWired errors. - **/ -GQuark -nm_setting_wired_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-setting-wired-error-quark"); - return quark; -} - - G_DEFINE_TYPE_WITH_CODE (NMSettingWired, nm_setting_wired, NM_TYPE_SETTING, _nm_register_setting (WIRED, 1)) NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_WIRED) @@ -586,8 +568,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->port && !_nm_utils_string_in_list (priv->port, valid_ports)) { g_set_error (error, - NM_SETTING_WIRED_ERROR, - NM_SETTING_WIRED_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' is not a valid Ethernet port value"), priv->port); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_PORT); @@ -596,8 +578,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->duplex && !_nm_utils_string_in_list (priv->duplex, valid_duplex)) { g_set_error (error, - NM_SETTING_WIRED_ERROR, - NM_SETTING_WIRED_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' is not a valid duplex value"), priv->duplex); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_DUPLEX); @@ -606,8 +588,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->device_mac_address && !nm_utils_hwaddr_valid (priv->device_mac_address, ETH_ALEN)) { g_set_error_literal (error, - NM_SETTING_WIRED_ERROR, - NM_SETTING_WIRED_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("is not a valid MAC address")); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_MAC_ADDRESS); return FALSE; @@ -617,8 +599,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) mac_blacklist_iter = mac_blacklist_iter->next) { if (!nm_utils_hwaddr_valid (mac_blacklist_iter->data, ETH_ALEN)) { g_set_error (error, - NM_SETTING_WIRED_ERROR, - NM_SETTING_WIRED_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' is not a valid MAC address"), (const char *) mac_blacklist_iter->data); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST); @@ -631,8 +613,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (len != 2 && len != 3) { g_set_error_literal (error, - NM_SETTING_WIRED_ERROR, - NM_SETTING_WIRED_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is invalid")); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_S390_SUBCHANNELS); return FALSE; @@ -641,8 +623,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->s390_nettype && !_nm_utils_string_in_list (priv->s390_nettype, valid_nettype)) { g_set_error_literal (error, - NM_SETTING_WIRED_ERROR, - NM_SETTING_WIRED_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is invalid")); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_S390_NETTYPE); return FALSE; @@ -654,8 +636,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) || !strlen (value) || (strlen (value) > 200)) { g_set_error (error, - NM_SETTING_WIRED_ERROR, - NM_SETTING_WIRED_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("invalid '%s' or its value '%s'"), key, value); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_S390_OPTIONS); @@ -665,8 +647,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->cloned_mac_address && !nm_utils_hwaddr_valid (priv->cloned_mac_address, ETH_ALEN)) { g_set_error_literal (error, - NM_SETTING_WIRED_ERROR, - NM_SETTING_WIRED_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("is not a valid MAC address")); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_CLONED_MAC_ADDRESS); return FALSE; diff --git a/libnm-core/nm-setting-wired.h b/libnm-core/nm-setting-wired.h index 73a25230c..ba8b4303f 100644 --- a/libnm-core/nm-setting-wired.h +++ b/libnm-core/nm-setting-wired.h @@ -40,22 +40,6 @@ G_BEGIN_DECLS #define NM_SETTING_WIRED_SETTING_NAME "802-3-ethernet" -/** - * NMSettingWiredError: - * @NM_SETTING_WIRED_ERROR_UNKNOWN: unknown or unclassified error - * @NM_SETTING_WIRED_ERROR_INVALID_PROPERTY: the property was invalid - * @NM_SETTING_WIRED_ERROR_MISSING_PROPERTY: the property was missing and is - * required - */ -typedef enum { - NM_SETTING_WIRED_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_SETTING_WIRED_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ - NM_SETTING_WIRED_ERROR_MISSING_PROPERTY /*< nick=MissingProperty >*/ -} NMSettingWiredError; - -#define NM_SETTING_WIRED_ERROR nm_setting_wired_error_quark () -GQuark nm_setting_wired_error_quark (void); - #define NM_SETTING_WIRED_PORT "port" #define NM_SETTING_WIRED_SPEED "speed" #define NM_SETTING_WIRED_DUPLEX "duplex" diff --git a/libnm-core/nm-setting-wireless-security.c b/libnm-core/nm-setting-wireless-security.c index c3e38bfc5..c6171869c 100644 --- a/libnm-core/nm-setting-wireless-security.c +++ b/libnm-core/nm-setting-wireless-security.c @@ -53,24 +53,6 @@ * ISBN: 978-1587051548 **/ -/** - * nm_setting_wireless_security_error_quark: - * - * Registers an error quark for #NMSettingWired if necessary. - * - * Returns: the error quark used for #NMSettingWired errors. - **/ -GQuark -nm_setting_wireless_security_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-setting-wireless-security-error-quark"); - return quark; -} - - G_DEFINE_TYPE_WITH_CODE (NMSettingWirelessSecurity, nm_setting_wireless_security, NM_TYPE_SETTING, _nm_register_setting (WIRELESS_SECURITY, 2)) NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_WIRELESS_SECURITY) @@ -874,8 +856,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!priv->key_mgmt) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property is missing")); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT); return FALSE; @@ -883,8 +865,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!_nm_utils_string_in_list (priv->key_mgmt, valid_key_mgmt)) { g_set_error (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' is not a valid value for the property"), priv->key_mgmt); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT); @@ -895,8 +877,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) /* LEAP must use ieee8021x key management */ if (strcmp (priv->key_mgmt, "ieee8021x")) { g_set_error (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' security requires '%s=%s'"), "leap", NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x"); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG); @@ -904,16 +886,16 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) } if (!priv->leap_username) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property is empty")); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME); return FALSE; } if (priv->leap_password && !strlen (priv->leap_password)) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property is empty")); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD); return FALSE; @@ -924,11 +906,11 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) /* Need an 802.1x setting too */ if (!nm_setting_find_in_list (all_settings, NM_SETTING_802_1X_SETTING_NAME)) { g_set_error (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_SETTING, _("'%s' security requires '%s' setting presence"), priv->key_mgmt, NM_SETTING_802_1X_SETTING_NAME); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT); + g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME); return FALSE; } } @@ -936,8 +918,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->leap_username && !strlen (priv->leap_username)) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is empty")); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME); return FALSE; @@ -945,8 +927,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->wep_tx_keyidx > 3) { g_set_error (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%d' value is out of range <0-3>"), priv->wep_tx_keyidx); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX); @@ -955,8 +937,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->wep_key_type > NM_WEP_KEY_TYPE_LAST) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is invalid")); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE); return FALSE; @@ -964,32 +946,32 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->wep_key0 && !nm_utils_wep_key_valid (priv->wep_key0, priv->wep_key_type)) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is invalid")); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0); return FALSE; } if (priv->wep_key1 && !nm_utils_wep_key_valid (priv->wep_key1, priv->wep_key_type)) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is invalid")); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_WEP_KEY1); return FALSE; } if (priv->wep_key2 && !nm_utils_wep_key_valid (priv->wep_key2, priv->wep_key_type)) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is invalid")); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_WEP_KEY2); return FALSE; } if (priv->wep_key3 && !nm_utils_wep_key_valid (priv->wep_key3, priv->wep_key_type)) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is invalid")); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_WEP_KEY3); return FALSE; @@ -997,8 +979,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->auth_alg && !_nm_utils_string_in_list (priv->auth_alg, valid_auth_algs)) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is invalid")); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG); return FALSE; @@ -1006,8 +988,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->psk && !nm_utils_wpa_psk_valid (priv->psk)) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is invalid")); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_PSK); return FALSE; @@ -1015,8 +997,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->proto && !_nm_utils_string_slist_validate (priv->proto, valid_protos)) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is invalid")); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_PROTO); return FALSE; @@ -1042,8 +1024,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) */ if (!found) { g_set_error (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' connections require '%s' in this property"), NM_SETTING_WIRELESS_MODE_ADHOC, "none"); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_PAIRWISE); @@ -1051,8 +1033,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) } } else if (!_nm_utils_string_slist_validate (priv->pairwise, valid_pairwise)) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is invalid")); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_PAIRWISE); return FALSE; @@ -1061,8 +1043,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->group && !_nm_utils_string_slist_validate (priv->group, valid_groups)) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is invalid")); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_GROUP); return FALSE; @@ -1072,8 +1054,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->auth_alg && !strcmp (priv->auth_alg, "shared")) { if (priv->key_mgmt && strcmp (priv->key_mgmt, "none")) { g_set_error (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' can only be used with '%s=%s' (WEP)"), "shared", NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none"); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG); diff --git a/libnm-core/nm-setting-wireless-security.h b/libnm-core/nm-setting-wireless-security.h index dac735784..7c9e7ec47 100644 --- a/libnm-core/nm-setting-wireless-security.h +++ b/libnm-core/nm-setting-wireless-security.h @@ -41,35 +41,6 @@ G_BEGIN_DECLS #define NM_SETTING_WIRELESS_SECURITY_SETTING_NAME "802-11-wireless-security" /** - * NMSettingWirelessSecurityError: - * @NM_SETTING_WIRELESS_SECURITY_ERROR_UNKNOWN: unknown or unclassified error - * @NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY: the property was invalid - * @NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_PROPERTY: the property was - * missing and is required - * @NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING: a property contained - * a value that requires the connection to contain a #NMSetting8021x setting - * @NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X: LEAP authentication - * was specified but key management was not set to "8021x" - * @NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME: LEAP authentication - * was specified but no LEAP username was given - * @NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP: Shared Key - * authentication was specified but the setting did not specify WEP as the - * encryption protocol - */ -typedef enum { - NM_SETTING_WIRELESS_SECURITY_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ - NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ - NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING, /*< nick=Missing8021xSetting >*/ - NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X, /*< nick=LEAPRequires8021x >*/ - NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME, /*< nick=LEAPRequiresUsername >*/ - NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP /*< nick=SharedKeyRequiresWEP >*/ -} NMSettingWirelessSecurityError; - -#define NM_SETTING_WIRELESS_SECURITY_ERROR nm_setting_wireless_security_error_quark () -GQuark nm_setting_wireless_security_error_quark (void); - -/** * NMWepKeyType: * @NM_WEP_KEY_TYPE_UNKNOWN: unknown WEP key type * @NM_WEP_KEY_TYPE_KEY: indicates a hexadecimal or ASCII formatted WEP key. diff --git a/libnm-core/nm-setting-wireless.c b/libnm-core/nm-setting-wireless.c index 17e7c3f3b..2c0dd5845 100644 --- a/libnm-core/nm-setting-wireless.c +++ b/libnm-core/nm-setting-wireless.c @@ -38,24 +38,6 @@ * necessary for connection to 802.11 Wi-Fi networks. **/ -/** - * nm_setting_wireless_error_quark: - * - * Registers an error quark for #NMSettingWireless if necessary. - * - * Returns: the error quark used for #NMSettingWireless errors. - **/ -GQuark -nm_setting_wireless_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-setting-wireless-error-quark"); - return quark; -} - - G_DEFINE_TYPE_WITH_CODE (NMSettingWireless, nm_setting_wireless, NM_TYPE_SETTING, _nm_register_setting (WIRELESS, 1)) NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_WIRELESS) @@ -705,8 +687,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!priv->ssid) { g_set_error_literal (error, - NM_SETTING_WIRELESS_ERROR, - NM_SETTING_WIRELESS_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property is missing")); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SSID); return FALSE; @@ -715,8 +697,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) length = g_bytes_get_size (priv->ssid); if (length == 0 || length > 32) { g_set_error_literal (error, - NM_SETTING_WIRELESS_ERROR, - NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("SSID length is out of range <1-32> bytes")); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SSID); return FALSE; @@ -724,8 +706,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->mode && !_nm_utils_string_in_list (priv->mode, valid_modes)) { g_set_error (error, - NM_SETTING_WIRELESS_ERROR, - NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' is not a valid Wi-Fi mode"), priv->mode); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_MODE); @@ -734,8 +716,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->band && !_nm_utils_string_in_list (priv->band, valid_bands)) { g_set_error (error, - NM_SETTING_WIRELESS_ERROR, - NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' is not a valid band"), priv->band); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_BAND); @@ -744,19 +726,19 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->channel && !priv->band) { g_set_error (error, - NM_SETTING_WIRELESS_ERROR, - NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND, - _("requires setting '%s' property"), - NM_SETTING_WIRELESS_BAND); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_CHANNEL); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, + _("'%s' requires setting '%s' property"), + NM_SETTING_WIRELESS_CHANNEL, NM_SETTING_WIRELESS_BAND); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_BAND); return FALSE; } if (priv->channel) { if (!nm_utils_wifi_is_channel_valid (priv->channel, priv->band)) { g_set_error (error, - NM_SETTING_WIRELESS_ERROR, - NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%d' is not a valid channel"), priv->channel); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_CHANNEL); @@ -766,8 +748,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->bssid && !nm_utils_hwaddr_valid (priv->bssid, ETH_ALEN)) { g_set_error_literal (error, - NM_SETTING_WIRELESS_ERROR, - NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is invalid")); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_BSSID); return FALSE; @@ -775,8 +757,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->device_mac_address && !nm_utils_hwaddr_valid (priv->device_mac_address, ETH_ALEN)) { g_set_error_literal (error, - NM_SETTING_WIRELESS_ERROR, - NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is invalid")); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_MAC_ADDRESS); return FALSE; @@ -784,8 +766,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (priv->cloned_mac_address && !nm_utils_hwaddr_valid (priv->cloned_mac_address, ETH_ALEN)) { g_set_error_literal (error, - NM_SETTING_WIRELESS_ERROR, - NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is invalid")); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS); return FALSE; @@ -794,8 +776,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) for (iter = priv->mac_address_blacklist; iter; iter = iter->next) { if (!nm_utils_hwaddr_valid (iter->data, ETH_ALEN)) { g_set_error (error, - NM_SETTING_WIRELESS_ERROR, - NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' is not a valid MAC address"), (const char *) iter->data); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST); @@ -806,8 +788,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) for (iter = priv->seen_bssids; iter; iter = iter->next) { if (!nm_utils_hwaddr_valid (iter->data, ETH_ALEN)) { g_set_error (error, - NM_SETTING_WIRELESS_ERROR, - NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' is not a valid MAC address"), (const char *) iter->data); g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SEEN_BSSIDS); diff --git a/libnm-core/nm-setting-wireless.h b/libnm-core/nm-setting-wireless.h index 50826efe6..b402934cf 100644 --- a/libnm-core/nm-setting-wireless.h +++ b/libnm-core/nm-setting-wireless.h @@ -42,28 +42,6 @@ G_BEGIN_DECLS #define NM_SETTING_WIRELESS_SETTING_NAME "802-11-wireless" -/** - * NMSettingWirelessError: - * @NM_SETTING_WIRELESS_ERROR_UNKNOWN: unknown or unclassified error - * @NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY: the property was invalid - * @NM_SETTING_WIRELESS_ERROR_MISSING_PROPERTY: the property was missing and is - * required - * @NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING: property values require - * the presence of an #NMSettingWirelessSecurity object in the connection - * @NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND: the property channel was - * set to a value that requires the #NMSettingWireless:band property to be set - */ -typedef enum { - NM_SETTING_WIRELESS_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/ - NM_SETTING_WIRELESS_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/ - NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING, /*< nick=MissingSecuritySetting >*/ - NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND /*< nick=ChannelRequiresBand >*/ -} NMSettingWirelessError; - -#define NM_SETTING_WIRELESS_ERROR nm_setting_wireless_error_quark () -GQuark nm_setting_wireless_error_quark (void); - #define NM_SETTING_WIRELESS_SSID "ssid" #define NM_SETTING_WIRELESS_MODE "mode" #define NM_SETTING_WIRELESS_BAND "band" diff --git a/libnm-core/nm-setting.c b/libnm-core/nm-setting.c index 357ff1240..2fbd30029 100644 --- a/libnm-core/nm-setting.c +++ b/libnm-core/nm-setting.c @@ -44,23 +44,6 @@ * of properties and allowed values. */ -/** - * nm_setting_error_quark: - * - * Registers an error quark for #NMSetting if necessary. - * - * Returns: the error quark used for NMSetting errors. - **/ -GQuark -nm_setting_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-setting-error-quark"); - return quark; -} - G_DEFINE_ABSTRACT_TYPE (NMSetting, nm_setting, G_TYPE_OBJECT) #define NM_SETTING_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING, NMSettingPrivate)) @@ -127,8 +110,7 @@ _ensure_registered (void) * @type: the #GType of the #NMSetting * @priority: the sort priority of the setting, see below * - * INTERNAL ONLY: registers a setting's internal properties, like its priority - * and its error quark type, with libnm. + * INTERNAL ONLY: registers a setting's internal properties with libnm. * * A setting's priority should roughly follow the OSI layer model, but it also * controls which settings get asked for secrets first. Thus settings which @@ -1476,10 +1458,11 @@ update_one_secret (NMSetting *setting, const char *key, GVariant *value, GError property = nm_setting_class_find_property (NM_SETTING_GET_CLASS (setting), key); if (!property) { - g_set_error (error, - NM_SETTING_ERROR, - NM_SETTING_ERROR_PROPERTY_NOT_FOUND, - "%s", key); + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND, + _("secret not found")); + g_prefix_error (error, "%s.%s: ", nm_setting_get_name (setting), key); return NM_SETTING_UPDATE_SECRET_ERROR; } @@ -1567,19 +1550,21 @@ is_secret_prop (NMSetting *setting, const char *secret_name, GError **error) property = nm_setting_class_find_property (NM_SETTING_GET_CLASS (setting), secret_name); if (!property) { - g_set_error (error, - NM_SETTING_ERROR, - NM_SETTING_ERROR_PROPERTY_NOT_FOUND, - "Secret %s not provided by this setting", secret_name); + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND, + _("secret is not set")); + g_prefix_error (error, "%s.%s: ", nm_setting_get_name (setting), secret_name); return FALSE; } pspec = property->param_spec; if (!pspec || !(pspec->flags & NM_SETTING_PARAM_SECRET)) { - g_set_error (error, - NM_SETTING_ERROR, - NM_SETTING_ERROR_PROPERTY_NOT_SECRET, - "Property %s is not a secret", secret_name); + 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_get_name (setting), secret_name); return FALSE; } @@ -1773,8 +1758,8 @@ _nm_setting_verify_required_virtual_interface_name (GSList *all_settings, interface_name = s_con ? nm_setting_connection_get_interface_name (s_con) : NULL; if (!interface_name) { g_set_error_literal (error, - NM_SETTING_CONNECTION_ERROR, - NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property is missing")); g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_INTERFACE_NAME); return NM_SETTING_VERIFY_ERROR; diff --git a/libnm-core/nm-setting.h b/libnm-core/nm-setting.h index 038d5bc53..68cb1d5e0 100644 --- a/libnm-core/nm-setting.h +++ b/libnm-core/nm-setting.h @@ -41,32 +41,6 @@ G_BEGIN_DECLS #define NM_IS_SETTING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING)) #define NM_SETTING_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING, NMSettingClass)) -/** - * NMSettingError: - * @NM_SETTING_ERROR_UNKNOWN: unknown or unclassified error - * @NM_SETTING_ERROR_PROPERTY_NOT_FOUND: a property required by the operation - * was not found; for example, an attempt to update an invalid secret - * @NM_SETTING_ERROR_PROPERTY_NOT_SECRET: an operation which requires a secret - * was attempted on a non-secret property - * @NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH: the operation requires a property - * of a specific type, or the value couldn't be transformed to the same type - * as the property being acted upon - * - * Describes errors that may result from operations involving a #NMSetting. - * - **/ -typedef enum -{ - NM_SETTING_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_SETTING_ERROR_PROPERTY_NOT_FOUND, /*< nick=PropertyNotFound >*/ - NM_SETTING_ERROR_PROPERTY_NOT_SECRET, /*< nick=PropertyNotSecret >*/ - NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH /*< nick=PropertyTypeMismatch >*/ -} NMSettingError; - -#define NM_SETTING_ERROR nm_setting_error_quark () -GQuark nm_setting_error_quark (void); - - /* The property of the #NMSetting is required for the setting to be valid */ #define NM_SETTING_PARAM_REQUIRED (1 << (1 + G_PARAM_USER_SHIFT)) diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c index c46fc3207..32061426a 100644 --- a/libnm-core/tests/test-general.c +++ b/libnm-core/tests/test-general.c @@ -432,7 +432,7 @@ test_setting_ip4_config_labels (void) g_strfreev (labels); nm_setting_verify (NM_SETTING (s_ip4), NULL, &error); - g_assert_error (error, NM_SETTING_IP4_CONFIG_ERROR, NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY); + g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); g_assert (g_str_has_prefix (error->message, "ipv4.address-labels:")); g_clear_error (&error); @@ -450,7 +450,7 @@ test_setting_ip4_config_labels (void) NULL); g_strfreev (labels); nm_setting_verify (NM_SETTING (s_ip4), NULL, &error); - g_assert_error (error, NM_SETTING_IP4_CONFIG_ERROR, NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY); + g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); g_assert (g_str_has_prefix (error->message, "ipv4.address-labels:")); g_clear_error (&error); @@ -559,7 +559,7 @@ test_setting_gsm_without_number (void) g_object_set (s_gsm, NM_SETTING_GSM_NUMBER, "", NULL); success = nm_setting_verify (NM_SETTING (s_gsm), NULL, &error); - g_assert_error (error, NM_SETTING_GSM_ERROR, NM_SETTING_GSM_ERROR_INVALID_PROPERTY); + g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); g_error_free (error); } @@ -1965,7 +1965,7 @@ test_connection_bad_base_types (void) nm_connection_add_setting (connection, setting); success = nm_connection_verify (connection, &error); - g_assert_error (error, NM_SETTING_CONNECTION_ERROR, NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY); + g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); g_assert (g_str_has_prefix (error->message, "connection.type: ")); g_assert (success == FALSE); g_object_unref (connection); @@ -1980,7 +1980,7 @@ test_connection_bad_base_types (void) nm_connection_add_setting (connection, setting); success = nm_connection_verify (connection, &error); - g_assert_error (error, NM_SETTING_CONNECTION_ERROR, NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY); + g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); g_assert (g_str_has_prefix (error->message, "connection.type: ")); g_assert (success == FALSE); g_object_unref (connection); @@ -1995,7 +1995,7 @@ test_connection_bad_base_types (void) nm_connection_add_setting (connection, setting); success = nm_connection_verify (connection, &error); - g_assert_error (error, NM_SETTING_CONNECTION_ERROR, NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY); + g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); g_assert (g_str_has_prefix (error->message, "connection.type: ")); g_assert (success == FALSE); g_object_unref (connection); @@ -2008,7 +2008,7 @@ test_connection_bad_base_types (void) nm_connection_add_setting (connection, setting); success = nm_connection_verify (connection, &error); - g_assert_error (error, NM_SETTING_CONNECTION_ERROR, NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY); + g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); g_assert (g_str_has_prefix (error->message, "connection.type: ")); g_assert (success == FALSE); g_object_unref (connection); @@ -2021,7 +2021,7 @@ test_connection_bad_base_types (void) nm_connection_add_setting (connection, setting); success = nm_connection_verify (connection, &error); - g_assert_error (error, NM_SETTING_CONNECTION_ERROR, NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY); + g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); g_assert (g_str_has_prefix (error->message, "connection.type: ")); g_assert (success == FALSE); g_object_unref (connection); @@ -2839,7 +2839,7 @@ test_connection_normalize_virtual_iface_name (void) ); con = nm_simple_connection_new_from_dbus (connection_dict, &error); - g_assert_error (error, NM_SETTING_CONNECTION_ERROR, NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY); + g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); g_clear_error (&error); /* If vlan.interface-name is valid, but doesn't match, it will be ignored. */ @@ -2893,7 +2893,7 @@ _test_connection_normalize_type_normalizable_setting (const char *type, con = nmtst_create_minimal_connection (id, NULL, NULL, &s_con); - nmtst_assert_connection_unnormalizable (con, NM_SETTING_CONNECTION_ERROR, NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY); + nmtst_assert_connection_unnormalizable (con, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_MISSING_PROPERTY); g_object_set (s_con, NM_SETTING_CONNECTION_TYPE, type, NULL); @@ -2901,7 +2901,7 @@ _test_connection_normalize_type_normalizable_setting (const char *type, prepare_normalizable_fcn (con); g_assert (!nm_connection_get_setting_by_name (con, type)); - nmtst_assert_connection_verifies_after_normalization (con, NM_SETTING_CONNECTION_ERROR, NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND); + nmtst_assert_connection_verifies_after_normalization (con, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_MISSING_SETTING); s_base = nm_connection_get_setting_by_name (con, type); g_assert (s_base); @@ -2922,11 +2922,11 @@ _test_connection_normalize_type_unnormalizable_setting (const char *type) con = nmtst_create_minimal_connection (id, NULL, NULL, &s_con); - nmtst_assert_connection_unnormalizable (con, NM_SETTING_CONNECTION_ERROR, NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY); + nmtst_assert_connection_unnormalizable (con, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_MISSING_PROPERTY); g_object_set (s_con, NM_SETTING_CONNECTION_TYPE, type, NULL); - nmtst_assert_connection_unnormalizable (con, NM_SETTING_CONNECTION_ERROR, NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND); + nmtst_assert_connection_unnormalizable (con, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_MISSING_SETTING); } static void @@ -2945,7 +2945,7 @@ _test_connection_normalize_type_normalizable_type (const char *type, con = nmtst_create_minimal_connection (id, NULL, NULL, &s_con); - nmtst_assert_connection_unnormalizable (con, NM_SETTING_CONNECTION_ERROR, NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY); + nmtst_assert_connection_unnormalizable (con, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_MISSING_PROPERTY); if (add_setting_fcn) s_base = add_setting_fcn (con); @@ -2957,7 +2957,7 @@ _test_connection_normalize_type_normalizable_type (const char *type, g_assert (!nm_connection_get_connection_type (con)); g_assert (nm_connection_get_setting_by_name (con, type) == s_base); - nmtst_assert_connection_verifies_after_normalization (con, NM_SETTING_CONNECTION_ERROR, NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY); + nmtst_assert_connection_verifies_after_normalization (con, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_MISSING_PROPERTY); g_assert_cmpstr (nm_connection_get_connection_type (con), ==, type); g_assert (nm_connection_get_setting_by_name (con, type) == s_base); @@ -3213,7 +3213,7 @@ test_connection_normalize_slave_type_1 (void) NM_SETTING_CONNECTION_SLAVE_TYPE, "invalid-type", NULL); - nmtst_assert_connection_unnormalizable (con, NM_SETTING_CONNECTION_ERROR, NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY); + nmtst_assert_connection_unnormalizable (con, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); g_assert (!nm_connection_get_setting_by_name (con, NM_SETTING_BRIDGE_PORT_SETTING_NAME)); g_object_set (s_con, @@ -3221,7 +3221,7 @@ test_connection_normalize_slave_type_1 (void) NULL); g_assert (!nm_connection_get_setting_by_name (con, NM_SETTING_BRIDGE_PORT_SETTING_NAME)); - nmtst_assert_connection_verifies_after_normalization (con, NM_SETTING_CONNECTION_ERROR, NM_SETTING_CONNECTION_ERROR_SLAVE_SETTING_NOT_FOUND); + nmtst_assert_connection_verifies_after_normalization (con, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_MISSING_SETTING); g_assert (nm_connection_get_setting_by_name (con, NM_SETTING_BRIDGE_PORT_SETTING_NAME)); g_assert_cmpstr (nm_setting_connection_get_slave_type (s_con), ==, NM_SETTING_BRIDGE_SETTING_NAME); } @@ -3241,7 +3241,7 @@ test_connection_normalize_slave_type_2 (void) NM_SETTING_CONNECTION_SLAVE_TYPE, "invalid-type", NULL); - nmtst_assert_connection_unnormalizable (con, NM_SETTING_CONNECTION_ERROR, NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY); + nmtst_assert_connection_unnormalizable (con, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); g_assert (!nm_connection_get_setting_by_name (con, NM_SETTING_BRIDGE_PORT_SETTING_NAME)); g_object_set (s_con, @@ -3251,7 +3251,7 @@ test_connection_normalize_slave_type_2 (void) g_assert (nm_connection_get_setting_by_name (con, NM_SETTING_BRIDGE_PORT_SETTING_NAME)); g_assert_cmpstr (nm_setting_connection_get_slave_type (s_con), ==, NULL); - nmtst_assert_connection_verifies_after_normalization (con, NM_SETTING_CONNECTION_ERROR, NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY); + nmtst_assert_connection_verifies_after_normalization (con, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_MISSING_PROPERTY); g_assert (nm_connection_get_setting_by_name (con, NM_SETTING_BRIDGE_PORT_SETTING_NAME)); g_assert_cmpstr (nm_setting_connection_get_slave_type (s_con), ==, NM_SETTING_BRIDGE_SETTING_NAME); } @@ -3282,7 +3282,7 @@ test_connection_normalize_infiniband_mtu (void) NM_SETTING_INFINIBAND_TRANSPORT_MODE, "datagram", NM_SETTING_INFINIBAND_MTU, (guint) 2045, NULL); - nmtst_assert_connection_verifies_after_normalization (con, NM_SETTING_INFINIBAND_ERROR, NM_SETTING_INFINIBAND_ERROR_INVALID_PROPERTY); + nmtst_assert_connection_verifies_after_normalization (con, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); g_assert_cmpint (2044, ==, nm_setting_infiniband_get_mtu (s_infini)); g_object_set (s_infini, @@ -3296,7 +3296,7 @@ test_connection_normalize_infiniband_mtu (void) NM_SETTING_INFINIBAND_TRANSPORT_MODE, "connected", NM_SETTING_INFINIBAND_MTU, (guint) 65521, NULL); - nmtst_assert_connection_verifies_after_normalization (con, NM_SETTING_INFINIBAND_ERROR, NM_SETTING_INFINIBAND_ERROR_INVALID_PROPERTY); + nmtst_assert_connection_verifies_after_normalization (con, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); g_assert_cmpint (65520, ==, nm_setting_infiniband_get_mtu (s_infini)); } diff --git a/libnm-core/tests/test-setting-dcb.c b/libnm-core/tests/test-setting-dcb.c index 3c610186c..8e2872aee 100644 --- a/libnm-core/tests/test-setting-dcb.c +++ b/libnm-core/tests/test-setting-dcb.c @@ -124,7 +124,7 @@ test_dcb_flags_invalid (void) /* Assert that the setting is invalid while the app is disabled unless v is default */ \ success = nm_setting_verify (NM_SETTING (s_dcb), NULL, &error); \ if (v >= 0) { \ - g_assert_error (error, NM_SETTING_DCB_ERROR, NM_SETTING_DCB_ERROR_INVALID_PROPERTY); \ + g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); \ g_assert (success == FALSE); \ } else { \ g_assert_no_error (error); \ @@ -177,7 +177,7 @@ test_dcb_app_priorities (void) * and a value has been set. \ */ \ success = nm_setting_verify (NM_SETTING (s_dcb), NULL, &error); \ - g_assert_error (error, NM_SETTING_DCB_ERROR, NM_SETTING_DCB_ERROR_INVALID_PROPERTY); \ + g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); \ g_assert (success == FALSE); \ g_clear_error (&error); \ } \ @@ -291,7 +291,7 @@ test_dcb_bandwidth_sums (void) /* Assert verify fails when sums do not total 100% */ nm_setting_dcb_set_priority_group_bandwidth (s_dcb, 4, 20); success = nm_setting_verify (NM_SETTING (s_dcb), NULL, &error); - g_assert_error (error, NM_SETTING_DCB_ERROR, NM_SETTING_DCB_ERROR_INVALID_PROPERTY); + g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); g_assert (success == FALSE); g_clear_error (&error); } diff --git a/libnm/libnm.ver b/libnm/libnm.ver index b8c7fdb5b..db7140f20 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -401,8 +401,6 @@ global: nm_setting_802_1x_clear_altsubject_matches; nm_setting_802_1x_clear_eap_methods; nm_setting_802_1x_clear_phase2_altsubject_matches; - nm_setting_802_1x_error_get_type; - nm_setting_802_1x_error_quark; nm_setting_802_1x_get_altsubject_match; nm_setting_802_1x_get_anonymous_identity; nm_setting_802_1x_get_ca_cert_blob; @@ -466,8 +464,6 @@ global: nm_setting_802_1x_set_phase2_client_cert; nm_setting_802_1x_set_phase2_private_key; nm_setting_802_1x_set_private_key; - nm_setting_adsl_error_get_type; - nm_setting_adsl_error_quark; nm_setting_adsl_get_encapsulation; nm_setting_adsl_get_password; nm_setting_adsl_get_password_flags; @@ -477,15 +473,11 @@ global: nm_setting_adsl_get_vci; nm_setting_adsl_get_vpi; nm_setting_adsl_new; - nm_setting_bluetooth_error_get_type; - nm_setting_bluetooth_error_quark; nm_setting_bluetooth_get_bdaddr; nm_setting_bluetooth_get_connection_type; nm_setting_bluetooth_get_type; nm_setting_bluetooth_new; nm_setting_bond_add_option; - nm_setting_bond_error_get_type; - nm_setting_bond_error_quark; nm_setting_bond_get_num_options; nm_setting_bond_get_option; nm_setting_bond_get_option_by_name; @@ -495,8 +487,6 @@ global: nm_setting_bond_new; nm_setting_bond_remove_option; nm_setting_bond_validate_option; - nm_setting_bridge_error_get_type; - nm_setting_bridge_error_quark; nm_setting_bridge_get_ageing_time; nm_setting_bridge_get_forward_delay; nm_setting_bridge_get_hello_time; @@ -506,15 +496,11 @@ global: nm_setting_bridge_get_stp; nm_setting_bridge_get_type; nm_setting_bridge_new; - nm_setting_bridge_port_error_get_type; - nm_setting_bridge_port_error_quark; nm_setting_bridge_port_get_hairpin_mode; nm_setting_bridge_port_get_path_cost; nm_setting_bridge_port_get_priority; nm_setting_bridge_port_get_type; nm_setting_bridge_port_new; - nm_setting_cdma_error_get_type; - nm_setting_cdma_error_quark; nm_setting_cdma_get_number; nm_setting_cdma_get_password; nm_setting_cdma_get_password_flags; @@ -525,8 +511,6 @@ global: nm_setting_compare_flags_get_type; nm_setting_connection_add_permission; nm_setting_connection_add_secondary; - nm_setting_connection_error_get_type; - nm_setting_connection_error_quark; nm_setting_connection_get_autoconnect; nm_setting_connection_get_autoconnect_priority; nm_setting_connection_get_connection_type; @@ -551,8 +535,6 @@ global: nm_setting_connection_remove_permission_by_value; nm_setting_connection_remove_secondary; nm_setting_connection_remove_secondary_by_value; - nm_setting_dcb_error_get_type; - nm_setting_dcb_error_quark; nm_setting_dcb_flags_get_type; nm_setting_dcb_get_app_fcoe_flags; nm_setting_dcb_get_app_fcoe_mode; @@ -581,17 +563,11 @@ global: nm_setting_diff_result_get_type; nm_setting_duplicate; nm_setting_enumerate_values; - nm_setting_error_get_type; - nm_setting_error_quark; - nm_setting_generic_error_get_type; - nm_setting_generic_error_quark; nm_setting_generic_get_type; nm_setting_generic_new; nm_setting_get_name; nm_setting_get_secret_flags; nm_setting_get_type; - nm_setting_gsm_error_get_type; - nm_setting_gsm_error_quark; nm_setting_gsm_get_apn; nm_setting_gsm_get_home_only; nm_setting_gsm_get_network_id; @@ -603,8 +579,6 @@ global: nm_setting_gsm_get_type; nm_setting_gsm_get_username; nm_setting_gsm_new; - nm_setting_infiniband_error_get_type; - nm_setting_infiniband_error_quark; nm_setting_infiniband_get_mac_address; nm_setting_infiniband_get_mtu; nm_setting_infiniband_get_p_key; @@ -621,8 +595,6 @@ global: nm_setting_ip4_config_clear_dns; nm_setting_ip4_config_clear_dns_searches; nm_setting_ip4_config_clear_routes; - nm_setting_ip4_config_error_get_type; - nm_setting_ip4_config_error_quark; nm_setting_ip4_config_get_address; nm_setting_ip4_config_get_dhcp_client_id; nm_setting_ip4_config_get_dhcp_hostname; @@ -657,8 +629,6 @@ global: nm_setting_ip6_config_clear_dns; nm_setting_ip6_config_clear_dns_searches; nm_setting_ip6_config_clear_routes; - nm_setting_ip6_config_error_get_type; - nm_setting_ip6_config_error_quark; nm_setting_ip6_config_get_address; nm_setting_ip6_config_get_dhcp_hostname; nm_setting_ip6_config_get_dns; @@ -686,15 +656,11 @@ global: nm_setting_ip6_config_remove_route; nm_setting_ip6_config_remove_route_by_value; nm_setting_lookup_type; - nm_setting_olpc_mesh_error_get_type; - nm_setting_olpc_mesh_error_quark; nm_setting_olpc_mesh_get_channel; nm_setting_olpc_mesh_get_dhcp_anycast_address; nm_setting_olpc_mesh_get_ssid; nm_setting_olpc_mesh_get_type; nm_setting_olpc_mesh_new; - nm_setting_ppp_error_get_type; - nm_setting_ppp_error_quark; nm_setting_ppp_get_baud; nm_setting_ppp_get_crtscts; nm_setting_ppp_get_lcp_echo_failure; @@ -715,8 +681,6 @@ global: nm_setting_ppp_get_require_mppe_128; nm_setting_ppp_get_type; nm_setting_ppp_new; - nm_setting_pppoe_error_get_type; - nm_setting_pppoe_error_quark; nm_setting_pppoe_get_password; nm_setting_pppoe_get_password_flags; nm_setting_pppoe_get_service; @@ -724,8 +688,6 @@ global: nm_setting_pppoe_get_username; nm_setting_pppoe_new; nm_setting_secret_flags_get_type; - nm_setting_serial_error_get_type; - nm_setting_serial_error_quark; nm_setting_serial_get_baud; nm_setting_serial_get_bits; nm_setting_serial_get_parity; @@ -735,13 +697,9 @@ global: nm_setting_serial_new; nm_setting_serial_parity_get_type; nm_setting_set_secret_flags; - nm_setting_team_error_get_type; - nm_setting_team_error_quark; nm_setting_team_get_config; nm_setting_team_get_type; nm_setting_team_new; - nm_setting_team_port_error_get_type; - nm_setting_team_port_error_quark; nm_setting_team_port_get_config; nm_setting_team_port_get_type; nm_setting_team_port_new; @@ -750,8 +708,6 @@ global: nm_setting_vlan_add_priority; nm_setting_vlan_add_priority_str; nm_setting_vlan_clear_priorities; - nm_setting_vlan_error_get_type; - nm_setting_vlan_error_quark; nm_setting_vlan_get_flags; nm_setting_vlan_get_id; nm_setting_vlan_get_num_priorities; @@ -764,8 +720,6 @@ global: nm_setting_vlan_remove_priority_str_by_value; nm_setting_vpn_add_data_item; nm_setting_vpn_add_secret; - nm_setting_vpn_error_get_type; - nm_setting_vpn_error_quark; nm_setting_vpn_foreach_data_item; nm_setting_vpn_foreach_secret; nm_setting_vpn_get_data_item; @@ -778,8 +732,6 @@ global: nm_setting_vpn_new; nm_setting_vpn_remove_data_item; nm_setting_vpn_remove_secret; - nm_setting_wimax_error_get_type; - nm_setting_wimax_error_quark; nm_setting_wimax_get_mac_address; nm_setting_wimax_get_network_name; nm_setting_wimax_get_type; @@ -787,8 +739,6 @@ global: nm_setting_wired_add_mac_blacklist_item; nm_setting_wired_add_s390_option; nm_setting_wired_clear_mac_blacklist_items; - nm_setting_wired_error_get_type; - nm_setting_wired_error_quark; nm_setting_wired_get_auto_negotiate; nm_setting_wired_get_cloned_mac_address; nm_setting_wired_get_duplex; @@ -814,8 +764,6 @@ global: nm_setting_wireless_add_seen_bssid; nm_setting_wireless_ap_security_compatible; nm_setting_wireless_clear_mac_blacklist_items; - nm_setting_wireless_error_get_type; - nm_setting_wireless_error_quark; nm_setting_wireless_get_band; nm_setting_wireless_get_bssid; nm_setting_wireless_get_channel; @@ -842,8 +790,6 @@ global: nm_setting_wireless_security_clear_groups; nm_setting_wireless_security_clear_pairwise; nm_setting_wireless_security_clear_protos; - nm_setting_wireless_security_error_get_type; - nm_setting_wireless_security_error_quark; nm_setting_wireless_security_get_auth_alg; nm_setting_wireless_security_get_group; nm_setting_wireless_security_get_key_mgmt; diff --git a/po/POTFILES.in b/po/POTFILES.in index ddd590732..1657eae4f 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -121,6 +121,9 @@ src/devices/nm-device-infiniband.c src/devices/nm-device-vlan.c src/devices/team/nm-device-team.c src/devices/wifi/nm-device-olpc-mesh.c +src/devices/wifi/nm-device-wifi.c +src/devices/wifi/nm-wifi-ap-utils.c +src/devices/wimax/nm-device-wimax.c src/devices/wwan/nm-modem-broadband.c src/nm-config.c src/nm-logging.c diff --git a/src/devices/bluetooth/nm-device-bt.c b/src/devices/bluetooth/nm-device-bt.c index 18b7ab1bd..f8039ae6a 100644 --- a/src/devices/bluetooth/nm-device-bt.c +++ b/src/devices/bluetooth/nm-device-bt.c @@ -243,18 +243,24 @@ complete_connection (NMDevice *device, /* Make sure the device supports PAN */ if (!(priv->capabilities & NM_BT_CAPABILITY_NAP)) { g_set_error_literal (error, - NM_SETTING_BLUETOOTH_ERROR, - NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY, - "PAN required but Bluetooth device does not support NAP"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("PAN requested, but Bluetooth device does not support NAP")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_BLUETOOTH_SETTING_NAME, NM_SETTING_BLUETOOTH_TYPE); return FALSE; } /* PAN can't use any DUN-related settings */ if (s_gsm || s_cdma || s_serial || s_ppp) { g_set_error_literal (error, - NM_SETTING_BLUETOOTH_ERROR, - NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY, - "PAN incompatible with GSM, CDMA, or serial settings"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_SETTING, + _("PAN connections cannot specify GSM, CDMA, or serial settings")); + g_prefix_error (error, "%s: ", + s_gsm ? NM_SETTING_GSM_SETTING_NAME : + s_cdma ? NM_SETTING_CDMA_SETTING_NAME : + s_serial ? NM_SETTING_SERIAL_SETTING_NAME : + NM_SETTING_PPP_SETTING_NAME); return FALSE; } @@ -267,18 +273,20 @@ complete_connection (NMDevice *device, /* Make sure the device supports PAN */ if (!(priv->capabilities & NM_BT_CAPABILITY_DUN)) { g_set_error_literal (error, - NM_SETTING_BLUETOOTH_ERROR, - NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY, - "DUN required but Bluetooth device does not support DUN"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("DUN requested, but Bluetooth device does not support DUN")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_BLUETOOTH_SETTING_NAME, NM_SETTING_BLUETOOTH_TYPE); return FALSE; } /* Need at least a GSM or a CDMA setting */ if (!s_gsm && !s_cdma) { g_set_error_literal (error, - NM_SETTING_BLUETOOTH_ERROR, - NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY, - "Setting requires DUN but no GSM or CDMA setting is present"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_SETTING, + _("DUN connection must include a GSM or CDMA setting")); + g_prefix_error (error, "%s: ", NM_SETTING_BLUETOOTH_SETTING_NAME); return FALSE; } @@ -298,9 +306,10 @@ complete_connection (NMDevice *device, fallback_prefix = _("DUN connection"); } else { g_set_error_literal (error, - NM_SETTING_BLUETOOTH_ERROR, - NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY, - "Unknown/unhandled Bluetooth connection type"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("Unknown/unhandled Bluetooth connection type")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_BLUETOOTH_SETTING_NAME, NM_SETTING_BLUETOOTH_TYPE); return FALSE; } @@ -317,9 +326,10 @@ complete_connection (NMDevice *device, /* Make sure the setting BT Address (if any) matches the device's */ if (!nm_utils_hwaddr_matches (setting_bdaddr, -1, priv->bdaddr, -1)) { g_set_error_literal (error, - NM_SETTING_BLUETOOTH_ERROR, - NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY, - NM_SETTING_BLUETOOTH_BDADDR); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("connection does not match device")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_BLUETOOTH_SETTING_NAME, NM_SETTING_BLUETOOTH_BDADDR); return FALSE; } } else { diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index a0713a792..10637d614 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -1449,9 +1449,10 @@ complete_connection (NMDevice *device, /* Make sure the setting MAC (if any) matches the device's permanent MAC */ if (!nm_utils_hwaddr_matches (setting_mac, -1, priv->perm_hw_addr, -1)) { g_set_error_literal (error, - NM_SETTING_WIRED_ERROR, - NM_SETTING_WIRED_ERROR_INVALID_PROPERTY, - NM_SETTING_WIRED_MAC_ADDRESS); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("connection does not match device")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_MAC_ADDRESS); return FALSE; } } else { diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c index acf74490f..6d7ce34b5 100644 --- a/src/devices/nm-device-infiniband.c +++ b/src/devices/nm-device-infiniband.c @@ -202,9 +202,10 @@ complete_connection (NMDevice *device, /* Make sure the setting MAC (if any) matches the device's MAC */ if (!nm_utils_hwaddr_matches (setting_mac, -1, hw_address, -1)) { g_set_error_literal (error, - NM_SETTING_INFINIBAND_ERROR, - NM_SETTING_INFINIBAND_ERROR_INVALID_PROPERTY, - NM_SETTING_INFINIBAND_MAC_ADDRESS); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("connection does not match device")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_INFINIBAND_SETTING_NAME, NM_SETTING_INFINIBAND_MAC_ADDRESS); return FALSE; } } else { diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index cf5a4f631..3441ae3a7 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -1107,9 +1107,10 @@ complete_connection (NMDevice *device, */ if (is_adhoc_wpa (connection)) { g_set_error_literal (error, - NM_SETTING_WIRELESS_ERROR, - NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY, - "WPA Ad-Hoc disabled due to kernel bugs"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_SETTING, + _("WPA Ad-Hoc disabled due to kernel bugs")); + g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME); if (tmp_ssid) g_byte_array_unref (tmp_ssid); return FALSE; @@ -1136,10 +1137,11 @@ complete_connection (NMDevice *device, if (setting_mac) { /* Make sure the setting MAC (if any) matches the device's permanent MAC */ if (!nm_utils_hwaddr_matches (setting_mac, -1, priv->perm_hw_addr, -1)) { - g_set_error (error, - NM_SETTING_WIRELESS_ERROR, - NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY, - NM_SETTING_WIRELESS_MAC_ADDRESS); + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("connection does not match device")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_MAC_ADDRESS); return FALSE; } } else { diff --git a/src/devices/wifi/nm-wifi-ap-utils.c b/src/devices/wifi/nm-wifi-ap-utils.c index 19d8307e6..85d76d218 100644 --- a/src/devices/wifi/nm-wifi-ap-utils.c +++ b/src/devices/wifi/nm-wifi-ap-utils.c @@ -1,4 +1,4 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/*-*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ /* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -22,6 +22,8 @@ #include <string.h> #include <stdlib.h> +#include <glib/gi18n.h> + #include "nm-wifi-ap-utils.h" #include "nm-utils.h" @@ -36,9 +38,10 @@ verify_no_wep (NMSettingWirelessSecurity *s_wsec, const char *tag, GError **erro || nm_setting_wireless_security_get_wep_key_type (s_wsec)) { /* Dynamic WEP cannot have any WEP keys set */ g_set_error (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "%s is incompatible with static WEP keys", tag); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_SETTING, + _("%s is incompatible with static WEP keys"), tag); + g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME); return FALSE; } @@ -69,17 +72,21 @@ verify_leap (NMSettingWirelessSecurity *s_wsec, /* LEAP authentication requires at least a LEAP username */ if (!leap_username) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME, - "LEAP requires a LEAP username"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, + _("LEAP authentication requires a LEAP username")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME); return FALSE; } } else if (leap_username) { /* Leap username requires 'leap' auth */ g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "LEAP requires 'leap' authentication"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("LEAP username requires 'leap' authentication")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME); return FALSE; } } @@ -88,9 +95,11 @@ verify_leap (NMSettingWirelessSecurity *s_wsec, if (key_mgmt && strcmp (key_mgmt, "ieee8021x")) { /* LEAP requires ieee8021x key management */ g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X, - "LEAP requires IEEE 802.1x key management"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("LEAP authentication requires IEEE 802.1x key management")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_KEY_MGMT); return FALSE; } } @@ -106,9 +115,10 @@ verify_leap (NMSettingWirelessSecurity *s_wsec, if (adhoc) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "LEAP incompatible with Ad-Hoc mode"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_SETTING, + _("LEAP authentication is incompatible with Ad-Hoc mode")); + g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME); return FALSE; } @@ -117,9 +127,10 @@ verify_leap (NMSettingWirelessSecurity *s_wsec, if (s_8021x) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME, - "LEAP incompatible with 802.1x setting"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_SETTING, + _("LEAP authentication is incompatible with 802.1x setting")); + g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME); return FALSE; } } @@ -138,17 +149,23 @@ verify_no_wpa (NMSettingWirelessSecurity *s_wsec, key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wsec); if (key_mgmt && !strncmp (key_mgmt, "wpa", 3)) { g_set_error (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "%s incompatible with any WPA key management", tag); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("a connection using '%s' authentication cannot use WPA key management"), + tag); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_KEY_MGMT); return FALSE; } if (nm_setting_wireless_security_get_num_protos (s_wsec)) { g_set_error (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "%s incompatible with any 'proto' setting", tag); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("a connection using '%s' authentication cannot specific WPA protocols"), + tag); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_PROTO); return FALSE; } @@ -159,9 +176,12 @@ verify_no_wpa (NMSettingWirelessSecurity *s_wsec, pw = nm_setting_wireless_security_get_pairwise (s_wsec, i); if (!strcmp (pw, "tkip") || !strcmp (pw, "ccmp")) { g_set_error (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "%s is incompatible with WPA pairwise ciphers", tag); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("a connection using '%s' authentication cannot specific WPA ciphers"), + tag); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_PAIRWISE); return FALSE; } } @@ -173,18 +193,24 @@ verify_no_wpa (NMSettingWirelessSecurity *s_wsec, gr = nm_setting_wireless_security_get_group (s_wsec, i); if (strcmp (gr, "wep40") && strcmp (gr, "wep104")) { g_set_error (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "%s is incompatible with WPA group ciphers", tag); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("a connection using '%s' authentication cannot specific WPA ciphers"), + tag); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_GROUP); return FALSE; } } if (nm_setting_wireless_security_get_psk (s_wsec)) { g_set_error (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "%s is incompatible with a WPA Pre-Shared Key", tag); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("a connection using '%s' authentication cannot specific a WPA password"), + tag); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_PSK); return FALSE; } @@ -210,18 +236,21 @@ verify_dynamic_wep (NMSettingWirelessSecurity *s_wsec, if (!s_8021x) { /* 802.1x key management requires an 802.1x setting */ g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "Dynamic WEP requires an 802.1x setting"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_SETTING, + _("Dynamic WEP requires an 802.1x setting")); + g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME); return FALSE; } if (auth_alg && strcmp (auth_alg, "open")) { /* 802.1x key management must use "open" authentication */ g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "Dynamic WEP requires 'open' authentication"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("Dynamic WEP requires 'open' authentication")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_AUTH_ALG); return FALSE; } @@ -232,9 +261,11 @@ verify_dynamic_wep (NMSettingWirelessSecurity *s_wsec, if (s_8021x) { /* 802.1x setting requires 802.1x key management */ g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "Dynamic WEP requires 'ieee8021x' key management"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("Dynamic WEP requires 'ieee8021x' key management")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_KEY_MGMT); return FALSE; } } @@ -243,9 +274,11 @@ verify_dynamic_wep (NMSettingWirelessSecurity *s_wsec, if (auth_alg && strcmp (auth_alg, "open")) { /* 802.1x key management must use "open" authentication */ g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "Dynamic WEP requires 'open' authentication"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("Dynamic WEP requires 'open' authentication")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_AUTH_ALG); return FALSE; } @@ -275,18 +308,21 @@ verify_wpa_psk (NMSettingWirelessSecurity *s_wsec, if (!strcmp (key_mgmt, "wpa-psk") || !strcmp (key_mgmt, "wpa-none")) { if (s_8021x) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "WPA-PSK incompatible with 802.1x"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_SETTING, + _("WPA-PSK authentication is incompatible with 802.1x")); + g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME); return FALSE; } if (auth_alg && strcmp (auth_alg, "open")) { /* WPA must use "open" authentication */ g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "WPA-PSK requires 'open' authentication"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("WPA-PSK requires 'open' authentication")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_AUTH_ALG); return FALSE; } } @@ -294,9 +330,11 @@ verify_wpa_psk (NMSettingWirelessSecurity *s_wsec, if (!strcmp (key_mgmt, "wpa-none")) { if (!adhoc) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "WPA Ad-Hoc requires an Ad-Hoc mode AP"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("WPA Ad-Hoc authentication requires an Ad-Hoc mode AP")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, + NM_SETTING_WIRELESS_MODE); return FALSE; } @@ -305,9 +343,11 @@ verify_wpa_psk (NMSettingWirelessSecurity *s_wsec, tmp = (n > 0) ? nm_setting_wireless_security_get_proto (s_wsec, 0) : NULL; if (n > 1 || !tmp || strcmp (tmp, "wpa")) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "WPA Ad-Hoc requires 'wpa' proto"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("WPA Ad-Hoc authentication requires 'wpa' protocol")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_PROTO); return FALSE; } @@ -315,9 +355,11 @@ verify_wpa_psk (NMSettingWirelessSecurity *s_wsec, tmp = (n > 0) ? nm_setting_wireless_security_get_pairwise (s_wsec, 0) : NULL; if (n > 1 || g_strcmp0 (tmp, "none")) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "WPA Ad-Hoc requires 'none' pairwise cipher"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("WPA Ad-Hoc authentication requires 'none' pairwise cipher")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_PAIRWISE); return FALSE; } @@ -325,9 +367,11 @@ verify_wpa_psk (NMSettingWirelessSecurity *s_wsec, tmp = (n > 0) ? nm_setting_wireless_security_get_group (s_wsec, 0) : NULL; if (n > 1 || !tmp || strcmp (tmp, "tkip")) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "WPA Ad-Hoc requires 'tkip' group cipher"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("WPA Ad-Hoc requires 'tkip' group cipher")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_GROUP); return FALSE; } } @@ -337,9 +381,11 @@ verify_wpa_psk (NMSettingWirelessSecurity *s_wsec, if ( !(wpa_flags & NM_802_11_AP_SEC_KEY_MGMT_PSK) && !(rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_PSK)) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "AP does not support PSK but setting requires it"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("Access point does not support PSK but setting requires it")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_KEY_MGMT); return FALSE; } } @@ -365,27 +411,31 @@ verify_wpa_eap (NMSettingWirelessSecurity *s_wsec, if (!strcmp (key_mgmt, "wpa-eap")) { if (!s_8021x) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "WPA-EAP requires an 802.1x setting"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_SETTING, + _("WPA-EAP authentication requires an 802.1x setting")); + g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME); return FALSE; } if (auth_alg && strcmp (auth_alg, "open")) { /* WPA must use "open" authentication */ g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "WPA-EAP requires 'open' authentication"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("WPA-EAP requires 'open' authentication")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_AUTH_ALG); return FALSE; } is_wpa_eap = TRUE; } else if (s_8021x) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "Setting requires 802.1x but does not use 'wpa-eap' key management"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_SETTING, + _("802.1x setting requires 'wpa-eap' key management")); + g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME); return FALSE; } } @@ -395,9 +445,10 @@ verify_wpa_eap (NMSettingWirelessSecurity *s_wsec, if ( !(wpa_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X) && !(rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "AP does not support 802.1x but setting requires it"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_SETTING, + _("Access point does not support 802.1x but setting requires it")); + g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME); return FALSE; } } @@ -422,41 +473,50 @@ verify_adhoc (NMSettingWirelessSecurity *s_wsec, if (adhoc) { if (key_mgmt && strcmp (key_mgmt, "wpa-none") && strcmp (key_mgmt, "none")) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "AP mode is Ad-Hoc but setting requires Infrastructure security"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("Access point mode is Ad-Hoc but setting requires Infrastructure security")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_KEY_MGMT); return FALSE; } if (s_8021x) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "Ad-Hoc mode incompatible with 802.1x security"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_SETTING, + _("Ad-Hoc mode is incompatible with 802.1x security")); + g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME); return FALSE; } if (leap_username) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "Ad-Hoc mode incompatible with LEAP security"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("Ad-Hoc mode is incompatible with LEAP security")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_AUTH_ALG); return FALSE; } if (auth_alg && strcmp (auth_alg, "open")) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "Ad-Hoc mode requires 'open' authentication"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("Ad-Hoc mode requires 'open' authentication")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_AUTH_ALG); return FALSE; } } else { if (key_mgmt && !strcmp (key_mgmt, "wpa-none")) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "AP mode is Infrastructure but setting requires Ad-Hoc security"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("Access point mode is Infrastructure but setting requires Ad-Hoc security")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NM_SETTING_WIRELESS_SECURITY_KEY_MGMT); return FALSE; } } @@ -494,9 +554,10 @@ nm_ap_utils_complete_connection (const GByteArray *ap_ssid, g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_SSID, ap_ssid_bytes, NULL); else if (!g_bytes_equal (ssid, ap_ssid_bytes)) { g_set_error_literal (error, - NM_SETTING_WIRELESS_ERROR, - NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY, - "Setting SSID did not match AP SSID"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("connection does not match access point")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SSID); g_bytes_unref (ap_ssid_bytes); return FALSE; } @@ -523,9 +584,10 @@ nm_ap_utils_complete_connection (const GByteArray *ap_ssid, if (valid == FALSE) { g_set_error (error, - NM_SETTING_WIRELESS_ERROR, - NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY, - NM_SETTING_WIRELESS_MODE); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("connection does not match access point")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_MODE); return FALSE; } } else { @@ -546,9 +608,13 @@ nm_ap_utils_complete_connection (const GByteArray *ap_ssid, /* Make sure the connection doesn't specify security */ if (s_wsec || s_8021x) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "AP is unencrypted but setting specifies security"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_SETTING, + _("Access point is unencrypted but setting specifies security")); + if (s_wsec) + g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME); + else + g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME); return FALSE; } return TRUE; @@ -631,18 +697,20 @@ nm_ap_utils_complete_connection (const GByteArray *ap_ssid, /* Ensure key management is valid for WPA */ if ((key_mgmt && !strcmp (key_mgmt, "ieee8021x")) || leap_username) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "WPA incompatible with non-EAP (original) LEAP or Dynamic WEP"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("WPA authentication is incompatible with non-EAP (original) LEAP or Dynamic WEP")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT); return FALSE; } /* 'shared' auth incompatible with any type of WPA */ if (auth_alg && strcmp (auth_alg, "open")) { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "WPA incompatible with Shared Key authentication"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("WPA authentication is incompatible with Shared Key authentication")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG); return FALSE; } @@ -686,9 +754,9 @@ nm_ap_utils_complete_connection (const GByteArray *ap_ssid, */ } else { g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - "Failed to determine AP security information"); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_FAILED, + _("Failed to determine AP security information")); return FALSE; } diff --git a/src/devices/wifi/tests/test-wifi-ap-utils.c b/src/devices/wifi/tests/test-wifi-ap-utils.c index 9ca49e488..8a1772293 100644 --- a/src/devices/wifi/tests/test-wifi-ap-utils.c +++ b/src/devices/wifi/tests/test-wifi-ap-utils.c @@ -327,7 +327,7 @@ test_open_ap_leap_connection_1 (gconstpointer add_wifi) FALSE, src, &error); /* We expect failure */ - COMPARE (src, NULL, success, error, NM_SETTING_WIRELESS_SECURITY_ERROR, NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY); + COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_SETTING); g_object_unref (src); } @@ -357,7 +357,7 @@ test_open_ap_leap_connection_2 (void) FALSE, src, &error); /* We expect failure */ - COMPARE (src, NULL, success, error, NM_SETTING_WIRELESS_SECURITY_ERROR, NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY); + COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_SETTING); g_object_unref (src); } @@ -391,7 +391,7 @@ test_open_ap_wep_connection (gconstpointer add_wifi) FALSE, src, &error); /* We expect failure */ - COMPARE (src, NULL, success, error, NM_SETTING_WIRELESS_SECURITY_ERROR, NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY); + COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_SETTING); g_object_unref (src); } @@ -405,6 +405,7 @@ test_ap_wpa_psk_connection_base (const char *key_mgmt, guint32 wpa_flags, guint32 rsn_flags, gboolean add_wifi, + guint error_code, NMConnection *expected) { NMConnection *src; @@ -433,7 +434,7 @@ test_ap_wpa_psk_connection_base (const char *key_mgmt, fill_wifi (expected, exp_wifi); fill_wsec (expected, both_wsec); } - COMPARE (src, expected, success, error, NM_SETTING_WIRELESS_SECURITY_ERROR, NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY); + COMPARE (src, expected, success, error, NM_CONNECTION_ERROR, error_code); g_object_unref (src); } @@ -449,7 +450,9 @@ test_open_ap_wpa_psk_connection_1 (void) NM_802_11_AP_FLAGS_NONE, NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, - FALSE, NULL); + FALSE, + NM_CONNECTION_ERROR_INVALID_SETTING, + NULL); } static void @@ -463,7 +466,9 @@ test_open_ap_wpa_psk_connection_2 (void) NM_802_11_AP_FLAGS_NONE, NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, - TRUE, NULL); + TRUE, + NM_CONNECTION_ERROR_INVALID_SETTING, + NULL); } static void @@ -476,7 +481,9 @@ test_open_ap_wpa_psk_connection_3 (void) NM_802_11_AP_FLAGS_NONE, NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, - FALSE, NULL); + FALSE, + NM_CONNECTION_ERROR_INVALID_SETTING, + NULL); } static void @@ -490,7 +497,9 @@ test_open_ap_wpa_psk_connection_4 (void) NM_802_11_AP_FLAGS_NONE, NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, - FALSE, NULL); + FALSE, + NM_CONNECTION_ERROR_INVALID_SETTING, + NULL); } static void @@ -503,7 +512,9 @@ test_open_ap_wpa_psk_connection_5 (void) NM_802_11_AP_FLAGS_NONE, NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, - FALSE, NULL); + FALSE, + NM_CONNECTION_ERROR_INVALID_SETTING, + NULL); } /*******************************************/ @@ -515,7 +526,6 @@ test_ap_wpa_eap_connection_base (const char *key_mgmt, guint32 wpa_flags, guint32 rsn_flags, gboolean add_wifi, - guint error_domain, guint error_code) { NMConnection *src; @@ -537,7 +547,7 @@ test_ap_wpa_eap_connection_base (const char *key_mgmt, flags, wpa_flags, rsn_flags, FALSE, src, &error); /* Failure expected */ - COMPARE (src, NULL, success, error, error_domain, error_code); + COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, error_code); g_object_unref (src); } @@ -614,37 +624,22 @@ rsn_flags_for_idx (guint32 idx) } static guint32 -error_domain_for_idx (guint32 idx, guint num) -{ - if (idx == IDX_OPEN) - return NM_SETTING_WIRELESS_SECURITY_ERROR; - else if (idx == IDX_PRIV) { - if (num <= 3) - return NM_SETTING_802_1X_ERROR; - else - return NM_SETTING_WIRELESS_SECURITY_ERROR; - } else if (idx == IDX_WPA_PSK_PTKIP_GTKIP || idx == IDX_WPA_PSK_PTKIP_PCCMP_GTKIP - || idx == IDX_WPA_RSN_PSK_PCCMP_GCCMP || idx == IDX_WPA_RSN_PSK_PTKIP_PCCMP_GTKIP - || idx == IDX_RSN_PSK_PTKIP_PCCMP_GTKIP || idx == IDX_RSN_PSK_PCCMP_GCCMP) - return NM_SETTING_WIRELESS_SECURITY_ERROR; - else - g_assert_not_reached (); -} - -static guint32 error_code_for_idx (guint32 idx, guint num) { if (idx == IDX_OPEN) - return NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY; + return NM_CONNECTION_ERROR_INVALID_SETTING; else if (idx == IDX_PRIV) { if (num <= 3) - return NM_SETTING_802_1X_ERROR_MISSING_PROPERTY; + return NM_CONNECTION_ERROR_MISSING_PROPERTY; else - return NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY; - } else if (idx == IDX_WPA_PSK_PTKIP_GTKIP || idx == IDX_WPA_PSK_PTKIP_PCCMP_GTKIP + return NM_CONNECTION_ERROR_INVALID_PROPERTY; + } else if ( idx == IDX_WPA_PSK_PTKIP_GTKIP || idx == IDX_WPA_PSK_PTKIP_PCCMP_GTKIP || idx == IDX_WPA_RSN_PSK_PCCMP_GCCMP || idx == IDX_WPA_RSN_PSK_PTKIP_PCCMP_GTKIP || idx == IDX_RSN_PSK_PTKIP_PCCMP_GTKIP || idx == IDX_RSN_PSK_PCCMP_GCCMP) - return NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY; + if (num == 4) + return NM_CONNECTION_ERROR_INVALID_PROPERTY; + else + return NM_CONNECTION_ERROR_INVALID_SETTING; else g_assert_not_reached (); } @@ -659,7 +654,6 @@ test_ap_wpa_eap_connection_1 (gconstpointer data) wpa_flags_for_idx (idx), rsn_flags_for_idx (idx), FALSE, - error_domain_for_idx (idx, 1), error_code_for_idx (idx, 1)); } @@ -673,7 +667,6 @@ test_ap_wpa_eap_connection_2 (gconstpointer data) wpa_flags_for_idx (idx), rsn_flags_for_idx (idx), TRUE, - error_domain_for_idx (idx, 2), error_code_for_idx (idx, 2)); } @@ -687,7 +680,6 @@ test_ap_wpa_eap_connection_3 (gconstpointer data) wpa_flags_for_idx (idx), rsn_flags_for_idx (idx), FALSE, - error_domain_for_idx (idx, 3), error_code_for_idx (idx, 3)); } @@ -701,7 +693,6 @@ test_ap_wpa_eap_connection_4 (gconstpointer data) wpa_flags_for_idx (idx), rsn_flags_for_idx (idx), FALSE, - error_domain_for_idx (idx, 4), error_code_for_idx (idx, 4)); } @@ -715,7 +706,6 @@ test_ap_wpa_eap_connection_5 (gconstpointer data) wpa_flags_for_idx (idx), rsn_flags_for_idx (idx), FALSE, - error_domain_for_idx (idx, 5), error_code_for_idx (idx, 5)); } @@ -827,7 +817,7 @@ test_priv_ap_leap_connection_2 (void) FALSE, src, &error); /* We expect failure here, we need a LEAP username */ - COMPARE (src, NULL, success, error, NM_SETTING_WIRELESS_SECURITY_ERROR, NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME); + COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_MISSING_PROPERTY); g_object_unref (src); } @@ -959,7 +949,7 @@ test_priv_ap_dynamic_wep_3 (void) FALSE, src, &error); /* Expect failure; shared is not compatible with dynamic WEP */ - COMPARE (src, NULL, success, error, NM_SETTING_WIRELESS_SECURITY_ERROR, NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY); + COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); g_object_unref (src); } @@ -977,7 +967,9 @@ test_priv_ap_wpa_psk_connection_1 (void) NM_802_11_AP_FLAGS_PRIVACY, NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, - FALSE, NULL); + FALSE, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + NULL); } static void @@ -991,7 +983,9 @@ test_priv_ap_wpa_psk_connection_2 (void) NM_802_11_AP_FLAGS_PRIVACY, NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, - TRUE, NULL); + TRUE, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + NULL); } static void @@ -1006,7 +1000,9 @@ test_priv_ap_wpa_psk_connection_3 (void) NM_802_11_AP_FLAGS_PRIVACY, NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, - FALSE, NULL); + FALSE, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + NULL); } static void @@ -1021,7 +1017,9 @@ test_priv_ap_wpa_psk_connection_4 (void) NM_802_11_AP_FLAGS_PRIVACY, NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, - FALSE, NULL); + FALSE, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + NULL); } static void @@ -1036,7 +1034,9 @@ test_priv_ap_wpa_psk_connection_5 (void) NM_802_11_AP_FLAGS_PRIVACY, NM_802_11_AP_SEC_NONE, NM_802_11_AP_SEC_NONE, - FALSE, NULL); + FALSE, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + NULL); } /*******************************************/ @@ -1107,7 +1107,7 @@ test_wpa_ap_leap_connection_1 (gconstpointer data) FALSE, src, &error); /* Expect failure here; WPA APs don't support old-school LEAP */ - COMPARE (src, NULL, success, error, NM_SETTING_WIRELESS_SECURITY_ERROR, NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY); + COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); g_object_unref (src); } @@ -1141,7 +1141,7 @@ test_wpa_ap_leap_connection_2 (gconstpointer data) FALSE, src, &error); /* We expect failure here, we need a LEAP username */ - COMPARE (src, NULL, success, error, NM_SETTING_WIRELESS_SECURITY_ERROR, NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY); + COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); g_object_unref (src); } @@ -1174,7 +1174,7 @@ test_wpa_ap_dynamic_wep_connection (gconstpointer data) FALSE, src, &error); /* We expect failure here since Dynamic WEP is incompatible with WPA */ - COMPARE (src, NULL, success, error, NM_SETTING_WIRELESS_SECURITY_ERROR, NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY); + COMPARE (src, NULL, success, error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); g_object_unref (src); } @@ -1197,7 +1197,9 @@ test_wpa_ap_wpa_psk_connection_1 (gconstpointer data) NM_802_11_AP_FLAGS_PRIVACY, wpa_flags_for_idx (idx), rsn_flags_for_idx (idx), - FALSE, expected); + FALSE, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + expected); g_object_unref (expected); } @@ -1217,7 +1219,9 @@ test_wpa_ap_wpa_psk_connection_2 (gconstpointer data) NM_802_11_AP_FLAGS_PRIVACY, wpa_flags_for_idx (idx), rsn_flags_for_idx (idx), - TRUE, expected); + TRUE, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + expected); g_object_unref (expected); } @@ -1237,7 +1241,9 @@ test_wpa_ap_wpa_psk_connection_3 (gconstpointer data) NM_802_11_AP_FLAGS_PRIVACY, wpa_flags_for_idx (idx), rsn_flags_for_idx (idx), - FALSE, expected); + FALSE, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + expected); g_object_unref (expected); } @@ -1249,7 +1255,9 @@ test_wpa_ap_wpa_psk_connection_4 (gconstpointer data) NM_802_11_AP_FLAGS_PRIVACY, wpa_flags_for_idx (idx), rsn_flags_for_idx (idx), - FALSE, NULL); + FALSE, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + NULL); } static void @@ -1268,7 +1276,9 @@ test_wpa_ap_wpa_psk_connection_5 (gconstpointer data) NM_802_11_AP_FLAGS_PRIVACY, wpa_flags_for_idx (idx), rsn_flags_for_idx (idx), - FALSE, expected); + FALSE, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + expected); g_object_unref (expected); } diff --git a/src/devices/wimax/nm-device-wimax.c b/src/devices/wimax/nm-device-wimax.c index d428f1d2e..daa4f970f 100644 --- a/src/devices/wimax/nm-device-wimax.c +++ b/src/devices/wimax/nm-device-wimax.c @@ -25,6 +25,7 @@ #include <sys/ioctl.h> #include <sys/socket.h> +#include <glib/gi18n.h> #include <WiMaxAPI.h> #include <WiMaxAPIEx.h> @@ -451,10 +452,11 @@ complete_connection (NMDevice *device, if (setting_mac) { /* Make sure the setting MAC (if any) matches the device's permanent MAC */ if (!nm_utils_hwaddr_matches (setting_mac, -1, hw_address, -1)) { - g_set_error (error, - NM_SETTING_WIMAX_ERROR, - NM_SETTING_WIMAX_ERROR_INVALID_PROPERTY, - NM_SETTING_WIMAX_MAC_ADDRESS); + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("connection does not match device")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_WIMAX_SETTING_NAME, NM_SETTING_WIMAX_MAC_ADDRESS); return FALSE; } } else { diff --git a/src/devices/wwan/nm-modem-broadband.c b/src/devices/wwan/nm-modem-broadband.c index ad2c8de4f..ac0f54f50 100644 --- a/src/devices/wwan/nm-modem-broadband.c +++ b/src/devices/wwan/nm-modem-broadband.c @@ -466,9 +466,10 @@ complete_connection (NMModem *_self, if (!s_gsm) { /* Need a GSM setting at least */ g_set_error_literal (error, - NM_SETTING_GSM_ERROR, - NM_SETTING_GSM_ERROR_MISSING_PROPERTY, - NM_SETTING_GSM_APN); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_SETTING, + _("GSM mobile broadband connection requires a 'gsm' setting")); + g_prefix_error (error, "%s: ", NM_SETTING_GSM_SETTING_NAME); return FALSE; } diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c index 87b7d2fa3..558d94052 100644 --- a/src/settings/nm-settings.c +++ b/src/settings/nm-settings.c @@ -1998,23 +1998,6 @@ nm_settings_class_init (NMSettingsClass *class) /* 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); - dbus_g_error_domain_register (NM_SETTING_CONNECTION_ERROR, NULL, NM_TYPE_SETTING_CONNECTION_ERROR); - dbus_g_error_domain_register (NM_SETTING_GSM_ERROR, NULL, NM_TYPE_SETTING_GSM_ERROR); - dbus_g_error_domain_register (NM_SETTING_IP4_CONFIG_ERROR, NULL, NM_TYPE_SETTING_IP4_CONFIG_ERROR); - dbus_g_error_domain_register (NM_SETTING_IP6_CONFIG_ERROR, NULL, NM_TYPE_SETTING_IP6_CONFIG_ERROR); - dbus_g_error_domain_register (NM_SETTING_OLPC_MESH_ERROR, NULL, NM_TYPE_SETTING_OLPC_MESH_ERROR); - dbus_g_error_domain_register (NM_SETTING_PPP_ERROR, NULL, NM_TYPE_SETTING_PPP_ERROR); - dbus_g_error_domain_register (NM_SETTING_PPPOE_ERROR, NULL, NM_TYPE_SETTING_PPPOE_ERROR); - dbus_g_error_domain_register (NM_SETTING_SERIAL_ERROR, NULL, NM_TYPE_SETTING_SERIAL_ERROR); - dbus_g_error_domain_register (NM_SETTING_ADSL_ERROR, NULL, NM_TYPE_SETTING_ADSL_ERROR); - dbus_g_error_domain_register (NM_SETTING_VPN_ERROR, NULL, NM_TYPE_SETTING_VPN_ERROR); - dbus_g_error_domain_register (NM_SETTING_WIRED_ERROR, NULL, NM_TYPE_SETTING_WIRED_ERROR); - dbus_g_error_domain_register (NM_SETTING_WIRELESS_SECURITY_ERROR, NULL, NM_TYPE_SETTING_WIRELESS_SECURITY_ERROR); - dbus_g_error_domain_register (NM_SETTING_WIRELESS_ERROR, NULL, NM_TYPE_SETTING_WIRELESS_ERROR); - dbus_g_error_domain_register (NM_SETTING_ERROR, NULL, NM_TYPE_SETTING_ERROR); dbus_g_object_type_install_info (NM_TYPE_SETTINGS, &dbus_glib_nm_settings_object_info); |