[gnome-software/wip/mcrha/soup3: 2/2] misc: Remove conditional code for glib lower than 2.66.0




commit d1d412b83f9a86223c3bdd7e3a6f55476f338813
Author: Milan Crha <mcrha redhat com>
Date:   Tue Nov 16 17:56:51 2021 +0100

    misc: Remove conditional code for glib lower than 2.66.0
    
    Since the code depends on the GLib 2.66.0, all the code built for
    the lower version is not used, thus drop it, and enable unconditionally
    the code which is available in the 2.66.0.

 lib/gnome-software.h           |  1 -
 lib/gs-autocleanups.h          | 52 -------------------------------------
 lib/gs-metered.c               |  4 +--
 lib/gs-odrs-provider.c         | 58 ------------------------------------------
 lib/gs-plugin-loader.c         | 14 ++--------
 lib/gs-test.c                  |  2 --
 lib/gs-utils.h                 | 23 -----------------
 lib/meson.build                |  1 -
 plugins/core/gs-self-test.c    |  2 --
 plugins/dpkg/gs-self-test.c    |  2 --
 plugins/dummy/gs-self-test.c   |  2 --
 plugins/flatpak/gs-self-test.c |  2 --
 plugins/fwupd/gs-self-test.c   |  2 --
 src/gs-common.h                | 17 -------------
 14 files changed, 4 insertions(+), 178 deletions(-)
---
diff --git a/lib/gnome-software.h b/lib/gnome-software.h
index c91516baf..824b9524c 100644
--- a/lib/gnome-software.h
+++ b/lib/gnome-software.h
@@ -15,7 +15,6 @@
 #include <gs-app.h>
 #include <gs-app-list.h>
 #include <gs-app-collation.h>
-#include <gs-autocleanups.h>
 #include <gs-category.h>
 #include <gs-category-manager.h>
 #include <gs-desktop-data.h>
