[Tracker] From the client side

2008-11-21 Thread Marko Anastasov
Hey all,

A few questions:

In practice, pulling every single document's (whatever type) metadata
from Tracker over D-Bus is slow. For example it takes 10+s on my 2 yr
old machine to gather information for about ~1000 documents.
How do you see this problem?

I really do not want to see that every time Paperbox starts any more,
so I think that I'm going to add a private SQLite database for caching
document information so that all documents can be displayed instantly,
while querying Tracker for updates will begin in the background.

I think that there must be a way to sync the metadata database
between desktops. It's just not good enough if copying a file on another
computer leaves you with blank metadata. I only have tags in my mind
now actually but what if Tracker actually stored other useful information
such as notes and reference URLs. So maybe an additional tool could
export the metadata database contents to some file, and on the other
desktop the tool would import the data for recognised files?

Do you think that writing metadata to files should generally be a task
for Tracker or applications? For example if a file belongs to a group
of mime types covered by the XMP, an image, and I tag it in t-s-t,
I think that the tags should be written to the file itself, then inferred
by the metadata store. Atm I think that it might be better to do it on
the Tracker side.

I see in trunk (tracker-daemon.xml) that there is a new signal
for "whenever the count of a category changed":

  


Is this the signal for "there's a new file in index"? That's what's been
really missing IMO.

Marko
___
tracker-list mailing list
tracker-list@gnome.org
http://mail.gnome.org/mailman/listinfo/tracker-list


[Tracker] Please review, thumbnail cleanup code

2008-11-21 Thread Philip Van Hoof
Please review this patch

-- 


Philip Van Hoof
freelance software developer
Codeminded BVBA - http://codeminded.be
-- 
Philip Van Hoof, freelance software developer
home: me at pvanhoof dot be 
gnome: pvanhoof at gnome dot org 
http://pvanhoof.be/blog
http://codeminded.be
Index: src/tracker-indexer/tracker-thumbnailer.c
===
--- src/tracker-indexer/tracker-thumbnailer.c	(revision 0)
+++ src/tracker-indexer/tracker-thumbnailer.c	(revision 0)
@@ -0,0 +1,290 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006, Mr Jamie McCracken ([EMAIL PROTECTED])
+ * 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
+
+static GStrvthumbnailable = NULL;
+static gchar   *batch[51] = { 0 };
+static gchar   *hints[51] = { 0 };
+static guintcount = 0;
+static gboolean timeout_runs = FALSE;
+
+static void
+thumbnail_generic_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);
+	}
+}
+
+static gboolean
+thumbnail_this (GStrv list, const gchar *mime)
+{
+	guint i = 0;
+	gboolean retval = FALSE;
+
+	if (!list)
+		return TRUE;
+
+	while (list[i] != NULL && !retval) {
+		if (g_ascii_strcasecmp (list[i], mime) == 0)
+			retval = TRUE;
+		i++;
+	}
+
+	return retval;
+
+}
+
+static gboolean
+request_thumbnails (gpointer data)
+{
+	if (timeout_runs) {
+		guint i;
+
+		timeout_runs = FALSE;
+		batch[count] = NULL;
+		hints[count] = NULL;
+
+		g_debug ("Requesting thumbnails");
+
+		dbus_g_proxy_begin_call (tracker_dbus_get_thumbnailer (),
+	 "Queue",
+	 thumbnail_generic_cb,
+	 NULL, NULL,
+	 G_TYPE_STRV, batch,
+	 G_TYPE_STRV, hints,
+	 G_TYPE_UINT, 0,
+	 G_TYPE_INVALID);
+
+		for (i = 0; i <= count; i++) {
+			g_free (batch[i]);
+			g_free (hints[i]);
+			batch[i] = NULL;
+			hints[i] = NULL;
+		}
+
+		count = 0;
+	}
+
+	return FALSE;
+}
+
+
+static void
+prepare_thumbnailer (void)
+{
+	static gboolean tried = FALSE;
+
+	/* 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). */
+
+	if (!tried) {
+		GStrv mimes = NULL;
+		GError *error = NULL;
+
+		dbus_g_proxy_call (tracker_dbus_get_thumb_manager(),
+   "GetSupported", &error, G_TYPE_INVALID,
+   G_TYPE_STRV, &mimes, G_TYPE_INVALID);
+		if (error)
+			g_error_free (error);
+