From: Carlos Garnacho <carlosg@gnome.org>
Date: Thu, 24 Dec 2020 13:22:43 +0100
Subject: Support Tracker 3.0

Add the compile-time checks, and add the minimal code catering for
the API changes. In 3.0 connections are no longer singletons.

Origin: https://gitlab.gnome.org/GNOME/brasero/-/merge_requests/10
---
 configure.ac                 | 6 +++++-
 src/brasero-search-tracker.c | 8 ++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 69e0f00..3be1258 100644
--- a/configure.ac
+++ b/configure.ac
@@ -388,7 +388,7 @@ AC_ARG_ENABLE(search,
 if test x"$enable_search" != "xno"; then
         # Try to figure out the tracker API version to use
         tracker_api="0.10"
-        m4_foreach([VERSION], [[0.10], [0.12], [0.14], [0.16], [0.18], [1.0], [2.0]],
+        m4_foreach([VERSION], [[0.10], [0.12], [0.14], [0.16], [0.18], [1.0], [2.0], [3.0]],
                               [PKG_CHECK_EXISTS([tracker-sparql-VERSION >= $TRACKER_REQUIRED],
                                                 [tracker_api="VERSION"])
                               ])
@@ -408,6 +408,10 @@ if test x"$enable_search" = "xyes"; then
 	AC_SUBST(BRASERO_SEARCH_LIBS)
 	build_tracker="yes"
 	build_search="yes"
+
+	if test x"$tracker_api" = x"3.0"; then
+		AC_DEFINE(HAVE_TRACKER3, 1, [define if tracker3 is available])
+	fi
 else
 	build_search="no"
 fi
diff --git a/src/brasero-search-tracker.c b/src/brasero-search-tracker.c
index 9aa0628..40c5f1a 100644
--- a/src/brasero-search-tracker.c
+++ b/src/brasero-search-tracker.c
@@ -17,6 +17,8 @@
  * with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "config.h"
+
 #include <stdlib.h>
 
 #include <libtracker-sparql/tracker-sparql.h>
@@ -444,7 +446,13 @@ brasero_search_tracker_init (BraseroSearchTracker *object)
 
 	priv = BRASERO_SEARCH_TRACKER_PRIVATE (object);
 	priv->cancellable = g_cancellable_new ();
+
+#ifdef HAVE_TRACKER3
+	priv->connection = tracker_sparql_connection_bus_new ("org.freedesktop.Tracker3.Miner.Files",
+							      NULL, NULL, &error);
+#else
 	priv->connection = tracker_sparql_connection_get (priv->cancellable, &error);
+#endif
 
 	if (error) {
 		g_warning ("Could not establish a connection to Tracker: %s", error->message);
