Commit 3584b7eb authored by Jamie McCracken's avatar Jamie McCracken

added initial and experimental support for thunderbird + build fixes for solaris

svn path=/trunk/; revision=840
parent 1f987c5e
...@@ -28,3 +28,4 @@ Tshepang Lekhonkhobe <tshepang@gmail.com> ...@@ -28,3 +28,4 @@ Tshepang Lekhonkhobe <tshepang@gmail.com>
John Stowers <john.stowers@gmail.com> John Stowers <john.stowers@gmail.com>
Neil Patel <njpatel@gmail.com> Neil Patel <njpatel@gmail.com>
Anders Rune Jensen <anders@iola.dk> Anders Rune Jensen <anders@iola.dk>
Michal Pryc <Michal.Pryc at Sun.Com>
2007-09-12 Jamie McCracken <jamiemcc at gnome org>
* Added basic support for index merging
2007-09-12 Patch from Michal Pryc <Michal.Pryc@Sun.COM>
* added initial thunderbird support (experimental and requires separate thunderbird-extension)
* added solaris build fixes
2007-09-11 Patch from Marcus Fritzsch <fritschy at googlemail com> 2007-09-11 Patch from Marcus Fritzsch <fritschy at googlemail com>
* Split legacy deskbar handler into two files, static and live. * Split legacy deskbar handler into two files, static and live.
......
SUBDIRS = data src filters thumbnailers docs po python SUBDIRS = data src filters thumbnailers docs po python
if WITH_THUNDERBIRD_EXTENSION
SUBDIRS += @THUNDERBIRD_EXTENSION_DIRECTORY@
endif
autostartdir = $(sysconfdir)/xdg/autostart autostartdir = $(sysconfdir)/xdg/autostart
autostart_in_files = trackerd.desktop.in autostart_in_files = trackerd.desktop.in
autostart_DATA = $(autostart_in_files:.desktop.in=.desktop) autostart_DATA = $(autostart_in_files:.desktop.in=.desktop)
......
...@@ -25,7 +25,13 @@ AC_CHECK_HEADERS([fcntl.h sitdlib.h string.h sys/time.h unistd.h linux/unistd.h] ...@@ -25,7 +25,13 @@ AC_CHECK_HEADERS([fcntl.h sitdlib.h string.h sys/time.h unistd.h linux/unistd.h]
AC_CHECK_HEADER([zlib.h], [], [AC_MSG_ERROR([You must have zlib.h and zlib installed])]) AC_CHECK_HEADER([zlib.h], [], [AC_MSG_ERROR([You must have zlib.h and zlib installed])])
dnl can posix_fadvise be used
AC_CHECK_DECLS(posix_fadvise, [], [], [
#define _XOPEN_SOURCE 600
#include <fcntl.h>])
# Checks for functions # Checks for functions
AC_CHECK_FUNCS([posix_fadvise])
AC_CHECK_FUNCS([getline]) AC_CHECK_FUNCS([getline])
dnl Library Checks dnl Library Checks
...@@ -594,8 +600,37 @@ fi ...@@ -594,8 +600,37 @@ fi
AM_CONDITIONAL(ENABLE_PREFERENCES, test "$enable_preferences" != "no") AM_CONDITIONAL(ENABLE_PREFERENCES, test "$enable_preferences" != "no")
##################################################################
# check for thunderbird extension
##################################################################
AC_ARG_WITH(thunderbird-extension,
AC_HELP_STRING([--with-thunderbird-extension], [Build with thunderbird extension - note this is experimental and you will need the tunderbird extension for tracker]),
[
enable_tbird=no
AC_CHECK_FILES( thunderbird-extension/Makefile.am \
thunderbird-extension/install.rdf \
thunderbird-extension/components/BeagleIndexer.js,
[
enable_tbird=yes
AC_SUBST(THUNDERBIRD_EXTENSION_DIRECTORY,[thunderbird-extension])
thunderbird_extension_message="The extension will be build to: thunderbird-extension/tracker.x
pi
*****INFO*****
You have choosen to build with the Thunderbird extension.
Please refer to the README file, for notes about installing
the extension in the Thunderbird application
"
],
AC_MSG_ERROR([Couldn't find Thunderbird extension source directory. Please see
README file])
)
],
[
enable_tbird=no
])
AM_CONDITIONAL(WITH_THUNDERBIRD_EXTENSION, test "x$enable_tbird" = "xyes")
################################################################## ##################################################################
# check for poppler's glib bingings # check for poppler's glib bingings
...@@ -739,6 +774,7 @@ AC_CONFIG_FILES([ ...@@ -739,6 +774,7 @@ AC_CONFIG_FILES([
po/Makefile.in po/Makefile.in
python/Makefile python/Makefile
python/deskbar-handler/Makefile python/deskbar-handler/Makefile
]) ])
AC_CONFIG_HEADERS([config.h]) AC_CONFIG_HEADERS([config.h])
...@@ -773,6 +809,11 @@ Metadata extractors: ...@@ -773,6 +809,11 @@ Metadata extractors:
xml/html formats: $have_libxml2 xml/html formats: $have_libxml2
embedded/sidecar xmp: $have_exempi embedded/sidecar xmp: $have_exempi
Thunderbird extension (experimental - requires thunderbird extension):
Build Thunderbird extension: $enable_tbird
$thunderbird_extension_message
" "
echo " echo "
......
...@@ -154,6 +154,18 @@ TabularMetadata=Email:Sender;Email:Subject;Email:Date; ...@@ -154,6 +154,18 @@ TabularMetadata=Email:Sender;Email:Subject;Email:Date;
TileMetadata=Email:Sender;Email:Subject;Email:Date;Email:SentTo;Email:CC;Email:Attachments TileMetadata=Email:Sender;Email:Subject;Email:Date;Email:SentTo;Email:CC;Email:Attachments
ContentMetadata=Email:Body ContentMetadata=Email:Body
[ThunderbirdEmails]
DisplayName=Thunderbird Emails
Description=Thunderbird based emails
Parent=Emails
ViewerExec=thunderbird -viewmetatracker "%1"
KeyMetadata1=Email:Subject
KeyMetadata2=Email:Sender
KeyMetadata3=Email:Date
TabularMetadata=Email:Sender;Email:Subject;Email:Date;
TileMetadata=Email:Sender;Email:Subject;Email:Date;Email:SentTo;Email:CC;Email:Attachments
ContentMetadata=Email:Body
[KMailEmails] [KMailEmails]
DisplayName=KMail Emails DisplayName=KMail Emails
Description=KMail based emails Description=KMail based emails
......
...@@ -151,7 +151,10 @@ Enable or disable the stemmer. ...@@ -151,7 +151,10 @@ Enable or disable the stemmer.
This section may contain Email specific options. This section may contain Email specific options.
.TP .TP
IndexEvolutionEmails=BOOLEAN IndexEvolutionEmails=BOOLEAN
Enable or disable indexing or Evolution emails. Enable or disable indexing for Evolution emails.
.TP
IndexThunderbirdEmails=BOOLEAN
Enable or disable indexing for Thunderbird emails.
.SS Performance .SS Performance
Trackerd performance related options. Trackerd performance related options.
......
...@@ -43,7 +43,7 @@ tracker_extract_imagemagick (gchar *filename, GHashTable *metadata) ...@@ -43,7 +43,7 @@ tracker_extract_imagemagick (gchar *filename, GHashTable *metadata)
argv[0] = g_strdup ("identify"); argv[0] = g_strdup ("identify");
argv[1] = g_strdup ("-format"); argv[1] = g_strdup ("-format");
argv[2] = g_strdup ("'%w;\\n%h;\\n%c;\\n'"); argv[2] = g_strdup ("%w;\\n%h;\\n%c;\\n");
if (g_str_has_suffix (filename, ".xcf")) { if (g_str_has_suffix (filename, ".xcf")) {
argv[3] = g_strdup (filename); argv[3] = g_strdup (filename);
argv[4] = NULL; argv[4] = NULL;
......
...@@ -605,6 +605,8 @@ open_file_cb (GtkAction * action, ...@@ -605,6 +605,8 @@ open_file_cb (GtkAction * action,
exec = g_strdup_printf ("evolution \"%s\"", uri); exec = g_strdup_printf ("evolution \"%s\"", uri);
} else if (strstr (mime, "KMail")) { } else if (strstr (mime, "KMail")) {
exec = g_strdup_printf ("kmail --view \"%s\"", uri); exec = g_strdup_printf ("kmail --view \"%s\"", uri);
} else if (strstr (mime, "Thunderbird")) {
exec = g_strdup_printf ("thunderbird -viewbeagle \"%s\"", uri);
} else { } else {
exec = NULL; exec = NULL;
} }
......
...@@ -391,6 +391,8 @@ get_service_name (MailApplication app) ...@@ -391,6 +391,8 @@ get_service_name (MailApplication app)
return g_strdup ("KMailEmails"); return g_strdup ("KMailEmails");
} else if (app == MAIL_APP_THUNDERBIRD) { } else if (app == MAIL_APP_THUNDERBIRD) {
return g_strdup ("ThunderbirdEmails"); return g_strdup ("ThunderbirdEmails");
} else if (app == MAIL_APP_THUNDERBIRD_FEED) {
return g_strdup ("ThunderbirdEmails");
} else { } else {
return g_strdup ("OtherEmails"); return g_strdup ("OtherEmails");
} }
...@@ -406,6 +408,8 @@ get_mime (MailApplication app) ...@@ -406,6 +408,8 @@ get_mime (MailApplication app)
return g_strdup ("KMail/Email"); return g_strdup ("KMail/Email");
} else if (app == MAIL_APP_THUNDERBIRD) { } else if (app == MAIL_APP_THUNDERBIRD) {
return g_strdup ("Thunderbird/Email"); return g_strdup ("Thunderbird/Email");
} else if (app == MAIL_APP_THUNDERBIRD_FEED) {
return g_strdup ("Thunderbird/Feed");
} else { } else {
return g_strdup ("Other/Email"); return g_strdup ("Other/Email");
} }
...@@ -445,6 +449,11 @@ tracker_db_email_save_email (DBConnection *db_con, MailMessage *mm) ...@@ -445,6 +449,11 @@ tracker_db_email_save_email (DBConnection *db_con, MailMessage *mm)
return FALSE; return FALSE;
} }
if (!mm->subject) {
tracker_log ("WARNING: email with uri: %s has no subject",mm->uri);
mm->subject = g_strdup("");
}
if (mm->parent_mail_file && !mm->parent_mail_file->path) { if (mm->parent_mail_file && !mm->parent_mail_file->path) {
tracker_error ("ERROR: badly formatted email - abandoning index"); tracker_error ("ERROR: badly formatted email - abandoning index");
return FALSE; return FALSE;
......
...@@ -17,8 +17,6 @@ ...@@ -17,8 +17,6 @@
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#define _XOPEN_SOURCE 600
#ifndef _GNU_SOURCE #ifndef _GNU_SOURCE
#define _GNU_SOURCE #define _GNU_SOURCE
#endif #endif
...@@ -42,6 +40,7 @@ ...@@ -42,6 +40,7 @@
#include "tracker-indexer.h" #include "tracker-indexer.h"
#include "tracker-cache.h" #include "tracker-cache.h"
#include "tracker-metadata.h" #include "tracker-metadata.h"
#include "tracker-utils.h"
#include "config.h" #include "config.h"
...@@ -71,7 +70,7 @@ typedef struct { ...@@ -71,7 +70,7 @@ typedef struct {
/* slqite utf-8 user defined collation sequence */ /* sqlite utf-8 user defined collation sequence */
static int static int
sqlite3_utf8_collation (void *NotUsed, int len1, const void *str1, int len2, const void *str2) sqlite3_utf8_collation (void *NotUsed, int len1, const void *str1, int len2, const void *str2)
...@@ -350,7 +349,7 @@ tracker_db_log_result (char ***result) ...@@ -350,7 +349,7 @@ tracker_db_log_result (char ***result)
for (row = *rows; *row; row++) { for (row = *rows; *row; row++) {
char *value; char *value;
value = *row; value = tracker_string_replace (*row, "%", "%%");
if (!value) { if (!value) {
value = "NULL"; value = "NULL";
...@@ -366,6 +365,8 @@ tracker_db_log_result (char ***result) ...@@ -366,6 +365,8 @@ tracker_db_log_result (char ***result)
} else { } else {
str = g_strconcat (value, NULL); str = g_strconcat (value, NULL);
} }
g_free (value);
} }
if (str) { if (str) {
...@@ -2732,11 +2733,11 @@ tracker_db_save_file_contents (DBConnection *db_con, GHashTable *index_table, GH ...@@ -2732,11 +2733,11 @@ tracker_db_save_file_contents (DBConnection *db_con, GHashTable *index_table, GH
DBConnection *blob_db_con = db_con->blob; DBConnection *blob_db_con = db_con->blob;
#if defined(__linux__) #if defined(__linux__)
fd = open (file_name, O_RDONLY|O_NOATIME); fd = open (file_name, O_RDONLY|O_NOATIME);
#else #else
fd = open (file_name, O_RDONLY); fd = open (file_name, O_RDONLY);
#endif #endif
if (fd ==-1) { if (fd ==-1) {
tracker_error ("ERROR: could not open file %s", file_name); tracker_error ("ERROR: could not open file %s", file_name);
...@@ -2762,8 +2763,9 @@ tracker_db_save_file_contents (DBConnection *db_con, GHashTable *index_table, GH ...@@ -2762,8 +2763,9 @@ tracker_db_save_file_contents (DBConnection *db_con, GHashTable *index_table, GH
byte_array = g_byte_array_sized_new (MAX_TEXT_BUFFER); byte_array = g_byte_array_sized_new (MAX_TEXT_BUFFER);
/* boost readahead */ /* boost readahead */
#ifdef HAVE_POSIX_FADVISE
posix_fadvise (fd, 0, 0, POSIX_FADV_SEQUENTIAL); posix_fadvise (fd, 0, 0, POSIX_FADV_SEQUENTIAL);
#endif
while (!finished) { while (!finished) {
...@@ -2866,7 +2868,7 @@ tracker_db_save_file_contents (DBConnection *db_con, GHashTable *index_table, GH ...@@ -2866,7 +2868,7 @@ tracker_db_save_file_contents (DBConnection *db_con, GHashTable *index_table, GH
if (!use_buffer) g_free (value); if (!use_buffer) g_free (value);
if (tracker->throttle > 9) { if (tracker->throttle > 9) {
tracker_throttle (tracker->throttle); tracker_throttle (tracker->throttle * 100);
} }
} }
...@@ -2875,8 +2877,9 @@ tracker_db_save_file_contents (DBConnection *db_con, GHashTable *index_table, GH ...@@ -2875,8 +2877,9 @@ tracker_db_save_file_contents (DBConnection *db_con, GHashTable *index_table, GH
deflateEnd(&strm); deflateEnd(&strm);
/* flush cache for file as we wont touch it again */ /* flush cache for file as we wont touch it again */
#ifdef HAVE_POSIX_FADVISE
posix_fadvise (fd, 0, 0, POSIX_FADV_DONTNEED); posix_fadvise (fd, 0, 0, POSIX_FADV_DONTNEED);
#endif
close (fd); close (fd);
if (finished) { if (finished) {
......
...@@ -64,6 +64,7 @@ typedef struct { ...@@ -64,6 +64,7 @@ typedef struct {
gpointer user; gpointer user;
gpointer word_index; gpointer word_index;
gpointer merge_index; gpointer merge_index;
gpointer merge_update_index;
} DBConnection; } DBConnection;
......
...@@ -2421,8 +2421,11 @@ add_persons_from_internet_address_list_string_parsing (GSList *list, const gchar ...@@ -2421,8 +2421,11 @@ add_persons_from_internet_address_list_string_parsing (GSList *list, const gchar
mp = email_allocate_mail_person (); mp = email_allocate_mail_person ();
mp->name = g_strdup (addrs_list->address->name); mp->addr = g_strdup (tmp->address->value.addr);
mp->addr = g_strdup (addrs_list->address->value.addr); if(tmp->address->name)
mp->name = g_strdup (tmp->address->name);
else
mp->name = g_strdup (tmp->address->value.addr);
list = g_slist_prepend (list, mp); list = g_slist_prepend (list, mp);
} }
......
/* Tracker /* Tracker
* routines for emails with Thunderbird * routines for emails with Thunderbird
* Copyright (C) 2006, Laurent Aguerreche (laurent.aguerreche@free.fr) * Copyright (C) 2006, Laurent Aguerreche (laurent.aguerreche@free.fr)
* Copyright (C) 2007, Michal Pryc (Michal.Pryc@Sun.Com)
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public * modify it under the terms of the GNU General Public
...@@ -20,8 +21,10 @@ ...@@ -20,8 +21,10 @@
#include <string.h> #include <string.h>
#include <glib/gstdio.h> #include <glib/gstdio.h>
#include <stdlib.h>
#include "tracker-email-thunderbird.h" #include "tracker-email-thunderbird.h"
#include "tracker-db-email.h"
#ifdef HAVE_INOTIFY #ifdef HAVE_INOTIFY
# include "tracker-inotify.h" # include "tracker-inotify.h"
...@@ -31,11 +34,36 @@ ...@@ -31,11 +34,36 @@
# endif # endif
#endif #endif
typedef enum
{
TAG_NONE = 0,
TAG_FOLDER_FILE,
TAG_FEED_URL,
TAG_AUTHOR,
TAG_DATE,
TAG_FOLDER,
TAG_HAS_OFFLINE,
TAG_MESSAGE_ID,
TAG_MESSAGE_SIZE,
TAG_MESSAGE_OFFSET,
TAG_OFFLINE_SIZE,
TAG_RECIPIENTS,
TAG_SUBJECT,
TAG_MESSAGE_KEY,
TAG_URI,
} TmsParserTag;
typedef struct
{
TmsParserTag tag;
GString *buffer;
MailMessage *mail_message;
} TmsParserData;
extern Tracker *tracker; extern Tracker *tracker;
#define THUNDERBIRD_MAIL_DIR_S ".mozilla-thunderbird" #define THUNDERBIRD_MAIL_DIR_S ".xesam/ThunderbirdEmails/ToIndex"
typedef struct { typedef struct {
...@@ -50,7 +78,21 @@ static ThunderbirdPrefs * prefjs_parser (const char *filename); ...@@ -50,7 +78,21 @@ static ThunderbirdPrefs * prefjs_parser (const char *filename);
static void free_thunderbirdprefs_struct (ThunderbirdPrefs *prefs); static void free_thunderbirdprefs_struct (ThunderbirdPrefs *prefs);
static GSList * find_thunderbird_mboxes (GSList *list_of_mboxes, const char *profile_dir); static GSList * find_thunderbird_mboxes (GSList *list_of_mboxes, const char *profile_dir);
static GSList * add_inbox_mbox_of_dir (GSList *list_of_mboxes, const char *dir); static GSList * add_inbox_mbox_of_dir (GSList *list_of_mboxes, const char *dir);
static GSList * add_persons_from_internet_address_list_string_parsing (GSList *list, const gchar *s);
static gboolean email_parse_mail_tms_file_and_save_new_emails (DBConnection *db_con, MailApplication mail_app,
const char *path);
static MailMessage * email_parse_mail_tms_file_by_path (MailApplication mail_app, const char *path);
static void text_handler (GMarkupParseContext *context, const gchar *text,
gsize text_len, gpointer user_data, GError **error);
static void start_element_handler (GMarkupParseContext *context, const gchar *element_name,
const gchar **attribute_names, const gchar **attribute_values,
gpointer user_data, GError **error);
static void end_element_handler (GMarkupParseContext *context, const gchar *element_name,
gpointer user_data, GError **error);
static glong get_date_from_string (const gchar *date_string);
static gboolean get_boolean_from_string (const gchar *boolean_string);
static void free_parser_data (gpointer user_data);
static GMarkupParser tms_file_parser;
...@@ -65,7 +107,7 @@ thunderbird_init_module (void) ...@@ -65,7 +107,7 @@ thunderbird_init_module (void)
thunderbird_mail_dir = g_build_filename (g_get_home_dir (), THUNDERBIRD_MAIL_DIR_S, NULL); thunderbird_mail_dir = g_build_filename (g_get_home_dir (), THUNDERBIRD_MAIL_DIR_S, NULL);
} }
return TRUE; return thunderbird_module_is_running();
} }
...@@ -84,155 +126,329 @@ thunderbird_finalize_module (void) ...@@ -84,155 +126,329 @@ thunderbird_finalize_module (void)
thunderbird_mail_dir = NULL; thunderbird_mail_dir = NULL;
} }
return TRUE; return !thunderbird_module_is_running();
} }
void void
thunderbird_watch_emails () thunderbird_watch_emails (DBConnection *db_con)
{ {
char *thunderbird_dir, *thunderbird_profile_file; if( thunderbird_mail_dir != NULL ) {
GKeyFile *key_file; tracker_log("Thunderbird directory lookup: \"%s\"", thunderbird_mail_dir);
int i; email_watch_directory(thunderbird_mail_dir, "ThunderbirdEmails");
GSList *profile_dirs, *list_of_mboxes; }
const GSList *tmp; }
thunderbird_dir = g_build_filename (g_get_home_dir (), THUNDERBIRD_MAIL_DIR_S, NULL);
thunderbird_profile_file = g_build_filename (thunderbird_dir, "profiles.ini", NULL);
if (!g_file_test (thunderbird_profile_file, G_FILE_TEST_EXISTS)) {
g_free (thunderbird_profile_file);
g_free (thunderbird_dir);
return;
}
key_file = g_key_file_new ();
g_key_file_load_from_file (key_file, thunderbird_profile_file, G_KEY_FILE_NONE, NULL);
g_free (thunderbird_profile_file);
profile_dirs = NULL;
for (i = 0; ; i++) {
char *str_id, *profile_id;
str_id = g_strdup_printf ("%d", i);
profile_id = g_strconcat ("Profile", str_id, NULL);
g_free (str_id);
if (!g_key_file_has_group (key_file, profile_id)) { gboolean
/* there isn't probably more profiles */ thunderbird_file_is_interesting (FileInfo *info, const char *service)
g_free (profile_id); {
break; //Filename should be objectX.tms (Thunderbird Message Summary)
} if (g_str_has_suffix(info->uri, ".tms")) {
return TRUE;
} else {
return FALSE;
}
}
if (g_key_file_has_key (key_file, profile_id, "Path", NULL)) {
gboolean path_is_relative;
char *path;
path = g_key_file_get_string (key_file, profile_id, "Path", NULL); void
thunderbird_index_file (DBConnection *db_con, FileInfo *info)
{
g_return_if_fail (db_con && info);
if (!path) { tracker_log ("Thunderbird file index: \"%s\"\n",info->uri);
g_free (profile_id); if(email_parse_mail_tms_file_and_save_new_emails (db_con, MAIL_APP_THUNDERBIRD, info->uri))
continue; unlink(info->uri);
} }
if (g_key_file_has_key (key_file, profile_id, "IsRelative", NULL)) {
path_is_relative = g_key_file_get_boolean (key_file, profile_id, "IsRelative", NULL);
} else {
path_is_relative = !g_path_is_absolute (path);
}
if (path_is_relative) {
char *absolute_path;
absolute_path = g_build_filename (thunderbird_dir, path, NULL);
profile_dirs = g_slist_prepend (profile_dirs, absolute_path); /********************************************************************************************
} else { Private functions
profile_dirs = g_slist_prepend (profile_dirs, g_strdup (path)); *********************************************************************************************/
}
g_free (path); static gboolean
} email_parse_mail_tms_file_and_save_new_emails (DBConnection *db_con, MailApplication mail_app, const char *path)
{
MailMessage *mail_msg;
g_return_val_if_fail (db_con, FALSE);
g_return_val_if_fail (path, FALSE);
mail_msg = email_parse_mail_tms_file_by_path (mail_app, path);
if (!mail_msg) {
return FALSE;
}
//Check if it is valid mail message
if(mail_msg->parent_mail_file->mail_app == MAIL_APP_THUNDERBIRD ) {
// || mail_msg->parent_mail_file->mail_app == MAIL_APP_THUNDERBIRD_FEED) {
tracker_db_email_save_email (db_con, mail_msg);
email_free_mail_file(mail_msg->parent_mail_file);
email_free_mail_message (mail_msg);
return TRUE;
}
email_free_mail_file(mail_msg->parent_mail_file);
email_free_mail_message (mail_msg);
return FALSE;
}
g_free (profile_id); static MailMessage *
email_parse_mail_tms_file_by_path (MailApplication mail_app, const char *path)
{
MailMessage *mail_msg;
gsize length;
gchar *contents = NULL;
GMarkupParseContext *context;
GError *error = NULL;
TmsParserData *parser_data;
g_return_val_if_fail (path, NULL);
parser_data = g_new0(TmsParserData,1);
parser_data->mail_message = email_allocate_mail_message();
mail_msg = parser_data->mail_message;
mail_msg->parent_mail_file = g_slice_new0 (MailFile);
mail_msg->parent_mail_file->path = g_strdup(path);
if (!g_file_get_contents(path, &contents, &length, &error)) {
tracker_log ("Error reading Thunderbird message summary %s\n", error->message);
g_error_free(error);
return mail_msg;
} }
g_free (thunderbird_dir); context = g_markup_parse_context_new(&tms_file_parser, G_MARKUP_TREAT_CDATA_AS_TEXT,
parser_data, free_parser_data );
list_of_mboxes = NULL;
for (tmp = profile_dirs; tmp; tmp = tmp->next) {
const char *dir;
dir = tmp->data; if (!g_markup_parse_context_parse(context, contents, length, NULL)) {
tracker_log ("Error parsing context with length \n");
g_markup_parse_context_free(context);
g_free(contents);
return mail_msg;
}
list_of_mboxes = find_thunderbird_mboxes (list_of_mboxes, dir); if (!g_markup_parse_context_end_parse(context, NULL)) {
tracker_log ("Error parsing context \n");;
g_markup_parse_context_free(context);
g_free(contents);
return mail_msg;
} }
for (tmp = list_of_mboxes; tmp; tmp = tmp->next) { g_markup_parse_context_free(context);
const char *path; g_free(contents);
char *base_dir; return mail_msg;
}
path = tmp->data; static void
text_handler(GMarkupParseContext *context, const gchar *text,