Commits (2)
......@@ -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.
......
......@@ -2133,15 +2133,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 sendError = 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 sending error
sendError = Properties.Resources.Message_SendError + Environment.NewLine + Environment.NewLine + Properties.Resources.Message_SendUnencryptedConfirmation;
Log.Error("ProcessAndSendMessageAsync: Error processing message.");
sendError = true;
return null;
}
......@@ -2182,7 +2183,7 @@ namespace pEp
}
}
if (sendError == false)
if (string.IsNullOrEmpty(sendError))
{
// OUT-713: Prevent second "Empty subject" warning
if (string.IsNullOrEmpty(processedMessage.ShortMsg))
......@@ -2191,7 +2192,16 @@ namespace pEp
}
// Apply processed message to outgoing item
processedMessage.ApplyTo(sendItem, false, false, false);
try
{
processedMessage.ApplyTo(sendItem, false, false, false);
}
catch (AttachmentSizeException)
{
// Apply the original back to the message and show the error message
message.ApplyTo(omi, false, false, false);
sendError = Properties.Resources.Message_SendErrorAttachmentSize + Environment.NewLine + Environment.NewLine + Properties.Resources.Message_SendUnencryptedConfirmation;
}
// Set Reply or forward icon on original message if needed
string originalEntryId = sendItem.GetUserProperty(MailItemExtensions.USER_PROPERTY_KEY_ORIG_ENTRY_ID) as string;
......@@ -2212,11 +2222,14 @@ namespace pEp
{
sendItem.SetProcessingState(MailItemExtensions.ProcessingState.Processed);
}
}
// Send the message if no error occured or show error message
if (string.IsNullOrEmpty(sendError))
{
sendItem.Send();
}
if (sendError)
else
{
Log.Error("ProcessAndSendMessageAsync: Send failure.");
bool cancel = false;
......@@ -2225,12 +2238,16 @@ namespace pEp
// 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);
DialogResult result = MessageBox.Show(sendError,
Properties.Resources.Message_TitlePEPError,
MessageBoxButtons.YesNo,
MessageBoxIcon.Error);
cancel = (result != DialogResult.Yes);
if (cancel)
{
sendItem?.DeleteUserProperty(MailItemExtensions.USER_PROPERTY_KEY_PROCESSING_STATE);
}
}
Log.Info("ProcessAndSendMessageAsync: Error during sending. " + (cancel ? "User aborted sending." : "user chose to send mail unencrypted."));
......@@ -2241,10 +2258,10 @@ namespace pEp
sendItem.Send();
}
}
}
catch (Exception ex)
{
sendError = true;
Log.Error("ProcessAndSendMessageAsync: Error sending message. " + ex.ToString());
}
finally
......
......@@ -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
{
......
......@@ -1072,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>
......
......@@ -943,4 +943,7 @@ By buying the full version you can protect the privacy of this message.</value>
<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
......@@ -2603,9 +2603,9 @@ 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;
string sendError = Properties.Resources.Message_SendError + Environment.NewLine + Environment.NewLine + Properties.Resources.Message_SendUnencryptedConfirmation;
try
{
......@@ -2635,7 +2635,17 @@ namespace pEp
}
// Apply processed message to outgoing item
processedMessage.ApplyTo(omi, false, false, false);
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);
sendError = Properties.Resources.Message_SendErrorAttachmentSize + Environment.NewLine + Environment.NewLine + Properties.Resources.Message_SendUnencryptedConfirmation;
throw;
}
// Set Reply or forward icon on original message if needed
string originalEntryId = omi.GetUserProperty(MailItemExtensions.USER_PROPERTY_KEY_ORIG_ENTRY_ID) as string;
......@@ -2682,11 +2692,16 @@ namespace pEp
// Ask the user to continue (not for automatic messages)
if (omi?.GetIsAutoConsume() != true)
{
result = MessageBox.Show(sendUnencryptedWarning,
result = MessageBox.Show(sendError,
Properties.Resources.Message_TitlePEPError,
MessageBoxButtons.YesNo,
MessageBoxIcon.Error);
cancel = (result != DialogResult.Yes);
if (cancel)
{
omi.DeleteUserProperty(MailItemExtensions.USER_PROPERTY_KEY_PROCESSING_STATE);
}
}
Log.Info("Application_ItemSend: Error during sending. " + (cancel ? "User aborted sending." : "user chose to send mail unencrypted."));
......