[tracker/tracker-0.6] Disables evolution push module and improves the code



commit 1fa5f0e9f25f9e48b604a3c7a646305a078749f4
Author: Martyn Russell <martyn imendio com>
Date:   Mon Apr 27 11:50:41 2009 +0100

    Disables evolution push module and improves the code
    
    This patch also fixes the coding style in places and replaces some
    strchr() calls for the utf8 equivalent. Code was added to make the
    evolution plugin work. The "File:Modified" metadata was missing and
    that was the reason nothing was being added to the database.
    
    NOTE: We are not using this because doing so makes the indexer
    completely unresponsive. This is what is needed to actually make the
    evolution plugin feed our database.  However, there is no queueing, no
    pausing, no control at all, we simply handle everything as it comes.
    This is not good enough for tracker-0.6 because it causes a regression
    in the indexer. So this is disabled.
    
    NOTE: This code is supposed to be quite different in the tracker-0.7
    branch and as such it makes no sense fixing it.
---
 configure.ac                                      |    6 +-
 src/plugins/evolution/Makefile.am                 |    1 +
 src/plugins/evolution/tracker-evolution-indexer.c |  186 ++++++++++++---------
 src/plugins/kmail/Makefile.am                     |    1 +
 src/plugins/rss/Makefile.am                       |    1 +
 5 files changed, 110 insertions(+), 85 deletions(-)

diff --git a/configure.ac b/configure.ac
index 002af8c..3a05fc7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -615,14 +615,14 @@ AM_CONDITIONAL(HAVE_UNAC, test "x$have_unac" = "xyes")
 AC_ARG_ENABLE([evolution_push_module],
               AS_HELP_STRING([--enable-evolution-push-module],
                              [enable support for Evolution push mechanism (default=yes)]),,
-              [enable_evolution_push_module=yes])
+              [enable_evolution_push_module=no])
 
 AM_CONDITIONAL(USING_EVOLUTION_PUSH_MODULE, test "x$enable_evolution_push_module" = "xyes")
 
 AC_ARG_ENABLE([kmail_push_module],
               AS_HELP_STRING([--enable-kmail-push-module],
                              [enable support for KMail push mechanism (default=yes)]),,
-              [enable_kmail_push_module=yes])
+              [enable_kmail_push_module=no])
 
 AM_CONDITIONAL(USING_KMAIL_PUSH_MODULE, test "x$enable_kmail_push_module" = "xyes")
 
@@ -1455,6 +1455,8 @@ Plugins:
 
 	Evolution extracter (data-pull):	yes (old)
 	Evolution plugin    (data-push):	$have_evolution_plugin
+	KMail plugin        (data-push):	$enable_kmail_push_module
+	RSS plugin          (data-push):	$enable_rss_push_module
 
 Warning:
 
diff --git a/src/plugins/evolution/Makefile.am b/src/plugins/evolution/Makefile.am
index b5e6e67..598fedf 100644
--- a/src/plugins/evolution/Makefile.am
+++ b/src/plugins/evolution/Makefile.am
@@ -4,6 +4,7 @@ INCLUDES =								\
 	-I$(top_srcdir)/src						\
 	-DGETTEXT_PACKAGE="\"$(GETTEXT_PACKAGE)\""			\
 	-DLOCALEDIR="\"$(localedir)\""					\
+	-DG_LOG_DOMAIN=\"Tracker\"					\
 	-DTRACKER_COMPILATION						\
 	$(WARN_CFLAGS)							\
 	$(DBUS_CFLAGS)							\
diff --git a/src/plugins/evolution/tracker-evolution-indexer.c b/src/plugins/evolution/tracker-evolution-indexer.c
index 3afc472..ed731b8 100644
--- a/src/plugins/evolution/tracker-evolution-indexer.c
+++ b/src/plugins/evolution/tracker-evolution-indexer.c
@@ -126,16 +126,13 @@ tracker_evolution_indexer_init (TrackerEvolutionIndexer *object)
 {
 }
 
