all: consolidate error domains and fix up D-Bus error mapping (bgo #735900)

This commit is contained in:
Dan Winship 2014-10-22 08:29:29 -04:00
commit 558cbe5c11
220 changed files with 2259 additions and 4464 deletions

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -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"));
}

View file

@ -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__ */

View file

@ -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">

View file

@ -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 \

View file

@ -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);
}

View file

@ -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);

View file

@ -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;

View file

@ -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;
}

View file

@ -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)) {

View file

@ -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:
*

View file

@ -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

88
libnm-core/nm-errors.c Normal file
View file

@ -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);
}

319
libnm-core/nm-errors.h Normal file
View file

@ -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__ */

View file

@ -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);

View file

@ -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"

View file

@ -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);

View file

@ -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"

View file

@ -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;
}
}

View file

@ -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"

View file

@ -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);

View file

@ -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 */

View file

@ -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,

View file

@ -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"

View file

@ -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;

View file

@ -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"

View file

@ -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;

View file

@ -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"

View file

@ -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);

View file

@ -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

View file

@ -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;

View file

@ -39,22 +39,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

View file

@ -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)

View file

@ -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;

View file

@ -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);

View file

@ -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"

View file

@ -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);

View file

@ -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"

View file

@ -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);

View file

@ -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"

View file

@ -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);

View file

@ -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"

View file

@ -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;

View file

@ -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"

View file

@ -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);

View file

@ -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"

View file

@ -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;

View file

@ -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"

View file

@ -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);

View file

@ -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)

View file

@ -40,25 +40,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)

View file

@ -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,

View file

@ -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 {

View file

@ -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)

View file

@ -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 {

View file

@ -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;

View file

@ -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"

View file

@ -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)

View file

@ -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"

View file

@ -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;

View file

@ -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"

View file

@ -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;

View file

@ -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"

View file

@ -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);

View file

@ -40,35 +40,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

View file

@ -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);

View file

@ -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"

View file

@ -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;

View file

@ -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);

View file

@ -233,6 +233,8 @@ nm_utils_init (GError **error)
if (!crypto_init (error))
return FALSE;
_nm_dbus_errors_init ();
}
return TRUE;
}

View file

@ -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));
}

View file

@ -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 ();

View file

@ -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);
}

View file

@ -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;

View file

@ -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))

View file

@ -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 ()

View file

@ -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.
*/

View file

@ -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);

View file

@ -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)
@ -42,23 +43,6 @@ enum {
LAST_PROP
};
/**
* 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;
if (!NM_DEVICE_CLASS (nm_device_adsl_parent_class)->connection_compatible (device, connection, error))
return FALSE;
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_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;
}
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.");
return FALSE;
}
return NM_DEVICE_CLASS (nm_device_adsl_parent_class)->connection_compatible (device, connection, error);
return TRUE;
}
static GType

View file

@ -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 {

View file

@ -20,6 +20,7 @@
#include <config.h>
#include <string.h>
#include <glib/gi18n.h>
#include "nm-glib-compat.h"
@ -51,23 +52,6 @@ enum {
LAST_PROP
};
/**
* 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

View file

@ -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"

View file

@ -20,6 +20,7 @@
#include <config.h>
#include <string.h>
#include <glib/gi18n.h>
#include "nm-glib-compat.h"
@ -51,23 +52,6 @@ enum {
LAST_PROP
};
/**
* 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

View file

@ -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"

View file

@ -21,6 +21,7 @@
#include <config.h>
#include <string.h>
#include <glib/gi18n.h>
#include "nm-glib-compat.h"
@ -52,23 +53,6 @@ enum {
LAST_PROP
};
/**
* 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

View file

@ -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"

View file

@ -21,6 +21,7 @@
#include <config.h>
#include <string.h>
#include <glib/gi18n.h>
#include "nm-glib-compat.h"
@ -54,23 +55,6 @@ enum {
LAST_PROP
};
/**
* 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

View file

@ -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"

View file

@ -21,6 +21,7 @@
#include <config.h>
#include <string.h>
#include <glib/gi18n.h>
#include "nm-device-generic.h"
#include "nm-device-private.h"
@ -44,23 +45,6 @@ enum {
LAST_PROP
};
/**
* 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

View file

@ -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"

View file

@ -20,6 +20,7 @@
#include <config.h>
#include <string.h>
#include <glib/gi18n.h>
#include "nm-glib-compat.h"
@ -48,23 +49,6 @@ enum {
LAST_PROP
};
/**
* 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

View file

@ -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"

View file

@ -21,6 +21,7 @@
#include <config.h>
#include <string.h>
#include <glib/gi18n.h>
#include "nm-glib-compat.h"
@ -49,23 +50,6 @@ enum {
LAST_PROP
};
/**
* 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

View file

@ -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"

View file

@ -20,6 +20,7 @@
#include <config.h>
#include <string.h>
#include <glib/gi18n.h>
#include "nm-glib-compat.h"
@ -50,23 +51,6 @@ enum {
LAST_PROP
};
/**
* 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;
if (!NM_DEVICE_CLASS (nm_device_olpc_mesh_parent_class)->connection_compatible (device, connection, error))
return FALSE;
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_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;
}
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.");
return FALSE;
}
return NM_DEVICE_CLASS (nm_device_olpc_mesh_parent_class)->connection_compatible (device, connection, error);
return TRUE;
}
static GType

View file

@ -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"

View file

@ -20,6 +20,7 @@
#include <config.h>
#include <string.h>
#include <glib/gi18n.h>
#include "nm-glib-compat.h"
@ -51,23 +52,6 @@ enum {
LAST_PROP
};
/**
* 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

Some files were not shown because too many files have changed in this diff Show more