[network-manager-iodine/danw/cleanup-bgo746693] properties: use a real GError domain instead of 0



commit 737e5b2f51be20f831216abf8d467aba6eb15737
Author: Jiří Klimeš <jklimes redhat com>
Date:   Tue Mar 24 17:11:38 2015 +0100

    properties: use a real GError domain instead of 0
    
    GLib complains about domain being 0.

 properties/nm-iodine.c |   37 ++++++++++++++++++++++++++++++-------
 1 files changed, 30 insertions(+), 7 deletions(-)
---
diff --git a/properties/nm-iodine.c b/properties/nm-iodine.c
index 61d8d1b..be32b62 100644
--- a/properties/nm-iodine.c
+++ b/properties/nm-iodine.c
@@ -76,6 +76,24 @@ typedef struct {
        gboolean window_added;
 } IodinePluginUiWidgetPrivate;
 
+typedef enum {
+       NM_IODINE_IMPORT_EXPORT_ERROR_UNKNOWN = 0,
+       NM_IODINE_IMPORT_EXPORT_ERROR_NOT_IODINE,
+       NM_IODINE_IMPORT_EXPORT_ERROR_BAD_DATA,
+} NMIodineImportError;
+
+#define NM_IODINE_IMPORT_EXPORT_ERROR nm_iodine_import_export_error_quark ()
+
+static GQuark
+nm_iodine_import_export_error_quark (void)
+{
+       static GQuark quark = 0;
+
+       if (G_UNLIKELY (quark == 0))
+               quark = g_quark_from_static_string ("nm-iodine-import-export-error-quark");
+       return quark;
+}
+
 static NMConnection *
 import (NMVpnPluginUiInterface *iface, const char *path, GError **error)
 {
@@ -92,8 +110,8 @@ import (NMVpnPluginUiInterface *iface, const char *path, GError **error)
 
        if (!g_key_file_load_from_file (keyfile, path, flags, error)) {
                g_set_error (error,
-                                        0,
-                                        0,
+                                        NM_IODINE_IMPORT_EXPORT_ERROR,
+                                        NM_IODINE_IMPORT_EXPORT_ERROR_NOT_IODINE,
                                         "does not look like a %s VPN connection (parse failed)",
                                         IODINE_PLUGIN_NAME);
                return NULL;
@@ -119,8 +137,8 @@ import (NMVpnPluginUiInterface *iface, const char *path, GError **error)
                nm_setting_vpn_add_data_item (s_vpn, NM_IODINE_KEY_TOPDOMAIN, buf);
        } else {
                g_set_error (error,
-                                        0,
-                                        0,
+                                        NM_IODINE_IMPORT_EXPORT_ERROR,
+                                        NM_IODINE_IMPORT_EXPORT_ERROR_NOT_IODINE,
                                         "does not look like a %s VPN connection "
                                         "(no top level domain)",
                                         IODINE_PLUGIN_NAME);
@@ -163,7 +181,10 @@ export (NMVpnPluginUiInterface *iface,
 
        f = fopen (path, "w");
        if (!f) {
-               g_set_error (error, 0, 0, "could not open file for writing");
+               g_set_error (error,
+                            NM_IODINE_IMPORT_EXPORT_ERROR,
+                            NM_IODINE_IMPORT_EXPORT_ERROR_UNKNOWN,
+                            "could not open file for writing");
                return FALSE;
        }
 
@@ -173,8 +194,10 @@ export (NMVpnPluginUiInterface *iface,
        if (value && strlen (value))
                topdomain = value;
        else {
-               g_set_error (error, 0, 0,
-                                        "connection was incomplete (missing top level domain)");
+               g_set_error (error,
+                            NM_IODINE_IMPORT_EXPORT_ERROR,
+                            NM_IODINE_IMPORT_EXPORT_ERROR_UNKNOWN,
+                            "connection was incomplete (missing top level domain)");
                goto done;
        }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]