Geary.RFC822.Message: Add accessors for message headers and raw body

Allow accessing Header and Text representations of the message.
This commit is contained in:
Michael Gratton 2020-06-30 14:33:06 +10:00 committed by Michael James Gratton
parent 0b8bf7375f
commit e2f2b6cdab
3 changed files with 91 additions and 8 deletions

View file

@ -53,6 +53,8 @@ This is the second line.
multipart_alternative_as_converted_html);
add_test("multipart_alternative_as_html",
multipart_alternative_as_html);
add_test("get_header", get_header);
add_test("get_body", get_body);
add_test("get_preview", get_preview);
add_test("get_recipients", get_recipients);
add_test("get_searchable_body", get_searchable_body);
@ -177,6 +179,18 @@ This is the second line.
assert_equal(test.get_html_body(null), BASIC_HTML_BODY);
}
public void get_header() throws GLib.Error {
Message message = resource_to_message(BASIC_TEXT_PLAIN);
Header header = message.get_header();
assert(header.get_header("From") == "Alice <alice@example.net>");
}
public void get_body() throws GLib.Error {
Message message = resource_to_message(BASIC_TEXT_PLAIN);
Text body = message.get_body();
assert(body.buffer.to_string().replace("\r", "") == BASIC_PLAIN_BODY);
}
public void get_preview() throws GLib.Error {
Message multipart_signed = string_to_message(MULTIPART_SIGNED_MESSAGE_TEXT);