[tracker-miners/sam/upower: 1/2] Require upower and remove HAL power management backend



commit e71c397172ce41c13135f9feb119c1a5a4531a65
Author: Sam Thursfield <sam afuera me uk>
Date:   Wed May 20 21:09:13 2020 +0200

    Require upower and remove HAL power management backend
    
    upower superceded HAL about 10 years ago. It's now standard, we
    don't need to maintain extra code for the no-upower case any more.

 config-miners.h.meson.in             |   6 -
 meson.build                          |  38 +--
 src/miners/fs/meson.build            |  12 +-
 src/miners/fs/tracker-miner-files.c  |  25 +-
 src/miners/fs/tracker-power-hal.c    | 549 -----------------------------------
 src/miners/fs/tracker-power-upower.c |   4 -
 6 files changed, 5 insertions(+), 629 deletions(-)
---
diff --git a/config-miners.h.meson.in b/config-miners.h.meson.in
index 79fd4c17e..4caa01905 100644
--- a/config-miners.h.meson.in
+++ b/config-miners.h.meson.in
@@ -29,9 +29,6 @@
 /* Define if we have GStreamer */
 #mesondefine HAVE_GSTREAMER
 
-/* Define if we have HAL */
-#mesondefine HAVE_HAL
-
 /* Define if we have libcue */
 #mesondefine HAVE_LIBCUE
 
@@ -62,9 +59,6 @@
 /* Define to 1 if you have the `strnlen' function. */
 #mesondefine HAVE_STRNLEN
 
-/* Define if we have UPOWER */
-#mesondefine HAVE_UPOWER
-
 /* Define to 1 if you have the `up_client_get_on_low_battery' function. */
 #mesondefine HAVE_UP_CLIENT_GET_ON_LOW_BATTERY
 
diff --git a/meson.build b/meson.build
index 89e1e24bb..d55194c5a 100644
--- a/meson.build
+++ b/meson.build
@@ -84,7 +84,7 @@ libxml2 = dependency('libxml-2.0', version: '>= 2.6', required: get_option('xml'
 libvorbis = dependency('vorbisfile', version: '>= 0.22', required: get_option('vorbis'))
 poppler = dependency('poppler-glib', version: '>= 0.16.0', required: get_option('pdf'))
 totem_plparser = dependency('totem-plparser', required: get_option('playlist'))
-upower = dependency('upower-glib', version: '>= 0.9.0', required: false)
+upower = dependency('upower-glib', version: '>= 0.9.0')
 zlib = dependency('zlib')
 
 libgif = cc.find_library('gif', required: get_option('gif'))
@@ -134,39 +134,6 @@ endif
 
 add_project_arguments(debug_cflags, language: 'c')
 
-##################################################################
-# Check for libtracker-common: battery/mains power detection
-#
-# By default, AUTO with this order of preference:
-#  1)  upower
-#  2)  hal
-##################################################################
-
-have_hal = false
-battery_detection_library_name = ''
-
-if upower.found()
-  if get_option('battery_detection') == 'auto' or get_option('battery_detection') == 'upower'
-    battery_detection_library = upower
-    battery_detection_library_name = 'upower'
-  endif
-elif get_option('battery_detection') == 'upower'
-  error('upower explicitly requested, but upower library was not found')
-endif
-
-if battery_detection_library_name == ''
-  hal = dependency('hal', version: '>= 0.5', required: false)
-
-  if hal.found()
-    battery_detection_library = hal
-    battery_detection_library_name = 'hal'
-  elif get_option('battery_detection') == 'hal'
-    error('HAL explicitly requested, but not found')
-  else
-    battery_detection_library_name = '(none)'
-  endif
-endif
-
 ####################################################################
 # This section is for tracker-extract dependencies
 ####################################################################
@@ -337,14 +304,12 @@ conf.set('HAVE_EXEMPI', exempi.found())
 conf.set('HAVE_GSTREAMER', generic_media_handler_name == 'gstreamer')
 conf.set('GSTREAMER_BACKEND_DISCOVERER', gstreamer_backend_name == 'Discoverer')
 conf.set('GSTREAMER_BACKEND_GUPNP_DLNA', gstreamer_backend_name == 'GUPnP-DLNA')
-conf.set('HAVE_HAL', battery_detection_library_name == 'hal')
 conf.set('HAVE_LIBCUE', libcue.found())
 conf.set('HAVE_LIBCUE2', libcue.found() and libcue.version().version_compare('>= 2.0.0'))
 conf.set('HAVE_LIBICU_CHARSET_DETECTION', charset_library_name == 'icu')
 conf.set('HAVE_LIBEXIF', libexif.found())
 conf.set('HAVE_LIBIPTCDATA', libiptcdata.found())
 conf.set('HAVE_LIBSECCOMP', libseccomp.found())
-conf.set('HAVE_UPOWER', battery_detection_library_name == 'upower')
 conf.set('HAVE_NETWORK_MANAGER', have_network_manager)
 
 conf.set('HAVE_GETLINE', cc.has_function('getline', prefix : '#include <stdio.h>'))
@@ -452,7 +417,6 @@ summary = [
   '    Source code location:                   ' + meson.source_root(),
   '    Compiler:                               ' + cc.get_id(),
   '\nFeature Support:',
-  '    Battery/mains power detection:          ' + battery_detection_library_name,
   '    Support for network status detection:   ' + have_network_manager.to_string(),
   '\nData Miners / Writebacks:',
   '    FS (File System):                       ' + have_tracker_miner_fs.to_string(),
diff --git a/src/miners/fs/meson.build b/src/miners/fs/meson.build
index e117f9968..ad9ea6c6b 100644
--- a/src/miners/fs/meson.build
+++ b/src/miners/fs/meson.build
@@ -5,6 +5,7 @@ sources = [
     'tracker-miner-files.c',
     'tracker-miner-files-index.c',
     'tracker-miner-files-peer-listener.c',
+    'tracker-power-upower.c',
     'tracker-storage.c',
     'tracker-writeback-listener.c',
     'tracker-writeback-dispatcher.c',
@@ -14,17 +15,10 @@ sources = [
 tracker_miner_fs_deps = [
      tracker_miner,
      tracker_miners_common_dep,
-     tracker_extract_dep
+     tracker_extract_dep,
+     upower,
 ]
 
-if battery_detection_library_name == 'upower'
-  sources += 'tracker-power-upower.c'
-  tracker_miner_fs_deps += upower
-elif battery_detection_library_name == 'hal'
-  sources += 'tracker-power-hal.c'
-  tracker_miner_fs_deps += hal
-endif
-
 executable('tracker-miner-fs-@0@'.format(tracker_api_major),
     sources,
     dependencies: tracker_miner_fs_deps,
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index 316aa8f74..e21fc4a49 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -94,9 +94,7 @@ struct TrackerMinerFilesPrivate {
 
        gboolean low_battery_pause;
 
-#if defined(HAVE_UPOWER) || defined(HAVE_HAL)
        TrackerPower *power;
-#endif /* defined(HAVE_UPOWER) || defined(HAVE_HAL) */
        gulong finished_handler;
 
        GDBusConnection *connection;
@@ -169,7 +167,6 @@ static void        mount_point_removed_cb               (TrackerStorage       *s
                                                          const gchar          *uuid,
                                                          const gchar          *mount_point,
                                                          gpointer              user_data);
-#if defined(HAVE_UPOWER) || defined(HAVE_HAL)
 static void        check_battery_status                 (TrackerMinerFiles    *fs);
 static void        battery_status_cb                    (GObject              *object,
                                                          GParamSpec           *pspec,
@@ -177,7 +174,6 @@ static void        battery_status_cb                    (GObject              *o
 static void        index_on_battery_cb                  (GObject    *object,
                                                          GParamSpec *pspec,
                                                          gpointer    user_data);
-#endif /* defined(HAVE_UPOWER) || defined(HAVE_HAL) */
 static void        init_mount_points                    (TrackerMinerFiles    *miner);
 static void        init_stale_volume_removal            (TrackerMinerFiles    *miner);
 static void        disk_space_check_start               (TrackerMinerFiles    *mf);
@@ -489,7 +485,6 @@ tracker_miner_files_init (TrackerMinerFiles *mf)
                          G_CALLBACK (mount_point_removed_cb),
                          mf);
 
-#if defined(HAVE_UPOWER) || defined(HAVE_HAL)
        priv->power = tracker_power_new ();
 
        if (priv->power) {
@@ -500,7 +495,6 @@ tracker_miner_files_init (TrackerMinerFiles *mf)
                                  G_CALLBACK (battery_status_cb),
                                  mf);
        }
-#endif /* defined(HAVE_UPOWER) || defined(HAVE_HAL) */
 
        priv->finished_handler = g_signal_connect_after (mf, "finished",
                                                         G_CALLBACK (miner_finished_cb),
@@ -632,9 +626,7 @@ miner_files_initable_init (GInitable     *initable,
                mounts = g_slist_concat (mounts, m);
        }
 
-#if defined(HAVE_UPOWER) || defined(HAVE_HAL)
        check_battery_status (mf);
-#endif /* defined(HAVE_UPOWER) || defined(HAVE_HAL) */
 
        TRACKER_NOTE (CONFIG, g_message ("Setting up directories to iterate from config 
(IndexSingleDirectory)"));
 
@@ -808,9 +800,6 @@ miner_files_initable_init (GInitable     *initable,
        g_signal_connect (mf->private->config, "notify::removable-days-threshold",
                          G_CALLBACK (index_volumes_changed_cb),
                          mf);
-
-#if defined(HAVE_UPOWER) || defined(HAVE_HAL)
-
        g_signal_connect (mf->private->config, "notify::index-on-battery",
                          G_CALLBACK (index_on_battery_cb),
                          mf);
@@ -818,8 +807,6 @@ miner_files_initable_init (GInitable     *initable,
                          G_CALLBACK (index_on_battery_cb),
                          mf);
 
-#endif /* defined(HAVE_UPOWER) || defined(HAVE_HAL) */
-
        g_slist_foreach (mounts, (GFunc) g_free, NULL);
        g_slist_free (mounts);
 
@@ -921,11 +908,7 @@ miner_files_finalize (GObject *object)
                g_slist_free (priv->index_single_directories);
        }
 
-#if defined(HAVE_UPOWER) || defined(HAVE_HAL)
-       if (priv->power) {
-               g_object_unref (priv->power);
-       }
-#endif /* defined(HAVE_UPOWER) || defined(HAVE_HAL) */
+       g_clear_object (&priv->power);
 
        tracker_domain_ontology_unref (priv->domain_ontology);
 
@@ -1589,8 +1572,6 @@ mount_point_added_cb (TrackerStorage *storage,
        g_free (urn);
 }
 
-#if defined(HAVE_UPOWER) || defined(HAVE_HAL)
-
 static void
 set_up_throttle (TrackerMinerFiles *mf,
                  gboolean           enable)
@@ -1693,8 +1674,6 @@ index_on_battery_cb (GObject    *object,
        check_battery_status (mf);
 }
 
-#endif /* defined(HAVE_UPOWER) || defined(HAVE_HAL) */
-
 /* Called when mining has finished the first time */
 static void
 miner_finished_cb (TrackerMinerFS *fs,
@@ -1719,9 +1698,7 @@ miner_finished_cb (TrackerMinerFS *fs,
                mf->private->finished_handler = 0;
        }
 
-#if defined(HAVE_UPOWER) || defined(HAVE_HAL)
        check_battery_status (mf);
-#endif /* defined(HAVE_UPOWER) || defined(HAVE_HAL) */
 }
 
 static void
diff --git a/src/miners/fs/tracker-power-upower.c b/src/miners/fs/tracker-power-upower.c
index fbc130b48..3a99f0895 100644
--- a/src/miners/fs/tracker-power-upower.c
+++ b/src/miners/fs/tracker-power-upower.c
@@ -20,8 +20,6 @@
 
 #include "config-miners.h"
 
-#ifdef HAVE_UPOWER
-
 #include <upower.h>
 
 #include "tracker-power.h"
@@ -292,5 +290,3 @@ tracker_power_get_on_low_battery (TrackerPower *power)
 
        return priv->on_low_battery;
 }
-
-#endif /* HAVE_UPOWER */


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