Skip to content

Commit

Permalink
Merge pull request #198 from BeyondDimension/dev8-merge
Browse files Browse the repository at this point in the history
Dev8 merge
  • Loading branch information
yingpanwang authored Sep 4, 2024
2 parents ae645f9 + 2068848 commit 4de6c43
Show file tree
Hide file tree
Showing 3 changed files with 277 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/BD.SteamClient8.Impl/WebApi/SteamAccountService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ await WaitAndRetryAsync(sleepDurations).ExecuteAsync(async () =>
EncryptedPassword = encryptedPassword64,
EncryptionTimestamp = timestamp,
WebsiteId = "Community",
PlatformType = EAuthTokenPlatformType.KEauthTokenPlatformTypeWebBrowser,
PlatformType = EAuthTokenPlatformType.KEauthTokenPlatformTypeWebBrowser | EAuthTokenPlatformType.KEauthTokenPlatformTypeSteamClient,
RememberLogin = false,
Persistence = ESessionPersistence.KEsessionPersistencePersistent,
}.ToByteString().ToBase64();
Expand Down Expand Up @@ -1054,7 +1054,7 @@ public async Task<ApiRspImpl<bool>> CheckAccessTokenValidation(string access_tok
return false;
}

#endregion
#endregion Public Methods

#region Static Methods

Expand Down Expand Up @@ -1294,7 +1294,7 @@ int ParseMoneyString(string strMoney)
return result;
}

#endregion
#endregion Static Methods

#region Private Methods

Expand Down Expand Up @@ -1435,7 +1435,7 @@ async Task<T> ParseHtmlResponseStream<T>(Stream stream, Func<IDocument, Task<T>>
}
}

#endregion
#endregion Private Methods

#region GeneratedRegex

Expand All @@ -1460,5 +1460,5 @@ async Task<T> ParseHtmlResponseStream<T>(Stream stream, Func<IDocument, Task<T>>
[GeneratedRegex("<div class=\"currency_change_option btnv6_grey_black\" data-country=\"(?<grp0>[^\"]+)\" >[\\s]+<span>[\\s]+<div class=\"country\">(?<grp1>[\\w]+?)</div>")]
private static partial Regex CountryItemRegex();

#endregion
}
#endregion GeneratedRegex
}
242 changes: 240 additions & 2 deletions src/BD.SteamClient8.Models/WebApi/SteamApps/SteamApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public string? SortAs
// }
//}

#endregion
#endregion 暂时不用

/// <summary>
/// 是否被编辑
Expand Down Expand Up @@ -371,6 +371,10 @@ public string? SortAs
[SystemTextJsonIgnore]
public string LibraryGridUrl => string.Format(SteamApiUrls.STEAMAPP_LIBRARY_URL, AppId);

private Stream? _EditLibraryGridStream;

public Stream? EditLibraryGridStream { get; set; }

/// <summary>
/// LibraryHero 图片路径
/// </summary>
Expand Down Expand Up @@ -450,6 +454,11 @@ public string? SortAs
/// </summary>
public byte[]? OriginalData { get => _originalData; set => _originalData = value; }

public string GetIdAndName()
{
return $"{AppId} | {DisplayName}";
}

#if !(IOS || ANDROID)

/// <summary>
Expand All @@ -464,6 +473,63 @@ public string? SortAs
[SystemTextJsonIgnore]
public SteamAppPropertyTable? ChangesData => _properties;

public Process? StartSteamAppProcess(SteamAppRunType runType = SteamAppRunType.Idle)
{
var arg = runType switch
{
SteamAppRunType.UnlockAchievement => "-achievement",
SteamAppRunType.CloudManager => "-cloudmanager",
_ => "-silence",
};
string arguments = $"-clt app {arg} -id {AppId}";
var processPath = Environment.ProcessPath;
processPath.ThrowIsNull();
if (OperatingSystem.IsWindows())
{
return Process = Process2.Start(processPath, arguments);
}
else
{
if (OperatingSystem.IsLinux())
{
var psi = new ProcessStartInfo
{
Arguments = arguments,
FileName = Path.Combine(AppContext.BaseDirectory, "Steam++.sh"),
UseShellExecute = true,
};
Console.WriteLine(psi.FileName);
psi.Environment.Add("SteamAppId", AppId.ToString());
return Process = Process.Start(psi);
}
else
{
return Process = Process2.Start(
processPath,
arguments,
environment: new Dictionary<string, string>() {
{
"SteamAppId",
AppId.ToString()
}
});
}
}
}

