diff options
Diffstat (limited to 'libnm-util/nm-connection.c')
-rw-r--r-- | libnm-util/nm-connection.c | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/libnm-util/nm-connection.c b/libnm-util/nm-connection.c index 870fea5177..f8e7a71d62 100644 --- a/libnm-util/nm-connection.c +++ b/libnm-util/nm-connection.c @@ -45,6 +45,37 @@ #include "nm-setting-gsm.h" #include "nm-setting-cdma.h" +GQuark +nm_connection_error_quark (void) +{ + static GQuark quark; + + if (G_UNLIKELY (!quark)) + quark = g_quark_from_static_string ("nm-connection-error-quark"); + return quark; +} + +/* This should really be standard. */ +#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } + +GType +nm_connection_error_get_type (void) +{ + static GType etype = 0; + + if (etype == 0) { + static const GEnumValue values[] = { + /* Unknown error. */ + ENUM_ENTRY (NM_CONNECTION_ERROR_UNKNOWN, "UnknownError"), + /* The required 'connection' setting was not found. */ + ENUM_ENTRY (NM_CONNECTION_ERROR_CONNECTION_SETTING_NOT_FOUND, "ConnectionSettingNotFound"), + { 0, 0, 0 } + }; + etype = g_enum_register_static ("NMConnectionError", values); + } + return etype; +} + typedef struct { GHashTable *settings; @@ -430,7 +461,7 @@ gboolean nm_connection_verify (NMConnection *connection, GError **error) { NMConnectionPrivate *priv; - NMSetting *connection_setting; + NMSetting *s_con; VerifySettingsInfo info; g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE); @@ -440,9 +471,12 @@ nm_connection_verify (NMConnection *connection, GError **error) priv = NM_CONNECTION_GET_PRIVATE (connection); /* First, make sure there's at least 'connection' setting */ - connection_setting = nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION); - if (!connection_setting) { - g_warning ("'connection' setting not present."); + s_con = nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION); + if (!s_con) { + g_set_error (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_CONNECTION_SETTING_NOT_FOUND, + "connection setting not found"); return FALSE; } |