diff options
author | Dan Winship <danw@gnome.org> | 2014-10-22 08:29:29 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2014-10-22 08:29:29 -0400 |
commit | 558cbe5c1146cd7b45b18058e0d86f490af7a61e (patch) | |
tree | 72c920d7732692287779e7c499975fcc16f8e835 | |
parent | 63957e0ed23e949ad24290f8f4c02f6925bb6bef (diff) | |
parent | da8d79f1c5f7d9c34610ebf82fe2328678cb4169 (diff) | |
download | NetworkManager-558cbe5c1146cd7b45b18058e0d86f490af7a61e.tar.gz |
all: consolidate error domains and fix up D-Bus error mapping (bgo #735900)
220 files changed, 2257 insertions, 4462 deletions
diff --git a/clients/cli/connections.c b/clients/cli/connections.c index 782ed9af96..5c239563bf 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -1856,7 +1856,6 @@ activate_connection_cb (GObject *client, GAsyncResult *result, gpointer user_dat active = nm_client_activate_connection_finish (NM_CLIENT (client), result, &error); if (error) { - g_dbus_error_strip_remote_error (error); g_string_printf (nmc->return_text, _("Error: Connection activation failed: %s"), error->message); g_error_free (error); @@ -4958,7 +4957,6 @@ add_connection_cb (GObject *client, connection = nm_client_add_connection_finish (NM_CLIENT (client), result, &error); if (error) { - g_dbus_error_strip_remote_error (error); g_string_printf (nmc->return_text, _("Error: Failed to add '%s' connection: %s"), info->con_name, error->message); @@ -7461,7 +7459,6 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t g_cond_wait (&nmc_editor_cond, &nmc_editor_mutex); if (nmc_editor_error) { - g_dbus_error_strip_remote_error (nmc_editor_error); g_print (_("Error: Failed to save '%s' (%s) connection: %s\n"), nm_connection_get_id (connection), nm_connection_get_uuid (connection), @@ -7549,7 +7546,6 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t g_cond_wait (&nmc_editor_cond, &nmc_editor_mutex); if (nmc_editor_error) { - g_dbus_error_strip_remote_error (nmc_editor_error); g_print (_("Error: Failed to activate '%s' (%s) connection: %s\n"), nm_connection_get_id (connection), nm_connection_get_uuid (connection), @@ -8003,7 +7999,6 @@ modify_connection_cb (GObject *connection, if (!nm_remote_connection_commit_changes_finish (NM_REMOTE_CONNECTION (connection), result, &error)) { - g_dbus_error_strip_remote_error (error); g_string_printf (nmc->return_text, _("Error: Failed to modify connection '%s': %s"), nm_connection_get_id (NM_CONNECTION (connection)), @@ -8216,7 +8211,6 @@ delete_cb (GObject *con, GAsyncResult *result, gpointer user_data) GError *error = NULL; if (!nm_remote_connection_delete_finish (NM_REMOTE_CONNECTION (con), result, &error)) { - g_dbus_error_strip_remote_error (error); g_string_printf (info->nmc->return_text, _("Error: Connection deletion failed: %s"), error->message); g_error_free (error); @@ -8341,7 +8335,6 @@ do_connection_reload (NmCli *nmc, int argc, char **argv) } if (!nm_client_reload_connections (nmc->client, NULL, &error)) { - g_dbus_error_strip_remote_error (error); g_string_printf (nmc->return_text, _("Error: failed to reload connections: %s."), error->message); nmc->return_value = NMC_RESULT_ERROR_UNKNOWN; @@ -8381,7 +8374,6 @@ do_connection_load (NmCli *nmc, int argc, char **argv) nm_client_load_connections (nmc->client, filenames, &failures, NULL, &error); g_free (filenames); if (error) { - g_dbus_error_strip_remote_error (error); g_string_printf (nmc->return_text, _("Error: failed to load connection: %s."), error->message); nmc->return_value = NMC_RESULT_ERROR_UNKNOWN; diff --git a/clients/cli/devices.c b/clients/cli/devices.c index 4949691264..d9b46d9457 100644 --- a/clients/cli/devices.c +++ b/clients/cli/devices.c @@ -1396,7 +1396,6 @@ add_and_activate_cb (GObject *client, active = nm_client_add_and_activate_connection_finish (NM_CLIENT (client), result, &error); if (error) { - g_dbus_error_strip_remote_error (error); g_string_printf (nmc->return_text, _("Error: Failed to add/activate new connection: %s"), error->message); g_error_free (error); @@ -1472,18 +1471,12 @@ connect_device_cb (GObject *client, GAsyncResult *result, gpointer user_data) active = nm_client_activate_connection_finish (NM_CLIENT (client), result, &error); if (error) { - char *dbus_err; - /* If no connection existed for the device, create one and activate it */ - dbus_err = g_dbus_error_get_remote_error (error); - if (g_strcmp0 (dbus_err, "org.freedesktop.NetworkManager.UnknownConnection") == 0) { + if (g_error_matches (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_CONNECTION)) { create_connect_connection_for_device (info); - g_free (dbus_err); return; } - g_free (dbus_err); - g_dbus_error_strip_remote_error (error); g_string_printf (nmc->return_text, _("Error: Device activation failed: %s"), error->message); g_error_free (error); @@ -1626,7 +1619,6 @@ disconnect_device_cb (GObject *object, GAsyncResult *result, gpointer user_data) GError *error = NULL; if (!nm_device_disconnect_finish (device, result, &error)) { - g_dbus_error_strip_remote_error (error); g_string_printf (nmc->return_text, _("Error: Device '%s' (%s) disconnecting failed: %s"), nm_device_get_iface (device), nm_object_get_path (NM_OBJECT (device)), @@ -1732,7 +1724,6 @@ delete_device_cb (GObject *object, GAsyncResult *result, gpointer user_data) GError *error = NULL; if (!nm_device_delete_finish (device, result, &error)) { - g_dbus_error_strip_remote_error (error); g_string_printf (nmc->return_text, _("Error: Device '%s' (%s) deletion failed: %s"), nm_device_get_iface (device), nm_object_get_path (NM_OBJECT (device)), @@ -2416,7 +2407,6 @@ request_rescan_cb (GObject *object, GAsyncResult *result, gpointer user_data) nm_device_wifi_request_scan_finish (NM_DEVICE_WIFI (object), result, &error); if (error) { - g_dbus_error_strip_remote_error (error); g_string_printf (nmc->return_text, _("Error: %s."), error->message); nmc->return_value = NMC_RESULT_ERROR_UNKNOWN; g_error_free (error); diff --git a/clients/cli/general.c b/clients/cli/general.c index a4face54cc..531d4f7acd 100644 --- a/clients/cli/general.c +++ b/clients/cli/general.c @@ -542,7 +542,6 @@ save_hostname_cb (GObject *object, GAsyncResult *result, gpointer user_data) nm_client_save_hostname_finish (NM_CLIENT (object), result, &error); if (error) { - g_dbus_error_strip_remote_error (error); g_string_printf (nmc->return_text, _("Error: failed to set hostname: %s"), error->message); nmc->return_value = NMC_RESULT_ERROR_UNKNOWN; @@ -653,7 +652,6 @@ do_general (NmCli *nmc, int argc, char **argv) nmc->get_client (nmc); /* create NMClient */ nm_client_set_logging (nmc->client, level, domains, &error); if (error) { - g_dbus_error_strip_remote_error (error); g_string_printf (nmc->return_text, _("Error: failed to set logging: %s"), error->message); nmc->return_value = NMC_RESULT_ERROR_UNKNOWN; diff --git a/clients/tui/nmt-secret-agent.c b/clients/tui/nmt-secret-agent.c index d2ee50efd3..40ab9c14cb 100644 --- a/clients/tui/nmt-secret-agent.c +++ b/clients/tui/nmt-secret-agent.c @@ -444,7 +444,7 @@ nmt_secret_agent_get_secrets (NMSecretAgent *agent, request_id = g_strdup_printf ("%s/%s", connection_path, setting_name); if (g_hash_table_lookup (priv->requests, request_id) != NULL) { /* We already have a request pending for this (connection, setting) */ - error = g_error_new (NM_SECRET_AGENT_ERROR, NM_SECRET_AGENT_ERROR_INTERNAL_ERROR, + error = g_error_new (NM_SECRET_AGENT_ERROR, NM_SECRET_AGENT_ERROR_FAILED, "Request for %s secrets already pending", request_id); nope: callback (agent, connection, NULL, error, callback_data); diff --git a/clients/tui/nmtui-connect.c b/clients/tui/nmtui-connect.c index 7e04657aff..be03796986 100644 --- a/clients/tui/nmtui-connect.c +++ b/clients/tui/nmtui-connect.c @@ -86,7 +86,7 @@ activate_ac_state_changed (GObject *object, return; if (state != NM_ACTIVE_CONNECTION_STATE_ACTIVATED) { - error = g_error_new_literal (NM_CLIENT_ERROR, NM_CLIENT_ERROR_UNKNOWN, + error = g_error_new_literal (NM_CLIENT_ERROR, NM_CLIENT_ERROR_FAILED, _("Activation failed")); } diff --git a/include/nm-glib-compat.h b/include/nm-glib-compat.h index 397eabfaca..7a9bb3160a 100644 --- a/include/nm-glib-compat.h +++ b/include/nm-glib-compat.h @@ -150,4 +150,18 @@ __g_test_add_data_func_full (const char *testpath, #define g_test_add_data_func_full __g_test_add_data_func_full +#if !GLIB_CHECK_VERSION (2, 34, 0) +#define G_DEFINE_QUARK(QN, q_n) \ +GQuark \ +q_n##_quark (void) \ +{ \ + static GQuark q; \ + \ + if G_UNLIKELY (q == 0) \ + q = g_quark_from_static_string (#QN); \ + \ + return q; \ +} +#endif + #endif /* __NM_GLIB_COMPAT_H__ */ diff --git a/introspection/nm-manager.xml b/introspection/nm-manager.xml index ac9bec6676..05bcc99a36 100644 --- a/introspection/nm-manager.xml +++ b/introspection/nm-manager.xml @@ -73,16 +73,6 @@ The path of the active connection object representing this active connection. </tp:docstring> </arg> - <tp:possible-errors> - <tp:error name="org.freedesktop.NetworkManager.Error.UnknownConnection"/> - <tp:error name="org.freedesktop.NetworkManager.Error.UnknownDevice"/> - <tp:error name="org.freedesktop.NetworkManager.Error.ConnectionActivating"> - <tp:docstring>Another connection is already activating or the same connection is already active. FIXME: check if the error name is correct. FIXME: split into 2 errors?</tp:docstring> - </tp:error> - <tp:error name="org.freedesktop.NetworkManager.Error.ConnectionInvalid"> - <tp:docstring>The connection is invalid for this device.</tp:docstring> - </tp:error> - </tp:possible-errors> </method> <method name="AddAndActivateConnection"> @@ -125,13 +115,6 @@ The path of the active connection object representing this active connection. </tp:docstring> </arg> - <tp:possible-errors> - <tp:error name="org.freedesktop.NetworkManager.Error.UnknownConnection"/> - <tp:error name="org.freedesktop.NetworkManager.Error.UnknownDevice"/> - <tp:error name="org.freedesktop.NetworkManager.Error.ConnectionInvalid"> - <tp:docstring>The connection is invalid for this device.</tp:docstring> - </tp:error> - </tp:possible-errors> </method> <method name="DeactivateConnection"> diff --git a/libnm-core/Makefile.libnm-core b/libnm-core/Makefile.libnm-core index 22566e0638..c79665e9f5 100644 --- a/libnm-core/Makefile.libnm-core +++ b/libnm-core/Makefile.libnm-core @@ -10,6 +10,7 @@ libnm_core_headers = \ $(core_build)/nm-version.h \ $(core)/nm-connection.h \ $(core)/nm-dbus-interface.h \ + $(core)/nm-errors.h \ $(core)/nm-setting-8021x.h \ $(core)/nm-setting-adsl.h \ $(core)/nm-setting-bluetooth.h \ @@ -52,6 +53,7 @@ libnm_core_sources = \ $(core_build)/nm-core-enum-types.c \ $(core)/crypto.c \ $(core)/nm-connection.c \ + $(core)/nm-errors.c \ $(core)/nm-property-compare.c \ $(core)/nm-setting-8021x.c \ $(core)/nm-setting-adsl.c \ diff --git a/libnm-core/crypto.c b/libnm-core/crypto.c index 2cc671c7df..a695747109 100644 --- a/libnm-core/crypto.c +++ b/libnm-core/crypto.c @@ -31,17 +31,7 @@ #include <glib/gi18n.h> #include "crypto.h" - -GQuark -_nm_crypto_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-crypto-error-quark"); - return quark; -} - +#include "nm-errors.h" #define PEM_RSA_KEY_BEGIN "-----BEGIN RSA PRIVATE KEY-----" #define PEM_RSA_KEY_END "-----END RSA PRIVATE KEY-----" @@ -117,12 +107,7 @@ parse_old_openssl_key_file (const guint8 *data, end_tag = PEM_DSA_KEY_END; break; default: - g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_UNKNOWN_KEY_TYPE, - "Unknown key type %d", - key_type); g_assert_not_reached (); - return NULL; } if (!find_tag (start_tag, data, data_len, 0, &start)) @@ -131,7 +116,7 @@ parse_old_openssl_key_file (const guint8 *data, start += strlen (start_tag); if (!find_tag (end_tag, data, data_len, start, &end)) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_FILE_FORMAT_INVALID, + NM_CRYPTO_ERROR_INVALID_DATA, _("PEM key file had no end tag '%s'."), end_tag); goto parse_error; @@ -144,7 +129,7 @@ parse_old_openssl_key_file (const guint8 *data, if (!lines || g_strv_length (lines) <= 1) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_FILE_FORMAT_INVALID, + NM_CRYPTO_ERROR_INVALID_DATA, _("Doesn't look like a PEM private key file.")); goto parse_error; } @@ -161,7 +146,7 @@ parse_old_openssl_key_file (const guint8 *data, if (!strncmp (p, PROC_TYPE_TAG, strlen (PROC_TYPE_TAG))) { if (enc_tags++ != 0) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_FILE_FORMAT_INVALID, + NM_CRYPTO_ERROR_INVALID_DATA, _("Malformed PEM file: Proc-Type was not first tag.")); goto parse_error; } @@ -169,7 +154,7 @@ parse_old_openssl_key_file (const guint8 *data, p += strlen (PROC_TYPE_TAG); if (strcmp (p, "4,ENCRYPTED")) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_FILE_FORMAT_INVALID, + NM_CRYPTO_ERROR_INVALID_DATA, _("Malformed PEM file: unknown Proc-Type tag '%s'."), p); goto parse_error; @@ -179,7 +164,7 @@ parse_old_openssl_key_file (const guint8 *data, if (enc_tags++ != 1) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_FILE_FORMAT_INVALID, + NM_CRYPTO_ERROR_INVALID_DATA, _("Malformed PEM file: DEK-Info was not the second tag.")); goto parse_error; } @@ -190,14 +175,14 @@ parse_old_openssl_key_file (const guint8 *data, comma = strchr (p, ','); if (!comma || (*(comma + 1) == '\0')) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_FILE_FORMAT_INVALID, + NM_CRYPTO_ERROR_INVALID_DATA, _("Malformed PEM file: no IV found in DEK-Info tag.")); goto parse_error; } *comma++ = '\0'; if (!g_ascii_isxdigit (*comma)) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_FILE_FORMAT_INVALID, + NM_CRYPTO_ERROR_INVALID_DATA, _("Malformed PEM file: invalid format of IV in DEK-Info tag.")); goto parse_error; } @@ -212,7 +197,7 @@ parse_old_openssl_key_file (const guint8 *data, cipher = g_strdup (p); } else { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_UNKNOWN_KEY_TYPE, + NM_CRYPTO_ERROR_INVALID_DATA, _("Malformed PEM file: unknown private key cipher '%s'."), p); goto parse_error; @@ -220,7 +205,7 @@ parse_old_openssl_key_file (const guint8 *data, } else { if ((enc_tags != 0) && (enc_tags != 2)) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_FILE_FORMAT_INVALID, + NM_CRYPTO_ERROR_INVALID_DATA, "Malformed PEM file: both Proc-Type and DEK-Info tags are required."); goto parse_error; } @@ -231,7 +216,7 @@ parse_old_openssl_key_file (const guint8 *data, tmp = g_base64_decode (str->str, &tmp_len); if (tmp == NULL || !tmp_len) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_DECODE_FAILED, + NM_CRYPTO_ERROR_INVALID_DATA, _("Could not decode private key.")); goto parse_error; } @@ -284,7 +269,7 @@ parse_pkcs8_key_file (const guint8 *data, encrypted = FALSE; } else { g_set_error_literal (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_FILE_FORMAT_INVALID, + NM_CRYPTO_ERROR_INVALID_DATA, _("Failed to find expected PKCS#8 start tag.")); return NULL; } @@ -292,7 +277,7 @@ parse_pkcs8_key_file (const guint8 *data, start += strlen (start_tag); if (!find_tag (end_tag, data, data_len, start, &end)) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_FILE_FORMAT_INVALID, + NM_CRYPTO_ERROR_INVALID_DATA, _("Failed to find expected PKCS#8 end tag '%s'."), end_tag); return NULL; @@ -311,7 +296,7 @@ parse_pkcs8_key_file (const guint8 *data, *out_encrypted = encrypted; } else { g_set_error_literal (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_DECODE_FAILED, + NM_CRYPTO_ERROR_INVALID_DATA, _("Failed to decode PKCS#8 private key.")); } @@ -353,7 +338,7 @@ convert_iv (const char *src, num = strlen (src); if (num % 2) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_RAW_IV_INVALID, + NM_CRYPTO_ERROR_INVALID_DATA, _("IV must be an even number of bytes in length.")); return NULL; } @@ -367,7 +352,7 @@ convert_iv (const char *src, conv[1] = src[(i * 2) + 1]; if (!g_ascii_isxdigit (conv[0]) || !g_ascii_isxdigit (conv[1])) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_RAW_IV_INVALID, + NM_CRYPTO_ERROR_INVALID_DATA, _("IV contains non-hexadecimal digits.")); goto error; } @@ -407,7 +392,7 @@ make_des_aes_key (const char *cipher, digest_len = 16; else { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_UNKNOWN_CIPHER, + NM_CRYPTO_ERROR_UNKNOWN_CIPHER, _("Private key cipher '%s' was unknown."), cipher); return NULL; @@ -519,7 +504,7 @@ crypto_decrypt_private_key_data (const guint8 *data, if (!parsed) { g_clear_error (error); g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_FILE_FORMAT_INVALID, + NM_CRYPTO_ERROR_INVALID_DATA, _("Unable to determine private key type.")); } } @@ -576,7 +561,7 @@ extract_pem_cert_data (GByteArray *contents, GError **error) if (!find_tag (PEM_CERT_BEGIN, contents->data, contents->len, 0, &start)) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_FILE_FORMAT_INVALID, + NM_CRYPTO_ERROR_INVALID_DATA, _("PEM certificate had no start tag '%s'."), PEM_CERT_BEGIN); goto done; @@ -585,7 +570,7 @@ extract_pem_cert_data (GByteArray *contents, GError **error) start += strlen (PEM_CERT_BEGIN); if (!find_tag (PEM_CERT_END, contents->data, contents->len, start, &end)) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_FILE_FORMAT_INVALID, + NM_CRYPTO_ERROR_INVALID_DATA, _("PEM certificate had no end tag '%s'."), PEM_CERT_END); goto done; @@ -603,7 +588,7 @@ extract_pem_cert_data (GByteArray *contents, GError **error) g_assert (cert->len == length); } else { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_DECODE_FAILED, + NM_CRYPTO_ERROR_INVALID_DATA, _("Failed to decode certificate.")); } @@ -668,7 +653,7 @@ crypto_is_pkcs12_data (const guint8 *data, if (success == FALSE) { /* If the error was just a decryption error, then it's pkcs#12 */ if (error) { - if (g_error_matches (error, NM_CRYPTO_ERROR, NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED)) + if (g_error_matches (error, NM_CRYPTO_ERROR, NM_CRYPTO_ERROR_DECRYPTION_FAILED)) success = TRUE; g_error_free (error); } diff --git a/libnm-core/crypto.h b/libnm-core/crypto.h index a530080ec6..9173ba2203 100644 --- a/libnm-core/crypto.h +++ b/libnm-core/crypto.h @@ -31,27 +31,6 @@ #define CIPHER_DES_CBC "DES-CBC" #define CIPHER_AES_CBC "AES-128-CBC" -enum { - NM_CRYPTO_ERR_NONE = 0, - NM_CRYPTO_ERR_INIT_FAILED, - NM_CRYPTO_ERR_CANT_READ_FILE, - NM_CRYPTO_ERR_FILE_FORMAT_INVALID, - NM_CRYPTO_ERR_CERT_FORMAT_INVALID, - NM_CRYPTO_ERR_DECODE_FAILED, - NM_CRYPTO_ERR_OUT_OF_MEMORY, - NM_CRYPTO_ERR_UNKNOWN_KEY_TYPE, - NM_CRYPTO_ERR_UNKNOWN_CIPHER, - NM_CRYPTO_ERR_RAW_IV_INVALID, - NM_CRYPTO_ERR_MD5_INIT_FAILED, - NM_CRYPTO_ERR_CIPHER_INIT_FAILED, - NM_CRYPTO_ERR_CIPHER_SET_KEY_FAILED, - NM_CRYPTO_ERR_CIPHER_SET_IV_FAILED, - NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED, - NM_CRYPTO_ERR_INVALID_PASSWORD, - NM_CRYPTO_ERR_CIPHER_ENCRYPT_FAILED, - NM_CRYPTO_ERR_RANDOMIZE_FAILED -}; - typedef enum { NM_CRYPTO_KEY_TYPE_UNKNOWN = 0, NM_CRYPTO_KEY_TYPE_RSA, @@ -65,9 +44,6 @@ typedef enum { NM_CRYPTO_FILE_FORMAT_PKCS12 } NMCryptoFileFormat; -#define NM_CRYPTO_ERROR _nm_crypto_error_quark () -GQuark _nm_crypto_error_quark (void); - gboolean crypto_init (GError **error); void crypto_deinit (void); diff --git a/libnm-core/crypto_gnutls.c b/libnm-core/crypto_gnutls.c index e79d4fd3e2..28d9bf79b8 100644 --- a/libnm-core/crypto_gnutls.c +++ b/libnm-core/crypto_gnutls.c @@ -31,6 +31,7 @@ #include <gnutls/pkcs12.h> #include "crypto.h" +#include "nm-errors.h" #define SALT_LEN 8 @@ -44,10 +45,9 @@ crypto_init (GError **error) if (gnutls_global_init() != 0) { gnutls_global_deinit(); - g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_INIT_FAILED, - "%s", - _("Failed to initialize the crypto engine.")); + g_set_error_literal (error, NM_CRYPTO_ERROR, + NM_CRYPTO_ERROR_FAILED, + _("Failed to initialize the crypto engine.")); return FALSE; } @@ -88,7 +88,7 @@ crypto_md5_hash (const char *salt, err = gcry_md_open (&ctx, GCRY_MD_MD5, 0); if (err) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_MD5_INIT_FAILED, + NM_CRYPTO_ERROR_FAILED, _("Failed to initialize the MD5 engine: %s / %s."), gcry_strsource (err), gcry_strerror (err)); return FALSE; @@ -147,7 +147,7 @@ crypto_decrypt (const char *cipher, real_iv_len = 16; } else { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_UNKNOWN_CIPHER, + NM_CRYPTO_ERROR_UNKNOWN_CIPHER, _("Private key cipher '%s' was unknown."), cipher); return NULL; @@ -155,7 +155,7 @@ crypto_decrypt (const char *cipher, if (iv_len < real_iv_len) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_RAW_IV_INVALID, + NM_CRYPTO_ERROR_INVALID_DATA, _("Invalid IV length (must be at least %zd)."), real_iv_len); return NULL; @@ -166,7 +166,7 @@ crypto_decrypt (const char *cipher, err = gcry_cipher_open (&ctx, cipher_mech, GCRY_CIPHER_MODE_CBC, 0); if (err) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_CIPHER_INIT_FAILED, + NM_CRYPTO_ERROR_DECRYPTION_FAILED, _("Failed to initialize the decryption cipher context: %s / %s."), gcry_strsource (err), gcry_strerror (err)); goto out; @@ -175,7 +175,7 @@ crypto_decrypt (const char *cipher, err = gcry_cipher_setkey (ctx, key, key_len); if (err) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_CIPHER_SET_KEY_FAILED, + NM_CRYPTO_ERROR_DECRYPTION_FAILED, _("Failed to set symmetric key for decryption: %s / %s."), gcry_strsource (err), gcry_strerror (err)); goto out; @@ -184,7 +184,7 @@ crypto_decrypt (const char *cipher, err = gcry_cipher_setiv (ctx, iv, iv_len); if (err) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_CIPHER_SET_IV_FAILED, + NM_CRYPTO_ERROR_DECRYPTION_FAILED, _("Failed to set IV for decryption: %s / %s."), gcry_strsource (err), gcry_strerror (err)); goto out; @@ -193,7 +193,7 @@ crypto_decrypt (const char *cipher, err = gcry_cipher_decrypt (ctx, output, data_len, data, data_len); if (err) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED, + NM_CRYPTO_ERROR_DECRYPTION_FAILED, _("Failed to decrypt the private key: %s / %s."), gcry_strsource (err), gcry_strerror (err)); goto out; @@ -203,7 +203,7 @@ crypto_decrypt (const char *cipher, /* Check if the padding at the end of the decrypted data is valid */ if (pad_len == 0 || pad_len > real_iv_len) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED, + NM_CRYPTO_ERROR_DECRYPTION_FAILED, _("Failed to decrypt the private key: unexpected padding length.")); goto out; } @@ -214,7 +214,7 @@ crypto_decrypt (const char *cipher, for (i = 1; i <= pad_len; ++i) { if (output[data_len - i] != pad_len) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED, + NM_CRYPTO_ERROR_DECRYPTION_FAILED, _("Failed to decrypt the private key.")); goto out; } @@ -265,7 +265,7 @@ crypto_encrypt (const char *cipher, salt_len = iv_len; } else { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_UNKNOWN_CIPHER, + NM_CRYPTO_ERROR_UNKNOWN_CIPHER, _("Private key cipher '%s' was unknown."), cipher); return NULL; @@ -287,7 +287,7 @@ crypto_encrypt (const char *cipher, err = gcry_cipher_open (&ctx, cipher_mech, GCRY_CIPHER_MODE_CBC, 0); if (err) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_CIPHER_INIT_FAILED, + NM_CRYPTO_ERROR_ENCRYPTION_FAILED, _("Failed to initialize the encryption cipher context: %s / %s."), gcry_strsource (err), gcry_strerror (err)); goto out; @@ -296,7 +296,7 @@ crypto_encrypt (const char *cipher, err = gcry_cipher_setkey (ctx, key, key_len); if (err) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_CIPHER_SET_KEY_FAILED, + NM_CRYPTO_ERROR_ENCRYPTION_FAILED, _("Failed to set symmetric key for encryption: %s / %s."), gcry_strsource (err), gcry_strerror (err)); goto out; @@ -306,7 +306,7 @@ crypto_encrypt (const char *cipher, err = gcry_cipher_setiv (ctx, iv, salt_len); if (err) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_CIPHER_SET_IV_FAILED, + NM_CRYPTO_ERROR_ENCRYPTION_FAILED, _("Failed to set IV for encryption: %s / %s."), gcry_strsource (err), gcry_strerror (err)); goto out; @@ -315,7 +315,7 @@ crypto_encrypt (const char *cipher, err = gcry_cipher_encrypt (ctx, output, output_len, padded_buf, padded_buf_len); if (err) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED, + NM_CRYPTO_ERROR_ENCRYPTION_FAILED, _("Failed to encrypt the data: %s / %s."), gcry_strsource (err), gcry_strerror (err)); goto out; @@ -355,7 +355,7 @@ crypto_verify_cert (const unsigned char *data, err = gnutls_x509_crt_init (&der); if (err < 0) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_CERT_FORMAT_INVALID, + NM_CRYPTO_ERROR_INVALID_DATA, _("Error initializing certificate data: %s"), gnutls_strerror (err)); return NM_CRYPTO_FILE_FORMAT_UNKNOWN; @@ -377,7 +377,7 @@ crypto_verify_cert (const unsigned char *data, return NM_CRYPTO_FILE_FORMAT_X509; g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_CERT_FORMAT_INVALID, + NM_CRYPTO_ERROR_INVALID_DATA, _("Couldn't decode certificate: %s"), gnutls_strerror (err)); return NM_CRYPTO_FILE_FORMAT_UNKNOWN; @@ -402,7 +402,7 @@ crypto_verify_pkcs12 (const guint8 *data, err = gnutls_pkcs12_init (&p12); if (err < 0) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_DECODE_FAILED, + NM_CRYPTO_ERROR_FAILED, _("Couldn't initialize PKCS#12 decoder: %s"), gnutls_strerror (err)); return FALSE; @@ -415,7 +415,7 @@ crypto_verify_pkcs12 (const guint8 *data, err = gnutls_pkcs12_import (p12, &dt, GNUTLS_X509_FMT_PEM, 0); if (err < 0) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_FILE_FORMAT_INVALID, + NM_CRYPTO_ERROR_INVALID_DATA, _("Couldn't decode PKCS#12 file: %s"), gnutls_strerror (err)); goto out; @@ -427,7 +427,7 @@ crypto_verify_pkcs12 (const guint8 *data, success = TRUE; else { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED, + NM_CRYPTO_ERROR_DECRYPTION_FAILED, _("Couldn't verify PKCS#12 file: %s"), gnutls_strerror (err)); } @@ -456,7 +456,7 @@ crypto_verify_pkcs8 (const guint8 *data, err = gnutls_x509_privkey_init (&p8); if (err < 0) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_DECODE_FAILED, + NM_CRYPTO_ERROR_FAILED, _("Couldn't initialize PKCS#8 decoder: %s"), gnutls_strerror (err)); return FALSE; @@ -479,7 +479,7 @@ crypto_verify_pkcs8 (const guint8 *data, */ } else { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_FILE_FORMAT_INVALID, + NM_CRYPTO_ERROR_INVALID_DATA, _("Couldn't decode PKCS#8 file: %s"), gnutls_strerror (err)); return FALSE; diff --git a/libnm-core/crypto_nss.c b/libnm-core/crypto_nss.c index cc6418f452..b75fcf6662 100644 --- a/libnm-core/crypto_nss.c +++ b/libnm-core/crypto_nss.c @@ -37,6 +37,7 @@ #include <p12plcy.h> #include "crypto.h" +#include "nm-errors.h" static gboolean initialized = FALSE; @@ -52,7 +53,7 @@ crypto_init (GError **error) ret = NSS_NoDB_Init (NULL); if (ret != SECSuccess) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_INIT_FAILED, + NM_CRYPTO_ERROR_FAILED, _("Failed to initialize the crypto engine: %d."), PR_GetError ()); PR_Cleanup (); @@ -103,7 +104,7 @@ crypto_md5_hash (const char *salt, ctx = PK11_CreateDigestContext (SEC_OID_MD5); if (!ctx) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_MD5_INIT_FAILED, + NM_CRYPTO_ERROR_FAILED, _("Failed to initialize the MD5 context: %d."), PORT_GetError ()); return FALSE; @@ -167,7 +168,7 @@ crypto_decrypt (const char *cipher, real_iv_len = 16; } else { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_UNKNOWN_CIPHER, + NM_CRYPTO_ERROR_UNKNOWN_CIPHER, _("Private key cipher '%s' was unknown."), cipher); return NULL; @@ -175,7 +176,7 @@ crypto_decrypt (const char *cipher, if (iv_len < real_iv_len) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_RAW_IV_INVALID, + NM_CRYPTO_ERROR_INVALID_DATA, _("Invalid IV length (must be at least %d)."), real_iv_len); return NULL; @@ -186,7 +187,7 @@ crypto_decrypt (const char *cipher, slot = PK11_GetBestSlot (cipher_mech, NULL); if (!slot) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_CIPHER_INIT_FAILED, + NM_CRYPTO_ERROR_FAILED, _("Failed to initialize the decryption cipher slot.")); goto out; } @@ -196,7 +197,7 @@ crypto_decrypt (const char *cipher, sym_key = PK11_ImportSymKey (slot, cipher_mech, PK11_OriginUnwrap, CKA_DECRYPT, &key_item, NULL); if (!sym_key) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_CIPHER_SET_KEY_FAILED, + NM_CRYPTO_ERROR_DECRYPTION_FAILED, _("Failed to set symmetric key for decryption.")); goto out; } @@ -206,7 +207,7 @@ crypto_decrypt (const char *cipher, sec_param = PK11_ParamFromIV (cipher_mech, &key_item); if (!sec_param) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_CIPHER_SET_IV_FAILED, + NM_CRYPTO_ERROR_DECRYPTION_FAILED, _("Failed to set IV for decryption.")); goto out; } @@ -214,7 +215,7 @@ crypto_decrypt (const char *cipher, ctx = PK11_CreateContextBySymKey (cipher_mech, CKA_DECRYPT, sym_key, sec_param); if (!ctx) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_CIPHER_INIT_FAILED, + NM_CRYPTO_ERROR_DECRYPTION_FAILED, _("Failed to initialize the decryption context.")); goto out; } @@ -227,7 +228,7 @@ crypto_decrypt (const char *cipher, data_len); if (s != SECSuccess) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED, + NM_CRYPTO_ERROR_DECRYPTION_FAILED, _("Failed to decrypt the private key: %d."), PORT_GetError ()); goto out; @@ -235,7 +236,7 @@ crypto_decrypt (const char *cipher, if (decrypted_len > data_len) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED, + NM_CRYPTO_ERROR_DECRYPTION_FAILED, _("Failed to decrypt the private key: decrypted data too large.")); goto out; } @@ -246,7 +247,7 @@ crypto_decrypt (const char *cipher, data_len - decrypted_len); if (s != SECSuccess) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED, + NM_CRYPTO_ERROR_DECRYPTION_FAILED, _("Failed to finalize decryption of the private key: %d."), PORT_GetError ()); goto out; @@ -257,7 +258,7 @@ crypto_decrypt (const char *cipher, /* Check if the padding at the end of the decrypted data is valid */ if (pad_len == 0 || pad_len > real_iv_len) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED, + NM_CRYPTO_ERROR_DECRYPTION_FAILED, _("Failed to decrypt the private key: unexpected padding length.")); goto out; } @@ -268,7 +269,7 @@ crypto_decrypt (const char *cipher, for (i = pad_len; i > 0; i--) { if (output[data_len - i] != pad_len) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED, + NM_CRYPTO_ERROR_DECRYPTION_FAILED, _("Failed to decrypt the private key.")); goto out; } @@ -329,7 +330,7 @@ crypto_encrypt (const char *cipher, cipher_mech = CKM_AES_CBC_PAD; else { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_UNKNOWN_CIPHER, + NM_CRYPTO_ERROR_UNKNOWN_CIPHER, _("Private key cipher '%s' was unknown."), cipher); return NULL; @@ -351,7 +352,7 @@ crypto_encrypt (const char *cipher, slot = PK11_GetBestSlot (cipher_mech, NULL); if (!slot) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_CIPHER_INIT_FAILED, + NM_CRYPTO_ERROR_FAILED, _("Failed to initialize the encryption cipher slot.")); goto out; } @@ -359,7 +360,7 @@ crypto_encrypt (const char *cipher, sym_key = PK11_ImportSymKey (slot, cipher_mech, PK11_OriginUnwrap, CKA_ENCRYPT, &key_item, NULL); if (!sym_key) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_CIPHER_SET_KEY_FAILED, + NM_CRYPTO_ERROR_ENCRYPTION_FAILED, _("Failed to set symmetric key for encryption.")); goto out; } @@ -367,7 +368,7 @@ crypto_encrypt (const char *cipher, sec_param = PK11_ParamFromIV (cipher_mech, &iv_item); if (!sec_param) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_CIPHER_SET_IV_FAILED, + NM_CRYPTO_ERROR_ENCRYPTION_FAILED, _("Failed to set IV for encryption.")); goto out; } @@ -375,7 +376,7 @@ crypto_encrypt (const char *cipher, ctx = PK11_CreateContextBySymKey (cipher_mech, CKA_ENCRYPT, sym_key, sec_param); if (!ctx) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_CIPHER_INIT_FAILED, + NM_CRYPTO_ERROR_ENCRYPTION_FAILED, _("Failed to initialize the encryption context.")); goto out; } @@ -383,7 +384,7 @@ crypto_encrypt (const char *cipher, ret = PK11_CipherOp (ctx, output, &encrypted_len, output_len, padded_buf, padded_buf_len); if (ret != SECSuccess) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_CIPHER_ENCRYPT_FAILED, + NM_CRYPTO_ERROR_ENCRYPTION_FAILED, _("Failed to encrypt: %d."), PORT_GetError ()); goto out; @@ -391,7 +392,7 @@ crypto_encrypt (const char *cipher, if (encrypted_len != output_len) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_CIPHER_ENCRYPT_FAILED, + NM_CRYPTO_ERROR_ENCRYPTION_FAILED, _("Unexpected amount of data after encrypting.")); goto out; } @@ -431,7 +432,7 @@ crypto_verify_cert (const unsigned char *data, cert = CERT_DecodeCertFromPackage ((char *) data, len); if (!cert) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_CERT_FORMAT_INVALID, + NM_CRYPTO_ERROR_INVALID_DATA, _("Couldn't decode certificate: %d"), PORT_GetError()); return NM_CRYPTO_FILE_FORMAT_UNKNOWN; @@ -451,7 +452,7 @@ crypto_verify_pkcs12 (const guint8 *data, SECItem pw = { 0 }; PK11SlotInfo *slot = NULL; SECStatus s; - char *ucs2_password; + gunichar2 *ucs2_password; glong ucs2_chars = 0; #ifndef WORDS_BIGENDIAN guint16 *p; @@ -463,15 +464,16 @@ crypto_verify_pkcs12 (const guint8 *data, /* PKCS#12 passwords are apparently UCS2 BIG ENDIAN, and NSS doesn't do * any conversions for us. */ - if (password && strlen (password)) { - ucs2_password = (char *) g_utf8_to_utf16 (password, strlen (password), NULL, &ucs2_chars, NULL); - if (!ucs2_password || !ucs2_chars) { + if (password && *password) { + if (!g_utf8_validate (password, -1, NULL)) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_INVALID_PASSWORD, - _("Couldn't convert password to UCS2: %d"), - PORT_GetError()); + NM_CRYPTO_ERROR_INVALID_PASSWORD, + _("Password must be UTF-8")); return FALSE; } + ucs2_password = g_utf8_to_utf16 (password, strlen (password), NULL, &ucs2_chars, NULL); + /* Can't fail if g_utf8_validate() succeeded */ + g_return_val_if_fail (ucs2_password != NULL && ucs2_chars != 0, FALSE); ucs2_chars *= 2; /* convert # UCS2 characters -> bytes */ pw.data = PORT_ZAlloc(ucs2_chars + 2); @@ -495,7 +497,7 @@ crypto_verify_pkcs12 (const guint8 *data, p12ctx = SEC_PKCS12DecoderStart (&pw, slot, NULL, NULL, NULL, NULL, NULL, NULL); if (!p12ctx) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_DECODE_FAILED, + NM_CRYPTO_ERROR_FAILED, _("Couldn't initialize PKCS#12 decoder: %d"), PORT_GetError()); goto error; @@ -504,7 +506,7 @@ crypto_verify_pkcs12 (const guint8 *data, s = SEC_PKCS12DecoderUpdate (p12ctx, (guint8 *)data, data_len); if (s != SECSuccess) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_FILE_FORMAT_INVALID, + NM_CRYPTO_ERROR_INVALID_DATA, _("Couldn't decode PKCS#12 file: %d"), PORT_GetError()); goto error; @@ -513,7 +515,7 @@ crypto_verify_pkcs12 (const guint8 *data, s = SEC_PKCS12DecoderVerify (p12ctx); if (s != SECSuccess) { g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED, + NM_CRYPTO_ERROR_DECRYPTION_FAILED, _("Couldn't verify PKCS#12 file: %d"), PORT_GetError()); goto error; @@ -558,7 +560,7 @@ crypto_randomize (void *buffer, gsize buffer_len, GError **error) s = PK11_GenerateRandom (buffer, buffer_len); if (s != SECSuccess) { g_set_error_literal (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_RANDOMIZE_FAILED, + NM_CRYPTO_ERROR_FAILED, _("Could not generate random data.")); return FALSE; } diff --git a/libnm-core/nm-connection.c b/libnm-core/nm-connection.c index 1e0cdbf934..b43f0c0377 100644 --- a/libnm-core/nm-connection.c +++ b/libnm-core/nm-connection.c @@ -72,23 +72,6 @@ * */ -/** - * nm_connection_error_quark: - * - * Registers an error quark for #NMConnection if necessary. - * - * Returns: the error quark used for #NMConnection errors. - **/ -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; -} - typedef struct { NMConnection *self; @@ -259,9 +242,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); @@ -312,10 +296,11 @@ nm_connection_replace_settings (NMConnection *connection, type = nm_setting_lookup_type (setting_name); if (type == G_TYPE_INVALID) { - g_set_error (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_SETTING, - "unknown setting name '%s'", setting_name); + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_SETTING, + _("unknown setting name")); + g_prefix_error (error, "%s: ", setting_name); g_variant_unref (setting_dict); g_slist_free_full (settings, g_object_unref); return FALSE; @@ -749,8 +734,9 @@ _nm_connection_verify (NMConnection *connection, GError **error) if (!s_con) { g_set_error_literal (error, NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_CONNECTION_SETTING_NOT_FOUND, - "connection setting not found"); + NM_CONNECTION_ERROR_MISSING_SETTING, + _("setting not found")); + g_prefix_error (error, "%s: ", NM_SETTING_CONNECTION_SETTING_NAME); goto EXIT; } @@ -811,21 +797,23 @@ _nm_connection_verify (NMConnection *connection, GError **error) if ((normalizable_error_type == NM_SETTING_VERIFY_SUCCESS || (normalizable_error_type == NM_SETTING_VERIFY_NORMALIZABLE)) && (s_ip4 || s_ip6)) { g_clear_error (&normalizable_error); - g_set_error (&normalizable_error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_SETTING, - "slave connection cannot have an IP%c setting", - s_ip4 ? '4' : '6'); + g_set_error_literal (&normalizable_error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_SETTING, + _("setting not allowed in slave connection")); + g_prefix_error (&normalizable_error, "%s: ", + s_ip4 ? NM_SETTING_IP4_CONFIG_SETTING_NAME : NM_SETTING_IP6_CONFIG_SETTING_NAME); /* having a slave with IP config *was* and is a verify() error. */ normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE_ERROR; } } else { if (normalizable_error_type == NM_SETTING_VERIFY_SUCCESS && (!s_ip4 || !s_ip6)) { - g_set_error (&normalizable_error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_SETTING_NOT_FOUND, - "connection needs an IP%c setting", - !s_ip4 ? '4' : '6'); + g_set_error_literal (&normalizable_error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_SETTING, + _("setting is required for non-slave connections")); + g_prefix_error (&normalizable_error, "%s: ", + !s_ip4 ? NM_SETTING_IP4_CONFIG_SETTING_NAME : NM_SETTING_IP6_CONFIG_SETTING_NAME); /* having a master without IP config was not a verify() error, accept * it for backward compatibility. */ normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE; @@ -888,7 +876,7 @@ nm_connection_normalize (NMConnection *connection, if (success == NM_SETTING_VERIFY_ERROR && error && !*error) { g_set_error_literal (error, NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_UNKNOWN, + NM_CONNECTION_ERROR_FAILED, _("Unexpected failure to verify the connection")); g_return_val_if_reached (FALSE); } @@ -919,7 +907,7 @@ nm_connection_normalize (NMConnection *connection, if (error && !*error) { g_set_error_literal (error, NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_UNKNOWN, + NM_CONNECTION_ERROR_FAILED, _("Unexpected failure to normalize the connection")); } g_return_val_if_reached (FALSE); @@ -969,12 +957,13 @@ nm_connection_update_secrets (NMConnection *connection, if (error) g_return_val_if_fail (*error == NULL, FALSE); + full_connection = g_variant_is_of_type (secrets, NM_VARIANT_TYPE_CONNECTION); + g_return_val_if_fail (setting_name != NULL || full_connection, FALSE); + /* Empty @secrets means success */ if (g_variant_n_children (secrets) == 0) return TRUE; - full_connection = g_variant_is_of_type (secrets, NM_VARIANT_TYPE_CONNECTION); - if (setting_name) { /* Update just one setting's secrets */ setting = nm_connection_get_setting_by_name (connection, setting_name); @@ -1009,14 +998,6 @@ nm_connection_update_secrets (NMConnection *connection, if (success_detail == NM_SETTING_UPDATE_SECRET_SUCCESS_MODIFIED) updated = TRUE; } else { - if (!full_connection) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_SETTING, - _("Update secrets expects a full connection, instead only a setting is provided.")); - return FALSE; - } - /* check first, whether all the settings exist... */ g_variant_iter_init (&iter, secrets); while (g_variant_iter_next (&iter, "{&s@a{sv}}", &key, NULL)) { diff --git a/libnm-core/nm-connection.h b/libnm-core/nm-connection.h index de1cd528a4..28254c33fa 100644 --- a/libnm-core/nm-connection.h +++ b/libnm-core/nm-connection.h @@ -30,6 +30,7 @@ #include <glib.h> #include <glib-object.h> #include <nm-setting.h> +#include <nm-errors.h> #include <nm-setting-8021x.h> #include <nm-setting-bluetooth.h> @@ -70,33 +71,6 @@ G_BEGIN_DECLS #define NM_CONNECTION_SECRETS_CLEARED "secrets-cleared" #define NM_CONNECTION_CHANGED "changed" -/** - * NMConnectionError: - * @NM_CONNECTION_ERROR_UNKNOWN: unknown or unclassified error - * @NM_CONNECTION_ERROR_CONNECTION_SETTING_NOT_FOUND: the #NMConnection object - * did not contain the required #NMSettingConnection object, which must be - * present for all connections - * @NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID: the 'type' property of the - * 'connection' setting did not point to a valid connection base type; ie - * it was not a hardware-related setting like #NMSettingWired or - * #NMSettingWireless. - * @NM_CONNECTION_ERROR_SETTING_NOT_FOUND: the #NMConnection object - * did not contain the specified #NMSetting object - *@NM_CONNECTION_ERROR_INVALID_SETTING: the #NMConnection object contains - * a conflicting setting object - * - * Describes errors that may result from operations involving a #NMConnection. - * - **/ -typedef enum -{ - NM_CONNECTION_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_CONNECTION_ERROR_CONNECTION_SETTING_NOT_FOUND, /*< nick=ConnectionSettingNotFound >*/ - NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID, /*< nick=ConnectionTypeInvalid >*/ - NM_CONNECTION_ERROR_SETTING_NOT_FOUND, /*< nick=SettingNotFound >*/ - NM_CONNECTION_ERROR_INVALID_SETTING, /*< nick=InvalidSetting >*/ -} NMConnectionError; - /* * NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD: overwrite the ip6 method * when normalizing ip6 configuration. If omited, this defaults to @@ -104,9 +78,6 @@ typedef enum */ #define NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD "ip6-config-method" -#define NM_CONNECTION_ERROR nm_connection_error_quark () -GQuark nm_connection_error_quark (void); - /** * NMConnection: * diff --git a/libnm-core/nm-core-internal.h b/libnm-core/nm-core-internal.h index f83b486c12..da404046df 100644 --- a/libnm-core/nm-core-internal.h +++ b/libnm-core/nm-core-internal.h @@ -81,4 +81,6 @@ GPtrArray *_nm_utils_copy_array (const GPtrArray *array, GDestroyNotify free_func); GPtrArray *_nm_utils_copy_object_array (const GPtrArray *array); +void _nm_dbus_errors_init (void); + #endif diff --git a/libnm-core/nm-errors.c b/libnm-core/nm-errors.c new file mode 100644 index 0000000000..105425504c --- /dev/null +++ b/libnm-core/nm-errors.c @@ -0,0 +1,88 @@ +/* -*- 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 + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * Copyright 2004 - 2014 Red Hat, Inc. + */ + +#include <string.h> +#include <gio/gio.h> + +#include "nm-errors.h" +#include "nm-glib-compat.h" +#include "nm-dbus-interface.h" +#include "nm-vpn-dbus-interface.h" +#include "nm-core-internal.h" + +G_DEFINE_QUARK (nm-agent-manager-error-quark, nm_agent_manager_error) +G_DEFINE_QUARK (nm-connection-error-quark, nm_connection_error) +G_DEFINE_QUARK (nm-crypto-error-quark, nm_crypto_error) +G_DEFINE_QUARK (nm-device-error-quark, nm_device_error) +G_DEFINE_QUARK (nm-manager-error-quark, nm_manager_error) +G_DEFINE_QUARK (nm-secret-agent-error-quark, nm_secret_agent_error) +G_DEFINE_QUARK (nm-settings-error-quark, nm_settings_error) +G_DEFINE_QUARK (nm-vpn-plugin-quark, nm_vpn_plugin_error) + +static void +register_error_domain (GQuark domain, + const char *interface, + GType enum_type) +{ + GEnumClass *enum_class; + GEnumValue *e; + char *error_name; + int i; + + enum_class = g_type_class_ref (enum_type); + for (i = 0; i < enum_class->n_values; i++) { + e = &enum_class->values[i]; + g_assert (strchr (e->value_nick, '-') == NULL); + error_name = g_strdup_printf ("%s.%s", interface, e->value_nick); + g_dbus_error_register_error (domain, e->value, error_name); + g_free (error_name); + } + + g_type_class_unref (enum_class); +} + +void +_nm_dbus_errors_init (void) +{ + register_error_domain (NM_AGENT_MANAGER_ERROR, + NM_DBUS_INTERFACE_AGENT_MANAGER, + NM_TYPE_AGENT_MANAGER_ERROR); + register_error_domain (NM_CONNECTION_ERROR, + NM_DBUS_INTERFACE_SETTINGS_CONNECTION, + NM_TYPE_CONNECTION_ERROR); + register_error_domain (NM_DEVICE_ERROR, + NM_DBUS_INTERFACE_DEVICE, + NM_TYPE_DEVICE_ERROR); + register_error_domain (NM_MANAGER_ERROR, + NM_DBUS_INTERFACE, + NM_TYPE_MANAGER_ERROR); + register_error_domain (NM_SECRET_AGENT_ERROR, + NM_DBUS_INTERFACE_SECRET_AGENT, + NM_TYPE_SECRET_AGENT_ERROR); + register_error_domain (NM_SETTINGS_ERROR, + NM_DBUS_INTERFACE_SETTINGS, + NM_TYPE_SETTINGS_ERROR); + register_error_domain (NM_SETTINGS_ERROR, + NM_DBUS_INTERFACE_SETTINGS, + NM_TYPE_SETTINGS_ERROR); + register_error_domain (NM_VPN_PLUGIN_ERROR, + NM_VPN_DBUS_PLUGIN_INTERFACE, + NM_TYPE_VPN_PLUGIN_ERROR); +} diff --git a/libnm-core/nm-errors.h b/libnm-core/nm-errors.h new file mode 100644 index 0000000000..fa6919c569 --- /dev/null +++ b/libnm-core/nm-errors.h @@ -0,0 +1,319 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright 2004 - 2014 Red Hat, Inc. + */ + +#ifndef __NM_ERRORS_H__ +#define __NM_ERRORS_H__ + +/** + * NMAgentManagerError: + * @NM_AGENT_MANAGER_ERROR_FAILED: unknown or unspecified error + * @NM_AGENT_MANAGER_ERROR_PERMISSION_DENIED: The caller does not have permission + * to register a secret agent, or is trying to register the same secret agent + * twice. + * @NM_AGENT_MANAGER_ERROR_INVALID_IDENTIFIER: The identifier is not a valid + * secret agent identifier. + * @NM_AGENT_MANAGER_ERROR_NOT_REGISTERED: The caller tried to unregister an agent + * that was not registered. + * @NM_AGENT_MANAGER_ERROR_NO_SECRETS: No secret agent returned secrets for this + * request + * @NM_AGENT_MANAGER_ERROR_USER_CANCELED: The user canceled the secrets request. + * + * Errors returned from the secret-agent manager. + * + * These errors may be returned from operations that could cause secrets to be + * requested (such as nm_client_activate_connection()), and correspond to D-Bus + * errors in the "org.freedesktop.NetworkManager.AgentManager" namespace. + */ +typedef enum { + NM_AGENT_MANAGER_ERROR_FAILED = 0, /*< nick=Failed >*/ + NM_AGENT_MANAGER_ERROR_PERMISSION_DENIED, /*< nick=PermissionDenied >*/ + NM_AGENT_MANAGER_ERROR_INVALID_IDENTIFIER, /*< nick=InvalidIdentifier >*/ + NM_AGENT_MANAGER_ERROR_NOT_REGISTERED, /*< nick=NotRegistered >*/ + NM_AGENT_MANAGER_ERROR_NO_SECRETS, /*< nick=NoSecrets >*/ + NM_AGENT_MANAGER_ERROR_USER_CANCELED, /*< nick=UserCanceled >*/ +} NMAgentManagerError; + +GQuark nm_agent_manager_error_quark (void); +#define NM_AGENT_MANAGER_ERROR (nm_agent_manager_error_quark ()) + +/** + * NMConnectionError: + * @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 + * name of the setting that is missing. + * @NM_CONNECTION_ERROR_INVALID_SETTING: the #NMConnection object contains an + * 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 + * or its #NMSettings. + * + * These errors may be returned directly from #NMConnection and #NMSetting + * methods, or may be returned from D-Bus operations (eg on #NMClient or + * #NMDevice), where they correspond to errors in the + * "org.freedesktop.NetworkManager.Settings.Connection" namespace. + */ +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; + +#define NM_CONNECTION_ERROR nm_connection_error_quark () +GQuark nm_connection_error_quark (void); + +/** + * NMCryptoError: + * @NM_CRYPTO_ERROR_FAILED: generic failure + * @NM_CRYPTO_ERROR_INVALID_DATA: the certificate or key data provided + * was invalid + * @NM_CRYPTO_ERROR_INVALID_PASSWORD: the password was invalid + * @NM_CRYPTO_ERROR_UNKNOWN_CIPHER: the data uses an unknown cipher + * @NM_CRYPTO_ERROR_DECRYPTION_FAILED: decryption failed + * @NM_CRYPTO_ERROR_ENCRYPTION_FAILED: encryption failed + * + * Cryptography-related errors that can be returned from some nm-utils methods, + * and some #NMSetting8021x operations. + */ +typedef enum { + NM_CRYPTO_ERROR_FAILED = 0, + NM_CRYPTO_ERROR_INVALID_DATA, + NM_CRYPTO_ERROR_INVALID_PASSWORD, + NM_CRYPTO_ERROR_UNKNOWN_CIPHER, + NM_CRYPTO_ERROR_DECRYPTION_FAILED, + NM_CRYPTO_ERROR_ENCRYPTION_FAILED, +} NMCryptoError; + +#define NM_CRYPTO_ERROR nm_crypto_error_quark () +GQuark nm_crypto_error_quark (void); + +/** + * NMDeviceError: + * @NM_DEVICE_ERROR_FAILED: unknown or unclassified error + * @NM_DEVICE_ERROR_CREATION_FAILED: NetworkManager failed to create the device + * @NM_DEVICE_ERROR_INVALID_CONNECTION: the specified connection is not valid + * @NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION: the specified connection is not + * compatible with this device. + * @NM_DEVICE_ERROR_NOT_ACTIVE: the device does not have an active connection + * @NM_DEVICE_ERROR_NOT_SOFTWARE: the requested operation is only valid on + * software devices. + * @NM_DEVICE_ERROR_NOT_ALLOWED: the requested operation is not allowed at + * this time. + * @NM_DEVICE_ERROR_SPECIFIC_OBJECT_NOT_FOUND: the "specific object" in the + * activation request (eg, the #NMAccessPoint or #NMWimaxNsp) was not + * found. + * + * Device-related errors. + * + * These errors may be returned directly from #NMDevice methods, or may be + * returned from D-Bus operations (where they correspond to errors in the + * "org.freedesktop.NetworkManager.Device" namespace). + */ +typedef enum { + NM_DEVICE_ERROR_FAILED = 0, /*< nick=Failed >*/ + NM_DEVICE_ERROR_CREATION_FAILED, /*< nick=CreationFailed >*/ + NM_DEVICE_ERROR_INVALID_CONNECTION, /*< nick=InvalidConnection >*/ + NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, /*< nick=IncompatibleConnection >*/ + NM_DEVICE_ERROR_NOT_ACTIVE, /*< nick=NotActive >*/ + NM_DEVICE_ERROR_NOT_SOFTWARE, /*< nick=NotSoftware >*/ + NM_DEVICE_ERROR_NOT_ALLOWED, /*< nick=NotAllowed >*/ + NM_DEVICE_ERROR_SPECIFIC_OBJECT_NOT_FOUND, /*< nick=SpecificObjectNotFound >*/ +} NMDeviceError; + +#define NM_DEVICE_ERROR nm_device_error_quark () +GQuark nm_device_error_quark (void); + +/** + * NMManagerError: + * @NM_MANAGER_ERROR_FAILED: unknown or unclassified error + * @NM_MANAGER_ERROR_PERMISSION_DENIED: Permission denied. + * @NM_MANAGER_ERROR_UNKNOWN_CONNECTION: The requested connection is not known. + * @NM_MANAGER_ERROR_UNKNOWN_DEVICE: The requested device is not known. + * @NM_MANAGER_ERROR_CONNECTION_NOT_AVAILABLE: The requested connection cannot be + * activated at this time. + * @NM_MANAGER_ERROR_CONNECTION_NOT_ACTIVE: The request could not be completed + * because a required connection is not active. + * @NM_MANAGER_ERROR_CONNECTION_ALREADY_ACTIVE: The connection to be activated was + * already active on another device. + * @NM_MANAGER_ERROR_DEPENDENCY_FAILED: An activation request failed due to a + * dependency being unavailable. + * @NM_MANAGER_ERROR_ALREADY_ASLEEP_OR_AWAKE: The manager is already in the requested + * sleep/wake state. + * @NM_MANAGER_ERROR_ALREADY_ENABLED_OR_DISABLED: The network is already + * enabled/disabled. + * @NM_MANAGER_ERROR_UNKNOWN_LOG_LEVEL: Unknown log level in SetLogging + * @NM_MANAGER_ERROR_UNKNOWN_LOG_DOMAIN: Unknown log domain in SetLogging + * + * Errors related to the main "network management" interface of NetworkManager. + * These may be returned from #NMClient methods that invoke D-Bus operations on + * the "org.freedesktop.NetworkManager" interface, and correspond to D-Bus + * errors in that namespace. + */ +typedef enum { + NM_MANAGER_ERROR_FAILED = 0, /*< nick=Failed >*/ + NM_MANAGER_ERROR_PERMISSION_DENIED, /*< nick=PermissionDenied >*/ + NM_MANAGER_ERROR_UNKNOWN_CONNECTION, /*< nick=UnknownConnection >*/ + NM_MANAGER_ERROR_UNKNOWN_DEVICE, /*< nick=UnknownDevice >*/ + NM_MANAGER_ERROR_CONNECTION_NOT_AVAILABLE, /*< nick=ConnectionNotAvailable >*/ + NM_MANAGER_ERROR_CONNECTION_NOT_ACTIVE, /*< nick=ConnectionNotActive >*/ + NM_MANAGER_ERROR_CONNECTION_ALREADY_ACTIVE, /*< nick=ConnectionAlreadyActive >*/ + NM_MANAGER_ERROR_DEPENDENCY_FAILED, /*< nick=DependencyFailed >*/ + NM_MANAGER_ERROR_ALREADY_ASLEEP_OR_AWAKE, /*< nick=AlreadyAsleepOrAwake >*/ + NM_MANAGER_ERROR_ALREADY_ENABLED_OR_DISABLED, /*< nick=AlreadyEnabledOrDisabled >*/ + NM_MANAGER_ERROR_UNKNOWN_LOG_LEVEL, /*< nick=UnknownLogLevel >*/ + NM_MANAGER_ERROR_UNKNOWN_LOG_DOMAIN, /*< nick=UnknownLogDomain >*/ +} NMManagerError; + +GQuark nm_manager_error_quark (void); +#define NM_MANAGER_ERROR (nm_manager_error_quark ()) + +/** + * NMSecretAgentError: + * @NM_SECRET_AGENT_ERROR_FAILED: unknown or unclassified error + * @NM_SECRET_AGENT_ERROR_PERMISSION_DENIED: the caller (ie, NetworkManager) is + * not authorized to make this request + * @NM_SECRET_AGENT_ERROR_INVALID_CONNECTION: the connection for which secrets + * were requested is invalid + * @NM_SECRET_AGENT_ERROR_USER_CANCELED: the request was canceled by the user + * @NM_SECRET_AGENT_ERROR_AGENT_CANCELED: the agent canceled the request + * because it was requested to do so by NetworkManager + * @NM_SECRET_AGENT_ERROR_NO_SECRETS: the agent cannot find any secrets for this + * connection + * + * #NMSecretAgentError values are passed by secret agents back to NetworkManager + * when they encounter problems retrieving secrets on behalf of NM. They + * correspond to errors in the "org.freedesktop.NetworkManager.SecretManager" + * namespace. + * + * Client APIs such as nm_client_activate_connection() will not see these error + * codes; instead, the secret agent manager will translate them to the + * corresponding #NMAgentManagerError codes. + */ +typedef enum { + NM_SECRET_AGENT_ERROR_FAILED = 0, /*< nick=Failed >*/ + NM_SECRET_AGENT_ERROR_PERMISSION_DENIED, /*< nick=PermissionDenied >*/ + NM_SECRET_AGENT_ERROR_INVALID_CONNECTION, /*< nick=InvalidConnection >*/ + NM_SECRET_AGENT_ERROR_USER_CANCELED, /*< nick=UserCanceled >*/ + NM_SECRET_AGENT_ERROR_AGENT_CANCELED, /*< nick=AgentCanceled >*/ + NM_SECRET_AGENT_ERROR_NO_SECRETS, /*< nick=NoSecrets >*/ +} NMSecretAgentError; + +GQuark nm_secret_agent_error_quark (void); +#define NM_SECRET_AGENT_ERROR (nm_secret_agent_error_quark ()) + +/** + * NMSettingsError: + * @NM_SETTINGS_ERROR_FAILED: unknown or unclassified error + * @NM_SETTINGS_ERROR_PERMISSION_DENIED: permission denied + * @NM_SETTINGS_ERROR_NOT_SUPPORTED: the requested operation is not supported by any + * active settings backend + * @NM_SETTINGS_ERROR_INVALID_CONNECTION: the connection was invalid + * @NM_SETTINGS_ERROR_READ_ONLY_CONNECTION: attempted to modify a read-only connection + * @NM_SETTINGS_ERROR_UUID_EXISTS: a connection with that UUID already exists + * @NM_SETTINGS_ERROR_INVALID_HOSTNAME: attempted to set an invalid hostname + * + * Errors related to the settings/persistent configuration interface of + * NetworkManager. + * + * These may be returned from #NMClient methods that invoke D-Bus operations on + * the "org.freedesktop.NetworkManager.Settings" interface, and correspond to + * D-Bus errors in that namespace. + */ +typedef enum { + NM_SETTINGS_ERROR_FAILED = 0, /*< nick=Failed >*/ + NM_SETTINGS_ERROR_PERMISSION_DENIED, /*< nick=PermissionDenied >*/ + NM_SETTINGS_ERROR_NOT_SUPPORTED, /*< nick=NotSupported >*/ + NM_SETTINGS_ERROR_INVALID_CONNECTION, /*< nick=InvalidConnection >*/ + NM_SETTINGS_ERROR_READ_ONLY_CONNECTION, /*< nick=ReadOnlyConnection >*/ + NM_SETTINGS_ERROR_UUID_EXISTS, /*< nick=UuidExists >*/ + NM_SETTINGS_ERROR_INVALID_HOSTNAME, /*< nick=InvalidHostname >*/ +} NMSettingsError; + +GQuark nm_settings_error_quark (void); +#define NM_SETTINGS_ERROR (nm_settings_error_quark ()) + +/** + * NMVpnPluginError: + * @NM_VPN_PLUGIN_ERROR_FAILED: unknown or unclassified error + * @NM_VPN_PLUGIN_ERROR_STARTING_IN_PROGRESS: the plugin is already starting, + * and another connect request was received + * @NM_VPN_PLUGIN_ERROR_ALREADY_STARTED: the plugin is already connected, and + * another connect request was received + * @NM_VPN_PLUGIN_ERROR_STOPPING_IN_PROGRESS: the plugin is already stopping, + * and another stop request was received + * @NM_VPN_PLUGIN_ERROR_ALREADY_STOPPED: the plugin is already stopped, and + * another disconnect request was received + * @NM_VPN_PLUGIN_ERROR_WRONG_STATE: the operation could not be performed in + * this state + * @NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS: the operation could not be performed as + * the request contained malformed arguments, or arguments of unexpected type. + * Usually means that one of the VPN setting data items or secrets was not of + * the expected type (ie int, string, bool, etc). + * @NM_VPN_PLUGIN_ERROR_LAUNCH_FAILED: a child process failed to launch + * @NM_VPN_PLUGIN_ERROR_INVALID_CONNECTION: the operation could not be performed + * because the connection was invalid. Usually means that the connection's + * VPN setting was missing some required data item or secret. + * @NM_VPN_PLUGIN_ERROR_INTERACTIVE_NOT_SUPPORTED: the operation could not be + * performed as the plugin does not support interactive operations, such as + * ConnectInteractive() or NewSecrets() + * + * Returned by the VPN service plugin to indicate errors. These codes correspond + * to errors in the "org.freedesktop.NetworkManager.VPN.Error" namespace. + **/ +typedef enum { + NM_VPN_PLUGIN_ERROR_FAILED, /*< nick=Failed >*/ + NM_VPN_PLUGIN_ERROR_STARTING_IN_PROGRESS, /*< nick=StartingInProgress >*/ + NM_VPN_PLUGIN_ERROR_ALREADY_STARTED, /*< nick=AlreadyStarted >*/ + NM_VPN_PLUGIN_ERROR_STOPPING_IN_PROGRESS, /*< nick=StoppingInProgress >*/ + NM_VPN_PLUGIN_ERROR_ALREADY_STOPPED, /*< nick=AlreadyStopped >*/ + NM_VPN_PLUGIN_ERROR_WRONG_STATE, /*< nick=WrongState >*/ + NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS, /*< nick=BadArguments >*/ + NM_VPN_PLUGIN_ERROR_LAUNCH_FAILED, /*< nick=LaunchFailed >*/ + NM_VPN_PLUGIN_ERROR_INVALID_CONNECTION, /*< nick=InvalidConnection >*/ + NM_VPN_PLUGIN_ERROR_INTERACTIVE_NOT_SUPPORTED, /*< nick=InteractiveNotSupported >*/ +} NMVpnPluginError; + +#define NM_VPN_PLUGIN_ERROR (nm_vpn_plugin_error_quark ()) +GQuark nm_vpn_plugin_error_quark (void); + +#endif /* __NM_ERRORS_H__ */ diff --git a/libnm-core/nm-setting-8021x.c b/libnm-core/nm-setting-8021x.c index 352f84ef10..fc1b46fb67 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 d855df8584..ab6cde4401 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 26b01070ea..3ba569231f 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 baa8b8d7f3..57237f1e1b 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 8791744a04..4bc7e156a8 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 d030f9760c..ca0c17110a 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 3725553e14..19eee1edf4 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 18f5e105f6..e656ca887b 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 ffd21638c8..05d394721c 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: ", @@ -162,7 +145,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) s_con = NM_SETTING_CONNECTION (_nm_setting_find_in_list_required (all_settings, NM_SETTING_CONNECTION_SETTING_NAME, - error, NULL, NULL)); + error)); if (!s_con) return FALSE; @@ -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 cf38d90e0d..87fd898dbd 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 720f5cb278..082f8edb3d 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 6fca58a3a2..68eb10458a 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 88f1954db8..02e7e28928 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 5c13d67f5b..49f77a6ad6 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 890f77d1cc..b060345b6a 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,29 +814,19 @@ 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; } base_type = nm_setting_lookup_type (priv->type); - if (base_type == G_TYPE_INVALID) { - g_set_error (error, - NM_SETTING_CONNECTION_ERROR, - NM_SETTING_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); - return FALSE; - } - - if (!_nm_setting_type_is_base_type (base_type)) { + if (base_type == G_TYPE_INVALID || !_nm_setting_type_is_base_type (base_type)) { g_set_error (error, NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID, - _("connection type '%s' is not a valid base type"), + 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); return FALSE; @@ -887,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; @@ -897,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; @@ -918,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; @@ -931,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); @@ -946,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 4b40401d32..13890c32a1 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 b708098caa..e68be5e108 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 ab3c6bc9d0..089d266cf6 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 2c160b9176..35deb2de02 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 aa9efd17fb..db12b80491 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 84ea468a9f..7661db6557 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 c44a03486d..21e3c92b6e 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 6c8d31e23c..b7ae1a318a 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 2b8aabd106..35a576b3bd 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 ba31bcedb6..c1384bb54f 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 4891571131..004024113f 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 5e03e68913..ca08ad8bb9 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 349cc36a48..ec6299f3f0 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 2d5967c6d2..92d1045792 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 c363894540..a3e202adf0 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 6431dc550e..d150fe7783 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 34be5b26f0..a1d2b62811 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 dab6d942c5..488e4ba404 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 652c9c9b0d..8595baf14d 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-private.h b/libnm-core/nm-setting-private.h index 9f0c51a983..7940a161e2 100644 --- a/libnm-core/nm-setting-private.h +++ b/libnm-core/nm-setting-private.h @@ -46,13 +46,11 @@ typedef enum { void _nm_register_setting (const char *name, const GType type, - const guint32 priority, - const GQuark error_quark); + const guint32 priority); #define _nm_register_setting(name, priority) \ G_STMT_START { \ - _nm_register_setting (NM_SETTING_ ## name ## _SETTING_NAME "", g_define_type_id, priority, NM_SETTING_ ## name ## _ERROR); \ - g_type_ensure (NM_TYPE_SETTING_ ## name ## _ERROR); \ + _nm_register_setting (NM_SETTING_ ## name ## _SETTING_NAME "", g_define_type_id, priority); \ } G_STMT_END gboolean _nm_setting_is_base_type (NMSetting *setting); @@ -97,9 +95,7 @@ NMSetting *nm_setting_find_in_list (GSList *settings_list, const char *setting_n NMSetting * _nm_setting_find_in_list_required (GSList *all_settings, const char *setting_name, - GError **error, - const char *error_prefix_setting_name, - const char *error_prefix_property_name); + GError **error); NMSettingVerifyResult _nm_setting_verify_required_virtual_interface_name (GSList *all_settings, GError **error); diff --git a/libnm-core/nm-setting-serial.c b/libnm-core/nm-setting-serial.c index f2651a1821..23a37fe86a 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 80600ff80f..15b18150b2 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 1e04d68c69..dceab5c746 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) @@ -105,7 +88,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) s_con = NM_SETTING_CONNECTION (_nm_setting_find_in_list_required (all_settings, NM_SETTING_CONNECTION_SETTING_NAME, - error, NULL, NULL)); + error)); if (!s_con) return FALSE; @@ -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 f8ed805c60..644b0b5bd8 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 cb41e6f0a5..ab2d65eb60 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 1e949ca667..0c7fd1f940 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 d797164f29..31fa51d852 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 0ce5efbbd2..68f73b8151 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 667b83d78b..07f815716e 100644 --- a/libnm-core/nm-setting-vpn.c +++ b/libnm-core/nm-setting-vpn.c @@ -42,24 +42,6 @@ * properties. **/ -/** - * nm_setting_vpn_error_quark: - * - * Registers an error quark for #NMSettingVpn if necessary. - * - * Returns: the error quark used for #NMSettingVpn errors. - **/ -GQuark -nm_setting_vpn_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-setting-vpn-error-quark"); - return quark; -} - - G_DEFINE_TYPE_WITH_CODE (NMSettingVpn, nm_setting_vpn, NM_TYPE_SETTING, _nm_register_setting (VPN, 1)) NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_VPN) @@ -391,8 +373,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!priv->service_type) { g_set_error_literal (error, - NM_SETTING_VPN_ERROR, - NM_SETTING_VPN_ERROR_MISSING_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, _("property is missing")); g_prefix_error (error, "%s.%s: ", NM_SETTING_VPN_SETTING_NAME, NM_SETTING_VPN_SERVICE_TYPE); return FALSE; @@ -400,8 +382,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (!strlen (priv->service_type)) { g_set_error_literal (error, - NM_SETTING_VPN_ERROR, - NM_SETTING_VPN_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is empty")); g_prefix_error (error, "%s.%s: ", NM_SETTING_VPN_SETTING_NAME, NM_SETTING_VPN_SERVICE_TYPE); return FALSE; @@ -410,8 +392,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) /* default username can be NULL, but can't be zero-length */ if (priv->user_name && !strlen (priv->user_name)) { g_set_error_literal (error, - NM_SETTING_VPN_ERROR, - NM_SETTING_VPN_ERROR_INVALID_PROPERTY, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is empty")); g_prefix_error (error, "%s.%s: ", NM_SETTING_VPN_SETTING_NAME, NM_SETTING_VPN_USER_NAME); return FALSE; @@ -432,9 +414,10 @@ update_secret_string (NMSetting *setting, g_return_val_if_fail (value != NULL, NM_SETTING_UPDATE_SECRET_ERROR); if (!value || !strlen (value)) { - g_set_error (error, NM_SETTING_ERROR, - NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH, - "Secret %s was empty", key); + g_set_error (error, NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("secret was empty")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_VPN_SETTING_NAME, key); return NM_SETTING_UPDATE_SECRET_ERROR; } @@ -461,16 +444,18 @@ update_secret_dict (NMSetting *setting, g_variant_iter_init (&iter, secrets); while (g_variant_iter_next (&iter, "{&s&s}", &name, &value)) { if (!name || !strlen (name)) { - g_set_error_literal (error, NM_SETTING_ERROR, - NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH, - "Secret name was empty"); + g_set_error_literal (error, NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_SETTING, + _("setting contained a secret with an empty name")); + g_prefix_error (error, "%s: ", NM_SETTING_VPN_SETTING_NAME); return NM_SETTING_UPDATE_SECRET_ERROR; } if (!value || !strlen (value)) { - g_set_error (error, NM_SETTING_ERROR, - NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH, - "Secret %s value was empty", name); + g_set_error (error, NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("secret value was empty")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_VPN_SETTING_NAME, name); return NM_SETTING_UPDATE_SECRET_ERROR; } } @@ -514,12 +499,17 @@ update_one_secret (NMSetting *setting, const char *key, GVariant *value, GError success = update_secret_string (setting, key, g_variant_get_string (value, NULL), error); } else if (g_variant_is_of_type (value, G_VARIANT_TYPE ("a{ss}"))) { if (strcmp (key, NM_SETTING_VPN_SECRETS) != 0) { - g_set_error (error, NM_SETTING_ERROR, NM_SETTING_ERROR_PROPERTY_NOT_SECRET, - "Property %s not a secret property", key); + g_set_error_literal (error, NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_PROPERTY_NOT_SECRET, + _("not a secret property")); + g_prefix_error (error, "%s.%s ", NM_SETTING_VPN_SETTING_NAME, key); } else success = update_secret_dict (setting, value, error); - } else - g_set_error_literal (error, NM_SETTING_ERROR, NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH, key); + } else { + g_set_error_literal (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("secret is not of correct type")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_VPN_SETTING_NAME, key); + } if (success == NM_SETTING_UPDATE_SECRET_SUCCESS_MODIFIED) g_object_notify (G_OBJECT (setting), NM_SETTING_VPN_SECRETS); @@ -550,16 +540,18 @@ get_secret_flags (NMSetting *setting, success = TRUE; } else { g_set_error (error, - NM_SETTING_ERROR, - NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH, - _("Failed to convert '%s' value '%s' to uint"), - flags_key, (const char *) val); + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("failed to convert value '%s' to uint"), + (const char *) val); + g_prefix_error (error, "%s.%s: ", NM_SETTING_VPN_SETTING_NAME, flags_key); } } else { - g_set_error (error, - NM_SETTING_ERROR, - NM_SETTING_ERROR_PROPERTY_NOT_FOUND, - _("Secret flags property '%s' not found"), flags_key); + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, + _("secret flags property not found")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_VPN_SETTING_NAME, flags_key); } g_free (flags_key); if (out_flags) diff --git a/libnm-core/nm-setting-vpn.h b/libnm-core/nm-setting-vpn.h index 059f8f99bf..7a6fed86cb 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 bcb2458d4d..113e27fc45 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 68a7df93a1..fe262a5a73 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 4338ab047e..928dd628c9 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 73a25230c1..ba8b4303fc 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 c3e38bfc5b..c6171869cc 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 dac7357849..7c9e7ec472 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 17e7c3f3b5..2c0dd58455 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 50826efe6b..b402934cf7 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 14c5f404ce..2fbd300297 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)) @@ -69,7 +52,6 @@ typedef struct { const char *name; GType type; guint32 priority; - GQuark error_quark; } SettingInfo; typedef struct { @@ -127,10 +109,8 @@ _ensure_registered (void) * @name: the name of the #NMSetting object to register * @type: the #GType of the #NMSetting * @priority: the sort priority of the setting, see below - * @error_quark: the setting's error quark * - * 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 @@ -158,22 +138,19 @@ _ensure_registered (void) void (_nm_register_setting) (const char *name, const GType type, - const guint32 priority, - const GQuark error_quark) + const guint32 priority) { SettingInfo *info; g_return_if_fail (name != NULL && *name); g_return_if_fail (type != G_TYPE_INVALID); g_return_if_fail (type != G_TYPE_NONE); - g_return_if_fail (error_quark != 0); g_return_if_fail (priority <= 4); _ensure_registered (); if (G_LIKELY ((info = g_hash_table_lookup (registered_settings, name)))) { g_return_if_fail (info->type == type); - g_return_if_fail (info->error_quark == error_quark); g_return_if_fail (info->priority == priority); g_return_if_fail (g_strcmp0 (info->name, name) == 0); return; @@ -186,7 +163,6 @@ void info = g_slice_new0 (SettingInfo); info->type = type; info->priority = priority; - info->error_quark = error_quark; info->name = name; g_hash_table_insert (registered_settings, (void *) info->name, info); g_hash_table_insert (registered_settings_by_type, &info->type, info); @@ -260,32 +236,6 @@ nm_setting_lookup_type (const char *name) return info ? info->type : G_TYPE_INVALID; } -/** - * nm_setting_lookup_type_by_quark: - * @error_quark: a setting error quark - * - * Returns the #GType of the setting's class for a given setting error quark. - * Useful for figuring out which setting a returned error is for. - * - * Returns: the #GType of the setting's class, or %G_TYPE_INVALID if - * @error_quark is not recognized - **/ -GType -nm_setting_lookup_type_by_quark (GQuark error_quark) -{ - SettingInfo *info; - GHashTableIter iter; - - _ensure_registered (); - - g_hash_table_iter_init (&iter, registered_settings); - while (g_hash_table_iter_next (&iter, NULL, (gpointer) &info)) { - if (info->error_quark == error_quark) - return info->type; - } - return G_TYPE_INVALID; -} - gint _nm_setting_compare_priority (gconstpointer a, gconstpointer b) { @@ -1508,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; } @@ -1599,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; } @@ -1775,28 +1728,21 @@ nm_setting_to_string (NMSetting *setting) NMSetting * _nm_setting_find_in_list_required (GSList *all_settings, const char *setting_name, - GError **error, - const char *error_prefix_setting_name, - const char *error_prefix_property_name) + GError **error) { NMSetting *setting; g_return_val_if_fail (!error || !*error, NULL); g_return_val_if_fail (all_settings, NULL); g_return_val_if_fail (setting_name, NULL); - g_return_val_if_fail (!error_prefix_setting_name == !error_prefix_property_name, NULL); setting = nm_setting_find_in_list (all_settings, setting_name); if (!setting) { - g_set_error (error, - NM_CONNECTION_ERROR, - !strcmp (setting_name, NM_SETTING_CONNECTION_SETTING_NAME) - ? NM_CONNECTION_ERROR_CONNECTION_SETTING_NOT_FOUND - : NM_CONNECTION_ERROR_SETTING_NOT_FOUND, - _("Missing '%s' setting"), - setting_name); - if (error_prefix_setting_name) - g_prefix_error (error, "%s.%s: ", error_prefix_setting_name, error_prefix_property_name); + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_SETTING, + _("missing setting")); + g_prefix_error (error, "%s: ", setting_name); } return setting; } @@ -1812,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 8e179f2a4f..68cb1d5e01 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)) @@ -244,7 +218,6 @@ typedef void (*NMSettingValueIterFn) (NMSetting *setting, GType nm_setting_get_type (void); GType nm_setting_lookup_type (const char *name); -GType nm_setting_lookup_type_by_quark (GQuark error_quark); NMSetting *nm_setting_duplicate (NMSetting *setting); diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index 913ba4b4df..d3c3bef1dc 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -233,6 +233,8 @@ nm_utils_init (GError **error) if (!crypto_init (error)) return FALSE; + + _nm_dbus_errors_init (); } return TRUE; } diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c index 63811102ca..32061426ae 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,8 @@ test_connection_bad_base_types (void) nm_connection_add_setting (connection, setting); success = nm_connection_verify (connection, &error); - g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID); + 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); g_clear_error (&error); @@ -1979,7 +1980,8 @@ test_connection_bad_base_types (void) nm_connection_add_setting (connection, setting); success = nm_connection_verify (connection, &error); - g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID); + 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); g_clear_error (&error); @@ -1993,7 +1995,8 @@ test_connection_bad_base_types (void) nm_connection_add_setting (connection, setting); success = nm_connection_verify (connection, &error); - g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID); + 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); g_clear_error (&error); @@ -2005,7 +2008,8 @@ test_connection_bad_base_types (void) nm_connection_add_setting (connection, setting); success = nm_connection_verify (connection, &error); - g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID); + 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); g_clear_error (&error); @@ -2017,7 +2021,8 @@ test_connection_bad_base_types (void) nm_connection_add_setting (connection, setting); success = nm_connection_verify (connection, &error); - g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID); + 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); g_clear_error (&error); @@ -2834,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. */ @@ -2888,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); @@ -2896,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); @@ -2917,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 @@ -2940,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); @@ -2952,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); @@ -3208,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, @@ -3216,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); } @@ -3236,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, @@ -3246,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); } @@ -3277,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, @@ -3291,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-secrets.c b/libnm-core/tests/test-secrets.c index d728223b39..eec22524fd 100644 --- a/libnm-core/tests/test-secrets.c +++ b/libnm-core/tests/test-secrets.c @@ -607,10 +607,10 @@ test_update_secrets_whole_connection_empty_hash (void) GError *error = NULL; gboolean success; - /* Test that updating secrets with an empty hash returns success */ + /* Test that updating secrets with an empty connection hash returns success */ connection = wifi_connection_new (); - secrets = g_variant_new_array (G_VARIANT_TYPE ("{sv}"), NULL, 0); + secrets = g_variant_new_array (G_VARIANT_TYPE ("{sa{sv}}"), NULL, 0); success = nm_connection_update_secrets (connection, NULL, secrets, &error); g_assert_no_error (error); g_assert (success == TRUE); @@ -715,25 +715,29 @@ test_update_secrets_null_setting_name_with_setting_hash (void) secrets = build_wep_secrets (wepkey); + g_test_expect_message ("libnm", G_LOG_LEVEL_CRITICAL, + "*nm_connection_update_secrets*setting_name != NULL || full_connection*"); success = nm_connection_update_secrets (connection, NULL, secrets, &error); - g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_SETTING); + g_test_assert_expected_messages (); + g_assert_no_error (error); g_assert (!success); g_variant_unref (secrets); g_object_unref (connection); } -int main (int argc, char **argv) +NMTST_DEFINE (); + +int +main (int argc, char **argv) { - GError *error = NULL; char *base; #if !GLIB_CHECK_VERSION (2, 35, 0) g_type_init (); #endif - if (!nm_utils_init (&error)) - FAIL ("nm-utils-init", "failed to initialize libnm: %s", error->message); + nmtst_init (&argc, &argv, TRUE); /* The tests */ test_need_tls_secrets_path (); diff --git a/libnm-core/tests/test-setting-dcb.c b/libnm-core/tests/test-setting-dcb.c index 3c610186cf..8e2872aeee 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 e0c4795f9e..54d6057327 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -32,6 +32,8 @@ global: nm_active_connection_get_uuid; nm_active_connection_get_vpn; nm_active_connection_state_get_type; + nm_agent_manager_error_get_type; + nm_agent_manager_error_quark; nm_bluetooth_capabilities_get_type; nm_client_activate_connection_async; nm_client_activate_connection_finish; @@ -149,24 +151,18 @@ global: nm_connection_update_secrets; nm_connection_verify; nm_connectivity_state_get_type; - nm_device_adsl_error_get_type; - nm_device_adsl_error_quark; + nm_crypto_error_get_type; + nm_crypto_error_quark; nm_device_adsl_get_carrier; nm_device_adsl_get_type; - nm_device_bond_error_get_type; - nm_device_bond_error_quark; nm_device_bond_get_carrier; nm_device_bond_get_hw_address; nm_device_bond_get_slaves; nm_device_bond_get_type; - nm_device_bridge_error_get_type; - nm_device_bridge_error_quark; nm_device_bridge_get_carrier; nm_device_bridge_get_hw_address; nm_device_bridge_get_slaves; nm_device_bridge_get_type; - nm_device_bt_error_get_type; - nm_device_bt_error_quark; nm_device_bt_get_capabilities; nm_device_bt_get_hw_address; nm_device_bt_get_name; @@ -183,16 +179,12 @@ global: nm_device_disconnect_finish; nm_device_error_get_type; nm_device_error_quark; - nm_device_ethernet_error_get_type; - nm_device_ethernet_error_quark; nm_device_ethernet_get_carrier; nm_device_ethernet_get_hw_address; nm_device_ethernet_get_permanent_hw_address; nm_device_ethernet_get_speed; nm_device_ethernet_get_type; nm_device_filter_connections; - nm_device_generic_error_get_type; - nm_device_generic_error_quark; nm_device_generic_get_hw_address; nm_device_generic_get_type; nm_device_get_active_connection; @@ -223,20 +215,14 @@ global: nm_device_get_type_description; nm_device_get_udi; nm_device_get_vendor; - nm_device_infiniband_error_get_type; - nm_device_infiniband_error_quark; nm_device_infiniband_get_carrier; nm_device_infiniband_get_hw_address; nm_device_infiniband_get_type; nm_device_is_software; nm_device_modem_capabilities_get_type; - nm_device_modem_error_get_type; - nm_device_modem_error_quark; nm_device_modem_get_current_capabilities; nm_device_modem_get_modem_capabilities; nm_device_modem_get_type; - nm_device_olpc_mesh_error_get_type; - nm_device_olpc_mesh_error_quark; nm_device_olpc_mesh_get_active_channel; nm_device_olpc_mesh_get_companion; nm_device_olpc_mesh_get_hw_address; @@ -244,22 +230,16 @@ global: nm_device_set_autoconnect; nm_device_state_get_type; nm_device_state_reason_get_type; - nm_device_team_error_get_type; - nm_device_team_error_quark; nm_device_team_get_carrier; nm_device_team_get_hw_address; nm_device_team_get_slaves; nm_device_team_get_type; nm_device_type_get_type; - nm_device_vlan_error_get_type; - nm_device_vlan_error_quark; nm_device_vlan_get_carrier; nm_device_vlan_get_hw_address; nm_device_vlan_get_type; nm_device_vlan_get_vlan_id; nm_device_wifi_capabilities_get_type; - nm_device_wifi_error_get_type; - nm_device_wifi_error_quark; nm_device_wifi_get_access_point_by_path; nm_device_wifi_get_access_points; nm_device_wifi_get_active_access_point; @@ -272,8 +252,6 @@ global: nm_device_wifi_request_scan; nm_device_wifi_request_scan_async; nm_device_wifi_request_scan_finish; - nm_device_wimax_error_get_type; - nm_device_wimax_error_quark; nm_device_wimax_get_active_nsp; nm_device_wimax_get_bsid; nm_device_wimax_get_center_frequency; @@ -357,8 +335,8 @@ global: nm_ip6_route_set_next_hop; nm_ip6_route_set_prefix; nm_ip6_route_unref; - nm_object_error_get_type; - nm_object_error_quark; + nm_manager_error_get_type; + nm_manager_error_quark; nm_object_get_path; nm_object_get_type; nm_remote_connection_commit_changes; @@ -367,8 +345,6 @@ global: nm_remote_connection_delete; nm_remote_connection_delete_async; nm_remote_connection_delete_finish; - nm_remote_connection_error_get_type; - nm_remote_connection_error_quark; nm_remote_connection_get_secrets; nm_remote_connection_get_secrets_async; nm_remote_connection_get_secrets_finish; @@ -401,8 +377,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 +440,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 +449,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 +463,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 +472,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 +487,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 +511,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 +539,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 +555,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 +571,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 +605,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,16 +632,11 @@ global: nm_setting_ip6_config_remove_route; nm_setting_ip6_config_remove_route_by_value; nm_setting_lookup_type; - nm_setting_lookup_type_by_quark; - 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; @@ -716,8 +657,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; @@ -725,8 +664,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; @@ -736,13 +673,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; @@ -751,8 +684,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; @@ -765,8 +696,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; @@ -779,8 +708,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; @@ -788,8 +715,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; @@ -815,8 +740,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; @@ -843,8 +766,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; @@ -871,6 +792,8 @@ global: nm_setting_wireless_security_remove_proto; nm_setting_wireless_security_remove_proto_by_value; nm_setting_wireless_security_set_wep_key; + nm_settings_error_get_type; + nm_settings_error_quark; nm_simple_connection_get_type; nm_simple_connection_new; nm_simple_connection_new_clone; diff --git a/libnm/nm-client.c b/libnm/nm-client.c index cf4e9b28de..dad101b00b 100644 --- a/libnm/nm-client.c +++ b/libnm/nm-client.c @@ -1634,17 +1634,8 @@ nm_client_new_finish (GAsyncResult *result, GError **error) { GSimpleAsyncResult *simple; - g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - - if (!result) { - g_set_error_literal (error, - NM_CLIENT_ERROR, - NM_CLIENT_ERROR_UNKNOWN, - "NMClient initialization failed (or you passed NULL 'result' by mistake)"); - return NULL; - } - g_return_val_if_fail (g_simple_async_result_is_valid (result, NULL, nm_client_new_async), NULL); + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); simple = G_SIMPLE_ASYNC_RESULT (result); if (g_simple_async_result_propagate_error (simple, error)) diff --git a/libnm/nm-client.h b/libnm/nm-client.h index 64bd0a0d32..2f22289c1f 100644 --- a/libnm/nm-client.h +++ b/libnm/nm-client.h @@ -131,21 +131,23 @@ typedef enum { /** * NMClientError: - * @NM_CLIENT_ERROR_UNKNOWN: unknown or unclassified error + * @NM_CLIENT_ERROR_FAILED: unknown or unclassified error * @NM_CLIENT_ERROR_MANAGER_NOT_RUNNING: an operation that requires NetworkManager * failed because NetworkManager is not running - * @NM_CLIENT_ERROR_CONNECTION_REMOVED: the #NMRemoteConnection object - * was removed before it was completely initialized - * @NM_CLIENT_ERROR_CONNECTION_UNAVAILABLE: the #NMRemoteConnection object - * is not visible or otherwise unreadable + * @NM_CLIENT_ERROR_OBJECT_CREATION_FAILED: NetworkManager claimed that an + * operation succeeded, but the object that was allegedly created (eg, + * #NMRemoteConnection, #NMActiveConnection) was apparently destroyed before + * #NMClient could create a representation of it. * * Describes errors that may result from operations involving a #NMClient. + * + * D-Bus operations may also return errors from other domains, including + * #NMManagerError, #NMSettingsError, #NMAgentManagerError, and #NMConnectionError. **/ typedef enum { - NM_CLIENT_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_CLIENT_ERROR_MANAGER_NOT_RUNNING, /*< nick=ManagerNotRunning >*/ - NM_CLIENT_ERROR_CONNECTION_REMOVED, /*< nick=ConnectionRemoved >*/ - NM_CLIENT_ERROR_CONNECTION_UNAVAILABLE, /*< nick=ConnectionUnavailable >*/ + NM_CLIENT_ERROR_FAILED = 0, + NM_CLIENT_ERROR_MANAGER_NOT_RUNNING, + NM_CLIENT_ERROR_OBJECT_CREATION_FAILED, } NMClientError; #define NM_CLIENT_ERROR nm_client_error_quark () diff --git a/libnm/nm-dbus-helpers.c b/libnm/nm-dbus-helpers.c index 4c0318dd2e..5b24b2a366 100644 --- a/libnm/nm-dbus-helpers.c +++ b/libnm/nm-dbus-helpers.c @@ -329,27 +329,6 @@ _nm_dbus_new_proxy_for_connection_finish (GAsyncResult *result, return G_DBUS_PROXY (proxy); } -void -_nm_dbus_register_error_domain (GQuark domain, - const char *interface, - GType enum_type) -{ - GEnumClass *enum_class; - GEnumValue *e; - char *error_name; - int i; - - enum_class = g_type_class_ref (enum_type); - for (i = 0; i < enum_class->n_values; i++) { - e = &enum_class->values[i]; - error_name = g_strdup_printf ("%s.%s", interface, e->value_nick); - g_dbus_error_register_error (domain, e->value, error_name); - g_free (error_name); - } - - g_type_class_unref (enum_class); -} - /* Binds the properties on a generated server-side GDBus object to the * corresponding properties on the public object. */ diff --git a/libnm/nm-dbus-helpers.h b/libnm/nm-dbus-helpers.h index 9b0456b2bb..ca779d3a39 100644 --- a/libnm/nm-dbus-helpers.h +++ b/libnm/nm-dbus-helpers.h @@ -68,10 +68,6 @@ void _nm_dbus_new_proxy_for_connection_async (GDBusConnection *connectio GDBusProxy *_nm_dbus_new_proxy_for_connection_finish (GAsyncResult *result, GError **error); -void _nm_dbus_register_error_domain (GQuark domain, - const char *interface, - GType enum_type); - void _nm_dbus_bind_properties (gpointer object, gpointer skeleton); diff --git a/libnm/nm-device-adsl.c b/libnm/nm-device-adsl.c index 49d6595e42..dbf1cb406f 100644 --- a/libnm/nm-device-adsl.c +++ b/libnm/nm-device-adsl.c @@ -26,6 +26,7 @@ #include "nm-setting-adsl.h" #include <string.h> +#include <glib/gi18n.h> G_DEFINE_TYPE (NMDeviceAdsl, nm_device_adsl, NM_TYPE_DEVICE) @@ -43,23 +44,6 @@ enum { }; /** - * nm_device_adsl_error_quark: - * - * Registers an error quark for #NMDeviceAdsl if necessary. - * - * Returns: the error quark used for #NMDeviceAdsl errors. - **/ -GQuark -nm_device_adsl_error_quark (void) -{ - static GQuark quark = 0; - - if (G_UNLIKELY (quark == 0)) - quark = g_quark_from_static_string ("nm-device-adsl-error-quark"); - return quark; -} - -/** * nm_device_adsl_get_carrier: * @device: a #NMDeviceAdsl * @@ -78,28 +62,16 @@ nm_device_adsl_get_carrier (NMDeviceAdsl *device) static gboolean connection_compatible (NMDevice *device, NMConnection *connection, GError **error) { - NMSettingConnection *s_con; - NMSettingAdsl *s_adsl; - const char *ctype; - - s_con = nm_connection_get_setting_connection (connection); - g_assert (s_con); - - ctype = nm_setting_connection_get_connection_type (s_con); - if (strcmp (ctype, NM_SETTING_ADSL_SETTING_NAME) != 0) { - g_set_error (error, NM_DEVICE_ADSL_ERROR, NM_DEVICE_ADSL_ERROR_NOT_ADSL_CONNECTION, - "The connection was not an ADSL connection."); + if (!NM_DEVICE_CLASS (nm_device_adsl_parent_class)->connection_compatible (device, connection, error)) return FALSE; - } - s_adsl = nm_connection_get_setting_adsl (connection); - if (!s_adsl) { - g_set_error (error, NM_DEVICE_ADSL_ERROR, NM_DEVICE_ADSL_ERROR_INVALID_ADSL_CONNECTION, - "The connection was not a valid ADSL connection."); + if (!nm_connection_is_type (connection, NM_SETTING_ADSL_SETTING_NAME)) { + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The connection was not an ADSL connection.")); return FALSE; } - return NM_DEVICE_CLASS (nm_device_adsl_parent_class)->connection_compatible (device, connection, error); + return TRUE; } static GType diff --git a/libnm/nm-device-adsl.h b/libnm/nm-device-adsl.h index d76f35a891..d01745148f 100644 --- a/libnm/nm-device-adsl.h +++ b/libnm/nm-device-adsl.h @@ -36,21 +36,6 @@ G_BEGIN_DECLS #define NM_IS_DEVICE_ADSL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_ADSL)) #define NM_DEVICE_ADSL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_ADSL, NMDeviceAdslClass)) -/** - * NMDeviceAdslError: - * @NM_DEVICE_ADSL_ERROR_UNKNOWN: unknown or unclassified error - * @NM_DEVICE_ADSL_ERROR_NOT_ADSL_CONNECTION: the connection was not of ADSL type - * @NM_DEVICE_ADSL_ERROR_INVALID_ADSL_CONNECTION: the ADSL connection was invalid - */ -typedef enum { - NM_DEVICE_ADSL_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_DEVICE_ADSL_ERROR_NOT_ADSL_CONNECTION, /*< nick=NotAdslConnection >*/ - NM_DEVICE_ADSL_ERROR_INVALID_ADSL_CONNECTION, /*< nick=InvalidAdslConnection >*/ -} NMDeviceAdslError; - -#define NM_DEVICE_ADSL_ERROR nm_device_adsl_error_quark () -GQuark nm_device_adsl_error_quark (void); - #define NM_DEVICE_ADSL_CARRIER "carrier" struct _NMDeviceAdsl { diff --git a/libnm/nm-device-bond.c b/libnm/nm-device-bond.c index 9656de631e..7f2ada911d 100644 --- a/libnm/nm-device-bond.c +++ b/libnm/nm-device-bond.c @@ -20,6 +20,7 @@ #include <config.h> #include <string.h> +#include <glib/gi18n.h> #include "nm-glib-compat.h" @@ -52,23 +53,6 @@ enum { }; /** - * nm_device_bond_error_quark: - * - * Registers an error quark for #NMDeviceBond if necessary. - * - * Returns: the error quark used for #NMDeviceBond errors. - **/ -GQuark -nm_device_bond_error_quark (void) -{ - static GQuark quark = 0; - - if (G_UNLIKELY (quark == 0)) - quark = g_quark_from_static_string ("nm-device-bond-error-quark"); - return quark; -} - -/** * nm_device_bond_get_hw_address: * @device: a #NMDeviceBond * @@ -122,38 +106,18 @@ nm_device_bond_get_slaves (NMDeviceBond *device) static gboolean connection_compatible (NMDevice *device, NMConnection *connection, GError **error) { - NMSettingConnection *s_con; - NMSettingBond *s_bond; - const char *ctype, *dev_iface_name, *bond_iface_name; - - s_con = nm_connection_get_setting_connection (connection); - g_assert (s_con); - - ctype = nm_setting_connection_get_connection_type (s_con); - if (strcmp (ctype, NM_SETTING_BOND_SETTING_NAME) != 0) { - g_set_error (error, NM_DEVICE_BOND_ERROR, NM_DEVICE_BOND_ERROR_NOT_BOND_CONNECTION, - "The connection was not a bond connection."); + if (!NM_DEVICE_CLASS (nm_device_bond_parent_class)->connection_compatible (device, connection, error)) return FALSE; - } - - s_bond = nm_connection_get_setting_bond (connection); - if (!s_bond) { - g_set_error (error, NM_DEVICE_BOND_ERROR, NM_DEVICE_BOND_ERROR_INVALID_BOND_CONNECTION, - "The connection was not a valid bond connection."); - return FALSE; - } - dev_iface_name = nm_device_get_iface (device); - bond_iface_name = nm_setting_connection_get_interface_name (s_con); - if (g_strcmp0 (dev_iface_name, bond_iface_name) != 0) { - g_set_error (error, NM_DEVICE_BOND_ERROR, NM_DEVICE_BOND_ERROR_INTERFACE_MISMATCH, - "The interfaces of the device and the connection didn't match."); + if (!nm_connection_is_type (connection, NM_SETTING_BOND_SETTING_NAME)) { + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The connection was not a bond connection.")); return FALSE; } /* FIXME: check slaves? */ - return NM_DEVICE_CLASS (nm_device_bond_parent_class)->connection_compatible (device, connection, error); + return TRUE; } static GType diff --git a/libnm/nm-device-bond.h b/libnm/nm-device-bond.h index e8ffd8e633..b7a0b11315 100644 --- a/libnm/nm-device-bond.h +++ b/libnm/nm-device-bond.h @@ -36,23 +36,6 @@ G_BEGIN_DECLS #define NM_IS_DEVICE_BOND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_BOND)) #define NM_DEVICE_BOND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_BOND, NMDeviceBondClass)) -/** - * NMDeviceBondError: - * @NM_DEVICE_BOND_ERROR_UNKNOWN: unknown or unclassified error - * @NM_DEVICE_BOND_ERROR_NOT_BOND_CONNECTION: the connection was not of bond type - * @NM_DEVICE_BOND_ERROR_INVALID_BOND_CONNECTION: the bond connection was invalid - * @NM_DEVICE_BOND_ERROR_INTERFACE_MISMATCH: the interfaces of the connection and the device mismatched - */ -typedef enum { - NM_DEVICE_BOND_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_DEVICE_BOND_ERROR_NOT_BOND_CONNECTION, /*< nick=NotBondConnection >*/ - NM_DEVICE_BOND_ERROR_INVALID_BOND_CONNECTION, /*< nick=InvalidBondConnection >*/ - NM_DEVICE_BOND_ERROR_INTERFACE_MISMATCH, /*< nick=InterfaceMismatch >*/ -} NMDeviceBondError; - -#define NM_DEVICE_BOND_ERROR nm_device_bond_error_quark () -GQuark nm_device_bond_error_quark (void); - #define NM_DEVICE_BOND_HW_ADDRESS "hw-address" #define NM_DEVICE_BOND_CARRIER "carrier" #define NM_DEVICE_BOND_SLAVES "slaves" diff --git a/libnm/nm-device-bridge.c b/libnm/nm-device-bridge.c index 63d9040d49..5a3782e742 100644 --- a/libnm/nm-device-bridge.c +++ b/libnm/nm-device-bridge.c @@ -20,6 +20,7 @@ #include <config.h> #include <string.h> +#include <glib/gi18n.h> #include "nm-glib-compat.h" @@ -52,23 +53,6 @@ enum { }; /** - * nm_device_bridge_error_quark: - * - * Registers an error quark for #NMDeviceBridge if necessary. - * - * Returns: the error quark used for #NMDeviceBridge errors. - **/ -GQuark -nm_device_bridge_error_quark (void) -{ - static GQuark quark = 0; - - if (G_UNLIKELY (quark == 0)) - quark = g_quark_from_static_string ("nm-device-bridge-error-quark"); - return quark; -} - -/** * nm_device_bridge_get_hw_address: * @device: a #NMDeviceBridge * @@ -122,38 +106,18 @@ nm_device_bridge_get_slaves (NMDeviceBridge *device) static gboolean connection_compatible (NMDevice *device, NMConnection *connection, GError **error) { - NMSettingConnection *s_con; - NMSettingBridge *s_bridge; - const char *ctype, *dev_iface_name, *bridge_iface_name; - - s_con = nm_connection_get_setting_connection (connection); - g_assert (s_con); - - ctype = nm_setting_connection_get_connection_type (s_con); - if (strcmp (ctype, NM_SETTING_BRIDGE_SETTING_NAME) != 0) { - g_set_error (error, NM_DEVICE_BRIDGE_ERROR, NM_DEVICE_BRIDGE_ERROR_NOT_BRIDGE_CONNECTION, - "The connection was not a bridge connection."); + if (!NM_DEVICE_CLASS (nm_device_bridge_parent_class)->connection_compatible (device, connection, error)) return FALSE; - } - - s_bridge = nm_connection_get_setting_bridge (connection); - if (!s_bridge) { - g_set_error (error, NM_DEVICE_BRIDGE_ERROR, NM_DEVICE_BRIDGE_ERROR_INVALID_BRIDGE_CONNECTION, - "The connection was not a valid bridge connection."); - return FALSE; - } - dev_iface_name = nm_device_get_iface (device); - bridge_iface_name = nm_setting_connection_get_interface_name (s_con); - if (g_strcmp0 (dev_iface_name, bridge_iface_name) != 0) { - g_set_error (error, NM_DEVICE_BRIDGE_ERROR, NM_DEVICE_BRIDGE_ERROR_INTERFACE_MISMATCH, - "The interfaces of the device and the connection didn't match."); + if (!nm_connection_is_type (connection, NM_SETTING_BRIDGE_SETTING_NAME)) { + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The connection was not a bridge connection.")); return FALSE; } /* FIXME: check ports? */ - return NM_DEVICE_CLASS (nm_device_bridge_parent_class)->connection_compatible (device, connection, error); + return TRUE; } static GType diff --git a/libnm/nm-device-bridge.h b/libnm/nm-device-bridge.h index 4ec490e13f..42a0b3a51f 100644 --- a/libnm/nm-device-bridge.h +++ b/libnm/nm-device-bridge.h @@ -36,23 +36,6 @@ G_BEGIN_DECLS #define NM_IS_DEVICE_BRIDGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_BRIDGE)) #define NM_DEVICE_BRIDGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_BRIDGE, NMDeviceBridgeClass)) -/** - * NMDeviceBridgeError: - * @NM_DEVICE_BRIDGE_ERROR_UNKNOWN: unknown or unclassified error - * @NM_DEVICE_BRIDGE_ERROR_NOT_BRIDGE_CONNECTION: the connection was not of bridge type - * @NM_DEVICE_BRIDGE_ERROR_INVALID_BRIDGE_CONNECTION: the bridge connection was invalid - * @NM_DEVICE_BRIDGE_ERROR_INTERFACE_MISMATCH: the interfaces of the connection and the device mismatched - */ -typedef enum { - NM_DEVICE_BRIDGE_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_DEVICE_BRIDGE_ERROR_NOT_BRIDGE_CONNECTION, /*< nick=NotBridgeConnection >*/ - NM_DEVICE_BRIDGE_ERROR_INVALID_BRIDGE_CONNECTION, /*< nick=InvalidBridgeConnection >*/ - NM_DEVICE_BRIDGE_ERROR_INTERFACE_MISMATCH, /*< nick=InterfaceMismatch >*/ -} NMDeviceBridgeError; - -#define NM_DEVICE_BRIDGE_ERROR nm_device_bridge_error_quark () -GQuark nm_device_bridge_error_quark (void); - #define NM_DEVICE_BRIDGE_HW_ADDRESS "hw-address" #define NM_DEVICE_BRIDGE_CARRIER "carrier" #define NM_DEVICE_BRIDGE_SLAVES "slaves" diff --git a/libnm/nm-device-bt.c b/libnm/nm-device-bt.c index 5bd93b9773..5673792cfb 100644 --- a/libnm/nm-device-bt.c +++ b/libnm/nm-device-bt.c @@ -21,6 +21,7 @@ #include <config.h> #include <string.h> +#include <glib/gi18n.h> #include "nm-glib-compat.h" @@ -53,23 +54,6 @@ enum { }; /** - * nm_device_bt_error_quark: - * - * Registers an error quark for #NMDeviceBt if necessary. - * - * Returns: the error quark used for #NMDeviceBt errors. - **/ -GQuark -nm_device_bt_error_quark (void) -{ - static GQuark quark = 0; - - if (G_UNLIKELY (quark == 0)) - quark = g_quark_from_static_string ("nm-device-bt-error-quark"); - return quark; -} - -/** * nm_device_bt_get_hw_address: * @device: a #NMDeviceBt * @@ -142,27 +126,17 @@ get_connection_bt_type (NMConnection *connection) static gboolean connection_compatible (NMDevice *device, NMConnection *connection, GError **error) { - NMSettingConnection *s_con; NMSettingBluetooth *s_bt; - const char *ctype; const char *hw_addr, *setting_addr; NMBluetoothCapabilities dev_caps; NMBluetoothCapabilities bt_type; - s_con = nm_connection_get_setting_connection (connection); - g_assert (s_con); - - ctype = nm_setting_connection_get_connection_type (s_con); - if (strcmp (ctype, NM_SETTING_BLUETOOTH_SETTING_NAME) != 0) { - g_set_error (error, NM_DEVICE_BT_ERROR, NM_DEVICE_BT_ERROR_NOT_BT_CONNECTION, - "The connection was not a Bluetooth connection."); + if (!NM_DEVICE_CLASS (nm_device_bt_parent_class)->connection_compatible (device, connection, error)) return FALSE; - } - s_bt = nm_connection_get_setting_bluetooth (connection); - if (!s_bt) { - g_set_error (error, NM_DEVICE_BT_ERROR, NM_DEVICE_BT_ERROR_INVALID_BT_CONNECTION, - "The connection was not a valid Bluetooth connection."); + if (!nm_connection_is_type (connection, NM_SETTING_BLUETOOTH_SETTING_NAME)) { + g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The connection was not a Bluetooth connection.")); return FALSE; } @@ -170,14 +144,15 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro hw_addr = nm_device_bt_get_hw_address (NM_DEVICE_BT (device)); if (hw_addr) { if (!nm_utils_hwaddr_valid (hw_addr, ETH_ALEN)) { - g_set_error (error, NM_DEVICE_BT_ERROR, NM_DEVICE_BT_ERROR_INVALID_DEVICE_MAC, - "Invalid device MAC address."); + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, + _("Invalid device Bluetooth address.")); return FALSE; } + s_bt = nm_connection_get_setting_bluetooth (connection); setting_addr = nm_setting_bluetooth_get_bdaddr (s_bt); if (setting_addr && !nm_utils_hwaddr_matches (setting_addr, -1, hw_addr, -1)) { - g_set_error (error, NM_DEVICE_BT_ERROR, NM_DEVICE_BT_ERROR_MAC_MISMATCH, - "The MACs of the device and the connection didn't match."); + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The Bluetooth addresses of the device and the connection didn't match.")); return FALSE; } } @@ -185,12 +160,12 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro dev_caps = nm_device_bt_get_capabilities (NM_DEVICE_BT (device)); bt_type = get_connection_bt_type (connection); if (!(bt_type & dev_caps)) { - g_set_error (error, NM_DEVICE_BT_ERROR, NM_DEVICE_BT_ERROR_MISSING_DEVICE_CAPS, - "The device missed BT capabilities required by the connection."); + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The device is lacking Bluetooth capabilities required by the connection.")); return FALSE; } - return NM_DEVICE_CLASS (nm_device_bt_parent_class)->connection_compatible (device, connection, error); + return TRUE; } static GType diff --git a/libnm/nm-device-bt.h b/libnm/nm-device-bt.h index b6c6045ead..e066cbcd8c 100644 --- a/libnm/nm-device-bt.h +++ b/libnm/nm-device-bt.h @@ -37,27 +37,6 @@ G_BEGIN_DECLS #define NM_IS_DEVICE_BT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_BT)) #define NM_DEVICE_BT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_BT, NMDeviceBtClass)) -/** - * NMDeviceBtError: - * @NM_DEVICE_BT_ERROR_UNKNOWN: unknown or unclassified error - * @NM_DEVICE_BT_ERROR_NOT_BT_CONNECTION: the connection was not of bluetooth type - * @NM_DEVICE_BT_ERROR_INVALID_BT_CONNECTION: the bluetooth connection was invalid - * @NM_DEVICE_BT_ERROR_INVALID_DEVICE_MAC: the device's MAC was invalid - * @NM_DEVICE_BT_ERROR_MAC_MISMATCH: the MACs of the connection and the device mismatched - * @NM_DEVICE_BT_ERROR_MISSING_DEVICE_CAPS: the device missed required capabilities - */ -typedef enum { - NM_DEVICE_BT_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_DEVICE_BT_ERROR_NOT_BT_CONNECTION, /*< nick=NotBtConnection >*/ - NM_DEVICE_BT_ERROR_INVALID_BT_CONNECTION, /*< nick=InvalidBtConnection >*/ - NM_DEVICE_BT_ERROR_INVALID_DEVICE_MAC, /*< nick=InvalidDeviceMac >*/ - NM_DEVICE_BT_ERROR_MAC_MISMATCH, /*< nick=MacMismatch >*/ - NM_DEVICE_BT_ERROR_MISSING_DEVICE_CAPS, /*< nick=MissingDeviceCaps >*/ -} NMDeviceBtError; - -#define NM_DEVICE_BT_ERROR nm_device_bt_error_quark () -GQuark nm_device_bt_error_quark (void); - #define NM_DEVICE_BT_HW_ADDRESS "hw-address" #define NM_DEVICE_BT_NAME "name" #define NM_DEVICE_BT_CAPABILITIES "bt-capabilities" diff --git a/libnm/nm-device-ethernet.c b/libnm/nm-device-ethernet.c index e26a58ee21..c240aa9681 100644 --- a/libnm/nm-device-ethernet.c +++ b/libnm/nm-device-ethernet.c @@ -21,6 +21,7 @@ #include <config.h> #include <string.h> +#include <glib/gi18n.h> #include "nm-glib-compat.h" @@ -55,23 +56,6 @@ enum { }; /** - * nm_device_ethernet_error_quark: - * - * Registers an error quark for #NMDeviceEthernet if necessary. - * - * Returns: the error quark used for #NMDeviceEthernet errors. - **/ -GQuark -nm_device_ethernet_error_quark (void) -{ - static GQuark quark = 0; - - if (G_UNLIKELY (quark == 0)) - quark = g_quark_from_static_string ("nm-device-ethernet-error-quark"); - return quark; -} - -/** * nm_device_ethernet_get_hw_address: * @device: a #NMDeviceEthernet * @@ -140,31 +124,22 @@ nm_device_ethernet_get_carrier (NMDeviceEthernet *device) static gboolean connection_compatible (NMDevice *device, NMConnection *connection, GError **error) { - NMSettingConnection *s_con; NMSettingWired *s_wired; - const char *ctype; gboolean is_pppoe = FALSE; - s_con = nm_connection_get_setting_connection (connection); - g_assert (s_con); + if (!NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->connection_compatible (device, connection, error)) + return FALSE; - ctype = nm_setting_connection_get_connection_type (s_con); - if (!strcmp (ctype, NM_SETTING_PPPOE_SETTING_NAME)) + if (nm_connection_is_type (connection, NM_SETTING_PPPOE_SETTING_NAME)) is_pppoe = TRUE; - else if (strcmp (ctype, NM_SETTING_WIRED_SETTING_NAME) != 0) { - g_set_error (error, NM_DEVICE_ETHERNET_ERROR, NM_DEVICE_ETHERNET_ERROR_NOT_ETHERNET_CONNECTION, - "The connection was not a wired or PPPoE connection."); + else if (!nm_connection_is_type (connection, NM_SETTING_WIRED_SETTING_NAME)) { + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The connection was not an Ethernet or PPPoE connection.")); return FALSE; } s_wired = nm_connection_get_setting_wired (connection); /* Wired setting optional for PPPoE */ - if (!is_pppoe && !s_wired) { - g_set_error (error, NM_DEVICE_ETHERNET_ERROR, NM_DEVICE_ETHERNET_ERROR_INVALID_ETHERNET_CONNECTION, - "The connection was not a valid Ethernet connection."); - return FALSE; - } - if (s_wired) { const char *perm_addr, *setting_addr; @@ -174,20 +149,20 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro perm_addr = nm_device_ethernet_get_permanent_hw_address (NM_DEVICE_ETHERNET (device)); if (perm_addr) { if (!nm_utils_hwaddr_valid (perm_addr, ETH_ALEN)) { - g_set_error (error, NM_DEVICE_ETHERNET_ERROR, NM_DEVICE_ETHERNET_ERROR_INVALID_DEVICE_MAC, - "Invalid device MAC address."); + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, + _("Invalid device MAC address.")); return FALSE; } setting_addr = nm_setting_wired_get_mac_address (s_wired); if (setting_addr && !nm_utils_hwaddr_matches (setting_addr, -1, perm_addr, -1)) { - g_set_error (error, NM_DEVICE_ETHERNET_ERROR, NM_DEVICE_ETHERNET_ERROR_MAC_MISMATCH, - "The MACs of the device and the connection didn't match."); + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The MACs of the device and the connection didn't match.")); return FALSE; } } } - return NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->connection_compatible (device, connection, error); + return TRUE; } static GType diff --git a/libnm/nm-device-ethernet.h b/libnm/nm-device-ethernet.h index caea242c87..09286e73a7 100644 --- a/libnm/nm-device-ethernet.h +++ b/libnm/nm-device-ethernet.h @@ -37,25 +37,6 @@ G_BEGIN_DECLS #define NM_IS_DEVICE_ETHERNET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_ETHERNET)) #define NM_DEVICE_ETHERNET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_ETHERNET, NMDeviceEthernetClass)) -/** - * NMDeviceEthernetError: - * @NM_DEVICE_ETHERNET_ERROR_UNKNOWN: unknown or unclassified error - * @NM_DEVICE_ETHERNET_ERROR_NOT_ETHERNET_CONNECTION: the connection was not of Ethernet or PPPoE type - * @NM_DEVICE_ETHERNET_ERROR_INVALID_ETHERNET_CONNECTION: the Ethernet connection was invalid - * @NM_DEVICE_ETHERNET_ERROR_INVALID_DEVICE_MAC: the device's MAC was invalid - * @NM_DEVICE_ETHERNET_ERROR_MAC_MISMATCH: the MACs of the connection and the device mismatched - */ -typedef enum { - NM_DEVICE_ETHERNET_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_DEVICE_ETHERNET_ERROR_NOT_ETHERNET_CONNECTION, /*< nick=NotEthernetConnection >*/ - NM_DEVICE_ETHERNET_ERROR_INVALID_ETHERNET_CONNECTION, /*< nick=InvalidEthernetConnection >*/ - NM_DEVICE_ETHERNET_ERROR_INVALID_DEVICE_MAC, /*< nick=InvalidDeviceMac >*/ - NM_DEVICE_ETHERNET_ERROR_MAC_MISMATCH, /*< nick=MacMismatch >*/ -} NMDeviceEthernetError; - -#define NM_DEVICE_ETHERNET_ERROR nm_device_ethernet_error_quark () -GQuark nm_device_ethernet_error_quark (void); - #define NM_DEVICE_ETHERNET_HW_ADDRESS "hw-address" #define NM_DEVICE_ETHERNET_PERMANENT_HW_ADDRESS "perm-hw-address" #define NM_DEVICE_ETHERNET_SPEED "speed" diff --git a/libnm/nm-device-generic.c b/libnm/nm-device-generic.c index 5d11fcde0a..999bb802dd 100644 --- a/libnm/nm-device-generic.c +++ b/libnm/nm-device-generic.c @@ -21,6 +21,7 @@ #include <config.h> #include <string.h> +#include <glib/gi18n.h> #include "nm-device-generic.h" #include "nm-device-private.h" @@ -45,23 +46,6 @@ enum { }; /** - * nm_device_generic_error_quark: - * - * Registers an error quark for #NMDeviceGeneric if necessary. - * - * Returns: the error quark used for #NMDeviceGeneric errors. - **/ -GQuark -nm_device_generic_error_quark (void) -{ - static GQuark quark = 0; - - if (G_UNLIKELY (quark == 0)) - quark = g_quark_from_static_string ("nm-device-generic-error-quark"); - return quark; -} - -/** * nm_device_generic_get_hw_address: * @device: a #NMDeviceGeneric * @@ -97,27 +81,25 @@ get_hw_address (NMDevice *device) static gboolean connection_compatible (NMDevice *device, NMConnection *connection, GError **error) { - NMSettingConnection *s_con; - const char *ctype, *iface_name; + const char *iface_name; - s_con = nm_connection_get_setting_connection (connection); - g_assert (s_con); + if (!NM_DEVICE_CLASS (nm_device_generic_parent_class)->connection_compatible (device, connection, error)) + return FALSE; - ctype = nm_setting_connection_get_connection_type (s_con); - if (strcmp (ctype, NM_SETTING_GENERIC_SETTING_NAME) != 0) { - g_set_error (error, NM_DEVICE_GENERIC_ERROR, NM_DEVICE_GENERIC_ERROR_NOT_GENERIC_CONNECTION, - "The connection was not a generic connection."); + if (!nm_connection_is_type (connection, NM_SETTING_GENERIC_SETTING_NAME)) { + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The connection was not a generic connection.")); return FALSE; } - iface_name = nm_setting_connection_get_interface_name (s_con); + iface_name = nm_connection_get_interface_name (connection); if (!iface_name) { - g_set_error (error, NM_DEVICE_GENERIC_ERROR, NM_DEVICE_GENERIC_ERROR_MISSING_INTERFACE_NAME, - "The connection did not specify an interface name."); + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION, + _("The connection did not specify an interface name.")); return FALSE; } - return NM_DEVICE_CLASS (nm_device_generic_parent_class)->connection_compatible (device, connection, error); + return TRUE; } static GType diff --git a/libnm/nm-device-generic.h b/libnm/nm-device-generic.h index be0d932d93..457a88403e 100644 --- a/libnm/nm-device-generic.h +++ b/libnm/nm-device-generic.h @@ -36,21 +36,6 @@ G_BEGIN_DECLS #define NM_IS_DEVICE_GENERIC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_GENERIC)) #define NM_DEVICE_GENERIC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_GENERIC, NMDeviceGenericClass)) -/** - * NMDeviceGenericError: - * @NM_DEVICE_GENERIC_ERROR_UNKNOWN: unknown or unclassified error - * @NM_DEVICE_GENERIC_ERROR_NOT_GENERIC_CONNECTION: the connection was not of generic type - * @NM_DEVICE_GENERIC_ERROR_MISSING_INTERFACE_NAME: the connection did not specify the interface name - */ -typedef enum { - NM_DEVICE_GENERIC_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_DEVICE_GENERIC_ERROR_NOT_GENERIC_CONNECTION, /*< nick=NotGenericConnection >*/ - NM_DEVICE_GENERIC_ERROR_MISSING_INTERFACE_NAME, /*< nick=MissingInterfaceName >*/ -} NMDeviceGenericError; - -#define NM_DEVICE_GENERIC_ERROR nm_device_generic_error_quark () -GQuark nm_device_generic_error_quark (void); - #define NM_DEVICE_GENERIC_HW_ADDRESS "hw-address" #define NM_DEVICE_GENERIC_TYPE_DESCRIPTION "type-description" diff --git a/libnm/nm-device-infiniband.c b/libnm/nm-device-infiniband.c index 10ee1140d4..1409e0b298 100644 --- a/libnm/nm-device-infiniband.c +++ b/libnm/nm-device-infiniband.c @@ -20,6 +20,7 @@ #include <config.h> #include <string.h> +#include <glib/gi18n.h> #include "nm-glib-compat.h" @@ -49,23 +50,6 @@ enum { }; /** - * nm_device_infiniband_error_quark: - * - * Registers an error quark for #NMDeviceInfiniband if necessary. - * - * Returns: the error quark used for #NMDeviceInfiniband errors. - **/ -GQuark -nm_device_infiniband_error_quark (void) -{ - static GQuark quark = 0; - - if (G_UNLIKELY (quark == 0)) - quark = g_quark_from_static_string ("nm-device-infiniband-error-quark"); - return quark; -} - -/** * nm_device_infiniband_get_hw_address: * @device: a #NMDeviceInfiniband * @@ -101,44 +85,36 @@ nm_device_infiniband_get_carrier (NMDeviceInfiniband *device) static gboolean connection_compatible (NMDevice *device, NMConnection *connection, GError **error) { - NMSettingConnection *s_con; NMSettingInfiniband *s_infiniband; - const char *ctype, *hwaddr, *setting_hwaddr; + const char *hwaddr, *setting_hwaddr; - s_con = nm_connection_get_setting_connection (connection); - g_assert (s_con); - - ctype = nm_setting_connection_get_connection_type (s_con); - if (strcmp (ctype, NM_SETTING_INFINIBAND_SETTING_NAME) != 0) { - g_set_error (error, NM_DEVICE_INFINIBAND_ERROR, NM_DEVICE_INFINIBAND_ERROR_NOT_INFINIBAND_CONNECTION, - "The connection was not a InfiniBand connection."); + if (!NM_DEVICE_CLASS (nm_device_infiniband_parent_class)->connection_compatible (device, connection, error)) return FALSE; - } - s_infiniband = nm_connection_get_setting_infiniband (connection); - if (!s_infiniband) { - g_set_error (error, NM_DEVICE_INFINIBAND_ERROR, NM_DEVICE_INFINIBAND_ERROR_INVALID_INFINIBAND_CONNECTION, - "The connection was not a valid InfiniBand connection."); + if (!nm_connection_is_type (connection, NM_SETTING_INFINIBAND_SETTING_NAME)) { + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The connection was not an InfiniBand connection.")); return FALSE; } hwaddr = nm_device_infiniband_get_hw_address (NM_DEVICE_INFINIBAND (device)); if (hwaddr) { if (!nm_utils_hwaddr_valid (hwaddr, INFINIBAND_ALEN)) { - g_set_error (error, NM_DEVICE_INFINIBAND_ERROR, NM_DEVICE_INFINIBAND_ERROR_INVALID_DEVICE_MAC, - "Invalid device MAC address."); + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, + _("Invalid device MAC address.")); return FALSE; } + s_infiniband = nm_connection_get_setting_infiniband (connection); setting_hwaddr = nm_setting_infiniband_get_mac_address (s_infiniband); if (setting_hwaddr && !nm_utils_hwaddr_matches (setting_hwaddr, -1, hwaddr, -1)) { - g_set_error (error, NM_DEVICE_INFINIBAND_ERROR, NM_DEVICE_INFINIBAND_ERROR_MAC_MISMATCH, - "The MACs of the device and the connection didn't match."); + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The MACs of the device and the connection didn't match.")); return FALSE; } } - return NM_DEVICE_CLASS (nm_device_infiniband_parent_class)->connection_compatible (device, connection, error); + return TRUE; } static GType diff --git a/libnm/nm-device-infiniband.h b/libnm/nm-device-infiniband.h index ac15410afa..c1f9be073f 100644 --- a/libnm/nm-device-infiniband.h +++ b/libnm/nm-device-infiniband.h @@ -36,25 +36,6 @@ G_BEGIN_DECLS #define NM_IS_DEVICE_INFINIBAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_INFINIBAND)) #define NM_DEVICE_INFINIBAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_INFINIBAND, NMDeviceInfinibandClass)) -/** - * NMDeviceInfinibandError: - * @NM_DEVICE_INFINIBAND_ERROR_UNKNOWN: unknown or unclassified error - * @NM_DEVICE_INFINIBAND_ERROR_NOT_INFINIBAND_CONNECTION: the connection was not of InfiniBand type - * @NM_DEVICE_INFINIBAND_ERROR_INVALID_INFINIBAND_CONNECTION: the InfiniBand connection was invalid - * @NM_DEVICE_INFINIBAND_ERROR_INVALID_DEVICE_MAC: the device's MAC was invalid - * @NM_DEVICE_INFINIBAND_ERROR_MAC_MISMATCH: the MACs of the connection and the device mismatched - */ -typedef enum { - NM_DEVICE_INFINIBAND_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_DEVICE_INFINIBAND_ERROR_NOT_INFINIBAND_CONNECTION, /*< nick=NotInfinibandConnection >*/ - NM_DEVICE_INFINIBAND_ERROR_INVALID_INFINIBAND_CONNECTION, /*< nick=InvalidInfinibandConnection >*/ - NM_DEVICE_INFINIBAND_ERROR_INVALID_DEVICE_MAC, /*< nick=InvalidDeviceMac >*/ - NM_DEVICE_INFINIBAND_ERROR_MAC_MISMATCH, /*< nick=MacMismatch >*/ -} NMDeviceInfinibandError; - -#define NM_DEVICE_INFINIBAND_ERROR nm_device_infiniband_error_quark () -GQuark nm_device_infiniband_error_quark (void); - #define NM_DEVICE_INFINIBAND_HW_ADDRESS "hw-address" #define NM_DEVICE_INFINIBAND_CARRIER "carrier" diff --git a/libnm/nm-device-modem.c b/libnm/nm-device-modem.c index 1f8a91406a..25c63f753e 100644 --- a/libnm/nm-device-modem.c +++ b/libnm/nm-device-modem.c @@ -21,6 +21,7 @@ #include <config.h> #include <string.h> +#include <glib/gi18n.h> #include "nm-glib-compat.h" @@ -50,23 +51,6 @@ enum { }; /** - * nm_device_modem_error_quark: - * - * Registers an error quark for #NMDeviceModem if necessary. - * - * Returns: the error quark used for #NMDeviceModem errors. - **/ -GQuark -nm_device_modem_error_quark (void) -{ - static GQuark quark = 0; - - if (G_UNLIKELY (quark == 0)) - quark = g_quark_from_static_string ("nm-device-modem-error-quark"); - return quark; -} - -/** * nm_device_modem_get_modem_capabilities: * @self: a #NMDeviceModem * @@ -125,39 +109,36 @@ get_type_description (NMDevice *device) static gboolean connection_compatible (NMDevice *device, NMConnection *connection, GError **error) { - NMSettingConnection *s_con; NMSettingGsm *s_gsm; NMSettingCdma *s_cdma; - const char *ctype; NMDeviceModemCapabilities current_caps; - s_con = nm_connection_get_setting_connection (connection); - g_assert (s_con); + if (!NM_DEVICE_CLASS (nm_device_modem_parent_class)->connection_compatible (device, connection, error)) + return FALSE; - ctype = nm_setting_connection_get_connection_type (s_con); - if ( strcmp (ctype, NM_SETTING_GSM_SETTING_NAME) != 0 - && strcmp (ctype, NM_SETTING_CDMA_SETTING_NAME) != 0) { - g_set_error (error, NM_DEVICE_MODEM_ERROR, NM_DEVICE_MODEM_ERROR_NOT_MODEM_CONNECTION, - "The connection was not a modem connection."); + if ( !nm_connection_is_type (connection, NM_SETTING_GSM_SETTING_NAME) + && !nm_connection_is_type (connection, NM_SETTING_CDMA_SETTING_NAME)) { + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The connection was not a modem connection.")); return FALSE; } s_gsm = nm_connection_get_setting_gsm (connection); s_cdma = nm_connection_get_setting_cdma (connection); if (!s_cdma && !s_gsm) { - g_set_error (error, NM_DEVICE_MODEM_ERROR, NM_DEVICE_MODEM_ERROR_INVALID_MODEM_CONNECTION, - "The connection was not a valid modem connection."); + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION, + _("The connection was not a valid modem connection.")); return FALSE; } current_caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device)); if (!(s_gsm && MODEM_CAPS_3GPP (current_caps)) && !(s_cdma && MODEM_CAPS_3GPP2 (current_caps))) { - g_set_error (error, NM_DEVICE_MODEM_ERROR, NM_DEVICE_MODEM_ERROR_MISSING_DEVICE_CAPS, - "The device missed capabilities required by the GSM/CDMA connection."); + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The device is lacking capabilities required by the connection.")); return FALSE; } - return NM_DEVICE_CLASS (nm_device_modem_parent_class)->connection_compatible (device, connection, error); + return TRUE; } static GType diff --git a/libnm/nm-device-modem.h b/libnm/nm-device-modem.h index dd5b2656ea..38a4ddbb73 100644 --- a/libnm/nm-device-modem.h +++ b/libnm/nm-device-modem.h @@ -37,23 +37,6 @@ G_BEGIN_DECLS #define NM_IS_DEVICE_MODEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_MODEM)) #define NM_DEVICE_MODEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_MODEM, NMDeviceModemClass)) -/** - * NMDeviceModemError: - * @NM_DEVICE_MODEM_ERROR_UNKNOWN: unknown or unclassified error - * @NM_DEVICE_MODEM_ERROR_NOT_MODEM_CONNECTION: the connection was not of modem type - * @NM_DEVICE_MODEM_ERROR_INVALID_MODEM_CONNECTION: the modem connection was invalid - * @NM_DEVICE_MODEM_ERROR_MISSING_DEVICE_CAPS: the device missed required capabilities - */ -typedef enum { - NM_DEVICE_MODEM_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_DEVICE_MODEM_ERROR_NOT_MODEM_CONNECTION, /*< nick=NotModemConnection >*/ - NM_DEVICE_MODEM_ERROR_INVALID_MODEM_CONNECTION, /*< nick=InvalidModemConnection >*/ - NM_DEVICE_MODEM_ERROR_MISSING_DEVICE_CAPS, /*< nick=MissingDeviceCaps >*/ -} NMDeviceModemError; - -#define NM_DEVICE_MODEM_ERROR nm_device_modem_error_quark () -GQuark nm_device_modem_error_quark (void); - #define NM_DEVICE_MODEM_MODEM_CAPABILITIES "modem-capabilities" #define NM_DEVICE_MODEM_CURRENT_CAPABILITIES "current-capabilities" diff --git a/libnm/nm-device-olpc-mesh.c b/libnm/nm-device-olpc-mesh.c index ba139a2d43..6b5df27ca8 100644 --- a/libnm/nm-device-olpc-mesh.c +++ b/libnm/nm-device-olpc-mesh.c @@ -20,6 +20,7 @@ #include <config.h> #include <string.h> +#include <glib/gi18n.h> #include "nm-glib-compat.h" @@ -51,23 +52,6 @@ enum { }; /** - * nm_device_olpc_mesh_error_quark: - * - * Registers an error quark for #NMDeviceOlpcMesh if necessary. - * - * Returns: the error quark used for #NMDeviceOlpcMesh errors. - **/ -GQuark -nm_device_olpc_mesh_error_quark (void) -{ - static GQuark quark = 0; - - if (G_UNLIKELY (quark == 0)) - quark = g_quark_from_static_string ("nm-device-olpc-mesh-error-quark"); - return quark; -} - -/** * nm_device_olpc_mesh_get_hw_address: * @device: a #NMDeviceOlpcMesh * @@ -125,28 +109,16 @@ get_hw_address (NMDevice *device) static gboolean connection_compatible (NMDevice *device, NMConnection *connection, GError **error) { - NMSettingConnection *s_con; - NMSettingOlpcMesh *s_olpc_mesh; - const char *ctype; - - s_con = nm_connection_get_setting_connection (connection); - g_assert (s_con); - - ctype = nm_setting_connection_get_connection_type (s_con); - if (strcmp (ctype, NM_SETTING_OLPC_MESH_SETTING_NAME) != 0) { - g_set_error (error, NM_DEVICE_OLPC_MESH_ERROR, NM_DEVICE_OLPC_MESH_ERROR_NOT_OLPC_MESH_CONNECTION, - "The connection was not a Olpc Mesh connection."); + if (!NM_DEVICE_CLASS (nm_device_olpc_mesh_parent_class)->connection_compatible (device, connection, error)) return FALSE; - } - s_olpc_mesh = nm_connection_get_setting_olpc_mesh (connection); - if (!s_olpc_mesh) { - g_set_error (error, NM_DEVICE_OLPC_MESH_ERROR, NM_DEVICE_OLPC_MESH_ERROR_INVALID_OLPC_MESH_CONNECTION, - "The connection was not a valid Olpc Mesh connection."); + if (!nm_connection_is_type (connection, NM_SETTING_OLPC_MESH_SETTING_NAME)) { + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The connection was not an OLPC Mesh connection.")); return FALSE; } - return NM_DEVICE_CLASS (nm_device_olpc_mesh_parent_class)->connection_compatible (device, connection, error); + return TRUE; } static GType diff --git a/libnm/nm-device-olpc-mesh.h b/libnm/nm-device-olpc-mesh.h index c1bb7a9e28..b58994456c 100644 --- a/libnm/nm-device-olpc-mesh.h +++ b/libnm/nm-device-olpc-mesh.h @@ -36,21 +36,6 @@ G_BEGIN_DECLS #define NM_IS_DEVICE_OLPC_MESH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_OLPC_MESH)) #define NM_DEVICE_OLPC_MESH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_OLPC_MESH, NMDeviceOlpcMeshClass)) -/** - * NMDeviceOlpcMeshError: - * @NM_DEVICE_OLPC_MESH_ERROR_UNKNOWN: unknown or unclassified error - * @NM_DEVICE_OLPC_MESH_ERROR_NOT_OLPC_MESH_CONNECTION: the connection was not of Olpc Mesh type - * @NM_DEVICE_OLPC_MESH_ERROR_INVALID_OLPC_MESH_CONNECTION: the Olpc Mesh connection was invalid - */ -typedef enum { - NM_DEVICE_OLPC_MESH_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_DEVICE_OLPC_MESH_ERROR_NOT_OLPC_MESH_CONNECTION, /*< nick=NotOlpcMeshConnection >*/ - NM_DEVICE_OLPC_MESH_ERROR_INVALID_OLPC_MESH_CONNECTION, /*< nick=InvalidOlpcMeshConnection >*/ -} NMDeviceOlpcMeshError; - -#define NM_DEVICE_OLPC_MESH_ERROR nm_device_olpc_mesh_error_quark () -GQuark nm_device_olpc_mesh_error_quark (void); - #define NM_DEVICE_OLPC_MESH_HW_ADDRESS "hw-address" #define NM_DEVICE_OLPC_MESH_COMPANION "companion" #define NM_DEVICE_OLPC_MESH_ACTIVE_CHANNEL "active-channel" diff --git a/libnm/nm-device-team.c b/libnm/nm-device-team.c index ce7a82f9cd..d76baf22a6 100644 --- a/libnm/nm-device-team.c +++ b/libnm/nm-device-team.c @@ -20,6 +20,7 @@ #include <config.h> #include <string.h> +#include <glib/gi18n.h> #include "nm-glib-compat.h" @@ -52,23 +53,6 @@ enum { }; /** - * nm_device_team_error_quark: - * - * Registers an error quark for #NMDeviceTeam if necessary. - * - * Returns: the error quark used for #NMDeviceTeam errors. - **/ -GQuark -nm_device_team_error_quark (void) -{ - static GQuark quark = 0; - - if (G_UNLIKELY (quark == 0)) - quark = g_quark_from_static_string ("nm-device-team-error-quark"); - return quark; -} - -/** * nm_device_team_get_hw_address: * @device: a #NMDeviceTeam * @@ -128,38 +112,18 @@ get_hw_address (NMDevice *device) static gboolean connection_compatible (NMDevice *device, NMConnection *connection, GError **error) { - NMSettingConnection *s_con; - NMSettingTeam *s_team; - const char *ctype, *dev_iface_name, *team_iface_name; - - s_con = nm_connection_get_setting_connection (connection); - g_assert (s_con); - - ctype = nm_setting_connection_get_connection_type (s_con); - if (strcmp (ctype, NM_SETTING_TEAM_SETTING_NAME) != 0) { - g_set_error (error, NM_DEVICE_TEAM_ERROR, NM_DEVICE_TEAM_ERROR_NOT_TEAM_CONNECTION, - "The connection was not a team connection."); + if (!NM_DEVICE_CLASS (nm_device_team_parent_class)->connection_compatible (device, connection, error)) return FALSE; - } - - s_team = nm_connection_get_setting_team (connection); - if (!s_team) { - g_set_error (error, NM_DEVICE_TEAM_ERROR, NM_DEVICE_TEAM_ERROR_INVALID_TEAM_CONNECTION, - "The connection was not a valid team connection."); - return FALSE; - } - dev_iface_name = nm_device_get_iface (device); - team_iface_name = nm_setting_connection_get_interface_name (s_con); - if (g_strcmp0 (dev_iface_name, team_iface_name) != 0) { - g_set_error (error, NM_DEVICE_TEAM_ERROR, NM_DEVICE_TEAM_ERROR_INTERFACE_MISMATCH, - "The interfaces of the device and the connection didn't match."); + if (!nm_connection_is_type (connection, NM_SETTING_TEAM_SETTING_NAME)) { + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION, + _("The connection was not a team connection.")); return FALSE; } /* FIXME: check slaves? */ - return NM_DEVICE_CLASS (nm_device_team_parent_class)->connection_compatible (device, connection, error); + return TRUE; } static GType diff --git a/libnm/nm-device-team.h b/libnm/nm-device-team.h index f8b9548b00..a718579581 100644 --- a/libnm/nm-device-team.h +++ b/libnm/nm-device-team.h @@ -36,23 +36,6 @@ G_BEGIN_DECLS #define NM_IS_DEVICE_TEAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_TEAM)) #define NM_DEVICE_TEAM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_TEAM, NMDeviceTeamClass)) -/** - * NMDeviceTeamError: - * @NM_DEVICE_TEAM_ERROR_UNKNOWN: unknown or unclassified error - * @NM_DEVICE_TEAM_ERROR_NOT_TEAM_CONNECTION: the connection was not of team type - * @NM_DEVICE_TEAM_ERROR_INVALID_TEAM_CONNECTION: the team connection was invalid - * @NM_DEVICE_TEAM_ERROR_INTERFACE_MISMATCH: the interfaces of the connection and the device mismatched - */ -typedef enum { - NM_DEVICE_TEAM_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_DEVICE_TEAM_ERROR_NOT_TEAM_CONNECTION, /*< nick=NotTeamConnection >*/ - NM_DEVICE_TEAM_ERROR_INVALID_TEAM_CONNECTION, /*< nick=InvalidTeamConnection >*/ - NM_DEVICE_TEAM_ERROR_INTERFACE_MISMATCH, /*< nick=InterfaceMismatch >*/ -} NMDeviceTeamError; - -#define NM_DEVICE_TEAM_ERROR nm_device_team_error_quark () -GQuark nm_device_team_error_quark (void); - #define NM_DEVICE_TEAM_HW_ADDRESS "hw-address" #define NM_DEVICE_TEAM_CARRIER "carrier" #define NM_DEVICE_TEAM_SLAVES "slaves" diff --git a/libnm/nm-device-vlan.c b/libnm/nm-device-vlan.c index 9cb9d9fde1..9796c4523d 100644 --- a/libnm/nm-device-vlan.c +++ b/libnm/nm-device-vlan.c @@ -20,6 +20,7 @@ #include <config.h> #include <string.h> +#include <glib/gi18n.h> #include "nm-glib-compat.h" @@ -51,23 +52,6 @@ enum { }; /** - * nm_device_vlan_error_quark: - * - * Registers an error quark for #NMDeviceVlan if necessary. - * - * Returns: the error quark used for #NMDeviceVlan errors. - **/ -GQuark -nm_device_vlan_error_quark (void) -{ - static GQuark quark = 0; - - if (G_UNLIKELY (quark == 0)) - quark = g_quark_from_static_string ("nm-device-vlan-error-quark"); - return quark; -} - -/** * nm_device_vlan_get_hw_address: * @device: a #NMDeviceVlan * @@ -117,40 +101,23 @@ nm_device_vlan_get_vlan_id (NMDeviceVlan *device) static gboolean connection_compatible (NMDevice *device, NMConnection *connection, GError **error) { - NMSettingConnection *s_con; NMSettingVlan *s_vlan; NMSettingWired *s_wired; - const char *ctype, *dev_iface_name, *vlan_iface_name; const char *setting_hwaddr; - s_con = nm_connection_get_setting_connection (connection); - g_assert (s_con); - - ctype = nm_setting_connection_get_connection_type (s_con); - if (strcmp (ctype, NM_SETTING_VLAN_SETTING_NAME) != 0) { - g_set_error (error, NM_DEVICE_VLAN_ERROR, NM_DEVICE_VLAN_ERROR_NOT_VLAN_CONNECTION, - "The connection was not a VLAN connection."); + if (!NM_DEVICE_CLASS (nm_device_vlan_parent_class)->connection_compatible (device, connection, error)) return FALSE; - } - s_vlan = nm_connection_get_setting_vlan (connection); - if (!s_vlan) { - g_set_error (error, NM_DEVICE_VLAN_ERROR, NM_DEVICE_VLAN_ERROR_INVALID_VLAN_CONNECTION, - "The connection was not a valid VLAN connection."); + if (!nm_connection_is_type (connection, NM_SETTING_VLAN_SETTING_NAME)) { + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The connection was not a VLAN connection.")); return FALSE; } + s_vlan = nm_connection_get_setting_vlan (connection); if (nm_setting_vlan_get_id (s_vlan) != nm_device_vlan_get_vlan_id (NM_DEVICE_VLAN (device))) { - g_set_error (error, NM_DEVICE_VLAN_ERROR, NM_DEVICE_VLAN_ERROR_ID_MISMATCH, - "The VLAN identifiers of the device and the connection didn't match."); - return FALSE; - } - - dev_iface_name = nm_device_get_iface (device); - vlan_iface_name = nm_setting_connection_get_interface_name (s_con); - if (vlan_iface_name && g_strcmp0 (dev_iface_name, vlan_iface_name) != 0) { - g_set_error (error, NM_DEVICE_VLAN_ERROR, NM_DEVICE_VLAN_ERROR_INTERFACE_MISMATCH, - "The interfaces of the device and the connection didn't match."); + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The VLAN identifiers of the device and the connection didn't match.")); return FALSE; } @@ -161,13 +128,13 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro setting_hwaddr = NULL; if (setting_hwaddr) { if (!nm_utils_hwaddr_matches (setting_hwaddr, -1, - NM_DEVICE_VLAN_GET_PRIVATE (device)->hw_address, -1)) { - g_set_error (error, NM_DEVICE_VLAN_ERROR, NM_DEVICE_VLAN_ERROR_MAC_MISMATCH, - "The hardware address of the device and the connection didn't match."); + NM_DEVICE_VLAN_GET_PRIVATE (device)->hw_address, -1)) { + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The hardware address of the device and the connection didn't match.")); } } - return NM_DEVICE_CLASS (nm_device_vlan_parent_class)->connection_compatible (device, connection, error); + return TRUE; } static GType diff --git a/libnm/nm-device-vlan.h b/libnm/nm-device-vlan.h index 379364beba..824944f743 100644 --- a/libnm/nm-device-vlan.h +++ b/libnm/nm-device-vlan.h @@ -36,27 +36,6 @@ G_BEGIN_DECLS #define NM_IS_DEVICE_VLAN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_VLAN)) #define NM_DEVICE_VLAN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_VLAN, NMDeviceVlanClass)) -/** - * NMDeviceVlanError: - * @NM_DEVICE_VLAN_ERROR_UNKNOWN: unknown or unclassified error - * @NM_DEVICE_VLAN_ERROR_NOT_VLAN_CONNECTION: the connection was not of VLAN type - * @NM_DEVICE_VLAN_ERROR_INVALID_VLAN_CONNECTION: the VLAN connection was invalid - * @NM_DEVICE_VLAN_ERROR_ID_MISMATCH: the VLAN identifiers of the connection and the device mismatched - * @NM_DEVICE_VLAN_ERROR_INTERFACE_MISMATCH: the interfaces of the connection and the device mismatched - * @NM_DEVICE_VLAN_ERROR_MAC_MISMATCH: the MACs of the connection and the device mismatched - */ -typedef enum { - NM_DEVICE_VLAN_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_DEVICE_VLAN_ERROR_NOT_VLAN_CONNECTION, /*< nick=NotVlanConnection >*/ - NM_DEVICE_VLAN_ERROR_INVALID_VLAN_CONNECTION, /*< nick=InvalidVlanConnection >*/ - NM_DEVICE_VLAN_ERROR_ID_MISMATCH, /*< nick=IdMismatch >*/ - NM_DEVICE_VLAN_ERROR_INTERFACE_MISMATCH, /*< nick=InterfaceMismatch >*/ - NM_DEVICE_VLAN_ERROR_MAC_MISMATCH, /*< nick=MacMismatch >*/ -} NMDeviceVlanError; - -#define NM_DEVICE_VLAN_ERROR nm_device_vlan_error_quark () -GQuark nm_device_vlan_error_quark (void); - #define NM_DEVICE_VLAN_HW_ADDRESS "hw-address" #define NM_DEVICE_VLAN_CARRIER "carrier" #define NM_DEVICE_VLAN_VLAN_ID "vlan-id" diff --git a/libnm/nm-device-wifi.c b/libnm/nm-device-wifi.c index f804875719..c57c19c3f9 100644 --- a/libnm/nm-device-wifi.c +++ b/libnm/nm-device-wifi.c @@ -21,6 +21,7 @@ #include <config.h> #include <string.h> +#include <glib/gi18n.h> #include "nm-glib-compat.h" @@ -87,23 +88,6 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; /** - * nm_device_wifi_error_quark: - * - * Registers an error quark for #NMDeviceWifi if necessary. - * - * Returns: the error quark used for #NMDeviceWifi errors. - **/ -GQuark -nm_device_wifi_error_quark (void) -{ - static GQuark quark = 0; - - if (G_UNLIKELY (quark == 0)) - quark = g_quark_from_static_string ("nm-device-wifi-error-quark"); - return quark; -} - -/** * nm_device_wifi_get_hw_address: * @device: a #NMDeviceWifi * @@ -304,12 +288,17 @@ nm_device_wifi_request_scan (NMDeviceWifi *device, GCancellable *cancellable, GError **error) { + gboolean ret; + g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), FALSE); - return nmdbus_device_wifi_call_request_scan_sync (NM_DEVICE_WIFI_GET_PRIVATE (device)->proxy, - g_variant_new_array (G_VARIANT_TYPE ("{sv}"), - NULL, 0), - cancellable, error); + ret = nmdbus_device_wifi_call_request_scan_sync (NM_DEVICE_WIFI_GET_PRIVATE (device)->proxy, + g_variant_new_array (G_VARIANT_TYPE ("{sv}"), + NULL, 0), + cancellable, error); + if (error && *error) + g_dbus_error_strip_remote_error (*error); + return ret; } static void @@ -326,8 +315,10 @@ request_scan_cb (GObject *source, if (nmdbus_device_wifi_call_request_scan_finish (NMDBUS_DEVICE_WIFI (source), result, &error)) g_simple_async_result_set_op_res_gboolean (info->simple, TRUE); - else + else { + g_dbus_error_strip_remote_error (error); g_simple_async_result_take_error (info->simple, error); + } g_simple_async_result_complete (info->simple); g_object_unref (info->simple); @@ -477,28 +468,18 @@ has_proto (NMSettingWirelessSecurity *s_wsec, const char *proto) static gboolean connection_compatible (NMDevice *device, NMConnection *connection, GError **error) { - NMSettingConnection *s_con; NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; - const char *ctype; const char *hwaddr, *setting_hwaddr; NMDeviceWifiCapabilities wifi_caps; const char *key_mgmt; - s_con = nm_connection_get_setting_connection (connection); - g_assert (s_con); - - ctype = nm_setting_connection_get_connection_type (s_con); - if (strcmp (ctype, NM_SETTING_WIRELESS_SETTING_NAME) != 0) { - g_set_error (error, NM_DEVICE_WIFI_ERROR, NM_DEVICE_WIFI_ERROR_NOT_WIFI_CONNECTION, - "The connection was not a Wi-Fi connection."); + if (!NM_DEVICE_CLASS (nm_device_wifi_parent_class)->connection_compatible (device, connection, error)) return FALSE; - } - s_wifi = nm_connection_get_setting_wireless (connection); - if (!s_wifi) { - g_set_error (error, NM_DEVICE_WIFI_ERROR, NM_DEVICE_WIFI_ERROR_INVALID_WIFI_CONNECTION, - "The connection was not a valid Wi-Fi connection."); + if (!nm_connection_is_type (connection, NM_SETTING_WIRELESS_SETTING_NAME)) { + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The connection was not a Wi-Fi connection.")); return FALSE; } @@ -506,20 +487,20 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro hwaddr = nm_device_wifi_get_permanent_hw_address (NM_DEVICE_WIFI (device)); if (hwaddr) { if (!nm_utils_hwaddr_valid (hwaddr, ETH_ALEN)) { - g_set_error (error, NM_DEVICE_WIFI_ERROR, NM_DEVICE_WIFI_ERROR_INVALID_DEVICE_MAC, - "Invalid device MAC address."); + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, + _("Invalid device MAC address.")); return FALSE; } + s_wifi = nm_connection_get_setting_wireless (connection); setting_hwaddr = nm_setting_wireless_get_mac_address (s_wifi); if (setting_hwaddr && !nm_utils_hwaddr_matches (setting_hwaddr, -1, hwaddr, -1)) { - g_set_error (error, NM_DEVICE_WIFI_ERROR, NM_DEVICE_WIFI_ERROR_MAC_MISMATCH, - "The MACs of the device and the connection didn't match."); + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The MACs of the device and the connection didn't match.")); return FALSE; } } /* Check device capabilities; we assume all devices can do WEP at least */ - wifi_caps = nm_device_wifi_get_capabilities (NM_DEVICE_WIFI (device)); s_wsec = nm_connection_get_setting_wireless_security (connection); if (s_wsec) { @@ -529,23 +510,25 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro || !g_strcmp0 (key_mgmt, "wpa-psk") || !g_strcmp0 (key_mgmt, "wpa-eap")) { + wifi_caps = nm_device_wifi_get_capabilities (NM_DEVICE_WIFI (device)); + /* Is device only WEP capable? */ if (!(wifi_caps & WPA_CAPS)) { - g_set_error (error, NM_DEVICE_WIFI_ERROR, NM_DEVICE_WIFI_ERROR_MISSING_DEVICE_WPA_CAPS, - "The device missed WPA capabilities required by the connection."); + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The device is lacking WPA capabilities required by the connection.")); return FALSE; } /* Make sure WPA2/RSN-only connections don't get chosen for WPA-only cards */ if (has_proto (s_wsec, "rsn") && !has_proto (s_wsec, "wpa") && !(wifi_caps & RSN_CAPS)) { - g_set_error (error, NM_DEVICE_WIFI_ERROR, NM_DEVICE_WIFI_ERROR_MISSING_DEVICE_RSN_CAPS, - "The device missed WPA2/RSN capabilities required by the connection."); + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The device is lacking WPA2/RSN capabilities required by the connection.")); return FALSE; } } } - return NM_DEVICE_CLASS (nm_device_wifi_parent_class)->connection_compatible (device, connection, error); + return TRUE; } static GType diff --git a/libnm/nm-device-wifi.h b/libnm/nm-device-wifi.h index 7947f6959f..24339fd3d5 100644 --- a/libnm/nm-device-wifi.h +++ b/libnm/nm-device-wifi.h @@ -37,31 +37,6 @@ G_BEGIN_DECLS #define NM_IS_DEVICE_WIFI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_WIFI)) #define NM_DEVICE_WIFI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_WIFI, NMDeviceWifiClass)) -/** - * NMDeviceWifiError: - * @NM_DEVICE_WIFI_ERROR_UNKNOWN: unknown or unclassified error - * @NM_DEVICE_WIFI_ERROR_NOT_WIFI_CONNECTION: the connection was not of Wi-Fi type - * @NM_DEVICE_WIFI_ERROR_INVALID_WIFI_CONNECTION: the Wi-Fi connection was invalid - * @NM_DEVICE_WIFI_ERROR_INVALID_DEVICE_MAC: the device's MAC was invalid - * @NM_DEVICE_WIFI_ERROR_MAC_MISMATCH: the MACs of the connection and the device mismatched - * @NM_DEVICE_WIFI_ERROR_MISSING_DEVICE_WPA_CAPS: the device missed WPA capabilities - * required by the connection - * @NM_DEVICE_WIFI_ERROR_MISSING_DEVICE_RSN_CAPS: the device missed RSN capabilities - * required by the connection - */ -typedef enum { - NM_DEVICE_WIFI_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_DEVICE_WIFI_ERROR_NOT_WIFI_CONNECTION, /*< nick=NotWifiConnection >*/ - NM_DEVICE_WIFI_ERROR_INVALID_WIFI_CONNECTION, /*< nick=InvalidWifiConnection >*/ - NM_DEVICE_WIFI_ERROR_INVALID_DEVICE_MAC, /*< nick=InvalidDeviceMac >*/ - NM_DEVICE_WIFI_ERROR_MAC_MISMATCH, /*< nick=MacMismatch >*/ - NM_DEVICE_WIFI_ERROR_MISSING_DEVICE_WPA_CAPS, /*< nick=MissingDeviceWpaCaps >*/ - NM_DEVICE_WIFI_ERROR_MISSING_DEVICE_RSN_CAPS, /*< nick=MissingDeviceRsnCaps >*/ -} NMDeviceWifiError; - -#define NM_DEVICE_WIFI_ERROR nm_device_wifi_error_quark () -GQuark nm_device_wifi_error_quark (void); - #define NM_DEVICE_WIFI_HW_ADDRESS "hw-address" #define NM_DEVICE_WIFI_PERMANENT_HW_ADDRESS "perm-hw-address" #define NM_DEVICE_WIFI_MODE "mode" diff --git a/libnm/nm-device-wimax.c b/libnm/nm-device-wimax.c index dfb6fbe53d..13097198c3 100644 --- a/libnm/nm-device-wimax.c +++ b/libnm/nm-device-wimax.c @@ -21,6 +21,7 @@ #include <config.h> #include <string.h> +#include <glib/gi18n.h> #include "nm-glib-compat.h" @@ -77,23 +78,6 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; /** - * nm_device_wimax_error_quark: - * - * Registers an error quark for #NMDeviceWimax if necessary. - * - * Returns: the error quark used for #NMDeviceWimax errors. - **/ -GQuark -nm_device_wimax_error_quark (void) -{ - static GQuark quark = 0; - - if (G_UNLIKELY (quark == 0)) - quark = g_quark_from_static_string ("nm-device-wimax-error-quark"); - return quark; -} - -/** * nm_device_wimax_get_hw_address: * @wimax: a #NMDeviceWimax * @@ -306,25 +290,15 @@ nm_device_wimax_get_bsid (NMDeviceWimax *self) static gboolean connection_compatible (NMDevice *device, NMConnection *connection, GError **error) { - NMSettingConnection *s_con; NMSettingWimax *s_wimax; - const char *ctype; const char *hwaddr, *setting_hwaddr; - s_con = nm_connection_get_setting_connection (connection); - g_assert (s_con); - - ctype = nm_setting_connection_get_connection_type (s_con); - if (strcmp (ctype, NM_SETTING_WIMAX_SETTING_NAME) != 0) { - g_set_error (error, NM_DEVICE_WIMAX_ERROR, NM_DEVICE_WIMAX_ERROR_NOT_WIMAX_CONNECTION, - "The connection was not a Wimax connection."); + if (!NM_DEVICE_CLASS (nm_device_wimax_parent_class)->connection_compatible (device, connection, error)) return FALSE; - } - s_wimax = nm_connection_get_setting_wimax (connection); - if (!s_wimax) { - g_set_error (error, NM_DEVICE_WIMAX_ERROR, NM_DEVICE_WIMAX_ERROR_INVALID_WIMAX_CONNECTION, - "The connection was not a valid Wimax connection."); + if (!nm_connection_is_type (connection, NM_SETTING_WIMAX_SETTING_NAME)) { + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The connection was not a WiMAX connection.")); return FALSE; } @@ -332,19 +306,20 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro hwaddr = nm_device_wimax_get_hw_address (NM_DEVICE_WIMAX (device)); if (hwaddr) { if (!nm_utils_hwaddr_valid (hwaddr, ETH_ALEN)) { - g_set_error (error, NM_DEVICE_WIMAX_ERROR, NM_DEVICE_WIMAX_ERROR_INVALID_DEVICE_MAC, - "Invalid device MAC address."); + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, + _("Invalid device MAC address.")); return FALSE; } + s_wimax = nm_connection_get_setting_wimax (connection); setting_hwaddr = nm_setting_wimax_get_mac_address (s_wimax); if (setting_hwaddr && !nm_utils_hwaddr_matches (setting_hwaddr, -1, hwaddr, -1)) { - g_set_error (error, NM_DEVICE_WIMAX_ERROR, NM_DEVICE_WIMAX_ERROR_MAC_MISMATCH, - "The MACs of the device and the connection didn't match."); + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The MACs of the device and the connection didn't match.")); return FALSE; } } - return NM_DEVICE_CLASS (nm_device_wimax_parent_class)->connection_compatible (device, connection, error); + return TRUE; } static GType diff --git a/libnm/nm-device-wimax.h b/libnm/nm-device-wimax.h index ea76547b15..60910984c1 100644 --- a/libnm/nm-device-wimax.h +++ b/libnm/nm-device-wimax.h @@ -37,25 +37,6 @@ G_BEGIN_DECLS #define NM_IS_DEVICE_WIMAX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_WIMAX)) #define NM_DEVICE_WIMAX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_WIMAX, NMDeviceWimaxClass)) -/** - * NMDeviceWimaxError: - * @NM_DEVICE_WIMAX_ERROR_UNKNOWN: unknown or unclassified error - * @NM_DEVICE_WIMAX_ERROR_NOT_WIMAX_CONNECTION: the connection was not of WiMax type - * @NM_DEVICE_WIMAX_ERROR_INVALID_WIMAX_CONNECTION: the WiMax connection was invalid - * @NM_DEVICE_WIMAX_ERROR_INVALID_DEVICE_MAC: the device's MAC was invalid - * @NM_DEVICE_WIMAX_ERROR_MAC_MISMATCH: the MACs of the connection and the device mismatched - */ -typedef enum { - NM_DEVICE_WIMAX_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_DEVICE_WIMAX_ERROR_NOT_WIMAX_CONNECTION, /*< nick=NotWimaxConnection >*/ - NM_DEVICE_WIMAX_ERROR_INVALID_WIMAX_CONNECTION, /*< nick=InvalidWimaxConnection >*/ - NM_DEVICE_WIMAX_ERROR_INVALID_DEVICE_MAC, /*< nick=InvalidDeviceMac >*/ - NM_DEVICE_WIMAX_ERROR_MAC_MISMATCH, /*< nick=MacMismatch >*/ -} NMDeviceWimaxError; - -#define NM_DEVICE_WIMAX_ERROR nm_device_wimax_error_quark () -GQuark nm_device_wimax_error_quark (void); - #define NM_DEVICE_WIMAX_HW_ADDRESS "hw-address" #define NM_DEVICE_WIMAX_ACTIVE_NSP "active-nsp" #define NM_DEVICE_WIMAX_CENTER_FREQUENCY "center-frequency" diff --git a/libnm/nm-device.c b/libnm/nm-device.c index e1cadb1ae8..bf7cbe9357 100644 --- a/libnm/nm-device.c +++ b/libnm/nm-device.c @@ -139,23 +139,6 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; -/** - * nm_device_error_quark: - * - * Registers an error quark for #NMDevice if necessary. - * - * Returns: the error quark used for #NMDevice errors. - **/ -GQuark -nm_device_error_quark (void) -{ - static GQuark quark = 0; - - if (G_UNLIKELY (quark == 0)) - quark = g_quark_from_static_string ("nm-device-error-quark"); - return quark; -} - static void nm_device_init (NMDevice *device) { @@ -1917,10 +1900,15 @@ nm_device_disconnect (NMDevice *device, GCancellable *cancellable, GError **error) { + gboolean ret; + g_return_val_if_fail (NM_IS_DEVICE (device), FALSE); - return nmdbus_device_call_disconnect_sync (NM_DEVICE_GET_PRIVATE (device)->proxy, - cancellable, error); + ret = nmdbus_device_call_disconnect_sync (NM_DEVICE_GET_PRIVATE (device)->proxy, + cancellable, error); + if (error && *error) + g_dbus_error_strip_remote_error (*error); + return ret; } static void @@ -1933,8 +1921,10 @@ device_disconnect_cb (GObject *proxy, if (nmdbus_device_call_disconnect_finish (NMDBUS_DEVICE (proxy), result, &error)) g_simple_async_result_set_op_res_gboolean (simple, TRUE); - else + else { + g_dbus_error_strip_remote_error (error); g_simple_async_result_take_error (simple, error); + } g_simple_async_result_complete (simple); g_object_unref (simple); @@ -2012,10 +2002,15 @@ nm_device_delete (NMDevice *device, GCancellable *cancellable, GError **error) { + gboolean ret; + g_return_val_if_fail (NM_IS_DEVICE (device), FALSE); - return nmdbus_device_call_delete_sync (NM_DEVICE_GET_PRIVATE (device)->proxy, - cancellable, error); + ret = nmdbus_device_call_delete_sync (NM_DEVICE_GET_PRIVATE (device)->proxy, + cancellable, error); + if (error && *error) + g_dbus_error_strip_remote_error (*error); + return ret; } static void @@ -2028,8 +2023,10 @@ device_delete_cb (GObject *proxy, if (nmdbus_device_call_delete_finish (NMDBUS_DEVICE (proxy), result, &error)) g_simple_async_result_set_op_res_gboolean (simple, TRUE); - else + else { + g_dbus_error_strip_remote_error (error); g_simple_async_result_take_error (simple, error); + } g_simple_async_result_complete (simple); g_object_unref (simple); @@ -2115,17 +2112,21 @@ nm_device_connection_valid (NMDevice *device, NMConnection *connection) gboolean connection_compatible (NMDevice *device, NMConnection *connection, GError **error) { - NMSettingConnection *s_con; const char *config_iface, *device_iface; + GError *local = NULL; - s_con = nm_connection_get_setting_connection (connection); - g_assert (s_con); + if (!nm_connection_verify (connection, &local)) { + g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION, + _("The connection was not valid: %s"), local->message); + g_error_free (local); + return FALSE; + } - config_iface = nm_setting_connection_get_interface_name (s_con); + config_iface = nm_connection_get_interface_name (connection); device_iface = nm_device_get_iface (device); if (config_iface && g_strcmp0 (config_iface, device_iface) != 0) { - g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INTERFACE_MISMATCH, - "The interface names of the device and the connection didn't match."); + g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The interface names of the device and the connection didn't match.")); return FALSE; } diff --git a/libnm/nm-device.h b/libnm/nm-device.h index 5af1e07b29..cbfe6d4309 100644 --- a/libnm/nm-device.h +++ b/libnm/nm-device.h @@ -37,20 +37,6 @@ G_BEGIN_DECLS #define NM_IS_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE)) #define NM_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE, NMDeviceClass)) -/** - * NMDeviceError: - * @NM_DEVICE_ERROR_UNKNOWN: unknown or unclassified error - * @NM_DEVICE_ERROR_INTERFACE_MISMATCH: the interface names of the connection and the - * device mismatched - */ -typedef enum { - NM_DEVICE_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_DEVICE_ERROR_INTERFACE_MISMATCH, /*< nick=InterfaceMismatch >*/ -} NMDeviceError; - -#define NM_DEVICE_ERROR nm_device_error_quark () -GQuark nm_device_error_quark (void); - #define NM_DEVICE_DEVICE_TYPE "device-type" #define NM_DEVICE_UDI "udi" #define NM_DEVICE_INTERFACE "interface" diff --git a/libnm/nm-manager.c b/libnm/nm-manager.c index 4088548344..3f6ef585c0 100644 --- a/libnm/nm-manager.c +++ b/libnm/nm-manager.c @@ -20,6 +20,7 @@ */ #include <string.h> +#include <glib/gi18n.h> #include <nm-utils.h> #include "nm-manager.h" @@ -312,6 +313,8 @@ get_permissions_sync (NMManager *self, GError **error) g_variant_unref (permissions); return TRUE; } else { + if (error && *error) + g_dbus_error_strip_remote_error (*error); update_permissions (self, NULL); return FALSE; } @@ -409,11 +412,16 @@ nm_manager_networking_get_enabled (NMManager *manager) gboolean nm_manager_networking_set_enabled (NMManager *manager, gboolean enable, GError **error) { + gboolean ret; + g_return_val_if_fail (NM_IS_MANAGER (manager), FALSE); - return nmdbus_manager_call_enable_sync (NM_MANAGER_GET_PRIVATE (manager)->manager_proxy, - enable, - NULL, error); + ret = nmdbus_manager_call_enable_sync (NM_MANAGER_GET_PRIVATE (manager)->manager_proxy, + enable, + NULL, error); + if (error && *error) + g_dbus_error_strip_remote_error (*error); + return ret; } gboolean @@ -500,6 +508,8 @@ nm_manager_wimax_hardware_get_enabled (NMManager *manager) gboolean nm_manager_get_logging (NMManager *manager, char **level, char **domains, GError **error) { + gboolean ret; + g_return_val_if_fail (NM_IS_MANAGER (manager), FALSE); g_return_val_if_fail (level == NULL || *level == NULL, FALSE); g_return_val_if_fail (domains == NULL || *domains == NULL, FALSE); @@ -508,14 +518,19 @@ nm_manager_get_logging (NMManager *manager, char **level, char **domains, GError if (!level && !domains) return TRUE; - return nmdbus_manager_call_get_logging_sync (NM_MANAGER_GET_PRIVATE (manager)->manager_proxy, - level, domains, - NULL, error); + ret = nmdbus_manager_call_get_logging_sync (NM_MANAGER_GET_PRIVATE (manager)->manager_proxy, + level, domains, + NULL, error); + if (error && *error) + g_dbus_error_strip_remote_error (*error); + return ret; } gboolean nm_manager_set_logging (NMManager *manager, const char *level, const char *domains, GError **error) { + gboolean ret; + g_return_val_if_fail (NM_IS_MANAGER (manager), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); @@ -527,9 +542,12 @@ nm_manager_set_logging (NMManager *manager, const char *level, const char *domai if (!domains) domains = ""; - return nmdbus_manager_call_set_logging_sync (NM_MANAGER_GET_PRIVATE (manager)->manager_proxy, - level, domains, - NULL, error); + ret = nmdbus_manager_call_set_logging_sync (NM_MANAGER_GET_PRIVATE (manager)->manager_proxy, + level, domains, + NULL, error); + if (error && *error) + g_dbus_error_strip_remote_error (*error); + return ret; } NMClientPermissionResult @@ -567,8 +585,11 @@ nm_manager_check_connectivity (NMManager *manager, &connectivity, cancellable, error)) return connectivity; - else + else { + if (error && *error) + g_dbus_error_strip_remote_error (*error); return NM_CONNECTIVITY_UNKNOWN; + } } static void @@ -584,8 +605,10 @@ check_connectivity_cb (GObject *object, &connectivity, result, &error)) g_simple_async_result_set_op_res_gssize (simple, connectivity); - else + else { + g_dbus_error_strip_remote_error (error); g_simple_async_result_take_error (simple, error); + } g_simple_async_result_complete (simple); g_object_unref (simple); @@ -830,6 +853,7 @@ activate_cb (GObject *object, recheck_pending_activations (info->manager); } else { + g_dbus_error_strip_remote_error (error); activate_info_complete (info, NULL, error); g_clear_error (&error); } @@ -905,6 +929,7 @@ add_activate_cb (GObject *object, recheck_pending_activations (info->manager); } else { + g_dbus_error_strip_remote_error (error); activate_info_complete (info, NULL, error); g_clear_error (&error); } @@ -1010,25 +1035,29 @@ active_connection_removed (NMManager *self, NMActiveConnection *ac) } static void -object_creation_failed_cb (GObject *object, GError *error, char *failed_path) +object_creation_failed (NMObject *object, const char *failed_path) { NMManager *self = NM_MANAGER (object); NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self); + GError *error; GSList *iter; - g_return_if_fail (error != NULL); g_return_if_fail (find_active_connection_by_path (self, failed_path) == NULL); /* A newly activated connection failed due to some immediate error * and disappeared from active connection list. Make sure the * callback gets called. */ + error = g_error_new_literal (NM_CLIENT_ERROR, + NM_CLIENT_ERROR_OBJECT_CREATION_FAILED, + _("Active connection removed before it was initialized")); for (iter = priv->pending_activations; iter; iter = iter->next) { ActivateInfo *info = iter->data; if (g_strcmp0 (failed_path, info->active_path) == 0) { activate_info_complete (info, NULL, error); + g_error_free (error); return; } } @@ -1041,14 +1070,18 @@ nm_manager_deactivate_connection (NMManager *manager, GError **error) { const char *path; + gboolean ret; g_return_val_if_fail (NM_IS_MANAGER (manager), FALSE); g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (active), FALSE); path = nm_object_get_path (NM_OBJECT (active)); - return nmdbus_manager_call_deactivate_connection_sync (NM_MANAGER_GET_PRIVATE (manager)->manager_proxy, - path, - cancellable, error); + ret = nmdbus_manager_call_deactivate_connection_sync (NM_MANAGER_GET_PRIVATE (manager)->manager_proxy, + path, + cancellable, error); + if (error && *error) + g_dbus_error_strip_remote_error (*error); + return ret; } static void @@ -1062,8 +1095,10 @@ deactivated_cb (GObject *object, if (nmdbus_manager_call_deactivate_connection_finish (NMDBUS_MANAGER (object), result, &error)) g_simple_async_result_set_op_res_gboolean (simple, TRUE); - else + else { + g_dbus_error_strip_remote_error (error); g_simple_async_result_take_error (simple, error); + } g_simple_async_result_complete (simple); g_object_unref (simple); } @@ -1228,9 +1263,6 @@ constructed (GObject *object) g_signal_connect (object, "notify::" NM_MANAGER_WIRELESS_ENABLED, G_CALLBACK (wireless_enabled_cb), NULL); - - g_signal_connect (object, "object-creation-failed", - G_CALLBACK (object_creation_failed_cb), NULL); } static gboolean @@ -1504,6 +1536,7 @@ nm_manager_class_init (NMManagerClass *manager_class) object_class->finalize = finalize; nm_object_class->init_dbus = init_dbus; + nm_object_class->object_creation_failed = object_creation_failed; manager_class->device_added = device_added; manager_class->device_removed = device_removed; diff --git a/libnm/nm-object.c b/libnm/nm-object.c index 65186577eb..735881b227 100644 --- a/libnm/nm-object.c +++ b/libnm/nm-object.c @@ -31,6 +31,7 @@ #include "nm-object-private.h" #include "nm-glib-compat.h" #include "nm-dbus-helpers.h" +#include "nm-client.h" static gboolean debug = FALSE; #define dbgmsg(f,...) if (G_UNLIKELY (debug)) { g_message (f, ## __VA_ARGS__ ); } @@ -99,31 +100,6 @@ enum { LAST_PROP }; -enum { - OBJECT_CREATION_FAILED, - - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -/** - * nm_object_error_quark: - * - * Registers an error quark for #NMObject if necessary. - * - * Returns: the error quark used for #NMObject errors. - **/ -GQuark -nm_object_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-object-error-quark"); - return quark; -} - static void on_name_owner_changed (GObject *proxy, GParamSpec *pspec, @@ -171,7 +147,7 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error) GSList *iter; if (!priv->path) { - g_set_error_literal (error, NM_OBJECT_ERROR, NM_OBJECT_ERROR_OBJECT_CREATION_FAILURE, + g_set_error_literal (error, NM_CLIENT_ERROR, NM_CLIENT_ERROR_OBJECT_CREATION_FAILED, _("Caller did not specify D-Bus path for object")); return FALSE; } @@ -313,8 +289,8 @@ init_async (GAsyncInitable *initable, int io_priority, if (!priv->path) { g_simple_async_report_error_in_idle (G_OBJECT (initable), callback, user_data, - NM_OBJECT_ERROR, - NM_OBJECT_ERROR_OBJECT_CREATION_FAILURE, + NM_CLIENT_ERROR, + NM_CLIENT_ERROR_OBJECT_CREATION_FAILED, "%s", _("Caller did not specify D-Bus path for object")); return; @@ -468,28 +444,6 @@ nm_object_class_init (NMObjectClass *nm_object_class) FALSE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); - - /* signals */ - - /** - * NMObject::object-creation-failed: - * @master_object: the object that received the signal - * @error: the error that occured while creating object - * @failed_path: object path of the failed object - * - * Indicates that an error occured while creating an #NMObject object - * during property handling of @master_object. - * - * Note: Be aware that the signal is private for libnm's internal - * use. - **/ - signals[OBJECT_CREATION_FAILED] = - g_signal_new ("object-creation-failed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMObjectClass, object_creation_failed), - NULL, NULL, NULL, - G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER); } static void @@ -1038,14 +992,10 @@ object_created (GObject *obj, const char *path, gpointer user_data) /* We assume that on error, the creator_func printed something */ if (obj == NULL && g_strcmp0 (path, "/") != 0 ) { - GError *error; - error = g_error_new (NM_OBJECT_ERROR, - NM_OBJECT_ERROR_OBJECT_CREATION_FAILURE, - "Creating object for path '%s' failed in libnm.", - path); - /* Emit a signal about the error. */ - g_signal_emit (odata->self, signals[OBJECT_CREATION_FAILED], 0, error, path); - g_error_free (error); + NMObjectClass *object_class = NM_OBJECT_GET_CLASS (odata->self); + + if (object_class->object_creation_failed) + object_class->object_creation_failed (odata->self, path); } odata->objects[--odata->remaining] = obj; @@ -1445,8 +1395,11 @@ _nm_object_reload_properties (NMObject *object, GError **error) g_variant_new ("(s)", interface), G_DBUS_CALL_FLAGS_NONE, -1, NULL, error); - if (!ret) + if (!ret) { + if (error && *error) + g_dbus_error_strip_remote_error (*error); return FALSE; + } g_variant_get (ret, "(@a{sv})", &props); process_properties_changed (object, props, TRUE); @@ -1581,6 +1534,7 @@ reload_got_properties (GObject *proxy, g_variant_unref (props); g_variant_unref (ret); } else { + g_dbus_error_strip_remote_error (error); if (priv->reload_error) g_error_free (error); else diff --git a/libnm/nm-object.h b/libnm/nm-object.h index 829c539229..b42f160d5c 100644 --- a/libnm/nm-object.h +++ b/libnm/nm-object.h @@ -37,22 +37,6 @@ G_BEGIN_DECLS #define NM_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_OBJECT)) #define NM_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_OBJECT, NMObjectClass)) -/** - * NMObjectError: - * @NM_OBJECT_ERROR_UNKNOWN: unknown or unclassified error - * @NM_OBJECT_ERROR_OBJECT_CREATION_FAILURE: an error ocured while creating an #NMObject - * - * Describes errors that may result from operations involving a #NMObject. - * - **/ -typedef enum { - NM_OBJECT_ERROR_UNKNOWN = 0, - NM_OBJECT_ERROR_OBJECT_CREATION_FAILURE, -} NMObjectError; - -#define NM_OBJECT_ERROR nm_object_error_quark () -GQuark nm_object_error_quark (void); - #define NM_OBJECT_PATH "path" #define NM_OBJECT_DBUS_CONNECTION "dbus-connection" @@ -63,17 +47,15 @@ struct _NMObject { typedef struct { GObjectClass parent; - /* Signals */ - /* The "object-creation-failed" signal is PRIVATE for libnm and + /* Methods */ + void (*init_dbus) (NMObject *object); + + /* The "object-creation-failed" method is PRIVATE for libnm and * is not meant for any external usage. It indicates that an error * occured during creation of an object. */ void (*object_creation_failed) (NMObject *master_object, - GError *error, - char *failed_path); - - /* Methods */ - void (*init_dbus) (NMObject *object); + const char *failed_path); /*< private >*/ gpointer padding[8]; diff --git a/libnm/nm-remote-connection.c b/libnm/nm-remote-connection.c index 210c62cffc..a8592231cd 100644 --- a/libnm/nm-remote-connection.c +++ b/libnm/nm-remote-connection.c @@ -64,23 +64,6 @@ typedef struct { #define NM_REMOTE_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_REMOTE_CONNECTION, NMRemoteConnectionPrivate)) -/** - * nm_remote_connection_error_quark: - * - * Registers an error quark for #NMRemoteConnection if necessary. - * - * Returns: the error quark used for #NMRemoteConnection errors. - **/ -GQuark -nm_remote_connection_error_quark (void) -{ - static GQuark quark = 0; - - if (G_UNLIKELY (quark == 0)) - quark = g_quark_from_static_string ("nm-remote-connection-error-quark"); - return quark; -} - /****************************************************************/ /** @@ -104,6 +87,7 @@ nm_remote_connection_commit_changes (NMRemoteConnection *connection, { NMRemoteConnectionPrivate *priv; GVariant *settings; + gboolean ret; g_return_val_if_fail (NM_IS_REMOTE_CONNECTION (connection), FALSE); @@ -111,14 +95,17 @@ nm_remote_connection_commit_changes (NMRemoteConnection *connection, settings = nm_connection_to_dbus (NM_CONNECTION (connection), NM_CONNECTION_SERIALIZE_ALL); if (save_to_disk) { - return nmdbus_settings_connection_call_update_sync (priv->proxy, - settings, - cancellable, error); + ret = nmdbus_settings_connection_call_update_sync (priv->proxy, + settings, + cancellable, error); } else { - return nmdbus_settings_connection_call_update_unsaved_sync (priv->proxy, - settings, - cancellable, error); + ret = nmdbus_settings_connection_call_update_unsaved_sync (priv->proxy, + settings, + cancellable, error); } + if (error && *error) + g_dbus_error_strip_remote_error (*error); + return ret; } static void @@ -131,8 +118,10 @@ update_cb (GObject *proxy, GAsyncResult *result, gpointer user_data) finish_func = g_object_get_data (G_OBJECT (simple), "finish_func"); if (finish_func (NMDBUS_SETTINGS_CONNECTION (proxy), result, &error)) g_simple_async_result_set_op_res_gboolean (simple, TRUE); - else + else { + g_dbus_error_strip_remote_error (error); g_simple_async_result_take_error (simple, error); + } g_simple_async_result_complete (simple); g_object_unref (simple); } @@ -229,12 +218,16 @@ nm_remote_connection_save (NMRemoteConnection *connection, GError **error) { NMRemoteConnectionPrivate *priv; + gboolean ret; g_return_val_if_fail (NM_IS_REMOTE_CONNECTION (connection), FALSE); priv = NM_REMOTE_CONNECTION_GET_PRIVATE (connection); - return nmdbus_settings_connection_call_save_sync (priv->proxy, cancellable, error); + ret = nmdbus_settings_connection_call_save_sync (priv->proxy, cancellable, error); + if (error && *error) + g_dbus_error_strip_remote_error (*error); + return ret; } static void @@ -246,8 +239,10 @@ save_cb (GObject *proxy, GAsyncResult *result, gpointer user_data) if (nmdbus_settings_connection_call_save_finish (NMDBUS_SETTINGS_CONNECTION (proxy), result, &error)) g_simple_async_result_set_op_res_gboolean (simple, TRUE); - else + else { + g_dbus_error_strip_remote_error (error); g_simple_async_result_take_error (simple, error); + } g_simple_async_result_complete (simple); g_object_unref (simple); } @@ -322,12 +317,16 @@ nm_remote_connection_delete (NMRemoteConnection *connection, GError **error) { NMRemoteConnectionPrivate *priv; + gboolean ret; g_return_val_if_fail (NM_IS_REMOTE_CONNECTION (connection), FALSE); priv = NM_REMOTE_CONNECTION_GET_PRIVATE (connection); - return nmdbus_settings_connection_call_delete_sync (priv->proxy, cancellable, error); + ret = nmdbus_settings_connection_call_delete_sync (priv->proxy, cancellable, error); + if (error && *error) + g_dbus_error_strip_remote_error (*error); + return ret; } static void @@ -339,8 +338,10 @@ delete_cb (GObject *proxy, GAsyncResult *result, gpointer user_data) if (nmdbus_settings_connection_call_delete_finish (NMDBUS_SETTINGS_CONNECTION (proxy), result, &error)) g_simple_async_result_set_op_res_gboolean (simple, TRUE); - else + else { + g_dbus_error_strip_remote_error (error); g_simple_async_result_take_error (simple, error); + } g_simple_async_result_complete (simple); g_object_unref (simple); } @@ -429,8 +430,11 @@ nm_remote_connection_get_secrets (NMRemoteConnection *connection, &secrets, cancellable, error)) return secrets; - else + else { + if (error && *error) + g_dbus_error_strip_remote_error (*error); return NULL; + } } static void @@ -443,8 +447,10 @@ get_secrets_cb (GObject *proxy, GAsyncResult *result, gpointer user_data) if (nmdbus_settings_connection_call_get_secrets_finish (NMDBUS_SETTINGS_CONNECTION (proxy), &secrets, result, &error)) g_simple_async_result_set_op_res_gpointer (simple, secrets, (GDestroyNotify) g_variant_unref); - else + else { + g_dbus_error_strip_remote_error (error); g_simple_async_result_take_error (simple, error); + } g_simple_async_result_complete (simple); g_object_unref (simple); @@ -644,8 +650,11 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error) if (!nmdbus_settings_connection_call_get_settings_sync (priv->proxy, &settings, - cancellable, error)) + cancellable, error)) { + if (error && *error) + g_dbus_error_strip_remote_error (*error); return FALSE; + } priv->visible = TRUE; replace_settings (self, settings); @@ -686,6 +695,7 @@ init_get_settings_cb (GObject *proxy, if (!nmdbus_settings_connection_call_get_settings_finish (priv->proxy, &settings, result, &error)) { + g_dbus_error_strip_remote_error (error); init_async_complete (init_data, error); return; } diff --git a/libnm/nm-remote-connection.h b/libnm/nm-remote-connection.h index 191a8c3fa9..3ea8037fba 100644 --- a/libnm/nm-remote-connection.h +++ b/libnm/nm-remote-connection.h @@ -38,19 +38,6 @@ G_BEGIN_DECLS #define NM_REMOTE_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_REMOTE_CONNECTION, NMRemoteConnectionClass)) -/** - * NMRemoteConnectionError: - * @NM_REMOTE_CONNECTION_ERROR_UNKNOWN: unknown or unclassified error - * @NM_REMOTE_CONNECTION_ERROR_DISCONNECTED: dbus disconnected - */ -typedef enum { - NM_REMOTE_CONNECTION_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/ - NM_REMOTE_CONNECTION_ERROR_DISCONNECTED, /*< nick=Disconnected >*/ -} NMRemoteConnectionError; - -#define NM_REMOTE_CONNECTION_ERROR (nm_remote_connection_error_quark ()) -GQuark nm_remote_connection_error_quark (void); - /* Properties */ #define NM_REMOTE_CONNECTION_DBUS_CONNECTION "dbus-connection" #define NM_REMOTE_CONNECTION_PATH "path" diff --git a/libnm/nm-remote-settings.c b/libnm/nm-remote-settings.c index e072e9ac1c..62a3853d69 100644 --- a/libnm/nm-remote-settings.c +++ b/libnm/nm-remote-settings.c @@ -20,6 +20,7 @@ */ #include <string.h> +#include <glib/gi18n.h> #include <nm-dbus-interface.h> #include <nm-connection.h> @@ -244,7 +245,7 @@ connection_added (NMRemoteSettings *self, } static void -object_creation_failed (NMObject *object, GError *error, char *failed_path) +object_creation_failed (NMObject *object, const char *failed_path) { NMRemoteSettings *self = NM_REMOTE_SETTINGS (object); AddConnectionInfo *addinfo; @@ -253,8 +254,8 @@ object_creation_failed (NMObject *object, GError *error, char *failed_path) addinfo = add_connection_info_find (self, failed_path); if (addinfo) { add_error = g_error_new_literal (NM_CLIENT_ERROR, - NM_CLIENT_ERROR_CONNECTION_REMOVED, - "Connection removed before it was initialized"); + NM_CLIENT_ERROR_OBJECT_CREATION_FAILED, + _("Connection removed before it was initialized")); add_connection_info_complete (self, addinfo, NULL, add_error); g_error_free (add_error); } @@ -297,6 +298,7 @@ add_connection_done (GObject *proxy, GAsyncResult *result, gpointer user_data) } if (error) { + g_dbus_error_strip_remote_error (error); add_connection_info_complete (info->self, info, NULL, error); g_clear_error (&error); } @@ -381,9 +383,11 @@ nm_remote_settings_load_connections (NMRemoteSettings *settings, (const char * const *) filenames, &success, failures, - cancellable, error)) + cancellable, error)) { + if (error && *error) + g_dbus_error_strip_remote_error (*error); success = FALSE; - + } return success; } @@ -399,8 +403,10 @@ load_connections_cb (GObject *proxy, GAsyncResult *result, gpointer user_data) &success, &failures, result, &error)) g_simple_async_result_set_op_res_gpointer (simple, failures, (GDestroyNotify) g_strfreev); - else + else { + g_dbus_error_strip_remote_error (error); g_simple_async_result_take_error (simple, error); + } g_simple_async_result_complete (simple); g_object_unref (simple); @@ -461,8 +467,11 @@ nm_remote_settings_reload_connections (NMRemoteSettings *settings, priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings); if (!nmdbus_settings_call_reload_connections_sync (priv->proxy, &success, - cancellable, error)) + cancellable, error)) { + if (error && *error) + g_dbus_error_strip_remote_error (*error); success = FALSE; + } return success; } @@ -478,8 +487,10 @@ reload_connections_cb (GObject *proxy, GAsyncResult *result, gpointer user_data) &success, result, &error)) g_simple_async_result_set_op_res_gboolean (simple, success); - else + else { + g_dbus_error_strip_remote_error (error); g_simple_async_result_take_error (simple, error); + } g_simple_async_result_complete (simple); g_object_unref (simple); @@ -528,14 +539,19 @@ nm_remote_settings_save_hostname (NMRemoteSettings *settings, GError **error) { NMRemoteSettingsPrivate *priv; + gboolean ret; + g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), FALSE); priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings); - return nmdbus_settings_call_save_hostname_sync (priv->proxy, - hostname ? hostname : "", - cancellable, error); + ret = nmdbus_settings_call_save_hostname_sync (priv->proxy, + hostname ? hostname : "", + cancellable, error); + if (error && *error) + g_dbus_error_strip_remote_error (*error); + return ret; } static void @@ -548,8 +564,10 @@ save_hostname_cb (GObject *proxy, if (nmdbus_settings_call_save_hostname_finish (NMDBUS_SETTINGS (proxy), result, &error)) g_simple_async_result_set_op_res_gboolean (simple, TRUE); - else + else { + g_dbus_error_strip_remote_error (error); g_simple_async_result_take_error (simple, error); + } g_simple_async_result_complete (simple); g_object_unref (simple); } diff --git a/libnm/nm-secret-agent.c b/libnm/nm-secret-agent.c index 7c782d1d94..93555c4151 100644 --- a/libnm/nm-secret-agent.c +++ b/libnm/nm-secret-agent.c @@ -69,18 +69,6 @@ enum { LAST_PROP }; -/********************************************************************/ - -GQuark -nm_secret_agent_error_quark (void) -{ - static GQuark ret = 0; - - if (G_UNLIKELY (ret == 0)) - ret = g_quark_from_static_string ("nm-secret-agent-error"); - return ret; -} - /*************************************************************/ static void @@ -182,7 +170,7 @@ verify_sender (NMSecretAgent *self, if (!nm_owner) { g_set_error_literal (error, NM_SECRET_AGENT_ERROR, - NM_SECRET_AGENT_ERROR_NOT_AUTHORIZED, + NM_SECRET_AGENT_ERROR_PERMISSION_DENIED, "NetworkManager bus name owner unknown."); return FALSE; } @@ -191,7 +179,7 @@ verify_sender (NMSecretAgent *self, if (!sender) { g_set_error_literal (error, NM_SECRET_AGENT_ERROR, - NM_SECRET_AGENT_ERROR_NOT_AUTHORIZED, + NM_SECRET_AGENT_ERROR_PERMISSION_DENIED, "Failed to get request sender."); return FALSE; } @@ -200,7 +188,7 @@ verify_sender (NMSecretAgent *self, if (strcmp (sender, nm_owner) != 0) { g_set_error_literal (error, NM_SECRET_AGENT_ERROR, - NM_SECRET_AGENT_ERROR_NOT_AUTHORIZED, + NM_SECRET_AGENT_ERROR_PERMISSION_DENIED, "Request sender does not match NetworkManager bus name owner."); return FALSE; } @@ -227,7 +215,7 @@ verify_sender (NMSecretAgent *self, g_dbus_error_strip_remote_error (local); g_set_error (error, NM_SECRET_AGENT_ERROR, - NM_SECRET_AGENT_ERROR_NOT_AUTHORIZED, + NM_SECRET_AGENT_ERROR_PERMISSION_DENIED, "Failed to request unix user: (%s) %s.", remote_error ? remote_error : "", local->message); @@ -242,7 +230,7 @@ verify_sender (NMSecretAgent *self, if (0 != sender_uid) { g_set_error_literal (error, NM_SECRET_AGENT_ERROR, - NM_SECRET_AGENT_ERROR_NOT_AUTHORIZED, + NM_SECRET_AGENT_ERROR_PERMISSION_DENIED, "Request sender is not root."); return FALSE; } @@ -287,9 +275,7 @@ verify_request (NMSecretAgent *self, g_set_error (error, NM_SECRET_AGENT_ERROR, NM_SECRET_AGENT_ERROR_INVALID_CONNECTION, - "Invalid connection: (%d) %s", - local ? local->code : -1, - (local && local->message) ? local->message : "(unknown)"); + "Invalid connection: %s", local->message); g_clear_error (&local); } @@ -390,7 +376,7 @@ impl_secret_agent_cancel_get_secrets (NMSecretAgent *self, if (!info) { g_dbus_method_invocation_return_error (context, NM_SECRET_AGENT_ERROR, - NM_SECRET_AGENT_ERROR_INTERNAL_ERROR, + NM_SECRET_AGENT_ERROR_FAILED, "No secrets request in progress for this connection."); return; } @@ -490,7 +476,7 @@ check_nm_running (NMSecretAgent *self, GError **error) if (g_dbus_proxy_get_name_owner (G_DBUS_PROXY (priv->manager_proxy))) return TRUE; - g_set_error (error, NM_SECRET_AGENT_ERROR, NM_SECRET_AGENT_ERROR_INTERNAL_ERROR, + g_set_error (error, NM_SECRET_AGENT_ERROR, NM_SECRET_AGENT_ERROR_FAILED, "NetworkManager is not running"); return FALSE; } @@ -612,7 +598,8 @@ reg_request_cb (GObject *proxy, g_object_unref (self); /* drop extra ref added by get_source_object() */ priv = NM_SECRET_AGENT_GET_PRIVATE (self); - nmdbus_agent_manager_call_register_finish (NMDBUS_AGENT_MANAGER (proxy), result, &error); + if (!nmdbus_agent_manager_call_register_finish (NMDBUS_AGENT_MANAGER (proxy), result, &error)) + g_dbus_error_strip_remote_error (error); reg_result (self, simple, error); g_clear_error (&error); } @@ -771,6 +758,8 @@ nm_secret_agent_unregister (NMSecretAgent *self, priv->suppress_auto = TRUE; success = nmdbus_agent_manager_call_unregister_sync (priv->manager_proxy, cancellable, error); + if (error && *error) + g_dbus_error_strip_remote_error (*error); _internal_unregister (self); return success; @@ -791,8 +780,10 @@ unregister_cb (GObject *proxy, GAsyncResult *result, gpointer user_data) if (nmdbus_agent_manager_call_unregister_finish (NMDBUS_AGENT_MANAGER (proxy), result, &error)) g_simple_async_result_set_op_res_gboolean (simple, TRUE); - else + else { + g_dbus_error_strip_remote_error (error); g_simple_async_result_take_error (simple, error); + } g_simple_async_result_complete (simple); g_object_unref (simple); @@ -1347,10 +1338,6 @@ nm_secret_agent_class_init (NMSecretAgentClass *class) _nm_dbus_register_proxy_type (NM_DBUS_INTERFACE_AGENT_MANAGER, NMDBUS_TYPE_AGENT_MANAGER_PROXY); - - _nm_dbus_register_error_domain (NM_SECRET_AGENT_ERROR, - NM_DBUS_INTERFACE_SECRET_AGENT, - NM_TYPE_SECRET_AGENT_ERROR); } static void diff --git a/libnm/nm-secret-agent.h b/libnm/nm-secret-agent.h index 6b88699005..41b8b742a2 100644 --- a/libnm/nm-secret-agent.h +++ b/libnm/nm-secret-agent.h @@ -29,36 +29,6 @@ G_BEGIN_DECLS -#define NM_SECRET_AGENT_ERROR (nm_secret_agent_error_quark ()) - -GQuark nm_secret_agent_error_quark (void); - -/** - * NMSecretAgentError: - * @NM_SECRET_AGENT_ERROR_NOT_AUTHORIZED: the caller (ie, NetworkManager) is not - * authorized to make this request - * @NM_SECRET_AGENT_ERROR_INVALID_CONNECTION: the connection for which secrets - * were requested could not be found - * @NM_SECRET_AGENT_ERROR_USER_CANCELED: the request was canceled by the user - * @NM_SECRET_AGENT_ERROR_AGENT_CANCELED: the agent canceled the request - * because it was requested to do so by NetworkManager - * @NM_SECRET_AGENT_ERROR_INTERNAL_ERROR: some internal error in the agent caused - * the request to fail - * @NM_SECRET_AGENT_ERROR_NO_SECRETS: the agent cannot find any secrets for this - * connection - * - * #NMSecretAgentError values are passed by secret agents back to NetworkManager - * when they encounter problems retrieving secrets on behalf of NM. - */ -typedef enum { - NM_SECRET_AGENT_ERROR_NOT_AUTHORIZED = 0, /*< nick=NotAuthorized >*/ - NM_SECRET_AGENT_ERROR_INVALID_CONNECTION, /*< nick=InvalidConnection >*/ - NM_SECRET_AGENT_ERROR_USER_CANCELED, /*< nick=UserCanceled >*/ - NM_SECRET_AGENT_ERROR_AGENT_CANCELED, /*< nick=AgentCanceled >*/ - NM_SECRET_AGENT_ERROR_INTERNAL_ERROR, /*< nick=InternalError >*/ - NM_SECRET_AGENT_ERROR_NO_SECRETS, /*< nick=NoSecrets >*/ -} NMSecretAgentError; - #define NM_TYPE_SECRET_AGENT (nm_secret_agent_get_type ()) #define NM_SECRET_AGENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SECRET_AGENT, NMSecretAgent)) #define NM_SECRET_AGENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SECRET_AGENT, NMSecretAgentClass)) diff --git a/libnm/nm-vpn-plugin.c b/libnm/nm-vpn-plugin.c index 674c7a97f3..f6e00dbb24 100644 --- a/libnm/nm-vpn-plugin.c +++ b/libnm/nm-vpn-plugin.c @@ -91,18 +91,6 @@ enum { static GSList *active_plugins = NULL; -GQuark -nm_vpn_plugin_error_quark (void) -{ - static GQuark quark = 0; - - if (!quark) - quark = g_quark_from_static_string ("nm_vpn_plugin_error"); - - return quark; -} - - static void nm_vpn_plugin_set_connection (NMVpnPlugin *plugin, GDBusConnection *connection) @@ -490,10 +478,9 @@ impl_vpn_plugin_need_secrets (NMVpnPlugin *plugin, if (!connection) { g_dbus_method_invocation_return_error (context, NM_VPN_PLUGIN_ERROR, - NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID, - "The connection was invalid: '%s' / '%s' invalid: %d.", - g_type_name (nm_setting_lookup_type_by_quark (error->domain)), - error->message, error->code); + NM_VPN_PLUGIN_ERROR_INVALID_CONNECTION, + "The connection was invalid: %s", + error->message); g_error_free (error); return; } @@ -748,8 +735,11 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error) G_DBUS_CALL_FLAGS_NONE, 0, cancellable, error); g_object_unref (proxy); - if (!ret) + if (!ret) { + if (error && *error) + g_dbus_error_strip_remote_error (*error); goto out; + } g_variant_unref (ret); priv->dbus_vpn_plugin = nmdbus_vpn_plugin_skeleton_new (); @@ -1034,10 +1024,6 @@ nm_vpn_plugin_class_init (NMVpnPluginClass *plugin_class) G_TYPE_NONE, 0, G_TYPE_NONE); - _nm_dbus_register_error_domain (NM_VPN_PLUGIN_ERROR, - NM_DBUS_VPN_ERROR_PREFIX, - NM_TYPE_VPN_PLUGIN_ERROR); - setup_unix_signal_handler (); } diff --git a/libnm/nm-vpn-plugin.h b/libnm/nm-vpn-plugin.h index a81a5c7abe..02245d9a44 100644 --- a/libnm/nm-vpn-plugin.h +++ b/libnm/nm-vpn-plugin.h @@ -42,48 +42,6 @@ G_BEGIN_DECLS #define NM_VPN_PLUGIN_DBUS_SERVICE_NAME "service-name" #define NM_VPN_PLUGIN_STATE "state" -/** - * NMVpnPluginError: - * @NM_VPN_PLUGIN_ERROR_GENERAL: general failure - * @NM_VPN_PLUGIN_ERROR_STARTING_IN_PROGRESS: the plugin is already starting, - * and another connect request was received - * @NM_VPN_PLUGIN_ERROR_ALREADY_STARTED: the plugin is already connected, and - * another connect request was received - * @NM_VPN_PLUGIN_ERROR_STOPPING_IN_PROGRESS: the plugin is already stopping, - * and another stop request was received - * @NM_VPN_PLUGIN_ERROR_ALREADY_STOPPED: the plugin is already stopped, and - * another disconnect request was received - * @NM_VPN_PLUGIN_ERROR_WRONG_STATE: the operation could not be performed in - * this state - * @NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS: the operation could not be performed as - * the request contained malformed arguments, or arguments of unexpected type. - * Usually means that one of the VPN setting data items or secrets was not of - * the expected type (ie int, string, bool, etc). - * @NM_VPN_PLUGIN_ERROR_LAUNCH_FAILED: a child process failed to launch - * @NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID: the operation could not be performed - * because the connection was invalid. Usually means that the connection's - * VPN setting was missing some required data item or secret. - * @NM_VPN_PLUGIN_ERROR_INTERACTIVE_NOT_SUPPORTED: the operation could not be - * performed as the plugin does not support interactive operations, such as - * ConnectInteractive() or NewSecrets() - * - * Returned by the VPN service plugin to indicate errors. - **/ -typedef enum { - NM_VPN_PLUGIN_ERROR_GENERAL, /*< nick=General >*/ - NM_VPN_PLUGIN_ERROR_STARTING_IN_PROGRESS, /*< nick=StartingInProgress >*/ - NM_VPN_PLUGIN_ERROR_ALREADY_STARTED, /*< nick=AlreadyStarted >*/ - NM_VPN_PLUGIN_ERROR_STOPPING_IN_PROGRESS, /*< nick=StoppingInProgress >*/ - NM_VPN_PLUGIN_ERROR_ALREADY_STOPPED, /*< nick=AlreadyStopped >*/ - NM_VPN_PLUGIN_ERROR_WRONG_STATE, /*< nick=WrongState >*/ - NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS, /*< nick=BadArguments >*/ - NM_VPN_PLUGIN_ERROR_LAUNCH_FAILED, /*< nick=LaunchFailed >*/ - NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID, /*< nick=ConnectionInvalid >*/ - NM_VPN_PLUGIN_ERROR_INTERACTIVE_NOT_SUPPORTED /*< nick=InteractiveNotSupported >*/ -} NMVpnPluginError; - -#define NM_VPN_PLUGIN_ERROR (nm_vpn_plugin_error_quark ()) - typedef struct { GObject parent; } NMVpnPlugin; @@ -139,7 +97,6 @@ typedef struct { } NMVpnPluginClass; GType nm_vpn_plugin_get_type (void); -GQuark nm_vpn_plugin_error_quark (void); GDBusConnection *nm_vpn_plugin_get_connection (NMVpnPlugin *plugin); NMVpnServiceState nm_vpn_plugin_get_state (NMVpnPlugin *plugin); diff --git a/libnm/tests/test-nm-client.c b/libnm/tests/test-nm-client.c index 26ffbec4ac..2c5b91246c 100644 --- a/libnm/tests/test-nm-client.c +++ b/libnm/tests/test-nm-client.c @@ -101,6 +101,10 @@ test_device_added (void) g_assert (device); g_assert_cmpstr (nm_device_get_iface (device), ==, "eth0"); + /* Try deleting the device via the ordinary NM interface, which should fail */ + nm_device_delete (device, NULL, &error); + g_assert_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_NOT_SOFTWARE); + g_object_unref (client); g_clear_pointer (&sinfo, nm_test_service_cleanup); } @@ -1019,7 +1023,7 @@ activate_failed_cb (GObject *object, ac = nm_client_activate_connection_finish (client, result, &error); g_assert (ac == NULL); - g_assert_error (error, NM_OBJECT_ERROR, NM_OBJECT_ERROR_OBJECT_CREATION_FAILURE); + g_assert_error (error, NM_CLIENT_ERROR, NM_CLIENT_ERROR_OBJECT_CREATION_FAILED); g_clear_error (&error); g_main_loop_quit (loop); diff --git a/libnm/tests/test-remote-settings-client.c b/libnm/tests/test-remote-settings-client.c index ca0f03f6d4..f521dbc1c0 100644 --- a/libnm/tests/test-remote-settings-client.c +++ b/libnm/tests/test-remote-settings-client.c @@ -368,7 +368,7 @@ add_remove_cb (GObject *s, GError *error = NULL; connection = nm_client_add_connection_finish (client, result, &error); - g_assert_error (error, NM_CLIENT_ERROR, NM_CLIENT_ERROR_CONNECTION_REMOVED); + g_assert_error (error, NM_CLIENT_ERROR, NM_CLIENT_ERROR_OBJECT_CREATION_FAILED); g_assert (connection == NULL); *done = TRUE; @@ -415,6 +415,88 @@ test_add_remove_connection (void) /*******************************************************************/ +static void +add_bad_cb (GObject *s, + GAsyncResult *result, + gpointer user_data) +{ + gboolean *done = user_data; + GError *error = NULL; + + remote = nm_client_add_connection_finish (client, result, &error); + g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); + + *done = TRUE; +} + +static void +test_add_bad_connection (void) +{ + NMConnection *connection; + time_t start, now; + gboolean done = FALSE; + + /* The test daemon doesn't support bond connections */ + connection = nmtst_create_minimal_connection ("bad connection test", NULL, NM_SETTING_BOND_SETTING_NAME, NULL); + + nm_client_add_connection_async (client, + connection, + TRUE, + NULL, + add_bad_cb, + &done); + g_object_unref (connection); + + start = time (NULL); + do { + now = time (NULL); + g_main_context_iteration (NULL, FALSE); + } while ((done == FALSE) && (now - start < 5)); + g_assert (done == TRUE); + g_assert (remote == NULL); +} + +/*******************************************************************/ + +static void +save_hostname_cb (GObject *s, + GAsyncResult *result, + gpointer user_data) +{ + gboolean *done = user_data; + GError *error = NULL; + + nm_client_save_hostname_finish (client, result, &error); + g_assert_no_error (error); + + *done = TRUE; +} + +static void +test_save_hostname (void) +{ + time_t start, now; + gboolean done = FALSE; + GError *error = NULL; + + /* test-networkmanager-service.py requires the hostname to contain a '.' */ + nm_client_save_hostname (client, "foo", NULL, &error); + g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_HOSTNAME); + g_clear_error (&error); + + nm_client_save_hostname_async (client, "example.com", NULL, save_hostname_cb, &done); + + start = time (NULL); + do { + now = time (NULL); + g_main_context_iteration (NULL, FALSE); + } while ((done == FALSE) && (now - start < 5)); + g_assert (done == TRUE); + g_assert (remote == NULL); +} + +/*******************************************************************/ + int main (int argc, char **argv) { @@ -446,6 +528,8 @@ main (int argc, char **argv) g_test_add_func ("/client/make_visible", test_make_visible); g_test_add_func ("/client/remove_connection", test_remove_connection); g_test_add_func ("/client/add_remove_connection", test_add_remove_connection); + g_test_add_func ("/client/add_bad_connection", test_add_bad_connection); + g_test_add_func ("/client/save_hostname", test_save_hostname); ret = g_test_run (); diff --git a/libnm/tests/test-secret-agent.c b/libnm/tests/test-secret-agent.c index a1ce5d5324..76f8a02e20 100644 --- a/libnm/tests/test-secret-agent.c +++ b/libnm/tests/test-secret-agent.c @@ -354,10 +354,7 @@ connection_activated_none_cb (GObject *c, GError *error = NULL; ac = nm_client_activate_connection_finish (sadata->client, result, &error); - - g_assert (error != NULL); - g_dbus_error_strip_remote_error (error); - g_assert_cmpstr (error->message, ==, "No secret agent available"); + g_assert_error (error, NM_AGENT_MANAGER_ERROR, NM_AGENT_MANAGER_ERROR_NO_SECRETS); g_main_loop_quit (sadata->loop); } @@ -403,11 +400,7 @@ connection_activated_no_secrets_cb (GObject *c, GError *error = NULL; ac = nm_client_activate_connection_finish (sadata->client, result, &error); - - g_assert (error != NULL); - g_dbus_error_strip_remote_error (error); - g_assert_cmpstr (error->message, ==, "No secrets provided"); - + g_assert_error (error, NM_AGENT_MANAGER_ERROR, NM_AGENT_MANAGER_ERROR_NO_SECRETS); g_main_loop_quit (sadata->loop); } @@ -442,11 +435,7 @@ connection_activated_cancel_cb (GObject *c, GError *error = NULL; ac = nm_client_activate_connection_finish (sadata->client, result, &error); - - g_assert (error != NULL); - g_dbus_error_strip_remote_error (error); - g_assert_cmpstr (error->message, ==, "User canceled"); - + g_assert_error (error, NM_AGENT_MANAGER_ERROR, NM_AGENT_MANAGER_ERROR_USER_CANCELED); g_main_loop_quit (sadata->loop); } @@ -548,7 +537,7 @@ async_init_cb (GObject *object, GAsyncResult *result, gpointer user_data) GObject *agent; agent = g_async_initable_new_finish (G_ASYNC_INITABLE (object), result, &error); - g_assert_error (error, NM_SECRET_AGENT_ERROR, NM_SECRET_AGENT_ERROR_INTERNAL_ERROR); + g_assert_error (error, NM_SECRET_AGENT_ERROR, NM_SECRET_AGENT_ERROR_FAILED); g_assert (agent == NULL); g_clear_error (&error); @@ -565,7 +554,7 @@ test_secret_agent_nm_not_running (void) agent = g_initable_new (test_secret_agent_get_type (), NULL, &error, NM_SECRET_AGENT_IDENTIFIER, "test-secret-agent", NULL); - g_assert_error (error, NM_SECRET_AGENT_ERROR, NM_SECRET_AGENT_ERROR_INTERNAL_ERROR); + g_assert_error (error, NM_SECRET_AGENT_ERROR, NM_SECRET_AGENT_ERROR_FAILED); g_assert (agent == NULL); g_clear_error (&error); diff --git a/po/POTFILES.in b/po/POTFILES.in index ddd5907324..c97e05de54 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -100,8 +100,24 @@ libnm-util/nm-setting-wired.c libnm-util/nm-setting-wireless-security.c libnm-util/nm-setting-wireless.c libnm-util/nm-utils.c +libnm/nm-device-adsl.c +libnm/nm-device-bond.c +libnm/nm-device-bridge.c +libnm/nm-device-bt.c +libnm/nm-device-ethernet.c +libnm/nm-device-generic.c +libnm/nm-device-infiniband.c +libnm/nm-device-modem.c +libnm/nm-device-olpc-mesh.c +libnm/nm-device-team.c +libnm/nm-device-vlan.c +libnm/nm-device-wifi.c +libnm/nm-device-wimax.c +libnm/nm-device.c +libnm/nm-manager.c libnm/nm-object.c libnm/nm-remote-connection.c +libnm/nm-remote-settings.c libnm/nm-vpn-plugin.c policy/org.freedesktop.NetworkManager.policy.in.in src/NetworkManagerUtils.c @@ -121,6 +137,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/Makefile.am b/src/Makefile.am index 95df89be74..d568c00a46 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -163,15 +163,12 @@ nm_sources = \ settings/nm-secret-agent.h \ settings/nm-settings-connection.c \ settings/nm-settings-connection.h \ - settings/nm-settings-error.c \ - settings/nm-settings-error.h \ settings/nm-settings.c \ settings/nm-settings.h \ settings/nm-system-config-interface.c \ settings/nm-system-config-interface.h \ \ settings/plugins/keyfile/common.h \ - settings/plugins/keyfile/errors.c \ settings/plugins/keyfile/nm-keyfile-connection.c \ settings/plugins/keyfile/nm-keyfile-connection.h \ settings/plugins/keyfile/plugin.c \ @@ -279,7 +276,7 @@ endif GLIB_GENERATED = nm-enum-types.h nm-enum-types.c -GLIB_MKENUMS_H_FLAGS = --identifier-prefix NM +GLIB_MKENUMS_H_FLAGS = --identifier-prefix NM --fhead '\#include <nm-core-enum-types.h>\n' GLIB_MKENUMS_C_FLAGS = --identifier-prefix NM nm_enum_types_sources = $(nm_sources) diff --git a/src/devices/bluetooth/nm-device-bt.c b/src/devices/bluetooth/nm-device-bt.c index 18b7ab1bd8..0a1f591540 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 { @@ -1217,6 +1227,4 @@ nm_device_bt_class_init (NMDeviceBtClass *klass) nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), G_TYPE_FROM_CLASS (klass), &dbus_glib_nm_device_bt_object_info); - - dbus_g_error_domain_register (NM_BT_ERROR, NULL, NM_TYPE_BT_ERROR); } diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c index 68375d81f5..e029aafa06 100644 --- a/src/devices/nm-device-bond.c +++ b/src/devices/nm-device-bond.c @@ -47,8 +47,6 @@ G_DEFINE_TYPE (NMDeviceBond, nm_device_bond, NM_TYPE_DEVICE) #define NM_DEVICE_BOND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_BOND, NMDeviceBondPrivate)) -#define NM_BOND_ERROR (nm_bond_error_quark ()) - typedef struct { int dummy; } NMDeviceBondPrivate; @@ -62,17 +60,6 @@ enum { /******************************************************************/ -static GQuark -nm_bond_error_quark (void) -{ - static GQuark quark = 0; - if (!quark) - quark = g_quark_from_static_string ("nm-bond-error"); - return quark; -} - -/******************************************************************/ - static guint32 get_generic_capabilities (NMDevice *dev) { @@ -536,8 +523,6 @@ nm_device_bond_class_init (NMDeviceBondClass *klass) nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), G_TYPE_FROM_CLASS (klass), &dbus_glib_nm_device_bond_object_info); - - dbus_g_error_domain_register (NM_BOND_ERROR, NULL, NM_TYPE_BOND_ERROR); } /*************************************************************/ diff --git a/src/devices/nm-device-bond.h b/src/devices/nm-device-bond.h index ed1c023434..17217a57c4 100644 --- a/src/devices/nm-device-bond.h +++ b/src/devices/nm-device-bond.h @@ -34,12 +34,6 @@ G_BEGIN_DECLS #define NM_IS_DEVICE_BOND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_BOND)) #define NM_DEVICE_BOND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_BOND, NMDeviceBondClass)) -typedef enum { - NM_BOND_ERROR_CONNECTION_NOT_BOND = 0, /*< nick=ConnectionNotBond >*/ - NM_BOND_ERROR_CONNECTION_INVALID, /*< nick=ConnectionInvalid >*/ - NM_BOND_ERROR_CONNECTION_INCOMPATIBLE, /*< nick=ConnectionIncompatible >*/ -} NMBondError; - #define NM_DEVICE_BOND_SLAVES "slaves" typedef NMDevice NMDeviceBond; diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c index 191cbdd366..7a3c373c47 100644 --- a/src/devices/nm-device-bridge.c +++ b/src/devices/nm-device-bridge.c @@ -46,8 +46,6 @@ G_DEFINE_TYPE (NMDeviceBridge, nm_device_bridge, NM_TYPE_DEVICE) #define NM_DEVICE_BRIDGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_BRIDGE, NMDeviceBridgePrivate)) -#define NM_BRIDGE_ERROR (nm_bridge_error_quark ()) - typedef struct { int dummy; } NMDeviceBridgePrivate; @@ -61,17 +59,6 @@ enum { /******************************************************************/ -static GQuark -nm_bridge_error_quark (void) -{ - static GQuark quark = 0; - if (!quark) - quark = g_quark_from_static_string ("nm-bridge-error"); - return quark; -} - -/******************************************************************/ - static guint32 get_generic_capabilities (NMDevice *dev) { @@ -481,8 +468,6 @@ nm_device_bridge_class_init (NMDeviceBridgeClass *klass) nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), G_TYPE_FROM_CLASS (klass), &dbus_glib_nm_device_bridge_object_info); - - dbus_g_error_domain_register (NM_BRIDGE_ERROR, NULL, NM_TYPE_BRIDGE_ERROR); } /*************************************************************/ diff --git a/src/devices/nm-device-bridge.h b/src/devices/nm-device-bridge.h index 7c6d7c53af..c11a2c40f7 100644 --- a/src/devices/nm-device-bridge.h +++ b/src/devices/nm-device-bridge.h @@ -34,12 +34,6 @@ G_BEGIN_DECLS #define NM_IS_DEVICE_BRIDGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_BRIDGE)) #define NM_DEVICE_BRIDGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_BRIDGE, NMDeviceBridgeClass)) -typedef enum { - NM_BRIDGE_ERROR_CONNECTION_NOT_BRIDGE = 0, /*< nick=ConnectionNotBridge >*/ - NM_BRIDGE_ERROR_CONNECTION_INVALID, /*< nick=ConnectionInvalid >*/ - NM_BRIDGE_ERROR_CONNECTION_INCOMPATIBLE, /*< nick=ConnectionIncompatible >*/ -} NMBridgeError; - #define NM_DEVICE_BRIDGE_SLAVES "slaves" typedef NMDevice NMDeviceBridge; diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index a0713a7922..e4b726a221 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -73,8 +73,6 @@ G_DEFINE_TYPE (NMDeviceEthernet, nm_device_ethernet, NM_TYPE_DEVICE) #define PPPOE_RECONNECT_DELAY 7 -#define NM_ETHERNET_ERROR (nm_ethernet_error_quark ()) - static NMSetting *device_get_setting (NMDevice *device, GType setting_type); typedef struct Supplicant { @@ -142,15 +140,6 @@ enum { }; -static GQuark -nm_ethernet_error_quark (void) -{ - static GQuark quark = 0; - if (!quark) - quark = g_quark_from_static_string ("nm-ethernet-error"); - return quark; -} - static char * get_link_basename (const char *parent_path, const char *name, GError **error) { @@ -1449,9 +1438,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 { @@ -1743,8 +1733,6 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *klass) nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), G_TYPE_FROM_CLASS (klass), &dbus_glib_nm_device_ethernet_object_info); - - dbus_g_error_domain_register (NM_ETHERNET_ERROR, NULL, NM_TYPE_ETHERNET_ERROR); } /*************************************************************/ diff --git a/src/devices/nm-device-ethernet.h b/src/devices/nm-device-ethernet.h index ff21bcad99..ad9ce85669 100644 --- a/src/devices/nm-device-ethernet.h +++ b/src/devices/nm-device-ethernet.h @@ -35,13 +35,6 @@ G_BEGIN_DECLS #define NM_IS_DEVICE_ETHERNET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_ETHERNET)) #define NM_DEVICE_ETHERNET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_ETHERNET, NMDeviceEthernetClass)) -typedef enum -{ - NM_ETHERNET_ERROR_CONNECTION_NOT_WIRED = 0, /*< nick=ConnectionNotWired >*/ - NM_ETHERNET_ERROR_CONNECTION_INVALID, /*< nick=ConnectionInvalid >*/ - NM_ETHERNET_ERROR_CONNECTION_INCOMPATIBLE, /*< nick=ConnectionIncompatible >*/ -} NMEthernetError; - #define NM_DEVICE_ETHERNET_PERMANENT_HW_ADDRESS "perm-hw-address" #define NM_DEVICE_ETHERNET_SPEED "speed" diff --git a/src/devices/nm-device-generic.c b/src/devices/nm-device-generic.c index af262f7733..c5aadb8f20 100644 --- a/src/devices/nm-device-generic.c +++ b/src/devices/nm-device-generic.c @@ -45,19 +45,6 @@ enum { LAST_PROP }; -#define NM_DEVICE_GENERIC_ERROR (nm_device_generic_error_quark ()) - -static GQuark -nm_device_generic_error_quark (void) -{ - static GQuark quark = 0; - if (!quark) - quark = g_quark_from_static_string ("nm-device-generic-error"); - return quark; -} - -/**************************************************************/ - static guint32 get_generic_capabilities (NMDevice *dev) { @@ -211,6 +198,4 @@ nm_device_generic_class_init (NMDeviceGenericClass *klass) nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), G_TYPE_FROM_CLASS (klass), &dbus_glib_nm_device_generic_object_info); - - dbus_g_error_domain_register (NM_DEVICE_GENERIC_ERROR, NULL, NM_TYPE_DEVICE_GENERIC_ERROR); } diff --git a/src/devices/nm-device-generic.h b/src/devices/nm-device-generic.h index 1decc2eb6c..c889b1ddc7 100644 --- a/src/devices/nm-device-generic.h +++ b/src/devices/nm-device-generic.h @@ -34,13 +34,6 @@ G_BEGIN_DECLS #define NM_IS_DEVICE_GENERIC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_GENERIC)) #define NM_DEVICE_GENERIC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_GENERIC, NMDeviceGenericClass)) -typedef enum -{ - NM_DEVICE_GENERIC_ERROR_CONNECTION_NOT_GENERIC = 0, /*< nick=ConnectionNotGeneric >*/ - NM_DEVICE_GENERIC_ERROR_CONNECTION_INVALID, /*< nick=ConnectionInvalid >*/ - NM_DEVICE_GENERIC_ERROR_CONNECTION_INCOMPATIBLE, /*< nick=ConnectionIncompatible >*/ -} NMDeviceGenericError; - #define NM_DEVICE_GENERIC_TYPE_DESCRIPTION "type-description" typedef struct { diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c index acf74490f2..69cdc6715e 100644 --- a/src/devices/nm-device-infiniband.c +++ b/src/devices/nm-device-infiniband.c @@ -44,8 +44,6 @@ G_DEFINE_TYPE (NMDeviceInfiniband, nm_device_infiniband, NM_TYPE_DEVICE) #define NM_DEVICE_INFINIBAND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_INFINIBAND, NMDeviceInfinibandPrivate)) -#define NM_INFINIBAND_ERROR (nm_infiniband_error_quark ()) - typedef struct { int dummy; } NMDeviceInfinibandPrivate; @@ -56,15 +54,6 @@ enum { LAST_PROP }; -static GQuark -nm_infiniband_error_quark (void) -{ - static GQuark quark = 0; - if (!quark) - quark = g_quark_from_static_string ("nm-infiniband-error"); - return quark; -} - static void nm_device_infiniband_init (NMDeviceInfiniband * self) { @@ -202,9 +191,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 { @@ -295,8 +285,6 @@ nm_device_infiniband_class_init (NMDeviceInfinibandClass *klass) nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), G_TYPE_FROM_CLASS (klass), &dbus_glib_nm_device_infiniband_object_info); - - dbus_g_error_domain_register (NM_INFINIBAND_ERROR, NULL, NM_TYPE_INFINIBAND_ERROR); } /*************************************************************/ diff --git a/src/devices/nm-device-infiniband.h b/src/devices/nm-device-infiniband.h index e9b5be92ba..b81b762ad2 100644 --- a/src/devices/nm-device-infiniband.h +++ b/src/devices/nm-device-infiniband.h @@ -34,12 +34,6 @@ G_BEGIN_DECLS #define NM_IS_DEVICE_INFINIBAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_INFINIBAND)) #define NM_DEVICE_INFINIBAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_INFINIBAND, NMDeviceInfinibandClass)) -typedef enum { - NM_INFINIBAND_ERROR_CONNECTION_NOT_INFINIBAND = 0, /*< nick=ConnectionNotInfiniband >*/ - NM_INFINIBAND_ERROR_CONNECTION_INVALID, /*< nick=ConnectionInvalid >*/ - NM_INFINIBAND_ERROR_CONNECTION_INCOMPATIBLE, /*< nick=ConnectionIncompatible >*/ -} NMInfinibandError; - typedef NMDevice NMDeviceInfiniband; typedef NMDeviceClass NMDeviceInfinibandClass; diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c index 8ca39be64b..1c78dd1ea2 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -50,8 +50,6 @@ G_DEFINE_TYPE (NMDeviceVlan, nm_device_vlan, NM_TYPE_DEVICE) #define NM_DEVICE_VLAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_VLAN, NMDeviceVlanPrivate)) -#define NM_VLAN_ERROR (nm_vlan_error_quark ()) - typedef struct { char *initial_hw_addr; @@ -74,17 +72,6 @@ enum { /******************************************************************/ -static GQuark -nm_vlan_error_quark (void) -{ - static GQuark quark = 0; - if (!quark) - quark = g_quark_from_static_string ("nm-vlan-error"); - return quark; -} - -/******************************************************************/ - static void update_initial_hw_address (NMDevice *dev) { @@ -232,7 +219,7 @@ complete_connection (NMDevice *device, s_vlan = nm_connection_get_setting_vlan (connection); if (!s_vlan) { - g_set_error_literal (error, NM_VLAN_ERROR, NM_VLAN_ERROR_CONNECTION_INVALID, + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION, "A 'vlan' setting is required."); return FALSE; } @@ -242,7 +229,7 @@ complete_connection (NMDevice *device, */ if ( !nm_setting_vlan_get_parent (s_vlan) && !match_hwaddr (device, connection, TRUE)) { - g_set_error_literal (error, NM_VLAN_ERROR, NM_VLAN_ERROR_CONNECTION_INVALID, + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION, "The 'vlan' setting had no interface name, parent, or hardware address."); return FALSE; } @@ -591,8 +578,6 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass) nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), G_TYPE_FROM_CLASS (klass), &dbus_glib_nm_device_vlan_object_info); - - dbus_g_error_domain_register (NM_VLAN_ERROR, NULL, NM_TYPE_VLAN_ERROR); } /*************************************************************/ diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 10dd77dbd7..45bcd22a83 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -334,19 +334,6 @@ static void nm_device_update_hw_address (NMDevice *self); /***********************************************************/ -static GQuark -nm_device_error_quark (void) -{ - static GQuark quark = 0; - if (!quark) - quark = g_quark_from_static_string ("nm-device-error"); - return quark; -} - -#define NM_DEVICE_ERROR (nm_device_error_quark ()) - -/***********************************************************/ - #define QUEUED_PREFIX "queued state change to " static const char *state_table[] = { @@ -1731,7 +1718,7 @@ nm_device_master_update_slave_connection (NMDevice *self, g_set_error (error, NM_DEVICE_ERROR, - NM_DEVICE_ERROR_UNSUPPORTED_DEVICE_TYPE, + NM_DEVICE_ERROR_FAILED, "master device '%s' cannot update a slave connection for slave device '%s' (master type not supported?)", nm_device_get_iface (self), nm_device_get_iface (slave)); return FALSE; @@ -1837,7 +1824,7 @@ nm_device_complete_connection (NMDevice *self, g_return_val_if_fail (connection != NULL, FALSE); if (!NM_DEVICE_GET_CLASS (self)->complete_connection) { - g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CONNECTION_INVALID, + g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION, "Device class %s had no complete_connection method", G_OBJECT_TYPE_NAME (self)); return FALSE; diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index 00da022905..b053070388 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -85,14 +85,6 @@ G_BEGIN_DECLS typedef enum NMActStageReturn NMActStageReturn; -typedef enum { - NM_DEVICE_ERROR_CONNECTION_ACTIVATING = 0, /*< nick=ConnectionActivating >*/ - NM_DEVICE_ERROR_CONNECTION_INVALID, /*< nick=ConnectionInvalid >*/ - NM_DEVICE_ERROR_NOT_ACTIVE, /*< nick=NotActive >*/ - NM_DEVICE_ERROR_UNSUPPORTED_DEVICE_TYPE, /*< nick=UnsupportedDeviceType >*/ - NM_DEVICE_ERROR_NOT_SOFTWARE, /*< nick=NotSoftware >*/ -} NMDeviceError; - struct _NMDevice { GObject parent; }; diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c index 40055961bd..6778d46dc6 100644 --- a/src/devices/team/nm-device-team.c +++ b/src/devices/team/nm-device-team.c @@ -51,8 +51,6 @@ G_DEFINE_TYPE (NMDeviceTeam, nm_device_team, NM_TYPE_DEVICE) #define NM_DEVICE_TEAM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_TEAM, NMDeviceTeamPrivate)) -#define NM_DEVICE_TEAM_ERROR (nm_device_team_error_quark ()) - static gboolean teamd_start (NMDevice *device, NMSettingTeam *s_team); typedef struct { @@ -72,17 +70,6 @@ enum { /******************************************************************/ -static GQuark -nm_device_team_error_quark (void) -{ - static GQuark quark = 0; - if (!quark) - quark = g_quark_from_static_string ("nm-team-error"); - return quark; -} - -/******************************************************************/ - static guint32 get_generic_capabilities (NMDevice *device) { @@ -224,8 +211,8 @@ master_update_slave_connection (NMDevice *self, tdc = teamdctl_alloc (); if (!tdc) { g_set_error (error, - NM_DEVICE_TEAM_ERROR, - NM_DEVICE_TEAM_ERROR_TEAMCTL_FAILURE, + NM_DEVICE_ERROR, + NM_DEVICE_ERROR_FAILED, "update slave connection for slave '%s' failed to connect to teamd for master %s (out of memory?)", iface_slave, iface); g_return_val_if_reached (FALSE); @@ -235,8 +222,8 @@ master_update_slave_connection (NMDevice *self, if (err) { teamdctl_free (tdc); g_set_error (error, - NM_DEVICE_TEAM_ERROR, - NM_DEVICE_TEAM_ERROR_TEAMCTL_FAILURE, + NM_DEVICE_ERROR, + NM_DEVICE_ERROR_FAILED, "update slave connection for slave '%s' failed to connect to teamd for master %s (err=%d)", iface_slave, iface, err); return FALSE; @@ -247,8 +234,8 @@ master_update_slave_connection (NMDevice *self, teamdctl_free (tdc); if (err) { g_set_error (error, - NM_DEVICE_TEAM_ERROR, - NM_DEVICE_TEAM_ERROR_TEAMCTL_FAILURE, + NM_DEVICE_ERROR, + NM_DEVICE_ERROR_FAILED, "update slave connection for slave '%s' failed to get configuration from teamd master %s (err=%d)", iface_slave, iface, err); g_free (port_config); @@ -678,8 +665,8 @@ nm_device_team_new_for_connection (NMConnection *connection, GError **error) if ( !nm_platform_team_add (iface) && nm_platform_get_error () != NM_PLATFORM_ERROR_EXISTS) { g_set_error (error, - NM_DEVICE_TEAM_ERROR, - NM_DEVICE_TEAM_ERROR_PLATFORM_FAILURE, + NM_DEVICE_ERROR, + NM_DEVICE_ERROR_CREATION_FAILED, "failed to create team master interface '%s' for connection '%s': %s", iface, nm_connection_get_id (connection), nm_platform_get_error_msg ()); @@ -781,6 +768,4 @@ nm_device_team_class_init (NMDeviceTeamClass *klass) nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), G_TYPE_FROM_CLASS (klass), &dbus_glib_nm_device_team_object_info); - - dbus_g_error_domain_register (NM_DEVICE_TEAM_ERROR, NULL, NM_TYPE_TEAM_ERROR); } diff --git a/src/devices/team/nm-device-team.h b/src/devices/team/nm-device-team.h index 57f3aeffc8..26ba573721 100644 --- a/src/devices/team/nm-device-team.h +++ b/src/devices/team/nm-device-team.h @@ -34,15 +34,6 @@ G_BEGIN_DECLS #define NM_IS_DEVICE_TEAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_TEAM)) #define NM_DEVICE_TEAM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_TEAM, NMDeviceTeamClass)) -typedef enum { - NM_DEVICE_TEAM_ERROR_CONNECTION_NOT_TEAM = 0, /*< nick=ConnectionNotTeam >*/ - NM_DEVICE_TEAM_ERROR_CONNECTION_INVALID, /*< nick=ConnectionInvalid >*/ - NM_DEVICE_TEAM_ERROR_CONNECTION_INCOMPATIBLE, /*< nick=ConnectionIncompatible >*/ - NM_DEVICE_TEAM_ERROR_TEAMCTL_FAILURE, /*< nick=TeamCtlFailure >*/ - NM_DEVICE_TEAM_ERROR_NO_SUPPORT, /*< nick=NoSupport >*/ - NM_DEVICE_TEAM_ERROR_PLATFORM_FAILURE, /*< nick=PlatformFailure >*/ -} NMTeamError; - #define NM_DEVICE_TEAM_SLAVES "slaves" typedef struct { diff --git a/src/devices/wifi/nm-device-olpc-mesh.c b/src/devices/wifi/nm-device-olpc-mesh.c index 2306155019..d801795985 100644 --- a/src/devices/wifi/nm-device-olpc-mesh.c +++ b/src/devices/wifi/nm-device-olpc-mesh.c @@ -81,19 +81,6 @@ struct _NMDeviceOlpcMeshPrivate { /*******************************************************************/ -static GQuark -nm_olpc_mesh_error_quark (void) -{ - static GQuark quark = 0; - if (!quark) - quark = g_quark_from_static_string ("nm-mesh-error"); - return quark; -} - -#define NM_OLPC_MESH_ERROR (nm_olpc_mesh_error_quark ()) - -/*******************************************************************/ - static gboolean check_connection_compatible (NMDevice *device, NMConnection *connection) { @@ -566,7 +553,5 @@ nm_device_olpc_mesh_class_init (NMDeviceOlpcMeshClass *klass) nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), G_TYPE_FROM_CLASS (klass), &dbus_glib_nm_device_olpc_mesh_object_info); - - dbus_g_error_domain_register (NM_OLPC_MESH_ERROR, NULL, NM_TYPE_OLPC_MESH_ERROR); } diff --git a/src/devices/wifi/nm-device-olpc-mesh.h b/src/devices/wifi/nm-device-olpc-mesh.h index 8f8060ba87..67d83fb059 100644 --- a/src/devices/wifi/nm-device-olpc-mesh.h +++ b/src/devices/wifi/nm-device-olpc-mesh.h @@ -41,13 +41,6 @@ G_BEGIN_DECLS #define NM_IS_DEVICE_OLPC_MESH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_OLPC_MESH)) #define NM_DEVICE_OLPC_MESH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_OLPC_MESH, NMDeviceOlpcMeshClass)) -typedef enum -{ - NM_OLPC_MESH_ERROR_CONNECTION_NOT_MESH = 0, /*< nick=ConnectionNotMesh >*/ - NM_OLPC_MESH_ERROR_CONNECTION_INVALID, /*< nick=ConnectionInvalid >*/ - NM_OLPC_MESH_ERROR_CONNECTION_INCOMPATIBLE, /*< nick=ConnectionIncompatible >*/ -} NMOlpcMeshError; - #define NM_DEVICE_OLPC_MESH_COMPANION "companion" #define NM_DEVICE_OLPC_MESH_BITRATE "bitrate" #define NM_DEVICE_OLPC_MESH_ACTIVE_CHANNEL "active-channel" diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index cf5a4f631c..6617f4a69e 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -193,19 +193,6 @@ static void remove_supplicant_interface_error_handler (NMDeviceWifi *self); /*****************************************************************/ -#define NM_WIFI_ERROR (nm_wifi_error_quark ()) - -static GQuark -nm_wifi_error_quark (void) -{ - static GQuark quark = 0; - if (!quark) - quark = g_quark_from_static_string ("nm-wifi-error"); - return quark; -} - -/*****************************************************************/ - static GObject* constructor (GType type, guint n_construct_params, @@ -998,8 +985,8 @@ complete_connection (NMDevice *device, /* If not given a specific object, we need at minimum an SSID */ if (!s_wifi) { g_set_error_literal (error, - NM_WIFI_ERROR, - NM_WIFI_ERROR_CONNECTION_INVALID, + NM_DEVICE_ERROR, + NM_DEVICE_ERROR_INVALID_CONNECTION, "A 'wireless' setting is required if no AP path was given."); return FALSE; } @@ -1007,8 +994,8 @@ complete_connection (NMDevice *device, setting_ssid = nm_setting_wireless_get_ssid (s_wifi); if (!setting_ssid || g_bytes_get_size (setting_ssid) == 0) { g_set_error_literal (error, - NM_WIFI_ERROR, - NM_WIFI_ERROR_CONNECTION_INVALID, + NM_DEVICE_ERROR, + NM_DEVICE_ERROR_INVALID_CONNECTION, "A 'wireless' setting with a valid SSID is required if no AP path was given."); return FALSE; } @@ -1045,8 +1032,8 @@ complete_connection (NMDevice *device, ap = get_ap_by_path (self, specific_object); if (!ap) { g_set_error (error, - NM_WIFI_ERROR, - NM_WIFI_ERROR_ACCESS_POINT_NOT_FOUND, + NM_DEVICE_ERROR, + NM_DEVICE_ERROR_SPECIFIC_OBJECT_NOT_FOUND, "The access point %s was not in the scan list.", specific_object); return FALSE; @@ -1082,8 +1069,8 @@ complete_connection (NMDevice *device, * connection data, then we cannot connect at all. Return an error. */ g_set_error_literal (error, - NM_WIFI_ERROR, - NM_WIFI_ERROR_CONNECTION_INVALID, + NM_DEVICE_ERROR, + NM_DEVICE_ERROR_INVALID_CONNECTION, "A 'wireless' setting with a valid SSID is required for hidden access points."); return FALSE; } @@ -1107,9 +1094,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 +1124,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 { @@ -1292,8 +1281,8 @@ request_scan_cb (NMDevice *device, } if (!check_scanning_allowed (self)) { - local = g_error_new_literal (NM_WIFI_ERROR, - NM_WIFI_ERROR_SCAN_NOT_ALLOWED, + local = g_error_new_literal (NM_DEVICE_ERROR, + NM_DEVICE_ERROR_NOT_ALLOWED, "Scanning not allowed at this time"); dbus_g_method_return_error (context, local); g_error_free (local); @@ -1319,23 +1308,23 @@ impl_device_request_scan (NMDeviceWifi *self, || !priv->sup_iface || nm_device_get_state (device) < NM_DEVICE_STATE_DISCONNECTED || nm_device_is_activating (device)) { - error = g_error_new_literal (NM_WIFI_ERROR, - NM_WIFI_ERROR_SCAN_NOT_ALLOWED, + error = g_error_new_literal (NM_DEVICE_ERROR, + NM_DEVICE_ERROR_NOT_ALLOWED, "Scanning not allowed while unavailable or activating"); goto error; } if (nm_supplicant_interface_get_scanning (priv->sup_iface)) { - error = g_error_new_literal (NM_WIFI_ERROR, - NM_WIFI_ERROR_SCAN_NOT_ALLOWED, + error = g_error_new_literal (NM_DEVICE_ERROR, + NM_DEVICE_ERROR_NOT_ALLOWED, "Scanning not allowed while already scanning"); goto error; } last_scan = nm_supplicant_interface_get_last_scan_time (priv->sup_iface); if (last_scan && (nm_utils_get_monotonic_timestamp_s () - last_scan) < 10) { - error = g_error_new_literal (NM_WIFI_ERROR, - NM_WIFI_ERROR_SCAN_NOT_ALLOWED, + error = g_error_new_literal (NM_DEVICE_ERROR, + NM_DEVICE_ERROR_NOT_ALLOWED, "Scanning not allowed immediately following previous scan"); goto error; } @@ -3454,8 +3443,6 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass) nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), G_TYPE_FROM_CLASS (klass), &dbus_glib_nm_device_wifi_object_info); - - dbus_g_error_domain_register (NM_WIFI_ERROR, NULL, NM_TYPE_WIFI_ERROR); } diff --git a/src/devices/wifi/nm-device-wifi.h b/src/devices/wifi/nm-device-wifi.h index 538aef0820..bcba91da2f 100644 --- a/src/devices/wifi/nm-device-wifi.h +++ b/src/devices/wifi/nm-device-wifi.h @@ -38,16 +38,6 @@ G_BEGIN_DECLS #define NM_IS_DEVICE_WIFI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_WIFI)) #define NM_DEVICE_WIFI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_WIFI, NMDeviceWifiClass)) -typedef enum { - NM_WIFI_ERROR_CONNECTION_NOT_WIRELESS = 0, /*< nick=ConnectionNotWireless >*/ - NM_WIFI_ERROR_CONNECTION_INVALID, /*< nick=ConnectionInvalid >*/ - NM_WIFI_ERROR_CONNECTION_INCOMPATIBLE, /*< nick=ConnectionIncompatible >*/ - NM_WIFI_ERROR_ACCESS_POINT_NOT_FOUND, /*< nick=AccessPointNotFound >*/ - NM_WIFI_ERROR_SCAN_NOT_ALLOWED, /*< nick=ScanNotAllowed >*/ - NM_WIFI_ERROR_AP_MODE_UNSUPPORTED, /*< nick=ApModeUnsupported >*/ - NM_WIFI_ERROR_ADHOC_MODE_UNSUPPORTED, /*< nick=AdhocModeUnsupported >*/ -} NMWifiError; - #define NM_DEVICE_WIFI_PERMANENT_HW_ADDRESS "perm-hw-address" #define NM_DEVICE_WIFI_MODE "mode" #define NM_DEVICE_WIFI_BITRATE "bitrate" diff --git a/src/devices/wifi/nm-wifi-ap-utils.c b/src/devices/wifi/nm-wifi-ap-utils.c index 19d8307e6d..85d76d2187 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 9ca49e4889..8a17722935 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 d428f1d2eb..ec892b68ff 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> @@ -109,19 +110,6 @@ typedef struct { /***********************************************************/ -#define NM_WIMAX_ERROR (nm_wimax_error_quark ()) - -static GQuark -nm_wimax_error_quark (void) -{ - static GQuark quark = 0; - if (!quark) - quark = g_quark_from_static_string ("nm-wimax-error"); - return quark; -} - -/***********************************************************/ - static gboolean impl_device_get_nsp_list (NMDeviceWimax *self, GPtrArray **nsps, GError **error) { @@ -383,8 +371,8 @@ complete_connection (NMDevice *device, /* If not given a specific object, we need at minimum an NSP name */ if (!s_wimax) { g_set_error_literal (error, - NM_WIMAX_ERROR, - NM_WIMAX_ERROR_CONNECTION_INVALID, + NM_DEVICE_ERROR, + NM_DEVICE_ERROR_INVALID_CONNECTION, "A 'wimax' setting is required if no NSP path was given."); return FALSE; } @@ -392,8 +380,8 @@ complete_connection (NMDevice *device, nsp_name = nm_setting_wimax_get_network_name (s_wimax); if (!nsp_name || !strlen (nsp_name)) { g_set_error_literal (error, - NM_WIMAX_ERROR, - NM_WIMAX_ERROR_CONNECTION_INVALID, + NM_DEVICE_ERROR, + NM_DEVICE_ERROR_INVALID_CONNECTION, "A 'wimax' setting with a valid network name is required if no NSP path was given."); return FALSE; } @@ -420,8 +408,8 @@ complete_connection (NMDevice *device, if (!nsp) { g_set_error (error, - NM_WIMAX_ERROR, - NM_WIMAX_ERROR_NSP_NOT_FOUND, + NM_DEVICE_ERROR, + NM_DEVICE_ERROR_SPECIFIC_OBJECT_NOT_FOUND, "The NSP %s was not in the scan list.", specific_object); return FALSE; @@ -451,10 +439,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 { @@ -1424,6 +1413,4 @@ nm_device_wimax_class_init (NMDeviceWimaxClass *klass) nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), G_TYPE_FROM_CLASS (klass), &dbus_glib_nm_device_wimax_object_info); - - dbus_g_error_domain_register (NM_WIMAX_ERROR, NULL, NM_TYPE_WIMAX_ERROR); } diff --git a/src/devices/wimax/nm-device-wimax.h b/src/devices/wimax/nm-device-wimax.h index b70c3f88bb..30b2481ffc 100644 --- a/src/devices/wimax/nm-device-wimax.h +++ b/src/devices/wimax/nm-device-wimax.h @@ -34,14 +34,6 @@ G_BEGIN_DECLS #define NM_IS_DEVICE_WIMAX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_WIMAX)) #define NM_DEVICE_WIMAX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_WIMAX, NMDeviceWimaxClass)) -typedef enum -{ - NM_WIMAX_ERROR_CONNECTION_NOT_WIMAX = 0, /*< nick=ConnectionNotWimax >*/ - NM_WIMAX_ERROR_CONNECTION_INVALID, /*< nick=ConnectionInvalid >*/ - NM_WIMAX_ERROR_CONNECTION_INCOMPATIBLE, /*< nick=ConnectionIncompatible >*/ - NM_WIMAX_ERROR_NSP_NOT_FOUND, /*< nick=NspNotFound >*/ -} NMWimaxError; - #define NM_DEVICE_WIMAX_NSPS "nsps" #define NM_DEVICE_WIMAX_ACTIVE_NSP "active-nsp" #define NM_DEVICE_WIMAX_CENTER_FREQUENCY "center-frequency" diff --git a/src/devices/wwan/nm-modem-broadband.c b/src/devices/wwan/nm-modem-broadband.c index ad2c8de4fa..a9ed5d5a82 100644 --- a/src/devices/wwan/nm-modem-broadband.c +++ b/src/devices/wwan/nm-modem-broadband.c @@ -224,8 +224,8 @@ connect_ready (MMModemSimple *simple_iface, nm_log_warn (LOGD_MB, "(%s) failed to connect modem: invalid bearer IP configuration", nm_modem_get_uid (NM_MODEM (self))); - error = g_error_new_literal (NM_MODEM_ERROR, - NM_MODEM_ERROR_CONNECTION_INVALID, + error = g_error_new_literal (NM_DEVICE_ERROR, + NM_DEVICE_ERROR_INVALID_CONNECTION, "invalid bearer IP configuration"); g_signal_emit_by_name (self, NM_MODEM_PREPARE_RESULT, FALSE, error); g_error_free (error); @@ -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; } @@ -511,8 +512,8 @@ complete_connection (NMModem *_self, } g_set_error (error, - NM_MODEM_ERROR, - NM_MODEM_ERROR_CONNECTION_INCOMPATIBLE, + NM_DEVICE_ERROR, + NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, "Device is not a mobile broadband modem"); return FALSE; } @@ -674,8 +675,8 @@ static_stage3_ip4_done (NMModemBroadband *self) /* Fully fail if invalid IP address retrieved */ address_string = mm_bearer_ip_config_get_address (self->priv->ipv4_config); if (!ip4_string_to_num (address_string, &address_network)) { - error = g_error_new (NM_MODEM_ERROR, - NM_MODEM_ERROR_CONNECTION_INVALID, + error = g_error_new (NM_DEVICE_ERROR, + NM_DEVICE_ERROR_INVALID_CONNECTION, "(%s) retrieving IP4 configuration failed: invalid address given '%s'", nm_modem_get_uid (NM_MODEM (self)), address_string); @@ -755,8 +756,8 @@ stage3_ip6_done (NMModemBroadband *self) if (!address_string) { /* DHCP/SLAAC is allowed to skip addresses; other methods require it */ if (ip_method != NM_MODEM_IP_METHOD_AUTO) { - error = g_error_new (NM_MODEM_ERROR, - NM_MODEM_ERROR_CONNECTION_INVALID, + error = g_error_new (NM_DEVICE_ERROR, + NM_DEVICE_ERROR_INVALID_CONNECTION, "(%s) retrieving IPv6 configuration failed: no address given", nm_modem_get_uid (NM_MODEM (self))); } @@ -765,8 +766,8 @@ stage3_ip6_done (NMModemBroadband *self) /* Fail if invalid IP address retrieved */ if (!inet_pton (AF_INET6, address_string, (void *) &(address.address))) { - error = g_error_new (NM_MODEM_ERROR, - NM_MODEM_ERROR_CONNECTION_INVALID, + error = g_error_new (NM_DEVICE_ERROR, + NM_DEVICE_ERROR_INVALID_CONNECTION, "(%s) retrieving IPv6 configuration failed: invalid address given '%s'", nm_modem_get_uid (NM_MODEM (self)), address_string); @@ -786,8 +787,8 @@ stage3_ip6_done (NMModemBroadband *self) address_string = mm_bearer_ip_config_get_gateway (self->priv->ipv6_config); if (address_string) { if (!inet_pton (AF_INET6, address_string, (void *) &(address.address))) { - error = g_error_new (NM_MODEM_ERROR, - NM_MODEM_ERROR_CONNECTION_INVALID, + error = g_error_new (NM_DEVICE_ERROR, + NM_DEVICE_ERROR_INVALID_CONNECTION, "(%s) retrieving IPv6 configuration failed: invalid gateway given '%s'", nm_modem_get_uid (NM_MODEM (self)), address_string); @@ -797,8 +798,8 @@ stage3_ip6_done (NMModemBroadband *self) nm_ip6_config_set_gateway (config, &address.address); } else if (ip_method == NM_MODEM_IP_METHOD_STATIC) { /* Gateway required for the 'static' method */ - error = g_error_new (NM_MODEM_ERROR, - NM_MODEM_ERROR_CONNECTION_INVALID, + error = g_error_new (NM_DEVICE_ERROR, + NM_DEVICE_ERROR_INVALID_CONNECTION, "(%s) retrieving IPv6 configuration failed: missing gateway", nm_modem_get_uid (NM_MODEM (self))); goto out; diff --git a/src/devices/wwan/nm-modem.c b/src/devices/wwan/nm-modem.c index 3860979902..431dc05c0b 100644 --- a/src/devices/wwan/nm-modem.c +++ b/src/devices/wwan/nm-modem.c @@ -100,17 +100,6 @@ static guint signals[LAST_SIGNAL] = { 0 }; /*****************************************************************************/ - -GQuark -nm_modem_error_quark (void) -{ - static GQuark quark = 0; - if (!quark) - quark = g_quark_from_static_string ("nm-modem-error"); - return quark; -} - -/*****************************************************************************/ /* State/enabled/connected */ static const char *state_table[] = { @@ -271,8 +260,8 @@ nm_modem_get_connection_ip_type (NMModem *self, if (ip4 && !ip6) { if (!(priv->ip_types & NM_MODEM_IP_TYPE_IPV4)) { g_set_error_literal (error, - NM_MODEM_ERROR, - NM_MODEM_ERROR_CONNECTION_INCOMPATIBLE, + NM_DEVICE_ERROR, + NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, "Connection requested IPv4 but IPv4 is " "unsuported by the modem."); return NM_MODEM_IP_TYPE_UNKNOWN; @@ -283,8 +272,8 @@ nm_modem_get_connection_ip_type (NMModem *self, if (ip6 && !ip4) { if (!(priv->ip_types & NM_MODEM_IP_TYPE_IPV6)) { g_set_error_literal (error, - NM_MODEM_ERROR, - NM_MODEM_ERROR_CONNECTION_INCOMPATIBLE, + NM_DEVICE_ERROR, + NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, "Connection requested IPv6 but IPv6 is " "unsuported by the modem."); return NM_MODEM_IP_TYPE_UNKNOWN; @@ -306,8 +295,8 @@ nm_modem_get_connection_ip_type (NMModem *self, return NM_MODEM_IP_TYPE_IPV6; g_set_error_literal (error, - NM_MODEM_ERROR, - NM_MODEM_ERROR_CONNECTION_INCOMPATIBLE, + NM_DEVICE_ERROR, + NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, "Connection requested both IPv4 and IPv6 " "but dual-stack addressing is unsupported " "by the modem."); @@ -315,8 +304,8 @@ nm_modem_get_connection_ip_type (NMModem *self, } g_set_error_literal (error, - NM_MODEM_ERROR, - NM_MODEM_ERROR_CONNECTION_INCOMPATIBLE, + NM_DEVICE_ERROR, + NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, "Connection specified no IP configuration!"); return NM_MODEM_IP_TYPE_UNKNOWN; } @@ -1400,8 +1389,4 @@ nm_modem_class_init (NMModemClass *klass) G_STRUCT_OFFSET (NMModemClass, state_changed), NULL, NULL, NULL, G_TYPE_NONE, 2, NM_TYPE_MODEM_STATE, NM_TYPE_MODEM_STATE); - - dbus_g_error_domain_register (NM_MODEM_ERROR, - NM_DBUS_INTERFACE_DEVICE_MODEM, - NM_TYPE_MODEM_ERROR); } diff --git a/src/devices/wwan/nm-modem.h b/src/devices/wwan/nm-modem.h index dba368d37d..2a4d917332 100644 --- a/src/devices/wwan/nm-modem.h +++ b/src/devices/wwan/nm-modem.h @@ -86,15 +86,6 @@ typedef enum { NM_MODEM_IP_TYPE_IPV4V6 = 0x4 } NMModemIPType; -typedef enum { - NM_MODEM_ERROR_CONNECTION_NOT_GSM, /*< nick=ConnectionNotGsm >*/ - NM_MODEM_ERROR_CONNECTION_NOT_CDMA, /*< nick=ConnectionNotCdma >*/ - NM_MODEM_ERROR_CONNECTION_INVALID, /*< nick=ConnectionInvalid >*/ - NM_MODEM_ERROR_CONNECTION_INCOMPATIBLE, /*< nick=ConnectionIncompatible >*/ - NM_MODEM_ERROR_INITIALIZATION_FAILED, /*< nick=InitializationFailed >*/ - NM_MODEM_ERROR_IP_CONFIG_INVALID, /*< nick=IpConfigInvalid >*/ -} NMModemError; - typedef enum { /*< underscore_name=nm_modem_state >*/ NM_MODEM_STATE_UNKNOWN = 0, NM_MODEM_STATE_FAILED = 1, @@ -111,9 +102,6 @@ typedef enum { /*< underscore_name=nm_modem_state >*/ NM_MODEM_STATE_CONNECTED = 12, } NMModemState; -#define NM_MODEM_ERROR (nm_modem_error_quark ()) -GQuark nm_modem_error_quark (void); - typedef struct { GObject parent; diff --git a/src/dhcp-manager/nm-dhcp-manager.c b/src/dhcp-manager/nm-dhcp-manager.c index f24aad8dcc..b19590a69b 100644 --- a/src/dhcp-manager/nm-dhcp-manager.c +++ b/src/dhcp-manager/nm-dhcp-manager.c @@ -44,17 +44,6 @@ #include "nm-glib-compat.h" #include "NetworkManagerUtils.h" -GQuark -nm_dhcp_manager_error_quark (void) -{ - static GQuark ret = 0; - - if (ret == 0) - ret = g_quark_from_static_string ("nm_dhcp_manager_error"); - - return ret; -} - #define NM_DHCP_CLIENT_DBUS_IFACE "org.freedesktop.nm_dhcp_client" #define DHCP_TIMEOUT 45 /* default DHCP timeout, in seconds */ @@ -298,7 +287,7 @@ get_client_type (const char *client, GError **error) return NM_TYPE_DHCP_DHCPCD; else { g_set_error_literal (error, - NM_DHCP_MANAGER_ERROR, NM_DHCP_MANAGER_ERROR_BAD_CLIENT, + NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED, _("no usable DHCP client could be found.")); return G_TYPE_INVALID; } @@ -307,7 +296,7 @@ get_client_type (const char *client, GError **error) if (!strcmp (client, "dhclient")) { if (!use_dhclient) { g_set_error_literal (error, - NM_DHCP_MANAGER_ERROR, NM_DHCP_MANAGER_ERROR_BAD_CLIENT, + NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED, _("'dhclient' could not be found or was disabled.")); return G_TYPE_INVALID; } @@ -317,7 +306,7 @@ get_client_type (const char *client, GError **error) if (!strcmp (client, "dhcpcd")) { if (!use_dhcpcd) { g_set_error_literal (error, - NM_DHCP_MANAGER_ERROR, NM_DHCP_MANAGER_ERROR_BAD_CLIENT, + NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED, _("'dhcpcd' could not be found or was disabled.")); return G_TYPE_INVALID; } @@ -325,7 +314,7 @@ get_client_type (const char *client, GError **error) } g_set_error (error, - NM_DHCP_MANAGER_ERROR, NM_DHCP_MANAGER_ERROR_BAD_CLIENT, + NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED, _("unsupported DHCP client '%s'"), client); return G_TYPE_INVALID; } diff --git a/src/dhcp-manager/nm-dhcp-manager.h b/src/dhcp-manager/nm-dhcp-manager.h index 16af333274..58fc23d28e 100644 --- a/src/dhcp-manager/nm-dhcp-manager.h +++ b/src/dhcp-manager/nm-dhcp-manager.h @@ -29,16 +29,6 @@ #include "nm-ip4-config.h" #include "nm-dhcp4-config.h" -typedef enum { - NM_DHCP_MANAGER_ERROR_BAD_CLIENT = 0, /*< nick=BadClient >*/ - NM_DHCP_MANAGER_ERROR_INTERNAL = 1, /*< nick=InternalError >*/ -} NMDhcpManagerError; - -#define NM_DHCP_MANAGER_ERROR (nm_dhcp_manager_error_quark ()) - -GQuark nm_dhcp_manager_error_quark (void); - - #define NM_TYPE_DHCP_MANAGER (nm_dhcp_manager_get_type ()) #define NM_DHCP_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP_MANAGER, NMDhcpManager)) #define NM_DHCP_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DHCP_MANAGER, NMDhcpManagerClass)) diff --git a/src/dns-manager/nm-dns-manager.c b/src/dns-manager/nm-dns-manager.c index e816436bbf..0d93d8bb41 100644 --- a/src/dns-manager/nm-dns-manager.c +++ b/src/dns-manager/nm-dns-manager.c @@ -348,8 +348,8 @@ write_resolv_conf (FILE *f, if (fprintf (f, "%s","# Generated by NetworkManager\n") < 0) { g_set_error (error, - NM_DNS_MANAGER_ERROR, - NM_DNS_MANAGER_ERROR_SYSTEM, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_FAILED, "Could not write " _PATH_RESCONF ": %s\n", g_strerror (errno)); return FALSE; @@ -414,8 +414,8 @@ dispatch_resolvconf (char **searches, nm_log_info (LOGD_DNS, "Writing DNS information to %s", RESOLVCONF_PATH); if ((f = popen (cmd, "w")) == NULL) g_set_error (error, - NM_DNS_MANAGER_ERROR, - NM_DNS_MANAGER_ERROR_SYSTEM, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_FAILED, "Could not write to %s: %s\n", RESOLVCONF_PATH, g_strerror (errno)); @@ -470,8 +470,8 @@ update_resolv_conf (char **searches, old_errno = errno; if ((f = fopen (_PATH_RESCONF, "w")) == NULL) { g_set_error (error, - NM_DNS_MANAGER_ERROR, - NM_DNS_MANAGER_ERROR_SYSTEM, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_FAILED, "Could not open %s: %s\nCould not open %s: %s\n", tmp_resolv_conf_realpath, g_strerror (old_errno), @@ -493,8 +493,8 @@ update_resolv_conf (char **searches, * since its error is more important. */ g_set_error (error, - NM_DNS_MANAGER_ERROR, - NM_DNS_MANAGER_ERROR_SYSTEM, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_FAILED, "Could not close %s: %s\n", tmp_resolv_conf_realpath, g_strerror (errno)); @@ -507,8 +507,8 @@ update_resolv_conf (char **searches, if (*error == NULL && do_rename) { if (rename (tmp_resolv_conf_realpath, resolv_conf_realpath) < 0) { g_set_error (error, - NM_DNS_MANAGER_ERROR, - NM_DNS_MANAGER_ERROR_SYSTEM, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_FAILED, "Could not replace " _PATH_RESCONF ": %s\n", g_strerror (errno)); } @@ -1055,16 +1055,6 @@ nm_dns_manager_get (void) return singleton; } -GQuark -nm_dns_manager_error_quark (void) -{ - static GQuark quark = 0; - if (!quark) - quark = g_quark_from_static_string ("nm_dns_manager_error"); - - return quark; -} - static void init_resolv_conf_mode (NMDnsManager *self) { diff --git a/src/dns-manager/nm-dns-manager.h b/src/dns-manager/nm-dns-manager.h index 367dec52d9..bc374fcf5f 100644 --- a/src/dns-manager/nm-dns-manager.h +++ b/src/dns-manager/nm-dns-manager.h @@ -29,21 +29,11 @@ #include "nm-ip6-config.h" typedef enum { - NM_DNS_MANAGER_ERROR_SYSTEM, - NM_DNS_MANAGER_ERROR_INVALID_NAMESERVER, - NM_DNS_MANAGER_ERROR_INVALID_HOST, - NM_DNS_MANAGER_ERROR_INVALID_ID -} NMDnsManagerError; - -typedef enum { NM_DNS_IP_CONFIG_TYPE_DEFAULT = 0, NM_DNS_IP_CONFIG_TYPE_BEST_DEVICE, NM_DNS_IP_CONFIG_TYPE_VPN } NMDnsIPConfigType; -#define NM_DNS_MANAGER_ERROR nm_dns_manager_error_quark () -GQuark nm_dns_manager_error_quark (void); - G_BEGIN_DECLS #define NM_TYPE_DNS_MANAGER (nm_dns_manager_get_type ()) diff --git a/src/dnsmasq-manager/nm-dnsmasq-manager.c b/src/dnsmasq-manager/nm-dnsmasq-manager.c index 7d6337e914..8cc397eac0 100644 --- a/src/dnsmasq-manager/nm-dnsmasq-manager.c +++ b/src/dnsmasq-manager/nm-dnsmasq-manager.c @@ -54,22 +54,6 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; -typedef enum { - NM_DNSMASQ_MANAGER_ERROR_NOT_FOUND, - NM_DNSMASQ_MANAGER_ERROR_INVALID_IP_RANGE, -} NMDnsMasqManagerError; - -GQuark -nm_dnsmasq_manager_error_quark (void) -{ - static GQuark quark; - - if (!quark) - quark = g_quark_from_static_string ("nm_dnsmasq_manager_error"); - - return quark; -} - static void nm_dnsmasq_manager_init (NMDnsMasqManager *manager) { @@ -282,8 +266,8 @@ create_dm_cmd_line (const char *iface, if (!nm_dnsmasq_utils_get_range (tmp, first, last, &error_desc)) { g_set_error_literal (error, - NM_DNSMASQ_MANAGER_ERROR, - NM_DNSMASQ_MANAGER_ERROR_INVALID_IP_RANGE, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_FAILED, error_desc); nm_log_warn (LOGD_SHARING, "Failed to find DHCP address ranges: %s", error_desc); g_free (error_desc); diff --git a/src/dnsmasq-manager/nm-dnsmasq-manager.h b/src/dnsmasq-manager/nm-dnsmasq-manager.h index c6afcd7cb0..257cc7559e 100644 --- a/src/dnsmasq-manager/nm-dnsmasq-manager.h +++ b/src/dnsmasq-manager/nm-dnsmasq-manager.h @@ -61,9 +61,4 @@ gboolean nm_dnsmasq_manager_start (NMDnsMasqManager *manager, void nm_dnsmasq_manager_stop (NMDnsMasqManager *manager); -#define NM_DNSMASQ_MANAGER_ERROR nm_dnsmasq_manager_error_quark() -#define NM_TYPE_DNSMASQ_MANAGER_ERROR (nm_dnsmasq_manager_error_get_type ()) - -GQuark nm_dnsmasq_manager_error_quark (void); - #endif /* __NETWORKMANAGER_DNSMASQ_MANAGER_H__ */ diff --git a/src/nm-auth-manager.c b/src/nm-auth-manager.c index 07996709d5..df849d58d6 100644 --- a/src/nm-auth-manager.c +++ b/src/nm-auth-manager.c @@ -21,7 +21,7 @@ #include "nm-auth-manager.h" #include "nm-logging.h" - +#include "nm-errors.h" #define POLKIT_SERVICE "org.freedesktop.PolicyKit1" #define POLKIT_OBJECT_PATH "/org/freedesktop/PolicyKit1/Authority" @@ -80,16 +80,6 @@ G_DEFINE_TYPE (NMAuthManager, nm_auth_manager, G_TYPE_OBJECT) #define NM_AUTH_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_AUTH_MANAGER, NMAuthManagerPrivate)) -GQuark -nm_auth_manager_error_quark (void) -{ - static GQuark quark = 0; - - if (G_UNLIKELY (quark == 0)) - quark = g_quark_from_static_string ("nm-auth-manager-error-quark"); - return quark; -} - /*****************************************************************************/ gboolean @@ -135,12 +125,13 @@ _call_check_authorization_complete_with_error (CheckAuthData *data, const char *error_message) { NMAuthManager *self = data->self; - GError *error = NULL; _LOGD ("call[%u]: CheckAuthorization failed due to internal error: %s", data->call_id, error_message); - g_set_error_literal (&error, NM_AUTH_MANAGER_ERROR, NM_AUTH_MANAGER_ERROR_DBUS_FAILURE, error_message); - g_simple_async_result_set_from_error (data->simple, error); - g_clear_error (&error); + g_simple_async_result_set_error (data->simple, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_FAILED, + "Authorization check failed: %s", + error_message); g_simple_async_result_complete_in_idle (data->simple); @@ -199,7 +190,11 @@ check_authorization_cb (GDBusProxy *proxy, g_object_ref (self)); } else _LOGD ("call[%u]: CheckAuthorization failed: %s", data->call_id, error->message); - g_simple_async_result_set_from_error (data->simple, error); + g_simple_async_result_set_error (data->simple, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_FAILED, + "Authorization check failed: %s", + error->message); g_error_free (error); } else { GVariant *result_value; diff --git a/src/nm-auth-manager.h b/src/nm-auth-manager.h index 06cd00867d..cc3b5d3c72 100644 --- a/src/nm-auth-manager.h +++ b/src/nm-auth-manager.h @@ -40,12 +40,6 @@ G_BEGIN_DECLS #define NM_AUTH_MANAGER_SIGNAL_CHANGED "changed" -#define NM_AUTH_MANAGER_ERROR (nm_auth_manager_error_quark ()) - -typedef enum { - NM_AUTH_MANAGER_ERROR_DBUS_FAILURE = 1, -} NMAuthManagerError; - typedef struct { GObject parent; } NMAuthManager; @@ -55,7 +49,6 @@ typedef struct { } NMAuthManagerClass; GType nm_auth_manager_get_type (void); -GQuark nm_auth_manager_error_quark (void); NMAuthManager *nm_auth_manager_setup (gboolean polkit_enabled); NMAuthManager *nm_auth_manager_get (void); diff --git a/src/nm-dcb.c b/src/nm-dcb.c index 3829e1a2e9..3dfa306c4c 100644 --- a/src/nm-dcb.c +++ b/src/nm-dcb.c @@ -29,16 +29,6 @@ #include "nm-posix-signals.h" #include "nm-logging.h" -GQuark -nm_dcb_error_quark (void) -{ - static GQuark ret = 0; - - if (ret == 0) - ret = g_quark_from_static_string ("nm-dcb-error"); - return ret; -} - static const char *helper_names[] = { "dcbtool", "fcoeadm" }; gboolean @@ -63,7 +53,7 @@ do_helper (const char *iface, split = g_strsplit_set (cmdline, " ", 0); if (!split) { - g_set_error (error, NM_DCB_ERROR, NM_DCB_ERROR_INTERNAL, + g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED, "failure parsing %s command line", helper_names[which]); goto out; } @@ -327,7 +317,7 @@ run_helper (char **argv, guint which, gpointer user_data, GError **error) if (ignore_error == FALSE) { nm_log_warn (LOGD_DCB, "'%s' failed: '%s'", cmdline, (errmsg && strlen (errmsg)) ? errmsg : outmsg); - g_set_error (error, NM_DCB_ERROR, NM_DCB_ERROR_HELPER_FAILED, + g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED, "Failed to run '%s'", cmdline); success = FALSE; } diff --git a/src/nm-dcb.h b/src/nm-dcb.h index 7c56d653af..e409dd4832 100644 --- a/src/nm-dcb.h +++ b/src/nm-dcb.h @@ -24,30 +24,6 @@ #include <glib.h> #include "nm-setting-dcb.h" -/** - * NMDcbError: - * @NM_DCB_ERROR_UNKNOWN: unknown or unclassified error - * @NM_DCB_ERROR_INTERNAL: a internal programmer error - * @NM_DCB_ERROR_BAD_CONFIG: configuration was invalid - * @NM_DCB_ERROR_HELPER_NOT_FOUND: the required helper program was not found - * @NM_DCB_ERROR_HELPER_FAILED: the helper program failed - * - * NOTE: these errors are internal-use only and should never be used with D-Bus. - **/ -typedef enum { - NM_DCB_ERROR_UNKNOWN = 0, - NM_DCB_ERROR_INTERNAL, - NM_DCB_ERROR_BAD_CONFIG, - NM_DCB_ERROR_HELPER_NOT_FOUND, - NM_DCB_ERROR_HELPER_FAILED, -} NMDcbError; - -#define NM_DCB_ERROR (nm_dcb_error_quark ()) -GQuark nm_dcb_error_quark (void); -#define NM_TYPE_DCB_ERROR (nm_dcb_error_get_type ()) -GType nm_dcb_error_get_type (void); - - gboolean nm_dcb_enable (const char *iface, gboolean enable, GError **error); gboolean nm_dcb_setup (const char *iface, NMSettingDcb *s_dcb, GError **error); gboolean nm_dcb_cleanup (const char *iface, GError **error); diff --git a/src/nm-logging.c b/src/nm-logging.c index 70d5304891..9dbc9f2618 100644 --- a/src/nm-logging.c +++ b/src/nm-logging.c @@ -36,6 +36,7 @@ #include "nm-glib-compat.h" #include "nm-logging.h" +#include "nm-errors.h" static void nm_log_handler (const gchar *log_domain, @@ -123,18 +124,6 @@ static const LogDesc domain_descs[] = { /************************************************************************/ -GQuark -nm_logging_error_quark (void) -{ - static GQuark ret = 0; - - if (ret == 0) - ret = g_quark_from_static_string ("nm_logging_error"); - return ret; -} - -/************************************************************************/ - static void _ensure_initialized () { @@ -156,7 +145,7 @@ match_log_level (const char *level, } } - g_set_error (error, NM_LOGGING_ERROR, NM_LOGGING_ERROR_UNKNOWN_LEVEL, + g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_LOG_LEVEL, _("Unknown log level '%s'"), level); return FALSE; } @@ -238,7 +227,7 @@ nm_logging_setup (const char *level, if (!bits) { if (!bad_domains) { - g_set_error (error, NM_LOGGING_ERROR, NM_LOGGING_ERROR_UNKNOWN_DOMAIN, + g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_LOG_DOMAIN, _("Unknown log domain '%s'"), *iter); return FALSE; } diff --git a/src/nm-logging.h b/src/nm-logging.h index 4239a20dda..d50ca8cbd0 100644 --- a/src/nm-logging.h +++ b/src/nm-logging.h @@ -86,15 +86,6 @@ enum { LOGL_MAX }; -typedef enum { - NM_LOGGING_ERROR_UNKNOWN_LEVEL = 0, /*< nick=UnknownLevel >*/ - NM_LOGGING_ERROR_UNKNOWN_DOMAIN = 1, /*< nick=UnknownDomain >*/ -} NMLoggingError; - -#define NM_LOGGING_ERROR (nm_logging_error_quark ()) -GQuark nm_logging_error_quark (void); - - #define nm_log_err(domain, ...) nm_log (LOGL_ERR, (domain), __VA_ARGS__) #define nm_log_warn(domain, ...) nm_log (LOGL_WARN, (domain), __VA_ARGS__) #define nm_log_info(domain, ...) nm_log (LOGL_INFO, (domain), __VA_ARGS__) diff --git a/src/nm-manager.c b/src/nm-manager.c index 959bc551f8..aa2224484e 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -250,19 +250,6 @@ enum { /************************************************************************/ -#define NM_MANAGER_ERROR (nm_manager_error_quark ()) - -static GQuark -nm_manager_error_quark (void) -{ - static GQuark quark = 0; - if (!quark) - quark = g_quark_from_static_string ("nm-manager-error"); - return quark; -} - -/************************************************************************/ - static void active_connection_state_changed (NMActiveConnection *active, GParamSpec *pspec, NMManager *self); @@ -1997,7 +1984,7 @@ _register_device_factory (NMManager *self, ftype = nm_device_factory_get_device_type (factory); for (iter = priv->factories; iter; iter = iter->next) { if (ftype == nm_device_factory_get_device_type (iter->data)) { - g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_INTERNAL, + g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED, "multiple plugins for same type (using '%s' instead of '%s')", (char *) g_object_get_data (G_OBJECT (iter->data), PLUGIN_PATH_TAG), path); @@ -2517,7 +2504,7 @@ ensure_master_active_connection (NMManager *self, /* Otherwise, the device is unmanaged, unavailable, or disconnecting */ g_set_error (error, NM_MANAGER_ERROR, - NM_MANAGER_ERROR_UNMANAGED_DEVICE, + NM_MANAGER_ERROR_DEPENDENCY_FAILED, "Master device %s unmanaged or not available for activation", nm_device_get_iface (master_device)); } else if (master_connection) { @@ -2692,7 +2679,7 @@ _internal_activate_device (NMManager *self, NMActiveConnection *active, GError * */ if (!nm_active_connection_get_user_requested (active) && !nm_device_autoconnect_allowed (device)) { - g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_AUTOCONNECT_NOT_ALLOWED, + g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_CONNECTION_NOT_AVAILABLE, "%s does not allow automatic connections at this time", nm_device_get_iface (device)); return FALSE; @@ -3361,9 +3348,10 @@ impl_manager_add_and_activate_connection (NMManager *self, if (vpn) { /* Try to fill the VPN's connection setting and name at least */ if (!nm_connection_get_setting_vpn (connection)) { - error = g_error_new_literal (NM_MANAGER_ERROR, - NM_MANAGER_ERROR_UNSUPPORTED_CONNECTION_TYPE, + error = g_error_new_literal (NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_SETTING, "VPN connections require a 'vpn' setting"); + g_prefix_error (&error, "%s: ", NM_SETTING_VPN_SETTING_NAME); goto error; } @@ -4677,7 +4665,7 @@ nm_manager_new (NMSettings *settings, bus = nm_dbus_manager_get_connection (priv->dbus_mgr); if (!bus) { - g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_INTERNAL, + g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED, "Failed to initialize D-Bus connection"); g_object_unref (singleton); return NULL; @@ -4701,7 +4689,7 @@ nm_manager_new (NMSettings *settings, G_CALLBACK (connectivity_changed), singleton); if (!dbus_connection_add_filter (dbus_connection, prop_filter, singleton, NULL)) { - g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_INTERNAL, + g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED, "Failed to register DBus connection filter"); g_object_unref (singleton); return NULL; @@ -5261,7 +5249,6 @@ nm_manager_class_init (NMManagerClass *manager_class) G_TYPE_FROM_CLASS (manager_class), &dbus_glib_nm_manager_object_info); - dbus_g_error_domain_register (NM_MANAGER_ERROR, NULL, NM_TYPE_MANAGER_ERROR); - dbus_g_error_domain_register (NM_LOGGING_ERROR, "org.freedesktop.NetworkManager.Logging", NM_TYPE_LOGGING_ERROR); + dbus_g_error_domain_register (NM_MANAGER_ERROR, NM_DBUS_INTERFACE, NM_TYPE_MANAGER_ERROR); } diff --git a/src/nm-manager.h b/src/nm-manager.h index 55b0b3fc9f..6413c71449 100644 --- a/src/nm-manager.h +++ b/src/nm-manager.h @@ -35,22 +35,6 @@ #define NM_IS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_MANAGER)) #define NM_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_MANAGER, NMManagerClass)) -typedef enum { - NM_MANAGER_ERROR_UNKNOWN_CONNECTION = 0, /*< nick=UnknownConnection >*/ - NM_MANAGER_ERROR_UNKNOWN_DEVICE, /*< nick=UnknownDevice >*/ - NM_MANAGER_ERROR_UNMANAGED_DEVICE, /*< nick=UnmanagedDevice >*/ - NM_MANAGER_ERROR_SYSTEM_CONNECTION, /*< nick=SystemConnection >*/ - NM_MANAGER_ERROR_PERMISSION_DENIED, /*< nick=PermissionDenied >*/ - NM_MANAGER_ERROR_CONNECTION_NOT_ACTIVE, /*< nick=ConnectionNotActive >*/ - NM_MANAGER_ERROR_ALREADY_ASLEEP_OR_AWAKE, /*< nick=AlreadyAsleepOrAwake >*/ - NM_MANAGER_ERROR_ALREADY_ENABLED_OR_DISABLED, /*< nick=AlreadyEnabledOrDisabled >*/ - NM_MANAGER_ERROR_UNSUPPORTED_CONNECTION_TYPE, /*< nick=UnsupportedConnectionType >*/ - NM_MANAGER_ERROR_DEPENDENCY_FAILED, /*< nick=DependencyFailed >*/ - NM_MANAGER_ERROR_AUTOCONNECT_NOT_ALLOWED, /*< nick=AutoconnectNotAllowed >*/ - NM_MANAGER_ERROR_CONNECTION_ALREADY_ACTIVE, /*< nick=ConnectionAlreadyActive >*/ - NM_MANAGER_ERROR_INTERNAL, /*< nick=Internal >*/ -} NMManagerError; - #define NM_MANAGER_VERSION "version" #define NM_MANAGER_STATE "state" #define NM_MANAGER_STARTUP "startup" diff --git a/src/nm-session-utils.c b/src/nm-session-utils.c index 269e2f81cf..e70f69ed1d 100644 --- a/src/nm-session-utils.c +++ b/src/nm-session-utils.c @@ -21,18 +21,7 @@ #include <sys/types.h> #include "nm-session-utils.h" - -/********************************************************************/ - -GQuark -nm_session_monitor_error_quark (void) -{ - static GQuark ret = 0; - - if (G_UNLIKELY (ret == 0)) - ret = g_quark_from_static_string ("nm-session-monitor-error"); - return ret; -} +#include "nm-errors.h" /********************************************************************/ @@ -44,8 +33,8 @@ nm_session_uid_to_user (uid_t uid, const char **out_user, GError **error) pw = getpwuid (uid); if (!pw) { g_set_error (error, - NM_SESSION_MONITOR_ERROR, - NM_SESSION_MONITOR_ERROR_UNKNOWN_USER, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_FAILED, "Could not get username for UID %d", uid); return FALSE; @@ -64,8 +53,8 @@ nm_session_user_to_uid (const char *user, uid_t *out_uid, GError **error) pw = getpwnam (user); if (!pw) { g_set_error (error, - NM_SESSION_MONITOR_ERROR, - NM_SESSION_MONITOR_ERROR_UNKNOWN_USER, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_FAILED, "Could not get UID for username '%s'", user); return FALSE; diff --git a/src/nm-session-utils.h b/src/nm-session-utils.h index 1608c222da..e626f52ae0 100644 --- a/src/nm-session-utils.h +++ b/src/nm-session-utils.h @@ -23,17 +23,6 @@ #include <glib.h> #include <glib-object.h> -#define NM_SESSION_MONITOR_ERROR (nm_session_monitor_error_quark ()) -GQuark nm_session_monitor_error_quark (void) G_GNUC_CONST; -GType nm_session_monitor_error_get_type (void) G_GNUC_CONST; - -typedef enum { - NM_SESSION_MONITOR_ERROR_IO_ERROR = 0, /*< nick=IOError >*/ - NM_SESSION_MONITOR_ERROR_MALFORMED_DATABASE, /*< nick=MalformedDatabase >*/ - NM_SESSION_MONITOR_ERROR_UNKNOWN_USER, /*< nick=UnknownUser >*/ - NM_SESSION_MONITOR_ERROR_NO_DATABASE, /*< nick=NoDatabase >*/ -} NMSessionMonitorError; - gboolean nm_session_uid_to_user (uid_t uid, const char **out_user, GError **error); gboolean nm_session_user_to_uid (const char *user, uid_t *out_uid, GError **error); diff --git a/src/ppp-manager/nm-ppp-manager.c b/src/ppp-manager/nm-ppp-manager.c index ac2fb9f7a3..a7bb62569e 100644 --- a/src/ppp-manager/nm-ppp-manager.c +++ b/src/ppp-manager/nm-ppp-manager.c @@ -118,21 +118,6 @@ enum { LAST_PROP }; -typedef enum { - NM_PPP_MANAGER_ERROR_UNKOWN -} NMPPPManagerError; - -GQuark -nm_ppp_manager_error_quark (void) -{ - static GQuark quark; - - if (!quark) - quark = g_quark_from_static_string ("nm_ppp_manager_error"); - - return quark; -} - static void nm_ppp_manager_init (NMPPPManager *manager) { @@ -388,7 +373,8 @@ extract_details_from_connection (NMConnection *connection, setting = nm_connection_get_setting_by_name (connection, setting_name); if (!setting) { - g_set_error_literal (error, NM_PPP_MANAGER_ERROR, NM_PPP_MANAGER_ERROR_UNKOWN, + /* This shouldn't ever happen */ + g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED, "Missing type-specific setting; no secrets could be found."); return FALSE; } @@ -1112,8 +1098,8 @@ nm_ppp_manager_start (NMPPPManager *manager, #if !WITH_PPP /* PPP support disabled */ g_set_error_literal (err, - NM_PPP_MANAGER_ERROR, - NM_PPP_MANAGER_ERROR_UNKOWN, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_FAILED, "PPP support is not enabled."); return FALSE; #endif diff --git a/src/ppp-manager/nm-ppp-manager.h b/src/ppp-manager/nm-ppp-manager.h index e074534e41..84be76d044 100644 --- a/src/ppp-manager/nm-ppp-manager.h +++ b/src/ppp-manager/nm-ppp-manager.h @@ -70,9 +70,4 @@ gboolean nm_ppp_manager_start (NMPPPManager *manager, GError **err); -#define NM_PPP_MANAGER_ERROR nm_ppp_manager_error_quark() -#define NM_TYPE_PPP_MANAGER_ERROR (nm_ppp_manager_error_get_type ()) - -GQuark nm_ppp_manager_error_quark (void); - #endif /* __NETWORKMANAGER_PPP_MANAGER_H__ */ diff --git a/src/settings/nm-agent-manager.c b/src/settings/nm-agent-manager.c index 1076ae2143..3028e42871 100644 --- a/src/settings/nm-agent-manager.c +++ b/src/settings/nm-agent-manager.c @@ -94,20 +94,6 @@ static void impl_agent_manager_unregister (NMAgentManager *self, #include "nm-agent-manager-glue.h" -/********************************************************************/ - -#define NM_AGENT_MANAGER_ERROR (nm_agent_manager_error_quark ()) - -static GQuark -nm_agent_manager_error_quark (void) -{ - static GQuark ret = 0; - - if (G_UNLIKELY (ret == 0)) - ret = g_quark_from_static_string ("nm-agent-manager-error"); - return ret; -} - /*************************************************************/ static gboolean @@ -293,7 +279,7 @@ impl_agent_manager_register_with_capabilities (NMAgentManager *self, subject = nm_auth_subject_new_unix_process_from_context (context); if (!subject) { error = g_error_new_literal (NM_AGENT_MANAGER_ERROR, - NM_AGENT_MANAGER_ERROR_SENDER_UNKNOWN, + NM_AGENT_MANAGER_ERROR_PERMISSION_DENIED, "Unable to determine request sender and UID."); goto done; } @@ -305,7 +291,7 @@ impl_agent_manager_register_with_capabilities (NMAgentManager *self, NULL, &local)) { error = g_error_new_literal (NM_AGENT_MANAGER_ERROR, - NM_AGENT_MANAGER_ERROR_SESSION_NOT_FOUND, + NM_AGENT_MANAGER_ERROR_PERMISSION_DENIED, local && local->message ? local->message : "Session not found"); goto done; } @@ -326,7 +312,7 @@ impl_agent_manager_register_with_capabilities (NMAgentManager *self, agent = nm_secret_agent_new (context, subject, identifier, capabilities); if (!agent) { error = g_error_new_literal (NM_AGENT_MANAGER_ERROR, - NM_AGENT_MANAGER_ERROR_INTERNAL_ERROR, + NM_AGENT_MANAGER_ERROR_FAILED, "Failed to initialize the agent"); goto done; } @@ -344,7 +330,7 @@ impl_agent_manager_register_with_capabilities (NMAgentManager *self, priv->chains = g_slist_append (priv->chains, chain); } else { error = g_error_new_literal (NM_AGENT_MANAGER_ERROR, - NM_AGENT_MANAGER_ERROR_SENDER_UNKNOWN, + NM_AGENT_MANAGER_ERROR_FAILED, "Unable to start agent authentication."); } @@ -378,7 +364,7 @@ impl_agent_manager_unregister (NMAgentManager *self, NULL, NULL)) { error = g_error_new_literal (NM_AGENT_MANAGER_ERROR, - NM_AGENT_MANAGER_ERROR_SENDER_UNKNOWN, + NM_AGENT_MANAGER_ERROR_PERMISSION_DENIED, "Unable to determine request sender."); goto done; } diff --git a/src/settings/nm-agent-manager.h b/src/settings/nm-agent-manager.h index 1aac2d2ae0..ac29df2291 100644 --- a/src/settings/nm-agent-manager.h +++ b/src/settings/nm-agent-manager.h @@ -34,17 +34,6 @@ #define NM_IS_AGENT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_AGENT_MANAGER)) #define NM_AGENT_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_AGENT_MANAGER, NMAgentManagerClass)) -typedef enum { - NM_AGENT_MANAGER_ERROR_SENDER_UNKNOWN = 0, /*< nick=SenderUnknown >*/ - NM_AGENT_MANAGER_ERROR_PERMISSION_DENIED, /*< nick=PermissionDenied >*/ - NM_AGENT_MANAGER_ERROR_SESSION_NOT_FOUND, /*< nick=SessionNotFound >*/ - NM_AGENT_MANAGER_ERROR_INVALID_IDENTIFIER, /*< nick=InvalidIdentifier >*/ - NM_AGENT_MANAGER_ERROR_NOT_REGISTERED, /*< nick=NotRegistered >*/ - NM_AGENT_MANAGER_ERROR_INTERNAL_ERROR, /*< nick=InternalError >*/ - NM_AGENT_MANAGER_ERROR_NO_SECRETS, /*< nick=NoSecrets >*/ - NM_AGENT_MANAGER_ERROR_USER_CANCELED /*< nick=UserCanceled >*/ -} NMAgentManagerError; - struct _NMAgentManager { GObject parent; }; diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c index fe3ba3af06..6fc158b182 100644 --- a/src/settings/nm-settings-connection.c +++ b/src/settings/nm-settings-connection.c @@ -33,7 +33,6 @@ #include "nm-settings-connection.h" #include "nm-session-monitor.h" #include "nm-dbus-manager.h" -#include "nm-settings-error.h" #include "nm-dbus-glib-types.h" #include "nm-logging.h" #include "nm-auth-utils.h" @@ -570,7 +569,7 @@ nm_settings_connection_commit_changes (NMSettingsConnection *connection, user_data); } else { GError *error = g_error_new (NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_INTERNAL_ERROR, + NM_SETTINGS_ERROR_FAILED, "%s: %s:%d commit_changes() unimplemented", __func__, __FILE__, __LINE__); if (callback) callback (connection, error, user_data); @@ -591,7 +590,7 @@ nm_settings_connection_delete (NMSettingsConnection *connection, user_data); } else { GError *error = g_error_new (NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_INTERNAL_ERROR, + NM_SETTINGS_ERROR_FAILED, "%s: %s:%d delete() unimplemented", __func__, __FILE__, __LINE__); if (callback) callback (connection, error, user_data); @@ -754,7 +753,7 @@ agent_secrets_done_cb (NMAgentManager *manager, } if (!nm_connection_get_setting_by_name (NM_CONNECTION (self), setting_name)) { - local = g_error_new (NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_SETTING, + local = g_error_new (NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_SETTING_NOT_FOUND, "%s.%d - Connection didn't have requested setting '%s'.", __FILE__, __LINE__, setting_name); callback (self, call_id, NULL, setting_name, local, callback_data); @@ -916,7 +915,7 @@ nm_settings_connection_get_secrets (NMSettingsConnection *self, * will clear secrets on this object's settings. */ if (!priv->system_secrets) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "%s.%d - Internal error; secrets cache invalid.", __FILE__, __LINE__); return 0; @@ -924,7 +923,7 @@ nm_settings_connection_get_secrets (NMSettingsConnection *self, /* Make sure the request actually requests something we can return */ if (!nm_connection_get_setting_by_name (NM_CONNECTION (self), setting_name)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_SETTING, + g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_SETTING_NOT_FOUND, "%s.%d - Connection didn't have requested setting '%s'.", __FILE__, __LINE__, setting_name); return 0; @@ -1009,7 +1008,7 @@ pk_auth_cb (NMAuthChain *chain, /* If our NMSettingsConnection is already gone, do nothing */ if (chain_error) { error = g_error_new (NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_GENERAL, + NM_SETTINGS_ERROR_FAILED, "Error checking authorization: %s", chain_error->message ? chain_error->message : "(unknown)"); } else if (result != NM_AUTH_CALL_RESULT_YES) { diff --git a/src/settings/nm-settings-error.c b/src/settings/nm-settings-error.c deleted file mode 100644 index fd4eca3647..0000000000 --- a/src/settings/nm-settings-error.c +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 Novell, Inc. - * Copyright (C) 2008 - 2011 Red Hat, Inc. - */ - -#include "nm-settings-error.h" - -GQuark -nm_settings_error_quark (void) -{ - static GQuark ret = 0; - - if (ret == 0) - ret = g_quark_from_static_string ("nm-settings-error"); - - return ret; -} diff --git a/src/settings/nm-settings-error.h b/src/settings/nm-settings-error.h deleted file mode 100644 index a63968a4b1..0000000000 --- a/src/settings/nm-settings-error.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 Novell, Inc. - * Copyright (C) 2008 - 2011 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_SETTINGS_ERROR_H__ -#define __NETWORKMANAGER_SETTINGS_ERROR_H__ - -#include <glib.h> -#include <glib-object.h> - -typedef enum { - NM_SETTINGS_ERROR_GENERAL = 0, /*< nick=GeneralError >*/ - NM_SETTINGS_ERROR_INVALID_CONNECTION, /*< nick=InvalidConnection >*/ - NM_SETTINGS_ERROR_READ_ONLY_CONNECTION, /*< nick=ReadOnlyConnection >*/ - NM_SETTINGS_ERROR_INTERNAL_ERROR, /*< nick=InternalError >*/ - NM_SETTINGS_ERROR_SECRETS_UNAVAILABLE, /*< nick=SecretsUnavailable >*/ - NM_SETTINGS_ERROR_SECRETS_REQUEST_CANCELED, /*< nick=SecretsRequestCanceled >*/ - NM_SETTINGS_ERROR_PERMISSION_DENIED, /*< nick=PermissionDenied >*/ - NM_SETTINGS_ERROR_INVALID_SETTING, /*< nick=InvalidSetting >*/ - NM_SETTINGS_ERROR_ADD_NOT_SUPPORTED, /*< nick=AddNotSupported >*/ - NM_SETTINGS_ERROR_UPDATE_NOT_SUPPORTED, /*< nick=UpdateNotSupported >*/ - NM_SETTINGS_ERROR_DELETE_NOT_SUPPORTED, /*< nick=DeleteNotSupported >*/ - NM_SETTINGS_ERROR_ADD_FAILED, /*< nick=AddFailed >*/ - NM_SETTINGS_ERROR_SAVE_HOSTNAME_NOT_SUPPORTED, /*< nick=SaveHostnameNotSupported >*/ - NM_SETTINGS_ERROR_SAVE_HOSTNAME_FAILED, /*< nick=SaveHostnameFailed >*/ - NM_SETTINGS_ERROR_HOSTNAME_INVALID, /*< nick=HostnameInvalid >*/ - NM_SETTINGS_ERROR_UUID_EXISTS, /*< nick=UuidExists >*/ -} NMSettingsError; - -#define NM_SETTINGS_ERROR (nm_settings_error_quark ()) -GQuark nm_settings_error_quark (void); - -#define NM_TYPE_SETTINGS_ERROR (nm_settings_error_get_type ()) -GType nm_settings_error_get_type (void); - -#endif /* __NETWORKMANAGER_SETTINGS_ERROR_H__ */ diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c index f4ab2839d4..1bf2734457 100644 --- a/src/settings/nm-settings.c +++ b/src/settings/nm-settings.c @@ -58,7 +58,6 @@ #include "nm-dbus-glib-types.h" #include "nm-settings.h" #include "nm-settings-connection.h" -#include "nm-settings-error.h" #include "nm-system-config-interface.h" #include "nm-logging.h" #include "nm-dbus-manager.h" @@ -834,9 +833,8 @@ claim_connection (NMSettings *self, } if (!nm_connection_normalize (NM_CONNECTION (connection), NULL, NULL, &error)) { - nm_log_warn (LOGD_SETTINGS, "plugin provided invalid connection: '%s' / '%s' invalid: %d", - g_type_name (nm_setting_lookup_type_by_quark (error->domain)), - error->message, error->code); + nm_log_warn (LOGD_SETTINGS, "plugin provided invalid connection: %s", + error->message); g_error_free (error); return; } @@ -953,7 +951,7 @@ nm_settings_add_connection (NMSettings *self, g_clear_error (&add_error); } - g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_ADD_FAILED, + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "No plugin supported adding this connection"); return NULL; } @@ -1035,7 +1033,7 @@ pk_add_cb (NMAuthChain *chain, if (chain_error) { error = g_error_new (NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_GENERAL, + NM_SETTINGS_ERROR_FAILED, "Error checking authorization: %s", chain_error->message ? chain_error->message : "(unknown)"); } else if (result != NM_AUTH_CALL_RESULT_YES) { @@ -1139,7 +1137,7 @@ nm_settings_add_connection_dbus (NMSettings *self, /* Do any of the plugins support adding? */ if (!get_plugin (self, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS)) { error = g_error_new_literal (NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_ADD_NOT_SUPPORTED, + NM_SETTINGS_ERROR_NOT_SUPPORTED, "None of the registered plugins support add."); goto done; } @@ -1363,7 +1361,7 @@ pk_hostname_cb (NMAuthChain *chain, /* If our NMSettingsConnection is already gone, do nothing */ if (chain_error) { error = g_error_new (NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_GENERAL, + NM_SETTINGS_ERROR_FAILED, "Error checking authorization: %s", chain_error->message ? chain_error->message : "(unknown)"); } else if (result != NM_AUTH_CALL_RESULT_YES) { @@ -1378,7 +1376,7 @@ pk_hostname_cb (NMAuthChain *chain, /* error will be cleared if any plugin supports saving the hostname */ error = g_error_new_literal (NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_SAVE_HOSTNAME_FAILED, + NM_SETTINGS_ERROR_FAILED, "Saving the hostname failed."); g_object_get (G_OBJECT (iter->data), NM_SYSTEM_CONFIG_INTERFACE_CAPABILITIES, &caps, NULL); @@ -1437,7 +1435,7 @@ impl_settings_save_hostname (NMSettings *self, /* Minimal validation of the hostname */ if (!validate_hostname (hostname)) { error = g_error_new_literal (NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_HOSTNAME_INVALID, + NM_SETTINGS_ERROR_INVALID_HOSTNAME, "The hostname was too long or contained invalid characters."); goto done; } @@ -1445,7 +1443,7 @@ impl_settings_save_hostname (NMSettings *self, /* Do any of the plugins support setting the hostname? */ if (!get_plugin (self, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME)) { error = g_error_new_literal (NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_SAVE_HOSTNAME_NOT_SUPPORTED, + NM_SETTINGS_ERROR_NOT_SUPPORTED, "None of the registered plugins support setting the hostname."); goto done; } @@ -1996,26 +1994,9 @@ nm_settings_class_init (NMSettingsClass *class) dbus_g_error_domain_register (NM_SETTINGS_ERROR, NM_DBUS_INTERFACE_SETTINGS, NM_TYPE_SETTINGS_ERROR); - - /* 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_error_domain_register (NM_CONNECTION_ERROR, + NM_DBUS_INTERFACE_SETTINGS_CONNECTION, + NM_TYPE_CONNECTION_ERROR); dbus_g_object_type_install_info (NM_TYPE_SETTINGS, &dbus_glib_nm_settings_object_info); diff --git a/src/settings/plugins/example/Makefile.am b/src/settings/plugins/example/Makefile.am index 8fc4aa92b1..b98f66ef44 100644 --- a/src/settings/plugins/example/Makefile.am +++ b/src/settings/plugins/example/Makefile.am @@ -24,7 +24,6 @@ libnm_settings_plugin_example_la_SOURCES = \ nm-example-connection.h \ plugin.c \ plugin.h \ - errors.c \ common.h \ reader.c \ writer.c diff --git a/src/settings/plugins/example/common.h b/src/settings/plugins/example/common.h index ed0be9a7f7..cf209fe0a8 100644 --- a/src/settings/plugins/example/common.h +++ b/src/settings/plugins/example/common.h @@ -33,17 +33,6 @@ #define EXAMPLE_DIR NMCONFDIR "/example-plugin" -/* Boilerplate stuff for the plugin's error domain. Bits of the code that - * create new errors in the plugin's domain will create errors of - * type EXAMPLE_PLUGIN_ERROR like so: - * - * error = g_error_new_literal (EXAMPLE_PLUGIN_ERROR, - * <specific error number>, - * "This is a really bad error."); - */ -#define EXAMPLE_PLUGIN_ERROR (example_plugin_error_quark ()) -GQuark example_plugin_error_quark (void); - /* Prototypes for the reader/writer functions */ NMConnection *connection_from_file (const char *filename, GError **error); diff --git a/src/settings/plugins/example/errors.c b/src/settings/plugins/example/errors.c deleted file mode 100644 index 8181f8a3a0..0000000000 --- a/src/settings/plugins/example/errors.c +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2012 Red Hat, Inc. - */ - -#include <glib.h> -#include "common.h" - -/* This is boilerplate code for defining the error domain that the plugin may - * return to NetworkManager for various operations. It just registers a - * GObject "quark" (a UUID really) for the error which allows glib to keep - * track of all the different error domains. - */ -GQuark -example_plugin_error_quark (void) -{ - static GQuark error_quark = 0; - - if (G_UNLIKELY (error_quark == 0)) - error_quark = g_quark_from_static_string ("example-plugin-error-quark"); - - return error_quark; -} - - diff --git a/src/settings/plugins/example/nm-example-connection.c b/src/settings/plugins/example/nm-example-connection.c index c634388e9f..858c67f216 100644 --- a/src/settings/plugins/example/nm-example-connection.c +++ b/src/settings/plugins/example/nm-example-connection.c @@ -89,7 +89,7 @@ nm_example_connection_new (const char *full_path, /* Make sure we have a UUID; just a sanity check */ uuid = nm_connection_get_uuid (NM_CONNECTION (object)); if (!uuid) { - g_set_error (error, EXAMPLE_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Connection in file %s had no UUID", full_path); g_object_unref (object); object = NULL; diff --git a/src/settings/plugins/example/plugin.c b/src/settings/plugins/example/plugin.c index 35fc4a0f63..bc5c06e99d 100644 --- a/src/settings/plugins/example/plugin.c +++ b/src/settings/plugins/example/plugin.c @@ -197,11 +197,8 @@ update_connection_settings_commit_cb (NMSettingsConnection *orig, GError *error, * an error here. */ if (error) { - nm_log_warn (LOGD_SETTINGS, "%s: '%s' / '%s' invalid: %d", - __func__, - error ? g_type_name (nm_setting_lookup_type_by_quark (error->domain)) : "(none)", - (error && error->message) ? error->message : "(none)", - error ? error->code : -1); + nm_log_warn (LOGD_SETTINGS, "%s: connection invalid: %s", + __func__, error->message); g_clear_error (&error); nm_settings_connection_signal_remove (orig); diff --git a/src/settings/plugins/ibft/Makefile.am b/src/settings/plugins/ibft/Makefile.am index c687cf3008..00a5d175f0 100644 --- a/src/settings/plugins/ibft/Makefile.am +++ b/src/settings/plugins/ibft/Makefile.am @@ -8,9 +8,7 @@ noinst_LTLIBRARIES = libibft-io.la libibft_io_la_SOURCES = \ reader.c \ - reader.h \ - errors.c \ - errors.h + reader.h AM_CPPFLAGS = \ -I$(top_srcdir)/src/ \ diff --git a/src/settings/plugins/ibft/errors.c b/src/settings/plugins/ibft/errors.c deleted file mode 100644 index ead26867bb..0000000000 --- a/src/settings/plugins/ibft/errors.c +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright 2014 Red Hat, Inc. - */ - -#include <glib.h> -#include "errors.h" - -GQuark -ibft_plugin_error_quark (void) -{ - static GQuark error_quark = 0; - - if (G_UNLIKELY (error_quark == 0)) - error_quark = g_quark_from_static_string ("ibft-plugin-error-quark"); - return error_quark; -} - - diff --git a/src/settings/plugins/ibft/errors.h b/src/settings/plugins/ibft/errors.h deleted file mode 100644 index cb3756775b..0000000000 --- a/src/settings/plugins/ibft/errors.h +++ /dev/null @@ -1,29 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright 2014 Red Hat, Inc. - */ - -#ifndef __ERRORS_H__ -#define __ERRORS_H__ - -#define IBFT_PLUGIN_ERROR (ibft_plugin_error_quark ()) -GQuark ibft_plugin_error_quark (void); - - -#endif /* __ERRORS_H__ */ - diff --git a/src/settings/plugins/ibft/nm-ibft-connection.c b/src/settings/plugins/ibft/nm-ibft-connection.c index 2ed4679e59..5558f0e7ab 100644 --- a/src/settings/plugins/ibft/nm-ibft-connection.c +++ b/src/settings/plugins/ibft/nm-ibft-connection.c @@ -25,7 +25,6 @@ #include <glib/gstdio.h> #include "nm-ibft-connection.h" -#include "errors.h" #include "reader.h" G_DEFINE_TYPE (NMIbftConnection, nm_ibft_connection, NM_TYPE_SETTINGS_CONNECTION) diff --git a/src/settings/plugins/ibft/plugin.c b/src/settings/plugins/ibft/plugin.c index c8f9b589d7..0fa19dab9a 100644 --- a/src/settings/plugins/ibft/plugin.c +++ b/src/settings/plugins/ibft/plugin.c @@ -32,12 +32,10 @@ #include "nm-dbus-glib-types.h" #include "nm-system-config-interface.h" -#include "nm-settings-error.h" #include "nm-logging.h" #include "NetworkManagerUtils.h" #include "plugin.h" -#include "errors.h" #include "reader.h" #include "nm-ibft-connection.h" diff --git a/src/settings/plugins/ibft/reader.c b/src/settings/plugins/ibft/reader.c index 57fdb34536..f7e845231f 100644 --- a/src/settings/plugins/ibft/reader.c +++ b/src/settings/plugins/ibft/reader.c @@ -45,7 +45,6 @@ #include "NetworkManagerUtils.h" #include "nm-logging.h" -#include "errors.h" #include "reader.h" #define PARSE_WARNING(msg...) nm_log_warn (LOGD_SETTINGS, " " msg) @@ -136,13 +135,13 @@ read_ibft_blocks (const char *iscsiadm_path, goto done; if (!WIFEXITED (status)) { - g_set_error (error, IBFT_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "iBFT: %s exited abnormally.", iscsiadm_path); goto done; } if (WEXITSTATUS (status) != 0) { - g_set_error (error, IBFT_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "iBFT: %s exited with error %d. Message: '%s'", iscsiadm_path, WEXITSTATUS (status), err ? err : "(none)"); goto done; @@ -263,7 +262,7 @@ parse_ibft_config (const GPtrArray *data, GError **error, ...) va_end (ap); if (!success) { - g_set_error_literal (error, IBFT_PLUGIN_ERROR, 0, + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "iBFT: failed to match at least one iscsiadm block field"); } return success; @@ -302,7 +301,7 @@ ip4_setting_add_from_block (const GPtrArray *block, goto error; if (!s_method) { - g_set_error_literal (error, IBFT_PLUGIN_ERROR, 0, + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "iBFT: malformed iscsiadm record: missing " ISCSI_BOOTPROTO_TAG); goto error; } @@ -313,7 +312,7 @@ ip4_setting_add_from_block (const GPtrArray *block, g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); goto success; } else if (g_ascii_strcasecmp (s_method, "static") != 0) { - g_set_error (error, IBFT_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "iBFT: malformed iscsiadm record: unknown " ISCSI_BOOTPROTO_TAG " '%s'.", s_method); goto error; @@ -324,7 +323,7 @@ ip4_setting_add_from_block (const GPtrArray *block, /* IP address */ if (!s_ipaddr || inet_pton (AF_INET, s_ipaddr, &ipaddr) != 1) { - g_set_error (error, IBFT_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "iBFT: malformed iscsiadm record: invalid IP address '%s'.", s_ipaddr); goto error; @@ -332,7 +331,7 @@ ip4_setting_add_from_block (const GPtrArray *block, /* Subnet/prefix */ if (!s_netmask || inet_pton (AF_INET, s_netmask, &netmask) != 1) { - g_set_error (error, IBFT_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "iBFT: malformed iscsiadm record: invalid subnet mask '%s'.", s_netmask); goto error; @@ -340,21 +339,21 @@ ip4_setting_add_from_block (const GPtrArray *block, prefix = nm_utils_ip4_netmask_to_prefix (netmask); if (s_gateway && inet_pton (AF_INET, s_gateway, &gateway) != 1) { - g_set_error (error, IBFT_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "iBFT: malformed iscsiadm record: invalid IP gateway '%s'.", s_gateway); goto error; } if (s_dns1 && inet_pton (AF_INET, s_dns1, &dns1) != 1) { - g_set_error (error, IBFT_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "iBFT: malformed iscsiadm record: invalid DNS1 address '%s'.", s_dns1); goto error; } if (s_dns2 && inet_pton (AF_INET, s_dns2, &dns2) != 1) { - g_set_error (error, IBFT_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "iBFT: malformed iscsiadm record: invalid DNS2 address '%s'.", s_dns2); goto error; @@ -400,7 +399,7 @@ connection_setting_add (const GPtrArray *block, NULL)) return FALSE; if (!s_hwaddr) { - g_set_error_literal (error, IBFT_PLUGIN_ERROR, 0, + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "iBFT: malformed iscsiadm record: missing " ISCSI_HWADDR_TAG); return FALSE; } @@ -472,7 +471,8 @@ vlan_setting_add_from_block (const GPtrArray *block, /* VLAN 0 is normally a valid VLAN ID, but in the iBFT case it means "no VLAN" */ vlan_id = nm_utils_ascii_str_to_int64 (vlan_id_str, 10, 1, 4095, -1); if (vlan_id == -1) { - g_set_error (error, IBFT_PLUGIN_ERROR, 0, "Invalid VLAN_ID '%s'", vlan_id_str); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid VLAN_ID '%s'", vlan_id_str); return FALSE; } @@ -495,13 +495,13 @@ wired_setting_add_from_block (const GPtrArray *block, g_assert (connection); if (!parse_ibft_config (block, NULL, ISCSI_HWADDR_TAG, &hwaddr, NULL)) { - g_set_error_literal (error, IBFT_PLUGIN_ERROR, 0, + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "iBFT: malformed iscsiadm record: missing " ISCSI_HWADDR_TAG); return FALSE; } if (!nm_utils_hwaddr_valid (hwaddr, ETH_ALEN)) { - g_set_error (error, IBFT_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "iBFT: malformed iscsiadm record: invalid " ISCSI_HWADDR_TAG " '%s'.", hwaddr); return FALSE; @@ -524,7 +524,7 @@ connection_from_block (const GPtrArray *block, GError **error) g_assert (block); if (!parse_ibft_config (block, error, ISCSI_IFACE_TAG, &iface, NULL)) { - g_set_error_literal (error, IBFT_PLUGIN_ERROR, 0, + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "iBFT: malformed iscsiadm record: missing " ISCSI_IFACE_TAG); return NULL; } diff --git a/src/settings/plugins/ibft/tests/Makefile.am b/src/settings/plugins/ibft/tests/Makefile.am index 62011759fa..9946d20859 100644 --- a/src/settings/plugins/ibft/tests/Makefile.am +++ b/src/settings/plugins/ibft/tests/Makefile.am @@ -27,7 +27,6 @@ noinst_PROGRAMS = test-ibft test_ibft_SOURCES = \ test-ibft.c \ - ../errors.c \ ../reader.c test_ibft_LDADD = \ diff --git a/src/settings/plugins/ibft/tests/test-ibft.c b/src/settings/plugins/ibft/tests/test-ibft.c index 8252dda769..8cf705a05a 100644 --- a/src/settings/plugins/ibft/tests/test-ibft.c +++ b/src/settings/plugins/ibft/tests/test-ibft.c @@ -35,7 +35,6 @@ #include "NetworkManagerUtils.h" -#include "errors.h" #include "reader.h" #include "nm-logging.h" @@ -208,7 +207,7 @@ test_read_ibft_bad_address (gconstpointer user_data) block = read_block (iscsiadm_path, expected_mac_address); connection = connection_from_block (block, &error); - g_assert_error (error, IBFT_PLUGIN_ERROR, 0); + g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION); g_assert (strstr (error->message, "iBFT: malformed iscsiadm record: invalid")); g_clear_error (&error); g_assert (connection == NULL); diff --git a/src/settings/plugins/ifcfg-rh/Makefile.am b/src/settings/plugins/ifcfg-rh/Makefile.am index 10064812d0..4989f4ba77 100644 --- a/src/settings/plugins/ifcfg-rh/Makefile.am +++ b/src/settings/plugins/ifcfg-rh/Makefile.am @@ -19,7 +19,6 @@ libifcfg_rh_io_la_SOURCES = \ reader.h \ writer.c \ writer.h \ - errors.c \ common.h \ utils.c \ utils.h diff --git a/src/settings/plugins/ifcfg-rh/common.h b/src/settings/plugins/ifcfg-rh/common.h index d9627bddeb..d78f375250 100644 --- a/src/settings/plugins/ifcfg-rh/common.h +++ b/src/settings/plugins/ifcfg-rh/common.h @@ -78,9 +78,5 @@ #define KEY_DCB_PG_STRICT "DCB_PG_STRICT" #define KEY_DCB_PG_UP2TC "DCB_PG_UP2TC" -#define IFCFG_PLUGIN_ERROR (ifcfg_plugin_error_quark ()) -GQuark ifcfg_plugin_error_quark (void); - - #endif /* __COMMON_H__ */ diff --git a/src/settings/plugins/ifcfg-rh/errors.c b/src/settings/plugins/ifcfg-rh/errors.c deleted file mode 100644 index 25039104a4..0000000000 --- a/src/settings/plugins/ifcfg-rh/errors.c +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2008 - 2009 Red Hat, Inc. - */ - -#include <glib.h> -#include "common.h" - -GQuark -ifcfg_plugin_error_quark (void) -{ - static GQuark error_quark = 0; - - if (G_UNLIKELY (error_quark == 0)) - error_quark = g_quark_from_static_string ("ifcfg-plugin-error-quark"); - - return error_quark; -} - - diff --git a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c b/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c index c933ed8484..a10743d64b 100644 --- a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c +++ b/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c @@ -143,20 +143,16 @@ nm_ifcfg_connection_new (NMConnection *source, NM_IFCFG_CONNECTION_UNMANAGED_SPEC, unmanaged_spec, NM_IFCFG_CONNECTION_UNRECOGNIZED_SPEC, unrecognized_spec, NULL); - if (object) { - /* Update our settings with what was read from the file */ - if (nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object), - tmp, - update_unsaved, - error)) { - /* Set the path and start monitoring */ - if (full_path) - nm_ifcfg_connection_set_path (NM_IFCFG_CONNECTION (object), full_path); - } else { - g_object_unref (object); - object = NULL; - } - } + /* Update our settings with what was read from the file */ + if (nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object), + tmp, + update_unsaved, + error)) { + /* Set the path and start monitoring */ + if (full_path) + nm_ifcfg_connection_set_path (NM_IFCFG_CONNECTION (object), full_path); + } else + g_clear_object (&object); g_object_unref (tmp); g_free (unhandled_spec); diff --git a/src/settings/plugins/ifcfg-rh/plugin.c b/src/settings/plugins/ifcfg-rh/plugin.c index f4a25effce..097ad0c902 100644 --- a/src/settings/plugins/ifcfg-rh/plugin.c +++ b/src/settings/plugins/ifcfg-rh/plugin.c @@ -47,7 +47,6 @@ #include "nm-dbus-glib-types.h" #include "plugin.h" #include "nm-system-config-interface.h" -#include "nm-settings-error.h" #include "nm-config.h" #include "nm-logging.h" #include "NetworkManagerUtils.h" @@ -142,7 +141,8 @@ _internal_new_connection (SCPluginIfcfg *self, if (local) g_propagate_error (error, local); else - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "(unknown)"); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "(unknown)"); return NULL; } @@ -789,7 +789,7 @@ impl_ifcfgrh_get_ifcfg_details (SCPluginIfcfg *plugin, if (!s_con) { g_set_error (error, NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_INTERNAL_ERROR, + NM_SETTINGS_ERROR_FAILED, "unable to retrieve the connection setting"); return FALSE; } @@ -798,7 +798,7 @@ impl_ifcfgrh_get_ifcfg_details (SCPluginIfcfg *plugin, if (!uuid) { g_set_error (error, NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_INTERNAL_ERROR, + NM_SETTINGS_ERROR_FAILED, "unable to get the UUID"); return FALSE; } @@ -807,7 +807,7 @@ impl_ifcfgrh_get_ifcfg_details (SCPluginIfcfg *plugin, if (!path) { g_set_error (error, NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_INTERNAL_ERROR, + NM_SETTINGS_ERROR_FAILED, "unable to get the connection D-Bus path"); return FALSE; } diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c index 1c6aa70cb2..60ca5b52c6 100644 --- a/src/settings/plugins/ifcfg-rh/reader.c +++ b/src/settings/plugins/ifcfg-rh/reader.c @@ -278,7 +278,7 @@ read_ip4_address (shvarFile *ifcfg, *out_addr = ip4_addr; success = TRUE; } else { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid %s IP4 address '%s'", tag, value); } g_free (value); @@ -300,7 +300,7 @@ parse_ip6_address (const char *value, *out_addr = in6addr_any; if (inet_pton (AF_INET6, value, &ip6_addr) <= 0) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid IP6 address '%s'", value); return FALSE; } @@ -416,7 +416,7 @@ read_full_ip4_address (shvarFile *ifcfg, errno = 0; prefix = strtol (value, NULL, 10); if (errno || prefix <= 0 || prefix > 32) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid IP4 prefix '%s'", value); g_free (value); goto done; @@ -447,7 +447,7 @@ read_full_ip4_address (shvarFile *ifcfg, /* Validate the prefix */ if (nm_ip4_address_get_prefix (addr) > 32) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing or invalid IP4 prefix '%d'", nm_ip4_address_get_prefix (addr)); goto done; @@ -523,7 +523,7 @@ read_one_ip4_route (shvarFile *ifcfg, /* Validate the prefix */ if ( !nm_ip4_route_get_prefix (route) || nm_ip4_route_get_prefix (route) > 32) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing or invalid IP4 prefix '%d'", nm_ip4_route_get_prefix (route)); goto out; @@ -537,7 +537,7 @@ read_one_ip4_route (shvarFile *ifcfg, errno = 0; metric = strtol (value, NULL, 10); if (errno || metric < 0) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid IP4 route metric '%s'", value); g_free (value); goto out; @@ -617,8 +617,8 @@ read_route_file_legacy (const char *filename, NMSettingIP4Config *s_ip4, GError g_regex_match (regex_to2, *iter, 0, &match_info); if (!g_match_info_matches (match_info)) { g_match_info_free (match_info); - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, - "Missing IP4 route destination address in record: '%s'", *iter); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing IP4 route destination address in record: '%s'", *iter); goto error; } } @@ -626,8 +626,8 @@ read_route_file_legacy (const char *filename, NMSettingIP4Config *s_ip4, GError if (!strcmp (dest, "default")) strcpy (dest, "0.0.0.0"); if (inet_pton (AF_INET, dest, &ip4_addr) != 1) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, - "Invalid IP4 route destination address '%s'", dest); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid IP4 route destination address '%s'", dest); g_free (dest); goto error; } @@ -642,8 +642,8 @@ read_route_file_legacy (const char *filename, NMSettingIP4Config *s_ip4, GError errno = 0; prefix_int = strtol (prefix, NULL, 10); if (errno || prefix_int <= 0 || prefix_int > 32) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, - "Invalid IP4 route destination prefix '%s'", prefix); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid IP4 route destination prefix '%s'", prefix); g_free (prefix); goto error; } @@ -656,7 +656,7 @@ read_route_file_legacy (const char *filename, NMSettingIP4Config *s_ip4, GError if (g_match_info_matches (match_info)) { char *next_hop = g_match_info_fetch (match_info, 1); if (inet_pton (AF_INET, next_hop, &ip4_addr) != 1) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid IP4 route gateway address '%s'", next_hop); g_match_info_free (match_info); @@ -680,7 +680,7 @@ read_route_file_legacy (const char *filename, NMSettingIP4Config *s_ip4, GError metric_int = strtol (metric, NULL, 10); if (errno || metric_int < 0) { g_match_info_free (match_info); - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid IP4 route metric '%s'", metric); g_free (metric); goto error; @@ -735,7 +735,7 @@ parse_full_ip6_address (shvarFile *ifcfg, /* Split the address and prefix */ list = g_strsplit_set (addr_str, "/", 2); if (g_strv_length (list) < 1) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid IP6 address '%s'", addr_str); goto error; } @@ -748,7 +748,7 @@ parse_full_ip6_address (shvarFile *ifcfg, if (!parse_ip6_address (ip_val, &tmp, error)) goto error; if (IN6_IS_ADDR_UNSPECIFIED (&tmp)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid IP6 address '%s'", ip_val); goto error; } @@ -761,7 +761,7 @@ parse_full_ip6_address (shvarFile *ifcfg, errno = 0; prefix = strtol (prefix_val, NULL, 10); if (errno || prefix <= 0 || prefix > 128) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid IP6 prefix '%s'", prefix_val); goto error; } @@ -873,8 +873,8 @@ read_route6_file (const char *filename, NMSettingIP6Config *s_ip6, GError **erro g_regex_match (regex_to2, *iter, 0, &match_info); if (!g_match_info_matches (match_info)) { g_match_info_free (match_info); - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, - "Missing IP6 route destination address in record: '%s'", *iter); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing IP6 route destination address in record: '%s'", *iter); goto error; } } @@ -887,8 +887,8 @@ read_route6_file (const char *filename, NMSettingIP6Config *s_ip6, GError **erro continue; } if (inet_pton (AF_INET6, dest, &ip6_addr) != 1) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, - "Invalid IP6 route destination address '%s'", dest); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid IP6 route destination address '%s'", dest); g_free (dest); goto error; } @@ -903,8 +903,8 @@ read_route6_file (const char *filename, NMSettingIP6Config *s_ip6, GError **erro errno = 0; prefix_int = strtol (prefix, NULL, 10); if (errno || prefix_int <= 0 || prefix_int > 128) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, - "Invalid IP6 route destination prefix '%s'", prefix); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid IP6 route destination prefix '%s'", prefix); g_free (prefix); goto error; } @@ -917,7 +917,7 @@ read_route6_file (const char *filename, NMSettingIP6Config *s_ip6, GError **erro if (g_match_info_matches (match_info)) { char *next_hop = g_match_info_fetch (match_info, 1); if (inet_pton (AF_INET6, next_hop, &ip6_addr) != 1) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid IPv6 route nexthop address '%s'", next_hop); g_match_info_free (match_info); @@ -941,7 +941,7 @@ read_route6_file (const char *filename, NMSettingIP6Config *s_ip6, GError **erro metric_int = strtol (metric, NULL, 10); if (errno || metric_int < 0 || metric_int > G_MAXUINT32) { g_match_info_free (match_info); - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid IP6 route metric '%s'", metric); g_free (metric); goto error; @@ -1040,7 +1040,7 @@ make_ip4_setting (shvarFile *ifcfg, NULL); return NM_SETTING (s_ip4); } else { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Unknown BOOTPROTO '%s'", value); g_free (value); goto done; @@ -1158,7 +1158,7 @@ make_ip4_setting (shvarFile *ifcfg, /* Static routes - route-<name> file */ route_path = utils_get_route_path (ifcfg->fileName); if (!route_path) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Could not get route file path for '%s'", ifcfg->fileName); goto done; } @@ -1527,7 +1527,7 @@ make_ip6_setting (shvarFile *ifcfg, /* Read static routes from route6-<interface> file */ route6_path = utils_get_route6_path (ifcfg->fileName); if (!route6_path) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Could not get route6 file path for '%s'", ifcfg->fileName); goto error; } @@ -1648,7 +1648,7 @@ read_dcb_app (shvarFile *ifcfg, if (success) success = (priority >= 0 && priority <= 7); if (!success) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid %s value '%s' (expected 0 - 7)", tmp, val); } @@ -1697,7 +1697,8 @@ read_dcb_bool_array (shvarFile *ifcfg, val = g_strstrip (val); if (strlen (val) != 8) { PARSE_WARNING ("%s value '%s' must be 8 characters long", prop, val); - g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, "boolean array must be 8 characters"); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "boolean array must be 8 characters"); goto out; } @@ -1705,7 +1706,8 @@ read_dcb_bool_array (shvarFile *ifcfg, for (i = 0; i < 8; i++) { if (val[i] != '0' && val[i] != '1') { PARSE_WARNING ("invalid %s value '%s': not all 0s and 1s", prop, val); - g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, "invalid boolean digit"); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "invalid boolean digit"); goto out; } set_func (s_dcb, i, (val[i] == '1')); @@ -1746,7 +1748,8 @@ read_dcb_uint_array (shvarFile *ifcfg, val = g_strstrip (val); if (strlen (val) != 8) { PARSE_WARNING ("%s value '%s' must be 8 characters long", prop, val); - g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, "uint array must be 8 characters"); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "uint array must be 8 characters"); goto out; } @@ -1759,7 +1762,8 @@ read_dcb_uint_array (shvarFile *ifcfg, else { PARSE_WARNING ("invalid %s value '%s': not 0 - 7%s", prop, val, f_allowed ? " or 'f'" : ""); - g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, "invalid uint digit"); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "invalid uint digit"); goto out; } } @@ -1800,14 +1804,16 @@ read_dcb_percent_array (shvarFile *ifcfg, split = g_strsplit_set (val, ",", 0); if (!split || (g_strv_length (split) != 8)) { PARSE_WARNING ("invalid %s percentage list value '%s'", prop, val); - g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, "percent array must be 8 elements"); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "percent array must be 8 elements"); goto out; } for (iter = split, i = 0; iter && *iter; iter++, i++) { if (!get_int (*iter, &tmp) || tmp < 0 || tmp > 100) { PARSE_WARNING ("invalid %s percentage value '%s'", prop, *iter); - g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, "invalid percent element"); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "invalid percent element"); goto out; } set_func (s_dcb, i, (guint) tmp); @@ -1816,7 +1822,8 @@ read_dcb_percent_array (shvarFile *ifcfg, if (sum_pct && (sum != 100)) { PARSE_WARNING ("%s percentages do not equal 100%%", prop); - g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, "invalid percentage sum"); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "invalid percentage sum"); goto out; } @@ -1865,7 +1872,8 @@ make_dcb_setting (shvarFile *ifcfg, g_object_set (G_OBJECT (s_dcb), NM_SETTING_DCB_APP_FCOE_MODE, val, NULL); else { PARSE_WARNING ("invalid FCoE mode '%s'", val); - g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, "invalid FCoE mode"); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "invalid FCoE mode"); g_free (val); g_object_unref (s_dcb); return FALSE; @@ -2016,7 +2024,7 @@ add_one_wep_key (shvarFile *ifcfg, while (*p) { if (!g_ascii_isxdigit (*p)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid hexadecimal WEP key."); goto out; } @@ -2030,7 +2038,7 @@ add_one_wep_key (shvarFile *ifcfg, while (*p) { if (!g_ascii_isprint ((int) (*p))) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid ASCII WEP key."); goto out; } @@ -2052,7 +2060,8 @@ add_one_wep_key (shvarFile *ifcfg, g_free (key); success = TRUE; } else - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "Invalid WEP key length."); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid WEP key length."); out: g_free (value); @@ -2137,7 +2146,7 @@ make_wep_setting (shvarFile *ifcfg, default_key_idx--; /* convert to [0...3] */ g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, default_key_idx, NULL); } else { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid default WEP key '%s'", value); g_free (value); goto error; @@ -2178,7 +2187,7 @@ make_wep_setting (shvarFile *ifcfg, } else if (!strcmp (lcase, "restricted")) { g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "shared", NULL); } else { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid WEP authentication algorithm '%s'", lcase); g_free (lcase); @@ -2200,7 +2209,7 @@ make_wep_setting (shvarFile *ifcfg, auth_alg = nm_setting_wireless_security_get_auth_alg (s_wsec); if (auth_alg && !strcmp (auth_alg, "shared")) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "WEP Shared Key authentication is invalid for " "unencrypted connections."); goto error; @@ -2328,7 +2337,7 @@ parse_wpa_psk (shvarFile *ifcfg, /* Verify the hex PSK; 64 digits */ while (*p) { if (!g_ascii_isxdigit (*p++)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid WPA_PSK (contains non-hexadecimal characters)"); goto out; } @@ -2346,7 +2355,7 @@ parse_wpa_psk (shvarFile *ifcfg, /* Length check */ if (strlen (hashed) < 8 || strlen (hashed) > 63) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid WPA_PSK (passphrases must be between " "8 and 63 characters long (inclusive))"); g_free (hashed); @@ -2356,7 +2365,7 @@ parse_wpa_psk (shvarFile *ifcfg, } if (!hashed) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid WPA_PSK (doesn't look like a passphrase or hex key)"); goto out; } @@ -2379,7 +2388,7 @@ eap_simple_reader (const char *eap_method, value = svGetValue (ifcfg, "IEEE_8021X_IDENTITY", FALSE); if (!value) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing IEEE_8021X_IDENTITY for EAP method '%s'.", eap_method); return FALSE; @@ -2399,7 +2408,7 @@ eap_simple_reader (const char *eap_method, } if (!value) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing IEEE_8021X_PASSWORD for EAP method '%s'.", eap_method); return FALSE; @@ -2460,7 +2469,7 @@ eap_tls_reader (const char *eap_method, value = svGetValue (ifcfg, "IEEE_8021X_IDENTITY", FALSE); if (!value) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing IEEE_8021X_IDENTITY for EAP method '%s'.", eap_method); return FALSE; @@ -2507,7 +2516,7 @@ eap_tls_reader (const char *eap_method, } if (!privkey_password) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing %s for EAP method '%s'.", pk_pw_key, eap_method); @@ -2518,7 +2527,7 @@ eap_tls_reader (const char *eap_method, /* The private key itself */ privkey = svGetValue (ifcfg, pk_key, FALSE); if (!privkey) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing %s for EAP method '%s'.", pk_key, eap_method); @@ -2555,7 +2564,7 @@ eap_tls_reader (const char *eap_method, || privkey_format == NM_SETTING_802_1X_CK_FORMAT_X509) { client_cert = svGetValue (ifcfg, cli_cert_key, FALSE); if (!client_cert) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing %s for EAP method '%s'.", cli_cert_key, eap_method); @@ -2631,7 +2640,7 @@ eap_peap_reader (const char *eap_method, else if (!strcmp (peapver, "1")) g_object_set (s_8021x, NM_SETTING_802_1X_PHASE1_PEAPVER, "1", NULL); else { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Unknown IEEE_8021X_PEAP_VERSION value '%s'", peapver); goto done; @@ -2647,7 +2656,7 @@ eap_peap_reader (const char *eap_method, inner_auth = svGetValue (ifcfg, "IEEE_8021X_INNER_AUTH_METHODS", FALSE); if (!inner_auth) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing IEEE_8021X_INNER_AUTH_METHODS."); goto done; } @@ -2667,7 +2676,7 @@ eap_peap_reader (const char *eap_method, if (!eap_tls_reader (*iter, ifcfg, keys, s_8021x, TRUE, error)) goto done; } else { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Unknown IEEE_8021X_INNER_AUTH_METHOD '%s'.", *iter); goto done; @@ -2680,7 +2689,7 @@ eap_peap_reader (const char *eap_method, } if (!nm_setting_802_1x_get_phase2_auth (s_8021x)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "No valid IEEE_8021X_INNER_AUTH_METHODS found."); goto done; } @@ -2734,7 +2743,7 @@ eap_ttls_reader (const char *eap_method, tmp = svGetValue (ifcfg, "IEEE_8021X_INNER_AUTH_METHODS", FALSE); if (!tmp) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing IEEE_8021X_INNER_AUTH_METHODS."); goto done; } @@ -2766,7 +2775,7 @@ eap_ttls_reader (const char *eap_method, goto done; g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTHEAP, (*iter + STRLEN ("eap-")), NULL); } else { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Unknown IEEE_8021X_INNER_AUTH_METHOD '%s'.", *iter); goto done; @@ -2834,7 +2843,7 @@ eap_fast_reader (const char *eap_method, g_object_set (s_8021x, NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING, pac_prov_str, NULL); if (!pac_file && !(allow_unauth || allow_auth)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "IEEE_8021X_PAC_FILE not provided and EAP-FAST automatic PAC provisioning disabled."); goto done; } @@ -2845,7 +2854,7 @@ eap_fast_reader (const char *eap_method, inner_auth = svGetValue (ifcfg, "IEEE_8021X_INNER_AUTH_METHODS", FALSE); if (!inner_auth) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing IEEE_8021X_INNER_AUTH_METHODS."); goto done; } @@ -2861,7 +2870,7 @@ eap_fast_reader (const char *eap_method, if (!eap_simple_reader (*iter, ifcfg, keys, s_8021x, TRUE, error)) goto done; } else { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Unknown IEEE_8021X_INNER_AUTH_METHOD '%s'.", *iter); goto done; @@ -2874,7 +2883,7 @@ eap_fast_reader (const char *eap_method, } if (!nm_setting_802_1x_get_phase2_auth (s_8021x)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "No valid IEEE_8021X_INNER_AUTH_METHODS found."); goto done; } @@ -2955,7 +2964,7 @@ fill_8021x (shvarFile *ifcfg, value = svGetValue (ifcfg, "IEEE_8021X_EAP_METHODS", FALSE); if (!value) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing IEEE_8021X_EAP_METHODS for key management '%s'", key_mgmt); return NULL; @@ -3009,7 +3018,7 @@ fill_8021x (shvarFile *ifcfg, } if (nm_setting_802_1x_get_num_eap_methods (s_8021x) == 0) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "No valid EAP methods found in IEEE_8021X_EAP_METHODS."); goto error; } @@ -3119,7 +3128,7 @@ make_wpa_setting (shvarFile *ifcfg, } else if (!strcmp (value, "WPA-EAP") || !strcmp (value, "IEEE8021X")) { /* Adhoc mode is mutually exclusive with any 802.1x-based authentication */ if (adhoc) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Ad-Hoc mode cannot be used with KEY_MGMT type '%s'", value); goto error; } @@ -3132,7 +3141,7 @@ make_wpa_setting (shvarFile *ifcfg, g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, lower, NULL); g_free (lower); } else { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Unknown wireless KEY_MGMT type '%s'", value); goto error; } @@ -3191,7 +3200,7 @@ make_leap_setting (shvarFile *ifcfg, value = svGetValue (ifcfg, "IEEE_8021X_IDENTITY", FALSE); if (!value || !strlen (value)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing LEAP identity"); goto error; } @@ -3320,7 +3329,7 @@ make_wireless_setting (shvarFile *ifcfg, } else if ((value_len > 2) && (strncmp (value, "0x", 2) == 0)) { /* Hex representation */ if (value_len % 2) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid SSID '%s' size (looks like hex but length not multiple of 2)", value); g_free (value); @@ -3330,7 +3339,7 @@ make_wireless_setting (shvarFile *ifcfg, p = value + 2; while (*p) { if (!g_ascii_isxdigit (*p)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid SSID '%s' character (looks like hex SSID but '%c' isn't a hex digit)", value, *p); g_free (value); @@ -3347,7 +3356,7 @@ make_wireless_setting (shvarFile *ifcfg, } if (ssid_len > 32 || ssid_len == 0) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid SSID '%s' (size %zu not between 1 and 32 inclusive)", value, ssid_len); g_free (value); @@ -3373,7 +3382,7 @@ make_wireless_setting (shvarFile *ifcfg, } else if (!strcmp (lcase, "managed") || !strcmp (lcase, "auto")) { mode = "infrastructure"; } else { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid mode '%s' (not 'Ad-Hoc', 'Managed', or 'Auto')", lcase); g_free (lcase); @@ -3396,7 +3405,7 @@ make_wireless_setting (shvarFile *ifcfg, errno = 0; chan = nm_utils_ascii_str_to_int64 (value, 10, 1, 196, 0); if (errno || (chan == 0)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid wireless channel '%s'", value); g_free (value); goto error; @@ -3409,20 +3418,20 @@ make_wireless_setting (shvarFile *ifcfg, if (value) { if (!strcmp (value, "a")) { if (chan && chan <= 14) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Band '%s' invalid for channel %u", value, (guint32) chan); g_free (value); goto error; } } else if (!strcmp (value, "bg")) { if (chan && chan > 14) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Band '%s' invalid for channel %u", value, (guint32) chan); g_free (value); goto error; } } else { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid wireless band '%s'", value); g_free (value); goto error; @@ -3443,7 +3452,7 @@ make_wireless_setting (shvarFile *ifcfg, errno = 0; mtu = strtol (value, NULL, 10); if (errno || mtu < 0 || mtu > 50000) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid wireless MTU '%s'", value); g_free (value); goto error; @@ -3525,7 +3534,7 @@ wireless_connection_from_ifcfg (const char *file, printable_ssid, NULL); g_free (printable_ssid); if (!con_setting) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Failed to create connection setting."); g_object_unref (connection); return NULL; @@ -3663,7 +3672,7 @@ make_wired_setting (shvarFile *ifcfg, if (!*s_8021x) goto error; } else { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Unknown wired KEY_MGMT type '%s'", value); goto error; } @@ -3695,7 +3704,7 @@ wired_connection_from_ifcfg (const char *file, con_setting = make_connection_setting (file, ifcfg, NM_SETTING_WIRED_SETTING_NAME, NULL, NULL); if (!con_setting) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Failed to create connection setting."); g_object_unref (connection); return NULL; @@ -3776,7 +3785,7 @@ parse_infiniband_p_key (shvarFile *ifcfg, g_free (ifname); if (!ret) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Failed to create InfiniBand setting."); } return ret; @@ -3852,7 +3861,7 @@ infiniband_connection_from_ifcfg (const char *file, con_setting = make_connection_setting (file, ifcfg, NM_SETTING_INFINIBAND_SETTING_NAME, NULL, NULL); if (!con_setting) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Failed to create connection setting."); g_object_unref (connection); return NULL; @@ -3908,7 +3917,8 @@ make_bond_setting (shvarFile *ifcfg, value = svGetValue (ifcfg, "DEVICE", FALSE); if (!value || !strlen (value)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "mandatory DEVICE keyword missing"); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "mandatory DEVICE keyword missing"); goto error; } g_free (value); @@ -3962,7 +3972,7 @@ bond_connection_from_ifcfg (const char *file, con_setting = make_connection_setting (file, ifcfg, NM_SETTING_BOND_SETTING_NAME, NULL, _("Bond")); if (!con_setting) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Failed to create connection setting."); g_object_unref (connection); return NULL; @@ -4007,7 +4017,8 @@ read_team_config (shvarFile *ifcfg, const char *key, GError **error) */ l = strlen (value); if (l > 20000) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "%s too long (size %zd)", key, l); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "%s too long (size %zd)", key, l); g_free (value); return NULL; } @@ -4028,7 +4039,8 @@ make_team_setting (shvarFile *ifcfg, value = svGetValue (ifcfg, "DEVICE", FALSE); if (!value || !strlen (value)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "mandatory DEVICE keyword missing"); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "mandatory DEVICE keyword missing"); goto error; } g_free (value); @@ -4066,7 +4078,7 @@ team_connection_from_ifcfg (const char *file, con_setting = make_connection_setting (file, ifcfg, NM_SETTING_TEAM_SETTING_NAME, NULL, _("Team")); if (!con_setting) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Failed to create connection setting."); g_object_unref (connection); return NULL; @@ -4178,7 +4190,8 @@ make_bridge_setting (shvarFile *ifcfg, value = svGetValue (ifcfg, "DEVICE", FALSE); if (!value || !strlen (value)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "mandatory DEVICE keyword missing"); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "mandatory DEVICE keyword missing"); goto error; } g_free (value); @@ -4250,7 +4263,7 @@ bridge_connection_from_ifcfg (const char *file, con_setting = make_connection_setting (file, ifcfg, NM_SETTING_BRIDGE_SETTING_NAME, NULL, _("Bridge")); if (!con_setting) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Failed to create connection setting."); g_object_unref (connection); return NULL; @@ -4424,7 +4437,8 @@ make_vlan_setting (shvarFile *ifcfg, errno = 0; vlan_id = (gint) g_ascii_strtoll (value, NULL, 10); if (vlan_id < 0 || vlan_id > 4096 || errno) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "Invalid VLAN_ID '%s'", value); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid VLAN_ID '%s'", value); g_free (value); return NULL; } @@ -4434,7 +4448,7 @@ make_vlan_setting (shvarFile *ifcfg, /* Need DEVICE if we don't have a separate VLAN_ID property */ iface_name = svGetValue (ifcfg, "DEVICE", FALSE); if (!iface_name && vlan_id < 0) { - g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing DEVICE property; cannot determine VLAN ID."); return NULL; } @@ -4471,7 +4485,7 @@ make_vlan_setting (shvarFile *ifcfg, */ vlan_id = (gint) g_ascii_strtoll (p, &end, 10); if (vlan_id < 0 || vlan_id > 4095 || end == p || *end) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Failed to determine VLAN ID from DEVICE '%s'", iface_name); goto error; @@ -4480,14 +4494,14 @@ make_vlan_setting (shvarFile *ifcfg, } if (vlan_id < 0) { - g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Failed to determine VLAN ID from DEVICE or VLAN_ID."); goto error; } g_object_set (s_vlan, NM_SETTING_VLAN_ID, vlan_id, NULL); if (parent == NULL) { - g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Failed to determine VLAN parent from DEVICE or PHYSDEV"); goto error; } @@ -4537,8 +4551,8 @@ vlan_connection_from_ifcfg (const char *file, con_setting = make_connection_setting (file, ifcfg, NM_SETTING_VLAN_SETTING_NAME, NULL, "Vlan"); if (!con_setting) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, - "Failed to create connection setting."); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Failed to create connection setting."); g_object_unref (connection); return NULL; } @@ -4706,7 +4720,7 @@ connection_from_file (const char *filename, ifcfg_name = utils_get_ifcfg_name (filename, TRUE); if (!ifcfg_name) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Ignoring connection '%s' because it's not an ifcfg file.", filename); return NULL; } @@ -4729,7 +4743,7 @@ connection_from_file (const char *filename, if (bootproto && !g_ascii_strcasecmp (bootproto, "ibft")) { if (out_ignore_error) *out_ignore_error = TRUE; - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Ignoring iBFT configuration"); g_free (bootproto); goto done; @@ -4754,7 +4768,7 @@ connection_from_file (const char *filename, device = svGetValue (parsed, "DEVICE", FALSE); if (!device) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "File '%s' had neither TYPE nor DEVICE keys.", filename); goto done; } @@ -4762,7 +4776,7 @@ connection_from_file (const char *filename, if (!strcmp (device, "lo")) { if (out_ignore_error) *out_ignore_error = TRUE; - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Ignoring loopback device config."); g_free (device); goto done; @@ -4796,7 +4810,7 @@ connection_from_file (const char *filename, if (svTrueValue (parsed, "BONDING_MASTER", FALSE) && strcasecmp (type, TYPE_BOND)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "BONDING_MASTER=yes key only allowed in TYPE=bond connections"); goto done; } diff --git a/src/settings/plugins/ifcfg-rh/tests/Makefile.am b/src/settings/plugins/ifcfg-rh/tests/Makefile.am index e3eae46609..5a17ed9bb6 100644 --- a/src/settings/plugins/ifcfg-rh/tests/Makefile.am +++ b/src/settings/plugins/ifcfg-rh/tests/Makefile.am @@ -31,7 +31,6 @@ noinst_PROGRAMS = test-ifcfg-rh test-ifcfg-rh-utils test_ifcfg_rh_SOURCES = \ test-ifcfg-rh.c \ - ../errors.c \ ../reader.c \ ../shvar.c \ ../utils.c \ diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c index 03caff5f81..3558f825c5 100644 --- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c +++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c @@ -5952,7 +5952,7 @@ test_read_wifi_band_a_channel_mismatch (void) connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-band-a-channel-mismatch", NULL, TYPE_WIRELESS, NULL, NULL, NULL, NULL, &error, NULL); g_assert (connection == NULL); - g_assert_error (error, IFCFG_PLUGIN_ERROR, 0); + g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION); } static void @@ -5964,7 +5964,7 @@ test_read_wifi_band_bg_channel_mismatch (void) connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-band-bg-channel-mismatch", NULL, TYPE_WIRELESS, NULL, NULL, NULL, NULL, &error, NULL); g_assert (connection == NULL); - g_assert_error (error, IFCFG_PLUGIN_ERROR, 0); + g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION); } #define TEST_IFCFG_WIRED_QETH_STATIC TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-qeth-static" @@ -12287,7 +12287,7 @@ test_read_ibft_ignored (void) connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-ibft", NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); - g_assert_error (error, IFCFG_PLUGIN_ERROR, 0); + g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION); g_assert (connection == NULL); } @@ -13169,7 +13169,7 @@ test_read_dcb_bad_booleans (void) NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); g_test_assert_expected_messages (); - g_assert_error (error, IFCFG_PLUGIN_ERROR, 0); + g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION); g_assert (strstr (error->message, "invalid boolean digit")); g_assert (connection == NULL); } @@ -13186,7 +13186,7 @@ test_read_dcb_short_booleans (void) NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); g_test_assert_expected_messages (); - g_assert_error (error, IFCFG_PLUGIN_ERROR, 0); + g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION); g_assert (strstr (error->message, "boolean array must be 8 characters")); g_assert (connection == NULL); } @@ -13203,7 +13203,7 @@ test_read_dcb_bad_uints (void) NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); g_test_assert_expected_messages (); - g_assert_error (error, IFCFG_PLUGIN_ERROR, 0); + g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION); g_assert (strstr (error->message, "invalid uint digit")); g_assert (connection == NULL); } @@ -13220,7 +13220,7 @@ test_read_dcb_short_uints (void) NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); g_test_assert_expected_messages (); - g_assert_error (error, IFCFG_PLUGIN_ERROR, 0); + g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION); g_assert (strstr (error->message, "uint array must be 8 characters")); g_assert (connection == NULL); } @@ -13237,7 +13237,7 @@ test_read_dcb_bad_percent (void) NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); g_test_assert_expected_messages (); - g_assert_error (error, IFCFG_PLUGIN_ERROR, 0); + g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION); g_assert (strstr (error->message, "invalid percent element")); g_assert (connection == NULL); } @@ -13254,7 +13254,7 @@ test_read_dcb_short_percent (void) NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); g_test_assert_expected_messages (); - g_assert_error (error, IFCFG_PLUGIN_ERROR, 0); + g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION); g_assert (strstr (error->message, "percent array must be 8 elements")); g_assert (connection == NULL); } @@ -13271,7 +13271,7 @@ test_read_dcb_pgpct_not_100 (void) NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL); g_test_assert_expected_messages (); - g_assert_error (error, IFCFG_PLUGIN_ERROR, 0); + g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION); g_assert (strstr (error->message, "invalid percentage sum")); g_assert (connection == NULL); } diff --git a/src/settings/plugins/ifcfg-rh/writer.c b/src/settings/plugins/ifcfg-rh/writer.c index 70c0e1b024..90bbe71eb2 100644 --- a/src/settings/plugins/ifcfg-rh/writer.c +++ b/src/settings/plugins/ifcfg-rh/writer.c @@ -148,7 +148,7 @@ write_secret_file (const char *path, errno = 0; fd = mkstemp (tmppath); if (fd < 0) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Could not create temporary file for '%s': %d", path, errno); goto out; @@ -159,7 +159,7 @@ write_secret_file (const char *path, if (fchmod (fd, S_IRUSR | S_IWUSR)) { close (fd); unlink (tmppath); - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Could not set permissions for temporary file '%s': %d", path, errno); goto out; @@ -170,7 +170,7 @@ write_secret_file (const char *path, if (written != len) { close (fd); unlink (tmppath); - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Could not write temporary file for '%s': %d", path, errno); goto out; @@ -181,7 +181,7 @@ write_secret_file (const char *path, errno = 0; if (rename (tmppath, path)) { unlink (tmppath); - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Could not rename temporary file to '%s': %d", path, errno); goto out; @@ -337,7 +337,7 @@ write_object (NMSetting8021x *s_8021x, new_file = utils_cert_path (ifcfg->fileName, objtype->suffix); if (!new_file) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Could not create file path for %s / %s", NM_SETTING_802_1X_SETTING_NAME, objtype->setting_key); return FALSE; @@ -356,7 +356,7 @@ write_object (NMSetting8021x *s_8021x, g_free (new_file); return TRUE; } else { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Could not write certificate/key for %s / %s: %s", NM_SETTING_802_1X_SETTING_NAME, objtype->setting_key, (write_error && write_error->message) ? write_error->message : "(unknown)"); @@ -609,7 +609,7 @@ write_wireless_security_setting (NMConnection *connection, s_wsec = nm_connection_get_setting_wireless_security (connection); if (!s_wsec) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Missing '%s' setting", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME); return FALSE; } @@ -815,7 +815,7 @@ write_wireless_setting (NMConnection *connection, s_wireless = nm_connection_get_setting_wireless (connection); if (!s_wireless) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Missing '%s' setting", NM_SETTING_WIRELESS_SETTING_NAME); return FALSE; } @@ -853,13 +853,13 @@ write_wireless_setting (NMConnection *connection, ssid = nm_setting_wireless_get_ssid (s_wireless); if (!ssid) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Missing SSID in '%s' setting", NM_SETTING_WIRELESS_SETTING_NAME); return FALSE; } ssid_data = g_bytes_get_data (ssid, &ssid_len); if (!ssid_len || ssid_len > 32) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Invalid SSID in '%s' setting", NM_SETTING_WIRELESS_SETTING_NAME); return FALSE; } @@ -909,7 +909,7 @@ write_wireless_setting (NMConnection *connection, svSetValue (ifcfg, "MODE", "Ad-Hoc", FALSE); adhoc = TRUE; } else { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Invalid mode '%s' in '%s' setting", mode, NM_SETTING_WIRELESS_SETTING_NAME); return FALSE; @@ -992,7 +992,7 @@ write_infiniband_setting (NMConnection *connection, shvarFile *ifcfg, GError **e s_infiniband = nm_connection_get_setting_infiniband (connection); if (!s_infiniband) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Missing '%s' setting", NM_SETTING_INFINIBAND_SETTING_NAME); return FALSE; } @@ -1044,7 +1044,7 @@ write_wired_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) s_wired = nm_connection_get_setting_wired (connection); if (!s_wired) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Missing '%s' setting", NM_SETTING_WIRED_SETTING_NAME); return FALSE; } @@ -1169,13 +1169,15 @@ write_vlan_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, s_con = nm_connection_get_setting_connection (connection); if (!s_con) { - g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, "Missing connection setting"); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Missing connection setting"); return FALSE; } s_vlan = nm_connection_get_setting_vlan (connection); if (!s_vlan) { - g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, "Missing VLAN setting"); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Missing VLAN setting"); return FALSE; } @@ -1250,14 +1252,15 @@ write_bonding_setting (NMConnection *connection, shvarFile *ifcfg, GError **erro s_bond = nm_connection_get_setting_bond (connection); if (!s_bond) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Missing '%s' setting", NM_SETTING_BOND_SETTING_NAME); return FALSE; } iface = nm_connection_get_interface_name (connection); if (!iface) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "Missing interface name"); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Missing interface name"); return FALSE; } @@ -1301,14 +1304,15 @@ write_team_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) s_team = nm_connection_get_setting_team (connection); if (!s_team) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Missing '%s' setting", NM_SETTING_TEAM_SETTING_NAME); return FALSE; } iface = nm_connection_get_interface_name (connection); if (!iface) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "Missing interface name"); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Missing interface name"); return FALSE; } @@ -1349,14 +1353,15 @@ write_bridge_setting (NMConnection *connection, shvarFile *ifcfg, GError **error s_bridge = nm_connection_get_setting_bridge (connection); if (!s_bridge) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Missing '%s' setting", NM_SETTING_BRIDGE_SETTING_NAME); return FALSE; } iface = nm_connection_get_interface_name (connection); if (!iface) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "Missing interface name"); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Missing interface name"); return FALSE; } @@ -1793,7 +1798,7 @@ write_route_file_legacy (const char *filename, NMSettingIP4Config *s_ip4, GError g_strfreev (route_items); if (!g_file_set_contents (filename, route_contents, -1, NULL)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Writing route file '%s' failed", filename); goto error; } @@ -2037,7 +2042,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) /* Static routes - route-<name> file */ route_path = utils_get_route_path (ifcfg->fileName); if (!route_path) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Could not get route file path for '%s'", ifcfg->fileName); goto out; } @@ -2047,7 +2052,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) routefile = utils_get_route_ifcfg (ifcfg->fileName, TRUE); if (!routefile) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Could not create route file '%s'", route_path); g_free (route_path); goto out; @@ -2265,7 +2270,7 @@ write_route6_file (const char *filename, NMSettingIP6Config *s_ip6, GError **err g_strfreev (route_items); if (!g_file_set_contents (filename, route_contents, -1, NULL)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Writing route6 file '%s' failed", filename); goto error; } @@ -2451,7 +2456,7 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) /* Static routes go to route6-<dev> file */ route6_path = utils_get_route6_path (ifcfg->fileName); if (!route6_path) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Could not get route6 file path for '%s'", ifcfg->fileName); goto error; } @@ -2539,7 +2544,7 @@ write_connection (NMConnection *connection, g_free (escaped); if (ifcfg_name == NULL) { - g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Failed to find usable ifcfg file name"); return FALSE; } @@ -2549,7 +2554,7 @@ write_connection (NMConnection *connection, type = nm_setting_connection_get_connection_type (s_con); if (!type) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Missing connection type!"); goto out; } @@ -2557,7 +2562,7 @@ write_connection (NMConnection *connection, if (!strcmp (type, NM_SETTING_WIRED_SETTING_NAME)) { // FIXME: can't write PPPoE at this time if (nm_connection_get_setting_pppoe (connection)) { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Can't write connection type '%s'", NM_SETTING_PPPOE_SETTING_NAME); goto out; @@ -2585,7 +2590,7 @@ write_connection (NMConnection *connection, if (!write_bridge_setting (connection, ifcfg, error)) goto out; } else { - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Can't write connection type '%s'", type); goto out; } @@ -2650,7 +2655,7 @@ writer_can_write_connection (NMConnection *connection, GError **error) s_con = nm_connection_get_setting_connection (connection); g_assert (s_con); - g_set_error (error, IFCFG_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "The ifcfg-rh plugin cannot write the connection '%s' (type '%s' pppoe %d)", nm_connection_get_id (connection), nm_setting_connection_get_connection_type (s_con), diff --git a/src/settings/plugins/ifcfg-suse/plugin.c b/src/settings/plugins/ifcfg-suse/plugin.c index d6aa79fb57..cf73548d8e 100644 --- a/src/settings/plugins/ifcfg-suse/plugin.c +++ b/src/settings/plugins/ifcfg-suse/plugin.c @@ -55,17 +55,6 @@ typedef struct { char *hostname; } SCPluginIfcfgPrivate; -GQuark -ifcfg_plugin_error_quark (void) -{ - static GQuark error_quark = 0; - - if (G_UNLIKELY (error_quark == 0)) - error_quark = g_quark_from_static_string ("ifcfg-plugin-error-quark"); - - return error_quark; -} - typedef void (*FileChangedFn) (gpointer user_data); typedef struct { diff --git a/src/settings/plugins/ifcfg-suse/plugin.h b/src/settings/plugins/ifcfg-suse/plugin.h index 4090a11e16..24dbff9533 100644 --- a/src/settings/plugins/ifcfg-suse/plugin.h +++ b/src/settings/plugins/ifcfg-suse/plugin.h @@ -46,7 +46,5 @@ struct _SCPluginIfcfgClass { GType sc_plugin_ifcfg_get_type (void); -GQuark ifcfg_plugin_error_quark (void); - #endif /* _PLUGIN_H_ */ diff --git a/src/settings/plugins/ifnet/Makefile.am b/src/settings/plugins/ifnet/Makefile.am index 02b5207b8e..b0cfd9a11e 100644 --- a/src/settings/plugins/ifnet/Makefile.am +++ b/src/settings/plugins/ifnet/Makefile.am @@ -38,6 +38,4 @@ lib_ifnet_io_la_SOURCES = \ net_utils.h\ net_utils.c\ wpa_parser.h\ - wpa_parser.c \ - errors.h \ - errors.c + wpa_parser.c diff --git a/src/settings/plugins/ifnet/connection_parser.c b/src/settings/plugins/ifnet/connection_parser.c index 25b958fd4f..8fcc6a62b8 100644 --- a/src/settings/plugins/ifnet/connection_parser.c +++ b/src/settings/plugins/ifnet/connection_parser.c @@ -43,7 +43,6 @@ #include "wpa_parser.h" #include "connection_parser.h" #include "nm-ifnet-connection.h" -#include "errors.h" static char * connection_id_from_ifnet_name (const char *conn_name) @@ -124,7 +123,7 @@ eap_simple_reader (const char *eap_method, /* identity */ value = wpa_get_value (ssid, "identity"); if (!value) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing IEEE_8021X_IDENTITY for EAP method '%s'.", eap_method); return FALSE; @@ -134,7 +133,7 @@ eap_simple_reader (const char *eap_method, /* password */ value = wpa_get_value (ssid, "password"); if (!value) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing IEEE_8021X_PASSWORD for EAP method '%s'.", eap_method); return FALSE; @@ -176,7 +175,7 @@ eap_tls_reader (const char *eap_method, /* identity */ value = wpa_get_value (ssid, "identity"); if (!value) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing IEEE_8021X_IDENTITY for EAP method '%s'.", eap_method); return FALSE; @@ -211,7 +210,7 @@ eap_tls_reader (const char *eap_method, "private_key_passwd"); if (!privkey_password) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing %s for EAP method '%s'.", phase2 ? "IEEE_8021X_INNER_PRIVATE_KEY_PASSWORD" : "IEEE_8021X_PRIVATE_KEY_PASSWORD", eap_method); @@ -221,7 +220,7 @@ eap_tls_reader (const char *eap_method, /* The private key itself */ privkey = get_cert (ssid, phase2 ? "private_key2" : "private_key", basepath); if (!privkey) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing %s for EAP method '%s'.", phase2 ? "IEEE_8021X_INNER_PRIVATE_KEY" : "IEEE_8021X_PRIVATE_KEY", eap_method); @@ -254,7 +253,7 @@ eap_tls_reader (const char *eap_method, || privkey_format == NM_SETTING_802_1X_CK_FORMAT_X509) { client_cert = get_cert (ssid, phase2 ? "client_cert2" : "client_cert", basepath); if (!client_cert) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing %s for EAP method '%s'.", phase2 ? "IEEE_8021X_INNER_CLIENT_CERT" : "IEEE_8021X_CLIENT_CERT", eap_method); @@ -322,7 +321,7 @@ eap_peap_reader (const char *eap_method, g_object_set (s_8021x, NM_SETTING_802_1X_PHASE1_PEAPVER, "1", NULL); else { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Unknown IEEE_8021X_PEAP_VERSION value '%s'", peapver); goto done; @@ -336,7 +335,7 @@ eap_peap_reader (const char *eap_method, inner_auth = wpa_get_value (ssid, "phase2"); if (!inner_auth) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing IEEE_8021X_INNER_AUTH_METHODS."); goto done; } @@ -357,7 +356,7 @@ eap_peap_reader (const char *eap_method, if (!eap_tls_reader (pos, ssid, s_8021x, TRUE, basepath, error)) goto done; } else { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Unknown IEEE_8021X_INNER_AUTH_METHOD '%s'.", *iter); goto done; @@ -373,7 +372,7 @@ eap_peap_reader (const char *eap_method, } if (!nm_setting_802_1x_get_phase2_auth (s_8021x)) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "No valid IEEE_8021X_INNER_AUTH_METHODS found."); goto done; } @@ -422,7 +421,7 @@ eap_ttls_reader (const char *eap_method, tmp = wpa_get_value (ssid, "phase2"); if (!tmp) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing IEEE_8021X_INNER_AUTH_METHODS."); goto done; } @@ -457,7 +456,7 @@ eap_ttls_reader (const char *eap_method, g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTHEAP, pos, NULL); } else { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Unknown IEEE_8021X_INNER_AUTH_METHOD '%s'.", *iter); goto done; @@ -506,7 +505,7 @@ read_mac_address (const char *conn_name, const char **mac, GError **error) return TRUE; if (!nm_utils_hwaddr_valid (value, ETH_ALEN)) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "The MAC address '%s' was invalid.", value); return FALSE; } @@ -577,7 +576,7 @@ make_ip4_setting (NMConnection *connection, if (!is_static_block) { method = ifnet_get_data (conn_name, "config"); if (!method){ - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Unknown config for %s", conn_name); g_object_unref (ip4_setting); return; @@ -602,7 +601,7 @@ make_ip4_setting (NMConnection *connection, nm_connection_add_setting (connection, NM_SETTING (ip4_setting)); return; } else { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Unknown config for %s", conn_name); g_object_unref (ip4_setting); return; @@ -611,7 +610,7 @@ make_ip4_setting (NMConnection *connection, }else { iblock = convert_ip4_config_block (conn_name); if (!iblock) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Ifnet plugin: can't aquire ip configuration for %s", conn_name); g_object_unref (ip4_setting); @@ -789,7 +788,7 @@ make_ip6_setting (NMConnection *connection, iblock = convert_ip6_config_block (conn_name); if (!iblock) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Ifnet plugin: can't aquire ip6 configuration for %s", conn_name); goto error; @@ -919,8 +918,7 @@ make_wireless_connection_setting (const char *conn_name, if ((value_len > 2) && (g_str_has_prefix (conn_name, "0x"))) { /* Hex representation */ if (value_len % 2) { - g_set_error (error, ifnet_plugin_error_quark (), - 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid SSID '%s' size (looks like hex but length not multiple of 2)", conn_name); goto error; @@ -928,9 +926,7 @@ make_wireless_connection_setting (const char *conn_name, // ignore "0x" p = conn_name + 2; if (!is_hex (p)) { - g_set_error (error, - ifnet_plugin_error_quark (), - 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid SSID '%s' character (looks like hex SSID but '%c' isn't a hex digit)", conn_name, *p); goto error; @@ -944,7 +940,7 @@ make_wireless_connection_setting (const char *conn_name, } if (ssid_len > 32 || ssid_len == 0) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid SSID '%s' (size %zu not between 1 and 32 inclusive)", conn_name, ssid_len); goto error; @@ -954,7 +950,7 @@ make_wireless_connection_setting (const char *conn_name, g_bytes_unref (bytes); g_free (converted); } else { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing SSID"); goto error; } @@ -977,7 +973,7 @@ make_wireless_connection_setting (const char *conn_name, value = wpa_get_value (conn_name, "bssid"); if (value) { if (!nm_utils_hwaddr_valid (value, ETH_ALEN)) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid BSSID '%s'", value); goto error; } @@ -1035,7 +1031,7 @@ make_leap_setting (const char *ssid, GError **error) value = wpa_get_value (ssid, "identity"); if (!value || !strlen (value)) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing LEAP identity"); goto error; } @@ -1077,8 +1073,8 @@ add_one_wep_key (const char *ssid, if (strlen (value) == 10 || strlen (value) == 26) { /* Hexadecimal WEP key */ if (!is_hex (value)) { - g_set_error (error, ifnet_plugin_error_quark (), - 0, "Invalid hexadecimal WEP key."); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid hexadecimal WEP key."); goto out; } converted = g_strdup (value); @@ -1089,8 +1085,8 @@ add_one_wep_key (const char *ssid, char *p = strip_string (tmp, '"'); if (!is_ascii (p)) { - g_set_error (error, ifnet_plugin_error_quark (), - 0, "Invalid ASCII WEP passphrase."); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid ASCII WEP passphrase."); g_free (tmp); goto out; @@ -1099,7 +1095,7 @@ add_one_wep_key (const char *ssid, converted = nm_utils_bin2hexstr (tmp, strlen (tmp), strlen (tmp) * 2); g_free (tmp); } else { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid WEP key length. Key: %s", value); goto out; } @@ -1153,7 +1149,7 @@ make_wep_setting (const char *ssid, GError **error) default_key_idx, NULL); nm_log_info (LOGD_SETTINGS, "Default key index: %d", default_key_idx); } else { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid default WEP key '%s'", value); goto error; } @@ -1165,19 +1161,19 @@ make_wep_setting (const char *ssid, GError **error) /* If there's a default key, ensure that key exists */ if ((default_key_idx == 1) && !nm_setting_wireless_security_get_wep_key (s_wireless_sec, 1)) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Default WEP key index was 2, but no valid KEY2 exists."); goto error; } else if ((default_key_idx == 2) && !nm_setting_wireless_security_get_wep_key (s_wireless_sec, 2)) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Default WEP key index was 3, but no valid KEY3 exists."); goto error; } else if ((default_key_idx == 3) && !nm_setting_wireless_security_get_wep_key (s_wireless_sec, 3)) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Default WEP key index was 4, but no valid KEY4 exists."); goto error; } @@ -1196,7 +1192,7 @@ make_wep_setting (const char *ssid, GError **error) "shared", NULL); nm_log_info (LOGD_SETTINGS, "WEP: Use shared system authentication"); } else { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid WEP authentication algorithm '%s'", auth_alg); goto error; @@ -1210,7 +1206,7 @@ make_wep_setting (const char *ssid, GError **error) && !nm_setting_wireless_security_get_wep_key (s_wireless_sec, 3) && !nm_setting_wireless_security_get_wep_tx_keyidx (s_wireless_sec)) { if (auth_alg && !strcmp (auth_alg, "shared")) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "WEP Shared Key authentication is invalid for " "unencrypted connections."); goto error; @@ -1234,7 +1230,7 @@ parse_wpa_psk (const char *psk, GError **error) gboolean quoted = FALSE; if (!psk) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing WPA_PSK for WPA-PSK key management"); return NULL; } @@ -1250,9 +1246,8 @@ parse_wpa_psk (const char *psk, GError **error) if (!quoted && (strlen (psk) == 64)) { /* Verify the hex PSK; 64 digits */ if (!is_hex (psk)) { - g_set_error (error, ifnet_plugin_error_quark (), - 0, - "Invalid WPA_PSK (contains non-hexadecimal characters)"); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid WPA_PSK (contains non-hexadecimal characters)"); goto out; } hashed = g_strdup (psk); @@ -1263,7 +1258,7 @@ parse_wpa_psk (const char *psk, GError **error) /* Length check */ if (strlen (stripped) < 8 || strlen (stripped) > 63) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid WPA_PSK (passphrases must be between " "8 and 63 characters long (inclusive))"); g_free (stripped); @@ -1275,7 +1270,7 @@ parse_wpa_psk (const char *psk, GError **error) } if (!hashed) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid WPA_PSK (doesn't look like a passphrase or hex key)"); goto out; } @@ -1359,7 +1354,7 @@ fill_8021x (const char *ssid, value = wpa_get_value (ssid, "eap"); if (!value) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing IEEE_8021X_EAP_METHODS for key management '%s'", key_mgmt); return NULL; @@ -1410,7 +1405,7 @@ fill_8021x (const char *ssid, g_strfreev (list); if (nm_setting_802_1x_get_num_eap_methods (s_8021x) == 0) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "No valid EAP methods found in IEEE_8021X_EAP_METHODS."); goto error; } @@ -1434,7 +1429,7 @@ make_wpa_setting (const char *ssid, gboolean adhoc = FALSE; if (!exist_ssid (ssid)) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "No security info found for ssid: %s", ssid); return NULL; } @@ -1486,7 +1481,7 @@ make_wpa_setting (const char *ssid, "wpa-psk", NULL); } else if (!strcmp (value, "WPA-EAP") || !strcmp (value, "IEEE8021X")) { if (adhoc) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Ad-Hoc mode cannot be used with KEY_MGMT type '%s'", value); goto error; @@ -1500,7 +1495,7 @@ make_wpa_setting (const char *ssid, lower, NULL); g_free (lower); } else { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Unknown wireless KEY_MGMT type '%s'", value); goto error; } @@ -1551,7 +1546,7 @@ make_wireless_security_setting (const char *conn_name, } if (!wsec) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Can't handle security information for ssid: %s", conn_name); } @@ -1576,7 +1571,7 @@ make_pppoe_connection_setting (NMConnection *connection, /* username */ value = ifnet_get_data (conn_name, "username"); if (!value) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "ppp requires at lease a username"); return; } @@ -2070,7 +2065,7 @@ write_wireless_security_setting (NMConnection * connection, s_wsec = nm_connection_get_setting_wireless_security (connection); if (!s_wsec) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing '%s' setting", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME); return FALSE; @@ -2238,7 +2233,7 @@ write_wireless_setting (NMConnection *connection, s_wireless = nm_connection_get_setting_wireless (connection); if (!s_wireless) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing '%s' setting", NM_SETTING_WIRELESS_SETTING_NAME); return FALSE; @@ -2246,14 +2241,14 @@ write_wireless_setting (NMConnection *connection, ssid = nm_setting_wireless_get_ssid (s_wireless); if (!ssid) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing SSID in '%s' setting", NM_SETTING_WIRELESS_SETTING_NAME); return FALSE; } ssid_data = g_bytes_get_data (ssid, &ssid_len); if (!ssid_len || ssid_len > 32) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid SSID in '%s' setting", NM_SETTING_WIRELESS_SETTING_NAME); return FALSE; @@ -2345,7 +2340,7 @@ write_wired_setting (NMConnection *connection, s_wired = nm_connection_get_setting_wired (connection); if (!s_wired) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing '%s' setting", NM_SETTING_WIRED_SETTING_NAME); return FALSE; @@ -2385,7 +2380,7 @@ write_ip4_setting (NMConnection *connection, const char *conn_name, GError **err s_ip4 = nm_connection_get_setting_ip4_config (connection); if (!s_ip4) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing '%s' setting", NM_SETTING_IP4_CONFIG_SETTING_NAME); return FALSE; @@ -2584,7 +2579,7 @@ write_ip6_setting (NMConnection *connection, const char *conn_name, GError **err s_ip6 = nm_connection_get_setting_ip6_config (connection); if (!s_ip6) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing '%s' setting", NM_SETTING_IP6_CONFIG_SETTING_NAME); return FALSE; @@ -2743,7 +2738,7 @@ ifnet_update_parsers_by_connection (NMConnection *connection, type = nm_setting_connection_get_connection_type (s_con); if (!type) { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing connection type!"); goto out; } @@ -2769,7 +2764,7 @@ ifnet_update_parsers_by_connection (NMConnection *connection, wired = TRUE; no_8021x = TRUE; } else { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_NOT_SUPPORTED, "Can't write connection type '%s'", type); goto out; } @@ -2865,7 +2860,7 @@ ifnet_can_write_connection (NMConnection *connection, GError **error) /* If the connection is not available for all users, ignore * it as this plugin only deals with System Connections */ if (nm_setting_connection_get_num_permissions (s_con)) { - g_set_error_literal (error, IFNET_PLUGIN_ERROR, 0, + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_NOT_SUPPORTED, "The ifnet plugin does not support non-system-wide connections."); return FALSE; } @@ -2874,7 +2869,7 @@ ifnet_can_write_connection (NMConnection *connection, GError **error) if ( !nm_connection_is_type (connection, NM_SETTING_WIRED_SETTING_NAME) && !nm_connection_is_type (connection, NM_SETTING_WIRELESS_SETTING_NAME) && !nm_connection_is_type (connection, NM_SETTING_PPPOE_SETTING_NAME)) { - g_set_error (error, IFNET_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_NOT_SUPPORTED, "The ifnet plugin cannot write the connection '%s' (type '%s')", nm_connection_get_id (connection), nm_setting_connection_get_connection_type (s_con)); @@ -2887,7 +2882,7 @@ ifnet_can_write_connection (NMConnection *connection, GError **error) check_unsupported_secrets, &has_unsupported_secrets); if (has_unsupported_secrets) { - g_set_error_literal (error, IFNET_PLUGIN_ERROR, 0, + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_NOT_SUPPORTED, "The ifnet plugin only supports persistent system secrets."); return FALSE; } @@ -3019,7 +3014,7 @@ ifnet_add_new_connection (NMConnection *connection, goto out; new_type = "ppp"; } else { - g_set_error (error, ifnet_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_NOT_SUPPORTED, "Can't write connection type '%s'", type); goto out; } diff --git a/src/settings/plugins/ifnet/errors.c b/src/settings/plugins/ifnet/errors.c deleted file mode 100644 index 295db18bae..0000000000 --- a/src/settings/plugins/ifnet/errors.c +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2013 Red Hat, Inc. - */ - -#include <glib.h> -#include "errors.h" - -GQuark -ifnet_plugin_error_quark (void) -{ - static GQuark error_quark = 0; - - if (G_UNLIKELY (error_quark == 0)) - error_quark = g_quark_from_static_string ("ifnet-plugin-error-quark"); - - return error_quark; -} - - diff --git a/src/settings/plugins/ifnet/errors.h b/src/settings/plugins/ifnet/errors.h deleted file mode 100644 index 52517d007e..0000000000 --- a/src/settings/plugins/ifnet/errors.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2013 Red Hat, Inc. - */ - -#ifndef __ERRORS_H__ -#define __ERRORS_H__ - -#include <glib.h> - -#define IFNET_PLUGIN_ERROR (ifnet_plugin_error_quark ()) -GQuark ifnet_plugin_error_quark (void); - -#endif /* __ERRORS_H__ */ - diff --git a/src/settings/plugins/ifnet/nm-ifnet-connection.c b/src/settings/plugins/ifnet/nm-ifnet-connection.c index 2408d73d92..3a7cc810a4 100644 --- a/src/settings/plugins/ifnet/nm-ifnet-connection.c +++ b/src/settings/plugins/ifnet/nm-ifnet-connection.c @@ -27,7 +27,6 @@ #include <nm-settings-connection.h> #include <nm-system-config-interface.h> #include <nm-logging.h> -#include <nm-settings-error.h> #include "nm-ifnet-connection.h" #include "connection_parser.h" #include "net_parser.h" diff --git a/src/settings/plugins/ifnet/tests/Makefile.am b/src/settings/plugins/ifnet/tests/Makefile.am index 90d7243020..a842a206ec 100644 --- a/src/settings/plugins/ifnet/tests/Makefile.am +++ b/src/settings/plugins/ifnet/tests/Makefile.am @@ -25,8 +25,7 @@ check_ifnet_SOURCES = \ ../connection_parser.c \ ../net_parser.c \ ../net_utils.c \ - ../wpa_parser.c \ - ../errors.c + ../wpa_parser.c check_ifnet_LDFLAGS = \ $(CODE_COVERAGE_LDFLAGS) diff --git a/src/settings/plugins/ifupdown/nm-ifupdown-connection.c b/src/settings/plugins/ifupdown/nm-ifupdown-connection.c index 6b48cacd0a..43fa670a61 100644 --- a/src/settings/plugins/ifupdown/nm-ifupdown-connection.c +++ b/src/settings/plugins/ifupdown/nm-ifupdown-connection.c @@ -28,7 +28,6 @@ #include <nm-setting-wireless-security.h> #include <nm-settings-connection.h> #include <nm-system-config-interface.h> -#include <nm-settings-error.h> #include <nm-logging.h> #include "nm-ifupdown-connection.h" #include "parser.h" diff --git a/src/settings/plugins/ifupdown/parser.c b/src/settings/plugins/ifupdown/parser.c index 097fe7b64e..18b8932494 100644 --- a/src/settings/plugins/ifupdown/parser.c +++ b/src/settings/plugins/ifupdown/parser.c @@ -417,17 +417,6 @@ update_wired_setting_from_if_block(NMConnection *connection, nm_connection_add_setting(connection, NM_SETTING(s_wired)); } -static GQuark -eni_plugin_error_quark() { - static GQuark error_quark = 0; - - if(!error_quark) { - error_quark = g_quark_from_static_string ("eni-plugin-error-quark"); - } - - return error_quark; -} - static void ifupdown_ip4_add_dns (NMSettingIP4Config *s_ip4, const char *dns) { @@ -480,7 +469,7 @@ update_ip4_setting_from_if_block(NMConnection *connection, /* Address */ address_v = ifparser_getkey (block, "address"); if (!address_v || !inet_pton (AF_INET, address_v, &tmp_addr)) { - g_set_error (error, eni_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing IPv4 address '%s'", address_v ? address_v : "(none)"); goto error; @@ -492,12 +481,12 @@ update_ip4_setting_from_if_block(NMConnection *connection, if (strlen (netmask_v) < 7) { netmask_int = atoi (netmask_v); if (netmask_int > 32) { - g_set_error (error, eni_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid IPv4 netmask '%s'", netmask_v); goto error; } } else if (!inet_pton (AF_INET, netmask_v, &tmp_mask)) { - g_set_error (error, eni_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid IPv4 netmask '%s'", netmask_v); goto error; } else { @@ -510,7 +499,7 @@ update_ip4_setting_from_if_block(NMConnection *connection, if (!gateway_v) gateway_v = address_v; /* dcbw: whaaa?? */ if (!inet_pton (AF_INET, gateway_v, &tmp_gw)) { - g_set_error (error, eni_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid IPv4 gateway '%s'", gateway_v); goto error; } @@ -615,7 +604,7 @@ update_ip6_setting_from_if_block(NMConnection *connection, /* Address */ address_v = ifparser_getkey(block, "address"); if (!address_v || !inet_pton (AF_INET6, address_v, &tmp_addr)) { - g_set_error (error, eni_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Missing IPv6 address '%s'", address_v ? address_v : "(none)"); goto error; @@ -631,7 +620,7 @@ update_ip6_setting_from_if_block(NMConnection *connection, if (!gateway_v) gateway_v = address_v; /* dcbw: whaaa?? */ if (!inet_pton (AF_INET6, gateway_v, &tmp_gw)) { - g_set_error (error, eni_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid IPv6 gateway '%s'", gateway_v); goto error; } diff --git a/src/settings/plugins/ifupdown/plugin.h b/src/settings/plugins/ifupdown/plugin.h index ed7732b887..943b8b9f6e 100644 --- a/src/settings/plugins/ifupdown/plugin.h +++ b/src/settings/plugins/ifupdown/plugin.h @@ -48,6 +48,4 @@ struct _SCPluginIfupdownClass { GType sc_plugin_ifupdown_get_type (void); -GQuark ifupdown_plugin_error_quark (void); - #endif /* _PLUGIN_H_ */ diff --git a/src/settings/plugins/keyfile/Makefile.am b/src/settings/plugins/keyfile/Makefile.am index bf89b06796..079c45c39e 100644 --- a/src/settings/plugins/keyfile/Makefile.am +++ b/src/settings/plugins/keyfile/Makefile.am @@ -26,7 +26,6 @@ libkeyfile_io_la_SOURCES = \ reader.h \ writer.c \ writer.h \ - errors.c \ utils.c \ utils.h \ common.h diff --git a/src/settings/plugins/keyfile/common.h b/src/settings/plugins/keyfile/common.h index 4faa5a848b..db6569e54a 100644 --- a/src/settings/plugins/keyfile/common.h +++ b/src/settings/plugins/keyfile/common.h @@ -30,8 +30,5 @@ #define VPN_SECRETS_GROUP "vpn-secrets" -#define KEYFILE_PLUGIN_ERROR (keyfile_plugin_error_quark ()) -GQuark keyfile_plugin_error_quark (void); - #endif /* __COMMON_H__ */ diff --git a/src/settings/plugins/keyfile/errors.c b/src/settings/plugins/keyfile/errors.c deleted file mode 100644 index e2e97690f1..0000000000 --- a/src/settings/plugins/keyfile/errors.c +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2008 - 2010 Red Hat, Inc. - */ - -#include <glib.h> -#include "common.h" - -GQuark -keyfile_plugin_error_quark (void) -{ - static GQuark error_quark = 0; - - if (G_UNLIKELY (error_quark == 0)) - error_quark = g_quark_from_static_string ("keyfile-plugin-error-quark"); - - return error_quark; -} - - diff --git a/src/settings/plugins/keyfile/nm-keyfile-connection.c b/src/settings/plugins/keyfile/nm-keyfile-connection.c index c078b6de09..661b6745e0 100644 --- a/src/settings/plugins/keyfile/nm-keyfile-connection.c +++ b/src/settings/plugins/keyfile/nm-keyfile-connection.c @@ -63,7 +63,7 @@ nm_keyfile_connection_new (NMConnection *source, uuid = nm_connection_get_uuid (NM_CONNECTION (tmp)); if (!uuid) { - g_set_error (error, KEYFILE_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Connection in file %s had no UUID", full_path); g_object_unref (tmp); return NULL; diff --git a/src/settings/plugins/keyfile/plugin.h b/src/settings/plugins/keyfile/plugin.h index 5f43739055..48579785d8 100644 --- a/src/settings/plugins/keyfile/plugin.h +++ b/src/settings/plugins/keyfile/plugin.h @@ -41,8 +41,6 @@ typedef struct { GType sc_plugin_keyfile_get_type (void); -GQuark keyfile_plugin_error_quark (void); - GObject *nm_settings_keyfile_plugin_new (void); #endif /* _PLUGIN_H_ */ diff --git a/src/settings/plugins/keyfile/reader.c b/src/settings/plugins/keyfile/reader.c index 4c6ce24397..4be044c716 100644 --- a/src/settings/plugins/keyfile/reader.c +++ b/src/settings/plugins/keyfile/reader.c @@ -1297,7 +1297,7 @@ nm_keyfile_plugin_connection_from_file (const char *filename, GError **error) GError *verify_error = NULL; if (stat (filename, &statbuf) != 0 || !S_ISREG (statbuf.st_mode)) { - g_set_error_literal (error, KEYFILE_PLUGIN_ERROR, 0, + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "File did not exist or was not a regular file"); return NULL; } @@ -1305,7 +1305,7 @@ nm_keyfile_plugin_connection_from_file (const char *filename, GError **error) bad_permissions = statbuf.st_mode & 0077; if (bad_permissions) { - g_set_error (error, KEYFILE_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "File permissions (%o) were insecure", statbuf.st_mode); return NULL; @@ -1384,10 +1384,9 @@ nm_keyfile_plugin_connection_from_file (const char *filename, GError **error) /* Normalize and verify the connection */ if (!nm_connection_normalize (connection, NULL, NULL, &verify_error)) { - g_set_error (error, KEYFILE_PLUGIN_ERROR, 0, - "invalid or missing connection property '%s/%s'", - verify_error ? g_type_name (nm_setting_lookup_type_by_quark (verify_error->domain)) : "(unknown)", - (verify_error && verify_error->message) ? verify_error->message : "(unknown)"); + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "invalid connection: %s", + verify_error->message); g_clear_error (&verify_error); g_object_unref (connection); connection = NULL; diff --git a/src/settings/plugins/keyfile/tests/Makefile.am b/src/settings/plugins/keyfile/tests/Makefile.am index 1cd6ab91cd..20b9820c9e 100644 --- a/src/settings/plugins/keyfile/tests/Makefile.am +++ b/src/settings/plugins/keyfile/tests/Makefile.am @@ -27,7 +27,6 @@ test_keyfile_SOURCES = \ test-keyfile.c \ ../reader.c \ ../writer.c \ - ../errors.c \ ../utils.c test_keyfile_LDADD = \ diff --git a/src/settings/plugins/keyfile/writer.c b/src/settings/plugins/keyfile/writer.c index 7404d54e13..17d4d9581a 100644 --- a/src/settings/plugins/keyfile/writer.c +++ b/src/settings/plugins/keyfile/writer.c @@ -552,7 +552,7 @@ write_cert_key_file (const char *path, errno = 0; fd = mkstemp (tmppath); if (fd < 0) { - g_set_error (error, KEYFILE_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Could not create temporary file for '%s': %d", path, errno); goto out; @@ -563,7 +563,7 @@ write_cert_key_file (const char *path, if (fchmod (fd, S_IRUSR | S_IWUSR) != 0) { close (fd); unlink (tmppath); - g_set_error (error, KEYFILE_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Could not set permissions for temporary file '%s': %d", path, errno); goto out; @@ -574,7 +574,7 @@ write_cert_key_file (const char *path, if (written != data_len) { close (fd); unlink (tmppath); - g_set_error (error, KEYFILE_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Could not write temporary file for '%s': %d", path, errno); goto out; @@ -587,7 +587,7 @@ write_cert_key_file (const char *path, success = TRUE; else { unlink (tmppath); - g_set_error (error, KEYFILE_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Could not rename temporary file to '%s': %d", path, errno); } @@ -922,7 +922,7 @@ _internal_write_connection (NMConnection *connection, id = nm_connection_get_id (connection); if (!id) { - g_set_error (error, KEYFILE_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "%s.%d: connection had no ID", __FILE__, __LINE__); return FALSE; } @@ -965,7 +965,7 @@ _internal_write_connection (NMConnection *connection, * is edited to contain the same ID as the other one. * Give up. */ - g_set_error (error, KEYFILE_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "%s.%d: could not find suitable keyfile file name (%s already used)", __FILE__, __LINE__, path); g_free (path); @@ -982,7 +982,7 @@ _internal_write_connection (NMConnection *connection, g_file_set_contents (path, data, len, &local_err); if (local_err) { - g_set_error (error, KEYFILE_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "%s.%d: error writing to file '%s': %s", __FILE__, __LINE__, path, local_err->message); g_error_free (local_err); @@ -991,13 +991,13 @@ _internal_write_connection (NMConnection *connection, } if (chown (path, owner_uid, owner_grp) < 0) { - g_set_error (error, KEYFILE_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "%s.%d: error chowning '%s': %d", __FILE__, __LINE__, path, errno); unlink (path); } else { if (chmod (path, S_IRUSR | S_IWUSR) < 0) { - g_set_error (error, KEYFILE_PLUGIN_ERROR, 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "%s.%d: error setting permissions on '%s': %d", __FILE__, __LINE__, path, errno); unlink (path); diff --git a/src/vpn-manager/nm-vpn-manager.c b/src/vpn-manager/nm-vpn-manager.c index 139a17aca1..7daa8cec96 100644 --- a/src/vpn-manager/nm-vpn-manager.c +++ b/src/vpn-manager/nm-vpn-manager.c @@ -43,15 +43,6 @@ typedef struct { guint monitor_id; } NMVpnManagerPrivate; -GQuark -nm_vpn_manager_error_quark (void) -{ - static GQuark quark = 0; - if (!quark) - quark = g_quark_from_static_string ("nm-vpn-manager-error"); - return quark; -} - static NMVpnService * get_service_by_namefile (NMVpnManager *self, const char *namefile) @@ -95,7 +86,7 @@ nm_vpn_manager_activate_connection (NMVpnManager *manager, g_assert (device); if ( nm_device_get_state (device) != NM_DEVICE_STATE_ACTIVATED && nm_device_get_state (device) != NM_DEVICE_STATE_SECONDARIES) { - g_set_error_literal (error, NM_VPN_MANAGER_ERROR, NM_VPN_MANAGER_ERROR_DEVICE_NOT_ACTIVE, + g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_DEPENDENCY_FAILED, "The base device for the VPN connection was not active."); return FALSE; } @@ -109,7 +100,7 @@ nm_vpn_manager_activate_connection (NMVpnManager *manager, g_assert (service_name); service = g_hash_table_lookup (NM_VPN_MANAGER_GET_PRIVATE (manager)->services, service_name); if (!service) { - g_set_error (error, NM_VPN_MANAGER_ERROR, NM_VPN_MANAGER_ERROR_SERVICE_INVALID, + g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_CONNECTION_NOT_AVAILABLE, "The VPN service '%s' was not installed.", service_name); return FALSE; @@ -302,7 +293,5 @@ nm_vpn_manager_class_init (NMVpnManagerClass *manager_class) /* virtual methods */ object_class->dispose = dispose; - - dbus_g_error_domain_register (NM_VPN_MANAGER_ERROR, NULL, NM_TYPE_VPN_MANAGER_ERROR); } diff --git a/src/vpn-manager/nm-vpn-manager.h b/src/vpn-manager/nm-vpn-manager.h index bb272be9a6..b75a617955 100644 --- a/src/vpn-manager/nm-vpn-manager.h +++ b/src/vpn-manager/nm-vpn-manager.h @@ -33,20 +33,6 @@ #define NM_IS_VPN_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_VPN_MANAGER)) #define NM_VPN_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_VPN_MANAGER, NMVpnManagerClass)) -typedef enum -{ - NM_VPN_MANAGER_ERROR_DEVICE_NOT_ACTIVE = 0, /*< nick=BaseDeviceNotActive >*/ - NM_VPN_MANAGER_ERROR_CONNECTION_INVALID, /*< nick=ConnectionInvalid >*/ - NM_VPN_MANAGER_ERROR_SERVICE_INVALID, /*< nick=ServiceInvalid >*/ - NM_VPN_MANAGER_ERROR_SERVICE_START_FAILED, /*< nick=ServiceStartFailed >*/ -} NMVpnManagerError; - -#define NM_VPN_MANAGER_ERROR (nm_vpn_manager_error_quark ()) - -GQuark nm_vpn_manager_error_quark (void); -GType nm_vpn_manager_error_get_type (void); - - typedef struct { GObject parent; } NMVpnManager; diff --git a/src/vpn-manager/nm-vpn-service.c b/src/vpn-manager/nm-vpn-service.c index a142a30ac8..142644a2d0 100644 --- a/src/vpn-manager/nm-vpn-service.c +++ b/src/vpn-manager/nm-vpn-service.c @@ -218,7 +218,7 @@ nm_vpn_service_daemon_exec (NMVpnService *service, GError **error) spawn_error && spawn_error->message ? spawn_error->message : "(unknown)"); g_set_error (error, - NM_VPN_MANAGER_ERROR, NM_VPN_MANAGER_ERROR_SERVICE_START_FAILED, + NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED, "%s", spawn_error ? spawn_error->message : "unknown g_spawn_async() error"); nm_vpn_service_stop_connections (service, FALSE, NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_FAILED); diff --git a/tools/test-networkmanager-service.py b/tools/test-networkmanager-service.py index d98174ce20..64701e7ce8 100755 --- a/tools/test-networkmanager-service.py +++ b/tools/test-networkmanager-service.py @@ -113,6 +113,9 @@ class ExportedObj(dbus.service.Object): ################################################################### IFACE_DEVICE = 'org.freedesktop.NetworkManager.Device' +class NotSoftwareException(dbus.DBusException): + _dbus_error_name = IFACE_DEVICE + '.NotSoftware' + PD_UDI = "Udi" PD_IFACE = "Interface" PD_DRIVER = "Driver" @@ -170,6 +173,12 @@ class Device(ExportedObj): def Disconnect(self): pass + @dbus.service.method(dbus_interface=IFACE_DEVICE, in_signature='', out_signature='') + def Delete(self): + # We don't currently support any software device types, so... + raise NotSoftwareException() + pass + def __notify(self, propname): props = self._get_dbus_properties(IFACE_DEVICE) changed = { propname: props[propname] } @@ -905,9 +914,31 @@ class NetworkManager(ExportedObj): ################################################################### IFACE_CONNECTION = 'org.freedesktop.NetworkManager.Settings.Connection' +class InvalidPropertyException(dbus.DBusException): + _dbus_error_name = IFACE_CONNECTION + '.InvalidProperty' + +class MissingPropertyException(dbus.DBusException): + _dbus_error_name = IFACE_CONNECTION + '.MissingProperty' + +class InvalidSettingException(dbus.DBusException): + _dbus_error_name = IFACE_CONNECTION + '.InvalidSetting' + +class MissingSettingException(dbus.DBusException): + _dbus_error_name = IFACE_CONNECTION + '.MissingSetting' + class Connection(dbus.service.Object): def __init__(self, bus, object_path, settings, remove_func): dbus.service.Object.__init__(self, bus, object_path) + + if not settings.has_key('connection'): + raise MissingSettingException('connection: setting is required') + s_con = settings['connection'] + if not s_con.has_key('type'): + raise MissingPropertyException('connection.type: property is required') + type = s_con['type'] + if not type in ['802-3-ethernet', '802-11-wireless', 'vlan', 'wimax']: + raise InvalidPropertyException('connection.type: unsupported connection type') + self.path = object_path self.settings = settings self.remove_func = remove_func @@ -959,6 +990,9 @@ class Connection(dbus.service.Object): ################################################################### IFACE_SETTINGS = 'org.freedesktop.NetworkManager.Settings' +class InvalidHostnameException(dbus.DBusException): + _dbus_error_name = IFACE_SETTINGS + '.InvalidHostname' + class Settings(dbus.service.Object): def __init__(self, bus, object_path): dbus.service.Object.__init__(self, bus, object_path) @@ -1001,6 +1035,14 @@ class Settings(dbus.service.Object): self.props['Connections'] = dbus.Array(self.connections.keys(), 'o') self.PropertiesChanged({ 'connections': self.props['Connections'] }) + @dbus.service.method(dbus_interface=IFACE_SETTINGS, in_signature='s', out_signature='') + def SaveHostname(self, hostname): + # Arbitrary requirement to test error handling + if hostname.find('.') == -1: + raise InvalidHostnameException() + self.props['Hostname'] = hostname + self.PropertiesChanged({ 'hostname': hostname }) + @dbus.service.method(dbus_interface=dbus.PROPERTIES_IFACE, in_signature='s', out_signature='a{sv}') def GetAll(self, iface): if iface != IFACE_SETTINGS: |