gpgol.git
2 years agoPass key by reference to get_uid
Andre Heinecke [Thu, 15 Dec 2016 16:48:48 +0000 (17:48 +0100)]
Pass key by reference to get_uid

* src/mail.cpp (get_uid_for_sender): Pass key by reference
to avoid a copy.

2 years agoAlways activate the GpgOL read button
Andre Heinecke [Thu, 15 Dec 2016 16:07:09 +0000 (17:07 +0100)]
Always activate the GpgOL read button

* src/gpgoladdin.cpp (getCustomUI_MIME): Always enable button.
* src/ribbon-callbacks.cpp (launch_cert_details): Open
the emailselfdefense infographic for unencrypted / unsigned
mails.

--
Maybe a bit too much, but the idea is to raise awareness
that unencrypted / unsigned mails are insecure.

2 years agoHandle opaque signed inline pgp messages
Andre Heinecke [Thu, 15 Dec 2016 11:01:25 +0000 (12:01 +0100)]
Handle opaque signed inline pgp messages

* src/parsecontroller.cpp (ParseController::parse):
Handle opaque signed PGP Messages.

--
For signed only messages decryptandverify would create no
output we need to just verify in that case.

2 years agoFix / improve inline PGP decryption
Andre Heinecke [Wed, 14 Dec 2016 16:04:08 +0000 (17:04 +0100)]
Fix / improve inline PGP decryption

* src/mapihelp.cpp (change_message_class_ipm_note): Look for
PGP Lines even without content type.
* src/mimedataprovider.cpp (MimeDataProvider::write): Respect
m_collect_everything.
* src/parsecontroller.cpp (ParseController::ParseController): Don't
expect MIME headers for inline pgp data.
(expect_no_mime): New.

2 years agoUpdate copyright year
Andre Heinecke [Wed, 14 Dec 2016 16:03:20 +0000 (17:03 +0100)]
Update copyright year

--

2 years agoUpdate signature status display
Andre Heinecke [Wed, 14 Dec 2016 15:51:17 +0000 (16:51 +0100)]
Update signature status display

* src/icons: Add new Icons, remove old icons.
* src/icons/Makefile.am (EXTRA_DIST): Update accordingly.
* src/dialogs.h: Define ids
* src/dialogs.rc: Include new icons.
* src/gpgoladdin.cpp: Update some function names.
* src/mail.cpp (Mail::update_sigstate): Use tofu validity
from gnupg.
(Mail::get_valid_sig): Removed. Too confusing.
(Mail::is_signed): Constify.
(Mail::is_encrypted): New, similar to is_signed.
(level_4_check): Helper to figure out the correct message
for level 4.
(Mail::get_crypto_summary): New. More differntiated title.
(Mail::get_signature_level): New. defines levels.
(Mail::get_crypto_details): New. Replacement for get_signature_status
(Mail::get_crypto_icon_id): Use levels and new icons.
* src/mail.h: Update accordingly.
* src/ribbon-callbacks.cpp (get_is_crypto): Renamed from
get_is_signed.
(get_sig_label): Use get_crypto_summary.
(get_sig_ttip): Use get_crypto_summary.
(get_sig_stip): Use get_crypto_details.
(get_crypto_icon): Use renamed function.
* src/ribbon-callbacks.h: Update accordingly.

--
This commits starts implementing signature / crypto status
display as discussed on:
https://wiki.gnupg.org/EasyGpg2016/AutomatedEncryption

Apologies for the large commits that mushes the string
and icon changes.

There are still bugs but I needed to commit some changes so
that I won't get lost completely.

2 years agoRecuce Sign and Encrypt to single split button
Andre Heinecke [Fri, 9 Dec 2016 14:19:22 +0000 (15:19 +0100)]
Recuce Sign and Encrypt to single split button

* src/dialogs.h: Add new icon ids.
* src/ribbon-callbacks.h: Add new ids.
* src/ribbon-callbacks.cpp (GpgolRibbonExtender::GetIDsOfNames),
(GpgolRibbonExtender::Invoke): Handle new ids.
(GetCustomUI_MIME): Use split button.
* src/ribbon-callbacks.cpp (mark_mime_action): Invalidate ui.
(get_crypt_pressed): Handle queries for multiple flags.

2 years agoImprove messagelist icon
Andre Heinecke [Fri, 9 Dec 2016 14:17:13 +0000 (15:17 +0100)]
Improve messagelist icon

* encr-s.ico, encr-s.xcf: Imrpove 1bit alpha use by mixing more
white into the still transparent colors. Remove line in the middle
this was too small for 16x16

2 years agoAdd new icons for sign / encrypt
Andre Heinecke [Fri, 9 Dec 2016 14:23:08 +0000 (15:23 +0100)]
Add new icons for sign / encrypt

* src/icons/Makefile.am (EXTRA_DIST): Update accordingly.
* encrypt-20.png, encrypt.svg, sign-20.png, sign-enc-40.png,
sign-enc.svg, sign.svg: New.

--
This is more in the visual language of Outlook with the ribbon
as a signature icon. It's also using the new lock of gpgol.

3 years agoFix multipart/alternative html mails
Andre Heinecke [Mon, 5 Dec 2016 16:43:43 +0000 (17:43 +0100)]
Fix multipart/alternative html mails

* src/mimemaker.cpp (add_body_and_attachments): Properly
handle the case when inner and outer boundary is null.

3 years agoUse MAPI message for mapi_get_uid
Andre Heinecke [Mon, 5 Dec 2016 16:42:00 +0000 (17:42 +0100)]
Use MAPI message for mapi_get_uid

