OUT-386: Add Reset Trust context menu entry for contacts sync
authorThomas
Tue, 30 Jul 2019 08:18:44 +0200
branchsync
changeset 2687f7f12cd4dd77
parent 2686 f2e370d69120
child 2688 580069604044
OUT-386: Add Reset Trust context menu entry for contacts
UI/RibbonCustomizations.cs
UI/RibbonCustomizationsExplorer.xml
     1.1 --- a/UI/RibbonCustomizations.cs	Mon Jul 29 11:21:16 2019 +0200
     1.2 +++ b/UI/RibbonCustomizations.cs	Tue Jul 30 08:18:44 2019 +0200
     1.3 @@ -878,6 +878,26 @@
     1.4          }
     1.5  
     1.6          ///////////////////////////////////////////////////////////
     1.7 +        // ContextMenuResetContactTrust
     1.8 +        ///////////////////////////////////////////////////////////
     1.9 +
    1.10 +        /// <summary>
    1.11 +        /// Callback to get the store context menu key import button text.
    1.12 +        /// </summary>
    1.13 +        public string ContextMenuResetContactTrust_GetLabel(Office.IRibbonControl control)
    1.14 +        {
    1.15 +            return Properties.Resources.PrivacyStatus_ResetTrust;
    1.16 +        }
    1.17 +
    1.18 +        /// <summary>
    1.19 +        /// Callback to get the store context menu key import button image.
    1.20 +        /// </summary>
    1.21 +        public System.Drawing.Bitmap ContextMenuResetContactTrust_GetImage(Office.IRibbonControl control)
    1.22 +        {
    1.23 +            return Properties.Resources.ImageLogoIcon;
    1.24 +        }
    1.25 +
    1.26 +        ///////////////////////////////////////////////////////////
    1.27          // ButtonPrivacyStatus
    1.28          ///////////////////////////////////////////////////////////
    1.29  
    1.30 @@ -1499,7 +1519,7 @@
    1.31               * IMPORTANT: Never call Explorer.ActiveInlineResponse on Outlook 2010
    1.32               *            as this might lead to a crash of Outlook (even inside a
    1.33               *            try/catch block)
    1.34 -             */ 
    1.35 +             */
    1.36              if (Globals.OutlookVersion != Globals.Version.Outlook2010)
    1.37              {
    1.38                  Outlook.Explorer explorer = null;
    1.39 @@ -1622,6 +1642,38 @@
    1.40              }
    1.41          }
    1.42  
    1.43 +        /// <summary>
    1.44 +        /// Event handler for when the reset contact context menu button is clicked.
    1.45 +        /// </summary>
    1.46 +        public void ContextMenuResetContactTrustButton_Click(Office.IRibbonControl control)
    1.47 +        {
    1.48 +            Outlook.Selection selection;
    1.49 +            Outlook.ContactItem contact;
    1.50 +
    1.51 +            try
    1.52 +            {
    1.53 +                // Get the selected contact(s) and reset their trust
    1.54 +                selection = control.Context as Outlook.Selection;
    1.55 +
    1.56 +                for (int i = 1; i <= selection.Count; i++)
    1.57 +                {
    1.58 +                    contact = selection[i];
    1.59 +                    string id = contact.EntryID;
    1.60 +                    ThisAddIn.PEPEngine.KeyResetUser(id, null);
    1.61 +                    contact = null;
    1.62 +                }
    1.63 +            }
    1.64 +            catch (Exception ex)
    1.65 +            {
    1.66 +                Log.Error("ContextMenuResetContactTrustButton_Click: Error occured. " + ex.ToString());
    1.67 +            }
    1.68 +            finally
    1.69 +            {
    1.70 +                contact = null;
    1.71 +                selection = null;
    1.72 +            }
    1.73 +        }
    1.74 +
    1.75          /**************************************************************
    1.76           *
    1.77           * Event Handling (Backstage)
     2.1 --- a/UI/RibbonCustomizationsExplorer.xml	Mon Jul 29 11:21:16 2019 +0200
     2.2 +++ b/UI/RibbonCustomizationsExplorer.xml	Tue Jul 30 08:18:44 2019 +0200
     2.3 @@ -153,6 +153,8 @@
     2.4      </tab>
     2.5    </backstage>
     2.6    <contextMenus>
     2.7 +    
     2.8 +    <!--The manual Key Import context menu entry-->
     2.9      <contextMenu idMso="ContextMenuStore">
    2.10        <menu id="ContextMenuKeyImport"
    2.11              getImage="ContextMenuKeyImport_GetImage"
    2.12 @@ -168,6 +170,14 @@
    2.13                  onAction="ContextMenuKeyImportButton_Click"/>
    2.14        </menu>
    2.15      </contextMenu>
    2.16 +    
    2.17 +    <!--The Contact context menu to reset trust-->
    2.18 +    <contextMenu idMso="ContextMenuContactItem">
    2.19 +      <button id="ContextMenuResetContactTrust"
    2.20 +            getImage="ContextMenuResetContactTrust_GetImage"            
    2.21 +            getLabel="ContextMenuResetContactTrust_GetLabel"
    2.22 +            onAction="ContextMenuResetContactTrustButton_Click"/>       
    2.23 +    </contextMenu>
    2.24    </contextMenus>
    2.25  </customUI>
    2.26