tracker r2132 - in branches/indexer-split: . src/tracker-indexer/modules



Author: carlosg
Date: Thu Aug 21 11:36:21 2008
New Revision: 2132
URL: http://svn.gnome.org/viewvc/tracker?rev=2132&view=rev

Log:
2008-08-21  Carlos Garnacho  <carlos imendio com>

        * src/tracker-indexer/modules/evolution.c (get_text_for_mbox)
        (get_text_for_imap) (tracker_module_file_get_text): New functions, get
        the emails body through the get_text() module function, so it's saved
        in the contents DB.


Modified:
   branches/indexer-split/ChangeLog
   branches/indexer-split/src/tracker-indexer/modules/evolution.c

Modified: branches/indexer-split/src/tracker-indexer/modules/evolution.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/modules/evolution.c	(original)
+++ branches/indexer-split/src/tracker-indexer/modules/evolution.c	Thu Aug 21 11:36:21 2008
@@ -41,7 +41,6 @@
 #define METADATA_EMAIL_SUBJECT       "Email:Subject"
 #define METADATA_EMAIL_SENT_TO       "Email:SentTo"
 #define METADATA_EMAIL_CC            "Email:CC"
-#define METADATA_EMAIL_BODY          "Email:Body"
 
 typedef union EvolutionFileData EvolutionFileData;
 typedef struct EvolutionLocalData EvolutionLocalData;
@@ -745,8 +744,7 @@
         EvolutionLocalData *data;
         GMimeMessage *message;
         TrackerMetadata *metadata;
-        gchar *dirname, *basename, *body;
-        gboolean is_html;
+        gchar *dirname, *basename;
         time_t date;
         GList *list;
         guint flags;
@@ -791,9 +789,6 @@
         list = get_mbox_recipient_list (message, GMIME_RECIPIENT_TYPE_CC);
         tracker_metadata_insert_multiple_values (metadata, METADATA_EMAIL_CC, list);
 
-        body = g_mime_message_get_body (message, TRUE, &is_html);
-        tracker_metadata_insert (metadata, METADATA_EMAIL_BODY, body);
-
         return metadata;
 }
 
@@ -1037,20 +1032,6 @@
         return message_path;
 }
 
-static gchar *
-get_imap_message_body (TrackerFile *file,
-                       const gchar *uid)
-{
-        gchar *message_path;
-        gchar *body = NULL;
-
-        message_path = get_imap_message_path (file, uid);
-        g_file_get_contents (message_path, &body, NULL, NULL);
-        g_free (message_path);
-
-        return body;
-}
-
 static TrackerMetadata *
 get_metadata_for_imap_attachment (TrackerFile *file,
                                   const gchar *mime_file)
@@ -1115,7 +1096,7 @@
         EvolutionImapData *data;
         TrackerMetadata *metadata = NULL;
         gchar *dirname, *basename;
-        gchar *uid, *subject, *from, *to, *cc, *body;
+        gchar *uid, *subject, *from, *to, *cc;
         gint32 i, count, flags;
         time_t date;
         GList *list;
@@ -1187,9 +1168,6 @@
 
                 list = get_imap_recipient_list (cc);
                 tracker_metadata_insert_multiple_values (metadata, METADATA_EMAIL_CC, list);
-
-                body = get_imap_message_body (file, uid);
-                tracker_metadata_insert (metadata, METADATA_EMAIL_BODY, body);
         }
 
         g_free (uid);
@@ -1370,6 +1348,66 @@
         return NULL;
 }
 
+static gchar *
+get_text_for_mbox (TrackerFile *file)
+{
+        EvolutionLocalData *data;
+        gboolean is_html;
+
+        data = file->data;
+
+        if (data->current_mime_part) {
+                /* FIXME: Extract text from attachments */
+                return NULL;
+        }
+
+        return g_mime_message_get_body (data->message, TRUE, &is_html);
+}
+
+static gchar *
+get_text_for_imap (TrackerFile *file)
+{
+        EvolutionImapData *data;
+        gchar *message_path;
+        gchar *body = NULL;
+
+        data = file->data;
+
+        if (data->current_mime_part) {
+                /* FIXME: Extract text from attachments */
+                return NULL;
+        }
+
+        message_path = get_imap_message_path (file, data->cur_message_uid);
+        g_file_get_contents (message_path, &body, NULL, NULL);
+        g_free (message_path);
+
+        return body;
+}
+
+gchar *
+tracker_module_file_get_text (TrackerFile *file)
+{
+        EvolutionFileData *data;
+        gchar *text = NULL;
+
+        data = file->data;
+
+        if (!data) {
+                /* It isn't any of the files the
+                 * module is interested in */
+                return NULL;
+        }
+
+        if (data->type == MAIL_STORAGE_LOCAL) {
+                text = get_text_for_mbox (file);
+        } else if (data->type == MAIL_STORAGE_IMAP) {
+                text = get_text_for_imap (file);
+        }
+
+        return text;
+}
+
 static GList *
 extract_imap_mime_parts (TrackerFile *file)
 {



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