[tracker/album-art-to-libtracker-extract] tracker-extract: Move album-art modules to libtracker-extract



commit d1f138469fc728038beff2b91a0ab661a923b6c1
Author: Martyn Russell <martyn lanedo com>
Date:   Mon Mar 29 17:22:14 2010 +0100

    tracker-extract: Move album-art modules to libtracker-extract

 .../libtracker-extract-docs.sgml                   |    2 +
 .../libtracker-extract-sections.txt                |   12 +
 src/libtracker-extract/Makefile.am                 |   34 ++-
 .../tracker-album-art-dummy.c}                     |    2 -
 .../tracker-album-art-generic.h}                   |   22 +-
 .../tracker-album-art-pixbuf.c}                    |   17 +-
 .../tracker-album-art-quill.cpp}                   |   12 +-
 .../tracker-album-art.c}                           |  299 +++++++++-----------
 src/libtracker-extract/tracker-album-art.h         |   44 +++
 src/libtracker-extract/tracker-extract.h           |    2 +
 src/tracker-extract/Makefile.am                    |   16 +-
 src/tracker-extract/tracker-albumart.h             |   38 ---
 src/tracker-extract/tracker-extract-gstreamer.c    |   13 +-
 src/tracker-extract/tracker-extract-mp3.c          |   13 +-
 src/tracker-extract/tracker-main.c                 |   11 +-
 tests/libtracker-extract/Makefile.am               |    2 +
 16 files changed, 273 insertions(+), 266 deletions(-)
