add PluginsManager

This commit is contained in:
Jeremy Wu 2020-12-06 19:58:27 +11:00
parent 920668db00
commit a460aefa1f
7 changed files with 164 additions and 0 deletions

View file

@ -20,6 +20,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Launcher", "Flow.Launc
{59BD9891-3837-438A-958D-ADC7F91F6F7E} = {59BD9891-3837-438A-958D-ADC7F91F6F7E}
{C21BFF9C-2C99-4B5F-B7C9-A5E6DDDB37B0} = {C21BFF9C-2C99-4B5F-B7C9-A5E6DDDB37B0}
{F35190AA-4758-4D9E-A193-E3BDF6AD3567} = {F35190AA-4758-4D9E-A193-E3BDF6AD3567}
{70CB72BC-1CD6-453D-9CA5-F7E2441426FE} = {70CB72BC-1CD6-453D-9CA5-F7E2441426FE}
{9B130CC5-14FB-41FF-B310-0A95B6894C37} = {9B130CC5-14FB-41FF-B310-0A95B6894C37}
{FDED22C8-B637-42E8-824A-63B5B6E05A3A} = {FDED22C8-B637-42E8-824A-63B5B6E05A3A}
{A3DCCBCA-ACC1-421D-B16E-210896234C26} = {A3DCCBCA-ACC1-421D-B16E-210896234C26}
@ -71,6 +72,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Launcher.Plugin.Explor
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Launcher.Plugin.ProcessKiller", "Plugins\Flow.Launcher.Plugin.ProcessKiller\Flow.Launcher.Plugin.ProcessKiller.csproj", "{588088F4-3262-4F9F-9663-A05DE12534C3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Flow.Launcher.Plugin.PluginsManager", "Plugins\Flow.Launcher.Plugin.PluginManager\Flow.Launcher.Plugin.PluginsManager.csproj", "{70CB72BC-1CD6-453D-9CA5-F7E2441426FE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -298,6 +301,18 @@ Global
{588088F4-3262-4F9F-9663-A05DE12534C3}.Release|x64.Build.0 = Release|Any CPU
{588088F4-3262-4F9F-9663-A05DE12534C3}.Release|x86.ActiveCfg = Release|Any CPU
{588088F4-3262-4F9F-9663-A05DE12534C3}.Release|x86.Build.0 = Release|Any CPU
{70CB72BC-1CD6-453D-9CA5-F7E2441426FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{70CB72BC-1CD6-453D-9CA5-F7E2441426FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{70CB72BC-1CD6-453D-9CA5-F7E2441426FE}.Debug|x64.ActiveCfg = Debug|Any CPU
{70CB72BC-1CD6-453D-9CA5-F7E2441426FE}.Debug|x64.Build.0 = Debug|Any CPU
{70CB72BC-1CD6-453D-9CA5-F7E2441426FE}.Debug|x86.ActiveCfg = Debug|Any CPU
{70CB72BC-1CD6-453D-9CA5-F7E2441426FE}.Debug|x86.Build.0 = Debug|Any CPU
{70CB72BC-1CD6-453D-9CA5-F7E2441426FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{70CB72BC-1CD6-453D-9CA5-F7E2441426FE}.Release|Any CPU.Build.0 = Release|Any CPU
{70CB72BC-1CD6-453D-9CA5-F7E2441426FE}.Release|x64.ActiveCfg = Release|Any CPU
{70CB72BC-1CD6-453D-9CA5-F7E2441426FE}.Release|x64.Build.0 = Release|Any CPU
{70CB72BC-1CD6-453D-9CA5-F7E2441426FE}.Release|x86.ActiveCfg = Release|Any CPU
{70CB72BC-1CD6-453D-9CA5-F7E2441426FE}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -316,6 +331,7 @@ Global
{59BD9891-3837-438A-958D-ADC7F91F6F7E} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
{F9C4C081-4CC3-4146-95F1-E102B4E10A5F} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
{588088F4-3262-4F9F-9663-A05DE12534C3} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
{70CB72BC-1CD6-453D-9CA5-F7E2441426FE} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F26ACB50-3F6C-4907-B0C9-1ADACC1D0DED}

View file

@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath>..\..\Output\Debug\Plugins\Flow.Launcher.Plugin.PluginsManager</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<OutputPath>..\..\Output\Release\Plugins\Flow.Launcher.Plugin.PluginsManager</OutputPath>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Flow.Launcher.Infrastructure\Flow.Launcher.Infrastructure.csproj" />
<ProjectReference Include="..\..\Flow.Launcher.Plugin\Flow.Launcher.Plugin.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="plugin.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View file

@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Flow.Launcher.Plugin.PluginsManager
{
class Main
{
}
}

View file

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Flow.Launcher.Plugin.PluginsManager
{
internal class Plugin
{
public string Name { get; set; }
public string Url { get; set; }
public string Version { get; set; }
}
}

View file

@ -0,0 +1,46 @@
using Flow.Launcher.Infrastructure.Http;
using System;
using System.Collections.Generic;
using System.Net;
using System.Text;
namespace Flow.Launcher.Plugin.PluginsManager
{
internal class PluginsManager
{
internal void PluginInstall(Plugin plugin)
{
if (PluginExists())
{
//prompt user if want to install
return;
}
PluginDowload(plugin.Url, "");
}
private void PluginDowload(string downloadUrl, string toFilePath)
{
using (var wc = new WebClient { Proxy = Http.WebProxy() })
{
wc.DownloadFile(downloadUrl, toFilePath);
}
}
internal void PluginUpdate()
{
}
internal bool PluginExists()
{
return false;
}
internal void PluginsManifestSiteOpen()
{
}
}
}

View file

@ -0,0 +1,35 @@
using Flow.Launcher.Infrastructure.Http;
using Flow.Launcher.Infrastructure.Logger;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Net;
using System.Text;
namespace Flow.Launcher.Plugin.PluginsManager
{
class PluginsManifest
{
public List<Plugin> Plugins { get; private set; }
public PluginsManifest()
{
var json = string.Empty;
using (var wc = new WebClient { Proxy = Http.WebProxy() })
{
try
{
json = wc.DownloadString("https://raw.githubusercontent.com/Flow-Launcher/Flow.Launcher.PluginsManifest/main/plugins.json");
}
catch (Exception e)
{
Log.Exception("|PluginManagement.GetManifest|Encountered error trying to download plugins manifest", e);
Plugins = new List<Plugin>();
}
}
Plugins = !string.IsNullOrEmpty(json) ? JsonConvert.DeserializeObject<List<Plugin>>(json) : new List<Plugin>();
}
}
}

View file

@ -0,0 +1,14 @@
{
"ID": "9f8f9b14-2518-4907-b211-35ab6290dee7",
"ActionKeywords": [
"pm"
],
"Name": "Plugins Manager",
"Description": "Management of installing, uninstalling or updating Flow Launcher plugins",
"Author": "Jeremy Wu",
"Version": "1.0.0",
"Language": "csharp",
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
"ExecuteFileName": "Flow.Launcher.Plugin.PluginsManager.dll",
"IcoPath": "Images\\pluginsmanager.png"
}