Current WIP: optimizations
authorThomas
Fri, 07 Sep 2018 19:21:46 +0200
branchoptimizations
changeset 2362c1d0285f1a7f
parent 2358 5d193f09df27
child 2363 21803747b944
Current WIP:
- Update project to .NET 4.7
- Add Caching: cache all received and decrypted messages and check cache when opening message
- Add OutgoingRatingPreview: call directly OutgoingRatingPreview and full GetOutgoingRating after it
CryptableMailItem.cs
Extensions/MailItemExtensions.cs
PEPCache.cs
PEPMessage.cs
Properties/Resources.Designer.cs
Properties/Settings.Designer.cs
ThisAddIn.Designer.cs
ThisAddIn.Designer.xml
UI/FormRegionPrivacyStatus.cs
app.config
pEpForOutlook.csproj
packages.config
     1.1 --- a/CryptableMailItem.cs	Tue Sep 04 11:14:15 2018 +0200
     1.2 +++ b/CryptableMailItem.cs	Fri Sep 07 19:21:46 2018 +0200
     1.3 @@ -1687,6 +1687,19 @@
     1.4                  // Save rating in db
     1.5                  PEPDatabase.StoreOrUpdateRating(entryId, result.Rating);
     1.6  
     1.7 +                // Save message in cache
     1.8 +                if (isSecurelyStored)
     1.9 +                {
    1.10 +                    if (Mirror != null)
    1.11 +                    {
    1.12 +                        PEPCache.AddItemToCache(internalMailItem?.EntryID, Mirror);
    1.13 +                    }
    1.14 +                    else if (Message != null)
    1.15 +                    {
    1.16 +                        PEPCache.AddItemToCache(internalMailItem?.EntryID, Message);
    1.17 +                    }
    1.18 +                }
    1.19 +
    1.20                  // Release objects
    1.21                  mirrorMailItem = null;
    1.22  
     2.1 --- a/Extensions/MailItemExtensions.cs	Tue Sep 04 11:14:15 2018 +0200
     2.2 +++ b/Extensions/MailItemExtensions.cs	Fri Sep 07 19:21:46 2018 +0200
     2.3 @@ -2328,7 +2328,8 @@
     2.4          /// ForceUnencrypted and return always calculated engine rating.</param>
     2.5          /// <returns>The outgoing rating for the mail item.</returns>
     2.6          public static pEpRating GetOutgoingRating(this Outlook.MailItem omi,
     2.7 -                                                  bool ignoreOptions = false)
     2.8 +                                                  bool ignoreOptions = false,
     2.9 +                                                  bool previewOnly = false)
    2.10          {
    2.11              pEpRating rating = pEpRating.pEpRatingUndefined;
    2.12  
    2.13 @@ -2380,7 +2381,7 @@
    2.14              PEPMessage message;
    2.15              if (PEPMessage.Create(omi, out message, true, false) == Globals.ReturnStatus.Success)
    2.16              {
    2.17 -                rating = message?.GetOutgoingRating(ignoreOptions) ?? pEpRating.pEpRatingUndefined;
    2.18 +                rating = message?.GetOutgoingRating(ignoreOptions, previewOnly) ?? pEpRating.pEpRatingUndefined;
    2.19              }
    2.20              else
    2.21              {
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/PEPCache.cs	Fri Sep 07 19:21:46 2018 +0200
     3.3 @@ -0,0 +1,60 @@
     3.4 +using System;
     3.5 +using System.Runtime.Caching;
     3.6 +
     3.7 +namespace pEp
     3.8 +{
     3.9 +    internal class PEPCache
    3.10 +    {
    3.11 +        private static MemoryCache cache = MemoryCache.Default;
    3.12 +        private const int MAX_TIME = 4; // time in hours
    3.13 +
    3.14 +        public static bool AddItemToCache(string id, object item)
    3.15 +        {
    3.16 +            bool success = false;
    3.17 +
    3.18 +            if ((string.IsNullOrEmpty(id) == false) &&
    3.19 +                (item != null))
    3.20 +            {
    3.21 +                try
    3.22 +                {
    3.23 +                    success = (cache?.AddOrGetExisting(id, item, new CacheItemPolicy()) != null);
    3.24 +                }
    3.25 +                catch (Exception ex)
    3.26 +                {
    3.27 +                    success = false;
    3.28 +                    Log.Error("AddItemToCache: Error adding item to cache. " + ex.ToString());
    3.29 +                }
    3.30 +            }
    3.31 +            else
    3.32 +            {
    3.33 +                Log.Error("AddItemToCache: Error adding item to cache. Id or item are null.");
    3.34 +            }
    3.35 +
    3.36 +            return success;
    3.37 +        }
    3.38 +
    3.39 +        public static object GetItemFromCache(string id)
    3.40 +        {
    3.41 +            object item = null;
    3.42 +
    3.43 +            if (string.IsNullOrEmpty(id) == false)
    3.44 +            {
    3.45 +                try
    3.46 +                {
    3.47 +                    item = cache?.Get(id);
    3.48 +                }
    3.49 +                catch (Exception ex)
    3.50 +                {
    3.51 +                    item = null;
    3.52 +                    Log.Error("GetItemFromCache: Error getting item from cache. " + ex.ToString());
    3.53 +                }
    3.54 +            }
    3.55 +            else
    3.56 +            {
    3.57 +                Log.Error("GetItemFromCache: Error getting item from cache. Id is null.");
    3.58 +            }
    3.59 +
    3.60 +            return item;
    3.61 +        }
    3.62 +    }
    3.63 +}
     4.1 --- a/PEPMessage.cs	Tue Sep 04 11:14:15 2018 +0200
     4.2 +++ b/PEPMessage.cs	Fri Sep 07 19:21:46 2018 +0200
     4.3 @@ -453,7 +453,8 @@
     4.4          /// <param name="ignoreOptions">Ignore user settings like ForceProtection or
     4.5          /// ForceUnencrypted and return always calculated engine rating.</param>
     4.6          /// </summary>
     4.7 -        public pEpRating GetOutgoingRating(bool ignoreOptions = false)
     4.8 +        public pEpRating GetOutgoingRating(bool ignoreOptions = false,
     4.9 +                                           bool previewOnly = false)
    4.10          {
    4.11              pEpRating rating = pEpRating.pEpRatingUndefined;
    4.12  
    4.13 @@ -489,7 +490,14 @@
    4.14  
    4.15              try
    4.16              {
    4.17 -                rating = ThisAddIn.PEPEngine.OutgoingMessageRating(workingMessage.ToCOMType());
    4.18 +                if (previewOnly)
    4.19 +                {
    4.20 +                    rating = ThisAddIn.PEPEngine.OutgoingMessageRatingPreview(workingMessage.ToCOMType());
    4.21 +                }
    4.22 +                else
    4.23 +                {
    4.24 +                    rating = ThisAddIn.PEPEngine.OutgoingMessageRating(workingMessage.ToCOMType());
    4.25 +                }
    4.26              }
    4.27              catch (Exception ex)
    4.28              {
    4.29 @@ -2818,7 +2826,7 @@
    4.30                          // Decode content object and copy to data property
    4.31                          using (var memStream = new MemoryStream())
    4.32                          {
    4.33 -                            currentAttachment.ContentObject?.DecodeTo(memStream);
    4.34 +                            currentAttachment.Content?.DecodeTo(memStream);
    4.35                              pEpAttachment.Data = memStream.ToArray();
    4.36                          }
    4.37  
    4.38 @@ -2842,7 +2850,7 @@
    4.39                          // Decode content object and copy to data property
    4.40                          using (var memStream = new MemoryStream())
    4.41                          {
    4.42 -                            (bodyPart as MimePart)?.ContentObject?.DecodeTo(memStream);
    4.43 +                            (bodyPart as MimePart)?.Content?.DecodeTo(memStream);
    4.44                              pEpAttachment.Data = memStream.ToArray();
    4.45                          }
    4.46  
     5.1 --- a/Properties/Resources.Designer.cs	Tue Sep 04 11:14:15 2018 +0200
     5.2 +++ b/Properties/Resources.Designer.cs	Fri Sep 07 19:21:46 2018 +0200
     5.3 @@ -19,7 +19,7 @@
     5.4      // class via a tool like ResGen or Visual Studio.
     5.5      // To add or remove a member, edit your .ResX file then rerun ResGen
     5.6      // with the /str option, or rebuild your VS project.
     5.7 -    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
     5.8 +    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
     5.9      [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    5.10      [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    5.11      public class Resources {
     6.1 --- a/Properties/Settings.Designer.cs	Tue Sep 04 11:14:15 2018 +0200
     6.2 +++ b/Properties/Settings.Designer.cs	Fri Sep 07 19:21:46 2018 +0200
     6.3 @@ -12,7 +12,7 @@
     6.4      
     6.5      
     6.6      [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
     6.7 -    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
     6.8 +    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.8.0.0")]
     6.9      internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
    6.10          
    6.11          private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
     7.1 --- a/ThisAddIn.Designer.cs	Tue Sep 04 11:14:15 2018 +0200
     7.2 +++ b/ThisAddIn.Designer.cs	Fri Sep 07 19:21:46 2018 +0200
     7.3 @@ -1,7 +1,7 @@
     7.4  //------------------------------------------------------------------------------
     7.5  // <auto-generated>
     7.6  //     This code was generated by a tool.
     7.7 -//     Runtime Version:4.0.30319.34014
     7.8 +//     Runtime Version:4.0.30319.42000
     7.9  //
    7.10  //     Changes to this file may cause incorrect behavior and will be lost if
    7.11  //     the code is regenerated.
    7.12 @@ -19,10 +19,10 @@
    7.13          
    7.14          internal Microsoft.Office.Tools.CustomTaskPaneCollection CustomTaskPanes;
    7.15          
    7.16 -        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "12.0.0.0")]
    7.17 +        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "15.0.0.0")]
    7.18          private global::System.Object missing = global::System.Type.Missing;
    7.19          
    7.20 -        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "12.0.0.0")]
    7.21 +        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "15.0.0.0")]
    7.22          internal Microsoft.Office.Interop.Outlook.Application Application;
    7.23          
    7.24          /// 
    7.25 @@ -35,7 +35,7 @@
    7.26          
    7.27          /// 
    7.28          [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    7.29 -        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "12.0.0.0")]
    7.30 +        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "15.0.0.0")]
    7.31          [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
    7.32          protected override void Initialize() {
    7.33              base.Initialize();
    7.34 @@ -50,7 +50,7 @@
    7.35          
    7.36          /// 
    7.37          [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    7.38 -        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "12.0.0.0")]
    7.39 +        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "15.0.0.0")]
    7.40          [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
    7.41          protected override void FinishInitialization() {
    7.42              this.InternalStartup();
    7.43 @@ -59,7 +59,7 @@
    7.44          
    7.45          /// 
    7.46          [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    7.47 -        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "12.0.0.0")]
    7.48 +        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "15.0.0.0")]
    7.49          [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
    7.50          protected override void InitializeDataBindings() {
    7.51              this.BeginInitialization();
    7.52 @@ -69,7 +69,7 @@
    7.53          
    7.54          /// 
    7.55          [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    7.56 -        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "12.0.0.0")]
    7.57 +        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "15.0.0.0")]
    7.58          [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
    7.59          private void InitializeCachedData() {
    7.60              if ((this.DataHost == null)) {
    7.61 @@ -82,14 +82,14 @@
    7.62          
    7.63          /// 
    7.64          [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    7.65 -        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "12.0.0.0")]
    7.66 +        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "15.0.0.0")]
    7.67          [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
    7.68          private void InitializeData() {
    7.69          }
    7.70          
    7.71          /// 
    7.72          [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    7.73 -        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "12.0.0.0")]
    7.74 +        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "15.0.0.0")]
    7.75          [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
    7.76          private void BindToData() {
    7.77          }
    7.78 @@ -117,7 +117,7 @@
    7.79          
    7.80          /// 
    7.81          [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    7.82 -        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "12.0.0.0")]
    7.83 +        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "15.0.0.0")]
    7.84          [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
    7.85          private void BeginInitialization() {
    7.86              this.BeginInit();
    7.87 @@ -126,7 +126,7 @@
    7.88          
    7.89          /// 
    7.90          [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    7.91 -        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "12.0.0.0")]
    7.92 +        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "15.0.0.0")]
    7.93          [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
    7.94          private void EndInitialization() {
    7.95              this.CustomTaskPanes.EndInit();
    7.96 @@ -135,7 +135,7 @@
    7.97          
    7.98          /// 
    7.99          [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
   7.100 -        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "12.0.0.0")]
   7.101 +        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "15.0.0.0")]
   7.102          [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
   7.103          private void InitializeControls() {
   7.104              this.CustomTaskPanes = Globals.Factory.CreateCustomTaskPaneCollection(null, null, "CustomTaskPanes", "CustomTaskPanes", this);
   7.105 @@ -143,7 +143,7 @@
   7.106          
   7.107          /// 
   7.108          [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
   7.109 -        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "12.0.0.0")]
   7.110 +        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "15.0.0.0")]
   7.111          [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
   7.112          private void InitializeComponents() {
   7.113          }
   7.114 @@ -157,7 +157,7 @@
   7.115          
   7.116          /// 
   7.117          [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
   7.118 -        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "12.0.0.0")]
   7.119 +        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "15.0.0.0")]
   7.120          [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
   7.121          protected override void OnShutdown() {
   7.122              this.CustomTaskPanes.Dispose();
   7.123 @@ -167,7 +167,7 @@
   7.124      
   7.125      /// 
   7.126      [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
   7.127 -    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "12.0.0.0")]
   7.128 +    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "15.0.0.0")]
   7.129      internal sealed partial class Globals {
   7.130          
   7.131          /// 
   7.132 @@ -231,7 +231,7 @@
   7.133      
   7.134      /// 
   7.135      [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
   7.136 -    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "12.0.0.0")]
   7.137 +    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "15.0.0.0")]
   7.138      internal sealed partial class ThisRibbonCollection : Microsoft.Office.Tools.Ribbon.RibbonCollectionBase {
   7.139          
   7.140          /// 
     8.1 --- a/ThisAddIn.Designer.xml	Tue Sep 04 11:14:15 2018 +0200
     8.2 +++ b/ThisAddIn.Designer.xml	Fri Sep 07 19:21:46 2018 +0200
     8.3 @@ -1,4 +1,4 @@
     8.4 -<hostitem:hostItem hostitem:baseType="Microsoft.Office.Tools.Outlook.OutlookAddInBase" hostitem:namespace="pEp" hostitem:className="ThisAddIn" hostitem:identifier="ThisAddIn" hostitem:primaryCookie="AddIn" hostitem:master="true" hostitem:factoryType="Microsoft.Office.Tools.Outlook.Factory" hostitem:startupIndex="0" xmlns:hostitem="http://schemas.microsoft.com/2004/VisualStudio/Tools/Applications/HostItem.xsd">
     8.5 +<hostitem:hostItem hostitem:baseType="Microsoft.Office.Tools.Outlook.OutlookAddInBase" hostitem:namespace="pEp" hostitem:className="ThisAddIn" hostitem:identifier="ThisAddIn" hostitem:primaryCookie="AddIn" hostitem:master="true" hostitem:factoryType="Microsoft.Office.Tools.Outlook.Factory" hostitem:startupIndex="0" xmlns:hostitem="http://schemas.microsoft.com/2004/VisualStudio/Tools/Applications/HostItem.xsd">
     8.6    <hostitem:hostObject hostitem:name="Application" hostitem:identifier="Application" hostitem:type="Microsoft.Office.Interop.Outlook.Application" hostitem:cookie="Application" hostitem:modifier="Internal" />
     8.7    <hostitem:hostControl hostitem:name="CustomTaskPanes" hostitem:identifier="CustomTaskPanes" hostitem:type="Microsoft.Office.Tools.CustomTaskPaneCollection" hostitem:primaryCookie="CustomTaskPanes" hostitem:modifier="Internal" />
     8.8  </hostitem:hostItem>
     8.9 \ No newline at end of file
     9.1 --- a/UI/FormRegionPrivacyStatus.cs	Tue Sep 04 11:14:15 2018 +0200
     9.2 +++ b/UI/FormRegionPrivacyStatus.cs	Fri Sep 07 19:21:46 2018 +0200
     9.3 @@ -372,6 +372,31 @@
     9.4                  // Start the rating calculation/decryption process
     9.5                  this.cryptableMailItem.StartProcessing();
     9.6                  this.processingOngoing = true;
     9.7 +
     9.8 +                // If we have a draft message, fetch directly a preview outgoing rating
     9.9 +                if (this.IsDraft)
    9.10 +                {
    9.11 +                    Outlook.MailItem omi = null;
    9.12 +                    pEpRating rating = pEpRating.pEpRatingUndefined;
    9.13 +                    try
    9.14 +                    {
    9.15 +                        omi = this.OutlookItem as Outlook.MailItem;
    9.16 +                        rating = omi?.GetOutgoingRating(false, true) ?? pEpRating.pEpRatingUndefined;
    9.17 +                    }
    9.18 +                    catch (Exception ex)
    9.19 +                    {
    9.20 +                        Log.Error("ImmediateRatingAndUIUpdate: Error getting outgoing preview rating. " + ex.ToString());
    9.21 +                    }
    9.22 +                    finally
    9.23 +                    {
    9.24 +                        omi = null;
    9.25 +                    }
    9.26 +
    9.27 +                    if (rating != pEpRating.pEpRatingUndefined)
    9.28 +                    {
    9.29 +                        this.SetRating(rating);
    9.30 +                    }
    9.31 +                }
    9.32              }
    9.33  
    9.34              return;
    9.35 @@ -816,6 +841,17 @@
    9.36                          }
    9.37                      }
    9.38  
    9.39 +                    // Check for item in cache and show it
    9.40 +                    if ((this.IsDraft == false) &&
    9.41 +                        (omi.GetIsInSecureStore()))
    9.42 +                    {
    9.43 +                        PEPMessage message = PEPCache.GetItemFromCache(omi?.EntryID) as PEPMessage;
    9.44 +                        if (message != null)
    9.45 +                        {
    9.46 +                            this.MailItem_GetMirrorCompleted(this, new CryptableMailItem.GetMirrorCompletedEventArgs(message));
    9.47 +                        }
    9.48 +                    }
    9.49 +
    9.50                      this.cryptableMailItem = new CryptableMailItem(omi, provisionalRating);
    9.51  
    9.52                      // Check if inline response
    10.1 --- a/app.config	Tue Sep 04 11:14:15 2018 +0200
    10.2 +++ b/app.config	Fri Sep 07 19:21:46 2018 +0200
    10.3 @@ -1,8 +1,8 @@
    10.4 -<?xml version="1.0" encoding="utf-8" ?>
    10.5 +<?xml version="1.0" encoding="utf-8"?>
    10.6  <configuration>
    10.7      <configSections>
    10.8 -        <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
    10.9 -            <section name="pEp.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
   10.10 +        <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
   10.11 +            <section name="pEp.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
   10.12          </sectionGroup>
   10.13      </configSections>
   10.14      <applicationSettings>
   10.15 @@ -14,8 +14,8 @@
   10.16                  <value>https://anupdatelink.pep.security/update?hash={0}</value>
   10.17              </setting>
   10.18              <setting name="UpdateLevel" serializeAs="String">
   10.19 -                <value />
   10.20 +                <value/>
   10.21              </setting>
   10.22          </pEp.Properties.Settings>
   10.23      </applicationSettings>
   10.24 -</configuration>
   10.25 +<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7"/></startup></configuration>
    11.1 --- a/pEpForOutlook.csproj	Tue Sep 04 11:14:15 2018 +0200
    11.2 +++ b/pEpForOutlook.csproj	Fri Sep 07 19:21:46 2018 +0200
    11.3 @@ -27,8 +27,9 @@
    11.4      <NoStandardLibraries>false</NoStandardLibraries>
    11.5      <RootNamespace>pEp</RootNamespace>
    11.6      <AssemblyName>pEp</AssemblyName>
    11.7 -    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    11.8 -    <TargetFrameworkProfile>Client</TargetFrameworkProfile>
    11.9 +    <TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
   11.10 +    <TargetFrameworkProfile>
   11.11 +    </TargetFrameworkProfile>
   11.12      <DefineConstants>VSTO40</DefineConstants>
   11.13      <IsWebBootstrapper>True</IsWebBootstrapper>
   11.14      <FileUpgradeFlags>
   11.15 @@ -128,6 +129,7 @@
   11.16      <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
   11.17      <DefineConstants>$(DefineConstants);DEBUG;TRACE</DefineConstants>
   11.18      <WarningLevel>4</WarningLevel>
   11.19 +    <Prefer32Bit>false</Prefer32Bit>
   11.20    </PropertyGroup>
   11.21    <!--
   11.22      This section defines properties that are set when the "Release" configuration is selected.
   11.23 @@ -157,6 +159,7 @@
   11.24      <RunCodeAnalysis>true</RunCodeAnalysis>
   11.25      <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
   11.26      <DebugSymbols>true</DebugSymbols>
   11.27 +    <Prefer32Bit>false</Prefer32Bit>
   11.28    </PropertyGroup>
   11.29    <!--
   11.30      This section defines properties that are set when the "ReaderRelease" configuration is selected.
   11.31 @@ -185,6 +188,7 @@
   11.32      <PlatformTarget>AnyCPU</PlatformTarget>
   11.33      <RunCodeAnalysis>true</RunCodeAnalysis>
   11.34      <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
   11.35 +    <Prefer32Bit>false</Prefer32Bit>
   11.36    </PropertyGroup>
   11.37    <!--
   11.38      This section enables pre- and post-build steps. However, in VSTO use
   11.39 @@ -220,9 +224,8 @@
   11.40        <EmbedInteropTypes>False</EmbedInteropTypes>
   11.41      </Reference>
   11.42      <Reference Include="Microsoft.VisualStudio.Tools.Applications.Runtime, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
   11.43 -    <Reference Include="MimeKitLite, Version=1.20.0.0, Culture=neutral, PublicKeyToken=bede1c8a46c66814, processorArchitecture=MSIL">
   11.44 -      <HintPath>..\packages\MimeKitLite.1.20.0\lib\net40\MimeKitLite.dll</HintPath>
   11.45 -      <Private>True</Private>
   11.46 +    <Reference Include="MimeKitLite, Version=2.0.0.0, Culture=neutral, PublicKeyToken=bede1c8a46c66814, processorArchitecture=MSIL">
   11.47 +      <HintPath>..\packages\MimeKitLite.2.0.6\lib\net45\MimeKitLite.dll</HintPath>
   11.48      </Reference>
   11.49      <Reference Include="Office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
   11.50        <EmbedInteropTypes>True</EmbedInteropTypes>
   11.51 @@ -243,11 +246,11 @@
   11.52      <Reference Include="PresentationFramework" />
   11.53      <Reference Include="System" />
   11.54      <Reference Include="System.Data" />
   11.55 -    <Reference Include="System.Data.SQLite, Version=1.0.106.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
   11.56 -      <HintPath>..\packages\System.Data.SQLite.Core.1.0.106.0\lib\net40\System.Data.SQLite.dll</HintPath>
   11.57 -      <Private>True</Private>
   11.58 +    <Reference Include="System.Data.SQLite, Version=1.0.109.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
   11.59 +      <HintPath>..\packages\System.Data.SQLite.Core.1.0.109.1\lib\net46\System.Data.SQLite.dll</HintPath>
   11.60      </Reference>
   11.61      <Reference Include="System.Drawing" />
   11.62 +    <Reference Include="System.Runtime.Caching" />
   11.63      <Reference Include="System.Security" />
   11.64      <Reference Include="System.Windows.Forms" />
   11.65      <Reference Include="System.Windows.Presentation" />
   11.66 @@ -304,6 +307,7 @@
   11.67      <Compile Include="NativeMethods.cs" />
   11.68      <Compile Include="OutlookOptions.cs" />
   11.69      <Compile Include="PEPAttachment.cs" />
   11.70 +    <Compile Include="PEPCache.cs" />
   11.71      <Compile Include="PEPDatabase.cs" />
   11.72      <Compile Include="PEPIdentity.cs" />
   11.73      <Compile Include="PEPMessage.cs" />
   11.74 @@ -617,18 +621,18 @@
   11.75    <ProjectExtensions>
   11.76      <VisualStudio>
   11.77        <FlavorProperties GUID="{BAA0C2D2-18E2-41B9-852F-F413020CAA33}">
   11.78 -        <ProjectProperties HostName="Outlook" HostPackage="{29A7B9D7-A7F1-4328-8EF0-6B2D1A56B2C1}" OfficeVersion="15.0" VstxVersion="4.0" ApplicationType="Outlook" Language="cs" TemplatesPath="VSTOTemplates" DebugInfoExeName="#Software\Microsoft\Office\15.0\Outlook\InstallRoot\Path#outlook.exe" AddItemTemplatesGuid="{A58A78EB-1C92-4DDD-80CF-E8BD872ABFC4}" />
   11.79 +        <ProjectProperties HostName="Outlook" HostPackage="{29A7B9D7-A7F1-4328-8EF0-6B2D1A56B2C1}" OfficeVersion="15.0" VstxVersion="4.0" ApplicationType="Outlook" Language="cs" TemplatesPath="VSTOTemplates" DebugInfoExeName="#Software\Microsoft\Office\16.0\Outlook\InstallRoot\Path#outlook.exe" AddItemTemplatesGuid="{A58A78EB-1C92-4DDD-80CF-E8BD872ABFC4}" />
   11.80          <Host Name="Outlook" GeneratedCodeNamespace="pEp" PublishedHash="69C324AB27932AA2FBF2B7EA72250886FF164DE6" IconIndex="0">
   11.81            <HostItem Name="ThisAddIn" Code="ThisAddIn.cs" CanonicalName="AddIn" PublishedHash="0FBE11FE0E084B3A3A2542A0D3FA7161F113BEA5" CanActivate="false" IconIndex="1" Blueprint="ThisAddIn.Designer.xml" GeneratedCode="ThisAddIn.Designer.cs" />
   11.82          </Host>
   11.83        </FlavorProperties>
   11.84      </VisualStudio>
   11.85    </ProjectExtensions>
   11.86 -  <Import Project="..\packages\System.Data.SQLite.Core.1.0.106.0\build\net40\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.106.0\build\net40\System.Data.SQLite.Core.targets')" />
   11.87 +  <Import Project="..\packages\System.Data.SQLite.Core.1.0.109.1\build\net46\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.109.1\build\net46\System.Data.SQLite.Core.targets')" />
   11.88    <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
   11.89      <PropertyGroup>
   11.90        <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
   11.91      </PropertyGroup>
   11.92 -    <Error Condition="!Exists('..\packages\System.Data.SQLite.Core.1.0.106.0\build\net40\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.Data.SQLite.Core.1.0.106.0\build\net40\System.Data.SQLite.Core.targets'))" />
   11.93 +    <Error Condition="!Exists('..\packages\System.Data.SQLite.Core.1.0.109.1\build\net46\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.Data.SQLite.Core.1.0.109.1\build\net46\System.Data.SQLite.Core.targets'))" />
   11.94    </Target>
   11.95  </Project>
   11.96 \ No newline at end of file
    12.1 --- a/packages.config	Tue Sep 04 11:14:15 2018 +0200
    12.2 +++ b/packages.config	Fri Sep 07 19:21:46 2018 +0200
    12.3 @@ -1,5 +1,5 @@
    12.4  <?xml version="1.0" encoding="utf-8"?>
    12.5  <packages>
    12.6 -  <package id="MimeKitLite" version="1.20.0" targetFramework="net40-client" />
    12.7 -  <package id="System.Data.SQLite.Core" version="1.0.106.0" targetFramework="net40-client" />
    12.8 +  <package id="MimeKitLite" version="2.0.6" targetFramework="net47" />
    12.9 +  <package id="System.Data.SQLite.Core" version="1.0.109.1" targetFramework="net47" />
   12.10  </packages>
   12.11 \ No newline at end of file