tracker r2655 - in trunk: . src/libtracker-data src/tracker-indexer src/tracker-indexer/modules tests/tracker-indexer



Author: carlosg
Date: Thu Dec  4 15:47:03 2008
New Revision: 2655
URL: http://svn.gnome.org/viewvc/tracker?rev=2655&view=rev

Log:
2008-12-04  Carlos Garnacho  <carlos imendio com>

        * src/tracker-indexer/tracker-module-metadata.[ch]:
        * src/tracker-indexer/tracker-module-metadata-private.h: New files.
        TrackerModuleMetadata is the object used for exchanging information
        between the indexer and the modules, similar to TrackerDataMetadata,
        but more suited to the task, and in the correct library.

        * src/tracker-indexer/tracker-metadata-utils.[ch]: Moved to
        * src/tracker-indexer/tracker-module-metadata-utils.[ch]: Just for
        consistency.

        * src/tracker-indexer/Makefile.am: Compile the new files.

        * src/tracker-indexer/tracker-module-file.[ch]:
        * src/tracker-indexer/tracker-indexer.c: Updated to use
        TrackerModuleMetadata where it's relevant.

        * src/tracker-indexer/modules/*.c: Update to these changes.

        * src/libtracker-data/tracker-data-update.[ch]
        (tracker_data_update_create_service): Modify to receive a GHashTable
        instead of a TrackerDataMetadata. to avoid type conversions, circular
        dependencies, etc...

        * configure.ac:
        * tests/tracker-indexer/Makefile.am: Update to latest changes to get
        testcases compiling.

Added:
   trunk/src/tracker-indexer/tracker-module-metadata-private.h
   trunk/src/tracker-indexer/tracker-module-metadata-utils.c
      - copied, changed from r2654, /trunk/src/tracker-indexer/tracker-metadata-utils.c
   trunk/src/tracker-indexer/tracker-module-metadata-utils.h
      - copied, changed from r2654, /trunk/src/tracker-indexer/tracker-metadata-utils.h
   trunk/src/tracker-indexer/tracker-module-metadata.c
   trunk/src/tracker-indexer/tracker-module-metadata.h
Removed:
   trunk/src/tracker-indexer/tracker-metadata-utils.c
   trunk/src/tracker-indexer/tracker-metadata-utils.h
Modified:
   trunk/ChangeLog
   trunk/configure.ac
   trunk/src/libtracker-data/tracker-data-update.c
   trunk/src/libtracker-data/tracker-data-update.h
   trunk/src/tracker-indexer/Makefile.am
   trunk/src/tracker-indexer/modules/applications.c
   trunk/src/tracker-indexer/modules/dummy.c
   trunk/src/tracker-indexer/modules/evolution-common.c
   trunk/src/tracker-indexer/modules/evolution-common.h
   trunk/src/tracker-indexer/modules/evolution-imap.c
   trunk/src/tracker-indexer/modules/evolution-pop.c
   trunk/src/tracker-indexer/modules/files.c
   trunk/src/tracker-indexer/modules/gaim-conversations.c
   trunk/src/tracker-indexer/tracker-indexer.c
   trunk/src/tracker-indexer/tracker-module-file.c
   trunk/src/tracker-indexer/tracker-module-file.h
   trunk/tests/tracker-indexer/Makefile.am

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Thu Dec  4 15:47:03 2008
@@ -1104,8 +1104,8 @@
                 tests/tracker-indexer/tracker-indexer-module.c:src/tracker-indexer/tracker-indexer-module.c
                 tests/tracker-indexer/tracker-indexer-module.h:src/tracker-indexer/tracker-indexer-module.h
                 tests/tracker-indexer/tracker-marshal-main.c:src/tracker-indexer/tracker-marshal-main.c
-                tests/tracker-indexer/tracker-metadata-utils.c:src/tracker-indexer/tracker-metadata-utils.c
-                tests/tracker-indexer/tracker-metadata-utils.h:src/tracker-indexer/tracker-metadata-utils.h
+                tests/tracker-indexer/tracker-module-metadata-utils.c:src/tracker-indexer/tracker-module-metadata-utils.c
+                tests/tracker-indexer/tracker-module-metadata-utils.h:src/tracker-indexer/tracker-module-metadata-utils.h
                 tests/tracker-indexer/tracker-module-file.c:src/tracker-indexer/tracker-module-file.c
                 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

Modified: trunk/src/libtracker-data/tracker-data-update.c
==============================================================================
--- trunk/src/libtracker-data/tracker-data-update.c	(original)
+++ trunk/src/libtracker-data/tracker-data-update.c	Thu Dec  4 15:47:03 2008
@@ -144,11 +144,11 @@
 }
 
 gboolean
-tracker_data_update_create_service (TrackerService      *service,
-				    guint32	        service_id,
-				    const gchar	       *dirname,
-				    const gchar	       *basename,
-				    TrackerDataMetadata *metadata)
+tracker_data_update_create_service (TrackerService *service,
+				    guint32	    service_id,
+				    const gchar	   *dirname,
+				    const gchar	   *basename,
+				    GHashTable     *metadata)
 {
 	TrackerDBInterface *iface;
 	TrackerDBResultSet *result_set;
@@ -184,18 +184,17 @@
 	is_dir = g_file_test (path, G_FILE_TEST_IS_DIR);
 	is_symlink = g_file_test (path, G_FILE_TEST_IS_SYMLINK);
 
-	/* FIXME: do not hardcode arguments */
 	tracker_db_interface_execute_procedure (iface, NULL, "CreateService",
 						id_str,
 						dirname,
 						basename,
 						service_type_id_str,
-						is_dir ? "Folder" : tracker_data_metadata_lookup (metadata, "File:Mime"),
-						tracker_data_metadata_lookup (metadata, "File:Size"),
+						is_dir ? "Folder" : g_hash_table_lookup (metadata, "File:Mime"),
+						g_hash_table_lookup (metadata, "File:Size"),
 						is_dir ? "1" : "0",
 						is_symlink ? "1" : "0",
 						"0", /* Offset */
-						tracker_data_metadata_lookup (metadata, "File:Modified"),
+						g_hash_table_lookup (metadata, "File:Modified"),
 						volume_id_str, /* Aux ID */
 						NULL);
 

Modified: trunk/src/libtracker-data/tracker-data-update.h
==============================================================================
--- trunk/src/libtracker-data/tracker-data-update.h	(original)
+++ trunk/src/libtracker-data/tracker-data-update.h	Thu Dec  4 15:47:03 2008
@@ -43,7 +43,7 @@
 							 guint32              service_id,
 							 const gchar         *dirname,
 							 const gchar         *basename,
-							 TrackerDataMetadata *metadata);
+							 GHashTable          *metadata);
 void     tracker_data_update_delete_service             (TrackerService      *service,
 							 guint32              service_id);
 void     tracker_data_update_delete_service_recursively (TrackerService      *service,

Modified: trunk/src/tracker-indexer/Makefile.am
==============================================================================
--- trunk/src/tracker-indexer/Makefile.am	(original)
+++ trunk/src/tracker-indexer/Makefile.am	Thu Dec  4 15:47:03 2008
@@ -20,14 +20,16 @@
 libtracker_indexer_LTLIBRARIES = libtracker-indexer.la
 
 libtracker_indexer_la_SOURCES =	 					\
-	tracker-metadata-utils.c					\
 	tracker-module-file.c						\
-	tracker-module-iteratable.c
+	tracker-module-iteratable.c					\
+	tracker-module-metadata-utils.c					\
+	tracker-module-metadata.c
 
 libtracker_indexerinclude_HEADERS =					\
-	tracker-metadata-utils.h					\
 	tracker-module-file.h						\
-	tracker-module-iteratable.h
+	tracker-module-iteratable.h					\
+	tracker-module-metadata-utils.h					\
+	tracker-module-metadata.h
 
 libexec_PROGRAMS = tracker-indexer
 
@@ -39,7 +41,8 @@
 	tracker-indexer-module.c					\
 	tracker-indexer-module.h					\
 	tracker-main.c							\
-	tracker-marshal-main.c						
+	tracker-marshal-main.c						\
+	tracker-module-metadata-private.h
 
 tracker_indexer_LDADD =							\
 	libtracker-indexer.la						\

Modified: trunk/src/tracker-indexer/modules/applications.c
==============================================================================
--- trunk/src/tracker-indexer/modules/applications.c	(original)
+++ trunk/src/tracker-indexer/modules/applications.c	Thu Dec  4 15:47:03 2008
@@ -65,7 +65,7 @@
 };
 
 
