Home GnuPG
Diffusion GpgOL c8f46557da70

Implement auto secure feature


Implement auto secure feature

* src/common_indep.h (opt): Add autosecure.
* src/cryptcontroller.cpp (CryptController::CryptController): Adopt
new API.
* src/keycache.cpp (do_locate, do_locate_secret): Fix broken handling
of args.
(locate_secret): Add check for empty mbox. Otherwise it could
select the first secret key if the sender address could not be
(KeyCache::startLocate): Take recipients as vector.
(KeyCache::isMailResolvable): New. Check if all keys are found
in the cache.
* src/keycache.h: Update accordingly.
* src/mail.cpp (m_cached_recipients): Use a vector instead of
a carray.
(m_first_autoresolve_check): Track state of autoresolve.
(Mail::~Mail): No need to free cached recipients.
(Mail::update_oom_data): Use vector for cached recipients.
(Mail::locate_keys): Adapt to new recipients API. Do
(Mail::take_cached_recipients): Removed.
(Mail::get_cached_recipents): New. Get a copy of the recipients.
(Mail::decrement_locate_count): Trigger autoresolve check.
(Mail::autoresolve_check_s): New. Check if mail is resolvable.
* src/mail.h: Update accordingly.
* src/mailitem-events.cpp (RecipientAdded): Handle opt.autosecure.
* src/main.c (read_options): Read autosecure.
* src/ribbon-callbacks.cpp (mark_mime_action): Use more modern
style. Mark if crypto state was set manually.
* src/windowmessages.cpp (DO_AUTO_SECURE, DONT_AUTO_SECURE): New
messages to set state.

This is a first implementation of opportunistic encryption
in GpgOL. If we have enough keys with marginal validity
or if the keys come from WKD we can select "secure" automatically.