Skip to content

Commit

Permalink
Fixed adding accounts function
Browse files Browse the repository at this point in the history
  • Loading branch information
MakcStudio authored Jun 25, 2023
1 parent 6bfdb98 commit 3d732d4
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 33 deletions.
22 changes: 6 additions & 16 deletions Steam Desktop Authenticator/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 40 additions & 15 deletions Steam Desktop Authenticator/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Confirmation> confs = new List<Confirmation>();
Dictionary<SteamGuardAccount, List<Confirmation>> autoAcceptConfirmations = new Dictionary<SteamGuardAccount, List<Confirmation>>();

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

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

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) ||
Expand All @@ -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<Confirmation>();
confs[acc].Add(conf);
}
//confs.Add(conf);
}
}
catch (SteamGuardAccount.WGTokenInvalidException)
Expand All @@ -447,28 +453,47 @@ 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)
{

}
}

lblStatus.Text = "";

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)
{

}
}
}
}
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@
<Content Include="icon.ico" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\lib\SteamAuth\SteamAuth.csproj">
<ProjectReference Include="..\..\NEW PANEL\SteamAuth\SteamAuth.csproj">
<Project>{008bd387-3fca-48a4-899b-3bbf6b5946a2}</Project>
<Name>SteamAuth</Name>
</ProjectReference>
Expand Down
2 changes: 1 addition & 1 deletion Steam Desktop Authenticator/TradePopupForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private void Reset()

btnAccept.Text = "Принять";
btnDeny.Text = "Отклонить";
lblAccount.Text = "";
lblAccount.Text = Account.AccountName;
lblStatus.Text = "";

if (confirms.Count == 0)
Expand Down

0 comments on commit 3d732d4

Please sign in to comment.