[evolution-data-server] camel_imapx_server_list: Pass the LIST pattern verbatim.



commit 207fbc3ea4b0cae2565f2c43d70335cfdba7d573
Author: Matthew Barnes <mbarnes redhat com>
Date:   Tue Aug 27 10:00:10 2013 -0400

    camel_imapx_server_list: Pass the LIST pattern verbatim.
    
    The pattern string passed to camel_imapx_server_list() should already be
    UTF-7 encoded with any desired wildcards.  The pattern string is used in
    the LIST or LSUB command verbatim.

 camel/camel-imapx-server.c |   12 ++----------
 camel/camel-imapx-server.h |    2 +-
 camel/camel-imapx-store.c  |   20 ++++++++------------
 3 files changed, 11 insertions(+), 23 deletions(-)
---
diff --git a/camel/camel-imapx-server.c b/camel/camel-imapx-server.c
index 64abb2c..8f5bbed 100644
--- a/camel/camel-imapx-server.c
+++ b/camel/camel-imapx-server.c
@@ -7910,7 +7910,7 @@ camel_imapx_server_expunge (CamelIMAPXServer *is,
 
 GPtrArray *
 camel_imapx_server_list (CamelIMAPXServer *is,
-                         const gchar *top,
+                         const gchar *pattern,
                          CamelStoreGetFolderInfoFlags flags,
                          const gchar *ext,
                          GCancellable *cancellable,
@@ -7919,11 +7919,9 @@ camel_imapx_server_list (CamelIMAPXServer *is,
        CamelIMAPXJob *job;
        GPtrArray *folders = NULL;
        ListData *data;
-       gchar *encoded_name;
-
-       encoded_name = camel_utf8_utf7 (top);
 
        data = g_slice_new0 (ListData);
+       data->pattern = g_strdup (pattern);
        data->flags = flags;
        data->ext = g_strdup (ext);
        data->folders = g_hash_table_new_full (
@@ -7932,11 +7930,6 @@ camel_imapx_server_list (CamelIMAPXServer *is,
                (GDestroyNotify) g_object_unref,
                (GDestroyNotify) NULL);
 
-       if (flags & CAMEL_STORE_FOLDER_INFO_RECURSIVE)
-               data->pattern = g_strdup_printf ("%s*", encoded_name);
-       else
-               data->pattern = g_strdup (encoded_name);
-
        job = camel_imapx_job_new (cancellable);
        job->type = IMAPX_JOB_LIST;
        job->start = imapx_job_list_start;
@@ -7965,7 +7958,6 @@ camel_imapx_server_list (CamelIMAPXServer *is,
                g_list_free (list);
        }
 
-       g_free (encoded_name);
        camel_imapx_job_unref (job);
 
        return folders;
diff --git a/camel/camel-imapx-server.h b/camel/camel-imapx-server.h
index ce43b14..f21809a 100644
--- a/camel/camel-imapx-server.h
+++ b/camel/camel-imapx-server.h
@@ -173,7 +173,7 @@ CamelAuthenticationResult
                                                 GCancellable *cancellable,
                                                 GError **error);
 GPtrArray *    camel_imapx_server_list         (CamelIMAPXServer *is,
-                                                const gchar *top,
+                                                const gchar *pattern,
                                                 CamelStoreGetFolderInfoFlags flags,
                                                 const gchar *ext,
                                                 GCancellable *cancellable,
diff --git a/camel/camel-imapx-store.c b/camel/camel-imapx-store.c
index bce7033..8994bc4 100644
--- a/camel/camel-imapx-store.c
+++ b/camel/camel-imapx-store.c
@@ -1244,17 +1244,16 @@ fetch_folders_for_namespaces (CamelIMAPXStore *imapx_store,
                        gchar *pat;
 
                        if (pattern != NULL)
-                               pat = g_strdup (pattern);
+                               pat = g_strdup_printf ("%s*", pattern);
                        else if (*ns->prefix != '\0')
                                pat = g_strdup_printf (
-                                       "%s%c", ns->prefix, ns->sep);
+                                       "%s%c*", ns->prefix, ns->sep);
                        else
-                               pat = g_strdup ("");
+                               pat = g_strdup ("*");
 
                        if (sync)
                                flags |= CAMEL_STORE_FOLDER_INFO_SUBSCRIPTION_LIST;
 
-                       flags |= CAMEL_STORE_FOLDER_INFO_RECURSIVE;
                        success = fetch_folders_for_pattern (
                                imapx_store, server, pat, flags, list_ext,
                                folders, cancellable, error);
@@ -1574,7 +1573,7 @@ imapx_store_get_folder_info_sync (CamelStore *store,
        CamelStoreSummary *store_summary;
        gboolean initial_setup = FALSE;
        gboolean use_subscriptions;
-       gchar *pattern;
+       gchar *pattern = NULL;
 
        service = CAMEL_SERVICE (store);
        imapx_store = CAMEL_IMAPX_STORE (store);
@@ -1635,7 +1634,6 @@ imapx_store_get_folder_info_sync (CamelStore *store,
 
        if (*top) {
                gchar *mailbox;
-               gint i;
 
                mailbox = camel_imapx_store_summary_mailbox_from_path (
                        imapx_store->summary, top);
@@ -1643,14 +1641,10 @@ imapx_store_get_folder_info_sync (CamelStore *store,
                        mailbox = camel_imapx_store_summary_path_to_mailbox (
                                imapx_store->summary, top,
                                imapx_store->dir_sep);
-
-               i = strlen (mailbox);
-               pattern = g_alloca (i + 5);
-               strcpy (pattern, mailbox);
+               pattern = camel_utf8_utf7 (mailbox);
                g_free (mailbox);
        } else {
-               pattern = g_alloca (1);
-               pattern[0] = '\0';
+               pattern = g_strdup ("");
        }
 
        if (!sync_folders (imapx_store, pattern, TRUE, cancellable, error))
@@ -1667,6 +1661,8 @@ imapx_store_get_folder_info_sync (CamelStore *store,
 exit:
        g_mutex_unlock (&imapx_store->priv->get_finfo_lock);
 
+       g_free (pattern);
+
        return fi;
 }
 


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