aboutsummaryrefslogtreecommitdiff
path: root/notmuch-show.c
Commit message (Collapse)AuthorAge
...
* Fix build warning: "/*" within commentAustin Clements2012-01-14
|
* notmuch/emacs: Observe the charset of text/html parts, where known.David Edmondson2012-01-13
| | | | | | Add the charset of text/html parts to the JSON output of 'notmuch -show' when it is known. Observe the encoding when rendering such parts in emacs.
* show: Pass notmuch_message_t instead of path to show_message_body.Austin Clements2011-12-25
| | | | | In addition to simplifying the code, we'll need the notmuch_message_t* in show_message_body shortly.
* notmuch: Quiet buildbot warnings.David Edmondson2011-12-21
| | | | | Cast away the result of various *write functions. Provide a default value for some variables to avoid "use before set" warnings.
* notmuch: unref charset_filter to fix one memory leakTomi Ollila2011-12-15
| | | | | | In my test case added g_object_unref(charset_filter) reduces memory consumption over 90% when 'notmuch show --format=text "*"' is executed (~11000 messages, RES ~330M -> ~25M).
* Release memory allocated by internet_address_list_parse_string()Tomi Ollila2011-12-11
| | | | | | g_object_unref() releases the memory of the InternetAddressList object returned by internet_address_list_parse_string() -- when last (only) reference is released, internet_address_list_finalize() will do cleanup.
* cli: change argument parsing convention for subcommandsDavid Bremner2011-10-22
| | | | | | | | | previously we deleted the subcommand name from argv before passing to the subcommand. In this version, the deletion is done in the actual subcommands. Although this causes some duplication of code, it allows us to be more flexible about how we parse command line arguments in the subcommand, including possibly using off-the-shelf routines like getopt_long that expect the name of the command in argv[0].
* Do not attempt to output part raw if part is not GMimePart.Jameson Graef Rollins2011-09-07
| | | | | | | | | | | This was a minor oversite in checking of part type when outputing content raw. This was causing gmime was to throw an exception to stderr. Unfortunately the gmime exception was not being caught by notmuch, or the test suite. I'm not sure if notmuch should have done anything in this case, but certainly the test suite should be capable of detecting that something unexpected was output to stderr.
* Improve handling of message/rfc822 parts by adding a new header_message_part ↵Jameson Graef Rollins2011-09-05
| | | | | | | | | function to the formating structure. This new function takes a GMimeMessage as input, and outputs the formatted headers. This allows for message/rfc822 parts to be formatted on output in a similar way to full messages (see previous patch that overhauls the multipart test for more info).
* Add part filename and content-id in notmuch show output if available.Dmitry Kurochkin2011-06-28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before the change, notmuch show output had filename only for parts with "Content-Disposition: attachment". But parts with inline disposition may have filename as well. The patch makes notmuch show always output filename if available, independent of Content-Disposition. Both JSON and text output formats are changed. Also, the patch adds Content-id to text output format of notmuch show. The main goal of these changes is to have filenames on Emacs buttons for inline attachments. In particular, this is very helpful for inline patches. Note: text format changes may require updates in clients that use it. The changes are: * text part header format changed from: ^Lpart{ ID: 2, Content-type: text/x-diff to: ^Lpart{ ID: 2, Filename: cool-feature.patch, Content-type: text/x-diff * attachment format changed from: ^Lattachment{ ID: 4, Content-type: application/octet-stream Attachment: data.tar.bz2 (application/octet-stream) Non-text part: application/octet-stream ^Lattachment} to: ^Lattachment{ ID: 4, Filename: data.tar.bz2, Content-type: application/octet-stream Non-text part: application/octet-stream ^Lattachment}
* Use stock GMimeSession by defaultDaniel Kahn Gillmor2011-06-03
| | | | | | | | | | | | Our use of GMimeSession was unneeded boilerplate, and we weren't doing anything with it. This simplifies and clarifies that assumption. If we want to do anything fancier later, the examples in the gmime source are a reasonable source to work from in defining a new GMimeSession derivative. Since GMimeSession is going away in GMime 2.6, though, i don't recommend using it.
* show: Avoid inadvertently closing stdoutJameson Graef Rollins2011-06-03
| | | | | | | | | | | | | | | | | | | | | | | GMime has a nasty habit of taking ownership by default of any FILE* handed to it va g_mime_stream_file_new. Specifically it will close the FILE* when the stream is destroyed---even though GMime didn't open the file itself. To avoid this bad behavior, we have to carefully set_owner(FALSE) after calling g_mime_stream_file_new. In the format_part_content_text function, since commit d92146d3a6809f8ad940302af49cd99a0820665e we've been calling g_mime_stream_file_new unconditionally, but only calling g_mime_stream_file_set_owner(FALSE) conditionally. This led to the FILE* being closed early when notmuch show output was redirected to a file. Fixing this fixes the test-suite cases that broke with the previous commit, (which added redirected "notmuch show" calls to the test suite to expose this bug). Edited-by: Carl Worth <cworth@cworth.org> with a new commit message to explain the bug and fix.
* Rename signerstatustostring to signer_status_to_stringCarl Worth2011-05-31
| | | | Otherwise, it's fartoohardformetoreadthis code.
* Reduce some excessive indentation.Carl Worth2011-05-31
| | | | | I prefer checking a condition and returning early rather than making large blocks of code within a function conditional.
* show: Remove some dead code from show_text_part_contentCarl Worth2011-05-31
| | | | | | Now that this function registers an internal error if called with a non-text part, we can remove the conditions for multipart and message-part content types.
* notmuch show: Don't do text conversions for non-text partsCarl Worth2011-05-31
| | | | | | | | | | | This fixes the recently-added test case (in test/multipart) demonstrating corruption of binary parts that happen to contain CRLF pairs. We restore the original code from show_one_part_content to format_part_content_raw. Then, for good measure, we rename show_part_content to the more descriptive show_text_part_content and add an internal error if it is ever called with a non-text part.
* Add decryption of PGP/MIME-encrypted parts with --decrypt.Jameson Graef Rollins2011-05-27
| | | | | | | | | | | | | This adds support for decrypting PGP/MIME-encrypted parts to notmuch-show and notmuch-reply. The --decrypt option implies --verify. Once decryption (and possibly signature verification) is done, a new part_encstatus formatter is emitted, the part_sigstatus formatter is emitted, and the entire multipart/encrypted part is replaced by the contents of the encrypted part. At the moment only a json part_encstatus formatting function is available, even though decryption is done for all formats. Emacs support to follow.
* Add signature verification of PGP/MIME-signed parts with --verify.Jameson Graef Rollins2011-05-27
| | | | | | | | | | | | | | | | This is primarily for notmuch-show, although the functionality is added to show-message. Once signatures are processed a new part_sigstatus formatter is emitted, and the entire multipart/signed part is replaced with the contents of the signed part. At the moment only a json part_sigstatus formatting function is available. Emacs support to follow. The original work for this patch was done by Daniel Kahn Gillmor <dkg@fifthhorseman.net> whose help with this functionality I greatly appreciate.
* Break up format->part function into part_start and part_content functions.Jameson Graef Rollins2011-05-27
| | | | | | | Future improvements (eg. crypto support) will require adding new part header. By breaking up the output of part headers from the output of part content, we can easily out new part headers with new formatting functions.
* Fix handling of message/rfc822 partsJameson Graef Rollins2011-05-24
| | | | | | | Since message/rfc822 parts are really just a special kind of multipart, we here normalize the handling of the two. This will provide access to sub-parts of message/rfc822 parts, which was previously unavailable.
* use format=raw by default when requesting part with --part=Jameson Graef Rollins2011-05-24
| | | | | This makes part retrieval a little more intuitive, since generally one will always want to retrieve parts in raw form.
* throw error if mbox format specified with --partJameson Graef Rollins2011-05-24
| | | | | These formats are incompatible, since mbox format requires full messages.
* New part output handling as option to notmuch-show.Jameson Graef Rollins2011-05-23
| | | | | | | | | Outputting of single MIME parts is moved to an option of notmuch show, instead of being handled in it's own sub-command. The recent rework of multipart mime allowed for this change but consolidating part handling into a single recursive function (show_message_part) that includes formatting. This allows for far simpler handling single output of a single part, including formatting.
* rename do_show_raw to do_show_single, and create params.raw for raw message ↵Jameson Graef Rollins2011-05-23
| | | | | | | | | | | | | output We rename here in order to make do_show_single into a generic function for handling output of just a single message, or which format=raw is a special case. The raw case is handled by setting a new parameter, params.raw, which is used to tell do_show_single to output a single message as a raw file. This is mostly in preparation for much improved part handling to follow imminently.
* add part_sep formatter to replace "first" argument to part format functionsJameson Graef Rollins2011-05-23
| | | | | | | | A new field "part_sep" is added to the notmuch_show_format structure, to be used for part separation. This is cleaner than the "first" argument that was being passed around to the part arguments, and allows the function that handles overall part output formatting (show_message_part) to directly handle when outputting the separator.
* create notmuch_show_params_t structure for holding parameters passed to show ↵Jameson Graef Rollins2011-05-23
| | | | | | | | | functions. This simplifies the passing of arguments to the show functions. This will be very useful as we accumulate more parameters that will need to be passed. Currently only the entire_thread parameter is passed this way.
* pass entire format structure to various show_message functionsJameson Graef Rollins2011-05-20
| | | | | | | | | | | | | | Various show_message* functions require formatting functions, which were previously being passed individually as arguments. Since we will need to be needing to passing in more formatting function in the future (ie. for crypto support), we here modify things so that we just pass in the entire format structure. This will make things much simpler down the line as we need to pass in new format functions. We move the show_format structure into notmuch-client.c as notmuch_show_format. This also affects notmuch-reply.c, so we create a mostly-empty format_reply to pass the reply_part function to show_message_body.
* notmuch: Add the content-id of a part to the JSON output if it is known.David Edmondson2011-05-18
| | | | | | | It's simply one more property of a MIME part that might be useful, and json makes it so easy to add additional properties. Signed-off-by: Jameson Rollins <jrollins@finestructure.net>
* notmuch show: Properly nest MIME parts within mulipart partsCarl Worth2011-05-17
| | | | | | | | | | | | | | | | | | | | | | | Previously, notmuch show flattened all output, losing information about the nesting of the MIME hierarchy. Now, the output is properly nested, (both in the --format=text and --format=json output), so that clients can analyze the original MIME structure. Internally, this required splitting the final closing delimiter out of the various show_part functions and putting it into a new show_part_end function instead. Also, the show_part function now accepts a new "first" argument that is set not only for the first MIME part of a message, but also for each first MIME part within a series of multipart parts. This "first" argument controls the omission of a preceding comma when printing a part (for json). Many thanks to David Edmondson <dme@dme.org> for originally identifying the lack of nesting in the json output and submitting an early implementation of this feature. Thanks as well to Jameson Graef Rollins <jrollins@finestructure.net> for carefully shepherding David's patches through a remarkably long review process, patiently explaining them, and providing a cleaned up series that led to this final implementation. Jameson also provided the new emacs code here.
* notmuch show: Include output for the enclosing multipart part of a MIME mailCarl Worth2011-05-17
| | | | | | | | | | | | | | | | | Previously, the outer multipart part of any multipart/mixed, multipart/signed, etc. MIME message was silently omitted from the "notmuch show" output. This prevented any client from correctly determining to which parts a signature applies, for example. Now, we actually emit these parts as their own parts. The output is still flattened---the contained parts are not yet included "within" the multipart part---so it's still not possible to determine to which parts a signature applies, but this is one step along the path. The test suite is updated to reflect this change, (though we'll eventually want to fix the emacs interface to not display buttons for the multipart enclosure parts as there's nothing useful for the user to actually do with them).
* Rename "notmuch cat" to "notmuch show --format=raw"Carl Worth2010-11-06
| | | | | | | | | This is part of an effort to avoid proliferation of excessive top-level notmuch commands. Also, "raw" better captures the functionality here, (as opposed to "cat" which is a fairly oblique reference to a bad Unix abbreviation whose metaphor doesn't work here since "notmuch cat" operates only on a single message and hence cannot "con'cat'enate" anything).
* Add 'cat' subcommandMichal Sojka2010-11-05
| | | | | | | | | | | | This command outputs a raw message matched by search term to the standard output. It allows MUAs to access the messages for piping, attachment manipulation, etc. by running notmuch cat rather then directly access the file. This will simplify the MUAs when they need to operate on a remote database. Edited-by: Carl Worth <cworth@cworth.org>: Remove trailing whitespace, add missing "test_done" to new test script to avoid "Unexpected exit" error.
* notmuch show: Add a --format=mbox optionCarl Worth2010-06-08
| | | | | | | | | | | | | | | | | | | | | We don't love the mbox format, but it's still sometimes the most practical way to share a collection of messages as a single file. Here we implement the "mboxrd" variant of the mbox file format. This variant applies reversible escaping by prefixing a '>' character to all lines in the email messages matching the regular expression: "^>*From " This allows the escaping to be reliably removed. A reader should remove a '>' from any line matching the regular expression: "^>>*From " More details on the mboxrd formats (and others as well) can be found here: http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/mail-mbox-formats.html
* Fix minor style issues in show_part_content function.Carl Worth2010-06-05
| | | | | I was recently editing the code in this function and decided to clean it up a bit.
* Avoid giving GMime a NULL MIME-stream filter.Carl Worth2010-06-05
| | | | | | | | | | | | | | | | | | | | Micah Anderson reported an issue where a message failed to display in the emacs interface, (it instead gave an error, "json-read-string: Bad string format"). Micah tracked this down to the json output from "notmuch show" being interrupted by a GMime error message: gmime-CRITICAL **: g_mime_stream_filter_add: assertion `GMIME_IS_FILTER (filter) I tracked this down further to notmuch passing a NULL value to g_mime_stream_filter_add. And this was due to calling g_mime_filter_charset_new with a value of "unknown-8bit". So we add a test message withe a Conten-Type of "text/plain; charset=unknown-8bit" from Micah's message. Then we fix "notmuch show" to test for NULL before calling g_mime_stream_filter_add. Bug fixed.
* json: Replace `date_unix' with `timestamp' in show outputDavid Edmondson2010-04-22
| | | | | Search output was already using `timestamp' for a very similar field, so follow that.
* notmuch: Correctly terminate text/* parts in JSON outputDavid Edmondson2010-04-05
| | | | | | Text parts returned by `g_mime_stream_mem_get_byte_array()' are not NULL terminated strings - add `json_quote_chararray()' to handle them correctly.
* notmuch: Add a 'part' subcommandDavid Edmondson2010-04-02
| | | | | | | | | | | A new 'part' subcommand allows the user to extract a single part from a MIME message. Usage: notmuch part --part=<n> <search terms> The search terms must match only a single message (e.g. id:foo@bar.com). The part number specified refers to the part identifiers output by `notmuch show'. The content of the part is written the stdout with no formatting or identification marks. It is not JSON formatted.
* notmuch-show: Add unix and relative dates to the JSON outputDavid Edmondson2010-04-02
| | | | | | Include a 'date_unix' and 'date_relative' field in the JSON output for each message. 'date_relative' can be used by a UI implementation, whereas 'date_unix' is useful when scripting.
* Setup the GMimeStream only when needednstraz@redhat.com2010-04-01
| | | | | | | | | | | | | | | | | I ran into this while looking at the vim plugin. Vim's system() call redirects output to a file and it was missing many of the part{ lines. If stream_stdout is setup too early, it will overwrite the part start when notmuch is redirected to a file. Reviewed-by Carl Worth <cworth@cworth.org>: GMime is calling fseek before every write to reset the FILE* to the position it believes is correct based on the writes it has seen. Our code was getting incorrect results because our GMime writes were interleaved with non-GMime writes via printf. The bug appears when writing to a file because it's seekable, but not when writing to a pipe which is not.
* notmuch-show: add tags to json outputSebastian Spaeth2010-03-11
| | | | | | | | The previous json patches forgot to add the notmuch tags to the json output. This is inconsistent to the text output so here they are. We just output a 'tags' field that sends notmuch tags as a json array. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* notmuch show: Don't show empty headers.Carl Worth2010-03-09
| | | | | | | This is a fairly old regression. There has always been code to avoid printing empty headers (such as Cc or Bcc with no values), but it has been broken since notmuch_message_get_header was changed to return an empty string rather than a NULL pointer for these fields.
* lib: Rename iterator functions to prepare for reverse iteration.Carl Worth2010-03-09
| | | | | | | | We rename 'has_more' to 'valid' so that it can function whether iterating in a forward or reverse direction. We also rename 'advance' to 'move_to_next' to setup parallel naming with the proposed functions 'move_to_first', 'move_to_last', and 'move_to_previous'.
* Add an "--format=(json|text)" command-line option to both notmuch-search and ↵Scott Robinson2010-02-23
| | | | | | | | | | | | | notmuch-show. In the case of notmuch-show, "--format=json" also implies "--entire-thread" as the thread structure is implicit in the emitted document tree. As a coincidence to the implementation, multipart message ID numbers are now incremented with each part printed. This changes the previous semantics, which were unclear and not necessary related to the actual ordering of the message parts.
* notmuch show: Preserve thread-ordering and nesting without --entire-threadCarl Worth2009-12-02
| | | | | | | | | | | | | | | | | | | | | | | | When "notmuch show" was recently modified to not show an entire thread by default, it also lost all capability to properly order the messages in a thread and to print their proper depth. For example, the command: notmuch show thread:6d5e3e276461188c5778c9f219f63782 had dramatically different output than: notmuch show --entire-thread thread:6d5e3e276461188c5778c9f219f63782 even though both commands were selecting and displaying the same set of messages. The first command would diplay them "flat", (all with depth:0), and in strict date order; while the second command would display them "nested" (with depth based on threading), and in thread order. We now fix "notmuch show" without the --entire-thread option to also display nested and thread-ordered messages. If some messages in the thread are not included in the displayed results, then they are not counted when computing depth values.
* notmuch show: limit display to only matching messagesBart Trojanowski2009-12-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch changes the default behaviour of notmuch show to display only messages that match the search expression. However, --entire-thread option is provided to display all messages in threads that matched the search expression. It is deemed that will be more useful for human users on the command line. Scripts can be modified to include the --entire-thread option so that they can display all messages once more. Example: $ notmuch search subject:git AND thread:23d99d0f364f93e90e15df8b42eddb5b thread:23d99d0f364f93e90e15df8b42eddb5b July 31 [4/12] Johan Herland; [RFCv2 00/12] Foreign VCS helper program for CVS repositories (inbox unread) Note that in this thread 4 out of 12 messages matched. The default show behaviour is to show only those messages that match: $ notmuch show subject:git AND thread:23d99d0f364f93e90e15df8b42eddb5b | grep 'message{' | wc -l 4 With the --entire-thread option the output will contain all dozen messages: $ notmuch show --entire-thread subject:git AND thread:23d99d0f364f93e90e15df8b42eddb5b | grep 'message{' | wc -l 12 Signed-off-by: Bart Trojanowski <bart@jukie.net>
* correct message flag enum value so that it matches the typeBart Trojanowski2009-11-27
| | | | | | | As per Carl's request, this patch corrects the only value defined under the notmuch_message_flag_t enum typedef to match the name of the type. Signed-off-by: Bart Trojanowski <bart@jukie.net>
* notmuch-show: identify which messages printed matched the query stringBart Trojanowski2009-11-27
| | | | | | | | | The show command outputs all messages in the threads that match the search-terms. This patch introduces a 'match:[01]' entry to the 'message{' line output by the show command. Value of 1 indicates that the message is matching the search expression. Signed-off-by: Bart Trojanowski <bart@jukie.net>
* notmuch search: Remove the chunked-searching hack.Carl Worth2009-11-23
| | | | | | | | | | | | | This was a poor workaround around the fact that the existing notmuch_threads_t object is implemented poorly. It's got a fine iterartor-based interface, but the implementation does all of the work up-front in _create rather than doing the work incrementally while iterating. So to start fixing this, first get rid of all the hacks we had working around this. This drops the --first and --max-threads options from the search command, (but hopefully nobody was using them anyway---notmuch.el certainly wasn't).
* notmuch-show: Show message part using UTF-8.Kan-Ru Chen2009-11-22
| | | | | | | Pass the message through the charset filter so that we can view messages wrote in different charset encoding. Signed-off-by: Kan-Ru Chen <kanru@kanru.info>