OUT-386: Add context menu entry to reset a communication partner's identity sync
authorThomas
Wed, 07 Aug 2019 09:47:17 +0200
branchsync
changeset 2695273816414b64
parent 2694 227c4be4d54d
child 2696 428b91e45c69
child 2697 b9b470a40aec
OUT-386: Add context menu entry to reset a communication partner's identity
Properties/Resources.Designer.cs
Properties/Resources.de.resx
Properties/Resources.es.resx
Properties/Resources.resx
UI/RibbonCustomizations.cs
UI/RibbonCustomizationsExplorer.xml
UI/RibbonCustomizationsIMLayerUI.xml
pEpForOutlook.csproj
     1.1 --- a/Properties/Resources.Designer.cs	Wed Aug 07 07:41:28 2019 +0200
     1.2 +++ b/Properties/Resources.Designer.cs	Wed Aug 07 09:47:17 2019 +0200
     1.3 @@ -1457,6 +1457,15 @@
     1.4          }
     1.5          
     1.6          /// <summary>
     1.7 +        ///   Looks up a localized string similar to The account has been reset..
     1.8 +        /// </summary>
     1.9 +        public static string Notifications_AccountReset {
    1.10 +            get {
    1.11 +                return ResourceManager.GetString("Notifications_AccountReset", resourceCulture);
    1.12 +            }
    1.13 +        }
    1.14 +        
    1.15 +        /// <summary>
    1.16          ///   Looks up a localized string similar to All accounts have been reset..
    1.17          /// </summary>
    1.18          public static string Notifications_AllOwnKeysReset {
     2.1 --- a/Properties/Resources.de.resx	Wed Aug 07 07:41:28 2019 +0200
     2.2 +++ b/Properties/Resources.de.resx	Wed Aug 07 09:47:17 2019 +0200
     2.3 @@ -858,4 +858,7 @@
     2.4    <data name="Notifications_AllOwnKeysReset" xml:space="preserve">
     2.5      <value>Alle Konten wurden zurückgesetzt.</value>
     2.6    </data>
     2.7 +  <data name="Notifications_AccountReset" xml:space="preserve">
     2.8 +    <value>Das Konto wurde zurückgesetzt</value>
     2.9 +  </data>
    2.10  </root>
    2.11 \ No newline at end of file
     3.1 --- a/Properties/Resources.es.resx	Wed Aug 07 07:41:28 2019 +0200
     3.2 +++ b/Properties/Resources.es.resx	Wed Aug 07 09:47:17 2019 +0200
     3.3 @@ -858,4 +858,7 @@
     3.4    <data name="Notifications_AllOwnKeysReset" xml:space="preserve">
     3.5      <value>Todas las cuentas han sido restablecidas.</value>
     3.6    </data>
     3.7 +  <data name="Notifications_AccountReset" xml:space="preserve">
     3.8 +    <value>La cuenta ha sido restablecida.</value>
     3.9 +  </data>
    3.10  </root>
    3.11 \ No newline at end of file
     4.1 --- a/Properties/Resources.resx	Wed Aug 07 07:41:28 2019 +0200
     4.2 +++ b/Properties/Resources.resx	Wed Aug 07 09:47:17 2019 +0200
     4.3 @@ -979,4 +979,7 @@
     4.4    <data name="Notifications_AllOwnKeysReset" xml:space="preserve">
     4.5      <value>All accounts have been reset.</value>
     4.6    </data>
     4.7 +  <data name="Notifications_AccountReset" xml:space="preserve">
     4.8 +    <value>The account has been reset.</value>
     4.9 +  </data>
    4.10  </root>
    4.11 \ No newline at end of file
     5.1 --- a/UI/RibbonCustomizations.cs	Wed Aug 07 07:41:28 2019 +0200
     5.2 +++ b/UI/RibbonCustomizations.cs	Wed Aug 07 09:47:17 2019 +0200
     5.3 @@ -878,7 +878,7 @@
     5.4          }
     5.5  
     5.6          ///////////////////////////////////////////////////////////
     5.7 -        // ContextMenuResetContactTrust
     5.8 +        // ButtonContextMenuContactResetTrust
     5.9          ///////////////////////////////////////////////////////////
    5.10  
    5.11          /// <summary>
    5.12 @@ -892,7 +892,27 @@
    5.13          /// <summary>
    5.14          /// Callback to get the store context menu key import button image.
    5.15          /// </summary>
    5.16 -        public System.Drawing.Bitmap ContextMenuResetContactTrust_GetImage(Office.IRibbonControl control)
    5.17 +        public System.Drawing.Bitmap ButtonContextMenuResetContactTrust_GetImage(Office.IRibbonControl control)
    5.18 +        {
    5.19 +            return Properties.Resources.ImageLogoIcon;
    5.20 +        }
    5.21 +
    5.22 +        ///////////////////////////////////////////////////////////
    5.23 +        // ButtonContextMenuContactCardResetTrust
    5.24 +        ///////////////////////////////////////////////////////////
    5.25 +
    5.26 +        /// <summary>
    5.27 +        /// Callback to get the store context menu key import button text.
    5.28 +        /// </summary>
    5.29 +        public string ButtonContextMenuContactCardResetTrust_GetLabel(Office.IRibbonControl control)
    5.30 +        {
    5.31 +            return Properties.Resources.PrivacyStatus_ResetTrust;
    5.32 +        }
    5.33 +
    5.34 +        /// <summary>
    5.35 +        /// Callback to get the store context menu key import button image.
    5.36 +        /// </summary>
    5.37 +        public System.Drawing.Bitmap ButtonContextMenuContactCardResetTrust_GetImage(Office.IRibbonControl control)
    5.38          {
    5.39              return Properties.Resources.ImageLogoIcon;
    5.40          }
    5.41 @@ -930,7 +950,7 @@
    5.42          /// Callback to get the label of the ButtonPrivacyStatus.
    5.43          /// </summary>
    5.44          public string ButtonPrivacyStatus_GetLabel(Office.IRibbonControl control)
    5.45 -        {
    5.46 +        {            
    5.47              string label = Globals.ThisAddIn.GetWatchedWindow(control?.Context)?.PrivacyState?.Label;
    5.48  
    5.49              // Workaround to show ampersands correctly
    5.50 @@ -1645,7 +1665,7 @@
    5.51          /// <summary>
    5.52          /// Event handler for when the reset contact context menu button is clicked.
    5.53          /// </summary>
    5.54 -        public void ContextMenuResetContactTrustButton_Click(Office.IRibbonControl control)
    5.55 +        public void ButtonContextMenuContactResetTrust_Click(Office.IRibbonControl control)
    5.56          {
    5.57              Outlook.Selection selection;
    5.58              Outlook.ContactItem contact;
    5.59 @@ -1662,6 +1682,9 @@
    5.60                      ThisAddIn.PEPEngine.KeyResetUser(id, null);
    5.61                      contact = null;
    5.62                  }
    5.63 +
    5.64 +                // Show notification to user that identity/identities have been reset
    5.65 +                Notification.Show(Properties.Resources.PrivacyStatus_ResetTrust, Properties.Resources.Notifications_AccountReset);
    5.66              }
    5.67              catch (Exception ex)
    5.68              {
    5.69 @@ -1674,6 +1697,57 @@
    5.70              }
    5.71          }
    5.72  
    5.73 +        /// <summary>
    5.74 +        /// Event handler for when the reset contact card context menu button is clicked.
    5.75 +        /// </summary>
    5.76 +        public void ButtonContextMenuContactCardResetTrust_Click(Office.IRibbonControl control)
    5.77 +        {
    5.78 +            Office.IMsoContactCard contactCard;
    5.79 +            Outlook.AddressEntry addressEntry;
    5.80 +            Outlook.Application application;
    5.81 +            Outlook.NameSpace session;
    5.82 +
    5.83 +            try
    5.84 +            {
    5.85 +                // Extract address from contact card, get its PEPIdentity and reset
    5.86 +                contactCard = control.Context as Office.IMsoContactCard;
    5.87 +                if (contactCard?.AddressType == Office.MsoContactCardAddressType.msoContactCardAddressTypeOutlook)
    5.88 +                {
    5.89 +                    application = Globals.ThisAddIn.Application;
    5.90 +                    session = application.Session;
    5.91 +                    addressEntry = session.GetAddressEntryFromID(contactCard.Address);
    5.92 +
    5.93 +                    // Reset identity and show notification that identity has been reset
    5.94 +                    if (PEPIdentity.Create(addressEntry, out PEPIdentity identity) == Globals.ReturnStatus.Success)
    5.95 +                    {
    5.96 +                        pEpIdentity comTypeIdentity = identity.ToCOMType();
    5.97 +                        ThisAddIn.PEPEngine.KeyResetIdentity(comTypeIdentity, null);
    5.98 +
    5.99 +                        Notification.Show(Properties.Resources.PrivacyStatus_ResetTrust, Properties.Resources.Notifications_AccountReset);
   5.100 +                    }
   5.101 +                    else
   5.102 +                    {
   5.103 +                        Log.Error("ButtonContextMenuContactCardResetTrust_Click: Could not reset identity. Error getting PEPIdentity.");
   5.104 +                    }
   5.105 +                }
   5.106 +                else
   5.107 +                {
   5.108 +                    Log.Error("ButtonContextMenuContactCardResetTrust_Click: Could not retrieve address. Address type is " + Enum.GetName(typeof(Office.MsoContactCardAddressType), contactCard?.AddressType));
   5.109 +                }
   5.110 +            }
   5.111 +            catch (Exception ex)
   5.112 +            {
   5.113 +                Log.Error("ButtonContextMenuContactCardResetTrust_Click: Error occured. " + ex.ToString());
   5.114 +            }
   5.115 +            finally
   5.116 +            {
   5.117 +                contactCard = null;
   5.118 +                addressEntry = null;
   5.119 +                application = null;
   5.120 +                session = null;
   5.121 +            }
   5.122 +        }
   5.123 +
   5.124          /**************************************************************
   5.125           *
   5.126           * Event Handling (Backstage)
   5.127 @@ -1726,6 +1800,8 @@
   5.128                      return GetResourceText("pEp.UI.RibbonCustomizationsCompose.xml");
   5.129                  case "Microsoft.Outlook.Mail.Read":
   5.130                      return GetResourceText("pEp.UI.RibbonCustomizationsRead.xml");
   5.131 +                case "Microsoft.Mso.IMLayerUI":
   5.132 +                    return GetResourceText("pEp.UI.RibbonCustomizationsIMLayerUI.xml");
   5.133                  default:
   5.134                      return GetResourceText("pEp.UI.RibbonCustomizations.xml");
   5.135              }
     6.1 --- a/UI/RibbonCustomizationsExplorer.xml	Wed Aug 07 07:41:28 2019 +0200
     6.2 +++ b/UI/RibbonCustomizationsExplorer.xml	Wed Aug 07 09:47:17 2019 +0200
     6.3 @@ -173,10 +173,10 @@
     6.4      
     6.5      <!--The Contact context menu to reset trust-->
     6.6      <contextMenu idMso="ContextMenuContactItem">
     6.7 -      <button id="ContextMenuResetContactTrust"
     6.8 -            getImage="ContextMenuResetContactTrust_GetImage"            
     6.9 -            getLabel="ContextMenuResetContactTrust_GetLabel"
    6.10 -            onAction="ContextMenuResetContactTrustButton_Click"/>       
    6.11 +      <button id="ButtonContextMenuResetContactTrust"
    6.12 +            getImage="ButtonContextMenuResetContactTrust_GetImage"            
    6.13 +            getLabel="ButtonContextMenuResetContactTrust_GetLabel"
    6.14 +            onAction="ButtonContextMenuResetContactTrustButton_Click"/>       
    6.15      </contextMenu>
    6.16    </contextMenus>
    6.17  </customUI>
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/UI/RibbonCustomizationsIMLayerUI.xml	Wed Aug 07 09:47:17 2019 +0200
     7.3 @@ -0,0 +1,13 @@
     7.4 +<?xml version="1.0" encoding="UTF-8"?>
     7.5 +<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui"
     7.6 +          onLoad="Ribbon_Load">
     7.7 +  <contextMenus>
     7.8 +    <contextMenu idMso="ContextMenuContactCardRecipient">
     7.9 +      <button id="ButtonContextMenuContactCardResetTrust"
    7.10 +                getImage="ButtonContextMenuContactCardResetTrust_GetImage"
    7.11 +                getLabel="ButtonContextMenuContactCardResetTrust_GetLabel"
    7.12 +                onAction="ButtonContextMenuContactCardResetTrust_Click"/>
    7.13 +    </contextMenu>
    7.14 +  </contextMenus>
    7.15 +</customUI>
    7.16 +
     8.1 --- a/pEpForOutlook.csproj	Wed Aug 07 07:41:28 2019 +0200
     8.2 +++ b/pEpForOutlook.csproj	Wed Aug 07 09:47:17 2019 +0200
     8.3 @@ -562,6 +562,7 @@
     8.4      <WCFMetadata Include="Service References\" />
     8.5    </ItemGroup>
     8.6    <ItemGroup>
     8.7 +    <EmbeddedResource Include="UI\RibbonCustomizationsIMLayerUI.xml" />
     8.8      <EmbeddedResource Include="UI\RibbonCustomizationsExplorer2010.xml" />
     8.9      <Resource Include="Resources\ImagePrivacyStatusGreenProtectionDisabled.png" />
    8.10      <Resource Include="Resources\ImagePrivacyStatusYellowProtectionDisabled.png" />