diff options
author | Dan Winship <danw@gnome.org> | 2012-03-02 11:23:23 -0500 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2012-03-12 20:24:32 -0400 |
commit | fb6cd6e56eef01e77bc7e4e9ef0a7b7faad28271 (patch) | |
tree | 1e14e750f03122bdaa6c5f6f6fcf3843fb6eaf9d | |
parent | 32bcd021e2db759081bd135ce0810ded91d7bdcc (diff) | |
download | network-manager-applet-fb6cd6e56eef01e77bc7e4e9ef0a7b7faad28271.tar.gz |
Fix use of GError
Using a domain of 0 with GError is invalid, and recent versions of
GLib emit a warning if you do. Add an NMA_ERROR domain, with the
single error NMA_ERROR_GENERIC, and use that instead.
-rw-r--r-- | src/connection-editor/Makefile.am | 1 | ||||
-rw-r--r-- | src/connection-editor/ce-page.c | 2 | ||||
-rw-r--r-- | src/connection-editor/ce-page.h | 1 | ||||
-rw-r--r-- | src/connection-editor/nm-connection-editor.c | 2 | ||||
-rw-r--r-- | src/connection-editor/nm-connection-editor.h | 1 | ||||
-rw-r--r-- | src/connection-editor/page-dsl.c | 2 | ||||
-rw-r--r-- | src/connection-editor/page-ip4.c | 2 | ||||
-rw-r--r-- | src/connection-editor/page-ip6.c | 2 | ||||
-rw-r--r-- | src/connection-editor/page-mobile.c | 4 | ||||
-rw-r--r-- | src/connection-editor/page-ppp.c | 2 | ||||
-rw-r--r-- | src/connection-editor/page-vpn.c | 4 | ||||
-rw-r--r-- | src/connection-editor/page-wired-security.c | 4 | ||||
-rw-r--r-- | src/connection-editor/page-wired.c | 2 | ||||
-rw-r--r-- | src/connection-editor/page-wireless-security.c | 8 | ||||
-rw-r--r-- | src/connection-editor/page-wireless.c | 2 | ||||
-rw-r--r-- | src/connection-editor/vpn-helpers.c | 19 | ||||
-rw-r--r-- | src/gconf-helpers/Makefile.am | 2 | ||||
-rw-r--r-- | src/gconf-helpers/gconf-helpers.c | 16 | ||||
-rw-r--r-- | src/gconf-helpers/gconf-helpers.h | 2 | ||||
-rw-r--r-- | src/utils/utils.c | 1 | ||||
-rw-r--r-- | src/utils/utils.h | 6 |
21 files changed, 49 insertions, 36 deletions
diff --git a/src/connection-editor/Makefile.am b/src/connection-editor/Makefile.am index 59d2b509..d26b6743 100644 --- a/src/connection-editor/Makefile.am +++ b/src/connection-editor/Makefile.am @@ -3,6 +3,7 @@ bin_PROGRAMS = nm-connection-editor nm_connection_editor_CPPFLAGS = \ $(GTK_CFLAGS) \ $(NMA_CFLAGS) \ + $(GNOME_KEYRING_CFLAGS) \ -DICONDIR=\""$(datadir)/icons"\" \ -DUIDIR=\""$(uidir)"\" \ -DBINDIR=\""$(bindir)"\" \ diff --git a/src/connection-editor/ce-page.c b/src/connection-editor/ce-page.c index 44fd952b..528757fb 100644 --- a/src/connection-editor/ce-page.c +++ b/src/connection-editor/ce-page.c @@ -306,7 +306,7 @@ ce_page_complete_init (CEPage *self, } if (!update_error) { - g_set_error_literal (&update_error, 0, 0, + g_set_error_literal (&update_error, NMA_ERROR, NMA_ERROR_GENERIC, _("Failed to update connection secrets due to an unknown error.")); } diff --git a/src/connection-editor/ce-page.h b/src/connection-editor/ce-page.h index 692790d8..fae65220 100644 --- a/src/connection-editor/ce-page.h +++ b/src/connection-editor/ce-page.h @@ -31,6 +31,7 @@ #include <dbus/dbus-glib.h> #include <nm-connection.h> #include <nm-client.h> +#include "utils.h" typedef void (*PageNewConnectionResultFunc) (NMConnection *connection, gboolean canceled, diff --git a/src/connection-editor/nm-connection-editor.c b/src/connection-editor/nm-connection-editor.c index 3e9a2141..26b59fed 100644 --- a/src/connection-editor/nm-connection-editor.c +++ b/src/connection-editor/nm-connection-editor.c @@ -388,7 +388,7 @@ nm_connection_editor_new (NMConnection *connection, editor = g_object_new (NM_TYPE_CONNECTION_EDITOR, NULL); if (!editor) { - g_set_error (error, 0, 0, "%s", _("Error creating connection editor dialog.")); + g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, "%s", _("Error creating connection editor dialog.")); return NULL; } diff --git a/src/connection-editor/nm-connection-editor.h b/src/connection-editor/nm-connection-editor.h index a80814f4..3e66fe64 100644 --- a/src/connection-editor/nm-connection-editor.h +++ b/src/connection-editor/nm-connection-editor.h @@ -25,6 +25,7 @@ #include <glib-object.h> #include <nm-client.h> +#include "utils.h" #define NM_TYPE_CONNECTION_EDITOR (nm_connection_editor_get_type ()) #define NM_IS_CONNECTION_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_CONNECTION_EDITOR)) diff --git a/src/connection-editor/page-dsl.c b/src/connection-editor/page-dsl.c index 0c413b6e..5485a552 100644 --- a/src/connection-editor/page-dsl.c +++ b/src/connection-editor/page-dsl.c @@ -138,7 +138,7 @@ ce_page_dsl_new (NMConnection *connection, "DslPage", _("DSL"))); if (!self) { - g_set_error_literal (error, 0, 0, _("Could not load DSL user interface.")); + g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("Could not load DSL user interface.")); return NULL; } diff --git a/src/connection-editor/page-ip4.c b/src/connection-editor/page-ip4.c index 4e50a02f..d397a103 100644 --- a/src/connection-editor/page-ip4.c +++ b/src/connection-editor/page-ip4.c @@ -980,7 +980,7 @@ ce_page_ip4_new (NMConnection *connection, "IP4Page", _("IPv4 Settings"))); if (!self) { - g_set_error_literal (error, 0, 0, _("Could not load IPv4 user interface.")); + g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("Could not load IPv4 user interface.")); return NULL; } diff --git a/src/connection-editor/page-ip6.c b/src/connection-editor/page-ip6.c index c2e89e96..41b3a39d 100644 --- a/src/connection-editor/page-ip6.c +++ b/src/connection-editor/page-ip6.c @@ -944,7 +944,7 @@ ce_page_ip6_new (NMConnection *connection, "IP6Page", _("IPv6 Settings"))); if (!self) { - g_set_error_literal (error, 0, 0, _("Could not load IPv6 user interface.")); + g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("Could not load IPv6 user interface.")); return NULL; } diff --git a/src/connection-editor/page-mobile.c b/src/connection-editor/page-mobile.c index 9ae7c652..517ebb97 100644 --- a/src/connection-editor/page-mobile.c +++ b/src/connection-editor/page-mobile.c @@ -378,7 +378,7 @@ ce_page_mobile_new (NMConnection *connection, "MobilePage", _("Mobile Broadband"))); if (!self) { - g_set_error_literal (error, 0, 0, _("Could not load mobile broadband user interface.")); + g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("Could not load mobile broadband user interface.")); return NULL; } @@ -395,7 +395,7 @@ ce_page_mobile_new (NMConnection *connection, } if (!priv->setting) { - g_set_error (error, 0, 0, "%s", _("Unsupported mobile broadband connection type.")); + g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, "%s", _("Unsupported mobile broadband connection type.")); g_object_unref (self); return NULL; } diff --git a/src/connection-editor/page-ppp.c b/src/connection-editor/page-ppp.c index b27bc4cb..db742450 100644 --- a/src/connection-editor/page-ppp.c +++ b/src/connection-editor/page-ppp.c @@ -281,7 +281,7 @@ ce_page_ppp_new (NMConnection *connection, "PppPage", _("PPP Settings"))); if (!self) { - g_set_error_literal (error, 0, 0, _("Could not load PPP user interface.")); + g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("Could not load PPP user interface.")); return NULL; } diff --git a/src/connection-editor/page-vpn.c b/src/connection-editor/page-vpn.c index a66da9c5..70910eb6 100644 --- a/src/connection-editor/page-vpn.c +++ b/src/connection-editor/page-vpn.c @@ -108,7 +108,7 @@ ce_page_vpn_new (NMConnection *connection, NULL, _("VPN"))); if (!self) { - g_set_error_literal (error, 0, 0, _("Could not load VPN user interface.")); + g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("Could not load VPN user interface.")); return NULL; } @@ -123,7 +123,7 @@ ce_page_vpn_new (NMConnection *connection, priv->plugin = vpn_get_plugin_by_service (service_type); if (!priv->plugin) { - g_set_error (error, 0, 0, _("Could not find VPN plugin service for '%s'."), service_type); + g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("Could not find VPN plugin service for '%s'."), service_type); g_object_unref (self); return NULL; } diff --git a/src/connection-editor/page-wired-security.c b/src/connection-editor/page-wired-security.c index a5ee2033..7bec62e1 100644 --- a/src/connection-editor/page-wired-security.c +++ b/src/connection-editor/page-wired-security.c @@ -115,7 +115,7 @@ ce_page_wired_security_new (NMConnection *connection, NULL, _("802.1x Security"))); if (!self) { - g_set_error_literal (error, 0, 0, _("Could not load Wired Security security user interface.")); + g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("Could not load Wired Security security user interface.")); return NULL; } @@ -175,7 +175,7 @@ validate (CEPage *page, NMConnection *connection, GError **error) g_object_unref (tmp_connection); } else - g_set_error (error, 0, 0, "Invalid 802.1x security"); + g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, "Invalid 802.1x security"); } else { nm_connection_remove_setting (connection, NM_TYPE_SETTING_802_1X); valid = TRUE; diff --git a/src/connection-editor/page-wired.c b/src/connection-editor/page-wired.c index 5de3cb23..2d1ad0f3 100644 --- a/src/connection-editor/page-wired.c +++ b/src/connection-editor/page-wired.c @@ -271,7 +271,7 @@ ce_page_wired_new (NMConnection *connection, "WiredPage", _("Wired"))); if (!self) { - g_set_error_literal (error, 0, 0, _("Could not load wired user interface.")); + g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("Could not load wired user interface.")); return NULL; } diff --git a/src/connection-editor/page-wireless-security.c b/src/connection-editor/page-wireless-security.c index b51ab223..90426cfd 100644 --- a/src/connection-editor/page-wireless-security.c +++ b/src/connection-editor/page-wireless-security.c @@ -356,7 +356,7 @@ ce_page_wireless_security_new (NMConnection *connection, s_wireless = nm_connection_get_setting_wireless (connection); if (!s_wireless) { - g_set_error_literal (error, 0, 0, _("Could not load WiFi security user interface; missing WiFi setting.")); + g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("Could not load WiFi security user interface; missing WiFi setting.")); return NULL; } @@ -368,7 +368,7 @@ ce_page_wireless_security_new (NMConnection *connection, "WirelessSecurityPage", _("Wireless Security"))); if (!self) { - g_set_error_literal (error, 0, 0, _("Could not load WiFi security user interface.")); + g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("Could not load WiFi security user interface.")); return NULL; } @@ -445,9 +445,9 @@ validate (CEPage *page, NMConnection *connection, GError **error) if (valid) wireless_security_fill_connection (sec, connection); else - g_set_error (error, 0, 0, "Invalid wireless security"); + g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, "Invalid wireless security"); } else - g_set_error (error, 0, 0, "Missing SSID"); + g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, "Missing SSID"); } else { /* No security, unencrypted */ g_object_set (s_wireless, NM_SETTING_WIRELESS_SEC, NULL, NULL); diff --git a/src/connection-editor/page-wireless.c b/src/connection-editor/page-wireless.c index cc00e9e1..886f175c 100644 --- a/src/connection-editor/page-wireless.c +++ b/src/connection-editor/page-wireless.c @@ -456,7 +456,7 @@ ce_page_wireless_new (NMConnection *connection, "WirelessPage", _("Wireless"))); if (!self) { - g_set_error_literal (error, 0, 0, _("Could not load WiFi user interface.")); + g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("Could not load WiFi user interface.")); return NULL; } diff --git a/src/connection-editor/vpn-helpers.c b/src/connection-editor/vpn-helpers.c index 943ee2cc..8b162074 100644 --- a/src/connection-editor/vpn-helpers.c +++ b/src/connection-editor/vpn-helpers.c @@ -33,6 +33,7 @@ #include <nm-setting-vpn.h> #include "vpn-helpers.h" +#include "utils.h" #define NM_VPN_API_SUBJECT_TO_CHANGE #include "nm-vpn-plugin-ui-interface.h" @@ -63,7 +64,7 @@ vpn_get_plugins (GError **error) dir = g_dir_open (VPN_NAME_FILES_DIR, 0, NULL); if (!dir) { - g_set_error (error, 0, 0, "Couldn't read VPN .name files directory " VPN_NAME_FILES_DIR "."); + g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, "Couldn't read VPN .name files directory " VPN_NAME_FILES_DIR "."); return NULL; } @@ -104,7 +105,7 @@ vpn_get_plugins (GError **error) module = g_module_open (so_path, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL); if (!module) { - g_set_error (error, 0, 0, "Cannot load the VPN plugin which provides the " + g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, "Cannot load the VPN plugin which provides the " "service '%s'.", service); goto next; } @@ -124,10 +125,10 @@ vpn_get_plugins (GError **error) NM_VPN_PLUGIN_UI_INTERFACE_SERVICE, &plug_service, NULL); if (!plug_name || !strlen (plug_name)) { - g_set_error (error, 0, 0, "cannot load VPN plugin in '%s': missing plugin name", + g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, "cannot load VPN plugin in '%s': missing plugin name", g_module_name (module)); } else if (!plug_service || strcmp (plug_service, service)) { - g_set_error (error, 0, 0, "cannot load VPN plugin in '%s': invalid service name", + g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, "cannot load VPN plugin in '%s': invalid service name", g_module_name (module)); } else { /* Success! */ @@ -139,14 +140,14 @@ vpn_get_plugins (GError **error) g_free (plug_name); g_free (plug_service); } else { - g_set_error (error, 0, 0, "cannot load VPN plugin in '%s': %s", + g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, "cannot load VPN plugin in '%s': %s", g_module_name (module), g_module_error ()); } if (!success) g_module_close (module); } else { - g_set_error (error, 0, 0, "cannot locate nm_vpn_plugin_ui_factory() in '%s': %s", + g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, "cannot locate nm_vpn_plugin_ui_factory() in '%s': %s", g_module_name (module), g_module_error ()); g_module_close (module); } @@ -296,7 +297,7 @@ export_vpn_to_file_cb (GtkWidget *dialog, gint response, gpointer user_data) filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); if (!filename) { - g_set_error (&error, 0, 0, "no filename"); + g_set_error (&error, NMA_ERROR, NMA_ERROR_GENERIC, "no filename"); goto done; } @@ -325,7 +326,7 @@ export_vpn_to_file_cb (GtkWidget *dialog, gint response, gpointer user_data) s_con = nm_connection_get_setting_connection (connection); id = s_con ? nm_setting_connection_get_id (s_con) : NULL; if (!id) { - g_set_error (&error, 0, 0, "connection setting invalid"); + g_set_error (&error, NMA_ERROR, NMA_ERROR_GENERIC, "connection setting invalid"); goto done; } @@ -333,7 +334,7 @@ export_vpn_to_file_cb (GtkWidget *dialog, gint response, gpointer user_data) service_type = s_vpn ? nm_setting_vpn_get_service_type (s_vpn) : NULL; if (!service_type) { - g_set_error (&error, 0, 0, "VPN setting invalid"); + g_set_error (&error, NMA_ERROR, NMA_ERROR_GENERIC, "VPN setting invalid"); goto done; } diff --git a/src/gconf-helpers/Makefile.am b/src/gconf-helpers/Makefile.am index 1cf81f76..c4c52c3d 100644 --- a/src/gconf-helpers/Makefile.am +++ b/src/gconf-helpers/Makefile.am @@ -13,6 +13,7 @@ HELPERS_SOURCES = \ libgconf_helpers_la_SOURCES = $(HELPERS_SOURCES) libgconf_helpers_la_CPPFLAGS = \ + -I$(top_srcdir)/src/utils \ $(GTK_CFLAGS) \ $(NMA_CFLAGS) \ $(GCONF_CFLAGS) \ @@ -32,6 +33,7 @@ libgconf_helpers_la_LIBADD = \ libgconf_helpers_test_la_SOURCES = $(HELPERS_SOURCES) libgconf_helpers_test_la_CPPFLAGS = \ + -I$(top_srcdir)/src/utils \ $(GTK_CFLAGS) \ $(NMA_CFLAGS) \ $(GCONF_CFLAGS) \ diff --git a/src/gconf-helpers/gconf-helpers.c b/src/gconf-helpers/gconf-helpers.c index ce76248b..c244671c 100644 --- a/src/gconf-helpers/gconf-helpers.c +++ b/src/gconf-helpers/gconf-helpers.c @@ -2204,7 +2204,7 @@ write_secret_file (const char *path, tmppath = g_malloc0 (strlen (path) + 10); if (!tmppath) { - g_set_error (error, 0, 0, + g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, "Could not allocate memory for temporary file for '%s'", path); return FALSE; @@ -2216,7 +2216,7 @@ write_secret_file (const char *path, errno = 0; fd = mkstemp (tmppath); if (fd < 0) { - g_set_error (error, 0, 0, + g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, "Could not create temporary file for '%s': %d", path, errno); goto out; @@ -2227,7 +2227,7 @@ write_secret_file (const char *path, if (fchmod (fd, S_IRUSR | S_IWUSR)) { close (fd); unlink (tmppath); - g_set_error (error, 0, 0, + g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, "Could not set permissions for temporary file '%s': %d", path, errno); goto out; @@ -2238,7 +2238,7 @@ write_secret_file (const char *path, if (written != len) { close (fd); unlink (tmppath); - g_set_error (error, 0, 0, + g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, "Could not write temporary file for '%s': %d", path, errno); goto out; @@ -2249,7 +2249,7 @@ write_secret_file (const char *path, errno = 0; if (rename (tmppath, path)) { unlink (tmppath); - g_set_error (error, 0, 0, + g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, "Could not rename temporary file to '%s': %d", path, errno); goto out; @@ -2455,7 +2455,7 @@ write_object (GConfClient *client, new_file = generate_cert_path (id, objtype->suffix); if (!new_file) { - g_set_error (error, 0, 0, + g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, "Could not create file path for %s / %s", setting_name, objtype->setting_key); return FALSE; @@ -2470,7 +2470,7 @@ write_object (GConfClient *client, nm_gconf_set_string_helper (client, dir, objtype->setting_key, setting_name, new_file); return TRUE; } else { - g_set_error (error, 0, 0, + g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, "Could not write certificate/key for %s / %s: %s", setting_name, objtype->setting_key, (write_error && write_error->message) ? write_error->message : "(unknown)"); @@ -2570,7 +2570,7 @@ write_one_certificate (GConfClient *client, } if (!handled) { - g_set_error (error, 0, 0, + g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, "Unhandled certificate/private-key item '%s'", key); } diff --git a/src/gconf-helpers/gconf-helpers.h b/src/gconf-helpers/gconf-helpers.h index 132d1f99..2a1aca0c 100644 --- a/src/gconf-helpers/gconf-helpers.h +++ b/src/gconf-helpers/gconf-helpers.h @@ -27,6 +27,8 @@ #include <glib.h> #include <nm-connection.h> +#include "utils.h" + #define GCONF_PATH_CONNECTIONS "/system/networking/connections" #define KEYRING_UUID_TAG "connection-uuid" diff --git a/src/utils/utils.c b/src/utils/utils.c index 09f4a708..084d402f 100644 --- a/src/utils/utils.c +++ b/src/utils/utils.c @@ -768,4 +768,3 @@ utils_create_keyring_add_attr_list (NMConnection *connection, setting_key); return attrs; } - diff --git a/src/utils/utils.h b/src/utils/utils.h index fe6095c6..d5eee02f 100644 --- a/src/utils/utils.h +++ b/src/utils/utils.h @@ -63,5 +63,11 @@ GnomeKeyringAttributeList *utils_create_keyring_add_attr_list (NMConnection *con const char *setting_key, char **out_display_name); +#define NMA_ERROR (g_quark_from_static_string ("nma-error-quark")) + +typedef enum { + NMA_ERROR_GENERIC +} NMAError; + #endif /* UTILS_H */ |