[evolution-data-server] evo-I#686 - Broken search folder that includes all mails from other search folders



commit 1c630299a189feb801153dd35a518defb0ef093e
Author: Milan Crha <mcrha redhat com>
Date:   Tue Jan 28 12:46:06 2020 +0100

    evo-I#686 - Broken search folder that includes all mails from other search folders
    
    Closes https://gitlab.gnome.org/GNOME/evolution/issues/686

 src/camel/camel-vee-folder.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
---
diff --git a/src/camel/camel-vee-folder.c b/src/camel/camel-vee-folder.c
index 2d64daa65..e922efbe5 100644
--- a/src/camel/camel-vee-folder.c
+++ b/src/camel/camel-vee-folder.c
@@ -841,6 +841,25 @@ vee_folder_add_subfolder_uids_to_search_matches (CamelVeeDataCache *data_cache,
        }
 }
 
+static const gchar *
+vee_folder_combine_expressions (CamelVeeFolder *vfolder,
+                               const gchar *expression,
+                               gchar **tmp)
+{
+       const gchar *my_expression;
+
+       my_expression = camel_vee_folder_get_expression (vfolder);
+
+       if (!expression || !*expression) {
+               expression = my_expression;
+       } else if (my_expression && *my_expression) {
+               *tmp = g_strconcat ("(and ", expression, " ", my_expression, ")", NULL);
+               expression = *tmp;
+       }
+
+       return expression;
+}
+
 static GPtrArray *
 vee_folder_search_by_expression (CamelFolder *folder,
                                  const gchar *expression,
@@ -851,6 +870,7 @@ vee_folder_search_by_expression (CamelFolder *folder,
        CamelVeeDataCache *data_cache;
        GPtrArray *matches = NULL;
        GList *link;
+       gchar *tmp = NULL;
 
        g_return_val_if_fail (CAMEL_IS_VEE_FOLDER (folder), NULL);
 
@@ -859,6 +879,8 @@ vee_folder_search_by_expression (CamelFolder *folder,
 
        g_rec_mutex_lock (&vfolder->priv->subfolder_lock);
 
+       expression = vee_folder_combine_expressions (vfolder, expression, &tmp);
+
        for (link = vfolder->priv->subfolders; link && !g_cancellable_is_cancelled (cancellable); link = 
g_list_next (link)) {
                CamelFolder *subfolder = link->data;
                GPtrArray *submatches;
@@ -877,6 +899,8 @@ vee_folder_search_by_expression (CamelFolder *folder,
                }
        }
 
+       g_free (tmp);
+
        g_rec_mutex_unlock (&vfolder->priv->subfolder_lock);
 
        if (g_cancellable_set_error_if_cancelled (cancellable, error)) {
@@ -943,6 +967,7 @@ vee_folder_search_by_uids (CamelFolder *folder,
        GPtrArray *matches = NULL;
        GList *link;
        guint ii;
+       gchar *tmp = NULL;
 
        g_return_val_if_fail (CAMEL_IS_VEE_FOLDER (folder), NULL);
 
@@ -973,6 +998,8 @@ vee_folder_search_by_uids (CamelFolder *folder,
 
        g_rec_mutex_lock (&vfolder->priv->subfolder_lock);
 
+       expression = vee_folder_combine_expressions (vfolder, expression, &tmp);
+
        for (link = vfolder->priv->subfolders; link && !g_cancellable_is_cancelled (cancellable); link = 
g_list_next (link)) {
                CamelFolder *subfolder = link->data;
                GPtrArray *submatches, *subuids;
@@ -1005,6 +1032,8 @@ vee_folder_search_by_uids (CamelFolder *folder,
                }
        }
 
+       g_free (tmp);
+
        g_rec_mutex_unlock (&vfolder->priv->subfolder_lock);
 
        if (g_cancellable_set_error_if_cancelled (cancellable, error)) {
@@ -1029,6 +1058,7 @@ vee_folder_count_by_expression (CamelFolder *folder,
 {
        CamelVeeFolder *vfolder;
        GList *link;
+       gchar *tmp = NULL;
        guint32 count = 0;
 
        g_return_val_if_fail (CAMEL_IS_VEE_FOLDER (folder), 0);
@@ -1037,12 +1067,16 @@ vee_folder_count_by_expression (CamelFolder *folder,
 
        g_rec_mutex_lock (&vfolder->priv->subfolder_lock);
 
+       expression = vee_folder_combine_expressions (vfolder, expression, &tmp);
+
        for (link = vfolder->priv->subfolders; link && !g_cancellable_is_cancelled (cancellable); link = 
g_list_next (link)) {
                CamelFolder *subfolder = link->data;
 
                count += camel_folder_count_by_expression (subfolder, expression, cancellable, NULL);
        }
 
+       g_free (tmp);
+
        g_rec_mutex_unlock (&vfolder->priv->subfolder_lock);
 
        if (g_cancellable_set_error_if_cancelled (cancellable, error))


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