[tracker/data-provider-monitor-interface: 6/10] Revert "libtracker-miner: Removed unused APIs from tracker-monitor"
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/data-provider-monitor-interface: 6/10] Revert "libtracker-miner: Removed unused APIs from tracker-monitor"
- Date: Wed, 14 Jan 2015 17:04:47 +0000 (UTC)
commit 10866ed1160388902565f0617cd16cdd685ec928
Author: Martyn Russell <martyn lanedo com>
Date: Wed Jan 14 11:37:28 2015 +0000
Revert "libtracker-miner: Removed unused APIs from tracker-monitor"
This reverts commit 65951061a4e841f50cb2724657472697f1530b51.
src/libtracker-miner/tracker-miner-fs.c | 4 +
src/libtracker-miner/tracker-monitor.c | 153 +++++++++++++++++++++++++++++++
src/libtracker-miner/tracker-monitor.h | 9 ++
3 files changed, 166 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index 98824e0..6154550 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -1179,6 +1179,10 @@ process_print_stats (TrackerMinerFS *fs)
g_info ("Total files : %d (%d ignored)",
fs->priv->total_files_found,
fs->priv->total_files_ignored);
+#if 0
+ g_info ("Total monitors : %d",
+ tracker_monitor_get_count (fs->priv->monitor));
+#endif
g_info ("Total processed : %d (%d notified, %d with error)",
fs->priv->total_files_processed,
fs->priv->total_files_notified,
diff --git a/src/libtracker-miner/tracker-monitor.c b/src/libtracker-miner/tracker-monitor.c
index 67be9e6..fd34531 100644
--- a/src/libtracker-miner/tracker-monitor.c
+++ b/src/libtracker-miner/tracker-monitor.c
@@ -111,7 +111,20 @@ enum {
LAST_SIGNAL
};
+enum {
+ PROP_0,
+ PROP_ENABLED
+};
+
static void tracker_monitor_finalize (GObject *object);
+static void tracker_monitor_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void tracker_monitor_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
static guint get_kqueue_limit (void);
static guint get_inotify_limit (void);
static GFileMonitor * directory_monitor_new (TrackerMonitor *monitor,
@@ -137,6 +150,8 @@ tracker_monitor_class_init (TrackerMonitorClass *klass)
object_class = G_OBJECT_CLASS (klass);
object_class->finalize = tracker_monitor_finalize;
+ object_class->set_property = tracker_monitor_set_property;
+ object_class->get_property = tracker_monitor_get_property;
signals[ITEM_CREATED] =
g_signal_new ("item-created",
@@ -196,6 +211,14 @@ tracker_monitor_class_init (TrackerMonitorClass *klass)
G_TYPE_BOOLEAN,
G_TYPE_BOOLEAN);
+ g_object_class_install_property (object_class,
+ PROP_ENABLED,
+ g_param_spec_boolean ("enabled",
+ "Enabled",
+ "Enabled",
+ TRUE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
g_type_class_add_private (object_class, sizeof (TrackerMonitorPrivate));
}
@@ -352,6 +375,43 @@ tracker_monitor_finalize (GObject *object)
G_OBJECT_CLASS (tracker_monitor_parent_class)->finalize (object);
}
+static void
+tracker_monitor_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (prop_id) {
+ case PROP_ENABLED:
+ tracker_monitor_set_enabled (TRACKER_MONITOR (object),
+ g_value_get_boolean (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+tracker_monitor_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ TrackerMonitorPrivate *priv;
+
+ priv = TRACKER_MONITOR_GET_PRIVATE (object);
+
+ switch (prop_id) {
+ case PROP_ENABLED:
+ g_value_set_boolean (value, priv->enabled);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
static guint
get_kqueue_limit (void)
{
@@ -1363,6 +1423,14 @@ tracker_monitor_new (void)
return g_object_new (TRACKER_TYPE_MONITOR, NULL);
}
+gboolean
+tracker_monitor_get_enabled (TrackerMonitor *monitor)
+{
+ g_return_val_if_fail (TRACKER_IS_MONITOR (monitor), FALSE);
+
+ return monitor->priv->enabled;
+}
+
TrackerIndexingTree *
tracker_monitor_get_indexing_tree (TrackerMonitor *monitor)
{
@@ -1388,6 +1456,48 @@ tracker_monitor_set_indexing_tree (TrackerMonitor *monitor,
}
}
+void
+tracker_monitor_set_enabled (TrackerMonitor *monitor,
+ gboolean enabled)
+{
+ GList *keys, *k;
+
+ g_return_if_fail (TRACKER_IS_MONITOR (monitor));
+
+ /* Don't replace all monitors if we are already
+ * enabled/disabled.
+ */
+ if (monitor->priv->enabled == enabled) {
+ return;
+ }
+
+ monitor->priv->enabled = enabled;
+ g_object_notify (G_OBJECT (monitor), "enabled");
+
+ keys = g_hash_table_get_keys (monitor->priv->monitors);
+
+ /* Update state on all monitored dirs */
+ for (k = keys; k != NULL; k = k->next) {
+ GFile *file;
+
+ file = k->data;
+
+ if (enabled) {
+ GFileMonitor *dir_monitor;
+
+ dir_monitor = directory_monitor_new (monitor, file);
+ g_hash_table_replace (monitor->priv->monitors,
+ g_object_ref (file), dir_monitor);
+ } else {
+ /* Remove monitor */
+ g_hash_table_replace (monitor->priv->monitors,
+ g_object_ref (file), NULL);
+ }
+ }
+
+ g_list_free (keys);
+}
+
gboolean
tracker_monitor_add (TrackerMonitor *monitor,
GFile *file)
@@ -1540,3 +1650,46 @@ monitor_cancel_recursively (TrackerMonitor *monitor,
return items_cancelled > 0;
}
+
+gboolean
+tracker_monitor_is_watched (TrackerMonitor *monitor,
+ GFile *file)
+{
+ g_return_val_if_fail (TRACKER_IS_MONITOR (monitor), FALSE);
+ g_return_val_if_fail (G_IS_FILE (file), FALSE);
+
+ return g_hash_table_lookup (monitor->priv->monitors, file) != NULL;
+}
+
+gboolean
+tracker_monitor_is_watched_by_string (TrackerMonitor *monitor,
+ const gchar *path)
+{
+ GFile *file;
+ gboolean watched;
+
+ g_return_val_if_fail (TRACKER_IS_MONITOR (monitor), FALSE);
+ g_return_val_if_fail (path != NULL, FALSE);
+
+ file = g_file_new_for_path (path);
+ watched = g_hash_table_lookup (monitor->priv->monitors, file) != NULL;
+ g_object_unref (file);
+
+ return watched;
+}
+
+guint
+tracker_monitor_get_count (TrackerMonitor *monitor)
+{
+ g_return_val_if_fail (TRACKER_IS_MONITOR (monitor), 0);
+
+ return g_hash_table_size (monitor->priv->monitors);
+}
+
+guint
+tracker_monitor_get_ignored (TrackerMonitor *monitor)
+{
+ g_return_val_if_fail (TRACKER_IS_MONITOR (monitor), 0);
+
+ return monitor->priv->monitors_ignored;
+}
diff --git a/src/libtracker-miner/tracker-monitor.h b/src/libtracker-miner/tracker-monitor.h
index 9fed653..132a530 100644
--- a/src/libtracker-miner/tracker-monitor.h
+++ b/src/libtracker-miner/tracker-monitor.h
@@ -57,6 +57,9 @@ TrackerIndexingTree * tracker_monitor_get_indexing_tree (TrackerMonitor *monitor
void tracker_monitor_set_indexing_tree (TrackerMonitor *monitor,
TrackerIndexingTree *tree);
+gboolean tracker_monitor_get_enabled (TrackerMonitor *monitor);
+void tracker_monitor_set_enabled (TrackerMonitor *monitor,
+ gboolean enabled);
gboolean tracker_monitor_add (TrackerMonitor *monitor,
GFile *file);
gboolean tracker_monitor_remove (TrackerMonitor *monitor,
@@ -66,6 +69,12 @@ gboolean tracker_monitor_remove_recursively (TrackerMonitor *monitor,
gboolean tracker_monitor_move (TrackerMonitor *monitor,
GFile *old_file,
GFile *new_file);
+gboolean tracker_monitor_is_watched (TrackerMonitor *monitor,
+ GFile *file);
+gboolean tracker_monitor_is_watched_by_string (TrackerMonitor *monitor,
+ const gchar *path);
+guint tracker_monitor_get_count (TrackerMonitor *monitor);
+guint tracker_monitor_get_ignored (TrackerMonitor *monitor);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]