Fix some logical corner cases with Force Protection and Force Unencrypted OUT-470
authorThomas
Thu, 19 Jul 2018 11:04:17 +0200
branchOUT-470
changeset 2305f0d2f138c306
parent 2304 ff17a2db652c
child 2306 d5aad9e654c6
Fix some logical corner cases with Force Protection and Force Unencrypted
UI/RibbonCustomizations.cs
     1.1 --- a/UI/RibbonCustomizations.cs	Thu Jul 19 09:36:39 2018 +0200
     1.2 +++ b/UI/RibbonCustomizations.cs	Thu Jul 19 11:04:17 2018 +0200
     1.3 @@ -983,6 +983,14 @@
     1.4          public void ToggleButtonForceUnencrypted_Click(Office.IRibbonControl control, bool isPressed)
     1.5          {
     1.6              this.SetForceUnencrypted(control, isPressed);
     1.7 +
     1.8 +            // Disable Force Protection and Never Unsecure if needed
     1.9 +            if (isPressed)
    1.10 +            {
    1.11 +                this.SetForceProtection(control, false);
    1.12 +                this.SetNeverUnsecure(control, false);
    1.13 +            }
    1.14 +
    1.15              RibbonCustomizations.Invalidate();
    1.16          }
    1.17  
    1.18 @@ -991,13 +999,16 @@
    1.19          /// </summary>
    1.20          public bool ToggleButtonForceUnencrypted_GetEnabled(Office.IRibbonControl control)
    1.21          {
    1.22 -            // When a message is marked as never unsecure or forcefully proteced, it cannot be forcefully unencrypted
    1.23 -            if ((this.GetNeverUnsecure(control)) ||
    1.24 -                (this.GetForceProtection(control)) ||
    1.25 -                (this.GetRating(control) <= pEpRating.pEpRatingUnencryptedForSome))
    1.26 +            /* The button is disabled if
    1.27 +             *  - Rating is lower than reliable
    1.28 +             *  - Force Protection or Never Unsecure are enabled and not overridden
    1.29 +             */ 
    1.30 +            if (((this.GetRating(control) < pEpRating.pEpRatingReliable) ||
    1.31 +                 (this.GetNeverUnsecure(control))) ||
    1.32 +                 ((this.GetForceProtection(control)) && (this.GetDisableForceProtection(control) == false)))
    1.33              {
    1.34                  return false;
    1.35 -            }
    1.36 +            }            
    1.37              else
    1.38              {
    1.39                  return true;
    1.40 @@ -1137,13 +1148,13 @@
    1.41  
    1.42              if (this.GetIsPEPEnabled(control))
    1.43              {
    1.44 -                enabled = ((this.GetForceUnencrypted(control) == false) &&
    1.45 -                           (this.GetRating(control) == pEpRating.pEpRatingUnencrypted));
    1.46 +                enabled = ((this.GetRating(control) == pEpRating.pEpRatingUnencrypted) && 
    1.47 +                           (this.GetForceUnencrypted(control) == false));
    1.48              }
    1.49              else
    1.50              {
    1.51 -                enabled = (((this.GetProperty(control, MailItemExtensions.PEPProperty.EnableProtection) as bool?) ?? false) &&
    1.52 -                           (this.GetRating(control) == pEpRating.pEpRatingUnencrypted));
    1.53 +                enabled = ((this.GetRating(control) == pEpRating.pEpRatingUnencrypted) &&
    1.54 +                           ((this.GetProperty(control, MailItemExtensions.PEPProperty.EnableProtection) as bool?) ?? false));
    1.55              }
    1.56  
    1.57              return enabled;
    1.58 @@ -1162,7 +1173,8 @@
    1.59          /// </summary>
    1.60          public bool ToggleButtonForceProtection_GetPressed(Office.IRibbonControl control)
    1.61          {
    1.62 -            return this.GetForceProtection(control);
    1.63 +            return ((this.GetForceProtection(control)) && 
    1.64 +                    (this.GetDisableForceProtection(control) == false));
    1.65          }
    1.66  
    1.67          /// <summary>