Commit df142a5d authored by Jiří Klimeš's avatar Jiří Klimeš

libnm-util: make property verification errors more descriptive

- fix g_set_error()/g_set_error_literal() usage
- make the error messages translatable
- use g_prefix_error() to prepend property name
parent cc66b547
This diff is collapsed.
......@@ -20,14 +20,16 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2007 - 2008 Red Hat, Inc.
* (C) Copyright 2011 - 2013 Red Hat, Inc.
*/
#include <string.h>
#include <glib/gi18n.h>
#include "nm-setting-adsl.h"
#include "nm-setting-ppp.h"
#include "nm-setting-private.h"
#include "nm-utils.h"
#include <string.h>
/**
* SECTION:nm-setting-adsl
......@@ -204,34 +206,39 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
NMSettingAdslPrivate *priv = NM_SETTING_ADSL_GET_PRIVATE (setting);
if (!priv->username) {
g_set_error (error,
NM_SETTING_ADSL_ERROR,
NM_SETTING_ADSL_ERROR_MISSING_PROPERTY,
NM_SETTING_ADSL_USERNAME);
g_set_error_literal (error,
NM_SETTING_ADSL_ERROR,
NM_SETTING_ADSL_ERROR_MISSING_PROPERTY,
_("property is missing"));
g_prefix_error (error, "%s: ", NM_SETTING_ADSL_USERNAME);
return FALSE;
} else if (!strlen (priv->username)) {
g_set_error (error,
NM_SETTING_ADSL_ERROR,
NM_SETTING_ADSL_ERROR_INVALID_PROPERTY,
NM_SETTING_ADSL_USERNAME);
g_set_error_literal (error,
NM_SETTING_ADSL_ERROR,
NM_SETTING_ADSL_ERROR_INVALID_PROPERTY,
_("property is empty"));
g_prefix_error (error, "%s: ", NM_SETTING_ADSL_USERNAME);
return FALSE;
}
if (priv->password && !strlen (priv->password)) {
g_set_error (error,
NM_SETTING_ADSL_ERROR,
NM_SETTING_ADSL_ERROR_INVALID_PROPERTY,
NM_SETTING_ADSL_PASSWORD);
g_set_error_literal (error,
NM_SETTING_ADSL_ERROR,
NM_SETTING_ADSL_ERROR_INVALID_PROPERTY,
_("property is empty"));
g_prefix_error (error, "%s: ", NM_SETTING_ADSL_PASSWORD);
return FALSE;
}
if (strcmp (priv->protocol, NM_SETTING_ADSL_PROTOCOL_PPPOA) &&
strcmp (priv->protocol, NM_SETTING_ADSL_PROTOCOL_PPPOE) &&
strcmp (priv->protocol, NM_SETTING_ADSL_PROTOCOL_IPOATM)) {
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_SETTING_ADSL_PROTOCOL);
_("'%s' is not a valid value for the property"),
priv->protocol);
g_prefix_error (error, "%s: ", NM_SETTING_ADSL_PROTOCOL);
return FALSE;
}
......@@ -240,7 +247,9 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
g_set_error (error,
NM_SETTING_ADSL_ERROR,
NM_SETTING_ADSL_ERROR_INVALID_PROPERTY,
NM_SETTING_ADSL_ENCAPSULATION);
_("'%s' is not a valid value for the property"),
priv->encapsulation);
g_prefix_error (error, "%s: ", NM_SETTING_ADSL_ENCAPSULATION);
return FALSE;
}
......
......@@ -20,12 +20,13 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2007 - 2009 Red Hat, Inc.
* (C) Copyright 2007 - 2013 Red Hat, Inc.
* (C) Copyright 2007 - 2008 Novell, Inc.
*/
#include <string.h>
#include <net/ethernet.h>
#include <glib/gi18n.h>
#include "nm-param-spec-specialized.h"
#include "nm-dbus-glib-types.h"
......@@ -146,33 +147,38 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
NMSettingBluetoothPrivate *priv = NM_SETTING_BLUETOOTH_GET_PRIVATE (setting);
if (!priv->bdaddr) {
g_set_error (error,
NM_SETTING_BLUETOOTH_ERROR,
NM_SETTING_BLUETOOTH_ERROR_MISSING_PROPERTY,
NM_SETTING_BLUETOOTH_BDADDR);
g_set_error_literal (error,
NM_SETTING_BLUETOOTH_ERROR,
NM_SETTING_BLUETOOTH_ERROR_MISSING_PROPERTY,
_("property is missing"));
g_prefix_error (error, "%s: ", NM_SETTING_BLUETOOTH_BDADDR);
return FALSE;
}
if (priv->bdaddr && priv->bdaddr->len != ETH_ALEN) {
g_set_error (error,
NM_SETTING_BLUETOOTH_ERROR,
NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY,
NM_SETTING_BLUETOOTH_BDADDR);
g_set_error_literal (error,
NM_SETTING_BLUETOOTH_ERROR,
NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY,
_("property is invalid"));
g_prefix_error (error, "%s: ", NM_SETTING_BLUETOOTH_BDADDR);
return FALSE;
}
if (!priv->type) {
g_set_error (error,
NM_SETTING_BLUETOOTH_ERROR,
NM_SETTING_BLUETOOTH_ERROR_MISSING_PROPERTY,
NM_SETTING_BLUETOOTH_TYPE);
g_set_error_literal (error,
NM_SETTING_BLUETOOTH_ERROR,
NM_SETTING_BLUETOOTH_ERROR_MISSING_PROPERTY,
_("property is missing"));
g_prefix_error (error, "%s: ", 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_SETTING_BLUETOOTH_TYPE);
_("'%s' is not a valid value for the property"),
priv->type);
g_prefix_error (error, "%s: ", NM_SETTING_BLUETOOTH_TYPE);
return FALSE;
}
......@@ -192,7 +198,9 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
g_set_error (error,
NM_SETTING_BLUETOOTH_ERROR,
NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND,
NM_SETTING_BLUETOOTH_TYPE);
_("requires '%s' or '%s' setting"),
NM_SETTING_GSM_SETTING_NAME, NM_SETTING_CDMA_SETTING_NAME);
g_prefix_error (error, "%s: ", NM_SETTING_BLUETOOTH_TYPE);
return FALSE;
}
}
......
......@@ -18,12 +18,13 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2011 - 2012 Red Hat, Inc.
* (C) Copyright 2011 - 2013 Red Hat, Inc.
*/
#include <string.h>
#include <stdlib.h>
#include <dbus/dbus-glib.h>
#include <glib/gi18n.h>
#include "nm-setting-bond.h"
#include "nm-param-spec-specialized.h"
......@@ -361,18 +362,20 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
const char *arp_ip_target = NULL;
if (!priv->interface_name || !strlen(priv->interface_name)) {
g_set_error (error,
NM_SETTING_BOND_ERROR,
NM_SETTING_BOND_ERROR_MISSING_PROPERTY,
NM_SETTING_BOND_INTERFACE_NAME);
g_set_error_literal (error,
NM_SETTING_BOND_ERROR,
NM_SETTING_BOND_ERROR_MISSING_PROPERTY,
_("property is missing"));
g_prefix_error (error, "%s: ", NM_SETTING_BOND_INTERFACE_NAME);
return FALSE;
}
if (!nm_utils_iface_valid_name (priv->interface_name)) {
g_set_error (error,
NM_SETTING_BOND_ERROR,
NM_SETTING_BOND_ERROR_INVALID_PROPERTY,
NM_SETTING_BOND_INTERFACE_NAME);
g_set_error_literal (error,
NM_SETTING_BOND_ERROR,
NM_SETTING_BOND_ERROR_INVALID_PROPERTY,
_("property is invalid"));
g_prefix_error (error, "%s: ", NM_SETTING_BOND_INTERFACE_NAME);
return FALSE;
}
......@@ -382,10 +385,12 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|| !value[0]
|| (strlen (value) > 200)
|| strchr (value, ' ')) {
g_set_error_literal (error,
NM_SETTING_BOND_ERROR,
NM_SETTING_BOND_ERROR_INVALID_OPTION,
key);
g_set_error (error,
NM_SETTING_BOND_ERROR,
NM_SETTING_BOND_ERROR_INVALID_OPTION,
_("invalid option '%s' or its value '%s'"),
key, value);
g_prefix_error (error, "%s: ", NM_SETTING_BOND_OPTIONS);
return FALSE;
}
}
......@@ -402,7 +407,10 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
g_set_error (error,
NM_SETTING_BOND_ERROR,
NM_SETTING_BOND_ERROR_INVALID_OPTION,
_("only one of '%s' and '%s' can be set"),
NM_SETTING_BOND_OPTION_MIIMON,
NM_SETTING_BOND_OPTION_ARP_INTERVAL);
g_prefix_error (error, "%s: ", NM_SETTING_BOND_OPTIONS);
}
value = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_MODE);
......@@ -410,14 +418,18 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
g_set_error (error,
NM_SETTING_BOND_ERROR,
NM_SETTING_BOND_ERROR_MISSING_OPTION,
_("setting '%s' is required"),
NM_SETTING_BOND_OPTION_MODE);
g_prefix_error (error, "%s: ", NM_SETTING_BOND_OPTIONS);
return FALSE;
}
if (!_nm_utils_string_in_list (value, valid_modes)) {
g_set_error (error,
NM_SETTING_BOND_ERROR,
NM_SETTING_BOND_ERROR_INVALID_OPTION,
NM_SETTING_BOND_OPTION_MODE);
_("'%s' is not a valid value for '%s'"),
value, NM_SETTING_BOND_OPTION_MODE);
g_prefix_error (error, "%s: ", NM_SETTING_BOND_OPTIONS);
return FALSE;
}
......@@ -428,7 +440,10 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
g_set_error (error,
NM_SETTING_BOND_ERROR,
NM_SETTING_BOND_ERROR_INVALID_OPTION,
NM_SETTING_BOND_OPTION_ARP_INTERVAL);
_("'%s=%s' is incompatible with '%s > 0'"),
NM_SETTING_BOND_OPTION_MODE, value, NM_SETTING_BOND_OPTION_ARP_INTERVAL);
g_prefix_error (error, "%s: ", NM_SETTING_BOND_OPTIONS);
return FALSE;
}
}
if (g_slist_find_custom (all_settings, NM_SETTING_INFINIBAND_SETTING_NAME, find_setting_by_name)) {
......@@ -436,7 +451,9 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
g_set_error (error,
NM_SETTING_BOND_ERROR,
NM_SETTING_BOND_ERROR_INVALID_OPTION,
NM_SETTING_BOND_OPTION_MODE);
_("'%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: ", NM_SETTING_BOND_OPTIONS);
return FALSE;
}
}
......@@ -447,14 +464,18 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
g_set_error (error,
NM_SETTING_BOND_ERROR,
NM_SETTING_BOND_ERROR_INVALID_OPTION,
NM_SETTING_BOND_OPTION_UPDELAY);
_("'%s' option requires setting '%s' option"),
NM_SETTING_BOND_OPTION_UPDELAY, NM_SETTING_BOND_OPTION_MIIMON);
g_prefix_error (error, "%s: ", NM_SETTING_BOND_OPTIONS);
return FALSE;
}
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_SETTING_BOND_OPTION_DOWNDELAY);
_("'%s' option requires setting '%s' option"),
NM_SETTING_BOND_OPTION_DOWNDELAY, NM_SETTING_BOND_OPTION_MIIMON);
g_prefix_error (error, "%s: ", NM_SETTING_BOND_OPTIONS);
return FALSE;
}
}
......@@ -472,7 +493,9 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
g_set_error (error,
NM_SETTING_BOND_ERROR,
NM_SETTING_BOND_ERROR_MISSING_OPTION,
NM_SETTING_BOND_OPTION_ARP_IP_TARGET);
_("'%s' option requires setting '%s' option"),
NM_SETTING_BOND_OPTION_ARP_INTERVAL, NM_SETTING_BOND_OPTION_ARP_IP_TARGET);
g_prefix_error (error, "%s: ", NM_SETTING_BOND_OPTIONS);
return FALSE;
}
......@@ -482,7 +505,9 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
g_set_error (error,
NM_SETTING_BOND_ERROR,
NM_SETTING_BOND_ERROR_INVALID_OPTION,
_("'%s' option is empty"),
NM_SETTING_BOND_OPTION_ARP_IP_TARGET);
g_prefix_error (error, "%s: ", NM_SETTING_BOND_OPTIONS);
return FALSE;
}
......@@ -492,7 +517,9 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
g_set_error (error,
NM_SETTING_BOND_ERROR,
NM_SETTING_BOND_ERROR_INVALID_OPTION,
NM_SETTING_BOND_OPTION_ARP_IP_TARGET);
_("'%s' is not a valid IPv4 address for '%s' option"),
NM_SETTING_BOND_OPTION_ARP_IP_TARGET, addrs[i]);
g_prefix_error (error, "%s: ", NM_SETTING_BOND_OPTIONS);
return FALSE;
}
}
......@@ -502,7 +529,9 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
g_set_error (error,
NM_SETTING_BOND_ERROR,
NM_SETTING_BOND_ERROR_INVALID_OPTION,
NM_SETTING_BOND_OPTION_ARP_IP_TARGET);
_("'%s' option requires setting '%s' option"),
NM_SETTING_BOND_OPTION_ARP_IP_TARGET, NM_SETTING_BOND_OPTION_ARP_INTERVAL);
g_prefix_error (error, "%s: ", NM_SETTING_BOND_OPTIONS);
return FALSE;
}
}
......
......@@ -18,13 +18,14 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2012 Red Hat, Inc.
* (C) Copyright 2012 - 2013 Red Hat, Inc.
*/
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <dbus/dbus-glib.h>
#include <glib/gi18n.h>
#include "nm-setting-bridge-port.h"
#include "nm-utils.h"
......@@ -151,7 +152,9 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
g_set_error (error,
NM_SETTING_BRIDGE_PORT_ERROR,
NM_SETTING_BRIDGE_PORT_ERROR_INVALID_PROPERTY,
NM_SETTING_BRIDGE_PORT_PRIORITY);
_("'%d' is not a valid value for the property (should be <= %d)"),
priv->priority, BR_MAX_PORT_PRIORITY);
g_prefix_error (error, "%s: ", NM_SETTING_BRIDGE_PORT_PRIORITY);
return FALSE;
}
......@@ -159,7 +162,9 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
g_set_error (error,
NM_SETTING_BRIDGE_PORT_ERROR,
NM_SETTING_BRIDGE_PORT_ERROR_INVALID_PROPERTY,
NM_SETTING_BRIDGE_PORT_PATH_COST);
_("'%d' is not a valid value for the property (should be <= %d)"),
priv->path_cost, BR_MAX_PATH_COST);
g_prefix_error (error, "%s: ", NM_SETTING_BRIDGE_PORT_PATH_COST);
return FALSE;
}
......
......@@ -18,13 +18,14 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2011 - 2012 Red Hat, Inc.
* (C) Copyright 2011 - 2013 Red Hat, Inc.
*/
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <dbus/dbus-glib.h>
#include <glib/gi18n.h>
#include "nm-setting-bridge.h"
#include "nm-param-spec-specialized.h"
......@@ -244,10 +245,12 @@ check_range (guint32 val,
GError **error)
{
if ((val != 0) && (val < min || val > max)) {
g_set_error_literal (error,
NM_SETTING_BRIDGE_ERROR,
NM_SETTING_BRIDGE_ERROR_INVALID_PROPERTY,
prop);
g_set_error (error,
NM_SETTING_BRIDGE_ERROR,
NM_SETTING_BRIDGE_ERROR_INVALID_PROPERTY,
_("value '%d' is out of range <%d-%d>"),
val, min, max);
g_prefix_error (error, "%s: ", prop);
return FALSE;
}
return TRUE;
......@@ -259,10 +262,11 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
NMSettingBridgePrivate *priv = NM_SETTING_BRIDGE_GET_PRIVATE (setting);
if (!priv->interface_name || !strlen(priv->interface_name)) {
g_set_error (error,
NM_SETTING_BRIDGE_ERROR,
NM_SETTING_BRIDGE_ERROR_MISSING_PROPERTY,
NM_SETTING_BRIDGE_INTERFACE_NAME);
g_set_error_literal (error,
NM_SETTING_BRIDGE_ERROR,
NM_SETTING_BRIDGE_ERROR_MISSING_PROPERTY,
_("property is missing"));
g_prefix_error (error, "%s: ", NM_SETTING_BRIDGE_INTERFACE_NAME);
return FALSE;
}
......@@ -270,7 +274,9 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
g_set_error (error,
NM_SETTING_BRIDGE_ERROR,
NM_SETTING_BRIDGE_ERROR_INVALID_PROPERTY,
NM_SETTING_BRIDGE_INTERFACE_NAME);
_("'%s' is not a valid interface name"),
priv->interface_name);
g_prefix_error (error, "%s: ", NM_SETTING_BRIDGE_INTERFACE_NAME);
return FALSE;
}
......
......@@ -18,10 +18,12 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2007 - 2011 Red Hat, Inc.
* (C) Copyright 2007 - 2013 Red Hat, Inc.
*/
#include <string.h>
#include <glib/gi18n.h>
#include "nm-setting-cdma.h"
#include "nm-utils.h"
#include "nm-setting-private.h"
......@@ -155,32 +157,36 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
NMSettingCdmaPrivate *priv = NM_SETTING_CDMA_GET_PRIVATE (setting);
if (!priv->number) {
g_set_error (error,
NM_SETTING_CDMA_ERROR,
NM_SETTING_CDMA_ERROR_MISSING_PROPERTY,
NM_SETTING_CDMA_NUMBER);
g_set_error_literal (error,
NM_SETTING_CDMA_ERROR,
NM_SETTING_CDMA_ERROR_MISSING_PROPERTY,
_("property is missing"));
g_prefix_error (error, "%s: ", NM_SETTING_CDMA_NUMBER);
return FALSE;
} else if (!strlen (priv->number)) {
g_set_error (error,
NM_SETTING_CDMA_ERROR,
NM_SETTING_CDMA_ERROR_INVALID_PROPERTY,
NM_SETTING_CDMA_NUMBER);
g_set_error_literal (error,
NM_SETTING_CDMA_ERROR,
NM_SETTING_CDMA_ERROR_INVALID_PROPERTY,
_("property is empty'"));
g_prefix_error (error, "%s: ", NM_SETTING_CDMA_NUMBER);
return FALSE;
}
if (priv->username && !strlen (priv->username)) {
g_set_error (error,
NM_SETTING_CDMA_ERROR,
NM_SETTING_CDMA_ERROR_INVALID_PROPERTY,
NM_SETTING_CDMA_USERNAME);
g_set_error_literal (error,
NM_SETTING_CDMA_ERROR,
NM_SETTING_CDMA_ERROR_INVALID_PROPERTY,
_("property is empty"));
g_prefix_error (error, "%s: ", NM_SETTING_CDMA_USERNAME);
return FALSE;
}
if (priv->password && !strlen (priv->password)) {
g_set_error (error,
NM_SETTING_CDMA_ERROR,
NM_SETTING_CDMA_ERROR_INVALID_PROPERTY,
NM_SETTING_CDMA_PASSWORD);
g_set_error_literal (error,
NM_SETTING_CDMA_ERROR,
NM_SETTING_CDMA_ERROR_INVALID_PROPERTY,
_("property is empty"));
g_prefix_error (error, "%s: ", NM_SETTING_CDMA_PASSWORD);
return FALSE;
}
......
......@@ -19,11 +19,13 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2007 - 2012 Red Hat, Inc.
* (C) Copyright 2007 - 2013 Red Hat, Inc.
* (C) Copyright 2007 - 2008 Novell, Inc.
*/
#include <string.h>
#include <glib/gi18n.h>
#include "nm-utils.h"
#include "nm-dbus-glib-types.h"
#include "nm-param-spec-specialized.h"
......@@ -647,44 +649,51 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
NMSettingConnectionPrivate *priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting);
if (!priv->id) {
g_set_error (error,
NM_SETTING_CONNECTION_ERROR,
NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY,
NM_SETTING_CONNECTION_ID);
g_set_error_literal (error,
NM_SETTING_CONNECTION_ERROR,
NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY,
_("property is missing"));
g_prefix_error (error, "%s: ", NM_SETTING_CONNECTION_ID);
return FALSE;
} else if (!strlen (priv->id)) {
g_set_error (error,
NM_SETTING_CONNECTION_ERROR,
NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY,
NM_SETTING_CONNECTION_ID);
g_set_error_literal (error,
NM_SETTING_CONNECTION_ERROR,
NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY,
_("property is empty"));
g_prefix_error (error, "%s: ", NM_SETTING_CONNECTION_ID);
return FALSE;
}
if (!priv->uuid) {
g_set_error (error,
NM_SETTING_CONNECTION_ERROR,
NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY,
NM_SETTING_CONNECTION_UUID);
g_set_error_literal (error,
NM_SETTING_CONNECTION_ERROR,
NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY,
_("property is missing"));
g_prefix_error (error, "%s: ", 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_SETTING_CONNECTION_UUID);
_("'%s' is not a valid UUID"),
priv->uuid);
g_prefix_error (error, "%s: ", NM_SETTING_CONNECTION_UUID);
return FALSE;
}
if (!priv->type) {
g_set_error (error,
NM_SETTING_CONNECTION_ERROR,
NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY,
NM_SETTING_CONNECTION_TYPE);
g_set_error_literal (error,
NM_SETTING_CONNECTION_ERROR,
NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY,
_("property is missing"));
g_prefix_error (error, "%s: ", NM_SETTING_CONNECTION_TYPE);
return FALSE;
} else if (!strlen (priv->type)) {
g_set_error (error,
NM_SETTING_CONNECTION_ERROR,
NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY,
NM_SETTING_CONNECTION_TYPE);
g_set_error_literal (error,
NM_SETTING_CONNECTION_ERROR,
NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY,
_("property is empty"));
g_prefix_error (error, "%s: ", NM_SETTING_CONNECTION_TYPE);
return FALSE;
}
......@@ -693,7 +702,9 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
g_set_error (error,
NM_SETTING_CONNECTION_ERROR,
NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND,
NM_SETTING_CONNECTION_TYPE);
_("requires presence of '%s' setting in the connection"),
priv->type);
g_prefix_error (error, "%s: ", NM_SETTING_CONNECTION_TYPE);
return FALSE;
}
......@@ -712,10 +723,11 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
if (strcmp (nm_setting_ip4_config_get_method (s_ip4),
NM_SETTING_IP4_CONFIG_METHOD_DISABLED)) {
g_set_error (error,
NM_SETTING_CONNECTION_ERROR,
NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED,
"No IP configuration allowed for bonding slave");
g_set_error_literal (error,
NM_SETTING_CONNECTION_ERROR,
NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED,
_("IPv4 configuration is not allowed for bonding slave"));
g_prefix_error (error, "%s: ", NM_SETTING_CONNECTION_SLAVE_TYPE);
return FALSE;
}
}
......@@ -728,10 +740,11 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
if (strcmp (nm_setting_ip6_config_get_method (s_ip6),
NM_SETTING_IP6_CONFIG_METHOD_IGNORE)) {
g_set_error (error,
NM_SETTING_CONNECTION_ERROR,
NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED,
"No IPv6 configuration allowed for bonding slave");
g_set_error_literal (error,
NM_SETTING_CONNECTION_ERROR,
NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED,
_("IPv6 configuration is not allowed for bonding slave"));
g_prefix_error (error, "%s: ", NM_SETTING_CONNECTION_SLAVE_TYPE);
return FALSE;
}
}
......
......@@ -19,11 +19,13 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2007 - 2011 Red Hat, Inc.
* (C) Copyright 2007 - 2013 Red Hat, Inc.
* (C) Copyright 2007 - 2008 Novell, Inc.
*/
#include <string.h>
#include <glib/gi18n.h>
#include "nm-setting-gsm.h"
#include "nm-utils.h"
#include "nm-setting-private.h"
......@@ -272,10 +274,11 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE (setting);
if (priv->number && !priv->number[0]) {
g_set_error (error,
NM_SETTING_GSM_ERROR,
NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
NM_SETTING_GSM_NUMBER);
g_set_error_literal (error,
NM_SETTING_GSM_ERROR,
NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
_("property is empty"));
g_prefix_error (error, "%s: ", NM_SETTING_GSM_NUMBER);
return FALSE;
}
......@@ -287,7 +290,9 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
g_set_error (error,
NM_SETTING_GSM_ERROR,
NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
NM_SETTING_GSM_APN);
_("property value '%s' is empty or too long (>64)"),
priv->apn);
g_prefix_error (error, "%s: ", NM_SETTING_GSM_APN);
return FALSE;
}
......@@ -317,25 +322,29 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
g_set_error (error,
NM_SETTING_GSM_ERROR,
NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
NM_SETTING_GSM_APN);
_("'%s' contains invalid char(s) (use [A-Za-z._-])"),
priv->apn);
g_prefix_error (error, "%s: ", NM_SETTING_GSM_APN);
return FALSE;
}
}
}
if (priv->username && !strlen (priv->username)) {
g_set_error (error,
NM_SETTING_GSM_ERROR,
NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
NM_SETTING_GSM_USERNAME);
g_set_error_literal (error,
NM_SETTING_GSM_ERROR,
NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
_("property is empty"));
g_prefix_error (error, "%s: ", NM_SETTING_GSM_USERNAME);
return FALSE;
}
if (priv->password && !strlen (priv->password)) {
g_set_error (error,
NM_SETTING_GSM_ERROR,
NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
NM_SETTING_GSM_USERNAME);
g_set_error_literal (error,
NM_SETTING_GSM_ERROR,
NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
_("property is empty"));
g_prefix_error (error, "%s: ", NM_SETTING_GSM_USERNAME);
return FALSE;
}
......@@ -348,7 +357,9 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
g_set_error (error,
NM_SETTING_GSM_ERROR,
NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
NM_SETTING_GSM_NETWORK_ID);
_("'%s' length is invalid (should be 5 or 6 digits)"),
priv->network_id);
g_prefix_error (error, "%s: ", NM_SETTING_GSM_NETWORK_ID);
return FALSE;
}
......@@ -357,7 +368,9 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
g_set_error (error,
NM_SETTING_GSM_ERROR,
NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
NM_SETTING_GSM_NETWORK_ID);
_("'%s' is not a number"),
priv->network_id);
g_prefix_error (error, "%s: ", NM_SETTING_GSM_NETWORK_ID);
return FALSE;
}
}
......
......@@ -16,11 +16,12 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* Copyright 2011 Red Hat, Inc.
* Copyright 2011 - 2013 Red Hat, Inc.
*/
#include <dbus/dbus-glib.h>
#include <linux/if_infiniband.h>
#include <glib/gi18n.h>