diff options
author | Dan Winship <danw@gnome.org> | 2014-10-15 14:55:41 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2014-10-22 08:29:08 -0400 |
commit | 9c67b6fb08e4b2794ccab461f0ac9a6cffac33ee (patch) | |
tree | de9c44c0aecb5fe63b431fb3076645a788c8dd03 /libnm-core/nm-errors.c | |
parent | b1bcfa8fedc65a6d7e9eacbf1dbf736767126820 (diff) | |
download | NetworkManager-9c67b6fb08e4b2794ccab461f0ac9a6cffac33ee.tar.gz |
libnm-core, core: register NMConnectionError with D-Bus
Register NMConnectionError with D-Bus on both sides, so that, eg,
connection validation failures in the daemon will translate to the
correct error codes in the client.
Diffstat (limited to 'libnm-core/nm-errors.c')
-rw-r--r-- | libnm-core/nm-errors.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/libnm-core/nm-errors.c b/libnm-core/nm-errors.c index 99040419d7..9469740050 100644 --- a/libnm-core/nm-errors.c +++ b/libnm-core/nm-errors.c @@ -18,10 +18,43 @@ * Copyright 2004 - 2014 Red Hat, Inc. */ -#include <glib.h> +#include <string.h> +#include <gio/gio.h> #include "nm-errors.h" #include "nm-glib-compat.h" +#include "nm-dbus-interface.h" +#include "nm-core-internal.h" G_DEFINE_QUARK (nm-connection-error-quark, nm_connection_error) G_DEFINE_QUARK (nm-crypto-error-quark, nm_crypto_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_CONNECTION_ERROR, + NM_DBUS_INTERFACE_SETTINGS_CONNECTION, + NM_TYPE_CONNECTION_ERROR); +} |