Home GnuPG
Diffusion GpgOL 016ee4854c66

Add support to disable automatic verify/decrypt of the mail in preview
016ee4854c66Unpublished

Unpublished Commit · Learn More

Not On Permanent Ref: This commit is not an ancestor of any permanent ref.

Description

Add support to disable automatic verify/decrypt of the mail in preview

* src/common_indep.h: Add new flag dont_autodecrypt_preview to opt_s
* src/gpgoladdin.cpp: Add function check_auto_vd_mail which checks if
the registy value disableAutoPreviewHandling is set and updates the
global opt structure. Adds new button to the context menu to start
validation/decryption and adds mapping for the two new Ribbon
IDs ID_CMD_DECRYPT_MANUAL, ID_GET_VD_PROSPONED used by the menu entry.
* src/gpgoladdin.h: Declare new function
* src/mail.h: Add flag m_vd_prosponed to mail, declare Getter for it and
add version of decryptVerify_o with bool option doRevertOnly.
Add getCopy function
* src/mail.cpp: Init the new flag, add boolean parameter to the original
decrypt_verify_o wether to stop processing after reverting the
MessageClass and return after setting m_vd_prosponed to true.
Create a parameter less version which calls the the original version
with false. If parameter is not set set m_vd_prosponed to false.
Implement getCopy
* mailitem-events.cpp: on Open if the mail is a crypto mail and
decyption has been prosponed call decryptVerify_o.
on Read call check_auto_vd_mail and call decrypt_verify_o with the
parameter opt.dont_autodecrypt_preview.
Add logging for events BeforeAttachmentSave,BeforeCheckNames
* src/main.cpp: reading disableAutoPreviewHandling from config
* src/ribbon-callbacks.cpp: add functions get_is_vd_prosponed,
decrypt_manual used by the context menu to see if the entry should be
shown and handle the click event.
* src/ribbon-callbacks.h: declare context menu IDs & handling functions

If the new Registry value "disableAutoPreviewHandling" is set to 1
then the decryption/validation funtion/eventflow is aborted after
reseting the messageclass. The User has to either open the mail by
doubleclicking or pressing "Start decyption" in the context menu to
continue the normal eventflow.
If the key is not set or 0 the "old" behaviour is shown and emails are
auto verified/decryped when selected.

Details

Provenance
mmontkowskiAuthored on Nov 25 2024, 10:37 AM
Parents
rO1bf6a16404db: Post release version bump
Branches
Unknown
Tags
Unknown
References
feat/no_auto_preview

Event Timeline

While some comments are minor I think that I see that you are stuck trying to work on the copy in the event handler of the original. That will not work. I have outlined the problem and a proposed solution in the inline comment of the open event.

/src/gpgoladdin.cpp
401

Please do this in main.c read_options so that its aligned with all other options, see my comment in the header below, why.

737

Postponed?

/src/gpgoladdin.h
292

I see why you made this a function instead of using read_options if you used "check_html_preferred" as an example. The difference between check_html_preffered and check_auto_vd_mail is that check_html_preferred depends on an Outlook setting. All the other options (including auto decrypt) are gpgol options. Since we don't get a signal when the outlook option changes, we check it at runtime.

/src/mail.cpp
5161

Here it gets intresting. In the log, check how far in the event loop the second mail is created. I think here it is only the item load event. No further events. But an event handler will be installed for the "new" mail and a GpgOL mail object is created.

5162

This is done to mark in the GpgOL Mail object that this is a copy, so that in the event handler it can be treated differently.

/src/mail.h
257
int decryptVerify_o (bool doRevertOnly = false);
/src/mailitem-events.cpp
191

I think this is the main issue where you might be stuck. The copied mail at this point will only be very shallow. You have to return here, give outlook a chance to really load and populate the copy (read etc.) and then decrypt in the event handler of the second mail. I would expect calling "open" directly will also fail with an oom error like "you cannot call this method at this time" so you need to use an async window message to queue the open for the newly created mail and return in this event handler.

So something like:

if (m_mail->isCryptoMail () && m_mail->isVdProsponed ())
        {
               Mail *copy = m_mail->copy();
               do_in_ui_thread_async (OPEN, copy);
               log_dbg("Delegating open to copy: %p", copy);
               TBREAK;
        }
 else if (!opt.dont_autodecrypt_preview || m_mail->isCopyOfCryptoMail())
        {
              m_mail->decryptVerify_o();
        }

The open windowmessage you have to implement, it should just invoke open, like the send window message. There are examples. There is also a decrypt window message which was used to enable some kind of API like access to GpgOL allowing an external tool to send a window message to trigger a decrypt.

/src/ribbon-callbacks.cpp
850

isVDProsponed should probably be something like opt.dont_autodecrypt_preview && mail->is_crypto_mail(). The naming could be clearer that this is queried to decide wether or not to show the decrypt action.

werner added inline comments.
/src/gpgoladdin.h
292

The idea is that the user can switch the feature on and off w/o restarting Outlook. I meanwhile merged the patch and added a comment

/* Note: This is called for each Read event - it may make sense to add
    some optimization.  */

For example timer based or via some other reload mechanism for certain options.

/src/mailitem-events.cpp
191

We tested the code and it works as expected. Thus I do not really undertand your idea here. Anyway it has been merged and we can enable the code via a Regisry setting. Thus no harm should happen in the standard case. The new code needs more testing in the field of course.