* src/mapihelp.cpp, src/mapihelp.h (mapi_get_message):
Change to take message as argument.
* src/ribbon-callbacks.cpp (get_mail_from_control): Update usage.

3 years agoMention srcname / func in debug of invalidation
Andre Heinecke [Mon, 5 Dec 2016 16:21:23 +0000 (17:21 +0100)]
Mention srcname / func in debug of invalidation

* src/gpgoladdin.cpp (gpgoladdin_invalidate_ui): Put srcname
and func in debug.

--
Makes debug output easier to read.

3 years agoPrepare OOM Event handler for OL 2007
Andre Heinecke [Mon, 5 Dec 2016 16:19:50 +0000 (17:19 +0100)]
Prepare OOM Event handler for OL 2007

* src/mailitem-events.cpp (EVENT_SINK_INVOKE): Set uuid
on Open and pre_process in Read for OL 2007.

3 years agoAdd send_seen as member variable to Mail object
Andre Heinecke [Mon, 5 Dec 2016 16:17:54 +0000 (17:17 +0100)]
Add send_seen as member variable to Mail object

* src/mail.cpp, src/mail.h (Mail::needs_encrypt),
(Mail::set_needs_encrypt): New.
* src/mailitem-events.cpp (EVENT_SINK_INVOKE): Use new functions.

--
This puts the last state variable from the event handler into
the Mail object. It will be needed to Support Outlook 2007
where we have two event handlers.

3 years agoAdd fallback to create categories
Andre Heinecke [Mon, 5 Dec 2016 16:14:54 +0000 (17:14 +0100)]
Add fallback to create categories

* src/oomhelp.cpp (ensure_category_exists): Fallback to
Session.Categories.

--
If there are not multiple sessions this fallback is needed
t least for outlook 2007.

3 years agoAlways initialize execpinfo
Andre Heinecke [Mon, 5 Dec 2016 16:12:56 +0000 (17:12 +0100)]
Always initialize execpinfo

* src/oomhelp.cpp (get_oom_object, put_oom_string),
(add_oom_attachment, get_pa_variant, invoke_oom_method_with_parms):
Initialize execepinfo.

--
It is not assured that invoke sets excepinfo. This might have
lead to crashes in dump_excepinfo.

3 years agoPreselect sign / encrypt for reply / forward
Andre Heinecke [Thu, 1 Dec 2016 16:37:57 +0000 (17:37 +0100)]
Preselect sign / encrypt for reply / forward

* src/mail.cpp (Mail::Mail): Initalize crypto flags.
(Mail::get_crypto_flags): New.
(Mail::parsing_done): Set crypto flags.
* src/mailitem-events.cpp (EVENT_SINK_INVOKE): Handle reply, forward
and ReplyAll.

--
This sets sign for signed mails, encrypt for encrypted mails
and sign & encrypt for signed and encrypted mails.

3 years agoFix Reply event ID
Andre Heinecke [Thu, 1 Dec 2016 16:22:05 +0000 (17:22 +0100)]
Fix Reply event ID

* src/mailitem-events.cpp (MailEvent): Fix reply id.

--
This explains why the reply event behaved surprisingly as
it was actually the ReadComplete event...

3 years agoAdd supertip for unsigned messages
Andre Heinecke [Thu, 1 Dec 2016 16:13:14 +0000 (17:13 +0100)]
Add supertip for unsigned messages

* src/ribbon-callbacks.cpp (get_sig_stip): Handle mail not found
case.

--
Mail not found means no crypto mail

3 years agoFix crash when viewing unsigned mails
Andre Heinecke [Thu, 1 Dec 2016 16:09:30 +0000 (17:09 +0100)]
Fix crash when viewing unsigned mails

* src/ribbon-callbacks.cpp (get_sig_label): Return early
if mail not found.

--
Ooops. Although it could be considered a security feature ;-)

3 years agoAdd missing icon
Andre Heinecke [Thu, 1 Dec 2016 15:57:43 +0000 (16:57 +0100)]
Add missing icon

* src/icons/emblem-success-yellow-64.png: New.

3 years agoRemove some development debugs
Andre Heinecke [Thu, 1 Dec 2016 15:52:35 +0000 (16:52 +0100)]
Remove some development debugs

* src/mail.cpp (update_oom_data): Remove some development
debug statements.

3 years agoChange wording to better distinguish fully trusted
Andre Heinecke [Thu, 1 Dec 2016 15:47:39 +0000 (16:47 +0100)]
Change wording to better distinguish fully trusted

* src/mail.cpp (Mail::get_signature_status): Distinguish between
trusted and fully trusted.
* src/ribbon-callbacks.cpp (get_sig_label): Use three labels
instead of two.

--
Only changing the icon color was a too weak distinction. Especially
regarding accessibility.

3 years agoChange wording in signature details
Andre Heinecke [Thu, 1 Dec 2016 14:48:12 +0000 (15:48 +0100)]
Change wording in signature details

* src/mail.cpp (Mail::get_signature_status): Change wording.
* src/ribbon-callbacks.cpp (get_sig_label): Use trust instead
verified.

--
Trusted Sender is still very easygoing but we now have a better
distinction between fully trusted and marginally trusted.

3 years agoLog if a uid was skipped because of no email
Andre Heinecke [Thu, 1 Dec 2016 14:47:30 +0000 (15:47 +0100)]
Log if a uid was skipped because of no email

* src/mail.cpp (get_uid_for_sender): Log if mail is null.

3 years agoChange valid category to Trusted Sender Address
Andre Heinecke [Thu, 1 Dec 2016 14:45:36 +0000 (15:45 +0100)]
Change valid category to Trusted Sender Address

