* src/engine/api/geary-engine.vala (Engine::create_orphan_account): Fix
sense of test when determining the next account id to use. Add unit
tests.
(Engine::add_account): Made public so it can be used in public test.
This restores some old behaviour after teh WK2 port.
* src/client/conversation-viewer/conversation-message.vala
(ConversationMessage): Add alt_text param to ::save_image
signal. Replace ::set_action_param_string with
::set_action_param_string so we can pass a (url, alt_text) tuple for
the save_image tuple and update call sites. Set this tuple for the
action when enabling it, and pass the two values to the ::save_image
signal handler when activated.
* src/engine/api/geary-attachment.vala (Attachment::get_safe_file_name):
Add alt_file_name param method, use that when constructing a file
name. Add doc comment, test.
* src/client/application/geary-controller.vala: Updated to pass alt text
from save_imge signal emission all thr way through to
get_safe_file_name.
This ensures both inline images are saved using the specified content
filename, if any, and that an extension is attempted to be guessed when
no filename is specified.
Fixes Bug 713999, Bug 712923, Bug 778026.
* src/client/application/geary-controller.vala: Major rework of how
attachments are saved. Rework how save dialogs are constructed,
combining common code paths into one constrcutor method. Split up code
for saving one attachment vs many into two different methods. Ensure
all code baths ultimately use the same method to do the actual
saving. Lookup a attachment when saving an inline image and use that
by default. Get filenames from new Attachment::get_useful_filename
method that guesses if needed.
* src/client/conversation-viewer/conversation-message.vala
(ConversationMessage::save_image): Fix name of first param to reflect
what it actually is.
* src/engine/api/geary-attachment.vala (Attachment): Add
::get_safe_filename method that checks the type of both the
attachment's content and its file name, if any. Will construct an
appropriate file name if non is given. Add unit tests.
* src/engine/api/geary-email.vala (Email): Add new
::get_attachment_by_content_id to lookup attachments by MIME
content-id. Rename old ::get_attachment method to disambiguate.
Fixes Base64 encoded parts when fetching PREVIEW, and armour, etc
stripping etc not being applied to previews geneated via
Geary.RFC822.Message.
* src/engine/rfc822/rfc822-utils.vala
(Geary.RFC822.Utils::to_preview_text): Assume line endings are LF
encoded, update doc comment and unit tests to reflect that.
* src/engine/rfc822/rfc822-message-data.vala (PreviewText.with_header):
Add CRLF filter to preveiw text to strip CR chars from lines.
Bug 772607.
* src/engine/rfc822/rfc822-utils.vala (Geary.RFC822.Utils): Don't
truncate the preview here - fetch preview will already be truncated,
and the conversation message preview needs the full text anyway. Update
unit tests.
* src/client/conversation-viewer/conversation-message.vala
(ConversationMessage::ConversationMessage): Since we need to know if
the preview has been truncated so we know if we need to add an elipsis
or not, get the full preview and tuncate it here if needed.
* src/engine/rfc822/rfc822-message.vala (Message): Don't bother trying to
set the preview when creating a Geary.Email from the message. Minor
code & doc cleanup.
* src/engine/api/geary-email.vala (Email): Double length of max fetch
preview so HTML parts might actually pick up some content. Tidy up doc
comments.
* src/engine/rfc822/rfc822-utils.vala (to_preview_text): Don't bother to
check for MIME Content-* headers now that we are only treating a part
as plain text if it is actually text/plain.
Ensures that both appear the same to the user, and that the conversation
message preview gets the same armour and quote stripping that the fecth
preview does.
Added tests.
Bug 714317
* src/engine/rfc822/rfc822-utils.vala
(Geary.RFC822.Utils::to_preview_text): New common function to handle
generating a preview from a RFC 822 plain text or HTML string.
* src/engine/rfc822/rfc822-message-data.vala (PreviewText::with_header):
Move plain text armour and quote stripping to to_preview_text(), call
that to generate preview text.
* src/engine/rfc822/rfc822-message.vala (Message::get_preview): call
to_preview_text() to generate the preview text.
When generating the preview, only the first 128 bytes of the first MIME
part is fetched and used. If this part is text/html with a significant
amount of embedded CSS, then there is a good chance the string passed to
Geary.HTML::remove_html_tags() will be invalid, or be missing closing
elements. Since that function uses regexes that require balanced tags to
remove script and style blocks, then it was very possible that in these
cases this method will miss removing these blocks.
To solve this, remove_html_tags() is removed and its call sites are
replaced by calls to Geary.HTML::html_to_text(), which has been tidyied
up to produce more human-readable result.
Add unit tests to cover new html_to_text functionality and its call
sites.
* src/engine/util/util-html.vala: Remove remove_html_tags(). Update
html_to_text() to not just insert line breaks, but also insert spaces
and alt text, and ignore tags like HEAD, SCRIPT and STYLE, as
appropriate. Add an optional param to also allow skipping BLOCKQUOTE
elements, which we don't want in the preview.