From 3d732d48c1eee40fb94178560ed9c9b9d5e1b058 Mon Sep 17 00:00:00 2001 From: MakcStudio <41212099+MakcStudio@users.noreply.github.com> Date: Sun, 25 Jun 2023 14:23:32 +0300 Subject: [PATCH] Fixed adding accounts function --- .../MainForm.Designer.cs | 22 ++------ Steam Desktop Authenticator/MainForm.cs | 55 ++++++++++++++----- .../Steam Desktop Authenticator.csproj | 2 +- Steam Desktop Authenticator/TradePopupForm.cs | 2 +- 4 files changed, 48 insertions(+), 33 deletions(-) diff --git a/Steam Desktop Authenticator/MainForm.Designer.cs b/Steam Desktop Authenticator/MainForm.Designer.cs index 4b2d800..2beb66f 100644 --- a/Steam Desktop Authenticator/MainForm.Designer.cs +++ b/Steam Desktop Authenticator/MainForm.Designer.cs @@ -45,7 +45,6 @@ private void InitializeComponent() this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.importAccountToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuImportMaFile = new System.Windows.Forms.ToolStripMenuItem(); - this.menuImportAndroid = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.menuSettings = new System.Windows.Forms.ToolStripMenuItem(); this.menuQuit = new System.Windows.Forms.ToolStripMenuItem(); @@ -214,42 +213,34 @@ private void InitializeComponent() // importAccountToolStripMenuItem // this.importAccountToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.menuImportMaFile, - this.menuImportAndroid}); + this.menuImportMaFile}); this.importAccountToolStripMenuItem.Name = "importAccountToolStripMenuItem"; - this.importAccountToolStripMenuItem.Size = new System.Drawing.Size(169, 22); + this.importAccountToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.importAccountToolStripMenuItem.Text = "Импорт аккаунта"; // // menuImportMaFile // this.menuImportMaFile.Name = "menuImportMaFile"; - this.menuImportMaFile.Size = new System.Drawing.Size(186, 22); + this.menuImportMaFile.Size = new System.Drawing.Size(180, 22); this.menuImportMaFile.Text = "From maFile"; this.menuImportMaFile.Click += new System.EventHandler(this.menuImportMaFile_Click); // - // menuImportAndroid - // - this.menuImportAndroid.Name = "menuImportAndroid"; - this.menuImportAndroid.Size = new System.Drawing.Size(186, 22); - this.menuImportAndroid.Text = "From Android Device"; - this.menuImportAndroid.Click += new System.EventHandler(this.menuImportAndroid_Click); - // // toolStripSeparator1 // this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(166, 6); + this.toolStripSeparator1.Size = new System.Drawing.Size(177, 6); // // menuSettings // this.menuSettings.Name = "menuSettings"; - this.menuSettings.Size = new System.Drawing.Size(169, 22); + this.menuSettings.Size = new System.Drawing.Size(180, 22); this.menuSettings.Text = "Настройки"; this.menuSettings.Click += new System.EventHandler(this.menuSettings_Click); // // menuQuit // this.menuQuit.Name = "menuQuit"; - this.menuQuit.Size = new System.Drawing.Size(169, 22); + this.menuQuit.Size = new System.Drawing.Size(180, 22); this.menuQuit.Text = "Выход"; this.menuQuit.Click += new System.EventHandler(this.menuQuit_Click); // @@ -471,7 +462,6 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripComboBox trayAccountList; private System.Windows.Forms.ToolStripMenuItem importAccountToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem menuImportMaFile; - private System.Windows.Forms.ToolStripMenuItem menuImportAndroid; private System.Windows.Forms.Label lblStatus; private System.Windows.Forms.TextBox txtAccSearch; private System.Windows.Forms.Label label1; diff --git a/Steam Desktop Authenticator/MainForm.cs b/Steam Desktop Authenticator/MainForm.cs index 6eb307c..857cf49 100644 --- a/Steam Desktop Authenticator/MainForm.cs +++ b/Steam Desktop Authenticator/MainForm.cs @@ -404,27 +404,28 @@ private async void timerSteamGuard_Tick(object sender, EventArgs e) private async void timerTradesPopup_Tick(object sender, EventArgs e) { - if (currentAccount == null || popupFrm.Visible) return; + if (currentAccount == null || (popupFrm != 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 confs = new List(); - Dictionary> autoAcceptConfirmations = new Dictionary>(); - - SteamGuardAccount[] accs = - manifest.CheckAllAccounts ? allAccounts : new SteamGuardAccount[] { currentAccount }; - try { + Dictionary> confs = new Dictionary>(); + //List confs = new List(); + Dictionary> autoAcceptConfirmations = new Dictionary>(); + + SteamGuardAccount[] accs = + manifest.CheckAllAccounts ? allAccounts : new SteamGuardAccount[] { currentAccount }; + lblStatus.Text = "Проверка подтверждений..."; foreach (var acc in accs) { try { - Confirmation[] tmp = currentAccount.FetchConfirmations(); + Confirmation[] tmp = acc.FetchConfirmations(); foreach (var conf in tmp) { if ((conf.ConfType == Confirmation.ConfirmationType.MarketSellTransaction && manifest.AutoConfirmMarketTransactions) || @@ -435,7 +436,12 @@ private async void timerTradesPopup_Tick(object sender, EventArgs e) autoAcceptConfirmations[acc].Add(conf); } else - confs.Add(conf); + { + if (!confs.ContainsKey(acc)) + confs[acc] = new List(); + confs[acc].Add(conf); + } + //confs.Add(conf); } } catch (SteamGuardAccount.WGTokenInvalidException) @@ -447,12 +453,16 @@ private async void timerTradesPopup_Tick(object sender, EventArgs e) catch (SteamGuardAccount.WGTokenExpiredException) { //Prompt to relogin - PromptRefreshLogin(currentAccount); + PromptRefreshLogin(acc); 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) { + } + catch (Exception ex) + { + } } @@ -460,15 +470,30 @@ private async void timerTradesPopup_Tick(object sender, EventArgs e) if (confs.Count > 0) { - popupFrm.Confirmations = confs.ToArray(); - popupFrm.Popup(); + foreach (var acc in confs.Keys) + { + try + { + popupFrm.Account = acc; + popupFrm.Confirmations = confs[acc].ToArray(); + popupFrm.Popup(); + } + catch (Exception ex) { popupFrm = new TradePopupForm(); } + } } if (autoAcceptConfirmations.Count > 0) { foreach (var acc in autoAcceptConfirmations.Keys) { - var confirmations = autoAcceptConfirmations[acc].ToArray(); - acc.AcceptMultipleConfirmations(confirmations); + try + { + var confirmations = autoAcceptConfirmations[acc].ToArray(); + acc.AcceptMultipleConfirmations(confirmations); + } + catch (Exception ex) + { + + } } } } @@ -533,7 +558,7 @@ private void loadAccountInfo() { if (currentAccount != null && steamTime != 0) { - popupFrm.Account = currentAccount; + //popupFrm.Account = currentAccount; txtLoginToken.Text = currentAccount.GenerateSteamGuardCodeForTime(steamTime); groupAccount.Text = "Аккаунт: " + currentAccount.AccountName; } diff --git a/Steam Desktop Authenticator/Steam Desktop Authenticator.csproj b/Steam Desktop Authenticator/Steam Desktop Authenticator.csproj index a1745ae..ff2fcd8 100644 --- a/Steam Desktop Authenticator/Steam Desktop Authenticator.csproj +++ b/Steam Desktop Authenticator/Steam Desktop Authenticator.csproj @@ -248,7 +248,7 @@ - + {008bd387-3fca-48a4-899b-3bbf6b5946a2} SteamAuth diff --git a/Steam Desktop Authenticator/TradePopupForm.cs b/Steam Desktop Authenticator/TradePopupForm.cs index 8b5ddf2..9bf57a6 100644 --- a/Steam Desktop Authenticator/TradePopupForm.cs +++ b/Steam Desktop Authenticator/TradePopupForm.cs @@ -84,7 +84,7 @@ private void Reset() btnAccept.Text = "Принять"; btnDeny.Text = "Отклонить"; - lblAccount.Text = ""; + lblAccount.Text = Account.AccountName; lblStatus.Text = ""; if (confirms.Count == 0)