* src/gpgoladdin.cpp (GpgolAddin::OnStartupComplete): Change
category name.
(Mail::remove_categories, Mail::update_categories): Use new
name.

--
Verified Sender was too strong, we now relate to the
address.

3 years agoEnable clearsigned support again for reading
Andre Heinecke [Thu, 1 Dec 2016 14:44:17 +0000 (15:44 +0100)]
Enable clearsigned support again for reading

* src/mapihelp.cpp (get_msgcls_from_pgp_lines): Enable clearsigned
support.

--
I just forgot that this was disabled. We can support this now.

3 years agoAdd yellow checker for basic / marginal trust
Andre Heinecke [Thu, 1 Dec 2016 14:42:32 +0000 (15:42 +0100)]
Add yellow checker for basic / marginal trust

* src/dialogs.h, src/dialogs.rc: Update accordingly.
* src/icons/emblem-success-yellow.svg,
src/icons/emblem-success-yellow-64.png: New.
* src/icons/Makefile.am (EXTRA_DIST): Add new icon and
svg icons.
* srC/mail.cpp (Mail::get_signature_icon_id): Use it.

3 years agoSupport multipart/related reading
Andre Heinecke [Wed, 30 Nov 2016 16:17:14 +0000 (17:17 +0100)]
Support multipart/related reading

* src/attachment.cpp (Attachment::set_content_id)
(Attachment::get_content_id): New.
* src/mail.cpp (get_attachment): Return last attachment on -1 pos
(fixup_last_attachment): New. Set content id.
(add_attachments): Call fixup.
* src/oomhelp.h (PR_ATTACH_CONTENT_ID_DASL): New.
* src/mimedataprovider.cpp (t2body): Parse content-id.
(MimeDataProvider::create_attachment): Set content-id.

--
This magically hides the attachment from the attachment list
and Outlook shows images in the body.

3 years agoSupport sending embedded images(multipart/related)
Andre Heinecke [Wed, 30 Nov 2016 14:34:11 +0000 (15:34 +0100)]
Support sending embedded images(multipart/related)

* src/mimemaker.cpp (add_body_and_attachments): New. Common
multipart handling for the encrypt / sign functions.
* src/mimemaker.cpp (mime_encrypt, do_mime_sign):
Use add_body_and_attachments.
(is_related): New. Check if we have a multipart/related.
(write_attachments): Allow to filter out related attachments.
(write_part): Write Content-ID if there is one.
* src/mymapitags.h (PR_ATTACH_CONTENT_ID): New.

--
This enables multipart/related and multipart/mixed with a
multipart/related subpart.

3 years agoAdd content_id to our attach table
Andre Heinecke [Wed, 30 Nov 2016 14:30:55 +0000 (15:30 +0100)]
Add content_id to our attach table

* src/common_indep.h (mapi_attach_item_t): Extend with
content_id.
* src/mapihelp.cpp (get_attach_content_id): New.
(mapi_create_attach_table): Use it.
(mapi_release_attach_table): Free it.

3 years agoFix content type detection
Andre Heinecke [Wed, 30 Nov 2016 14:29:19 +0000 (15:29 +0100)]
Fix content type detection

* src/mimemaker.cpp (infer_content_type): Fix it.

--
This never worked because the tolower did not increase the
suffix pointer and just filled the buffer with the first letter
of the suffix.

Now we have c++ we can simplify the tolower.

3 years agoFix mulipart/mixed with alternative content
Andre Heinecke [Tue, 29 Nov 2016 17:22:49 +0000 (18:22 +0100)]
Fix mulipart/mixed with alternative content

* src/mimemaker.cpp (add_body): Open new part if in mixed structure.

3 years agoSupport HTML sending and fix sender updates
Andre Heinecke [Tue, 29 Nov 2016 17:01:19 +0000 (18:01 +0100)]
Support HTML sending and fix sender updates

* src/mail.cpp (Mail::Mail): Update init.
(Mail::get_sender): Sender is now a string.
(Mail::encrypt_sign): Update accordingly.
(Mail::update_sender): Changed to update_oom_data.
(Mail::update_oom_data): More generic. Caches BodyFormat,
HTMLBody and sender. Changed order for sender retrieval
when composing mails.
(Mail::update_sigstate): Update accordingly.
(Mail::is_html_alternative, Mail::get_cached_html_body): New.
* src/mail.h: Update accordingly.
* src/mailitem-events.cpp (EVENT_SINK_INVOKE): Update oom data
on send.
* src/mimemaker.cpp (create_mapi_attachment): Fix another use
after free.
(infer_content_type): is_mapibody now defines text/html or
text/plain. The naive content deduction is removed.
(add_body): Handler for the HTML / multipart body.
(do_mime_sign, mime_encrypt): Use add_body.
(mime_sign, mime_sign_encrypt): Pass on mail object.

--
We now send multipart/alternative mails in case HTML or RichText
is selected as body format. This is the way outlook does it, too.

The sender update fix is a bit mushed in as this is now all
update_oom_data.

3 years agoIgnore more property changes
Andre Heinecke [Tue, 29 Nov 2016 16:51:26 +0000 (17:51 +0100)]
Ignore more property changes

* src/mailitem-events.cpp (prop_blacklist): Add OutlookVersion
and OutlookInternalVersion.

--
For mails imported from the filesystem outlook changed these
properties.

3 years agoRework close and remove hacks for bad events
Andre Heinecke [Mon, 28 Nov 2016 15:45:26 +0000 (16:45 +0100)]
Rework close and remove hacks for bad events

