Commit graph

107 commits

Author SHA1 Message Date
Jani Nikula
1abc338331 cli: content disposition values are not case-sensitive
Per RFC 2183, the values for Content-Disposition values are not
case-sensitive. While at it, use the gmime function for getting at the
disposition string instead of referencing the field directly.

This fixes attachment display and quoting in notmuch show and reply,
respectively.
2015-11-19 07:47:29 -04:00
David Bremner
e7b420a854 cli: update to use new count API
Essentially replace each call to notmuch_count_* with the corresponding
_st call, followed by print_status_query.
2015-10-05 19:51:08 -03:00
David Bremner
6cdd34a4c7 cli: convert remainder of CLI to n_q_search_{messages,threads}_st
I think it would be no real problem to cut and paste the gdb based
error message test from count to the other clients modified here, but
I'm not currently convinced it's worth the trouble since the code path
being tested is almost the the same, and the tests are relatively
heavyweight.
2015-09-23 08:03:34 -03:00
David Bremner
f76d8f82dd cli: add global option "--uuid"
The function notmuch_exit_if_unmatched_db_uuid is split from
notmuch_process_shared_options because it needs an open notmuch
database.

There are two exceptional cases in uuid handling.

1) notmuch config and notmuch setup don't currently open the database,
   so it doesn't make sense to check the UUID.

2) notmuch compact opens the database inside the library, so we either
   need to open the database just to check uuid, or change the API.
2015-08-14 18:23:49 +02:00
David Bremner
0018a8d787 cli: define shared options, use for --help and --version
Unfortunately it seems trickier to support --config globally

The non-trivial changes are in notmuch.c; most of the other changes
consists of blindly inserting two lines into every subcommand.
2015-06-01 07:32:54 +02:00
David Bremner
c883e632bf CLI: make gpg binary used by libgmime configurable.
Previously we set up a way for the top level notmuch command to choose
which gpg binary was invoked by libgmime. In this commit we add the
(mostly boilerplate) code to allow the notmuch-config command to read
and write this path, and use it in the appropriate struct.

Update tests for new default variable
2015-03-11 08:04:00 +01:00
David Bremner
21ecd7369a CLI: set up infrastructure to make path to gpg configurable.
GMIME takes a path to gpg, but we hardcode that path.  In this commit
we set up argument passing and option storage to allow this path to
specified in the top level notmuch command.
2015-03-09 08:19:28 +01:00
Jani Nikula
31a6333aa4 cli: sanitize the received header before scanning for replies
This makes the from guessing agnostic to header folding by spaces or
tabs.
2014-03-25 21:22:03 -03:00
Jani Nikula
998a8a95c3 cli: refactor reply from guessing
The guess_from_received_header() function had grown quite big. Chop it
up into smaller functions.

No functional changes.
2014-03-09 10:13:17 -03:00
Jani Nikula
c745377306 cli: clean up exit status code returned by the cli commands
Apart from the status codes for format mismatches, the non-zero exit
status codes have been arbitrary. Make the cli consistently return
either EXIT_SUCCESS or EXIT_FAILURE.
2014-01-18 14:45:26 -04:00
John Lenz
f735a85c28 cli: add --include-html option to notmuch show
For my client, the largest bottleneck for displaying large threads is
exporting each html part individually since by default notmuch will not
show the json parts.  For large threads there can be quite a few parts and
each must be exported and decoded one by one.  Also, I then have to deal
with all the crazy charsets which I can do through a library but is a
pain.

Therefore, this patch adds an --include-html option that causes the
text/html parts to be included as part of the output of show.

diff man/man1/notmuch-show.1
2013-08-27 07:57:36 -03:00
Austin Clements
dc51bf0ad4 reply: Use RFC 2822/MIME wholly for text format template
Previously, reply's default text format used an odd mix of RFC 2045
MIME encoding for the reply template's body and some made-up RFC
2822-like UTF-8 format for the headers.  The intent was to present the
headers to the user in a nice, un-encoded format, but this assumed
that whatever ultimately sent the email would RFC 2047-encode the
headers, while at the same time the body was already RFC 2045 encoded,
so it assumed that whatever sent the email would *not* re-encode the
body.

This can be fixed by either producing a fully decoded UTF-8 reply
template, or a fully encoded MIME-compliant RFC 2822 message.  This
patch does the latter because it is

