Commit graph

6 commits

Author SHA1 Message Date
Michael James Gratton
8827bc2a09 Add a mock Account object. 2017-12-19 10:47:36 +11:00
Michael James Gratton
dcdbcbeef9 Add some useful Engine API mock objects. 2017-12-19 10:23:47 +11:00
Michael James Gratton
ccabe6ed6c Update testcase to fix failure introduced by commit da15ebe. 2017-11-16 10:37:29 +11:00
Michael James Gratton
e8dcad9a43 Add unit tests for adding accounts.
* 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.
2017-02-23 11:33:12 +11:00
Michael James Gratton
9f5def0d0f Re-implement alt text filename fallback when saving inline images.
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.
2017-02-16 08:58:58 +11:00
Michael James Gratton
2a7fca9397 Clean up default filename when saving attachments.
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.
2017-02-16 08:44:27 +11:00