Exemplo n.º 1
0
        public void Start()
        {
            if (_started == true) return;
            _started = true;

            _server = new Microsoft.VisualStudio.WebHost.Server(Port, "/", App);

            Mara.Log("Cassini starting ... ");
            try {
                _server.Start();
            } catch (SocketException ex) {
                //throw new Exception(string.Format("Couldn't start Cassini ... do you already have something running on port {0}?\n{1}",
                //        Port, ex.Message));
                Mara.Log("Cassini complained about something: {0}", ex.Message);
            }
            // Mara.WaitForLocalPortToBecomeUnavailable(Port);
            System.Threading.Thread.Sleep(3000); // it's not happy, let's just keep sleeping for now FIXME
            Mara.Log("done");
        }
Exemplo n.º 2
0
        public void Start()
        {
            if (_started == true)
            {
                return;
            }
            _started = true;

            _server = new Microsoft.VisualStudio.WebHost.Server(Port, "/", App);

            Mara.Log("Cassini starting ... ");
            try {
                _server.Start();
            } catch (SocketException ex) {
                //throw new Exception(string.Format("Couldn't start Cassini ... do you already have something running on port {0}?\n{1}",
                //        Port, ex.Message));
                Mara.Log("Cassini complained about something: {0}", ex.Message);
            }
            // Mara.WaitForLocalPortToBecomeUnavailable(Port);
            System.Threading.Thread.Sleep(3000); // it's not happy, let's just keep sleeping for now FIXME
            Mara.Log("done");
        }
Exemplo n.º 3
0
        public bool Start()
        {
            if (_started)
            {
                return(false);
            }
            _started = true;

            DeleporterUtilities.SetWebAndRemotingPortsBasedOnAvailability();

            if (!DeleporterUtilities.LocalPortIsAvailable(DeleporterConfiguration.WebHostPort))
            {
                LoggerClient.Log("ERROR: Cassini port {0} is being used. Attempt to start Cassini has been aborted",
                                 DeleporterConfiguration.WebHostPort);
                throw new InvalidOperationException(string.Format("Cassini port {0} is being used by something else. Attempt to start Cassini has been aborted",
                                                                  DeleporterConfiguration.WebHostPort));
            }

            LoggerClient.Log("Using web.config location {0} with port {1}",
                             DeleporterConfiguration.FullyQualifiedPathToWebApp, DeleporterConfiguration.WebHostPort);

            _casinniServer = new Microsoft.VisualStudio.WebHost.Server(DeleporterConfiguration.WebHostPort, "/",
                                                                       DeleporterConfiguration.FullyQualifiedPathToWebApp);

            LoggerClient.Log("Cassini starting on port {0} using path {1}... ", DeleporterConfiguration.WebHostPort, DeleporterConfiguration.FullyQualifiedPathToWebApp);
            try {
                _casinniServer.Start();
            } catch (Exception ex) {
                LoggerClient.Log("Couldn't start Cassini ... {0}", ex.Message);
                return(false);
            }

            DeleporterUtilities.WaitForLocalPortToBecomeUnavailable(DeleporterConfiguration.WebHostPort);
            LoggerClient.Log("Cassini Started");
            DeleporterUtilities.PrimeServerHomepage();
            return(true);
        }