* src/mail.cpp (Mail::close): Make it static to handle the
case were close causes a mail deletion.
(Mail::close_inspector): Make it static.
(Mail::close_all_mails): Close inspector first. Handle
map changes and object deletion.
(Mail::~Mail): Don't delete event sink.
(Mail::get_close_triggered, Mail::set_close_triggered): New.
* src/mailitem-events.h (EVENT_SINK_INVOKE): Remove
uneccessary Close hacks. Fix fallthrough from Open to
before read. Fix fallthrough from Close to unload.
Check if a close was triggered by us.
(request_close, request_decrypt): Remvoed.
* src/windowmessages.cpp, src/windowmessages.h (REQUEST_DECRYPT)
(REQUEST_CLOSE): Removed.

--
This fixes various inconsistentcies in the Close handling, especially
if the Object calling the close was deleted during the call. Also
closing the inspectors before closing the mail fixes a crash that
could be triggered if more then one mail was open when closing.

The proper closing now also prevents the necessity for decrypt again.

The Open to BeforeRead fallthrough should not be a big issue,
still a problem. And the close to unload fallthrough with my
long comments explaining it,.. well *facepalm*..

GnuPG-Bug-Id: 2855

3 years agoDon't close non-crypto mails
Andre Heinecke [Mon, 28 Nov 2016 13:59:48 +0000 (14:59 +0100)]
Don't close non-crypto mails

* src/mail.cpp (Mail::close_all_mails): Ignore non crypto mails.
Don't delete mail on error.

--
Closing non crypto mails is a chance for data loss as it could
have caused drafts to be discarded. The delete on error is also
not good as we don't know if the close already triggered the
unload event and so may have unloaded the mail already.

3 years agoFix race between deletion and parser access
Andre Heinecke [Mon, 28 Nov 2016 13:58:09 +0000 (14:58 +0100)]
Fix race between deletion and parser access

* src/mail.cpp (Mail::~Mail): Lock destruction.
(do_decrypt): Lock validity check and parser access.

--
This fixes a crash that could be triggered by wildly switching
between encrypted / signed mails.

3 years agoUse inline text as body if no body seen
Andre Heinecke [Mon, 28 Nov 2016 11:38:44 +0000 (12:38 +0100)]
Use inline text as body if no body seen

* src/mimedataprovider.cpp (t2body): Use first text
attachment as body if it is an inline attachment.
(MimeDataProvider::create_attachment): Log the attachment
name.

--
This fixes handling mails from kmail 1

3 years agoHandle detected attachments without filenames
Andre Heinecke [Mon, 28 Nov 2016 11:36:13 +0000 (12:36 +0100)]
Handle detected attachments without filenames

* src/mail.cpp (Mail::add_attachments): Ingore attachments without
filenames.
(Mail::parsing_done): Don't fail hard on attachment add failure.

--
This fixes the case if some mimestructure or unknown multipart/mixed
attachments like the "private-headers" mimepart from Enigmail is
present. Before this the first empty attachment filename would
result in an error and no other attachments would have been shown.

3 years agoIgnoore WM_SYSCOMMAND / SC_CLOSE
Andre Heinecke [Thu, 17 Nov 2016 15:57:26 +0000 (16:57 +0100)]
Ignoore WM_SYSCOMMAND / SC_CLOSE

* src/windowmessages.cpp (gpgol_hook): Ignore WM_SYSCOMMAND
SC_CLOSE.

--
I have not found a way where SC_CLOSE is sent but WM_CLOSE
is not sent. This fixes double close crashes when both WM_SYCOMMAND
and SC_CLOSE are handled but the close did not complete the
unload of the message.

Maybe we should remove our mails from the internal map as soon
as we call close.

3 years agoImprove wording in debug output for failed crypto
Andre Heinecke [Thu, 17 Nov 2016 14:48:59 +0000 (15:48 +0100)]
Improve wording in debug output for failed crypto

--

3 years agoDon't show MessageBox when encryption failed
Andre Heinecke [Thu, 17 Nov 2016 14:47:31 +0000 (15:47 +0100)]
Don't show MessageBox when encryption failed

* src/message.cpp (sign_encrypt): Disable messagebox

--
At least kleopatra returns -1 if encryption is cancelled by
the user. In that case we really really don't want to have
that messagebox.

3 years agoStart locate-keys when a recipient is added
Andre Heinecke [Thu, 17 Nov 2016 14:36:45 +0000 (15:36 +0100)]
Start locate-keys when a recipient is added

* src/mail.cpp (Mail::locate_keys): Check for recipient keys.
(do_locate): New.
(Mail::needs_crypto): Return flags.
* src/mail.h: Update accordingly.
* src/mailitem-events.cpp (EVENT_SINK_INVOKE): Handle recipient
changes and do locate_keys if necessary.

--
Checked addresses are stored in a set so that they are not
searched twice per session to avoid spammy requests.

This feature is mostly useful for users of auto-key-locate
where this can be used to retrieve keys from dane etc.

3 years agoAdd autoresolve keys option for encryption
Andre Heinecke [Thu, 17 Nov 2016 14:34:07 +0000 (15:34 +0100)]
Add autoresolve keys option for encryption

* src/addin-options.cpp (set_labels): Improve wording.
* src/dialogs.rc: Fix layout of autoresolve option.
* src/main.c (read_options, write_options): Handle option.

3 years agoSleep a bit in engine_wait
Andre Heinecke [Thu, 17 Nov 2016 12:35:14 +0000 (13:35 +0100)]
Sleep a bit in engine_wait

* src/engine.c (engine_wait): Sleep in the busy wait loop.

