[evolution-kolab: 4/8] updated IMAPX files as of EDS commit 891f5b4cf7a680135af907027ba82150cad777c8
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab: 4/8] updated IMAPX files as of EDS commit 891f5b4cf7a680135af907027ba82150cad777c8
- Date: Mon, 26 Mar 2012 15:43:17 +0000 (UTC)
commit f3db0695fc4bd3a136fba88269395f09a15f54a8
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Mon Mar 26 10:52:28 2012 +0200
updated IMAPX files as of EDS commit 891f5b4cf7a680135af907027ba82150cad777c8
* updated the local IMAPX code from upstream
* now at EDS commit
891f5b4cf7a680135af907027ba82150cad777c8
src/camel/providers/imapx/camel-imapx-command.c | 90 ++++++--
src/camel/providers/imapx/camel-imapx-command.h | 9 +-
src/camel/providers/imapx/camel-imapx-job.c | 53 +++--
src/camel/providers/imapx/camel-imapx-job.h | 4 +
src/camel/providers/imapx/camel-imapx-server.c | 311 ++++++++++++++++-------
5 files changed, 340 insertions(+), 127 deletions(-)
---
diff --git a/src/camel/providers/imapx/camel-imapx-command.c b/src/camel/providers/imapx/camel-imapx-command.c
index e9d1298..8afcc4e 100644
--- a/src/camel/providers/imapx/camel-imapx-command.c
+++ b/src/camel/providers/imapx/camel-imapx-command.c
@@ -23,6 +23,7 @@
#include <glib/gstdio.h>
#include <glib/gi18n-lib.h>
+#include "camel-imapx-job.h"
#include "camel-imapx-server.h"
#include "camel-imapx-store.h"
@@ -36,6 +37,8 @@ struct _CamelIMAPXRealCommand {
volatile gint ref_count;
+ CamelIMAPXJob *job;
+
/* For building the part. */
GString *buffer;
@@ -91,10 +94,9 @@ camel_imapx_command_ref (CamelIMAPXCommand *ic)
{
CamelIMAPXRealCommand *real_ic;
- real_ic = (CamelIMAPXRealCommand *) ic;
+ g_return_val_if_fail (CAMEL_IS_IMAPX_COMMAND (ic), NULL);
- g_return_val_if_fail (real_ic != NULL, NULL);
- g_return_val_if_fail (real_ic->ref_count > 0, NULL);
+ real_ic = (CamelIMAPXRealCommand *) ic;
g_atomic_int_inc (&real_ic->ref_count);
@@ -106,10 +108,9 @@ camel_imapx_command_unref (CamelIMAPXCommand *ic)
{
CamelIMAPXRealCommand *real_ic;
- real_ic = (CamelIMAPXRealCommand *) ic;
+ g_return_if_fail (CAMEL_IS_IMAPX_COMMAND (ic));
- g_return_if_fail (real_ic != NULL);
- g_return_if_fail (real_ic->ref_count > 0);
+ real_ic = (CamelIMAPXRealCommand *) ic;
if (g_atomic_int_dec_and_test (&real_ic->ref_count)) {
CamelIMAPXCommandPart *cp;
@@ -135,6 +136,9 @@ camel_imapx_command_unref (CamelIMAPXCommand *ic)
/* Free the private stuff. */
+ if (real_ic->job != NULL)
+ camel_imapx_job_unref (real_ic->job);
+
g_string_free (real_ic->buffer, TRUE);
g_cond_free (real_ic->done_sync_cond);
@@ -144,16 +148,35 @@ camel_imapx_command_unref (CamelIMAPXCommand *ic)
* propagated to the CamelIMAPXJob, so it's either NULL or the
* CamelIMAPXJob owns it now. */
+ /* Fill the memory with a bit pattern before releasing
+ * it back to the slab allocator, so we can more easily
+ * identify dangling CamelIMAPXCommand pointers. */
+ memset (real_ic, 0xaa, sizeof (CamelIMAPXRealCommand));
+
+ /* But leave the reference count set to zero, so
+ * CAMEL_IS_IMAPX_COMMAND can identify it as bad. */
+ real_ic->ref_count = 0;
+
g_slice_free (CamelIMAPXRealCommand, real_ic);
}
}
+gboolean
+camel_imapx_command_check (CamelIMAPXCommand *ic)
+{
+ CamelIMAPXRealCommand *real_ic;
+
+ real_ic = (CamelIMAPXRealCommand *) ic;
+
+ return (real_ic != NULL && real_ic->ref_count > 0);
+}
+
gint
camel_imapx_command_compare (CamelIMAPXCommand *ic1,
CamelIMAPXCommand *ic2)
{
- g_return_val_if_fail (ic1 != NULL, 0);
- g_return_val_if_fail (ic2 != NULL, 0);
+ g_return_val_if_fail (CAMEL_IS_IMAPX_COMMAND (ic1), 0);
+ g_return_val_if_fail (CAMEL_IS_IMAPX_COMMAND (ic2), 0);
if (ic1->pri == ic2->pri)
return 0;
@@ -161,6 +184,39 @@ camel_imapx_command_compare (CamelIMAPXCommand *ic1,
return (ic1->pri < ic2->pri) ? -1 : 1;
}
+CamelIMAPXJob *
+camel_imapx_command_get_job (CamelIMAPXCommand *ic)
+{
+ CamelIMAPXRealCommand *real_ic;
+
+ g_return_val_if_fail (CAMEL_IS_IMAPX_COMMAND (ic), NULL);
+
+ real_ic = (CamelIMAPXRealCommand *) ic;
+
+ return real_ic->job;
+}
+
+void
+camel_imapx_command_set_job (CamelIMAPXCommand *ic,
+ CamelIMAPXJob *job)
+{
+ CamelIMAPXRealCommand *real_ic;
+
+ g_return_if_fail (CAMEL_IS_IMAPX_COMMAND (ic));
+
+ real_ic = (CamelIMAPXRealCommand *) ic;
+
+ if (job != NULL) {
+ g_return_if_fail (CAMEL_IS_IMAPX_JOB (job));
+ camel_imapx_job_ref (job);
+ }
+
+ if (real_ic->job != NULL)
+ camel_imapx_job_unref (real_ic->job);
+
+ real_ic->job = job;
+}
+
void
camel_imapx_command_add (CamelIMAPXCommand *ic,
const gchar *format,
@@ -168,7 +224,7 @@ camel_imapx_command_add (CamelIMAPXCommand *ic,
{
va_list ap;
- g_return_if_fail (ic != NULL);
+ g_return_if_fail (CAMEL_IS_IMAPX_COMMAND (ic));
if (format != NULL && *format != '\0') {
va_start (ap, format);
@@ -203,7 +259,7 @@ camel_imapx_command_addv (CamelIMAPXCommand *ic,
gchar *fname = NULL, *encoded = NULL;
const gchar *full_name;
- g_return_if_fail (ic != NULL);
+ g_return_if_fail (CAMEL_IS_IMAPX_COMMAND (ic));
c(ic->is->tagprefix, "adding command, format = '%s'\n", format);
@@ -474,7 +530,7 @@ camel_imapx_command_close (CamelIMAPXCommand *ic)
{
GString *buffer;
- g_return_if_fail (ic != NULL);
+ g_return_if_fail (CAMEL_IS_IMAPX_COMMAND (ic));
buffer = ((CamelIMAPXRealCommand *) ic)->buffer;
@@ -494,7 +550,7 @@ camel_imapx_command_wait (CamelIMAPXCommand *ic)
{
CamelIMAPXRealCommand *real_ic;
- g_return_if_fail (ic != NULL);
+ g_return_if_fail (CAMEL_IS_IMAPX_COMMAND (ic));
real_ic = (CamelIMAPXRealCommand *) ic;
@@ -511,7 +567,7 @@ camel_imapx_command_done (CamelIMAPXCommand *ic)
{
CamelIMAPXRealCommand *real_ic;
- g_return_if_fail (ic != NULL);
+ g_return_if_fail (CAMEL_IS_IMAPX_COMMAND (ic));
real_ic = (CamelIMAPXRealCommand *) ic;
@@ -525,7 +581,7 @@ gboolean
camel_imapx_command_set_error_if_failed (CamelIMAPXCommand *ic,
GError **error)
{
- g_return_val_if_fail (ic != NULL, FALSE);
+ g_return_val_if_fail (CAMEL_IS_IMAPX_COMMAND (ic), FALSE);
if (ic->status != NULL && ic->status->result != IMAPX_OK) {
if (ic->status->text != NULL)
@@ -581,7 +637,7 @@ camel_imapx_command_queue_push_tail (CamelIMAPXCommandQueue *queue,
CamelIMAPXCommand *ic)
{
g_return_if_fail (queue != NULL);
- g_return_if_fail (ic != NULL);
+ g_return_if_fail (CAMEL_IS_IMAPX_COMMAND (ic));
camel_imapx_command_ref (ic);
@@ -593,7 +649,7 @@ camel_imapx_command_queue_insert_sorted (CamelIMAPXCommandQueue *queue,
CamelIMAPXCommand *ic)
{
g_return_if_fail (queue != NULL);
- g_return_if_fail (ic != NULL);
+ g_return_if_fail (CAMEL_IS_IMAPX_COMMAND (ic));
camel_imapx_command_ref (ic);
@@ -639,7 +695,7 @@ camel_imapx_command_queue_remove (CamelIMAPXCommandQueue *queue,
CamelIMAPXCommand *ic)
{
g_return_val_if_fail (queue != NULL, FALSE);
- g_return_val_if_fail (ic != NULL, FALSE);
+ g_return_val_if_fail (CAMEL_IS_IMAPX_COMMAND (ic), FALSE);
if (g_queue_remove ((GQueue *) queue, ic)) {
camel_imapx_command_unref (ic);
diff --git a/src/camel/providers/imapx/camel-imapx-command.h b/src/camel/providers/imapx/camel-imapx-command.h
index b4ab2c2..49f8f39 100644
--- a/src/camel/providers/imapx/camel-imapx-command.h
+++ b/src/camel/providers/imapx/camel-imapx-command.h
@@ -23,6 +23,9 @@
#include "camel-imapx-utils.h"
+#define CAMEL_IS_IMAPX_COMMAND(command) \
+ (camel_imapx_command_check (command))
+
G_BEGIN_DECLS
/* Avoid a circular reference. */
@@ -84,7 +87,6 @@ struct _CamelIMAPXCommand {
/* Responsible for free'ing the command. */
CamelIMAPXCommandFunc complete;
- struct _CamelIMAPXJob *job;
};
CamelIMAPXCommand *
@@ -96,8 +98,13 @@ CamelIMAPXCommand *
CamelIMAPXCommand *
camel_imapx_command_ref (CamelIMAPXCommand *ic);
void camel_imapx_command_unref (CamelIMAPXCommand *ic);
+gboolean camel_imapx_command_check (CamelIMAPXCommand *ic);
gint camel_imapx_command_compare (CamelIMAPXCommand *ic1,
CamelIMAPXCommand *ic2);
+struct _CamelIMAPXJob *
+ camel_imapx_command_get_job (CamelIMAPXCommand *ic);
+void camel_imapx_command_set_job (CamelIMAPXCommand *ic,
+ struct _CamelIMAPXJob *job);
void camel_imapx_command_add (CamelIMAPXCommand *ic,
const gchar *format,
...);
diff --git a/src/camel/providers/imapx/camel-imapx-job.c b/src/camel/providers/imapx/camel-imapx-job.c
index e61ed3b..c8fc68a 100644
--- a/src/camel/providers/imapx/camel-imapx-job.c
+++ b/src/camel/providers/imapx/camel-imapx-job.c
@@ -18,6 +18,8 @@
#include "camel-imapx-job.h"
+#include <string.h>
+
typedef struct _CamelIMAPXRealJob CamelIMAPXRealJob;
/* CamelIMAPXJob + some private bits */
@@ -74,10 +76,9 @@ camel_imapx_job_ref (CamelIMAPXJob *job)
{
CamelIMAPXRealJob *real_job;
- real_job = (CamelIMAPXRealJob *) job;
+ g_return_val_if_fail (CAMEL_IS_IMAPX_JOB (job), NULL);
- g_return_val_if_fail (real_job != NULL, NULL);
- g_return_val_if_fail (real_job->ref_count > 0, NULL);
+ real_job = (CamelIMAPXRealJob *) job;
g_atomic_int_inc (&real_job->ref_count);
@@ -89,10 +90,9 @@ camel_imapx_job_unref (CamelIMAPXJob *job)
{
CamelIMAPXRealJob *real_job;
- real_job = (CamelIMAPXRealJob *) job;
+ g_return_if_fail (CAMEL_IS_IMAPX_JOB (job));
- g_return_if_fail (real_job != NULL);
- g_return_if_fail (real_job->ref_count > 0);
+ real_job = (CamelIMAPXRealJob *) job;
if (g_atomic_int_dec_and_test (&real_job->ref_count)) {
@@ -115,18 +115,37 @@ camel_imapx_job_unref (CamelIMAPXJob *job)
if (real_job->destroy_data != NULL)
real_job->destroy_data (real_job->data);
+ /* Fill the memory with a bit pattern before releasing
+ * it back to the slab allocator, so we can more easily
+ * identify dangling CamelIMAPXJob pointers. */
+ memset (real_job, 0xaa, sizeof (CamelIMAPXRealJob));
+
+ /* But leave the reference count set to zero, so
+ * CAMEL_IS_IMAPX_JOB can identify it as bad. */
+ real_job->ref_count = 0;
+
g_slice_free (CamelIMAPXRealJob, real_job);
}
}
+gboolean
+camel_imapx_job_check (CamelIMAPXJob *job)
+{
+ CamelIMAPXRealJob *real_job;
+
+ real_job = (CamelIMAPXRealJob *) job;
+
+ return (real_job != NULL && real_job->ref_count > 0);
+}
+
void
camel_imapx_job_wait (CamelIMAPXJob *job)
{
CamelIMAPXRealJob *real_job;
- real_job = (CamelIMAPXRealJob *) job;
+ g_return_if_fail (CAMEL_IS_IMAPX_JOB (job));
- g_return_if_fail (real_job != NULL);
+ real_job = (CamelIMAPXRealJob *) job;
g_mutex_lock (real_job->done_mutex);
while (!real_job->done_flag)
@@ -141,9 +160,9 @@ camel_imapx_job_done (CamelIMAPXJob *job)
{
CamelIMAPXRealJob *real_job;
- real_job = (CamelIMAPXRealJob *) job;
+ g_return_if_fail (CAMEL_IS_IMAPX_JOB (job));
- g_return_if_fail (real_job != NULL);
+ real_job = (CamelIMAPXRealJob *) job;
g_mutex_lock (real_job->done_mutex);
real_job->done_flag = TRUE;
@@ -158,9 +177,9 @@ camel_imapx_job_run (CamelIMAPXJob *job,
{
gulong cancel_id = 0;
- g_return_val_if_fail (job != NULL, FALSE);
- g_return_val_if_fail (job->start != NULL, FALSE);
+ g_return_val_if_fail (CAMEL_IS_IMAPX_JOB (job), FALSE);
g_return_val_if_fail (CAMEL_IS_IMAPX_SERVER (is), FALSE);
+ g_return_val_if_fail (job->start != NULL, FALSE);
if (g_cancellable_set_error_if_cancelled (job->cancellable, error))
return FALSE;
@@ -200,7 +219,7 @@ camel_imapx_job_matches (CamelIMAPXJob *job,
/* XXX CamelFolder can be NULL. I'm less sure about the
* message UID but let's assume that can be NULL too. */
- g_return_val_if_fail (job != NULL, FALSE);
+ g_return_val_if_fail (CAMEL_IS_IMAPX_JOB (job), FALSE);
if (folder != NULL)
g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE);
@@ -216,9 +235,9 @@ camel_imapx_job_get_data (CamelIMAPXJob *job)
{
CamelIMAPXRealJob *real_job;
- real_job = (CamelIMAPXRealJob *) job;
+ g_return_val_if_fail (CAMEL_IS_IMAPX_JOB (job), NULL);
- g_return_val_if_fail (real_job != NULL, NULL);
+ real_job = (CamelIMAPXRealJob *) job;
return real_job->data;
}
@@ -230,9 +249,9 @@ camel_imapx_job_set_data (CamelIMAPXJob *job,
{
CamelIMAPXRealJob *real_job;
- real_job = (CamelIMAPXRealJob *) job;
+ g_return_if_fail (CAMEL_IS_IMAPX_JOB (job));
- g_return_if_fail (real_job != NULL);
+ real_job = (CamelIMAPXRealJob *) job;
if (real_job->destroy_data != NULL)
real_job->destroy_data (real_job->data);
diff --git a/src/camel/providers/imapx/camel-imapx-job.h b/src/camel/providers/imapx/camel-imapx-job.h
index 69f7bf4..d4eaed0 100644
--- a/src/camel/providers/imapx/camel-imapx-job.h
+++ b/src/camel/providers/imapx/camel-imapx-job.h
@@ -23,6 +23,9 @@
#include "camel-imapx-server.h"
+#define CAMEL_IS_IMAPX_JOB(job) \
+ (camel_imapx_job_check (job))
+
G_BEGIN_DECLS
typedef struct _CamelIMAPXJob CamelIMAPXJob;
@@ -59,6 +62,7 @@ struct _CamelIMAPXJob {
CamelIMAPXJob * camel_imapx_job_new (GCancellable *cancellable);
CamelIMAPXJob * camel_imapx_job_ref (CamelIMAPXJob *job);
void camel_imapx_job_unref (CamelIMAPXJob *job);
+gboolean camel_imapx_job_check (CamelIMAPXJob *job);
void camel_imapx_job_wait (CamelIMAPXJob *job);
void camel_imapx_job_done (CamelIMAPXJob *job);
gboolean camel_imapx_job_run (CamelIMAPXJob *job,
diff --git a/src/camel/providers/imapx/camel-imapx-server.c b/src/camel/providers/imapx/camel-imapx-server.c
index 13a4bc1..35e4384 100644
--- a/src/camel/providers/imapx/camel-imapx-server.c
+++ b/src/camel/providers/imapx/camel-imapx-server.c
@@ -546,6 +546,14 @@ err:
camel_imapx_command_queue_remove (is->active, ic);
+ /* HACK: Since we're failing, make sure the command has a status
+ * structure and the result code indicates failure, so the
+ * ic->complete() callback does not start a new command. */
+ if (ic->status == NULL)
+ ic->status = g_malloc0 (sizeof (struct _status_info));
+ if (ic->status->result == IMAPX_OK)
+ ic->status->result = IMAPX_UNKNOWN;
+
/* Send a NULL GError since we've already set a
* GError to get here, and we're not interested
* in individual command errors. */
@@ -559,10 +567,14 @@ static gboolean
duplicate_fetch_or_refresh (CamelIMAPXServer *is,
CamelIMAPXCommand *ic)
{
- if (!ic->job)
+ CamelIMAPXJob *job;
+
+ job = camel_imapx_command_get_job (ic);
+
+ if (job == NULL)
return FALSE;
- if (!(ic->job->type & (IMAPX_JOB_FETCH_NEW_MESSAGES | IMAPX_JOB_REFRESH_INFO | IMAPX_JOB_FETCH_MESSAGES)))
+ if (!(job->type & (IMAPX_JOB_FETCH_NEW_MESSAGES | IMAPX_JOB_REFRESH_INFO | IMAPX_JOB_FETCH_MESSAGES)))
return FALSE;
if (imapx_match_active_job (is, IMAPX_JOB_FETCH_NEW_MESSAGES | IMAPX_JOB_REFRESH_INFO | IMAPX_JOB_FETCH_MESSAGES, NULL)) {
@@ -634,11 +646,17 @@ imapx_command_start_next (CamelIMAPXServer *is,
if (g_queue_is_empty (&start))
c(is->tagprefix, "* no, waiting for pending select '%s'\n", camel_folder_get_full_name (is->select_pending));
- /* Start the tagged commands. */
+ /* Start the tagged commands.
+ *
+ * Each command must be removed from 'is->queue' before
+ * starting it, so we temporarily reference the command
+ * to avoid accidentally finalizing it. */
while ((link = g_queue_pop_head (&start)) != NULL) {
- CamelIMAPXCommand *ic = link->data;
- imapx_command_start (is, ic, cancellable, error);
+ CamelIMAPXCommand *ic;
+ ic = camel_imapx_command_ref (link->data);
camel_imapx_command_queue_delete_link (is->queue, link);
+ imapx_command_start (is, ic, cancellable, error);
+ camel_imapx_command_unref (ic);
}
return;
@@ -724,11 +742,17 @@ imapx_command_start_next (CamelIMAPXServer *is,
break;
}
- /* Start the tagged commands. */
+ /* Start the tagged commands.
+ *
+ * Each command must be removed from 'is->queue' before
+ * starting it, so we temporarily reference the command
+ * to avoid accidentally finalizing it. */
while ((link = g_queue_pop_head (&start)) != NULL) {
- CamelIMAPXCommand *ic = link->data;
- imapx_command_start (is, ic, cancellable, error);
+ CamelIMAPXCommand *ic;
+ ic = camel_imapx_command_ref (link->data);
camel_imapx_command_queue_delete_link (is->queue, link);
+ imapx_command_start (is, ic, cancellable, error);
+ camel_imapx_command_unref (ic);
commands_started = TRUE;
}
@@ -775,11 +799,17 @@ imapx_command_start_next (CamelIMAPXServer *is,
break;
}
- /* Start the tagged commands. */
+ /* Start the tagged commands.
+ *
+ * Each command must be removed from 'is->queue' before
+ * starting it, so we temporarily reference the command
+ * to avoid accidentally finalizing it. */
while ((link = g_queue_pop_head (&start)) != NULL) {
- CamelIMAPXCommand *ic = link->data;
- imapx_command_start (is, ic, cancellable, error);
+ CamelIMAPXCommand *ic;
+ ic = camel_imapx_command_ref (link->data);
camel_imapx_command_queue_delete_link (is->queue, link);
+ imapx_command_start (is, ic, cancellable, error);
+ camel_imapx_command_unref (ic);
}
}
}
@@ -800,9 +830,14 @@ static void
imapx_command_queue (CamelIMAPXServer *is,
CamelIMAPXCommand *ic)
{
+ CamelIMAPXJob *job;
+
/* We enqueue in priority order, new messages have
* higher priority than older messages with the same priority */
+ job = camel_imapx_command_get_job (ic);
+ g_return_if_fail (CAMEL_IS_IMAPX_JOB (job));
+
camel_imapx_command_close (ic);
c(is->tagprefix, "enqueue job '%.*s'\n", ((CamelIMAPXCommandPart *)ic->parts.head->data)->data_size, ((CamelIMAPXCommandPart *)ic->parts.head->data)->data);
@@ -811,9 +846,9 @@ imapx_command_queue (CamelIMAPXServer *is,
if (is->state == IMAPX_SHUTDOWN) {
c(is->tagprefix, "refuse to queue job on disconnected server\n");
- if (ic->job->error == NULL)
+ if (job->error == NULL)
g_set_error (
- &ic->job->error, CAMEL_IMAPX_ERROR, 1,
+ &job->error, CAMEL_IMAPX_ERROR, 1,
"%s", _("Server disconnected"));
QUEUE_UNLOCK (is);
@@ -827,7 +862,7 @@ imapx_command_queue (CamelIMAPXServer *is,
camel_imapx_command_queue_insert_sorted (is->queue, ic);
- imapx_command_start_next (is, ic->job->cancellable, NULL);
+ imapx_command_start_next (is, job->cancellable, NULL);
QUEUE_UNLOCK (is);
@@ -872,7 +907,7 @@ imapx_match_active_job (CamelIMAPXServer *is,
guint32 type,
const gchar *uid)
{
- CamelIMAPXJob *job = NULL;
+ CamelIMAPXJob *match = NULL;
GList *head, *link;
QUEUE_LOCK (is);
@@ -881,22 +916,25 @@ imapx_match_active_job (CamelIMAPXServer *is,
for (link = head; link != NULL; link = g_list_next (link)) {
CamelIMAPXCommand *ic = link->data;
+ CamelIMAPXJob *job;
+
+ job = camel_imapx_command_get_job (ic);
- if (ic->job == NULL)
+ if (job == NULL)
continue;
- if (!(ic->job->type & type))
+ if (!(job->type & type))
continue;
- if (camel_imapx_job_matches (ic->job, is->select_folder, uid)) {
- job = ic->job;
+ if (camel_imapx_job_matches (job, is->select_folder, uid)) {
+ match = job;
break;
}
}
QUEUE_UNLOCK (is);
- return job;
+ return match;
}
static CamelIMAPXJob *
@@ -1987,8 +2025,12 @@ imapx_command_idle_done (CamelIMAPXServer *is,
GError **error)
{
CamelIMAPXIdle *idle = is->idle;
+ CamelIMAPXJob *job;
gboolean success = TRUE;
+ job = camel_imapx_command_get_job (ic);
+ g_return_val_if_fail (CAMEL_IS_IMAPX_JOB (job), FALSE);
+
if (camel_imapx_command_set_error_if_failed (ic, error)) {
g_prefix_error (
error, "%s: ",
@@ -2000,7 +2042,7 @@ imapx_command_idle_done (CamelIMAPXServer *is,
idle->state = IMAPX_IDLE_OFF;
IDLE_UNLOCK (idle);
- imapx_unregister_job (is, ic->job);
+ imapx_unregister_job (is, job);
camel_imapx_command_unref (ic);
return success;
@@ -2015,7 +2057,7 @@ imapx_job_idle_start (CamelIMAPXJob *job,
ic = camel_imapx_command_new (
is, "IDLE", job->folder, "IDLE");
- ic->job = job;
+ camel_imapx_command_set_job (ic, job);
ic->pri = job->pri;
ic->complete = imapx_command_idle_done;
@@ -2030,7 +2072,7 @@ imapx_job_idle_start (CamelIMAPXJob *job,
is->idle->state = IMAPX_IDLE_ISSUED;
imapx_command_start (is, ic, job->cancellable, &job->error);
} else {
- imapx_unregister_job (is, ic->job);
+ imapx_unregister_job (is, job);
camel_imapx_command_unref (ic);
}
IDLE_UNLOCK (is->idle);
@@ -2338,17 +2380,24 @@ imapx_command_select_done (CamelIMAPXServer *is,
while (!g_queue_is_empty (&failed)) {
CamelIMAPXCommand *cw;
+ CamelIMAPXJob *job;
cw = g_queue_pop_head (&failed);
+ job = camel_imapx_command_get_job (cw);
+
+ if (!CAMEL_IS_IMAPX_JOB (job)) {
+ g_warn_if_reached ();
+ continue;
+ }
if (ic->status)
cw->status = imapx_copy_status (ic->status);
- if (cw->job->error == NULL) {
+ if (job->error == NULL) {
if (ic->status == NULL)
/* FIXME: why is ic->status == NULL here? It shouldn't happen. */
g_debug ("imapx_command_select_done: ic->status is NULL.");
g_set_error (
- &cw->job->error,
+ &job->error,
CAMEL_IMAPX_ERROR, 1,
"SELECT %s failed: %s",
camel_folder_get_full_name (cw->select),
@@ -3130,11 +3179,14 @@ imapx_command_fetch_message_done (CamelIMAPXServer *is,
CamelIMAPXCommand *ic,
GError **error)
{
- CamelIMAPXJob *job = ic->job;
+ CamelIMAPXJob *job;
GetMessageData *data;
gboolean success = TRUE;
GError *local_error = NULL;
+ job = camel_imapx_command_get_job (ic);
+ g_return_val_if_fail (CAMEL_IS_IMAPX_JOB (job), FALSE);
+
data = camel_imapx_job_get_data (job);
g_return_val_if_fail (data != NULL, FALSE);
@@ -3158,23 +3210,27 @@ imapx_command_fetch_message_done (CamelIMAPXServer *is,
* time) until the data actually stop coming. */
if (data->fetch_offset < data->size ||
data->fetch_offset == really_fetched) {
- camel_imapx_command_unref (ic);
+ CamelIMAPXCommand *new_ic;
+
camel_operation_progress (
job->cancellable,
(data->fetch_offset *100) / data->size);
- ic = camel_imapx_command_new (
+ new_ic = camel_imapx_command_new (
is, "FETCH", job->folder,
"UID FETCH %t (BODY.PEEK[]",
data->uid);
- camel_imapx_command_add (ic, "<%u.%u>", data->fetch_offset, MULTI_SIZE);
- camel_imapx_command_add (ic, ")");
- ic->complete = imapx_command_fetch_message_done;
- ic->job = job;
- ic->pri = job->pri - 1;
+ camel_imapx_command_add (new_ic, "<%u.%u>", data->fetch_offset, MULTI_SIZE);
+ camel_imapx_command_add (new_ic, ")");
+ new_ic->complete = imapx_command_fetch_message_done;
+ camel_imapx_command_set_job (new_ic, job);
+ new_ic->pri = job->pri - 1;
data->fetch_offset += MULTI_SIZE;
job->commands++;
- imapx_command_queue (is, ic);
+ imapx_command_queue (is, new_ic);
+
+ camel_imapx_command_unref (ic);
+
return TRUE;
}
}
@@ -3254,7 +3310,7 @@ imapx_job_get_message_start (CamelIMAPXJob *job,
camel_imapx_command_add (ic, "<%u.%u>", data->fetch_offset, MULTI_SIZE);
camel_imapx_command_add (ic, ")");
ic->complete = imapx_command_fetch_message_done;
- ic->job = job;
+ camel_imapx_command_set_job (ic, job);
ic->pri = job->pri;
data->fetch_offset += MULTI_SIZE;
job->commands++;
@@ -3266,7 +3322,7 @@ imapx_job_get_message_start (CamelIMAPXJob *job,
"UID FETCH %t (BODY.PEEK[])",
data->uid);
ic->complete = imapx_command_fetch_message_done;
- ic->job = job;
+ camel_imapx_command_set_job (ic, job);
ic->pri = job->pri;
job->commands++;
imapx_command_queue (is, ic);
@@ -3299,12 +3355,15 @@ imapx_command_copy_messages_step_done (CamelIMAPXServer *is,
CamelIMAPXCommand *ic,
GError **error)
{
- CamelIMAPXJob *job = ic->job;
+ CamelIMAPXJob *job;
CopyMessagesData *data;
GPtrArray *uids;
gint i;
gboolean success = TRUE;
+ job = camel_imapx_command_get_job (ic);
+ g_return_val_if_fail (CAMEL_IS_IMAPX_JOB (job), FALSE);
+
data = camel_imapx_job_get_data (job);
g_return_val_if_fail (data != NULL, FALSE);
@@ -3313,7 +3372,7 @@ imapx_command_copy_messages_step_done (CamelIMAPXServer *is,
if (camel_imapx_command_set_error_if_failed (ic, error)) {
g_prefix_error (
- &ic->job->error, "%s: ",
+ &job->error, "%s: ",
_("Error copying messages"));
success = FALSE;
goto cleanup;
@@ -3373,7 +3432,7 @@ imapx_command_copy_messages_step_start (CamelIMAPXServer *is,
ic = camel_imapx_command_new (
is, "COPY", job->folder, "UID COPY ");
ic->complete = imapx_command_copy_messages_step_done;
- ic->job = job;
+ camel_imapx_command_set_job (ic, job);
ic->pri = job->pri;
data->last_index = i;
@@ -3423,16 +3482,21 @@ imapx_command_append_message_done (CamelIMAPXServer *is,
CamelIMAPXCommand *ic,
GError **error)
{
- CamelIMAPXJob *job = ic->job;
- CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) job->folder;
+ CamelIMAPXJob *job;
+ CamelIMAPXFolder *ifolder;
CamelMessageInfo *mi;
AppendMessageData *data;
gchar *cur, *old_uid;
gboolean success = TRUE;
+ job = camel_imapx_command_get_job (ic);
+ g_return_val_if_fail (CAMEL_IS_IMAPX_JOB (job), FALSE);
+
data = camel_imapx_job_get_data (job);
g_return_val_if_fail (data != NULL, FALSE);
+ ifolder = (CamelIMAPXFolder *) job->folder;
+
/* Append done. If we the server supports UIDPLUS we will get an APPENDUID response
* with the new uid. This lets us move the message we have directly to the cache
* and also create a correctly numbered MessageInfo, without losing any information.
@@ -3504,7 +3568,7 @@ imapx_job_append_message_start (CamelIMAPXJob *job,
((CamelMessageInfoBase *) data->info)->user_flags,
data->path);
ic->complete = imapx_command_append_message_done;
- ic->job = job;
+ camel_imapx_command_set_job (ic, job);
ic->pri = job->pri;
job->commands++;
imapx_command_queue (is, ic);
@@ -3596,9 +3660,9 @@ imapx_command_step_fetch_done (CamelIMAPXServer *is,
CamelIMAPXCommand *ic,
GError **error)
{
- CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) ic->job->folder;
- CamelIMAPXSummary *isum = (CamelIMAPXSummary *) ic->job->folder->summary;
- CamelIMAPXJob *job = ic->job;
+ CamelIMAPXFolder *ifolder;
+ CamelIMAPXSummary *isum;
+ CamelIMAPXJob *job;
RefreshInfoData *data;
gint i;
gboolean success = TRUE;
@@ -3607,9 +3671,15 @@ imapx_command_step_fetch_done (CamelIMAPXServer *is,
guint batch_count;
gboolean mobile_mode;
+ job = camel_imapx_command_get_job (ic);
+ g_return_val_if_fail (CAMEL_IS_IMAPX_JOB (job), FALSE);
+
data = camel_imapx_job_get_data (job);
g_return_val_if_fail (data != NULL, FALSE);
+ ifolder = (CamelIMAPXFolder *) job->folder;
+ isum = (CamelIMAPXSummary *) job->folder->summary;
+
service = CAMEL_SERVICE (is->store);
settings = camel_service_get_settings (service);
@@ -3646,7 +3716,7 @@ imapx_command_step_fetch_done (CamelIMAPXServer *is,
ic = camel_imapx_command_new (
is, "FETCH", job->folder, "UID FETCH ");
ic->complete = imapx_command_step_fetch_done;
- ic->job = job;
+ camel_imapx_command_set_job (ic, job);
ic->pri = job->pri - 1;
//printf("Total: %d: %d, %d, %d\n", total, fetch_limit, i, data->last_index);
@@ -3742,7 +3812,7 @@ imapx_job_scan_changes_done (CamelIMAPXServer *is,
CamelIMAPXCommand *ic,
GError **error)
{
- CamelIMAPXJob *job = ic->job;
+ CamelIMAPXJob *job;
CamelService *service;
CamelSettings *settings;
RefreshInfoData *data;
@@ -3751,6 +3821,9 @@ imapx_job_scan_changes_done (CamelIMAPXServer *is,
gboolean success = TRUE;
gboolean mobile_mode;
+ job = camel_imapx_command_get_job (ic);
+ g_return_val_if_fail (CAMEL_IS_IMAPX_JOB (job), FALSE);
+
data = camel_imapx_job_get_data (job);
g_return_val_if_fail (data != NULL, FALSE);
@@ -3942,8 +4015,7 @@ imapx_job_scan_changes_start (CamelIMAPXJob *job,
ic = camel_imapx_command_new (
is, "FETCH", job->folder,
"UID FETCH %s:* (UID FLAGS)", uid ? uid : "1");
-
- ic->job = job;
+ camel_imapx_command_set_job (ic, job);
ic->complete = imapx_job_scan_changes_done;
ic->pri = job->pri;
data->infos = g_array_new (0, 0, sizeof (struct _refresh_info));
@@ -3956,15 +4028,21 @@ imapx_command_fetch_new_messages_done (CamelIMAPXServer *is,
CamelIMAPXCommand *ic,
GError **error)
{
- CamelIMAPXJob *job = ic->job;
- CamelIMAPXSummary *isum = (CamelIMAPXSummary *) job->folder->summary;
- CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) job->folder;
+ CamelIMAPXJob *job;
+ CamelIMAPXSummary *isum;
+ CamelIMAPXFolder *ifolder;
RefreshInfoData *data;
gboolean success = TRUE;
+ job = camel_imapx_command_get_job (ic);
+ g_return_val_if_fail (CAMEL_IS_IMAPX_JOB (job), FALSE);
+
data = camel_imapx_job_get_data (job);
g_return_val_if_fail (data != NULL, FALSE);
+ ifolder = (CamelIMAPXFolder *) job->folder;
+ isum = (CamelIMAPXSummary *) job->folder->summary;
+
if (camel_imapx_command_set_error_if_failed (ic, error)) {
g_prefix_error (
error, "%s: ",
@@ -4009,9 +4087,12 @@ imapx_command_fetch_new_uids_done (CamelIMAPXServer *is,
CamelIMAPXCommand *ic,
GError **error)
{
- CamelIMAPXJob *job = ic->job;
+ CamelIMAPXJob *job;
RefreshInfoData *data;
+ job = camel_imapx_command_get_job (ic);
+ g_return_val_if_fail (CAMEL_IS_IMAPX_JOB (job), FALSE);
+
data = camel_imapx_job_get_data (job);
g_return_val_if_fail (data != NULL, FALSE);
@@ -4092,7 +4173,7 @@ imapx_job_fetch_new_messages_start (CamelIMAPXJob *job,
}
g_free (uid);
- ic->job = job;
+ camel_imapx_command_set_job (ic, job);
imapx_command_queue (is, ic);
}
@@ -4149,15 +4230,17 @@ imapx_job_fetch_messages_start (CamelIMAPXJob *job,
ic = camel_imapx_command_new (
is, "STATUS", NULL,
"STATUS %f (MESSAGES UNSEEN UIDVALIDITY UIDNEXT)", folder);
-
- ic->job = job;
+ camel_imapx_command_set_job (ic, job);
ic->pri = job->pri;
imapx_command_run_sync (is, ic, job->cancellable, &job->error);
- if (ic->job->error != NULL || camel_imapx_command_set_error_if_failed (ic, &ic->job->error)) {
+ job = camel_imapx_command_get_job (ic);
+ g_return_if_fail (CAMEL_IS_IMAPX_JOB (job));
+
+ if (job->error != NULL || camel_imapx_command_set_error_if_failed (ic, &job->error)) {
g_prefix_error (
- &ic->job->error, "%s: ",
+ &job->error, "%s: ",
_("Error while fetching messages"));
}
@@ -4184,10 +4267,10 @@ imapx_job_fetch_messages_start (CamelIMAPXJob *job,
ic->complete = imapx_command_step_fetch_done;
g_free (uid);
- ic->job = job;
+
+ camel_imapx_command_set_job (ic, job);
imapx_command_queue (is, ic);
- return;
} else if (ftype == CAMEL_FETCH_OLD_MESSAGES && total > 0) {
guint64 uidl;
start_uid = imapx_get_uid_from_index (folder->summary, 0);
@@ -4208,7 +4291,7 @@ imapx_job_fetch_messages_start (CamelIMAPXJob *job,
g_free (start_uid);
g_free (end_uid);
- ic->job = job;
+ camel_imapx_command_set_job (ic, job);
imapx_command_queue (is, ic);
} else {
@@ -4309,19 +4392,22 @@ imapx_job_refresh_info_start (CamelIMAPXJob *job,
is, "STATUS", NULL,
"STATUS %f (MESSAGES UNSEEN UIDVALIDITY UIDNEXT)", folder);
- ic->job = job;
+ camel_imapx_command_set_job (ic, job);
ic->pri = job->pri;
imapx_command_run_sync (
is, ic, job->cancellable, &job->error);
- if (ic->job->error != NULL || camel_imapx_command_set_error_if_failed (ic, &ic->job->error)) {
+ job = camel_imapx_command_get_job (ic);
+ g_return_if_fail (CAMEL_IS_IMAPX_JOB (job));
+
+ if (job->error != NULL || camel_imapx_command_set_error_if_failed (ic, &job->error)) {
g_prefix_error (
- &ic->job->error, "%s: ",
+ &job->error, "%s: ",
_("Error refreshing folder"));
}
- if (ic->job->error != NULL) {
+ if (job->error != NULL) {
camel_imapx_command_unref (ic);
goto done;
}
@@ -4343,19 +4429,21 @@ imapx_job_refresh_info_start (CamelIMAPXJob *job,
ic = camel_imapx_command_new (
is, "STATUS", NULL,
"STATUS %f (MESSAGES UNSEEN UIDVALIDITY UIDNEXT)", folder);
-
- ic->job = job;
+ camel_imapx_command_set_job (ic, job);
ic->pri = job->pri;
imapx_command_run_sync (is, ic, job->cancellable, &job->error);
- if (ic->job->error != NULL || camel_imapx_command_set_error_if_failed (ic, &ic->job->error)) {
+ job = camel_imapx_command_get_job (ic);
+ g_return_if_fail (CAMEL_IS_IMAPX_JOB (job));
+
+ if (job->error != NULL || camel_imapx_command_set_error_if_failed (ic, &job->error)) {
g_prefix_error (
- &ic->job->error, "%s: ",
+ &job->error, "%s: ",
_("Error refreshing folder"));
}
- if (ic->job->error != NULL) {
+ if (job->error != NULL) {
camel_imapx_command_unref (ic);
goto done;
}
@@ -4436,8 +4524,12 @@ imapx_command_expunge_done (CamelIMAPXServer *is,
CamelIMAPXCommand *ic,
GError **error)
{
+ CamelIMAPXJob *job;
gboolean success = TRUE;
+ job = camel_imapx_command_get_job (ic);
+ g_return_val_if_fail (CAMEL_IS_IMAPX_JOB (job), FALSE);
+
if (camel_imapx_command_set_error_if_failed (ic, error)) {
g_prefix_error (
error, "%s: ",
@@ -4446,7 +4538,7 @@ imapx_command_expunge_done (CamelIMAPXServer *is,
} else {
GPtrArray *uids;
- CamelFolder *folder = ic->job->folder;
+ CamelFolder *folder = job->folder;
CamelStore *parent_store;
const gchar *full_name;
@@ -4454,7 +4546,7 @@ imapx_command_expunge_done (CamelIMAPXServer *is,
parent_store = camel_folder_get_parent_store (folder);
camel_folder_summary_save_to_db (folder->summary, NULL);
- uids = camel_db_get_folder_deleted_uids (parent_store->cdb_r, full_name, &ic->job->error);
+ uids = camel_db_get_folder_deleted_uids (parent_store->cdb_r, full_name, &job->error);
if (uids && uids->len) {
CamelFolderChangeInfo *changes;
@@ -4480,7 +4572,7 @@ imapx_command_expunge_done (CamelIMAPXServer *is,
}
}
- imapx_unregister_job (is, ic->job);
+ imapx_unregister_job (is, job);
camel_imapx_command_unref (ic);
return success;
@@ -4499,9 +4591,10 @@ imapx_job_expunge_start (CamelIMAPXJob *job,
/* TODO handle UIDPLUS capability */
ic = camel_imapx_command_new (
is, "EXPUNGE", job->folder, "EXPUNGE");
- ic->job = job;
+ camel_imapx_command_set_job (ic, job);
ic->pri = job->pri;
ic->complete = imapx_command_expunge_done;
+
imapx_command_queue (is, ic);
}
@@ -4520,8 +4613,12 @@ imapx_command_list_done (CamelIMAPXServer *is,
CamelIMAPXCommand *ic,
GError **error)
{
+ CamelIMAPXJob *job;
gboolean success = TRUE;
+ job = camel_imapx_command_get_job (ic);
+ g_return_val_if_fail (CAMEL_IS_IMAPX_JOB (job), FALSE);
+
if (camel_imapx_command_set_error_if_failed (ic, error)) {
g_prefix_error (
error, "%s: ",
@@ -4530,7 +4627,7 @@ imapx_command_list_done (CamelIMAPXServer *is,
}
e (is->tagprefix, "==== list or lsub completed ==== \n");
- imapx_unregister_job (is, ic->job);
+ imapx_unregister_job (is, job);
camel_imapx_command_unref (ic);
return success;
@@ -4558,8 +4655,9 @@ imapx_job_list_start (CamelIMAPXJob *job,
camel_imapx_command_add (ic, data->ext);
}
ic->pri = job->pri;
- ic->job = job;
+ camel_imapx_command_set_job (ic, job);
ic->complete = imapx_command_list_done;
+
imapx_command_queue (is, ic);
}
@@ -4594,8 +4692,12 @@ imapx_command_subscription_done (CamelIMAPXServer *is,
CamelIMAPXCommand *ic,
GError **error)
{
+ CamelIMAPXJob *job;
gboolean success = TRUE;
+ job = camel_imapx_command_get_job (ic);
+ g_return_val_if_fail (CAMEL_IS_IMAPX_JOB (job), FALSE);
+
if (camel_imapx_command_set_error_if_failed (ic, error)) {
g_prefix_error (
error, "%s: ",
@@ -4603,7 +4705,7 @@ imapx_command_subscription_done (CamelIMAPXServer *is,
success = FALSE;
}
- imapx_unregister_job (is, ic->job);
+ imapx_unregister_job (is, job);
camel_imapx_command_unref (ic);
return success;
@@ -4633,7 +4735,7 @@ imapx_job_manage_subscription_start (CamelIMAPXJob *job,
"UNSUBSCRIBE %s", encoded_fname);
ic->pri = job->pri;
- ic->job = job;
+ camel_imapx_command_set_job (ic, job);
ic->complete = imapx_command_subscription_done;
imapx_command_queue (is, ic);
@@ -4647,8 +4749,12 @@ imapx_command_create_folder_done (CamelIMAPXServer *is,
CamelIMAPXCommand *ic,
GError **error)
{
+ CamelIMAPXJob *job;
gboolean success = TRUE;
+ job = camel_imapx_command_get_job (ic);
+ g_return_val_if_fail (CAMEL_IS_IMAPX_JOB (job), FALSE);
+
if (camel_imapx_command_set_error_if_failed (ic, error)) {
g_prefix_error (
error, "%s: ",
@@ -4656,7 +4762,7 @@ imapx_command_create_folder_done (CamelIMAPXServer *is,
success = FALSE;
}
- imapx_unregister_job (is, ic->job);
+ imapx_unregister_job (is, job);
camel_imapx_command_unref (ic);
return success;
@@ -4678,7 +4784,7 @@ imapx_job_create_folder_start (CamelIMAPXJob *job,
is, "CREATE", NULL,
"CREATE %s", encoded_fname);
ic->pri = job->pri;
- ic->job = job;
+ camel_imapx_command_set_job (ic, job);
ic->complete = imapx_command_create_folder_done;
imapx_command_queue (is, ic);
@@ -4692,8 +4798,12 @@ imapx_command_delete_folder_done (CamelIMAPXServer *is,
CamelIMAPXCommand *ic,
GError **error)
{
+ CamelIMAPXJob *job;
gboolean success;
+ job = camel_imapx_command_get_job (ic);
+ g_return_val_if_fail (CAMEL_IS_IMAPX_JOB (job), FALSE);
+
if (camel_imapx_command_set_error_if_failed (ic, error)) {
g_prefix_error (
error, "%s: ",
@@ -4701,7 +4811,7 @@ imapx_command_delete_folder_done (CamelIMAPXServer *is,
success = FALSE;
}
- imapx_unregister_job (is, ic->job);
+ imapx_unregister_job (is, job);
camel_imapx_command_unref (ic);
return success;
@@ -4728,7 +4838,7 @@ imapx_job_delete_folder_start (CamelIMAPXJob *job,
is, "DELETE", job->folder,
"DELETE %s", encoded_fname);
ic->pri = job->pri;
- ic->job = job;
+ camel_imapx_command_set_job (ic, job);
ic->complete = imapx_command_delete_folder_done;
imapx_command_queue (is, ic);
@@ -4742,8 +4852,12 @@ imapx_command_rename_folder_done (CamelIMAPXServer *is,
CamelIMAPXCommand *ic,
GError **error)
{
+ CamelIMAPXJob *job;
gboolean success = TRUE;
+ job = camel_imapx_command_get_job (ic);
+ g_return_val_if_fail (CAMEL_IS_IMAPX_JOB (job), FALSE);
+
if (camel_imapx_command_set_error_if_failed (ic, error)) {
g_prefix_error (
error, "%s: ",
@@ -4751,7 +4865,7 @@ imapx_command_rename_folder_done (CamelIMAPXServer *is,
success = FALSE;
}
- imapx_unregister_job (is, ic->job);
+ imapx_unregister_job (is, job);
camel_imapx_command_unref (ic);
return success;
@@ -4778,7 +4892,7 @@ imapx_job_rename_folder_start (CamelIMAPXJob *job,
is, "RENAME", job->folder,
"RENAME %s %s", en_ofname, en_nfname);
ic->pri = job->pri;
- ic->job = job;
+ camel_imapx_command_set_job (ic, job);
ic->complete = imapx_command_rename_folder_done;
imapx_command_queue (is, ic);
@@ -4793,8 +4907,12 @@ imapx_command_noop_done (CamelIMAPXServer *is,
CamelIMAPXCommand *ic,
GError **error)
{
+ CamelIMAPXJob *job;
gboolean success = TRUE;
+ job = camel_imapx_command_get_job (ic);
+ g_return_val_if_fail (CAMEL_IS_IMAPX_JOB (job), FALSE);
+
if (camel_imapx_command_set_error_if_failed (ic, error)) {
g_prefix_error (
error, "%s: ",
@@ -4802,7 +4920,7 @@ imapx_command_noop_done (CamelIMAPXServer *is,
success = FALSE;
}
- imapx_unregister_job (is, ic->job);
+ imapx_unregister_job (is, job);
camel_imapx_command_unref (ic);
return success;
@@ -4817,7 +4935,7 @@ imapx_job_noop_start (CamelIMAPXJob *job,
ic = camel_imapx_command_new (
is, "NOOP", job->folder, "NOOP");
- ic->job = job;
+ camel_imapx_command_set_job (ic, job);
ic->complete = imapx_command_noop_done;
if (job->folder)
ic->pri = IMAPX_PRIORITY_REFRESH_INFO;
@@ -4858,7 +4976,7 @@ imapx_command_sync_changes_done (CamelIMAPXServer *is,
CamelIMAPXCommand *ic,
GError **error)
{
- CamelIMAPXJob *job = ic->job;
+ CamelIMAPXJob *job;
CamelStore *parent_store;
SyncChangesData *data;
const gchar *full_name;
@@ -4867,6 +4985,9 @@ imapx_command_sync_changes_done (CamelIMAPXServer *is,
gboolean mobile_mode;
gboolean success = TRUE;
+ job = camel_imapx_command_get_job (ic);
+ g_return_val_if_fail (CAMEL_IS_IMAPX_JOB (job), FALSE);
+
data = camel_imapx_job_get_data (job);
g_return_val_if_fail (data != NULL, FALSE);
@@ -4999,7 +5120,7 @@ imapx_job_sync_changes_start (CamelIMAPXJob *job,
is, "STORE", job->folder,
"UID STORE ");
ic->complete = imapx_command_sync_changes_done;
- ic->job = job;
+ camel_imapx_command_set_job (ic, job);
ic->pri = job->pri;
}
send = imapx_uidset_add (&ss, ic, camel_message_info_uid (info));
@@ -5037,7 +5158,7 @@ imapx_job_sync_changes_start (CamelIMAPXJob *job,
is, "STORE", job->folder,
"UID STORE ");
ic->complete = imapx_command_sync_changes_done;
- ic->job = job;
+ camel_imapx_command_set_job (ic, job);
ic->pri = job->pri;
}
@@ -5093,15 +5214,21 @@ cancel_all_jobs (CamelIMAPXServer *is,
for (link = head; link != NULL; link = g_list_next (link)) {
CamelIMAPXCommand *ic = link->data;
+ CamelIMAPXJob *job;
/* Sanity check the CamelIMAPXCommand before proceeding.
* XXX We are actually getting reports of crashes here...
* not sure how this is happening but it's happening. */
- if (ic == NULL || ic->job == NULL)
+ if (ic == NULL)
+ continue;
+
+ /* Similarly with the CamelIMAPXJob contained within. */
+ job = camel_imapx_command_get_job (ic);
+ if (!CAMEL_IS_IMAPX_JOB (job))
continue;
- if (ic->job->error == NULL)
- ic->job->error = g_error_copy (error);
+ if (job->error == NULL)
+ job->error = g_error_copy (error);
/* Send a NULL GError since we've already set
* the job's GError, and we're not interested
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]