[evolution-data-server] CamelIMAPXJob: Add camel_imapx_job_run().
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] CamelIMAPXJob: Add camel_imapx_job_run().
- Date: Tue, 31 Jan 2012 22:09:29 +0000 (UTC)
commit 0f7fd0446093a364e198f12e7bf8e36af5f28b76
Author: Matthew Barnes <mbarnes redhat com>
Date: Mon Jan 30 14:26:34 2012 -0500
CamelIMAPXJob: Add camel_imapx_job_run().
camel/providers/imapx/camel-imapx-job.c | 53 ++++++++++++++++++++++++
camel/providers/imapx/camel-imapx-job.h | 3 +
camel/providers/imapx/camel-imapx-server.c | 60 ++-------------------------
3 files changed, 61 insertions(+), 55 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-job.c b/camel/providers/imapx/camel-imapx-job.c
index 19ba0fd..d6df79c 100644
--- a/camel/providers/imapx/camel-imapx-job.c
+++ b/camel/providers/imapx/camel-imapx-job.c
@@ -36,6 +36,18 @@ struct _CamelIMAPXRealJob {
GDestroyNotify destroy_data;
};
+static void
+imapx_job_cancelled_cb (GCancellable *cancellable,
+ CamelIMAPXJob *job)
+{
+ /* Unblock camel_imapx_run_job() immediately.
+ *
+ * If camel_imapx_job_done() is called sometime later,
+ * the GCond will broadcast but no one will be listening. */
+
+ camel_imapx_job_done (job);
+}
+
CamelIMAPXJob *
camel_imapx_job_new (GCancellable *cancellable)
{
@@ -139,6 +151,47 @@ camel_imapx_job_done (CamelIMAPXJob *job)
g_mutex_unlock (real_job->done_mutex);
}
+gboolean
+camel_imapx_job_run (CamelIMAPXJob *job,
+ CamelIMAPXServer *is,
+ GError **error)
+{
+ 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_SERVER (is), FALSE);
+
+ if (g_cancellable_set_error_if_cancelled (job->cancellable, error))
+ return FALSE;
+
+ if (G_IS_CANCELLABLE (job->cancellable))
+ cancel_id = g_cancellable_connect (
+ job->cancellable,
+ G_CALLBACK (imapx_job_cancelled_cb),
+ camel_imapx_job_ref (job),
+ (GDestroyNotify) camel_imapx_job_unref);
+
+ job->start (job, is);
+
+ if (!job->noreply)
+ camel_imapx_job_wait (job);
+
+ if (cancel_id > 0)
+ g_cancellable_disconnect (job->cancellable, cancel_id);
+
+ if (g_cancellable_set_error_if_cancelled (job->cancellable, error))
+ return FALSE;
+
+ if (job->error != NULL) {
+ g_propagate_error (error, job->error);
+ job->error = NULL;
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
gpointer
camel_imapx_job_get_data (CamelIMAPXJob *job)
{
diff --git a/camel/providers/imapx/camel-imapx-job.h b/camel/providers/imapx/camel-imapx-job.h
index 9e2a021..36ac855 100644
--- a/camel/providers/imapx/camel-imapx-job.h
+++ b/camel/providers/imapx/camel-imapx-job.h
@@ -122,6 +122,9 @@ CamelIMAPXJob * camel_imapx_job_ref (CamelIMAPXJob *job);
void camel_imapx_job_unref (CamelIMAPXJob *job);
void camel_imapx_job_wait (CamelIMAPXJob *job);
void camel_imapx_job_done (CamelIMAPXJob *job);
+gboolean camel_imapx_job_run (CamelIMAPXJob *job,
+ CamelIMAPXServer *is,
+ GError **error);
gpointer camel_imapx_job_get_data (CamelIMAPXJob *job);
void camel_imapx_job_set_data (CamelIMAPXJob *job,
gpointer data,
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 01bda7f..3742202 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -150,7 +150,6 @@ struct _imapx_flag_change {
static CamelIMAPXJob *imapx_match_active_job (CamelIMAPXServer *is, guint32 type, const gchar *uid);
static void imapx_job_done (CamelIMAPXServer *is, CamelIMAPXJob *job);
-static gboolean imapx_run_job (CamelIMAPXServer *is, CamelIMAPXJob *job, GError **error);
static void imapx_job_fetch_new_messages_start (CamelIMAPXJob *job, CamelIMAPXServer *is);
static gint imapx_refresh_info_uid_cmp (gconstpointer ap, gconstpointer bp, gboolean ascending);
static gint imapx_uids_array_cmp (gconstpointer ap, gconstpointer bp);
@@ -1754,18 +1753,6 @@ imapx_job_done (CamelIMAPXServer *is,
QUEUE_UNLOCK (is);
}
-static void
-imapx_job_cancelled (GCancellable *cancellable,
- CamelIMAPXJob *job)
-{
- /* Unblock imapx_run_job() immediately.
- *
- * If camel_imapx_job_done() is called sometime later,
- * the GCond will broadcast but no one will be listening. */
-
- camel_imapx_job_done (job);
-}
-
static gboolean
imapx_register_job (CamelIMAPXServer *is,
CamelIMAPXJob *job,
@@ -1789,43 +1776,6 @@ imapx_register_job (CamelIMAPXServer *is,
}
static gboolean
-imapx_run_job (CamelIMAPXServer *is,
- CamelIMAPXJob *job,
- GError **error)
-{
- gulong cancel_id = 0;
-
- if (g_cancellable_set_error_if_cancelled (is->cancellable, error))
- return FALSE;
-
- if (G_IS_CANCELLABLE (job->cancellable))
- cancel_id = g_cancellable_connect (
- job->cancellable,
- G_CALLBACK (imapx_job_cancelled),
- camel_imapx_job_ref (job),
- (GDestroyNotify) camel_imapx_job_unref);
-
- job->start (job, is);
-
- if (!job->noreply)
- camel_imapx_job_wait (job);
-
- if (cancel_id > 0)
- g_cancellable_disconnect (job->cancellable, cancel_id);
-
- if (g_cancellable_set_error_if_cancelled (job->cancellable, error))
- return FALSE;
-
- if (job->error != NULL) {
- g_propagate_error (error, job->error);
- job->error = NULL;
- return FALSE;
- }
-
- return TRUE;
-}
-
-static gboolean
imapx_submit_job (CamelIMAPXServer *is,
CamelIMAPXJob *job,
GError **error)
@@ -1833,7 +1783,7 @@ imapx_submit_job (CamelIMAPXServer *is,
if (!imapx_register_job (is, job, error))
return FALSE;
- return imapx_run_job (is, job, error);
+ return camel_imapx_job_run (job, is, error);
}
/* ********************************************************************** */
@@ -5043,7 +4993,7 @@ imapx_server_get_message (CamelIMAPXServer *is,
QUEUE_UNLOCK (is);
- success = registered && imapx_run_job (is, job, error);
+ success = registered && camel_imapx_job_run (job, is, error);
if (success)
stream = job->u.get_message.stream;
@@ -5269,7 +5219,7 @@ camel_imapx_server_refresh_info (CamelIMAPXServer *is,
QUEUE_UNLOCK (is);
- success = registered && imapx_run_job (is, job, error);
+ success = registered && camel_imapx_job_run (job, is, error);
if (success && camel_folder_change_info_changed (job->u.refresh_info.changes))
camel_folder_changed (folder, job->u.refresh_info.changes);
@@ -5450,7 +5400,7 @@ imapx_server_sync_changes (CamelIMAPXServer *is,
QUEUE_UNLOCK (is);
- success = registered && imapx_run_job (is, job, error);
+ success = registered && camel_imapx_job_run (job, is, error);
camel_imapx_job_unref (job);
@@ -5503,7 +5453,7 @@ camel_imapx_server_expunge (CamelIMAPXServer *is,
QUEUE_UNLOCK (is);
- success = registered && imapx_run_job (is, job, error);
+ success = registered && camel_imapx_job_run (job, is, error);
camel_imapx_job_unref (job);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]