Currently, a lot of our build variables that are defined at
configuration time, are spread out across the code base, often declared
as `extern` which can break when moving around sections of the code
across files.
This commit introduces a "Config" namespace which basically maps to the
definitions in `config.h`, but allows us to properly access them too
from the Vala source code.
By doing so, it helps us to more explicitly see where we rely on a
build variable from this file (which should be obvious from the `Config'
namespace).
To make it ourselves a bit easier in Meson too, we can declare an
internal dependency, which helps ensure that we pull in the dependency
where needed.
This replaces the const ContentType.DEFAULT_CONTENT_TYPE string and
related code with static defaults for both displayed and attached MIME
entities.
* src/engine/mime/mime-content-type.vala (ContentType): Replace
DEFAULT_CONTENT_TYPE const with static DISPLAY_DEFAULT and
ATTACHMENT_DEFAULT static instances. Remove is_default() since that no
longer makes sense. Update call sites and unit tests.
* src/engine/mime/mime-content-parameters.vala (ContentParameters): Make
the class immutable so it is safe to be used as a component of the
static ContentType DISPLAY_DEFAULT and ATTACHMENT_DEFAULT members.
This mostly aims to make the Geary.Attachment and ImapDB.Attachment
objects usable more generally for managing attachments, allowing
these to be instantiated once, persisted, and then reused, rather than
going through a number of representations (GMime, SQlite, Geary) and
having to be saved and re-loaded.
* src/engine/api/geary-attachment.vala (Attachment): Remove id property
and allow both file and filesize properties to be set after instances
are constructed. Update call sites.
* src/engine/api/geary-email.vala (Email): Remove get_attachment_by_id
since it unused.
* src/engine/imap-db/imap-db-attachment.vala (Attachment): Chase
Geary.Attachment API changes, move object-specific persistence code
into methods on the actual object class itself and modernise a
bit. Rename static methods to be a bit more terse. Update call sites
and add unit tests.
* src/engine/imap-db/imap-db-folder.vala (Folder): Rather than saving
attachments to the db then reloading them to add them to their email
objects, just instantiate Attachment instances once, save and then add
them.
* src/engine/imap-db/imap-db-gc.vala (GC): Replace custom SQL with
existing accessor for listing attachments.
* src/engine/util/util-stream.vala (MimeOutputStream): New adaptor class
for GMime streams to GIO output streams.
* test/api/*.vala: Renamed files that contained mock objects to *-mock.vala,
not *-test.vala.
* test/testcase.vala: Renamed to test-case.vala for consistency, remove
TestCase class from Gee package since that's really not true. Clean up
code for consistency.
* test/meson.build, test/CMakeLists.txt: Split TestCase compilation out
into a separate test lib.
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.