[gnome-photos/sam/tracker3] WIP: Port to Tracker 3



commit 077d2e1564d752cdc7244904b1c271c7ce5e7b04
Author: Sam Thursfield <sam afuera me uk>
Date:   Sat May 23 13:36:25 2020 +0200

    WIP: Port to Tracker 3

 meson.build                            |  3 +--
 src/meson.build                        |  1 -
 src/photos-application.c               | 26 ++++++++----------
 src/photos-indexing-notification.c     | 18 +++++++++----
 src/photos-item-manager.c              |  6 ++---
 src/photos-tracker-import-controller.c | 48 +++-------------------------------
 src/photos-tracker-queue.c             |  3 ++-
 7 files changed, 34 insertions(+), 71 deletions(-)
---
diff --git a/meson.build b/meson.build
index 567ad517..227f6192 100644
--- a/meson.build
+++ b/meson.build
@@ -172,8 +172,7 @@ libgdata_dep = dependency('libgdata', version: '>= 0.15.2')
 libgfgraph_dep = dependency('libgfbgraph-0.2', version: '>= 0.2.1')
 libjpeg_dep = dependency('libjpeg')
 libpng_dep = dependency('libpng16')
-tracker_control_dep = dependency('tracker-control-2.0')
-tracker_sparql_dep = dependency('tracker-sparql-2.0')
+tracker_sparql_dep = dependency('tracker-sparql-3.0')
 
 dbus_dep = dependency('dbus-1')
 dbus_service_dir = dbus_dep.get_pkgconfig_variable(
diff --git a/src/meson.build b/src/meson.build
index 1b29d045..7f9da99b 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -395,7 +395,6 @@ deps = common_deps + [
   libgdata_dep,
   libgfgraph_dep,
   m_dep,
-  tracker_control_dep,
   tracker_sparql_dep,
 ]
 
diff --git a/src/photos-application.c b/src/photos-application.c
index cb114fda..9d6b900c 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -36,7 +36,6 @@
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <grilo.h>
-#include <libtracker-control/tracker-control.h>
 
 #include "photos-application.h"
 #include "photos-base-item.h"
@@ -195,7 +194,7 @@ struct _PhotosApplicationImportData
   GFile *import_sub_dir;
   GList *files;
   PhotosBaseItem *collection;
-  TrackerMinerManager *manager;
+  void *manager;  /* FIXME */
   gchar *collection_urn;
   gint64 ctime_latest;
 };
