[gnome-photos/wip/rishi/tracker3] Port to Tracker 3
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/tracker3] Port to Tracker 3
- Date: Sat, 6 Mar 2021 16:44:36 +0000 (UTC)
commit dc3fb81c721c60db0b8fe350db8a5697f1edb563
Author: Sam Thursfield <sam afuera me uk>
Date: Thu Mar 4 21:04:07 2021 +0100
Port to Tracker 3
Notable changes:
* User data (favourites, albums) is now stored in a private database
in ~/.local/share/gnome-photos. This is combined with the Tracker
Miner FS index of photos at query time.
* Inside Flatpak, the application connects to Tracker via the new
xdg-tracker-portal instead of talking directly over D-Bus. Access
is limited by the portal so the app can only see the Pictures
graph.
* The Flatpak build can use a bundled version of Tracker Miners, if a
suitable version is not available on the host.
https://gitlab.gnome.org/GNOME/gnome-photos/-/issues/152
data/meson.build | 5 +-
....gnome.Photos.Tracker1.Miner.Extract.service.in | 8 -
...rg.gnome.Photos.Tracker1.Miner.Files.service.in | 8 -
data/org.gnome.Photos.Tracker1.service.in | 3 -
....gnome.Photos.Tracker3.Miner.Extract.service.in | 3 +
...rg.gnome.Photos.Tracker3.Miner.Files.service.in | 3 +
data/org.gnome.Photos.rule.in | 12 +-
flatpak/org.gnome.Photos.json | 46 +---
meson.build | 3 +-
src/meson.build | 15 +-
src/org.freedesktop.Tracker3.Miner.Files.Index.xml | 11 +
src/org.freedesktop.Tracker3.Miner.xml | 56 +++++
src/photos-application.c | 235 +++++++++------------
src/photos-application.h | 5 +
src/photos-indexing-notification.c | 120 ++++++++---
src/photos-item-manager.c | 29 +--
src/photos-quarks.c | 20 +-
src/photos-search-match-manager.c | 2 +-
src/photos-source.c | 14 +-
src/photos-tracker-extract-priority.xml | 30 ---
src/photos-utils.h | 4 +-
21 files changed, 331 insertions(+), 301 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
index 279dd536..e477647c 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -60,9 +60,8 @@ configure_file(
)
tracker_domain_services = [
- 'Tracker1',
- 'Tracker1.Miner.Extract',
- 'Tracker1.Miner.Files'
+ 'Tracker3.Miner.Extract',
+ 'Tracker3.Miner.Files'
]
foreach service: tracker_domain_services
diff --git a/data/org.gnome.Photos.Tracker3.Miner.Extract.service.in
b/data/org.gnome.Photos.Tracker3.Miner.Extract.service.in
new file mode 100644
index 00000000..54624264
--- /dev/null
+++ b/data/org.gnome.Photos.Tracker3.Miner.Extract.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=@application_id@.Tracker3.Miner.Extract
+Exec=@libexecdir@/tracker-extract-3 --domain-ontology @application_id@
diff --git a/data/org.gnome.Photos.Tracker3.Miner.Files.service.in
b/data/org.gnome.Photos.Tracker3.Miner.Files.service.in
new file mode 100644
index 00000000..427d5d1c
--- /dev/null
+++ b/data/org.gnome.Photos.Tracker3.Miner.Files.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=@application_id@.Tracker3.Miner.Files
+Exec=@libexecdir@/tracker-miner-fs-3 --initial-sleep=0 --domain-ontology @application_id@
diff --git a/data/org.gnome.Photos.rule.in b/data/org.gnome.Photos.rule.in
index 38a4c397..bd908499 100644
--- a/data/org.gnome.Photos.rule.in
+++ b/data/org.gnome.Photos.rule.in
@@ -1,3 +1,7 @@
+# This is used to run the Tracker indexer inside a Flatpak sandbox, when
+# Photos is running on a host that doesn't have a suitable version of Tracker
+# installed.
+
[DomainOntology]
# All locations accept
# 1) Paths relative from a variable, the variables
@@ -14,14 +18,10 @@
#
# Location for the Tracker database (not optional)
-CacheLocation=$XDG_CACHE_HOME/gnome-photos/tracker
-
-# Location for the data journal, used in data recovery
-# situations (optional)
-JournalLocation=$XDG_DATA_HOME/gnome-photos/tracker/data
+CacheLocation=$XDG_CACHE_HOME/gnome-photos/tracker3/files
# Name of the ontology to use, must be one located in
-# $(sharedir)/tracker/ontologies
+# $(sharedir)/tracker3/ontologies
OntologyName=nepomuk
# DBus name for the owner (not optional). Tracker will use
diff --git a/flatpak/org.gnome.Photos.json b/flatpak/org.gnome.Photos.json
index fe5c0e46..e716037b 100644
--- a/flatpak/org.gnome.Photos.json
+++ b/flatpak/org.gnome.Photos.json
@@ -7,7 +7,7 @@
"tags": [ "nightly" ],
"desktop-file-name-prefix": "(Nightly) ",
"finish-args": [
- "--env=TRACKER_SPARQL_BACKEND=bus",
+ "--add-policy=Tracker3.dbus:org.freedesktop.Tracker3.Miner.Files=tracker:Pictures",
"--filesystem=xdg-download",
"--filesystem=xdg-pictures",
"--metadata=X-DConf=migrate-path=/org/gnome/photos/",
@@ -17,8 +17,7 @@
"--socket=wayland",
"--socket=x11",
"--talk-name=org.freedesktop.FileManager1",
- "--talk-name=org.freedesktop.Tracker1",
- "--talk-name=org.freedesktop.Tracker1.Miner.Extract",
+ "--talk-name=org.freedesktop.Tracker3.Miner.Files.Control",
"--talk-name=com.intel.dleyna-renderer",
"--talk-name=org.gnome.ControlCenter",
"--talk-name=org.gnome.SettingsDaemon",
@@ -265,50 +264,21 @@
}
]
},
- {
- "name": "tracker",
- "buildsystem": "meson",
- "cleanup": [ "/bin", "/etc", "/lib/girepository-1.0", "/share/dbus-1", "/share/gir-1.0" ],
- "config-opts": [ "-Dbash_completion=no", "-Ddocs=false", "-Dsystemd_user_services=no" ],
- "sources": [
- {
- "type": "git",
- "url": "https://gitlab.gnome.org/GNOME/tracker.git",
- "branch": "tracker-2.3"
- }
- ]
- },
- {
- "name": "intltool",
- "cleanup": [ "*" ],
- "sources": [
- {
- "type": "archive",
- "url": "https://launchpad.net/intltool/trunk/0.51.0/+download/intltool-0.51.0.tar.gz",
- "sha256": "67c74d94196b153b774ab9f89b2fa6c6ba79352407037c8c14d5aeb334e959cd"
- }
- ]
- },
{
"name": "tracker-miners",
"buildsystem": "meson",
- "cleanup": [ "/etc",
- "/share/dbus-1/services/org.freedesktop.Tracker1.Miner.Extract.service",
- "/share/dbus-1/services/org.freedesktop.Tracker1.Writeback.service",
- "/share/tracker/miners/org.freedesktop.Tracker1.Miner.Applications.service",
- "/share/tracker/miners/org.freedesktop.Tracker1.Miner.Extract.service",
- "/share/tracker/miners/org.freedesktop.Tracker1.Miner.RSS.service",
- "/share/glib-2.0/schemas/org.freedesktop.Tracker.Writeback.gschema.xml" ],
- "config-opts": [ "-Dextract=true",
+ "cleanup": [ "/share/dbus-1/services/org.freedesktop.Tracker3.Miner.Extract.service",
+ "/share/dbus-1/services/org.freedesktop.Tracker3.Miner.Files.service",
+ "/share/dbus-1/services/org.freedesktop.Tracker3.Writeback.service" ],
+ "config-opts": [ "-Dman=false",
"-Dminer_fs=true",
"-Dminer_rss=false",
- "-Dsystemd_user_services=no",
+ "-Dsystemd_user_services=false",
"-Dwriteback=false" ],
"sources": [
{
"type": "git",
- "url": "https://gitlab.gnome.org/GNOME/tracker-miners.git",
- "branch": "tracker-miners-2.3"
+ "url": "https://gitlab.gnome.org/GNOME/tracker-miners.git"
}
]
},
diff --git a/meson.build b/meson.build
index a949382c..2e290caf 100644
--- a/meson.build
+++ b/meson.build
@@ -175,8 +175,7 @@ libgfgraph_dep = dependency('libgfbgraph-0.2', version: '>= 0.2.1')
libhandy_dep = dependency ('libhandy-1', version: '>= 1.1.90')
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_services_dir = dbus_dep.get_pkgconfig_variable(
diff --git a/src/meson.build b/src/meson.build
index e25fb077..154f7d52 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -365,12 +365,18 @@ sources += gnome.gdbus_codegen(
autocleanup: 'all',
)
-tracker_extract_priority = 'photos-tracker-extract-priority'
+sources += gnome.gdbus_codegen(
+ 'photos-tracker-miner',
+ 'org.freedesktop.Tracker3.Miner.xml',
+ interface_prefix: 'org.freedesktop.Tracker3.',
+ namespace: 'Tracker',
+ autocleanup: 'all',
+)
sources += gnome.gdbus_codegen(
- tracker_extract_priority,
- tracker_extract_priority + '.xml',
- interface_prefix: 'org.freedesktop.Tracker1.',
+ 'photos-tracker-miner-files-index',
+ 'org.freedesktop.Tracker3.Miner.Files.Index.xml',
+ interface_prefix: 'org.freedesktop.Tracker3.',
namespace: 'Tracker',
autocleanup: 'all',
)
@@ -390,7 +396,6 @@ deps = common_deps + [
libgfgraph_dep,
libhandy_dep,
m_dep,
- tracker_control_dep,
tracker_sparql_dep,
]
diff --git a/src/org.freedesktop.Tracker3.Miner.Files.Index.xml
b/src/org.freedesktop.Tracker3.Miner.Files.Index.xml
new file mode 100644
index 00000000..e368f1e2
--- /dev/null
+++ b/src/org.freedesktop.Tracker3.Miner.Files.Index.xml
@@ -0,0 +1,11 @@
+<node>
+ <interface name='org.freedesktop.Tracker3.Miner.Files.Index'>
+ <method name='IndexLocation'>
+ <arg type='s' name='file_uri' direction='in' />
+ <arg type='as' name='graphs' direction='in' />
+ <arg type='as' name='flags' direction='in'>"
+ <doc:doc><doc:summary>Extension flags, no allowed values at the moment</doc:summary></doc:doc>
+ </arg>
+ </method>
+ </interface>
+</node>
diff --git a/src/org.freedesktop.Tracker3.Miner.xml b/src/org.freedesktop.Tracker3.Miner.xml
new file mode 100644
index 00000000..6fe09c84
--- /dev/null
+++ b/src/org.freedesktop.Tracker3.Miner.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<node name="/">
+ <interface name="org.freedesktop.Tracker3.Miner">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="_tracker_miner_dbus"/>
+ <method name="Start">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ </method>
+ <method name="GetStatus">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <arg type="s" name="status" direction="out" />
+ </method>
+ <method name="GetProgress">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <arg type="d" name="progress" direction="out" />
+ </method>
+ <method name="GetRemainingTime">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <arg type="i" name="remaining_time" direction="out" />
+ </method>
+ <method name="GetPauseDetails">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <arg type="as" name="pause_applications" direction="out" />
+ <arg type="as" name="pause_reasons" direction="out" />
+ </method>
+ <method name="Pause">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <arg type="s" name="application" direction="in" />
+ <arg type="s" name="reason" direction="in" />
+ <arg type="i" name="cookie" direction="out" />
+ </method>
+ <method name="PauseForProcess">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <arg type="s" name="application" direction="in" />
+ <arg type="s" name="reason" direction="in" />
+ <arg type="i" name="cookie" direction="out" />
+ </method>
+ <method name="Resume">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <arg type="i" name="cookie" direction="in" />
+ </method>
+
+ <!-- Signals -->
+ <signal name="Started" />
+ <signal name="Stopped">
+ <arg type="b" name="interrupted" />
+ </signal>
+ <signal name="Paused" />
+ <signal name="Resumed" />
+ <signal name="Progress">
+ <arg type="s" name="status" />
+ <arg type="d" name="progress" />
+ <arg type="i" name="remaining_time" />
+ </signal>
+ </interface>
+</node>
diff --git a/src/photos-application.c b/src/photos-application.c
index abcaf837..c3de9a59 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -37,8 +37,6 @@
#include <glib/gi18n.h>
#include <grilo.h>
#include <handy.h>
-#include <libtracker-control/tracker-control.h>
-#include <tracker-sparql.h>
#include "photos-application.h"
#include "photos-base-item.h"
@@ -70,7 +68,8 @@
#include "photos-share-notification.h"
#include "photos-share-point-manager.h"
#include "photos-thumbnail-factory.h"
-#include "photos-tracker-extract-priority.h"
+#include "photos-tracker-miner-files-index.h"
+#include "photos-tracker-queue.h"
#include "photos-utils.h"
@@ -129,10 +128,11 @@ struct _PhotosApplication
PhotosSearchProvider *search_provider;
PhotosSelectionController *sel_cntrlr;
PhotosThumbnailFactory *factory;
- TrackerMinerManager *miner_manager;
- TrackerExtractPriority *extract_priority;
+ TrackerMinerFilesIndex *miner_files;
+ TrackerSparqlConnection *miner_files_connection;
gboolean empty_results;
gboolean main_window_deleted;
+ const gchar *miner_files_name;
guint create_miners_count;
guint init_fishes_id;
guint use_count;
@@ -176,7 +176,11 @@ static const gchar *DESKTOP_KEY_PICTURE_OPTIONS = "picture-options";
static const gchar *DESKTOP_KEY_COLOR_SHADING_TYPE = "color-shading-type";
static const gchar *DESKTOP_KEY_PRIMARY_COLOR = "primary-color";
static const gchar *DESKTOP_KEY_SECONDARY_COLOR = "secondary-color";
-static const gchar *MINER_FILES = "org.gnome.Photos.Tracker1.Miner.Files";
+static const gchar *MINER_FILES_NAME_PRIVATE = "org.gnome.Photos.Tracker3.Miner.Files";
+static const gchar *MINER_FILES_NAME_PRIVATE_CONTROL = "org.gnome.Photos.Tracker3.Miner.Files.Control";
+static const gchar *MINER_FILES_NAME_SESSION = "org.freedesktop.Tracker3.Miner.Files";
+static const gchar *MINER_FILES_NAME_SESSION_CONTROL = "org.freedesktop.Tracker3.Miner.Files.Control";
+static const gchar *MINER_FILES_OBJECT_PATH_CONTROL = "/org/freedesktop/Tracker3/Miner/Files/Control";
typedef struct _PhotosApplicationCreateData PhotosApplicationCreateData;
typedef struct _PhotosApplicationImportData PhotosApplicationImportData;
@@ -584,27 +588,6 @@ photos_application_actions_update (PhotosApplication *self)
}
-static void
-photos_application_tracker_clear_rdf_types (GObject *source_object, GAsyncResult *res, gpointer user_data)
-{
- PhotosApplication *self = PHOTOS_APPLICATION (user_data);
- TrackerExtractPriority *extract_priority = TRACKER_EXTRACT_PRIORITY (source_object);
-
- {
- g_autoptr (GError) error = NULL;
-
- if (!tracker_extract_priority_call_clear_rdf_types_finish (extract_priority, res, &error))
- {
- g_warning ("Unable to call ClearRdfTypes: %s", error->message);
- goto out;
- }
- }
-
- out:
- g_application_release (G_APPLICATION (self));
-}
-
-
static gboolean
photos_application_delete_event (PhotosApplication *self)
{
@@ -641,16 +624,6 @@ photos_application_destroy (PhotosApplication *self)
self->create_window_cancellable = g_cancellable_new ();
photos_application_stop_miners (self);
-
- if (self->extract_priority != NULL)
- {
- g_application_hold (G_APPLICATION (self));
- tracker_extract_priority_call_clear_rdf_types (self->extract_priority,
- NULL,
- photos_application_tracker_clear_rdf_types,
- self);
- g_clear_object (&self->extract_priority);
- }
}
@@ -740,60 +713,6 @@ photos_application_gegl_init_fishes_idle (gpointer user_data)
}
-static void
-photos_application_tracker_set_rdf_types (GObject *source_object, GAsyncResult *res, gpointer user_data)
-{
- PhotosApplication *self = PHOTOS_APPLICATION (user_data);
- TrackerExtractPriority *extract_priority = TRACKER_EXTRACT_PRIORITY (source_object);
-
- {
- g_autoptr (GError) error = NULL;
-
- if (!tracker_extract_priority_call_set_rdf_types_finish (extract_priority, res, &error))
- {
- if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- g_warning ("Unable to call SetRdfTypes: %s", error->message);
-
- goto out;
- }
- }
-
- out:
- g_application_release (G_APPLICATION (self));
-}
-
-
-static void
-photos_application_tracker_extract_priority (GObject *source_object, GAsyncResult *res, gpointer user_data)
-{
- PhotosApplication *self = PHOTOS_APPLICATION (user_data);
- const gchar *const rdf_types[] = {"nfo:Image", NULL};
-
- {
- g_autoptr (GError) error = NULL;
-
- self->extract_priority = tracker_extract_priority_proxy_new_for_bus_finish (res, &error);
- if (error != NULL)
- {
- if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- g_warning ("Unable to create TrackerExtractPriority proxy: %s", error->message);
-
- goto out;
- }
- }
-
- g_application_hold (G_APPLICATION (self));
- tracker_extract_priority_call_set_rdf_types (self->extract_priority,
- rdf_types,
- self->create_window_cancellable,
- photos_application_tracker_set_rdf_types,
- self);
-
- out:
- g_application_release (G_APPLICATION (self));
-}
-
-
static gboolean
photos_application_create_window (PhotosApplication *self)
{
@@ -813,6 +732,8 @@ photos_application_create_window (PhotosApplication *self)
gexiv2_registered_namespace = gexiv2_metadata_register_xmp_namespace ("http://www.gnome.org/xmp", "gnome");
g_return_val_if_fail (gexiv2_registered_namespace, FALSE);
+ photos_application_start_miners (self);
+
self->main_window = photos_main_window_new (GTK_APPLICATION (self));
g_signal_connect_object (self->main_window,
"delete-event",
@@ -827,16 +748,6 @@ photos_application_create_window (PhotosApplication *self)
if (self->init_fishes_id == 0)
self->init_fishes_id = g_idle_add (photos_application_gegl_init_fishes_idle, self);
- g_application_hold (G_APPLICATION (self));
- tracker_extract_priority_proxy_new_for_bus (G_BUS_TYPE_SESSION,
- G_DBUS_PROXY_FLAGS_NONE,
- "org.gnome.Photos.Tracker1.Miner.Extract",
- "/org/freedesktop/Tracker1/Extract/Priority",
- self->create_window_cancellable,
- photos_application_tracker_extract_priority,
- self);
-
- photos_application_start_miners (self);
return TRUE;
}
@@ -1113,18 +1024,18 @@ photos_application_get_state (PhotosSearchContext *context)
static void
-photos_application_import_index_file (GObject *source_object, GAsyncResult *res, gpointer user_data)
+photos_application_import_index_location (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
PhotosApplication *self;
g_autoptr (GFile) file = G_FILE (user_data);
- TrackerMinerManager *manager = TRACKER_MINER_MANAGER (source_object);
+ TrackerMinerFilesIndex *miner_files = TRACKER_MINER_FILES_INDEX (source_object);
self = PHOTOS_APPLICATION (g_application_get_default ());
{
g_autoptr (GError) error = NULL;
- if (!tracker_miner_manager_index_file_for_process_finish (manager, res, &error))
+ if (!tracker_miner_files_index_call_index_location_finish (miner_files, res, &error))
{
g_autofree gchar *uri = NULL;
@@ -1346,6 +1257,8 @@ photos_application_import_file_copy (GObject *source_object, GAsyncResult *res,
}
else
{
+ const gchar *tracker_priority_graphs[] = { PHOTOS_PICTURES_GRAPH };
+ const gchar *tracker_index_location_flags[] = { };
g_autofree gchar *destination_uri = NULL;
g_assert_true (G_IS_FILE (destination));
@@ -1363,11 +1276,13 @@ photos_application_import_file_copy (GObject *source_object, GAsyncResult *res,
g_application_hold (G_APPLICATION (self));
g_application_mark_busy (G_APPLICATION (self));
- tracker_miner_manager_index_file_for_process_async (self->miner_manager,
- destination,
- NULL,
- photos_application_import_index_file,
- g_object_ref (destination));
+ tracker_miner_files_index_call_index_location (self->miner_files,
+ destination_uri,
+ tracker_priority_graphs,
+ tracker_index_location_flags,
+ NULL,
+ photos_application_import_index_location,
+ g_object_ref (destination));
}
out:
@@ -1531,9 +1446,9 @@ photos_application_import (PhotosApplication *self)
selection = photos_selection_controller_get_selection (self->sel_cntrlr);
g_return_if_fail (selection != NULL);
- if (self->miner_manager == NULL)
+ if (self->miner_files == NULL)
{
- g_warning ("No TrackerMinerManager, importing from attached devices won't work");
+ g_warning ("No TrackerMinerFilesIndex proxy, importing from attached devices won't work");
goto out;
}
@@ -2234,36 +2149,73 @@ photos_application_share_current (PhotosApplication *self)
static void
-photos_application_start_miners (PhotosApplication *self)
+photos_application_start_miners_local (PhotosApplication *self)
{
+ const gchar *control_name;
+
+ self->miner_files_name = MINER_FILES_NAME_SESSION;
+ control_name = MINER_FILES_NAME_SESSION_CONTROL;
+ photos_debug (PHOTOS_DEBUG_TRACKER, "Connecting to %s", self->miner_files_name);
+
{
g_autoptr (GError) error = NULL;
- self->miner_manager = tracker_miner_manager_new_full (TRUE, &error);
+ self->miner_files_connection = tracker_sparql_connection_bus_new (self->miner_files_name, NULL, NULL,
&error);
if (error != NULL)
- g_warning ("Unable to create a TrackerMinerManager: %s", error->message);
+ {
+ g_warning ("Unable to create connection for session-wide Tracker indexer at %s: %s",
+ self->miner_files_name,
+ error->message);
+ self->miner_files_name = NULL;
+ }
}
- if (self->miner_manager != NULL)
+ if (self->miner_files_connection == NULL && photos_utils_is_flatpak ())
{
- GSList *available = NULL;
- GSList *miner_files = NULL;
+ self->miner_files_name = MINER_FILES_NAME_PRIVATE;
+ control_name = MINER_FILES_NAME_PRIVATE_CONTROL;
+ photos_debug (PHOTOS_DEBUG_TRACKER, "Connecting to %s", self->miner_files_name);
- available = tracker_miner_manager_get_available (self->miner_manager);
- miner_files = g_slist_find_custom (available, MINER_FILES, (GCompareFunc) strcmp);
- if (miner_files == NULL)
- {
- g_warning ("Unable to find miner %s", MINER_FILES);
- }
- else
- {
- if (!tracker_miner_manager_is_active (self->miner_manager, MINER_FILES))
- g_warning ("Unable to activate miner %s", MINER_FILES);
- }
+ {
+ g_autoptr (GError) error = NULL;
- g_slist_free_full (available, g_free);
+ self->miner_files_connection = tracker_sparql_connection_bus_new (self->miner_files_name, NULL,
NULL, &error);
+ if (error != NULL)
+ {
+ g_warning ("Unable to create connection for private Tracker indexer at %s: %s",
+ self->miner_files_name,
+ error->message);
+ self->miner_files_name = NULL;
+ }
+ }
}
+ if (self->miner_files_connection == NULL)
+ goto out;
+
+ {
+ g_autoptr (GError) error = NULL;
+
+ self->miner_files = tracker_miner_files_index_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS
+ |
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+ control_name,
+ MINER_FILES_OBJECT_PATH_CONTROL,
+ NULL,
+ &error);
+ if (error != NULL)
+ g_warning ("Unable to create TrackerMinerFilesIndex proxy: %s", error->message);
+ }
+
+ out:
+ return;
+}
+
+
+static void
+photos_application_start_miners (PhotosApplication *self)
+{
+ photos_application_start_miners_local (self);
photos_application_create_online_miners (self);
}
@@ -3023,8 +2975,8 @@ photos_application_dispose (GObject *object)
g_clear_object (&self->camera_cache);
g_clear_object (&self->sel_cntrlr);
g_clear_object (&self->factory);
- g_clear_object (&self->extract_priority);
- g_clear_object (&self->miner_manager);
+ g_clear_object (&self->miner_files);
+ g_clear_object (&self->miner_files_connection);
if (self->state != NULL)
{
@@ -3060,7 +3012,6 @@ photos_application_init (PhotosApplication *self)
textdomain (GETTEXT_PACKAGE);
g_set_application_name (_("Photos"));
- tracker_sparql_connection_set_domain ("org.gnome.Photos");
photos_utils_ensure_builtins ();
@@ -3116,6 +3067,18 @@ photos_application_new (void)
}
+TrackerNotifier *
+photos_application_create_notifier (PhotosApplication *self)
+{
+ TrackerNotifier *notifier;
+
+ g_return_val_if_fail (PHOTOS_IS_APPLICATION (self), NULL);
+
+ notifier = tracker_sparql_connection_create_notifier (self->miner_files_connection);
+ return notifier;
+}
+
+
gboolean
photos_application_get_empty_results (PhotosApplication *self)
{
@@ -3147,6 +3110,14 @@ photos_application_get_miner (PhotosApplication *self, const gchar *provider_typ
}
+const gchar *
+photos_application_get_miner_files_name (PhotosApplication *self)
+{
+ g_return_val_if_fail (PHOTOS_IS_APPLICATION (self), NULL);
+ return self->miner_files_name;
+}
+
+
GList *
photos_application_get_miners_running (PhotosApplication *self)
{
diff --git a/src/photos-application.h b/src/photos-application.h
index ae28361c..faf6c3e9 100644
--- a/src/photos-application.h
+++ b/src/photos-application.h
@@ -24,6 +24,7 @@
#define PHOTOS_APPLICATION_H
#include <gtk/gtk.h>
+#include <tracker-sparql.h>
#include "photos-gom-miner.h"
@@ -34,11 +35,15 @@ G_DECLARE_FINAL_TYPE (PhotosApplication, photos_application, PHOTOS, APPLICATION
GApplication *photos_application_new (void);
+TrackerNotifier *photos_application_create_notifier (PhotosApplication *self);
+
gboolean photos_application_get_empty_results (PhotosApplication *self);
GomMiner *photos_application_get_miner (PhotosApplication *self,
const gchar *provider_type);
+const gchar *photos_application_get_miner_files_name (PhotosApplication *self);
+
GList *photos_application_get_miners_running (PhotosApplication *self);
gint photos_application_get_scale_factor (PhotosApplication *self);
diff --git a/src/photos-indexing-notification.c b/src/photos-indexing-notification.c
index 72394983..97e08164 100644
--- a/src/photos-indexing-notification.c
+++ b/src/photos-indexing-notification.c
@@ -26,22 +26,23 @@
#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"
#include "photos-indexing-notification.h"
#include "photos-notification-manager.h"
+#include "photos-tracker-miner.h"
struct _PhotosIndexingNotification
{
GtkGrid parent_instance;
+ GCancellable *cancellable;
GtkWidget *ntfctn_mngr;
GtkWidget *primary_label;
GtkWidget *secondary_label;
GtkWidget *spinner;
- TrackerMinerManager *manager;
+ TrackerMiner *miner_files;
gboolean closed;
gboolean on_display;
guint timeout_id;
@@ -56,8 +57,6 @@ enum
REMOTE_MINER_TIMEOUT = 10 /* s */
};
-static const gchar *MINER_FILES = "org.gnome.Photos.Tracker1.Miner.Files";
-
static void
photos_indexing_notification_remove_timeout (PhotosIndexingNotification *self)
@@ -173,23 +172,36 @@ photos_indexing_notification_timeout (gpointer user_data)
static void
-photos_indexing_notification_check_notification (PhotosIndexingNotification *self)
+photos_indexing_notification_check_notification_get_progress (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
{
+ PhotosIndexingNotification *self;
GApplication *app;
GList *miners_running;
GSList *running = NULL;
+ TrackerMiner *miner_files = TRACKER_MINER (source_object);
gboolean is_indexing_local = FALSE;
gboolean is_indexing_remote = FALSE;
+ gdouble progress;
- running = tracker_miner_manager_get_running (self->manager);
- if (g_slist_find_custom (running, (gconstpointer) MINER_FILES, (GCompareFunc) g_strcmp0) != NULL)
- {
- gdouble progress;
+ {
+ g_autoptr (GError) error = NULL;
- tracker_miner_manager_get_status (self->manager, MINER_FILES, NULL, &progress, NULL);
- if (progress < 1)
- is_indexing_local = TRUE;
- }
+ if (!tracker_miner_call_get_progress_finish (miner_files, &progress, res, &error))
+ {
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ goto out;
+
+ g_warning ("Unable to get indexing progress from TrackerMiner proxy: %s", error->message);
+ progress = 1.0;
+ }
+ }
+
+ self = PHOTOS_INDEXING_NOTIFICATION (user_data);
+
+ if (progress < 1)
+ is_indexing_local = TRUE;
app = g_application_get_default ();
miners_running = photos_application_get_miners_running (PHOTOS_APPLICATION (app));
@@ -210,10 +222,53 @@ photos_indexing_notification_check_notification (PhotosIndexingNotification *sel
else
photos_indexing_notification_destroy (self, FALSE);
+ out:
g_slist_free_full (running, g_free);
}
+static void
+photos_indexing_notification_check_notification (PhotosIndexingNotification *self)
+{
+ tracker_miner_call_get_progress (self->miner_files,
+ self->cancellable,
+ photos_indexing_notification_check_notification_get_progress,
+ self);
+}
+
+
+static void
+photos_indexing_notification_tracker_miner (GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+ PhotosIndexingNotification *self;
+ g_autoptr (TrackerMiner) miner_files = NULL;
+
+ {
+ g_autoptr (GError) error = NULL;
+
+ miner_files = tracker_miner_proxy_new_for_bus_finish (res, &error);
+ if (error != NULL)
+ {
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_warning ("Unable to create TrackerMiner proxy: %s", error->message);
+
+ goto out;
+ }
+ }
+
+ self = PHOTOS_INDEXING_NOTIFICATION (user_data);
+
+ self->miner_files = g_object_ref (miner_files);
+ g_signal_connect_swapped (self->miner_files,
+ "progress",
+ G_CALLBACK (photos_indexing_notification_check_notification),
+ self);
+
+ out:
+ return;
+}
+
+
static void
photos_indexing_notification_dispose (GObject *object)
{
@@ -221,8 +276,14 @@ photos_indexing_notification_dispose (GObject *object)
photos_indexing_notification_remove_timeout (self);
+ if (self->cancellable != NULL)
+ {
+ g_cancellable_cancel (self->cancellable);
+ g_clear_object (&self->cancellable);
+ }
+
g_clear_object (&self->ntfctn_mngr);
- g_clear_object (&self->manager);
+ g_clear_object (&self->miner_files);
G_OBJECT_CLASS (photos_indexing_notification_parent_class)->dispose (object);
}
@@ -236,21 +297,9 @@ photos_indexing_notification_init (PhotosIndexingNotification *self)
GtkWidget *close;
GtkWidget *image;
GtkWidget *labels;
+ const gchar *miner_files_name;
app = g_application_get_default ();
-
- {
- g_autoptr (GError) error = NULL;
-
- self->manager = tracker_miner_manager_new_full (TRUE, &error);
- if (error != NULL)
- {
- g_warning ("Unable to create a TrackerMinerManager, indexing progress notification won't work: %s",
- error->message);
- return;
- }
- }
-
self->ntfctn_mngr = photos_notification_manager_dup_singleton ();
self->spinner = gtk_spinner_new ();
@@ -287,16 +336,23 @@ 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);
+ miner_files_name = photos_application_get_miner_files_name (PHOTOS_APPLICATION (app));
+ if (miner_files_name != NULL)
+ {
+ tracker_miner_proxy_new_for_bus (G_BUS_TYPE_SESSION,
+ G_DBUS_PROXY_FLAGS_NONE,
+ miner_files_name,
+ "/org/freedesktop/Tracker3/Miner/Files",
+ self->cancellable,
+ photos_indexing_notification_tracker_miner,
+ self);
+ }
+
g_signal_connect_object (app,
"miners-changed",
G_CALLBACK (photos_indexing_notification_check_notification),
self,
G_CONNECT_SWAPPED);
-
- g_signal_connect_swapped (self->manager,
- "miner-progress",
- G_CALLBACK (photos_indexing_notification_check_notification),
- self);
}
diff --git a/src/photos-item-manager.c b/src/photos-item-manager.c
index 7958c463..084b07a7 100644
--- a/src/photos-item-manager.c
+++ b/src/photos-item-manager.c
@@ -309,7 +309,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);
@@ -532,17 +532,11 @@ photos_item_manager_notifier_events_foreach (gpointer data, gpointer user_data)
PhotosItemManager *self = PHOTOS_ITEM_MANAGER (user_data);
TrackerNotifierEvent *event = (TrackerNotifierEvent *) data;
TrackerNotifierEventType event_type;
- const gchar *event_rdf_type;
const gchar *event_urn;
- event_rdf_type = tracker_notifier_event_get_type (event);
event_type = tracker_notifier_event_get_event_type (event);
event_urn = tracker_notifier_event_get_urn (event);
- photos_debug (PHOTOS_DEBUG_TRACKER,
- "Received TrackerNotifierEvent (%d): RDF type %s, URN %s",
- event_type,
- event_rdf_type,
- event_urn);
+ photos_debug (PHOTOS_DEBUG_TRACKER, "Received TrackerNotifierEvent (%d): URN %s", event_type, event_urn);
g_return_if_fail (event_urn != NULL && event_urn[0] != '\0');
@@ -584,9 +578,13 @@ photos_item_manager_notifier_events_foreach (gpointer data, gpointer user_data)
static void
-photos_item_manager_notifier_events (PhotosItemManager *self, GPtrArray *events)
+photos_item_manager_notifier_events (PhotosItemManager *self,
+ const gchar *service,
+ const gchar *graph,
+ GPtrArray *events)
{
- g_ptr_array_foreach (events, photos_item_manager_notifier_events_foreach, self);
+ if (g_strcmp0 (graph, PHOTOS_PICTURES_GRAPH) == 0)
+ g_ptr_array_foreach (events, photos_item_manager_notifier_events_foreach, self);
}
@@ -724,7 +722,7 @@ photos_item_manager_wait_for_changes_timeout (gpointer user_data)
g_autoptr (PhotosQuery) query = NULL;
g_autofree gchar *sparql = NULL;
- sparql = g_strdup_printf ("SELECT ?urn nie:url (?urn) WHERE { ?urn nie:url '%s' }", uri);
+ sparql = g_strdup_printf ("SELECT ?urn nie:isStoredAs (?urn) WHERE { ?urn nie:isStoredAs '%s' }", uri);
query = photos_query_new (NULL, sparql);
photos_tracker_queue_select (self->queue,
query,
@@ -1069,11 +1067,14 @@ photos_item_manager_finalize (GObject *object)
static void
photos_item_manager_init (PhotosItemManager *self)
{
+ GApplication *app;
GEnumClass *window_mode_class; /* TODO: use g_autoptr */
guint i;
DZL_COUNTER_INC (instances);
+ app = g_application_get_default ();
+
self->collections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
self->hidden_items = g_hash_table_new_full (g_str_hash,
g_str_equal,
@@ -1100,7 +1101,7 @@ photos_item_manager_init (PhotosItemManager *self)
self->mode = PHOTOS_WINDOW_MODE_NONE;
- self->notifier = tracker_notifier_new (NULL, TRACKER_NOTIFIER_FLAG_QUERY_URN, NULL, NULL);
+ self->notifier = photos_application_create_notifier (PHOTOS_APPLICATION (app));
if (G_LIKELY (self->notifier != NULL))
g_signal_connect_swapped (self->notifier,
"events",
@@ -1247,7 +1248,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');
@@ -1376,7 +1377,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-quarks.c b/src/photos-quarks.c
index 0870ef62..5ee25745 100644
--- a/src/photos-quarks.c
+++ b/src/photos-quarks.c
@@ -25,68 +25,68 @@
GQuark
photos_quarks_flash_off_quark (void)
{
- return g_quark_from_static_string ("http://www.tracker-project.org/temp/nmm#flash-off");
+ return g_quark_from_static_string ("http://tracker.api.gnome.org/ontology/v3/nmm#flash-off");
}
GQuark
photos_quarks_flash_on_quark (void)
{
- return g_quark_from_static_string ("http://www.tracker-project.org/temp/nmm#flash-on");
+ return g_quark_from_static_string ("http://tracker.api.gnome.org/ontology/v3/nmm#flash-on");
}
GQuark
photos_quarks_orientation_bottom_quark (void)
{
- return g_quark_from_static_string
("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#orientation-bottom");
+ return g_quark_from_static_string ("http://tracker.api.gnome.org/ontology/v3/nfo#orientation-bottom");
}
GQuark
photos_quarks_orientation_bottom_mirror_quark (void)
{
- return g_quark_from_static_string
("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#orientation-bottom-mirror");
+ return g_quark_from_static_string
("http://tracker.api.gnome.org/ontology/v3/nfo#orientation-bottom-mirror");
}
GQuark
photos_quarks_orientation_left_quark (void)
{
- return g_quark_from_static_string
("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#orientation-left");
+ return g_quark_from_static_string ("http://tracker.api.gnome.org/ontology/v3/nfo#orientation-left");
}
GQuark
photos_quarks_orientation_left_mirror_quark (void)
{
- return g_quark_from_static_string
("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#orientation-left-mirror");
+ return g_quark_from_static_string ("http://tracker.api.gnome.org/ontology/v3/nfo#orientation-left-mirror");
}
GQuark
photos_quarks_orientation_right_quark (void)
{
- return g_quark_from_static_string
("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#orientation-right");
+ return g_quark_from_static_string ("http://tracker.api.gnome.org/ontology/v3/nfo#orientation-right");
}
GQuark
photos_quarks_orientation_right_mirror_quark (void)
{
- return g_quark_from_static_string
("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#orientation-right-mirror");
+ return g_quark_from_static_string
("http://tracker.api.gnome.org/ontology/v3/nfo#orientation-right-mirror");
}
GQuark
photos_quarks_orientation_top_quark (void)
{
- return g_quark_from_static_string
("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#orientation-top");
+ return g_quark_from_static_string ("http://tracker.api.gnome.org/ontology/v3/nfo#orientation-top");
}
GQuark
photos_quarks_orientation_top_mirror_quark (void)
{
- return g_quark_from_static_string
("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#orientation-top-mirror");
+ return g_quark_from_static_string ("http://tracker.api.gnome.org/ontology/v3/nfo#orientation-top-mirror");
}
diff --git a/src/photos-search-match-manager.c b/src/photos-search-match-manager.c
index e6dc429a..2ba1fd0f 100644
--- a/src/photos-search-match-manager.c
+++ b/src/photos-search-match-manager.c
@@ -148,7 +148,7 @@ photos_search_match_manager_init (PhotosSearchMatchManager *self)
" tracker:case-fold (tracker:coalesce (nco:fullname (?creator),
nco:fullname(?publisher))),"
" \"%s\")";
title_filter = "fn:contains ("
- " tracker:case-fold (tracker:coalesce (nie:title (?urn), nfo:fileName(?urn))),"
+ " tracker:case-fold (tracker:coalesce (nie:title (?urn), nfo:fileName(?file))),"
" \"%s\")";
search_match = photos_search_match_new (PHOTOS_SEARCH_MATCH_STOCK_ALL,
diff --git a/src/photos-source.c b/src/photos-source.c
index db6f2de9..5219652c 100644
--- a/src/photos-source.c
+++ b/src/photos-source.c
@@ -62,7 +62,7 @@ G_DEFINE_TYPE_WITH_CODE (PhotosSource, photos_source, G_TYPE_OBJECT,
DZL_DEFINE_COUNTER (instances, "PhotosSource", "Instances", "Number of PhotosSource instances")
-static const gchar *TRACKER_SCHEMA = "org.freedesktop.Tracker.Miner.Files";
+static const gchar *TRACKER_SCHEMA = "org.freedesktop.Tracker3.Miner.Files";
static const gchar *TRACKER_KEY_RECURSIVE_DIRECTORIES = "index-recursive-directories";
@@ -94,7 +94,7 @@ photos_source_build_filter_local (void)
continue;
tracker_uri = photos_utils_convert_path_to_uri (tracker_dirs[i]);
- g_string_append_printf (tracker_filter, " || fn:contains (nie:url (?urn), '%s')", tracker_uri);
+ g_string_append_printf (tracker_filter, " || fn:contains (nie:isStoredAs (?urn), '%s')", tracker_uri);
}
path = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
@@ -109,11 +109,11 @@ photos_source_build_filter_local (void)
export_path = g_build_filename (path, PHOTOS_EXPORT_SUBPATH, NULL);
export_uri = photos_utils_convert_path_to_uri (export_path);
- filter = g_strdup_printf ("(((fn:contains (nie:url (?urn), '%s')"
- " || fn:contains (nie:url (?urn), '%s')"
- " || fn:contains (nie:url (?urn), '%s')"
+ filter = g_strdup_printf ("(((fn:contains (nie:isStoredAs (?urn), '%s')"
+ " || fn:contains (nie:isStoredAs (?urn), '%s')"
+ " || fn:contains (nie:isStoredAs (?urn), '%s')"
" %s)"
- " && !fn:contains (nie:url (?urn), '%s'))"
+ " && !fn:contains (nie:isStoredAs (?urn), '%s'))"
" || fn:starts-with (nao:identifier (?urn), '%s')"
" || (?urn = nfo:image-category-screenshot))",
desktop_uri,
@@ -146,7 +146,7 @@ photos_source_build_filter_resource (PhotosSource *self)
root = g_mount_get_root (self->mount);
uri = g_file_get_uri (root);
- filter = g_strdup_printf ("(fn:starts-with (nie:url (?urn), '%s'))", uri);
+ filter = g_strdup_printf ("(fn:starts-with (nie:isStoredAs (?urn), '%s'))", uri);
}
else
{
diff --git a/src/photos-utils.h b/src/photos-utils.h
index 1e7a4cb7..8709537d 100644
--- a/src/photos-utils.h
+++ b/src/photos-utils.h
@@ -45,9 +45,9 @@ G_BEGIN_DECLS
#define PHOTOS_TOOL_EXTENSION_POINT_NAME "photos-tool"
#define PHOTOS_TRACKER_CONTROLLER_EXTENSION_POINT_NAME "photos-tracker-controller"
-#define PHOTOS_COLLECTION_SCREENSHOT \
- "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#image-category-screenshot"
+#define PHOTOS_COLLECTION_SCREENSHOT "http://tracker.api.gnome.org/ontology/v3/nfo#image-category-screenshot"
#define PHOTOS_EXPORT_SUBPATH "Exports"
+#define PHOTOS_PICTURES_GRAPH "http://tracker.api.gnome.org/ontology/v3/tracker#Pictures"
typedef enum
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]