[evolution-data-server] Add camel_folder_get_full_display_name()



commit f5a1dc5c671aca6cf25b71634679dd1701f80b42
Author: Milan Crha <mcrha redhat com>
Date:   Fri Jul 8 12:56:05 2022 +0200

    Add camel_folder_get_full_display_name()
    
    Providers having different display names from the folder names can override
    the function to return appropriate display name.

 src/camel/camel-filter-driver.c                |  2 +-
 src/camel/camel-folder-summary.c               |  2 +-
 src/camel/camel-folder.c                       | 68 +++++++++++++++++++++-----
 src/camel/camel-folder.h                       |  5 +-
 src/camel/camel-offline-folder.c               |  8 +--
 src/camel/camel-vee-folder.c                   |  4 +-
 src/camel/providers/imapx/camel-imapx-folder.c |  6 +--
 src/camel/providers/imapx/camel-imapx-server.c |  4 +-
 8 files changed, 74 insertions(+), 25 deletions(-)
---
diff --git a/src/camel/camel-filter-driver.c b/src/camel/camel-filter-driver.c
index 766f5feb3..ab0bd0d27 100644
--- a/src/camel/camel-filter-driver.c
+++ b/src/camel/camel-filter-driver.c
@@ -263,7 +263,7 @@ filter_driver_process_transfers (CamelFilterDriver *driver,
                   the whole “%s : %s” is meant as an absolute identification of the folder. */
                camel_operation_push_message (cancellable, _("Transferring filtered messages in “%s : %s”"),
                        camel_service_get_display_name (CAMEL_SERVICE (parent_store)),
-                       camel_folder_get_full_name (driver->priv->source));
+                       camel_folder_get_full_display_name (driver->priv->source));
 
                ii = 0;
                sz = g_hash_table_size (driver->priv->transfers);
diff --git a/src/camel/camel-folder-summary.c b/src/camel/camel-folder-summary.c
index e10ab33af..8a8a9ba96 100644
--- a/src/camel/camel-folder-summary.c
+++ b/src/camel/camel-folder-summary.c
@@ -1661,7 +1661,7 @@ cfs_try_release_memory (gpointer user_data)
           the whole “%s : %s” is meant as an absolute identification of the folder. */
        description = g_strdup_printf (_("Release unused memory for folder “%s : %s”"),
                camel_service_get_display_name (CAMEL_SERVICE (parent_store)),
-               camel_folder_get_full_name (summary->priv->folder));
+               camel_folder_get_full_display_name (summary->priv->folder));
 
        camel_session_submit_job (
                session, description,
diff --git a/src/camel/camel-folder.c b/src/camel/camel-folder.c
index f18fbcbb2..459cd0c74 100644
--- a/src/camel/camel-folder.c
+++ b/src/camel/camel-folder.c
@@ -170,7 +170,7 @@ folder_schedule_store_changes_job (CamelFolder *folder)
                   the whole “%s : %s” is meant as an absolute identification of the folder. */
                description = g_strdup_printf (_("Storing changes in folder “%s : %s”"),
                        camel_service_get_display_name (CAMEL_SERVICE (parent_store)),
-                       camel_folder_get_full_name (folder));
+                       camel_folder_get_full_display_name (folder));
 
                camel_session_submit_job (session, description,
                        folder_store_changes_job_cb,
@@ -392,9 +392,10 @@ folder_filter (CamelSession *session,
        gint i;
        CamelJunkFilter *junk_filter;
        gboolean synchronize = FALSE;
-       const gchar *full_name;
+       const gchar *full_name, *full_display_name;
 
        full_name = camel_folder_get_full_name (data->folder);
+       full_display_name = camel_folder_get_full_display_name (data->folder);
        parent_store = camel_folder_get_parent_store (data->folder);
        junk_filter = camel_session_get_junk_filter (session);
 
@@ -457,7 +458,7 @@ folder_filter (CamelSession *session,
                        "Learning new spam messages in “%s : %s”",
                        data->junk->len),
                        camel_service_get_display_name (CAMEL_SERVICE (parent_store)),
-                       full_name);
+                       full_display_name);
 
                for (i = 0; success && i < data->junk->len; i++) {
                        CamelMimeMessage *message;
@@ -500,7 +501,7 @@ folder_filter (CamelSession *session,
                        "Learning new ham messages in “%s : %s”",
                        data->notjunk->len),
                        camel_service_get_display_name (CAMEL_SERVICE (parent_store)),
-                       full_name);
+                       full_display_name);
 
                for (i = 0; success && i < data->notjunk->len; i++) {
                        CamelMimeMessage *message;
@@ -548,7 +549,7 @@ folder_filter (CamelSession *session,
                        "Filtering new messages in “%s : %s”",
                        data->recents->len),
                        camel_service_get_display_name (CAMEL_SERVICE (parent_store)),
-                       full_name);
+                       full_display_name);
 
                camel_filter_driver_log_info (data->driver, "\nReported %d recent messages in '%s : %s'",
                        data->recents->len, camel_service_get_display_name (CAMEL_SERVICE (parent_store)), 
full_name);
@@ -1257,7 +1258,7 @@ folder_get_quota_info_sync (CamelFolder *folder,
                   the whole “%s : %s” is meant as an absolute identification of the folder. */
                _("Quota information not supported for folder “%s : %s”"),
                camel_service_get_display_name (CAMEL_SERVICE (camel_folder_get_parent_store (folder))),
-               camel_folder_get_full_name (folder));
+               camel_folder_get_full_display_name (folder));
 
        return NULL;
 }