diff --git a/lib/gs-metered.c b/lib/gs-metered.c
index 17c42a087..d4080e97e 100644
--- a/lib/gs-metered.c
+++ b/lib/gs-metered.c
@@ -119,7 +119,7 @@ gs_metered_block_on_download_scheduler (GVariant      *parameters,
        g_autoptr(MwscScheduleEntry) schedule_entry = NULL;
        g_autofree gchar *parameters_str = NULL;
        g_autoptr(GMainContext) context = NULL;
-       g_autoptr(GsMainContextPusher) pusher = NULL;
+       g_autoptr(GMainContextPusher) pusher = NULL;
 
        g_return_val_if_fail (schedule_entry_handle_out != NULL, FALSE);
 
@@ -131,7 +131,7 @@ gs_metered_block_on_download_scheduler (GVariant      *parameters,
 
        /* Push the context early so that the #MwscScheduler is created to run within it. */
        context = g_main_context_new ();
-       pusher = gs_main_context_pusher_new (context);
+       pusher = g_main_context_pusher_new (context);
 
        /* Wait until the download can be scheduled.
         * FIXME: In future, downloads could be split up by app, so they can all
diff --git a/lib/gs-odrs-provider.c b/lib/gs-odrs-provider.c
index 9d34c4efc..7d12722bb 100644
--- a/lib/gs-odrs-provider.c
+++ b/lib/gs-odrs-provider.c
@@ -41,64 +41,6 @@
 #include <math.h>
 #include <string.h>
 
-#if !GLIB_CHECK_VERSION(2, 62, 0)
-typedef struct
-{
-  guint8 *data;
-  guint   len;
-  guint   alloc;
-  guint   elt_size;
-  guint   zero_terminated : 1;
-  guint   clear : 1;
-  gatomicrefcount ref_count;
-  GDestroyNotify clear_func;
-} GRealArray;
-
-static gboolean
-g_array_binary_search (GArray        *array,
-                       gconstpointer  target,
-                       GCompareFunc   compare_func,
-                       guint         *out_match_index)
-{
-  gboolean result = FALSE;
-  GRealArray *_array = (GRealArray *) array;
-  guint left, middle, right;
-  gint val;
-
-  g_return_val_if_fail (_array != NULL, FALSE);
-  g_return_val_if_fail (compare_func != NULL, FALSE);
-
-  if (G_LIKELY(_array->len))
-    {
-      left = 0;
-      right = _array->len - 1;
-
-      while (left <= right)
-        {
-          middle = left + (right - left) / 2;
-
-          val = compare_func (_array->data + (_array->elt_size * middle), target);
-          if (val == 0)
-            {
-              result = TRUE;
-              break;
-            }
-          else if (val < 0)
-            left = middle + 1;
-          else if (/* val > 0 && */ middle > 0)
-            right = middle - 1;
-          else
-            break;  /* element not found */
-        }
-    }
-
-  if (result && out_match_index != NULL)
-    *out_match_index = middle;
-
-  return result;
-}
-#endif  /* glib < 2.62.0 */
-
 /* Element in self->ratings, all allocated in one big block and sorted
  * alphabetically to reduce the number of allocations and fragmentation. */
 typedef struct {
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index b3dadcf8a..1db48d6ca 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -1650,7 +1650,7 @@ gs_plugin_loader_job_get_categories_thread_cb (GTask *task,
        GError *error = NULL;
        GsPluginLoaderHelper *helper = (GsPluginLoaderHelper *) task_data;
        g_autoptr(GMainContext) context = g_main_context_new ();
-       g_autoptr(GsMainContextPusher) pusher = gs_main_context_pusher_new (context);
+       g_autoptr(GMainContextPusher) pusher = g_main_context_pusher_new (context);
        GsCategory * const *categories = NULL;
        gsize n_categories;
 #ifdef HAVE_SYSPROF
@@ -3289,7 +3289,7 @@ gs_plugin_loader_process_thread_cb (GTask *task,
        guint max_results;
        GsAppListSortFunc sort_func;
        g_autoptr(GMainContext) context = g_main_context_new ();
-       g_autoptr(GsMainContextPusher) pusher = gs_main_context_pusher_new (context);
+       g_autoptr(GMainContextPusher) pusher = g_main_context_pusher_new (context);
 #ifdef HAVE_SYSPROF
        gint64 begin_time_nsec G_GNUC_UNUSED = SYSPROF_CAPTURE_CURRENT_TIME;
 #endif
@@ -3702,26 +3702,20 @@ gs_plugin_loader_job_process_async (GsPluginLoader *plugin_loader,
        GsPluginLoaderHelper *helper;
        g_autoptr(GTask) task = NULL;
        g_autoptr(GCancellable) cancellable_job = g_cancellable_new ();
-#if GLIB_CHECK_VERSION(2, 60, 0)
        g_autofree gchar *task_name = NULL;
-#endif
 
        g_return_if_fail (GS_IS_PLUGIN_LOADER (plugin_loader));
        g_return_if_fail (GS_IS_PLUGIN_JOB (plugin_job));
        g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
 
        action = gs_plugin_job_get_action (plugin_job);
-#if GLIB_CHECK_VERSION(2, 60, 0)
        task_name = g_strdup_printf ("%s %s", G_STRFUNC, gs_plugin_action_to_string (action));
-#endif
 
        /* check job has valid action */
        if (action == GS_PLUGIN_ACTION_UNKNOWN) {
                g_autofree gchar *job_str = gs_plugin_job_to_string (plugin_job);
                task = g_task_new (plugin_loader, cancellable_job, callback, user_data);
-#if GLIB_CHECK_VERSION(2, 60, 0)
                g_task_set_name (task, task_name);
-#endif
                g_task_return_new_error (task,
                                         GS_PLUGIN_ERROR,
                                         GS_PLUGIN_ERROR_NOT_SUPPORTED,
@@ -3734,9 +3728,7 @@ gs_plugin_loader_job_process_async (GsPluginLoader *plugin_loader,
                if (remove_app_from_install_queue (plugin_loader, gs_plugin_job_get_app (plugin_job))) {
                        GsAppList *list = gs_plugin_job_get_list (plugin_job);
                        task = g_task_new (plugin_loader, cancellable, callback, user_data);
-#if GLIB_CHECK_VERSION(2, 60, 0)
                        g_task_set_name (task, task_name);
-#endif
                        g_task_return_pointer (task, g_object_ref (list), (GDestroyNotify) g_object_unref);
                        return;
                }
@@ -3794,9 +3786,7 @@ gs_plugin_loader_job_process_async (GsPluginLoader *plugin_loader,
 
        /* check required args */
        task = g_task_new (plugin_loader, cancellable_job, callback, user_data);
-#if GLIB_CHECK_VERSION(2, 60, 0)
        g_task_set_name (task, task_name);
-#endif
 
        switch (action) {
        case GS_PLUGIN_ACTION_SEARCH:
diff --git a/lib/gs-test.c b/lib/gs-test.c
index 2b7d54743..7abb55e91 100644
--- a/lib/gs-test.c
+++ b/lib/gs-test.c
@@ -32,9 +32,7 @@ gs_test_init (gint *pargc,
        g_settings_set_string (settings, "review-server", "");
 
        g_test_init (pargc, pargv,
-#if GLIB_CHECK_VERSION(2, 60, 0)
                     G_TEST_OPTION_ISOLATE_DIRS,
-#endif
                     NULL);
 
        /* only critical and error are fatal */
diff --git a/lib/gs-utils.h b/lib/gs-utils.h
index d83d79938..38fcf7dbc 100644
--- a/lib/gs-utils.h
+++ b/lib/gs-utils.h
@@ -134,27 +134,4 @@ gboolean    gs_utils_set_file_etag         (const gchar            *filename,
                                                 const gchar            *etag,
                                                 GCancellable           *cancellable);
 
-#if !GLIB_CHECK_VERSION(2, 64, 0)
-typedef void GsMainContextPusher;
-
-static inline GsMainContextPusher *
-gs_main_context_pusher_new (GMainContext *main_context)
-{
-  g_main_context_push_thread_default (main_context);
-  return (GsMainContextPusher *) main_context;
-}
-
-static inline void
-gs_main_context_pusher_free (GsMainContextPusher *pusher)
-{
-  g_main_context_pop_thread_default ((GMainContext *) pusher);
-}
-
-G_DEFINE_AUTOPTR_CLEANUP_FUNC (GsMainContextPusher, gs_main_context_pusher_free)
-#else
-#define GsMainContextPusher GMainContextPusher
-#define gs_main_context_pusher_new g_main_context_pusher_new
-#define gs_main_context_pusher_free g_main_context_pusher_free
-#endif
-
 G_END_DECLS
diff --git a/lib/meson.build b/lib/meson.build
index c11cfb059..64ae55438 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -7,7 +7,6 @@ libgnomesoftware_public_headers = [
   'gs-app-collation.h',
   'gs-app-list.h',
   'gs-appstream.h',
-  'gs-autocleanups.h',
   'gs-category.h',
   'gs-category-manager.h',
   'gs-desktop-data.h',
diff --git a/plugins/core/gs-self-test.c b/plugins/core/gs-self-test.c
index 63204a373..7114fd01a 100644
--- a/plugins/core/gs-self-test.c
+++ b/plugins/core/gs-self-test.c
@@ -204,9 +204,7 @@ main (int argc, char **argv)
        /* While we use %G_TEST_OPTION_ISOLATE_DIRS to create temporary directories
         * for each of the tests, we want to use the system MIME registry, assuming
         * that it exists and correctly has shared-mime-info installed. */
-#if GLIB_CHECK_VERSION(2, 60, 0)
        g_content_type_set_mime_dirs (NULL);
-#endif
 
        /* Similarly, add the system-wide icon theme path before it’s
         * overwritten by %G_TEST_OPTION_ISOLATE_DIRS. */
diff --git a/plugins/dpkg/gs-self-test.c b/plugins/dpkg/gs-self-test.c
index 09c7971b8..0c09b3048 100644
--- a/plugins/dpkg/gs-self-test.c
+++ b/plugins/dpkg/gs-self-test.c
@@ -63,9 +63,7 @@ main (int argc, char **argv)
        /* While we use %G_TEST_OPTION_ISOLATE_DIRS to create temporary directories
         * for each of the tests, we want to use the system MIME registry, assuming
         * that it exists and correctly has shared-mime-info installed. */
-#if GLIB_CHECK_VERSION(2, 60, 0)
        g_content_type_set_mime_dirs (NULL);
-#endif
 
        gs_test_init (&argc, &argv);
 
diff --git a/plugins/dummy/gs-self-test.c b/plugins/dummy/gs-self-test.c
index 92d054f1e..34727acbd 100644
--- a/plugins/dummy/gs-self-test.c
+++ b/plugins/dummy/gs-self-test.c
@@ -738,9 +738,7 @@ main (int argc, char **argv)
        /* While we use %G_TEST_OPTION_ISOLATE_DIRS to create temporary directories
         * for each of the tests, we want to use the system MIME registry, assuming
         * that it exists and correctly has shared-mime-info installed. */
-#if GLIB_CHECK_VERSION(2, 60, 0)
        g_content_type_set_mime_dirs (NULL);
-#endif
 
        /* Force the GTK resources to be registered, needed for fallback icons. */
        gtk_init_check ();
diff --git a/plugins/flatpak/gs-self-test.c b/plugins/flatpak/gs-self-test.c
index 13e2bb7b4..d83d15fa8 100644
--- a/plugins/flatpak/gs-self-test.c
+++ b/plugins/flatpak/gs-self-test.c
@@ -1902,9 +1902,7 @@ main (int argc, char **argv)
        /* While we use %G_TEST_OPTION_ISOLATE_DIRS to create temporary directories
         * for each of the tests, we want to use the system MIME registry, assuming
         * that it exists and correctly has shared-mime-info installed. */
-#if GLIB_CHECK_VERSION(2, 60, 0)
        g_content_type_set_mime_dirs (NULL);
-#endif
 
        /* Similarly, add the system-wide icon theme path before it’s
         * overwritten by %G_TEST_OPTION_ISOLATE_DIRS. */
diff --git a/plugins/fwupd/gs-self-test.c b/plugins/fwupd/gs-self-test.c
index f5f222b6c..018b4afd7 100644
--- a/plugins/fwupd/gs-self-test.c
+++ b/plugins/fwupd/gs-self-test.c
@@ -71,9 +71,7 @@ main (int argc, char **argv)
        /* While we use %G_TEST_OPTION_ISOLATE_DIRS to create temporary directories
         * for each of the tests, we want to use the system MIME registry, assuming
         * that it exists and correctly has shared-mime-info installed. */
-#if GLIB_CHECK_VERSION(2, 60, 0)
        g_content_type_set_mime_dirs (NULL);
-#endif
 
        gs_test_init (&argc, &argv);
 
diff --git a/src/gs-common.h b/src/gs-common.h
index 0a19daab6..7863ec3f6 100644
--- a/src/gs-common.h
+++ b/src/gs-common.h
@@ -60,21 +60,4 @@ gboolean     gs_utils_split_time_difference  (gint64 unix_time_seconds,
                                                 gint *out_months_ago,
                                                 gint *out_years_ago);
 
-#if !GLIB_CHECK_VERSION(2, 62, 0)
-
-#define  g_clear_signal_handler(handler_id_ptr, instance)           \
-  G_STMT_START {                                                    \
-    gpointer const _instance      = (instance);                     \
-    gulong *const _handler_id_ptr = (handler_id_ptr);               \
-    const gulong _handler_id      = *_handler_id_ptr;               \
-                                                                    \
-    if (_handler_id > 0)                                            \
-      {                                                             \
-        *_handler_id_ptr = 0;                                       \
-        g_signal_handler_disconnect (_instance, _handler_id);       \
-      }                                                             \
-  } G_STMT_END                                                      \
-
-#endif
-
 G_END_DECLS


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