Commit graph

121 commits

Author SHA1 Message Date
Peter Wang
b96ba6326a show: indicate length, encoding of omitted body content
If a leaf part's body content is omitted, return the encoded length and
transfer encoding in --format=json output.  This information may be used
by the consumer, e.g. to decide whether to download a large attachment
over a slow link.

Returning the _encoded_ content length is more efficient than returning
the _decoded_ content length.  Returning the transfer encoding allows
the consumer to estimate the decoded content length.
2012-12-17 09:10:35 -04:00
Peter Wang
35860e00d1 show: indicate charset for all omitted parts
Write a "charset" field for all omitted parts for which it is applicable,
not only text/html parts. Factor out the code to a separate function.
It will be extended with more fields next.
2012-12-17 09:10:00 -04:00
Austin Clements
aecff2c9fd show: Support --format-version 2012-12-16 17:21:00 -04:00
Peter Feigl
102f58d7a4 Use the S-Expression structured printer in notmuch-show, notmuch-reply and notmuch-search.
This patch uses the new S-Expression printer in the notmuch CLI (show,
search and reply). You can now use --format=sexp for any of them.
2012-12-08 09:30:19 -04:00
Peter Feigl
1bf3720b6e Rename the -json printer functions in notmuch-reply and notmuch-show to generic -sprinter functions.
All the structured output functions in notmuch-reply and notmuch-show
are renamed to a generic name (as they do not contain any json-specific
code anyway). This patch is a preparation to actually using the new
S-Expression sprinter in notmuch-reply and notmuch-show.
2012-12-08 09:28:19 -04:00
Austin Clements
a437031a3c show: More aggressively document the presence of devel/schemata
Previously, the only mention of devel/schemata was a comment at the
top of format_part_json, but the JSON output code is spread across
several functions that are distributed across notmuch-show.c.  Add
references from the other three key JSON output functions.
2012-11-08 09:49:41 -04:00
Peter Wang
7d3c06dcbe show: include Reply-To header in json output
Output the Reply-To header field if present in a message.
I want to be able to see what the sender intended in my mail client,
before hitting the reply key.  Only json output is changed,
like the recently added Bcc field.
2012-11-07 08:03:45 -04:00
Michal Nazarewicz
ffb629cc5d notmuch-show: include Bcc header in json output
With this change, emacs users can use notmuch-message-headers
variable to configure notmuch-show display Bcc header.
2012-10-22 20:06:21 -03:00
Austin Clements
1cbaad158e show: Remove now unused fields from notmuch_show_format
The message_set_{begin,sep,end} and null_message fields are no longer
used because we now use the structure printer provided by the format.
2012-08-03 20:40:01 -03:00
Austin Clements
e41417d7b4 show: Convert do_show to use sprinter 2012-08-03 20:37:50 -03:00
Austin Clements
305a7ade1e show: Convert show_message to use sprinter
Unlike the previous patches, this function is used for all formats.
However, for formats other than the JSON format, the sprinter methods
used by show_message are all no-ops, so this code continues to
function correctly for all of the formats.

