[PATCH] Fix tinymails usage of gerror



Tinymails GErrors are broken - Domain is a quark, not an enum value, and no GType needed at all. Patch attached.

Thanks,
Rob
Index: libtinymail-camel/tny-camel-bs-msg-receive-strategy.c
===================================================================
--- libtinymail-camel/tny-camel-bs-msg-receive-strategy.c	(revision 3648)
+++ libtinymail-camel/tny-camel-bs-msg-receive-strategy.c	(working copy)
@@ -93,7 +93,7 @@
 			int fd = open (filename, 0);
 
 			if (fd == -1) {
-				g_set_error (err, TNY_IO_ERROR, 
+				g_set_error (err, TNY_ERROR_DOMAIN,
 					TNY_IO_ERROR_READ,
 					"Can't open %s for reading", filename);
 				retval = NULL;
Index: libtinymail-camel/tny-camel-folder.c
===================================================================
--- libtinymail-camel/tny-camel-folder.c	(revision 3648)
+++ libtinymail-camel/tny-camel-folder.c	(working copy)
@@ -759,7 +759,7 @@
 		}
 
 	} else {
-		g_set_error (err, TNY_MIME_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_MIME_ERROR_MALFORMED,
 			_("Malformed message"));
 		haderr = TRUE;
@@ -1012,12 +1012,12 @@
 	}
 
 	if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv), 
-			priv->account, err, TNY_SERVICE_ERROR, 
+			priv->account, err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_ADD_MSG))
 		return;
 
 	if (!priv->account) {
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_ADD_MSG,
 			"Folder not ready for adding messages");
 		return;
@@ -1073,12 +1073,12 @@
 	g_assert (TNY_IS_HEADER (header));
 
 	if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv), 
-			priv->account, err, TNY_SERVICE_ERROR, 
+			priv->account, err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_REMOVE_MSG))
 		return;
 
 	if (!priv->account) {
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_REMOVE_MSG,
 			_("Folder not ready for removing"));
 		return;
@@ -1274,12 +1274,12 @@
 	g_assert (TNY_IS_LIST (headers));
 
 	if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv), 
-			priv->account, err, TNY_SERVICE_ERROR, 
+			priv->account, err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_REMOVE_MSG))
 		return;
 
 	if (!priv->account) {
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_REMOVE_MSG,
 			_("Folder not ready for removing"));
 		return;
@@ -1538,7 +1538,7 @@
 	CamelException ex = CAMEL_EXCEPTION_INITIALISER;
 
 	if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv), 
-			priv->account, err, TNY_SERVICE_ERROR, 
+			priv->account, err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_SYNC))
 		return;
 
@@ -1665,7 +1665,7 @@
 	CamelException ex = CAMEL_EXCEPTION_INITIALISER;
 
 	if (!priv->account) {
-		g_set_error (&info->err, TNY_SERVICE_ERROR, 
+		g_set_error (&info->err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_SYNC,
 			"Folder not ready for synchronization");
 		info->cancelled = TRUE;
@@ -2048,12 +2048,12 @@
 	TnyConnectionPolicy *constrat;
 
 	if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv), 
-			priv->account, err, TNY_SERVICE_ERROR, 
+			priv->account, err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_REFRESH))
 		return;
 
 	if (!priv->account) {
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_REFRESH,
 			_("Folder not ready for refresh"));
 		return;
@@ -2294,11 +2294,11 @@
 	g_assert (TNY_IS_LIST (headers));
 
 	if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv), priv->account, err, 
-			TNY_SERVICE_ERROR, TNY_SERVICE_ERROR_REFRESH))
+			TNY_ERROR_DOMAIN, TNY_SERVICE_ERROR_REFRESH))
 		return;
 
 	if (!priv->account) {
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_REFRESH,
 			_("Folder not ready for getting headers"));
 		return;
@@ -2822,12 +2822,12 @@
 	TnyFolderChange *change;
 
 	if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv), 
-			priv->account, err, TNY_SERVICE_ERROR, 
+			priv->account, err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_GET_MSG))
 		return NULL;
 
 	if (!priv->account) {
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_GET_MSG,
 			_("Folder not ready for getting messages"));
 		return NULL;
@@ -2891,12 +2891,12 @@
 	const gchar *uid;
 
 	if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv), 
