OUT-445: Implement Update Now button. Change to adapter function needed until it works fully. OUT-445
authorThomas
Tue, 22 May 2018 09:49:37 +0200
branchOUT-445
changeset 22054299ea51fbf6
parent 2204 94aaeb734ef2
child 2212 02f58420dce0
OUT-445: Implement Update Now button. Change to adapter function needed until it works fully.
Properties/Resources.Designer.cs
Properties/Resources.de.resx
Properties/Resources.resx
UI/FormControlOptions.xaml
UI/FormControlOptions.xaml.cs
     1.1 --- a/Properties/Resources.Designer.cs	Fri May 18 12:14:05 2018 +0200
     1.2 +++ b/Properties/Resources.Designer.cs	Tue May 22 09:49:37 2018 +0200
     1.3 @@ -1356,6 +1356,15 @@
     1.4          }
     1.5          
     1.6          /// <summary>
     1.7 +        ///   Looks up a localized string similar to Check for update.
     1.8 +        /// </summary>
     1.9 +        public static string Options_CheckForUpdate {
    1.10 +            get {
    1.11 +                return ResourceManager.GetString("Options_CheckForUpdate", resourceCulture);
    1.12 +            }
    1.13 +        }
    1.14 +        
    1.15 +        /// <summary>
    1.16          ///   Looks up a localized string similar to Store messages securely for these accounts:.
    1.17          /// </summary>
    1.18          public static string Options_EncryptedAccountsText {
    1.19 @@ -1527,6 +1536,24 @@
    1.20          }
    1.21          
    1.22          /// <summary>
    1.23 +        ///   Looks up a localized string similar to Looking for updates....
    1.24 +        /// </summary>
    1.25 +        public static string Options_LookingForUpdate {
    1.26 +            get {
    1.27 +                return ResourceManager.GetString("Options_LookingForUpdate", resourceCulture);
    1.28 +            }
    1.29 +        }
    1.30 +        
    1.31 +        /// <summary>
    1.32 +        ///   Looks up a localized string similar to No updates found.
    1.33 +        /// </summary>
    1.34 +        public static string Options_NoUpdateFound {
    1.35 +            get {
    1.36 +                return ResourceManager.GetString("Options_NoUpdateFound", resourceCulture);
    1.37 +            }
    1.38 +        }
    1.39 +        
    1.40 +        /// <summary>
    1.41          ///   Looks up a localized string similar to OK.
    1.42          /// </summary>
    1.43          public static string Options_OKText {
    1.44 @@ -1671,6 +1698,15 @@
    1.45          }
    1.46          
    1.47          /// <summary>
    1.48 +        ///   Looks up a localized string similar to Update found. The installer will be launched..
    1.49 +        /// </summary>
    1.50 +        public static string Options_UpdateFound {
    1.51 +            get {
    1.52 +                return ResourceManager.GetString("Options_UpdateFound", resourceCulture);
    1.53 +            }
    1.54 +        }
    1.55 +        
    1.56 +        /// <summary>
    1.57          ///   Looks up a localized string similar to Cc.
    1.58          /// </summary>
    1.59          public static string PreviewMessage_CcText {
     2.1 --- a/Properties/Resources.de.resx	Fri May 18 12:14:05 2018 +0200
     2.2 +++ b/Properties/Resources.de.resx	Tue May 22 09:49:37 2018 +0200
     2.3 @@ -819,4 +819,16 @@
     2.4    <data name="KeySyncWizard_PEPSuccessOtherKeyUsedAsDefault" xml:space="preserve">
     2.5      <value>Der Schlüssel von Ihrem anderen Gerät wird nun standardmäßig verwendet.</value>
     2.6    </data>
     2.7 +  <data name="Options_CheckForUpdate" xml:space="preserve">
     2.8 +    <value>Nach Update suchen</value>
     2.9 +  </data>
    2.10 +  <data name="Options_LookingForUpdate" xml:space="preserve">
    2.11 +    <value>Es wird nach einem Update gesucht ...</value>
    2.12 +  </data>
    2.13 +  <data name="Options_NoUpdateFound" xml:space="preserve">
    2.14 +    <value>Es wurde kein Update gefunden</value>
    2.15 +  </data>
    2.16 +  <data name="Options_UpdateFound" xml:space="preserve">
    2.17 +    <value>Update gefunden. Der Installer wird automatisch geöffnet.</value>
    2.18 +  </data>
    2.19  </root>
    2.20 \ No newline at end of file
     3.1 --- a/Properties/Resources.resx	Fri May 18 12:14:05 2018 +0200
     3.2 +++ b/Properties/Resources.resx	Tue May 22 09:49:37 2018 +0200
     3.3 @@ -907,4 +907,16 @@
     3.4    <data name="KeySyncWizard_PEPSuccessOtherKeyUsed" xml:space="preserve">
     3.5      <value>The key from your other device will now also be used to decrypt messages.</value>
     3.6    </data>
     3.7 +  <data name="Options_CheckForUpdate" xml:space="preserve">
     3.8 +    <value>Check for update</value>
     3.9 +  </data>
    3.10 +  <data name="Options_LookingForUpdate" xml:space="preserve">
    3.11 +    <value>Looking for updates...</value>
    3.12 +  </data>
    3.13 +  <data name="Options_NoUpdateFound" xml:space="preserve">
    3.14 +    <value>No updates found</value>
    3.15 +  </data>
    3.16 +  <data name="Options_UpdateFound" xml:space="preserve">
    3.17 +    <value>Update found. The installer will be launched.</value>
    3.18 +  </data>
    3.19  </root>
    3.20 \ No newline at end of file
     4.1 --- a/UI/FormControlOptions.xaml	Fri May 18 12:14:05 2018 +0200
     4.2 +++ b/UI/FormControlOptions.xaml	Tue May 22 09:49:37 2018 +0200
     4.3 @@ -691,8 +691,10 @@
     4.4                          <RowDefinition Height="Auto" />
     4.5                          <RowDefinition Height="Auto" />
     4.6                          <RowDefinition Height="Auto" />
     4.7 +                        <RowDefinition Height="*" />
     4.8                          <RowDefinition Height="Auto" />
     4.9 -                        <RowDefinition Height="*" />
    4.10 +                        <RowDefinition Height="Auto" />
    4.11 +                        <RowDefinition Height="Auto" />
    4.12                      </Grid.RowDefinitions>
    4.13  
    4.14                      <!-- About title -->
    4.15 @@ -771,7 +773,7 @@
    4.16                      <Grid Grid.Row="5"
    4.17                            VerticalAlignment="Bottom">
    4.18                          <Grid.Margin>
    4.19 -                            <Thickness Bottom="{StaticResource PageBottomSpacing}"
    4.20 +                            <Thickness Bottom="{StaticResource PageSubSectionSpacing}"
    4.21                                         Left="{StaticResource PageLeftSpacing}"
    4.22                                         Right="0"
    4.23                                         Top="0" />
    4.24 @@ -801,6 +803,48 @@
    4.25                                         Margin="{StaticResource CheckBoxContentMarginWhenCenter}" />
    4.26                          </CheckBox>
    4.27                      </Grid>
    4.28 +                    <Label Grid.Row="6"
    4.29 +                           x:Name="LookingForUpdateLabel"
    4.30 +                           Content="{Binding Path=LookingForUpdateLabelText}"
    4.31 +                           Visibility="{Binding Path=LookingForUpdateLabelVisibility}">
    4.32 +                        <Label.Margin>
    4.33 +                            <Thickness Bottom="0"
    4.34 +                                       Left="{StaticResource PageLeftSpacing}"
    4.35 +                                       Right="0"
    4.36 +                                       Top="0">
    4.37 +                            </Thickness>
    4.38 +                        </Label.Margin>
    4.39 +                    </Label>
    4.40 +                    <Button Grid.Row="7"
    4.41 +                            Content="{x:Static p:Resources.Options_CheckForUpdate}"
    4.42 +                            Style="{StaticResource StyleConfirmButton}"
    4.43 +                            HorizontalAlignment="Left"
    4.44 +                            Padding="{StaticResource ButtonPaddingStandard}"
    4.45 +                            Click="ButtonCheckForUpdates_Click"
    4.46 +                            Visibility="{Binding Path=IsCheckingForUpdates, Converter={StaticResource InvertBoolToVisibility}}">
    4.47 +                        <Button.Margin>
    4.48 +                            <Thickness Bottom="{StaticResource PageBottomSpacing}"
    4.49 +                                       Left="{StaticResource PageLeftSpacing}"
    4.50 +                                       Right="0"
    4.51 +                                       Top="{StaticResource PageSubSectionSpacing}">
    4.52 +                            </Thickness>
    4.53 +                        </Button.Margin>
    4.54 +                    </Button>
    4.55 +                    <Button Grid.Row="7"
    4.56 +                            Content="{x:Static p:Resources.Options_CancelText}"
    4.57 +                            Style="{StaticResource StyleWrongButton}"
    4.58 +                            HorizontalAlignment="Left"
    4.59 +                            Padding="{StaticResource ButtonPaddingStandard}"
    4.60 +                            Click="ButtonCheckForUpdatesCancel_Click"
    4.61 +                            Visibility="{Binding Path=IsCheckingForUpdates, Converter={StaticResource BoolToVisibility}}">
    4.62 +                        <Button.Margin>
    4.63 +                            <Thickness Bottom="{StaticResource PageBottomSpacing}"
    4.64 +                                       Left="{StaticResource PageLeftSpacing}"
    4.65 +                                       Right="0"
    4.66 +                                       Top="{StaticResource PageSubSectionSpacing}">
    4.67 +                            </Thickness>
    4.68 +                        </Button.Margin>
    4.69 +                    </Button>
    4.70                  </Grid>
    4.71              </TabItem>
    4.72  
     5.1 --- a/UI/FormControlOptions.xaml.cs	Fri May 18 12:14:05 2018 +0200
     5.2 +++ b/UI/FormControlOptions.xaml.cs	Tue May 22 09:49:37 2018 +0200
     5.3 @@ -121,6 +121,50 @@
     5.4          }
     5.5  
     5.6          /// <summary>
     5.7 +        /// Event handler for when the Check for updates button is pressed.
     5.8 +        /// </summary>
     5.9 +        private void ButtonCheckForUpdates_Click(object sender, RoutedEventArgs e)
    5.10 +        {
    5.11 +            try
    5.12 +            {
    5.13 +                this.displayState.IsCheckingForUpdates = true;
    5.14 +                this.displayState.LookingForUpdateLabelText = Properties.Resources.Options_LookingForUpdate;
    5.15 +                this.displayState.LookingForUpdateLabelVisibility = Visibility.Visible;
    5.16 +                System.Threading.Tasks.Task.Factory.StartNew(new Action(() =>
    5.17 +                {
    5.18 +                    // TODO: This method has to return a status whether an update has been found or not
    5.19 +                    ThisAddIn.PEPEngine.UpdateNow();
    5.20 +                }), System.Threading.Tasks.TaskCreationOptions.LongRunning).ContinueWith((result) =>
    5.21 +                 {
    5.22 +                     this.displayState.IsCheckingForUpdates = false;
    5.23 +
    5.24 +                     // TODO: Adjust this condition to the return status of the UpdateNow() method
    5.25 +                     if (result.IsCompleted)
    5.26 +                     {
    5.27 +                         this.displayState.LookingForUpdateLabelText = Properties.Resources.Options_UpdateFound;
    5.28 +                     }
    5.29 +                     else
    5.30 +                     {
    5.31 +                         this.displayState.LookingForUpdateLabelText = Properties.Resources.Options_NoUpdateFound;
    5.32 +                     }
    5.33 +                 });
    5.34 +            }
    5.35 +            catch (Exception ex)
    5.36 +            {
    5.37 +                Log.Error("ButtonCheckForUpdates_Click: Error checking for updates. " + ex.ToString());
    5.38 +                this.displayState.IsCheckingForUpdates = false;
    5.39 +            }
    5.40 +        }
    5.41 +
    5.42 +        /// <summary>
    5.43 +        /// Event handler for when the Cancel to check for updates button is pressed.
    5.44 +        /// </summary>
    5.45 +        private void ButtonCheckForUpdatesCancel_Click(object sender, RoutedEventArgs e)
    5.46 +        {
    5.47 +            this.displayState.IsCheckingForUpdates = false;
    5.48 +        }
    5.49 +
    5.50 +        /// <summary>
    5.51          /// Event handler for when the OK button is pressed.
    5.52          /// </summary>
    5.53          private void ButtonOK_Click(object sender, RoutedEventArgs e)
    5.54 @@ -351,6 +395,7 @@
    5.55              private bool                                    _IsAutoUpdateEnabled;
    5.56              private string                                  _IsAutoUpdateEnabledText;
    5.57              private bool                                    _IsBlacklistAddEnabled;
    5.58 +            private bool                                    _IsCheckingForUpdates;
    5.59              private bool                                    _IsDeveloperModeEnabled;
    5.60              private bool                                    _IsEncryptAllAccountsEnabled;
    5.61              private string                                  _IsEncryptAllAccountsEnabledText;
    5.62 @@ -378,6 +423,8 @@
    5.63              private string                                  _LogOutlook;
    5.64              private string                                  _LogOutlookText;
    5.65              private string                                  _LogRefreshText;
    5.66 +            private string                                  _LookingForUpdateLabelText;
    5.67 +            private Visibility                              _LookingForUpdateLabelVisibility;
    5.68              private string                                  _OKText;
    5.69              private string                                  _OpenKeyManagerText;
    5.70              private string                                  _PageAboutText;
    5.71 @@ -614,6 +661,22 @@
    5.72                  get { return (this._IsBlacklistAddEnabled); }
    5.73              }
    5.74  
    5.75 +
    5.76 +            /// <summary>
    5.77 +            /// Gets or sets whether we are currently checking for updates.
    5.78 +            /// </summary>
    5.79 +            public bool IsCheckingForUpdates
    5.80 +            {
    5.81 +                get { return (this._IsCheckingForUpdates); }
    5.82 +                set
    5.83 +                {
    5.84 +                    this._IsCheckingForUpdates = value;
    5.85 +                    this.RaisePropertyChangedEvent(nameof(this.IsCheckingForUpdates));
    5.86 +
    5.87 +                    this.CalcDependentProperties();
    5.88 +                }
    5.89 +            }
    5.90 +
    5.91              /// <summary>
    5.92              /// Gets or sets whether developer mode is enabled.
    5.93              /// </summary>
    5.94 @@ -930,6 +993,32 @@
    5.95              }
    5.96  
    5.97              /// <summary>
    5.98 +            /// Gets or sets the text for the Looking for updates label
    5.99 +            /// </summary>
   5.100 +            public string LookingForUpdateLabelText
   5.101 +            {
   5.102 +                get { return (this._LookingForUpdateLabelText); }
   5.103 +                set
   5.104 +                {
   5.105 +                    this._LookingForUpdateLabelText = value;
   5.106 +                    this.RaisePropertyChangedEvent(nameof(this.LookingForUpdateLabelText));
   5.107 +                }
   5.108 +            }
   5.109 +
   5.110 +            /// <summary>
   5.111 +            /// Gets or sets the visibility for the Looking for updates label
   5.112 +            /// </summary>
   5.113 +            public Visibility LookingForUpdateLabelVisibility
   5.114 +            {
   5.115 +                get { return (this._LookingForUpdateLabelVisibility); }
   5.116 +                set
   5.117 +                {
   5.118 +                    this._LookingForUpdateLabelVisibility = value;
   5.119 +                    this.RaisePropertyChangedEvent(nameof(this.LookingForUpdateLabelVisibility));
   5.120 +                }
   5.121 +            }
   5.122 +
   5.123 +            /// <summary>
   5.124              /// Gets the OK button text.
   5.125              /// </summary>
   5.126              public string OKText
   5.127 @@ -1291,6 +1380,7 @@
   5.128  
   5.129                  copy.IsAdvancedEnabled = this._IsAdvancedEnabled;
   5.130                  copy.IsAutoUpdateEnabled = this._IsAutoUpdateEnabled;
   5.131 +                copy.IsCheckingForUpdates = this._IsCheckingForUpdates;
   5.132                  copy.IsDeveloperModeEnabled = this._IsDeveloperModeEnabled;
   5.133                  copy.IsEncryptAllAccountsEnabled = this._IsEncryptAllAccountsEnabled;
   5.134                  copy.IsKeyServerUsed = this._IsKeyServerUsed;
   5.135 @@ -1341,6 +1431,7 @@
   5.136                  this._BlacklistSelectedIndex = -1;
   5.137                  this._IsAdvancedEnabled = false;
   5.138                  this._IsAutoUpdateEnabled = PEPSettings.IS_AUTO_UPDATE_ENABLED_DEFAULT;
   5.139 +                this._IsCheckingForUpdates = false;
   5.140                  this._IsDeveloperModeEnabled = PEPSettings.IS_DEVELOPER_MODE_ENABLED_DEFAULT;
   5.141                  this._IsEncryptAllAccountsEnabled = PEPSettings.IS_ENCRYPT_ALL_ACCOUNTS_ENABLED_DEFAULT;
   5.142                  this._IsKeyServerUsed = PEPSettings.IS_KEY_SERVER_USED_DEFAULT;
   5.143 @@ -1355,6 +1446,7 @@
   5.144                  this._IsVerboseLoggingEnabled = PEPSettings.IS_VERBOSE_LOGGING_ENABLED_DEFAULT;
   5.145                  this._LogEngine = null;
   5.146                  this._LogOutlook = null;
   5.147 +                this._LookingForUpdateLabelVisibility = Visibility.Hidden;
   5.148                  this._PEPCopyright = null;
   5.149                  this._PEPCredits = null;
   5.150                  this._PEPName = null;
   5.151 @@ -1375,6 +1467,7 @@
   5.152                  this.RaisePropertyChangedEvent(nameof(this.BlacklistSelectedIndex));
   5.153                  this.RaisePropertyChangedEvent(nameof(this.IsAdvancedEnabled));
   5.154                  this.RaisePropertyChangedEvent(nameof(this.IsAutoUpdateEnabled));
   5.155 +                this.RaisePropertyChangedEvent(nameof(this.IsCheckingForUpdates));
   5.156                  this.RaisePropertyChangedEvent(nameof(this.IsDeveloperModeEnabled));
   5.157                  this.RaisePropertyChangedEvent(nameof(this.IsEncryptAllAccountsEnabled));
   5.158                  this.RaisePropertyChangedEvent(nameof(this.IsKeyServerUsed));
   5.159 @@ -1389,6 +1482,7 @@
   5.160                  this.RaisePropertyChangedEvent(nameof(this.IsVerboseLoggingEnabled));
   5.161                  this.RaisePropertyChangedEvent(nameof(this.LogEngine));
   5.162                  this.RaisePropertyChangedEvent(nameof(this.LogOutlook));
   5.163 +                this.RaisePropertyChangedEvent(nameof(this.LookingForUpdateLabelVisibility));
   5.164                  this.RaisePropertyChangedEvent(nameof(this.PEPCopyright));
   5.165                  this.RaisePropertyChangedEvent(nameof(this.PEPCredits));
   5.166                  this.RaisePropertyChangedEvent(nameof(this.PEPName));
   5.167 @@ -1422,6 +1516,7 @@
   5.168                  this._LogEngineText = pEp.Properties.Resources.Options_LogEngineText;
   5.169                  this._LogOutlookText = pEp.Properties.Resources.Options_LogOutlookText;
   5.170                  this._LogRefreshText = pEp.Properties.Resources.Options_LogRefreshText;
   5.171 +                this._LookingForUpdateLabelText = pEp.Properties.Resources.Options_LookingForUpdate;
   5.172                  this._OKText = pEp.Properties.Resources.Options_OKText;
   5.173                  this._OpenKeyManagerText = pEp.Properties.Resources.Options_OpenKeyManagerText;
   5.174                  this._PageAboutText = pEp.Properties.Resources.Options_PageAboutText;
   5.175 @@ -1461,6 +1556,7 @@
   5.176                  this.RaisePropertyChangedEvent(nameof(this.LogEngineText));
   5.177                  this.RaisePropertyChangedEvent(nameof(this.LogOutlookText));
   5.178                  this.RaisePropertyChangedEvent(nameof(this.LogRefreshText));
   5.179 +                this.RaisePropertyChangedEvent(nameof(this.LookingForUpdateLabelText));
   5.180                  this.RaisePropertyChangedEvent(nameof(this.OKText));
   5.181                  this.RaisePropertyChangedEvent(nameof(this.OpenKeyManagerText));
   5.182                  this.RaisePropertyChangedEvent(nameof(this.PageAboutText));