public void RunOrStopSteamAppProcess()
{
if (Process != null && !Process.HasExited)
{
Process.KillEntireProcessTree();
Process = null;
}
else
{
StartSteamAppProcess();
}
}

#region Replace DLSS dll files methods

// public void DetectDLSS()
Expand Down Expand Up @@ -599,7 +665,178 @@ public string? SortAs
// return true;
// }

#endregion
#endregion Replace DLSS dll files methods

public SteamApp ExtractReaderProperty(SteamAppPropertyTable properties, uint[]? installedAppIds = null)
{
if (properties != null)
{
//var installpath = properties.GetPropertyValue<string>(null, NodeAppInfo, NodeConfig, "installdir");

//if (!string.IsNullOrEmpty(installpath))
//{
// app.InstalledDir = Path.Combine(ISteamService.Instance.SteamDirPath, ISteamService.dirname_steamapps, NodeCommon, installpath);
//}

Name = properties.GetPropertyValue(string.Empty, NodeAppInfo, NodeCommon, NodeName);
SortAs = properties.GetPropertyValue(string.Empty, NodeAppInfo, NodeCommon, NodeSortAs);
if (!SortAs.Any_Nullable())
{
SortAs = Name;
}
ParentId = properties.GetPropertyValue<uint>(0, NodeAppInfo, NodeCommon, NodeParentId);
Developer = properties.GetPropertyValue(string.Empty, NodeAppInfo, NodeExtended, NodeDeveloper);
Publisher = properties.GetPropertyValue(string.Empty, NodeAppInfo, NodeExtended, NodePublisher);
//SteamReleaseDate = properties.GetPropertyValue<uint>(0, NodeAppInfo, NodeCommon, "steam_release_date");
//OriginReleaseDate = properties.GetPropertyValue<uint>(0, NodeAppInfo, NodeCommon, "original_release_date");

var type = properties.GetPropertyValue(string.Empty, NodeAppInfo, NodeCommon, NodeAppType);
if (Enum.TryParse(type, true, out SteamAppType apptype))
{
Type = apptype;
}
else
{
Type = SteamAppType.Unknown;
Debug.WriteLineIf(!string.IsNullOrEmpty(type), string.Format("AppInfo: New AppType '{0}'", type));
}

OSList = properties.GetPropertyValue(string.Empty, NodeAppInfo, NodeCommon, NodePlatforms);

if (installedAppIds != null)
{
if (installedAppIds.Contains(AppId) &&
(Type == SteamAppType.Application ||
Type == SteamAppType.Game ||
Type == SteamAppType.Tool ||
Type == SteamAppType.Demo))
{
// This is an installed app.
State = 4;
}
}

if (IsInstalled)
{
var launchTable = properties.GetPropertyValue<SteamAppPropertyTable?>(null, NodeAppInfo, NodeConfig, NodeLaunch);

if (launchTable != null)
{
var launchItems = from table in from prop in (from prop in launchTable.Properties
where prop.PropertyType == SteamAppPropertyType.Table
select prop).OrderBy((SteamAppProperty prop) => prop.Name, StringComparer.OrdinalIgnoreCase)
select prop.GetValue<SteamAppPropertyTable>()
select new SteamAppLaunchItem
{
Label = table.GetPropertyValue<string?>("description"),
Executable = table.GetPropertyValue<string?>("executable"),
Arguments = table.GetPropertyValue<string?>("arguments"),
WorkingDir = table.GetPropertyValue<string?>("workingdir"),
Platform = table.TryGetPropertyValue<SteamAppPropertyTable>(NodeConfig, out var propertyTable) ?
propertyTable.TryGetPropertyValue<string>(NodePlatforms, out var os) ? os : null : null,
};

LaunchItems = new ObservableCollection<SteamAppLaunchItem>(launchItems.ToList());
}
}

CloudQuota = properties.GetPropertyValue(0, NodeAppInfo, "ufs", "quota");
CloudMaxnumFiles = properties.GetPropertyValue(0, NodeAppInfo, "ufs", "maxnumfiles");

var savefilesTable = properties.GetPropertyValue<SteamAppPropertyTable?>(null, NodeAppInfo, "ufs", "savefiles");

if (savefilesTable != null)
{
var savefiles = from table in from prop in (from prop in savefilesTable.Properties
where prop.PropertyType == SteamAppPropertyType.Table
select prop).OrderBy((SteamAppProperty prop) => prop.Name, StringComparer.OrdinalIgnoreCase)
select prop.GetValue<SteamAppPropertyTable>()
select new SteamAppSaveFile
(
AppId,
table.GetPropertyValue<string?>("root"),
table.GetPropertyValue<string?>("path"),
table.GetPropertyValue<string?>("pattern")
)
{
Recursive = table.GetPropertyValue(false, "recursive"),
};

SaveFiles = new ObservableCollection<SteamAppSaveFile>(savefiles.ToList());
}

BaseName = properties.GetPropertyValue(string.Empty, NodeAppInfo, "steam_edit", "base_name");

if (string.IsNullOrEmpty(BaseName))
{
BaseName = Name;
}
}
return this;
}