Exemplo n.º 4
0
        private void onWindowLoaded(object sender, RoutedEventArgs e)
        {
            InitializeBinding();

            var gaAppIdsToolTip = new ToolTip();

            gaAppIdsToolTip.Content         = resources["GaAppIdsTooltip"] as string;
            gaAppIdsToolTip.StaysOpen       = true;
            gaAppIdsToolTip.PlacementTarget = gaAppIdsTextBox;
            gaAppIdsToolTip.Placement       = System.Windows.Controls.Primitives.PlacementMode.Top;
            gaAppIdsTextBox.ToolTip         = gaAppIdsToolTip;

            notificationController = new NotificationController(this);
            plink   = new Plink();
            privoxy = new Privoxy();
            goagent = new GoAgent();


            versionTextBlock.Text += resources["Version"] as string + " " + Assembly.GetExecutingAssembly().GetName().Version.ToString();
            websiteUrlText.Text    = settings.WebsiteUrl;
            feedbackEmailText.Text = settings.FeedbackEmail;

            if (!(
                    (settings.ProxyType == "SSH" && !Plink.CheckSettings()) ||
                    (settings.ProxyType == "GA" && settings.GaAppIds == "")
                    ))
            {
                WindowState = WindowState.Minimized;
            }

            goagent.Started += () => {
                notificationController.SetStatus("GA", NotificationController.Status.OK);
            };

            goagent.Stopped += () => {
                notificationController.SetStatus("GA", NotificationController.Status.Stopped);
            };

            //goagent.RequireRunas += () => {
            //    MessageBox.Show(resources["GoAgentRequiresRunasMessage"] as string);

            //    //var si = new ProcessStartInfo();
            //    //si.FileName = System.Windows.Forms.Application.ExecutablePath;
            //    //si.Verb = "runas";
            //    //si.Arguments = "restart";
            //    //Process.Start(si);
            //    Process.Start(System.Windows.Forms.Application.ExecutablePath, "restart");


            //    //App.Current.Shutdown();
            //};


            plink.Started += () => {
                Dispatcher.BeginInvoke(new Action(() => {
                    sshInformationGrid.IsEnabled = false;
                    sshConnectButton.IsEnabled   = true;
                    sshConnectButton.Content     = resources["Stop"] as string;
                    notificationController.SetStatus("SSH", NotificationController.Status.Processing, resources["Connecting"] as string);
                }));
            };

            plink.Connected += () => {
                Dispatcher.BeginInvoke(new Action(() => {
                    sshConnectButton.IsEnabled = true;
                    sshConnectButton.Content   = resources["Disconnect"] as string;
                    notificationController.SetStatus("SSH", NotificationController.Status.OK, resources["Connected"] as string, settings.SshNotification ? String.Format(resources["SuccessConnectDescription"] as string, settings.SshServer) : null);
                }));
            };

            plink.ReconnectCountingDown += (seconds) => {
                Dispatcher.BeginInvoke(new Action(() => {
                    sshConnectButton.IsEnabled = true;
                    sshConnectButton.Content   = resources["Stop"] as string;
                    notificationController.SetStatus("SSH", NotificationController.Status.Stopped, String.Format(resources["ReconnectDescription"] as string, seconds));
                }));
            };

            plink.Disconnected += (isLastSuccess, isReconnect) => {
                Dispatcher.BeginInvoke(new Action(() => {
                    sshInformationGrid.IsEnabled = true;
                    sshConnectButton.IsEnabled   = true;
                    sshConnectButton.Content     = resources["Connect"] as string;

                    if (plink.Error != null)
                    {
                        notificationController.SetStatus("SSH", NotificationController.Status.Error, resources["ErrorConnect"] as string, plink.Error != lastPlinkError ? plink.Error : null, System.Windows.Forms.ToolTipIcon.Error);
                    }
                    else if (isLastSuccess)
                    {
                        notificationController.SetStatus("SSH", NotificationController.Status.Stopped, resources["Disconnected"] as string, settings.SshNotification ? resources["DisconnectedDescription"] as string : null, System.Windows.Forms.ToolTipIcon.Warning);
                    }
                    else if (plink.IsNormallyStopped)
                    {
                        notificationController.SetStatus("SSH", NotificationController.Status.Stopped, resources["ConnectStopped"] as string);
                    }
                    else if (isReconnect)
                    {
                        notificationController.SetStatus("SSH", NotificationController.Status.Stopped, resources["ConnectFailed"] as string);
                    }
                    else
                    {
                        notificationController.SetStatus("SSH", NotificationController.Status.Stopped, resources["ConnectFailed"] as string, String.Format(resources["ConnectFailedDescription"] as string, settings.SshServer), System.Windows.Forms.ToolTipIcon.Warning);
                    }

                    lastPlinkError = plink.Error;
                }));
            };

            //RULES
            //online rules
            if (settings.OnlineRulesLastUpdateTime.Ticks > 0)
            {
                lastUpdateTimeTextBlock.Text = settings.OnlineRulesLastUpdateTime.ToString(@"M\/d\/yyyy");
            }

            Rules.OnlineRules.UpdateStarted += () => {
                Dispatcher.BeginInvoke(new Action(() => {
                    onlineRulesUpdateButton.Content   = resources["Updating"] as string;
                    onlineRulesUpdateButton.IsEnabled = false;
                }));
            };

            Rules.OnlineRules.Updated += (success) => {
                Dispatcher.BeginInvoke(new Action(() => {
                    onlineRulesUpdateButton.Content   = resources["Update"] as string;
                    onlineRulesUpdateButton.IsEnabled = true;
                    if (success)
                    {
                        lastUpdateTimeTextBlock.Text = settings.OnlineRulesLastUpdateTime.ToString(@"M\/d\/yyyy");
                    }
                    //else
                    //    notificationController.Tray.ShowBalloonTip(0, resources["UpdateOnlineRulesFailed"] as string, resources["UpdateOnlineRulesFailedDescription"] as string, System.Windows.Forms.ToolTipIcon.Warning);
                }));
            };

            //custom rules
            updateCustomRulesStatus();

            Rules.CustomRules.Rules.ListChanged += (o, a) => {
                Dispatcher.BeginInvoke(new Action(updateCustomRulesStatus));
            };

            Rules.Initialize();

            //* DEBUG CODE
            privoxy.Start();

            var server = new Microsoft.VisualStudio.WebHost.Server(settings.LocalServerPort, "/", App.AppDataDirectory + settings.LocalServerFolderName);

            try {
                server.Start();
            }
            catch {
                MessageBox.Show(string.Format(resources["FailedStartLocalServer"] as string, settings.LocalServerPort));
            }

            App.Current.Exit += (o, a) => {
                try {
                    server.Stop();
                }
                catch { }
            };

            settings.PropertyChanged += (o, a) => {
                switch (a.PropertyName)
                {
                case "ProxyPort": break;

                case "ListenToLocalOnly": break;

                case "UseIntranetProxy": break;

                case "IntranetProxyServer": break;

                case "IntranetProxyPort": break;

                default: return;
                }

                privoxy.Start();
            };
            //*/

            //ga

            if (settings.ProxyType == "GA")
            {
                goagent.Start();
            }

            settings.PropertyChanged += (o, a) => {
                switch (a.PropertyName)
                {
                case "ProxyType": break;

                default: return;
                }

                if (settings.ProxyType == "GA")
                {
                    goagent.Start();
                }
                else
                {
                    goagent.Stop();
                }
            };

            settings.PropertyChanged += (o, a) => {
                switch (a.PropertyName)
                {
                case "GaPort": break;

                case "GaProfile": break;

                case "GaAppIds": break;

                default: return;
                }

                if (settings.ProxyType == "GA")
                {
                    goagent.Start();
                }
            };


            //ssh

            if (settings.ProxyType == "SSH" && settings.AutoStart)
            {
                plink.Start();
            }

            settings.PropertyChanged += (o, a) => {
                switch (a.PropertyName)
                {
                case "ProxyType": break;

                default: return;
                }

                if (settings.ProxyType == "SSH")
                {
                    if (settings.AutoStart)
                    {
                        plink.Start();
                    }
                }
                else
                {
                    plink.Stop();
                }
            };

            settings.PropertyChanged += (o, a) => {
                switch (a.PropertyName)
                {
                case "SshSocksPort": break;

                case "SshCompression": break;

                case "SshPlonkKeyword": break;

                default: return;
                }

                if (settings.ProxyType == "SSH")
                {
                    if (plink.IsConnected || plink.IsConnecting)
                    {
                        plink.Start();
                    }
                }
            };

            var usePlonkChangeBack = false;

            settings.PropertyChanged += (o, a) => {
                switch (a.PropertyName)
                {
                case "SshUsePlonk":
                    if (usePlonkChangeBack)
                    {
                        usePlonkChangeBack = false;
                        return;
                    }
                    else
                    {
                        break;
                    }

                default: return;
                }

                if (settings.SshUsePlonk && !File.Exists(settings.PlonkFileName))
                {
                    usePlonkChangeBack            = true;
                    sshUsePlonkCheckBox.IsChecked = false;
                    MessageBox.Show(resources["PlonkMissingMessage"] as string);
                }
                else if (settings.ProxyType == "SSH")
                {
                    if (plink.IsConnected || plink.IsConnecting)
                    {
                        plink.Start();
                    }
                }
            };

            //http&socks
            settings.PropertyChanged += (o, a) => {
                switch (a.PropertyName)
                {
                case "ProxyType": break;

                default: return;
                }

                initIconStatus();
            };

            initIconStatus();

            var ruleCommandWatcher = new FileSystemWatcher(App.AppDataDirectory + settings.ConfigsFolderName, "*-cmd");

            ruleCommandWatcher.Created            += ruleCommandHandler;
            ruleCommandWatcher.Changed            += ruleCommandHandler;
            ruleCommandWatcher.EnableRaisingEvents = true;

            Timer updateCheckTimer = null;

            updateCheckTimer = new Timer((st) => {
                Dispatcher.BeginInvoke(new Action(() => {
                    if (onlineVersionStr == null)
                    {
                        checkVersion();
                    }
                    else
                    {
                        updateCheckTimer.Dispose();
                    }
                }));
            }, null, 0, settings.UpdateCheckDelay * 1000);

            if (App.Updated)
            {
                new Action(() => {
                    Thread.Sleep(1000);
                    try {
                        File.Delete(App.AppDataDirectory + settings.ResourcesFolderName + settings.UpdateInstallerName);
                    }
                    catch { }
                    notificationController.SendMessage(resources["UpdateSuccessTitle"] as string, resources["UpdateSuccessDetails"] as string);

                    if (Directory.Exists(App.AppDataDirectory + settings.GaFolderName) && settings.GaServerVersion > settings.GaLastServerVersion)
                    {
                        settings.GaLastServerVersion = settings.GaServerVersion;
                        MessageBox.Show(resources["NewGaServerMessage"] as string);
                    }
                }).BeginInvoke(null, null);
            }

            if (App.Updated || App.FirstRun)
            {
                new WebClient().DownloadStringAsync(new Uri(settings.UpdateReportUrl + "?v=" + Assembly.GetExecutingAssembly().GetName().Version.ToString()));
            }

            if (WindowState != WindowState.Minimized)
            {
                Activate();
            }

            //if (!settings.SubmitNewRuleAsked) {
            //    settings.SubmitNewRuleAsked = true;
            //    var message = (resources["ShareRuleMessage"] as string).Replace("%n ", Environment.NewLine + Environment.NewLine);

            //    var result = MessageBox.Show(message, resources["ShareRuleTitle"] as string, MessageBoxButton.YesNo);
            //    settings.SubmitNewRule = result == MessageBoxResult.Yes;
            //}
        }
