From 00d0c032c22d74dc025cf9a01f4e687dfaf32f63 Mon Sep 17 00:00:00 2001 From: Rodrigo Moya Date: Fri, 14 Jan 2005 16:20:53 +0000 Subject: new function to correctly retrieve the body of the message. 2005-01-14 Rodrigo Moya * mail-to-task.c (set_description): new function to correctly retrieve the body of the message. (do_mail_to_task): call set_description. svn path=/trunk/; revision=28406 --- plugins/mail-to-task/mail-to-task.c | 58 +++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 18 deletions(-) (limited to 'plugins/mail-to-task/mail-to-task.c') diff --git a/plugins/mail-to-task/mail-to-task.c b/plugins/mail-to-task/mail-to-task.c index 595d64d974..d2c5f9eb71 100644 --- a/plugins/mail-to-task/mail-to-task.c +++ b/plugins/mail-to-task/mail-to-task.c @@ -1,11 +1,11 @@ -/* Copyright (C) 2004 Michael Zucchi */ +/* Copyright (C) 2004 Novell, Inc */ +/* Authors: Michael Zucchi + Rodrigo Moya */ /* This file is licensed under the GNU GPL v2 or later */ -/* Add 'copy to clipboard' things to various menu's. - - Uh, so far only to copy mail addresses from mail content */ +/* Convert a mail message into a task */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -18,8 +18,11 @@ #include #include #include -#include "camel/camel-folder.h" -#include "camel/camel-mime-message.h" +#include +#include +#include +#include +#include #include "mail/em-popup.h" static void @@ -53,6 +56,35 @@ set_attendees (ECalComponent *comp, CamelMimeMessage *message) g_slist_free (attendees); } +static void +set_description (ECalComponent *comp, CamelMimeMessage *message) +{ + CamelDataWrapper *content; + CamelStream *mem; + ECalComponentText text; + GSList sl; + char *str; + + content = camel_medium_get_content_object ((CamelMedium *) message); + if (!content) + return; + + mem = camel_stream_mem_new (); + camel_data_wrapper_decode_to_stream (content, mem); + + str = g_strndup (((CamelStreamMem *) mem)->buffer->data, ((CamelStreamMem *) mem)->buffer->len); + camel_object_unref (mem); + + text.value = str; + text.altrep = NULL; + sl.next = NULL; + sl.data = &text; + + e_cal_component_set_description_list (comp, &sl); + + g_free (str); +} + static void set_organizer (ECalComponent *comp, CamelMimeMessage *message) { @@ -89,8 +121,6 @@ do_mail_to_task (EMPopupTargetSelect *t, ESource *tasks_source) CamelMimeMessage *message; ECalComponent *comp; ECalComponentText text; - GSList sl; - char *str; /* retrieve the message from the CamelFolder */ message = camel_folder_get_message (t->folder, g_ptr_array_index (t->uids, i), NULL); @@ -106,16 +136,8 @@ do_mail_to_task (EMPopupTargetSelect *t, ESource *tasks_source) text.altrep = NULL; e_cal_component_set_summary (comp, &text); - /* FIXME: a better way to get the full body */ - str = camel_mime_message_build_mbox_from (message); - text.value = str; - sl.next = NULL; - sl.data = &text; - e_cal_component_set_description_list (comp, &sl); - - g_free (str); - - /* set the organizer, and the attendees */ + /* set all fields */ + set_description (comp, message); set_organizer (comp, message); set_attendees (comp, message); -- cgit v1.2.3