[evolution-ews] Fix a build break with glib pre-2.54 and bump libsoup version to 2.58



commit 64a5ff2db277933a7b95f342046052f4b281646f
Author: Milan Crha <mcrha redhat com>
Date:   Wed Nov 14 11:22:49 2018 +0100

    Fix a build break with glib pre-2.54 and bump libsoup version to 2.58
    
    The g_ptr_array_find_with_equal_func() had been added for 2.54, but
    the requirement of glib is set lower. No need to bump it yet, thus
    the function is replaced with a custom code.
    
    Related to https://gitlab.gnome.org/GNOME/evolution-ews/issues/24

 CMakeLists.txt              |  4 ++--
 src/camel/camel-ews-utils.c | 32 +++++++++++++++++++++++++++++---
 2 files changed, 31 insertions(+), 5 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0b914253..314be535 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -26,8 +26,8 @@ set(gdk_minimum_version 3.10)
 set(gdk_encoded_version GDK_VERSION_3_10)
 
 # Keep these two definitions in agreement.
-set(soup_minimum_version 2.42)
-set(soup_encoded_version SOUP_VERSION_2_42)
+set(soup_minimum_version 2.58)
+set(soup_encoded_version SOUP_VERSION_2_58)
 
 # Warn about API usage that violates our minimum requirements.
 add_definitions(-DGLIB_VERSION_MAX_ALLOWED=${glib_encoded_version})
diff --git a/src/camel/camel-ews-utils.c b/src/camel/camel-ews-utils.c
index 4368b184..92db0ceb 100644
--- a/src/camel/camel-ews-utils.c
+++ b/src/camel/camel-ews-utils.c
@@ -1475,6 +1475,32 @@ ews_util_equal_label_tag_cb (gconstpointer ptr1,
        return pos > evo_label_def && pos[-1] == '|' && !pos[strlen (tag)];
 }
 
+static gboolean
+ews_utils_find_in_ptr_array (GPtrArray *haystack,
+                            gconstpointer needle,
+                            GEqualFunc equal_func,
+                            guint *out_index)
+{
+       guint ii;
+
+       if (!haystack)
+               return FALSE;
+
+       if (!equal_func)
+               equal_func = g_direct_equal;
+
+       for (ii = 0; ii < haystack->len; ii++) {
+               if (equal_func (haystack->pdata[ii], needle)) {
+                       if (out_index)
+                               *out_index = ii;
+
+                       return TRUE;
+               }
+       }
+
+       return FALSE;
+}
+
 /* Returns whether had been done any changes */
 static gboolean
 ews_utils_save_category_changes (GHashTable *old_categories, /* gchar *guid ~> CamelEwsCategory * */
@@ -1538,7 +1564,7 @@ ews_utils_save_category_changes (GHashTable *old_categories, /* gchar *guid ~> C
                                gchar *old_tag = camel_ews_utils_encode_category_name (old_cat->name);
 
                                if (old_tag && *old_tag) {
-                                       if (!g_ptr_array_find_with_equal_func (evo_labels, old_tag, 
ews_util_equal_label_tag_cb, &index))
+                                       if (!ews_utils_find_in_ptr_array (evo_labels, old_tag, 
ews_util_equal_label_tag_cb, &index))
                                                index = (guint) -1;
                                }
 
@@ -1551,7 +1577,7 @@ ews_utils_save_category_changes (GHashTable *old_categories, /* gchar *guid ~> C
                        }
 
                        if (index == (guint) -1 &&
-                           !g_ptr_array_find_with_equal_func (evo_labels, tag, ews_util_equal_label_tag_cb, 
&index))
+                           !ews_utils_find_in_ptr_array (evo_labels, tag, ews_util_equal_label_tag_cb, 
&index))
                                index = (guint) -1;
 
                        label_def = g_strconcat (new_cat->name, "|", new_cat->color_def ? new_cat->color_def 
: "#FF0000", "|", tag, NULL);
@@ -1590,7 +1616,7 @@ ews_utils_save_category_changes (GHashTable *old_categories, /* gchar *guid ~> C
                        }
 
                        if (old_tag &&
-                           g_ptr_array_find_with_equal_func (evo_labels, old_tag, 
ews_util_equal_label_tag_cb, &index))
+                           ews_utils_find_in_ptr_array (evo_labels, old_tag, ews_util_equal_label_tag_cb, 
&index))
                                g_ptr_array_remove_index (evo_labels, index);
 
                        g_free (old_tag);


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