Esempio n. 1
0
        private void FillRSS(UpdaterPresentation presentation)
        {
            switch (AssemblyHelper.BuildType)
            {
            // for Developer and Nightly fill the presentation with the SVN-changelog
            case Ct2BuildType.Developer:
            case Ct2BuildType.Nightly:
                if (changelog != null)
                {
                    presentation.ReadAndFillRSSChangelog(changelog);
                }
                break;

            // for Beta and Stable use dedicated text in presentation
            case Ct2BuildType.Beta:
            case Ct2BuildType.Stable:
                if (changelogText != null)
                {
                    presentation.FillChangelogText(changelogText);
                }
                break;

            default:
                // Unknown build type - do nothing.
                break;
            }
        }
 public static UpdaterPresentation GetSingleton()
 {
     if (singleton == null)
     {
         singleton = new UpdaterPresentation();
     }
     return(singleton);
 }
Esempio n. 3
0
        private void wc_DownloadProgressChanged(object sender, System.Net.DownloadProgressChangedEventArgs e)
        {
            OnUpdateDownloadProgressChanged(e.ProgressPercentage);
            try
            {
                progressTimer.Stop();
                UpdaterPresentation.GetSingleton().Dispatcher.BeginInvoke(DispatcherPriority.Normal, (SendOrPostCallback) delegate
                {
                    try
                    {
                        UpdaterPresentation.GetSingleton().progressBar1.Value = e.ProgressPercentage;
                        if (DateTime.Now > lastGuiUpdateTime.AddMilliseconds(750))
                        {
                            double interval       = DateTime.Now.Subtract(lastTime).TotalMilliseconds;
                            lastTime              = DateTime.Now;
                            double bytes          = e.BytesReceived - bytesReceived;
                            bytesReceived         = e.BytesReceived;
                            double bytesPerSecond = (bytes / interval) * 1000.1;

                            if (bytesPerSecond < 1024)
                            {
                                UpdaterPresentation.GetSingleton().text.Text = string.Format("{0:0.00} Bytes/sec", bytesPerSecond);
                            }
                            else if (bytesPerSecond / 1024 < 1024)
                            {
                                UpdaterPresentation.GetSingleton().text.Text = string.Format("{0:0.00} KiB/sec", (bytesPerSecond / 1024.0));
                            }
                            else
                            {
                                UpdaterPresentation.GetSingleton().text.Text = string.Format("{0:0.00} MiB/sec", (bytesPerSecond / (1024.0 * 1024.0)));
                            }
                            lastGuiUpdateTime = DateTime.Now;
                        }
                    }
                    catch (Exception ex)
                    {
                        //wtf?
                    }
                }, e.ProgressPercentage);
                if (wc.IsBusy)
                {
                    progressTimer.Start();
                }
            }
            catch (Exception ex)
            {
                GuiLogMessage("Error during download: " + ex.Message, NotificationLevel.Error);
            }
        }
Esempio n. 4
0
 private void AutoUpdater_OnUpdaterStatusChanged(AutoUpdater.State newStatus)
 {
     UpdaterPresentation.GetSingleton().Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback) delegate
     {
         UpdaterStateChanged(newStatus);
     }, null);
     if (newStatus == State.UpdateAvailable && Settings.Default.AutoDownload)
     {
         if (downloadRetry < 3)
         {
             Download();
             downloadRetry++;
         }
         else
         {
             GuiLogMessage("AutoUpdate: Auto download failed, try again later.", NotificationLevel.Warning);
         }
     }
 }
Esempio n. 5
0
        private void InitUpdater()
        {
            update      = (ImageSource)FindResource("Update");
            noUpdate    = (ImageSource)FindResource("NoUpdate");
            updateReady = (ImageSource)FindResource("UpdateReady");
            autoUpdateButton.ToolTip = Properties.Resources.No_update_available_;

            AutoUpdater.GetSingleton().OnGuiLogNotificationOccured     += new GuiLogNotificationEventHandler(OnGuiLogNotificationOccured);
            AutoUpdater.GetSingleton().OnUpdaterStateChanged           += new AutoUpdater.UpdaterStateChangedHandler(MainWindow_OnUpdaterStateChanged);
            AutoUpdater.GetSingleton().OnUpdateDownloadProgressChanged += new AutoUpdater.UpdateDownloadProgressChangedHandler(MainWindow_OnUpdateDownloadProgressChanged);
            UpdaterPresentation.GetSingleton().OnRestartClicked        += new UpdaterPresentation.RestartClickedHandler(RestartCrypTool);

            if (Settings.Default.CheckPeriodically)
            {
                AutoUpdater.GetSingleton().BeginCheckingForUpdates('S');
                AutoUpdater.GetSingleton().StartCheckTimer();
            }
            else if (Settings.Default.CheckOnStartup)
            {
                AutoUpdater.GetSingleton().BeginCheckingForUpdates('S');
            }
        }
