Skip to content

Commit 2f679e9

Browse files
authored
Merge pull request #2563 from Flow-Launcher/dev
Release 1.17.2
2 parents b623295 + 2370ec9 commit 2f679e9

File tree

12 files changed

+132
-52
lines changed

12 files changed

+132
-52
lines changed

Flow.Launcher.Core/ExternalPlugins/CommunityPluginSource.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
using System.Net;
66
using System.Net.Http;
77
using System.Net.Http.Json;
8+
using System.Text.Json;
9+
using System.Text.Json.Serialization;
810
using System.Threading;
911
using System.Threading.Tasks;
1012

@@ -16,6 +18,11 @@ public record CommunityPluginSource(string ManifestFileUrl)
1618

1719
private List<UserPlugin> plugins = new();
1820

21+
private static JsonSerializerOptions PluginStoreItemSerializationOption = new JsonSerializerOptions()
22+
{
23+
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault
24+
};
25+
1926
/// <summary>
2027
/// Fetch and deserialize the contents of a plugins.json file found at <see cref="ManifestFileUrl"/>.
2128
/// We use conditional http requests to keep repeat requests fast.
@@ -32,12 +39,15 @@ public async Task<List<UserPlugin>> FetchAsync(CancellationToken token)
3239

3340
request.Headers.Add("If-None-Match", latestEtag);
3441

35-
using var response = await Http.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, token).ConfigureAwait(false);
42+
using var response = await Http.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, token)
43+
.ConfigureAwait(false);
3644

3745
if (response.StatusCode == HttpStatusCode.OK)
3846
{
39-
this.plugins = await response.Content.ReadFromJsonAsync<List<UserPlugin>>(cancellationToken: token).ConfigureAwait(false);
40-
this.latestEtag = response.Headers.ETag.Tag;
47+
this.plugins = await response.Content
48+
.ReadFromJsonAsync<List<UserPlugin>>(PluginStoreItemSerializationOption, cancellationToken: token)
49+
.ConfigureAwait(false);
50+
this.latestEtag = response.Headers.ETag?.Tag;
4151

4252
Log.Info(nameof(CommunityPluginSource), $"Loaded {this.plugins.Count} plugins from {ManifestFileUrl}");
4353
return this.plugins;
@@ -49,7 +59,8 @@ public async Task<List<UserPlugin>> FetchAsync(CancellationToken token)
4959
}
5060
else
5161
{
52-
Log.Warn(nameof(CommunityPluginSource), $"Failed to load resource {ManifestFileUrl} with response {response.StatusCode}");
62+
Log.Warn(nameof(CommunityPluginSource),
63+
$"Failed to load resource {ManifestFileUrl} with response {response.StatusCode}");
5364
throw new Exception($"Failed to load resource {ManifestFileUrl} with response {response.StatusCode}");
5465
}
5566
}

Flow.Launcher.Core/ExternalPlugins/UserPlugin.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ public record UserPlugin
1414
public string UrlDownload { get; set; }
1515
public string UrlSourceCode { get; set; }
1616
public string IcoPath { get; set; }
17-
public DateTime LatestReleaseDate { get; set; }
18-
public DateTime DateAdded { get; set; }
17+
public DateTime? LatestReleaseDate { get; set; }
18+
public DateTime? DateAdded { get; set; }
1919

2020
}
2121
}

Flow.Launcher.Core/Flow.Launcher.Core.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<ItemGroup>
5656
<PackageReference Include="Droplex" Version="1.7.0" />
5757
<PackageReference Include="FSharp.Core" Version="7.0.401" />
58+
<PackageReference Include="Meziantou.Framework.Win32.Jobs" Version="3.2.1" />
5859
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="2.3.2" />
5960
<PackageReference Include="squirrel.windows" Version="1.5.2" NoWarn="NU1701" />
6061
<PackageReference Include="StreamJsonRpc" Version="2.17.8" />

Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public async Task InitializeAsync()
3737
_storage = new JsonStorage<ConcurrentDictionary<string, object>>(SettingPath);
3838
Settings = await _storage.LoadAsync();
3939

40-
if (Settings != null || Configuration == null)
40+
if (Configuration == null)
4141
{
4242
return;
4343
}

Flow.Launcher.Core/Plugin/NodePlugin.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,21 @@ public NodePlugin(string filename)
2828

2929
protected override Task<Stream> RequestAsync(JsonRPCRequestModel request, CancellationToken token = default)
3030
{
31-
_startInfo.ArgumentList[1] = JsonSerializer.Serialize(request);
31+
_startInfo.ArgumentList[1] = JsonSerializer.Serialize(request, RequestSerializeOption);
3232
return ExecuteAsync(_startInfo, token);
3333
}
3434