-
 #if 0
 static void
 extract_mime_parts (GMimeObject *object,
 		    gpointer     user_data)
 {
-	const gchar *message_subject = user_data;
-	gchar *subject = NULL;
-	const gchar *disposition, *filename;
 	GMimePart *part;
+	const gchar *disposition, *filename;
 
 	if (GMIME_IS_MESSAGE_PART (object)) {
 		GMimeMessage *message;
@@ -181,8 +178,7 @@ extract_mime_parts (GMimeObject *object,
 		 * Evolution can cope with as URI for an attachment (I don't 
 		 * think it can cope with any attachment URI, btw). */
 
-		subject = g_strdup_printf ("%s/%s", message_subject, 
-					   filename);
+		subject = g_strdup_printf ("%s/%s", user_data, filename);
 
 		metadata = tracker_module_metadata_new ();
 
@@ -226,7 +222,8 @@ get_object_encoding (GMimeObject *object)
 		return NULL;
 	}
 
-	start_encoding += strlen ("charset=");
+	/* Length of "charset=" */
+	start_encoding += 8;
 
 	if (start_encoding[0] == '"') {
 		/* encoding is quoted */
@@ -246,18 +243,20 @@ get_object_encoding (GMimeObject *object)
 
 static void
 perform_set (TrackerEvolutionIndexer *object, 
-	     const gchar *subject, 
-	     const GStrv predicates, 
-	     const GStrv values)
+	     const gchar             *subject, 
+	     const GStrv              predicates, 
+	     const GStrv              values)
 {
-	guint i = 0;
 	TrackerModuleMetadata *metadata;
 	GHashTable *data;
+#if 0
+	GTimeVal now;
+#endif
+	guint i;
 
 	metadata = tracker_module_metadata_new ();
 
-	while (predicates [i] != NULL && values[i] != NULL) {
-
+	for (i = 0; predicates[i] && values[i]; i++) {
 		/* TODO: TRACKER_EVOLUTION_PREDICATE_JUNK (!)
 		 *       TRACKER_EVOLUTION_PREDICATE_ANSWERED
 		 *       TRACKER_EVOLUTION_PREDICATE_FLAGGED
@@ -270,9 +269,7 @@ perform_set (TrackerEvolutionIndexer *object,
 		 * set. Perhaps when we merge this to that branch that we can 
 		 * improve this situation. */
 
-
 #if 0
-
 		/* Disabling this as I can't find any version of GMime-2.0 that
 		 * wont crash on any of my test E-mails. Going to ask Garnacho
 		 * to migrate to GMime-2.4 with his old Evolution support. */
@@ -282,36 +279,40 @@ perform_set (TrackerEvolutionIndexer *object,
 			GMimeParser *parser;
 			GMimeMessage *message;
 			gint fd;
-			gchar *text, *orig_text, *ptr, *encoding;
-			gchar *path = g_strdup (values[i]);
-			off_t offset = 0;
+			gchar *text, *orig_text, *p, *encoding;
+			gchar *path;
+			off_t offset;
 			gboolean is_html;
 
-			ptr = strstr (path, "/!");
-			if (ptr) {
-				offset = (off_t) atol (ptr+2);
-				*ptr = '\0';
+			path = g_strdup (values[i]);
+
+			p = strstr (path, "/!");
+			if (p) {
+				offset = (off_t) atol (p + 2);
+				*p = '\0';
+			} else {
+				offset = 0;
 			}
 
 			fd = tracker_file_open (path, FALSE);
-
 			g_free (path);
 
-			if (fd == -1) 
-				goto cont;
+			if (fd == -1) {
+				continue;
+			}
 
 			stream = g_mime_stream_fs_new_with_bounds (fd, offset, -1);
 
 			if (!stream) {
-				close (fd);
-				goto cont;
+				tracker_file_close (fd);
+				continue;
 			}
 
 			parser = g_mime_parser_new_with_stream (stream);
 
 			if (!parser) {
 				g_object_unref (stream);
-				goto cont;
+				continue;
 			}
 
 			g_mime_parser_set_scan_from (parser, FALSE);
@@ -321,7 +322,7 @@ perform_set (TrackerEvolutionIndexer *object,
 			if (!message) {
 				g_object_unref (parser);
 				g_object_unref (stream);
-				goto cont;
+				continue;
 			}
 
 			g_mime_message_foreach_part (message,
@@ -331,14 +332,14 @@ perform_set (TrackerEvolutionIndexer *object,
 			orig_text = g_mime_message_get_body (message, TRUE, &is_html);
 
 			if (orig_text) {
-
 				encoding = get_object_encoding (GMIME_OBJECT (message));
 
 				if (encoding) {
 					text = g_convert (text, -1, "utf8", encoding, NULL, NULL, NULL);
 					g_free (orig_text);
-				} else
+				} else {
 					text = orig_text;
+				}
 
 				tracker_module_metadata_add_string (metadata, 
 								    METADATA_EMAIL_TEXT, 
@@ -357,12 +358,12 @@ perform_set (TrackerEvolutionIndexer *object,
 		if (g_strcmp0 (predicates[i], TRACKER_EVOLUTION_PREDICATE_TAG) == 0) {
 			gchar *key, *value;
 
-			if (!values[i] || strlen (values[i]) < 1)
-				goto cont;
+			if (tracker_is_empty_string (values[i])) {
+				continue;
+			}
 
 			key = g_strdup (values[i]);
-
-			value = strchr (key, '=');
+			value = g_utf8_strchr (key, -1, '=');
 
 			if (value) {
 				*value = '\0';
@@ -409,52 +410,72 @@ perform_set (TrackerEvolutionIndexer *object,
 							    METADATA_EMAIL_CC, 
 							    values[i]);
 		}
-
-		cont:
-
-		i++;
 	}
 
-	data = tracker_module_metadata_get_hash_table (metadata);
-
-	tracker_data_update_replace_service (subject, "EvolutionEmails", data);
+#if 0
+	/* Add a hack so tracker_data_update_replace_service() doesn't
+	 * fail because File:Modified metadata doesn't exist.
+	 * 
+	 * NOTE: We are not using this because doing so makes the
+	 * indexer completely unresponsive. This is what is needed to
+	 * actually make the evolution plugin feed our database.
+	 * However, there is no queueing, no pausing, no control at
+	 * all, we simply handle everything as it comes. This is not
+	 * good enough for tracker-0.6 because it causes a regression
+	 * in the indexer. So this is disabled.
+	 *
+	 * NOTE: This code is supposed to be quite different in the
+	 * tracker-0.7 branch and as such it makes no sense fixing it.
+	 */
+	g_get_current_time (&now);
+	tracker_module_metadata_add_double (metadata, 
+					    "File:Modified", 
+					    now.tv_sec);
+
+	g_message ("Evolution Plugin is adding subject:'%s'", subject);
+#endif
 
-	g_hash_table_destroy (data);
+	data = tracker_module_metadata_get_hash_table (metadata);
+	tracker_data_update_replace_service (subject, "EvolutionEmails", data);				    
+					    
+	g_hash_table_unref (data);
 	g_object_unref (metadata);
 }
 
 static void 
 perform_unset (TrackerEvolutionIndexer *object, 
-	       const gchar *subject)
+	       const gchar             *subject)
 {
+	g_message ("Evolution Plugin is deleting subject:'%s'", subject);
 	tracker_data_update_delete_service_by_path (subject, "EvolutionEmails"); 
 }
 
 static void
 perform_cleanup (TrackerEvolutionIndexer *object)
 {
+	g_message ("Evolution Plugin is deleting all items");
 	tracker_data_update_delete_service_all ("EvolutionEmails");
 }
 
 static void
 set_stored_last_modseq (guint last_modseq)
 {
+	g_message ("Evolution Plugin is setting last modseq to:%d", last_modseq);
 	tracker_data_manager_set_db_option_int ("EvolutionLastModseq", (gint) last_modseq);
 }
 
 void
 tracker_evolution_indexer_set (TrackerEvolutionIndexer *object, 
-			       const gchar *subject, 
-			       const GStrv predicates,
-			       const GStrv values,
-			       const guint modseq,
-			       DBusGMethodInvocation *context,
-			       GError *derror)
+			       const gchar             *subject, 
+			       const GStrv              predicates,
+			       const GStrv              values,
+			       const guint              modseq,
+			       DBusGMethodInvocation   *context,
+			       GError                  *derror)
 {
 	dbus_async_return_if_fail (subject != NULL, context);
 
 	if (predicates && values) {
-
 		dbus_async_return_if_fail (g_strv_length (predicates) == 
 					   g_strv_length (values), context);
 
@@ -468,15 +489,15 @@ tracker_evolution_indexer_set (TrackerEvolutionIndexer *object,
 
 void
 tracker_evolution_indexer_set_many (TrackerEvolutionIndexer *object, 
-				    const GStrv subjects, 
-				    const GPtrArray *predicates,
-				    const GPtrArray *values,
-				    const guint modseq,
-				    DBusGMethodInvocation *context,
-				    GError *derror)
+				    const GStrv              subjects, 
+				    const GPtrArray         *predicates,
+				    const GPtrArray         *values,
+				    const guint              modseq,
+				    DBusGMethodInvocation   *context,
+				    GError                  *derror)
 {
 	guint len;
-	guint i = 0;
+	guint i;
 
 	dbus_async_return_if_fail (subjects != NULL, context);
 	dbus_async_return_if_fail (predicates != NULL, context);
@@ -487,13 +508,11 @@ tracker_evolution_indexer_set_many (TrackerEvolutionIndexer *object,
 	dbus_async_return_if_fail (len == predicates->len, context);
 	dbus_async_return_if_fail (len == values->len, context);
 
-	while (subjects[i] != NULL) {
-		GStrv preds = g_ptr_array_index (predicates, i);
-		GStrv vals = g_ptr_array_index (values, i);
-
-		perform_set (object, subjects[i], preds, vals);
-
-		i++;
+	for (i = 0; subjects[i]; i++) {
+		perform_set (object, 
+			     subjects[i], 
+			     g_ptr_array_index (predicates, i), 
+			     g_ptr_array_index (values, i));
 	}
 
 	set_stored_last_modseq (modseq);
@@ -503,20 +522,17 @@ tracker_evolution_indexer_set_many (TrackerEvolutionIndexer *object,
 
 void
 tracker_evolution_indexer_unset_many (TrackerEvolutionIndexer *object, 
-				      const GStrv subjects, 
-				      const guint modseq,
-				      DBusGMethodInvocation *context,
-				      GError *derror)
+				      const GStrv              subjects, 
+				      const guint              modseq,
+				      DBusGMethodInvocation   *context,
+				      GError                  *derror)
 {
-	guint i = 0;
+	guint i;
 
 	dbus_async_return_if_fail (subjects != NULL, context);
 
-	while (subjects[i] != NULL) {
-
+	for (i = 0; subjects[i]; i++) {
 		perform_unset (object, subjects[i]);
-
-		i++;
 	}
 
 	set_stored_last_modseq (modseq);
@@ -526,10 +542,10 @@ tracker_evolution_indexer_unset_many (TrackerEvolutionIndexer *object,
 
 void
 tracker_evolution_indexer_unset (TrackerEvolutionIndexer *object, 
-				 const gchar *subject, 
-				 const guint modseq,
-				 DBusGMethodInvocation *context,
-				 GError *derror)
+				 const gchar             *subject, 
+				 const guint              modseq,
+				 DBusGMethodInvocation   *context,
+				 GError                  *derror)
 {
 	dbus_async_return_if_fail (subject != NULL, context);
 
@@ -540,12 +556,11 @@ tracker_evolution_indexer_unset (TrackerEvolutionIndexer *object,
 
 void
 tracker_evolution_indexer_cleanup (TrackerEvolutionIndexer *object, 
-				   const guint modseq,
-				   DBusGMethodInvocation *context,
-				   GError *derror)
+				   const guint              modseq,
+				   DBusGMethodInvocation   *context,
+				   GError                  *derror)
 {
 	perform_cleanup (object);
-
 	set_stored_last_modseq (modseq);
 
 	dbus_g_method_return (context);
@@ -557,6 +572,8 @@ tracker_push_module_init (TrackerConfig *config)
 	GError *error = NULL;
 	DBusGConnection *connection;
 
+	g_message ("Evolution Plugin is initializing");
+
 	connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
 
 	if (!error) {
@@ -579,6 +596,9 @@ tracker_push_module_init (TrackerConfig *config)
 void
 tracker_push_module_shutdown (void)
 {
-	if (idx_indexer)
+	g_message ("Evolution Plugin is shutting down");
+
+	if (idx_indexer) {
 		g_object_unref (idx_indexer);
+	}
 }
diff --git a/src/plugins/kmail/Makefile.am b/src/plugins/kmail/Makefile.am
index bcb7ea7..b6a85c1 100644
--- a/src/plugins/kmail/Makefile.am
+++ b/src/plugins/kmail/Makefile.am
@@ -3,6 +3,7 @@ include $(top_srcdir)/Makefile.decl
 INCLUDES = -I$(top_srcdir)/src						\
 	-DGETTEXT_PACKAGE="\"$(GETTEXT_PACKAGE)\""			\
 	-DLOCALEDIR="\"$(localedir)\""					\
+	-DG_LOG_DOMAIN=\"Tracker\"					\
 	-DTRACKER_COMPILATION						\
 	$(WARN_CFLAGS)							\
 	$(DBUS_CFLAGS)							\
diff --git a/src/plugins/rss/Makefile.am b/src/plugins/rss/Makefile.am
index a1f72af..912f1b8 100644
--- a/src/plugins/rss/Makefile.am
+++ b/src/plugins/rss/Makefile.am
@@ -3,6 +3,7 @@ include $(top_srcdir)/Makefile.decl
 INCLUDES = -I$(top_srcdir)/src						\
 	-DGETTEXT_PACKAGE="\"$(GETTEXT_PACKAGE)\""			\
 	-DLOCALEDIR="\"$(localedir)\""					\
+	-DG_LOG_DOMAIN=\"Tracker\"					\
 	-DTRACKER_COMPILATION						\
 	$(WARN_CFLAGS)							\
 	$(DBUS_CFLAGS)							\



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