[evolution] Mail: Use lower priority pool for contact photo requests
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Mail: Use lower priority pool for contact photo requests
- Date: Tue, 11 Oct 2022 15:14:24 +0000 (UTC)
commit 4a2c2bafaaf6d6eab9814b9529a5005d87b16dbe
Author: Milan Crha <mcrha redhat com>
Date: Tue Oct 11 17:12:47 2022 +0200
Mail: Use lower priority pool for contact photo requests
This way a stale requests won't block other important requests, keeping
the GUI responsive in some cases.
src/e-util/e-client-cache.c | 37 +++----
src/e-util/e-content-request.c | 6 +-
src/e-util/e-photo-cache.c | 44 ++++----
src/e-util/e-simple-async-result.c | 111 +++++++++++++++++++--
src/e-util/e-simple-async-result.h | 3 +
.../contact-photos/e-contact-photo-source.c | 47 +++++----
src/modules/gravatar/e-gravatar-photo-source.c | 37 +++----
7 files changed, 198 insertions(+), 87 deletions(-)
---
diff --git a/src/e-util/e-client-cache.c b/src/e-util/e-client-cache.c
index bbbb6ed8a7..d0a26a924b 100644
--- a/src/e-util/e-client-cache.c
+++ b/src/e-util/e-client-cache.c
@@ -38,6 +38,7 @@
#include <libebook/libebook.h>
#include <libebackend/libebackend.h>
+#include "e-simple-async-result.h"
#include "e-client-cache.h"
#define E_CLIENT_CACHE_GET_PRIVATE(obj) \
@@ -603,16 +604,16 @@ client_cache_process_results (ClientData *client_data,
g_mutex_unlock (&client_data->lock);
while (!g_queue_is_empty (&queue)) {
- GSimpleAsyncResult *simple;
+ ESimpleAsyncResult *simple;
simple = g_queue_pop_head (&queue);
if (client != NULL)
- g_simple_async_result_set_op_res_gpointer (
+ e_simple_async_result_set_op_pointer (
simple, g_object_ref (client),
(GDestroyNotify) g_object_unref);
if (error != NULL)
- g_simple_async_result_set_from_error (simple, error);
- g_simple_async_result_complete_in_idle (simple);
+ e_simple_async_result_take_error (simple, g_error_copy (error));
+ e_simple_async_result_complete_idle (simple);
g_object_unref (simple);
}
}
@@ -1253,7 +1254,7 @@ e_client_cache_get_client (EClientCache *client_cache,
GAsyncReadyCallback callback,
gpointer user_data)
{
- GSimpleAsyncResult *simple;
+ ESimpleAsyncResult *simple;
ClientData *client_data;
EClient *client = NULL;
gboolean connect_in_progress = FALSE;
@@ -1262,21 +1263,21 @@ e_client_cache_get_client (EClientCache *client_cache,
g_return_if_fail (E_IS_SOURCE (source));
g_return_if_fail (extension_name != NULL);
- simple = g_simple_async_result_new (
+ simple = e_simple_async_result_new (
G_OBJECT (client_cache), callback,
user_data, e_client_cache_get_client);
- g_simple_async_result_set_check_cancellable (simple, cancellable);
+ e_simple_async_result_set_check_cancellable (simple, cancellable);
client_data = client_ht_lookup (client_cache, source, extension_name);
if (client_data == NULL) {
- g_simple_async_result_set_error (
- simple, G_IO_ERROR,
+ e_simple_async_result_take_error (
+ simple, g_error_new (G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
_("Cannot create a client object from "
- "extension name ā%sā"), extension_name);
- g_simple_async_result_complete_in_idle (simple);
+ "extension name ā%sā"), extension_name));
+ e_simple_async_result_complete_idle (simple);
goto exit;
}
@@ -1294,9 +1295,9 @@ e_client_cache_get_client (EClientCache *client_cache,
/* If a cached EClient already exists, we're done. */
if (client != NULL) {
- g_simple_async_result_set_op_res_gpointer (
+ e_simple_async_result_set_op_pointer (
simple, client, (GDestroyNotify) g_object_unref);
- g_simple_async_result_complete_in_idle (simple);
+ e_simple_async_result_complete_idle (simple);
goto exit;
}
@@ -1368,20 +1369,20 @@ e_client_cache_get_client_finish (EClientCache *client_cache,
GAsyncResult *result,
GError **error)
{
- GSimpleAsyncResult *simple;
+ ESimpleAsyncResult *simple;
EClient *client;
g_return_val_if_fail (
- g_simple_async_result_is_valid (
+ e_simple_async_result_is_valid (
result, G_OBJECT (client_cache),
e_client_cache_get_client), NULL);
- simple = G_SIMPLE_ASYNC_RESULT (result);
+ simple = E_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
+ if (e_simple_async_result_propagate_error (simple, error))
return NULL;
- client = g_simple_async_result_get_op_res_gpointer (simple);
+ client = e_simple_async_result_get_op_pointer (simple);
g_return_val_if_fail (client != NULL, NULL);
return g_object_ref (client);
diff --git a/src/e-util/e-content-request.c b/src/e-util/e-content-request.c
index bc026f3892..a8bed9a16c 100644
--- a/src/e-util/e-content-request.c
+++ b/src/e-util/e-content-request.c
@@ -138,7 +138,7 @@ e_content_request_process (EContentRequest *request,
{
ThreadData *td;
ESimpleAsyncResult *result;
- gboolean is_http;
+ gboolean is_http, is_contact;
g_return_if_fail (E_IS_CONTENT_REQUEST (request));
g_return_if_fail (uri != NULL);
@@ -146,6 +146,7 @@ e_content_request_process (EContentRequest *request,
is_http = g_ascii_strncasecmp (uri, "http", 4) == 0 ||
g_ascii_strncasecmp (uri, "evo-http", 8) == 0;
+ is_contact = g_ascii_strncasecmp (uri, "mail://contact-photo", 20) == 0;
td = g_slice_new0 (ThreadData);
td->uri = g_strdup (uri);
@@ -154,7 +155,8 @@ e_content_request_process (EContentRequest *request,
result = e_simple_async_result_new (G_OBJECT (request), callback, user_data,
e_content_request_process);
e_simple_async_result_set_user_data (result, td, thread_data_free);
- e_simple_async_result_run_in_thread (result, is_http ? G_PRIORITY_LOW : G_PRIORITY_DEFAULT,
content_request_process_thread, cancellable);
+ e_simple_async_result_set_check_cancellable (result, cancellable);
+ e_simple_async_result_run_in_thread (result, (is_http || is_contact) ? G_PRIORITY_LOW :
G_PRIORITY_DEFAULT, content_request_process_thread, cancellable);
g_object_unref (result);
}
diff --git a/src/e-util/e-photo-cache.c b/src/e-util/e-photo-cache.c
index 111564ab7e..0b6be2ec7d 100644
--- a/src/e-util/e-photo-cache.c
+++ b/src/e-util/e-photo-cache.c
@@ -27,13 +27,16 @@
* to change.
**/
-#include "e-photo-cache.h"
+#include "evolution-config.h"
#include <string.h>
#include <libebackend/libebackend.h>
#include <e-util/e-data-capture.h>
+#include "e-simple-async-result.h"
+#include "e-photo-cache.h"
+
#define E_PHOTO_CACHE_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_PHOTO_CACHE, EPhotoCachePrivate))
@@ -83,7 +86,7 @@ struct _AsyncContext {
struct _AsyncSubtask {
volatile gint ref_count;
EPhotoSource *photo_source;
- GSimpleAsyncResult *simple;
+ ESimpleAsyncResult *simple;
GCancellable *cancellable;
GInputStream *stream;
gint priority;
@@ -118,7 +121,7 @@ G_DEFINE_TYPE_WITH_CODE (
static AsyncSubtask *
async_subtask_new (EPhotoSource *photo_source,
- GSimpleAsyncResult *simple)
+ ESimpleAsyncResult *simple)
{
AsyncSubtask *async_subtask;
@@ -213,13 +216,13 @@ async_subtask_compare (gconstpointer a,
static void
async_subtask_complete (AsyncSubtask *async_subtask)
{
- GSimpleAsyncResult *simple;
+ ESimpleAsyncResult *simple;
AsyncContext *async_context;
gboolean cancel_subtasks = FALSE;
gdouble seconds_elapsed;
simple = async_subtask->simple;
- async_context = g_simple_async_result_get_op_res_gpointer (simple);
+ async_context = e_simple_async_result_get_op_pointer (simple);
g_mutex_lock (&async_context->lock);
@@ -270,7 +273,7 @@ async_subtask_complete (AsyncSubtask *async_subtask)
}
if (async_subtask->error != NULL) {
- g_simple_async_result_take_error (
+ e_simple_async_result_take_error (
simple, async_subtask->error);
async_subtask->error = NULL;
}
@@ -278,7 +281,7 @@ async_subtask_complete (AsyncSubtask *async_subtask)
async_subtask_unref (async_subtask);
}
- g_simple_async_result_complete_in_idle (simple);
+ e_simple_async_result_complete_idle (simple);
exit:
g_mutex_unlock (&async_context->lock);
@@ -365,7 +368,7 @@ async_context_cancel_subtasks (AsyncContext *async_context)
list = g_hash_table_get_keys (async_context->subtasks);
/* XXX Cancel subtasks from idle callbacks to make sure we don't
- * finalize the GSimpleAsyncResult during a "cancelled" signal
+ * finalize the ESimpleAsyncResult during a "cancelled" signal
* emission from the main task's GCancellable. That will make
* g_cancellable_disconnect() in async_context_free() deadlock. */
for (link = list; link != NULL; link = g_list_next (link)) {
@@ -1057,6 +1060,9 @@ e_photo_cache_get_photo_sync (EPhotoCache *photo_cache,
GAsyncResult *result;
gboolean success;
+ if (g_cancellable_set_error_if_cancelled (cancellable, error))
+ return FALSE;
+
closure = e_async_closure_new ();
e_photo_cache_get_photo (
@@ -1094,7 +1100,7 @@ e_photo_cache_get_photo (EPhotoCache *photo_cache,
GAsyncReadyCallback callback,
gpointer user_data)
{
- GSimpleAsyncResult *simple;
+ ESimpleAsyncResult *simple;
AsyncContext *async_context;
EDataCapture *data_capture;
GInputStream *stream = NULL;
@@ -1115,26 +1121,26 @@ e_photo_cache_get_photo (EPhotoCache *photo_cache,
async_context = async_context_new (data_capture, cancellable);
- simple = g_simple_async_result_new (
+ simple = e_simple_async_result_new (
G_OBJECT (photo_cache), callback,
user_data, e_photo_cache_get_photo);
- g_simple_async_result_set_check_cancellable (simple, cancellable);
+ e_simple_async_result_set_check_cancellable (simple, cancellable);
- g_simple_async_result_set_op_res_gpointer (
+ e_simple_async_result_set_op_pointer (
simple, async_context, (GDestroyNotify) async_context_free);
/* Check if we have this email address already cached. */
if (photo_ht_lookup (photo_cache, email_address, &stream)) {
async_context->stream = stream; /* takes ownership */
- g_simple_async_result_complete_in_idle (simple);
+ e_simple_async_result_complete_idle (simple);
goto exit;
}
list = e_photo_cache_list_photo_sources (photo_cache);
if (list == NULL) {
- g_simple_async_result_complete_in_idle (simple);
+ e_simple_async_result_complete_idle (simple);
goto exit;
}
@@ -1199,18 +1205,18 @@ e_photo_cache_get_photo_finish (EPhotoCache *photo_cache,
GInputStream **out_stream,
GError **error)
{
- GSimpleAsyncResult *simple;
+ ESimpleAsyncResult *simple;
AsyncContext *async_context;
g_return_val_if_fail (
- g_simple_async_result_is_valid (
+ e_simple_async_result_is_valid (
result, G_OBJECT (photo_cache),
e_photo_cache_get_photo), FALSE);
- simple = G_SIMPLE_ASYNC_RESULT (result);
- async_context = g_simple_async_result_get_op_res_gpointer (simple);
+ simple = E_SIMPLE_ASYNC_RESULT (result);
+ async_context = e_simple_async_result_get_op_pointer (simple);
- if (g_simple_async_result_propagate_error (simple, error))
+ if (e_simple_async_result_propagate_error (simple, error))
return FALSE;
if (out_stream != NULL) {
diff --git a/src/e-util/e-simple-async-result.c b/src/e-util/e-simple-async-result.c
index 5bb7273111..d95a1b4830 100644
--- a/src/e-util/e-simple-async-result.c
+++ b/src/e-util/e-simple-async-result.c
@@ -32,6 +32,7 @@ struct _ESimpleAsyncResultPrivate {
gpointer op_pointer;
GDestroyNotify destroy_op_pointer;
+ GCancellable *cancellable;
GError *error;
};
@@ -103,6 +104,7 @@ e_simple_async_result_finalize (GObject *object)
result->priv->op_pointer = NULL;
g_clear_object (&result->priv->source_object);
+ g_clear_object (&result->priv->cancellable);
g_clear_error (&result->priv->error);
/* Chain up to parent's method */
@@ -234,15 +236,52 @@ e_simple_async_result_get_op_pointer (ESimpleAsyncResult *result)
return result->priv->op_pointer;
}
+#define DEFAULT_N_THREADS 10
+#define MAX_N_THREADS 30
+
+static void
+update_thread_pool_threads_locked (GThreadPool *pool,
+ gint n_pending)
+{
+ gint set_max = 0;
+
+ if (!pool)
+ return;
+
+ if (n_pending > g_thread_pool_get_max_threads (pool) && g_thread_pool_get_max_threads (pool) <
MAX_N_THREADS)
+ set_max = MIN (n_pending, MAX_N_THREADS);
+ else if (n_pending <= DEFAULT_N_THREADS && g_thread_pool_get_max_threads (pool) > DEFAULT_N_THREADS)
+ set_max = DEFAULT_N_THREADS;
+
+ if (set_max != 0)
+ g_thread_pool_set_max_threads (pool, set_max, NULL);
+}
+
static GThreadPool *thread_pool = NULL;
static GThreadPool *low_prio_thread_pool = NULL;
+static gint normal_n_pending = 0;
+static gint low_prio_n_pending = 0;
+static guint update_thread_pool_threads_id = 0;
G_LOCK_DEFINE_STATIC (thread_pool);
+static gboolean
+update_thread_pool_threads_cb (gpointer user_data)
+{
+ G_LOCK (thread_pool);
+ update_thread_pool_threads_locked (thread_pool, normal_n_pending);
+ update_thread_pool_threads_locked (low_prio_thread_pool, low_prio_n_pending);
+ update_thread_pool_threads_id = 0;
+ G_UNLOCK (thread_pool);
+
+ return FALSE;
+}
+
typedef struct _ThreadData {
ESimpleAsyncResult *result;
gint io_priority;
ESimpleAsyncResultThreadFunc func;
GCancellable *cancellable;
+ gint *p_n_pending;
} ThreadData;
static gint
@@ -265,16 +304,36 @@ e_simple_async_result_thread (gpointer data,
{
ThreadData *td = data;
+ GError *error = NULL;
+
g_return_if_fail (td != NULL);
g_return_if_fail (E_IS_SIMPLE_ASYNC_RESULT (td->result));
g_return_if_fail (td->func != NULL);
- td->func (td->result,
- g_async_result_get_source_object (G_ASYNC_RESULT (td->result)),
- td->cancellable);
+ if (td->result->priv->cancellable &&
+ g_cancellable_set_error_if_cancelled (td->result->priv->cancellable, &error)) {
+ e_simple_async_result_take_error (td->result, error);
+ } else {
+ td->func (td->result,
+ g_async_result_get_source_object (G_ASYNC_RESULT (td->result)),
+ td->cancellable);
+ }
e_simple_async_result_complete_idle_take (td->result);
+ if (g_atomic_int_add (td->p_n_pending, -1) <= DEFAULT_N_THREADS) {
+ G_LOCK (thread_pool);
+ if (!update_thread_pool_threads_id && (
+ (thread_pool &&
+ g_thread_pool_get_max_threads (thread_pool) > DEFAULT_N_THREADS &&
+ normal_n_pending < g_thread_pool_get_max_threads (thread_pool)) ||
+ (low_prio_thread_pool &&
+ g_thread_pool_get_max_threads (low_prio_thread_pool) > DEFAULT_N_THREADS &&
+ low_prio_n_pending < g_thread_pool_get_max_threads (low_prio_thread_pool)))) {
+ update_thread_pool_threads_id = g_timeout_add_seconds (2,
update_thread_pool_threads_cb, NULL);
+ }
+ G_UNLOCK (thread_pool);
+ }
g_clear_object (&td->cancellable);
g_slice_free (ThreadData, td);
}
@@ -286,10 +345,19 @@ e_simple_async_result_run_in_thread (ESimpleAsyncResult *result,
GCancellable *cancellable)
{
ThreadData *td;
+ GThreadPool *use_thread_pool;
+ GError *error = NULL;
g_return_if_fail (E_IS_SIMPLE_ASYNC_RESULT (result));
g_return_if_fail (func != NULL);
+ if (g_cancellable_set_error_if_cancelled (result->priv->cancellable, &error) ||
+ g_cancellable_set_error_if_cancelled (cancellable, &error)) {
+ e_simple_async_result_take_error (result, error);
+ e_simple_async_result_complete_idle (result);
+ return;
+ }
+
td = g_slice_new0 (ThreadData);
td->result = g_object_ref (result);
td->io_priority = io_priority;
@@ -299,17 +367,29 @@ e_simple_async_result_run_in_thread (ESimpleAsyncResult *result,
G_LOCK (thread_pool);
if (!thread_pool) {
- thread_pool = g_thread_pool_new (e_simple_async_result_thread, NULL, 10, FALSE, NULL);
+ thread_pool = g_thread_pool_new (e_simple_async_result_thread, NULL, DEFAULT_N_THREADS,
FALSE, NULL);
g_thread_pool_set_sort_function (thread_pool, e_simple_async_result_thread_pool_sort_func,
NULL);
- low_prio_thread_pool = g_thread_pool_new (e_simple_async_result_thread, NULL, 10, FALSE,
NULL);
+ low_prio_thread_pool = g_thread_pool_new (e_simple_async_result_thread, NULL,
DEFAULT_N_THREADS, FALSE, NULL);
g_thread_pool_set_sort_function (low_prio_thread_pool,
e_simple_async_result_thread_pool_sort_func, NULL);
}
- if (io_priority >= G_PRIORITY_LOW)
- g_thread_pool_push (low_prio_thread_pool, td, NULL);
- else
- g_thread_pool_push (thread_pool, td, NULL);
+ if (io_priority >= G_PRIORITY_LOW) {
+ td->p_n_pending = &low_prio_n_pending;
+ use_thread_pool = low_prio_thread_pool;
+ } else {
+ td->p_n_pending = &normal_n_pending;
+ use_thread_pool = thread_pool;
+ }
+
+ g_atomic_int_add (td->p_n_pending, 1);
+
+ if (!update_thread_pool_threads_id &&
+ *td->p_n_pending > g_thread_pool_get_max_threads (use_thread_pool)) {
+ update_thread_pool_threads_id = g_timeout_add_seconds (2, update_thread_pool_threads_cb,
NULL);
+ }
+
+ g_thread_pool_push (use_thread_pool, td, NULL);
G_UNLOCK (thread_pool);
}
@@ -385,6 +465,19 @@ e_simple_async_result_propagate_error (ESimpleAsyncResult *result,
return TRUE;
}
+void
+e_simple_async_result_set_check_cancellable (ESimpleAsyncResult *result,
+ GCancellable *cancellable)
+{
+ g_return_if_fail (E_IS_SIMPLE_ASYNC_RESULT (result));
+
+ if (result->priv->cancellable != cancellable) {
+ g_clear_object (&result->priv->cancellable);
+ if (cancellable)
+ result->priv->cancellable = g_object_ref (cancellable);
+ }
+}
+
void
e_simple_async_result_free_global_memory (void)
{
diff --git a/src/e-util/e-simple-async-result.h b/src/e-util/e-simple-async-result.h
index e065732f89..37586f6576 100644
--- a/src/e-util/e-simple-async-result.h
+++ b/src/e-util/e-simple-async-result.h
@@ -107,6 +107,9 @@ void e_simple_async_result_take_error
gboolean e_simple_async_result_propagate_error
(ESimpleAsyncResult *result,
GError **error);
+void e_simple_async_result_set_check_cancellable
+ (ESimpleAsyncResult *result,
+ GCancellable *cancellable);
void e_simple_async_result_free_global_memory
(void);
diff --git a/src/modules/contact-photos/e-contact-photo-source.c
b/src/modules/contact-photos/e-contact-photo-source.c
index ca5f8a650c..a9706584b1 100644
--- a/src/modules/contact-photos/e-contact-photo-source.c
+++ b/src/modules/contact-photos/e-contact-photo-source.c
@@ -15,6 +15,9 @@
*
*/
+#include "evolution-config.h"
+
+#include "e-util/e-util.h"
#include "e-contact-photo-source.h"
#define E_CONTACT_PHOTO_SOURCE_GET_PRIVATE(obj) \
@@ -84,8 +87,8 @@ contact_photo_source_extract_photo (EContact *contact,
}
static void
-contact_photo_source_get_photo_thread (GSimpleAsyncResult *simple,
- GObject *source_object,
+contact_photo_source_get_photo_thread (ESimpleAsyncResult *simple,
+ gpointer source_object,
GCancellable *cancellable)
{
AsyncContext *async_context;
@@ -93,7 +96,7 @@ contact_photo_source_get_photo_thread (GSimpleAsyncResult *simple,
GSList *slink;
GError *error = NULL;
- async_context = g_simple_async_result_get_op_res_gpointer (simple);
+ async_context = e_simple_async_result_get_op_pointer (simple);
e_book_client_get_contacts_sync (
async_context->client,
@@ -102,7 +105,7 @@ contact_photo_source_get_photo_thread (GSimpleAsyncResult *simple,
if (error != NULL) {
g_warn_if_fail (slist == NULL);
- g_simple_async_result_take_error (simple, error);
+ e_simple_async_result_take_error (simple, error);
return;
}
@@ -162,13 +165,13 @@ contact_photo_source_get_client_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
- GSimpleAsyncResult *simple;
+ ESimpleAsyncResult *simple;
AsyncContext *async_context;
EClient *client;
GError *error = NULL;
- simple = G_SIMPLE_ASYNC_RESULT (user_data);
- async_context = g_simple_async_result_get_op_res_gpointer (simple);
+ simple = E_SIMPLE_ASYNC_RESULT (user_data);
+ async_context = e_simple_async_result_get_op_pointer (simple);
client = e_client_cache_get_client_finish (
E_CLIENT_CACHE (source_object), result, &error);
@@ -183,15 +186,15 @@ contact_photo_source_get_client_cb (GObject *source_object,
/* The rest of the operation we can run from a
* worker thread to keep the logic flow simple. */
- g_simple_async_result_run_in_thread (
- simple, contact_photo_source_get_photo_thread,
- G_PRIORITY_DEFAULT, async_context->cancellable);
+ e_simple_async_result_run_in_thread (
+ simple, G_PRIORITY_LOW,
+ contact_photo_source_get_photo_thread, async_context->cancellable);
g_object_unref (client);
} else {
- g_simple_async_result_take_error (simple, error);
- g_simple_async_result_complete_in_idle (simple);
+ e_simple_async_result_take_error (simple, error);
+ e_simple_async_result_complete_idle (simple);
}
g_object_unref (simple);
@@ -286,7 +289,7 @@ contact_photo_source_get_photo (EPhotoSource *photo_source,
GAsyncReadyCallback callback,
gpointer user_data)
{
- GSimpleAsyncResult *simple;
+ ESimpleAsyncResult *simple;
AsyncContext *async_context;
EClientCache *client_cache;
ESourceRegistry *registry;
@@ -304,13 +307,13 @@ contact_photo_source_get_photo (EPhotoSource *photo_source,
e_book_query_unref (book_query);
- simple = g_simple_async_result_new (
+ simple = e_simple_async_result_new (
G_OBJECT (photo_source), callback,
user_data, contact_photo_source_get_photo);
- g_simple_async_result_set_check_cancellable (simple, cancellable);
+ e_simple_async_result_set_check_cancellable (simple, cancellable);
- g_simple_async_result_set_op_res_gpointer (
+ e_simple_async_result_set_op_pointer (
simple, async_context, (GDestroyNotify) async_context_free);
client_cache = e_contact_photo_source_ref_client_cache (
@@ -332,7 +335,7 @@ contact_photo_source_get_photo (EPhotoSource *photo_source,
g_object_ref (simple));
} else {
/* Return no result if the source is disabled. */
- g_simple_async_result_complete_in_idle (simple);
+ e_simple_async_result_complete_idle (simple);
}
g_object_unref (client_cache);
@@ -349,18 +352,18 @@ contact_photo_source_get_photo_finish (EPhotoSource *photo_source,
gint *out_priority,
GError **error)
{
- GSimpleAsyncResult *simple;
+ ESimpleAsyncResult *simple;
AsyncContext *async_context;
g_return_val_if_fail (
- g_simple_async_result_is_valid (
+ e_simple_async_result_is_valid (
result, G_OBJECT (photo_source),
contact_photo_source_get_photo), FALSE);
- simple = G_SIMPLE_ASYNC_RESULT (result);
- async_context = g_simple_async_result_get_op_res_gpointer (simple);
+ simple = E_SIMPLE_ASYNC_RESULT (result);
+ async_context = e_simple_async_result_get_op_pointer (simple);
- if (g_simple_async_result_propagate_error (simple, error))
+ if (e_simple_async_result_propagate_error (simple, error))
return FALSE;
if (async_context->stream != NULL) {
diff --git a/src/modules/gravatar/e-gravatar-photo-source.c b/src/modules/gravatar/e-gravatar-photo-source.c
index 6f5d09bfd8..863b99e69f 100644
--- a/src/modules/gravatar/e-gravatar-photo-source.c
+++ b/src/modules/gravatar/e-gravatar-photo-source.c
@@ -15,11 +15,14 @@
*
*/
-#include "e-gravatar-photo-source.h"
+#include "evolution-config.h"
#include <libsoup/soup.h>
#include <libedataserver/libedataserver.h>
+#include "e-util/e-util.h"
+#include "e-gravatar-photo-source.h"
+
#define E_GRAVATAR_PHOTO_SOURCE_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_GRAVATAR_PHOTO_SOURCE, EGravatarPhotoSourcePrivate))
@@ -66,8 +69,8 @@ async_context_free (AsyncContext *async_context)
}
static void
-gravatar_photo_source_get_photo_thread (GSimpleAsyncResult *simple,
- GObject *source_object,
+gravatar_photo_source_get_photo_thread (ESimpleAsyncResult *simple,
+ gpointer source_object,
GCancellable *cancellable)
{
AsyncContext *async_context;
@@ -83,7 +86,7 @@ gravatar_photo_source_get_photo_thread (GSimpleAsyncResult *simple,
if (!e_gravatar_photo_source_get_enabled (E_GRAVATAR_PHOTO_SOURCE (source_object)))
return;
- async_context = g_simple_async_result_get_op_res_gpointer (simple);
+ async_context = e_simple_async_result_get_op_pointer (simple);
hash = e_gravatar_get_hash (async_context->email_address);
uri = g_strdup_printf ("%s%s?d=404", AVATAR_BASE_URI, hash);
@@ -126,7 +129,7 @@ gravatar_photo_source_get_photo_thread (GSimpleAsyncResult *simple,
domain = g_quark_to_string (local_error->domain);
g_debug ("Error: %s (%s)", local_error->message, domain);
- g_simple_async_result_take_error (simple, local_error);
+ e_simple_async_result_take_error (simple, local_error);
}
g_debug ("Request complete");
@@ -145,24 +148,24 @@ gravatar_photo_source_get_photo (EPhotoSource *photo_source,
GAsyncReadyCallback callback,
gpointer user_data)
{
- GSimpleAsyncResult *simple;
+ ESimpleAsyncResult *simple;
AsyncContext *async_context;
async_context = g_slice_new0 (AsyncContext);
async_context->email_address = g_strdup (email_address);
- simple = g_simple_async_result_new (
+ simple = e_simple_async_result_new (
G_OBJECT (photo_source), callback,
user_data, gravatar_photo_source_get_photo);
- g_simple_async_result_set_check_cancellable (simple, cancellable);
+ e_simple_async_result_set_check_cancellable (simple, cancellable);
- g_simple_async_result_set_op_res_gpointer (
+ e_simple_async_result_set_op_pointer (
simple, async_context, (GDestroyNotify) async_context_free);
- g_simple_async_result_run_in_thread (
- simple, gravatar_photo_source_get_photo_thread,
- G_PRIORITY_DEFAULT, cancellable);
+ e_simple_async_result_run_in_thread (
+ simple, G_PRIORITY_LOW,
+ gravatar_photo_source_get_photo_thread, cancellable);
g_object_unref (simple);
}
@@ -174,18 +177,18 @@ gravatar_photo_source_get_photo_finish (EPhotoSource *photo_source,
gint *out_priority,
GError **error)
{
- GSimpleAsyncResult *simple;
+ ESimpleAsyncResult *simple;
AsyncContext *async_context;
g_return_val_if_fail (
- g_simple_async_result_is_valid (
+ e_simple_async_result_is_valid (
result, G_OBJECT (photo_source),
gravatar_photo_source_get_photo), FALSE);
- simple = G_SIMPLE_ASYNC_RESULT (result);
- async_context = g_simple_async_result_get_op_res_gpointer (simple);
+ simple = E_SIMPLE_ASYNC_RESULT (result);
+ async_context = e_simple_async_result_get_op_pointer (simple);
- if (g_simple_async_result_propagate_error (simple, error))
+ if (e_simple_async_result_propagate_error (simple, error))
return FALSE;
if (async_context->stream != NULL) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]