-static TrackerDataMetadata * tracker_application_file_get_metadata  (TrackerModuleFile *file);
+static TrackerModuleMetadata * tracker_application_file_get_metadata  (TrackerModuleFile *file);
 
 
 G_DEFINE_DYNAMIC_TYPE (TrackerApplicationFile, tracker_application_file, TRACKER_TYPE_MODULE_FILE);
@@ -90,11 +90,11 @@
 }
 
 static void
-insert_data_from_desktop_file (TrackerDataMetadata *metadata,
-			       const gchar     *metadata_key,
-			       GKeyFile        *desktop_file,
-			       const gchar     *key,
-			       gboolean		use_locale)
+insert_data_from_desktop_file (TrackerModuleMetadata *metadata,
+			       const gchar           *metadata_key,
+			       GKeyFile              *desktop_file,
+			       const gchar           *key,
+			       gboolean		      use_locale)
 {
 	gchar *str;
 
@@ -105,17 +105,17 @@
 	}
 
 	if (str) {
-		tracker_data_metadata_insert (metadata, metadata_key, str);
+		tracker_module_metadata_add_string (metadata, metadata_key, str);
 		g_free (str);
 	}
 }
 
 static void
-insert_list_from_desktop_file (TrackerDataMetadata *metadata,
-			       const gchar     *metadata_key,
-			       GKeyFile        *desktop_file,
-			       const gchar     *key,
-			       gboolean		use_locale)
+insert_list_from_desktop_file (TrackerModuleMetadata *metadata,
+			       const gchar           *metadata_key,
+			       GKeyFile              *desktop_file,
+			       const gchar           *key,
+			       gboolean		      use_locale)
 {
 	gchar **arr;
 
@@ -126,26 +126,20 @@
 	}
 
 	if (arr) {
-		GList *list = NULL;
 		gint i;
 
 		for (i = 0; arr[i]; i++) {
-			list = g_list_prepend (list, arr[i]);
+			tracker_module_metadata_add_string (metadata, metadata_key, arr[i]);
 		}
 
-		list = g_list_reverse (list);
-		g_free (arr);
-
-		tracker_data_metadata_insert_values (metadata, metadata_key, list);
-		g_list_foreach (list, (GFunc) g_free, NULL);
-		g_list_free (list);
+		g_strfreev (arr);
 	}
 }
 
-static TrackerDataMetadata *
+static TrackerModuleMetadata *
 tracker_application_file_get_metadata (TrackerModuleFile *file)
 {
-	TrackerDataMetadata *metadata;
+	TrackerModuleMetadata *metadata;
 	GKeyFile *key_file;
         GFile *f;
 	gchar *path, *type, *filename;
@@ -186,7 +180,7 @@
 	}
 
 	/* Begin collecting data */
-	metadata = tracker_data_metadata_new ();
+	metadata = tracker_module_metadata_new ();
 
 	insert_data_from_desktop_file (metadata, METADATA_APP_NAME, key_file, KEY_NAME, FALSE);
 	insert_data_from_desktop_file (metadata, METADATA_APP_DISPLAY_NAME, key_file, KEY_NAME, TRUE);
@@ -199,7 +193,7 @@
 	insert_list_from_desktop_file (metadata, METADATA_APP_CATEGORIES, key_file, KEY_CATEGORIES, FALSE);
 
 	filename = g_filename_display_basename (path);
-	tracker_data_metadata_insert (metadata, METADATA_FILE_NAME, filename);
+	tracker_module_metadata_add_string (metadata, METADATA_FILE_NAME, filename);
 	g_free (filename);
 
 	g_key_file_free (key_file);

Modified: trunk/src/tracker-indexer/modules/dummy.c
==============================================================================
--- trunk/src/tracker-indexer/modules/dummy.c	(original)
+++ trunk/src/tracker-indexer/modules/dummy.c	Thu Dec  4 15:47:03 2008
@@ -60,7 +60,7 @@
 static const gchar * dummy_file_get_service_type (TrackerModuleFile *file);
 static gchar *       dummy_file_get_uri          (TrackerModuleFile *file);
 static gchar *       dummy_file_get_text         (TrackerModuleFile *file);
-static TrackerDataMetadata *
+static TrackerModuleMetadata *
                      dummy_file_get_metadata     (TrackerModuleFile *file);
 
 static gboolean      dummy_file_iter_contents    (TrackerModuleIteratable *iteratable);
@@ -156,10 +156,10 @@
 	return NULL;
 }
 
-static TrackerDataMetadata *
+static TrackerModuleMetadata *
 dummy_file_get_metadata (TrackerModuleFile *file)
 {
-	/* Return a TrackerDataMetadata filled with metadata for file,
+	/* Return a TrackerModuleMetadata filled with metadata for file,
          * given the current state. Also see TrackerModuleIteratable.
 	 */
 	return NULL;

Modified: trunk/src/tracker-indexer/modules/evolution-common.c
==============================================================================
--- trunk/src/tracker-indexer/modules/evolution-common.c	(original)
+++ trunk/src/tracker-indexer/modules/evolution-common.c	Thu Dec  4 15:47:03 2008
@@ -25,8 +25,9 @@
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <gio/gio.h>
 
-#include <tracker-indexer/tracker-metadata-utils.h>
+#include <tracker-indexer/tracker-module-metadata-utils.h>
 
 #include "evolution-common.h"
 
@@ -53,10 +54,10 @@
 	return stream;
 }
 
-TrackerDataMetadata *
+TrackerModuleMetadata *
 evolution_common_get_wrapper_metadata (GMimeDataWrapper *wrapper)
 {
-	TrackerDataMetadata *metadata;
+	TrackerModuleMetadata *metadata;
 	GMimeStream *stream;
 	gchar *path;
 	gint fd;
@@ -73,7 +74,7 @@
                 file = g_file_new_for_path (path);
 		g_mime_stream_flush (stream);
 
-		metadata = tracker_metadata_utils_get_data (file);
+		metadata = tracker_module_metadata_utils_get_data (file);
 
                 g_object_unref (file);
 		g_unlink (path);

Modified: trunk/src/tracker-indexer/modules/evolution-common.h
==============================================================================
--- trunk/src/tracker-indexer/modules/evolution-common.h	(original)
+++ trunk/src/tracker-indexer/modules/evolution-common.h	Thu Dec  4 15:47:03 2008
@@ -51,11 +51,11 @@
 	EVOLUTION_MESSAGE_SECURE       = 1 << 8
 };
 
-GMimeStream *         evolution_common_get_stream           (const gchar      *path,
-                                                             gint              flags,
-                                                             off_t             start);
-TrackerDataMetadata * evolution_common_get_wrapper_metadata (GMimeDataWrapper *wrapper);
-gchar *               evolution_common_get_object_encoding  (GMimeObject      *object);
+GMimeStream *           evolution_common_get_stream           (const gchar      *path,
+							       gint              flags,
+							       off_t             start);
+TrackerModuleMetadata * evolution_common_get_wrapper_metadata (GMimeDataWrapper *wrapper);
+gchar *                 evolution_common_get_object_encoding  (GMimeObject      *object);
 
 G_END_DECLS
 

Modified: trunk/src/tracker-indexer/modules/evolution-imap.c
==============================================================================
--- trunk/src/tracker-indexer/modules/evolution-imap.c	(original)
+++ trunk/src/tracker-indexer/modules/evolution-imap.c	Thu Dec  4 15:47:03 2008
@@ -73,7 +73,7 @@
 static const gchar * tracker_evolution_imap_file_get_service_type (TrackerModuleFile *file);
 static gchar *       tracker_evolution_imap_file_get_uri          (TrackerModuleFile *file);
 static gchar *       tracker_evolution_imap_file_get_text         (TrackerModuleFile *file);