Esempio n. 6
0
        private void UpdaterStateChanged(State newStatus)
        {
            try
            {
                var presentation = UpdaterPresentation.GetSingleton();

                switch (newStatus)
                {
                case State.Idle:
                    presentation.updateButton.Visibility = Visibility.Visible;
                    presentation.updateButton.IsEnabled  = true;
                    presentation.updateButton.Content    = Properties.Resources.Check_for_updates_now;
                    presentation.label1.Content          = serverAvailable ?
                                                           Properties.Resources.You_have_currently_the_latest_version_installed_ :
                                                           string.Format(Properties.Resources.Checking_failed__cannot_contact_server__0, serverNotAvailableMessage);
                    presentation.smallRightImage.Visibility = Visibility.Collapsed;
                    break;

                case State.Checking:
                    presentation.updateButton.Visibility = Visibility.Collapsed;
                    presentation.updateButton.IsEnabled  = false;
                    presentation.label1.Content          = Properties.Resources.Checking_for_updates___;
                    break;

                case State.UpdateAvailable:
                    presentation.updateButton.IsEnabled = true;
                    presentation.updateButton.Content   = Properties.Resources.Download_update_now;
                    presentation.label1.Content         = (updateName == null) ?
                                                          Properties.Resources.Update_available_ :
                                                          string.Format(Properties.Resources.Update_available___0, updateName);
                    presentation.updateButton.Visibility    = Visibility.Visible;
                    presentation.progressBar1.Visibility    = Visibility.Collapsed;
                    presentation.text.Visibility            = Visibility.Collapsed;
                    presentation.smallRightImage.Source     = (ImageSource)presentation.FindResource("Update");
                    presentation.smallRightImage.Visibility = Visibility.Visible;
                    presentation.ChangelogBorder.Visibility = Visibility.Visible;
                    FillRSS(presentation);
                    break;

                case State.Downloading:
                    presentation.updateButton.IsEnabled  = false;
                    presentation.updateButton.Visibility = Visibility.Collapsed;
                    presentation.progressBar1.Visibility = Visibility.Visible;
                    presentation.text.Visibility         = Visibility.Visible;
                    presentation.label1.Content          = (updateName == null) ?
                                                           Properties.Resources.Downloading_update___ :
                                                           string.Format(Properties.Resources.Downloading_update___0_____, updateName);
                    presentation.smallRightImage.Source     = (ImageSource)presentation.FindResource("Update");
                    presentation.ChangelogBorder.Visibility = Visibility.Visible;
                    presentation.smallRightImage.Visibility = Visibility.Visible;
                    FillRSS(presentation);
                    break;

                case State.UpdateReady:
                    presentation.updateButton.IsEnabled  = true;
                    presentation.updateButton.Content    = Properties.Resources.Restart_and_install_now;
                    presentation.updateButton.Visibility = Visibility.Visible;
                    presentation.progressBar1.Visibility = Visibility.Collapsed;
                    presentation.text.Visibility         = Visibility.Collapsed;
                    presentation.label1.Content          = (updateName == null) ?
                                                           Properties.Resources.Update_ready_to_install_ :
                                                           string.Format(Properties.Resources.Update___0___ready_to_install_, updateName);
                    presentation.smallRightImage.Source     = (ImageSource)presentation.FindResource("UpdateReady");
                    presentation.ChangelogBorder.Visibility = Visibility.Visible;
                    presentation.smallRightImage.Visibility = Visibility.Visible;
                    FillRSS(presentation);
                    break;
                }
            }
            catch (Exception)
            {
                GuiLogMessage("AutoUpdate: Error occured while trying to get update information.", NotificationLevel.Warning);
            }
        }