3535
protected override string Request(JsonRPCRequestModel rpcRequest, CancellationToken token = default)
3636
{
3737
// since this is not static, request strings will build up in ArgumentList if index is not specified
38-
_startInfo.ArgumentList[1] = JsonSerializer.Serialize(rpcRequest);
38+
_startInfo.ArgumentList[1] = JsonSerializer.Serialize(rpcRequest, RequestSerializeOption);
3939
return Execute(_startInfo);
4040
}
4141

4242
public override async Task InitAsync(PluginInitContext context)
4343
{
4444
_startInfo.ArgumentList.Add(context.CurrentPluginMetadata.ExecuteFilePath);
45+
_startInfo.ArgumentList.Add(string.Empty);
4546
_startInfo.WorkingDirectory = context.CurrentPluginMetadata.PluginDirectory;
4647
await base.InitAsync(context);
4748
}

Flow.Launcher.Core/Plugin/ProcessStreamPluginV2.cs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,24 @@
55
using System.Threading.Tasks;
66
using Flow.Launcher.Infrastructure;
77
using Flow.Launcher.Plugin;
8+
using Meziantou.Framework.Win32;
89
using Nerdbank.Streams;
910

1011
namespace Flow.Launcher.Core.Plugin
1112
{
1213
internal abstract class ProcessStreamPluginV2 : JsonRPCPluginV2
1314
{
15+
private static JobObject _jobObject = new JobObject();
16+
17+
static ProcessStreamPluginV2()
18+
{
19+
_jobObject.SetLimits(new JobObjectLimits()
20+
{
21+
Flags = JobObjectLimitFlags.KillOnJobClose | JobObjectLimitFlags.DieOnUnhandledException
22+
});
23+
24+
_jobObject.AssignProcess(Process.GetCurrentProcess());
25+
}
1426

1527
public override string SupportedLanguage { get; set; }
1628
protected sealed override IDuplexPipe ClientPipe { get; set; }
@@ -30,22 +42,22 @@ public override async Task InitAsync(PluginInitContext context)
3042

3143
ClientProcess = Process.Start(StartInfo);
3244
ArgumentNullException.ThrowIfNull(ClientProcess);
33-
45+
3446
SetupPipe(ClientProcess);
3547

3648
ErrorStream = ClientProcess.StandardError;
3749

3850
await base.InitAsync(context);
3951
}
40-
52+
4153
private void SetupPipe(Process process)
4254
{
4355
var (reader, writer) = (PipeReader.Create(process.StandardOutput.BaseStream),
4456
PipeWriter.Create(process.StandardInput.BaseStream));
4557
ClientPipe = new DuplexPipe(reader, writer);
4658
}
47-
48-
59+
60+
4961
public override async Task ReloadDataAsync()
5062
{
5163
var oldProcess = ClientProcess;
@@ -57,8 +69,8 @@ public override async Task ReloadDataAsync()
5769
await oldProcess.WaitForExitAsync();
5870
oldProcess.Dispose();
5971
}
60-
61-
72+
73+
6274
public override async ValueTask DisposeAsync()
6375
{
6476
ClientProcess.Kill(true);

Plugins/Flow.Launcher.Plugin.Sys/Languages/de.xaml

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,57 +5,57 @@
55
<system:String x:Key="flowlauncher_plugin_sys_command">Befehl</system:String>
66
<system:String x:Key="flowlauncher_plugin_sys_desc">Beschreibung</system:String>
77

8-
<system:String x:Key="flowlauncher_plugin_sys_shutdown_computer_cmd">Shutdown</system:String>
9-
<system:String x:Key="flowlauncher_plugin_sys_restart_computer_cmd">Restart</system:String>
10-
<system:String x:Key="flowlauncher_plugin_sys_restart_advanced_cmd">Restart With Advanced Boot Options</system:String>
11-
<system:String x:Key="flowlauncher_plugin_sys_log_off_cmd">Log Off/Sign Out</system:String>
12-
<system:String x:Key="flowlauncher_plugin_sys_lock_cmd">Lock</system:String>
13-
<system:String x:Key="flowlauncher_plugin_sys_sleep_cmd">Sleep</system:String>
14-
<system:String x:Key="flowlauncher_plugin_sys_hibernate_cmd">Hibernate</system:String>
15-
<system:String x:Key="flowlauncher_plugin_sys_indexoption_cmd">Index Option</system:String>
16-
<system:String x:Key="flowlauncher_plugin_sys_emptyrecyclebin_cmd">Empty Recycle Bin</system:String>
17-
<system:String x:Key="flowlauncher_plugin_sys_openrecyclebin_cmd">Open Recycle Bin</system:String>
8+
<system:String x:Key="flowlauncher_plugin_sys_shutdown_computer_cmd">Herunterfahren</system:String>
9+
<system:String x:Key="flowlauncher_plugin_sys_restart_computer_cmd">Neu starten</system:String>
10+
<system:String x:Key="flowlauncher_plugin_sys_restart_advanced_cmd">Neustart mit erweiterten Startoptionen</system:String>
11+
<system:String x:Key="flowlauncher_plugin_sys_log_off_cmd">Abmelden</system:String>
12+
<system:String x:Key="flowlauncher_plugin_sys_lock_cmd">Sperren</system:String>
13+
<system:String x:Key="flowlauncher_plugin_sys_sleep_cmd">Energie sparen</system:String>
14+
<system:String x:Key="flowlauncher_plugin_sys_hibernate_cmd">Ruhezustand</system:String>
15+
<system:String x:Key="flowlauncher_plugin_sys_indexoption_cmd">Indizierungsoptionen</system:String>
16+
<system:String x:Key="flowlauncher_plugin_sys_emptyrecyclebin_cmd">Papierkorb leeren</system:String>
17+
<system:String x:Key="flowlauncher_plugin_sys_openrecyclebin_cmd">Papierkorb öffnen</system:String>
1818
<system:String x:Key="flowlauncher_plugin_sys_exit_cmd">Schließen</system:String>
19-
<system:String x:Key="flowlauncher_plugin_sys_save_all_settings_cmd">Save Settings</system:String>
20-
<system:String x:Key="flowlauncher_plugin_sys_restart_cmd">Restart Flow Launcher&quot;</system:String>
19+
<system:String x:Key="flowlauncher_plugin_sys_save_all_settings_cmd">Einstellungen speichern</system:String>
20+
<system:String x:Key="flowlauncher_plugin_sys_restart_cmd">Flow Launcher neu starten</system:String>
2121
<system:String x:Key="flowlauncher_plugin_sys_setting_cmd">Einstellungen</system:String>
2222
<system:String x:Key="flowlauncher_plugin_sys_reload_plugin_data_cmd">Plugin-Daten neu laden</system:String>
23-
<system:String x:Key="flowlauncher_plugin_sys_check_for_update_cmd">Check For Update</system:String>
24-
<system:String x:Key="flowlauncher_plugin_sys_open_log_location_cmd">Open Log Location</system:String>
25-
<system:String x:Key="flowlauncher_plugin_sys_open_docs_tips_cmd">Flow Launcher Tips</system:String>
26-
<system:String x:Key="flowlauncher_plugin_sys_open_userdata_location_cmd">Flow Launcher UserData Folder</system:String>
23+
<system:String x:Key="flowlauncher_plugin_sys_check_for_update_cmd">Auf Updates prüfen</system:String>
24+
<system:String x:Key="flowlauncher_plugin_sys_open_log_location_cmd">Log-Speicherort öffnen</system:String>
25+
<system:String x:Key="flowlauncher_plugin_sys_open_docs_tips_cmd">Flow Launcher Tipps</system:String>
26+
<system:String x:Key="flowlauncher_plugin_sys_open_userdata_location_cmd">Flow Launcher Benutzerdaten-Ordner</system:String>
2727
<system:String x:Key="flowlauncher_plugin_sys_toggle_game_mode_cmd">Gott Modus</system:String>
2828

2929
<!-- Command Descriptions -->
3030
<system:String x:Key="flowlauncher_plugin_sys_shutdown_computer">Computer herunterfahren</system:String>
3131
<system:String x:Key="flowlauncher_plugin_sys_restart_computer">Computer neu starten</system:String>
32-
<system:String x:Key="flowlauncher_plugin_sys_restart_advanced">Restart the computer with Advanced Boot Options for Safe and Debugging modes, as well as other options</system:String>
32+
<system:String x:Key="flowlauncher_plugin_sys_restart_advanced">Startet den Computer mit erweiterten Startoptionen für den abgesicherten Modus neu</system:String>
3333
<system:String x:Key="flowlauncher_plugin_sys_log_off">Abmelden</system:String>
3434
<system:String x:Key="flowlauncher_plugin_sys_lock">Computer sperren</system:String>
3535
<system:String x:Key="flowlauncher_plugin_sys_exit">Flow Launcher schließen</system:String>
3636
<system:String x:Key="flowlauncher_plugin_sys_restart">Flow Launcher neu starten</system:String>
37-
<system:String x:Key="flowlauncher_plugin_sys_setting">Tweak Flow Launcher's settings</system:String>
37+
<system:String x:Key="flowlauncher_plugin_sys_setting">Einstellungen des Flow Launchers anpassen</system:String>
3838
<system:String x:Key="flowlauncher_plugin_sys_sleep">Computer in Schlafmodus versetzen</system:String>
3939
<system:String x:Key="flowlauncher_plugin_sys_emptyrecyclebin">Papierkorb leeren</system:String>
40-
<system:String x:Key="flowlauncher_plugin_sys_openrecyclebin">Open recycle bin</system:String>
41-
<system:String x:Key="flowlauncher_plugin_sys_indexoption">Indexierungsoptionen</system:String>
42-
<system:String x:Key="flowlauncher_plugin_sys_hibernate">Hibernate computer</system:String>
43-
<system:String x:Key="flowlauncher_plugin_sys_save_all_settings">Save all Flow Launcher settings</system:String>
44-
<system:String x:Key="flowlauncher_plugin_sys_reload_plugin_data">Refreshes plugin data with new content</system:String>
45-
<system:String x:Key="flowlauncher_plugin_sys_open_log_location">Open Flow Launcher's log location</system:String>
46-
<system:String x:Key="flowlauncher_plugin_sys_check_for_update">Check for new Flow Launcher update</system:String>
47-
<system:String x:Key="flowlauncher_plugin_sys_open_docs_tips">Visit Flow Launcher's documentation for more help and how to use tips</system:String>
48-
<system:String x:Key="flowlauncher_plugin_sys_open_userdata_location">Open the location where Flow Launcher's settings are stored</system:String>
40+
<system:String x:Key="flowlauncher_plugin_sys_openrecyclebin">Papierkorb öffnen</system:String>
41+
<system:String x:Key="flowlauncher_plugin_sys_indexoption">Indizierungsoptionen</system:String>
42+
<system:String x:Key="flowlauncher_plugin_sys_hibernate">Computer in den Ruhezustand versetzen</system:String>
43+
<system:String x:Key="flowlauncher_plugin_sys_save_all_settings">Alle Flow Launcher Einstellungen speichern</system:String>
44+
<system:String x:Key="flowlauncher_plugin_sys_reload_plugin_data">Aktualisiert Plugin-Daten mit neuen Inhalten</system:String>
45+
<system:String x:Key="flowlauncher_plugin_sys_open_log_location">Öffnet den Speicherort der Flow Launcher Logs</system:String>
46+
<system:String x:Key="flowlauncher_plugin_sys_check_for_update">Prüft auf neue Flow Launcher Updates</system:String>
47+
<system:String x:Key="flowlauncher_plugin_sys_open_docs_tips">Öffnet die Dokumentation von Flow Launcher für Hilfe und Tipps</system:String>
48+
<system:String x:Key="flowlauncher_plugin_sys_open_userdata_location">Öffnet den Ort an dem Flow Laucher Einstellungen speichert</system:String>
4949
<system:String x:Key="flowlauncher_plugin_sys_toggle_game_mode">Gott Modus</system:String>
5050

5151
<!-- Dialogs -->
5252
<system:String x:Key="flowlauncher_plugin_sys_dlgtitle_success">Erfolgreich</system:String>
53-
<system:String x:Key="flowlauncher_plugin_sys_dlgtext_all_settings_saved">All Flow Launcher settings saved</system:String>
54-
<system:String x:Key="flowlauncher_plugin_sys_dlgtext_all_applicableplugins_reloaded">Reloaded all applicable plugin data</system:String>
55-
<system:String x:Key="flowlauncher_plugin_sys_dlgtext_shutdown_computer">Are you sure you want to shut the computer down?</system:String>
56-
<system:String x:Key="flowlauncher_plugin_sys_dlgtext_restart_computer">Are you sure you want to restart the computer?</system:String>
57-
<system:String x:Key="flowlauncher_plugin_sys_dlgtext_restart_computer_advanced">Are you sure you want to restart the computer with Advanced Boot Options?</system:String>
58-
<system:String x:Key="flowlauncher_plugin_sys_dlgtext_logoff_computer">Are you sure you want to log off?</system:String>
53+
<system:String x:Key="flowlauncher_plugin_sys_dlgtext_all_settings_saved">Alle Flow Launcher Einstellungen wurden gespeichert</system:String>
54+
<system:String x:Key="flowlauncher_plugin_sys_dlgtext_all_applicableplugins_reloaded">Alle betroffenen Plugin-Daten wurden neu geladen</system:String>
55+
<system:String x:Key="flowlauncher_plugin_sys_dlgtext_shutdown_computer">Soll der Computer wirklich heruntergefahren werden?</system:String>
56+
<system:String x:Key="flowlauncher_plugin_sys_dlgtext_restart_computer">Soll der Computer wirklich neu gestartet werden?</system:String>
57+
<system:String x:Key="flowlauncher_plugin_sys_dlgtext_restart_computer_advanced">Soll der Computer wirklich mit erweiterten Startoptionen neu gestartet werden?</system:String>
58+
<system:String x:Key="flowlauncher_plugin_sys_dlgtext_logoff_computer">Soll der aktuelle Benutzer wirklich abgemeldet werden?</system:String>
5959

6060
<system:String x:Key="flowlauncher_plugin_sys_plugin_name">Systembefehle</system:String>
6161
<system:String x:Key="flowlauncher_plugin_sys_plugin_description">Stellt Systemrelevante Befehle bereit. z.B. herunterfahren, sperren, Einstellungen, usw.</system:String>

Plugins/Flow.Launcher.Plugin.Sys/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"Name": "System Commands",
55
"Description": "Provide System related commands. e.g. shutdown,lock, setting etc.",
66
"Author": "qianlifeng",
7-
"Version": "3.1.0",
7+
"Version": "3.1.1",
88
"Language": "csharp",
99
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
1010
"ExecuteFileName": "Flow.Launcher.Plugin.Sys.dll",

Plugins/Flow.Launcher.Plugin.WebSearch/Settings.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ public Settings()
197197
public SuggestionSource[] Suggestions { get; set; } = {
198198
new Google(),
199199
new Baidu(),
200-
new Bing()
200+
new Bing(),
201+
new DuckDuckGo()
201202
};
202203

203204
[JsonIgnore]
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Flow.Launcher.Infrastructure.Http;
6+
using Flow.Launcher.Infrastructure.Logger;
7+
using System.Net.Http;
8+
using System.Threading;
9+
using System.Text.Json;
10+
11+
namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
12+
{
13+
public class DuckDuckGo : SuggestionSource
14+
{
15+
public override async Task<List<string>> SuggestionsAsync(string query, CancellationToken token)
16+
{
17+
// When the search query is empty, DuckDuckGo returns `[]`. When it's not empty, it returns data
18+
// in the following format: `["query", ["suggestion1", "suggestion2", ...]]`.
19+
if (string.IsNullOrEmpty(query))
20+
{
21+
return new List<string>();
22+
}
23+
24+
try
25+
{
26+
const string api = "https://duckduckgo.com/ac/?type=list&q=";
27+
28+
await using var resultStream = await Http.GetStreamAsync(api + Uri.EscapeDataString(query), token: token).ConfigureAwait(false);
29+
30+
using var json = await JsonDocument.ParseAsync(resultStream, cancellationToken: token);
31+
32+
var results = json.RootElement.EnumerateArray().ElementAt(1);
33+
34+
return results.EnumerateArray().Select(o => o.GetString()).ToList();
35+
36+
}
37+
catch (Exception e) when (e is HttpRequestException or {InnerException: TimeoutException})
38+
{
39+
Log.Exception("|DuckDuckGo.Suggestions|Can't get suggestion from DuckDuckGo", e);
40+
return null;
41+
}
42+
catch (JsonException e)
43+
{
44+
Log.Exception("|DuckDuckGo.Suggestions|can't parse suggestions", e);
45+
return new List<string>();
46+
}
47+
}
48+
49+
public override string ToString()
50+
{
51+
return "DuckDuckGo";
52+
}
53+
}
54+
}

Plugins/Flow.Launcher.Plugin.WebSearch/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"Name": "Web Searches",
2727
"Description": "Provide the web search ability",
2828
"Author": "qianlifeng",
29-
"Version": "3.0.6",
29+
"Version": "3.0.7",
3030
"Language": "csharp",
3131
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
3232
"ExecuteFileName": "Flow.Launcher.Plugin.WebSearch.dll",

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '1.17.1.{build}'
1+
version: '1.17.2.{build}'
22

33
init:
44
- ps: |

0 commit comments

Comments
 (0)