[evolution-data-server/imap-notify: 13/23] CamelIMAPXCommand: Replace '%f' format character with '%m'.



commit a89ef53f567efb3adc86f72b88ee1f8cfdfd510e
Author: Matthew Barnes <mbarnes redhat com>
Date:   Mon Sep 2 15:13:43 2013 -0400

    CamelIMAPXCommand: Replace '%f' format character with '%m'.
    
    Whereas '%f' took a CamelFolder argument and had to be converted to an
    IMAP mailbox name (with the correct separator character), '%m' takes a
    CamelIMAPXMailbox which already has the IMAP mailbox name.

 camel/camel-imapx-command.c |   38 +++++++++-------------------------
 camel/camel-imapx-server.c  |   48 ++++++++++++++++++++++++++++++++++---------
 2 files changed, 48 insertions(+), 38 deletions(-)
---
diff --git a/camel/camel-imapx-command.c b/camel/camel-imapx-command.c
index 4322777..4fabc47 100644
--- a/camel/camel-imapx-command.c
+++ b/camel/camel-imapx-command.c
@@ -258,11 +258,10 @@ camel_imapx_command_addv (CamelIMAPXCommand *ic,
        CamelDataWrapper *D;
        CamelSasl *A;
        gchar literal_format[16];
-       CamelFolder *folder;
-       CamelStore *parent_store;
+       CamelIMAPXMailbox *mailbox;
        GString *buffer;
-       gchar *mailbox = NULL, *encoded = NULL;
-       const gchar *full_name;
+       gchar *encoded_name = NULL;
+       const gchar *name;
 
        g_return_if_fail (CAMEL_IS_IMAPX_COMMAND (ic));
 
@@ -363,31 +362,14 @@ camel_imapx_command_addv (CamelIMAPXCommand *ic,
                                } else {
                                        g_string_append (buffer, "\"\"");
                                }
-                               if (encoded) {
-                                       g_free (encoded);
-                                       encoded = NULL;
-                               }
-                               break;
-                       case 'f': /* imap folder name */
-                               folder = va_arg (ap, CamelFolder *);
-                               full_name = camel_folder_get_full_name (folder);
-                               c (ic->is->tagprefix, "got folder '%s'\n", full_name);
-                               parent_store = camel_folder_get_parent_store (folder);
-                               mailbox = camel_imapx_store_summary_mailbox_from_path (
-                                       ((CamelIMAPXStore *) parent_store)->summary, full_name);
-                               if (mailbox != NULL) {
-                                       encoded = camel_utf8_utf7 (mailbox);
-                                       g_free (mailbox);
-                               } else
-                                       encoded = camel_utf8_utf7 (full_name);
-
-                               if (encoded) {
-                                       s = encoded;
-                                       goto output_string;
-                               } else
-                                       g_string_append (buffer, "\"\"");
-
+                               g_free (encoded_name);
+                               encoded_name = NULL;
                                break;
+                       case 'm': /* IMAP mailbox name */
+                               mailbox = va_arg (ap, CamelIMAPXMailbox *);
+                               name = camel_imapx_mailbox_get_name (mailbox);
+                               s = camel_utf8_utf7 (name);
+                               goto output_string;
                        case 'F': /* IMAP flags set */
                                f = va_arg (ap, guint32);
                                F = va_arg (ap, CamelFlag *);
diff --git a/camel/camel-imapx-server.c b/camel/camel-imapx-server.c
index 3e7d5eb..731e613 100644
--- a/camel/camel-imapx-server.c
+++ b/camel/camel-imapx-server.c
@@ -3996,6 +3996,7 @@ imapx_maybe_select (CamelIMAPXServer *is,
                     CamelFolder *folder)
 {
        CamelIMAPXCommand *ic;
+       CamelIMAPXMailbox *mailbox;
        CamelFolder *select_folder;
        CamelFolder *select_pending;
        gboolean nothing_to_do = FALSE;
@@ -4051,8 +4052,13 @@ imapx_maybe_select (CamelIMAPXServer *is,
        if (nothing_to_do)
                return;
 
+       mailbox = camel_imapx_folder_ref_mailbox (CAMEL_IMAPX_FOLDER (folder));
+       g_warn_if_fail (mailbox != NULL);
+
        ic = camel_imapx_command_new (
-               is, "SELECT", NULL, "SELECT %f", folder);
+               is, "SELECT", NULL, "SELECT %m", mailbox);
+
+       g_object_unref (mailbox);
 
        if (is->use_qresync)
                camel_imapx_command_add_qresync_parameter (ic, folder);
@@ -5030,6 +5036,7 @@ imapx_command_copy_messages_step_start (CamelIMAPXServer *is,
                                         GError **error)
 {
        CamelFolder *folder;
+       CamelIMAPXMailbox *dest_mailbox;
        CamelIMAPXCommand *ic;
        CopyMessagesData *data;
        GPtrArray *uids;
@@ -5055,13 +5062,16 @@ imapx_command_copy_messages_step_start (CamelIMAPXServer *is,
 
        g_object_unref (folder);
 
+       dest_mailbox = camel_imapx_folder_ref_mailbox (
+               CAMEL_IMAPX_FOLDER (data->dest));
+
        for (; i < uids->len; i++) {
                gint res;
                const gchar *uid = (gchar *) g_ptr_array_index (uids, i);
 
                res = imapx_uidset_add (&data->uidset, ic, uid);
                if (res == 1) {
-                       camel_imapx_command_add (ic, " %f", data->dest);
+                       camel_imapx_command_add (ic, " %m", dest_mailbox);
                        data->index = i + 1;
                        imapx_command_queue (is, ic);
                        goto exit;
@@ -5070,12 +5080,14 @@ imapx_command_copy_messages_step_start (CamelIMAPXServer *is,
 
        data->index = i;
        if (imapx_uidset_done (&data->uidset, ic)) {
-               camel_imapx_command_add (ic, " %f", data->dest);
+               camel_imapx_command_add (ic, " %m", dest_mailbox);
                imapx_command_queue (is, ic);
                goto exit;
        }
 
 exit:
+       g_object_unref (dest_mailbox);
+
        camel_imapx_command_unref (ic);
 
        return success;
@@ -5195,6 +5207,7 @@ imapx_job_append_message_start (CamelIMAPXJob *job,
                                 GError **error)
 {
        CamelFolder *folder;
+       CamelIMAPXMailbox *mailbox;
        CamelIMAPXCommand *ic;
        AppendMessageData *data;
 
@@ -5204,10 +5217,13 @@ imapx_job_append_message_start (CamelIMAPXJob *job,
        folder = camel_imapx_job_ref_folder (job);
        g_return_val_if_fail (folder != NULL, FALSE);
 
+       mailbox = camel_imapx_folder_ref_mailbox (CAMEL_IMAPX_FOLDER (folder));
+       g_warn_if_fail (mailbox != NULL);
+
        /* TODO: we could supply the original append date from the file timestamp */
        ic = camel_imapx_command_new (
                is, "APPEND", NULL,
-               "APPEND %f %F %P", folder,
+               "APPEND %m %F %P", mailbox,
                ((CamelMessageInfoBase *) data->info)->flags,
                ((CamelMessageInfoBase *) data->info)->user_flags,
                data->path);
@@ -5220,6 +5236,7 @@ imapx_job_append_message_start (CamelIMAPXJob *job,
 
        camel_imapx_command_unref (ic);
 
+       g_object_unref (mailbox);
        g_object_unref (folder);
 
        return TRUE;
@@ -5908,6 +5925,7 @@ imapx_job_fetch_messages_start (CamelIMAPXJob *job,
 {
        CamelIMAPXCommand *ic;
        CamelFolder *folder;
+       CamelIMAPXMailbox *mailbox;
        guint32 total;
        gchar *start_uid = NULL, *end_uid = NULL;
        CamelFetchType ftype;
@@ -5923,6 +5941,9 @@ imapx_job_fetch_messages_start (CamelIMAPXJob *job,
        folder = camel_imapx_job_ref_folder (job);
        g_return_val_if_fail (folder != NULL, FALSE);
 
+       mailbox = camel_imapx_folder_ref_mailbox (CAMEL_IMAPX_FOLDER (folder));
+       g_warn_if_fail (mailbox != NULL);
+
        settings = camel_imapx_server_ref_settings (is);
        fetch_order = camel_imapx_settings_get_fetch_order (settings);
        uidset_size = camel_imapx_settings_get_batch_fetch_count (settings);
@@ -5953,8 +5974,8 @@ imapx_job_fetch_messages_start (CamelIMAPXJob *job,
 
                        /* We need to issue Status command to get the total unread count */
                        ic = camel_imapx_command_new (
-                               is, "STATUS", NULL, "STATUS %f (%t)",
-                               folder, is->priv->status_data_items);
+                               is, "STATUS", NULL, "STATUS %m (%t)",
+                               mailbox, is->priv->status_data_items);
                        camel_imapx_command_set_job (ic, job);
                        ic->pri = job->pri;
 
@@ -6032,6 +6053,7 @@ imapx_job_fetch_messages_start (CamelIMAPXJob *job,
 
        camel_imapx_command_unref (ic);
 
+       g_object_unref (mailbox);
        g_object_unref (folder);
 
        return TRUE;
@@ -6047,6 +6069,7 @@ imapx_job_refresh_info_start (CamelIMAPXJob *job,
        CamelIMAPXSettings *settings;
        CamelIMAPXSummary *isum;
        CamelFolder *folder;
+       CamelIMAPXMailbox *mailbox;
        const gchar *full_name;
        gboolean need_rescan = FALSE;
        gboolean is_selected = FALSE;
@@ -6058,6 +6081,9 @@ imapx_job_refresh_info_start (CamelIMAPXJob *job,
        folder = camel_imapx_job_ref_folder (job);
        g_return_val_if_fail (folder != NULL, FALSE);
 
+       mailbox = camel_imapx_folder_ref_mailbox (CAMEL_IMAPX_FOLDER (folder));
+       g_warn_if_fail (mailbox != NULL);
+
        settings = camel_imapx_server_ref_settings (is);
        mobile_mode = camel_imapx_settings_get_mobile_mode (settings);
        g_object_unref (settings);
@@ -6127,8 +6153,8 @@ imapx_job_refresh_info_start (CamelIMAPXJob *job,
                #endif
                {
                        ic = camel_imapx_command_new (
-                               is, "STATUS", NULL, "STATUS %f (%t)",
-                               folder, is->priv->status_data_items);
+                               is, "STATUS", NULL, "STATUS %m (%t)",
+                               mailbox, is->priv->status_data_items);
 
                        camel_imapx_command_set_job (ic, job);
                        ic->pri = job->pri;
@@ -6158,8 +6184,8 @@ imapx_job_refresh_info_start (CamelIMAPXJob *job,
                CamelIMAPXCommand *ic;
 
                ic = camel_imapx_command_new (
-                       is, "STATUS", NULL, "STATUS %f (%t)",
-                       folder, is->priv->status_data_items);
+                       is, "STATUS", NULL, "STATUS %m (%t)",
+                       mailbox, is->priv->status_data_items);
                camel_imapx_command_set_job (ic, job);
                ic->pri = job->pri;
 
@@ -6254,11 +6280,13 @@ imapx_job_refresh_info_start (CamelIMAPXJob *job,
                }
        }
 
+       g_object_unref (mailbox);
        g_object_unref (folder);
 
        return imapx_job_scan_changes_start (job, is, cancellable, error);
 
 done:
+       g_object_unref (mailbox);
        g_object_unref (folder);
 
        imapx_unregister_job (is, job);


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