2014-05-21 12:53:32 +08:00
|
|
|
|
using System.Collections.Generic;
|
2014-07-16 20:17:51 +08:00
|
|
|
|
using System.IO;
|
2014-07-01 22:19:46 +08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using Wox.Infrastructure.Storage.UserSettings;
|
2014-01-15 22:45:02 +08:00
|
|
|
|
|
2014-05-25 18:11:27 +08:00
|
|
|
|
namespace Wox.Plugin.SystemPlugins
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public abstract class BaseSystemPlugin : ISystemPlugin
|
|
|
|
|
{
|
|
|
|
|
public string PluginDirectory { get; set; }
|
2014-07-01 22:19:46 +08:00
|
|
|
|
|
|
|
|
|
public abstract string ID { get; }
|
2014-05-25 18:11:27 +08:00
|
|
|
|
public virtual string Name { get { return "System workflow"; } }
|
|
|
|
|
public virtual string Description { get { return "System workflow"; } }
|
|
|
|
|
public virtual string IcoPath { get { return null; } }
|
|
|
|
|
|
2014-07-16 20:17:51 +08:00
|
|
|
|
public string FullIcoPath
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2014-07-17 18:51:34 +08:00
|
|
|
|
if (string.IsNullOrEmpty(IcoPath)) return string.Empty;
|
2014-07-16 20:17:51 +08:00
|
|
|
|
if (IcoPath.StartsWith("data:"))
|
|
|
|
|
{
|
|
|
|
|
return IcoPath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Path.Combine(PluginDirectory, IcoPath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-25 18:11:27 +08:00
|
|
|
|
protected abstract List<Result> QueryInternal(Query query);
|
|
|
|
|
|
|
|
|
|
protected abstract void InitInternal(PluginInitContext context);
|
|
|
|
|
|
|
|
|
|
public List<Result> Query(Query query)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(query.RawQuery)) return new List<Result>();
|
2014-07-01 22:19:46 +08:00
|
|
|
|
var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == ID);
|
|
|
|
|
if (customizedPluginConfig != null && customizedPluginConfig.Disabled)
|
|
|
|
|
{
|
|
|
|
|
return new List<Result>();
|
|
|
|
|
}
|
2014-05-25 18:11:27 +08:00
|
|
|
|
return QueryInternal(query);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Init(PluginInitContext context)
|
|
|
|
|
{
|
|
|
|
|
InitInternal(context);
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-05-21 12:53:32 +08:00
|
|
|
|
}
|