@@ -1359,7 +1360,7 @@ folder_changed (CamelFolder *folder,
                   the whole “%s : %s” is meant as an absolute identification of the folder. */
                description = g_strdup_printf (_("Filtering folder “%s : %s”"),
                        camel_service_get_display_name (CAMEL_SERVICE (parent_store)),
-                       camel_folder_get_full_name (folder));
+                       camel_folder_get_full_display_name (folder));
 
                camel_session_submit_job (
                        session, description, (CamelSessionCallback) folder_filter,
@@ -1373,6 +1374,25 @@ folder_changed (CamelFolder *folder,
        g_object_unref (session);
 }
 
+/* Providers having different display names from the folder names can override
+   the function to return appropriate display name. */
+static const gchar *
+folder_get_full_display_name (CamelFolder *folder)
+{
+       const gchar *res;
+
+       g_mutex_lock (&folder->priv->property_lock);
+
+       if (!strchr (folder->priv->full_name, '/'))
+               res = folder->priv->display_name;
+       else
+               res = folder->priv->full_name;
+
+       g_mutex_unlock (&folder->priv->property_lock);
+
+       return res;
+}
+
 static void
 camel_folder_class_init (CamelFolderClass *class)
 {
@@ -1410,6 +1430,7 @@ camel_folder_class_init (CamelFolderClass *class)
        class->refresh_info_sync = folder_refresh_info_sync;
        class->transfer_messages_to_sync = folder_transfer_messages_to_sync;
        class->changed = folder_changed;
+       class->get_full_display_name = folder_get_full_display_name;
 
        /**
         * CamelFolder:description
@@ -1789,6 +1810,31 @@ camel_folder_set_display_name (CamelFolder *folder,
        g_object_notify (G_OBJECT (folder), "display-name");
 }
 
+/**
+ * camel_folder_get_full_display_name:
+ * @folder: a #CamelFolder
+ *
+ * Similar to the camel_folder_get_full_name(), only returning
+ * full path to the @folder suitable for the display to a user.
+ *
+ * Return: (transfer none): full path to the @folder suitable for the display to a user
+ *
+ * Since: 3.46
+ **/
+const gchar *
+camel_folder_get_full_display_name (CamelFolder *folder)
+{
+       CamelFolderClass *klass;
+
+       g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
+
+       klass = CAMEL_FOLDER_GET_CLASS (folder);
+       g_return_val_if_fail (klass != NULL, NULL);
+       g_return_val_if_fail (klass->get_full_display_name != NULL, NULL);
+
+       return klass->get_full_display_name (folder);
+}
+
 /**
  * camel_folder_get_description:
  * @folder: a #CamelFolder
@@ -3325,7 +3371,7 @@ camel_folder_expunge_sync (CamelFolder *folder,
           the whole “%s : %s” is meant as an absolute identification of the folder. */
        camel_operation_push_message (cancellable, _("Expunging folder “%s : %s”"),
                camel_service_get_display_name (CAMEL_SERVICE (camel_folder_get_parent_store (folder))),
-               camel_folder_get_full_name (folder));
+               camel_folder_get_full_display_name (folder));
 
        if (!(camel_folder_get_flags (folder) & CAMEL_FOLDER_HAS_BEEN_DELETED)) {
                success = class->expunge_sync (folder, cancellable, error);
@@ -3460,7 +3506,7 @@ camel_folder_get_message_sync (CamelFolder *folder,
                   the whole “%s : %s” is meant as an absolute identification of the folder. */
                cancellable, _("Retrieving message “%s” in “%s : %s”"),
                message_uid, camel_service_get_display_name (CAMEL_SERVICE (camel_folder_get_parent_store 
(folder))),
-               camel_folder_get_full_name (folder));
+               camel_folder_get_full_display_name (folder));
 
        message = camel_folder_get_message_cached (folder, message_uid, cancellable);
 
@@ -3685,7 +3731,7 @@ camel_folder_get_quota_info_sync (CamelFolder *folder,
           the whole “%s : %s” is meant as an absolute identification of the folder. */
        camel_operation_push_message (cancellable, _("Retrieving quota information for “%s : %s”"),
                camel_service_get_display_name (CAMEL_SERVICE (camel_folder_get_parent_store (folder))),
-               camel_folder_get_full_name (folder));
+               camel_folder_get_full_display_name (folder));
 
        quota_info = class->get_quota_info_sync (folder, cancellable, error);
        CAMEL_CHECK_GERROR (
@@ -3985,7 +4031,7 @@ camel_folder_refresh_info_sync (CamelFolder *folder,
           the whole “%s : %s” is meant as an absolute identification of the folder. */
        camel_operation_push_message (cancellable, _("Refreshing folder “%s : %s”"),
                camel_service_get_display_name (CAMEL_SERVICE (camel_folder_get_parent_store (folder))),
-               camel_folder_get_full_name (folder));
+               camel_folder_get_full_display_name (folder));
 
        success = class->refresh_info_sync (folder, cancellable, error);
        CAMEL_CHECK_GERROR (folder, refresh_info_sync, success, error);
diff --git a/src/camel/camel-folder.h b/src/camel/camel-folder.h
index ea5b80c44..02e6e9c7c 100644
--- a/src/camel/camel-folder.h
+++ b/src/camel/camel-folder.h
@@ -260,9 +260,10 @@ struct _CamelFolderClass {
                                                 GError **error);
        void            (*prepare_content_refresh)
                                                (CamelFolder *folder);
+       const gchar *   (*get_full_display_name)(CamelFolder *folder);
 
        /* Padding for future expansion */
-       gpointer reserved_methods[20];
+       gpointer reserved_methods[19];
 
        /* Signals */
        void            (*changed)              (CamelFolder *folder,
@@ -294,6 +295,8 @@ const gchar *       camel_folder_get_display_name   (CamelFolder *folder);
 gchar *                camel_folder_dup_display_name   (CamelFolder *folder);
 void           camel_folder_set_display_name   (CamelFolder *folder,
                                                 const gchar *display_name);
+const gchar *  camel_folder_get_full_display_name
+                                               (CamelFolder *folder);
 const gchar *  camel_folder_get_description    (CamelFolder *folder);
 gchar *                camel_folder_dup_description    (CamelFolder *folder);
 void           camel_folder_set_description    (CamelFolder *folder,
diff --git a/src/camel/camel-offline-folder.c b/src/camel/camel-offline-folder.c
index 5b7a88731..3b86393b6 100644
--- a/src/camel/camel-offline-folder.c
+++ b/src/camel/camel-offline-folder.c
@@ -174,7 +174,7 @@ offline_folder_downsync_background (CamelSession *session,
                   the whole “%s : %s” is meant as an absolute identification of the folder. */
                cancellable, _("Downloading new messages for offline mode in “%s : %s”"),
                camel_service_get_display_name (CAMEL_SERVICE (camel_folder_get_parent_store (data->folder))),
-               camel_folder_get_full_name (data->folder));
+               camel_folder_get_full_display_name (data->folder));
 
        limit_time = offline_folder_get_limit_time (data->folder);
 
@@ -259,7 +259,7 @@ offline_folder_changed (CamelFolder *folder,
                   the whole “%s : %s” is meant as an absolute identification of the folder. */
                description = g_strdup_printf (_("Checking download of new messages for offline in “%s : 
%s”"),
                        camel_service_get_display_name (CAMEL_SERVICE (store)),
-                       camel_folder_get_full_name (folder));
+                       camel_folder_get_full_display_name (folder));
 
                camel_session_submit_job (
                        session, description, (CamelSessionCallback)
@@ -335,7 +335,7 @@ offline_folder_downsync_sync (CamelOfflineFolder *offline,
           the whole “%s : %s” is meant as an absolute identification of the folder. */
        camel_operation_push_message (cancellable, _("Syncing messages in folder “%s : %s” to disk"),
                camel_service_get_display_name (CAMEL_SERVICE (camel_folder_get_parent_store (folder))),
-               camel_folder_get_full_name (folder));
+               camel_folder_get_full_display_name (folder));
 
        limit_time = offline_folder_get_limit_time (folder);
        if (limit_time > 0 && camel_folder_get_folder_summary (folder)) {
@@ -430,7 +430,7 @@ offline_folder_downsync_sync (CamelOfflineFolder *offline,
                        camel_operation_push_message (cancellable, _("Syncing message %d of %d in folder “%s 
: %s” to disk"),
                                i + 1, uncached_uids->len,
                                camel_service_get_display_name (CAMEL_SERVICE (camel_folder_get_parent_store 
(folder))),
-                               camel_folder_get_full_name (folder));
+                               camel_folder_get_full_display_name (folder));
 
                        /* Stop on failure */
                        if (!offline_folder_synchronize_message_wrapper_sync (folder, uid, cancellable, 
&local_error)) {
diff --git a/src/camel/camel-vee-folder.c b/src/camel/camel-vee-folder.c
index 24feca551..751afc1c7 100644
--- a/src/camel/camel-vee-folder.c
+++ b/src/camel/camel-vee-folder.c
@@ -1319,7 +1319,7 @@ vee_folder_get_message_sync (CamelFolder *folder,
                           meant as an absolute identification of the folder. */
                        _("No such message %s in “%s : %s”"), uid,
                        camel_service_get_display_name (CAMEL_SERVICE (camel_folder_get_parent_store 
(folder))),
-                       camel_folder_get_full_name (folder));
+                       camel_folder_get_full_display_name (folder));
        }
 
        return msg;
@@ -1582,7 +1582,7 @@ vee_folder_folder_changed (CamelVeeFolder *vee_folder,
        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)));
+               description = g_strdup_printf (_("Updating search folder “%s”"), 
camel_folder_get_full_display_name (CAMEL_FOLDER (vee_folder)));
 
                camel_session_submit_job (
                        session, description, (CamelSessionCallback)
diff --git a/src/camel/providers/imapx/camel-imapx-folder.c b/src/camel/providers/imapx/camel-imapx-folder.c
index 09d4a2c94..91ce26097 100644
--- a/src/camel/providers/imapx/camel-imapx-folder.c
+++ b/src/camel/providers/imapx/camel-imapx-folder.c
@@ -764,7 +764,7 @@ imapx_get_quota_info_sync (CamelFolder *folder,
                           the whole “%s : %s” is meant as an absolute identification of the folder. */
                        _("No quota information available for folder “%s : %s”"),
                        camel_service_get_display_name (CAMEL_SERVICE (store)),
-                       camel_folder_get_full_name (folder));
+                       camel_folder_get_full_display_name (folder));
 
 exit:
        g_clear_object (&mailbox);
@@ -1031,7 +1031,7 @@ imapx_folder_changed (CamelFolder *folder,
                                   the whole “%s : %s” is meant as an absolute identification of the folder. 
*/
                                description = g_strdup_printf (_("Removing stale cache files in folder “%s : 
%s”"),
                                        camel_service_get_display_name (CAMEL_SERVICE (parent_store)),
-                                       camel_folder_get_full_name (CAMEL_FOLDER (imapx_folder)));
+                                       camel_folder_get_full_display_name (CAMEL_FOLDER (imapx_folder)));
 
                                camel_session_submit_job (session, description,
                                        imapx_folder_remove_cache_files_thread, rcf, remove_cache_files_free);
@@ -1462,7 +1462,7 @@ camel_imapx_folder_list_mailbox (CamelIMAPXFolder *folder,
                           the whole “%s : %s” is meant as an absolute identification of the folder. */
                        _("No IMAP mailbox available for folder “%s : %s”"),
                        camel_service_get_display_name (CAMEL_SERVICE (parent_store)),
-                       camel_folder_get_full_name (CAMEL_FOLDER (folder)));
+                       camel_folder_get_full_display_name (CAMEL_FOLDER (folder)));
        }
 
 exit:
diff --git a/src/camel/providers/imapx/camel-imapx-server.c b/src/camel/providers/imapx/camel-imapx-server.c
index 1eeff8ddb..2ed68cff5 100644
--- a/src/camel/providers/imapx/camel-imapx-server.c
+++ b/src/camel/providers/imapx/camel-imapx-server.c
@@ -5422,7 +5422,7 @@ imapx_server_fetch_changes (CamelIMAPXServer *is,
                   the whole “%s : %s” is meant as an absolute identification of the folder. */
                _("Scanning for changed messages in “%s : %s”"),
                camel_service_get_display_name (CAMEL_SERVICE (camel_folder_get_parent_store (folder))),
-               camel_folder_get_full_name (folder));
+               camel_folder_get_full_display_name (folder));
 
        success = camel_imapx_server_process_command_sync (is, ic, _("Error scanning changes"), cancellable, 
error);
 
@@ -5447,7 +5447,7 @@ imapx_server_fetch_changes (CamelIMAPXServer *is,
                           the whole “%s : %s” is meant as an absolute identification of the folder. */
                        _("Fetching summary information for new messages in “%s : %s”"),
                        camel_service_get_display_name (CAMEL_SERVICE (camel_folder_get_parent_store 
(folder))),
-                       camel_folder_get_full_name (folder));
+                       camel_folder_get_full_display_name (folder));
 
                fetch_summary_uids = g_slist_sort (fetch_summary_uids, imapx_uids_desc_cmp);
 


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