-static TrackerDataMetadata *
+static TrackerModuleMetadata *
                      tracker_evolution_imap_file_get_metadata     (TrackerModuleFile *file);
 
 static void          tracker_evolution_imap_file_iteratable_init  (TrackerModuleIteratableIface *iface);
@@ -870,16 +870,16 @@
 	return g_list_reverse (list);
 }
 
-static TrackerDataMetadata *
+static TrackerModuleMetadata *
 get_message_metadata (TrackerModuleFile *file)
 {
         TrackerEvolutionImapFile *self;
-	TrackerDataMetadata *metadata = NULL;
+	TrackerModuleMetadata *metadata = NULL;
 	gchar *subject, *from, *to, *cc;
 	gchar *date;
 	gint32 i, count, flags;
 	time_t t;
-	GList *list;
+	GList *list, *l;
 	gboolean deleted;
 
         self = TRACKER_EVOLUTION_IMAP_FILE (file);
@@ -916,28 +916,29 @@
 	}
 
 	if (!deleted) {
-		gchar *date;
+		metadata = tracker_module_metadata_new ();
 
-		metadata = tracker_data_metadata_new ();
+		tracker_module_metadata_add_date (metadata, METADATA_EMAIL_DATE, t);
+		tracker_module_metadata_add_string (metadata, METADATA_EMAIL_SENDER, from);
+		tracker_module_metadata_add_string (metadata, METADATA_EMAIL_SUBJECT, subject);
 
-		date = tracker_guint_to_string (t);
-
-		tracker_data_metadata_insert (metadata, METADATA_EMAIL_DATE, date);
-		tracker_data_metadata_insert (metadata, METADATA_EMAIL_SENDER, from);
-		tracker_data_metadata_insert (metadata, METADATA_EMAIL_SUBJECT, subject);
+		list = get_recipient_list (to);
 
-		g_free (date);
+		for (l = list; l; l = l->next) {
+			tracker_module_metadata_add_string (metadata, METADATA_EMAIL_SENT_TO, l->data);
+			g_free (l->data);
+		}
 
-		list = get_recipient_list (to);
-		tracker_data_metadata_insert_values (metadata, METADATA_EMAIL_SENT_TO, list);
-		g_list_foreach (list, (GFunc) g_free, NULL);
 		g_list_free (list);
 
 		list = get_recipient_list (cc);
-		tracker_data_metadata_insert_values (metadata, METADATA_EMAIL_CC, list);
-		g_list_foreach (list, (GFunc) g_free, NULL);
-		g_list_free (list);
 
+		for (l = list; l; l = l->next) {
+			tracker_module_metadata_add_string (metadata, METADATA_EMAIL_CC, l->data);
+			g_free (l->data);
+		}
+
+		g_list_free (list);
 	}
 
 	g_free (subject);
@@ -1008,17 +1009,17 @@
 corruption:
 	/* assume corruption */
 	if (metadata) {
-		tracker_data_metadata_free (metadata);
+		g_object_unref (metadata);
 	}
 
 	return NULL;
 }
 
-static TrackerDataMetadata *
+static TrackerModuleMetadata *
 get_attachment_metadata (TrackerModuleFile *file,
                          const gchar       *mime_file)
 {
-	TrackerDataMetadata *metadata;
+	TrackerModuleMetadata *metadata;
 	GMimeStream *stream;
 	GMimeDataWrapper *wrapper;
 	GMimePartEncodingType encoding;
@@ -1054,7 +1055,7 @@
 	return metadata;
 }
 
-static TrackerDataMetadata *
+static TrackerModuleMetadata *
 tracker_evolution_imap_file_get_metadata (TrackerModuleFile *file)
 {
         TrackerEvolutionImapFile *self;

Modified: trunk/src/tracker-indexer/modules/evolution-pop.c
==============================================================================
--- trunk/src/tracker-indexer/modules/evolution-pop.c	(original)
+++ trunk/src/tracker-indexer/modules/evolution-pop.c	Thu Dec  4 15:47:03 2008
@@ -46,7 +46,7 @@
 static const gchar * tracker_evolution_pop_file_get_service_type (TrackerModuleFile *file);
 static gchar *       tracker_evolution_pop_file_get_uri          (TrackerModuleFile *file);
 static gchar *       tracker_evolution_pop_file_get_text         (TrackerModuleFile *file);
-static TrackerDataMetadata *
+static TrackerModuleMetadata *
                      tracker_evolution_pop_file_get_metadata     (TrackerModuleFile *file);
 
 static void          tracker_evolution_pop_file_iteratable_init  (TrackerModuleIteratableIface *iface);
@@ -328,43 +328,44 @@
 	return g_list_reverse (list);
 }
 
-static TrackerDataMetadata *
+static TrackerModuleMetadata *
 get_message_metadata (GMimeMessage *message)
 {
-	TrackerDataMetadata *metadata;
+	TrackerModuleMetadata *metadata;
 	time_t t;
-	GList *list;
-	gchar *date;
+	GList *list, *l;
 
-	metadata = tracker_data_metadata_new ();
+	metadata = tracker_module_metadata_new ();
 
 	g_mime_message_get_date (message, &t, NULL);
 
-	date = tracker_guint_to_string (t);
+	tracker_module_metadata_add_date (metadata, METADATA_EMAIL_DATE, t);
+	tracker_module_metadata_add_string (metadata, METADATA_EMAIL_SENDER, g_mime_message_get_sender (message));
+	tracker_module_metadata_add_string (metadata, METADATA_EMAIL_SUBJECT, g_mime_message_get_subject (message));
 
-	tracker_data_metadata_insert (metadata, METADATA_EMAIL_DATE, date);
-	tracker_data_metadata_insert (metadata, METADATA_EMAIL_SENDER, g_mime_message_get_sender (message));
-	tracker_data_metadata_insert (metadata, METADATA_EMAIL_SUBJECT, g_mime_message_get_subject (message));
+	list = get_message_recipients (message, GMIME_RECIPIENT_TYPE_TO);
 
-	g_free (date);
+	for (l = list; l; l = l->next) {
+		tracker_module_metadata_add_string (metadata, METADATA_EMAIL_SENT_TO, l->data);
+		g_free (l->data);
+	}
 
-	list = get_message_recipients (message, GMIME_RECIPIENT_TYPE_TO);
-	tracker_data_metadata_insert_values (metadata, METADATA_EMAIL_SENT_TO, list);
-	g_list_foreach (list, (GFunc) g_free, NULL);
 	g_list_free (list);
 
 	list = get_message_recipients (message, GMIME_RECIPIENT_TYPE_CC);
-	tracker_data_metadata_insert_values (metadata, METADATA_EMAIL_CC, list);
-	g_list_foreach (list, (GFunc) g_free, NULL);
-	g_list_free (list);
 
-	return metadata;
+	for (l = list; l; l = l->next) {
+		tracker_module_metadata_add_string (metadata, METADATA_EMAIL_CC, l->data);
+		g_free (l->data);
+	}
+
+	g_list_free (list);
 }
 
-static TrackerDataMetadata *
+static TrackerModuleMetadata *
 get_attachment_metadata (GMimePart *part)
 {
-	TrackerDataMetadata *metadata;
+	TrackerModuleMetadata *metadata;
 	GMimeDataWrapper *content;
 
 	content = g_mime_part_get_content_object (part);
@@ -379,11 +380,11 @@
 	return metadata;
 }
 
