Commit graph

173 commits

Author SHA1 Message Date
Jani Nikula
9a0df8128c cli: use notmuch_bool_t for boolean argument in show
Pedantically correct, although they're the same underlying type.
2017-10-04 22:02:57 -03:00
Jani Nikula
ed43b8ddcd cli: use the arg parser .present feature to handle show --entire-thread
The --entire-thread default depends on other arguments, so we'll have
to figure out if it was explicitly set by the user or not. The arg
parser .present feature helps us clean up the code here.
2017-10-04 22:02:09 -03:00
Jani Nikula
4a6721970a cli: use designated initializers for opt desc
Several changes at once, just to not have to change the same lines
several times over:

- Use designated initializers to initialize opt desc arrays.

- Only initialize the needed fields.

- Remove arg_id (short options) as unused.

- Replace opt_type and output_var with several type safe output
  variables, where the output variable being non-NULL determines the
  type. Introduce checks to ensure only one is set. The downside is
  some waste of const space per argument; this could be saved by
  retaining opt_type and using a union, but that's still pretty
  verbose.

- Fix some variables due to the type safety. Mostly a good thing, but
  leads to some enums being changed to ints. This is pedantically
  correct, but somewhat annoying. We could also cast, but that defeats
  the purpose a bit.

- Terminate the opt desc arrays using {}.

The output variable type safety and the ability to add new fields for
just some output types or arguments are the big wins. For example, if
we wanted to add a variable to set when the argument is present, we
could do so for just the arguments that need it.

Beauty is in the eye of the beholder, but I think this looks nice when
defining the arguments, and reduces some of the verbosity we have
there.
2017-10-04 22:00:42 -03:00
Daniel Kahn Gillmor
23eed88e32 remove boolean "first" argument from format_part_sprinter
This argument seems to be unused, and format_part_sprinter isn't
required to meet any specific API so it seems cleaner and simpler to
drop it.
2017-08-16 21:56:58 -03:00
Daniel Kahn Gillmor
e142de643d config: deprecate/drop crypto.gpg_path under gmime 2.6/3.0
gmime 3.0 no longer offers a means to set the path for gpg.

Users can set $PATH anyway if they want to pick a
differently-installed gpg (e.g. /usr/local/bin/gpg), so this isn't
much of a reduction in functionality.

The one main difference is for people who have tried to use "gpg2" to
make use of gpg 2.1, but that isn't usefully co-installable anyway.
2017-07-14 21:23:52 -03:00
David Bremner
cd853915ec cli: wrap getting uid
Apparently it moved from "name" to "key_id" in gmime-3.0
2017-07-14 21:23:52 -03:00
David Bremner
2b3224a6c4 cli: make keyid from fingerprint in gmime 3.0
The "key_id" field seems to used for userid in gmime-3.0, while the
keyid is dropped in the fingerprint field if the full fingerprint is
not available.
2017-07-14 21:23:52 -03:00
David Bremner
c7b9bdb81e cli: generalize use of GMIME_SIGNATURE_{ERROR,STATUS} to gmime-3
The ERROR enum is merged into to the STATUS enum, and the set of flags
is different.
2017-07-14 21:23:52 -03:00
David Bremner
32819f74d3 cli: replace use of g_mime_message_get_recipients
This function, and associated enum, have been renamed and generalized
in gmime-3.0.
2017-07-14 17:58:09 -03:00
David Bremner
cbb2d5608e lib/cli: replace use of g_mime_message_get_sender
This function changes semantics in gmime-3.0 so make a new function
that provides the same functionality in both
2017-07-14 17:58:09 -03:00
David Bremner
d7fea36916 cli: replace use of g_mime_message_get_reply_to
This function changes signature in gmime 3.0, so we provide two new
functions, one for each signature.
2017-07-14 17:58:09 -03:00
David Bremner
67dbd24ece cli: replace use of g_mime_message_get_date_as_string
This function goes away in gmime-3.0. Also, the memory management is
apparently error prone, witness the memory leak in notmuch-reply.
2017-07-14 17:58:09 -03:00
David Bremner
15815d4e4c cli/show: convert keyword options to booleans
There are two keyword options here that impliment boolean options. It
is simpler to use the built-in boolean argument handling, and also
more robust against divergence in parsing boolean and keyword arguments.
2017-07-12 17:42:23 -03:00
David Bremner
e1b7d32db0 cli: implement structured output version 4
Since the error field is unused by the emacs front end, no changes are
needed other than bumping the format version number.

