diff --git a/Plugins/Flow.Launcher.Plugin.PluginManager/Flow.Launcher.Plugin.PluginsManager.csproj b/Plugins/Flow.Launcher.Plugin.PluginManager/Flow.Launcher.Plugin.PluginsManager.csproj
index 43a1e089b..84cc5ffb1 100644
--- a/Plugins/Flow.Launcher.Plugin.PluginManager/Flow.Launcher.Plugin.PluginsManager.csproj
+++ b/Plugins/Flow.Launcher.Plugin.PluginManager/Flow.Launcher.Plugin.PluginsManager.csproj
@@ -29,10 +29,14 @@
-
+
+ PreserveNewest
+
-
+
+ PreserveNewest
+
\ No newline at end of file
diff --git a/Plugins/Flow.Launcher.Plugin.PluginManager/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.PluginManager/Languages/en.xaml
index 75caf81ec..7930eb743 100644
--- a/Plugins/Flow.Launcher.Plugin.PluginManager/Languages/en.xaml
+++ b/Plugins/Flow.Launcher.Plugin.PluginManager/Languages/en.xaml
@@ -3,7 +3,9 @@
xmlns:system="clr-namespace:System;assembly=mscorlib">
-
+ Downloading plugin
+ Please wait...
+ Successfully downloaded
diff --git a/Plugins/Flow.Launcher.Plugin.PluginManager/Main.cs b/Plugins/Flow.Launcher.Plugin.PluginManager/Main.cs
index 829bb9715..1a21f6026 100644
--- a/Plugins/Flow.Launcher.Plugin.PluginManager/Main.cs
+++ b/Plugins/Flow.Launcher.Plugin.PluginManager/Main.cs
@@ -39,7 +39,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
{
var search = query.Search;
- var pluginManager = new PluginsManager();
+ var pluginManager = new PluginsManager(Context);
return pluginManager.PluginsSearch(search);
}
diff --git a/Plugins/Flow.Launcher.Plugin.PluginManager/PluginsManager.cs b/Plugins/Flow.Launcher.Plugin.PluginManager/PluginsManager.cs
index 5457c1562..6a9da4eea 100644
--- a/Plugins/Flow.Launcher.Plugin.PluginManager/PluginsManager.cs
+++ b/Plugins/Flow.Launcher.Plugin.PluginManager/PluginsManager.cs
@@ -1,23 +1,29 @@
-using Flow.Launcher.Infrastructure;
+using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.Http;
+using Flow.Launcher.Infrastructure.Logger;
+using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin.PluginsManager.Models;
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using System.Net;
using System.Text;
+using System.Windows;
namespace Flow.Launcher.Plugin.PluginsManager
{
internal class PluginsManager
{
private PluginsManifest pluginsManifest;
+ private PluginInitContext context { get; set; }
private string icoPath = "Images\\plugin.png";
- internal PluginsManager()
+ internal PluginsManager(PluginInitContext context)
{
pluginsManifest = new PluginsManifest();
+ this.context = context;
}
internal void PluginInstall(UserPlugin plugin)
{
@@ -28,14 +34,28 @@ namespace Flow.Launcher.Plugin.PluginsManager
return;
}
- PluginDowload(plugin.UrlDownload, "");
+ var filePath = Path.Combine(DataLocation.PluginsDirectory, $"{plugin.Name}{plugin.ID}.zip");
+ PluginDownload(plugin.UrlDownload, filePath);
}
- private void PluginDowload(string downloadUrl, string toFilePath)
+ private void PluginDownload(string downloadUrl, string toFilePath)
{
- using (var wc = new WebClient { Proxy = Http.WebProxy() })
+ try
{
- wc.DownloadFile(downloadUrl, toFilePath);
+ using (var wc = new WebClient { Proxy = Http.WebProxy() })
+ {
+ wc.DownloadFile(downloadUrl, toFilePath);
+ }
+
+ context.API.ShowMsg(context.API.GetTranslation("plugin_pluginsmanager_downloading_plugin"),
+ context.API.GetTranslation("plugin_pluginsmanager_download_success"));
+ }
+ catch(Exception e)
+ {
+ context.API.ShowMsg(context.API.GetTranslation("plugin_pluginsmanager_downloading_plugin"),
+ context.API.GetTranslation("plugin_pluginsmanager_download_success"));
+
+ Log.Exception("PluginsManager", "An error occured while downloading plugin", e, "PluginDownload");
}
}
@@ -58,9 +78,8 @@ namespace Flow.Launcher.Plugin.PluginsManager
{
var results = new List();
- if (string.IsNullOrEmpty(searchName))
- {
- pluginsManifest.UserPlugins
+ pluginsManifest
+ .UserPlugins
.ForEach(x => results.Add(
new Result
{
@@ -69,32 +88,22 @@ namespace Flow.Launcher.Plugin.PluginsManager
IcoPath = icoPath,
Action = e =>
{
+ context.API.ShowMsg(context.API.GetTranslation("plugin_pluginsmanager_downloading_plugin"),
+ context.API.GetTranslation("plugin_pluginsmanager_please_wait"));
+ Application.Current.MainWindow.Hide();
PluginInstall(x);
- return false;
+
+ return true;
}
}));
+ if (string.IsNullOrEmpty(searchName))
return results;
- }
- pluginsManifest.UserPlugins
- .Where(x => StringMatcher.FuzzySearch(searchName, x.Name).IsSearchPrecisionScoreMet())
- .Select(x => x)
- .ToList()
- .ForEach(x => results.Add(
- new Result
- {
- Title = $"{x.Name} by {x.Author}",
- SubTitle = x.Description,
- IcoPath = icoPath,
- Action = e =>
- {
- PluginInstall(x);
- return false;
- }
- }));
-
- return results;
+ return results
+ .Where(x => StringMatcher.FuzzySearch(searchName, x.Title).IsSearchPrecisionScoreMet())
+ .Select(x => x)
+ .ToList();
}
}
}