3 years agoFix minor memory leak in error condition
Andre Heinecke [Thu, 17 Nov 2016 12:32:06 +0000 (13:32 +0100)]
Fix minor memory leak in error condition

* src/ommon_indep.c (qp_encode): Free outbuf on error.

3 years agoAdd some NEWS
Andre Heinecke [Wed, 16 Nov 2016 09:00:15 +0000 (10:00 +0100)]
Add some NEWS

--

3 years agoUse undecoded body if charset unkown or not found
Andre Heinecke [Tue, 15 Nov 2016 14:16:59 +0000 (15:16 +0100)]
Use undecoded body if charset unkown or not found

* src/mlang-charset.cpp (ansi_charset_to_utf8): Handle no charset.

3 years agoAdd some more error messages to finalize_message
Andre Heinecke [Tue, 15 Nov 2016 14:16:18 +0000 (15:16 +0100)]
Add some more error messages to finalize_message

* src/mimemaker.cpp (finalize_message): Add some more errors.

3 years agoFix use after free in mimemaker
Andre Heinecke [Tue, 15 Nov 2016 14:15:14 +0000 (15:15 +0100)]
Fix use after free in mimemaker

* src/mimemaker.cpp (create_mapi_attachment),
(finalize_message): Do not use GpgOLStr for assignments.

3 years agoFix use after free & double free
Andre Heinecke [Tue, 15 Nov 2016 14:12:54 +0000 (15:12 +0100)]
Fix use after free & double free

* src/mail.cpp (Mail::get_signature_status): Do not append / free
buf as it is no longer set in the above block.

3 years agoInstall forms for formpath forms
Andre Heinecke [Tue, 15 Nov 2016 12:06:06 +0000 (13:06 +0100)]
Install forms for formpath forms

* forms/Makefile.am (cfg): Add new forms.

3 years agoIgnore UnRead property change notification
Andre Heinecke [Tue, 15 Nov 2016 10:28:57 +0000 (11:28 +0100)]
Ignore UnRead property change notification

* src/mailitem-events.cpp: Ignore UnRead

--
UnRead is handled, we just ignore the notification.

3 years agoFix check for gpgme-w32spawn
Andre Heinecke [Tue, 15 Nov 2016 09:48:16 +0000 (10:48 +0100)]
Fix check for gpgme-w32spawn

* src/main.cpp (get_gpgme_w32_inst_dir): Fix name of
gpgme-w32spawn.exe

3 years agoRemove buggy debug output warning
Andre Heinecke [Tue, 15 Nov 2016 08:26:38 +0000 (09:26 +0100)]
Remove buggy debug output warning

* src/main.c (read_options): Don't show messagebox about
debug output.

--
Let's assume that users that have enabled debug output know
that. This message also was only shown if log_file was set
(even if set to an empty string) and debug output was off.

3 years agoLook for libgpgmepp in the right libdir
Andre Heinecke [Mon, 14 Nov 2016 17:38:48 +0000 (18:38 +0100)]
Look for libgpgmepp in the right libdir

* src/Makefile.am (libgpgmepp.a): Use correct prefix.

3 years agoFix errors from 1b822ad2
Andre Heinecke [Mon, 14 Nov 2016 17:17:24 +0000 (18:17 +0100)]
Fix errors from 1b822ad2

* src/mail.cpp: Fix utf8 macro.
(Mail::get_signature_status): Fix typo.
* src/mailitem-events.cpp: Fix utf8 macro.

--
One should never push without compiling.

3 years agoUpdate translations and translate german
Andre Heinecke [Mon, 14 Nov 2016 14:10:46 +0000 (15:10 +0100)]
Update translations and translate german

* po/POTFILES.in: Add all files containing gettext macros.
* po/de.po: Update and translate.
* po/fr.po, po/pt.po, po/sv.po, po/zh_CN.po, po/zh_TW.po: Autoupdate

3 years agoImprove some strings for l10n
Andre Heinecke [Mon, 14 Nov 2016 14:10:05 +0000 (15:10 +0100)]
Improve some strings for l10n

--

3 years agoMake gpgme install dir selection more flexible
Andre Heinecke [Mon, 14 Nov 2016 10:03:36 +0000 (11:03 +0100)]
Make gpgme install dir selection more flexible

* src/main.c (get_gpgme_w32_inst_dir): New.
(DllMain): Use it.

--
This makes the w32-inst-dir finding work with gpg4win-2 where
gpg-w32-spawn is not in the bin dir.

3 years agoNext version will be 2.0.0
Andre Heinecke [Fri, 11 Nov 2016 16:35:55 +0000 (17:35 +0100)]
Next version will be 2.0.0

* NEWS, configure.ac: Bump version

--
This helps beta version numbering. The next version
brings major changes.

3 years agoUse _WIN64 instead of WIN64 to detect arch
Andre Heinecke [Fri, 11 Nov 2016 16:23:13 +0000 (17:23 +0100)]
Use _WIN64 instead of WIN64 to detect arch

* common_indep.h, config-dialog.c, olflange-dlgs.cpp: Use
_WIN64 instead of WIN64.

--
Somehow WIN64 is no longer defined by my mingw like
it was before. _WIN64 is more correct.

3 years agoAdd automake test-driver
Andre Heinecke [Fri, 11 Nov 2016 15:51:13 +0000 (16:51 +0100)]
Add automake test-driver

* build-aux/test-driver: New. From debian jessie.
--
Automake told me to do this.

3 years agoAdd property change warning nomapi
Andre Heinecke [Fri, 11 Nov 2016 15:01:18 +0000 (16:01 +0100)]
Add property change warning

* src/mailitem-events.cpp (EVENT_SINK_INVOKE): Warn on property
change done by the user.

