[tracker/extractor-dev: 1/17] libtracker-extract: Added example to examples/libtracker-extract



commit 86911d51577a558727038770b04c95501b3ea627
Author: Martyn Russell <martyn lanedo com>
Date:   Mon Mar 8 16:27:44 2010 +0000

    libtracker-extract: Added example to examples/libtracker-extract
    
    Moved mockup from src/tracker-extract/ to here.
    Used MP3 source and added comments to detail what is going on

 configure.ac                                       |    1 +
 .../libtracker-client-sections.txt                 |    2 +
 .../libtracker-common-sections.txt                 |    2 -
 examples/Makefile.am                               |    1 +
 examples/libtracker-extract/Makefile.am            |   23 ++
 .../libtracker-extract/tracker-extract-mockup.c    |  345 ++++++++++++++++++++
 src/libtracker-client/tracker.c                    |  236 +++++++++++++-
 src/libtracker-client/tracker.h                    |    5 +
 src/libtracker-common/tracker-common.h             |   16 +-
 src/libtracker-common/tracker-utils.c              |  198 -----------
 src/libtracker-common/tracker-utils.h              |    4 -
 src/plugins/kmail/tracker-kmail-registrar.c        |    5 +-
 src/tracker-extract/Makefile.am                    |   16 -
 src/tracker-extract/tracker-extract-gstreamer.c    |    7 +-
 src/tracker-extract/tracker-extract-mockup.c       |   95 ------
 src/tracker-extract/tracker-extract-mp3.c          |    7 +-
 16 files changed, 625 insertions(+), 338 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index e797e47..37d47ac 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1702,6 +1702,7 @@ AC_CONFIG_FILES([
 	utils/tracker-fts/Makefile
         utils/services/Makefile
 	examples/Makefile
+        examples/libtracker-extract/Makefile
         examples/libtracker-miner/Makefile
 	examples/rss-reader/Makefile
 ])
diff --git a/docs/reference/libtracker-client/libtracker-client-sections.txt b/docs/reference/libtracker-client/libtracker-client-sections.txt
index a337ea1..7e33943 100644
--- a/docs/reference/libtracker-client/libtracker-client-sections.txt
+++ b/docs/reference/libtracker-client/libtracker-client-sections.txt
@@ -30,6 +30,8 @@ tracker_cancel_last_call
 <FILE>tracker_misc</FILE>
 <TITLE>Utilities</TITLE>
 tracker_sparql_escape
+tracker_uri_printf_escaped
+tracker_uri_vprintf_escaped
 </SECTION>
 
 <SECTION>
diff --git a/docs/reference/libtracker-common/libtracker-common-sections.txt b/docs/reference/libtracker-common/libtracker-common-sections.txt
index 930b639..9244f82 100644
--- a/docs/reference/libtracker-common/libtracker-common-sections.txt
+++ b/docs/reference/libtracker-common/libtracker-common-sections.txt
@@ -395,8 +395,6 @@ tracker_string_replace
 tracker_string_remove
 tracker_seconds_estimate_to_string
 tracker_seconds_to_string
-tracker_uri_vprintf_escaped
-tracker_uri_printf_escaped
 </SECTION>
 
 <SECTION>
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 44c1e3f..41a8a67 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -1,5 +1,6 @@
 include $(top_srcdir)/Makefile.decl
 
 SUBDIRS = 			\
+	libtracker-extract	\
 	libtracker-miner	\
 	rss-reader