public static SteamApp? FromReader(BinaryReader reader, string[]? stringPool = null, uint[]? installedAppIds = null, bool isSaveProperties = false, bool isMagicNumberV2 = false, bool isMagicNumberV3 = false)
{
uint id = reader.ReadUInt32();
if (id == 0)
{
return null;
}
SteamApp app = new()
{
AppId = id,
};
try
{
int count = reader.ReadInt32();
byte[] array = reader.ReadBytes(count);
using BinaryReader binaryReader = new(new MemoryStream(array), Encoding.UTF8, true);
app._stuffBeforeHash = binaryReader.ReadBytes(16);
binaryReader.ReadBytes(20);
app._changeNumber = binaryReader.ReadUInt32();

if (isMagicNumberV2 || isMagicNumberV3)
{
binaryReader.ReadBytes(20);
}

var properties = binaryReader.ReadPropertyTable();

if (properties == null)
return app;

if (isSaveProperties)
{
app._properties = properties;
app._originalData = array;
}
app.ExtractReaderProperty(properties, installedAppIds);
}
catch (Exception ex)
{
Log.Error(nameof(SteamApp), ex, string.Format("Failed to load entry with appId {0}", app.AppId));
}
return app;
}

public void Write(BinaryWriter writer)
{
if (_properties == null)
throw new ArgumentNullException($"SteamApp Write Failed. {nameof(_properties)} is null.");
SteamAppPropertyTable propertyTable = new SteamAppPropertyTable(_properties);
string s = propertyTable.ToString();
byte[] bytes = Encoding.UTF8.GetBytes(s);
byte[] buffer = SHA1.HashData(bytes);
writer.Write((int)AppId);
using BinaryWriter binaryWriter = new BinaryWriter(new MemoryStream(), Encoding.UTF8, true);
binaryWriter.Write(_stuffBeforeHash.ThrowIsNull());
binaryWriter.Write(buffer);
binaryWriter.Write(_changeNumber);
binaryWriter.Write(propertyTable);
MemoryStream memoryStream = (MemoryStream)binaryWriter.BaseStream;
writer.Write((int)memoryStream.Length);
writer.Write(memoryStream.GetBuffer(), 0, (int)memoryStream.Length);
}

#endif

Expand Down Expand Up @@ -654,5 +891,6 @@ public bool CheckDownloading(int appState)
* I think Bit 5 indicates if "something" is happening with a DLC and Bit 10 indicates if it is downloading.
*/
}

#endif
}
32 changes: 31 additions & 1 deletion src/BD.SteamClient8.Primitives/Constants/SteamApiUrls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public static partial class SteamApiUrls
public const string STEAM_PROFILES_URL = "https://steamcommunity.com/profiles/{0}";

public const string STEAM_LOGIN_URL = "https://steamcommunity.com/login/home/?goto=my/profile";
public const string STEAM_BADGES_URL = "https://steamcommunity.com/profiles/{0}/badges/l=schinese&p={1}";
public const string STEAM_BADGES_URL = "https://steamcommunity.com/profiles/{0}/badges/?l=schinese&p={1}";
public const string STEAM_GAMECARDS_URL = "https://steamcommunity.com/profiles/{0}/gamecards/{1}?l=english";
public const string STEAMAPP_LIST_URL = "https://api.steampowered.com/ISteamApps/GetAppList/v2";
public const string STEAMAPP_LOGO_URL = "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/apps/{0}/{1}.jpg";
Expand Down Expand Up @@ -71,6 +71,10 @@ public static partial class SteamApiUrls
public const string STEAM_COMMUNITY_URL = "https://steamcommunity.com";
public const string STEAM_STORE_URL = "https://store.steampowered.com";