---
diff --git a/docs/reference/libtracker-extract/libtracker-extract-docs.sgml b/docs/reference/libtracker-extract/libtracker-extract-docs.sgml
index 213abda..22a497e 100644
--- a/docs/reference/libtracker-extract/libtracker-extract-docs.sgml
+++ b/docs/reference/libtracker-extract/libtracker-extract-docs.sgml
@@ -1,6 +1,7 @@
 <?xml version="1.0"?>
 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" 
                "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"; [
+<!ENTITY tracker-album-art SYSTEM "xml/tracker-album-art.xml">
 <!ENTITY tracker-data SYSTEM "xml/tracker-data.xml">
 <!ENTITY tracker-utils SYSTEM "xml/tracker-utils.xml">
 <!ENTITY tracker-xmp SYSTEM "xml/tracker-xmp.xml">
@@ -38,6 +39,7 @@
     </chapter>
     <chapter>
       <title>Common Embedded Support</title>
+      &tracker-album-art;
       &tracker-xmp;
       &tracker-iptc;
       &tracker-exif;
diff --git a/docs/reference/libtracker-extract/libtracker-extract-sections.txt b/docs/reference/libtracker-extract/libtracker-extract-sections.txt
index 966237f..8a874c9 100644
--- a/docs/reference/libtracker-extract/libtracker-extract-sections.txt
+++ b/docs/reference/libtracker-extract/libtracker-extract-sections.txt
@@ -34,3 +34,15 @@ TrackerExifData
 tracker_exif_read
 </SECTION>
 
+<SECTION>
+<FILE>tracker-album-art</FILE>
+ALBUM_ART_INTERFACE
+ALBUM_ART_PATH
+ALBUM_ART_SERVICE
+tracker_album_art_init
+tracker_album_art_shutdown
+tracker_album_art_process
+tracker_album_art_buffer_to_jpeg
+tracker_album_art_file_to_jpeg
+</SECTION>
+
diff --git a/src/libtracker-extract/Makefile.am b/src/libtracker-extract/Makefile.am
index 1cf67f7..3b0d5d8 100644
--- a/src/libtracker-extract/Makefile.am
+++ b/src/libtracker-extract/Makefile.am
@@ -6,9 +6,9 @@ INCLUDES =						\
 	-DTRACKER_COMPILATION				\
 	-I$(top_srcdir)/src				\
 	$(WARN_CFLAGS)					\
+	$(DBUS_CFLAGS)					\
 	$(GLIB2_CFLAGS)					\
 	$(GCOV_CFLAGS)					\
-	$(GDKPIXBUF_CFLAGS)				\
 	$(GIO_CFLAGS)					\
 	$(LIBIPTCDATA_CFLAGS)				\
 	$(LIBEXIF_CFLAGS) 				\
@@ -16,21 +16,36 @@ INCLUDES =						\
 
 lib_LTLIBRARIES = libtracker-extract- TRACKER_API_VERSION@.la
 
-libtracker_extractincdir=$(includedir)/tracker-$(TRACKER_API_VERSION)/libtracker-extract/
+if HAVE_GDKPIXBUF
+INCLUDES += $(GDKPIXBUF_CFLAGS)
+album_art_sources = tracker-album-art-pixbuf.c
+album_art_libs = $(GDKPIXBUF_LIBS)
+else
+if HAVE_QUILL
+INCLUDES += $(QUILL_CFLAGS)
+album_art_sources = tracker-albumart-quill.cpp
+album_art_libs = $(QUILL_LIBS)
+else
+album_art_sources = tracker-album-art-dummy.c
+album_art_libs =
+endif
+endif
 
 libtracker_extract_ TRACKER_API_VERSION@_la_SOURCES =	\
-	tracker-data.h					\
+	$(album_art_sources)				\
+	tracker-album-art.c				\
 	tracker-exif.c					\
-	tracker-exif.h					\
 	tracker-iptc.c					\
-	tracker-iptc.h					\
 	tracker-utils.c					\
-	tracker-xmp.c					\
-	tracker-xmp.h
+	tracker-xmp.c
 
 noinst_HEADERS =
 
-libtracker_extractinc_HEADERS =				\
+libtracker_extract_includedir = $(includedir)/tracker-$(TRACKER_API_VERSION)/libtracker-extract/
+
+libtracker_extract_include_HEADERS =			\
+	tracker-album-art.h				\
+	tracker-album-art-generic.h			\
 	tracker-data.h					\
 	tracker-exif.h					\
 	tracker-extract.h				\
@@ -48,7 +63,8 @@ libtracker_extract_ TRACKER_API_VERSION@_la_LIBADD = 	\
 	$(GIO_LIBS)					\
 	$(GCOV_LIBS)					\
 	$(GLIB2_LIBS)					\
-	$(GDKPIXBUF_LIBS)				\
+	$(album_art_libs)				\
+	$(DBUS_LIBS)					\
 	$(LIBIPTCDATA_LIBS)				\
 	$(LIBEXIF_LIBS)					\
 	$(EXEMPI_LIBS)
diff --git a/src/tracker-extract/tracker-albumart-dummy.c b/src/libtracker-extract/tracker-album-art-dummy.c
similarity index 96%
rename from src/tracker-extract/tracker-albumart-dummy.c
rename to src/libtracker-extract/tracker-album-art-dummy.c
index 8980ae7..d4aa09b 100644
--- a/src/tracker-extract/tracker-albumart-dummy.c
+++ b/src/libtracker-extract/tracker-album-art-dummy.c
@@ -20,8 +20,6 @@
  * Philip Van Hoof <philip codeminded be>
  */
 
-#include "tracker-albumart-generic.h"
-
 gboolean
 tracker_albumart_file_to_jpeg (const gchar *filename,
                                const gchar *target)
diff --git a/src/tracker-extract/tracker-albumart-generic.h b/src/libtracker-extract/tracker-album-art-generic.h
similarity index 52%
rename from src/tracker-extract/tracker-albumart-generic.h
rename to src/libtracker-extract/tracker-album-art-generic.h
index d93e756..d1d5d23 100644
--- a/src/tracker-extract/tracker-albumart-generic.h
+++ b/src/libtracker-extract/tracker-album-art-generic.h
@@ -20,20 +20,22 @@
  * Philip Van Hoof <philip codeminded be>
  */
 
-#ifndef __TRACKER_ALBUMART_GENERIC_H__
-#define __TRACKER_ALBUMART_GENERIC_H__
+#ifndef __LIBTRACKER_EXTRACT_ALBUM_ART_GENERIC_H__
+#define __LIBTRACKER_EXTRACT_ALBUM_ART_GENERIC_H__
 
-#include <glib.h>
+#if !defined (__LIBTRACKER_EXTRACT_INSIDE__) && !defined (TRACKER_COMPILATION)
+#error "only <libtracker-extract/tracker-extract.h> must be included directly."
+#endif
 
 G_BEGIN_DECLS
 
-gboolean  tracker_albumart_file_to_jpeg   (const gchar         *filename,
-                                           const gchar         *target);
-gboolean  tracker_albumart_buffer_to_jpeg (const unsigned char *buffer,
-                                           size_t               len,
-                                           const gchar         *buffer_mime,
-                                           const gchar         *target);
+gboolean  tracker_album_art_file_to_jpeg   (const gchar         *filename,
+                                            const gchar         *target);
+gboolean  tracker_album_art_buffer_to_jpeg (const unsigned char *buffer,
+                                            size_t               len,
+                                            const gchar         *buffer_mime,
+                                            const gchar         *target);
 
 G_END_DECLS
 
-#endif /* __TRACKER_ALBUMART_GENERIC_H__ */
+#endif /* __LIBTRACKER_EXTRACT_ALBUM_ART_GENERIC_H__ */
diff --git a/src/tracker-extract/tracker-albumart-pixbuf.c b/src/libtracker-extract/tracker-album-art-pixbuf.c
similarity index 85%
rename from src/tracker-extract/tracker-albumart-pixbuf.c
rename to src/libtracker-extract/tracker-album-art-pixbuf.c
index 9bdbcba..be73e9c 100644
--- a/src/tracker-extract/tracker-albumart-pixbuf.c
+++ b/src/libtracker-extract/tracker-album-art-pixbuf.c
@@ -20,13 +20,15 @@
  * Philip Van Hoof <philip codeminded be>
  */
 
+#include "config.h"
+
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
-#include "tracker-albumart-generic.h"
+#include "tracker-album-art-generic.h"
 
 gboolean
-tracker_albumart_file_to_jpeg (const gchar *filename,
-                               const gchar *target)
+tracker_album_art_file_to_jpeg (const gchar *filename,
+                                const gchar *target)
 {
 	GdkPixbuf *pixbuf;
 	GError *error = NULL;
@@ -50,12 +52,11 @@ tracker_albumart_file_to_jpeg (const gchar *filename,
 	return TRUE;
 }
 
-
 gboolean
-tracker_albumart_buffer_to_jpeg (const unsigned char *buffer,
-                                 size_t               len,
-                                 const gchar         *buffer_mime,
-                                 const gchar         *target)
+tracker_album_art_buffer_to_jpeg (const unsigned char *buffer,
+                                  size_t               len,
+                                  const gchar         *buffer_mime,
+                                  const gchar         *target)
 {
 	if (g_strcmp0 (buffer_mime, "image/jpeg") == 0 ||
 	    g_strcmp0 (buffer_mime, "JPG") == 0) {
diff --git a/src/tracker-extract/tracker-albumart-quill.cpp b/src/libtracker-extract/tracker-album-art-quill.cpp
similarity index 86%
rename from src/tracker-extract/tracker-albumart-quill.cpp
rename to src/libtracker-extract/tracker-album-art-quill.cpp
index f8c95a1..e926e38 100644
--- a/src/tracker-extract/tracker-albumart-quill.cpp
+++ b/src/libtracker-extract/tracker-album-art-quill.cpp
@@ -40,8 +40,8 @@ G_BEGIN_DECLS
 static gboolean init = FALSE;
 
 gboolean
-tracker_albumart_file_to_jpeg (const gchar *filename,
-                               const gchar *target)
+tracker_album_art_file_to_jpeg (const gchar *filename,
+                                const gchar *target)
 {
 	if (!init) {
 		QuillImageFilter::registerAll();
@@ -71,10 +71,10 @@ tracker_albumart_file_to_jpeg (const gchar *filename,
 }
 
 gboolean
-tracker_albumart_buffer_to_jpeg (const unsigned char *buffer,
-                                 size_t               len,
-                                 const gchar         *buffer_mime,
-                                 const gchar         *target)
+tracker_album_art_buffer_to_jpeg (const unsigned char *buffer,
+                                  size_t               len,
+                                  const gchar         *buffer_mime,
+                                  const gchar         *target)
 {
 	if (!init) {
 		QuillImageFilter::registerAll();
diff --git a/src/tracker-extract/tracker-albumart.c b/src/libtracker-extract/tracker-album-art.c
similarity index 68%
rename from src/tracker-extract/tracker-albumart.c
rename to src/libtracker-extract/tracker-album-art.c
index 1c62365..3d8edbb 100644
--- a/src/tracker-extract/tracker-albumart.c
+++ b/src/libtracker-extract/tracker-album-art.c
@@ -19,31 +19,12 @@
 
 #include "config.h"
 
-#include <string.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
 #include <ctype.h>
 
-#include <glib.h>
-#include <glib/gprintf.h>
-#include <glib/gstdio.h>
-#include <gio/gio.h>
-
-#include <dbus/dbus-glib-bindings.h>
-
 #include <libtracker-miner/tracker-miner.h>
 
-#include "tracker-albumart.h"
-#include "tracker-dbus.h"
-#include "tracker-extract.h"
-#include "tracker-marshal.h"
-#include "tracker-albumart-generic.h"
-
-#define ALBUMARTER_SERVICE    "com.nokia.albumart"
-#define ALBUMARTER_PATH       "/com/nokia/albumart/Requester"
-#define ALBUMARTER_INTERFACE  "com.nokia.albumart.Requester"
+#include "tracker-album-art.h"
+#include "tracker-album-art-generic.h"
 
 typedef struct {
 	TrackerStorage *storage;
@@ -51,15 +32,15 @@ typedef struct {
 	gchar *local_uri;
 } GetFileInfo;
 
-static void albumart_queue_cb (DBusGProxy     *proxy,
-                               DBusGProxyCall *call,
-                               gpointer        user_data);
+static void album_art_queue_cb (DBusGProxy     *proxy,
+                                DBusGProxyCall *call,
+                                gpointer        user_data);
 
 static gboolean initialized;
 static gboolean disable_requests;
-static TrackerStorage *albumart_storage;
-static GHashTable *albumart_cache;
-static DBusGProxy *albumart_proxy;
+static TrackerStorage *album_art_storage;
+static GHashTable *album_art_cache;
+static DBusGProxy *album_art_proxy;
 
 #ifndef HAVE_STRCASESTR
 
@@ -92,11 +73,11 @@ strcasestr (const gchar *haystack,
 #endif /* HAVE_STRCASESTR */
 
 static gboolean
-albumart_strip_find_next_block (const gchar    *original,
-                                const gunichar  open_char,
-                                const gunichar  close_char,
-                                gint           *open_pos,
-                                gint           *close_pos)
+album_art_strip_find_next_block (const gchar    *original,
+                                 const gunichar  open_char,
+                                 const gunichar  close_char,
+                                 gint           *open_pos,
+                                 gint           *close_pos)
 {
 	const gchar *p1, *p2;
 
@@ -128,7 +109,7 @@ albumart_strip_find_next_block (const gchar    *original,
 }
 
 static gchar *
-albumart_strip_invalid_entities (const gchar *original)
+album_art_strip_invalid_entities (const gchar *original)
 {
 	GString         *str_no_blocks;
 	gchar          **strv;
@@ -161,7 +142,7 @@ albumart_strip_invalid_entities (const gchar *original)
 			gint start, end;
 
 			/* Go through blocks, find the earliest block we can */
-			if (albumart_strip_find_next_block (p, blocks[i][0], blocks[i][1], &start, &end)) {
+			if (album_art_strip_find_next_block (p, blocks[i][0], blocks[i][1], &start, &end)) {
 				if (pos1 == -1 || start < pos1) {
 					pos1 = start;
 					pos2 = end;
@@ -220,9 +201,9 @@ albumart_strip_invalid_entities (const gchar *original)
 }
 
 static gchar *
-albumart_checksum_for_data (GChecksumType  checksum_type,
-                            const guchar  *data,
-                            gsize          length)
+album_art_checksum_for_data (GChecksumType  checksum_type,
+                             const guchar  *data,
+                             gsize          length)
 {
 	GChecksum *checksum;
 	gchar *retval;
@@ -240,12 +221,12 @@ albumart_checksum_for_data (GChecksumType  checksum_type,
 }
 
 static void
-albumart_get_path (const gchar  *artist,
-                   const gchar  *album,
-                   const gchar  *prefix,
-                   const gchar  *uri,
-                   gchar       **path,
-                   gchar       **local_uri)
+album_art_get_path (const gchar  *artist,
+                    const gchar  *album,
+                    const gchar  *prefix,
+                    const gchar  *uri,
+                    gchar       **path,
+                    gchar       **local_uri)
 {
 	gchar *art_filename;
 	gchar *dir;
@@ -270,13 +251,13 @@ albumart_get_path (const gchar  *artist,
 	if (!artist) {
 		artist_stripped = g_strdup (" ");
 	} else {
-		artist_stripped = albumart_strip_invalid_entities (artist);
+		artist_stripped = album_art_strip_invalid_entities (artist);
 	}
 
 	if (!album) {
 		album_stripped = g_strdup (" ");
 	} else {
-		album_stripped = albumart_strip_invalid_entities (album);
+		album_stripped = album_art_strip_invalid_entities (album);
 	}
 
 	artist_down = g_utf8_strdown (artist_stripped, -1);
@@ -293,12 +274,12 @@ albumart_get_path (const gchar  *artist,
 		g_mkdir_with_parents (dir, 0770);
 	}
 
-	artist_checksum = albumart_checksum_for_data (G_CHECKSUM_MD5,
-	                                              (const guchar *) artist_down,
-	                                              strlen (artist_down));
-	album_checksum = albumart_checksum_for_data (G_CHECKSUM_MD5,
-	                                             (const guchar *) album_down,
-	                                             strlen (album_down));
+	artist_checksum = album_art_checksum_for_data (G_CHECKSUM_MD5,
+	                                               (const guchar *) artist_down,
+	                                               strlen (artist_down));
+	album_checksum = album_art_checksum_for_data (G_CHECKSUM_MD5,
+	                                              (const guchar *) album_down,
+	                                              strlen (album_down));
 
 	g_free (artist_down);
 	g_free (album_down);
@@ -340,11 +321,11 @@ albumart_get_path (const gchar  *artist,
 }
 
 static gboolean
-albumart_heuristic (const gchar *artist,
-                    const gchar *album,
-                    const gchar *filename_uri,
-                    const gchar *local_uri,
-                    gboolean    *copied)
+album_art_heuristic (const gchar *artist,
+                     const gchar *album,
+                     const gchar *filename_uri,
+                     const gchar *local_uri,
+                     gboolean    *copied)
 {
 	GFile *file, *dirf;
 	GDir *dir;
@@ -362,11 +343,11 @@ albumart_heuristic (const gchar *artist,
 	}
 
 	if (artist) {
-		artist_stripped = albumart_strip_invalid_entities (artist);
+		artist_stripped = album_art_strip_invalid_entities (artist);
 	}
 
 	if (album) {
-		album_stripped = albumart_strip_invalid_entities (album);
+		album_stripped = album_art_strip_invalid_entities (album);
 	}
 
 	/* Copy from local album art (.mediaartlocal) to spec */
@@ -379,10 +360,10 @@ albumart_heuristic (const gchar *artist,
 			g_debug ("Album art being copied from local (.mediaartlocal) file:'%s'",
 			         local_uri);
 
-			albumart_get_path (artist_stripped,
-			                   album_stripped,
-			                   "album", NULL,
-			                   &target, NULL);
+			album_art_get_path (artist_stripped,
+			                    album_stripped,
+			                    "album", NULL,
+			                    &target, NULL);
 			if (target) {
 				file = g_file_new_for_path (target);
 
@@ -443,23 +424,23 @@ albumart_heuristic (const gchar *artist,
 	for (name = g_dir_read_name (dir), count = 0, retval = FALSE;
 	     name != NULL && !retval && count < 50;
 	     name = g_dir_read_name (dir), count++) {
-            /* Accept cover, front, folder, AlbumArt_{GUID}_Large
-               reject AlbumArt_{GUID}_Small and AlbumArtSmall */
+		/* Accept cover, front, folder, Album_Art_{GUID}_Large
+		   reject Album_Art_{GUID}_Small and Album_ArtSmall */
 		if ((artist_stripped && strcasestr (name, artist_stripped)) ||
 		    (album_stripped && strcasestr (name, album_stripped)) ||
 		    (strcasestr (name, "cover")) ||
-                    (strcasestr (name, "front")) ||
-                    (strcasestr (name, "folder")) ||
-                    ((strcasestr (name, "albumart") && strcasestr (name, "large")))) {
+		    (strcasestr (name, "front")) ||
+		    (strcasestr (name, "folder")) ||
+		    ((strcasestr (name, "album_art") && strcasestr (name, "large")))) {
 			if (g_str_has_suffix (name, "jpeg") ||
 			    g_str_has_suffix (name, "jpg")) {
 				if (!target) {
-					albumart_get_path (artist_stripped,
-					                   album_stripped,
-					                   "album",
-					                   NULL,
-					                   &target,
-					                   NULL);
+					album_art_get_path (artist_stripped,
+					                    album_stripped,
+					                    "album",
+					                    NULL,
+					                    &target,
+					                    NULL);
 				}
 
 				if (!file && target) {
@@ -486,17 +467,17 @@ albumart_heuristic (const gchar *artist,
 				gchar *found;
 
 				if (!target) {
-					albumart_get_path (artist_stripped,
-					                   album_stripped,
-					                   "album",
-					                   NULL,
-					                   &target,
-					                   NULL);
+					album_art_get_path (artist_stripped,
+					                    album_stripped,
+					                    "album",
+					                    NULL,
+					                    &target,
+					                    NULL);
 				}
 
 				found = g_build_filename (dirname, name, NULL);
 				g_debug ("Album art (PNG) found in same directory being used:'%s'", found);
-				retval = tracker_albumart_file_to_jpeg (found, target);
+				retval = tracker_album_art_file_to_jpeg (found, target);
 				g_free (found);
 			}
 		}
@@ -523,12 +504,12 @@ albumart_heuristic (const gchar *artist,
 }
 
 static gboolean
-albumart_set (const unsigned char *buffer,
-              size_t               len,
-              const gchar         *mime,
-              const gchar         *artist,
-              const gchar         *album,
-              const gchar         *uri)
+album_art_set (const unsigned char *buffer,
+               size_t               len,
+               const gchar         *mime,
+               const gchar         *artist,
+               const gchar         *album,
+               const gchar         *uri)
 {
 	gchar *local_path;
 	gboolean retval;
@@ -538,9 +519,9 @@ albumart_set (const unsigned char *buffer,
 		return FALSE;
 	}
 
-	albumart_get_path (artist, album, "album", NULL, &local_path, NULL);
+	album_art_get_path (artist, album, "album", NULL, &local_path, NULL);
 
-	retval = tracker_albumart_buffer_to_jpeg (buffer, len, mime, local_path);
+	retval = tracker_album_art_buffer_to_jpeg (buffer, len, mime, local_path);
 
 	g_free (local_path);
 
@@ -548,11 +529,11 @@ albumart_set (const unsigned char *buffer,
 }
 
 static void
-albumart_request_download (TrackerStorage *storage,
-                           const gchar    *album,
-                           const gchar    *artist,
-                           const gchar    *local_uri,
-                           const gchar    *art_path)
+album_art_request_download (TrackerStorage *storage,
+                            const gchar    *album,
+                            const gchar    *artist,
+                            const gchar    *local_uri,
+                            const gchar    *art_path)
 {
 	GetFileInfo *info;
 
@@ -567,25 +548,25 @@ albumart_request_download (TrackerStorage *storage,
 	info->local_uri = g_strdup (local_uri);
 	info->art_path = g_strdup (art_path);
 
-	if (!albumart_proxy) {
+	if (!album_art_proxy) {
 		GError          *error = NULL;
 		DBusGConnection *connection;
 
 		connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
 
 		if (!error) {
-			albumart_proxy = dbus_g_proxy_new_for_name (connection,
-			                                            ALBUMARTER_SERVICE,
-			                                            ALBUMARTER_PATH,
-			                                            ALBUMARTER_INTERFACE);
+			album_art_proxy = dbus_g_proxy_new_for_name (connection,
+			                                             ALBUM_ART_SERVICE,
+			                                             ALBUM_ART_PATH,
+			                                             ALBUM_ART_INTERFACE);
 		} else {
 			g_error_free (error);
 		}
 	}
 
-	dbus_g_proxy_begin_call (albumart_proxy,
+	dbus_g_proxy_begin_call (album_art_proxy,
 	                         "Queue",
-	                         albumart_queue_cb,
+	                         album_art_queue_cb,
 	                         info,
 	                         NULL,
 	                         G_TYPE_STRING, artist,
@@ -596,9 +577,9 @@ albumart_request_download (TrackerStorage *storage,
 }
 
 static void
-albumart_copy_to_local (TrackerStorage *storage,
-                        const gchar    *filename,
-                        const gchar    *local_uri)
+album_art_copy_to_local (TrackerStorage *storage,
+                         const gchar    *filename,
+                         const gchar    *local_uri)
 {
 	GSList *roots, *l;
 	gboolean on_removable_device = FALSE;
@@ -660,9 +641,9 @@ albumart_copy_to_local (TrackerStorage *storage,
 }
 
 static void
-albumart_queue_cb (DBusGProxy     *proxy,
-                   DBusGProxyCall *call,
-                   gpointer        user_data)
+album_art_queue_cb (DBusGProxy     *proxy,
+                    DBusGProxyCall *call,
+                    gpointer        user_data)
 {
 	GError      *error = NULL;
 	guint        handle;
@@ -687,9 +668,9 @@ albumart_queue_cb (DBusGProxy     *proxy,
 	if (info->storage && info->art_path &&
 	    g_file_test (info->art_path, G_FILE_TEST_EXISTS)) {
 
-		albumart_copy_to_local (info->storage,
-		                        info->art_path,
-		                        info->local_uri);
+		album_art_copy_to_local (info->storage,
+		                         info->art_path,
+		                         info->local_uri);
 	}
 
 	g_free (info->art_path);
@@ -703,20 +684,20 @@ albumart_queue_cb (DBusGProxy     *proxy,
 }
 
 gboolean
-tracker_albumart_init (void)
+tracker_album_art_init (void)
 {
 	DBusGConnection *connection;
 	GError *error = NULL;
 
 	g_return_val_if_fail (initialized == FALSE, FALSE);
 
-	albumart_storage = tracker_storage_new ();
+	album_art_storage = tracker_storage_new ();
 
 	/* Cache to know if we have already handled uris */
-	albumart_cache = g_hash_table_new_full (g_str_hash,
-	                                        g_str_equal,
-	                                        (GDestroyNotify) g_free,
-	                                        NULL);
+	album_art_cache = g_hash_table_new_full (g_str_hash,
+	                                         g_str_equal,
+	                                         (GDestroyNotify) g_free,
+	                                         NULL);
 
 	/* Signal handler for new album art from the extractor */
 	connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
@@ -729,10 +710,10 @@ tracker_albumart_init (void)
 	}
 
 	/* Get album art downloader proxy */
-	albumart_proxy = dbus_g_proxy_new_for_name (connection,
-	                                            ALBUMARTER_SERVICE,
-	                                            ALBUMARTER_PATH,
-	                                            ALBUMARTER_INTERFACE);
+	album_art_proxy = dbus_g_proxy_new_for_name (connection,
+	                                             ALBUM_ART_SERVICE,
+	                                             ALBUM_ART_PATH,
+	                                             ALBUM_ART_INTERFACE);
 
 	initialized = TRUE;
 
@@ -740,32 +721,32 @@ tracker_albumart_init (void)
 }
 
 void
-tracker_albumart_shutdown (void)
+tracker_album_art_shutdown (void)
 {
 	g_return_if_fail (initialized == TRUE);
 
-	if (albumart_proxy) {
-		g_object_unref (albumart_proxy);
+	if (album_art_proxy) {
+		g_object_unref (album_art_proxy);
 	}
 
-	if (albumart_cache) {
-		g_hash_table_unref (albumart_cache);
+	if (album_art_cache) {
+		g_hash_table_unref (album_art_cache);
 	}
 
-	if (albumart_storage) {
-		g_object_unref (albumart_storage);
+	if (album_art_storage) {
+		g_object_unref (album_art_storage);
 	}
 
 	initialized = FALSE;
 }
 
 gboolean
-tracker_albumart_process (const unsigned char *buffer,
-                          size_t               len,
-                          const gchar         *mime,
-                          const gchar         *artist,
-                          const gchar         *album,
-                          const gchar         *filename)
+tracker_album_art_process (const unsigned char *buffer,
+                           size_t               len,
+                           const gchar         *mime,
+                           const gchar         *artist,
+                           const gchar         *album,
+                           const gchar         *filename)
 {
 	gchar *art_path;
 	gboolean processed = TRUE;
@@ -785,12 +766,12 @@ tracker_albumart_process (const unsigned char *buffer,
 		filename_uri = g_filename_to_uri (filename, NULL, NULL);
 	}
 
-	albumart_get_path (artist,
-	                   album,
-	                   "album",
-	                   filename_uri,
-	                   &art_path,
-	                   &local_uri);
+	album_art_get_path (artist,
+	                    album,
+	                    "album",
+	                    filename_uri,
+	                    &art_path,
+	                    &local_uri);
 
 	if (!art_path) {
 		g_debug ("Album art path could not be obtained, not processing any further");
@@ -804,12 +785,12 @@ tracker_albumart_process (const unsigned char *buffer,
 	if (!g_file_test (art_path, G_FILE_TEST_EXISTS)) {
 		/* If we have embedded album art */
 		if (buffer && len > 0) {
-			processed = albumart_set (buffer,
-			                          len,
-			                          mime,
-			                          artist,
-			                          album,
-			                          filename_uri);
+			processed = album_art_set (buffer,
+			                           len,
+			                           mime,
+			                           artist,
+			                           album,
+			                           filename_uri);
 		} else {
 			/* If not, we perform a heuristic on the dir */
 			gchar *key;
@@ -829,25 +810,25 @@ tracker_albumart_process (const unsigned char *buffer,
 
 			g_free (dirname);
 
-			if (!g_hash_table_lookup (albumart_cache, key)) {
-				if (!albumart_heuristic (artist,
-				                         album,
-				                         filename_uri,
-				                         local_uri,
-				                         NULL)) {
+			if (!g_hash_table_lookup (album_art_cache, key)) {
+				if (!album_art_heuristic (artist,
+				                          album,
+				                          filename_uri,
+				                          local_uri,
+				                          NULL)) {
 					/* If the heuristic failed, we
 					 * request the download the
 					 * media-art to the media-art
 					 * downloaders
 					 */
-					albumart_request_download (albumart_storage,
-					                           artist,
-					                           album,
-					                           local_uri,
-					                           art_path);
+					album_art_request_download (album_art_storage,
+					                            artist,
+					                            album,
+					                            local_uri,
+					                            art_path);
 				}
 
-				g_hash_table_insert (albumart_cache,
+				g_hash_table_insert (album_art_cache,
 				                     key,
 				                     GINT_TO_POINTER(TRUE));
 			} else {
@@ -866,9 +847,9 @@ tracker_albumart_process (const unsigned char *buffer,
 		 * situation might have changed
 		 */
 		if (g_file_test (art_path, G_FILE_TEST_EXISTS)) {
-			albumart_copy_to_local (albumart_storage,
-			                        art_path,
-			                        local_uri);
+			album_art_copy_to_local (album_art_storage,
+			                         art_path,
+			                         local_uri);
 		}
 	}
 
diff --git a/src/libtracker-extract/tracker-album-art.h b/src/libtracker-extract/tracker-album-art.h
new file mode 100644
index 0000000..df3f78e
--- /dev/null
+++ b/src/libtracker-extract/tracker-album-art.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2008, Nokia
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ */
+
+#ifndef __LIBTRACKER_EXTRACT_ALBUM_ART_H__
+#define __LIBTRACKER_EXTRACT_ALBUM_ART_H__
+
+#if !defined (__LIBTRACKER_EXTRACT_INSIDE__) && !defined (TRACKER_COMPILATION)
+#error "only <libtracker-extract/tracker-extract.h> must be included directly."
+#endif
+
+#define ALBUM_ART_SERVICE    "com.nokia.albumart"
+#define ALBUM_ART_PATH       "/com/nokia/albumart/Requester"
+#define ALBUM_ART_INTERFACE  "com.nokia.albumart.Requester"
+
+G_BEGIN_DECLS
+
+gboolean tracker_album_art_init     (void);
+void     tracker_album_art_shutdown (void);
+gboolean tracker_album_art_process  (const unsigned char *buffer,
+                                     size_t               len,
+                                     const gchar         *mime,
+                                     const gchar         *artist,
+                                     const gchar         *album,
+                                     const gchar         *filename);
+
+G_END_DECLS
+
+#endif /* __LIBTRACKER_EXTRACT_ALBUM_ART_H__ */
diff --git a/src/libtracker-extract/tracker-extract.h b/src/libtracker-extract/tracker-extract.h
index 4c371cc..4c965ba 100644
--- a/src/libtracker-extract/tracker-extract.h
+++ b/src/libtracker-extract/tracker-extract.h
@@ -24,6 +24,8 @@
 
 #define __LIBTRACKER_EXTRACT_INSIDE__
 
+#include "tracker-album-art.h"
+#include "tracker-album-art-generic.h"
 #include "tracker-data.h"
 #include "tracker-exif.h"
 #include "tracker-iptc.h"
diff --git a/src/tracker-extract/Makefile.am b/src/tracker-extract/Makefile.am
index 47d7397..30463ef 100644
--- a/src/tracker-extract/Makefile.am
+++ b/src/tracker-extract/Makefile.am
@@ -295,8 +295,6 @@ libexec_PROGRAMS = tracker-extract
 tracker_extract_SOURCES = 						\
 	$(marshal_sources)						\
 	$(dbus_sources)							\
-	tracker-albumart.c						\
-	tracker-albumart.h						\
 	tracker-config.c						\
 	tracker-config.h						\
 	tracker-dbus.c							\
@@ -312,6 +310,7 @@ tracker_extract_SOURCES = 						\
 tracker_extract_LDADD = 						\
 	$(top_builddir)/src/libtracker-client/libtracker-client- TRACKER_API_VERSION@.la \
 	$(top_builddir)/src/libtracker-miner/libtracker-miner- TRACKER_API_VERSION@.la \
+	$(top_builddir)/src/libtracker-extract/libtracker-extract- TRACKER_API_VERSION@.la \
 	$(top_builddir)/src/libtracker-common/libtracker-common.la	\
 	$(DBUS_LIBS)							\
 	$(GMODULE_LIBS)							\
@@ -325,19 +324,6 @@ tracker_extract_SOURCES += tracker-topanalyzer.cpp tracker-topanalyzer.h
 tracker_extract_LDADD += $(LIBSTREAMANALYZER_LIBS)
 endif
 
-if HAVE_GDKPIXBUF
-tracker_extract_LDADD += $(GDKPIXBUF_LIBS)
-tracker_extract_SOURCES += tracker-albumart-pixbuf.c
-else
-if HAVE_QUILL
-INCLUDES += $(QUILL_CFLAGS)
-tracker_extract_SOURCES += tracker-albumart-quill.cpp
-tracker_extract_LDADD += $(QUILL_LIBS)
-else
-tracker_extract_SOURCES += tracker-albumart-dummy.c
-endif
-endif
-
 marshal_sources =                                         		\
         tracker-marshal.h                             			\
         tracker-marshal.c
diff --git a/src/tracker-extract/tracker-extract-gstreamer.c b/src/tracker-extract/tracker-extract-gstreamer.c
index 7be0164..739ba25 100644
--- a/src/tracker-extract/tracker-extract-gstreamer.c
+++ b/src/tracker-extract/tracker-extract-gstreamer.c
@@ -39,7 +39,6 @@ long long int llroundl(long double x);
 
 #include <libtracker-extract/tracker-extract.h>
 
-#include "tracker-albumart.h"
 #include "tracker-dbus.h"
 
 /* We wait this long (seconds) for NULL state before freeing */
@@ -1146,12 +1145,12 @@ tracker_extract_gstreamer (const gchar *uri,
 
 	extract_metadata (extractor, uri, preupdate, metadata, &artist, &album, &scount);
 
-	tracker_albumart_process (extractor->album_art_data,
-	                          extractor->album_art_size,
-	                          extractor->album_art_mime,
-	                          artist,
-	                          album,
-	                          uri);
+	tracker_album_art_process (extractor->album_art_data,
+	                           extractor->album_art_size,
+	                           extractor->album_art_mime,
+	                           artist,
+	                           album,
+	                           uri);
 
 	g_free (scount);
 	g_free (album);
diff --git a/src/tracker-extract/tracker-extract-mp3.c b/src/tracker-extract/tracker-extract-mp3.c
index 3a9e8cb..6407fc5 100644
--- a/src/tracker-extract/tracker-extract-mp3.c
+++ b/src/tracker-extract/tracker-extract-mp3.c
@@ -49,7 +49,6 @@
 
 #include <libtracker-extract/tracker-extract.h>
 
-#include "tracker-albumart.h"
 #include "tracker-dbus.h"
 
 /* We mmap the beginning of the file and read separately the last 128
@@ -2149,12 +2148,12 @@ extract_mp3 (const gchar          *uri,
 	/* Get mp3 stream info */
 	mp3_parse (buffer, buffer_size, audio_offset, uri, metadata, &md);
 
-	tracker_albumart_process (md.albumart_data,
-	                          md.albumart_size,
-	                          md.albumart_mime,
-	                          md.performer,
-	                          md.album,
-	                          filename);
+	tracker_album_art_process (md.albumart_data,
+	                           md.albumart_size,
+	                           md.albumart_mime,
+	                           md.performer,
+	                           md.album,
+	                           filename);
 
 	g_free (md.performer);
 	g_free (md.composer);
diff --git a/src/tracker-extract/tracker-main.c b/src/tracker-extract/tracker-main.c
index 90725af..0c2c1d0 100644
--- a/src/tracker-extract/tracker-main.c
+++ b/src/tracker-extract/tracker-main.c
@@ -47,7 +47,8 @@
 #include <libtracker-common/tracker-os-dependant.h>
 #include <libtracker-common/tracker-ioprio.h>
 
-#include "tracker-albumart.h"
+#include <libtracker-extract/tracker-extract.h>
+
 #include "tracker-config.h"
 #include "tracker-main.h"
 #include "tracker-dbus.h"
@@ -294,7 +295,7 @@ run_standalone (void)
 		verbosity = 3;
 	}
 
-	tracker_albumart_init ();
+	tracker_album_art_init ();
 
 	/* This makes sure we don't steal all the system's resources */
 	initialize_priority ();
@@ -324,7 +325,7 @@ run_standalone (void)
 		g_log_remove_handler (NULL, log_handler_id);
 	}
 
-	tracker_albumart_shutdown ();
+	tracker_album_art_shutdown ();
 
 	return EXIT_SUCCESS;
 }
@@ -458,7 +459,7 @@ main (int argc, char *argv[])
 
 	g_message ("Waiting for D-Bus requests...");
 
-	tracker_albumart_init ();
+	tracker_album_art_init ();
 
 	/* Main loop */
 	main_loop = g_main_loop_new (NULL, FALSE);
@@ -469,7 +470,7 @@ main (int argc, char *argv[])
 	g_message ("Shutdown started");
 
 	/* Shutdown subsystems */
-	tracker_albumart_shutdown ();
+	tracker_album_art_shutdown ();
 	tracker_dbus_shutdown ();
 	tracker_log_shutdown ();
 
diff --git a/tests/libtracker-extract/Makefile.am b/tests/libtracker-extract/Makefile.am
index ef8e4df..3cd121c 100644
--- a/tests/libtracker-extract/Makefile.am
+++ b/tests/libtracker-extract/Makefile.am
@@ -26,6 +26,7 @@ tracker_utils_LDADD =							\
 	$(top_builddir)/tests/common/libtracker-testcommon.la 		\
 	$(top_builddir)/src/libtracker-common/libtracker-common.la 	\
 	$(top_builddir)/src/libtracker-extract/libtracker-extract- TRACKER_API_VERSION@.la \
+	$(top_builddir)/src/libtracker-miner/libtracker-miner- TRACKER_API_VERSION@.la   \
 	$(top_builddir)/src/libtracker-client/libtracker-client- TRACKER_API_VERSION@.la   \
 	$(GMODULE_LIBS)							\
 	$(GTHREAD_LIBS)							\
@@ -40,6 +41,7 @@ tracker_xmp_LDADD =							\
 	$(top_builddir)/tests/common/libtracker-testcommon.la 		\
 	$(top_builddir)/src/libtracker-common/libtracker-common.la 	\
 	$(top_builddir)/src/libtracker-extract/libtracker-extract- TRACKER_API_VERSION@.la \
+	$(top_builddir)/src/libtracker-miner/libtracker-miner- TRACKER_API_VERSION@.la   \
 	$(top_builddir)/src/libtracker-client/libtracker-client- TRACKER_API_VERSION@.la   \
 	$(GMODULE_LIBS)							\
 	$(GTHREAD_LIBS)							\



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