[tracker/data-provider-monitor-interface: 9/10] libtracker-miner: Connect FileDataProvider monitor signals up
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/data-provider-monitor-interface: 9/10] libtracker-miner: Connect FileDataProvider monitor signals up
- Date: Wed, 14 Jan 2015 17:05:02 +0000 (UTC)
commit fd3801cb2b0e6ef80db4b150642b64749cbeab91
Author: Martyn Russell <martyn lanedo com>
Date: Wed Jan 14 16:13:02 2015 +0000
libtracker-miner: Connect FileDataProvider monitor signals up
src/libtracker-miner/Makefile.am | 4 +-
src/libtracker-miner/tracker-file-data-provider.c | 131 +++++++++++++++++++++
src/libtracker-miner/tracker-miner-fs.c | 2 +-
3 files changed, 134 insertions(+), 3 deletions(-)
---
diff --git a/src/libtracker-miner/Makefile.am b/src/libtracker-miner/Makefile.am
index 5df74a3..60ca585 100644
--- a/src/libtracker-miner/Makefile.am
+++ b/src/libtracker-miner/Makefile.am
@@ -41,6 +41,8 @@ private_sources = \
tracker-file-notifier.c \
tracker-file-system.h \
tracker-file-system.c \
+ tracker-monitor.c \
+ tracker-monitor.h \
tracker-priority-queue.h \
tracker-priority-queue.c \
tracker-task-pool.h \
@@ -59,8 +61,6 @@ private_sources += \
endif
miner_sources = \
- $(libtracker_miner_monitor_sources) \
- $(libtracker_miner_monitor_headers) \
tracker-data-provider.c \
tracker-data-provider.h \
tracker-decorator.c \
diff --git a/src/libtracker-miner/tracker-file-data-provider.c
b/src/libtracker-miner/tracker-file-data-provider.c
index 1a68725..20e58a6 100644
--- a/src/libtracker-miner/tracker-file-data-provider.c
+++ b/src/libtracker-miner/tracker-file-data-provider.c
@@ -60,6 +60,16 @@ G_DEFINE_TYPE_WITH_CODE (TrackerFileDataProvider, tracker_file_data_provider, G_
static void
tracker_file_data_provider_finalize (GObject *object)
{
+ TrackerFileDataProvider *fdp = TRACKER_FILE_DATA_PROVIDER (object);
+
+ if (fdp->indexing_tree) {
+ g_object_unref (fdp->indexing_tree);
+ }
+
+ if (fdp->monitor) {
+ g_object_unref (fdp->monitor);
+ }
+
G_OBJECT_CLASS (tracker_file_data_provider_parent_class)->finalize (object);
}
@@ -72,9 +82,66 @@ tracker_file_data_provider_class_init (TrackerFileDataProviderClass *klass)
}
static void
+item_created_cb (TrackerMonitor *monitor,
+ GFile *file,
+ gboolean is_directory,
+ gpointer user_data)
+{
+ TrackerDataProvider *dp = TRACKER_DATA_PROVIDER (user_data);
+ g_signal_emit_by_name (dp, "item-created", file, is_directory);
+}
+
+static void
+item_updated_cb (TrackerMonitor *monitor,
+ GFile *file,
+ gboolean is_directory,
+ gpointer user_data)
+{
+ TrackerDataProvider *dp = TRACKER_DATA_PROVIDER (user_data);
+ g_signal_emit_by_name (dp, "item-updated", file, is_directory);
+}
+
+static void
+item_attribute_updated_cb (TrackerMonitor *monitor,
+ GFile *file,
+ gboolean is_directory,
+ gpointer user_data)
+{
+ TrackerDataProvider *dp = TRACKER_DATA_PROVIDER (user_data);
+ g_signal_emit_by_name (dp, "item-attribute-updated", file, is_directory);
+}
+
+static void
+item_deleted_cb (TrackerMonitor *monitor,
+ GFile *file,
+ gboolean is_directory,
+ gpointer user_data)
+{
+ TrackerDataProvider *dp = TRACKER_DATA_PROVIDER (user_data);
+ g_signal_emit_by_name (dp, "item-deleted", file, is_directory);
+}
+
+static void
+item_moved_cb (TrackerMonitor *monitor,
+ GFile *file,
+ GFile *other_file,
+ gboolean is_directory,
+ gboolean is_source_monitored,
+ gpointer user_data)
+{
+ TrackerDataProvider *dp = TRACKER_DATA_PROVIDER (user_data);
+ g_signal_emit_by_name (dp, "item-moved", file, other_file, is_directory, is_source_monitored);
+}
+
+static void
tracker_file_data_provider_init (TrackerFileDataProvider *fe)
{
fe->monitor = tracker_monitor_new ();
+ g_signal_connect_object (fe->monitor, "item-created", G_CALLBACK (item_created_cb), fe,
G_CONNECT_AFTER);
+ g_signal_connect_object (fe->monitor, "item-updated", G_CALLBACK (item_updated_cb), fe,
G_CONNECT_AFTER);
+ g_signal_connect_object (fe->monitor, "item-deleted", G_CALLBACK (item_deleted_cb), fe,
G_CONNECT_AFTER);
+ g_signal_connect_object (fe->monitor, "item-attribute-updated", G_CALLBACK
(item_attribute_updated_cb), fe, G_CONNECT_AFTER);
+ g_signal_connect_object (fe->monitor, "item-moved", G_CALLBACK (item_moved_cb), fe, G_CONNECT_AFTER);
}
static BeginData *
@@ -317,6 +384,66 @@ file_data_provider_monitor_remove (TrackerDataProvider *data_provider,
}
static gboolean
+file_data_provider_monitor_move (TrackerDataProvider *data_provider,
+ GFile *container_from,
+ GFile *container_to,
+ GError **error)
+{
+ TrackerFileDataProvider *fdp;
+
+ g_return_val_if_fail (TRACKER_IS_FILE_DATA_PROVIDER (data_provider), FALSE);
+ g_return_val_if_fail (G_IS_FILE (container_from), FALSE);
+ g_return_val_if_fail (G_IS_FILE (container_to), FALSE);
+
+ fdp = TRACKER_FILE_DATA_PROVIDER (data_provider);
+
+ return tracker_monitor_move (fdp->monitor, container_from, container_to);
+}
+
+static gboolean
+file_data_provider_is_monitored (TrackerDataProvider *data_provider,
+ GFile *container,
+ GError **error)
+{
+ TrackerFileDataProvider *fdp;
+
+ g_return_val_if_fail (TRACKER_IS_FILE_DATA_PROVIDER (data_provider), FALSE);
+ g_return_val_if_fail (G_IS_FILE (container), FALSE);
+
+ fdp = TRACKER_FILE_DATA_PROVIDER (data_provider);
+
+ return tracker_monitor_is_watched (fdp->monitor, container);
+}
+
+static gboolean
+file_data_provider_is_monitored_by_path (TrackerDataProvider *data_provider,
+ const gchar *container,
+ GError **error)
+{
+ TrackerFileDataProvider *fdp;
+
+ g_return_val_if_fail (TRACKER_IS_FILE_DATA_PROVIDER (data_provider), FALSE);
+ g_return_val_if_fail (container != NULL, FALSE);
+
+ fdp = TRACKER_FILE_DATA_PROVIDER (data_provider);
+
+ return tracker_monitor_is_watched_by_string (fdp->monitor, container);
+}
+
+static guint
+file_data_provider_monitor_count (TrackerDataProvider *data_provider,
+ GError **error)
+{
+ TrackerFileDataProvider *fdp;
+
+ g_return_val_if_fail (TRACKER_IS_FILE_DATA_PROVIDER (data_provider), 0);
+
+ fdp = TRACKER_FILE_DATA_PROVIDER (data_provider);
+
+ return tracker_monitor_get_count (fdp->monitor);
+}
+
+static gboolean
file_data_provider_set_indexing_tree (TrackerDataProvider *data_provider,
TrackerIndexingTree *indexing_tree,
GError **error)
@@ -364,6 +491,10 @@ tracker_file_data_provider_file_iface_init (TrackerDataProviderIface *iface)
iface->end_finish = file_data_provider_end_finish;
iface->monitor_add = file_data_provider_monitor_add;
iface->monitor_remove = file_data_provider_monitor_remove;
+ iface->monitor_move = file_data_provider_monitor_move;
+ iface->is_monitored = file_data_provider_is_monitored;
+ iface->is_monitored_by_path = file_data_provider_is_monitored_by_path;
+ iface->monitor_count = file_data_provider_monitor_count;
iface->set_indexing_tree = file_data_provider_set_indexing_tree;
iface->get_indexing_tree = file_data_provider_get_indexing_tree;
}
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index 6154550..009c5ab 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -1181,7 +1181,7 @@ process_print_stats (TrackerMinerFS *fs)
fs->priv->total_files_ignored);
#if 0
g_info ("Total monitors : %d",
- tracker_monitor_get_count (fs->priv->monitor));
+ tracker_data_provider_monitor_count (fs->priv->data_provider));
#endif
g_info ("Total processed : %d (%d notified, %d with error)",
fs->priv->total_files_processed,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]