[tracker] tracker-extract: push all albumart code to tracker-miner-fs



commit 2bf21059b68b51103c8c700e5f7dba400e91f492
Author: Martyn Russell <martyn imendio com>
Date:   Mon Jul 27 15:56:50 2009 +0100

    tracker-extract: push all albumart code to tracker-miner-fs
    
    Now we signal data that is used to be processed for albumart. This is
    all handled in the miner-fs now, so the extractors simply say, here is
    my data and length of data (and some other details like artist), now
    process it. The miner-fs then uses the code previously
    tracker-extract-albumart.c to either download the art, use GdkPixbuf
    or save the data directly to the right filename. The thumbnails are
    then requested staight after.

 data/dbus/tracker-extract.xml                      |    9 +-
 src/libtracker-common/tracker-albumart.c           |  153 ++++++++-----
 src/libtracker-common/tracker-albumart.h           |    2 -
 src/libtracker-common/tracker-thumbnailer.c        |   20 +-
 src/libtracker-common/tracker-thumbnailer.h        |   17 +-
 src/tracker-extract/Makefile.am                    |   27 ++-
 src/tracker-extract/tracker-extract-gstreamer.c    |   35 ++--
 src/tracker-extract/tracker-extract-mp3.c          |   52 +++--
 src/tracker-extract/tracker-extract.c              |   44 +++-
 src/tracker-extract/tracker-extract.h              |    9 +-
 src/tracker-extract/tracker-main.c                 |   41 ++--
 src/tracker-extract/tracker-marshal-main.c         |    2 +
 src/tracker-extract/tracker-marshal.list           |    1 +
 src/tracker-miner-fs/Makefile.am                   |    8 +-
 .../tracker-albumart.c                             |  217 ++++++++++++------
 .../tracker-albumart.h                             |   17 +-
 src/tracker-miner-fs/tracker-indexer.c             |  244 ++++++++++++--------
 src/tracker-miner-fs/tracker-indexer.h             |    5 +-
 src/tracker-miner-fs/tracker-main.c                |   24 ++-
 src/tracker-miner-fs/tracker-marshal.list          |    1 +
 tests/libtracker-common/tracker-thumbnailer-test.c |    8 +-
 21 files changed, 580 insertions(+), 356 deletions(-)
---
diff --git a/data/dbus/tracker-extract.xml b/data/dbus/tracker-extract.xml
index 65580bf..20dc59b 100644
--- a/data/dbus/tracker-extract.xml
+++ b/data/dbus/tracker-extract.xml
@@ -22,8 +22,13 @@
       <arg type="s" name="sparql" direction="out" />
     </method>
 
-    <signal name="NeedsThumbnailing">
-      <arg type="s" name="uri"/>
+    <signal name="ProcessAlbumArt">
+      <arg type="y" name="buffer"/>
+      <arg type="i" name="size"/>
+      <arg type="s" name="mime"/>
+      <arg type="s" name="artist"/>
+      <arg type="s" name="album"/>
+      <arg type="s" name="filename"/>
     </signal>
   </interface>
 </node>
