Hello,
This patch adds converting to utf8, while parsing TMS files if needed.
Michael Biebl had problem with u "umlaut" ΓΌ.
This patch tries to convert to utf8 if it fails, than the TMS is not indexed.

--
best
Michal Pryc
Index: tracker-email-thunderbird.c
===================================================================
--- tracker-email-thunderbird.c	(revision 850)
+++ tracker-email-thunderbird.c	(working copy)
@@ -203,6 +203,7 @@
 	MailMessage 		*mail_msg;
 	gsize			length;
 	gchar			*contents = NULL;
+	gchar			*parse;
 	GMarkupParseContext 	*context;
 	GError 			*error = NULL;
 	TmsParserData 		*parser_data;
@@ -222,25 +223,39 @@
 		return mail_msg;
 	}
 
+        if(g_utf8_validate(contents, -1, NULL) == FALSE) {
+                parse = g_filename_to_utf8(contents, strlen(contents), NULL, NULL, &error);
+                if(!parse) {
+                        tracker_log ("Error converting to utf8: %s\nIn file: %s\n", error->message, path);
+                        g_error_free(error);
+                        g_free(contents);
+                        return mail_msg;
+                }
+                g_free(contents);
+        } else {
+                parse = g_strdup(contents);
+                g_free(contents);
+        } 
+
 	context = g_markup_parse_context_new(&tms_file_parser, G_MARKUP_TREAT_CDATA_AS_TEXT,
 					parser_data, free_parser_data );
-
-        if (!g_markup_parse_context_parse(context, contents, length, NULL)) {
+		
+        if (!g_markup_parse_context_parse(context, parse, length, NULL)) {
 		tracker_log ("Error parsing context with length \n");
 		g_markup_parse_context_free(context);
-		g_free(contents);
+		g_free(parse);
 		return mail_msg;
 	}
 
 	if (!g_markup_parse_context_end_parse(context, NULL)) {
                 tracker_log ("Error parsing context \n");;
 		g_markup_parse_context_free(context);
-		g_free(contents);
+		g_free(parse);
 		return mail_msg;
 	}
 
 	g_markup_parse_context_free(context);
-	g_free(contents);
+	g_free(parse);
 	return mail_msg;
 }
 
_______________________________________________
tracker-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/tracker-list

Reply via email to