mirror of https://github.com/djcb/mu.git
* guile: fix getting message bodies
This commit is contained in:
parent
cd506d6d79
commit
0b32a63537
|
@ -162,6 +162,32 @@ msg_string_list_field (MuMsg *msg, MuMsgFieldId mfid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static SCM
|
||||||
|
get_body (MuMsg *msg, gboolean html)
|
||||||
|
{
|
||||||
|
SCM data;
|
||||||
|
const char* body;
|
||||||
|
MuMsgOptions opts;
|
||||||
|
|
||||||
|
opts = MU_MSG_OPTION_NONE;
|
||||||
|
|
||||||
|
if (html)
|
||||||
|
body = mu_msg_get_body_html (msg, opts);
|
||||||
|
else
|
||||||
|
body = mu_msg_get_body_text (msg, opts);
|
||||||
|
|
||||||
|
if (body)
|
||||||
|
data = mu_guile_scm_from_str (body);
|
||||||
|
else
|
||||||
|
data = SCM_BOOL_F;
|
||||||
|
|
||||||
|
/* explicitly close the file backend, so we won't run of fds */
|
||||||
|
mu_msg_unload_msg_file (msg);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
SCM_DEFINE (get_field, "mu:c:get-field", 2, 0, 0,
|
SCM_DEFINE (get_field, "mu:c:get-field", 2, 0, 0,
|
||||||
(SCM MSG, SCM FIELD),
|
(SCM MSG, SCM FIELD),
|
||||||
"Get the field FIELD from message MSG.\n")
|
"Get the field FIELD from message MSG.\n")
|
||||||
|
@ -186,21 +212,14 @@ SCM_DEFINE (get_field, "mu:c:get-field", 2, 0, 0,
|
||||||
case MU_MSG_FIELD_ID_FLAGS: return get_flags_scm (msgwrap->_msg);
|
case MU_MSG_FIELD_ID_FLAGS: return get_flags_scm (msgwrap->_msg);
|
||||||
|
|
||||||
case MU_MSG_FIELD_ID_BODY_HTML:
|
case MU_MSG_FIELD_ID_BODY_HTML:
|
||||||
|
return get_body (msgwrap->_msg, TRUE);
|
||||||
case MU_MSG_FIELD_ID_BODY_TEXT:
|
case MU_MSG_FIELD_ID_BODY_TEXT:
|
||||||
{
|
return get_body (msgwrap->_msg, FALSE);
|
||||||
SCM data;
|
|
||||||
data = mu_guile_scm_from_str
|
|
||||||
(mu_msg_get_field_string (msgwrap->_msg, mfid));
|
|
||||||
/* explicitly close the file backend, so we won't run of fds */
|
|
||||||
mu_msg_unload_msg_file (msgwrap->_msg);
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* our pseudo-field; we get it from the message file */
|
/* our pseudo-field; we get it from the message file */
|
||||||
case MU_GUILE_MSG_FIELD_ID_TIMESTAMP:
|
case MU_GUILE_MSG_FIELD_ID_TIMESTAMP:
|
||||||
return scm_from_uint (
|
return scm_from_uint (
|
||||||
(unsigned)mu_msg_get_timestamp(msgwrap->_msg));
|
(unsigned)mu_msg_get_timestamp(msgwrap->_msg));
|
||||||
|
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -602,13 +602,12 @@ mu_msg_file_get_str_field (MuMsgFile *self, MuMsgFieldId mfid,
|
||||||
|
|
||||||
case MU_MSG_FIELD_ID_MAILDIR: return self->_maildir;
|
case MU_MSG_FIELD_ID_MAILDIR: return self->_maildir;
|
||||||
|
|
||||||
case MU_MSG_FIELD_ID_BODY_TEXT:
|
case MU_MSG_FIELD_ID_BODY_TEXT: /* use mu_msg_get_body_text */
|
||||||
case MU_MSG_FIELD_ID_BODY_HTML:
|
case MU_MSG_FIELD_ID_BODY_HTML: /* use mu_msg_get_body_html */
|
||||||
case MU_MSG_FIELD_ID_EMBEDDED_TEXT:
|
case MU_MSG_FIELD_ID_EMBEDDED_TEXT:
|
||||||
g_warning ("not available here: %s",
|
g_warning ("%s is not retrievable through: %s",
|
||||||
mu_msg_field_name (mfid));
|
mu_msg_field_name (mfid), __FUNCTION__);
|
||||||
g_return_val_if_reached (NULL);
|
return NULL;
|
||||||
return NULL;
|
|
||||||
|
|
||||||
default: g_return_val_if_reached (NULL);
|
default: g_return_val_if_reached (NULL);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue