[tracker/writeback-refactor-rebase: 4/28] libtracker-miner: Add signal to connect to for writeback



commit ac6d9a4782cbeca70829587378e9e85e07bd4afc
Author: Philip Van Hoof <philip codeminded be>
Date:   Fri Jul 8 17:04:57 2011 +0200

    libtracker-miner: Add signal to connect to for writeback

 src/libtracker-miner/tracker-marshal.list |    1 +
 src/libtracker-miner/tracker-miner-fs.c   |   55 ++++++++++++++++++++++-------
 src/libtracker-miner/tracker-miner-fs.h   |    7 +++-
 3 files changed, 49 insertions(+), 14 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-marshal.list b/src/libtracker-miner/tracker-marshal.list
index eb7e526..d045146 100644
--- a/src/libtracker-miner/tracker-marshal.list
+++ b/src/libtracker-miner/tracker-marshal.list
@@ -11,3 +11,4 @@ BOOL:OBJECT,OBJECT,OBJECT
 BOOL:OBJECT,OBJECT
 BOOL:OBJECT,POINTER
 BOOL:OBJECT
+BOOL:OBJECT,BOXED
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index ba5bd92..e6988d7 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -126,8 +126,8 @@ typedef struct {
 } ItemMovedData;
 
 typedef struct {
-	GFile *file;
-	/* TODO */
+	GFile     *file;
+	GPtrArray *results;
 } ItemWritebackData;
 
 typedef struct {
@@ -277,6 +277,7 @@ enum {
 	PROCESS_FILE_ATTRIBUTES,
 	IGNORE_NEXT_UPDATE_FILE,
 	FINISHED,
+	WRITEBACK_FILE,
 	LAST_SIGNAL
 };
 
@@ -669,6 +670,31 @@ tracker_miner_fs_class_init (TrackerMinerFSClass *klass)
 		              G_TYPE_UINT,
 		              G_TYPE_UINT);
 
+	/**
+	 * TrackerMinerFS::writeback-file:
+	 * @miner_fs: the #TrackerMinerFS
+	 * @file: a #GFile
+	 * @results: a set of results prepared by the preparation query
+	 *
+	 * The ::writeback-file signal is emitted whenever a file must be written
+	 * back
+	 *
+	 * Returns: %TRUE on success, %FALSE otherwise
+	 *
+	 * Since: 0.10.20
+	 **/
+	signals[WRITEBACK_FILE] =
+		g_signal_new ("writeback-file",
+		              G_OBJECT_CLASS_TYPE (object_class),
+		              G_SIGNAL_RUN_LAST,
+		              G_STRUCT_OFFSET (TrackerMinerFSClass, writeback_file),
+		              NULL,
+		              NULL,
+		              tracker_marshal_BOOLEAN__OBJECT_BOXED,
+		              G_TYPE_BOOLEAN, 2,
+		              G_TYPE_FILE,
+		              G_TYPE_PTR_ARRAY);
+
 	g_type_class_add_private (object_class, sizeof (TrackerMinerFSPrivate));
 }
 
@@ -1181,13 +1207,14 @@ item_moved_data_free (ItemMovedData *data)
 }
 
 static ItemWritebackData *
-item_writeback_data_new (GFile *file)
+item_writeback_data_new (GFile     *file,
+                         GPtrArray *results)
 {
 	ItemWritebackData *data;
 
-	/* TODO */
 	data = g_slice_new (ItemWritebackData);
 	data->file = g_object_ref (file);
+	data->results = g_ptr_array_ref (results);
 
 	return data;
 }
@@ -1196,6 +1223,7 @@ static void
 item_writeback_data_free (ItemWritebackData *data)
 {
 	g_object_unref (data->file);
+	g_ptr_array_unref (data->results);
 	g_slice_free (ItemWritebackData, data);
 }
 
@@ -2704,14 +2732,13 @@ item_queue_get_next_file (TrackerMinerFS  *fs,
 	wdata = tracker_priority_queue_pop (fs->priv->items_writeback,
 					    &priority);
 	if (wdata) {
-		*file = g_object_ref (data->file);
-
-		*file = queue_file;
+		*file = g_object_ref (wdata->file);
 		*source_file = NULL;
 
-		trace_eq_pop_head ("WRITEBACK", queue_file);
+		trace_eq_pop_head ("WRITEBACK", wdata->file);
 
-		/* TODO */
+		g_signal_emit (fs, signals[WRITEBACK_FILE], 0,
+		               wdata->file, wdata->results);
 
 		item_writeback_data_free (wdata);
 
@@ -4660,6 +4687,7 @@ tracker_miner_fs_check_file_with_priority (TrackerMinerFS *fs,
  * tracker_miner_fs_writeback_file:
  * @fs: a #TrackerMinerFS
  * @file: #GFile for the file to check
+ @ @results: A array of results from the preparation query
  *
  * Tells the filesystem miner to writeback a file.
  *
@@ -4667,7 +4695,8 @@ tracker_miner_fs_check_file_with_priority (TrackerMinerFS *fs,
  **/
 void
 tracker_miner_fs_writeback_file (TrackerMinerFS *fs,
-                                 GFile          *file)
+                                 GFile          *file,
+                                 GPtrArray      *results)
 {
 	gchar *path;
 	ItemWritebackData *data;
@@ -4680,10 +4709,10 @@ tracker_miner_fs_writeback_file (TrackerMinerFS *fs,
 	g_debug ("%s (WRITEBACK) (requested by application)",
 	         path);
 
-	trace_eq_push_tail ("UPDATED", file, "Requested by application");
+	trace_eq_push_tail ("WRITEBACK", file, "Requested by application");
 
-	data = item_writeback_data_new (file);
-	g_queue_push_tail (fs->priv->items_updated,
+	data = item_writeback_data_new (file, results);
+	g_queue_push_tail (fs->priv->items_writeback,
 	                   data);
 
 	item_queue_handlers_set_up (fs);
diff --git a/src/libtracker-miner/tracker-miner-fs.h b/src/libtracker-miner/tracker-miner-fs.h
index 137912d..9913e49 100644
--- a/src/libtracker-miner/tracker-miner-fs.h
+++ b/src/libtracker-miner/tracker-miner-fs.h
@@ -73,6 +73,7 @@ struct _TrackerMinerFS {
  * @finished: Called when all processing has been performed.
  * @process_file_attributes: Called when the metadata associated with
  * a file's attributes changes, for example, the mtime.
+ * @writeback_file: Called when a file must be written back
  *
  * Prototype for the abstract class, @check_file, @check_directory,
  * @check_directory_contents, @process_file and @monitor_directory
@@ -104,6 +105,9 @@ typedef struct {
 	                                       GFile                *file,
 	                                       TrackerSparqlBuilder *builder,
 	                                       GCancellable         *cancellable);
+	gboolean (* writeback_file)           (TrackerMinerFS       *fs,
+	                                       GFile                *file,
+	                                       GPtrArray            *results);
 } TrackerMinerFSClass;
 
 GType                 tracker_miner_fs_get_type             (void) G_GNUC_CONST;
@@ -126,7 +130,8 @@ void                  tracker_miner_fs_check_file           (TrackerMinerFS *fs,
                                                              GFile          *file,
                                                              gboolean        check_parents);
 void                  tracker_miner_fs_writeback_file       (TrackerMinerFS *fs,
-                                                             GFile          *file);
+                                                             GFile          *file,
+                                                             GPtrArray      *results);
 void                  tracker_miner_fs_check_directory      (TrackerMinerFS *fs,
                                                              GFile          *file,
                                                              gboolean        check_parents);



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