forked from BeyondDimension/SteamTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
1,055 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<Project Sdk="MSBuild.Sdk.Extras"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>net6.0-android;MonoAndroid11.0</TargetFrameworks> | ||
<RootNamespace>System.Application</RootNamespace> | ||
<AssemblyName>System.Application.SteamTools.Client.Android</AssemblyName> | ||
<DefineConstants>__HAVE_ANDROIDX__;$(DefineConstants)</DefineConstants> | ||
</PropertyGroup> | ||
|
||
<!--当前包是否为应用商店渠道包(IS_STORE_PACKAGE)--> | ||
<!--<PropertyGroup> | ||
<DefineConstants>IS_STORE_PACKAGE;$(DefineConstants)</DefineConstants> | ||
</PropertyGroup>--> | ||
|
||
<ItemGroup> | ||
<Compile Include="..\Common.CoreLib\Properties\AssemblyInfo.cs"> | ||
<Link>Properties\AssemblyInfo.cs</Link> | ||
</Compile> | ||
<Compile Include="..\Common.CoreLib\Properties\AssemblyInfo.Version.cs"> | ||
<Link>Properties\AssemblyInfo.Version.cs</Link> | ||
</Compile> | ||
<Compile Include="..\ST\Properties\InternalsVisibleTo.cs"> | ||
<Link>Properties\InternalsVisibleTo.cs</Link> | ||
</Compile> | ||
<!--<Compile Include="..\ST.Client.Desktop\ServiceCollectionExtensions.AddGeneralLogging.cs" />--> | ||
</ItemGroup> | ||
|
||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\ST.Client\ST.Client.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
src/ST.Client.Desktop.Linux/Services/Implementation/LinuxPlatformServiceImpl.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
using System.Application.Internals; | ||
using System.Application.Models; | ||
using System.Diagnostics; | ||
using System.IO; | ||
|
75 changes: 75 additions & 0 deletions
75
src/ST.Client.Desktop.Mac/Internals/UnixHelper.RunShellAsync.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using System; | ||
using System.Application.UI.Resx; | ||
using System.Application.UI.ViewModels; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Application.Services; | ||
|
||
static partial class UnixHelper | ||
{ | ||
static readonly Lazy<string> _bin_bash = new(() => string.Format("{0}bin{0}bash", Path.DirectorySeparatorChar)); | ||
|
||
/// <summary> | ||
/// /bin/bash | ||
/// </summary> | ||
public static string BinBash => _bin_bash.Value; | ||
|
||
/// <inheritdoc cref="IPlatformService.RunShellAsync(string, bool)"/> | ||
public static ValueTask RunShellAsync(string script, bool admin) | ||
=> RunShellAsync(script, admin, 3); | ||
|
||
/// <inheritdoc cref="IPlatformService.RunShellAsync(string, bool)"/> | ||
static async ValueTask RunShellAsync(string script, bool admin, sbyte retry_count) | ||
{ | ||
if (retry_count <= 0) return; | ||
|
||
var file = new FileInfo(Path.Combine(IOPath.AppDataDirectory, $@"{(admin ? "sudo" : "")}shell.sh")); | ||
|
||
if (file.Exists) | ||
file.Delete(); | ||
var scriptContent = new StringBuilder(); | ||
if (admin) | ||
{ | ||
TextBoxWindowViewModel vm = new() | ||
{ | ||
Title = AppResources.MacSudoPasswordTips, | ||
InputType = TextBoxWindowViewModel.TextBoxInputType.Password, | ||
Description = $"sudo {script}", | ||
}; | ||
await TextBoxWindowViewModel.ShowDialogAsync(vm); | ||
if (string.IsNullOrWhiteSpace(vm.Value)) | ||
return; | ||
scriptContent.AppendLine($"echo \"{vm.Value}\" | sudo -S {script}"); | ||
} | ||
else | ||
{ | ||
scriptContent.AppendLine(script); | ||
} | ||
using (var stream = file.CreateText()) | ||
{ | ||
stream.Write(scriptContent); | ||
stream.Flush(); | ||
} | ||
using var p = new Process(); | ||
p.StartInfo.FileName = BinBash; | ||
p.StartInfo.Arguments = $"\"{file.FullName}\""; | ||
p.StartInfo.UseShellExecute = false; | ||
p.StartInfo.RedirectStandardOutput = true; | ||
p.Exited += async (_, _) => | ||
{ | ||
if (file.Exists) | ||
file.Delete(); | ||
if (p.ExitCode != 0) | ||
{ | ||
await RunShellAsync(script, admin, --retry_count); | ||
} | ||
}; | ||
p.Start(); | ||
var ret = p.StandardOutput.ReadToEnd(); | ||
p.Kill(); | ||
if (file.Exists) | ||
file.Delete(); | ||
} | ||
} |
Oops, something went wrong.