Files
Libation/Source/LoadByOS/WindowsConfigApp/WinInterop.cs
Michael Bucari-Tovo fa238a0915 Use xplat webview control for Audible login
- Use Avalonia-based webview control for Audible login with Chardonnay
- Remove webview interfaces from IInteropFunctions
- Remove Microsoft.Web.WebView2 package from WindowsConfigApp
- Add Microsoft.Web.WebView2 to LibationWinForms
- Remove all other login forms except the external login dialog (fallback in case webview doesn't work). The AudibleApi login with username/password doesn't work anymore. Need to use external browser login method.
2025-11-03 11:29:57 -07:00

58 lines
1.6 KiB
C#

using SixLabors.ImageSharp;
using System.Diagnostics;
using LibationFileManager;
using System.IO;
using System;
using Dinah.Core;
namespace WindowsConfigApp
{
internal class WinInterop : IInteropFunctions
{
public WinInterop() { }
public WinInterop(params object[] values) { }
public void SetFolderIcon(string image, string directory)
{
var icon = Image.Load(image).ToIcon();
new DirectoryInfo(directory)?.SetIcon(icon, "Music");
}
public void DeleteFolderIcon(string directory)
=> new DirectoryInfo(directory)?.DeleteIcon();
public bool CanUpgrade => true;
public string ReleaseIdString => AppScaffolding.LibationScaffolding.ReleaseIdentifier.ToString();
public void InstallUpgrade(string upgradeBundle)
{
const string ExtractorExeName = "ZipExtractor.exe";
var thisExe = Environment.ProcessPath;
var thisDir = Path.GetDirectoryName(thisExe);
var zipExtractor = Path.Combine(Path.GetTempPath(), ExtractorExeName);
File.Copy(Path.Combine(thisDir, ExtractorExeName), zipExtractor, overwrite: true);
RunAsRoot(zipExtractor,
$"--input {upgradeBundle.SurroundWithQuotes()} " +
$"--output {thisDir.SurroundWithQuotes()} " +
$"--executable {thisExe.SurroundWithQuotes()}");
}
public Process RunAsRoot(string exe, string args)
{
var psi = new ProcessStartInfo()
{
FileName = exe,
UseShellExecute = true,
Verb = "runas",
WindowStyle = ProcessWindowStyle.Normal,
CreateNoWindow = true,
Arguments = args
};
return Process.Start(psi);
}
}
}