-			priv->account, err, TNY_SERVICE_ERROR, 
+			priv->account, err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_GET_MSG))
 		return NULL;
 
 	if (!priv->account) {
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_GET_MSG,
 			_("Folder not ready for finding messages"));
 		return NULL;
@@ -2929,7 +2929,7 @@
 		TnyHeader *nhdr;
 		info = camel_folder_get_message_info (priv->folder, uid);
 		if (info == NULL) {
-			g_set_error (err, TNY_SERVICE_ERROR, TNY_SERVICE_ERROR_NO_SUCH_MESSAGE,
+			g_set_error (err, TNY_ERROR_DOMAIN, TNY_SERVICE_ERROR_NO_SUCH_MESSAGE,
 				     _("Message uid not found in folder"));
 			retval = NULL;
 		} else {
@@ -2949,7 +2949,7 @@
 		}
 
 	} else {
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 				TNY_SERVICE_ERROR_GET_MSG,
 				_("This url string is malformed"));
 		retval = NULL;
@@ -3182,7 +3182,7 @@
 			tny_folder_store_remove_folder (a_store, folder, &nerr);
 			g_object_unref (a_store);
 		} else {
-			g_set_error (&nerr, TNY_SERVICE_ERROR, 
+			g_set_error (&nerr, TNY_ERROR_DOMAIN,
 				TNY_SERVICE_ERROR_UNKNOWN,
 				"The folder (%s) didn't have a parent, therefore "
 				"failed to remove it while moving. This problem "
@@ -3358,7 +3358,7 @@
 
 	if (del && priv->reason_to_live != 0)
 	{
-		g_set_error (&nerr, TNY_SERVICE_ERROR, 
+		g_set_error (&nerr, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_STATE,
 			"You should not use this operation with del=TRUE "
 			"while the folder is still in use. There are "
@@ -3447,7 +3447,7 @@
 					if (camel_exception_is_set (&ex) || !iter)
 					{
 						if (!camel_exception_is_set (&ex))
-							g_set_error (&terr, TNY_SERVICE_ERROR, 
+							g_set_error (&terr, TNY_ERROR_DOMAIN,
 								TNY_SERVICE_ERROR_COPY, 
 								_("Folder not ready for copy"));
 						else {
@@ -3572,13 +3572,13 @@
 	TnyFolderStore *orig_store;
 
 	if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv), 
-			priv->account, err, TNY_SERVICE_ERROR, 
+			priv->account, err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_COPY))
 		return NULL;
 
 
 	if (!priv->account) {
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_COPY,
 			_("Folder not ready for copy"));
 		return NULL;
@@ -4001,14 +4001,14 @@
 	g_assert (TNY_IS_FOLDER (folder_dst));
 
 	if (!priv->account) {
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_TRANSFER,
 			_("Folder not ready for transfer"));
 		return;
 	}
 
 	if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv), 
-			priv->account, err, TNY_SERVICE_ERROR, 
+			priv->account, err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_TRANSFER))
 		return;
 
@@ -4062,7 +4062,7 @@
 
 		if (G_UNLIKELY (uid == NULL)) 
 		{
-			g_set_error (err, TNY_SERVICE_ERROR, 
+			g_set_error (err, TNY_ERROR_DOMAIN,
 				TNY_SERVICE_ERROR_TRANSFER,
 				"You can only pass summary items as headers. "
 				"These are instances that you got with the "
@@ -4693,7 +4693,7 @@
 	gboolean changed = FALSE;
 
 	if (!priv->account) {
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_FOLDER_REMOVE,
 			_("Folder store not ready for removal"));
 		return;
@@ -4887,11 +4887,11 @@
 	GList *changes = NULL;
 
 	if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv), priv->account, err, 
-			TNY_SERVICE_ERROR, TNY_SERVICE_ERROR_FOLDER_REMOVE))
+			TNY_ERROR_DOMAIN, TNY_SERVICE_ERROR_FOLDER_REMOVE))
 		return;
 
 	if (!priv->account) {
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_FOLDER_REMOVE,
 			_("Folder store not ready for removing folders"));
 		return;
@@ -4970,12 +4970,12 @@
 	gboolean was_new = FALSE;
 
 	if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv), 
-			priv->account, err, TNY_SERVICE_ERROR, 
+			priv->account, err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_FOLDER_CREATE))
 		return NULL;
 
 	if (!name || strlen (name) <= 0) {
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 				TNY_SERVICE_ERROR_FOLDER_CREATE,
 				_("Failed to create folder with no name"));
 		_tny_session_stop_operation (TNY_FOLDER_PRIV_GET_SESSION (priv));
