[PATCH 4/4] Retrieve subparts headers on retrieving bs message.
- From: José Dapena Paz <jdapena igalia com>
- Subject: [PATCH 4/4] Retrieve subparts headers on retrieving bs message.
- Date: Mon, 21 Dec 2009 18:08:58 +0100
* libtinymail-camel/tny-camel-bs-mime-part.c: fix
fetching properly the headers of message/rfc822 attachments
on fetching the bodystructure.
* libtinymail-camel/tny-camel-mime-part.c: properly fetch the
children messages when the message comes from IMAP bodystructure.
---
ChangeLog | 7 +++
libtinymail-camel/tny-camel-bs-mime-part.c | 13 +++++-
.../tny-camel-bs-msg-receive-strategy.c | 43 ++++++++++++++++++++
libtinymail-camel/tny-camel-mime-part.c | 3 +-
4 files changed, 63 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 8fb6baa..313b817 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2009-12-21 Jose Dapena Paz <jdapena igalia com>
+ * libtinymail-camel/tny-camel-bs-mime-part.c: fix
+ fetching properly the headers of message/rfc822 attachments
+ on fetching the bodystructure.
+
+ * libtinymail-camel/tny-camel-mime-part.c: properly fetch the
+ children messages when the message comes from IMAP bodystructure.
+
* libtinymail-camel/tny-camel-bs-msg-receive-strategy.c:
fetch the message/rfc822 contents using part.TEXT in
IMAP request.
diff --git a/libtinymail-camel/tny-camel-bs-mime-part.c b/libtinymail-camel/tny-camel-bs-mime-part.c
index ffc07f9..03873df 100644
--- a/libtinymail-camel/tny-camel-bs-mime-part.c
+++ b/libtinymail-camel/tny-camel-bs-mime-part.c
@@ -324,8 +324,17 @@ tny_camel_bs_mime_part_get_header_pairs_default (TnyMimePart *self, TnyList *lis
TnyCamelBsMimePartPriv *priv = TNY_CAMEL_BS_MIME_PART_GET_PRIVATE (self);
CamelFolderPartState state;
CamelFolder *cfolder = _tny_camel_folder_get_camel_folder (TNY_CAMEL_FOLDER (priv->folder));
+ gchar *part_uid;
+
+ if (priv->bodystructure && priv->bodystructure->parent) {
+ /* this means we have to read the cached header of a subpart */
+ part_uid = g_strconcat (priv->uid, "_", priv->bodystructure->part_spec, NULL);
+ } else {
+ part_uid = g_strdup (priv->uid);
+ }
gchar *pos_filename = camel_folder_get_cache_filename (cfolder,
- priv->uid, "HEADER", &state);
+ part_uid, "HEADER", &state);
+ g_free (part_uid);
if (pos_filename && !priv->parent && TNY_IS_MSG (self)) {
FILE *f = fopen (pos_filename, "r");
@@ -913,7 +922,7 @@ tny_camel_bs_mime_part_get_filename_default (TnyMimePart *self)
if (charset && (g_ascii_strcasecmp(charset, "us-ascii") == 0))
charset = NULL;
- charset = charset ? e_iconv_charset_name (charset) : NULL;
+ charset = charset ? (const gchar *) e_iconv_charset_name (charset) : NULL;
while (isspace ((unsigned) *raw_value))
raw_value++;
diff --git a/libtinymail-camel/tny-camel-bs-msg-receive-strategy.c b/libtinymail-camel/tny-camel-bs-msg-receive-strategy.c
index c9104fa..39708ae 100644
--- a/libtinymail-camel/tny-camel-bs-msg-receive-strategy.c
+++ b/libtinymail-camel/tny-camel-bs-msg-receive-strategy.c
@@ -120,6 +120,37 @@ tny_camel_bs_msg_receive_strategy_start_receiving_part (TnyCamelBsMsgReceiveStra
return retval;
}
+static void
+retrieve_subparts_headers (CamelFolder *folder, const gchar *uid, bodystruct_t *bodystructure, CamelException *ex)
+{
+ bodystruct_t *children;
+
+ if (!strcasecmp (bodystructure->content.type, "message") &&
+ !strcasecmp (bodystructure->content.subtype, "rfc822") &&
+ bodystructure->parent != NULL) {
+ gchar *part_spec;
+ gboolean hdr_bin = FALSE;
+
+ part_spec = g_strconcat (bodystructure->part_spec, ".HEADER", NULL);
+ gchar *mpstr = camel_folder_fetch (folder, uid, part_spec, &hdr_bin, ex);
+ g_free (mpstr);
+ g_free (part_spec);
+
+ if (camel_exception_is_set (ex))
+ return;
+ }
+
+ children = bodystructure->subparts;
+ while (children != NULL) {
+
+ retrieve_subparts_headers (folder, uid, children, ex);
+
+ if (camel_exception_is_set (ex))
+ return;
+ children = children->next;
+ }
+}
+
static TnyMsg *
tny_camel_bs_msg_receive_strategy_perform_get_msg_default (TnyMsgReceiveStrategy *self, TnyFolder *folder, TnyHeader *header, GError **err)
{
@@ -154,6 +185,18 @@ tny_camel_bs_msg_receive_strategy_perform_get_msg_default (TnyMsgReceiveStrategy
}
if (bodystructure) {
+ retrieve_subparts_headers (cfolder, uid, bodystructure, &ex);
+
+ if (camel_exception_is_set (&ex)) {
+ _tny_camel_exception_to_tny_error (&ex, err);
+ camel_exception_clear (&ex);
+ g_free (uid);
+ bodystruct_free (bodystructure);
+ return NULL;
+ }
+ }
+
+ if (bodystructure) {
message = _tny_camel_bs_msg_new (bodystructure, uid, NULL);
_tny_camel_bs_msg_set_header (TNY_CAMEL_BS_MSG (message), header);
diff --git a/libtinymail-camel/tny-camel-mime-part.c b/libtinymail-camel/tny-camel-mime-part.c
index 3fd1c05..6d6e7a0 100644
--- a/libtinymail-camel/tny-camel-mime-part.c
+++ b/libtinymail-camel/tny-camel-mime-part.c
@@ -354,7 +354,8 @@ recreate_part (TnyMimePart *orig)
g_object_unref (dest_header);
piece = tny_camel_mime_part_new ();
piece_needs_unref = TRUE;
- type = NULL;
+ if (!g_ascii_strcasecmp (type, "message/rfc822"))
+ type = NULL;
} else {
piece = tny_camel_mime_part_new ();
retval = piece;
--
1.6.3.3
--=-1Q3M1KkkA2Tq782WYTM/--
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]