[git] GpgOL - branch, master, updated. gpgol-2.0.6-75-gb4c25ec
by Andre Heinecke
cvs at cvs.gnupg.org
Tue Mar 6 15:17:47 CET 2018
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG extension for MS Outlook".
The branch, master has been updated
via b4c25ecda4b02f1c3dda9ce424ce21aa5471509e (commit)
via 4f97c6c378cc93c889c8f9f0977af77df4510f60 (commit)
from a243c8af5f07ea375f4953808d31c4933e79b928 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit b4c25ecda4b02f1c3dda9ce424ce21aa5471509e
Author: Andre Heinecke <aheinecke at intevation.de>
Date: Tue Mar 6 15:11:26 2018 +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
(reading).
--
GnuPG-Bug-Id: T3802
diff --git a/src/mail.cpp b/src/mail.cpp
index 5fd8c55..db27ee6 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -1259,13 +1259,19 @@ Mail::update_oom_data ()
outlook will keep the SenderEmailAddress of UserA. This is all
so horrible. */
buf = get_sender_SenderEMailAddress (m_mailitem);
+
+ if (!buf)
+ {
+ /* Try the sender Object */
+ buf = get_sender_Sender (m_mailitem);
+ }
}
if (!buf)
{
buf = get_sender_SendUsingAccount (m_mailitem, &m_is_gsuite);
}
- if (!buf)
+ if (!buf && !is_crypto_mail ())
{
/* Try the sender Object */
buf = get_sender_Sender (m_mailitem);
commit 4f97c6c378cc93c889c8f9f0977af77df4510f60
Author: Andre Heinecke <aheinecke at intevation.de>
Date: Tue Mar 6 15:02:41 2018 +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.
diff --git a/src/mail.cpp b/src/mail.cpp
index 07b41a7..5fd8c55 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -1224,7 +1224,7 @@ Mail::wipe (bool force)
int
Mail::update_oom_data ()
{
- LPDISPATCH sender = NULL;
+ char *buf = nullptr;
log_debug ("%s:%s", SRCNAME, __func__);
if (!is_crypto_mail())
@@ -1258,98 +1258,33 @@ Mail::update_oom_data ()
you send from the folder of userA but change the from to userB
outlook will keep the SenderEmailAddress of UserA. This is all
so horrible. */
- char *type = get_oom_string (m_mailitem, "SenderEmailType");
- if (type && !strcmp ("SMTP", type))
- {
- char *senderMail = get_oom_string (m_mailitem, "SenderEmailAddress");
- if (senderMail)
- {
- log_debug ("%s:%s Sender found", SRCNAME, __func__);
- m_sender = senderMail;
- xfree (senderMail);
- xfree (type);
- return 0;
- }
- }
- xfree (type);
+ buf = get_sender_SenderEMailAddress (m_mailitem);
}
- sender = get_oom_object (m_mailitem, "SendUsingAccount");
- if (sender)
- {
- char *buf = get_oom_string (sender, "SmtpAddress");
- char *dispName = get_oom_string (sender, "DisplayName");
- gpgol_release (sender);
- /* Check for G Suite account */
- if (dispName && !strcmp ("G Suite", dispName))
- {
- m_is_gsuite = true;
- }
- xfree (dispName);
- if (buf && strlen (buf))
- {
- log_debug ("%s:%s Sender fallback 1", SRCNAME, __func__);
- m_sender = buf;
- xfree (buf);
- return 0;
- }
- xfree (buf);
+ if (!buf)
+ {
+ buf = get_sender_SendUsingAccount (m_mailitem, &m_is_gsuite);
}
- /* Fallback to Sender object */
- sender = get_oom_object (m_mailitem, "Sender");
- if (sender)
+ if (!buf)
{
- char *buf = get_pa_string (sender, PR_SMTP_ADDRESS_DASL);
- gpgol_release (sender);
- if (buf && strlen (buf))
- {
- log_debug ("%s:%s Sender fallback 2", SRCNAME, __func__);
- m_sender = buf;
- xfree (buf);
- return 0;
- }
- xfree (buf);
- /* We have a sender object but not yet an smtp address likely
- exchange. Try some more propertys of the message. */
- buf = get_pa_string (m_mailitem, PR_TAG_SENDER_SMTP_ADDRESS);
- if (buf && strlen (buf))
- {
- log_debug ("%s:%s Sender fallback 3", SRCNAME, __func__);
- m_sender = buf;
- xfree (buf);
- return 0;
- }
- xfree (buf);
- buf = get_pa_string (m_mailitem, PR_TAG_RECEIVED_REPRESENTING_SMTP_ADDRESS);
- if (buf && strlen (buf))
- {
- log_debug ("%s:%s Sender fallback 4", SRCNAME, __func__);
- m_sender = buf;
- xfree (buf);
- return 0;
- }
- xfree (buf);
+ /* Try the sender Object */
+ buf = get_sender_Sender (m_mailitem);
}
- /* We don't have s sender object or SendUsingAccount,
- well, in that case fall back to the current user. */
- sender = get_oom_object (m_mailitem, "Session.CurrentUser");
- if (sender)
+ if (!buf)
{
- char *buf = get_pa_string (sender, PR_SMTP_ADDRESS_DASL);
- gpgol_release (sender);
- if (buf && strlen (buf))
- {
- log_debug ("%s:%s Sender fallback 5", SRCNAME, __func__);
- m_sender = buf;
- xfree (buf);
- return 0;
- }
- xfree (buf);
+ /* We don't have s sender object or SendUsingAccount,
+ well, in that case fall back to the current user. */
+ buf = get_sender_CurrentUser (m_mailitem);
}
-
- log_debug ("%s:%s: All fallbacks failed.",
- SRCNAME, __func__);
- return -1;
+ if (!buf)
+ {
+ log_debug ("%s:%s: All fallbacks failed.",
+ SRCNAME, __func__);
+ return -1;
+ }
+ m_sender = buf;
+ xfree (buf);
+ return 0;
}
std::string
diff --git a/src/oomhelp.cpp b/src/oomhelp.cpp
index 69695f1..ba3d89f 100644
--- a/src/oomhelp.cpp
+++ b/src/oomhelp.cpp
@@ -1900,3 +1900,105 @@ get_account_for_mail (const char *mbox)
return nullptr;
}
+
+char *
+get_sender_SendUsingAccount (LPDISPATCH mailitem, bool *r_is_GSuite)
+{
+ LPDISPATCH sender = get_oom_object (mailitem, "SendUsingAccount");
+ if (!sender)
+ {
+ return nullptr;
+ }
+
+ char *buf = get_oom_string (sender, "SmtpAddress");
+ char *dispName = get_oom_string (sender, "DisplayName");
+ gpgol_release (sender);
+
+ /* Check for G Suite account */
+ if (dispName && !strcmp ("G Suite", dispName) && r_is_GSuite)
+ {
+ *r_is_GSuite = true;
+ }
+ xfree (dispName);
+ if (buf && strlen (buf))
+ {
+ log_debug ("%s:%s: found sender", SRCNAME, __func__);
+ return buf;
+ }
+ xfree (buf);
+ return nullptr;
+}
+
+char *
+get_sender_Sender (LPDISPATCH mailitem)
+{
+ LPDISPATCH sender = get_oom_object (mailitem, "Sender");
+ if (!sender)
+ {
+ return nullptr;
+ }
+ char *buf = get_pa_string (sender, PR_SMTP_ADDRESS_DASL);
+ gpgol_release (sender);
+ if (buf && strlen (buf))
+ {
+ log_debug ("%s:%s Sender fallback 2", SRCNAME, __func__);
+ return buf;
+ }
+ xfree (buf);
+ /* We have a sender object but not yet an smtp address likely
+ exchange. Try some more propertys of the message. */
+ buf = get_pa_string (mailitem, PR_TAG_SENDER_SMTP_ADDRESS);
+ if (buf && strlen (buf))
+ {
+ log_debug ("%s:%s Sender fallback 3", SRCNAME, __func__);
+ return buf;
+ }
+ xfree (buf);
+ buf = get_pa_string (mailitem, PR_TAG_RECEIVED_REPRESENTING_SMTP_ADDRESS);
+ if (buf && strlen (buf))
+ {
+ log_debug ("%s:%s Sender fallback 4", SRCNAME, __func__);
+ return buf;
+ }
+ xfree (buf);
+ return nullptr;
+}
+
+char *
+get_sender_CurrentUser (LPDISPATCH mailitem)
+{
+ LPDISPATCH sender = get_oom_object (mailitem,
+ "Session.CurrentUser");
+ if (!sender)
+ {
+ return nullptr;
+ }
+ char *buf = get_pa_string (sender, PR_SMTP_ADDRESS_DASL);
+ gpgol_release (sender);
+ if (buf && strlen (buf))
+ {
+ log_debug ("%s:%s Sender fallback 5", SRCNAME, __func__);
+ return buf;
+ }
+ xfree (buf);
+ return nullptr;
+}
+
+char *
+get_sender_SenderEMailAddress (LPDISPATCH mailitem)
+{
+
+ char *type = get_oom_string (mailitem, "SenderEmailType");
+ if (type && !strcmp ("SMTP", type))
+ {
+ char *senderMail = get_oom_string (mailitem, "SenderEmailAddress");
+ if (senderMail)
+ {
+ log_debug ("%s:%s: Sender found", SRCNAME, __func__);
+ xfree (type);
+ return senderMail;
+ }
+ }
+ xfree (type);
+ return nullptr;
+}
diff --git a/src/oomhelp.h b/src/oomhelp.h
index 430fee1..2af096b 100644
--- a/src/oomhelp.h
+++ b/src/oomhelp.h
@@ -333,7 +333,13 @@ HWND get_active_hwnd (void);
LPDISPATCH create_mail (void);
LPDISPATCH get_account_for_mail (const char *mbox);
+
+/* Sender fallbacks. All return either null or a malloced address. */
+char *get_sender_CurrentUser (LPDISPATCH mailitem);
+char *get_sender_Sender (LPDISPATCH mailitem);
+char *get_sender_SenderEMailAddress (LPDISPATCH mailitem);
#ifdef __cplusplus
+char *get_sender_SendUsingAccount (LPDISPATCH mailitem, bool *r_is_GSuite);
}
#endif
#endif /*OOMHELP_H*/
-----------------------------------------------------------------------
Summary of changes:
src/mail.cpp | 109 +++++++++++++-------------------------------------------
src/oomhelp.cpp | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++
src/oomhelp.h | 6 ++++
3 files changed, 133 insertions(+), 84 deletions(-)
hooks/post-receive
--
GnuPG extension for MS Outlook
http://git.gnupg.org
More information about the Gnupg-commits
mailing list