Index: src/tracker-indexer/tracker-thumbnailer.c =================================================================== --- src/tracker-indexer/tracker-thumbnailer.c (revision 2554) +++ src/tracker-indexer/tracker-thumbnailer.c (working copy) @@ -1,382 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org) - * Copyright (C) 2008, Nokia - - * This library is free software; you can redistribute it and/or - * 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 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "config.h" - -#include "tracker-dbus.h" - -/* Undef this to disable thumbnailing (don't remove unless you - * understand that that either you need to put in place another method - * to disable/enable this and that what will be used by the packager - * is probably *your* default, or unless you want to break expected - * functionality on-purpose) (It's not the first time that these - * ifdef-else-endifs where rewrapped incorrectly, and that way - * obviously broke the feature) - */ - -#ifndef THUMBNAILING_OVER_DBUS -#define THUMBNAILING_OVER_DBUS -#endif - -#ifdef THUMBNAILING_OVER_DBUS - -#define THUMBNAIL_REQUEST_LIMIT 50 - -typedef struct { - GStrv supported_mime_types; - - gchar *uris[THUMBNAIL_REQUEST_LIMIT + 1]; - gchar *mime_types[THUMBNAIL_REQUEST_LIMIT + 1]; - - guint request_id; - guint count; - guint timeout_id; - - gboolean service_is_prepared; -} TrackerThumbnailerPrivate; - -static GStaticPrivate private_key = G_STATIC_PRIVATE_INIT; - -static void -private_free (gpointer data) -{ - TrackerThumbnailerPrivate *private; - gint i; - - private = data; - - g_strfreev (private->supported_mime_types); - - for (i = 0; i <= private->count; i++) { - g_free (private->uris[i]); - g_free (private->mime_types[i]); - } - - if (private->timeout_id) { - g_source_remove (private->timeout_id); - } - - g_free (private); -} - -static gboolean -should_be_thumbnailed (GStrv list, - const gchar *mime) -{ - gboolean should_thumbnail; - guint i; - - if (!list) { - return TRUE; - } - - for (should_thumbnail = FALSE, i = 0; - should_thumbnail == FALSE && list[i] != NULL; - i++) { - if (g_ascii_strcasecmp (list[i], mime) == 0) { - should_thumbnail = TRUE; - } - } - - return should_thumbnail; -} - -static void -thumbnailer_reply_cb (DBusGProxy *proxy, - DBusGProxyCall *call, - gpointer user_data) -{ - GError *error = NULL; - guint handle; - - /* The point of this is dbus-glib correctness. Answering this - * because this comment used to be the question: what is the - * point of this. It's correct this way because we do - * asynchronous DBus calls using glib-dbus. For asynchronous - * DBus calls it's recommended (if not required for cleaning - * up) to call dbus_g_proxy_end_call. - */ - dbus_g_proxy_end_call (proxy, call, &error, - G_TYPE_UINT, &handle, - G_TYPE_INVALID); - - if (error) { - g_warning ("%s", error->message); - g_error_free (error); - return; - } - - g_message ("Received response from thumbnailer, request ID:%d", - GPOINTER_TO_UINT (user_data)); -} - -static gboolean -thumbnailer_request_timeout_cb (gpointer data) -{ - TrackerThumbnailerPrivate *private; - guint i; - - private = g_static_private_get (&private_key); - g_return_val_if_fail (private != NULL, FALSE); - - private->request_id++; - - private->uris[private->count] = NULL; - private->mime_types[private->count] = NULL; - - g_message ("Sending request to thumbnailer to queue %d files, request ID:%d...", - private->count, - private->request_id); - - dbus_g_proxy_begin_call (tracker_dbus_get_thumbnailer (), - "Queue", - thumbnailer_reply_cb, - GUINT_TO_POINTER (private->request_id), - NULL, - G_TYPE_STRV, private->uris, - G_TYPE_STRV, private->mime_types, - G_TYPE_UINT, 0, - G_TYPE_INVALID); - - for (i = 0; i <= private->count; i++) { - g_free (private->uris[i]); - g_free (private->mime_types[i]); - private->uris[i] = NULL; - private->mime_types[i] = NULL; - } - - private->count = 0; - private->timeout_id = 0; - - return FALSE; -} - -static void -thumbnailer_prepare (void) -{ - TrackerThumbnailerPrivate *private; - GStrv mime_types = NULL; - GError *error = NULL; - - private = g_static_private_get (&private_key); - - if (private->service_is_prepared) { - return; - } - - /* It's known that this relatively small GStrv is leaked: it contains - * the MIME types that the DBus thumbnailer supports. If a MIME type - * is not within this list, yet we retrieved it once, then we decide - * not to perform thumbnail actions over DBus. This is a performance - * improvement and the GStrv can be resident in memory until the end - * of the application - it's a cache - - * - * It doesn't support detecting when the DBus thumbnailer starts - * supporting more formats (which can indeed start happening). This is - * a known tradeoff and limitation of this cache. We could enhance this - * cache to listen for changes on the bus, and invalidate it once we - * know that more MIME types have become supported. It has no high - * priority now, though (therefore, is this a TODO). - */ - - g_message ("Thumbnailer supported mime types being requested..."); - - dbus_g_proxy_call (tracker_dbus_get_thumb_manager (), - "GetSupported", &error, - G_TYPE_INVALID, - G_TYPE_STRV, &mime_types, - G_TYPE_INVALID); - - if (error) { - g_warning ("Thumbnailer service did not return supported mime types, %s", - error->message); - g_error_free (error); - } else if (mime_types) { - g_message ("Thumbnailer supports %d mime types", - g_strv_length (mime_types)); - private->supported_mime_types = mime_types; - } - - private->service_is_prepared = TRUE; -} - -#endif /* THUMBNAILING_OVER_DBUS */ - -void -tracker_thumbnailer_init (void) -{ - TrackerThumbnailerPrivate *private; - - private = g_new0 (TrackerThumbnailerPrivate, 1); - g_static_private_set (&private_key, - private, - private_free); - - thumbnailer_prepare (); -} - -void -tracker_thumbnailer_shutdown (void) -{ - g_static_private_set (&private_key, NULL, NULL); -} - -void -tracker_thumbnailer_move (const gchar *from_uri, - const gchar *mime_type, - const gchar *to_uri) -{ -#ifdef THUMBNAILING_OVER_DBUS - TrackerThumbnailerPrivate *private; - const gchar *to[2] = { NULL, NULL }; - const gchar *from[2] = { NULL, NULL }; - - g_return_if_fail (from_uri != NULL); - g_return_if_fail (mime_type != NULL); - g_return_if_fail (to_uri != NULL); - - private = g_static_private_get (&private_key); - g_return_if_fail (private != NULL); - - if (!should_be_thumbnailed (private->supported_mime_types, mime_type)) { - g_debug ("Thumbnailer ignoring mime type:'%s'", - mime_type); - return; - } - - private->request_id++; - - g_message ("Requesting thumbnailer moves URI from:'%s' to:'%s', request_id:%d...", - from_uri, - to_uri, - private->request_id); - - to[0] = to_uri; - from[0] = from_uri; - - dbus_g_proxy_begin_call (tracker_dbus_get_thumbnailer (), - "Move", - thumbnailer_reply_cb, - GUINT_TO_POINTER (private->request_id), - NULL, - G_TYPE_STRV, from, - G_TYPE_STRV, to, - G_TYPE_INVALID); -#endif /* THUMBNAILING_OVER_DBUS */ -} - -void -tracker_thumbnailer_remove (const gchar *uri, - const gchar *mime_type) -{ -#ifdef THUMBNAILING_OVER_DBUS - TrackerThumbnailerPrivate *private; - const gchar *uris[2] = { NULL, NULL }; - - g_return_if_fail (uri != NULL); - g_return_if_fail (mime_type != NULL); - - private = g_static_private_get (&private_key); - g_return_if_fail (private != NULL); - - if (!should_be_thumbnailed (private->supported_mime_types, mime_type)) { - g_debug ("Thumbnailer ignoring mime type:'%s' and uri:'%s'", - mime_type, - uri); - return; - } - - private->request_id++; - - uris[0] = uri; - - g_message ("Requesting thumbnailer removes URI:'%s', request_id:%d...", - uri, - private->request_id); - - dbus_g_proxy_begin_call (tracker_dbus_get_thumbnailer (), - "Delete", - thumbnailer_reply_cb, - GUINT_TO_POINTER (private->request_id), - NULL, - G_TYPE_STRV, uri, - G_TYPE_INVALID); -#endif /* THUMBNAILING_OVER_DBUS */ -} - -void -tracker_thumbnailer_get_file_thumbnail (const gchar *uri, - const gchar *mime_type) -{ -#ifdef THUMBNAILING_OVER_DBUS - TrackerThumbnailerPrivate *private; - - g_return_if_fail (uri != NULL); - g_return_if_fail (mime_type != NULL); - - private = g_static_private_get (&private_key); - g_return_if_fail (private != NULL); - - if (!should_be_thumbnailed (private->supported_mime_types, mime_type)) { - g_debug ("Thumbnailer ignoring mime type:'%s' and uri:'%s'", - mime_type, - uri); - return; - } - - private->request_id++; - - g_message ("Requesting thumbnailer to get thumbnail for URI:'%s', request_id:%d...", - uri, - private->request_id); - - /* We want to deal with the current list first if it is - * already at the limit. - */ - if (private->count == THUMBNAIL_REQUEST_LIMIT) { - g_debug ("Already have %d thumbnails queued, forcing thumbnailer request", - THUMBNAIL_REQUEST_LIMIT); - - g_source_remove (private->timeout_id); - private->timeout_id = 0; - - thumbnailer_request_timeout_cb (NULL); - } - - /* Add new URI */ - private->uris[private->count] = g_strdup (uri); - - if (mime_type) { - private->mime_types[private->count] = g_strdup (mime_type); - } else if (g_strv_length (private->mime_types) > 0) { - private->mime_types[private->count] = g_strdup ("unknown/unknown"); - } - - private->count++; - - if (private->timeout_id == 0) { - private->timeout_id = - g_timeout_add_seconds (30, - thumbnailer_request_timeout_cb, - NULL); - } -#endif /* THUMBNAILING_OVER_DBUS */ -} Index: src/tracker-indexer/tracker-metadata-utils.c =================================================================== --- src/tracker-indexer/tracker-metadata-utils.c (revision 2554) +++ src/tracker-indexer/tracker-metadata-utils.c (working copy) @@ -29,9 +29,9 @@ #include #include #include +#include #include "tracker-metadata-utils.h" -#include "tracker-thumbnailer.h" #define METADATA_FILE_NAME_DELIMITED "File:NameDelimited" #define METADATA_FILE_EXT "File:Ext" Index: src/tracker-indexer/tracker-thumbnailer.h =================================================================== --- src/tracker-indexer/tracker-thumbnailer.h (revision 2554) +++ src/tracker-indexer/tracker-thumbnailer.h (working copy) @@ -1,43 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org) - * Copyright (C) 2008, Nokia - - * This library is free software; you can redistribute it and/or - * 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 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __TRACKER_METADATA_UTILS_H__ -#define __TRACKER_METADATA_UTILS_H__ - -#include -#include - -G_BEGIN_DECLS - -void tracker_thumbnailer_init (void); -void tracker_thumbnailer_shutdown (void); - -void tracker_thumbnailer_get_file_thumbnail (const gchar *path, - const gchar *mime); -void tracker_thumbnailer_move (const gchar *from_uri, - const gchar *mime_type, - const gchar *to_uri); -void tracker_thumbnailer_remove (const gchar *uri, - const gchar *mime_type); - -G_END_DECLS - -#endif /* __TRACKER_METADATA_UTILS_H__ */ Index: src/tracker-indexer/tracker-main.c =================================================================== --- src/tracker-indexer/tracker-main.c (revision 2554) +++ src/tracker-indexer/tracker-main.c (working copy) @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -45,7 +46,6 @@ #include "tracker-dbus.h" #include "tracker-indexer.h" -#include "tracker-thumbnailer.h" #define ABOUT \ "Tracker " PACKAGE_VERSION "\n" \ Index: src/tracker-indexer/tracker-dbus.c =================================================================== --- src/tracker-indexer/tracker-dbus.c (revision 2554) +++ src/tracker-indexer/tracker-dbus.c (working copy) @@ -27,17 +27,9 @@ #include "tracker-indexer.h" #include "tracker-indexer-glue.h" -#define THUMBNAILER_SERVICE "org.freedesktop.thumbnailer" -#define THUMBNAILER_PATH "/org/freedesktop/thumbnailer/Generic" -#define THUMBNAILER_INTERFACE "org.freedesktop.thumbnailer.Generic" -#define THUMBMAN_PATH "/org/freedesktop/thumbnailer/Manager" -#define THUMBMAN_INTERFACE "org.freedesktop.thumbnailer.Manager" - static DBusGConnection *connection; static DBusGProxy *proxy; -static DBusGProxy *thumb_proxy; -static DBusGProxy *thumbm_proxy; static gboolean dbus_register_service (DBusGProxy *proxy, @@ -111,18 +103,7 @@ return TRUE; } -DBusGProxy* -tracker_dbus_get_thumbnailer (void) -{ - return thumb_proxy; -} -DBusGProxy* -tracker_dbus_get_thumb_manager (void) -{ - return thumbm_proxy; -} - static gboolean dbus_register_names (void) { @@ -160,15 +141,6 @@ return FALSE; } - thumb_proxy = dbus_g_proxy_new_for_name (connection, - THUMBNAILER_SERVICE, - THUMBNAILER_PATH, - THUMBNAILER_INTERFACE); - - thumbm_proxy = dbus_g_proxy_new_for_name (connection, - THUMBNAILER_SERVICE, - THUMBMAN_PATH, - THUMBMAN_INTERFACE); return TRUE; } Index: src/tracker-indexer/tracker-indexer.c =================================================================== --- src/tracker-indexer/tracker-indexer.c (revision 2554) +++ src/tracker-indexer/tracker-indexer.c (working copy) @@ -63,6 +63,7 @@ #include #include #include +#include #include #include @@ -74,7 +75,6 @@ #include "tracker-indexer.h" #include "tracker-indexer-module.h" #include "tracker-marshal.h" -#include "tracker-thumbnailer.h" #define TRACKER_INDEXER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRACKER_TYPE_INDEXER, TrackerIndexerPrivate)) Index: src/tracker-indexer/Makefile.am =================================================================== --- src/tracker-indexer/Makefile.am (revision 2554) +++ src/tracker-indexer/Makefile.am (working copy) @@ -39,9 +39,7 @@ tracker-indexer-module.c \ tracker-indexer-module.h \ tracker-main.c \ - tracker-marshal-main.c \ - tracker-thumbnailer.c \ - tracker-thumbnailer.h + tracker-marshal-main.c tracker_indexer_LDADD = \ libtracker-indexer.la \ Index: src/trackerd/tracker-main.c =================================================================== --- src/trackerd/tracker-main.c (revision 2554) +++ src/trackerd/tracker-main.c (working copy) @@ -60,6 +60,7 @@ #include "tracker-processor.h" #include "tracker-status.h" #include "tracker-xesam-manager.h" +#include "tracker-cleanup.h" #ifdef G_OS_WIN32 #include @@ -984,6 +985,7 @@ tracker_data_manager_init (config, language, file_index, email_index); tracker_xesam_manager_init (); + tracker_cleanup_init (); #ifdef HAVE_HAL /* We set up the throttle and mount points here. For the mount @@ -1071,6 +1073,7 @@ shutdown_directories (); /* Shutdown major subsystems */ + tracker_cleanup_shutdown (); tracker_xesam_manager_shutdown (); tracker_dbus_shutdown (); tracker_db_manager_shutdown (); Index: src/trackerd/tracker-cleanup.c =================================================================== --- src/trackerd/tracker-cleanup.c (revision 0) +++ src/trackerd/tracker-cleanup.c (revision 0) @@ -0,0 +1,118 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Copyright (C) 2008, Nokia + * + * This library 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 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "config.h" + +#include + +#include +#include + +#define MORE_THAN_A_DAY_OF_SECONDS 86400 + 60 + +/* Deals with cleaning up resident data after longer timeouts (days, sessions) */ + +static gboolean +check_for_volumes_to_cleanup (gpointer user_data) +{ + TrackerDBInterface *iface; + TrackerDBResultSet *result_set; + + iface = tracker_db_manager_get_db_interface (TRACKER_DB_COMMON); + + /* The stored statements of volume management have the "every one that + * is older than three days since their last unmount time" logic embed- + * ded in the SQL statements. Take a look at sqlite-stored-procs.sql */ + + result_set = tracker_db_interface_execute_procedure (iface, NULL, + "GetVolumesToClean", + NULL); + + if (result_set) { + gboolean is_valid = TRUE; + + while (is_valid) { + GValue value = { 0, }; + const gchar *mount_point; + + _tracker_db_result_set_get_value (result_set, 0, &value); + + mount_point = g_value_get_string (&value); + + /* Add cleanup items here */ + + tracker_thumbnailer_cleanup (mount_point); + + g_value_unset (&value); + + is_valid = tracker_db_result_set_iter_next (result_set); + } + + g_object_unref (result_set); + } + + return TRUE; +} + + +typedef struct { + guint timeout_id; +} TrackerCleanupPrivate; + +static GStaticPrivate private_key = G_STATIC_PRIVATE_INIT; + +static void +private_free (gpointer data) +{ + TrackerCleanupPrivate *private; + + private = data; + + if (private->timeout_id) { + g_source_remove (private->timeout_id); + } + + g_free (private); +} + +void +tracker_cleanup_init (void) +{ + TrackerCleanupPrivate *private; + + private = g_new0 (TrackerCleanupPrivate, 1); + + g_static_private_set (&private_key, + private, + private_free); + + check_for_volumes_to_cleanup (private); + + private->timeout_id = + g_timeout_add_seconds (MORE_THAN_A_DAY_OF_SECONDS, + check_for_volumes_to_cleanup, + private); +} + + +void tracker_cleanup_shutdown (void) +{ + g_static_private_set (&private_key, NULL, NULL); +} Index: src/trackerd/tracker-cleanup.h =================================================================== --- src/trackerd/tracker-cleanup.h (revision 0) +++ src/trackerd/tracker-cleanup.h (revision 0) @@ -0,0 +1,27 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Copyright (C) 2008, Nokia + * + * This library 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 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __TRACKERD_CLEANUP_H__ +#define __TRACKERD_CLEANUP_H__ + +void tracker_cleanup_init (void); +void tracker_cleanup_shutdown (void); + +#endif /* __TRACKERD_CLEANUP_H__ */ Index: src/trackerd/Makefile.am =================================================================== --- src/trackerd/Makefile.am (revision 2554) +++ src/trackerd/Makefile.am (working copy) @@ -61,7 +61,9 @@ tracker-xesam-session.c \ tracker-xesam-session.h \ tracker-xesam-live-search.c \ - tracker-xesam-live-search.h + tracker-xesam-live-search.h \ + tracker-cleanup.c \ + tracker-cleanup.h if OS_WIN32 trackerd_win_libs = -lws2_32 -lkernel32 Index: src/tracker-extract/tracker-albumart.c =================================================================== --- src/tracker-extract/tracker-albumart.c (revision 2554) +++ src/tracker-extract/tracker-albumart.c (working copy) @@ -40,6 +40,7 @@ #include #include +#include #include "tracker-albumart.h" @@ -59,31 +60,6 @@ gchar **path, gchar **local); - -static DBusGProxy* -get_thumb_requester (void) -{ - static DBusGProxy *thumb_proxy = NULL; - - if (!thumb_proxy) { - GError *error = NULL; - DBusGConnection *connection; - - connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - - if (!error) { - thumb_proxy = dbus_g_proxy_new_for_name (connection, - THUMBNAILER_SERVICE, - THUMBNAILER_PATH, - THUMBNAILER_INTERFACE); - } else { - g_error_free (error); - } - } - - return thumb_proxy; -} - #ifndef HAVE_STRCASESTR static gchar * @@ -254,24 +230,7 @@ return retval; } -static void -thumbnail_generic_cb (DBusGProxy *proxy, - DBusGProxyCall *call, - gpointer user_data) -{ - GError *error = NULL; - guint handle; - dbus_g_proxy_end_call (proxy, call, &error, - G_TYPE_UINT, &handle, - G_TYPE_INVALID); - - if (error) { - g_warning ("%s", error->message); - g_error_free (error); - } -} - static void perhaps_copy_to_local (const gchar *filename, const gchar *local_uri) { @@ -287,24 +246,8 @@ if (!filename) return; - as_uri = (gchar **) g_malloc0 (sizeof (gchar *) * 2); - hints = (gchar **) g_malloc0 (sizeof (gchar *) * 2); + tracker_thumbnailer_get_file_thumbnail (filename, "image/jpeg"); - as_uri[0] = g_strdup_printf ("file://%s", filename); - hints[0] = g_strdup ("image/jpeg"); - - dbus_g_proxy_begin_call (get_thumb_requester (), - "Queue", - thumbnail_generic_cb, - NULL, NULL, - G_TYPE_STRV, as_uri, - G_TYPE_STRV, hints, - G_TYPE_UINT, 0, - G_TYPE_INVALID); - - g_strfreev (as_uri); - g_strfreev (hints); - if (!local_uri) return; Index: src/libtracker-common/tracker-thumbnailer.c =================================================================== --- src/libtracker-common/tracker-thumbnailer.c (revision 2554) +++ src/libtracker-common/tracker-thumbnailer.c (working copy) @@ -38,8 +38,66 @@ #ifdef THUMBNAILING_OVER_DBUS +#define THUMBNAILER_SERVICE "org.freedesktop.thumbnailer" +#define THUMBNAILER_PATH "/org/freedesktop/thumbnailer/Generic" +#define THUMBNAILER_INTERFACE "org.freedesktop.thumbnailer.Generic" + +#define THUMBMAN_PATH "/org/freedesktop/thumbnailer/Manager" +#define THUMBMAN_INTERFACE "org.freedesktop.thumbnailer.Manager" + #define THUMBNAIL_REQUEST_LIMIT 50 + + +static DBusGProxy* +get_thumb_requester (void) +{ + static DBusGProxy *thumb_proxy = NULL; + + if (!thumb_proxy) { + GError *error = NULL; + DBusGConnection *connection; + + connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); + + if (!error) { + thumb_proxy = dbus_g_proxy_new_for_name (connection, + THUMBNAILER_SERVICE, + THUMBNAILER_PATH, + THUMBNAILER_INTERFACE); + } else { + g_error_free (error); + } + } + + return thumb_proxy; +} + + +static DBusGProxy* +get_thumb_manager (void) +{ + static DBusGProxy *thumbm_proxy = NULL; + + if (!thumbm_proxy) { + GError *error = NULL; + DBusGConnection *connection; + + connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); + + if (!error) { + thumbm_proxy = dbus_g_proxy_new_for_name (connection, + THUMBNAILER_SERVICE, + THUMBMAN_PATH, + THUMBMAN_INTERFACE); + } else { + g_error_free (error); + } + } + + return thumbm_proxy; +} + typedef struct { GStrv supported_mime_types; @@ -146,7 +204,7 @@ private->count, private->request_id); - dbus_g_proxy_begin_call (tracker_dbus_get_thumbnailer (), + dbus_g_proxy_begin_call (get_thumb_requester (), "Queue", thumbnailer_reply_cb, GUINT_TO_POINTER (private->request_id), @@ -199,7 +257,7 @@ g_message ("Thumbnailer supported mime types being requested..."); - dbus_g_proxy_call (tracker_dbus_get_thumb_manager (), + dbus_g_proxy_call (get_thumb_manager (), "GetSupported", &error, G_TYPE_INVALID, G_TYPE_STRV, &mime_types, @@ -272,7 +330,7 @@ to[0] = to_uri; from[0] = from_uri; - dbus_g_proxy_begin_call (tracker_dbus_get_thumbnailer (), + dbus_g_proxy_begin_call (get_thumb_requester (), "Move", thumbnailer_reply_cb, GUINT_TO_POINTER (private->request_id), @@ -312,7 +370,7 @@ uri, private->request_id); - dbus_g_proxy_begin_call (tracker_dbus_get_thumbnailer (), + dbus_g_proxy_begin_call (get_thumb_requester (), "Delete", thumbnailer_reply_cb, GUINT_TO_POINTER (private->request_id), @@ -322,6 +380,34 @@ #endif /* THUMBNAILING_OVER_DBUS */ } +void +tracker_thumbnailer_cleanup (const gchar *uri_prefix) +{ +#ifdef THUMBNAILING_OVER_DBUS + TrackerThumbnailerPrivate *private; + + private = g_static_private_get (&private_key); + g_return_if_fail (private != NULL); + + private->request_id++; + + g_message ("Requesting thumbnailer cleanup URI:'%s', request_id:%d...", + uri_prefix, + private->request_id); + + dbus_g_proxy_begin_call (get_thumb_requester (), + "Cleanup", + thumbnailer_reply_cb, + GUINT_TO_POINTER (private->request_id), + NULL, + G_TYPE_STRING, uri_prefix, + G_TYPE_INT64, 0, + G_TYPE_INVALID); + +#endif /* THUMBNAILING_OVER_DBUS */ +} + + void tracker_thumbnailer_get_file_thumbnail (const gchar *uri, const gchar *mime_type) Index: src/libtracker-common/tracker-thumbnailer.h =================================================================== --- src/libtracker-common/tracker-thumbnailer.h (revision 2554) +++ src/libtracker-common/tracker-thumbnailer.h (working copy) @@ -37,6 +37,7 @@ const gchar *to_uri); void tracker_thumbnailer_remove (const gchar *uri, const gchar *mime_type); +void tracker_thumbnailer_cleanup (const gchar *uri_prefix); G_END_DECLS Index: src/libtracker-common/Makefile.am =================================================================== --- src/libtracker-common/Makefile.am (revision 2554) +++ src/libtracker-common/Makefile.am (working copy) @@ -47,7 +47,8 @@ tracker-parser.c \ tracker-service.c \ tracker-type-utils.c \ - tracker-utils.c + tracker-utils.c \ + tracker-thumbnailer.c noinst_HEADERS = \ $(hal_headers) \ @@ -56,7 +57,8 @@ tracker-ioprio.h \ tracker-log.h \ tracker-nfs-lock.h \ - tracker-os-dependant.h + tracker-os-dependant.h \ + tracker-thumbnailer.h libtracker_commoninclude_HEADERS = \ tracker-common.h \ Index: tests/tracker-indexer/Makefile.am =================================================================== --- tests/tracker-indexer/Makefile.am (revision 2554) +++ tests/tracker-indexer/Makefile.am (working copy) @@ -34,9 +34,7 @@ tracker-module-file.c \ tracker-module-file.h \ tracker-module-iteratable.c \ - tracker-module-iteratable.h \ - tracker-thumbnailer.c \ - tracker-thumbnailer.h + tracker-module-iteratable.h tracker_metadata_utils_LDADD = \ $(top_builddir)/src/libtracker-data/libtracker-data.la \ Index: configure.ac =================================================================== --- configure.ac (revision 2554) +++ configure.ac (working copy) @@ -1114,8 +1114,6 @@ tests/tracker-indexer/tracker-module-file.h:src/tracker-indexer/tracker-module-file.h tests/tracker-indexer/tracker-module-iteratable.c:src/tracker-indexer/tracker-module-iteratable.c tests/tracker-indexer/tracker-module-iteratable.h:src/tracker-indexer/tracker-module-iteratable.h - tests/tracker-indexer/tracker-thumbnailer.h:src/tracker-indexer/tracker-thumbnailer.h - tests/tracker-indexer/tracker-thumbnailer.c:src/tracker-indexer/tracker-thumbnailer.c ) ################################################################## Index: data/db/sqlite-stored-procs.sql =================================================================== --- data/db/sqlite-stored-procs.sql (revision 2554) +++ data/db/sqlite-stored-procs.sql (working copy) @@ -131,10 +131,11 @@ GetVolumeID SELECT VolumeID FROM Volumes WHERE UDI = ?; GetVolumeByPath SELECT VolumeID FROM Volumes WHERE Enabled = 1 AND (? = MountPath OR ? LIKE (MountPath || '/%')); -InsertVolume INSERT INTO Volumes (MountPath, UDI, Enabled) VALUES (?, ?, 1); +GetVolumesToClean SELECT VolumeID FROM Volumes WHERE DisabledDate < date('now', '-3 day'); +InsertVolume INSERT INTO Volumes (MountPath, UDI, Enabled, DisabledDate) VALUES (?, ?, 1, date('now')); EnableVolume UPDATE Volumes SET MountPath = ?, Enabled = 1 WHERE UDI = ?; -DisableVolume UPDATE Volumes SET Enabled = 0 WHERE UDI = ?; -DisableAllVolumes UPDATE Volumes SET Enabled = 0; +DisableVolume UPDATE Volumes SET Enabled = 0, DisabledDate = date ('now') WHERE UDI = ?; +DisableAllVolumes UPDATE Volumes SET Enabled = 0, DisabledDate = date ('now'); /* * XESAM queries Index: data/db/sqlite-tracker.sql =================================================================== --- data/db/sqlite-tracker.sql (revision 2554) +++ data/db/sqlite-tracker.sql (working copy) @@ -17,8 +17,8 @@ UDI Text, VolumeName Text, MountPath Text, - Enabled Integer default 0 - + Enabled Integer default 0, + DisabledDate Text );