Fix explorer display after mail was closed
* src/mailitem-events.cpp (request_decrypt): New. Request a decypt. (EVENT_SINK_INVOKE(MailItemEvents)): Handle decrypt_after_write. Don't always unload in unload. * src/windowmessages.cpp: Handle REQUEST_DECRYPT. * src/windowmessages.h: Add REQUEST_DECRYPT.
To prevent the question of wether or not to save the changes
(Which would save the decrypted data without an event to
prevent it) we save proactively. This happens by set_needs_save
and calling save. Which will revert a mail because we never want
to save unreverted mails.
But as a side effect the mail, if opened in the explorer still will
be reverted, too. So shown as empty. This is bad. To prevent that
we request a decrypt in the AfterWrite event.
Evil Hack: Outlook sends an Unload event after the message is closed
This is not true our Internal Object is kept alive if it is opened
in the explorer. So we ignore the unload event and then check in
the window message handler that checks for decrypt again if the
mail is currently open in the active explorer. If not we delete our
Mail object so that the message is released.