[gnome-notes/wip/carlosg/tracker3: 11/12] Port to Tracker 3



commit ee29a513c841d10ab68c2e2aa1f8741e58ff3797
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Jun 14 23:37:13 2020 +0200

    Port to Tracker 3
    
    Add yet another compile check for it, on top of the older versions.
    Since Tracker3 databases are private by default, force the private_store
    option on if tracker3 is used, and use the new constructor as per 3.x
    API.

 meson.build                         | 21 ++++++++++++++-------
 src/bijiben-shell-search-provider.c | 15 ++++++++++++++-
 src/libbiji/biji-manager.c          | 15 ++++++++++++++-
 3 files changed, 42 insertions(+), 9 deletions(-)
---
diff --git a/meson.build b/meson.build
index d31f260..44a42c7 100644
--- a/meson.build
+++ b/meson.build
@@ -40,9 +40,6 @@ foreach define: set_defines
   config_h.set_quoted(define[0], define[1])
 endforeach
 
-# Tracker
-config_h.set('TRACKER_PRIVATE_STORE', get_option('private_store'))
-
 # compiler flags
 common_flags = [
   '-DHAVE_CONFIG_H',
@@ -99,14 +96,24 @@ libgd = subproject(
 )
 libgd_dep = libgd.get_variable('libgd_dep')
 
-tracker_sparql_dep = dependency('tracker-sparql-2.0', required: false)
+tracker_sparql_dep = dependency('tracker-sparql-3.0', required: false)
+has_tracker3 = tracker_sparql_dep.found()
+config_h.set10('HAVE_TRACKER3', has_tracker3)
+
 if not tracker_sparql_dep.found()
-  tracker_sparql_dep = dependency('tracker-sparql-1.0', required: false)
+  tracker_sparql_dep = dependency('tracker-sparql-2.0', required: false)
   if not tracker_sparql_dep.found()
-    tracker_sparql_dep = dependency('tracker-sparql-0.18', required: true)
+    tracker_sparql_dep = dependency('tracker-sparql-1.0', required: false)
+    if not tracker_sparql_dep.found()
+      tracker_sparql_dep = dependency('tracker-sparql-0.18', required: true)
+    endif
   endif
 endif
 
+# Tracker
+private_store = get_option('private_store') or has_tracker3
+config_h.set('TRACKER_PRIVATE_STORE', private_store)
+
 bijiben_deps = [
   libgd_dep,
   tracker_sparql_dep,
@@ -150,5 +157,5 @@ meson.add_install_script(
 
 output = '  Version:          ' + bijiben_version + '\n'
 output += '  Enable Zeitgeist  ' + enable_zeitgeist.to_string() + '\n'
-output += '  Use Private Store ' + get_option('private_store').to_string() + '\n'
+output += '  Use Private Store ' + private_store.to_string() + ' (Tracker3: ' + has_tracker3.to_string() + 
')\n'
 message(output)
diff --git a/src/bijiben-shell-search-provider.c b/src/bijiben-shell-search-provider.c
index 8e1c737..387b768 100644
--- a/src/bijiben-shell-search-provider.c
+++ b/src/bijiben-shell-search-provider.c
@@ -427,17 +427,30 @@ bijiben_shell_search_provider_app_init (BijibenShellSearchProviderApp *self)
 
   filename = g_build_filename (g_get_user_cache_dir (),
                                g_get_application_name (),
+#if HAVE_TRACKER3
+                               "tracker3",
+#else
                                "tracker",
+#endif /* HAVE_TRACKER3 */
                                NULL);
   data_location = g_file_new_for_path (filename);
 
+#if HAVE_TRACKER3
+  self->connection = tracker_sparql_connection_new (TRACKER_SPARQL_CONNECTION_FLAGS_READONLY,
+                                                    data_location,
+                                                    tracker_sparql_get_ontology_nepomuk (),
+                                                    NULL,
+                                                    &error);
+#else
   self->connection = tracker_sparql_connection_local_new (TRACKER_SPARQL_CONNECTION_FLAGS_READONLY,
                                                           data_location,
                                                           NULL, NULL, NULL,
                                                           &error);
+#endif /* HAVE_TRACKER3 */
+
 #else
   self->connection = tracker_sparql_connection_get (NULL, &error);
-#endif
+#endif /* TRACKER_PRIVATE_STORE */
 
   if (error)
   {
diff --git a/src/libbiji/biji-manager.c b/src/libbiji/biji-manager.c
index e781781..4990937 100644
--- a/src/libbiji/biji-manager.c
+++ b/src/libbiji/biji-manager.c
@@ -224,19 +224,32 @@ biji_manager_initable_init (GInitable *initable,
 
   filename = g_build_filename (g_get_user_cache_dir (),
                                g_get_application_name (),
+#if HAVE_TRACKER3
+                               "tracker3",
+#else
                                "tracker",
+#endif /* HAVE_TRACKER3 */
                                NULL);
   data_location = g_file_new_for_path (filename);
 
   /* If tracker fails for some reason,
    * do not attempt anything */
+#if HAVE_TRACKER3
+  self->connection = tracker_sparql_connection_new (TRACKER_SPARQL_CONNECTION_FLAGS_NONE,
+                                                    data_location,
+                                                    tracker_sparql_get_ontology_nepomuk (),
+                                                    NULL,
+                                                    &local_error);
+#else
   self->connection = tracker_sparql_connection_local_new (TRACKER_SPARQL_CONNECTION_FLAGS_NONE,
                                                           data_location,
                                                           NULL, NULL, NULL,
                                                           &local_error);
+#endif /* HAVE_TRACKER3 */
+
 #else
   self->connection = tracker_sparql_connection_get (NULL, &local_error);
-#endif
+#endif /* TRACKER_PRIVATE_STORE */
 
   if (local_error)
   {


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