Converting show_message eliminates show_null_message in the process,
since this maps directly to an sprinter method.
2012-08-03 20:37:20 -03:00
Austin Clements
26ba4abe53 show: Convert envelope format_part_json to use sprinter 2012-08-03 20:32:31 -03:00
Austin Clements
6da306b40a show: Convert non-envelope format_part_json to use sprinter 2012-08-03 20:31:40 -03:00
Austin Clements
85b326f13c show: Convert format_part_sigstatus_json to use sprinter 2012-08-03 20:31:03 -03:00
Austin Clements
7018fc58b4 show: Convert format_headers_json to use sprinter
This no longer requires a talloc context (not that it really did
before since it didn't return anything), so we remove its context
argument.
2012-08-03 20:30:49 -03:00
Austin Clements
3a08341e50 show: Feed the sprinter down to part formatters
There are several levels of function calls between where we create the
sprinter and the call to the part formatter in show_message. This
feeds the sprinter through all of them and into the part formatters.
2012-08-03 20:27:25 -03:00
Austin Clements
d79b24b98d show: Associate an sprinter with each format
This associates an sprinter constructor with each show format and uses
this to construct the appropriate sprinter.  Currently nothing is done
with this sprinter, but the following patches will weave it through
the layers of notmuch show.
2012-08-03 20:21:50 -03:00
Mark Walters
0e63372efe cli: add --body=true|false option to notmuch-show.c
This option allows the caller to suppress the output of the bodies of
the messages. Currently this is only implemented for format=json.

This is used by notmuch-pick.el (although not needed) because it gives
a speed-up of at least a factor of a two (and in some cases a speed up
of more than a factor of 8); moreover it reduces the memory usage in
emacs hugely.
2012-07-24 15:29:22 -03:00
Mark Walters
eff5f9126f cli: notmuch-show.c fix whitespace error
Fix an existing whitespace error since it is right next to
the changes of this series.
2012-06-29 22:33:50 -03:00
Mark Walters
15904cde12 cli: make --entire-thread=false work for format=json.
The --entire-thread option in notmuch-show.c defaults to true when
format=json. Previously there was no way to turn this off. This patch
makes it respect --entire-thread=false.

To do this the patch moves the --entire-thread option to be a keyword
option using the new command line parsing to allow the existing
--entire-thread to keep working.
2012-06-29 22:32:16 -03:00
Mark Walters
4d3bfba983 cli: Let json output "null" messages for non --entire-thread
All formats except Json can output empty messages for non
entire-thread, but in Json format we output "null" to keep the other
elements (e.g. the replies to the omitted message) in the correct
place.
2012-06-29 22:31:53 -03:00
Jameson Graef Rollins
e04b18cf36 cli: use new notmuch_crypto_get_context in mime-node.c
This has the affect of lazily creating the crypto contexts only when
needed.  This removes code duplication from notmuch-show and
notmuch-reply, and should speed up these functions considerably if the
crypto flags are provided but the messages don't have any
cryptographic parts.
2012-06-10 20:09:42 -03:00
Jameson Graef Rollins
b2c8fdee53 cli: new crypto verify flag to handle verification
Use this flag rather than depend on the existence of an initialized
gpgctx, to determine whether we should verify a multipart/signed.  We
will be moving to create the ctx lazily, so we don't want to depend on
it being previously initialized if it's not needed.
2012-06-10 20:09:09 -03:00
Jameson Graef Rollins
429ebf5d20 cli: modify mime_node_open to take new crypto struct as argument
This simplifies the interface considerably.
2012-06-10 20:06:48 -03:00
Jameson Graef Rollins
c3eba1c3f8 cli: modify show and reply to use new crypto struct
notmuch_show_params_t is modified to use the new notmuch_crypto_t, and
notmuch-show and notmuch-reply are modified accordingly.
2012-06-10 20:05:12 -03:00
Austin Clements
5fddc07dc3 lib/cli: Make notmuch_database_open return a status code
It has been a long-standing issue that notmuch_database_open doesn't
return any indication of why it failed.  This patch changes its
prototype to return a notmuch_status_t and set an out-argument to the
database itself, like other functions that return both a status and an
object.

In the interest of atomicity, this also updates every use in the CLI
so that notmuch still compiles.  Since this patch does not update the
bindings, the Python bindings test fails.
2012-05-05 10:11:57 -03:00
Justus Winter
6f7469f547 Use notmuch_database_destroy instead of notmuch_database_close
Adapt the notmuch binaries source to the notmuch_database_close split.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-04-28 09:27:33 -03:00
Austin Clements
2886af551e show: Remove empty message_set_{start,sep,end} fields
Setting these to NULL is equivalent to the empty string now.
2012-04-15 09:42:15 -03:00
Austin Clements
67da35222c show: Support NULL values for message_set_{start, sep, end}
Many formats don't need these, so it's more convenient if they don't
have to set them at all.
2012-04-15 09:42:15 -03:00
Austin Clements
b92f15d014 show: Remove support for old-style formatters in show_message
show_message used to have a compatibility path for old-style
formatters.  This removes that.
2012-04-15 09:42:15 -03:00
Mark Walters
903327279c cli: move show to the new --exclude= option naming scheme.
This moves notmuch show to the --exclude=(true|false) naming
scheme. When exclude=false show returns all threads that match
including those that only match in an excluded message. The excluded
messages are flagged.

When exclude=true the behaviour depends on whether --entire-thread is
set. If it is not set then show only returns the messages which match
and are not excluded. If it is set then show returns all messages in
the threads that match in a non-excluded message, flagging the excluded
messages in these threads. The rationale is that it is awkward to use
a thread with some missing messages.
2012-04-07 23:05:56 -03:00
Austin Clements
ea4fd50f45 show/reply: Unify the code that extracts text parts
Previously, show and reply had separate implementations of decoding
and printing text parts.  Now both use show's implementation, which
was more complete.  Show's implementation has been extended with an
option to add reply quoting to the extracted part (this is implemented
as a named flag to avoid naked booleans, even though it's the only
flag it can take).
2012-03-31 08:17:20 -03:00
Adam Wolfe Gordon
1904b01b96 reply: Add a JSON reply format.
This new JSON format for replies includes headers generated for a
reply message as well as the headers of the original message.  Using
this data, a client can intelligently create a reply. For example, the
emacs client will be able to create replies with quoted HTML parts by
parsing the HTML parts.
2012-03-19 21:53:53 -03:00
Austin Clements
b1130bc71c show: Convert raw format to the new self-recursive style, properly support interior parts
This is fully compatible for root and leaf parts, but now has proper
support for interior parts.  This requires some design decisions that
were guided by what I would want if I were to save a part.
Specifically:

- Leaf parts are printed without headers and with transfer decoding.
  This is what makes sense for saving attachments.  (Furthermore, the
  transfer decoding is necessary since, without the headers, the
  caller would not be able to interpret non-transfer-decoded output.)

- Message parts are printed with their message headers, but without
  enclosing part headers.  This is what makes sense for saving a
  message as a whole (which is a message part) and for saving attached
  messages.  This is symmetric for whole messages and for attached
  messages, though we special-case the whole message for performance
  reasons (and corner-case correctness reasons: given malformed input,
  GMime may not be able to reproduce it from the parsed
  representation).

- Multipart parts are printed with their headers and all child parts.
  It's not clear what the best thing to do for multipart is, but this
  was the most natural to implement and can be justified because such
  parts can't be interpreted without their headers.

As an added benefit, we can move the special-case code for part 0 into
the raw formatter.
2012-03-18 09:14:22 -03:00
Austin Clements
7e1742a82c show: Move format_part_content_raw with the other new-style formats
Just code motion.
2012-03-18 09:14:21 -03:00
Austin Clements
d431239353 show: Convert mbox format to new self-recursive style
Given the lack of recursion, this is pretty easy.
2012-03-18 09:14:21 -03:00
Austin Clements
8d01b0749c show: Move format_message_mbox with the other new-style formats
Just code motion.
2012-03-18 09:14:21 -03:00
Austin Clements
6a4df1b796 show: Allow formatters to return errors
Formatter errors are propagated to the exit status of notmuch show.

This isn't used by the JSON or text formatters, but it will be useful
for the raw format, which is pickier.
2012-03-18 09:14:21 -03:00
Mark Walters
7a1beb9e7c cli: omit excluded messages in results where appropriate.
In all cases of notmuch count/search/show where the results returned
cannot reflect the exclude flag return just the matched not-excluded
results. If the caller wishes to have all the matched results (i.e.,
including the excluded ones) they should call with the
--no-exclude option.

The relevant cases are
    count: both threads and messages
    search: all cases except the summary view
    show: mbox format
2012-03-02 08:37:32 -04:00
Mark Walters
ebe5e6712a cli: Make notmuch-show respect excludes.
This adds the excludes to notmuch-show.c. We do not exclude when only
a single message (or part) is requested. notmuch-show will output the
exclude information when either text or json format is requested. As
this changes the output from notmuch-show it breaks many tests (in a
trivial and expected fashion).
2012-03-02 08:34:36 -04:00
Austin Clements
4fa77d0318 show: Further general simplifications of the JSON formatter 2012-03-01 08:32:58 -04:00
Austin Clements
99789e77f2 show: Make format_part_sigstatus_json's API consistent between GMIME 2.4 and 2.6
The implementation is still different for GMIME 2.4 and 2.6, but at
least now the caller doesn't have to be aware of this.
2012-03-01 08:32:34 -04:00
Austin Clements
1f0ead385a show: Make JSON helper functions print complete objects
This makes the main recursive function easier to follow because helper
functions don't add fields to the running object.
2012-03-01 08:32:12 -04:00
Austin Clements
63ee244c8e show: Simplify talloc use in format_headers_json
Previously there was an unnecessary talloc context.
2012-03-01 08:31:11 -04:00
Austin Clements
86f89385c3 show: Unify JSON header output for messages and message parts
This has three ramifications:
- Blank To and Cc headers are no longer output for messages.
- Dates are now canonicalized for messages, which means they always
  have a day of the week and GMT is printed +0000 (never -0000)
- Invalid From message headers are handled slightly differently, since
  they get parsed by GMime now instead of notmuch.
2012-03-01 08:28:13 -04:00
Austin Clements
2209d7b952 show: Use consistent header ordering in the JSON format
Previously, top-level message headers were printed as Subject, From,
To, Date, while embedded message headers were printed From, To,
Subject, Date.  This makes both cases use the former order and updates
the tests accordingly.
2012-03-01 08:28:02 -04:00
Austin Clements
44d9656cbf show: Convert JSON format to the new self-recursive style
As before, this is all code movement and a smidgen of glue.  This
moves the existing JSON formatter code into one self-recursive
function, but doesn't change any of the logic to take advantage of the
new structure.

In general, "leafs" of the JSON structure are left in helper functions
(most of them untouched), so that it's easy to see the overall
structure of the format from the main recursive function.
2012-03-01 08:27:25 -04:00
Austin Clements
661c357123 Document the JSON schemata used by show and search 2012-02-27 22:32:49 -04:00
Jani Nikula
2c8959dad8 cli: reach previously unreachable cleanup code in "notmuch show"
The last lines of notmuch_show_command() function were
unreachable. Fix it by using a variable for return value.

Signed-off-by: Jani Nikula <jani@nikula.org>
2012-02-12 11:58:20 -05:00
Jani Nikula
2d09775baf cli: convert "notmuch show" to use the new argument parser
Use the new notmuch argument parser to handle arguments in "notmuch
show". There are three minor functional changes:

1) Also set params.raw = TRUE when defaulting to raw format when part
   is requested but format is not specified. This was a bug, and
   --part=0 without --format=raw did not work previously.

2) Set params.decrypt = FALSE if crypto context creation fails.

3) Only use the parameters for the last --format if specified multiple
   times. Previously this could have resulted in a non-working mixture
   of parameters.

Signed-off-by: Jani Nikula <jani@nikula.org>
2012-02-12 11:58:20 -05:00