diff --git a/examples/libtracker-extract/Makefile.am b/examples/libtracker-extract/Makefile.am
new file mode 100644
index 0000000..eb6987d
--- /dev/null
+++ b/examples/libtracker-extract/Makefile.am
@@ -0,0 +1,23 @@
+include $(top_srcdir)/Makefile.decl
+
+module_flags = -module -avoid-version -no-undefined
+modulesdir = $(libdir)/tracker-$(TRACKER_API_VERSION)/extract-modules
+
+INCLUDES = 								\
+	-DLOCALEDIR=\""$(localedir)"\" 					\
+	-DMODULESDIR=\"$(modulesdir)\"					\
+	-I$(top_srcdir)/src 						\
+	$(WARN_CFLAGS)							\
+	$(GLIB2_CFLAGS)							\
+	$(GCOV_CFLAGS)
+
+modules_LTLIBRARIES = libextract-mockup.la
+
+libextract_mockup_la_SOURCES = tracker-extract-mockup.c
+libextract_mockup_la_LDFLAGS = $(module_flags)
+libextract_mockup_la_LIBADD = 						\
+	$(top_builddir)/src/libtracker-extract/libtracker-extract- TRACKER_API_VERSION@.la \
+	$(top_builddir)/src/libtracker-common/libtracker-common.la	\
+	$(GLIB2_LIBS)  							\
+	$(GCOV_LIBS)
+
diff --git a/examples/libtracker-extract/tracker-extract-mockup.c b/examples/libtracker-extract/tracker-extract-mockup.c
new file mode 100644
index 0000000..03879cc
--- /dev/null
+++ b/examples/libtracker-extract/tracker-extract-mockup.c
@@ -0,0 +1,345 @@
+/*
+ * Copyright (C) 2010, Your name <Your email address>
+ *
+ * This program 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 program 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 program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ */
+
+#include "config.h"
+
+#include <stdio.h>
+
+/* TODO: Include any 3rd party libraries here. */
+
+/* #include <libtracker-common/tracker-file-utils.h> */
+/* #include <libtracker-common/tracker-utils.h> */
+
+#include <gio/gio.h>
+
+#include <libtracker-extract/tracker-extract.h>
+#include <libtracker-extract/tracker-utils.h>
+
+#include <libtracker-client/tracker.h>
+
+static void extract_mockup (const gchar          *uri,
+                            TrackerSparqlBuilder *preupdate,
+                            TrackerSparqlBuilder *metadata);
+
+static TrackerExtractData data[] = {
+	/* TODO: Insert mime types and functions here. */
+	{ "audio/mpeg",  extract_mockup },
+	{ "audio/x-mp3", extract_mockup },
+	{ NULL, NULL }
+};
+
+static void
+extract_mockup (const gchar          *uri,
+                TrackerSparqlBuilder *preupdate,
+                TrackerSparqlBuilder *metadata)
+{
+	/* File information */
+	FILE *f;
+	GFileInfo *info;
+	GFile *file;
+	GError *error = NULL;
+	gchar *filename;
+	goffset size;
+
+	/* Data input */
+	gchar *title_tagv1;
+	gchar *title_tagv2;
+	gchar *title_tagv3;
+	gchar *title_unknown;
+	gchar *lyricist_tagv2;
+	gchar *lyricist_unknown;
+
+	/* Coalesced input */
+	gchar *title;
+	gchar *performer;
+	gchar *performer_uri;
+	gchar *lyricist;
+	gchar *lyricist_uri;
+	gchar *album;
+	gchar *album_uri;
+	gchar *genre;
+	gchar *text;
+	gchar *recording_time;
+	gchar *copyright;
+	gchar *publisher;
+	gchar *comment;
+	gchar *composer;
+	gchar *composer_uri;
+	gint track_number;
+	gint track_count;
+	guint32 duration;
+
+	filename = g_filename_from_uri (uri, NULL, NULL);
+
+	file = g_file_new_for_path (filename);
+	info = g_file_query_info (file,
+	                          G_FILE_ATTRIBUTE_STANDARD_SIZE,
+	                          G_FILE_QUERY_INFO_NONE,
+	                          NULL,
+	                          &error);
+
+	if (G_UNLIKELY (error)) {
+		g_message ("Could not get size for '%s', %s",
+		           filename,
+		           error->message);
+		g_error_free (error);
+		size = 0;
+	} else {
+		size = g_file_info_get_size (info);
+		g_object_unref (info);
+	}
+
+	g_object_unref (file);
+
+	/* TODO: Do any pre-checks on the file
+	 * (i.e check file size so we don't handle files of 0 size)
+	 */
+	if (size < 64) {
+		g_free (filename);
+		return;
+	}
+
+	/* TODO: Open file */
+	f = fopen (filename, "r");
+
+	if (!f) {
+		g_free (filename);
+		return;
+	}
+	
+	/* TODO: Get data from file.
+	 *
+	 * (We will use dummy data for this example)
+	 */
+	title_tagv1 = NULL;
+	title_tagv2 = g_strdup ("Burn The Witch");
+	title_tagv3 = g_strdup ("");
+	title_unknown = g_strdup ("Unknown");
+
+	lyricist_tagv2 = g_strdup ("Someone");
+	lyricist_unknown = g_strdup ("Someone");
+
+	/* TODO: Close file */
+	fclose (f);
+
+	/* TODO: Make sure we coalesce duplicate values */
+	title = tracker_extract_coalesce (4, title_tagv1, title_tagv2, title_tagv3, title_unknown);
+	lyricist = tracker_extract_coalesce (2, lyricist_tagv2, lyricist_unknown);
+
+	performer = g_strdup ("Stone Gods");
+	composer = NULL;
+	album = g_strdup ("Silver Spoons And Broken Bones");
+	genre = g_strdup ("Rock");
+	recording_time = NULL;
+	publisher = NULL;
+	text = g_strdup ("Some description");
+	copyright = g_strdup ("Who knows?");
+	comment = g_strdup ("I love this track");
+	track_number = 1;
+	track_count = 12;
+	duration = 32;
+
+	/* TODO: Do any pre-updates
+	 *
+	 * (This involves creating any database nodes for consistent
+	 *  data objects, for example, an artist which might be used n times)
+	 */
+	if (performer) {
+		performer_uri = tracker_uri_printf_escaped ("urn:artist:%s", performer);
+
+		tracker_sparql_builder_insert_open (preupdate, NULL);
+		tracker_sparql_builder_subject_iri (preupdate, performer_uri);
+		tracker_sparql_builder_predicate (preupdate, "a");
+		tracker_sparql_builder_object (preupdate, "nmm:Artist");
+		tracker_sparql_builder_predicate (preupdate, "nmm:artistName");
+		tracker_sparql_builder_object_unvalidated (preupdate, performer);
+		tracker_sparql_builder_insert_close (preupdate);
+	} else {
+		performer_uri = NULL;
+	}
+
+	if (composer) {
+		composer_uri = tracker_uri_printf_escaped ("urn:artist:%s", composer);
+
+		tracker_sparql_builder_insert_open (preupdate, NULL);
+		tracker_sparql_builder_subject_iri (preupdate, composer_uri);
+		tracker_sparql_builder_predicate (preupdate, "a");
+		tracker_sparql_builder_object (preupdate, "nmm:Artist");
+		tracker_sparql_builder_predicate (preupdate, "nmm:artistName");
+		tracker_sparql_builder_object_unvalidated (preupdate, composer);
+		tracker_sparql_builder_insert_close (preupdate);
+	} else {
+		composer_uri = NULL;
+	}
+
+	if (lyricist) {
+		lyricist_uri = tracker_uri_printf_escaped ("urn:artist:%s", lyricist);
+
+		tracker_sparql_builder_insert_open (preupdate, NULL);
+		tracker_sparql_builder_subject_iri (preupdate, lyricist_uri);
+		tracker_sparql_builder_predicate (preupdate, "a");
+		tracker_sparql_builder_object (preupdate, "nmm:Artist");
+		tracker_sparql_builder_predicate (preupdate, "nmm:artistName");
+		tracker_sparql_builder_object_unvalidated (preupdate, lyricist);
+		tracker_sparql_builder_insert_close (preupdate);
+	} else {
+		lyricist_uri = NULL;
+	}
+
+	if (album) {
+		album_uri = tracker_uri_printf_escaped ("urn:album:%s", album);
+
+		tracker_sparql_builder_insert_open (preupdate, NULL);
+		tracker_sparql_builder_subject_iri (preupdate, album_uri);
+		tracker_sparql_builder_predicate (preupdate, "a");
+		tracker_sparql_builder_object (preupdate, "nmm:MusicAlbum");
+		tracker_sparql_builder_predicate (preupdate, "nmm:albumTitle");
+		tracker_sparql_builder_object_unvalidated (preupdate, album);
+		tracker_sparql_builder_insert_close (preupdate);
+
+		if (track_count > 0) {
+			tracker_sparql_builder_delete_open (preupdate, NULL);
+			tracker_sparql_builder_subject_iri (preupdate, album_uri);
+			tracker_sparql_builder_predicate (preupdate, "nmm:albumTrackCount");
+			tracker_sparql_builder_object_variable (preupdate, "unknown");
+			tracker_sparql_builder_delete_close (preupdate);
+
+			tracker_sparql_builder_where_open (preupdate);
+			tracker_sparql_builder_subject_iri (preupdate, album_uri);
+			tracker_sparql_builder_predicate (preupdate, "nmm:albumTrackCount");
+			tracker_sparql_builder_object_variable (preupdate, "unknown");
+			tracker_sparql_builder_where_close (preupdate);
+
+			tracker_sparql_builder_insert_open (preupdate, NULL);
+			tracker_sparql_builder_subject_iri (preupdate, album_uri);
+			tracker_sparql_builder_predicate (preupdate, "nmm:albumTrackCount");
+			tracker_sparql_builder_object_int64 (preupdate, track_count);
+			tracker_sparql_builder_insert_close (preupdate);
+		}
+	} else {
+		album_uri = NULL;
+	}
+
+	/* TODO: Do any metadata updates
+	 *
+	 * (This is where you can use entities created in the
+	 *  pre-updates part, like an artist).
+	 */
+	tracker_sparql_builder_predicate (metadata, "a");
+	tracker_sparql_builder_object (metadata, "nmm:MusicPiece");
+	tracker_sparql_builder_object (metadata, "nfo:Audio");
+
+	if (title) {
+		tracker_sparql_builder_predicate (metadata, "nie:title");
+		tracker_sparql_builder_object_unvalidated (metadata, title);
+		g_free (title);
+	}
+
+	if (lyricist_uri) {
+		tracker_sparql_builder_predicate (metadata, "nmm:lyricist");
+		tracker_sparql_builder_object_iri (metadata, lyricist_uri);
+		g_free (lyricist_uri);
+	}
+
+	if (performer_uri) {
+		tracker_sparql_builder_predicate (metadata, "nmm:performer");
+		tracker_sparql_builder_object_iri (metadata, performer_uri);
+		g_free (performer_uri);
+	}
+
+	if (composer_uri) {
+		tracker_sparql_builder_predicate (metadata, "nmm:composer");
+		tracker_sparql_builder_object_iri (metadata, composer_uri);
+		g_free (composer_uri);
+	}
+
+	if (album_uri) {
+		tracker_sparql_builder_predicate (metadata, "nmm:musicAlbum");
+		tracker_sparql_builder_object_iri (metadata, album_uri);
+		g_free (album_uri);
+	}
+
+	if (recording_time) {
+		tracker_sparql_builder_predicate (metadata, "nie:contentCreated");
+		tracker_sparql_builder_object_unvalidated (metadata, recording_time);
+		g_free (recording_time);
+	}
+
+	if (genre) {
+		tracker_sparql_builder_predicate (metadata, "nfo:genre");
+		tracker_sparql_builder_object_unvalidated (metadata, genre);
+		g_free (genre);
+	}
+
+	if (copyright) {
+		tracker_sparql_builder_predicate (metadata, "nie:copyright");
+		tracker_sparql_builder_object_unvalidated (metadata, copyright);
+		g_free (copyright);
+	}
+
+	if (comment) {
+		tracker_sparql_builder_predicate (metadata, "nie:comment");
+		tracker_sparql_builder_object_unvalidated (metadata, comment);
+		g_free (comment);
+	}
+
+	if (publisher) {
+		tracker_sparql_builder_predicate (metadata, "nco:publisher");
+		tracker_sparql_builder_object_blank_open (metadata);
+		tracker_sparql_builder_predicate (metadata, "a");
+		tracker_sparql_builder_object (metadata, "nco:Contact");
+		tracker_sparql_builder_predicate (metadata, "nco:fullname");
+		tracker_sparql_builder_object_unvalidated (metadata, publisher);
+		tracker_sparql_builder_object_blank_close (metadata);
+		g_free (publisher);
+	}
+
+	if (track_number > 0) {
+		tracker_sparql_builder_predicate (metadata, "nmm:trackNumber");
+		tracker_sparql_builder_object_int64 (metadata, track_number);
+	}
+
+	if (duration > 0) {
+		tracker_sparql_builder_predicate (metadata, "nfo:duration");
+		tracker_sparql_builder_object_int64 (metadata, duration);
+	}
+
+	if (text) {
+		/* NOTE: This is for Full Text Search (FTS) indexing content */
+		tracker_sparql_builder_predicate (metadata, "nie:plainTextContent");
+		tracker_sparql_builder_object_unvalidated (metadata, text);
+		g_free (text);
+	}
+
+	/* TODO: Clean up */
+	g_free (album);
+	g_free (composer);
+	g_free (performer);
+	g_free (filename);
+}
+
+TrackerExtractData *
+tracker_extract_get_data (void)
+{
+	/* NOTE: This function has to exist, tracker-extract checks
+	 * the symbole table for this function and if it doesn't
+	 * exist, the module is not loaded to be used as an extractor.
+	 */
+	return data;
+}
diff --git a/src/libtracker-client/tracker.c b/src/libtracker-client/tracker.c
index c2ad45e..c522231 100644
--- a/src/libtracker-client/tracker.c
+++ b/src/libtracker-client/tracker.c
@@ -488,9 +488,9 @@ is_service_available (void)
 gchar *
 tracker_sparql_escape (const gchar *str)
 {
-	gchar       *escaped_string;
+	gchar  *escaped_string;
 	const gchar *p;
-	gchar       *q;
+	gchar *q;
 
 	g_return_val_if_fail (str != NULL, NULL);
 
@@ -498,6 +498,7 @@ tracker_sparql_escape (const gchar *str)
 
 	p = str;
 	q = escaped_string;
+
 	while (*p != '\0') {
 		switch (*p) {
 		case '\t':
@@ -539,6 +540,237 @@ tracker_sparql_escape (const gchar *str)
 	return escaped_string;
 }
 
+static const char *
+find_conversion (const char  *format,
+                 const char **after)
+{
+	const char *start = format;
+	const char *cp;
+
+	while (*start != '\0' && *start != '%')
+		start++;
+
+	if (*start == '\0') {
+		*after = start;
+		return NULL;
+	}
+
+	cp = start + 1;
+
+	if (*cp == '\0') {
+		*after = cp;
+		return NULL;
+	}
+
+	/* Test for positional argument.  */
+	if (*cp >= '0' && *cp <= '9') {
+		const char *np;
+
+		for (np = cp; *np >= '0' && *np <= '9'; np++)
+			;
+		if (*np == '$')
+			cp = np + 1;
+	}
+
+	/* Skip the flags.  */
+	for (;;) {
+		if (*cp == '\'' ||
+		    *cp == '-' ||
+		    *cp == '+' ||
+		    *cp == ' ' ||
+		    *cp == '#' ||
+		    *cp == '0')
+			cp++;
+		else
+			break;
+	}
+
+	/* Skip the field width.  */
+	if (*cp == '*') {
+		cp++;
+
+		/* Test for positional argument.  */
+		if (*cp >= '0' && *cp <= '9') {
+			const char *np;
+
+			for (np = cp; *np >= '0' && *np <= '9'; np++)
+				;
+			if (*np == '$')
+				cp = np + 1;
+		}
+	} else {
+		for (; *cp >= '0' && *cp <= '9'; cp++)
+			;
+	}
+
+	/* Skip the precision.  */
+	if (*cp == '.') {
+		cp++;
+		if (*cp == '*') {
+			/* Test for positional argument.  */
+			if (*cp >= '0' && *cp <= '9') {
+				const char *np;
+
+				for (np = cp; *np >= '0' && *np <= '9'; np++)
+					;
+				if (*np == '$')
+					cp = np + 1;
+			}
+		} else {
+			for (; *cp >= '0' && *cp <= '9'; cp++)
+				;
+		}
+	}
+
+	/* Skip argument type/size specifiers.  */
+	while (*cp == 'h' ||
+	       *cp == 'L' ||
+	       *cp == 'l' ||
+	       *cp == 'j' ||
+	       *cp == 'z' ||
+	       *cp == 'Z' ||
+	       *cp == 't')
+		cp++;
+
+	/* Skip the conversion character.  */
+	cp++;
+
+	*after = cp;
+	return start;
+}
+
+/**
+ * tracker_uri_vprintf_escaped:
+ * @format: a standard printf() format string, but notice
+ *     <link linkend="string-precision">string precision pitfalls</link>
+ * @args: the list of parameters to insert into the format string
+ * 
+ * Similar to the standard C vsprintf() function but safer, since it 
+ * calculates the maximum space required and allocates memory to hold 
+ * the result. 
+ *
+ * The result is escaped using g_uri_escape_string().
+ *
+ * Returns: a newly-allocated string holding the result which should
+ * be freed with g_free() when finished with.
+ *
+ * Since: 0.8
+ */
+gchar *
+tracker_uri_vprintf_escaped (const gchar *format,
+                             va_list      args)
+{
+	GString *format1;
+	GString *format2;
+	GString *result = NULL;
+	gchar *output1 = NULL;
+	gchar *output2 = NULL;
+	const char *p;
+	gchar *op1, *op2;
+	va_list args2;
+
+	format1 = g_string_new (NULL);
+	format2 = g_string_new (NULL);
+	p = format;
+	while (TRUE) {
+		const char *after;
+		const char *conv = find_conversion (p, &after);
+		if (!conv)
+			break;
+
+		g_string_append_len (format1, conv, after - conv);
+		g_string_append_c (format1, 'X');
+		g_string_append_len (format2, conv, after - conv);
+		g_string_append_c (format2, 'Y');
+
+		p = after;
+	}
+
+	/* Use them to format the arguments
+	 */
+	G_VA_COPY (args2, args);
+
+	output1 = g_strdup_vprintf (format1->str, args);
+	va_end (args);
+	if (!output1)
+		goto cleanup;
+
+	output2 = g_strdup_vprintf (format2->str, args2);
+	va_end (args2);
+	if (!output2)
+		goto cleanup;
+
+	result = g_string_new (NULL);
+
+	op1 = output1;
+	op2 = output2;
+	p = format;
+	while (TRUE) {
+		const char *after;
+		const char *output_start;
+		const char *conv = find_conversion (p, &after);
+		char *escaped;
+
+		if (!conv) {
+			g_string_append_len (result, p, after - p);
+			break;
+		}
+
+		g_string_append_len (result, p, conv - p);
+		output_start = op1;
+		while (*op1 == *op2) {
+			op1++;
+			op2++;
+		}
+
+		*op1 = '\0';
+		escaped = g_uri_escape_string (output_start, NULL, FALSE);
+		g_string_append (result, escaped);
+		g_free (escaped);
+
+		p = after;
+		op1++;
+		op2++;
+	}
+
+ cleanup:
+	g_string_free (format1, TRUE);
+	g_string_free (format2, TRUE);
+	g_free (output1);
+	g_free (output2);
+
+	if (result)
+		return g_string_free (result, FALSE);
+	else
+		return NULL;
+}
+
+/**
+ * tracker_uri_printf_escaped:
+ * @format: a standard printf() format string, but notice
+ *     <link linkend="string-precision">string precision pitfalls</link>
+ * @Varargs: the parameters to insert into the format string
+ *
+ * Calls tracker_uri_vprintf_escaped() with the @Varargs supplied.
+ 
+ * Returns: a newly-allocated string holding the result which should
+ * be freed with g_free() when finished with.
+ *
+ * Since: 0.8
+ **/
+gchar *
+tracker_uri_printf_escaped (const gchar *format, ...)
+{
+	gchar *result;
+	va_list args;
+
+	va_start (args, format);
+	result = tracker_uri_vprintf_escaped (format, args);
+	va_end (args);
+
+	return result;
+}
+
 /**
  * tracker_client_new:
  * @flags: This can be one or more combinations of #TrackerClientFlags
diff --git a/src/libtracker-client/tracker.h b/src/libtracker-client/tracker.h
index 4a44815..06b7c90 100644
--- a/src/libtracker-client/tracker.h
+++ b/src/libtracker-client/tracker.h
@@ -89,8 +89,13 @@ gboolean       tracker_cancel_call                         (TrackerClient
                                                             guint                   call_id);
 gboolean       tracker_cancel_last_call                    (TrackerClient          *client);
 
+/* Utilities */
 gchar *        tracker_sparql_escape                       (const gchar            *str);
 
+gchar *        tracker_uri_vprintf_escaped                 (const gchar            *format,
+                                                            va_list                 args);
+gchar *        tracker_uri_printf_escaped                  (const gchar            *format, 
+                                                            ...);
 
 /* Synchronous API */
 GPtrArray *    tracker_statistics_get                      (TrackerClient          *client,
diff --git a/src/libtracker-common/tracker-common.h b/src/libtracker-common/tracker-common.h
index 06252f8..a1fe4dd 100644
--- a/src/libtracker-common/tracker-common.h
+++ b/src/libtracker-common/tracker-common.h
@@ -30,26 +30,20 @@ G_BEGIN_DECLS
 
 #define __LIBTRACKER_COMMON_INSIDE__
 
-/* Not installed headers */
-#if 0
-#include "tracker-dbus.h"
-#include "tracker-ioprio.h"
-#include "tracker-log.h"
-#include "tracker-os-dependant.h"
-#include "tracker-power.h"
-#include "tracker-storage.h"
-#endif
-
-/* Installed headers */
 #include "tracker-class.h"
 #include "tracker-config-file.h"
 #include "tracker-date-time.h"
+#include "tracker-dbus.h"
 #include "tracker-file-utils.h"
+#include "tracker-ioprio.h"
 #include "tracker-keyfile-object.h"
 #include "tracker-language.h"
+#include "tracker-log.h"
 #include "tracker-namespace.h"
 #include "tracker-ontology.h"
 #include "tracker-ontologies.h"
+#include "tracker-os-dependant.h"
+#include "tracker-power.h"
 #include "tracker-property.h"
 #include "tracker-type-utils.h"
 #include "tracker-utils.h"
diff --git a/src/libtracker-common/tracker-utils.c b/src/libtracker-common/tracker-utils.c
index 365c342..15f5e15 100644
--- a/src/libtracker-common/tracker-utils.c
+++ b/src/libtracker-common/tracker-utils.c
@@ -218,203 +218,5 @@ tracker_seconds_to_string (gdouble  seconds_elapsed,
 	return str;
 }
 
-static const char *
-find_conversion (const char  *format,
-                 const char **after)
-{
-	const char *start = format;
-	const char *cp;
-
-	while (*start != '\0' && *start != '%')
-		start++;
-
-	if (*start == '\0') {
-		*after = start;
-		return NULL;
-	}
-
-	cp = start + 1;
-
-	if (*cp == '\0') {
-		*after = cp;
-		return NULL;
-	}
-
-	/* Test for positional argument.  */
-	if (*cp >= '0' && *cp <= '9') {
-		const char *np;
-
-		for (np = cp; *np >= '0' && *np <= '9'; np++)
-			;
-		if (*np == '$')
-			cp = np + 1;
-	}
-
-	/* Skip the flags.  */
-	for (;;) {
-		if (*cp == '\'' ||
-		    *cp == '-' ||
-		    *cp == '+' ||
-		    *cp == ' ' ||
-		    *cp == '#' ||
-		    *cp == '0')
-			cp++;
-		else
-			break;
-	}
-
-	/* Skip the field width.  */
-	if (*cp == '*') {
-		cp++;
-
-		/* Test for positional argument.  */
-		if (*cp >= '0' && *cp <= '9') {
-			const char *np;
-
-			for (np = cp; *np >= '0' && *np <= '9'; np++)
-				;
-			if (*np == '$')
-				cp = np + 1;
-		}
-	} else {
-		for (; *cp >= '0' && *cp <= '9'; cp++)
-			;
-	}
-
-	/* Skip the precision.  */
-	if (*cp == '.') {
-		cp++;
-		if (*cp == '*') {
-			/* Test for positional argument.  */
-			if (*cp >= '0' && *cp <= '9') {
-				const char *np;
-
-				for (np = cp; *np >= '0' && *np <= '9'; np++)
-					;
-				if (*np == '$')
-					cp = np + 1;
-			}
-		} else {
-			for (; *cp >= '0' && *cp <= '9'; cp++)
-				;
-		}
-	}
-
-	/* Skip argument type/size specifiers.  */
-	while (*cp == 'h' ||
-	       *cp == 'L' ||
-	       *cp == 'l' ||
-	       *cp == 'j' ||
-	       *cp == 'z' ||
-	       *cp == 'Z' ||
-	       *cp == 't')
-		cp++;
-
-	/* Skip the conversion character.  */
-	cp++;
-
-	*after = cp;
-	return start;
-}
-
-gchar *
-tracker_uri_vprintf_escaped (const gchar *format,
-                             va_list      args)
-{
-	GString *format1;
-	GString *format2;
-	GString *result = NULL;
-	gchar *output1 = NULL;
-	gchar *output2 = NULL;
-	const char *p;
-	char       *op1, *op2;
-	va_list args2;
-
-	format1 = g_string_new (NULL);
-	format2 = g_string_new (NULL);
-	p = format;
-	while (TRUE) {
-		const char *after;
-		const char *conv = find_conversion (p, &after);
-		if (!conv)
-			break;
-
-		g_string_append_len (format1, conv, after - conv);
-		g_string_append_c (format1, 'X');
-		g_string_append_len (format2, conv, after - conv);
-		g_string_append_c (format2, 'Y');
-
-		p = after;
-	}
-
-	/* Use them to format the arguments
-	 */
-	G_VA_COPY (args2, args);
-
-	output1 = g_strdup_vprintf (format1->str, args);
-	va_end (args);
-	if (!output1)
-		goto cleanup;
-
-	output2 = g_strdup_vprintf (format2->str, args2);
-	va_end (args2);
-	if (!output2)
-		goto cleanup;
-
-	result = g_string_new (NULL);
-
-	op1 = output1;
-	op2 = output2;
-	p = format;
-	while (TRUE) {
-		const char *after;
-		const char *output_start;
-		const char *conv = find_conversion (p, &after);
-		char *escaped;
-
-		if (!conv) {
-			g_string_append_len (result, p, after - p);
-			break;
-		}
-
-		g_string_append_len (result, p, conv - p);
-		output_start = op1;
-		while (*op1 == *op2) {
-			op1++;
-			op2++;
-		}
-
-		*op1 = '\0';
-		escaped = g_uri_escape_string (output_start, NULL, FALSE);
-		g_string_append (result, escaped);
-		g_free (escaped);
-
-		p = after;
-		op1++;
-		op2++;
-	}
-
- cleanup:
-	g_string_free (format1, TRUE);
-	g_string_free (format2, TRUE);
-	g_free (output1);
-	g_free (output2);
 
-	if (result)
-		return g_string_free (result, FALSE);
-	else
-		return NULL;
-}
 
-gchar *
-tracker_uri_printf_escaped (const gchar *format, ...)
-{
-	char *result;
-	va_list args;
-
-	va_start (args, format);
-	result = tracker_uri_vprintf_escaped (format, args);
-	va_end (args);
-
-	return result;
-}
diff --git a/src/libtracker-common/tracker-utils.h b/src/libtracker-common/tracker-utils.h
index 60f4261..bc052c2 100644
--- a/src/libtracker-common/tracker-utils.h
+++ b/src/libtracker-common/tracker-utils.h
@@ -42,10 +42,6 @@ gchar *  tracker_seconds_estimate_to_string (gdouble      seconds_elapsed,
                                              guint        items_remaining);
 gchar *  tracker_seconds_to_string          (gdouble      seconds_elapsed,
                                              gboolean     short_string);
-gchar*   tracker_uri_vprintf_escaped        (const gchar *format,
-                                             va_list      args);
-gchar*   tracker_uri_printf_escaped         (const gchar *format,
-                                             ...);
 
 G_END_DECLS
 
diff --git a/src/plugins/kmail/tracker-kmail-registrar.c b/src/plugins/kmail/tracker-kmail-registrar.c
index 8291ea7..4d94fc9 100644
--- a/src/plugins/kmail/tracker-kmail-registrar.c
+++ b/src/plugins/kmail/tracker-kmail-registrar.c
@@ -27,11 +27,12 @@
 #include <glib-object.h>
 #include <dbus/dbus-glib-bindings.h>
 
+#include <libtracker-common/tracker-common.h>
+
 #include <libtracker-data/tracker-data-manager.h>
 
 #include <libtracker-client/tracker-sparql-builder.h>
-
-#include <libtracker-common/tracker-dbus.h>
+#include <libtracker-client/tracker.h>
 
 #include <tracker-store/tracker-push-registrar.h>
 #include <tracker-store/tracker-store.h>
diff --git a/src/tracker-extract/Makefile.am b/src/tracker-extract/Makefile.am
index 1f6f5d9..1bcffd9 100644
--- a/src/tracker-extract/Makefile.am
+++ b/src/tracker-extract/Makefile.am
@@ -94,11 +94,6 @@ if HAVE_TOTEM_PL_PARSER
 modules_LTLIBRARIES += libextract-playlist.la
 endif
 
-# A mockup extractor for testing purposes
-if HAVE_MOCKUP
-modules_LTLIBRARIES += libextract-mockup.la
-endif
-
 # ABW
 libextract_abw_la_SOURCES = tracker-extract-abw.c
 libextract_abw_la_LDFLAGS = $(module_flags)
@@ -274,17 +269,6 @@ libextract_tiff_la_LIBADD = 						\
 	$(GLIB2_LIBS) 							\
 	$(GCOV_LIBS)
 
-# MOCKUP
-if HAVE_MOCKUP
-libextract_mockup_la_SOURCES = tracker-extract-mockup.c
-libextract_mockup_la_LDFLAGS = $(module_flags)
-libextract_mockup_la_LIBADD = 						\
-	$(top_builddir)/src/libtracker-extract/libtracker-extract- TRACKER_API_VERSION@.la \
-	$(top_builddir)/src/libtracker-common/libtracker-common.la	\
-	$(GLIB2_LIBS)  							\
-	$(GCOV_LIBS)
-endif
-
 # Playlists using totem-pl-parser
 libextract_playlist_la_SOURCES = tracker-extract-playlist.c
 libextract_playlist_la_LDFLAGS = $(module_flags)
diff --git a/src/tracker-extract/tracker-extract-gstreamer.c b/src/tracker-extract/tracker-extract-gstreamer.c
index 7490b95..f54e968 100644
--- a/src/tracker-extract/tracker-extract-gstreamer.c
+++ b/src/tracker-extract/tracker-extract-gstreamer.c
@@ -35,10 +35,9 @@ long long int llroundl(long double x);
 #include <gst/gst.h>
 #include <gst/tag/tag.h>
 
-#include <libtracker-common/tracker-type-utils.h>
-#include <libtracker-common/tracker-file-utils.h>
-#include <libtracker-common/tracker-ontologies.h>
-#include <libtracker-common/tracker-utils.h>
+#include <libtracker-common/tracker-common.h>
+
+#include <libtracker-client/tracker.h>
 
 #include <libtracker-extract/tracker-extract.h>
 #include <libtracker-extract/tracker-utils.h>
diff --git a/src/tracker-extract/tracker-extract-mp3.c b/src/tracker-extract/tracker-extract-mp3.c
index aaf9466..dd31256 100644
--- a/src/tracker-extract/tracker-extract-mp3.c
+++ b/src/tracker-extract/tracker-extract-mp3.c
@@ -43,10 +43,9 @@
 #include <enca.h>
 #endif
 
-#include <libtracker-common/tracker-date-time.h>
-#include <libtracker-common/tracker-file-utils.h>
-#include <libtracker-common/tracker-ontologies.h>
-#include <libtracker-common/tracker-utils.h>
+#include <libtracker-common/tracker-common.h>
+
+#include <libtracker-client/tracker.h>
 
 #include <libtracker-extract/tracker-extract.h>
 #include <libtracker-extract/tracker-utils.h>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]