a) Well-defined by RFC 2822 and MIME (while any UTF-8 format would be
   ad hoc).

b) Ready to be piped to sendmail.  The point of the text format is to
   be minimal, so a user should be able to pop up the template in
   whatever editor they want, edit it, and push it to sendmail.

c) Consistent with frontend capabilities.  If a frontend has the
   smarts to RFC 2047 encode the headers before sending the mail, it
   probably has the smarts to RFC 2047 decode them before presenting
   the template to a user for editing.

Also, as far as I know, nothing automated consumes the reply text
format, so changing this should not cause serious problems.  (And if
anything does still consume this format, it probably gets these
encoding issues wrong anyway.)
2013-08-17 09:06:08 +02:00
Austin Clements
6cdab6e0b7 reply: Remove extraneous space from generated References
Previously, the References header code seemed to assume
notmuch_message_get_header would return NULL if the header was not
present, but it actually returns "".  As a result of this, it was
inserting an unnecessary space when concatenating an empty or missing
original references header with the new reference.

This shows up in only two tests because the text reply format later
passes the whole reply template through g_mime_filter_headers, which
has the side effect of stripping out this extra space.
2013-08-17 09:05:44 +02:00
Austin Clements
013d11c9f7 reply: Document the reason for g_mime_filter_headers
Given how long it took me to figure out why we pass the reply headers
through g_mime_filter_headers, it's worth a comment.
2013-08-13 17:44:08 +02:00
Jani Nikula
4ef2106792 cli: move config open/close to main() from subcommands
This allows specifying config file as a top level argument to notmuch,
and generally makes it possible to override config file options in
main(), without having to touch the subcommands.

If the config file does not exist, one will be created for the notmuch
main command and setup and help subcommands. Help is special in this
regard; the config is created just to avoid errors about missing
config, but it will not be saved.

This also makes notmuch config the talloc context for subcommands.
2013-03-08 07:54:41 -04:00
Jani Nikula
e76f6517de cli: config: make notmuch_config_open() "is new" parameter input only
We now have a notmuch_config_is_new() function to query whether a
config was created or not. Change the notmuch_config_open() is_new
parameter into boolean create_new to determine whether the function
should create a new config if one doesn't exist. This reduces the
complexity of the API.
2013-03-07 09:39:12 -04:00
Austin Clements
f6adf6615c reply: Support --format-version 2012-12-16 17:21:32 -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
e0d97a639c reply: Convert JSON format to use sprinter
Almost all of reply was already being formatted using the sprinter.
This patch converts the top-level dictionary to use the sprinter
interface.
2012-08-12 21:29:38 +02: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
7b2c4481f1 reply: Create a JSON sprinter 2012-08-03 20:24:07 -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
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
Jani Nikula
22a18fc921 cli: also use Delivered-To header to figure out the reply from address
Add another fallback header Delivered-To for guessing the user's from
address for notmuch reply before using the Received
headers. Apparently some MTAs use Delivered-To instead of
X-Original-To (which already exists as a fallback).

Reported-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Signed-off-by: Jani Nikula <jani@nikula.org>
2012-05-24 21:56:21 -03:00
Jani Nikula
4c526fe351 cli: clean up user address matching code in guess_from_received_header()
Get rid of user address matching code duplication in
guess_from_received_header() by using the new address matching
helpers.

No functional changes.

Signed-off-by: Jani Nikula <jani@nikula.org>
2012-05-23 22:47:51 -03:00
Jani Nikula
e03ed64c8f cli: add user address matching helpers for notmuch reply
Add a multi-purpose address_match() function for matching strings
against user's configured primary and other email addresses. Add thin
wrappers user_address_in_string() and string_in_user_address() for
ease of use, and also convert existing address_is_users() to wrapper
for the same.

No functional changes.

Signed-off-by: Jani Nikula <jani@nikula.org>
2012-05-23 22:47:51 -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
4ba18958b5 reply: Move reply citation printing to the recursive MIME walk
This makes more logical sense, since it makes the recursive printer
responsible for the entire reply body and lets it start at the root of
the MIME tree instead of the first child.  (We could move reply header
creation in there, too, but if we ever support proper reply to
multiple messages, we'll want just one set of reply headers computed
from the entire message set and many bodies.)
2012-03-31 08:17:55 -03:00
Austin Clements
4d322fb579 reply: Convert default reply format to self-recursive style
This re-arranges the default reply formatter code to use the
mime_node_t abstraction.  There are no semantic changes.
2012-03-31 08:17:41 -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
Adam Wolfe Gordon
766aebc02c reply: Factor out reply creation
Factor out the creation of a reply message based on an original
message so it can be shared by different reply formats.
2012-03-19 21:52:54 -03:00
Jani Nikula
c9c5a6f70c cli: use notmuch_bool_t for boolean fields in notmuch_show_params_t
Use notmuch_bool_t instead of int for entire_thread, raw, and decrypt
boolean fields in notmuch_show_params_t. No functional changes.