--
See the comment in the PropertyChange event why we can't handle
this.

3 years agoAdd helper method to get active window handle
Andre Heinecke [Fri, 11 Nov 2016 15:00:34 +0000 (16:00 +0100)]
Add helper method to get active window handle

* src/oomhelp.cpp, src/oomhelp.h (get_active_hwnd): New get the
handle of the active window.

3 years agoClean up some debug output
Andre Heinecke [Fri, 11 Nov 2016 14:14:07 +0000 (15:14 +0100)]
Clean up some debug output

* src/ribbon-callbacks.cpp (get_mail_from_control): Don't
print the Subject

3 years agoRemove accidentally commited AddRef experiment
Andre Heinecke [Fri, 11 Nov 2016 14:11:56 +0000 (15:11 +0100)]
Remove accidentally commited AddRef experiment

* src/mailitem-events.cpp (EVENT_SINK_INVOKE): Do not add
another ref on read.

--
This was part of an experiment if the additional ref prevented
an unload.

3 years agoFix WM_CLOSE handling
Andre Heinecke [Fri, 11 Nov 2016 14:07:30 +0000 (15:07 +0100)]
Fix WM_CLOSE handling

* src/windowmessages.h (add_explorer, remove_explorer): Use LPDISPATCH
* src/windowmessages.cpp (add_explorer, remove_explorer): Update
accordingly.
(gpgol_hook): Use FindWindowEx to find all explorer windows.
* src/gpgoladdin.cpp (install_explorer_sinks): Register explorer
dispatch.
* src/explorer-events.cpp (EVENT_SINK_INVOKE): Remove explorer
on close.

--
At least with Outlook 2016 casting to IOlewindow and using
GetWindow did not work anymore. The returned handle was always 1.
FindWindowEx should work reliably.

3 years agoFix UI Invalidation after selection change
Andre Heinecke [Fri, 11 Nov 2016 14:05:16 +0000 (15:05 +0100)]
Fix UI Invalidation after selection change

* src/explorer-events.cpp (EVENT_SINK_INVOKE): Invalidate again
on selection change.
(invalidate_ui): Delay invalidation.

--
We sleep before the invalidation to give outlook a chance to
actually read the mail properly after the selection is changed
before we invalidate the ui. This fixes some races after selection
change.

3 years agoEnsure uuid's are always logged
Andre Heinecke [Fri, 11 Nov 2016 14:01:51 +0000 (15:01 +0100)]
Ensure uuid's are always logged

* src/mail.cpp (Mail::set_uuid): Log uuid changes.

3 years agoFix sigstate code for multiple signatures
Andre Heinecke [Fri, 11 Nov 2016 13:58:56 +0000 (14:58 +0100)]
Fix sigstate code for multiple signatures

* src/mail.cpp (Mail::update_sigstate): Fix signature selection code.

--
Previously the first signature was selected always even if this
signature did not have the uid belonging to the sender. This
might be considered a security problem but was thankfully not
released yet.
Thanks to Daniel Vr├ítil <dvratil@kdab.com> for seeing this issue.

3 years agoSet uuid again in close
Andre Heinecke [Fri, 11 Nov 2016 13:58:23 +0000 (14:58 +0100)]
Set uuid again in close

* src/mail.cpp (Mail::close): Set uuid again.

--
This fixes the decrypt again code.

3 years agoRemove old error message template
Andre Heinecke [Fri, 11 Nov 2016 13:56:53 +0000 (14:56 +0100)]
Remove old error message template

* src/mail.cpp (HTML_TEMPLATE): Remove.
(Mail::wipe): Just empty out body.

--
This should no longer be needed. Only if close errors out
is wipe actually called.

3 years agoOnly decrypt / verify one mail at once
Andre Heinecke [Tue, 8 Nov 2016 17:13:35 +0000 (18:13 +0100)]
Only decrypt / verify one mail at once

* src/mail.cpp (do_parsing): Lock parsing

--
This fixes some threading problems when there were very
quick mail switches but it also makes the code more stable
and improves performance as it filters out parser calls
for mails that were already unloaded.

3 years agoOnly close on WM_CLOSE of explorers
Andre Heinecke [Mon, 7 Nov 2016 17:14:05 +0000 (18:14 +0100)]
Only close on WM_CLOSE of explorers

* src/explorer-events.cpp (EVENT_SINK_INVOKE): Track explorers.
* src/gpgoladdin.cpp (install_explorer_sinks): Install sinks.
* src/windowmessages.cpp (add_explorer_window)
(remove_explorer_window): New.
(gpgol_hook): Only react to explorers.

--
This prevents mails from beeing closed when they are opened
in a reader. Still todo is to close only the mails from the
selection of the explorer that is currently closing and
only to close all mails if it is the last explorer.

3 years agoRemove the need to revert mails
Andre Heinecke [Mon, 7 Nov 2016 14:28:53 +0000 (15:28 +0100)]
Remove the need to revert mails

* src/application-events.cpp (EVENT_SINK_INVOKE): Remove comment.
* src/gpgoladdin.cpp (GpgolAddin::OnDisconnection): Close instead
revert.
(GpgolAddin::OnStartupComplete): Create Window message hook.
* src/mail.cpp (Mail::close_all_mails): New.
* src/mail.h: Update accordingly.
* src/mailitem-events.cpp (request_close): New.
src/mailitem-events.cpp (EVENT_SINK_INVOKE): Update event
handling to new logic. See comments.
* src/windowmessages.cpp (gpgol_hook): New.
(create_message_hook): New. Registers gpgol_hook.
src/windowmessages.h: Update accordingly.

