[maemo-commits] [maemo-commits] r16286 - in projects/haf/branches/hildon-thumbnail/daemonize: . albumart-providers/googleimages daemon
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Mon Sep 29 20:15:12 EEST 2008
- Previous message: [maemo-commits] r16285 - in projects/haf/trunk/sapwood: . engine tests
- Next message: [maemo-commits] r16287 - projects/haf/branches/hildon-thumbnail/daemonize/albumart-providers/googleimages
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: pvanhoof Date: 2008-09-29 20:15:06 +0300 (Mon, 29 Sep 2008) New Revision: 16286 Modified: projects/haf/branches/hildon-thumbnail/daemonize/ChangeLog projects/haf/branches/hildon-thumbnail/daemonize/albumart-providers/googleimages/Makefile.am projects/haf/branches/hildon-thumbnail/daemonize/albumart-providers/googleimages/google-images-art-downloader.vala projects/haf/branches/hildon-thumbnail/daemonize/daemon/albumart-marshal.list projects/haf/branches/hildon-thumbnail/daemonize/daemon/albumart.c projects/haf/branches/hildon-thumbnail/daemonize/daemon/albumart.h projects/haf/branches/hildon-thumbnail/daemonize/daemon/albumart.xml projects/haf/branches/hildon-thumbnail/daemonize/daemon/utils.c projects/haf/branches/hildon-thumbnail/daemonize/daemon/utils.h Log: 2008-09-29 Philip Van Hoof <pvanhoof at gnome.org> * albumart-providers/googleimages/google-images-art-downloader.vala * albumart-providers/googleimages/Makefile.am * albumart-providers/Makefile.am * daemon/utils.c * daemon/utils.h * daemon/albumart.c * daemon/albumart.h * daemon/albumart-marshal.list * daemon/albumart.xml: Changed the DBus API Modified: projects/haf/branches/hildon-thumbnail/daemonize/ChangeLog =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/ChangeLog 2008-09-29 16:20:41 UTC (rev 16285) +++ projects/haf/branches/hildon-thumbnail/daemonize/ChangeLog 2008-09-29 17:15:06 UTC (rev 16286) @@ -1,5 +1,17 @@ 2008-09-29 Philip Van Hoof <pvanhoof at gnome.org> + * albumart-providers/googleimages/google-images-art-downloader.vala + * albumart-providers/googleimages/Makefile.am + * albumart-providers/Makefile.am + * daemon/utils.c + * daemon/utils.h + * daemon/albumart.c + * daemon/albumart.h + * daemon/albumart-marshal.list + * daemon/albumart.xml: Changed the DBus API + +2008-09-29 Philip Van Hoof <pvanhoof at gnome.org> + * albumart-providers * albumart-providers/googleimages * albumart-providers/googleimages/google-images-art-downloader.vala Modified: projects/haf/branches/hildon-thumbnail/daemonize/albumart-providers/googleimages/Makefile.am =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/albumart-providers/googleimages/Makefile.am 2008-09-29 16:20:41 UTC (rev 16285) +++ projects/haf/branches/hildon-thumbnail/daemonize/albumart-providers/googleimages/Makefile.am 2008-09-29 17:15:06 UTC (rev 16286) @@ -40,7 +40,7 @@ @sed -e "s|@libexecdir[@]|${libexecdir}|" $< > $@ CLEANFILES = $(BUILT_SOURCES) \ - $(org.freedesktop.thumbnailer_service_DATA) + $(com.nokia.albumart.GoogleImages_service_DATA) albartdowndir = /usr/share/albumart-providers albartdown_DATA = com.nokia.albumart.AlbumartProvider.GoogleImages.service Modified: projects/haf/branches/hildon-thumbnail/daemonize/albumart-providers/googleimages/google-images-art-downloader.vala =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/albumart-providers/googleimages/google-images-art-downloader.vala 2008-09-29 16:20:41 UTC (rev 16285) +++ projects/haf/branches/hildon-thumbnail/daemonize/albumart-providers/googleimages/google-images-art-downloader.vala 2008-09-29 17:15:06 UTC (rev 16286) @@ -4,7 +4,7 @@ [DBus (name = "com.nokia.albumart.Provider")] public interface Provider { - public abstract void Fetch (string artistalbum, string uri); + public abstract void Fetch (string artist, string album, string uri); } // Sample implementation of com.nokia.albumart.Provider that uses Google @@ -14,20 +14,34 @@ public class GoogleImages : Object, Provider { - public void Fetch (string artistalbum, string uri) { + public void Fetch (string artist, string album, string uri) { uint u = 0, hread = 0; - string [] pieces = artistalbum.split (" ", -1); + string [] pieces = artist.split (" ", -1); string stitched = ""; + bool first = true; - // Convert the album-artist into something that will work for Google images + // Convert the album and artist into something that will work for Google images while (pieces[u] != null) { - if (u != 0) + if (!first) stitched += "+"; stitched += pieces[u]; u++; + first = false; } + u = 0; + first = true; + pieces = album.split (" ", -1); + + while (pieces[u] != null) { + if (!first) + stitched += "+"; + stitched += pieces[u]; + u++; + first = false; + } + // Start the query on Google images File google_search = File.new_for_uri ("http://images.google.com/images?q=" + stitched); @@ -71,7 +85,7 @@ ".album_art", Checksum.compute_for_string ( ChecksumType.MD5, - artistalbum.down () + ".jpeg", + (artist + " " + album).down () + ".jpeg", -1), null); Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/albumart-marshal.list =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/daemon/albumart-marshal.list 2008-09-29 16:20:41 UTC (rev 16285) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/albumart-marshal.list 2008-09-29 17:15:06 UTC (rev 16286) @@ -1,2 +1,2 @@ VOID:UINT,INT,STRING -VOID:STRING,STRING,STRING +VOID:STRING,STRING,STRING,STRING Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/albumart.c =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/daemon/albumart.c 2008-09-29 16:20:41 UTC (rev 16285) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/albumart.c 2008-09-29 17:15:06 UTC (rev 16286) @@ -27,6 +27,7 @@ #include "config.h" #endif +#include <string.h> #include <glib.h> #include <gio/gio.h> #include <dbus/dbus-glib-bindings.h> @@ -73,7 +74,7 @@ typedef struct { Albumart *object; - gchar *albumartist; + gchar *album, *artist; gchar *uri; guint num; gboolean unqueued; @@ -111,13 +112,13 @@ } void -albumart_queue (Albumart *object, gchar *albumartist, gchar *uri, guint handle_to_unqueue, DBusGMethodInvocation *context) +albumart_queue (Albumart *object, gchar *artist, gchar *album, gchar *uri, guint handle_to_unqueue, DBusGMethodInvocation *context) { AlbumartPrivate *priv = ALBUMART_GET_PRIVATE (object); WorkTask *task; static guint num = 0; - if (!uri && !albumartist) + if (!uri && (!album || !artist)) return; task = g_slice_new0 (WorkTask); @@ -128,9 +129,10 @@ task->num = ++num; task->object = g_object_ref (object); - if (albumartist) - task->albumartist = g_strdup (albumartist); - if (uri) + if (album && artist && (strlen (album) > 0) && strlen (artist) > 0) { + task->album = g_strdup (album); + task->artist = g_strdup (album); + } if (uri) task->uri = g_strdup (uri); g_mutex_lock (priv->mutex); @@ -155,13 +157,14 @@ do_the_work (WorkTask *task, gpointer user_data) { AlbumartPrivate *priv = ALBUMART_GET_PRIVATE (task->object); - gchar *albumartist = task->albumartist; + gchar *artist = task->artist; + gchar *album = task->album; gchar *uri = task->uri; gchar *path; g_mutex_lock (priv->mutex); priv->tasks = g_list_remove (priv->tasks, task); - if (task->unqueued || (!uri && !albumartist)) { + if (task->unqueued || (!uri && (!album && !artist))) { g_mutex_unlock (priv->mutex); goto unqueued; } @@ -170,7 +173,7 @@ g_signal_emit (task->object, signals[STARTED_SIGNAL], 0, task->num); - hildon_thumbnail_util_get_albumart_path (albumartist, uri, &path); + hildon_thumbnail_util_get_albumart_path (artist, album, uri, &path); if (!g_file_test (path, G_FILE_TEST_EXISTS)) { @@ -193,7 +196,8 @@ // PROVIDER_INTERFACE dbus_g_proxy_call (proxy, "Fetch", &error, - G_TYPE_STRING, albumartist, + G_TYPE_STRING, artist, + G_TYPE_STRING, album, G_TYPE_STRING, uri, G_TYPE_INVALID, G_TYPE_INVALID); @@ -208,7 +212,7 @@ g_clear_error (&error); } else g_signal_emit (task->object, signals[READY_SIGNAL], - 0, albumartist, uri, path); + 0, artist, album, uri, path); copy = g_list_next (copy); } @@ -225,7 +229,8 @@ unqueued: g_object_unref (task->object); - g_free (task->albumartist); + g_free (task->artist); + g_free (task->album); g_free (task->uri); g_slice_free (WorkTask, task); @@ -234,13 +239,13 @@ void -albumart_delete (Albumart *object, gchar *albumartist, gchar *uri, DBusGMethodInvocation *context) +albumart_delete (Albumart *object, gchar *artist, gchar *album, gchar *uri, DBusGMethodInvocation *context) { gchar *path; keep_alive (); - hildon_thumbnail_util_get_albumart_path (albumartist, uri, &path); + hildon_thumbnail_util_get_albumart_path (artist, album, uri, &path); g_unlink (path); @@ -330,11 +335,12 @@ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (AlbumartClass, ready), NULL, NULL, - albumart_marshal_VOID__STRING_STRING_STRING, + albumart_marshal_VOID__STRING_STRING_STRING_STRING, G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_STRING); signals[STARTED_SIGNAL] = Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/albumart.h =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/daemon/albumart.h 2008-09-29 16:20:41 UTC (rev 16285) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/albumart.h 2008-09-29 17:15:06 UTC (rev 16286) @@ -57,9 +57,9 @@ GType albumart_get_type (void); -void albumart_queue (Albumart *object, gchar *albumartist, gchar *uri, guint handle_to_unqueue, DBusGMethodInvocation *context); +void albumart_queue (Albumart *object, gchar *artist, gchar *album, gchar *uri, guint handle_to_unqueue, DBusGMethodInvocation *context); void albumart_unqueue (Albumart *object, guint handle, DBusGMethodInvocation *context); -void albumart_delete (Albumart *object, gchar *albumartist, gchar *uri, DBusGMethodInvocation *context); +void albumart_delete (Albumart *object, gchar *artist, gchar *album, gchar *uri, DBusGMethodInvocation *context); void albumart_do_stop (void); void albumart_do_init (DBusGConnection *connection, AlbumartManager *manager, Albumart **albumart, GError **error); Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/albumart.xml =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/daemon/albumart.xml 2008-09-29 16:20:41 UTC (rev 16285) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/albumart.xml 2008-09-29 17:15:06 UTC (rev 16286) @@ -4,7 +4,8 @@ <method name="Queue"> <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> - <arg type="s" name="albumartist" direction="in" /> + <arg type="s" name="artist" direction="in" /> + <arg type="s" name="album" direction="in" /> <arg type="s" name="uri" direction="in" /> <arg type="u" name="handle_to_unqueue" direction="in" /> <arg type="u" name="handle" direction="out" /> @@ -24,7 +25,8 @@ </signal> <signal name="Ready"> - <arg type="s" name="albumart" /> + <arg type="s" name="artist" /> + <arg type="s" name="album" /> <arg type="s" name="uri" /> <arg type="s" name="art_path" /> </signal> @@ -37,7 +39,8 @@ <method name="Delete"> <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> - <arg type="s" name="albumartist" direction="in" /> + <arg type="s" name="artist" direction="in" /> + <arg type="s" name="album" direction="in" /> <arg type="s" name="uri" direction="in" /> </method> Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/utils.c =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/daemon/utils.c 2008-09-29 16:20:41 UTC (rev 16285) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/utils.c 2008-09-29 17:15:06 UTC (rev 16286) @@ -96,16 +96,18 @@ void -hildon_thumbnail_util_get_albumart_path (const gchar *albumartist, const gchar *uri, gchar **path) +hildon_thumbnail_util_get_albumart_path (const gchar *artist, const gchar *album, const gchar *uri, gchar **path) { gchar ascii_digest[33]; gchar art_filename[128]; static gchar *dir = NULL; gchar *down; - if (albumartist) - down = g_utf8_strdown (albumartist, -1); - else if (uri) + if (album && artist) { + gchar *both = g_strdup_printf ("%s %s", artist, album); + down = g_utf8_strdown (both, -1); + g_free (both); + } else if (uri) down = g_strdup (uri); else { *path = NULL; Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/utils.h =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/daemon/utils.h 2008-09-29 16:20:41 UTC (rev 16285) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/utils.h 2008-09-29 17:15:06 UTC (rev 16286) @@ -29,7 +29,7 @@ #include <gio/gio.h> void hildon_thumbnail_util_get_thumb_paths (const gchar *uri, gchar **large, gchar **normal, gchar **cropped); -void hildon_thumbnail_util_get_albumart_path (const gchar *albumartist, const gchar *uri, gchar **path); +void hildon_thumbnail_util_get_albumart_path (const gchar *artist, const gchar *album, const gchar *uri, gchar **path); #ifndef g_sprintf gint g_sprintf (gchar *string, gchar const *format, ...);
- Previous message: [maemo-commits] r16285 - in projects/haf/trunk/sapwood: . engine tests
- Next message: [maemo-commits] r16287 - projects/haf/branches/hildon-thumbnail/daemonize/albumart-providers/googleimages
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]