[evolution-data-server] Identify job description for camel_session_submit_job()



commit d4ea4a51c12e8e604da5e12e11199db01809d164
Author: Milan Crha <mcrha redhat com>
Date:   Fri Feb 6 09:05:38 2015 +0100

    Identify job description for camel_session_submit_job()
    
    The job is submitted as a GTask, which is limited to 10 threads running
    at one time currently, which means that the job can starve in the GTask's
    thread pool for some time, without a chance to identify itself in a human
    readable way to a user, which resulted in "Unknown background operation"
    in Evolution's status bar, despite the operation identified itself as soon
    as it was run (when it left the GTak's thread pool waiting queue).

 camel/camel-folder-summary.c              |   13 +++++++++++--
 camel/camel-folder.c                      |    7 ++++++-
 camel/camel-offline-folder.c              |    7 ++++++-
 camel/camel-session.c                     |    7 +++++++
 camel/camel-session.h                     |    1 +
 camel/camel-vee-folder.c                  |    8 +++++++-
 camel/camel-vee-store.c                   |    2 +-
 camel/providers/imapx/camel-imapx-store.c |    7 +++++--
 configure.ac                              |    2 +-
 9 files changed, 45 insertions(+), 9 deletions(-)
---
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c
index aaefe6c..88bc793 100644
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@ -2118,6 +2118,7 @@ cfs_try_release_memory (CamelFolderSummary *summary)
 {
        CamelStore *parent_store;
        CamelSession *session;
+       gchar *description;
 
        /* If folder is freed or if the cache is nil then clean up */
        if (!summary->priv->folder ||
@@ -2135,14 +2136,16 @@ cfs_try_release_memory (CamelFolderSummary *summary)
 
        parent_store = camel_folder_get_parent_store (summary->priv->folder);
        session = camel_service_ref_session (CAMEL_SERVICE (parent_store));
+       description = g_strdup_printf (_("Release unused memory for folder '%s'"), camel_folder_get_full_name 
(summary->priv->folder));
 
        camel_session_submit_job (
-               session,
+               session, description,
                (CamelSessionCallback) remove_cache,
                g_object_ref (summary),
                (GDestroyNotify) g_object_unref);
 
        g_object_unref (session);
+       g_free (description);
 
        return TRUE;
 }
@@ -2343,12 +2346,18 @@ cfs_reload_from_db (CamelFolderSummary *summary,
                   object which is invalidates its content when it reaches the dispose. */
                session = camel_service_ref_session (CAMEL_SERVICE (parent_store));
                if (session) {
+                       gchar *description;
+
+                       description = g_strdup_printf (_("Update preview data for folder '%s'"), 
camel_folder_get_full_name (summary->priv->folder));
+
                        camel_session_submit_job (
-                               session,
+                               session, description,
                                (CamelSessionCallback) preview_update,
                                g_object_ref (summary->priv->folder),
                                (GDestroyNotify) g_object_unref);
+
                        g_object_unref (session);
+                       g_free (description);
                }
        }
 
diff --git a/camel/camel-folder.c b/camel/camel-folder.c
index 9772019..9e9c14b 100644
--- a/camel/camel-folder.c
+++ b/camel/camel-folder.c
@@ -1131,6 +1131,7 @@ folder_changed (CamelFolder *folder,
 
        if (driver || junk || notjunk) {
                FolderFilterData *data;
+               gchar *description;
 
                data = g_slice_new0 (FolderFilterData);
                data->recents = recents;
@@ -1148,11 +1149,15 @@ folder_changed (CamelFolder *folder,
                        folder->priv->changed_frozen, info);
                g_mutex_unlock (&folder->priv->change_lock);
 
+               description = g_strdup_printf (_("Filtering folder '%s'"), camel_folder_get_full_name 
(folder));
+
                camel_session_submit_job (
-                       session, (CamelSessionCallback) folder_filter,
+                       session, description, (CamelSessionCallback) folder_filter,
                        data, (GDestroyNotify) prepare_folder_filter_data_free);
 
                g_signal_stop_emission (folder, signals[CHANGED], 0);
+
+               g_free (description);
        }
 
        g_object_unref (session);
diff --git a/camel/camel-offline-folder.c b/camel/camel-offline-folder.c
index 1081e6f..8b1528b 100644
--- a/camel/camel-offline-folder.c
+++ b/camel/camel-offline-folder.c
@@ -145,16 +145,21 @@ offline_folder_changed (CamelFolder *folder,
 
        if (changes->uid_added->len > 0 && (sync_store || sync_folder)) {
                OfflineDownsyncData *data;
+               gchar *description;
 
                data = g_slice_new0 (OfflineDownsyncData);
                data->changes = camel_folder_change_info_new ();
                camel_folder_change_info_cat (data->changes, changes);
                data->folder = g_object_ref (folder);
 
+               description = g_strdup_printf (_("Checking download of new messages for offline in '%s'"), 
camel_folder_get_full_name (folder));
+
                camel_session_submit_job (
-                       session, (CamelSessionCallback)
+                       session, description, (CamelSessionCallback)
                        offline_folder_downsync_background, data,
                        (GDestroyNotify) offline_downsync_data_free);
+
+               g_free (description);
        }
 
        g_object_unref (session);
diff --git a/camel/camel-session.c b/camel/camel-session.c
index 907caee..ed63596 100644
--- a/camel/camel-session.c
+++ b/camel/camel-session.c
@@ -150,6 +150,8 @@ signal_closure_free (SignalClosure *signal_closure)
 static void
 job_data_free (JobData *job_data)
 {
+       camel_operation_pop_message (job_data->cancellable);
+
        g_object_unref (job_data->session);
        g_object_unref (job_data->cancellable);
 
@@ -1407,6 +1409,7 @@ camel_session_idle_add (CamelSession *session,
 /**
  * camel_session_submit_job:
  * @session: a #CamelSession
+ * @description: human readable description of the job, shown to a user
  * @callback: a #CamelSessionCallback
  * @user_data: user data passed to the callback
  * @notify: a #GDestroyNotify function
@@ -1433,6 +1436,7 @@ camel_session_idle_add (CamelSession *session,
  **/
 void
 camel_session_submit_job (CamelSession *session,
+                         const gchar *description,
                           CamelSessionCallback callback,
                           gpointer user_data,
                           GDestroyNotify notify)
@@ -1440,6 +1444,7 @@ camel_session_submit_job (CamelSession *session,
        JobData *job_data;
 
        g_return_if_fail (CAMEL_IS_SESSION (session));
+       g_return_if_fail (description != NULL);
        g_return_if_fail (callback != NULL);
 
        job_data = g_slice_new0 (JobData);
@@ -1449,6 +1454,8 @@ camel_session_submit_job (CamelSession *session,
        job_data->user_data = user_data;
        job_data->notify = notify;
 
+       camel_operation_push_message (job_data->cancellable, "%s", description);
+
        camel_session_idle_add (
                session, JOB_PRIORITY,
                session_start_job_cb,
diff --git a/camel/camel-session.h b/camel/camel-session.h
index 6dee792..ce9b045 100644
--- a/camel/camel-session.h
+++ b/camel/camel-session.h
@@ -202,6 +202,7 @@ guint               camel_session_idle_add          (CamelSession *session,
                                                 gpointer data,
                                                 GDestroyNotify notify);
 void           camel_session_submit_job        (CamelSession *session,
+                                                const gchar *description,
                                                 CamelSessionCallback callback,
                                                 gpointer user_data,
                                                 GDestroyNotify notify);
diff --git a/camel/camel-vee-folder.c b/camel/camel-vee-folder.c
index 4d38a2c..3b1d770 100644
--- a/camel/camel-vee-folder.c
+++ b/camel/camel-vee-folder.c
@@ -1110,12 +1110,18 @@ vee_folder_folder_changed (CamelVeeFolder *vee_folder,
        g_async_queue_push_unlocked (vee_folder->priv->change_queue, data);
 
        if (!vee_folder->priv->change_queue_busy) {
+               gchar *description;
+
+               description = g_strdup_printf ("Updating search folder '%s'", camel_folder_get_full_name 
(CAMEL_FOLDER (vee_folder)));
+
                camel_session_submit_job (
-                       session, (CamelSessionCallback)
+                       session, description, (CamelSessionCallback)
                        vee_folder_process_changes,
                        g_object_ref (vee_folder),
                        (GDestroyNotify) g_object_unref);
                vee_folder->priv->change_queue_busy = TRUE;
+
+               g_free (description);
        }
 
        g_async_queue_unlock (vee_folder->priv->change_queue);
diff --git a/camel/camel-vee-store.c b/camel/camel-vee-store.c
index 5eeab01..39ac7cd 100644
--- a/camel/camel-vee-store.c
+++ b/camel/camel-vee-store.c
@@ -1022,7 +1022,7 @@ camel_vee_store_rebuild_unmatched_folder (CamelVeeStore *vstore,
                session = camel_service_ref_session (service);
 
                camel_session_submit_job (
-                       session, (CamelSessionCallback)
+                       session, _("Updating Unmatched search folder"), (CamelSessionCallback)
                        vee_store_rebuild_unmatched_folder,
                        g_object_ref (vstore),
                        g_object_unref);
diff --git a/camel/providers/imapx/camel-imapx-store.c b/camel/providers/imapx/camel-imapx-store.c
index 5f18a2d..d5ad905 100644
--- a/camel/providers/imapx/camel-imapx-store.c
+++ b/camel/providers/imapx/camel-imapx-store.c
@@ -1552,7 +1552,7 @@ imapx_refresh_finfo (CamelSession *session,
        display_name = camel_service_get_display_name (service);
 
        camel_operation_push_message (
-               cancellable, _("Retrieving folder list for %s"),
+               cancellable, _("Retrieving folder list for '%s'"),
                display_name);
 
        if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store)))
@@ -1792,18 +1792,21 @@ imapx_store_get_folder_info_sync (CamelStore *store,
 
                if (time_since_last_refresh > FINFO_REFRESH_INTERVAL) {
                        CamelSession *session;
+                       gchar *description;
 
                        imapx_store->priv->last_refresh_time = time (NULL);
 
                        session = camel_service_ref_session (service);
+                       description = g_strdup_printf (_("Retrieving folder list for '%s'"), 
camel_service_get_display_name (service));
 
                        camel_session_submit_job (
-                               session, (CamelSessionCallback)
+                               session, description, (CamelSessionCallback)
                                imapx_refresh_finfo,
                                g_object_ref (store),
                                (GDestroyNotify) g_object_unref);
 
                        g_object_unref (session);
+                       g_free (description);
                }
        }
 
diff --git a/configure.ac b/configure.ac
index e25d929..7bfe6ba 100644
--- a/configure.ac
+++ b/configure.ac
@@ -134,7 +134,7 @@ LIBEBOOK_CONTACTS_CURRENT=1
 LIBEBOOK_CONTACTS_REVISION=0
 LIBEBOOK_CONTACTS_AGE=0
 
-LIBCAMEL_CURRENT=51
+LIBCAMEL_CURRENT=52
 LIBCAMEL_REVISION=0
 LIBCAMEL_AGE=0
 


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