diff --git a/src/libtracker-common/tracker-albumart.c b/src/libtracker-common/tracker-albumart.c
index 5e07d40..8911314 100644
--- a/src/libtracker-common/tracker-albumart.c
+++ b/src/libtracker-common/tracker-albumart.c
@@ -1,6 +1,5 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /*
- * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
  * Copyright (C) 2008, Nokia
 
  * This library is free software; you can redistribute it and/or
@@ -63,16 +62,17 @@ typedef struct {
 static gboolean no_more_requesting = FALSE;
 
 static gchar *
-my_compute_checksum_for_data (GChecksumType  checksum_type,
-                              const guchar  *data,
-                              gsize          length)
+checksum_for_data (GChecksumType  checksum_type,
+		   const guchar  *data,
+		   gsize          length)
 {
 	GChecksum *checksum;
 	gchar *retval;
 	
 	checksum = g_checksum_new (checksum_type);
-	if (!checksum)
+	if (!checksum) {
 		return NULL;
+	}
 	
 	g_checksum_update (checksum, data, length);
 	retval = g_strdup (g_checksum_get_string (checksum));
@@ -304,9 +304,9 @@ tracker_albumart_strip_invalid_entities (const gchar *original)
 }
 
 void
-tracker_albumart_copy_to_local (TrackerStorage  *hal,
-				const gchar *filename, 
-				const gchar *local_uri)
+tracker_albumart_copy_to_local (TrackerStorage *hal,
+				const gchar    *filename, 
+				const gchar    *local_uri)
 {
 	GList *removable_roots, *l;
 	gboolean on_removable_device = FALSE;
@@ -371,9 +371,8 @@ tracker_albumart_copy_to_local (TrackerStorage  *hal,
 }
 
 gboolean 
-tracker_albumart_heuristic (const gchar *artist_,  
-			    const gchar *album_, 
-			    const gchar *tracks_str, 
+tracker_albumart_heuristic (const gchar *artist,  
+			    const gchar *album, 
 			    const gchar *filename,
 			    const gchar *local_uri,
 			    gboolean    *copied)
@@ -386,13 +385,25 @@ tracker_albumart_heuristic (const gchar *artist_,
 	const gchar *name;
 	gboolean retval;
 	gint count;
-	gchar *artist = NULL;
-	gchar *album = NULL;
+	gchar *artist_stripped = NULL;
+	gchar *album_stripped = NULL;
+
+	g_return_val_if_fail (artist != NULL, FALSE);
+	g_return_val_if_fail (album != NULL, FALSE);
+	g_return_val_if_fail (filename != NULL, FALSE);
 
 	if (copied) {
 		*copied = FALSE;
 	}
 
+	if (artist) {
+		artist_stripped = tracker_albumart_strip_invalid_entities (artist);
+	}
+
+	if (album) {
+		album_stripped = tracker_albumart_strip_invalid_entities (album);
+	}
+
 	/* Copy from local album art (.mediaartlocal) to spec */
 	if (local_uri) {
 		GFile *local_file;
@@ -400,7 +411,8 @@ tracker_albumart_heuristic (const gchar *artist_,
 		local_file = g_file_new_for_uri (local_uri);
 		
 		if (g_file_query_exists (local_file, NULL)) {
-			tracker_albumart_get_path (artist, album, 
+			tracker_albumart_get_path (artist_stripped, 
+						   album_stripped, 
 						   "album", NULL, 
 						   &target, NULL);
 			if (target) {
@@ -418,6 +430,8 @@ tracker_albumart_heuristic (const gchar *artist_,
 			}
 
 			g_free (target);
+			g_free (artist_stripped);
+			g_free (album_stripped);
 			
 			return TRUE;
 		}
@@ -432,13 +446,19 @@ tracker_albumart_heuristic (const gchar *artist_,
 	g_object_unref (dirf);
 
 	if (!dirname) {
+		g_free (artist_stripped);
+		g_free (album_stripped);
+
 		return FALSE;
 	}
 
 	dir = g_dir_open (dirname, 0, NULL);
 
 	if (!dir) {
+		g_free (artist_stripped);
+		g_free (album_stripped);
 		g_free (dirname);
+
 		return FALSE;
 	}
 
@@ -448,21 +468,17 @@ tracker_albumart_heuristic (const gchar *artist_,
 	if (g_stat (dirname, &st) == -1) {
 		g_warning ("Could not g_stat() directory:'%s' for albumart heuristic",
 			   dirname);
+
 		g_free (dirname);
+		g_free (artist_stripped);
+		g_free (album_stripped);
+
 		return FALSE;
 	}
 
 	/* do not count . and .. */
 	count = st.st_nlink - 2;
 	
-	if (artist_) {
-		artist = tracker_albumart_strip_invalid_entities (artist_);
-	}
-
-	if (album_) {
-		album = tracker_albumart_strip_invalid_entities (album_);
-	}
-
 	/* If amount of files and amount of tracks in the album somewhat match */
 
 	if (count >= 2 && count < 50) {
@@ -470,15 +486,16 @@ tracker_albumart_heuristic (const gchar *artist_,
 
 		/* Try to find cover art in the directory */
 		for (name = g_dir_read_name (dir); name; name = g_dir_read_name (dir)) {
-			if ((artist && strcasestr (name, artist)) || 
-			    (album && strcasestr (name, album))   || 
+			if ((artist_stripped && strcasestr (name, artist_stripped)) || 
+			    (album_stripped && strcasestr (name, album_stripped))   || 
 			    (strcasestr (name, "cover"))) {
 				GError *error = NULL;
 				
 				if (g_str_has_suffix (name, "jpeg") || 
 				    g_str_has_suffix (name, "jpg")) {
 					if (!target) {
-						tracker_albumart_get_path (artist, album, 
+						tracker_albumart_get_path (artist_stripped,
+									   album_stripped, 
 									   "album", NULL, 
 									   &target, NULL);
 					}
@@ -519,8 +536,8 @@ tracker_albumart_heuristic (const gchar *artist_,
 							retval = FALSE;
 						} else {
 							if (!target) {
-								tracker_albumart_get_path (artist, 
-											   album, 
+								tracker_albumart_get_path (artist_stripped, 
+											   album_stripped, 
 											   "album", 
 											   NULL, 
 											   &target, 
@@ -560,8 +577,8 @@ tracker_albumart_heuristic (const gchar *artist_,
 
 	g_free (target);
 	g_free (dirname);
-	g_free (artist);
-	g_free (album);
+	g_free (artist_stripped);
+	g_free (album_stripped);
 
 	return retval;
 }
@@ -618,7 +635,7 @@ tracker_albumart_queue_cb (DBusGProxy     *proxy,
 		gchar *uri;
 		
 		uri = g_filename_to_uri (info->art_path, NULL, NULL);
-		tracker_thumbnailer_queue_file (uri, "image/jpeg");
+		tracker_thumbnailer_queue_add (uri, "image/jpeg");
 		g_free (uri);
 
 		tracker_albumart_copy_to_local (info->hal,
@@ -637,8 +654,8 @@ tracker_albumart_queue_cb (DBusGProxy     *proxy,
 }
 
 void
-tracker_albumart_get_path (const gchar  *a, 
-			   const gchar  *b, 
+tracker_albumart_get_path (const gchar  *artist, 
+			   const gchar  *album, 
 			   const gchar  *prefix, 
 			   const gchar  *uri,
 			   gchar       **path,
@@ -646,9 +663,12 @@ tracker_albumart_get_path (const gchar  *a,
 {
 	gchar *art_filename;
 	gchar *dir;
-	gchar *down1, *down2;
-	gchar *str1 = NULL, *str2 = NULL;
-	gchar *f_a = NULL, *f_b = NULL;
+	gchar *artist_down, *album_down;
+	gchar *artist_stripped, *album_stripped;
+	gchar *artist_checksum, *album_checksum;
+
+	/* g_return_if_fail ((local_uri != NULL && uri != NULL) || local_uri == NULL); */
+	/* g_return_if_fail (artist != NULL || album != NULL); */
 
 	/* http://live.gnome.org/MediaArtStorageSpec */
 
@@ -660,46 +680,54 @@ tracker_albumart_get_path (const gchar  *a,
 		*local_uri = NULL;
 	}
 
-	if (!a && !b) {
+	if (!artist && !album) {
 		return;
 	}
 
-	if (!a) {
-		f_a = g_strdup (" ");
+	if (!artist) {
+		artist_stripped = g_strdup (" ");
 	} else {
-		f_a = tracker_albumart_strip_invalid_entities (a);
+		artist_stripped = tracker_albumart_strip_invalid_entities (artist);
 	}
 
-	if (!b) {
-		f_b = g_strdup (" ");
+	if (!album) {
+		album_stripped = g_strdup (" ");
 	} else {
-		f_b = tracker_albumart_strip_invalid_entities (b); 
+		album_stripped = tracker_albumart_strip_invalid_entities (album); 
 	}
 
-	down1 = g_utf8_strdown (f_a, -1);
-	down2 = g_utf8_strdown (f_b, -1);
+	artist_down = g_utf8_strdown (artist_stripped, -1);
+	album_down = g_utf8_strdown (album_stripped, -1);
 
-	g_free (f_a);
-	g_free (f_b);
+	g_free (artist_stripped);
+	g_free (album_stripped);
 
-	dir = g_build_filename (g_get_user_cache_dir (), "media-art", NULL);
+	dir = g_build_filename (g_get_user_cache_dir (), 
+				"media-art", 
+				NULL);
 
 	if (!g_file_test (dir, G_FILE_TEST_EXISTS)) {
 		g_mkdir_with_parents (dir, 0770);
 	}
 
-	str1 = my_compute_checksum_for_data (G_CHECKSUM_MD5, (const guchar *) down1, strlen (down1));
-	str2 = my_compute_checksum_for_data (G_CHECKSUM_MD5, (const guchar *) down2, strlen (down2));
-
-	g_free (down1);
-	g_free (down2);
+	artist_checksum = checksum_for_data (G_CHECKSUM_MD5, 
+					     (const guchar *) artist_down, 
+					     strlen (artist_down));
+	album_checksum = checksum_for_data (G_CHECKSUM_MD5, 
+					    (const guchar *) album_down, 
+					    strlen (album_down));
+	
+	g_free (artist_down);
+	g_free (album_down);
 
 	art_filename = g_strdup_printf ("%s-%s-%s.jpeg", 
 					prefix ? prefix : "album", 
-					str1, 
-					str2);
+					artist_checksum, 
+					album_checksum);
 
-	*path = g_build_filename (dir, art_filename, NULL);
+	if (path) {
+		*path = g_build_filename (dir, art_filename, NULL);
+	}
 
 	if (local_uri) {
 		gchar *local_dir;
@@ -724,19 +752,20 @@ tracker_albumart_get_path (const gchar  *a,
 
 	g_free (dir);
 	g_free (art_filename);
-	g_free (str1);
-	g_free (str2);
+	g_free (artist_checksum);
+	g_free (album_checksum);
 }
 
 void
 tracker_albumart_request_download (TrackerStorage *hal,
-				   const gchar *album, 
-				   const gchar *artist, 
-				   const gchar *local_uri, 
-				   const gchar *art_path)
+				   const gchar    *album, 
+				   const gchar    *artist, 
+				   const gchar    *local_uri, 
+				   const gchar    *art_path)
 {
 	GetFileInfo *info;
 
+
 	if (no_more_requesting) {
 		return;
 	}
@@ -744,7 +773,7 @@ tracker_albumart_request_download (TrackerStorage *hal,
 	info = g_slice_new (GetFileInfo);
 
 #ifdef HAVE_HAL
-	info->hal = hal?g_object_ref (hal):NULL;
+	info->hal = hal ? g_object_ref (hal) : NULL;
 #else 
 	info->hal = NULL;
 #endif
diff --git a/src/libtracker-common/tracker-albumart.h b/src/libtracker-common/tracker-albumart.h
index 9a3c3fd..6b4bd08 100644
--- a/src/libtracker-common/tracker-albumart.h
+++ b/src/libtracker-common/tracker-albumart.h
@@ -1,6 +1,5 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /*
- * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
  * Copyright (C) 2008, Nokia
 
  * This library is free software; you can redistribute it and/or
@@ -34,7 +33,6 @@ G_BEGIN_DECLS
 
 gboolean tracker_albumart_heuristic              (const gchar  *artist_,
 						  const gchar  *album_,
-						  const gchar  *tracks_str,
 						  const gchar  *filename,
 						  const gchar  *local_uri,
 						  gboolean     *copied);
diff --git a/src/libtracker-common/tracker-thumbnailer.c b/src/libtracker-common/tracker-thumbnailer.c
index 33d65b4..dd9b8f5 100644
--- a/src/libtracker-common/tracker-thumbnailer.c
+++ b/src/libtracker-common/tracker-thumbnailer.c
@@ -50,7 +50,6 @@ typedef struct {
 	guint request_id;
 
 	gboolean service_is_available;
-	gboolean service_is_enabled;
 } TrackerThumbnailerPrivate;
 
 static GStaticPrivate private_key = G_STATIC_PRIVATE_INIT;
@@ -113,8 +112,6 @@ tracker_thumbnailer_init (void)
 
 	private = g_new0 (TrackerThumbnailerPrivate, 1);
 
-	private->service_is_enabled = TRUE;
-
 	g_static_private_set (&private_key,
 			      private,
 			      private_free);
@@ -224,13 +221,13 @@ tracker_thumbnailer_move (const gchar *from_uri,
 		   to_uri,
 		   private->request_id); 
 
-	if (!strstr (to_uri, ":/")) {
+	if (!strstr (to_uri, "://")) {
 		to[0] = g_filename_to_uri (to_uri, NULL, NULL);
 	} else {
 		to[0] = g_strdup (to_uri);
 	}
 
-	if (!strstr (from_uri, ":/")) {
+	if (!strstr (from_uri, "://")) {
 		from[0] = g_filename_to_uri (from_uri, NULL, NULL);
 	} else {
 		from[0] = g_strdup (from_uri);
@@ -278,7 +275,7 @@ tracker_thumbnailer_remove (const gchar *uri,
 
 	private->request_id++;
 
-	if (!strstr (uri, ":/")) {
+	if (!strstr (uri, "://")) {
 		uris[0] = g_filename_to_uri (uri, NULL, NULL);
 	} else {
 		uris[0] = g_strdup (uri);
@@ -302,6 +299,8 @@ tracker_thumbnailer_cleanup (const gchar *uri_prefix)
 {
 	TrackerThumbnailerPrivate *private;
 
+	g_return_if_fail (uri_prefix != NULL);
+
 	private = g_static_private_get (&private_key);
 	g_return_if_fail (private != NULL);
 
@@ -328,8 +327,8 @@ tracker_thumbnailer_cleanup (const gchar *uri_prefix)
 }
 
 void
-tracker_thumbnailer_queue_file (const gchar *uri,
-				const gchar *mime_type)
+tracker_thumbnailer_queue_add (const gchar *uri,
+			       const gchar *mime_type)
 {
 	TrackerThumbnailerPrivate *private;
 	gchar *used_uri;
@@ -341,8 +340,7 @@ tracker_thumbnailer_queue_file (const gchar *uri,
 	private = g_static_private_get (&private_key);
 	g_return_if_fail (private != NULL);
 
-	if (!private->service_is_available ||
-	    !private->service_is_enabled) {
+	if (!private->service_is_available) {
 		return;
 	}
 
@@ -356,7 +354,7 @@ tracker_thumbnailer_queue_file (const gchar *uri,
 	private->request_id++;
 
 	/* Add new URI (detect if we got passed a path) */
-	if (!strstr (uri, ":/")) {
+	if (!strstr (uri, "://")) {
 		used_uri = g_filename_to_uri (uri, NULL, NULL);
 	} else {
 		used_uri = g_strdup (uri);
diff --git a/src/libtracker-common/tracker-thumbnailer.h b/src/libtracker-common/tracker-thumbnailer.h
index d662237..bddf308 100644
--- a/src/libtracker-common/tracker-thumbnailer.h
+++ b/src/libtracker-common/tracker-thumbnailer.h
@@ -30,16 +30,15 @@ G_BEGIN_DECLS
 
 void tracker_thumbnailer_init       (void);
 void tracker_thumbnailer_shutdown   (void);
-void tracker_thumbnailer_queue_file (const gchar   *path,
-				     const gchar   *mime);
+void tracker_thumbnailer_queue_add  (const gchar *uri,
+				     const gchar *mime);
 void tracker_thumbnailer_queue_send (void);
-void tracker_thumbnailer_move       (const gchar   *from_uri,
-				     const gchar   *mime_type,
-				     const gchar   *to_uri);
-void tracker_thumbnailer_remove     (const gchar   *uri,
-				     const gchar   *mime_type);
-void tracker_thumbnailer_cleanup    (const gchar   *uri_prefix);
-
+void tracker_thumbnailer_move       (const gchar *from_uri,
+				     const gchar *mime_type,
+				     const gchar *to_uri);
+void tracker_thumbnailer_remove     (const gchar *uri,
+				     const gchar *mime_type);
+void tracker_thumbnailer_cleanup    (const gchar *uri_prefix);
 
 G_END_DECLS
 
diff --git a/src/tracker-extract/Makefile.am b/src/tracker-extract/Makefile.am
index 64ebee6..5d2cb26 100644
--- a/src/tracker-extract/Makefile.am
+++ b/src/tracker-extract/Makefile.am
@@ -12,7 +12,6 @@ INCLUDES = 								\
 	$(WARN_CFLAGS)							\
 	$(GLIB2_CFLAGS)							\
 	$(GCOV_CFLAGS)							\
-	$(GDKPIXBUF_CFLAGS)						\
 	$(GMODULE_CFLAGS) 						\
 	$(DBUS_CFLAGS)							\
 	$(EXEMPI_CFLAGS) 						\
@@ -232,8 +231,6 @@ libextract_playlist_la_LIBADD = $(GLIB2_LIBS) $(TOTEM_PL_PARSER_LIBS) $(GCOV_LIB
 libexec_PROGRAMS = tracker-extract
 
 tracker_extract_SOURCES = 						\
-	tracker-albumart.c						\
-	tracker-albumart.h						\
 	tracker-config.c						\
 	tracker-config.h						\
 	tracker-dbus.c							\
@@ -241,7 +238,8 @@ tracker_extract_SOURCES = 						\
 	tracker-extract.c						\
 	tracker-extract.h						\
 	tracker-main.c							\
-	tracker-main.h							
+	tracker-main.h							\
+	tracker-marshal-main.c
 
 tracker_extract_LDADD = 						\
 	$(top_builddir)/src/libtracker-common/libtracker-common.la	\
@@ -252,15 +250,23 @@ tracker_extract_LDADD = 						\
 	$(GLIB2_LIBS)							\
 	$(STREAMANALYZER_LIBS)
 
-if HAVE_GDKPIXBUF
-tracker_extract_LDADD += $(GDKPIXBUF_LIBS) 
-endif
-
 if HAVE_STREAMANALYZER
 tracker_extract_SOURCES += tracker-topanalyzer.cpp tracker-topanalyzer.h
 tracker_extract_LDADD += $(STREAMANALYZER_LIBS)
 endif
 
+tracker-marshal.h: tracker-marshal.list
+	$(GLIB_GENMARSHAL) $< --prefix=tracker_marshal --header > $@
+
+tracker-marshal.c: tracker-marshal.list
+	$(GLIB_GENMARSHAL) $< --prefix=tracker_marshal --body > $@
+
+tracker-marshal-main.c: tracker-marshal.c tracker-marshal.h
+
+marshal_sources =                                         		\
+        tracker-marshal.h                             			\
+        tracker-marshal.c
+
 dbus_sources = 								\
 	tracker-extract-glue.h
 
@@ -268,6 +274,9 @@ dbus_sources = 								\
 	$(DBUSBINDINGTOOL) --mode=glib-server --output=$@ --prefix=$(subst -,_,$*) $^
 
 BUILT_SOURCES = 							\
-	$(dbus_sources)
+	$(dbus_sources)							\
+	$(marshal_sources)
 
 CLEANFILES = $(BUILT_SOURCES)
+
+EXTRA_DIST = tracker-marshal.list
\ No newline at end of file
diff --git a/src/tracker-extract/tracker-extract-gstreamer.c b/src/tracker-extract/tracker-extract-gstreamer.c
index 782cd80..aeae8df 100644
--- a/src/tracker-extract/tracker-extract-gstreamer.c
+++ b/src/tracker-extract/tracker-extract-gstreamer.c
@@ -39,7 +39,8 @@
 #include <libtracker-common/tracker-utils.h>
 
 #include "tracker-main.h"
-#include "tracker-albumart.h"
+#include "tracker-dbus.h"
+#include "tracker-extract.h"
 
 /* We wait this long (seconds) for NULL state before freeing */
 #define TRACKER_EXTRACT_GUARD_TIMEOUT 3
@@ -903,22 +904,26 @@ tracker_extract_gstreamer (const gchar *uri,
 
 	/* Save embedded art */
 	if (extractor->album_art_data && extractor->album_art_size) {
+		GObject *object;
+
+		object = tracker_dbus_get_object (TRACKER_TYPE_EXTRACT);
+
 #ifdef HAVE_GDKPIXBUF
-		tracker_albumart_process (extractor->album_art_data, 
-					  extractor->album_art_size, 
-					  extractor->album_art_mime,
-					  /* g_hash_table_lookup (metadata, "Audio:Artist") */ NULL,
-					  album,
-					  scount,
-					  uri);
+		tracker_extract_process_albumart (TRACKER_EXTRACT (object),
+						  extractor->album_art_data, 
+						  extractor->album_art_size, 
+						  extractor->album_art_mime,
+						  /* g_hash_table_lookup (metadata, "Audio:Artist") */ NULL,
+						  album,
+						  uri);
 #else
-		tracker_albumart_process (NULL, 
-					  0, 
-					  NULL,
-					  /* g_hash_table_lookup (metadata, "Audio:Artist") */ NULL,
-					  album,
-					  scount,
-					  uri);
+		tracker_extract_process_albumart (TRACKER_EXTRACT (object),
+						  NULL,
+						  0, 
+						  NULL,
+						  /* g_hash_table_lookup (metadata, "Audio:Artist") */ NULL,
+						  album,
+						  uri);
 		
 #endif /* HAVE_GDKPIXBUF */
 	}
diff --git a/src/tracker-extract/tracker-extract-mp3.c b/src/tracker-extract/tracker-extract-mp3.c
index 2af5a10..70802da 100644
--- a/src/tracker-extract/tracker-extract-mp3.c
+++ b/src/tracker-extract/tracker-extract-mp3.c
@@ -50,7 +50,8 @@
 #include <libtracker-common/tracker-utils.h>
 
 #include "tracker-main.h"
-#include "tracker-albumart.h"
+#include "tracker-dbus.h"
+#include "tracker-extract.h"
 
 /* We mmap the beginning of the file and read separately the last 128 bytes
    for id3v1 tags. While these are probably cornercases the rationale is that
@@ -1809,15 +1810,16 @@ static void
 extract_mp3 (const gchar *uri,
 	     TrackerSparqlBuilder  *metadata)
 {
-	gchar       *filename;
-	int	     fd;
-	void	    *buffer;
-	void        *id3v1_buffer;
-	goffset      size;
-	goffset      buffer_size;
-	id3tag	     info;
-	goffset      audio_offset;
-	file_data    filedata;
+	GObject *object;
+	gchar *filename;
+	int fd;
+	void *buffer;
+	void *id3v1_buffer;
+	goffset size;
+	goffset  buffer_size;
+	id3tag info;
+	goffset audio_offset;
+	file_data filedata;
 
 	info.title = NULL;
 	info.artist = NULL;
@@ -1966,22 +1968,24 @@ extract_mp3 (const gchar *uri,
 	g_free (info.genre);
 
 	/* TODO */
+	object = tracker_dbus_get_object (TRACKER_TYPE_EXTRACT);
+
 #ifdef HAVE_GDKPIXBUF
-	tracker_albumart_process (filedata.albumartdata, 
-				  filedata.albumartsize, 
-				  filedata.albumartmime,
-				  /* tracker_statement_list_find (metadata, NMM_PREFIX "performer") */ NULL,
-				  filedata.title, 
-				  "-1",
-				  filename);
+	tracker_extract_process_albumart (TRACKER_EXTRACT (object),
+					  filedata.albumartdata, 
+					  filedata.albumartsize, 
+					  filedata.albumartmime,
+					  /* tracker_statement_list_find (metadata, NMM_PREFIX "performer") */ NULL,
+					  filedata.title, 
+					  filename);
 #else
-	tracker_albumart_process (NULL, 
-				  0, 
-				  NULL,
-				  /* tracker_statement_list_find (metadata, NMM_PREFIX "performer") */ NULL,
-				  filedata.title, 
-				  "-1",
-				  filename);
+	tracker_extract_process_albumart (TRACKER_EXTRACT (object),
+					  NULL, 
+					  0, 
+					  NULL,
+					  /* tracker_statement_list_find (metadata, NMM_PREFIX "performer") */ NULL,
+					  filedata.title, 
+					  filename);
 
 #endif /* HAVE_GDKPIXBUF */
 
diff --git a/src/tracker-extract/tracker-extract.c b/src/tracker-extract/tracker-extract.c
index add97bf..826e767 100644
--- a/src/tracker-extract/tracker-extract.c
+++ b/src/tracker-extract/tracker-extract.c
@@ -29,9 +29,10 @@
 #include <libtracker-common/tracker-dbus.h>
 #include <libtracker-common/tracker-sparql-builder.h>
 
-#include "tracker-main.h"
 #include "tracker-dbus.h"
 #include "tracker-extract.h"
+#include "tracker-main.h"
+#include "tracker-marshal.h"
 
 #ifdef HAVE_STREAMANALYZER
 #include "tracker-topanalyzer.h"
@@ -54,7 +55,7 @@ typedef struct {
 }  ModuleData;
 
 enum {
-	NEEDS_THUMBNAILING,
+	PROCESS_ALBUM_ART,
 	LAST_SIGNAL
 };
 
@@ -73,15 +74,20 @@ tracker_extract_class_init (TrackerExtractClass *klass)
 
 	object_class->finalize = tracker_extract_finalize;
 
-	signals[NEEDS_THUMBNAILING] =
-		g_signal_new ("needs-thumbnailing",
+	signals[PROCESS_ALBUM_ART] =
+		g_signal_new ("process-album-art",
 			      G_TYPE_FROM_CLASS (klass),
 			      G_SIGNAL_RUN_LAST,
 			      0,
 			      NULL, NULL,
-			      g_cclosure_marshal_VOID__STRING,
+			      tracker_marshal_VOID__UCHAR_INT_STRING_STRING_STRING_STRING,
 			      G_TYPE_NONE,
-			      1,
+			      6,
+			      G_TYPE_UCHAR,
+			      G_TYPE_INT,
+			      G_TYPE_STRING,
+			      G_TYPE_STRING,
+			      G_TYPE_STRING,
 			      G_TYPE_STRING);
 
 	g_type_class_add_private (object_class, sizeof (TrackerExtractPrivate));
@@ -476,3 +482,29 @@ tracker_extract_get_metadata (TrackerExtract	     *object,
 		alarm (0);
 	}
 }
+
+void
+tracker_extract_process_albumart (TrackerExtract      *object, 
+				  const unsigned char *buffer,
+				  size_t               len,
+				  const gchar         *mime,
+				  const gchar         *artist,
+				  const gchar         *album,
+				  const gchar         *filename)
+{
+	g_return_if_fail (buffer != NULL);
+	g_return_if_fail (len > 0);
+	g_return_if_fail (object != NULL);
+	g_return_if_fail (mime != NULL);
+	g_return_if_fail (filename != NULL);
+
+	g_signal_emit (object,
+		       signals[PROCESS_ALBUM_ART],
+		       0,
+		       buffer,
+		       len,
+		       mime,
+		       artist,
+		       album,
+		       filename);
+}
diff --git a/src/tracker-extract/tracker-extract.h b/src/tracker-extract/tracker-extract.h
index 723ec7a..0b90cd4 100644
--- a/src/tracker-extract/tracker-extract.h
+++ b/src/tracker-extract/tracker-extract.h
@@ -60,10 +60,17 @@ void            tracker_extract_get_metadata            (TrackerExtract
 							 DBusGMethodInvocation  *context,
 							 GError                **error);
 
-/* Not DBus API, convenience for command line */
+/* Not DBus API */
 void            tracker_extract_get_metadata_by_cmdline (TrackerExtract         *object,
 							 const gchar            *path,
 							 const gchar            *mime);
+void            tracker_extract_process_albumart        (TrackerExtract         *object,
+							 const unsigned char    *buffer,
+							 size_t                  len,
+							 const gchar            *mime,
+							 const gchar            *artist,
+							 const gchar            *album,
+							 const gchar            *filename);
 
 G_END_DECLS
 
diff --git a/src/tracker-extract/tracker-main.c b/src/tracker-extract/tracker-main.c
index 30c6f69..8622811 100644
--- a/src/tracker-extract/tracker-main.c
+++ b/src/tracker-extract/tracker-main.c
@@ -49,7 +49,6 @@
 #include <libtracker-common/tracker-thumbnailer.h>
 #include <libtracker-common/tracker-ioprio.h>
 
-#include "tracker-albumart.h"
 #include "tracker-config.h"
 #include "tracker-main.h"
 #include "tracker-dbus.h"
@@ -263,6 +262,18 @@ main (int argc, char *argv[])
 	gboolean        stand_alone = FALSE;
 	guint           log_handler_id = 0;
 
+	g_type_init ();
+
+	if (!g_thread_supported ()) {
+		g_thread_init (NULL);
+	}
+
+	dbus_g_thread_init ();
+
+	g_set_application_name ("tracker-extract");
+
+	setlocale (LC_ALL, "");
+
 	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
 	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 	textdomain (GETTEXT_PACKAGE);
@@ -304,18 +315,6 @@ main (int argc, char *argv[])
 
 	tracker_memory_setrlimits ();
 
-	g_type_init ();
-
-	if (!g_thread_supported ()) {
-		g_thread_init (NULL);
-	}
-
-	dbus_g_thread_init ();
-
-	g_set_application_name ("tracker-extract");
-
-	setlocale (LC_ALL, "");
-
 	/* Set conditions when we use stand alone settings */
 	stand_alone |= filename != NULL;
 
@@ -335,21 +334,21 @@ main (int argc, char *argv[])
 	}
 
 	if (filename) {
-		TrackerExtract *object;
+		TrackerExtract *extract;
 		GFile *file;
 		gchar *uri;
 
-		object = tracker_extract_new ();
-		if (!object) {
+		extract = tracker_extract_new ();
+		if (!extract) {
 			return EXIT_FAILURE;
 		}
 
 		file = g_file_new_for_commandline_arg (filename);
 		uri = g_file_get_uri (file);
 
-		tracker_extract_get_metadata_by_cmdline (object, uri, mime_type);
+		tracker_extract_get_metadata_by_cmdline (extract, uri, mime_type);
 
-		g_object_unref (object);
+		g_object_unref (extract);
 		g_object_unref (file);
 		g_free (uri);
 
@@ -375,9 +374,6 @@ main (int argc, char *argv[])
 	g_print ("Starting log:\n  File:'%s'\n", log_filename);
 	g_free (log_filename);
 
-	tracker_albumart_init ();
-	tracker_thumbnailer_init ();
-
 	/* Make Tracker available for introspection */
 	if (!tracker_dbus_register_objects ()) {
 		g_object_unref (config);
@@ -385,6 +381,8 @@ main (int argc, char *argv[])
 		return EXIT_FAILURE;
 	}
 
+	tracker_thumbnailer_init ();
+
 	/* Main loop */
 	main_loop = g_main_loop_new (NULL, FALSE);
 	tracker_main_quit_timeout_reset ();
@@ -395,7 +393,6 @@ main (int argc, char *argv[])
 
 	/* Push all items in thumbnail queue to the thumbnailer */
 	tracker_thumbnailer_queue_send ();
-	tracker_albumart_shutdown ();
 
 	/* Shutdown subsystems */
 	tracker_dbus_shutdown ();
diff --git a/src/tracker-extract/tracker-marshal-main.c b/src/tracker-extract/tracker-marshal-main.c
new file mode 100644
index 0000000..3ff573d
--- /dev/null
+++ b/src/tracker-extract/tracker-marshal-main.c
@@ -0,0 +1,2 @@
+#include "tracker-marshal.h"
+#include "tracker-marshal.c"
diff --git a/src/tracker-extract/tracker-marshal.list b/src/tracker-extract/tracker-marshal.list
new file mode 100644
index 0000000..5c71fca
--- /dev/null
+++ b/src/tracker-extract/tracker-marshal.list
@@ -0,0 +1 @@
+VOID:UCHAR,INT,STRING,STRING,STRING,STRING
diff --git a/src/tracker-miner-fs/Makefile.am b/src/tracker-miner-fs/Makefile.am
index c1946c9..61dbe55 100644
--- a/src/tracker-miner-fs/Makefile.am
+++ b/src/tracker-miner-fs/Makefile.am
@@ -13,14 +13,13 @@ INCLUDES =								\
 	-DTRACKER_COMPILATION						\
 	-I$(top_srcdir)/src						\
 	$(WARN_CFLAGS)							\
+	$(GDKPIXBUF_CFLAGS)						\
 	$(GMODULE_CFLAGS)						\
 	$(PANGO_CFLAGS)							\
 	$(DBUS_CFLAGS)							\
 	$(GCOV_CFLAGS)							\
 	$(RAPTOR_CFLAGS)
 
-
-
 libtracker_moduledir = $(libdir)/tracker-$(TRACKER_API_VERSION)
 libtracker_moduleincludedir=$(includedir)/tracker-$(TRACKER_API_VERSION)/libtracker-module/
 libtracker_module_LTLIBRARIES = libtracker-module.la
@@ -42,11 +41,13 @@ libtracker_module_la_LIBADD = $(GCOV_LIBS)
 libexec_PROGRAMS = tracker-miner-fs
 
 tracker_miner_fs_SOURCES =						\
-	tracker-dbus.h							\
+	tracker-albumart.c						\
+	tracker-albumart.h						\
 	tracker-config.c						\
 	tracker-config.h						\
 	tracker-crawler.c						\
 	tracker-crawler.h						\
+	tracker-dbus.h							\
 	tracker-indexer.c						\
 	tracker-indexer.h						\
 	tracker-indexer-module.c					\
@@ -77,6 +78,7 @@ tracker_miner_fs_LDADD =						\
 	$(top_builddir)/src/libinotify/libinotify.la			\
 	$(tracker_store_win_libs)					\
 	$(DBUS_LIBS)							\
+	$(GDKPIXBUF_LIBS)						\
 	$(GMODULE_LIBS)							\
 	$(GTHREAD_LIBS)							\
 	$(PANGO_LIBS)							\
diff --git a/src/tracker-extract/tracker-albumart.c b/src/tracker-miner-fs/tracker-albumart.c
similarity index 50%
rename from src/tracker-extract/tracker-albumart.c
rename to src/tracker-miner-fs/tracker-albumart.c
index 85d03ca..b0d1375 100644
--- a/src/tracker-extract/tracker-albumart.c
+++ b/src/tracker-miner-fs/tracker-albumart.c
@@ -40,43 +40,53 @@
 #include <libtracker-common/tracker-thumbnailer.h>
 #include <libtracker-common/tracker-albumart.h>
 
-#include "tracker-main.h"
 #include "tracker-albumart.h"
-
-static GHashTable *albumart;
-static TrackerStorage *hal;
+#include "tracker-dbus.h"
+#include "tracker-marshal.h"
+
+static gboolean initialized;
+static GHashTable *albumart_cache;
+static TrackerStorage *albumart_storage;
+
+static gboolean albumart_process_cb (DBusGProxy          *proxy,
+				     const unsigned char *buffer,
+				     size_t               len,
+				     const gchar         *mime,
+				     const gchar         *artist,
+				     const gchar         *album,
+				     const gchar         *filename,
+				     gpointer             user_data);
 
 #ifdef HAVE_GDKPIXBUF
 
 static gboolean
-set_albumart (const unsigned char *buffer,
+albumart_set (const unsigned char *buffer,
 	      size_t               len,
 	      const gchar         *mime,
 	      const gchar         *artist, 
 	      const gchar         *album,
-	      const gchar         *uri,
-	      gboolean            *was_thumbnail_queued)
+	      const gchar         *uri)
 {
-	GdkPixbufLoader *loader;
-	GdkPixbuf       *pixbuf = NULL;
-	gchar           *filename;
-	GError          *error = NULL;
-
-	if (was_thumbnail_queued) {
-		*was_thumbnail_queued = FALSE;
-	}
+	gchar *local_path;
 
 	if (!artist && !album) {
-		g_warning ("No identification data for embedded image");
+		g_warning ("Could not save embedded album art, no artist or album supplied");
 		return FALSE;
 	}
 
-	tracker_albumart_get_path (artist, album, "album", NULL, &filename, NULL);
+	tracker_albumart_get_path (artist, album, "album", NULL, &local_path, NULL);
+
+	g_message ("Saving album art using GdkPixbuf for uri:'%s'", 
+		   local_path);
 
 	if (g_strcmp0 (mime, "image/jpeg") == 0 ||
 	    g_strcmp0 (mime, "JPG") == 0) {
-		g_file_set_contents (filename, buffer, (gssize) len, NULL);
+		g_file_set_contents (local_path, buffer, (gssize) len, NULL);
 	} else {
+		GdkPixbuf *pixbuf;
+		GdkPixbufLoader *loader;
+		GError *error = NULL;
+
 		loader = gdk_pixbuf_loader_new ();
 
 		if (!gdk_pixbuf_loader_write (loader, buffer, len, &error)) {
@@ -85,19 +95,19 @@ set_albumart (const unsigned char *buffer,
 
 			g_clear_error (&error);
 			gdk_pixbuf_loader_close (loader, NULL);
-			g_free (filename);
+			g_free (local_path);
 
 			return FALSE;
 		}
 
 		pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
 
-		if (!gdk_pixbuf_save (pixbuf, filename, "jpeg", &error, NULL)) {
+		if (!gdk_pixbuf_save (pixbuf, local_path, "jpeg", &error, NULL)) {
 			g_warning ("Could not save GdkPixbuf when setting album art, %s", 
 				   error ? error->message : "no error given");
 
 			g_clear_error (&error);
-			g_free (filename);
+			g_free (local_path);
 			g_object_unref (pixbuf);
 			gdk_pixbuf_loader_close (loader, NULL);
 
@@ -113,56 +123,30 @@ set_albumart (const unsigned char *buffer,
 		}
 	}
 
-	if (was_thumbnail_queued) {
-		*was_thumbnail_queued = TRUE;
-	}
-
-	tracker_thumbnailer_queue_file (filename, "image/jpeg");
-	g_free (filename);
+	tracker_thumbnailer_queue_add (local_path, "image/jpeg"); 
+	g_free (local_path);
 
 	return TRUE;
 }
 
 #endif /* HAVE_GDKPIXBUF */
 
-void
-tracker_albumart_init (void)
-{
-	g_type_init ();
-
-	albumart = g_hash_table_new_full (g_str_hash,
-					  g_str_equal,
-					  (GDestroyNotify) g_free,
-					  NULL);
-
-#ifdef HAVE_HAL
-	hal = tracker_storage_new ();
-#else 
-	hal = NULL;
-#endif
-}
-
-void
-tracker_albumart_shutdown (void)
-{
-	g_hash_table_unref (albumart);
-}
-
-gboolean
-tracker_albumart_process (const unsigned char *buffer,
-                          size_t               len,
-                          const gchar         *mime,
-                          const gchar         *artist,
-                          const gchar         *album,
-                          const gchar         *trackercnt_str,
-                          const gchar         *filename)
+static gboolean
+albumart_process_cb (DBusGProxy          *proxy,
+		     const unsigned char *buffer,
+		     size_t               len,
+		     const gchar         *mime,
+		     const gchar         *artist,
+		     const gchar         *album,
+		     const gchar         *filename,
+		     gpointer             user_data)
 {
 	gchar *art_path;
 	gboolean processed = TRUE;
 	gchar *local_uri = NULL;
 	gchar *filename_uri;
-	gboolean art_exists;
-	gboolean was_thumbnail_queued;
+
+	g_message ("***** PROCESSING NEW ALBUM ART!! *****");
 
 	if (strstr (filename, "://")) {
 		filename_uri = g_strdup (filename);
@@ -178,25 +162,24 @@ tracker_albumart_process (const unsigned char *buffer,
 				   &local_uri);
 
 	if (!art_path) {
+		g_warning ("Albumart path could not be obtained, not processing any further");
+
 		g_free (filename_uri);
 		g_free (local_uri);
 
 		return FALSE;
 	}
 
-	art_exists = g_file_test (art_path, G_FILE_TEST_EXISTS);
-
-	if (!art_exists) {
+	if (!g_file_test (art_path, G_FILE_TEST_EXISTS)) {
 #ifdef HAVE_GDKPIXBUF
 		/* If we have embedded album art */
 		if (buffer && len) {
-			processed = set_albumart (buffer, 
+			processed = albumart_set (buffer, 
 						  len, 
 						  mime,
 						  artist,
 						  album,
-						  filename,
-						  &was_thumbnail_queued);
+						  filename);
 		} else {
 #endif /* HAVE_GDK_PIXBUF */
 			/* If not, we perform a heuristic on the dir */
@@ -217,10 +200,9 @@ tracker_albumart_process (const unsigned char *buffer,
 
 			g_free (dirname);
 
-			if (!g_hash_table_lookup (albumart, key)) {
+			if (!g_hash_table_lookup (albumart_cache, key)) {
 				if (!tracker_albumart_heuristic (artist, 
 								 album, 
-					                         trackercnt_str, 
 					                         filename, 
 					                         local_uri, 
 					                         NULL)) {
@@ -229,14 +211,14 @@ tracker_albumart_process (const unsigned char *buffer,
 					 * media-art to the media-art
 					 * downloaders
 					 */
-					tracker_albumart_request_download (hal, 
+					tracker_albumart_request_download (albumart_storage, 
 									   artist,
 									   album,
 									   local_uri,
 									   art_path);
 				}
 
-				g_hash_table_insert (albumart, 
+				g_hash_table_insert (albumart_cache, 
 						     key, 
 						     GINT_TO_POINTER(TRUE));
 			} else {
@@ -246,10 +228,12 @@ tracker_albumart_process (const unsigned char *buffer,
 		}
 #endif /* HAVE_GDKPIXBUF */
 
-		if (!was_thumbnail_queued) {
-			was_thumbnail_queued = TRUE;
-			tracker_thumbnailer_queue_file (filename_uri, "image/jpeg");
+		if (processed) {
+			tracker_thumbnailer_queue_add (filename_uri, "image/jpeg"); 
 		}
+	} else {
+		g_message ("Albumart already exists for uri:'%s'", 
+			   filename_uri);
 	}
 
 	if (local_uri && !g_file_test (local_uri, G_FILE_TEST_EXISTS)) {
@@ -257,7 +241,7 @@ tracker_albumart_process (const unsigned char *buffer,
 		 * situation might have changed
 		 */
 		if (g_file_test (art_path, G_FILE_TEST_EXISTS)) {
-			tracker_albumart_copy_to_local (hal,
+			tracker_albumart_copy_to_local (albumart_storage,
 							art_path, 
 							local_uri);
 		}
@@ -269,3 +253,88 @@ tracker_albumart_process (const unsigned char *buffer,
 
 	return processed;
 }
+
+gboolean
+tracker_albumart_init (TrackerStorage *storage)
+{
+	DBusGProxy *proxy;
+	DBusGConnection *connection;
+	GError *error = NULL;
+
+	g_return_val_if_fail (initialized == FALSE, FALSE);
+
+	albumart_cache = g_hash_table_new_full (g_str_hash,
+						g_str_equal,
+						(GDestroyNotify) g_free,
+						NULL);
+
+#ifdef HAVE_HAL
+	g_return_val_if_fail (TRACKER_IS_STORAGE (storage), FALSE);
+
+	albumart_storage = g_object_ref (storage);
+#endif /* HAVE_HAL */
+
+	connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+
+	if (!connection) {
+		g_critical ("Could not connect to the DBus session bus, %s",
+			    error ? error->message : "no error given.");
+		g_clear_error (&error);
+		return FALSE;
+	}
+
+	/* Get proxy for Service / Path / Interface of the indexer */
+	proxy = dbus_g_proxy_new_for_name (connection,
+					   "org.freedesktop.Tracker.Extract",
+					   "/org/freedesktop/Tracker/Extract",
+					   "org.freedesktop.Tracker.Extract");
+
+	if (!proxy) {
+		g_critical ("Could not create a DBusGProxy to the extract service");
+                return FALSE;
+	}
+
+        dbus_g_object_register_marshaller (tracker_marshal_VOID__UCHAR_INT_STRING_STRING_STRING_STRING,
+                                           G_TYPE_NONE,
+					   G_TYPE_UCHAR,
+					   G_TYPE_INT,
+					   G_TYPE_STRING,
+					   G_TYPE_STRING,
+                                           G_TYPE_STRING,
+                                           G_TYPE_STRING,
+                                           G_TYPE_INVALID);
+	
+        dbus_g_proxy_add_signal (proxy,
+                                 "ProcessAlbumArt",
+                                 G_TYPE_UCHAR,
+                                 G_TYPE_INT,
+                                 G_TYPE_STRING,
+                                 G_TYPE_STRING,
+                                 G_TYPE_STRING,
+                                 G_TYPE_STRING,
+                                 G_TYPE_INVALID);
+        			
+        dbus_g_proxy_connect_signal (proxy,
+                                     "ProcessAlbumArt",
+                                     G_CALLBACK (albumart_process_cb),
+                                     NULL,
+                                     NULL);
+
+	return TRUE;
+}
+
+void
+tracker_albumart_shutdown (void)
+{
+	g_return_if_fail (initialized == TRUE);
+
+	if (albumart_cache) {
+		g_hash_table_unref (albumart_cache);
+	}
+
+#ifdef HAVE_HAL
+	if (albumart_storage) {
+		g_object_unref (albumart_storage);
+	}
+#endif /* HAVE_HAL */
+}
diff --git a/src/tracker-extract/tracker-albumart.h b/src/tracker-miner-fs/tracker-albumart.h
similarity index 59%
rename from src/tracker-extract/tracker-albumart.h
rename to src/tracker-miner-fs/tracker-albumart.h
index 5c69c07..ea92147 100644
--- a/src/tracker-extract/tracker-albumart.h
+++ b/src/tracker-miner-fs/tracker-albumart.h
@@ -18,23 +18,18 @@
  * Boston, MA  02110-1301, USA.
  */
 
-#ifndef __TRACKER_EXTRACT_ALBUMART_H__
-#define __TRACKER_EXTRACT_ALBUMART_H__
+#ifndef __TRACKER_MINER_FS_ALBUMART_H__
+#define __TRACKER_MINER_FS_ALBUMART_H__
 
 #include <glib.h>
 
+#include <libtracker-common/tracker-storage.h>
+
 G_BEGIN_DECLS
 
-void     tracker_albumart_init     (void);
+gboolean tracker_albumart_init     (TrackerStorage *hal);
 void     tracker_albumart_shutdown (void);
-gboolean tracker_albumart_process  (const unsigned char *buffer,
-                                    size_t               len,
-                                    const gchar         *buf_mime,
-                                    const gchar         *artist,
-                                    const gchar         *album,
-                                    const gchar         *trackercnt_str,
-                                    const gchar         *uri);
 
 G_END_DECLS
 
-#endif /* __TRACKER_EXTRACT_ALBUMART_H__ */
+#endif /* __TRACKER_MINER_FS_ALBUMART_H__ */
diff --git a/src/tracker-miner-fs/tracker-indexer.c b/src/tracker-miner-fs/tracker-indexer.c
index ca0982a..e4afbf9 100644
--- a/src/tracker-miner-fs/tracker-indexer.c
+++ b/src/tracker-miner-fs/tracker-indexer.c
@@ -111,7 +111,6 @@
 #define NIE_PLAIN_TEXT_CONTENT NIE_PREFIX "plainTextContent"
 #define NIE_MIME_TYPE NIE_PREFIX "mimeType"
 
-
 typedef struct PathInfo PathInfo;
 typedef struct MetadataForeachData MetadataForeachData;
 typedef struct MetadataRequest MetadataRequest;
@@ -126,8 +125,6 @@ struct TrackerIndexerPrivate {
 	GQuark current_module;
 	GHashTable *indexer_modules;
 
-	gchar *db_dir;
-
 	TrackerConfig *config;
 
 	TrackerPower   *power;
@@ -183,6 +180,7 @@ enum TrackerIndexerState {
 
 enum {
 	PROP_0,
+	PROP_STORAGE,
 	PROP_RUNNING,
 };
 
@@ -198,24 +196,32 @@ enum {
 	LAST_SIGNAL
 };
 
-static gboolean process_func	       (gpointer	     data);
-static void	state_set_flags        (TrackerIndexer	    *indexer,
-					TrackerIndexerState  state);
-static void	state_unset_flags      (TrackerIndexer	    *indexer,
-					TrackerIndexerState  state);
-static void	state_check	       (TrackerIndexer	    *indexer);
-
-static void     item_remove            (TrackerIndexer      *indexer,
-					PathInfo	    *info,
-					const gchar         *uri,
-					const gchar         *mime_type);
-static void     check_finished         (TrackerIndexer      *indexer,
-					gboolean             interrupted);
-
-static gboolean item_process           (TrackerIndexer      *indexer,
-					PathInfo            *info,
-					const gchar         *uri);
-
+static void     indexer_set_property (GObject             *object,
+				      guint                param_id,
+				      const GValue        *value,
+				      GParamSpec          *pspec);
+static void     indexer_get_property (GObject             *object,
+				      guint                prop_id,
+				      GValue              *value,
+				      GParamSpec          *pspec);
+static void     indexer_constructed  (GObject             *object);
+static gboolean process_func         (gpointer             data);
+static void     state_set_flags      (TrackerIndexer      *indexer,
+				      TrackerIndexerState  state);
+static void     state_unset_flags    (TrackerIndexer      *indexer,
+				      TrackerIndexerState  state);
+static void     state_check          (TrackerIndexer      *indexer);
+static void     item_remove          (TrackerIndexer      *indexer,
+				      PathInfo            *info,
+				      const gchar         *uri,
+				      const gchar         *mime_type);
+static void     check_finished       (TrackerIndexer      *indexer,
+				      gboolean             interrupted);
+static gboolean item_process         (TrackerIndexer      *indexer,
+				      PathInfo            *info,
+				      const gchar         *uri);
+static void     indexer_load_modules (TrackerIndexer      *indexer);
+static gboolean start_cb             (gpointer             user_data);
 
 static guint signals[LAST_SIGNAL] = { 0, };
 
@@ -581,8 +587,6 @@ tracker_indexer_finalize (GObject *object)
 
 	g_object_unref (priv->config);
 
-	g_free (priv->db_dir);
-
 	g_hash_table_unref (priv->indexer_modules);
 
 	g_list_foreach (priv->module_names, (GFunc) g_free, NULL);
@@ -608,28 +612,14 @@ tracker_indexer_finalize (GObject *object)
 }
 
 static void
-tracker_indexer_get_property (GObject	 *object,
-			      guint	  prop_id,
-			      GValue	 *value,
-			      GParamSpec *pspec)
-{
-	switch (prop_id) {
-	case PROP_RUNNING:
-		g_value_set_boolean (value,
-				     tracker_indexer_get_running (TRACKER_INDEXER (object)));
-		break;
-	default:
-		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-	}
-}
-
-static void
 tracker_indexer_class_init (TrackerIndexerClass *class)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (class);
 
 	object_class->finalize = tracker_indexer_finalize;
-	object_class->get_property = tracker_indexer_get_property;
+	object_class->set_property = indexer_set_property;
+	object_class->get_property = indexer_get_property;
+	object_class->constructed = indexer_constructed;
 
 	signals[STATUS] =
 		g_signal_new ("status",
@@ -716,17 +706,123 @@ tracker_indexer_class_init (TrackerIndexerClass *class)
 			      2, G_TYPE_STRING, G_TYPE_BOOLEAN);
 
 	g_object_class_install_property (object_class,
+					 PROP_STORAGE,
+					 g_param_spec_pointer ("storage",
+							       "Storage HAL object",
+							       "The object used for storage knowledge",
+							       G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+	g_object_class_install_property (object_class,
 					 PROP_RUNNING,
 					 g_param_spec_boolean ("running",
 							       "Running",
 							       "Whether the indexer is running",
 							       TRUE,
-							       G_PARAM_READABLE));
+							       G_PARAM_READWRITE));
 
 	g_type_class_add_private (object_class, sizeof (TrackerIndexerPrivate));
 }
 
 static void
+indexer_set_property (GObject	   *object,
+		      guint	    param_id,
+		      const GValue *value,
+		      GParamSpec   *pspec)
+{
+	TrackerIndexer *indexer;
+
+	indexer = TRACKER_INDEXER (object);
+
+	switch (param_id) {
+	case PROP_STORAGE: {
+		gpointer p;
+
+		p = g_value_get_pointer (value);
+
+		if (indexer->private->storage) {
+			g_object_unref (indexer->private->storage);
+		}
+
+		if (p) {
+			indexer->private->storage = g_object_ref (p);
+		} else {
+			indexer->private->storage = NULL;
+		}
+
+		break;
+	}
+
+	case PROP_RUNNING:
+		tracker_indexer_set_running (TRACKER_INDEXER (object),
+					     g_value_get_boolean (value));
+		break;
+
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+		break;
+	};
+}
+
+static void
+indexer_get_property (GObject	 *object,
+		      guint	  prop_id,
+		      GValue	 *value,
+		      GParamSpec *pspec)
+{
+	switch (prop_id) {
+	case PROP_RUNNING:
+		g_value_set_boolean (value,
+				     tracker_indexer_get_running (TRACKER_INDEXER (object)));
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+	}
+}
+
+static void
+indexer_constructed (GObject *object)
+{
+	TrackerIndexer *indexer;
+	gint seconds;
+
+	indexer = TRACKER_INDEXER (object);
+
+	tracker_status_init (indexer->private->config, 
+			     indexer->private->power);
+
+	/* Set our status as running, if this is FALSE, threads stop
+	 * doing what they do and shutdown.
+	 */
+	tracker_status_set_is_ready (TRUE);
+
+	/* We set the state here because it is not set in the
+	 * processor otherwise.
+	 */
+	tracker_status_set_and_signal (TRACKER_STATUS_IDLE);
+
+	indexer->private->processor = 
+		tracker_processor_new (indexer->private->config, 
+				       indexer->private->storage, 
+				       indexer);
+
+	indexer_load_modules (indexer);
+
+	/* Set up idle handler to process files/directories */
+	state_check (indexer);
+
+	/* Set up wait time */
+	seconds = tracker_config_get_initial_sleep (indexer->private->config);
+
+	if (seconds > 0) {
+		g_message ("Waiting %d seconds before starting",
+		           seconds);
+		g_timeout_add_seconds (seconds, start_cb, indexer);
+	} else {
+		g_idle_add (start_cb, indexer);
+	}
+}
+
+static void
 check_started (TrackerIndexer *indexer)
 {
 	TrackerIndexerState state;
@@ -835,7 +931,7 @@ signal_status_timeout_stop (TrackerIndexer *indexer)
 }
 
 static void
-tracker_indexer_load_modules (TrackerIndexer *indexer)
+indexer_load_modules (TrackerIndexer *indexer)
 {
 	TrackerIndexerPrivate *priv;
 	GSList *disabled_modules;
@@ -876,7 +972,7 @@ tracker_indexer_load_modules (TrackerIndexer *indexer)
 static gboolean
 start_cb (gpointer user_data)
 {
-	TrackerIndexer        *indexer;
+	TrackerIndexer *indexer;
 
 	if (!tracker_status_get_is_ready ()) {
 		return FALSE;
@@ -895,7 +991,6 @@ static void
 tracker_indexer_init (TrackerIndexer *indexer)
 {
 	TrackerIndexerPrivate *priv;
-	gint seconds;
 
 	priv = indexer->private = TRACKER_INDEXER_GET_PRIVATE (indexer);
 
@@ -917,10 +1012,6 @@ tracker_indexer_init (TrackerIndexer *indexer)
 
 	priv->client = tracker_connect (TRUE, -1);
 
-#ifdef HAVE_HAL
-	priv->storage = tracker_storage_new ();
-#endif /* HAVE_HAL */
-
 #if defined(HAVE_HAL) || defined(HAVE_DEVKIT_POWER)
 	priv->power = tracker_power_new ();
 	g_signal_connect (priv->power, "notify::on-battery",
@@ -930,43 +1021,11 @@ tracker_indexer_init (TrackerIndexer *indexer)
 	set_up_throttle (indexer);
 #endif /* HAVE_HAL || HAVE_DEVKIT_POWER */
 
-	tracker_status_init (priv->config, priv->power);
-
-	/* Set our status as running, if this is FALSE, threads stop
-	 * doing what they do and shutdown.
-	 */
-	tracker_status_set_is_ready (TRUE);
-
-	/* We set the state here because it is not set in the
-	 * processor otherwise.
-	 */
-	tracker_status_set_and_signal (TRACKER_STATUS_IDLE);
-
-	priv->processor = tracker_processor_new (priv->config, priv->storage, indexer);
-
-	priv->db_dir = g_build_filename (g_get_user_cache_dir (),
-					 "tracker",
-					 NULL);
-
-	tracker_indexer_load_modules (indexer);
-
 	/* Set up volume monitor */
 	priv->volume_monitor = g_volume_monitor_get ();
 	g_signal_connect (priv->volume_monitor, "mount-pre-unmount",
-			  G_CALLBACK (mount_pre_unmount_cb), indexer);
-
-	/* Set up idle handler to process files/directories */
-	state_check (indexer);
-
-	seconds = tracker_config_get_initial_sleep (priv->config);
-
-	if (seconds > 0) {
-		g_message ("Waiting %d seconds before starting",
-		           seconds);
-		g_timeout_add_seconds (seconds, start_cb, indexer);
-	} else {
-		g_idle_add (start_cb, indexer);
-	}
+			  G_CALLBACK (mount_pre_unmount_cb), 
+			  indexer);
 }
 
 static void
@@ -1044,16 +1103,6 @@ query_property_value (TrackerIndexer *indexer,
 }
 
 static void
-generate_item_thumbnail (TrackerIndexer        *indexer,
-			 const gchar           *uri,
-			 const gchar           *mime_type)
-{
-	if (mime_type && tracker_config_get_enable_thumbnails (indexer->private->config)) {
-		tracker_thumbnailer_queue_file (uri, mime_type);
-	}
-}
-
-static void
 item_add_to_datasource (TrackerIndexer *indexer,
 			const gchar *uri,
 			TrackerModuleFile *module_file,
@@ -1124,7 +1173,10 @@ item_add_or_update (TrackerIndexer        *indexer,
 
 	schedule_flush (indexer, FALSE);
 
-	generate_item_thumbnail (indexer, uri, mime_type);
+	if (mime_type && 
+	    tracker_config_get_enable_thumbnails (indexer->private->config)) {
+		tracker_thumbnailer_queue_add (uri, mime_type);
+	}
 
 #ifdef HAVE_HAL
 	if (tracker_storage_uri_is_on_removable_device (indexer->private->storage,
@@ -1671,9 +1723,11 @@ process_func (gpointer data)
 }
 
 TrackerIndexer *
-tracker_indexer_new (void)
+tracker_indexer_new (TrackerStorage *storage)
 {
-	return g_object_new (TRACKER_TYPE_INDEXER, NULL);
+	return g_object_new (TRACKER_TYPE_INDEXER, 
+			     "storage", storage,
+			     NULL);
 }
 
 gboolean
diff --git a/src/tracker-miner-fs/tracker-indexer.h b/src/tracker-miner-fs/tracker-indexer.h
index 58c4505..80f5624 100644
--- a/src/tracker-miner-fs/tracker-indexer.h
+++ b/src/tracker-miner-fs/tracker-indexer.h
@@ -23,8 +23,11 @@
 #define __TRACKER_INDEXER_H__
 
 #include <glib-object.h>
+
 #include <dbus/dbus-glib.h>
 
+#include <libtracker-common/tracker-storage.h>
+
 #define TRACKER_DAEMON_SERVICE	     "org.freedesktop.Tracker"
 #define TRACKER_INDEXER_SERVICE      "org.freedesktop.Tracker.Indexer"
 #define TRACKER_INDEXER_PATH	     "/org/freedesktop/Tracker/Indexer"
@@ -80,7 +83,7 @@ struct TrackerIndexerClass {
 
 GType		tracker_indexer_get_type	    (void) G_GNUC_CONST;
 
-TrackerIndexer *tracker_indexer_new                 (void);
+TrackerIndexer *tracker_indexer_new                 (TrackerStorage         *storage);
 gboolean        tracker_indexer_get_running         (TrackerIndexer         *indexer);
 void            tracker_indexer_set_running         (TrackerIndexer         *indexer,
 						     gboolean                running);
diff --git a/src/tracker-miner-fs/tracker-main.c b/src/tracker-miner-fs/tracker-main.c
index 752db4f..ee3a5a7 100644
--- a/src/tracker-miner-fs/tracker-main.c
+++ b/src/tracker-miner-fs/tracker-main.c
@@ -41,17 +41,20 @@
 #include <libtracker-common/tracker-module-config.h>
 #include <libtracker-common/tracker-file-utils.h>
 #include <libtracker-common/tracker-thumbnailer.h>
+#include <libtracker-common/tracker-storage.h>
 
 #include <libtracker-db/tracker-db-manager.h>
 #include <libtracker-db/tracker-db-dbus.h>
 
 #include <libtracker-data/tracker-turtle.h>
 
+#include "tracker-albumart.h"
 #include "tracker-dbus.h"
+#include "tracker-config.h"
 #include "tracker-indexer.h"
 #include "tracker-miner.h"
 #include "tracker-miner-glue.h"
-#include "tracker-config.h"
+#include "tracker-marshal.h"
 
 #define ABOUT								  \
 	"Tracker " PACKAGE_VERSION "\n"
@@ -197,7 +200,6 @@ indexer_finished_cb (TrackerIndexer *indexer,
 		g_main_loop_quit (main_loop);
 		return;
 	}
-
 }
 
 static void
@@ -210,12 +212,13 @@ daemon_availability_changed_cb (const gchar *name,
         }
 }
 
-gint
+int
 main (gint argc, gchar *argv[])
 {
 	TrackerConfig *config;
 	TrackerIndexer *indexer;
 	TrackerMiner *miner;
+        TrackerStorage *storage;
 	GOptionContext *context;
 	GError *error = NULL;
 	gchar *log_filename = NULL;
@@ -299,7 +302,13 @@ main (gint argc, gchar *argv[])
 			   str ? str : "no error given");
 	}
 
-	indexer = tracker_indexer_new ();
+#ifdef HAVE_HAL
+	storage = tracker_storage_new ();
+#else 
+	storage = NULL;
+#endif
+
+	indexer = tracker_indexer_new (storage);
 	miner = tracker_miner_new (indexer);
 
 	/* Make Tracker available for introspection */
@@ -321,6 +330,7 @@ main (gint argc, gchar *argv[])
 
 	/* Set up connections to the thumbnailer if supported */
 	tracker_thumbnailer_init ();
+        tracker_albumart_init (storage);
 
 	if (process_all) {
 		/* Tell the indexer to process all configured modules */
@@ -343,9 +353,13 @@ main (gint argc, gchar *argv[])
 	g_main_loop_unref (main_loop);
 	g_object_unref (indexer);
 	g_object_unref (miner);
-
 	g_object_unref (config);
+        
+        if (storage) {
+                g_object_unref (storage);
+        }
 
+        tracker_albumart_shutdown ();
 	tracker_thumbnailer_shutdown ();
 	tracker_dbus_shutdown ();
 	tracker_module_config_shutdown ();
diff --git a/src/tracker-miner-fs/tracker-marshal.list b/src/tracker-miner-fs/tracker-marshal.list
index 54d16ff..f7994f7 100644
--- a/src/tracker-miner-fs/tracker-marshal.list
+++ b/src/tracker-miner-fs/tracker-marshal.list
@@ -5,3 +5,4 @@ VOID:STRING,OBJECT,OBJECT,BOOLEAN,BOOLEAN
 VOID:STRING,BOOL
 VOID:STRING,OBJECT
 VOID:STRING,UINT,UINT,UINT,UINT
+VOID:UCHAR,INT,STRING,STRING,STRING,STRING
diff --git a/tests/libtracker-common/tracker-thumbnailer-test.c b/tests/libtracker-common/tracker-thumbnailer-test.c
index 583228d..956b669 100644
--- a/tests/libtracker-common/tracker-thumbnailer-test.c
+++ b/tests/libtracker-common/tracker-thumbnailer-test.c
@@ -65,14 +65,14 @@ test_queue_file ()
 
         /* URI with supported mimetype */
         if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) {
-                tracker_thumbnailer_queue_file ("file:///a/b/c.jpeg", "image/jpeg");
+                tracker_thumbnailer_queue_add ("file:///a/b/c.jpeg", "image/jpeg");
         }
         g_test_trap_assert_stderr ("*Thumbnailer queue appended with uri:'file:///a/b/c.jpeg', mime type:'image/jpeg', request_id:1...*");
 
 
         /* URI with unsupported mimetype */
         if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT)) {
-                tracker_thumbnailer_queue_file ("file:///a/b/c.jpeg", "unsupported");
+                tracker_thumbnailer_queue_add ("file:///a/b/c.jpeg", "unsupported");
                 exit (0);
         }
         g_test_trap_assert_passed ();
@@ -81,7 +81,7 @@ test_queue_file ()
 
         /* Path with supported mimetype */
         if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) {
-                tracker_thumbnailer_queue_file ("/a/b/c.jpeg", "image/jpeg");
+                tracker_thumbnailer_queue_add ("/a/b/c.jpeg", "image/jpeg");
         }
         g_test_trap_assert_stderr ("*Thumbnailer queue appended with uri:'file:///a/b/c.jpeg', mime type:'image/jpeg', request_id:1...*");
 
@@ -98,7 +98,7 @@ test_queue_send ()
         
         for (i = 0; i < 10; i++) {
                 gchar *filename = g_strdup_printf ("file:///a/b/c%d.jpeg", i);
-                tracker_thumbnailer_queue_file (filename, "image/jpeg");
+                tracker_thumbnailer_queue_add (filename, "image/jpeg");
         }
 
         if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) {



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