--
This is basically the yewel of the nomapi branch. Without
persistent changes in MAPI we can just close the Mails with
discard changes set to true to "revert" our mails. This
removes the need for a revert and Outlook won't create new
mails containing our reverted mails.

There should be no more need for revert at all. It's left
in as an additional fallback in case something fails.

3 years agoDisable ui invalidation in explorers for now
Andre Heinecke [Mon, 7 Nov 2016 14:27:14 +0000 (15:27 +0100)]
Disable ui invalidation in explorers for now

* src/explorer-events.cpp, src/explorers-events.cpp
(EVENT_SINK_INVOKE): Disable ui invalidation.

--
This triggers a bug causing duplicated mailitems so
disabled for now.

3 years agoAlways discard changes on close for now
Andre Heinecke [Mon, 7 Nov 2016 13:50:10 +0000 (14:50 +0100)]
Always discard changes on close for now

* src/mail.cpp, src/mail.h (Mail::close): Remove save changes
parameter.

--
We need to figure out if we want to save after disarding changes
by ourself depending on property changes.

3 years agoAdd request_close windowmessage
Andre Heinecke [Mon, 7 Nov 2016 13:47:38 +0000 (14:47 +0100)]
Add request_close windowmessage

* src/windowmessage.h (REQUEST_CLOSE): Declare.
* src/windowmessages.cpp (gpgol_window_proc): Handle REQUEST_CLOSE.
* src/ribbon-callbacks.cpp (get_mail_from_control): Update to new
get_unique_id signature.

3 years agoUse msgclass to determine if a mail is crypto
Andre Heinecke [Mon, 7 Nov 2016 11:59:50 +0000 (12:59 +0100)]
Use msgclass to determine if a mail is crypto

* src/mail.cpp (is_crypto_mail): Use messageclass instead
of processed.
* src/mail.h: Update accordingly.

--
This makes the function usable after prerproceessing and
not only after decryption.

3 years agoAdd IID and install functions for explorer sinks
Andre Heinecke [Mon, 7 Nov 2016 11:57:05 +0000 (12:57 +0100)]
Add IID and install functions for explorer sinks

* src/eventsinks.h (install_ExplorerEvents_sink)
(install_ExplorersEvents_sink): Declare.
* src/oomhelp.h: Add missing uuids.

3 years agoUse shared_ptr for parser object
Andre Heinecke [Mon, 7 Nov 2016 11:53:07 +0000 (12:53 +0100)]
Use shared_ptr for parser object

* src/mail.cpp (m_parser): Change to shared_ptr
(Mail::parsing_done): Check if parser already deleted.
* src/mail.h: Update accordingly.

--
The state in which this happens should no longer be
reached due to the previous commit that prevents
duplication in the uuid map. Still better handle
it.

3 years agoCheck for duplicates in mail map
Andre Heinecke [Mon, 7 Nov 2016 11:50:13 +0000 (12:50 +0100)]
Check for duplicates in mail map

* src/mail.cpp (Mail::set_uuid): Check for duplicates in mail
map and handle them.

--
Sometimes we have the troubling state that multiple
item load events occur for the same mail,
as identified by uuid. This is bad but now at least
we have some handling and report it as an error
otherwise it could lead to cases where a parser
returned for a wrong mail

According to documentation this should not
happen as this means that multiple ItemLoad
events occured for the same mailobject without
unload / destruction of the mail.

But it happens. If you invalidate the UI
in the selection change event Outlook loads a
new mailobject for the mail. Might happen in
other surprising cases. We replace in that
case as experiments have shown that the last
mailobject is the one that is visible.

3 years agoFix build by adding new event handlers to Makefile
Andre Heinecke [Mon, 7 Nov 2016 11:40:43 +0000 (12:40 +0100)]
Fix build by adding new event handlers to Makefile

* src/Makefile.am (gpgol_SOURCES): Add new files.

--
Forgotten in previous commit.

3 years agoAdd explorer and explorers event handler
Andre Heinecke [Thu, 3 Nov 2016 13:46:57 +0000 (14:46 +0100)]
Add explorer and explorers event handler

* explorer-events.cpp: New. Invalidate ui on selection change.
* explorers-events.cpp: New. Install event handler for new explorers.
* gpgoladdin.cpp (GpgolAddin::~GpgolAddin): Release explorers event
handler.
(install_explorer_sinks): Install explorers and explorer event
handler.
(GpgolAddin::OnStartupComplete): call install_explorer_sinks

--
This fixes the problem that without another read by outlook
the state of the ui might not have matched to the signature
state, which is critical as it may have shown the wrong sigstate.

3 years agoAdd mapi helpers for uuid retrieval
Andre Heinecke [Thu, 3 Nov 2016 12:39:54 +0000 (13:39 +0100)]
Add mapi helpers for uuid retrieval

* src/mapihelp.cpp, src/mapihelp.h: (get_gpgoluid_tag)
(mapi_get_uid): New.

--
Used in some experiments regarding UUID structures.

3 years agoAllow to reset uuid
Andre Heinecke [Thu, 3 Nov 2016 09:50:49 +0000 (10:50 +0100)]
Allow to reset uuid

* src/mail.cpp (Mail::set_uuid): Set uuid even if the mail
object already tracks a uuid.
* src/oomhelp.cpp (get_unique_id): Extend with uuid param.
* src/oomhelp.h: Update accordingly

--
This is important if we close with discard changes to set our
uuid again after the close.

3 years agoAdd close function to Mails
Andre Heinecke [Thu, 3 Nov 2016 09:48:52 +0000 (10:48 +0100)]
Add close function to Mails