-static TrackerDataMetadata *
+static TrackerModuleMetadata *
 tracker_evolution_pop_file_get_metadata (TrackerModuleFile *file)
 {
         TrackerEvolutionPopFile *self;
-        TrackerDataMetadata *metadata;
+        TrackerModuleMetadata *metadata;
         guint flags;
 
         self = TRACKER_EVOLUTION_POP_FILE (file);

Modified: trunk/src/tracker-indexer/modules/files.c
==============================================================================
--- trunk/src/tracker-indexer/modules/files.c	(original)
+++ trunk/src/tracker-indexer/modules/files.c	Thu Dec  4 15:47:03 2008
@@ -32,7 +32,7 @@
 #include <libtracker-common/tracker-file-utils.h>
 #include <libtracker-common/tracker-ontology.h>
 
-#include <tracker-indexer/tracker-metadata-utils.h>
+#include <tracker-indexer/tracker-module-metadata-utils.h>
 #include <tracker-indexer/tracker-module-file.h>
 
 /* This is ONLY needed for the indexer to run standalone with
@@ -57,9 +57,9 @@
 };
 
 
-static const gchar *         tracker_regular_file_get_service_type (TrackerModuleFile *file);
-static gchar *               tracker_regular_file_get_text         (TrackerModuleFile *file);
-static TrackerDataMetadata * tracker_regular_file_get_metadata     (TrackerModuleFile *file);
+static const gchar *           tracker_regular_file_get_service_type (TrackerModuleFile *file);
+static gchar *                 tracker_regular_file_get_text         (TrackerModuleFile *file);
+static TrackerModuleMetadata * tracker_regular_file_get_metadata     (TrackerModuleFile *file);
 
 
 G_DEFINE_DYNAMIC_TYPE (TrackerRegularFile, tracker_regular_file, TRACKER_TYPE_MODULE_FILE);
@@ -174,7 +174,7 @@
 
 #endif /* ENABLE_FILE_EXCLUDE_CHECKING */
 
-static TrackerDataMetadata *
+static TrackerModuleMetadata *
 tracker_regular_file_get_metadata (TrackerModuleFile *file)
 {
 #ifdef ENABLE_FILE_EXCLUDE_CHECKING
@@ -183,7 +183,7 @@
 	}
 #endif
 
-	return tracker_metadata_utils_get_data (tracker_module_file_get_file (file));
+	return tracker_module_metadata_utils_get_data (tracker_module_file_get_file (file));
 }
 
 static gchar *
@@ -195,7 +195,7 @@
 	}
 #endif
 
-	return tracker_metadata_utils_get_text (tracker_module_file_get_file (file));
+	return tracker_module_metadata_utils_get_text (tracker_module_file_get_file (file));
 }
 
 

Modified: trunk/src/tracker-indexer/modules/gaim-conversations.c
==============================================================================
--- trunk/src/tracker-indexer/modules/gaim-conversations.c	(original)
+++ trunk/src/tracker-indexer/modules/gaim-conversations.c	Thu Dec  4 15:47:03 2008
@@ -61,7 +61,7 @@
 static const gchar * gaim_file_get_service_type (TrackerModuleFile *file);
 static gchar *       gaim_file_get_uri          (TrackerModuleFile *file);
 static gchar *       gaim_file_get_text         (TrackerModuleFile *file);
-static TrackerDataMetadata *
+static TrackerModuleMetadata *
                      gaim_file_get_metadata     (TrackerModuleFile *file);
 
 static gboolean      gaim_file_iter_contents    (TrackerModuleIteratable *iteratable);
@@ -157,10 +157,10 @@
 	return NULL;
 }
 
-static TrackerDataMetadata *
+static TrackerModuleMetadata *
 gaim_file_get_metadata (TrackerModuleFile *file)
 {
-	/* Return a TrackerDataMetadata filled with metadata for file,
+	/* Return a TrackerModuleMetadata filled with metadata for file,
          * given the current state. Also see TrackerModuleIteratable.
 	 */
 	return NULL;

Modified: trunk/src/tracker-indexer/tracker-indexer.c
==============================================================================
--- trunk/src/tracker-indexer/tracker-indexer.c	(original)
+++ trunk/src/tracker-indexer/tracker-indexer.c	Thu Dec  4 15:47:03 2008
@@ -75,6 +75,7 @@
 #include "tracker-indexer.h"
 #include "tracker-indexer-module.h"
 #include "tracker-marshal.h"
+#include "tracker-module-metadata-private.h"
 
 #define TRACKER_INDEXER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRACKER_TYPE_INDEXER, TrackerIndexerPrivate))
 
@@ -1043,10 +1044,10 @@
 }
 
 static void
-index_metadata (TrackerIndexer	*indexer,
-		guint32		 id,
-		TrackerService	*service,
-		TrackerDataMetadata *metadata)
+index_metadata (TrackerIndexer	      *indexer,
+		guint32		       id,
+		TrackerService	      *service,
+		TrackerModuleMetadata *metadata)
 {
 	MetadataForeachData data;
 
@@ -1056,15 +1057,15 @@
 	data.id = id;
 	data.add = TRUE;
 
-	tracker_data_metadata_foreach (metadata, index_metadata_foreach, &data);
+	tracker_module_metadata_foreach (metadata, index_metadata_foreach, &data);
 
 	schedule_flush (indexer, FALSE);
 }
 
 static void
