[maemo-commits] [maemo-commits] r16236 - in projects/haf/branches/hildon-thumbnail/daemonize: . daemon daemon/plugins thumbs
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Fri Sep 26 12:24:55 EEST 2008
- Previous message: [maemo-commits] r16235 - projects/connectivity/bluez-debian/tags
- Next message: [maemo-commits] r16237 - in projects/haf/branches/hildon-thumbnail/daemonize: . daemon
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: pvanhoof Date: 2008-09-26 12:24:50 +0300 (Fri, 26 Sep 2008) New Revision: 16236 Added: 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 Modified: projects/haf/branches/hildon-thumbnail/daemonize/ChangeLog projects/haf/branches/hildon-thumbnail/daemonize/daemon/Makefile.am projects/haf/branches/hildon-thumbnail/daemonize/daemon/hildon-thumbnail-daemon.c projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/exec-plugin.c projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/gdkpixbuf-plugin.c projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/gstreamer-video-plugin.c projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.c projects/haf/branches/hildon-thumbnail/daemonize/daemon/utils.c projects/haf/branches/hildon-thumbnail/daemonize/daemon/utils.h projects/haf/branches/hildon-thumbnail/daemonize/thumbs/hildon-thumbnail-factory.c Log: 2008-09-26 Philip Van Hoof <pvanhoof at gnome.org> * thumbs/hildon-thumbnail-factory.c * daemon/utils.c * daemon/plugins/gdkpixbuf-plugin.c * daemon/plugins/exec-plugin.c * daemon/plugins/gstreamer-video-plugin.c * daemon/utils.h: Removed some unneeded error handling * daemon/hildon-thumbnail-daemon.c * daemon/albumart.c * daemon/thumbnailer.c * daemon/albumart.h * daemon/albumart-marshal.list * daemon/albumart.xml * daemon/Makefile.am: Added initial code for albumart handling Modified: projects/haf/branches/hildon-thumbnail/daemonize/ChangeLog =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/ChangeLog 2008-09-26 07:58:24 UTC (rev 16235) +++ projects/haf/branches/hildon-thumbnail/daemonize/ChangeLog 2008-09-26 09:24:50 UTC (rev 16236) @@ -1,3 +1,20 @@ +2008-09-26 Philip Van Hoof <pvanhoof at gnome.org> + + * thumbs/hildon-thumbnail-factory.c + * daemon/utils.c + * daemon/plugins/gdkpixbuf-plugin.c + * daemon/plugins/exec-plugin.c + * daemon/plugins/gstreamer-video-plugin.c + * daemon/utils.h: Removed some unneeded error handling + + * daemon/hildon-thumbnail-daemon.c + * daemon/albumart.c + * daemon/thumbnailer.c + * daemon/albumart.h + * daemon/albumart-marshal.list + * daemon/albumart.xml + * daemon/Makefile.am: Added initial code for albumart handling + 2008-09-24 Philip Van Hoof <pvanhoof at gnome.org> * thumbs/hildon-thumbnail-factory.c: Performance improvement when a Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/Makefile.am =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/daemon/Makefile.am 2008-09-26 07:58:24 UTC (rev 16235) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/Makefile.am 2008-09-26 09:24:50 UTC (rev 16236) @@ -23,6 +23,12 @@ thumbnailer-marshal.c: thumbnailer-marshal.list $(GLIB_GENMARSHAL) $< --prefix=thumbnailer_marshal --body > $@ +albumart-marshal.h: albumart-marshal.list + $(GLIB_GENMARSHAL) $< --prefix=albumart_marshal --header > $@ + +albumart-marshal.c: albumart-marshal.list + $(GLIB_GENMARSHAL) $< --prefix=albumart_marshal --body > $@ + hildon_thumbnailer_plugin_runner_SOURCES = \ plugin-runner.c \ $(plugin_stuff) \ @@ -43,7 +49,11 @@ manager-glue.h \ thumbnailer-glue.h \ dbus-utils.h \ - dbus-utils.c + dbus-utils.c \ + albumart.c \ + albumart.h \ + albumart-marshal.c \ + albumart-marshal.h hildon_thumbnailerd_LDADD = \ $(top_builddir)/daemon/libshared.la \ @@ -63,9 +73,11 @@ $(DBUSBINDINGTOOL) --mode=glib-server --output=$@ --prefix=$(subst -,_,$*) $^ BUILT_SOURCES = manager-glue.h thumbnailer-glue.h plugin-runner-glue.h \ - thumbnailer-marshal.c thumbnailer-marshal.h + thumbnailer-marshal.c thumbnailer-marshal.h albumart-glue.h \ + albumart-marshal.c albumart-marshal.h + configdir = $(datadir)/hildon-thumbnail -config_DATA = manager.xml thumbnailer.xml +config_DATA = manager.xml thumbnailer.xml albumart.xml EXTRA_DIST = $(BUILT_SOURCES) $(config_DATA) \ $(org.freedesktop.thumbnailer_service_DATA) \ Added: projects/haf/branches/hildon-thumbnail/daemonize/daemon/albumart-marshal.list =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/daemon/albumart-marshal.list 2008-09-26 07:58:24 UTC (rev 16235) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/albumart-marshal.list 2008-09-26 09:24:50 UTC (rev 16236) @@ -0,0 +1,2 @@ +VOID:UINT,INT,STRING +VOID:STRING,STRING Added: projects/haf/branches/hildon-thumbnail/daemonize/daemon/albumart.c =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/daemon/albumart.c 2008-09-26 07:58:24 UTC (rev 16235) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/albumart.c 2008-09-26 09:24:50 UTC (rev 16236) @@ -0,0 +1,389 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * This file is part of hildon-thumbnail package + * + * Copyright (C) 2005 Nokia Corporation. All Rights reserved. + * + * Contact: Marius Vollmer <marius.vollmer at nokia.com> + * Author: Philip Van Hoof <pvanhoof at gnome.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <glib.h> +#include <gio/gio.h> +#include <dbus/dbus-glib-bindings.h> + +#include "manager.h" +#include "albumart.h" +#include "albumart-marshal.h" +#include "albumart-glue.h" +#include "hildon-thumbnail-plugin.h" +#include "dbus-utils.h" +#include "utils.h" + +#define ALBUMART_ERROR_DOMAIN "HildonAlbumart" +#define ALBUMART_ERROR g_quark_from_static_string (ALBUMART_ERROR_DOMAIN) + +#define ALBUMART_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_ALBUMART, AlbumartPrivate)) + +G_DEFINE_TYPE (Albumart, albumart, G_TYPE_OBJECT) + +void keep_alive (void); + + +typedef struct { + Manager *manager; + GThreadPool *normal_pool; + GMutex *mutex; + GList *tasks; +} AlbumartPrivate; + +enum { + PROP_0, + PROP_MANAGER +}; + +enum { + STARTED_SIGNAL, + FINISHED_SIGNAL, + READY_SIGNAL, + ERROR_SIGNAL, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0, }; + + + +typedef struct { + Albumart *object; + gchar *albumartist; + guint num; + gboolean unqueued; +} WorkTask; + + +static gint +pool_sort_compare (gconstpointer a, gconstpointer b, gpointer user_data) +{ + WorkTask *task_a = (WorkTask *) a; + WorkTask *task_b = (WorkTask *) b; + + /* This makes pool a LIFO */ + + return task_b->num - task_a->num; +} + +static void +mark_unqueued (WorkTask *task, guint handle) +{ + if (task->num == handle) + task->unqueued = TRUE; +} + +void +albumart_unqueue (Albumart *object, guint handle, DBusGMethodInvocation *context) +{ + AlbumartPrivate *priv = ALBUMART_GET_PRIVATE (object); + + keep_alive (); + + g_mutex_lock (priv->mutex); + g_list_foreach (priv->tasks, (GFunc) mark_unqueued, (gpointer) handle); + g_mutex_unlock (priv->mutex); +} + +void +albumart_queue (Albumart *object, gchar *albumartist, guint handle_to_unqueue, DBusGMethodInvocation *context) +{ + AlbumartPrivate *priv = ALBUMART_GET_PRIVATE (object); + WorkTask *task = g_slice_new (WorkTask); + static guint num = 0; + + dbus_async_return_if_fail (albumartist != NULL, context); + + keep_alive (); + + task->unqueued = FALSE; + task->num = ++num; + task->object = g_object_ref (object); + task->albumartist = g_strdup (albumartist); + + g_mutex_lock (priv->mutex); + g_list_foreach (priv->tasks, (GFunc) mark_unqueued, (gpointer) handle_to_unqueue); + priv->tasks = g_list_prepend (priv->tasks, task); + g_thread_pool_push (priv->normal_pool, task, NULL); + g_mutex_unlock (priv->mutex); + + dbus_g_method_return (context, num); +} + +/* This is the threadpool's function. This means that everything we do is + * asynchronous wrt to the mainloop (we aren't blocking it). Because it all + * happens in a thread, we must care about proper locking, too. + * + * Thanks to the pool_sort_compare sorter is this pool a LIFO, which means that + * new requests get a certain priority over older requests. Note that we are not + * canceling currently running requests. Also note that the thread count of the + * pool is set to one. We could increase this number to add some parallelism */ + +static void +do_the_work (WorkTask *task, gpointer user_data) +{ + AlbumartPrivate *priv = ALBUMART_GET_PRIVATE (task->object); + gchar *albumartist = task->albumartist; + gchar *path; + + g_mutex_lock (priv->mutex); + priv->tasks = g_list_remove (priv->tasks, task); + if (task->unqueued) { + g_mutex_unlock (priv->mutex); + goto unqueued; + } + g_mutex_unlock (priv->mutex); + + g_signal_emit (task->object, signals[STARTED_SIGNAL], 0, + task->num); + + hildon_thumbnail_util_get_albumart_paths (albumartist, &path); + + if (!g_file_test (path, G_FILE_TEST_EXISTS)) { + + /* TODO */ + GList *proxies = NULL; + GList *copy = proxies; + + while (copy) { + DBusGProxy *proxy = copy->data; + GError *error = NULL; + + keep_alive (); + + // PROVIDER_INTERFACE + dbus_g_proxy_call (proxy, "Fetch", &error, + G_TYPE_STRING, albumartist, + G_TYPE_INVALID, + G_TYPE_INVALID); + + keep_alive (); + + g_object_unref (proxy); + + if (error) { + g_signal_emit (task->object, signals[ERROR_SIGNAL], + 0, task->num, 1, error->message); + g_clear_error (&error); + } else + g_signal_emit (task->object, signals[READY_SIGNAL], + 0, albumartist, path); + + copy = g_list_next (copy); + } + + g_list_free (proxies); + } + + g_free (path); + + g_signal_emit (task->object, signals[FINISHED_SIGNAL], 0, + task->num); + +unqueued: + + g_object_unref (task->object); + g_free (task->albumartist); + g_slice_free (WorkTask, task); + + return; +} + + +void +albumart_delete (Albumart *object, gchar *albumartist, DBusGMethodInvocation *context) +{ + gchar *path; + + dbus_async_return_if_fail (albumartist != NULL, context); + + keep_alive (); + + hildon_thumbnail_util_get_albumart_paths (albumartist, &path); + + g_unlink (path); + + g_free (path); + + dbus_g_method_return (context); +} + +static void +albumart_finalize (GObject *object) +{ + AlbumartPrivate *priv = ALBUMART_GET_PRIVATE (object); + + g_thread_pool_free (priv->normal_pool, TRUE, TRUE); + + g_mutex_free (priv->mutex); + + G_OBJECT_CLASS (albumart_parent_class)->finalize (object); +} + +static void +albumart_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + + +static void +albumart_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + AlbumartPrivate *priv; + + priv = ALBUMART_GET_PRIVATE (object); + + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +albumart_class_init (AlbumartClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->finalize = albumart_finalize; + object_class->set_property = albumart_set_property; + object_class->get_property = albumart_get_property; + + signals[READY_SIGNAL] = + g_signal_new ("ready", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (AlbumartClass, ready), + NULL, NULL, + albumart_marshal_VOID__STRING_STRING, + G_TYPE_NONE, + 2, + G_TYPE_STRING, + G_TYPE_STRING); + + signals[STARTED_SIGNAL] = + g_signal_new ("started", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (AlbumartClass, ready), + NULL, NULL, + g_cclosure_marshal_VOID__UINT, + G_TYPE_NONE, + 1, + G_TYPE_UINT); + + signals[FINISHED_SIGNAL] = + g_signal_new ("finished", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (AlbumartClass, finished), + NULL, NULL, + g_cclosure_marshal_VOID__UINT, + G_TYPE_NONE, + 1, + G_TYPE_UINT); + + signals[ERROR_SIGNAL] = + g_signal_new ("error", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (AlbumartClass, error), + NULL, NULL, + albumart_marshal_VOID__UINT_INT_STRING, + G_TYPE_NONE, + 2, + G_TYPE_UINT, + G_TYPE_INT, + G_TYPE_STRING); + + g_type_class_add_private (object_class, sizeof (AlbumartPrivate)); +} + +static void +albumart_init (Albumart *object) +{ + AlbumartPrivate *priv = ALBUMART_GET_PRIVATE (object); + + priv->mutex = g_mutex_new (); + + /* We could increase the amount of threads to add some parallelism */ + + priv->normal_pool = g_thread_pool_new ((GFunc) do_the_work,NULL,1,TRUE,NULL); + + /* This sort function makes the pool a LIFO */ + + g_thread_pool_set_sort_function (priv->normal_pool, pool_sort_compare, NULL); + +} + + + +void +albumart_do_stop (void) +{ +} + + +void +albumart_do_init (DBusGConnection *connection, Albumart **albumart, GError **error) +{ + guint result; + DBusGProxy *proxy; + GObject *object; + + proxy = dbus_g_proxy_new_for_name (connection, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS); + + org_freedesktop_DBus_request_name (proxy, ALBUMART_SERVICE, + DBUS_NAME_FLAG_DO_NOT_QUEUE, + &result, error); + + object = g_object_new (TYPE_ALBUMART, + NULL); + + dbus_g_object_type_install_info (G_OBJECT_TYPE (object), + &dbus_glib_albumart_object_info); + + dbus_g_connection_register_g_object (connection, + ALBUMART_PATH, + object); + + *albumart = ALBUMART (object); +} Added: projects/haf/branches/hildon-thumbnail/daemonize/daemon/albumart.h =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/daemon/albumart.h 2008-09-26 07:58:24 UTC (rev 16235) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/albumart.h 2008-09-26 09:24:50 UTC (rev 16236) @@ -0,0 +1,67 @@ +#ifndef __ALBUMART_H__ +#define __ALBUMART_H__ + +/* + * This file is part of hildon-thumbnail package + * + * Copyright (C) 2005 Nokia Corporation. All Rights reserved. + * + * Contact: Marius Vollmer <marius.vollmer at nokia.com> + * Author: Philip Van Hoof <pvanhoof at gnome.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +#include <gmodule.h> + +#include "manager.h" + +#define ALBUMART_SERVICE "com.nokia.albumart" +#define ALBUMART_PATH "/com/nokia/albumart/Requester" +#define ALBUMART_INTERFACE "com.nokia.albumart.Requester" +#define PROVIDER_INTERFACE "com.nokia.albumart.Provider" + +#define TYPE_ALBUMART (albumart_get_type()) +#define ALBUMART(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_ALBUMART, Albumart)) +#define ALBUMART_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), TYPE_ALBUMART, AlbumartClass)) +#define ALBUMART_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_ALBUMART, AlbumartClass)) + +typedef struct Albumart Albumart; +typedef struct AlbumartClass AlbumartClass; + +struct Albumart { + GObject parent; +}; + +struct AlbumartClass { + GObjectClass parent; + + void (*finished) (Albumart *object, guint handle); + void (*started) (Albumart *object, guint handle); + void (*ready) (Albumart *object, gchar *albumartist, gchar *path); + void (*error) (Albumart *object, guint handle, gchar *reason); +}; + +GType albumart_get_type (void); + +void albumart_queue (Albumart *object, gchar *albumartist, guint handle_to_unqueue, DBusGMethodInvocation *context); +void albumart_unqueue (Albumart *object, guint handle, DBusGMethodInvocation *context); +void albumart_delete (Albumart *object, gchar *albumartist, DBusGMethodInvocation *context); + +void albumart_do_stop (void); +void albumart_do_init (DBusGConnection *connection, Albumart **albumart, GError **error); + +#endif Added: projects/haf/branches/hildon-thumbnail/daemonize/daemon/albumart.xml =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/daemon/albumart.xml 2008-09-26 07:58:24 UTC (rev 16235) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/albumart.xml 2008-09-26 09:24:50 UTC (rev 16236) @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8"?> +<node name="/"> + <interface name="com.nokia.albumart.Requester"> + + <method name="Queue"> + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> + <arg type="s" name="albumartist" direction="in" /> + <arg type="u" name="handle_to_unqueue" direction="in" /> + <arg type="u" name="handle" direction="out" /> + </method> + + <method name="Unqueue"> + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> + <arg type="u" name="handle" direction="in" /> + </method> + + <signal name="Started"> + <arg type="u" name="handle" /> + </signal> + + <signal name="Finished"> + <arg type="u" name="handle" /> + </signal> + + <signal name="Ready"> + <arg type="s" name="uri" /> + <arg type="s" name="art_path" /> + </signal> + + <signal name="Error"> + <arg type="u" name="handle" /> + <arg type="i" name="error_code" /> + <arg type="s" name="message" /> + </signal> + + <method name="Delete"> + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> + <arg type="s" name="albumartist" direction="in" /> + </method> + + </interface> +</node> Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/hildon-thumbnail-daemon.c =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/daemon/hildon-thumbnail-daemon.c 2008-09-26 07:58:24 UTC (rev 16235) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/hildon-thumbnail-daemon.c 2008-09-26 09:24:50 UTC (rev 16236) @@ -30,6 +30,7 @@ #include "hildon-thumbnail-plugin.h" #include "thumbnailer.h" +#include "albumart.h" #include "manager.h" static GHashTable *registrations; @@ -184,12 +185,14 @@ GError *error = NULL; Manager *manager; Thumbnailer *thumbnailer; + Albumart *arter; DBusGProxy *manager_proxy; GFile *file; GFileMonitor *monitor; manager_do_init (connection, &manager, &error); thumbnailer_do_init (connection, manager, &thumbnailer, &error); + albumart_do_init (connection, &arter, &error); manager_proxy = dbus_g_proxy_new_for_name (connection, MANAGER_SERVICE, @@ -218,9 +221,14 @@ g_hash_table_unref (registrations); + albumart_do_stop (); thumbnailer_do_stop (); manager_do_stop (); + g_object_unref (thumbnailer); + g_object_unref (manager); + g_object_unref (arter); + g_main_loop_unref (main_loop); } Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/exec-plugin.c =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/exec-plugin.c 2008-09-26 07:58:24 UTC (rev 16235) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/exec-plugin.c 2008-09-26 09:24:50 UTC (rev 16236) @@ -269,11 +269,8 @@ content_type = g_file_info_get_content_type (info); hildon_thumbnail_util_get_thumb_paths (uri, &large, &normal, - &cropped, &nerror); + &cropped); - if (nerror) - goto nerror_handler; - mime_type = g_strdup (content_type); mime_type_at = g_strdup (content_type); slash_pos = strchr(mime_type_at, '/'); Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/gdkpixbuf-plugin.c =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/gdkpixbuf-plugin.c 2008-09-26 07:58:24 UTC (rev 16235) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/gdkpixbuf-plugin.c 2008-09-26 09:24:50 UTC (rev 16236) @@ -226,14 +226,9 @@ *cropped = NULL; gboolean just_crop; - //g_print ("%s\n", uri); - hildon_thumbnail_util_get_thumb_paths (uri, &large, &normal, &cropped, &nerror); + hildon_thumbnail_util_get_thumb_paths (uri, &large, &normal, &cropped); - - if (nerror) - goto nerror_handler; - just_crop = (g_file_test (large, G_FILE_TEST_EXISTS) && g_file_test (normal, G_FILE_TEST_EXISTS) && !g_file_test (cropped, G_FILE_TEST_EXISTS)); @@ -245,12 +240,6 @@ continue; } - //g_print ("L %s\n", large); - //g_print ("N %s\n", normal); - - if (nerror) - goto nerror_handler; - file = g_file_new_for_uri (uri); info = g_file_query_info (file, G_FILE_ATTRIBUTE_TIME_MODIFIED, Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/gstreamer-video-plugin.c =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/gstreamer-video-plugin.c 2008-09-26 07:58:24 UTC (rev 16235) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/gstreamer-video-plugin.c 2008-09-26 09:24:50 UTC (rev 16236) @@ -427,11 +427,8 @@ GError *nerror = NULL; hildon_thumbnail_util_get_thumb_paths (uris[i], &large, &normal, - &cropped, &nerror); + &cropped); - if (nerror) - goto nerror_handler; - /* Create the thumbnailer struct */ thumber = g_slice_new0 (VideoThumbnailer); Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.c =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.c 2008-09-26 07:58:24 UTC (rev 16235) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.c 2008-09-26 09:24:50 UTC (rev 16236) @@ -130,7 +130,7 @@ g_object_unref (info); } - hildon_thumbnail_util_get_thumb_paths (uri, &large, &normal, &cropped, error); + hildon_thumbnail_util_get_thumb_paths (uri, &large, &normal, &cropped); *has_thumb = (g_file_test (large, G_FILE_TEST_EXISTS) && g_file_test (normal, G_FILE_TEST_EXISTS) && @@ -410,8 +410,6 @@ thumbnailer_move (Thumbnailer *object, GStrv from_urls, GStrv to_urls, DBusGMethodInvocation *context) { guint i = 0; - GString *errors = NULL; - GError *error = NULL; dbus_async_return_if_fail (from_urls != NULL, context); dbus_async_return_if_fail (to_urls != NULL, context); @@ -422,7 +420,6 @@ const gchar *from_uri = from_urls[i]; const gchar *to_uri = to_urls[i]; - GError *nerror = NULL; gchar *from_normal = NULL, *from_large = NULL, *from_cropped = NULL; @@ -432,35 +429,17 @@ hildon_thumbnail_util_get_thumb_paths (from_uri, &from_large, &from_normal, - &from_cropped, &error); + &from_cropped); - if (nerror) - goto nerror_handler; hildon_thumbnail_util_get_thumb_paths (to_uri, &to_large, &to_normal, - &to_cropped, &error); + &to_cropped); - if (nerror) - goto nerror_handler; - - g_rename (from_large, to_large); g_rename (from_normal, to_normal); g_rename (from_cropped, to_cropped); - nerror_handler: - - if (nerror) { - if (!errors) - errors = g_string_new (""); - g_string_append_printf (errors, "[`%s': %s] ", - from_urls[i], - nerror->message); - g_error_free (nerror); - nerror = NULL; - } - g_free (from_normal); g_free (from_large); g_free (from_cropped); @@ -471,22 +450,13 @@ i++; } - if (errors) { - g_set_error (&error, THUMB_ERROR, 0, - errors->str); - g_string_free (errors, TRUE); - dbus_g_method_return_error (context, error); - g_error_free (error); - } else - dbus_g_method_return (context); + dbus_g_method_return (context); } void thumbnailer_copy (Thumbnailer *object, GStrv from_urls, GStrv to_urls, DBusGMethodInvocation *context) { guint i = 0; - GString *errors = NULL; - GError *error = NULL; dbus_async_return_if_fail (from_urls != NULL, context); dbus_async_return_if_fail (to_urls != NULL, context); @@ -497,21 +467,17 @@ const gchar *from_uri = from_urls[i]; const gchar *to_uri = to_urls[i]; - GError *nerror = NULL; gchar *from_s[3] = { NULL, NULL, NULL }; gchar *to_s[3] = { NULL, NULL, NULL }; guint n; hildon_thumbnail_util_get_thumb_paths (from_uri, &from_s[0], &from_s[1], - &from_s[2], &error); + &from_s[2]); - if (nerror) - goto nerror_handler; - hildon_thumbnail_util_get_thumb_paths (to_uri, &to_s[0], &to_s[1], - &to_s[2], &error); + &to_s[2]); for (n = 0; n<3; n++) { GFile *from, *to; @@ -534,18 +500,6 @@ } - nerror_handler: - - if (nerror) { - if (!errors) - errors = g_string_new (""); - g_string_append_printf (errors, "[`%s': %s] ", - from_urls[i], - nerror->message); - g_error_free (nerror); - nerror = NULL; - } - for (n = 0; n<3; n++) { /* These can be NULL, but that's ok for g_free */ g_free (from_s[n]); @@ -555,22 +509,13 @@ i++; } - if (errors) { - g_set_error (&error, THUMB_ERROR, 0, - errors->str); - g_string_free (errors, TRUE); - dbus_g_method_return_error (context, error); - g_error_free (error); - } else - dbus_g_method_return (context); + dbus_g_method_return (context); } void thumbnailer_delete (Thumbnailer *object, GStrv urls, DBusGMethodInvocation *context) { guint i = 0; - GString *errors = NULL; - GError *error = NULL; dbus_async_return_if_fail (urls != NULL, context); @@ -579,34 +524,20 @@ while (urls[i] != NULL) { const gchar *uri = urls[i]; - GError *nerror = NULL; gchar *normal = NULL, *large = NULL, *cropped = NULL; hildon_thumbnail_util_get_thumb_paths (uri, &large, &normal, - &cropped, &error); + &cropped); - if (nerror) - goto nerror_handler; - g_unlink (large); g_unlink (normal); g_unlink (cropped); nerror_handler: - if (nerror) { - if (!errors) - errors = g_string_new (""); - g_string_append_printf (errors, "[`%s': %s] ", - urls[i], - nerror->message); - g_error_free (nerror); - nerror = NULL; - } - g_free (normal); g_free (large); g_free (cropped); @@ -614,14 +545,7 @@ i++; } - if (errors) { - g_set_error (&error, THUMB_ERROR, 0, - errors->str); - g_string_free (errors, TRUE); - dbus_g_method_return_error (context, error); - g_error_free (error); - } else - dbus_g_method_return (context); + dbus_g_method_return (context); } static void Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/utils.c =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/daemon/utils.c 2008-09-26 07:58:24 UTC (rev 16235) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/utils.c 2008-09-26 09:24:50 UTC (rev 16236) @@ -50,7 +50,7 @@ } void -hildon_thumbnail_util_get_thumb_paths (const gchar *uri, gchar **large, gchar **normal, gchar **cropped, GError **error) +hildon_thumbnail_util_get_thumb_paths (const gchar *uri, gchar **large, gchar **normal, gchar **cropped) { gchar ascii_digest[33]; gchar thumb_filename[128]; @@ -93,3 +93,32 @@ *cropped = g_build_filename (cropped_dir, cropped_filename, NULL); } + + +void +hildon_thumbnail_util_get_albumart_paths (const gchar *albumartist, gchar **path) +{ + gchar ascii_digest[33]; + gchar art_filename[128]; + static gchar *dir = NULL; + gchar *down = g_utf8_strdown (albumartist, -1); + + /* I know we leak, but it's better than doing memory fragementation on + * these strings ... */ + + if (!dir) + dir = g_build_filename (g_get_home_dir (), ".album_art", NULL); + + *path = NULL; + + if(!g_file_test (dir, G_FILE_TEST_EXISTS)) + g_mkdir_with_parents (dir, 0770); + + md5_c_string (down, ascii_digest); + + g_sprintf (art_filename, "%s.png", ascii_digest); + + *path = g_build_filename (dir, art_filename, NULL); + + g_free (down); +} Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/utils.h =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/daemon/utils.h 2008-09-26 07:58:24 UTC (rev 16235) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/utils.h 2008-09-26 09:24:50 UTC (rev 16236) @@ -28,7 +28,8 @@ #include <glib.h> #include <gio/gio.h> -void hildon_thumbnail_util_get_thumb_paths (const gchar *uri, gchar **large, gchar **normal, gchar **cropped, GError **error); +void hildon_thumbnail_util_get_thumb_paths (const gchar *uri, gchar **large, gchar **normal, gchar **cropped); +void hildon_thumbnail_util_get_albumart_paths (const gchar *albumartist, gchar **path); #ifndef g_sprintf gint g_sprintf (gchar *string, gchar const *format, ...); Modified: projects/haf/branches/hildon-thumbnail/daemonize/thumbs/hildon-thumbnail-factory.c =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/thumbs/hildon-thumbnail-factory.c 2008-09-26 07:58:24 UTC (rev 16235) +++ projects/haf/branches/hildon-thumbnail/daemonize/thumbs/hildon-thumbnail-factory.c 2008-09-26 09:24:50 UTC (rev 16236) @@ -170,12 +170,8 @@ * URI */ hildon_thumbnail_util_get_thumb_paths (item->uri, &large, - &normal, &cropped, - &error); + &normal, &cropped); - if (error) - goto error_handler; - create_pixbuf_and_callback (item, large, normal, cropped); error_handler: @@ -367,14 +363,12 @@ NULL); hildon_thumbnail_util_get_thumb_paths (uri, &large, &normal, - &cropped, &error); + &cropped); if (flags & HILDON_THUMBNAIL_FLAG_RECREATE) { - if (!error) { - g_unlink (large); - g_unlink (normal); - g_unlink (cropped); - } + g_unlink (large); + g_unlink (normal); + g_unlink (cropped); } else { gchar *path; if (item->flags & HILDON_THUMBNAIL_FLAG_CROP) {
- Previous message: [maemo-commits] r16235 - projects/connectivity/bluez-debian/tags
- Next message: [maemo-commits] r16237 - in projects/haf/branches/hildon-thumbnail/daemonize: . daemon
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]