Commit graph

23 commits

Author SHA1 Message Date
Austin Clements
d61cef374b show: Rewrite show_message_body to use the MIME tree interface.
This removes all of the MIME traversal logic from show_message_body
and leaves only its interaction with the format callbacks.

Besides isolating concerns, since traversal happens behind a trivial
interface, there is now much less code duplication in
show_message_part.  Also, this uses mime_node_seek_dfs to start at the
requested part, eliminating all of the logic about parts being
selected or being in_zone (and reducing the "show state" to only a
part counter).  notmuch_show_params_t no longer needs to be passed
through the recursion because the only two fields that mattered
(related to crypto) are now handled by the MIME tree.

The few remaining complexities in show_message_part highlight
irregularities in the format callbacks with respect to top-level
messages and embedded message parts.

Since this is a rewrite, the diff is not very enlightening.  It's
easier to look at the old code and the new code side-by-side.
2011-12-25 22:23:15 -04:00
Austin Clements
36f7fe5a1c show: Pass notmuch_message_t instead of path to show_message_body.
In addition to simplifying the code, we'll need the notmuch_message_t*
in show_message_body shortly.
2011-12-25 22:17:27 -04:00
Jameson Graef Rollins
12de016686 Improve handling of message/rfc822 parts by adding a new header_message_part 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).
2011-09-05 22:58:52 -03:00
Jameson Graef Rollins
82daf29187 Render all parts of multipart/encrypted when decrypting.
The primary goal here is to keep the decrypted output as similarly
structured as undecrypted output as possible.  Now, when decrypting
parts, only the original encrypted part is replaced by the it's
decrypted content.  If this part isn't itself a multipart, then all
part numbering should remain consistent during decryption.

The only draw back here is that the useless application/pgp-encrypted
sub-part of the multipart/encrypted part is also emitted.  But this
part can be easily ignored by clients.
2011-05-27 16:22:00 -07:00
Jameson Graef Rollins
5404519749 Do not replace multipart/signed part with content part when doing verification.
Some folks have complained about the part renumbering that occurs when
the entire multipart/signed part is replaced with the part contents
after verification.  This is primarily because it incurs an additional
computational cost to retrieve individual parts, since verification
has to be performed again to ensure that part numbering is consistent.
This patch simply leaves the full multipart/signed part as is.

The emacs crypto test is also updated to reflect this change.
2011-05-27 16:22:00 -07:00
Jameson Graef Rollins
2e653db38f Add decryption of PGP/MIME-encrypted parts with --decrypt.
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.
2011-05-27 16:22:00 -07:00
Jameson Graef Rollins
8b18efe171 Add signature verification of PGP/MIME-signed parts with --verify.
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.
2011-05-27 16:22:00 -07:00
Jameson Graef Rollins
d92146d3a6 Break up format->part function into part_start and part_content functions.
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.
2011-05-27 16:18:57 -07:00
Jameson Graef Rollins
757e06f74b Use empty strings instead of NULL in format_reply structure.
This keeps things consistent with notmuch-show, and prevents having to
check for the existence of the field pointer for simple string output
formats.
2011-05-27 16:18:57 -07:00
Carl Worth
b825bce61d notmuch reply: Avoid segmentation fault when printing multiple parts
The code was previously trying to print a NULL string in this case, which
is obviously what we don't want to do.
2011-05-24 12:19:18 -07:00
Jameson Graef Rollins
2f8871df6e New part output handling as option to notmuch-show.
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.
2011-05-23 15:31:32 -07:00
Jameson Graef Rollins
ecae541031 Normalize part counting and formatting in show_message_part function.
Simplify the function by moving part counting and formatting outside
of conditionals, thereby eliminating redundant code.  This also wraps
message part output handling with proper part formatting.
2011-05-23 15:30:26 -07:00
Jameson Graef Rollins
6c2417cabc add part_sep formatter to replace "first" argument to part format functions
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.
2011-05-23 14:55:27 -07:00
Carl Worth
02ec2e420c notmuch part: Fix part numbering to match what's reported by "notmuch show"
Since commit c51d5b3cdb we are counting
multipart containers when emitting part numbers in the "notmuch show"
output. Unfortunately, "notmuch part" wasn't updated with the same
numbering, (and the test suite is inadequate to catch this).

Fix this by adding a similar part-numbering change to "notmuch part" here.
2011-05-23 14:27:23 -07:00
Jameson Graef Rollins
dcdb843094 pass entire format structure to various show_message functions
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.
2011-05-20 12:27:35 -07:00
Carl Worth
362ab047c2 notmuch show: Properly nest MIME parts within mulipart parts
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.
2011-05-17 15:58:57 -07:00
Carl Worth
c51d5b3cdb notmuch show: Include output for the enclosing multipart part of a MIME mail
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).
2011-05-17 14:51:06 -07:00
David Edmondson
2e9c7aba99 notmuch: Add a 'part' subcommand
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.
2010-04-02 09:43:03 +01:00
Scott Robinson
6ce2bf68f5 Add an "--format=(json|text)" command-line option to both notmuch-search and 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.
2010-02-23 12:01:12 -08:00
Carl Worth
67bad3483f notmuch show: Don't hide a digital signature.
This was a bug that was introduced in copying the indexing code over
into notmuch-show.c. When indexing, we want to ignore the signature,
(it has no interesting terms). But when presenting the message, it's
important to present the signature to the user.

(And would be even better if we presented whether or not the signature
is good.)
2009-11-21 01:00:41 +01:00
Ingmar Vanhassel
2ce25b93a7 Typsos 2009-11-18 03:21:36 -08:00
Carl Worth
a9f3ad4fcb notmuch reply: Use GMime to construct the header for the reply.
The advantage here is that we actually get the necessary folding of
long headers, (particularly the References header, but also things
like Subject). This also gives us parsed recipient addresses so that
we can easily elide the sender's address(es) from the recipient list
(just as soon as we have a configured value for the recipient's
address(es)).
2009-11-11 10:54:12 -08:00
Keith Packard
357aba3ec8 notmuch reply: Add (incomplete) reply command
Reviewed-by: Carl Worth <cworth@cworth.org>

Keith wrote all the code here against notmuch before notmuch.c was
split up into multiple files. So I've pushed the code around in
various ways to match the new code structure, but have generally tried
to avoid making any changes to the behavior of the code.

I did fix one bug---a missing call to g_mime_stream_file_set_owner in
show_part which would cause "notmuch show" to go off into the weeds
when trying to show multiple messages, (since the first stream would
fclose stdout).
2009-11-10 13:32:02 -08:00