[maemo-commits] [maemo-commits] r16166 - in projects/haf/branches/hildon-thumbnail/daemonize: . daemon daemon/plugins
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Wed Sep 17 17:53:58 EEST 2008
- Previous message: [maemo-commits] r16165 - projects/haf/trunk/shared-mime-info/debian
- Next message: [maemo-commits] r16167 - projects/haf/branches/hildon-thumbnail/daemonize/daemon
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: pvanhoof Date: 2008-09-17 17:53:56 +0300 (Wed, 17 Sep 2008) New Revision: 16166 Modified: projects/haf/branches/hildon-thumbnail/daemonize/ChangeLog 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 Log: 2008-09-17 Philip Van Hoof <pvanhoof at gnome.org> * daemon/plugins/gdkpixbuf-plugin.c: * daemon/plugins/exec-plugin.c: * daemon/plugins/gstreamer-video-plugin.c: Fixed memory leaks when errors occur * daemon/thumbnailer.c: Implemented the move, copy, delete hint handlers Modified: projects/haf/branches/hildon-thumbnail/daemonize/ChangeLog =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/ChangeLog 2008-09-17 14:02:33 UTC (rev 16165) +++ projects/haf/branches/hildon-thumbnail/daemonize/ChangeLog 2008-09-17 14:53:56 UTC (rev 16166) @@ -1,5 +1,13 @@ 2008-09-17 Philip Van Hoof <pvanhoof at gnome.org> + * daemon/plugins/gdkpixbuf-plugin.c: + * daemon/plugins/exec-plugin.c: + * daemon/plugins/gstreamer-video-plugin.c: Fixed memory leaks when errors occur + + * daemon/thumbnailer.c: Implemented the move, copy, delete hint handlers + +2008-09-17 Philip Van Hoof <pvanhoof at gnome.org> + * daemon/plugins/exec-plugin.c * daemon/manager.c: Respecting the override file 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-17 14:02:33 UTC (rev 16165) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/exec-plugin.c 2008-09-17 14:53:56 UTC (rev 16166) @@ -293,15 +293,17 @@ g_free (r_exec); -// TODO -// if (on_error) { -// if (!errors) -// errors = g_string_new (""); -// g_string_append_printf (errors, "error msg") -// } + nerror_handler: - nerror_handler: + if (nerror) { + if (!errors) + errors = g_string_new (""); + g_string_append_printf (errors, "[`%s': %s] ", + uri, nerror->message); + g_error_free (nerror); + nerror = NULL; + } if (file) g_object_unref (file); 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-17 14:02:33 UTC (rev 16165) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/gdkpixbuf-plugin.c 2008-09-17 14:53:56 UTC (rev 16166) @@ -333,8 +333,9 @@ if (!errors) errors = g_string_new (""); g_string_append_printf (errors, "[`%s': %s] ", - uri, - nerror->message); + uri, nerror->message); + g_error_free (nerror); + nerror = NULL; } if (stream) 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-17 14:02:33 UTC (rev 16165) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/gstreamer-video-plugin.c 2008-09-17 14:53:56 UTC (rev 16166) @@ -460,8 +460,9 @@ if (!errors) errors = g_string_new (""); g_string_append_printf (errors, "[`%s': %s] ", - uris[i], - nerror->message); + uris[i], nerror->message); + g_error_free (nerror); + nerror = NULL; } g_free (large); Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.c =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.c 2008-09-17 14:02:33 UTC (rev 16165) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.c 2008-09-17 14:53:56 UTC (rev 16166) @@ -39,6 +39,9 @@ #include "dbus-utils.h" #include "utils.h" +#define THUMB_ERROR_DOMAIN "HildonThumbnailer" +#define THUMB_ERROR g_quark_from_static_string (THUMB_ERROR_DOMAIN) + #define THUMBNAILER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_THUMBNAILER, ThumbnailerPrivate)) G_DEFINE_TYPE (Thumbnailer, thumbnailer, G_TYPE_OBJECT) @@ -393,39 +396,215 @@ void 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); keep_alive (); - // TODO - - dbus_g_method_return (context); + while (from_urls[i] != NULL && to_urls[i] != NULL) { + + 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; + gchar *to_normal = NULL, + *to_large = NULL, + *to_cropped = NULL; + + hildon_thumbnail_util_get_thumb_paths (from_uri, &from_large, + &from_normal, + &from_cropped, &error); + + if (nerror) + goto nerror_handler; + + hildon_thumbnail_util_get_thumb_paths (from_uri, &to_large, + &to_normal, + &to_cropped, &error); + + 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); + g_free (to_normal); + g_free (to_large); + g_free (to_cropped); + + 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); } 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); keep_alive (); - // TODO - - dbus_g_method_return (context); + while (from_urls[i] != NULL && to_urls[i] != NULL) { + + 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); + + if (nerror) + goto nerror_handler; + + hildon_thumbnail_util_get_thumb_paths (from_uri, &to_s[0], + &to_s[1], + &to_s[2], &error); + + for (n = 0; n<3; n++) { + GFile *from, *to; + + from = g_file_new_for_path (from_s[n]); + to = g_file_new_for_path (to_s[n]); + + g_file_copy (from, to, + G_FILE_COPY_NONE|G_FILE_COPY_OVERWRITE|G_FILE_COPY_ALL_METADATA, + NULL, NULL, NULL, + &nerror); + + g_object_unref (from); + g_object_unref (to); + + if (nerror) + goto nerror_handler; + } + + 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++) { + g_free (from_s[n]); + g_free (to_s[n]); + } + + 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); } 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); keep_alive (); - // TODO - - dbus_g_method_return (context); + 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); + + 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); + + 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); } static void
- Previous message: [maemo-commits] r16165 - projects/haf/trunk/shared-mime-info/debian
- Next message: [maemo-commits] r16167 - projects/haf/branches/hildon-thumbnail/daemonize/daemon
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]