* src/mail.cpp (Mail::close): New, close a mail.

--
Closing a Mail with discard changes prevents the Save Changes
popup without the requirement for a revert.

3 years agoAdd extra debug output for mail destruction
Andre Heinecke [Thu, 3 Nov 2016 09:47:49 +0000 (10:47 +0100)]
Add extra debug output for mail destruction

* src/mail.cpp (Mail::~Mail): Print uuid in dtor

3 years agoDisable revert all mails on quit
Andre Heinecke [Wed, 2 Nov 2016 10:34:16 +0000 (11:34 +0100)]
Disable revert all mails on quit

* src/application-events.cpp (EVENT_SINK_INVOKE): Disable
revert_all_mails.

--
Reverting all mails in quit brings outlook into a buggy state
in that it syncs the mail endlessly after the next start.

3 years agoInstall forms for InfoPath msg classes.
Andre Heinecke [Mon, 31 Oct 2016 11:36:01 +0000 (12:36 +0100)]
Install forms for InfoPath msg classes.

* forms/gpgol-form-encrypted.cfg,
 forms/gpgol-form-signed.cfg: New.
* src/olflange.cpp (install_forms): Install new forms.
* src/mimemaker.cpp (finalize_message): Use InfoPath msg classes.

--
This fixes that Outlook shows all our Mails as S/MIME signed
because we set the S/MIME message class when sending to enable
the behavior that it takes the MIME structure from the first
attachment.

It also fixes the display of reverted mails which was previously
wrong.

3 years agoFollow Outlook preference in alt. text/html mails
Andre Heinecke [Fri, 28 Oct 2016 14:44:14 +0000 (16:44 +0200)]
Follow Outlook preference in alt. text/html mails

* src/gpgoladdin.cpp (check_html_preferred): New. Read Outlook's
setting.
(GpgolAddin::OnStartupComplete): Check html state
* src/mail.cpp (Mail::decrypt_verify): Use plain placeholder
if html disabled.
(Mail::update_body): Use correct parts.
* src/main.cpp (read_options): Don't read preferHTML.
(write_options): Don't write preferHTML.
* src/parsecontroller.cpp: Add plain text template.
(format_error): Use it.
(ParseController::parse): Use it.

3 years agoDon't confuse Outlook and GpgME Versions
Andre Heinecke [Fri, 28 Oct 2016 14:43:13 +0000 (16:43 +0200)]
Don't confuse Outlook and GpgME Versions

* src/gpgoladdin.cpp (GpgolAddin::OnStartupComplete): Print
out proper version in debug output.

3 years agoAdd int / string property accessor setters
Andre Heinecke [Fri, 28 Oct 2016 13:38:14 +0000 (15:38 +0200)]
Add int / string property accessor setters

* src/oomhelp.cpp (put_pa_string, put_pa_int): New.
(put_pa_variant): Generic version of put_pa_string.
* src/oomhelp.h: Update accordingly.

3 years agoPass Mail object to mimemaker
Andre Heinecke [Fri, 28 Oct 2016 09:35:18 +0000 (11:35 +0200)]
Pass Mail object to mimemaker

--
Changelog ommitet because of trivial changes.

Passing the Mail object will allow us to modify / read our central
Data structure in the old mimemaker code.

3 years agoAdd some helper functions to Mail object
Andre Heinecke [Fri, 28 Oct 2016 09:23:54 +0000 (11:23 +0200)]
Add some helper functions to Mail object

* src/mail.cpp, src/mail.h (Mail::remove_attachments)
(Mail::add_attachments, get_string, Mail::get_body)
(Mail::get_html_body, Mail::get_recipients): New.

--
These helpers can be usefull even if we still use MAPI
to encrypt.

3 years agoRemove AfterWrite Windowmessage hack
Andre Heinecke [Fri, 28 Oct 2016 08:46:39 +0000 (10:46 +0200)]
Remove AfterWrite Windowmessage hack

* src/mailitem-events.cpp (EVENT_SINK_INVOKE): Call save in
the send event to trigger the write and then send the mail.
(request_send): Removed.
* src/Windowmessages.cpp (request_send_mail): Removed.
src/Windowmessages.h (REQUEST_SEND_MAIL): Removed.

--
The old code was written under the bad assumption that
after write we could not send the mail directly.

This should fix the reported crashes when sending mails:

GnuPG-Bug-Id: 2335

3 years agoRevert "Implement encryption without MAPI data"
Andre Heinecke [Fri, 28 Oct 2016 08:34:48 +0000 (10:34 +0200)]
Revert "Implement encryption without MAPI data"

This reverts commit 2b376a48241aaef927ab1ffd6e7d213480d6751e.

--
While the mails were correctly formatted in the sent mail folder
this didn't work. Outlook always sent out the mails empty without
attachments.

3 years agoImplement encryption without MAPI data
Andre Heinecke [Thu, 27 Oct 2016 15:48:06 +0000 (17:48 +0200)]
Implement encryption without MAPI data

* src/attachment.cpp (Attachment::get_data_string): New helper.
* src/attachment.h: Declare get_data_string.
* src/mail.cpp, src/mail.h (Mail::remove_attachments)
(Mail::add_attachments, get_string, Mail::get_body)
(Mail::get_html_body, Mail::get_recipients): New.
* src/mailitem-events.cpp (request_send): Comment out for now.
(EVENT_SINK_INVOKE): Encrypt in send event.
* src/mimemaker.cpp (sink_data_write): New to work with GpgME::Data.
(encrypt_sign_mail): New works based on Objects.

--
This still uses the engine style encryption. In this first impl
only encryption is supported. Can do both inline and MIME.