[evolution-data-server] Add camel_imapx_command_failed().
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Add camel_imapx_command_failed().
- Date: Mon, 12 Aug 2013 11:21:59 +0000 (UTC)
commit 8ca239f6a64181b00dca6060418828b6e6a81c95
Author: Matthew Barnes <mbarnes redhat com>
Date: Mon Aug 12 06:26:24 2013 -0400
Add camel_imapx_command_failed().
Sets an error to return in camel_imapx_command_set_error_if_failed().
Call this function if a networking or parsing error occurred to force
all active IMAP commands to abort processing.
camel/camel-imapx-command.c | 43 +++++++++++++++++++++++++++++++
camel/camel-imapx-command.h | 2 +
docs/reference/camel/camel-sections.txt | 1 +
3 files changed, 46 insertions(+), 0 deletions(-)
---
diff --git a/camel/camel-imapx-command.c b/camel/camel-imapx-command.c
index d297b56..11338f6 100644
--- a/camel/camel-imapx-command.c
+++ b/camel/camel-imapx-command.c
@@ -42,6 +42,9 @@ struct _CamelIMAPXRealCommand {
/* For building the part. */
GString *buffer;
+ /* For network/parse errors. */
+ GError *error;
+
/* Used for running some commands synchronously. */
GCond done_sync_cond;
GMutex done_sync_mutex;
@@ -141,6 +144,8 @@ camel_imapx_command_unref (CamelIMAPXCommand *ic)
g_string_free (real_ic->buffer, TRUE);
+ g_clear_error (&real_ic->error);
+
g_cond_clear (&real_ic->done_sync_cond);
g_mutex_clear (&real_ic->done_sync_mutex);
@@ -577,12 +582,50 @@ camel_imapx_command_done (CamelIMAPXCommand *ic)
g_mutex_unlock (&real_ic->done_sync_mutex);
}
+/**
+ * camel_imapx_command_failed:
+ * @ic: a #CamelIMAPXCommand
+ * @error: the error which caused the failure
+ *
+ * Copies @error to be returned in camel_imapx_command_set_error_if_failed().
+ * Call this function if a networking or parsing error occurred to force all
+ * active IMAP commands to abort processing.
+ *
+ * Since: 3.10
+ **/
+void
+camel_imapx_command_failed (CamelIMAPXCommand *ic,
+ const GError *error)
+{
+ CamelIMAPXRealCommand *real_ic;
+
+ g_return_if_fail (CAMEL_IS_IMAPX_COMMAND (ic));
+ g_return_if_fail (error != NULL);
+
+ real_ic = (CamelIMAPXRealCommand *) ic;
+ g_return_if_fail (real_ic->error == NULL);
+
+ real_ic->error = g_error_copy (error);
+}
+
gboolean
camel_imapx_command_set_error_if_failed (CamelIMAPXCommand *ic,
GError **error)
{
+ CamelIMAPXRealCommand *real_ic;
+
g_return_val_if_fail (CAMEL_IS_IMAPX_COMMAND (ic), FALSE);
+ real_ic = (CamelIMAPXRealCommand *) ic;
+
+ /* Check for a networking or parsing error. */
+ if (real_ic->error != NULL) {
+ g_propagate_error (error, real_ic->error);
+ real_ic->error = NULL;
+ return TRUE;
+ }
+
+ /* Check if the IMAP server rejected the command. */
if (ic->status != NULL && ic->status->result != IMAPX_OK) {
/* FIXME Map IMAP response codes to more
diff --git a/camel/camel-imapx-command.h b/camel/camel-imapx-command.h
index ac9e77b..ecaa8ea 100644
--- a/camel/camel-imapx-command.h
+++ b/camel/camel-imapx-command.h
@@ -120,6 +120,8 @@ void camel_imapx_command_add_part (CamelIMAPXCommand *ic,
void camel_imapx_command_close (CamelIMAPXCommand *ic);
void camel_imapx_command_wait (CamelIMAPXCommand *ic);
void camel_imapx_command_done (CamelIMAPXCommand *ic);
+void camel_imapx_command_failed (CamelIMAPXCommand *ic,
+ const GError *error);
gboolean camel_imapx_command_set_error_if_failed
(CamelIMAPXCommand *ic,
GError **error);
diff --git a/docs/reference/camel/camel-sections.txt b/docs/reference/camel/camel-sections.txt
index ae71fb4..6b9d327 100644
--- a/docs/reference/camel/camel-sections.txt
+++ b/docs/reference/camel/camel-sections.txt
@@ -754,6 +754,7 @@ camel_imapx_command_add_part
camel_imapx_command_close
camel_imapx_command_wait
camel_imapx_command_done
+camel_imapx_command_failed
camel_imapx_command_set_error_if_failed
CamelIMAPXCommandQueue
camel_imapx_command_queue_new
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]