public const string GetRSAkeyUrl = $"{STEAM_STORE_URL}/login/getrsakey/";
public const string DologinUrl = $"{STEAM_STORE_URL}/login/dologin?l=schinese";
public const string SteamLoginUrl = $"{STEAM_STORE_URL}/login?oldauth=1";

public const string CaptchaImageUrl = $"{STEAM_STORE_URL}/login/rendercaptcha/?gid=";

/// <summary>
Expand All @@ -83,6 +87,17 @@ public static partial class SteamApiUrls

#endregion OpenIdLogin

public const string SteamStoreRedeemWalletCodelUrl = $"{STEAM_STORE_URL}/account/ajaxredeemwalletcode?l=schinese";

public const string SteamStoreAccountlUrl = $"{STEAM_STORE_URL}/account?l=schinese";
public const string SteamStoreAccountHistoryDetailUrl = $"{STEAM_STORE_URL}/account/history?l=schinese";
public const string SteamStoreAccountHistoryAjaxlUrl = $"{STEAM_STORE_URL}/AjaxLoadMoreHistory?l=schinese";

public const string SteamStoreAccountSetCountryUrl = $"{STEAM_STORE_URL}/account/setcountry";
public const string SteamStoreAddFundsUrl = $"{STEAM_STORE_URL}/steamaccount/addfunds?l=schinese";

public const string AccountGetSteamNotificationsUrl = "https://api.steampowered.com/ISteamNotificationService/GetSteamNotifications/v1?access_token={0}";

//#region LoginV1
//public const string GetRSAkeyUrl = $"{STEAM_STORE_URL}/login/getrsakey/";
//public const string DologinUrl = $"{STEAM_STORE_URL}/login/dologin?l=schinese";
Expand Down Expand Up @@ -155,6 +170,7 @@ public static partial class SteamApiUrls
public const string STEAM_AUTHENTICATOR_REMOVE_VIACHALLENGESTARTSYNC = "https://api.steampowered.com/ITwoFactorService/RemoveAuthenticatorViaChallengeStart/v1?access_token={0}";
public const string STEAM_AUTHENTICATOR_REMOVE_VIACHALLENGECONTINUESYNC = "https://api.steampowered.com/ITwoFactorService/RemoveAuthenticatorViaChallengeContinue/v1?access_token={0}";
public const string STEAM_AUTHENTICATOR_REFRESHACCESSTOKEN = "https://api.steampowered.com/IAuthenticationService/GenerateAccessTokenForApp/v1/";
public const string STEAM_AUTHENTICATOR_ACCOUNTPHONESTATUS = "https://api.steampowered.com/IPhoneService/AccountPhoneStatus/v1?access_token={0}";

/// <summary>
/// Idle 挂卡
Expand All @@ -163,6 +179,20 @@ public static partial class SteamApiUrls

public const string STEAM_IDLE_APPCARDS_MARKETPRICE = "https://api.augmentedsteam.com/market/cards/v2?appid={0}&currency={1}";

/// <summary>
/// 家庭监控
/// </summary>
public const string STEAM_PARENTAL_UNLOCK_COMMUNITY = "https://steamcommunity.com/parental/ajaxunlock/";

public const string STEAM_PARENTAL_UNLOCK_STORE = "https://store.steampowered.com/parental/ajaxunlock/";
public const string STEAM_PARENTAL_UNLOCK_CHECKOUT = "https://checkout.steampowered.com/parental/ajaxunlock/";
public const string STEAM_PARENTAL_UNLOCK_TV = "https://steam.tv/parental/ajaxunlock";

public const string STEAM_PARENTAL_LOCK_COMMUNITY = "https://steamcommunity.com/parental/ajaxlock/";
public const string STEAM_PARENTAL_LOCK_STORE = "https://store.steampowered.com/parental/ajaxlock/";
public const string STEAM_PARENTAL_LOCK_CHECKOUT = "https://checkout.steampowered.com/parental/ajaxlock/";
public const string STEAM_PARENTAL_LOCK_TV = "https://steam.tv/parental/ajaxlock";

/// <summary>
/// Market 市场交易
/// </summary>
Expand Down

0 comments on commit 4de6c43

Please sign in to comment.