[tracker] libtracker-miner: Added tracker_miner_fs_get_directories()
- From: Martyn James Russell <mr src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker] libtracker-miner: Added tracker_miner_fs_get_directories()
- Date: Sun, 7 Feb 2010 12:11:07 +0000 (UTC)
commit 85d4b2497794792c6f9b56fa26998e65b518e729
Author: Martyn Russell <martyn lanedo com>
Date: Fri Feb 5 16:54:33 2010 +0000
libtracker-miner: Added tracker_miner_fs_get_directories()
This also renames the old APIs:
tracker_miner_fs_add_directory -> directory_add()
tracker_miner_fs_remove_directory -> directory_remove()
tracker_miner_fs_add_file -> file_add()
tracker_miner_fs_notify_file -> file_notify()
examples/libtracker-miner/tracker-main.c | 2 +-
src/libtracker-miner/tracker-miner-fs.c | 178 +++++++++++---------
src/libtracker-miner/tracker-miner-fs.h | 17 +-
src/tracker-miner-fs/tracker-miner-applications.c | 6 +-
src/tracker-miner-fs/tracker-miner-files-reindex.c | 2 +-
src/tracker-miner-fs/tracker-miner-files.c | 18 +-
6 files changed, 119 insertions(+), 104 deletions(-)
---
diff --git a/examples/libtracker-miner/tracker-main.c b/examples/libtracker-miner/tracker-main.c
index be3986b..b88c662 100644
--- a/examples/libtracker-miner/tracker-main.c
+++ b/examples/libtracker-miner/tracker-main.c
@@ -183,7 +183,7 @@ add_directory_path (TrackerMinerFS *fs,
GFile *file;
file = g_file_new_for_path (path);
- tracker_miner_fs_add_directory (fs, file, recurse);
+ tracker_miner_fs_directory_add (fs, file, recurse);
g_object_unref (file);
}
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index ee367b1..8b02ac4 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -1855,7 +1855,7 @@ monitor_item_created_cb (TrackerMonitor *monitor,
if (should_process) {
if (is_directory) {
- tracker_miner_fs_add_directory (fs, file, TRUE);
+ tracker_miner_fs_directory_add (fs, file, TRUE);
} else {
g_queue_push_tail (fs->private->items_created,
g_object_ref (file));
@@ -1969,7 +1969,7 @@ monitor_item_moved_cb (TrackerMonitor *monitor,
path);
/* If the source is not monitored, we need to crawl it. */
- tracker_miner_fs_add_directory (fs, other_file, TRUE);
+ tracker_miner_fs_directory_add (fs, other_file, TRUE);
g_free (path);
}
@@ -2010,7 +2010,7 @@ monitor_item_moved_cb (TrackerMonitor *monitor,
g_debug ("Not in store:'?'->'%s' (DIR) (move monitor event, source monitored)",
path);
- tracker_miner_fs_add_directory (fs, other_file, TRUE);
+ tracker_miner_fs_directory_add (fs, other_file, TRUE);
}
} else if (!should_process_other) {
/* Delete old file */
@@ -2252,7 +2252,7 @@ crawl_directories_stop (TrackerMinerFS *fs)
}
/**
- * tracker_miner_fs_add_directory:
+ * tracker_miner_fs_directory_add:
* @fs: a #TrackerMinerFS
* @file: #GFile for the directory to inspect
* @recurse: whether the directory should be inspected recursively
@@ -2260,7 +2260,7 @@ crawl_directories_stop (TrackerMinerFS *fs)
* Tells the filesystem miner to inspect a directory.
**/
void
-tracker_miner_fs_add_directory (TrackerMinerFS *fs,
+tracker_miner_fs_directory_add (TrackerMinerFS *fs,
GFile *file,
gboolean recurse)
{
@@ -2274,42 +2274,6 @@ tracker_miner_fs_add_directory (TrackerMinerFS *fs,
crawl_directories_start (fs);
}
-/**
- * tracker_miner_fs_add_file:
- * @fs: a #TrackerMinerFS
- * @file: #GFile for the file to inspect
- *
- * Tells the filesystem miner to inspect a file.
- **/
-void
-tracker_miner_fs_add_file (TrackerMinerFS *fs,
- GFile *file)
-{
- gboolean should_process;
- gchar *path;
-
- g_return_if_fail (TRACKER_IS_MINER_FS (fs));
- g_return_if_fail (G_IS_FILE (file));
-
- should_process = should_check_file (fs, file, FALSE);
-
- path = g_file_get_path (file);
-
- g_debug ("%s:'%s' (FILE) (requested by application)",
- should_process ? "Found " : "Ignored",
- path);
-
- if (should_process) {
- g_queue_push_tail (fs->private->items_updated,
- g_object_ref (file));
-
- item_queue_handlers_set_up (fs);
- }
-
- g_free (path);
-}
-
-
static void
check_files_removal (GQueue *queue,
GFile *parent)
@@ -2333,7 +2297,7 @@ check_files_removal (GQueue *queue,
}
/**
- * tracker_miner_fs_remove_directory:
+ * tracker_miner_fs_directory_remove:
* @fs: a #TrackerMinerFS
* @file: #GFile for the directory to be removed
*
@@ -2342,7 +2306,7 @@ check_files_removal (GQueue *queue,
* Returns: %TRUE if the directory was successfully removed.
**/
gboolean
-tracker_miner_fs_remove_directory (TrackerMinerFS *fs,
+tracker_miner_fs_directory_remove (TrackerMinerFS *fs,
GFile *file)
{
TrackerMinerFSPrivate *priv;
@@ -2406,6 +2370,87 @@ tracker_miner_fs_remove_directory (TrackerMinerFS *fs,
}
/**
+ * tracker_miner_fs_file_add:
+ * @fs: a #TrackerMinerFS
+ * @file: #GFile for the file to inspect
+ *
+ * Tells the filesystem miner to inspect a file.
+ **/
+void
+tracker_miner_fs_file_add (TrackerMinerFS *fs,
+ GFile *file)
+{
+ gboolean should_process;
+ gchar *path;
+
+ g_return_if_fail (TRACKER_IS_MINER_FS (fs));
+ g_return_if_fail (G_IS_FILE (file));
+
+ should_process = should_check_file (fs, file, FALSE);
+
+ path = g_file_get_path (file);
+
+ g_debug ("%s:'%s' (FILE) (requested by application)",
+ should_process ? "Found " : "Ignored",
+ path);
+
+ if (should_process) {
+ g_queue_push_tail (fs->private->items_updated,
+ g_object_ref (file));
+
+ item_queue_handlers_set_up (fs);
+ }
+
+ g_free (path);
+}
+
+/**
+ * tracker_miner_fs_file_notify:
+ * @fs: a #TrackerMinerFS
+ * @file: a #GFile
+ * @error: a #GError with the error that happened during processing, or %NULL.
+ *
+ * Notifies @fs that all processing on @file has been finished, if any error
+ * happened during file data processing, it should be passed in @error, else
+ * that parameter will contain %NULL to reflect success.
+ **/
+void
+tracker_miner_fs_file_notify (TrackerMinerFS *fs,
+ GFile *file,
+ const GError *error)
+{
+ ProcessData *data;
+
+ g_return_if_fail (TRACKER_IS_MINER_FS (fs));
+ g_return_if_fail (G_IS_FILE (file));
+
+ fs->private->total_files_notified++;
+
+ if (error) {
+ fs->private->total_files_notified_error++;
+ }
+
+ data = process_data_find (fs, file);
+
+ if (!data) {
+ gchar *uri;
+
+ uri = g_file_get_uri (file);
+ g_critical ("%s has notified that file '%s' has been processed, "
+ "but that file was not in the processing queue. "
+ "This is an implementation error, please ensure that "
+ "tracker_miner_fs_notify_file() is called on the right "
+ "file and that the ::process-file signal didn't return "
+ "FALSE for it", G_OBJECT_TYPE_NAME (fs), uri);
+ g_free (uri);
+
+ return;
+ }
+
+ item_add_or_update_cb (fs, data, error);
+}
+
+/**
* tracker_miner_fs_set_throttle:
* @fs: a #TrackerMinerFS
* @throttle: throttle value, between 0 and 1
@@ -2464,47 +2509,18 @@ tracker_miner_fs_get_throttle (TrackerMinerFS *fs)
}
/**
- * tracker_miner_fs_notify_file:
+ * tracker_miner_fs_get_throttle:
* @fs: a #TrackerMinerFS
- * @file: a #GFile
- * @error: a #GError with the error that happened during processing, or %NULL.
*
- * Notifies @fs that all processing on @file has been finished, if any error
- * happened during file data processing, it should be passed in @error, else
- * that parameter will contain %NULL to reflect success.
+ * Gets the current throttle value. see tracker_miner_fs_set_throttle().
+ *
+ * Returns: current throttle value.
**/
-void
-tracker_miner_fs_notify_file (TrackerMinerFS *fs,
- GFile *file,
- const GError *error)
+GList *
+tracker_miner_fs_get_directories (TrackerMinerFS *fs)
{
- ProcessData *data;
-
- g_return_if_fail (TRACKER_IS_MINER_FS (fs));
- g_return_if_fail (G_IS_FILE (file));
-
- fs->private->total_files_notified++;
-
- if (error) {
- fs->private->total_files_notified_error++;
- }
-
- data = process_data_find (fs, file);
-
- if (!data) {
- gchar *uri;
-
- uri = g_file_get_uri (file);
- g_critical ("%s has notified that file '%s' has been processed, "
- "but that file was not in the processing queue. "
- "This is an implementation error, please ensure that "
- "tracker_miner_fs_notify_file() is called on the right "
- "file and that the ::process-file signal didn't return "
- "FALSE for it", G_OBJECT_TYPE_NAME (fs), uri);
- g_free (uri);
-
- return;
- }
+ g_return_val_if_fail (TRACKER_IS_MINER_FS (fs), 0);
- item_add_or_update_cb (fs, data, error);
+ return fs->private->directories;
}
+
diff --git a/src/libtracker-miner/tracker-miner-fs.h b/src/libtracker-miner/tracker-miner-fs.h
index 557b17f..456dba7 100644
--- a/src/libtracker-miner/tracker-miner-fs.h
+++ b/src/libtracker-miner/tracker-miner-fs.h
@@ -91,21 +91,20 @@ typedef struct {
GType tracker_miner_fs_get_type (void) G_GNUC_CONST;
-void tracker_miner_fs_add_directory (TrackerMinerFS *fs,
+void tracker_miner_fs_directory_add (TrackerMinerFS *fs,
GFile *file,
gboolean recurse);
-gboolean tracker_miner_fs_remove_directory (TrackerMinerFS *fs,
+gboolean tracker_miner_fs_directory_remove (TrackerMinerFS *fs,
GFile *file);
-
+void tracker_miner_fs_file_add (TrackerMinerFS *fs,
+ GFile *file);
+void tracker_miner_fs_file_notify (TrackerMinerFS *fs,
+ GFile *file,
+ const GError *error);
void tracker_miner_fs_set_throttle (TrackerMinerFS *fs,
gdouble throttle);
gdouble tracker_miner_fs_get_throttle (TrackerMinerFS *fs);
-
-void tracker_miner_fs_notify_file (TrackerMinerFS *fs,
- GFile *file,
- const GError *error);
-void tracker_miner_fs_add_file (TrackerMinerFS *fs,
- GFile *file);
+GList * tracker_miner_fs_get_directories (TrackerMinerFS *fs);
G_END_DECLS
diff --git a/src/tracker-miner-fs/tracker-miner-applications.c b/src/tracker-miner-fs/tracker-miner-applications.c
index 3b52793..b8968c0 100644
--- a/src/tracker-miner-fs/tracker-miner-applications.c
+++ b/src/tracker-miner-fs/tracker-miner-applications.c
@@ -101,11 +101,11 @@ miner_applications_constructed (GObject *object)
G_OBJECT_CLASS (tracker_miner_applications_parent_class)->constructed (object);
file = g_file_new_for_path ("/usr/share/applications/");
- tracker_miner_fs_add_directory (TRACKER_MINER_FS (object), file, TRUE);
+ tracker_miner_fs_directory_add (TRACKER_MINER_FS (object), file, TRUE);
g_object_unref (file);
file = g_file_new_for_path ("/usr/share/desktop-directories/");
- tracker_miner_fs_add_directory (TRACKER_MINER_FS (object), file, TRUE);
+ tracker_miner_fs_directory_add (TRACKER_MINER_FS (object), file, TRUE);
g_object_unref (file);
/* FIXME: Check XDG_DATA_DIRS and also process applications in there */
@@ -417,7 +417,7 @@ miner_applications_process_file_cb (gpointer user_data)
tracker_sparql_builder_insert_close (sparql);
/* Notify about success */
- tracker_miner_fs_notify_file (data->miner, data->file, NULL);
+ tracker_miner_fs_file_notify (data->miner, data->file, NULL);
g_strfreev (cats);
diff --git a/src/tracker-miner-fs/tracker-miner-files-reindex.c b/src/tracker-miner-fs/tracker-miner-files-reindex.c
index d9118fd..0849bc3 100644
--- a/src/tracker-miner-fs/tracker-miner-files-reindex.c
+++ b/src/tracker-miner-fs/tracker-miner-files-reindex.c
@@ -182,7 +182,7 @@ mime_types_cb (GPtrArray *result,
if (row && row[0]) {
const gchar *url = (const gchar *) row[0];
GFile *file = g_file_new_for_uri (url);
- tracker_miner_fs_add_file (TRACKER_MINER_FS (mtd->miner_files), file);
+ tracker_miner_fs_file_add (TRACKER_MINER_FS (mtd->miner_files), file);
g_object_unref (file);
}
}
diff --git a/src/tracker-miner-fs/tracker-miner-files.c b/src/tracker-miner-fs/tracker-miner-files.c
index efb0bfe..021451a 100644
--- a/src/tracker-miner-fs/tracker-miner-files.c
+++ b/src/tracker-miner-fs/tracker-miner-files.c
@@ -351,7 +351,7 @@ miner_files_constructed (GObject *object)
g_message (" Adding:'%s'", (gchar*) dirs->data);
file = g_file_new_for_path (dirs->data);
- tracker_miner_fs_add_directory (fs, file, FALSE);
+ tracker_miner_fs_directory_add (fs, file, FALSE);
g_object_unref (file);
}
@@ -391,7 +391,7 @@ miner_files_constructed (GObject *object)
g_message (" Adding:'%s'", (gchar*) dirs->data);
file = g_file_new_for_path (dirs->data);
- tracker_miner_fs_add_directory (fs, file, TRUE);
+ tracker_miner_fs_directory_add (fs, file, TRUE);
g_object_unref (file);
}
@@ -410,7 +410,7 @@ miner_files_constructed (GObject *object)
#endif
g_message (" Adding:'%s'", (gchar*) m->data);
- tracker_miner_fs_add_directory (TRACKER_MINER_FS (mf),
+ tracker_miner_fs_directory_add (TRACKER_MINER_FS (mf),
file,
TRUE);
g_object_unref (file);
@@ -732,7 +732,7 @@ mount_point_added_cb (TrackerStorage *storage,
g_strdup (udi),
(GDestroyNotify) g_free);
- tracker_miner_fs_add_directory (TRACKER_MINER_FS (user_data),
+ tracker_miner_fs_directory_add (TRACKER_MINER_FS (user_data),
file,
TRUE);
g_object_unref (file);
@@ -832,7 +832,7 @@ mount_pre_unmount_cb (GVolumeMonitor *volume_monitor,
GFile *mount_root;
mount_root = g_mount_get_root (mount);
- tracker_miner_fs_remove_directory (TRACKER_MINER_FS (mf), mount_root);
+ tracker_miner_fs_directory_remove (TRACKER_MINER_FS (mf), mount_root);
g_object_unref (mount_root);
}
@@ -1257,7 +1257,7 @@ extractor_get_embedded_metadata_cb (DBusGProxy *proxy,
if (error) {
/* Something bad happened, notify about the error */
- tracker_miner_fs_notify_file (TRACKER_MINER_FS (data->miner), data->file, error);
+ tracker_miner_fs_file_notify (TRACKER_MINER_FS (data->miner), data->file, error);
process_file_data_free (data);
g_error_free (error);
return;
@@ -1313,7 +1313,7 @@ extractor_get_embedded_metadata_cb (DBusGProxy *proxy,
}
/* Notify about the success */
- tracker_miner_fs_notify_file (TRACKER_MINER_FS (data->miner), data->file, NULL);
+ tracker_miner_fs_file_notify (TRACKER_MINER_FS (data->miner), data->file, NULL);
process_file_data_free (data);
g_free (preupdate);
@@ -1331,7 +1331,7 @@ extractor_get_embedded_metadata_cancel (GCancellable *cancellable,
data->call);
error = g_error_new_literal (miner_files_error_quark, 0, "Embedded metadata extraction was cancelled");
- tracker_miner_fs_notify_file (TRACKER_MINER_FS (data->miner), data->file, error);
+ tracker_miner_fs_file_notify (TRACKER_MINER_FS (data->miner), data->file, error);
process_file_data_free (data);
g_error_free (error);
@@ -1372,7 +1372,7 @@ process_file_cb (GObject *object,
if (error) {
/* Something bad happened, notify about the error */
- tracker_miner_fs_notify_file (TRACKER_MINER_FS (data->miner), file, error);
+ tracker_miner_fs_file_notify (TRACKER_MINER_FS (data->miner), file, error);
process_file_data_free (data);
g_error_free (error);
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]