Popup() public method

public Popup ( ) : void
return void
        private async void timerTradesPopup_Tick(object sender, EventArgs e)
        {
            if (currentAccount == null || popupFrm.Visible)
            {
                return;
            }

            List <Confirmation> confs = new List <Confirmation>();

            SteamGuardAccount[] accs =
                checkAllAccounts ? allAccounts : new SteamGuardAccount[] { currentAccount };

            try
            {
                lblStatus.Text = "Checking confirmations...";

                foreach (var item in accs)
                {
                    try
                    {
                        Confirmation[] tmp = await currentAccount.FetchConfirmationsAsync();

                        confs.AddRange(tmp);
                    }
                    catch (SteamGuardAccount.WGTokenInvalidException)
                    {
                        lblStatus.Text = "Refreshing session";
                        await currentAccount.RefreshSessionAsync(); //Don't save it to the HDD, of course. We'd need their encryption passkey again.

                        lblStatus.Text = "";
                    }
                }

                lblStatus.Text = "";

                if (confs.Count == 0)
                {
                    return;
                }

                popupFrm.Confirmation = confs.ToArray();
                popupFrm.Popup();
            }
            catch (SteamGuardAccount.WGTokenInvalidException)
            {
                lblStatus.Text = "";
            }
        }
Example #2
0
        private async void timerTradesPopup_Tick(object sender, EventArgs e)
        {
            if (currentAccount == null || popupFrm.Visible)
            {
                return;
            }

            List <Confirmation> confs = new List <Confirmation>();

            SteamGuardAccount[] accs =
                checkAllAccounts ? allAccounts : new SteamGuardAccount[] { currentAccount };

            try
            {
                lblStatus.Text = "Checking confirmations...";

                foreach (var item in accs)
                {
                    Confirmation[] tmp = await currentAccount.FetchConfirmationsAsync();

                    confs.AddRange(tmp);
                }

                lblStatus.Text = "";

                if (confs.Count == 0)
                {
                    return;
                }

                popupFrm.Confirmation = confs.ToArray();
                popupFrm.Popup();
            }
            catch (SteamGuardAccount.WGTokenInvalidException)
            {
                lblStatus.Text = "";
            }
        }
Example #3
0
        private async void timerTradesPopup_Tick(object sender, EventArgs e)
        {
            if (currentAccount == null || popupFrm.Visible)
            {
                return;
            }

            List <Confirmation> confs = new List <Confirmation>();

            SteamGuardAccount[] accs =
                manifest.CheckAllAccounts ? allAccounts : new SteamGuardAccount[] { currentAccount };

            try
            {
                lblStatus.Text = "Checking confirmations...";

                foreach (var acc in accs)
                {
                    try
                    {
                        Confirmation[] tmp = await currentAccount.FetchConfirmationsAsync();

                        foreach (var conf in tmp)
                        {
                            if (conf.ConfType == Confirmation.ConfirmationType.MarketSellTransaction && manifest.AutoConfirmMarketTransactions)
                            {
                                acc.AcceptConfirmation(conf);
                            }
                            else if (conf.ConfType == Confirmation.ConfirmationType.Trade && manifest.AutoConfirmTrades)
                            {
                                acc.AcceptConfirmation(conf);
                            }
                            else
                            {
                                confs.Add(conf);
                            }
                        }
                    }
                    catch (SteamGuardAccount.WGTokenInvalidException)
                    {
                        lblStatus.Text = "Refreshing session";
                        await currentAccount.RefreshSessionAsync(); //Don't save it to the HDD, of course. We'd need their encryption passkey again.

                        lblStatus.Text = "";
                    }
                }

                lblStatus.Text = "";

                if (confs.Count == 0)
                {
                    return;
                }

                popupFrm.Confirmations = confs.ToArray();
                popupFrm.Popup();
            }
            catch (SteamGuardAccount.WGTokenInvalidException)
            {
                lblStatus.Text = "";
            }
        }
Example #4
0
        private async void timerTradesPopup_Tick(object sender, EventArgs e)
        {
            if (currentAccount == null || popupFrm.Visible)
            {
                return;
            }
            if (!confirmationsSemaphore.Wait(0))
            {
                return; //Only one thread may access this critical section at once. Mutex is a bad choice here because it'll cause a pileup of threads.
            }

            List <Confirmation> confs = new List <Confirmation>();
            Dictionary <SteamGuardAccount, List <Confirmation> > autoAcceptConfirmations = new Dictionary <SteamGuardAccount, List <Confirmation> >();

            SteamGuardAccount[] accs =
                manifest.CheckAllAccounts ? allAccounts : new SteamGuardAccount[] { currentAccount };

            try
            {
                lblStatus.Text = "Checking confirmations...";

                foreach (var acc in accs)
                {
                    try
                    {
                        Confirmation[] tmp = await currentAccount.FetchConfirmationsAsync();

                        foreach (var conf in tmp)
                        {
                            if ((conf.ConfType == Confirmation.ConfirmationType.MarketSellTransaction && manifest.AutoConfirmMarketTransactions) ||
                                (conf.ConfType == Confirmation.ConfirmationType.Trade && manifest.AutoConfirmTrades))
                            {
                                if (!autoAcceptConfirmations.ContainsKey(acc))
                                {
                                    autoAcceptConfirmations[acc] = new List <Confirmation>();
                                }
                                autoAcceptConfirmations[acc].Add(conf);
                            }
                            else
                            {
                                confs.Add(conf);
                            }
                        }
                    }
                    catch (SteamGuardAccount.WGTokenInvalidException)
                    {
                        lblStatus.Text = "Refreshing session";
                        await currentAccount.RefreshSessionAsync(); //Don't save it to the HDD, of course. We'd need their encryption passkey again.

                        lblStatus.Text = "";
                    }
                    catch (SteamGuardAccount.WGTokenExpiredException)
                    {
                        //Prompt to relogin
                        PromptRefreshLogin(currentAccount);
                        break; //Don't bombard a user with login refresh requests if they have multiple accounts. Give them a few seconds to disable the autocheck option if they want.
                    }
                    catch (WebException)
                    {
                    }
                }

                lblStatus.Text = "";

                if (confs.Count > 0)
                {
                    popupFrm.Confirmations = confs.ToArray();
                    popupFrm.Popup();
                }
                if (autoAcceptConfirmations.Count > 0)
                {
                    foreach (var acc in autoAcceptConfirmations.Keys)
                    {
                        var confirmations = autoAcceptConfirmations[acc].ToArray();
                        acc.AcceptMultipleConfirmations(confirmations);
                    }
                }
            }
            catch (SteamGuardAccount.WGTokenInvalidException)
            {
                lblStatus.Text = "";
            }

            confirmationsSemaphore.Release();
        }