From f2a0e196269f97bcd165ec5076ab23276f44ed65 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Sat, 18 Jun 2011 18:48:59 +0300 Subject: [PATCH] * mu-msg: small improvements, cosmetics --- src/mu-msg.c | 11 +++++++---- src/mu-msg.h | 12 +++++++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/mu-msg.c b/src/mu-msg.c index 9afdb570..c81a164b 100644 --- a/src/mu-msg.c +++ b/src/mu-msg.c @@ -62,14 +62,14 @@ mu_msg_new_from_file (const char *path, const char *mdir, GError **err) return NULL; self = msg_new (); - self->_file = msgfile; + self->_file = msgfile; return self; } MuMsg* -mu_msg_new_from_doc (const XapianDocument* doc, GError **err) +mu_msg_new_from_doc (XapianDocument *doc, GError **err) { MuMsg *self; MuMsgDoc *msgdoc; @@ -81,7 +81,7 @@ mu_msg_new_from_doc (const XapianDocument* doc, GError **err) return NULL; self = msg_new (); - self->_doc = msgdoc; + self->_doc = msgdoc; return self; } @@ -241,7 +241,7 @@ get_str_field (MuMsg *self, MuMsgFieldId mfid) val = NULL; if (self->_doc && mu_msg_field_xapian_value (mfid)) val = mu_msg_doc_get_str_field (self->_doc, mfid, &do_free); - else { + else if (mu_msg_field_gmime (mfid)) { /* if we don't have a file object yet, we need to * create it from the file on disk */ if (!self->_file) @@ -249,6 +249,9 @@ get_str_field (MuMsg *self, MuMsgFieldId mfid) if (!self->_file && !(self->_file = get_msg_file (self))) return NULL; val = mu_msg_file_get_str_field (self->_file, mfid, &do_free); + } else { + g_warning ("%s: cannot retrieve field", __FUNCTION__); + return NULL; } /* if we get a string that needs freeing, we tell the cache to diff --git a/src/mu-msg.h b/src/mu-msg.h index 1e4bdc1d..afda71ac 100644 --- a/src/mu-msg.h +++ b/src/mu-msg.h @@ -56,14 +56,15 @@ MuMsg *mu_msg_new_from_file (const char* filepath, const char *maildir, * create a new MuMsg* instance based on a Xapian::Document * * @param doc a ptr to a Xapian::Document (but cast to XapianDocument, - * because this is C not C++) + * because this is C not C++). MuMsg takes _ownership_ of this pointer; + * don't touch it afterwards * @param err receive error information, or NULL. There * will only be err info if the function returns NULL * * @return a new MuMsg instance or NULL in case of error; call * mu_msg_unref when done with this message */ -MuMsg *mu_msg_new_from_doc (const XapianDocument* doc, GError **err) +MuMsg *mu_msg_new_from_doc (XapianDocument* doc, GError **err) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; @@ -323,7 +324,9 @@ const char* mu_msg_get_header (MuMsg *self, const char *header); /** * get the list of references, with the direct parent as the final - * one; this final one is typically the 'In-reply-to' field + * one; this final one is typically the 'In-reply-to' field. Note, any + * reference (message-id) will appear at most once, duplicates are + * filtered out. * * @param msg a valid MuMsg * @@ -332,6 +335,9 @@ const char* mu_msg_get_header (MuMsg *self, const char *header); const GSList* mu_msg_get_references (MuMsg *msg); + + + /** * get the list of tags (ie., X-Label) *