# HG changeset patch
# Node ID 477afe9145207f1bac2ea2ceeb2cf3bd20e5fe2c
# Parent  cc362469ea9b6f163ac420960e5efad5bd6b85db
diff --git a/ibis/ibisclient.c b/ibis/ibisclient.c
--- a/ibis/ibisclient.c
+++ b/ibis/ibisclient.c
@@ -101,6 +101,8 @@
 	GRegex *mode_string_regex;
 };
 
+G_DEFINE_QUARK(ibis-client-error, ibis_client_error)
+
 /******************************************************************************
  * Helpers
  *****************************************************************************/
@@ -254,7 +256,8 @@
 		ibis_message_set_params(message, candidate_nick, NULL);
 		ibis_client_write(client, message);
 	} else {
-		GError *error = g_error_new_literal(IBIS_CLIENT_ERROR, 0,
+		GError *error = g_error_new_literal(IBIS_CLIENT_ERROR,
+		                                    IBIS_CLIENT_ERROR_NO_MORE_NICKS,
 		                                    _("no more nicks to try"));
 
 		ibis_client_stop(client, error);
@@ -334,7 +337,9 @@
 		if(!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
 			if(IBIS_IS_CLIENT(client)) {
 				if(error == NULL) {
-					g_set_error_literal(&error, IBIS_CLIENT_ERROR, 0,
+					g_set_error_literal(&error,
+					                    IBIS_CLIENT_ERROR,
+					                    IBIS_CLIENT_ERROR_SERVER_CLOSED_CONNECTION,
 					                    _("Server closed the connection"));
 				} else {
 					g_prefix_error(&error, "%s",
@@ -1347,7 +1352,9 @@
 
 			if(needs_parameter) {
 				if(param_index >= n_params) {
-					g_set_error_literal(error, IBIS_CLIENT_ERROR, 0,
+					g_set_error_literal(error,
+					                    IBIS_CLIENT_ERROR,
+					                    IBIS_CLIENT_ERROR_PARSE_MODE_STRING_NOT_ENOUGH_PARAMETERS,
 					                    "no more parameters");
 
 					g_array_remove_range(mode_changes, 0, mode_changes->len);
@@ -1382,8 +1389,12 @@
 	g_match_info_free(info);
 
 	if(param_index < n_params) {
-		g_set_error(error, IBIS_CLIENT_ERROR, 0,
-		            "got %u parameters, expected %u", param_index, n_params);
+		g_set_error(error,
+		            IBIS_CLIENT_ERROR,
+		            IBIS_CLIENT_ERROR_PARSE_MODE_STRING_TOO_MANY_PARAMETERS,
+		            "got %u parameters, expected %u",
+		            param_index,
+		            n_params);
 
 		g_array_remove_range(mode_changes, 0, mode_changes->len);
 	}
diff --git a/ibis/ibisclient.h b/ibis/ibisclient.h
--- a/ibis/ibisclient.h
+++ b/ibis/ibisclient.h
@@ -48,9 +48,41 @@
  *
  * Since: 0.1
  */
-#define IBIS_CLIENT_ERROR \
-	(g_quark_from_static_string("ibis-client")) \
-	IBIS_AVAILABLE_MACRO_IN_0_1
+#define IBIS_CLIENT_ERROR ibis_client_error_quark()
+
+/**
+ * IbisClientError:
+ * @IBIS_CLIENT_ERROR_SERVER_CLOSED_CONNECTION: the remote side closed the
+ *  connection.
+ * @IBIS_CLIENT_ERROR_NO_MORE_NICKS: the server didn't accept any of the
+ *  specified nick names.
+ * @IBIS_CLIENT_ERROR_PARSE_MODE_STRING_NOT_ENOUGH_PARAMETERS: not enough
+ *  parameters were provided to fully parse the mode string.
+ * @IBIS_CLIENT_ERROR_PARSE_MODE_STRING_TOO_MANY_PARAMETERS: more parameters
+ *  were given than the mode string called for.
+ *
+ * Error codes returned by the client.
+ *
+ * Since: 0.12
+ */
+typedef enum {
+	IBIS_CLIENT_ERROR_SERVER_CLOSED_CONNECTION IBIS_AVAILABLE_ENUMERATOR_IN_0_12,
+	IBIS_CLIENT_ERROR_NO_MORE_NICKS IBIS_AVAILABLE_ENUMERATOR_IN_0_12,
+	IBIS_CLIENT_ERROR_PARSE_MODE_STRING_NOT_ENOUGH_PARAMETERS IBIS_AVAILABLE_ENUMERATOR_IN_0_12,
+	IBIS_CLIENT_ERROR_PARSE_MODE_STRING_TOO_MANY_PARAMETERS IBIS_AVAILABLE_ENUMERATOR_IN_0_12,
+} IbisClientError;
+
+/**
+ * ibis_client_error_quark:
+ *
+ * The error domain to identify errors from the client.
+ *
+ * Returns: The error domain.
+ *
+ * Since: 0.12
+ */
+IBIS_AVAILABLE_IN_0_12
+GQuark ibis_client_error_quark(void);
 
 #define IBIS_TYPE_CLIENT (ibis_client_get_type())
 
diff --git a/ibis/meson.build b/ibis/meson.build
--- a/ibis/meson.build
+++ b/ibis/meson.build
@@ -74,12 +74,15 @@
 ###############################################################################
 IBIS_ENUM_HEADERS = [
   'ibischanmodes.h',
+  'ibisclient.h',
 ]
 
 if IBIS_ENUM_HEADERS.length() > 0
   ibis_enums = gnome.mkenums_simple(
     'ibisenums',
     sources : IBIS_ENUM_HEADERS,
+    decorator: '_IBIS_EXTERN',
+    header_prefix: '#include "ibisversion.h"',
     install_header : true,
     install_dir : get_option('includedir') / 'ibis-1.0' / 'ibis')
 
@@ -119,7 +122,7 @@
 ###############################################################################
 if get_option('introspection')
   ibis_gir = gnome.generate_gir(ibis_lib,
-    sources : IBIS_SOURCES + IBIS_HEADERS,
+    sources : IBIS_SOURCES + IBIS_HEADERS + IBIS_BUILT_HEADERS,
     includes : ['Gio-2.0', 'GObject-2.0', 'Hasl-1.0'],
     header : 'ibis.h',
     namespace : 'Ibis',
diff --git a/ibis/tests/test_client.c b/ibis/tests/test_client.c
--- a/ibis/tests/test_client.c
+++ b/ibis/tests/test_client.c
@@ -405,7 +405,9 @@
 	mode_changes = ibis_client_parse_mode_string(client, "+o-o",
 	                                             (GStrv)params, &n_changes,
 	                                             &error);
-	g_assert_error(error, IBIS_CLIENT_ERROR, 0);
+	g_assert_error(error,
+	               IBIS_CLIENT_ERROR,
+	               IBIS_CLIENT_ERROR_PARSE_MODE_STRING_NOT_ENOUGH_PARAMETERS);
 	g_clear_error(&error);
 
 	g_assert_nonnull(mode_changes);
@@ -428,7 +430,9 @@
 	mode_changes = ibis_client_parse_mode_string(client, "+o",
 	                                             (GStrv)params, &n_changes,
 	                                             &error);
-	g_assert_error(error, IBIS_CLIENT_ERROR, 0);
+	g_assert_error(error,
+	               IBIS_CLIENT_ERROR,
+	               IBIS_CLIENT_ERROR_PARSE_MODE_STRING_TOO_MANY_PARAMETERS);
 	g_clear_error(&error);
 
 	g_assert_nonnull(mode_changes);
