summaryrefslogtreecommitdiffstats
path: root/compose.c
AgeCommit message (Collapse)Author
2020-05-17Clean up Editor Menu interface inside Mutt.Kevin McCarthy
enter_filename() api: * Rename enter_fname() to _enter_fname() * Rename mutt_buffer_enter_mailbox() to mutt_enter_mailbox() * Rename mutt_buffer_enter_filenames() to mutt_enter_filenames() * Remove 'multiple' and 'fname buffer' parameters from mutt_enter_filenames(). Create a temp buffer, and enable multiple automatically. This removes the possibility of mistakenly looking at an unpopulated 'fname' parameter for the result. * Create mutt_enter_filename(). This isn't used currently, but it makes sense to have a "single filename" api already set up with correct parameters. get_field() api: * Rename _mutt_buffer_get_field() to a static _get_field() function. * Remove _mutt_get_field() and make mutt_get_field() an actual function. * Remove the multiple/files/numfiles parameters, since this should only be done through mutt_enter_filenames(). _mutt_enter_string() api: Add comments to mutt_enter_string() and _mutt_enter_string() headers. Noting that they should generally not be called directly. List the functions that should be used inside Mutt. Note the behavior of the multiple parameter.
2020-05-17Fix attach-file tag operation to work when quitting browser.Kevin McCarthy
There was a disconnect between the compose menu and the behavior when selecting multiple files. The select_file() operation populates the files and numfiles when hitting 'quit'. The compose menu was incorrectly looking at the fname parameter, which won't be populated unless the user presses enter. The enter_string() menu makes the same mistake. Change it to behave differently depending on whether multiple is set. The logic needs to be made clearer by changing the api. I will do that in the next commit.
2020-05-11Separate mailbox vs buffy-incoming for the "enter_fname" functions.Kevin McCarthy
Create mutt_buffer_enter_mailbox(), which turns on the MUTT_MAILBOX flag (renamed from MUTT_EFILE). This uses the mailbox history file category, and turns on MUTT_SEL_FOLDER in the select_file browser. Add a do_incoming paramter and a new separate flag MUTT_INCOMING, so that buffy-completion can be enabled optionally for mailboxes. It only makes sense for the change-folder operation, so disable it in other contexts (such as saving/copying a message, prompting for an Fcc mailbox, or an autocrypt scan mailbox). Change saving/copying a message to use the mailbox function, so that it shares the history file with other mailbox operations. It would previously use the "file" history category. Create mutt_buffer_enter_filenames() to replace the enter_fname() prompt for files. Since nothing directly uses the _mutt_buffer_enter_fname() function anymore, rename and make it static.
2020-03-21Add $fcc_delimiter, to allow multiple Fcc mailboxes.Kevin McCarthy
The variable defaults unset, to prevent breaking anyone's configuration. If set to a value, such as ",", $record and fcc-hook may list multiple mailboxes separated by the delimiter. Mutt will tokenize and expand/prettify each separate mailbox. At Fcc time, it will loop through trying to save to each mailbox. This patch introduces a bit more uglyness into init.c, which has to special-process for $record in a few places. I don't like that, but I believe the feature is important enough to allow for the one-off behavior hack, because we are constrained by backwards compatibility. Add documentation notes about the resulting issues with '<' mailbox shortcut expansion, and with fcc-save-hook processing. It is recommended to use fcc-hook to set multiple mailboxes in those cases instead.
2020-03-06Change mutt_FormatString() data parameter to type void *.Kevin McCarthy
All invocations pass a pointer parameter. Perhaps at one point this was like the init.h combined usage. But as with that, using an unsigned long is incorrect, and we've been lucky to get away with it. Since we don't need a union, just change it to void * to properly size the parameter.
2020-02-29Add background edit landing page.Kevin McCarthy
The landing page waits for the $editor process to exit, or until the user presses <exit>, "q" by default. If they press exit they are returned to the index. If the $editor exits first, they are returned directly to the compose process.
2020-02-29Enable backgrounding a single <mail> function.Kevin McCarthy
Backgrounding exits to the index menu. Re-invoking <mail> will resume the backgrounded session, if one exists, otherwise start a new session. This is just to get basic support going. Multiple background edits, a landing page, a background compose menu list will be added next.
2020-02-29Write out sctx sign_as values in mutt_write_fcc().Kevin McCarthy
2020-02-29Change send_menus to set sctx instead of globals.Kevin McCarthy
Add a "cleared" bit for smime_crypt_alg. Otherwise clearing the value in smime.c's menu would cause the compose menu and mutt_protect() to fall back to using SmimeCryptAlg.
2020-02-29Change mutt_protect() to use sctx signas values.Kevin McCarthy
Pass the sctx into postpone_message() and save_fcc() to it can be passed to mutt_protect. Change compose menu to show the sctx values, but fall back to the globals.
2020-02-29Use sctx->signas values in compose menu.Kevin McCarthy
todo: we need to fix the send_menus. We need to save/restore the globals in mutt_protect().
2020-02-29Pass sctx to mutt_builtin_editor() and mutt_edit_headers().Kevin McCarthy
This will be used to set the sctx signas instead of globals for header editing.
2020-02-29Add send_ctx to compose menu and get_postponed().Kevin McCarthy
This will be used to store and use sctx for sign_as values.
2020-02-29Rename ci_send_message() to mutt_send_message().Kevin McCarthy
This fits the current naming conventions. There are a few other "ci_" prefixed functions, but there's no need to tackle all those changes right now.
2020-01-23Add move-up and move-down functions to compose menu.Kevin McCarthy
This adds the ability to rearrange the order of the attachments, including swapping the first attachment if desired. The compose menu doesn't support nested attachments, but since data structures and code are shared with recvattach, the new functions use the v2r and try to behave sensibly with respect to parent pointer adjustments. However, the functions do restrict movement to be between siblings. Adding code to support cross-tree movement would be more complicated for no current purpose.
2019-11-13allow autoview preview of multipart/alternative contentmadroach
add view-alt function, so now we have * view-alt "v" * view-alt-text "Esc v" * view-alt-mailcap "V"
2019-11-10Add gcc comments for fallthrough case statements.Kevin McCarthy
Most of these were already commented. Change a few of them to a format gcc will recognize. In the future, we'll want to change to whatever is standardized.
2019-11-06Ensure APP_PGP flag is enabled for autocrypt.Kevin McCarthy
There was no code that explicitly enabled APP_PGP mode when either the recommendation engine or autocrypt menu were invoked. This would cause the actual encryption to fail when sending. This was hidden by the $crypt_opportunistic_encrypt config, which does ensure it gets turned on. I can only guess that this variable is popular with the autocrypt early adopters too. Also explicity enable APP_PGP for $autocrypt_reply. We can't rely on $crypt_autopgp to turn this on.
2019-11-01Add ability to generate multipart/alternative using a filter script.Kevin McCarthy
Create config variables $send_multipart_alternative (a quadoption) and $send_multipart_alternative_filter. The filter script expects output to be the mime type, a blank line, then the content. Add ability to preview alternative from compose menu. <view-alt-text> forces viewing as text. <view-alt-mailcap> forces using the mailcap. Bind them to 'v' and 'V', respectively. Improve <resend-message> so a multipart/alternative is stripped out, which would just confuse the compose menu. Currently this preserves the first alternative. Allow alternative generation in batch mode, as long as the quadoption is set to 'yes'.
2019-11-01Create multipart/mixed helpers.Kevin McCarthy
Since we will be dealing with multipart/alternative, we need the helpers to be a bit more specific. We need to distinguish a top-level multipart/alternative from a multipart/mixed created because of attachments.
2019-10-24Convert fcc to a buffer.Kevin McCarthy
This affects the send.c flow (ci_send_message()), the compose menu, and various helper functions.
2019-10-20Remove make_key_attachment parameter.Kevin McCarthy
The parameter is not actually used anywhere. The next commit will convert the classic pgp implementation to use the buffer pool. This change will simplify the logic.
2019-09-22Fix memory leak in compose write-fcc function.Kevin McCarthy
The outer multipart was not being freed after writing.
2019-09-22Convert compose menu fname variable to buffer.Kevin McCarthy
2019-09-21Convert compose check_attachments() to use buffer pool.Kevin McCarthy
Modify error message so that the filename comes last, to prevent a long path from hiding the error message or prompt.
2019-09-01Fix memory leak when attaching messages.Kevin McCarthy
Setting actx->idx[]->content->parts to NULL causes a memory leak, because message attachments store a BODY there that needs to be freed. I looked through the various use cases of ci_send_message() and actually believe content->parts will be NULL for all other cases except message attachments. From the comment added to delete_attachment(): Other ci_send_message() message constructors are careful to free any body->parts, removing depth: - mutt_prepare_template() used by postponed, resent, and draft files - mutt_copy_body() used by the recvattach menu and $forward_attachments. I believe it is safe to completely remove the "content->parts = NULL" statement. But for safety, am doing so only for the case it must be avoided: message attachments.
2019-08-31Re-enable and cleanup format-flowed space stuffing.Kevin McCarthy
Commit 04cb5bde tried to fix re-stuffing a postponed message more than once, but unfortunately broke the normal case of composing a new message. So actually, space-stuffing has been turned off the past 7 years. Move format=flowed parameter setting below the standard message pre-processing block. It shouldn't be performed for draft-files even with $resume_draft_files set. Moving out of the block makes that clearer. Create mutt_rfc3676_space_(un)stuff() functions, which check the content type and stuff/unstuff apprpropriately. Note that the stuff/unstuff does not depend on $text_flowed, which is only in charge of setting the format=flowed parameter. This parameter can also come from resumed/resent/draft messages and should still be respected. Add unstuffing to mutt_prepare_template(). This is called by postponed, resent, and draft files. This will prevent double-stuffing in those cases. Unstuff/restuff around editing the message in the compose menu, to keep everything transparent to the user. I originally put the stuffing *after* the compose menu, but previewing the messages in the compose menu did not work properly in that case. It's cleaner this way too. Change the stuff/unstuff functions to preserve the original hdr->content->filename. The "hack" previously used would interact poorly with editable body files (mutt -i -E). Fortunately space stuffing was pretty much disabled except in unusual cases before.
2019-08-03Add more translation string comments for autocrypt.Kevin McCarthy
2019-08-03Add L10N translation message comments.Kevin McCarthy
2019-08-03Autocrypt outgoing emails.Kevin McCarthy
Change crypt_get_keys() to query autocrypt. When oppenc_mode is set, we still query the original keyring regardless, because the compose menu can still run oppenc even if autocrypt is on. Since mutt_autocrypt_ui_recommendation() checks each key as part of making the recommendation, add a keylist parameter and use that function. Add gpgme changes to use the autocrypt context for encryption. Postpone work: * Change mutt_protect() to have a postpone parameter. Remove the manual toggling of the SIGN bit outside the call when postponing. * Since autocrypt doesn't set the SIGN bit, this allows us to turn off signing inside mutt_protect() for both normal and autocrypt mode. * Set the autocrypt postpone key in AutocryptDefaultKey. Write autocrypt and gossip headers in outgoing emails.
2019-08-03Add autocrypt line to the compose menu.Kevin McCarthy
Remove the hardcoded HDR_ATTACH offset calcuation, and add an explicit enum for the "-- Attachments" line to make loops and padding array sizes easier. Add security and recommendataion fields on the line. Add mutt_autocrypt_ui_recommendation, following the autocrypt spec guidelines.
2019-06-28Remove unnecessary "" checks for DT_STR and DT_PATH MuttVars.Kevin McCarthy
MuttVars of those types are set via safe_strdup(), which returns NULL if the original is "". Thus Var implies *Var. A good portion of the code relies on that axiom, but over the years some (Var && *Var) checks have crept in, including from me. This was partially because of the INITVAL("") that were in the code, which implied (incorrectly) the initial value could be "". Commit 2f91d43e removed those to make it more clear. This commit removes the *Var checks to make it even clearer, and help avoid them creeping back in again.
2019-04-11Generate version string during make not configureAaron Schrab
Switch to generating the version string during make process rather than at configure time. This makes it easier to keep the detailed version string accurate when doing development which doesn't require that the configure script be rerun.
2019-01-04Clean up formatting.Kevin McCarthy
Add spaces after if, else, while, for, switch. Unify the brace placement style. The vast majority of the code uses Allman style so convert the relatively few K&R braces over.
2019-01-04Clean up code indentation.Kevin McCarthy
These are mostly automated changes corresponding to the emacs settings: (c-set-style "linux") (setq c-basic-offset 2) (c-set-offset 'case-label '+) Most of the code follows the convention: (add-to-list 'c-cleanup-list 'space-before-funcall) but this is not enforced by this indentation cleanup. Also, I personally dislike tabs, so I have: (setq-default indent-tabs-mode nil) in my own configuration. However I have no desire to change every line just for that effect. So this cleanup does nothing about the mix issue. Some of the secondary files (e.g. regex.c) have been skipped. I've also skipped crypt-gpgme.c, because I need to think about that file. Werner Koch and the GnuPG team contributed most it, and it follows the Gnu indentation settings. It should probably be made uniform with Mutt, but I don't want to discourage future GnuPG contribution to the file. I manually reverted a few unsightly cleanups, and added a few tweeks when I saw things that could be improved.
2018-12-31Remove trailing whitespace.Kevin McCarthy
The result of find . -name "*.[ch]" -exec emacs -batch {} \ --eval="(progn (delete-trailing-whitespace) (and (buffer-modified-p) (save-buffer)))" \;
2018-12-31Remove dead code.Kevin McCarthy
Most of these have been "#if 0" out for 10-20 years. Any utility in keeping them around is miniscule at this point. There are a few other "#if 0" in the code, but I've kept them for now. Some are utility functions that are not used, but I think still may have some documentation value.
2018-01-11Create pgp and s/mime default and sign_as key vars. (see #3983)Kevin McCarthy
The $postpone_encrypt and $(pgp/smime)_self_encrypt configuration variables have created a somewhat messier situation for users. Many of them now have to specify their keys across multiple configuration variables. (Trac) Ticket #3983 had a reasonable request: "if my encrypt and signing keys are the same, why can't I just specify my key once in my .muttrc?" The problem currently is that $smime_default_key and $pgp_sign_as are both used to specify signing keys, and are set by the "sign (a)s" security menu choice. So we can't store encryption keys there because some users have separate sign-only capability keys. Create $pgp_default_key to store the default encryption key. Change signing to use $pgp_default_key, unless overridden by $pgp_sign_as. The pgp "sign (a)s" will continue setting $pgp_sign_as. Create $smime_sign_as. Change signing to use $smime_default_key unless overridden by $smime_sign_as. Change s/mime "sign (a)s" menu to set $smime_sign_as instead. Change $postpone_encrypt and $(pgp/smime)_self_encrypt to use $(pgp/smime)_default_key by default. Mark $(pgp/smime)_self_encrypt_as deprecated. They are now aliases for the $(pgp/smime)_default_key config vars. Change $(pgp/smime)_self_encrypt default to set. The intent is that most users now need only set $(pgp/smime)_default_key. If they have a sign-only key, or have separate signing and encryption keys, they can put that in $(pgp/smime)_sign_as. This also enables to default self_encrypt on and solve a very common request. Thanks to Michele Marcionelli and Vincent Lefèvre for gently pushing me towards a solution.
2017-12-30Disable message security if the backend is not available.Kevin McCarthy
Gitlab issue #3 exposed an awkward corner case: if mutt is configured without PGP or S/MIME, and with GPGME, but $crypt_use_gpgme is unset. In this case, no backend will be available, but WithCrypto will be set with both APPLICATION_PGP and APPLICATION_SMIME bits. That will allow various config vars to enable encryption or signing, even though there will be no backend available to perform them. The message security flag might then be set, but when the user hits send, will end up back at the compose menu due to the error. The pgp or smime menu might not even be available to clear the security setting! Add a check in send.c before the compose menu is invoked, and give a warning message for the menu ops inside the compose menu. I believe this should prevent the issue. However this is a corner case combined with user misconfiguration, so I don't believe is worth a large effort to completely eradicate.
2017-08-10Fix shared attachment functions. (see #3728)Kevin McCarthy
With nested decryption, the correct FP is associated with the ATTACHPTR entry. Also, the BODY entries are not continguous, so the functions need to iterate over the actx index, not the BODY structure.
2017-08-10Add virtual index to actx. (see #3728)Kevin McCarthy
The virtual index is modeled after the CONTEXT. Add a CURATTACH helper to reduce code verbosity. Store the actx as menu->data. Simplify and consolidate the recvattach and compose menu update code inside a function. Because compose and recvattach share so much code, change compose to use the virtual index even though it has no collapse/expand functionality.
2017-08-10Change recvattach to allow nested encryption. (see #3728)Kevin McCarthy
* Add a FP and BODY array to the actx. These are used to allow proper cleanup. * Add HEADER and root_fp entries, to allow for index regeneration. * Separate out the compose and recvattach index generation functions. * Change the recvattach index generator to decrypt as encrypted parts are found.
2017-08-10Add helpers to add and remove actx entries. (see #3728)Kevin McCarthy
Use the helper in compose update_idx(), to consolidate the resize logic and simplify the code. Separate out the actx "free" routine from a routine to empty out the idx. The index regeneration routines should flush and rebuild the index without having to renerate the actx structure.
2017-08-10Change helpers functions to pass actx. (see #3728)Kevin McCarthy
Change the pager, compose, recvattach and recvcmd to pass the actx instead of the individual idx and idxlen parameters. Separate out the compose menu exit logic to first free the BODY data and then call the shared actx free function at the bottom.
2017-08-10Create ATTACH_CONTEXT to hold attachment index. (see #3728)Kevin McCarthy
Move the idx and idxlen into ATTACH_CONTEXT. In subsequence patches, this structure will hold more useful items, such as the virtual index. The swap out is straightforward, except for: * update_idx() in compose.c, which post-increments the idxlen in the call and again in the function. * mutt_gen_attach_list() which doesn't need to returns the new values.
2017-06-18Improve the L10N comment about Sign as.Kevin McCarthy
Make it clearer what the indentation behavior is, and add suggestions about the width. Thanks to TAKAHASHI Tamotsu for the original patch suggesting changes to the L10N comments.
2017-06-14Enable all header fields in the compose menu to be translated.Kevin McCarthy
While it is suggested they need not be, for some locales it might be preferable to be able to localize the fields. For instance, fr_FR may want to change the punctuation to have a space in front of the colon. ja_JP may be more comfortable with a native character set description of the field when using it every day.
2017-06-09Rename 'sign as' to 'Sign as'; makes compose menu more consistent.Consus
2017-06-09Change the compose menu fields to be dynamically padded.Kevin McCarthy
Pad based on the maximum width of the fields. Note that this is a bit of a mess, because some of the fields are translated while others are not.
2017-05-03Add color commands for the compose menu headers and security status. (closes ↵Kevin McCarthy
#3915). Add "color compose header" to color the From/To/Subject/etc fields in the compose menu. Add "color compose security_encrypt/sign/both/none" to color the security status of the message.