From c1d2ec0123694a3b52e9c58de97c60994f5db587 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Fri, 1 Dec 2000 00:34:33 +0000 Subject: New convenience function, doesn't do much but it sure makes code cleaner 2000-11-30 Jeffrey Stedfast * camel-folder-summary.c (camel_message_info_new): New convenience function, doesn't do much but it sure makes code cleaner to read. (camel_message_info_new_from_header): This one makes my life heaven. svn path=/trunk/; revision=6749 --- camel/ChangeLog | 6 +++++ camel/camel-folder-summary.c | 54 ++++++++++++++++++++++++++++++++++++++++++++ camel/camel-folder-summary.h | 2 ++ 3 files changed, 62 insertions(+) diff --git a/camel/ChangeLog b/camel/ChangeLog index 855d9654dc..95457c91bd 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,9 @@ +2000-11-30 Jeffrey Stedfast + + * camel-folder-summary.c (camel_message_info_new): New convenience + function, doesn't do much but it sure makes code cleaner to read. + (camel_message_info_new_from_header): This one makes my life heaven. + 2000-11-30 Jeffrey Stedfast * providers/imap/camel-imap-summary.c (camel_imap_summary_new): diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c index 4879d547ee..b7b9b9c421 100644 --- a/camel/camel-folder-summary.c +++ b/camel/camel-folder-summary.c @@ -2138,6 +2138,60 @@ void camel_tag_list_free(CamelTag **list) *list = NULL; } + +/** + * camel_message_info_new: + * + * Returns a new CamelMessageInfo structure. + **/ +CamelMessageInfo * +camel_message_info_new () +{ + CamelMessageInfo *info; + + info = g_new0 (CamelMessageInfo, 1); +#ifdef DOESTRV + info->strings = e_strv_new (CAMEL_MESSAGE_INFO_LAST); +#endif + + return info; +} + + +/** + * camel_message_info_new_from_header: + * @header: raw header + * + * Returns a new CamelMessageInfo structure populated by the header. + **/ +CamelMessageInfo * +camel_message_info_new_from_header (struct _header_raw *header) +{ + CamelMessageInfo *info; + char *subject, *from, *to, *cc; + + subject = camel_folder_summary_format_string (header, "subject"); + from = camel_folder_summary_format_address (header, "from"); + to = camel_folder_summary_format_address (header, "to"); + cc = camel_folder_summary_format_address (header, "cc"); + + info = g_new0 (CamelMessageInfo, 1); +#ifdef DOESTRV + info->strings = e_strv_new (CAMEL_MESSAGE_INFO_LAST); + camel_message_info_set_subject (info, subject); + camel_message_info_set_from (info, from); + camel_message_info_set_to (info, to); + camel_message_info_set_cc (info, cc); +#else + info->subject = subject; + info->from = from; + info->to = to; + info->cc = cc; +#endif + + return info; +} + /** * camel_message_info_dup_to: * @from: source message info diff --git a/camel/camel-folder-summary.h b/camel/camel-folder-summary.h index defba693fc..eb8d839822 100644 --- a/camel/camel-folder-summary.h +++ b/camel/camel-folder-summary.h @@ -277,6 +277,8 @@ void camel_tag_list_free(CamelTag **list); /* message info utils for working with pseudo-messageinfo structures NOTE: These cannot be added to a real summary object, but suffice for all other external interfaces that use message info's */ +CamelMessageInfo *camel_message_info_new (); +CamelMessageInfo *camel_message_info_new_from_header (struct _header_raw *header); void camel_message_info_dup_to(const CamelMessageInfo *from, CamelMessageInfo *to); void camel_message_info_free(CamelMessageInfo *mi); -- cgit