Exemplo n.º 5
0
        private void onWindowLoaded(object sender, RoutedEventArgs e) {
            InitializeBinding();

            var gaAppIdsToolTip = new ToolTip();
            gaAppIdsToolTip.Content = resources["GaAppIdsTooltip"] as string;
            gaAppIdsToolTip.StaysOpen = true;
            gaAppIdsToolTip.PlacementTarget = gaAppIdsTextBox;
            gaAppIdsToolTip.Placement = System.Windows.Controls.Primitives.PlacementMode.Top;
            gaAppIdsTextBox.ToolTip = gaAppIdsToolTip;

            notificationController = new NotificationController(this);
            plink = new Plink();
            privoxy = new Privoxy();
            goagent = new GoAgent();


            versionTextBlock.Text += resources["Version"] as string + " " + Assembly.GetExecutingAssembly().GetName().Version.ToString();
            websiteUrlText.Text = settings.WebsiteUrl;
            feedbackEmailText.Text = settings.FeedbackEmail;

            if (!(
                (settings.ProxyType == "SSH" && !Plink.CheckSettings()) ||
                (settings.ProxyType == "GA" && settings.GaAppIds == "")
            )) WindowState = WindowState.Minimized;

            goagent.Started += () => {
                notificationController.SetStatus("GA", NotificationController.Status.OK);
            };

            goagent.Stopped += () => {
                notificationController.SetStatus("GA", NotificationController.Status.Stopped);
            };

            //goagent.RequireRunas += () => {
            //    MessageBox.Show(resources["GoAgentRequiresRunasMessage"] as string);

            //    //var si = new ProcessStartInfo();
            //    //si.FileName = System.Windows.Forms.Application.ExecutablePath;
            //    //si.Verb = "runas";
            //    //si.Arguments = "restart";
            //    //Process.Start(si);
            //    Process.Start(System.Windows.Forms.Application.ExecutablePath, "restart");
                

            //    //App.Current.Shutdown();
            //};


            plink.Started += () => {
                Dispatcher.BeginInvoke(new Action(() => {
                    sshInformationGrid.IsEnabled = false;
                    sshConnectButton.IsEnabled = true;
                    sshConnectButton.Content = resources["Stop"] as string;
                    notificationController.SetStatus("SSH", NotificationController.Status.Processing, resources["Connecting"] as string);
                }));
            };

            plink.Connected += () => {
                Dispatcher.BeginInvoke(new Action(() => {
                    sshConnectButton.IsEnabled = true;
                    sshConnectButton.Content = resources["Disconnect"] as string;
                    notificationController.SetStatus("SSH", NotificationController.Status.OK, resources["Connected"] as string, settings.SshNotification ? String.Format(resources["SuccessConnectDescription"] as string, settings.SshServer) : null);
                }));
            };

            plink.ReconnectCountingDown += (seconds) => {
                Dispatcher.BeginInvoke(new Action(() => {
                    sshConnectButton.IsEnabled = true;
                    sshConnectButton.Content = resources["Stop"] as string;
                    notificationController.SetStatus("SSH", NotificationController.Status.Stopped, String.Format(resources["ReconnectDescription"] as string, seconds));
                }));
            };

            plink.Disconnected += (isLastSuccess, isReconnect) => {
                Dispatcher.BeginInvoke(new Action(() => {
                    sshInformationGrid.IsEnabled = true;
                    sshConnectButton.IsEnabled = true;
                    sshConnectButton.Content = resources["Connect"] as string;

                    if (plink.Error != null)
                        notificationController.SetStatus("SSH", NotificationController.Status.Error, resources["ErrorConnect"] as string, plink.Error != lastPlinkError ? plink.Error : null, System.Windows.Forms.ToolTipIcon.Error);
                    else if (isLastSuccess)
                        notificationController.SetStatus("SSH", NotificationController.Status.Stopped, resources["Disconnected"] as string, settings.SshNotification ? resources["DisconnectedDescription"] as string : null, System.Windows.Forms.ToolTipIcon.Warning);
                    else if (plink.IsNormallyStopped)
                        notificationController.SetStatus("SSH", NotificationController.Status.Stopped, resources["ConnectStopped"] as string);
                    else if (isReconnect)
                        notificationController.SetStatus("SSH", NotificationController.Status.Stopped, resources["ConnectFailed"] as string);
                    else
                        notificationController.SetStatus("SSH", NotificationController.Status.Stopped, resources["ConnectFailed"] as string, String.Format(resources["ConnectFailedDescription"] as string, settings.SshServer), System.Windows.Forms.ToolTipIcon.Warning);
                    
                    lastPlinkError = plink.Error;
                }));
            };

            //RULES
            //online rules
            if (settings.OnlineRulesLastUpdateTime.Ticks > 0) {
                lastUpdateTimeTextBlock.Text = settings.OnlineRulesLastUpdateTime.ToString(@"M\/d\/yyyy");
            }

            Rules.OnlineRules.UpdateStarted += () => {
                Dispatcher.BeginInvoke(new Action(() => {
                    onlineRulesUpdateButton.Content = resources["Updating"] as string;
                    onlineRulesUpdateButton.IsEnabled = false;
                }));
            };

            Rules.OnlineRules.Updated += (success) => {
                Dispatcher.BeginInvoke(new Action(() => {
                    onlineRulesUpdateButton.Content = resources["Update"] as string;
                    onlineRulesUpdateButton.IsEnabled = true;
                    if (success)
                        lastUpdateTimeTextBlock.Text = settings.OnlineRulesLastUpdateTime.ToString(@"M\/d\/yyyy");
                    //else
                    //    notificationController.Tray.ShowBalloonTip(0, resources["UpdateOnlineRulesFailed"] as string, resources["UpdateOnlineRulesFailedDescription"] as string, System.Windows.Forms.ToolTipIcon.Warning);
                }));
            };

            //custom rules
            updateCustomRulesStatus();

            Rules.CustomRules.Rules.ListChanged += (o, a) => {
                Dispatcher.BeginInvoke(new Action(updateCustomRulesStatus));
            };

            Rules.Initialize();

            //* DEBUG CODE
            privoxy.Start();

            var server = new Microsoft.VisualStudio.WebHost.Server(settings.LocalServerPort, "/", App.AppDataDirectory + settings.LocalServerFolderName);
            try {
                server.Start();
            }
            catch {
                MessageBox.Show(string.Format(resources["FailedStartLocalServer"] as string, settings.LocalServerPort));
            }

            App.Current.Exit += (o, a) => {
                try {
                    server.Stop();
                }
                catch { }
            };

            settings.PropertyChanged += (o, a) => {
                switch (a.PropertyName) {
                    case "ProxyPort": break;
                    case "ListenToLocalOnly": break;
                    case "UseIntranetProxy": break;
                    case "IntranetProxyServer": break;
                    case "IntranetProxyPort": break;
                    default: return;
                }

                privoxy.Start();
            };
            //*/

            //ga

            if (settings.ProxyType == "GA") {
                goagent.Start();
            }

            settings.PropertyChanged += (o, a) => {
                switch (a.PropertyName) {
                    case "ProxyType": break;
                    default: return;
                }

                if (settings.ProxyType == "GA") {
                    goagent.Start();
                }
                else {
                    goagent.Stop();
                }
            };

            settings.PropertyChanged += (o, a) => {
                switch (a.PropertyName) {
                    case "GaPort": break;
                    case "GaProfile": break;
                    case "GaAppIds": break;
                    default: return;
                }

                if (settings.ProxyType == "GA") {
                    goagent.Start();
                }
            };


            //ssh

            if (settings.ProxyType == "SSH" && settings.AutoStart) {
                plink.Start();
            }

            settings.PropertyChanged += (o, a) => {
                switch (a.PropertyName) {
                    case "ProxyType": break;
                    default: return;
                }

                if (settings.ProxyType == "SSH") {
                    if (settings.AutoStart)
                        plink.Start();
                }
                else
                    plink.Stop();
            };

            settings.PropertyChanged += (o, a) => {
                switch (a.PropertyName) {
                    case "SshSocksPort": break;
                    case "SshCompression": break;
                    case "SshPlonkKeyword": break;
                    default: return;
                }

                if (settings.ProxyType == "SSH") {
                    if (plink.IsConnected || plink.IsConnecting)
                        plink.Start();
                }
            };

            var usePlonkChangeBack = false;
            settings.PropertyChanged += (o, a) => {
                switch (a.PropertyName) {
                    case "SshUsePlonk":
                        if (usePlonkChangeBack) {
                            usePlonkChangeBack = false;
                            return;
                        }
                        else break;
                    default: return;
                }

                if (settings.SshUsePlonk && !File.Exists(settings.PlonkFileName)) {
                    usePlonkChangeBack = true;
                    sshUsePlonkCheckBox.IsChecked = false;
                    MessageBox.Show(resources["PlonkMissingMessage"] as string);
                }
                else if (settings.ProxyType == "SSH") {
                    if (plink.IsConnected || plink.IsConnecting)
                        plink.Start();
                }
            };

            //http&socks
            settings.PropertyChanged += (o, a) => {
                switch (a.PropertyName) {
                    case "ProxyType": break;
                    default: return;
                }

                initIconStatus();
            };

            initIconStatus();

            var ruleCommandWatcher = new FileSystemWatcher(App.AppDataDirectory + settings.ConfigsFolderName, "*-cmd");
            ruleCommandWatcher.Created += ruleCommandHandler;
            ruleCommandWatcher.Changed += ruleCommandHandler;
            ruleCommandWatcher.EnableRaisingEvents = true;

            Timer updateCheckTimer = null;
            updateCheckTimer = new Timer((st) => {
                Dispatcher.BeginInvoke(new Action(() => {
                    if (onlineVersionStr == null) {
                        checkVersion();
                    }
                    else {
                        updateCheckTimer.Dispose();
                    }
                }));
            }, null, 0, settings.UpdateCheckDelay * 1000);

            if (App.Updated) {
                new Action(() => {
                    Thread.Sleep(1000);
                    try {
                        File.Delete(App.AppDataDirectory + settings.ResourcesFolderName + settings.UpdateInstallerName);
                    }
                    catch { }
                    notificationController.SendMessage(resources["UpdateSuccessTitle"] as string, resources["UpdateSuccessDetails"] as string);

                    if (Directory.Exists(App.AppDataDirectory + settings.GaFolderName) && settings.GaServerVersion > settings.GaLastServerVersion) {
                        settings.GaLastServerVersion = settings.GaServerVersion;
                        MessageBox.Show(resources["NewGaServerMessage"] as string);
                    }
                }).BeginInvoke(null, null);
            }

            if (App.Updated || App.FirstRun) {
                new WebClient().DownloadStringAsync(new Uri(settings.UpdateReportUrl + "?v=" + Assembly.GetExecutingAssembly().GetName().Version.ToString()));
            }

            if (WindowState != WindowState.Minimized)
                Activate();

            //if (!settings.SubmitNewRuleAsked) {
            //    settings.SubmitNewRuleAsked = true;
            //    var message = (resources["ShareRuleMessage"] as string).Replace("%n ", Environment.NewLine + Environment.NewLine);

            //    var result = MessageBox.Show(message, resources["ShareRuleTitle"] as string, MessageBoxButton.YesNo);
            //    settings.SubmitNewRule = result == MessageBoxResult.Yes;
            //}
        }