@@ -248,7 +247,7 @@ photos_application_create_data_free (PhotosApplicationCreateData *data)
 
 static PhotosApplicationImportData *
 photos_application_import_data_new (PhotosApplication *application,
-                                    TrackerMinerManager *manager,
+                                    void *manager,
                                     GList *files,
                                     gint64 ctime_latest)
 {
@@ -1117,10 +1116,11 @@ photos_application_import_index_file (GObject *source_object, GAsyncResult *res,
 {
   PhotosApplication *self;
   g_autoptr (GFile) file = G_FILE (user_data);
-  TrackerMinerManager *manager = TRACKER_MINER_MANAGER (source_object);
+  /*TrackerMinerManager *manager = TRACKER_MINER_MANAGER (source_object);*/
 
   self = PHOTOS_APPLICATION (g_application_get_default ());
 
+#if 0
   {
     g_autoptr (GError) error = NULL;
 
@@ -1132,6 +1132,7 @@ photos_application_import_index_file (GObject *source_object, GAsyncResult *res,
         g_warning ("Unable to index %s: %s", uri, error->message);
       }
   }
+#endif
 
   g_application_unmark_busy (G_APPLICATION (self));
   g_application_release (G_APPLICATION (self));
@@ -1323,7 +1324,6 @@ photos_application_import_file_copy (GObject *source_object, GAsyncResult *res,
   PhotosApplication *self = data->application;
   g_autoptr (GFile) destination = NULL;
   GFile *source = G_FILE (source_object);
-  TrackerMinerManager *manager = data->manager;
 
   {
     g_autoptr (GError) error = NULL;
@@ -1364,11 +1364,13 @@ photos_application_import_file_copy (GObject *source_object, GAsyncResult *res,
 
       g_application_hold (G_APPLICATION (self));
       g_application_mark_busy (G_APPLICATION (self));
+#if 0
       tracker_miner_manager_index_file_for_process_async (manager,
                                                           destination,
                                                           NULL,
                                                           photos_application_import_index_file,
                                                           g_object_ref (destination));
+#endif
     }
 
  out:
@@ -1519,7 +1521,6 @@ photos_application_import (PhotosApplication *self)
   GtkWidget *dialog;
   g_autoptr (PhotosApplicationImportData) data = NULL;
   PhotosSource *source;
-  TrackerMinerManager *manager = NULL; /* TODO: use g_autoptr */
   gint64 ctime_latest = -1;
 
   source = PHOTOS_SOURCE (photos_base_manager_get_active_object (self->state->src_mngr));
@@ -1536,13 +1537,9 @@ photos_application_import (PhotosApplication *self)
   {
     g_autoptr (GError) error = NULL;
 
-    manager = tracker_miner_manager_new_full (FALSE, &error);
-    if (error != NULL)
-      {
-        g_warning ("Unable to create a TrackerMinerManager, importing from attached devices won't work: %s",
-                   error->message);
-        goto out;
-      }
+    g_warning ("Unable to create a TrackerMinerManager, importing from attached devices won't work: %s",
+               error->message);
+    goto out;
   }
 
   for (l = selection; l != NULL; l = l->next)
@@ -1572,14 +1569,13 @@ photos_application_import (PhotosApplication *self)
   dialog = photos_import_dialog_new (GTK_WINDOW (self->main_window), ctime_latest);
   gtk_widget_show_all (dialog);
 
-  data = photos_application_import_data_new (self, manager, files, ctime_latest);
+  data = photos_application_import_data_new (self, NULL, files, ctime_latest);
   g_signal_connect (dialog,
                     "response",
                     G_CALLBACK (photos_application_import_response),
                     g_steal_pointer (&data));
 
  out:
-  g_clear_object (&manager);
   g_list_free_full (files, g_object_unref);
 }
 
diff --git a/src/photos-indexing-notification.c b/src/photos-indexing-notification.c
index 7b2ea7dd..566a1d98 100644
--- a/src/photos-indexing-notification.c
+++ b/src/photos-indexing-notification.c
@@ -26,7 +26,6 @@
 #include <gio/gio.h>
 #include <glib.h>
 #include <glib/gi18n.h>
-#include <libtracker-control/tracker-control.h>
 
 #include "photos-application.h"
 #include "photos-gom-miner.h"
@@ -41,7 +40,6 @@ struct _PhotosIndexingNotification
   GtkWidget *primary_label;
   GtkWidget *secondary_label;
   GtkWidget *spinner;
-  TrackerMinerManager *manager;
   gboolean closed;
   gboolean on_display;
   guint timeout_id;
@@ -181,6 +179,10 @@ photos_indexing_notification_check_notification (PhotosIndexingNotification *sel
   gboolean is_indexing_local = FALSE;
   gboolean is_indexing_remote = FALSE;
 
+  /* FIXME: since the tracker-control helper library is gone in tracker-3.0, we need a way to
+   * query the status of miners by calling the D-Bus API directly.
+   */
+#if 0
   running = tracker_miner_manager_get_running (self->manager);
   if (g_slist_find_custom (running, (gconstpointer) MINER_FILES, (GCompareFunc) g_strcmp0) != NULL)
     {
@@ -211,6 +213,7 @@ photos_indexing_notification_check_notification (PhotosIndexingNotification *sel
     photos_indexing_notification_destroy (self, FALSE);
 
   g_slist_free_full (running, g_free);
+#endif
 }
 
 
@@ -222,7 +225,6 @@ photos_indexing_notification_dispose (GObject *object)
   photos_indexing_notification_remove_timeout (self);
 
   g_clear_object (&self->ntfctn_mngr);
-  g_clear_object (&self->manager);
 
   G_OBJECT_CLASS (photos_indexing_notification_parent_class)->dispose (object);
 }
@@ -242,13 +244,17 @@ photos_indexing_notification_init (PhotosIndexingNotification *self)
   {
     g_autoptr (GError) error = NULL;
 
+/* FIXME */
+#if 0
     self->manager = tracker_miner_manager_new_full (FALSE, &error);
     if (error != NULL)
       {
-        g_warning ("Unable to create a TrackerMinerManager, indexing progress notification won't work: %s",
-                   error->message);
+#endif
+        g_warning ("Unable to create a TrackerMinerManager, indexing progress notification won't work");
         return;
+#if 0
       }
+#endif
   }
 
   self->ntfctn_mngr = photos_notification_manager_dup_singleton ();
@@ -287,6 +293,7 @@ photos_indexing_notification_init (PhotosIndexingNotification *self)
   gtk_container_add (GTK_CONTAINER (self), close);
   g_signal_connect_swapped (close, "clicked", G_CALLBACK (photos_indexing_notification_close_clicked), self);
 
+#if 0
   g_signal_connect_object (app,
                            "miners-changed",
                            G_CALLBACK (photos_indexing_notification_check_notification),
@@ -297,6 +304,7 @@ photos_indexing_notification_init (PhotosIndexingNotification *self)
                             "miner-progress",
                             G_CALLBACK (photos_indexing_notification_check_notification),
                             self);
+#endif
 }
 
 
diff --git a/src/photos-item-manager.c b/src/photos-item-manager.c
index c44fbbfc..74ac4a6c 100644
--- a/src/photos-item-manager.c
+++ b/src/photos-item-manager.c
@@ -311,7 +311,7 @@ photos_item_manager_add_cursor_for_mode (PhotosItemManager *self,
   g_return_if_fail (base_item_type == G_TYPE_NONE
                     || (base_item_type != PHOTOS_TYPE_BASE_ITEM
                         && g_type_is_a (base_item_type, PHOTOS_TYPE_BASE_ITEM)));
-  g_return_if_fail (TRACKER_SPARQL_IS_CURSOR (cursor));
+  g_return_if_fail (TRACKER_IS_SPARQL_CURSOR (cursor));
   g_return_if_fail (mode != PHOTOS_WINDOW_MODE_NONE);
   g_return_if_fail (mode != PHOTOS_WINDOW_MODE_EDIT);
   g_return_if_fail (mode != PHOTOS_WINDOW_MODE_PREVIEW);
@@ -1241,7 +1241,7 @@ photos_item_manager_add_item (PhotosItemManager *self,
   g_return_if_fail (base_item_type == G_TYPE_NONE
                     || (base_item_type != PHOTOS_TYPE_BASE_ITEM
                         && g_type_is_a (base_item_type, PHOTOS_TYPE_BASE_ITEM)));
-  g_return_if_fail (TRACKER_SPARQL_IS_CURSOR (cursor));
+  g_return_if_fail (TRACKER_IS_SPARQL_CURSOR (cursor));
 
   id = tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_URN, NULL);
   g_return_if_fail (id != NULL && id[0] != '\0');
@@ -1370,7 +1370,7 @@ photos_item_manager_create_item (PhotosItemManager *self,
   g_return_val_if_fail (base_item_type == G_TYPE_NONE
                         || (base_item_type != PHOTOS_TYPE_BASE_ITEM
                             && g_type_is_a (base_item_type, PHOTOS_TYPE_BASE_ITEM)), NULL);
-  g_return_val_if_fail (TRACKER_SPARQL_IS_CURSOR (cursor), NULL);
+  g_return_val_if_fail (TRACKER_IS_SPARQL_CURSOR (cursor), NULL);
 
   id = tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_URN, NULL);
   item = PHOTOS_BASE_ITEM (photos_base_manager_get_object_by_id (PHOTOS_BASE_MANAGER (self), id));
diff --git a/src/photos-tracker-import-controller.c b/src/photos-tracker-import-controller.c
index 085ace3a..128b1d88 100644
--- a/src/photos-tracker-import-controller.c
+++ b/src/photos-tracker-import-controller.c
@@ -24,7 +24,6 @@
 #include "config.h"
 
 #include <gio/gio.h>
-#include <libtracker-control/tracker-control.h>
 
 #include "photos-base-manager.h"
 #include "photos-debug.h"
@@ -45,7 +44,6 @@ struct _PhotosTrackerImportController
   PhotosBaseManager *item_mngr;
   PhotosBaseManager *src_mngr;
   PhotosOffsetController *offset_cntrlr;
-  TrackerMinerManager *manager;
 };
 
 
@@ -76,22 +74,11 @@ static void
 photos_tracker_import_controller_index (GObject *source_object, GAsyncResult *res, gpointer user_data)
 {
   g_autoptr (GFile) file = G_FILE (user_data);
-  TrackerMinerManager *manager = TRACKER_MINER_MANAGER (source_object);
 
-  {
-    g_autoptr (GError) error = NULL;
-
-    if (!tracker_miner_manager_index_file_for_process_finish (manager, res, &error))
-      {
-        if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
-          {
             g_autofree gchar *uri = NULL;
 
             uri = g_file_get_uri (file);
-            g_warning ("Unable to index %s: %s", uri, error->message);
-          }
-      }
-  }
+            g_warning ("Unable to index %s", uri);
 }
 
 
@@ -180,6 +167,7 @@ photos_tracker_import_controller_next_files (GObject *source_object, GAsyncResul
                 guint i;
                 guint n_elements;
 
+#if 0
                 mime_type = g_file_info_get_content_type (info);
                 n_elements = G_N_ELEMENTS (IMPORTABLE_MIME_TYPES);
                 for (i = 0; i < n_elements && !indexing; i++)
@@ -197,6 +185,7 @@ photos_tracker_import_controller_next_files (GObject *source_object, GAsyncResul
                   }
 
                 photos_debug (PHOTOS_DEBUG_IMPORT, "%s device file %s", indexing ? "Indexing" : "Skipped", 
uri);
+#endif
                 break;
               }
 
@@ -291,28 +280,6 @@ photos_tracker_import_controller_source_active_changed (PhotosTrackerImportContr
     {
       g_return_if_fail (g_queue_is_empty (self->pending_directories));
 
-      if (G_LIKELY (self->manager != NULL))
-        {
-          g_autoptr (GFile) root = NULL;
-          g_autofree gchar *uri = NULL;
-
-          root = g_mount_get_root (mount);
-          g_queue_push_tail (self->pending_directories, g_object_ref (root));
-
-          uri = g_file_get_uri (root);
-          photos_debug (PHOTOS_DEBUG_IMPORT, "Enumerating device directory %s", uri);
-
-          g_file_enumerate_children_async (root,
-                                           G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE","
-                                           G_FILE_ATTRIBUTE_STANDARD_NAME","
-                                           G_FILE_ATTRIBUTE_STANDARD_TYPE,
-                                           G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
-                                           G_PRIORITY_DEFAULT,
-                                           self->cancellable,
-                                           photos_tracker_import_controller_enumerate_children,
-                                           self);
-        }
-
       photos_tracker_controller_refresh_for_object (PHOTOS_TRACKER_CONTROLLER (self));
     }
 }
@@ -379,7 +346,6 @@ photos_tracker_import_controller_dispose (GObject *object)
 
   g_clear_object (&self->src_mngr);
   g_clear_object (&self->offset_cntrlr);
-  g_clear_object (&self->manager);
 
   G_OBJECT_CLASS (photos_tracker_import_controller_parent_class)->dispose (object);
 }
@@ -421,13 +387,7 @@ photos_tracker_import_controller_init (PhotosTrackerImportController *self)
 
   self->offset_cntrlr = photos_offset_import_controller_dup_singleton ();
 
-  {
-    g_autoptr (GError) error = NULL;
-
-    self->manager = tracker_miner_manager_new_full (FALSE, &error);
-    if (error != NULL)
-      g_warning ("Unable to create a TrackerMinerManager, indexing attached devices won't work: %s", 
error->message);
-  }
+  g_warning ("Unable to create a TrackerMinerManager, indexing attached devices won't work");
 }
 
 
diff --git a/src/photos-tracker-queue.c b/src/photos-tracker-queue.c
index 6ac829cd..d2bdbaa6 100644
--- a/src/photos-tracker-queue.c
+++ b/src/photos-tracker-queue.c
@@ -290,7 +290,8 @@ photos_tracker_queue_initable_init (GInitable *initable, GCancellable *cancellab
 
   g_assert_no_error (self->initialization_error);
 
-  self->connection = tracker_sparql_connection_get (cancellable, &self->initialization_error);
+  self->connection = tracker_sparql_connection_bus_new (
+    "org.freedesktop.Tracker3.Miner.Files", NULL, NULL, &self->initialization_error);
   if (G_UNLIKELY (self->initialization_error != NULL))
     goto out;
 


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