-unindex_metadata (TrackerIndexer  *indexer,
-		  guint32	   id,
-		  TrackerService  *service,
+unindex_metadata (TrackerIndexer      *indexer,
+		  guint32	       id,
+		  TrackerService      *service,
 		  TrackerDataMetadata *metadata)
 {
 	MetadataForeachData data;
@@ -1348,17 +1349,18 @@
 
 static gboolean
 remove_existing_non_emb_metadata (TrackerField *field,
-				  gpointer value,
-				  gpointer user_data)
+				  gpointer      value,
+				  gpointer      user_data)
 {
-	TrackerDataMetadata *old_metadata = (TrackerDataMetadata *)user_data;
+	TrackerDataMetadata *old_metadata = (TrackerDataMetadata *) user_data;
 	const gchar *name;
-	
+
 	if (tracker_field_get_embedded (field)) {
 		return FALSE;
 	}
 
 	name = tracker_field_get_name (field);
+
 	if (tracker_field_get_multiple_values (field)) {
 		return (tracker_data_metadata_lookup_values (old_metadata, name) != NULL);
 	} else {
@@ -1367,11 +1369,11 @@
 }
 
 static void
-item_add_or_update (TrackerIndexer  *indexer,
-		    PathInfo        *info,
-		    const gchar     *dirname,
-		    const gchar     *basename,
-		    TrackerDataMetadata *metadata)
+item_add_or_update (TrackerIndexer        *indexer,
+		    PathInfo              *info,
+		    const gchar           *dirname,
+		    const gchar           *basename,
+		    TrackerModuleMetadata *metadata)
 {
 	TrackerService *service;
 	gchar *text;
@@ -1406,10 +1408,10 @@
 		old_metadata_non_emb = tracker_data_query_metadata (service, id, FALSE);
 
 		unindex_metadata (indexer, id, service, old_metadata_emb);
-		
-		tracker_data_metadata_foreach_remove (metadata, 
-						      remove_existing_non_emb_metadata,
-						      old_metadata_non_emb);
+
+		tracker_module_metadata_foreach_remove (metadata,
+							remove_existing_non_emb_metadata,
+							old_metadata_non_emb);
 
 		index_metadata (indexer, id, service, metadata);
 
@@ -1420,45 +1422,44 @@
 		new_text = tracker_module_file_get_text (info->module_file);
 
 		item_update_content (indexer, service, id, old_text, new_text);
+
 		g_free (old_text);
 		g_free (new_text);
-		tracker_data_metadata_free (old_metadata_emb);
-		tracker_data_metadata_free (old_metadata_non_emb);
-
-		return;
-	}
-
-	g_debug ("Adding item '%s/%s'", 
-		 dirname, 
-		 basename);
-
-	/* Service wasn't previously indexed */
-	id = tracker_data_update_get_new_service_id (indexer->private->common);
+		g_object_unref (old_metadata_emb);
+		g_object_unref (old_metadata_non_emb);
+	} else {
+		g_debug ("Adding item '%s/%s'",
+			 dirname,
+			 basename);
 
-	tracker_data_update_create_service (service,
-				   id,
-				   dirname,
-				   basename,
-				   metadata);
+		/* Service wasn't previously indexed */
+		id = tracker_data_update_get_new_service_id (indexer->private->common);
 
-	tracker_data_update_create_event (indexer->private->cache, id, "Create");
-	tracker_data_update_increment_stats (indexer->private->common, service);
+		tracker_data_update_create_service (service,
+						    id,
+						    dirname,
+						    basename,
+						    tracker_module_metadata_get_hash_table (metadata));
 
-	index_metadata (indexer, id, service, metadata);
+		tracker_data_update_create_event (indexer->private->cache, id, "Create");
+		tracker_data_update_increment_stats (indexer->private->common, service);
 
-	text = tracker_module_file_get_text (info->module_file);
+		index_metadata (indexer, id, service, metadata);
 
-	if (text) {
-		/* Save in the index */
-		index_text_with_parsing (indexer,
-					 id,
-					 tracker_service_get_id (service),
-					 text,
-					 1);
+		text = tracker_module_file_get_text (info->module_file);
 
-		/* Save in the DB */
-		tracker_data_update_set_content (service, id, text);
-		g_free (text);
+		if (text) {
+			/* Save in the index */
+			index_text_with_parsing (indexer,
+						 id,
+						 tracker_service_get_id (service),
+						 text,
+						 1);
+
+			/* Save in the DB */
+			tracker_data_update_set_content (service, id, text);
+			g_free (text);
+		}
 	}
 }
 
@@ -1480,7 +1481,8 @@
 	   const gchar	   *basename)
 {
 	TrackerService *service;
-	TrackerDataMetadata *old_metadata, *new_metadata;
+	TrackerDataMetadata *old_metadata;
+	TrackerModuleMetadata *new_metadata;
 	gchar *service_type;
 	gchar *new_path, *new_name, *ext;
 	GFile *file, *other_file;
@@ -1497,7 +1499,6 @@
 	path = g_file_get_path (info->file);
 	other_path = g_file_get_path (info->other_file);
 
-
 	g_debug ("Moving item from '%s' to '%s'", path, other_path);
 
 	/* TODO URI branch: these are URI conversions */
@@ -1539,13 +1540,13 @@
 
 	unindex_metadata (indexer, id, service, old_metadata);
 
-	new_metadata = tracker_data_metadata_new ();
+	new_metadata = tracker_module_metadata_new ();
 
 	tracker_file_get_path_and_name (other_path, &new_path, &new_name);
 
-	tracker_data_metadata_insert (new_metadata, METADATA_FILE_PATH, new_path);
-	tracker_data_metadata_insert (new_metadata, METADATA_FILE_NAME, new_name);
-	tracker_data_metadata_insert (new_metadata, METADATA_FILE_NAME_DELIMITED, other_path);
+	tracker_module_metadata_add_string (new_metadata, METADATA_FILE_PATH, new_path);
+	tracker_module_metadata_add_string (new_metadata, METADATA_FILE_NAME, new_name);
+	tracker_module_metadata_add_string (new_metadata, METADATA_FILE_NAME_DELIMITED, other_path);
 
 	g_free (new_path);
 	g_free (new_name);
@@ -1553,14 +1554,13 @@
 	ext = strrchr (other_path, '.');
 	if (ext) {
 		ext++;
-		tracker_data_metadata_insert (new_metadata, METADATA_FILE_EXT, ext);
+		tracker_module_metadata_add_string (new_metadata, METADATA_FILE_EXT, ext);
 	}
 
 	index_metadata (indexer, id, service, new_metadata);
 
-	/* tracker_data_metadata_free frees the values */
-	tracker_data_metadata_free (old_metadata);
-	tracker_data_metadata_free (new_metadata);
+	g_object_unref (old_metadata);
+	g_object_unref (new_metadata);
 
 	g_free (path);
 	g_free (other_path);
@@ -2137,7 +2137,7 @@
 process_file (TrackerIndexer *indexer,
 	      PathInfo	     *info)
 {
-	TrackerDataMetadata *metadata;
+	TrackerModuleMetadata *metadata;
 	gchar *uri, *dirname, *basename;
 
 	/* Note: If info->other_file is set, the PathInfo is for a
@@ -2216,7 +2216,7 @@
 
 		if (metadata) {
 			item_add_or_update (indexer, info, dirname, basename, metadata);
-			tracker_data_metadata_free (metadata);
+			g_object_unref (metadata);
 		} else {
 			item_remove (indexer, info, dirname, basename);
 		}

Modified: trunk/src/tracker-indexer/tracker-module-file.c
==============================================================================
--- trunk/src/tracker-indexer/tracker-module-file.c	(original)
+++ trunk/src/tracker-indexer/tracker-module-file.c	Thu Dec  4 15:47:03 2008
@@ -18,6 +18,7 @@
  */
 
 #include <libtracker-common/tracker-file-utils.h>
+#include "tracker-module-metadata-private.h"
 #include "tracker-module-file.h"
 
 #define METADATA_FILE_PATH	     "File:Path"
@@ -197,26 +198,26 @@
         return TRACKER_MODULE_FILE_GET_CLASS (file)->get_text (file);
 }
 
-TrackerDataMetadata *
+TrackerModuleMetadata *
 tracker_module_file_get_metadata (TrackerModuleFile *file)
 {
-        TrackerDataMetadata *metadata = NULL;
+        TrackerModuleMetadata *metadata = NULL;
 
         if (TRACKER_MODULE_FILE_GET_CLASS (file)->get_metadata != NULL) {
                 metadata = TRACKER_MODULE_FILE_GET_CLASS (file)->get_metadata (file);
         }
 
         if (metadata &&
-            !tracker_data_metadata_lookup (metadata, METADATA_FILE_PATH) &&
-            !tracker_data_metadata_lookup (metadata, METADATA_FILE_NAME)) {
+            !tracker_module_metadata_lookup (metadata, METADATA_FILE_PATH, NULL) &&
+            !tracker_module_metadata_lookup (metadata, METADATA_FILE_NAME, NULL)) {
                 gchar *uri, *dirname, *basename;
 
                 uri = tracker_module_file_get_uri (file);
                 tracker_file_get_path_and_name (uri, &dirname, &basename);
 
-                tracker_data_metadata_insert (metadata, METADATA_FILE_PATH, dirname);
-                tracker_data_metadata_insert (metadata, METADATA_FILE_NAME, basename);
-                
+                tracker_module_metadata_add_string (metadata, METADATA_FILE_PATH, dirname);
+                tracker_module_metadata_add_string (metadata, METADATA_FILE_NAME, basename);
+
                 g_free (dirname);
                 g_free (basename);
                 g_free (uri);

Modified: trunk/src/tracker-indexer/tracker-module-file.h
==============================================================================
--- trunk/src/tracker-indexer/tracker-module-file.h	(original)
+++ trunk/src/tracker-indexer/tracker-module-file.h	Thu Dec  4 15:47:03 2008
@@ -22,7 +22,7 @@
 
 #include <glib-object.h>
 #include <gio/gio.h>
-#include <libtracker-data/tracker-data-metadata.h>
+#include "tracker-module-metadata.h"
 
 G_BEGIN_DECLS
 
@@ -48,17 +48,17 @@
         G_CONST_RETURN gchar * (* get_service_type) (TrackerModuleFile *file);
         gchar * (* get_uri) (TrackerModuleFile *file);
         gchar * (* get_text) (TrackerModuleFile *file);
-        TrackerDataMetadata * (* get_metadata) (TrackerModuleFile *file);
+        TrackerModuleMetadata * (* get_metadata) (TrackerModuleFile *file);
 };
 
 
 GType tracker_module_file_get_type (void) G_GNUC_CONST;
 
-GFile *                tracker_module_file_get_file         (TrackerModuleFile *file);
-G_CONST_RETURN gchar * tracker_module_file_get_service_type (TrackerModuleFile *file);
-gchar *                tracker_module_file_get_uri          (TrackerModuleFile *file);
-gchar *                tracker_module_file_get_text         (TrackerModuleFile *file);
-TrackerDataMetadata *  tracker_module_file_get_metadata     (TrackerModuleFile *file);
+GFile *                 tracker_module_file_get_file         (TrackerModuleFile *file);
+G_CONST_RETURN gchar *  tracker_module_file_get_service_type (TrackerModuleFile *file);
+gchar *                 tracker_module_file_get_uri          (TrackerModuleFile *file);
+gchar *                 tracker_module_file_get_text         (TrackerModuleFile *file);
+TrackerModuleMetadata * tracker_module_file_get_metadata     (TrackerModuleFile *file);
 
 
 G_END_DECLS

Added: trunk/src/tracker-indexer/tracker-module-metadata-private.h
==============================================================================
--- (empty file)
+++ trunk/src/tracker-indexer/tracker-module-metadata-private.h	Thu Dec  4 15:47:03 2008
@@ -0,0 +1,55 @@
+/* -*- 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_MODULE_METADATA_PRIVATE_H__
+#define __TRACKER_MODULE_METADATA_PRIVATE_H__
+
+#include <glib.h>
+#include <libtracker-common/tracker-ontology.h>
+#include "tracker-module-metadata.h"
+
+G_BEGIN_DECLS
+
+typedef void (* TrackerModuleMetadataForeach) (TrackerField *field,
+					       gpointer      value,
+					       gpointer      user_data);
+typedef gboolean (* TrackerModuleMetadataRemove) (TrackerField *field,
+						  gpointer      value,
+						  gpointer      user_data);
+
+gconstpointer          tracker_module_metadata_lookup         (TrackerModuleMetadata        *metadata,
+							       const gchar                  *field_name,
+							       gboolean                     *multiple_values);
+
+void		       tracker_module_metadata_foreach        (TrackerModuleMetadata        *metadata,
+							       TrackerModuleMetadataForeach  func,
+							       gpointer	                     user_data);
+
+void		       tracker_module_metadata_foreach_remove (TrackerModuleMetadata        *metadata,
+							       TrackerModuleMetadataRemove   func,
+							       gpointer	                     user_data);
+
+GHashTable *           tracker_module_metadata_get_hash_table (TrackerModuleMetadata        *metadata);
+
+
+G_END_DECLS
+
+#endif /* __TRACKER_MODULE_METADATA_PRIVATE_H__ */

Copied: trunk/src/tracker-indexer/tracker-module-metadata-utils.c (from r2654, /trunk/src/tracker-indexer/tracker-metadata-utils.c)
==============================================================================
--- /trunk/src/tracker-indexer/tracker-metadata-utils.c	(original)
+++ trunk/src/tracker-indexer/tracker-module-metadata-utils.c	Thu Dec  4 15:47:03 2008
@@ -31,7 +31,7 @@
 #include <libtracker-common/tracker-ontology.h>
 #include <libtracker-common/tracker-thumbnailer.h>
 
-#include "tracker-metadata-utils.h"
+#include "tracker-module-metadata-utils.h"
 
 #define METADATA_FILE_NAME_DELIMITED "File:NameDelimited"
 #define METADATA_FILE_EXT	     "File:Ext"
@@ -325,9 +325,9 @@
 }
 
 static void
-metadata_utils_get_embedded (const char          *path,
-			     const char          *mime_type,
-			     TrackerDataMetadata *metadata)
+metadata_utils_get_embedded (const char            *path,
+			     const char            *mime_type,
+			     TrackerModuleMetadata *metadata)
 {
 	gchar **values;
 	const gchar *service_type;
@@ -379,42 +379,38 @@
 		}
 		
 		if (tracker_field_get_multiple_values (field)) {
-			GStrv  values = NULL;
-			GList *list = NULL;
-			guint  i;
-
-			values = g_strsplit (value, "|",-1);
-
-			for (i = 0; values[i]; i++) {
-				if (!g_utf8_validate (values[i], -1, NULL)) {
-					utf_value = g_locale_to_utf8 (values[i], -1, NULL, NULL, NULL);
+			GStrv arr;
+			guint i;
+
+			arr = g_strsplit (value, "|",-1);
+
+			for (i = 0; arr[i]; i++) {
+				if (!g_utf8_validate (arr[i], -1, NULL)) {
+					utf_value = g_locale_to_utf8 (arr[i], -1, NULL, NULL, NULL);
 				} else {
-					utf_value = g_strdup (values[i]);
+					utf_value = g_strdup (arr[i]);
 				}
-				
+
 				if (!utf_value)
 					continue;
 
-				list = g_list_prepend (list, utf_value);
+				tracker_module_metadata_add_string (metadata, name, utf_value);
+				g_free (utf_value);
 			}
-			
-			g_strfreev (values);
 
-			tracker_data_metadata_insert_values (metadata, name, list);
-			g_list_foreach (list, (GFunc) g_free, NULL);
-			g_list_free (list);
+			g_strfreev (arr);
 		} else {
 			if (!g_utf8_validate (value, -1, NULL)) {
 				utf_value = g_locale_to_utf8 (value, -1, NULL, NULL, NULL);
 			} else {
 				utf_value = g_strdup (value);
 			}
-			
+
 			if (!utf_value) {
 				continue;
 			}
-			
-			tracker_data_metadata_insert (metadata, name, utf_value);
+
+			tracker_module_metadata_add_string (metadata, name, utf_value);
 			g_free (utf_value);
 		}
 	}
@@ -760,7 +756,7 @@
  * Returns: A newly allocated string containing the file text, or %NULL.
  **/
 gchar *
-tracker_metadata_utils_get_text (GFile *file)
+tracker_module_metadata_utils_get_text (GFile *file)
 {
 	const gchar *service_type;
 	gchar *path, *mime_type, *text;
@@ -789,20 +785,19 @@
  * tracker_metadata_utils_get_data:
  * @path: Path to a local file
  *
- * Returns a #TrackerDataMetadata filled with the most generic
- * metadata for files, such as file size, MIME type, mtime...
+ * Returns a #TrackerModuleMetadata filled in with all the
+ * metadata that could be extracted for the given file.
  *
- * Returns: A newly created #TrackerDataMetadata, or %NULL if the file is not found.
+ * Returns: A newly created #TrackerModuleMetadata, or %NULL if the file is not found.
  **/
-TrackerDataMetadata *
-tracker_metadata_utils_get_data (GFile *file)
+TrackerModuleMetadata *
+tracker_module_metadata_utils_get_data (GFile *file)
 {
-	TrackerDataMetadata *metadata;
+	TrackerModuleMetadata *metadata;
 	struct stat st;
 	const gchar *ext;
 	gchar *path, *mime_type;
 	gchar *dirname, *basename, *path_delimited;
-	gchar *size, *mtime, *atime;
 
 	path = g_file_get_path (file);
 
@@ -811,12 +806,12 @@
 		return NULL;
 	}
 
-	metadata = tracker_data_metadata_new ();
+	metadata = tracker_module_metadata_new ();
 	ext = strrchr (path, '.');
 
 	if (ext) {
 		ext++;
-		tracker_data_metadata_insert (metadata, METADATA_FILE_EXT, ext);
+		tracker_module_metadata_add_string (metadata, METADATA_FILE_EXT, ext);
 	}
 
 	mime_type = tracker_file_get_mime_type (path);
@@ -825,10 +820,10 @@
 	basename = g_filename_display_basename (path);
 	path_delimited = g_filename_to_utf8 (path, -1, NULL, NULL, NULL);
 
-	tracker_data_metadata_insert (metadata, METADATA_FILE_NAME, basename);
-	tracker_data_metadata_insert (metadata, METADATA_FILE_PATH, dirname);
-	tracker_data_metadata_insert (metadata, METADATA_FILE_NAME_DELIMITED, path_delimited);
-	tracker_data_metadata_insert (metadata, METADATA_FILE_MIMETYPE, mime_type);
+	tracker_module_metadata_add_string (metadata, METADATA_FILE_NAME, basename);
+	tracker_module_metadata_add_string (metadata, METADATA_FILE_PATH, dirname);
+	tracker_module_metadata_add_string (metadata, METADATA_FILE_NAME_DELIMITED, path_delimited);
+	tracker_module_metadata_add_string (metadata, METADATA_FILE_MIMETYPE, mime_type);
 
 	g_free (path_delimited);
 	g_free (basename);
@@ -849,24 +844,15 @@
 		link_path = g_file_read_link (path, NULL);
 		link_path_delimited = g_filename_to_utf8 (link_path, -1, NULL, NULL, NULL);
 
-		tracker_data_metadata_insert (metadata, METADATA_FILE_LINK, link_path_delimited);
+		tracker_module_metadata_add_string (metadata, METADATA_FILE_LINK, link_path_delimited);
 
 		g_free (link_path_delimited);
 		g_free (link_path);
 	}
 
-	/* FIXME: These should be dealt directly as integer/times/whatever, not strings */
-	size = tracker_guint_to_string (st.st_size);
-	mtime = tracker_date_to_string (st.st_mtime);
-	atime = tracker_date_to_string (st.st_atime);
-
-	tracker_data_metadata_insert (metadata, METADATA_FILE_SIZE, size);
-	tracker_data_metadata_insert (metadata, METADATA_FILE_MODIFIED, mtime);
-	tracker_data_metadata_insert (metadata, METADATA_FILE_ACCESSED, atime);
-
-	g_free (atime);
-	g_free (mtime);
-	g_free (size);
+	tracker_module_metadata_add_uint (metadata, METADATA_FILE_SIZE, st.st_size);
+	tracker_module_metadata_add_date (metadata, METADATA_FILE_MODIFIED, st.st_mtime);
+	tracker_module_metadata_add_date (metadata, METADATA_FILE_ACCESSED, st.st_atime);
 
 	metadata_utils_get_embedded (path, mime_type, metadata);
 

Copied: trunk/src/tracker-indexer/tracker-module-metadata-utils.h (from r2654, /trunk/src/tracker-indexer/tracker-metadata-utils.h)
==============================================================================
--- /trunk/src/tracker-indexer/tracker-metadata-utils.h	(original)
+++ trunk/src/tracker-indexer/tracker-module-metadata-utils.h	Thu Dec  4 15:47:03 2008
@@ -27,8 +27,8 @@
 
 G_BEGIN_DECLS
 
-TrackerDataMetadata *tracker_metadata_utils_get_data (GFile *file);
-gchar *		     tracker_metadata_utils_get_text (GFile *file);
+TrackerModuleMetadata *tracker_module_metadata_utils_get_data (GFile *file);
+gchar *		       tracker_module_metadata_utils_get_text (GFile *file);
 
 G_END_DECLS
 

Added: trunk/src/tracker-indexer/tracker-module-metadata.c
==============================================================================
--- (empty file)
+++ trunk/src/tracker-indexer/tracker-module-metadata.c	Thu Dec  4 15:47:03 2008
@@ -0,0 +1,384 @@
+/* -*- 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 <glib.h>
+#include <libtracker-common/tracker-type-utils.h>
+#include "tracker-module-metadata-private.h"
+
+struct TrackerModuleMetadata {
+	GObject parent_instance;
+	GHashTable *table;
+};
+
+struct TrackerModuleMetadataClass {
+	GObjectClass parent_class;
+};
+
+
+static void   tracker_module_metadata_finalize   (GObject *object);
+
+
+G_DEFINE_TYPE (TrackerModuleMetadata, tracker_module_metadata, G_TYPE_OBJECT)
+
+static void
+tracker_module_metadata_class_init (TrackerModuleMetadataClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+	object_class->finalize = tracker_module_metadata_finalize;
+}
+
+static void
+tracker_module_metadata_init (TrackerModuleMetadata *metadata)
+{
+	metadata->table = g_hash_table_new_full (g_direct_hash,
+						 g_direct_equal,
+						 (GDestroyNotify) g_object_unref,
+						 NULL);
+}
+
+static gboolean
+free_metadata (TrackerField *field,
+	       gpointer      data)
+{
+	if (tracker_field_get_multiple_values (field)) {
+		GList *list;
+
+		list = (GList *) data;
+		g_list_foreach (list, (GFunc) g_free, NULL);
+		g_list_free (list);
+	} else {
+		g_free (data);
+	}
+}
+
+static gboolean
+remove_metadata_foreach (gpointer key,
+			 gpointer value,
+			 gpointer user_data)
+{
+	TrackerField *field;
+
+	field = (TrackerField *) key;
+	free_metadata (field, value);
+
+	return TRUE;
+}
+
+static void
+tracker_module_metadata_finalize (GObject *object)
+{
+	TrackerModuleMetadata *metadata;
+
+	metadata = TRACKER_MODULE_METADATA (object);
+
+	g_hash_table_foreach_remove (metadata->table,
+				     remove_metadata_foreach,
+				     NULL);
+
+	g_hash_table_destroy (metadata->table);
+
+	G_OBJECT_CLASS (tracker_module_metadata_parent_class)->finalize (object);
+}
+
+gconstpointer
+tracker_module_metadata_lookup (TrackerModuleMetadata *metadata,
+				const gchar           *field_name,
+				gboolean              *multiple_values)
+{
+	TrackerField *field;
+
+	field = tracker_ontology_get_field_by_name (field_name);
+
+	if (multiple_values) {
+		*multiple_values = tracker_field_get_multiple_values (field);
+	}
+
+	return g_hash_table_lookup (metadata->table, field);
+}
+
+/**
+ * tracker_module_metadata_clear_field:
+ * @metadata: A #TrackerModuleMetadata
+ * @field_name: Field name for the metadata to clear
+ *
+ * Clears any content for the given field name.
+ **/
+void
+tracker_module_metadata_clear_field (TrackerModuleMetadata *metadata,
+				     const gchar           *field_name)
+{
+	TrackerField *field;
+
+	gpointer data;
+
+	field = tracker_ontology_get_field_by_name (field_name);
+
+	if (!field) {
+		g_warning ("Field name '%s' isn't described in the ontology", field_name);
+		return;
+	}
+
+	data = g_hash_table_lookup (metadata->table, field);
+
+	if (data) {
+		free_metadata (field, data);
+		g_hash_table_remove (metadata->table, field);
+	}
+}
+
+/**
+ * tracker_module_metadata_add_take_string:
+ * @metadata: A #TrackerModuleMetadata
+ * @field_name: Field name for the metadata to insert
+ * @value: Value for the metadata
+ *
+ * Adds a new metadata element as a string into @metadata.
+ * For ontology fields that can take several values, this
+ * function will allow adding several elements to the same
+ * field name.
+ *
+ * If the function returns #TRUE, @metadata will take
+ * ownership on @value, else you are responsible of
+ * freeing it.
+ *
+ * Returns: #TRUE if the value was added successfully.
+ **/
+gboolean
+tracker_module_metadata_add_take_string (TrackerModuleMetadata *metadata,
+					 const gchar           *field_name,
+					 gchar                 *value)
+{
+	TrackerField *field;
+	gpointer data;
+
+	g_return_val_if_fail (metadata != NULL, FALSE);
+	g_return_val_if_fail (field_name != NULL, FALSE);
+	g_return_val_if_fail (value != NULL, FALSE);
+
+	field = tracker_ontology_get_field_by_name (field_name);
+
+	if (!field) {
+		g_warning ("Field name '%s' isn't described in the ontology", field_name);
+		return FALSE;
+	}
+
+	if (tracker_field_get_multiple_values (field)) {
+		GList *list;
+
+		list = g_hash_table_lookup (metadata->table, field);
+		list = g_list_prepend (list, value);
+		data = list;
+	} else {
+		/* FIXME: warn if data already exists */
+		data = value;
+	}
+
+	g_hash_table_insert (metadata->table,
+			     g_object_ref (field),
+			     data);
+	return TRUE;
+}
+
+/**
+ * tracker_module_metadata_add_string:
+ * @metadata: A #TrackerModuleMetadata
+ * @field_name: Field name for the metadata to insert
+ * @value: Value for the metadata
+ *
+ * Adds a new metadata element as a string into @metadata.
+ * see tracker_module_metadata_add_take_string().
+ **/
+void
+tracker_module_metadata_add_string (TrackerModuleMetadata *metadata,
+				    const gchar           *field_name,
+				    const gchar           *value)
+{
+	gchar *str;
+
+	str = g_strdup (value);
+
+	if (!tracker_module_metadata_add_take_string (metadata, field_name, str)) {
+		g_free (str);
+	}
+}
+
+/**
+ * tracker_module_metadata_add_int:
+ * @metadata: A #TrackerModuleMetadata
+ * @field_name: Field name for the metadata to insert
+ * @value: Value for the metadata
+ *
+ * Adds a new metadata element as a integer into @metadata.
+ * see tracker_module_metadata_add_take_string().
+ **/
+void
+tracker_module_metadata_add_int (TrackerModuleMetadata *metadata,
+				 const gchar           *field_name,
+				 gint                   value)
+{
+	gchar *str;
+
+	str = tracker_gint_to_string (value);
+
+	if (!tracker_module_metadata_add_take_string (metadata, field_name, str)) {
+		g_free (str);
+	}
+}
+
+/**
+ * tracker_module_metadata_add_uint:
+ * @metadata: A #TrackerModuleMetadata
+ * @field_name: Field name for the metadata to insert
+ * @value: Value for the metadata
+ *
+ * Adds a new metadata element as an unsigned integer into @metadata.
+ * see tracker_module_metadata_add_take_string().
+ **/
+void
+tracker_module_metadata_add_uint (TrackerModuleMetadata *metadata,
+				  const gchar           *field_name,
+				  guint                  value)
+{
+	gchar *str;
+
+	str = tracker_guint_to_string (value);
+
+	if (!tracker_module_metadata_add_take_string (metadata, field_name, str)) {
+		g_free (str);
+	}
+}
+
+/**
+ * tracker_module_metadata_add_double:
+ * @metadata: A #TrackerModuleMetadata
+ * @field_name: Field name for the metadata to insert
+ * @value: Value for the metadata
+ *
+ * Adds a new metadata element as a double into @metadata.
+ * see tracker_module_metadata_add_take_string().
+ **/
+void
+tracker_module_metadata_add_double (TrackerModuleMetadata *metadata,
+				    const gchar           *field_name,
+				    gdouble                value)
+{
+	gchar *str;
+
+	str = g_strdup_printf ("%f", value);
+
+	if (!tracker_module_metadata_add_take_string (metadata, field_name, str)) {
+		g_free (str);
+	}
+}
+
+/**
+ * tracker_module_metadata_add_float:
+ * @metadata: A #TrackerModuleMetadata
+ * @field_name: Field name for the metadata to insert
+ * @value: Value for the metadata
+ *
+ * Adds a new metadata element as a float into @metadata.
+ * see tracker_module_metadata_add_take_string().
+ **/
+void
+tracker_module_metadata_add_float (TrackerModuleMetadata *metadata,
+				   const gchar           *field_name,
+				   gfloat                 value)
+{
+	gchar *str;
+
+	str = g_strdup_printf ("%f", value);
+
+	if (!tracker_module_metadata_add_take_string (metadata, field_name, str)) {
+		g_free (str);
+	}
+}
+
+/**
+ * tracker_module_metadata_add_date:
+ * @metadata: A #TrackerModuleMetadata
+ * @field_name: Field name for the metadata to insert
+ * @value: Value for the metadata
+ *
+ * Adds a new metadata element as a time_t into @metadata.
+ * see tracker_module_metadata_add_take_string().
+ **/
+void
+tracker_module_metadata_add_date (TrackerModuleMetadata *metadata,
+				  const gchar           *field_name,
+				  time_t                 value)
+{
+	gchar *str;
+
+	str = tracker_date_to_string (value);
+
+	if (!tracker_module_metadata_add_take_string (metadata, field_name, str)) {
+		g_free (str);
+	}
+}
+
+/**
+ * tracker_module_metadata_foreach:
+ * @metadata: A #TrackerModuleMetadata.
+ * @func: The function to call with each metadata.
+ * @user_data: user data to pass to the function.
+ *
+ * Calls a function for each element in @metadata.
+ **/
+void
+tracker_module_metadata_foreach (TrackerModuleMetadata        *metadata,
+				 TrackerModuleMetadataForeach  func,
+				 gpointer		       user_data)
+{
+	g_hash_table_foreach (metadata->table,
+			      (GHFunc) func,
+			      user_data);
+}
+
+void
+tracker_module_metadata_foreach_remove (TrackerModuleMetadata       *metadata,
+					TrackerModuleMetadataRemove  func,
+					gpointer                     user_data)
+{
+	g_hash_table_foreach_remove (metadata->table,
+				     (GHRFunc) func,
+				     user_data);
+}
+
+GHashTable *
+tracker_module_metadata_get_hash_table (TrackerModuleMetadata *metadata)
+{
+	return metadata->table;
+}
+
+/**
+ * tracker_module_metadata_new:
+ *
+ * Creates a new #TrackerModuleMetadata
+ *
+ * Returns: A newly created #TrackerModuleMetadata
+ **/
+TrackerModuleMetadata *
+tracker_module_metadata_new (void)
+{
+	return g_object_new (TRACKER_TYPE_MODULE_METADATA, NULL);
+}

Added: trunk/src/tracker-indexer/tracker-module-metadata.h
==============================================================================
--- (empty file)
+++ trunk/src/tracker-indexer/tracker-module-metadata.h	Thu Dec  4 15:47:03 2008
@@ -0,0 +1,72 @@
+/* -*- 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_MODULE_METADATA_H__
+#define __TRACKER_MODULE_METADATA_H__
+
+#include <glib.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define TRACKER_TYPE_MODULE_METADATA	     (tracker_module_metadata_get_type())
+#define TRACKER_MODULE_METADATA(o)	     (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_MODULE_METADATA, TrackerModuleMetadata))
+#define TRACKER_MODULE_METADATA_CLASS(c)     (G_TYPE_CHECK_CLASS_CAST ((c),    TRACKER_TYPE_MODULE_METADATA, TrackerModuleMetadataClass))
+#define TRACKER_IS_MODULE_METADATA(o)	     (G_TYPE_CHECK_INSTANCE_TYPE ((o), TRACKER_TYPE_MODULE_METADATA))
+#define TRACKER_IS_MODULE_METADATA_CLASS(c)  (G_TYPE_CHECK_CLASS_TYPE ((c),    TRACKER_TYPE_MODULE_METADATA))
+#define TRACKER_MODULE_METADATA_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o),  TRACKER_TYPE_MODULE_METADATA, TrackerModuleMetadataClass))
+
+typedef struct TrackerModuleMetadata TrackerModuleMetadata;           /* dummy typedef */
+typedef struct TrackerModuleMetadataClass TrackerModuleMetadataClass; /* dummy typedef */
+
+
+GType                  tracker_module_metadata_get_type         (void) G_GNUC_CONST;
+
+TrackerModuleMetadata *tracker_module_metadata_new              (void);
+
+void                   tracker_module_metadata_clear_field      (TrackerModuleMetadata *metadata,
+								 const gchar           *field_name);
+
+gboolean               tracker_module_metadata_add_take_string  (TrackerModuleMetadata *metadata,
+								 const gchar           *field_name,
+								 gchar                 *value);
+void                   tracker_module_metadata_add_string       (TrackerModuleMetadata *metadata,
+								 const gchar           *field_name,
+								 const gchar           *value);
+void                   tracker_module_metadata_add_int          (TrackerModuleMetadata *metadata,
+								 const gchar           *field_name,
+								 gint                   value);
+void                   tracker_module_metadata_add_uint         (TrackerModuleMetadata *metadata,
+								 const gchar           *field_name,
+								 guint                  value);
+void                   tracker_module_metadata_add_double       (TrackerModuleMetadata *metadata,
+								 const gchar           *field_name,
+								 gdouble                value);
+void                   tracker_module_metadata_add_float        (TrackerModuleMetadata *metadata,
+								 const gchar           *field_name,
+								 gfloat                 value);
+void                   tracker_module_metadata_add_date         (TrackerModuleMetadata *metadata,
+								 const gchar           *field_name,
+								 time_t                 value);
+
+G_END_DECLS
+
+#endif /* __TRACKER_MODULE_METADATA_H__*/

Modified: trunk/tests/tracker-indexer/Makefile.am
==============================================================================
--- trunk/tests/tracker-indexer/Makefile.am	(original)
+++ trunk/tests/tracker-indexer/Makefile.am	Thu Dec  4 15:47:03 2008
@@ -28,8 +28,8 @@
 	tracker-indexer-module.c					\
 	tracker-indexer-module.h					\
 	tracker-marshal-main.c						\
-	tracker-metadata-utils.c 					\
-	tracker-metadata-utils.h 					\
+	tracker-module-metadata-utils.c 					\
+	tracker-module-metadata-utils.h 					\
 	tracker-metadata-utils-test.c 					\
 	tracker-module-file.c						\
 	tracker-module-file.h						\



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