Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 35 additions & 30 deletions Plugins/Flow.Launcher.Plugin.Program/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
{
"uninst.exe",
"unins000.exe",
"uninst000.exe",

Check warning on line 45 in Plugins/Flow.Launcher.Plugin.Program/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`uninst` is not a recognized word. (unrecognized-spelling)

Check warning on line 45 in Plugins/Flow.Launcher.Plugin.Program/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`uninst` is not a recognized word. (unrecognized-spelling)
"uninstall.exe"
};
private static readonly string[] commonUninstallerPrefixs =

Check warning on line 48 in Plugins/Flow.Launcher.Plugin.Program/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Uninstaller` is not a recognized word. (unrecognized-spelling)

Check warning on line 48 in Plugins/Flow.Launcher.Plugin.Program/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Uninstaller` is not a recognized word. (unrecognized-spelling)
{
"uninstall",//en
"卸载",//zh-cn
Expand All @@ -61,9 +61,9 @@
"삭제",//ko
"деинсталирај",//sr
"desinstalar",//pt-pt
"desinstalar",//pt-br

Check warning on line 64 in Plugins/Flow.Launcher.Plugin.Program/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`desinstalar` is not a recognized word. (unrecognized-spelling)

Check warning on line 64 in Plugins/Flow.Launcher.Plugin.Program/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`desinstalar` is not a recognized word. (unrecognized-spelling)
"desinstalar",//es

Check warning on line 65 in Plugins/Flow.Launcher.Plugin.Program/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`desinstalar` is not a recognized word. (unrecognized-spelling)

Check warning on line 65 in Plugins/Flow.Launcher.Plugin.Program/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`desinstalar` is not a recognized word. (unrecognized-spelling)
"desinstalar",//es-419

Check warning on line 66 in Plugins/Flow.Launcher.Plugin.Program/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`desinstalar` is not a recognized word. (unrecognized-spelling)

Check warning on line 66 in Plugins/Flow.Launcher.Plugin.Program/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`desinstalar` is not a recognized word. (unrecognized-spelling)
"disinstallare",//it
"avinstallere",//nb-NO
"odinštalovať",//sk
Expand All @@ -73,8 +73,8 @@
"gỡ bỏ",//vi-vn
"הסרה"//he
};
private const string ExeUninstallerSuffix = ".exe";

Check warning on line 76 in Plugins/Flow.Launcher.Plugin.Program/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Uninstaller` is not a recognized word. (unrecognized-spelling)

Check warning on line 76 in Plugins/Flow.Launcher.Plugin.Program/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Uninstaller` is not a recognized word. (unrecognized-spelling)
private const string InkUninstallerSuffix = ".lnk";

Check warning on line 77 in Plugins/Flow.Launcher.Plugin.Program/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Uninstaller` is not a recognized word. (unrecognized-spelling)

Check warning on line 77 in Plugins/Flow.Launcher.Plugin.Program/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Uninstaller` is not a recognized word. (unrecognized-spelling)

private static readonly string WindowsAppPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "WindowsApps");

Expand Down Expand Up @@ -161,14 +161,14 @@
return result;
}

private bool HideUninstallersFilter(IProgram program)

Check warning on line 164 in Plugins/Flow.Launcher.Plugin.Program/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Uninstallers` is not a recognized word. (unrecognized-spelling)

Check warning on line 164 in Plugins/Flow.Launcher.Plugin.Program/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Uninstallers` is not a recognized word. (unrecognized-spelling)
{
if (!_settings.HideUninstallers) return true;

Check warning on line 166 in Plugins/Flow.Launcher.Plugin.Program/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Uninstallers` is not a recognized word. (unrecognized-spelling)

Check warning on line 166 in Plugins/Flow.Launcher.Plugin.Program/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Uninstallers` is not a recognized word. (unrecognized-spelling)
if (program is not Win32 win32) return true;

// First check the executable path
var fileName = Path.GetFileName(win32.ExecutablePath);
// For cases when the uninstaller is named like "uninst.exe"

Check warning on line 171 in Plugins/Flow.Launcher.Plugin.Program/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`uninst` is not a recognized word. (unrecognized-spelling)

Check warning on line 171 in Plugins/Flow.Launcher.Plugin.Program/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`uninst` is not a recognized word. (unrecognized-spelling)
if (commonUninstallerNames.Contains(fileName, StringComparer.OrdinalIgnoreCase)) return false;
// For cases when the uninstaller is named like "Uninstall Program Name.exe"
foreach (var prefix in commonUninstallerPrefixs)
Expand Down Expand Up @@ -442,12 +442,23 @@
Title = Context.API.GetTranslation("flowlauncher_plugin_program_disable_program"),
Action = c =>
{
_ = DisableProgramAsync(program);
Context.API.ShowMsg(
Context.API.GetTranslation("flowlauncher_plugin_program_disable_dlgtitle_success"),
Context.API.GetTranslation(
"flowlauncher_plugin_program_disable_dlgtitle_success_message"));
Context.API.ReQuery();
_ = Task.Run(async () =>
{
try
{
await DisableProgramAsync(program);
ResetCache();
Context.API.ShowMsg(
Context.API.GetTranslation("flowlauncher_plugin_program_disable_dlgtitle_success"),
Context.API.GetTranslation(
"flowlauncher_plugin_program_disable_dlgtitle_success_message"));
Context.API.ReQuery();
}
catch (Exception e)
{
Context.API.LogException(ClassName, "Failed to disable program", e);
}
});
return false;
},
IcoPath = "Images/disable.png",
Expand All @@ -464,46 +475,40 @@
return;

await _uwpsLock.WaitAsync();
var reindexUwps = true;
try
{
reindexUwps = _uwps.Any(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier);
var program = _uwps.First(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier);
program.Enabled = false;
_settings.DisabledProgramSources.Add(new ProgramSource(program));
var program = _uwps.FirstOrDefault(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier);
if (program != null)
{
program.Enabled = false;
_settings.DisabledProgramSources.Add(new ProgramSource(program));
// Reindex UWP programs
_ = Task.Run(IndexUwpProgramsAsync);
return;
}
}
finally
{
_uwpsLock.Release();
}

// Reindex UWP programs
if (reindexUwps)
{
_ = Task.Run(IndexUwpProgramsAsync);
return;
}

await _win32sLock.WaitAsync();
var reindexWin32s = true;
try
{
reindexWin32s = _win32s.Any(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier);
var program = _win32s.First(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier);
program.Enabled = false;
_settings.DisabledProgramSources.Add(new ProgramSource(program));
var program = _win32s.FirstOrDefault(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier);
if (program != null)
{
program.Enabled = false;
_settings.DisabledProgramSources.Add(new ProgramSource(program));
// Reindex Win32 programs
_ = Task.Run(IndexWin32ProgramsAsync);
return;
}
}
finally
{
_win32sLock.Release();
}

// Reindex Win32 programs
if (reindexWin32s)
{
_ = Task.Run(IndexWin32ProgramsAsync);
return;
}
}

public static void StartProcess(Func<ProcessStartInfo, Process> runProcess, ProcessStartInfo info)
Expand Down
Loading