Commit 2d8e7bd2 authored by Dan Winship's avatar Dan Winship

libnm-core: merge NMSetting*Error into NMConnectionError

Each setting type was defining its own error type, but most of them
had exactly the same three errors ("unknown", "missing property", and
"invalid property"), and none of the other values was of much use
programmatically anyway.

So, this commit merges NMSettingError, NMSettingAdslError, etc, all
into NMConnectionError. (The reason for merging into NMConnectionError
rather than NMSettingError is that we also already have
"NMSettingsError", for errors related to the settings service, so
"NMConnectionError" is a less-confusable name for settings/connection
errors than "NMSettingError".)

Also, make sure that all of the affected error messages are localized,
and (where appropriate) prefix them with the relevant property name.

Renamed error codes:

NM_SETTING_ERROR_PROPERTY_NOT_FOUND -> NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND
NM_SETTING_ERROR_PROPERTY_NOT_SECRET -> NM_CONNECTION_ERROR_PROPERTY_NOT_SECRET

Remapped error codes:

NM_SETTING_*_ERROR_MISSING_PROPERTY -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_*_ERROR_INVALID_PROPERTY -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_INVALID_SETTING
NM_SETTING_BOND_ERROR_INVALID_OPTION -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BOND_ERROR_MISSING_OPTION -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_CONNECTION_ERROR_SLAVE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_VLAN_ERROR_INVALID_PARENT -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND -> NM_CONNECTION_ERROR_MISSING_PROPERTY

Dropped error codes (were previously defined but unused):

NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED
NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED
NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING
NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING
NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING
parent aeb3d093
......@@ -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);
......
......@@ -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;
/*
......
This diff is collapsed.
......@@ -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"
......
......@@ -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);
......
......@@ -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"
......
......@@ -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;
}
}
......
......@@ -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"
......
......@@ -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);
......
......@@ -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 */
......
......@@ -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,
......
......@@ -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"
......
......@@ -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;
......
......@@ -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"
......
......@@ -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);