Signed-off-by: Jani Nikula <jani@nikula.org>
2012-02-12 11:58:20 -05:00
Austin Clements
7430a42e23 show: Introduce mime_node formatter callback
This callback is the gateway to the new mime_node_t-based formatters.
This maintains backwards compatibility so the formatters can be
transitioned one at a time.  Once all formatters are converted, the
formatter structure can be reduced to only message_set_{start,sep,end}
and part, most of show_message can be deleted, and all of
show-message.c can be deleted.
2012-01-25 07:21:40 -04:00
Thomas Jost
00b5623d1a Add compatibility with gmime 2.6
There are lots of API changes in gmime 2.6 crypto handling. By adding
preprocessor directives, it is however possible to add gmime 2.6 compatibility
while preserving compatibility with gmime 2.4 too.

This is mostly based on id:"8762i8hrb9.fsf@bookbinder.fernseed.info".

This was tested against both gmime 2.6.4 and 2.4.31. With gmime 2.4.31, the
crypto tests all work fine (as expected). With gmime 2.6.4, one crypto test is
currently broken (signature verification with signer key unavailable), most
likely because of a bug in gmime which will hopefully be fixed in a future
version.
2012-01-21 08:52:34 -04:00
Jani Nikula
982096d79d cli: pick the user's address in a group list as from address
Messages received to a group list were not replied to using the from
address in the list. Fix it.

Signed-off-by: Jani Nikula <jani@nikula.org>
2012-01-16 21:06:34 -04:00
Jani Nikula
0f8148e920 cli: add support for replying just to the sender in "notmuch reply"
Add new option --reply-to=(all|sender) to "notmuch reply" to select whether
to reply to all (sender and all recipients), or just sender. Reply to all
remains the default.

Credits to Mark Walters <markwalters1009@gmail.com> for his similar earlier
work where I picked up the basic idea of handling reply-to-sender in
add_recipients_from_message(). All bugs are mine, though.

Signed-off-by: Jani Nikula <jani@nikula.org>
2012-01-14 11:10:28 -04:00
Jani Nikula
fb1c016cb5 cli: slightly refactor "notmuch reply" address scanning functions
Slightly refactor "notmuch reply" recipient and user from address scanning
functions in preparation for reply-to-sender feature.

Add support for not adding recipients at all (just scan for user from
address), and returning the number of recipients added.

No externally visible functional changes.

Signed-off-by: Jani Nikula <jani@nikula.org>
2012-01-14 11:10:17 -04:00
Jani Nikula
2d1385e141 cli: convert "notmuch reply" to use the new argument parser
Use the new notmuch argument parser to handle arguments in "notmuch
reply". There should be no functional changes.

Signed-off-by: Jani Nikula <jani@nikula.org>
2012-01-09 06:45:02 -04:00
Jani Nikula
230c2ed357 cli: fix use of uninitialized variable in "notmuch reply"
notmuch_show_params_t params is only initialized partially in
notmuch_reply_command(). The only field that is used uninitialized is
params.decrypt. It is usually non-zero, making "notmuch reply" on encrypted
messages work by coincidence.

Initialize params properly, and set params.decrypt as needed.

Signed-off-by: Jani Nikula <jani@nikula.org>
2012-01-09 06:44:47 -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
David Bremner
61f0a5b8ee cli: change argument parsing convention for subcommands
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].
2011-10-22 19:42:54 -03:00
Jameson Graef Rollins
fbe3c38655 Ignore "application/pgp-*" parts in reply.
The quoted text doesn't need to mention that the message being replied
to had these crufty parts.
2011-10-06 10:13:51 -03:00
Jameson Graef Rollins
c75410fd81 Fix notmuch-reply to not output "Non-text part:" lines for non-leafnode parts.
These lines are just cruft in this case, and can be removed.
2011-10-06 10:12:48 -03:00