static const char* get_str_field (MuMsg *self, MuMsgFieldId mfid) { gboolean do_free; char *val; /* first we try the cache */ if (mu_msg_cache_cached (self->_cache, mfid)) return mu_msg_cache_str (self->_cache, mfid); /* if it's not in the cache but it is a value retrievable from * the doc backend, use that */ val = NULL; if (self->_doc && mu_msg_field_xapian_value (mfid)) val = mu_msg_doc_get_str_field (self->_doc, mfid, &do_free); 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) self->_file = get_msg_file (self); 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 * mark the string as such, so it will be freed when the cache * is freed (or when the value is overwritten) */ return mu_msg_cache_set_str (self->_cache, mfid, val, do_free); }
static const char* get_str_field (MuMsg *self, MuMsgFieldId mfid) { char *val; gboolean do_free; do_free = TRUE; val = NULL; if (self->_doc && mu_msg_field_xapian_value (mfid)) val = mu_msg_doc_get_str_field (self->_doc, mfid); 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 (!mu_msg_load_msg_file (self, NULL)) return NULL; val = mu_msg_file_get_str_field (self->_file, mfid, &do_free); } else { g_warning ("%s: cannot retrieve field", __FUNCTION__); val = NULL; } return do_free ? free_later_str (self, val) : val; }
static const GSList* get_str_list_field (MuMsg *self, MuMsgFieldId mfid) { GSList *val; val = NULL; if (self->_doc && mu_msg_field_xapian_value (mfid)) val = mu_msg_doc_get_str_list_field (self->_doc, mfid); 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 (!mu_msg_load_msg_file (self, NULL)) return NULL; val = mu_msg_file_get_str_list_field (self->_file, mfid); } return free_later_lst (self, val); }