Commits (10)
......@@ -253,6 +253,37 @@ namespace pEp
return enabled;
}
/// <summary>
/// Gets the current engine version with the specified amount of digits.
/// </summary>
/// <param name="digits">How many digits of the version to return.</param>
/// <returns>The pEp engine version or null if an error occured.</returns>
public static string GetPEPEngineVersion(int digits)
{
try
{
var version = ThisAddIn.PEPEngine.GetEngineVersion();
var parts = version.Split('.');
Debug.Assert(parts.Length > 1);
var parsedVersion = parts[0];
for (int i = 1; i < digits; i++)
{
Debug.Assert(parts.Length > i);
if (parts.Length > i)
{
parsedVersion += "." + parts[i];
}
}
return parsedVersion;
}
catch (Exception ex)
{
Log.Error("GetPEPEngineVersion: Error occured. " + ex.ToString());
}
return null;
}
/// <summary>
/// Gets the Trustwords for the two given identities.
/// This will never return null.
......
......@@ -358,7 +358,7 @@ namespace pEp
{
this.SetOriginallyEncryptedStatus(omi);
if (omi.GetIsInSecureStore())
if (omi.GetIsInSecureStore() && omi.GetIsSecure())
{
Outlook.MailItem mirror = null;
Outlook.MailItem reply = null;
......@@ -1203,7 +1203,7 @@ namespace pEp
}
else
{
Log.Error("ProcessAndGetRating: Error saving mirror. Mirror is null.");
Log.Error("ProcessAndGetRating: No mirror. " + ((processedMessage?.IsSecure == true) ? "Error occured." : "Unencrypted message"));
}
/* If we have a modified source and are on an untrusted server, apply
......@@ -1229,20 +1229,6 @@ namespace pEp
// Trusted server: apply message and save
processedMessage.ApplyTo(this.internalMailItem, true, false);
saveInternalMailItem = true;
// Hidden attachments need some properties to be set on the main thread after processing
int hiddenAttachmentsCount = processedMessage.Attachments?.Where(a => a.IsHidden)?.Count() ?? 0;
if (hiddenAttachmentsCount > 0)
{
result.HiddenAttachments = true;
// If we have only hidden attachments, we need to hide the attachments icon (paperclip)
if (processedMessage.Attachments.Count == hiddenAttachmentsCount)
{
// Note: The documented MAPI property PidLidSmartNoAttach (0x8514000B) doesn't work for some reason
result.PropertiesToSet.Add(MapiProperty.PidTagSmartNoAttach2, true);
}
}
}
}
// If processed message is null (= didn't run through decryption (again)), update UI rating
......@@ -1304,6 +1290,22 @@ namespace pEp
// Save internal mail item if necessary
if (saveInternalMailItem)
{
// If the internal mail item has been changed, check for hidden attachments that need
// some properties to be set on the main thread after processing
int hiddenAttachmentsCount = processedMessage?.Attachments?.Where(a => a.IsHidden)?.Count() ?? 0;
if (hiddenAttachmentsCount > 0)
{
result.HiddenAttachments = true;
// If we have only hidden attachments, we need to hide the attachments icon (paperclip)
if (processedMessage.Attachments.Count == hiddenAttachmentsCount)
{
// Note: The documented MAPI property PidLidSmartNoAttach (0x8514000B) doesn't work for some reason
result.PropertiesToSet.Add(MapiProperty.PidTagSmartNoAttach2, true);
}
}
// Now save the mail item
bool saveError = false;
try
{
......
......@@ -2126,6 +2126,142 @@ namespace pEp
}
}
/// <summary>
/// Applies the processed message to the message to send out and send it or show an error message if an error occurs.
/// </summary>
/// <param name="omi">The Outlook mail item to process with.</param>
/// <param name="message">The original message.</param>
/// <param name="processedMessage">The processed message.</param>
/// <param name="processingErrorMessage">The error message in case an error occured during processing.</param>
/// <param name="processedInBackground">Whether the message has been processed in a background thread.</param>
/// <param name="cancel">Whether to cancel sending.</param>
public static void ApplyAndSendMessage(this Outlook.MailItem omi,
PEPMessage message,
PEPMessage processedMessage,
string processingErrorMessage,
bool processedInBackground,
out bool cancel)
{
cancel = false;
if (string.IsNullOrEmpty(processingErrorMessage))
{
// OUT-713: Prevent second "Empty subject" warning
if (string.IsNullOrEmpty(processedMessage.ShortMsg))
{
processedMessage.ShortMsg = " ";
}
// Apply processed message to outgoing item
try
{
processedMessage.ApplyTo(omi, false, false, false);
}
catch (AttachmentSizeException)
{
// Apply the original back to the message and show the error message
message.ApplyTo(omi, false, false, false);
processingErrorMessage = Properties.Resources.Message_SendErrorAttachmentSize + Environment.NewLine + Environment.NewLine + Properties.Resources.Message_SendUnencryptedConfirmation;
}
// Set Reply or forward icon on original message if needed
string originalEntryId = omi.GetUserProperty(MailItemExtensions.USER_PROPERTY_KEY_ORIG_ENTRY_ID) as string;
if (string.IsNullOrEmpty(originalEntryId) == false)
{
omi.AddReplyIconsToOriginal(originalEntryId);
}
// Avoid creation of 'winmail.dat' attachment if needed
if (processedMessage.IsSecure == false)
{
omi.SetProcessingState(MailItemExtensions.ProcessingState.ProcessedAvoidWinmailDat);
// Remove the originally encrypted user property to avoid showing the warning dialog twice
omi?.DeleteUserProperty(CryptableMailItem.USER_PROPERTY_KEY_IS_ORIGINALLY_ENCRYPTED);
}
else
{
omi.SetProcessingState(MailItemExtensions.ProcessingState.Processed);
}
}
// Send the message if no error occured or show error message
if (string.IsNullOrEmpty(processingErrorMessage))
{
if (processedInBackground)
{
omi.Send();
}
}
else
{
// Show an error message and determine whether the user wishes to cancel sending
omi.ShowProcessingError(processingErrorMessage, processedInBackground, out cancel);
if ((cancel == false) &&
(processedInBackground))
{
omi.SetProcessingState(MailItemExtensions.ProcessingState.Processed);
omi.Send();
}
}
}
/// <summary>
/// Shows an error message and captures the user input, whether to cancel sending.
/// </summary>
/// <param name="omi">The Outlook mail item to process with.</param>
/// <param name="errorMessage">The error message to show.</param>
/// <param name="processedInBackground">Whether the message was processed in the background.</param>
/// <param name="cancel">Whether the user selected to cancel sending.</param>
public static void ShowProcessingError(this Outlook.MailItem omi, string errorMessage, bool processedInBackground, out bool cancel)
{
cancel = false;
Log.Error("ShowProcessingError: Error occured during processing. Showing error message.");
if (processedInBackground)
{
omi.Display();
}
// Ask the user to continue (not for automatic messages)
if (omi?.GetIsAutoConsume() != true)
{
DialogResult result = MessageBox.Show(errorMessage,
Properties.Resources.Message_TitlePEPError,
MessageBoxButtons.YesNo,
MessageBoxIcon.Error);
cancel = (result != DialogResult.Yes);
if (cancel)
{
omi?.DeleteUserProperty(MailItemExtensions.USER_PROPERTY_KEY_PROCESSING_STATE);
}
}
Log.Info("ShowProcessingError: " + (cancel ? "User aborted sending." : "User chose to send mail unencrypted."));
}
/// <summary>
/// Processes a mail item synchronously and sends it out.
/// </summary>
/// <param name="omi">The Outlook mail item to process with.</param>
/// <param name="message">The message to process.</param>
/// <param name="cancel">Whether to cancel sending.</param>
public static void ProcessAndSendMessage(this Outlook.MailItem omi, PEPMessage message, out bool cancel)
{
string processingError = null;
if (MsgProcessor.ProcessSentMessage(message, Globals.ThisAddIn.Settings.ExtraKeys, out PEPMessage processedMessage) != Globals.ReturnStatus.Success)
{
// Set the processing error
processingError = Properties.Resources.Message_SendError + Environment.NewLine + Environment.NewLine + Properties.Resources.Message_SendUnencryptedConfirmation;
Log.Error("ProcessAndSendMessageAsync: Error processing message.");
}
omi.ApplyAndSendMessage(message, processedMessage, processingError, false, out cancel);
}
/// <summary>
/// Processes a mail item asynchronously and sends it out.
/// </summary>
......@@ -2133,15 +2269,16 @@ namespace pEp
/// <param name="message">The message to process.</param>
public static async void ProcessAndSendMessageAsync(this Outlook.MailItem omi, PEPMessage message)
{
bool sendError = false;
string processingError = null;
PEPMessage processedMessage = await Task.Run(() =>
{
// Process outgoing message
if (MsgProcessor.ProcessSentMessage(message, Globals.ThisAddIn.Settings.ExtraKeys, out PEPMessage msg) != Globals.ReturnStatus.Success)
{
// Set the processing error
processingError = Properties.Resources.Message_SendError + Environment.NewLine + Environment.NewLine + Properties.Resources.Message_SendUnencryptedConfirmation;
Log.Error("ProcessAndSendMessageAsync: Error processing message.");
sendError = true;
return null;
}
......@@ -2182,69 +2319,10 @@ namespace pEp
}
}
if (sendError == false)
{
// OUT-713: Prevent second "Empty subject" warning
if (string.IsNullOrEmpty(processedMessage.ShortMsg))
{
processedMessage.ShortMsg = " ";
}
// Apply processed message to outgoing item
processedMessage.ApplyTo(sendItem, false, false, false);
// Set Reply or forward icon on original message if needed
string originalEntryId = sendItem.GetUserProperty(MailItemExtensions.USER_PROPERTY_KEY_ORIG_ENTRY_ID) as string;
if (string.IsNullOrEmpty(originalEntryId) == false)
{
sendItem.AddReplyIconsToOriginal(originalEntryId);
}
// Avoid creation of 'winmail.dat' attachment if needed
if (processedMessage.IsSecure == false)
{
sendItem.SetProcessingState(MailItemExtensions.ProcessingState.ProcessedAvoidWinmailDat);
// Remove the originally encrypted user property to avoid showing the warning dialog twice
sendItem?.DeleteUserProperty(CryptableMailItem.USER_PROPERTY_KEY_IS_ORIGINALLY_ENCRYPTED);
}
else
{
sendItem.SetProcessingState(MailItemExtensions.ProcessingState.Processed);
}
sendItem.Send();
}
if (sendError)
{
Log.Error("ProcessAndSendMessageAsync: Send failure.");
bool cancel = false;
sendItem.Display();
// Ask the user to continue (not for automatic messages)
if (sendItem?.GetIsAutoConsume() != true)
{
string sendUnencryptedWarning = Properties.Resources.Message_SendError + Environment.NewLine + Environment.NewLine + Properties.Resources.Message_SendUnencryptedConfirmation;
DialogResult result = MessageBox.Show(sendUnencryptedWarning,
Properties.Resources.Message_TitlePEPError,
MessageBoxButtons.YesNo,
MessageBoxIcon.Error);
cancel = (result != DialogResult.Yes);
}
Log.Info("ProcessAndSendMessageAsync: Error during sending. " + (cancel ? "User aborted sending." : "user chose to send mail unencrypted."));
if (cancel == false)
{
sendItem.SetProcessingState(MailItemExtensions.ProcessingState.Processed);
sendItem.Send();
}
}
sendItem.ApplyAndSendMessage(message, processedMessage, processingError, true, out bool cancel);
}
catch (Exception ex)
{
sendError = true;
Log.Error("ProcessAndSendMessageAsync: Error sending message. " + ex.ToString());
}
finally
......@@ -2306,7 +2384,7 @@ namespace pEp
(PEPIdentity.GetOwnIdentity(omi, out ownIdentity, true) == Globals.ReturnStatus.Success))
{
receivedBy = ownIdentity;
Log.Verbose("GetReceivedByIdentity: Retrieved identity " + ( receivedBy?.Address ?? "<null>" ) + " using GetOwnIdentity");
Log.Verbose("GetReceivedByIdentity: Retrieved identity " + (receivedBy?.Address ?? "<null>") + " using GetOwnIdentity");
}
// OUT-769: Doublecheck to make sure it's an own account so that no priv key is generated for foreign identities
......
......@@ -3,7 +3,6 @@ using pEpCOMServerAdapterLib;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.InteropServices;
using Outlook = Microsoft.Office.Interop.Outlook;
......@@ -30,7 +29,7 @@ namespace pEp
private pEpIdentity internalIdentity;
private static Dictionary<string, string> userIdCache = new Dictionary<string, string>();
private static Dictionary<string, string> userIdCache = new Dictionary<string, string>();
/**************************************************************
*
......
......@@ -2176,9 +2176,10 @@ namespace pEp
* and throw dedicated exception in that case (needed for user feedback).
*/
var pgpgMIMESizeInKB = pgpMIME.Data.Length / 1000; // Get size in kB
if (pgpgMIMESizeInKB > omi.GetMaxMailSize())
var maxMailSize = omi.GetMaxMailSize();
if (pgpgMIMESizeInKB > maxMailSize)
{
throw new AttachmentSizeException(string.Format("Failed to add PGP/MIME attachment due to size restrictions. Allowed size: {0} kB. Actual size: {1} kB.", omi.GetMaxMailSize(), pgpgMIMESizeInKB));
throw new AttachmentSizeException(string.Format("Failed to add PGP/MIME attachment due to size restrictions. Allowed size: {0} kB. Actual size: {1} kB.", maxMailSize, pgpgMIMESizeInKB));
}
else
{
......
......@@ -58,7 +58,7 @@ namespace pEp
public const string ACCOUNT_SETTING_USER_NAME_DEFAULT = null;
public static readonly string[] ACCOUNT_WHITELIST_DEFAULT = new string[] { };
public static pEpCipherSuite CIPHER_SUITE_DEFAULT = pEpCipherSuite.pEpCipherSuiteDefault;
public const string CRASH_REPORT_SEND_ADDRESS_DEFAULT = "crashreport@prettyeasyprivacy.com";
public const string CRASH_REPORT_SEND_ADDRESS_DEFAULT = "crashreport@pEp.security";
public const string CULTURE_CODE_DEFAULT = "en";
public const bool DELETE_MIRROR_MESSAGES_DEFAULT = false;
public const string DISCLAIMER_TEXT_DEFAULT = null;
......
......@@ -46,5 +46,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.257.0")]
[assembly: AssemblyFileVersion("1.1.257.0")]
[assembly: AssemblyVersion("1.1.258.0")]
[assembly: AssemblyFileVersion("1.1.258.0")]
......@@ -873,6 +873,15 @@ namespace pEp.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to In order to make the communication with this communication partner Secure &amp; Trusted, you will have to compare the Trustwords with this communication partner and ensure they match yours..
/// </summary>
public static string IntroTutorialSecureAndTrustedExplanation {
get {
return ResourceManager.GetString("IntroTutorialSecureAndTrustedExplanation", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Please enter the fingerprint of the key you want to import:.
/// </summary>
......@@ -1063,6 +1072,15 @@ namespace pEp.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to The mail size exceeds the allowable limit for encryption..
/// </summary>
public static string Message_SendErrorAttachmentSize {
get {
return ResourceManager.GetString("Message_SendErrorAttachmentSize", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to An internet or mail server connection is required to securely send this message. It&apos;s recommended to save this message as a draft until a connection is re-established..
/// </summary>
......
This diff is collapsed.
......@@ -933,4 +933,10 @@ Mit der Vollversion schützen Sie Ihre Daten auch in ausgehenden Nachrichten.</v
<data name="Options_EncryptedGroupsNoSubscribedGroupsText" xml:space="preserve">
<value>Keine Gruppenmitgliedschaften vorhanden</value>
</data>
<data name="IntroTutorialSecureAndTrustedExplanation" xml:space="preserve">
<value>Um zu garantieren, dass Ihre Nachrichtenverbindung nicht nur sicher, sondern auch verifiziert ist, vergleichen Sie die Trustwords mit denen Ihres Kommunikationspartners und stellen Sie sicher, dass sie übereinstimmen.</value>
</data>
<data name="Message_SendErrorAttachmentSize" xml:space="preserve">
<value>Die Mailgröße überschreitet die zulässige Größenbeschränkung für die Verschlüsselung.</value>
</data>
</root>
\ No newline at end of file
......@@ -932,4 +932,10 @@ Estás seguro de que quieras importar y usar esta clave?</value>
<data name="Options_EncryptedGroupsNoSubscribedGroupsText" xml:space="preserve">
<value>No formas parte de ningún grupo</value>
</data>
<data name="IntroTutorialSecureAndTrustedExplanation" xml:space="preserve">
<value>Para que la comunicación con este interlocutor no solo sea segura sino también verificada, compara las Trustwords con las del interlocutor y asegúrate de que coincidan.</value>
</data>
<data name="Message_SendErrorAttachmentSize" xml:space="preserve">
<value>El tamaño del correo excede el límite permitido para el cifrado.</value>
</data>
</root>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
......@@ -940,4 +940,10 @@ By buying the full version you can protect the privacy of this message.</value>
<data name="Options_EncryptedGroupsNoSubscribedGroupsText" xml:space="preserve">
<value>Currently you are not part of any encrypted group</value>
</data>
<data name="IntroTutorialSecureAndTrustedExplanation" xml:space="preserve">
<value>In order to make the communication with this communication partner Secure &amp; Trusted, you will have to compare the Trustwords with this communication partner and ensure they match yours.</value>
</data>
<data name="Message_SendErrorAttachmentSize" xml:space="preserve">
<value>The mail size exceeds the allowable limit for encryption.</value>
</data>
</root>
\ No newline at end of file
......@@ -894,4 +894,7 @@ Are you sure you want to import and use this key?</value>
<data name="MixedConfigWarning_MessageText" xml:space="preserve">
<value>We're detecting that another p≡p device is not trusting the server for account {0}. This device is configured to trust the same server. This is most likely a configuration mistake, which can result in unexpected behavior. Please check your settings and configure all devices the same.</value>
</data>
<data name="Message_SendErrorAttachmentSize" xml:space="preserve">
<value>Elektronik postanın boyutu, şifreleme için izin verilen sınırı aşıyor.</value>
</data>
</root>
\ No newline at end of file
......@@ -2564,6 +2564,7 @@ namespace pEp
if (processingState == MailItemExtensions.ProcessingState.Processed)
{
Log.Verbose("Application_ItemSend: Message already processed. Sending directly...");
omi.DeleteUserProperty(MailItemExtensions.USER_PROPERTY_KEY_PROCESSING_STATE);
return;
}
else if (processingState == MailItemExtensions.ProcessingState.ProcessedAvoidWinmailDat)
......@@ -2579,7 +2580,7 @@ namespace pEp
// If S/MIME is enabled, add pEp header and do not process
if (omi.GetIsSMIMEEnabled())
{
omi.SetPEPProperty(MailItemExtensions.PEPProperty.PEPProtocolVersion, "2.1");
omi.SetPEPProperty(MailItemExtensions.PEPProperty.PEPProtocolVersion, AdapterExtensions.GetPEPEngineVersion(2));
processMessage = false;
}
else if (omi.GetIsForcefullyProtected())
......@@ -2602,15 +2603,11 @@ namespace pEp
// If no special case was found, process normally
if (processMessage)
{
string sendUnencryptedWarning = Properties.Resources.Message_SendError + Environment.NewLine + Environment.NewLine + Properties.Resources.Message_SendUnencryptedConfirmation;
DialogResult result;
Globals.ReturnStatus status;
try
{
Log.Verbose("Application_ItemSend: Starting encryption and message processing.");
status = PEPMessage.Create(omi, out PEPMessage message);
Globals.ReturnStatus status = PEPMessage.Create(omi, out PEPMessage message);
if (status == Globals.ReturnStatus.Success)
{
/* If the message was marked to be processed in the background, cancel the normal
......@@ -2627,27 +2624,7 @@ namespace pEp
{
// Process outgoing message
Log.Verbose("Application_ItemSend: Normal processing.");
if (MsgProcessor.ProcessSentMessage(message, Globals.ThisAddIn.Settings.ExtraKeys, out PEPMessage processedMessage) != Globals.ReturnStatus.Success)
{
throw new Exception("Error processing message.");
}
// Apply processed message to outgoing item
processedMessage.ApplyTo(omi, false, false, false);
// Set Reply or forward icon on original message if needed
string originalEntryId = omi.GetUserProperty(MailItemExtensions.USER_PROPERTY_KEY_ORIG_ENTRY_ID) as string;
if (string.IsNullOrEmpty(originalEntryId) == false)
{
omi.AddReplyIconsToOriginal(originalEntryId);
}
// Avoid creation of 'winmail.dat' attachment if needed
if (processedMessage.IsSecure == false)
{
omi.AvoidWinmailDatAttachment();
}
omi.ProcessAndSendMessage(message, out cancel);
}
}
else if (status == Globals.ReturnStatus.FailureNoConnection)
......@@ -2673,22 +2650,10 @@ namespace pEp
{
Log.Error("Application_ItemSend: Send failure, " + ex.ToString());
if (processingState == MailItemExtensions.ProcessingState.ProcessInBackground)
{
omi.Display();
}
// Ask the user to continue (not for automatic messages)
if (omi?.GetIsAutoConsume() != true)
{
result = MessageBox.Show(sendUnencryptedWarning,
Properties.Resources.Message_TitlePEPError,
MessageBoxButtons.YesNo,
MessageBoxIcon.Error);
cancel = (result != DialogResult.Yes);
}
Log.Info("Application_ItemSend: Error during sending. " + (cancel ? "User aborted sending." : "user chose to send mail unencrypted."));
// Show an error message and determine whether the user wishes to cancel sending
omi.ShowProcessingError((Properties.Resources.Message_SendError + Environment.NewLine + Environment.NewLine + Properties.Resources.Message_SendUnencryptedConfirmation),
(processingState == MailItemExtensions.ProcessingState.ProcessInBackground),
out cancel);
}
}
}
......
......@@ -125,8 +125,8 @@
<labelControl id="LabelSpacer1"
label=" "/>
<hyperlink id="HyperlinkPEP"
label="www.prettyeasyprivacy.com"
target="https://prettyeasyprivacy.com"/>
label="www.pEp.security"
target="https://pEp.security"/>
</bottomItems>
</group>
</secondColumn>
......
......@@ -145,8 +145,8 @@
<labelControl id="LabelSpacer1"
label=" "/>
<hyperlink id="HyperlinkPEP"
label="www.prettyeasyprivacy.com"
target="https://prettyeasyprivacy.com"/>
label="www.pEp.security"
target="https://pEp.security"/>
</bottomItems>
</group>
</secondColumn>
......
......@@ -87,8 +87,8 @@
<labelControl id="LabelSpacer1"
label=" "/>
<hyperlink id="HyperlinkPEP"
label="www.prettyeasyprivacy.com"
target="https://prettyeasyprivacy.com"/>
label="www.pEp.security"
target="https://pEp.security"/>
</bottomItems>
</group>
</secondColumn>
......
......@@ -87,8 +87,8 @@
<labelControl id="LabelSpacer1"
label=" "/>
<hyperlink id="HyperlinkPEP"
label="www.prettyeasyprivacy.com"
target="https://prettyeasyprivacy.com"/>
label="www.pEp.security"
target="https://pEp.security"/>
</bottomItems>
</group>
</secondColumn>
......