12 months agoAuto update translations
Andre Heinecke [Wed, 21 Mar 2018 12:03:02 +0000 (13:03 +0100)]
Auto update translations

* po/*: update.

12 months agoAdd proper spawn flags to kleopatra initial start
Andre Heinecke [Tue, 20 Mar 2018 08:14:28 +0000 (09:14 +0100)]
Add proper spawn flags to kleopatra initial start

* src/ribbon-callbacks.cpp (launch_cert_details): Add spawn
flags to fix initial show.

This allows the initial start to show a window / foreground
window and fixes a bug that the initial cert details was
not shown.

GnuPG-Bug-Id: T3845

12 months agoProvide parent wid for certificate details
Andre Heinecke [Tue, 20 Mar 2018 07:43:45 +0000 (08:43 +0100)]
Provide parent wid for certificate details

* src/ribbon-callbacks.cpp (launch_cert_details): Add

This helps Kleopatra not to open the certificate details
in the background.

GnuPG-Bug-Id: T3845

13 months agoJump the event queue
Andre Heinecke [Thu, 15 Mar 2018 14:03:04 +0000 (15:03 +0100)]
Jump the event queue

* src/olflange.h (ProgID): We are now Z.GNU.GpgOL

According to hearsay events are handled in reverse
alphabetical order. Let's try this to see if it results
in fewer problems with other addins.

The ProgId is not user visible anywhere.

GnuPG-Bug-Id: T3769

13 months agoFix unencrypted forward of crypto mail
Andre Heinecke [Thu, 15 Mar 2018 08:27:24 +0000 (09:27 +0100)]
Fix unencrypted forward of crypto mail

* src/mail.cpp (Mail::Mail): Add new marker for forwarded
crypto mails.
(Mail::remove_our_attachments): New. Removes gpgol attachments.
(Mail::set_is_forwarded_crypto_mail, Mail::is_forwarded_crypto_mail):
New accessors to marker.
* src/mailitem-events.cpp (EVENT_SINK_INVOKE): Set marker on
forward. Handle marker on write.

GnuPG-Bug-Id: T3836

13 months agoAvoid double gpgme_data_identify
Andre Heinecke [Thu, 15 Mar 2018 07:26:46 +0000 (08:26 +0100)]
Avoid double gpgme_data_identify

* src/parsecontroller.cpp (ParseController::parse): Store first
identify value and reuse it.

13 months agoDisable async crypto for now
Andre Heinecke [Wed, 14 Mar 2018 14:24:45 +0000 (15:24 +0100)]
Disable async crypto for now

* src/mail.cpp (Mail::is_inline_response): Treat every mail
as inline response exept when DO_ASYNC_CRYPTO is defined.

So sad :'-(
I really hope I find a way in the future to make it work.

GnuPG-Bug-Id: T3838

13 months agoRemove error handling for failure to resolve
Andre Heinecke [Wed, 14 Mar 2018 13:11:18 +0000 (14:11 +0100)]
Remove error handling for failure to resolve

* src/cryptcontroller.cpp (CryptController::do_crypto):
Remove an error handling.

This should never happen except when a bug occurs. And
handling it here would result in the overlay not beeing
properly destroyed.

13 months agoAdd small safety check in ribbon callback
Andre Heinecke [Wed, 14 Mar 2018 13:09:34 +0000 (14:09 +0100)]
Add small safety check in ribbon callback

* src/ribbon-callbacks.cpp (get_is_details_enabled): Add
safety check.

I doubt that it is necessary but I've seen logs where this
function is the last before a crash. So just be sure.

13 months agoFurther extend debugging around mail dtor
Andre Heinecke [Wed, 14 Mar 2018 10:16:03 +0000 (11:16 +0100)]
Further extend debugging around mail dtor

* src/mail.cpp (do_crypt): Note when ui thread is done.
* src/mailitem-events.cpp (EVENT_SINK_INVOKE): Log when deletion
is done in unload.
* src/windowmessages.cpp (gpgol_window_proc): Log when crypto
done handler is complete.
(do_async): Log invocation.

13 months agoImplement forwarding crypto mails with attachments
Andre Heinecke [Tue, 13 Mar 2018 15:41:45 +0000 (16:41 +0100)]
Implement forwarding crypto mails with attachments

* src/application-events.cpp (EVENT_SINK_INVOKE): Invalidate last
mail in the next UI Loop.
* src/mail.cpp (Mail::update_body): Safety check for parser. Keep
parser around.
(Mail::invalidate_last_mail): New. Clear cached last mail ptr.
* src/mail.h: Update accordingly.
* src/mailitem-events.cpp (EVENT_SINK_INVOKE): Extend write
event to detect forward of mails with attachments.
* src/oomhelp.cpp (get_inline_body): New.
* src/oomhelp.h: Update accordingly.
* src/windowmessages.cpp, src/windowmessages.h
* src/wks-helper.cpp (WKSHelper::send_mail): Check if last
mail was invalidated.

This is a first working draft of forwarding crypto mails
with attachments. As we don't see the forward event before
we get the write event (that we have to cancel usually) we
now have some extra magic to detect the forward based on
an ItemLoad of an empty mail in the same UI loop as the
write event. This is pretty magic but it works.

Once we detect the forward we save the mail and then immediately
revert it and save it again. This has the usual uglyness of
reverting (sync) but works and allows to forward mails.

GnuPG-Bug-Id: T3836

13 months agoImprove error handling on enc/sign errors
Andre Heinecke [Tue, 13 Mar 2018 15:38:54 +0000 (16:38 +0100)]
Improve error handling on enc/sign errors

* src/cryptcontroller.cpp (CryptController::do_crypto):
Improve error handling.
* src/mail.cpp (do_crypt): Use correct window and hide overlay /
destroy crypter before showing the error. Add better text for
general "Crypto failed" error.

13 months agoTurn up debugging at the end of crypto
Andre Heinecke [Mon, 12 Mar 2018 14:02:25 +0000 (15:02 +0100)]
Turn up debugging at the end of crypto

* src/mail.cpp (Mail::~Mail): Very verbose logging in oom_extra.
(Mail::~Mail): Use release_cArray. Explicitly null shared ptrs.
(do_crypt): Log when done.
(Mail::update_oom_data): Use release_cArray.

GnuPG-Bug-Id: T3617

13 months agoUpdate portuguese translation
Andre Heinecke [Mon, 12 Mar 2018 14:01:07 +0000 (15:01 +0100)]
Update portuguese translation

* po/pt.po: Update.

Translation provided by Marco A.G. Pinto. Thanks.

13 months agoBump Version to 2.1.0 and update NEWS
Andre Heinecke [Wed, 7 Mar 2018 12:36:07 +0000 (13:36 +0100)]
Bump Version to 2.1.0 and update NEWS


13 months agoFix protocol selection for autoresolve
Andre Heinecke [Wed, 7 Mar 2018 12:33:01 +0000 (13:33 +0100)]
Fix protocol selection for autoresolve

* src/cryptcontroller.cpp (CryptController::resolve_keys_cached):
Handle Protocol.

13 months agoImprove error handling and fix encoding
Andre Heinecke [Wed, 7 Mar 2018 12:31:54 +0000 (13:31 +0100)]
Improve error handling and fix encoding

* src/cryptcontroller.cpp: Take care that command line
args are not encoded to utf8.
* src/mail.cpp (do_crypt): Inform user when crypto failed.

13 months agoFix deadlock in Outlook 2010
Andre Heinecke [Wed, 7 Mar 2018 12:30:14 +0000 (13:30 +0100)]
Fix deadlock in Outlook 2010

* src/mail.cpp (do_crypt): In Outlook 2010 sending destroys
the Mail. So we may not hold the dtor lock for the send call.

13 months agoUpdate translations and fix some german strings
Andre Heinecke [Wed, 7 Mar 2018 09:01:38 +0000 (10:01 +0100)]
Update translations and fix some german strings

* po: Update.

13 months agoProvide protocol argument to resolver
Andre Heinecke [Wed, 7 Mar 2018 09:00:44 +0000 (10:00 +0100)]
Provide protocol argument to resolver

* src/cryptcontroller.cpp (CryptController::resolve_recipients):
Use Protocol parameter if S/MIME is disabled.

13 months agoAdd cryptcontroller to Potfiles
Andre Heinecke [Wed, 7 Mar 2018 07:59:23 +0000 (08:59 +0100)]
Add cryptcontroller to Potfiles

* po/ Add cryptcontroller.

13 months agoAuto update translations
Andre Heinecke [Wed, 7 Mar 2018 07:24:31 +0000 (08:24 +0100)]
Auto update translations

* po/: update.

13 months agoAllow Inline for signed & encrypted with GSuite
Andre Heinecke [Wed, 7 Mar 2018 07:21:36 +0000 (08:21 +0100)]
Allow Inline for signed & encrypted with GSuite

* src/mail.cpp (Mail::encrypt_sign_start): Relax GSuite checks.
We now support clearsigned and signed & encrypted inline mails
thanks to the new crypto architecture.

GnuPG-Bug-Id: T3545

13 months agoPrefer Sender over SendUsingAccount for crypt mail
Andre Heinecke [Tue, 6 Mar 2018 14:11:26 +0000 (15:11 +0100)]
Prefer Sender over SendUsingAccount for crypt mail

* src/mail.cpp (Mail::update_oom_data): Prefer the
Sender fallbacks before using sendUsingAccount for crypto mail

GnuPG-Bug-Id: T3802

13 months agoFactor sender fallbacks into seperate functs
Andre Heinecke [Tue, 6 Mar 2018 14:02:41 +0000 (15:02 +0100)]
Factor sender fallbacks into seperate functs

* src/mail.cpp (Mail::update_oom_data): Move out sender fallbacks.
* src/oomhelp.cpp, src/oomhelp.h (get_sender_CurrentUser),
(get_sender_Sender, get_sender_SenderEMailAddress)
(get_sender_SendUsingAccount): New.

This should not do a functional change.

13 months agoBring Outlook back into focus after enc/sign
Andre Heinecke [Tue, 6 Mar 2018 08:51:38 +0000 (09:51 +0100)]
Bring Outlook back into focus after enc/sign

* src/mail.cpp (do_crypt): Send BRING_TO_FRONT message
after encryption.
* src/windowmessages.cpp, src/windowmessages.h: New call
to bring the active outlook window to front.

As explained in the comment this is a workaround for strange
behavior with pinentry and foreground windows. After encrypt/sign
often times the wrong window has focus. So we better bring
Outlook to front.

GnuPG-Bug-Id: T3732

13 months agoAdd new Window Message helper
Andre Heinecke [Tue, 6 Mar 2018 08:50:52 +0000 (09:50 +0100)]
Add new Window Message helper

* src/windowmessages.cpp (do_async, do_in_ui_thread_async):
Add new fire and forget window messaging helper.
* src/windowmessages.h: Update accordingly.

13 months agoBe more lenient with broken PGP Inline messages
Andre Heinecke [Tue, 6 Mar 2018 08:02:20 +0000 (09:02 +0100)]
Be more lenient with broken PGP Inline messages

* src/mimedataprovider.cpp (MimeDataProvider::collect_data):
Fix up PGP Messages.

In the Outlook world sometimes messages are rewritten / converted
to HTML and then converted back to Plaintext etc.
This can lead to broken PGP Messages where there is extra
whitespace. We now fix up the whitespace and remove comments
in the Mimedataprovider in the spirit of trying to accept
as much input as possible.

GnuPG-Bug-Id: T3821

13 months agoAdd trim and ltrim to cpphelp
Andre Heinecke [Tue, 6 Mar 2018 08:01:33 +0000 (09:01 +0100)]
Add trim and ltrim to cpphelp

* src/cpphelp.cpp (ltrim, trim): New.
* src/cpphelp.h: Update accordingly.

13 months agoAuto update translation
Andre Heinecke [Tue, 6 Mar 2018 07:36:53 +0000 (08:36 +0100)]
Auto update translation

* po/de.po: Msgmerge moves the newline.

13 months agoFix w64 build
Andre Heinecke [Tue, 6 Mar 2018 06:41:05 +0000 (07:41 +0100)]
Fix w64 build

* src/cryptcontroller.cpp (CryptController::resolve_keys): Use
SIZE_T_FORMAT and hwnd conversion.
* src/overlay.cpp (Overlay::Overlay): HWND cast to int is ok.

13 months agoUpdate german translation
Andre Heinecke [Mon, 5 Mar 2018 13:43:10 +0000 (14:43 +0100)]
Update german translation

* po/de.po: Update german translation.

13 months agoAuto update po files
Andre Heinecke [Mon, 5 Mar 2018 13:36:19 +0000 (14:36 +0100)]
Auto update po files

* po: Update.

13 months agoAdd new files to
Andre Heinecke [Mon, 5 Mar 2018 13:35:55 +0000 (14:35 +0100)]
Add new files to

* po/ Add new files.

13 months agoUpdate german localisation
Andre Heinecke [Mon, 5 Mar 2018 13:33:46 +0000 (14:33 +0100)]
Update german localisation

* po/de.po: Update

13 months agoAuto update po files
Andre Heinecke [Mon, 5 Mar 2018 13:28:56 +0000 (14:28 +0100)]
Auto update po files

* po: Update.

13 months agoRelabel autoresolve option to reflect new functs async-enc
Andre Heinecke [Mon, 5 Mar 2018 13:26:46 +0000 (14:26 +0100)]
Relabel autoresolve option to reflect new functs

* src/addin-options.cpp (IDC_AUTORRESOLVE): Relabel autoresolve.
It's now also working for S/MIME and does more then just
locate keys.

13 months agoImplement Load / Save for WKS States
Andre Heinecke [Mon, 5 Mar 2018 10:46:11 +0000 (11:46 +0100)]
Implement Load / Save for WKS States

* src/wks-helper.cpp (WKSHelper::load, WKSHelper::save): Implement.
(WKSHelper::check_published): New.
(do_check): Also check for published.
(WKSHelper::update_last_checked): New.
(WKSHelper::start_check): Handle saved states.

13 months agoAdd helpers to store string map in registry
Andre Heinecke [Mon, 5 Mar 2018 10:45:51 +0000 (11:45 +0100)]
Add helpers to store string map in registry

* src/common.c (store_extension_subkey_value): New.
(GPGOL_REGPATH): Move into header.
* src/common.h: Expose store_extension_subkey_value.
* src/cpphelp.cpp (get_registry_subkeys): New.
(gpgol_split): New Helper.
* src/cpphelp.h: Update accordingly.

13 months agoMove registry helper code into common
Andre Heinecke [Fri, 2 Mar 2018 13:32:08 +0000 (14:32 +0100)]
Move registry helper code into common

* src/common.c (load_extension_value, store_extension_value),
(store_config_value, load_config_value, expand_path): Moved
from config-dialog.c
* src/config-dialog.c: Remove moved functions.

13 months agoUse keycache to autoresolve
Andre Heinecke [Thu, 1 Mar 2018 15:16:09 +0000 (16:16 +0100)]
Use keycache to autoresolve

* lots of changes.

The keycache is now used if opt.autoresolve is set to resolve
the signing / encryption keys without loading the resolver binary.

13 months agoBring mail to front after encryption
Andre Heinecke [Thu, 1 Mar 2018 15:10:22 +0000 (16:10 +0100)]
Bring mail to front after encryption

* src/overlay.cpp (Overlay::~Overlay): Bring old window to front.

Pinentry brings the wrong window to front. This mitigates that a

13 months agoMinor wait cleanup in overlay
Andre Heinecke [Thu, 1 Mar 2018 12:46:50 +0000 (13:46 +0100)]
Minor wait cleanup in overlay

* src/overlay.cpp (Overlay::~Overlay): Wait afteer writing
the quit.

13 months agoLocalize keyresolver
Andre Heinecke [Thu, 1 Mar 2018 12:46:13 +0000 (13:46 +0100)]
Localize keyresolver

* src/cryptcontroller.cpp (CryptController::resolve_keys):
Add --lang argument.

13 months agoAdd keycache for located keys
Andre Heinecke [Thu, 1 Mar 2018 12:39:06 +0000 (13:39 +0100)]
Add keycache for located keys

* src/keycache.cpp, src/keycache.h: New.
* src/ Add new files.
* src/mail.cpp (in_de_vs_mode): Move to cpphelp.
Rename global maps to s_ prefix to be more clear.
(Mail::locate_keys): Use keycache.
(do_locate): Removed.
(Mail::locate_all_crypto_recipents): New.
* src/cpphelp.cpp: Add in_de_vs_mode.
* src/ribbon-callbacks.cpp (mark_mime_action): Trigger
locate on crypto toggle.

Every serious MUA needs a Keycache ;-)

This is needed to store the keys returned by
gpg --locate-keys if we want to use them later to automatically
send to the keys located this way.

13 months agoFix surprising toggle behavior
Andre Heinecke [Thu, 1 Mar 2018 12:37:38 +0000 (13:37 +0100)]
Fix surprising toggle behavior

* src/ribbon-callbacks.cpp (mark_mime_action): If a sub action
was active click on secure activates both sign and encrypt.

13 months agoMerge branch 'master' into async-enc
Andre Heinecke [Tue, 27 Feb 2018 06:50:01 +0000 (07:50 +0100)]
Merge branch 'master' into async-enc

13 months agoCheck first for view before accessing selection
Andre Heinecke [Tue, 27 Feb 2018 06:06:32 +0000 (07:06 +0100)]
Check first for view before accessing selection

* src/ribbon-callbacks.cpp (get_mail_from_control): Only
access the item selection after we checked if we have a
preview pane / word editor.

The selection.Item(x) call can trigger a load / unload event
cycle. This is expensive and should be avoided if not
necessary. Also in the Outbox this somehow prevents
sending a mail.

GnuPG-Bug-Id: T3812

13 months agoFix multipart/signed detection if ms-tnef wrapped
Andre Heinecke [Mon, 26 Feb 2018 15:45:51 +0000 (16:45 +0100)]
Fix multipart/signed detection if ms-tnef wrapped

* src/mapihelp.cpp (change_message_class_ipm_note_smime),
(change_message_class_ipm_note_smime_multipartsigned): Handle tnef.

This fixes mutlipart/signed detection both when s/mime is enabled
and when it's disabled. For these kind of ms-tnef wrapped mails
there is actually a virtual attachment with a filename smime.p7m
that contains our mimestructure. Happlily all our other code
can handle this already.

GnuPG-Bug-Id: T3802

13 months agoAdd some more sender address lookups
Andre Heinecke [Mon, 26 Feb 2018 15:44:35 +0000 (16:44 +0100)]
Add some more sender address lookups

* src/mail.cpp (Mail::update_oom_data): Add more sender fallbacks.
* src/oomhelp.h: Define new DASL's

These properties were the only way I could find the SMTP
Address in an example mail from T3802.

13 months agoFix WKS-Confirm mail detection
Andre Heinecke [Thu, 22 Feb 2018 09:40:58 +0000 (10:40 +0100)]
Fix WKS-Confirm mail detection

* src/mapihelp.cpp (mapi_get_message_content_type): Comparing
an empty line would result in wks confirm detection.

13 months agoPrint error when decryptresult is null
Andre Heinecke [Thu, 22 Feb 2018 08:53:19 +0000 (09:53 +0100)]
Print error when decryptresult is null

* src/parsecontroller.cpp (format_error): Print an error
when decrypt is requested but the result is null. This means
that parsing failed.

13 months agoHandle MS-TNEF PGP/MIME Mails
Andre Heinecke [Thu, 22 Feb 2018 08:50:28 +0000 (09:50 +0100)]

* src/mapihelp.cpp (get_first_attach_mime_tag): Work with more
then one attachment.
(change_message_class_ipm_note): More ms-tnef handling.

Apparently Office365 converts mails from some to ms-tnef
attachments. We still won't work for S/MIME ms-tnef attachments
as I would need an example, but PGP/MIME should work now
additionally to PGP/Inline.

GnuPG-Bug-Id: T3802

13 months agoImplement handling of WKS-Confirmation mails
Andre Heinecke [Thu, 22 Feb 2018 08:45:46 +0000 (09:45 +0100)]
Implement handling of WKS-Confirmation mails

* src/common_indep.h (msgtype_t): New messagtype for WKS_Confirm
* src/mail.cpp (Mail::decrypt_verify): Handle new message type.
(Mail::is_smime): Clarify an error message.
* src/mapihelp.cpp
(string_to_type, mapi_change_message_class),
(mapi_get_message_content_type): Handle
wks confirmation mails.
* src/message.cpp: Default / ignore new message type in old code.
* src/wks-helper.cpp: Lots of changes.

13 months agoUse gpgol_message_box in wks-helper
Andre Heinecke [Tue, 20 Feb 2018 14:13:03 +0000 (15:13 +0100)]
Use gpgol_message_box in wks-helper

* src/wks-helper.cpp (WKSHelper::notify),
(WKSHelper::start_publish): Use gpgol_message_box.

You eat with your eyes ;-)

13 months agoAdd UTF8 and Icon Message Box helper
Andre Heinecke [Tue, 20 Feb 2018 14:07:24 +0000 (15:07 +0100)]
Add UTF8 and Icon Message Box helper

* src/common.c (gpgol_message_box): New.
* src/common.h (gpgol_message_box): Declare.
* src/dialogs.h, src/dialogs.rc: Add icon.
* src/icons/ (EXTRA_DIST): Add icon.
* src/icons/lock.ico: New.

13 months agoFix setting the account for WKS Mails
Andre Heinecke [Tue, 20 Feb 2018 13:41:47 +0000 (14:41 +0100)]
Fix setting the account for WKS Mails

* src/oomhelp.cpp (put_oom_disp): For VT_DISPATCH it is
* src/wks-helper.cpp (WKSHelper::send_mail): Properly release

14 months agoImplement WKS-Client request sending
Andre Heinecke [Fri, 16 Feb 2018 15:30:25 +0000 (16:30 +0100)]
Implement WKS-Client request sending

* src/wks-helper.cpp (WKSHelper::send_mail): New.
* src/wks-helper.h: Update accordingly.

This basically works. But there is a big issue. Somehow
the SendUsingAccount setting does not work so it always
sends out the mails with the default account.

14 months agoAdd oom helper to create mail and handle accounts
Andre Heinecke [Fri, 16 Feb 2018 15:29:11 +0000 (16:29 +0100)]
Add oom helper to create mail and handle accounts

* src/oomhelp.cpp (create_mail): Create a new mail.
(get_account_for_mail): Get an account for a mail address.
(put_oom_disp): New.
* src/oomhelp.h: Update accordingly.

14 months agoMake it possible to get the last created mail
Andre Heinecke [Fri, 16 Feb 2018 15:27:38 +0000 (16:27 +0100)]
Make it possible to get the last created mail

* src/mail.cpp (Mail::get_last_mail): New.
* src/mail.h: Update accordingly.

This makes it easy to get a reference to our internal Mail
object for example if a mail was created programatically
as the returned DISPATCH pointer differ.

14 months agoAdd possibility to override mime struct for mail
Andre Heinecke [Fri, 16 Feb 2018 15:25:32 +0000 (16:25 +0100)]
Add possibility to override mime struct for mail

* src/cryptcontroller.cpp (update_mail_mapi): Prefer override mime.
* src/mail.cpp (Mail::set_override_mime, Mail::get_override_mime):
(Mail::update_crypt_mapi): Create dummy crypter for overidden mime.

14 months agoAdd notification handling to WKS Helper
Andre Heinecke [Fri, 16 Feb 2018 12:05:09 +0000 (13:05 +0100)]
Add notification handling to WKS Helper

* src/windowmessages.cpp,
src/windowmessages.h (WKS_NOTIFY): New.
* src/wks-helper.cpp, src/wks-helper.h: Add more code.

After an encrypt / sign we send a notification some time
later that a MessageBox for WKS Publishing can be opened
back in the UI thread.

14 months agoFix detection of unencrypted mails in send
Andre Heinecke [Fri, 16 Feb 2018 12:03:06 +0000 (13:03 +0100)]
Fix detection of unencrypted mails in send

* src/mailitem-events.cpp (EVENT_SINK_INVOKE): Check
state before passing send.

This has not lead to bugs because no needs_crypto mails
went to update_crypt_mapi but it's the wrong branch anyhow
and the mails should pass through our hacks in send.

14 months agoAdd EnableWindow functionality to Overlay
Andre Heinecke [Fri, 16 Feb 2018 12:01:49 +0000 (13:01 +0100)]
Add EnableWindow functionality to Overlay

* src/overlay.cpp (Overlay::~Overlay): Enable window.
(Overlay::Overlay): Disable window.
* src/overlay.h (m_wid): New member.

14 months agoPut overlayer calls in a simple RAII class
Andre Heinecke [Fri, 16 Feb 2018 09:53:54 +0000 (10:53 +0100)]
Put overlayer calls in a simple RAII class

* src/ Add overlay.
* src/cryptocontroller.cpp (start_crypto_overlay): Move code
into seperate class.
(stop_crypto_overlay): Removed. Unique ptr takes care of that.
* src/cryptocontroller.h: Update accordingly.
* src/overlay.cpp, src/overlay.h: New.

14 months agoImplement WKS Supported check
Andre Heinecke [Fri, 16 Feb 2018 08:40:23 +0000 (09:40 +0100)]
Implement WKS Supported check

* src/ Add wks-helper
* src/wks-helper.cpp: New.
* src/wks-helper.h: New.
* src/cryptcontroller.cpp (CryptController::do_crypto): Trigger
WKS Check when doing crypto.

14 months agoFix minor memleak
Andre Heinecke [Fri, 16 Feb 2018 08:39:53 +0000 (09:39 +0100)]
Fix minor memleak

* src/cryptcontroller.cpp (CryptController::do_crypto): Free

14 months agoFactor out common cpp helper to cpphelp
Andre Heinecke [Fri, 16 Feb 2018 07:09:03 +0000 (08:09 +0100)]
Factor out common cpp helper to cpphelp

* src/cryptcontroller.cpp (release_carray, vector_to_charArray)
(rtrim): Move into cpphelp.
* src/cpphelp.cpp, src/cpphelp.h: New.
* src/ Add it.

14 months agoUse overlayer tool for "encrypting..." overlay
Andre Heinecke [Wed, 14 Feb 2018 18:55:01 +0000 (19:55 +0100)]
Use overlayer tool for "encrypting..." overlay

* src/cryptcontroller.cpp (CryptController::~CryptController):
Ensure overlay is stopped.
(vector_to_charArray): New helper.
(CryptController::lookup_fingerprints): User helper.
(CryptController::resolve_keys): Start crypto overlay.
(CryptController::start_crypto_overlay): New.
* src/cryptcontroller.h: Update accordingly.
* src/mail.cpp (Mail::reset_crypter): New.
(do_crypt): Reset crypter on error.
* src/mail.h: Update accordingly.

This is basically nice. If spawning takes a long time the
mail window is not overlayed for a bit. But that should
be ok.

14 months agoDo sign then encrypt for MIME mails again
Andre Heinecke [Wed, 14 Feb 2018 12:03:28 +0000 (13:03 +0100)]
Do sign then encrypt for MIME mails again

* src/cryptcontroller.cpp (do_crypto): Do two step dance.

14 months agoTake micalg from the created signature
Andre Heinecke [Wed, 14 Feb 2018 11:42:28 +0000 (12:42 +0100)]
Take micalg from the created signature

* src/cryptcontroller.cpp (CryptController::parse_micalg): New.
(CryptController::update_mail_mapi): Pass micalg.
(create_sign_attach): Take micalg.
* src/cryptcontroller.h: Update accordingly.

14 months agoFix S/MIME Encrypt
Andre Heinecke [Wed, 14 Feb 2018 11:06:43 +0000 (12:06 +0100)]
Fix S/MIME Encrypt

* src/cryptcontroller.cpp (create_encrypt_attach): Write binary
as base64.

14 months agoFix S/MIME Signature in new architecture
Andre Heinecke [Wed, 14 Feb 2018 10:56:03 +0000 (11:56 +0100)]
Fix S/MIME Signature in new architecture

* src/cryptcontroller.cpp (CryptController::do_crypto):
Set text mode and armor only for PGP
(create_sign_attach): Write signature as base64 for S/MIME.
* src/mimemaker.h, src/mimemaker.cpp (write_b64): Export.

14 months agoStart fixing S/MIME
Andre Heinecke [Wed, 14 Feb 2018 10:18:37 +0000 (11:18 +0100)]
Start fixing S/MIME

* src/cryptcontroller.h (m_bodyInput): Place to cache
the plain text body.
* src/cryptcontroller.cpp (CryptController::collect_data):
Collect body into special data variable.
(CryptController::resolve_keys): Basically handle S/MIME.

We now collect the body of a mail twice because when we
do the protocol selection later we do not know if
we can do inline (S/MIME inline is not supported by us).

14 months agoRevert "Launch Kleo/GPA in the background on start"
Andre Heinecke [Wed, 14 Feb 2018 07:29:37 +0000 (08:29 +0100)]
Revert "Launch Kleo/GPA in the background on start"

This reverts commit 13950a98522818b27b3048617acb0282b65b54b3.

For the async-enc branch this is no longer needed.

14 months agoMinor cleanup
Andre Heinecke [Wed, 14 Feb 2018 07:15:34 +0000 (08:15 +0100)]
Minor cleanup


14 months agoFix parsing of command lines
Andre Heinecke [Wed, 14 Feb 2018 07:12:46 +0000 (08:12 +0100)]
Fix parsing of command lines

* src/cryptcontroller.cpp (CryptController::parse_output):
rtrim parsed lines.

This fixes cancel.

14 months agoBring mail window to front after keyresolution
Andre Heinecke [Wed, 14 Feb 2018 07:09:41 +0000 (08:09 +0100)]
Bring mail window to front after keyresolution

* src/common.c, src/common.h (bring_to_front): New.
* src/cryptcontroller.cpp (CryptController::resolve_keys): Use it.

Somehow when the Qt modal window is closed it brings the wrong
window back. This fix does not prevent that but at least returns
the previous active window to the front.

GnuPG-Bug-Id: T3732

14 months agoFix state machine for PGP/Inline mails
Andre Heinecke [Wed, 14 Feb 2018 06:51:45 +0000 (07:51 +0100)]
Fix state machine for PGP/Inline mails

* src/mail.cpp, src/mail.h (Mail::WantsSendMIME)
(Mail::WantsSendInline): More explicit states.
(Mail::update_crypt_oom): Switch into Inline send for inline
(Mail::update_crypt_mapi): Switch into WantsSendMime.
* src/mailitem-events.cpp (EVENT_SINK_INVOKE): Pass inline mails

14 months agoImplement key parsing in cryptcontroller
Andre Heinecke [Wed, 14 Feb 2018 06:48:11 +0000 (07:48 +0100)]
Implement key parsing in cryptcontroller

* src/cryptcontroller.cpp (release_recipient_array): Renamed.
(rtrim): New helper.
(CryptController::lookup_fingerprints): New. Resolve keys from
(CryptController::parse_keys): Renamed to parse_output.
* src/cryptcontroller.h: Update accordingly.

14 months agoAdd mail window id accessor
Andre Heinecke [Wed, 14 Feb 2018 06:53:37 +0000 (07:53 +0100)]
Add mail window id accessor

* src/mail.h (Mail::get_window): New.

Kind of ugly as the window is only valid for a short
time but helps in cryptcontroller.

14 months agoMerge branch 'master' into async-enc
Andre Heinecke [Mon, 12 Feb 2018 14:34:12 +0000 (15:34 +0100)]
Merge branch 'master' into async-enc

14 months agoUse different offsets for windowmessages
Andre Heinecke [Mon, 12 Feb 2018 13:54:34 +0000 (14:54 +0100)]
Use different offsets for windowmessages

* src/windowmessages.cpp (gpgol_window_proc)
(send_msg_to_ui_thread): Use WM_USER + 42
* src/windowmessages.h: Start enum at 1100.

While a better fix might be to use a nonce to ensure
that a message really originated from us I hope that this
is enough for other software that globally sends out
WM_USER messages.

GnuPG-Bug-ID: T3769

14 months agoHold invalidation lock while parsing
Andre Heinecke [Mon, 12 Feb 2018 13:52:40 +0000 (14:52 +0100)]
Hold invalidation lock while parsing

* src/mail.cpp (do_parsing): Hold invalidation lock.
* src/windowmessages.h: Expose invalidation lock.
* src/windowmessages.cpp: Define / initialize lock.

This should make it more robust to do the parsing without
having the mail deleted under our hands because of invalidation

GnuPG-Bug-Id: T3789

14 months agoUse delayed invalidation when parsing is done
Andre Heinecke [Mon, 12 Feb 2018 13:50:33 +0000 (14:50 +0100)]
Use delayed invalidation when parsing is done

* src/mail.cpp (Mail::parsing_done): Use delayed invalidation.

If we are unlucky the direct invalidate ui would come right before
or after a Window Message invalidation. This would then lead
to behavior as we had in T3523 where Outlook goes bonkers.

GnuPG-Bug-ID: T3769
GnuPG-Bug-ID: T3789

14 months agoLog errors strings
Andre Heinecke [Mon, 12 Feb 2018 13:49:38 +0000 (14:49 +0100)]
Log errors strings

* src/mail.cpp (Mail::update_body): Log errors.

Makes it easier to analyze what happend when only looking
at the log.

14 months agoRemove overly plain leaking debug output
Andre Heinecke [Mon, 12 Feb 2018 12:34:21 +0000 (13:34 +0100)]
Remove overly plain leaking debug output

* src/mailitem-events.cpp (EVENT_SINK_INVOKE): Don't print
full body in debug output.

This was a development debug statement that accidentally
made it into the release.

14 months agoShorter and more careful window disabling
Andre Heinecke [Mon, 12 Feb 2018 12:01:14 +0000 (13:01 +0100)]
Shorter and more careful window disabling

* src/mail.cpp (do_crypt): Ensure window is renabled on error.
(Mail::encrypt_sign_start): Disable window here.
* src/mailitem-events.cpp (EVENT_SINK_INVOKE): Don't disable
window in event.

Leaving Outlooks window disabled for whatever reason is a
big bug as Outlook then has to be killed.

14 months agoStart impl. new key resolution with resolver
Andre Heinecke [Mon, 12 Feb 2018 11:59:45 +0000 (12:59 +0100)]
Start impl. new key resolution with resolver

* src/cryptcontroller.cpp (release_recipient_array),
(CryptController::parse_keys): New helpers.
(CryptController::resolve_keys): Prepare args and launch resolver.
* src/mail.cpp, src/mail.h (Mail::get_cached_sender): New helper
to ensure getting sender without oom or mapi.

14 months agoFix inline responses by making them sync
Andre Heinecke [Wed, 31 Jan 2018 12:20:26 +0000 (13:20 +0100)]
Fix inline responses by making them sync

* src/mail.cpp (Mail::is_inline_response),
(Mail::check_inline_response): New.
(do_crypt): Work sync for inline response.
* src/mailitem-events.cpp: Work sync for inline response.

Its nice how we can switch between sync and async in the new
architecture. Hopefully this does not mean double bugs ;-)

Working sync for inline response is necessary because we
can't trigger a send event programatically for inline responses.

14 months agoReactivate T3656 workaround
Andre Heinecke [Wed, 31 Jan 2018 10:37:32 +0000 (11:37 +0100)]
Reactivate T3656 workaround

* src/mailitem-events.cpp: Reactivate workaround.

Now that we do real encryption we can activate this hack again.

14 months agoFix window modality of encryption
Andre Heinecke [Wed, 31 Jan 2018 10:28:43 +0000 (11:28 +0100)]
Fix window modality of encryption

* src/mail.cpp: Add new member m_window.
(do_crypt): Renable window when done.
(Mail::set_window_enabled): New.
* src/mail.h: Update accordingly.
* src/mailitem-events.cpp: Disable mail window on crypt send.
* src/oomhelp.cpp (get_active_hwnd): Add some fallbacks.

14 months agoImplement MIME Sign in the new way
Andre Heinecke [Tue, 30 Jan 2018 14:49:26 +0000 (15:49 +0100)]
Implement MIME Sign in the new way

* src/cryptcontroller.cpp (create_sign_attach): New.
(CryptController::update_mail_mapi): Handle sign only.
* src/mimemaker.h, src/mimemaker.cpp: Expose more functions.
* src/mail.cpp (do_crypt): Remove sleep ;-)

14 months agoMake MIME encrypt work in the new way
Andre Heinecke [Tue, 30 Jan 2018 14:17:48 +0000 (15:17 +0100)]
Make MIME encrypt work in the new way

* src/cryptcontroller.cpp (CryptController::update_mail_mapi):
Do actual update.
(create_encrypt_attach): Helper to set up the right attachment.
(write_data): Helper to write GpgME::Data to a sink.
* src/mail.cpp (Mail::update_crypt_mapi): Call update_mail_mapi.
* src/mimemaker.cpp, src/mimemaker.h: Export some more helpers.

14 months agoMake inline encryption work in the new way
Andre Heinecke [Tue, 30 Jan 2018 13:19:42 +0000 (14:19 +0100)]
Make inline encryption work in the new way

* src/cryptcontroller.cpp (CryptController::resolve_keys):
Dummy. Should resolve keys in the future.
(CryptController::do_crypto): Do something.
(CryptController::get_inline_data): Take data as string.
* src/cryptcontroller.h Update accordingly.
* src/mail.cpp (Mail::append_to_inline_body): Use cryptcontroller.

14 months agoContinue work on async encrypt
Andre Heinecke [Tue, 30 Jan 2018 10:59:56 +0000 (11:59 +0100)]
Continue work on async encrypt

* src/mail.cpp (do_crypt): Sleep as a dummy.
(Mail::update_crypt_oom): Add some code.
* src/mailitem-events.cpp (EVENT_SINK_INVOKE): Move some code
to update_crypt_oom.

14 months agoFirst steps for async encryption handling
Andre Heinecke [Tue, 30 Jan 2018 09:59:28 +0000 (10:59 +0100)]
First steps for async encryption handling

* src/ (gpgol_SOURCES): Add new files.
* src/common_indep.h (log_mime_data): Shorthand for DBG_MIME_DATA.
* src/cryptcontroller.cpp, src/cryptcontroller.h: New. Similar
to parsecontroller but the other way around.
* src/mail.cpp (do_crypt): New. Thread helper.
(Mail::encrypt_sign): Renamed to Mail::encrypt_sign_start. And
changed to use cryptcontroller.
(Mail::update_crypt_mapi): New. Dummy.
(Mail::update_crypt_oom): New. Dummy.
(Mail::CryptState): Helper state for encryption.
* src/mailitem-events.cpp: Add proof of concept for new enc.
* src/mimemaker.h (add_body_and_attachments): Export.
* src/windowmessage.h, src/windowmessages.cpp (CRYPTO_DONE): New.

This shows the general possibility of async crypto by first collecting
the data, then doing the crypto and then still to have the possibility
to update the encrypted data both in MAPI and in OOM.

15 months agoPost release version bump
Andre Heinecke [Fri, 12 Jan 2018 10:11:25 +0000 (11:11 +0100)]
Post release version bump

* po: Auto update.

15 months agoUpdate NEWS gpgol-2.0.6
Andre Heinecke [Fri, 12 Jan 2018 09:50:39 +0000 (10:50 +0100)]
Update NEWS


15 months agoFix multipart signed mails
Andre Heinecke [Fri, 12 Jan 2018 09:37:20 +0000 (10:37 +0100)]
Fix multipart signed mails

* src/mimemaker.cpp (add_body_and_attachments): Add extra line for
multipart/related and multipart/alternative.

Outlook adds that line when the message is constructed. If that
line is not part of our hashed message we will create an invalid

GnuPG-Bug-Id: T3736