As it is, this is a bit overengineered, but it will reduce duplication
when we support gmime 3.0
2017-07-04 08:32:44 -03:00
Piotr Trojanek
85c8304058 fix wrong printf formatting of signed/unsigned integers 2017-06-25 09:39:35 -03:00
David Bremner
331310c4ba cli/show: use single stream for printf / gmime object output
This is again motivated by the need to transition away from
GMimeStreamFile for output to stdout.

format_part_mbox is left alone for now, as this cannot be mixed in
with output using gmime object output.
2017-05-30 09:02:07 -03:00
David Bremner
242d5a3ed5 lib: make notmuch_query_add_tag_exclude return a status value
Since this is an ABI breaking change, but we already bumped the SONAME
for the next release
2017-03-22 08:47:13 -03:00
David Bremner
5ce8e0b11b lib: replace deprecated n_q_count_messages with status returning version
This function was deprecated in notmuch 0.21.  We re-use the name for
a status returning version, and deprecate the _st name. One or two
remaining uses of the (removed) non-status returning version fixed at
the same time
2017-03-22 08:35:07 -03:00
David Bremner
86cbd215eb lib: replace deprecated n_q_search_messages with status returning version
This function was deprecated in notmuch 0.21.  We re-use the name for
a status returning version, and deprecate the _st name.
2017-03-22 08:35:07 -03:00
David Bremner
1e982de508 lib: replace n_query_search_threads with status returning version
This function was deprecated in notmuch 0.21. We finally remove the
deprecated API, and rename the status returning version to the simpler
name. The status returning is kept as a deprecated alias.
2017-03-22 08:28:09 -03:00
David Bremner
a8a2705222 Merge branch 'release'
Merge in memory fixes
2017-03-18 21:02:42 -03:00
David Bremner
eafa8c62b3 cli/show: unref crlf filter.
Mimic the handling of the other filter g_objects. This cleans up a
fair sized memory leak.
2017-03-18 20:55:15 -03:00
David Bremner
b4cedc7824 cli/show: fix usage of g_mime_content_type_to_string
It returns an "allocated string", which needs to be freed.
2017-03-18 20:55:15 -03:00
David Bremner
2ae6b8cb68 cli/show: fix some memory leaks in format_part_text
Mimic Jeff Stedfast's changes to format_headers_sprinter, clean up use
of internet_address_list_to_string and
g_mime_message_get_date_as_string.
2017-03-18 20:55:15 -03:00
Jeffrey Stedfast
195361c8cd fix memory leaks in notmuch-show.c:format_headers_sprinter()
Internet_address_list_to_string() and
g_mime_message_get_date_as_string() return allocated string buffers
and not const, so from what I can tell from taking a look at the
sprinter-sexp.c’s sexp_string() function, the code leaks the
recipients_string as well as the date string.
2017-03-18 20:55:15 -03:00
Jani Nikula
ed22cd8bf1 cli: do not initialize zero values with designated initializers
Let the language initialize defaults to zero when some values are
initialized to non-zero values. No functional changes.
2017-03-10 07:56:11 -04:00
Jani Nikula
8481372956 cli/show: move formatter structs closer to where they're needed
The formatter structs are only needed for the formatter array
initialization. Move them closer to use. This also lets us drop some
forward declarations. No functional changes.
2017-03-10 07:53:38 -04:00
Jani Nikula
f2160ae540 cli/show: group --entire-thread option handling into one place
The --entire-thread option handling is split around, making the logic
harder to follow than necessary. Put it in one place. While at it,
make the true/false values match notmuch_bool_t values for
simplicity. No functional changes.
2017-03-10 07:52:29 -04:00
Jani Nikula
16f0507962 cli/show: rename format_sel to simply format
Now that the format pointer is a temporary variable, and named
formatter, shorten format_sel to format. No functional changes.
2017-03-10 07:48:14 -04:00
Jani Nikula
0bb3b3b8e8 cli/show: use a table for choosing the formatter
Continue detangling format pointer and format selection variables. No
functional changes.
2017-03-10 07:48:06 -04:00
Jani Nikula
1232584040 cli/show: consistently use format_sel for checking the format
The mixed use of the format pointer and the format selection variables
is confusing. Add more clarity by using format_sel alone. No
functional changes.
2017-03-10 07:47:56 -04:00
Jani Nikula
33944a559a cli/show: remove unused raw member from show parameters struct
The raw member has been unused since b1130bc71c ("show: Convert raw
format to the new self-recursive style, properly support interior
parts"). Good riddance. No functional changes.
2017-03-10 07:47:48 -04:00
Jani Nikula
b2488a925a cli/show: detangle overloading of params.part for single message display
The use of params.part has become rather convoluted in notmuch
show. Add another variable for selecting single message display to
make the code easier to read. No functional changes.
2017-03-10 07:47:35 -04:00
Jani Nikula
ea20a932f1 cli/show: add content-disposition to structured output message parts
Help the clients decide how to display parts.

Test updates by Mark Walters <markwalters1009@gmail.com>.
One more test fix by db
2017-02-28 08:03:00 -04:00
Jani Nikula
85caaaf861 cli/show: abstract get content disposition
Reduce duplication in follow-up work. As a side effect, handle error
returns from g_mime_content_disposition_get_disposition() without
segfaulting.
2017-02-28 07:59:00 -04:00
Jani Nikula
14c60cf168 cli/show: list all filenames of a message in the formatted output
Instead of just having the first filename for the message, list all
duplicate filenames of the message as a list in the formatted
outputs. This bumps the format version to 3.
2017-02-26 07:41:33 -04:00
Daniel Kahn Gillmor
6a833a6e83 Use https instead of http where possible
Many of the external links found in the notmuch source can be resolved
using https instead of http.  This changeset addresses as many as i
could find, without touching the e-mail corpus or expected outputs
found in tests.
2016-06-05 08:32:17 -03:00
Tomi Ollila
eac2976389 cli: tell how many messages were precisely matched when expected 1 match
In case of notmuch reply and notmuch show --part=N it is required that
search terms match to one message. If match count was != 1, error
message "Error: search term did not match precisely one message"
was too vague to explain what happened.

By appending (matched <num> messages) to the error message it
makes the problem more understandable (e.g when <num> is '0'
user reckons the query had a typo in it).
2016-05-19 07:49:03 -03:00
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
005c2f0df1 cli/lib: remove support for GMime 2.4
It's becoming a maintenance burden to do anything things with the
crypto glue code twice, once for 2.4 and once for 2.6. I don't have
any 2.4 version available to test on my development machine anymore,
so the 2.4 specific code paths are likely not very well tested.
2015-08-26 20:01:45 -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
David Bremner
ecbb29e8ce notmuch-show: detect NULL pointer returned from notmuch_query_search_threads
We want to return an error status, not 0 or (worse) segfault.
2014-01-24 20:24:11 -04: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
Jani Nikula
1c450ec5fa cli: conform to same conditional build style as elsewhere in notmuch-show
Conform to the same style for #ifdef GMIME_ATLEAST_26 conditional
builds as elsewhere.

There are no functional changes.
2013-04-01 15:39:41 -04:00