@@ -4983,7 +4983,7 @@
 	}
 
 	if (!priv->folder_name) {
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 				TNY_SERVICE_ERROR_FOLDER_CREATE,
 				_("Failed to create folder. Invalid parent folder"));
 		_tny_session_stop_operation (TNY_FOLDER_PRIV_GET_SESSION (priv));
@@ -5004,7 +5004,7 @@
 			_tny_camel_exception_to_tny_error (&ex, err);
 			camel_exception_clear (&ex);
 		} else
-			g_set_error (err, TNY_SERVICE_ERROR, 
+			g_set_error (err, TNY_ERROR_DOMAIN,
 				TNY_SERVICE_ERROR_FOLDER_CREATE,
 				_("Unknown error while trying to create folder"));
 
@@ -5249,7 +5249,7 @@
 	TnyAccount *account = NULL;
 
 	if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv), 
-			priv->account, err, TNY_SERVICE_ERROR, 
+			priv->account, err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_GET_FOLDERS))
 		return;
 
Index: libtinymail-camel/tny-camel-nntp-folder.c
===================================================================
--- libtinymail-camel/tny-camel-nntp-folder.c	(revision 3648)
+++ libtinymail-camel/tny-camel-nntp-folder.c	(working copy)
@@ -60,7 +60,7 @@
 static void 
 tny_camel_nntp_folder_remove_folder (TnyFolderStore *self, TnyFolder *folder, GError **err)
 {
-	g_set_error (err, TNY_SERVICE_ERROR, 
+	g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_UNSUPPORTED,
 			"You can't use the tny_folder_store_remove_folder API "
 			"on NNTP accounts. This problem indicates a bug "
@@ -72,7 +72,7 @@
 static TnyFolder* 
 tny_camel_nntp_folder_create_folder (TnyFolderStore *self, const gchar *name, GError **err)
 {
-	g_set_error (err, TNY_SERVICE_ERROR, 
+	g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_UNSUPPORTED,
 			"You can't use the tny_folder_store_create_folder "
 			"API on NNTP accounts. This problem indicates a bug "
Index: libtinymail-camel/tny-camel-mime-part.c
===================================================================
--- libtinymail-camel/tny-camel-mime-part.c	(revision 3648)
+++ libtinymail-camel/tny-camel-mime-part.c	(working copy)
@@ -668,7 +668,7 @@
 		g_warning (_("Mime part does not yet have a source stream, use "
 			     "tny_mime_part_construct first"));
 		camel_object_unref (cstream);
-		g_set_error (err, TNY_MIME_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 				TNY_MIME_ERROR_STATE,
 				_("Mime part does not yet have a source stream, use "
 				"tny_mime_part_construct first"));
@@ -685,7 +685,7 @@
 	camel_object_unref (medium);
 
 	if (bytes < 0) {
-		g_set_error (err, TNY_IO_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 				TNY_IO_ERROR_WRITE,
 				strerror (errno));
 	}
@@ -788,7 +788,7 @@
 	camel_object_unref (medium);
 	
 	if (bytes < 0) {
-		g_set_error (err, TNY_IO_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 				TNY_IO_ERROR_WRITE,
 				strerror (errno));
 	}
Index: libtinymail-camel/tny-camel-send-queue.c
===================================================================
--- libtinymail-camel/tny-camel-send-queue.c	(revision 3648)
+++ libtinymail-camel/tny-camel-send-queue.c	(working copy)
@@ -845,7 +845,7 @@
 
 			if (!info->outbox || !info->sentbox) {
 
-				g_set_error (err, TNY_SERVICE_ERROR, 
+				g_set_error (err, TNY_ERROR_DOMAIN,
 					TNY_SERVICE_ERROR_ADD_MSG, FOLDERSNOTREADY);
 				g_warning (FOLDERSNOTREADY);
 
@@ -1026,7 +1026,7 @@
 
 		if (!outbox || !TNY_IS_FOLDER (outbox))
 		{
-			g_set_error (err, TNY_SERVICE_ERROR, 
+			g_set_error (err, TNY_ERROR_DOMAIN,
 				TNY_SERVICE_ERROR_ADD_MSG,
 				_("Operating can't continue: send queue not ready "
 				"because it does not have a valid outbox. "
@@ -1084,7 +1084,7 @@
 	outbox = tny_send_queue_get_outbox (TNY_SEND_QUEUE (self));
 
 	if (!outbox || !TNY_IS_FOLDER (outbox)) {
-		g_set_error (&err, TNY_SERVICE_ERROR, 
+		g_set_error (&err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_ADD_MSG,
 			_("Operating can't continue: send queue not ready "
 			"because it does not have a valid outbox. "
Index: libtinymail-camel/tny-camel-pop-store-account.c
===================================================================
--- libtinymail-camel/tny-camel-pop-store-account.c	(revision 3648)
+++ libtinymail-camel/tny-camel-pop-store-account.c	(working copy)
@@ -68,7 +68,7 @@
 static void 
 tny_camel_pop_store_account_remove_folder (TnyFolderStore *self, TnyFolder *folder, GError **err)
 {
-	g_set_error (err, TNY_SERVICE_ERROR, 
+	g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_UNSUPPORTED,
 			"You can't use the tny_folder_store_remove_folder API "
 			"on POP accounts. This problem indicates a bug in the "
@@ -80,7 +80,7 @@
 static TnyFolder* 
 tny_camel_pop_store_account_create_folder (TnyFolderStore *self, const gchar *name, GError **err)
 {
-	g_set_error (err, TNY_SERVICE_ERROR, 
+	g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_UNSUPPORTED,
 			"You can't use the tny_folder_store_create_folder "
 			"API on POP accounts. This problem indicates a "
Index: libtinymail-camel/tny-camel-pop-folder.c
===================================================================
--- libtinymail-camel/tny-camel-pop-folder.c	(revision 3648)
+++ libtinymail-camel/tny-camel-pop-folder.c	(working copy)
@@ -77,7 +77,7 @@
 static void 
 tny_camel_pop_folder_remove_folder (TnyFolderStore *self, TnyFolder *folder, GError **err)
 {
-	g_set_error (err, TNY_SERVICE_ERROR, 
+	g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_UNSUPPORTED,
 			"You can't use the tny_folder_store_remove_folder "
 			"API on POP accounts. This problem indicates a bug in "
@@ -89,7 +89,7 @@
 static TnyFolder* 
 tny_camel_pop_folder_create_folder (TnyFolderStore *self, const gchar *name, GError **err)
 {
-	g_set_error (err, TNY_SERVICE_ERROR, 
+	g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_UNSUPPORTED,
 			"You can't use the tny_folder_store_create_folder "
 			"API on POP accounts. This problem indicates a "
Index: libtinymail-camel/tny-camel-common.c
===================================================================
--- libtinymail-camel/tny-camel-common.c	(revision 3648)
+++ libtinymail-camel/tny-camel-common.c	(working copy)
@@ -331,57 +331,57 @@
 	case CAMEL_EXCEPTION_INVALID_PARAM: 
 		/* The From/To address is not well formed while 
 		 * sending or NNTP authentication error*/
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_PROTOCOL,
 			camel_exception_get_description (ex));
 	break;
 
 	case CAMEL_EXCEPTION_SYSTEM:
-		g_set_error (err, TNY_SYSTEM_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SYSTEM_ERROR_UNKNOWN,
 			camel_exception_get_description (ex));
 	break;
 
 	case CAMEL_EXCEPTION_USER_CANCEL:
-		g_set_error (err, TNY_SYSTEM_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SYSTEM_ERROR_CANCEL,
 			camel_exception_get_description (ex));
 	break;
 
 	/* Usually fs space problems */
 	case CAMEL_EXCEPTION_SYSTEM_IO_WRITE:
-		g_set_error (err, TNY_IO_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_IO_ERROR_WRITE,
 			camel_exception_get_description (ex));
 	break;
 
 	case CAMEL_EXCEPTION_SYSTEM_MEMORY:
-		g_set_error (err, TNY_IO_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_IO_ERROR_WRITE,
 			camel_exception_get_description (ex));
 	break;
 
 	/* Usually fs corruption problems */
 	case CAMEL_EXCEPTION_SYSTEM_IO_READ:
-		g_set_error (err, TNY_IO_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_IO_ERROR_READ,
 			camel_exception_get_description (ex));
 	break;
 
 	case CAMEL_EXCEPTION_FOLDER_UID_NOT_AVAILABLE: /* message not available atm */
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_MESSAGE_NOT_AVAILABLE,
 			camel_exception_get_description (ex));
 	break;
 
 	case CAMEL_EXCEPTION_FOLDER_INVALID_UID: /* message does not exist */
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_NO_SUCH_MESSAGE,
 			camel_exception_get_description (ex));
 	break;
 
 	case CAMEL_EXCEPTION_SERVICE_NOT_SUPPORTED:
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_UNSUPPORTED,
 			camel_exception_get_description (ex));
 	break;
@@ -392,52 +392,52 @@
 	case CAMEL_EXCEPTION_FOLDER_NON_UID:  /* never used */
 	case CAMEL_EXCEPTION_FOLDER_INSUFFICIENT_PERMISSION:
 	case CAMEL_EXCEPTION_FOLDER_SUMMARY_INVALID: /* destroyed and recreated on server */
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_UNKNOWN,
 			camel_exception_get_description (ex));
 	break;
 
 	case CAMEL_EXCEPTION_FOLDER_RENAME: /* folder rename error */
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_FOLDER_RENAME,
 			camel_exception_get_description (ex));
 	break;
 
 	case CAMEL_EXCEPTION_FOLDER_NON_EMPTY: /* folder delete error */
 	case CAMEL_EXCEPTION_FOLDER_DELETE:
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_FOLDER_REMOVE,
 			camel_exception_get_description (ex));
 	break;
 
 	case CAMEL_EXCEPTION_FOLDER_CREATE: /* folder create error */
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_FOLDER_CREATE,
 			camel_exception_get_description (ex));
 	break;
 
 	case CAMEL_EXCEPTION_STORE_NO_FOLDER: /* Folder does not exist */
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_FOLDER_IS_UNKNOWN,
 			camel_exception_get_description (ex));
 	break;
 
 	case CAMEL_EXCEPTION_SERVICE_PROTOCOL:
 		/* For example BAD from IMAP server */
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_PROTOCOL,
 			camel_exception_get_description (ex));
 	break;
 
 	case CAMEL_EXCEPTION_STORE_NULL:
 	case CAMEL_EXCEPTION_STORE_INVALID: /* unused */
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_UNKNOWN,
 			camel_exception_get_description (ex));
 	break;
 
 	case CAMEL_EXCEPTION_SERVICE_INVALID:
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_PROTOCOL,
 			camel_exception_get_description (ex));
 	break;
@@ -445,38 +445,38 @@
 	case CAMEL_EXCEPTION_SERVICE_NOT_CONNECTED:
 	case CAMEL_EXCEPTION_SERVICE_UNAVAILABLE:
 		/* You must be working online */
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_UNAVAILABLE,
 			camel_exception_get_description (ex));
 	break;
 
 	case CAMEL_EXCEPTION_SERVICE_CONNECT:
 	case CAMEL_EXCEPTION_SYSTEM_HOST_LOOKUP_FAILED:
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_CONNECT,
 			camel_exception_get_description (ex));
 	break;
 
 	case CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE:
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_AUTHENTICATE,
 			camel_exception_get_description (ex));
 	break;
 
 	case CAMEL_EXCEPTION_SERVICE_CERTIFICATE:
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_CERTIFICATE,
 			camel_exception_get_description (ex));
 	break;
 
 	case CAMEL_EXCEPTION_SERVICE_NULL:
 	case CAMEL_EXCEPTION_SERVICE_URL_INVALID:
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_UNKNOWN,
 			camel_exception_get_description (ex));
 	break;
 	default:
-		g_set_error (err, TNY_SYSTEM_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SYSTEM_ERROR_UNKNOWN,
 			camel_exception_get_description (ex));
 	break;
Index: libtinymail-camel/tny-camel-nntp-store-account.c
===================================================================
--- libtinymail-camel/tny-camel-nntp-store-account.c	(revision 3648)
+++ libtinymail-camel/tny-camel-nntp-store-account.c	(working copy)
@@ -69,7 +69,7 @@
 static void 
 tny_camel_nntp_store_account_remove_folder (TnyFolderStore *self, TnyFolder *folder, GError **err)
 {
-	g_set_error (err, TNY_SERVICE_ERROR, 
+	g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_UNSUPPORTED,
 			"You can't use the tny_folder_store_remove_folder API "
 			"on NNTP accounts. This problem indicates a bug in the "
@@ -81,7 +81,7 @@
 static TnyFolder* 
 tny_camel_nntp_store_account_create_folder (TnyFolderStore *self, const gchar *name, GError **err)
 {
-	g_set_error (err, TNY_SERVICE_ERROR, 
+	g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_UNSUPPORTED,
 			"You can't use the tny_folder_store_create_folder "
 			"API on NNTP accounts. This problem indicates a "
Index: libtinymail-camel/tny-camel-store-account.c
===================================================================
--- libtinymail-camel/tny-camel-store-account.c	(revision 3648)
+++ libtinymail-camel/tny-camel-store-account.c	(working copy)
@@ -555,7 +555,7 @@
 			_tny_camel_exception_to_tny_error (apriv->ex, err);
 			camel_exception_clear (apriv->ex);
 		} else {
-			g_set_error (err, TNY_SERVICE_ERROR, 
+			g_set_error (err, TNY_ERROR_DOMAIN,
 				TNY_SERVICE_ERROR_CONNECT,
 				"Account not yet fully configured. "
 				"This problem indicates a bug in the software.");
@@ -581,7 +581,7 @@
 				_tny_camel_exception_to_tny_error (&ex, err);
 				camel_exception_clear (&ex);
 			} else {
-				g_set_error (err, TNY_SERVICE_ERROR, 
+				g_set_error (err, TNY_ERROR_DOMAIN,
 					TNY_SERVICE_ERROR_CONNECT,
 					_("Unknown error while connecting"));
 			}
@@ -592,7 +592,7 @@
 		g_static_rec_mutex_unlock (apriv->service_lock);
 
 	} else {
-			g_set_error (err, TNY_SERVICE_ERROR, 
+			g_set_error (err, TNY_ERROR_DOMAIN,
 				TNY_SERVICE_ERROR_CONNECT,
 				_("Get and Forget password functions not yet set. "
 				"This problem indicates a bug in the software."));
@@ -1025,12 +1025,12 @@
 	GList *changes = NULL;
 
 	if (!_tny_session_check_operation (apriv->session, TNY_ACCOUNT (self), err,
-			TNY_SERVICE_ERROR, TNY_SERVICE_ERROR_FOLDER_REMOVE))
+			TNY_ERROR_DOMAIN, TNY_SERVICE_ERROR_FOLDER_REMOVE))
 		return;
 
 	if (apriv->service == NULL || !CAMEL_IS_SERVICE (apriv->service))
 	{
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 				TNY_SERVICE_ERROR_FOLDER_REMOVE,
 				_("Account not ready for this operation."
 				"This problem indicates a bug in the software"));
@@ -1073,12 +1073,12 @@
 	gboolean was_new = FALSE;
 
 	if (!_tny_session_check_operation (apriv->session, TNY_ACCOUNT (self), err,
-			TNY_SERVICE_ERROR, TNY_SERVICE_ERROR_FOLDER_CREATE))
+			TNY_ERROR_DOMAIN, TNY_SERVICE_ERROR_FOLDER_CREATE))
 		return NULL;
 
 	if (!name || strlen (name) <= 0)
 	{
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 				TNY_SERVICE_ERROR_FOLDER_CREATE,
 				_("Failed to create folder with no name"));
 		_tny_session_stop_operation (apriv->session);
@@ -1089,7 +1089,7 @@
 
 	if (apriv->service == NULL || !CAMEL_IS_SERVICE (apriv->service))
 	{
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 				TNY_SERVICE_ERROR_FOLDER_CREATE,
 				_("Account not ready for this operation. "
 				"This problem indicates a bug in the softare."));
@@ -1354,7 +1354,7 @@
 
 
 	if (!_tny_session_check_operation (apriv->session, TNY_ACCOUNT (self), err, 
-			TNY_SERVICE_ERROR, TNY_SERVICE_ERROR_GET_FOLDERS))
+			TNY_ERROR_DOMAIN, TNY_SERVICE_ERROR_GET_FOLDERS))
 		return;
 
 	if (query != NULL)
@@ -1362,7 +1362,7 @@
 
 	if (apriv->service == NULL || !CAMEL_IS_SERVICE (apriv->service))
 	{
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 				TNY_SERVICE_ERROR_GET_FOLDERS,
 				_("Account not ready for this operation. "
 				"This problem indicates a bug in the software."));
@@ -1737,12 +1737,12 @@
 	g_assert (CAMEL_IS_SESSION (apriv->session));
 
 	if (!_tny_session_check_operation (apriv->session, TNY_ACCOUNT (self), err, 
-			TNY_SERVICE_ERROR, TNY_SERVICE_ERROR_GET_FOLDERS))
+			TNY_ERROR_DOMAIN, TNY_SERVICE_ERROR_GET_FOLDERS))
 		return NULL;
 
 	if (apriv->service == NULL || !CAMEL_IS_SERVICE (apriv->service))
 	{
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 				TNY_SERVICE_ERROR_GET_FOLDERS,
 				_("Account not ready for this operation."
 				"This problem indicates a bug in the software."));
@@ -1821,7 +1821,7 @@
 			nnstr = NULL;
 		}
 	} else {
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_GET_FOLDERS,
 			_("Invalid URL string"));
 		_tny_session_stop_operation (apriv->session);
@@ -2005,7 +2005,7 @@
 	if (!apriv->service) {
 		if (callback) {
 			GError *err = NULL;
-			g_set_error (&err, TNY_SYSTEM_ERROR, TNY_SYSTEM_ERROR_MEMORY, 
+			g_set_error (&err, TNY_ERROR_DOMAIN, TNY_SYSTEM_ERROR_MEMORY, 
 				_("Internal error, account not ready"));
 			callback ((TnyCamelAccount *) self, TRUE, err, user_data);
 			g_error_free (err);
Index: libtinymail-camel/tny-camel-transport-account.c
===================================================================
--- libtinymail-camel/tny-camel-transport-account.c	(revision 3648)
+++ libtinymail-camel/tny-camel-transport-account.c	(working copy)
@@ -119,7 +119,7 @@
 			_tny_camel_exception_to_tny_error (apriv->ex, err);
 			camel_exception_clear (apriv->ex);
 		} else {
-			g_set_error (err, TNY_SERVICE_ERROR, 
+			g_set_error (err, TNY_ERROR_DOMAIN,
 				TNY_SERVICE_ERROR_CONNECT,
 				_("Account not yet fully configured. "
 				"This problem indicates a bug in the software."));
@@ -134,7 +134,7 @@
 			camel_exception_clear (apriv->ex);
 
 	} else {
-			g_set_error (err, TNY_SERVICE_ERROR, 
+			g_set_error (err, TNY_ERROR_DOMAIN,
 				TNY_SERVICE_ERROR_CONNECT,
 				_("Get and Forget password functions not yet set "
 				"This problem indicates a bug in the software."));
@@ -198,7 +198,7 @@
 		if (camel_exception_is_set (&ex)) {
 			_tny_camel_exception_to_tny_error (&ex, err);
 		} else {
-			g_set_error (err, TNY_SERVICE_ERROR, 
+			g_set_error (err, TNY_ERROR_DOMAIN,
 				TNY_SERVICE_ERROR_AUTHENTICATE,
 				_("Authentication error"));
 		}
@@ -240,7 +240,7 @@
 			_tny_camel_exception_to_tny_error (&ex, err);
 			camel_exception_clear (&ex);
 		} else 
-			g_set_error (err, TNY_SERVICE_ERROR, 
+			g_set_error (err, TNY_ERROR_DOMAIN,
 				TNY_SERVICE_ERROR_SEND,
 				_("Unknown error while sending message"));
 
Index: libtinymail-camel/tny-camel-account.c
===================================================================
--- libtinymail-camel/tny-camel-account.c	(revision 3648)
+++ libtinymail-camel/tny-camel-account.c	(working copy)
@@ -1608,7 +1608,7 @@
 			_tny_camel_exception_to_tny_error (priv->ex, err);
 			camel_exception_clear (priv->ex);
 		} else {
-			g_set_error (err, TNY_SERVICE_ERROR, 
+			g_set_error (err, TNY_ERROR_DOMAIN,
 				TNY_SERVICE_ERROR_CONNECT,
 				"Account not yet fully configured. "
 				"This problem indicates a bug in the software.");
@@ -2066,7 +2066,7 @@
 	GError *err = NULL;
 
 	if (!_tny_session_check_operation (priv->session, TNY_ACCOUNT (self), &err, 
-			TNY_SERVICE_ERROR, TNY_SERVICE_ERROR_UNKNOWN))
+			TNY_ERROR_DOMAIN, TNY_SERVICE_ERROR_UNKNOWN))
 	{
 		if (callback) {
 			callback (self, TRUE /* cancelled */, NULL, err, user_data);
Index: libtinymail/tny-error.c
===================================================================
--- libtinymail/tny-error.c	(revision 3648)
+++ libtinymail/tny-error.c	(working copy)
@@ -49,44 +49,19 @@
 }
 
 /**
- * tny_error_domain_get_type:
+ * dbus_g_error_quark:
  *
- * GType system helper function
+ * The implementation of #DBUS_GERROR error domain. See documentation
+ * for #GError in GLib reference manual.
  *
- * returns: a #GType
- **/
-GType
-tny_error_domain_get_type (void)
+ * Returns: the error domain quark for use with #GError
+ */
+GQuark
+tny_get_error_quark (void)
 {
-  static GType etype = 0;
-  if (etype == 0) {
-    static const GEnumValue values[] = {
-      { 0, NULL, NULL }
-    };
-    etype = g_enum_register_static ("TnyErrorDomain", values);
-  }
-  return etype;
+  static GQuark quark = 0;
+  if (quark == 0)
+    quark = g_quark_from_static_string ("tinymail-error-quark");
+  return quark;
 }
 
-
-/**
- * tny_error_get_type:
- *
- * GType system helper function
- *
- * returns: a #GType
- **/
-GType
-tny_error_get_type (void)
-{
-  static GType etype = 0;
-  if (etype == 0) {
-    static const GEnumValue values[] = {
-
-
-      { 0, NULL, NULL }
-    };
-    etype = g_enum_register_static ("TnyError", values);
-  }
-  return etype;
-}
Index: libtinymail/tny-error.h
===================================================================
--- libtinymail/tny-error.h	(revision 3648)
+++ libtinymail/tny-error.h	(working copy)
@@ -24,22 +24,8 @@
 #include <glib-object.h>
 #include <tny-shared.h>
 
-#define TNY_TYPE_ERROR_DOMAIN (tny_error_domain_get_type())
+#define TNY_ERROR_DOMAIN (tny_get_error_quark())
 
-
-enum _TnyErrorDomain
-{
-	TNY_SYSTEM_ERROR = 1,
-	TNY_IO_ERROR = 2,
-	TNY_SERVICE_ERROR = 3,
-	TNY_MIME_ERROR = 4,
-};
-
-typedef enum _TnyErrorDomain TnyErrorDomain;
-
-#define TNY_TYPE_ERROR (tny_error_get_type())
-
- 
 /**
  * TnyError:
  *
@@ -93,8 +79,7 @@
 const gchar* tny_error_get_message (GError *err);
 gint tny_error_get_code (GError *err);
 
-GType tny_error_domain_get_type (void);
-GType tny_error_get_type (void);
+GQuark tny_get_error_quark (void);
 
 
 #endif
Index: libtinymail/tny-merge-folder.c
===================================================================
--- libtinymail/tny-merge-folder.c	(revision 3648)
+++ libtinymail/tny-merge-folder.c	(working copy)
@@ -257,7 +257,7 @@
 
 	if (callback) {
 		GError *err = NULL;
-		g_set_error (&err, TNY_SERVICE_ERROR, 
+		g_set_error (&err, TNY_ERROR_DOMAIN,
 			TNY_SERVICE_ERROR_UNSUPPORTED,
 			"tny_merge_folder_add_msg not implemented: add it to the mother "
 			"folder instead. This problem indicates a bug in the software.");
@@ -273,7 +273,7 @@
 	g_warning ("tny_merge_folder_add_msg not implemented: "
 		   "add it to the mother folder instead\n");
 
-	g_set_error (err, TNY_SERVICE_ERROR, 
+	g_set_error (err, TNY_ERROR_DOMAIN,
 		TNY_SERVICE_ERROR_UNSUPPORTED,
 		"tny_merge_folder_add_msg not implemented: add it to the mother "
 		"folder instead. This problem indicates a bug in the software.");
@@ -523,7 +523,7 @@
 
 
 	if (!retval)
-		g_set_error (err, TNY_SERVICE_ERROR, 
+		g_set_error (err, TNY_ERROR_DOMAIN,
 				TNY_SERVICE_ERROR_NO_SUCH_MESSAGE,
 				"Message not found");
 


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