2014-12-26 22:51:04 +08:00
|
|
|
|
using System.Collections.Generic;
|
2014-01-03 18:16:05 +08:00
|
|
|
|
using System.Linq;
|
2014-01-03 23:52:36 +08:00
|
|
|
|
using System.Threading;
|
2014-07-01 22:19:46 +08:00
|
|
|
|
using Wox.Infrastructure.Storage.UserSettings;
|
2014-01-29 18:33:24 +08:00
|
|
|
|
using Wox.Plugin;
|
2014-07-21 23:18:39 +08:00
|
|
|
|
using Wox.Plugin.SystemPlugins;
|
2014-01-03 18:16:05 +08:00
|
|
|
|
|
2014-12-26 22:51:04 +08:00
|
|
|
|
namespace Wox.Core.Plugin.QueryDispatcher
|
2014-01-03 18:16:05 +08:00
|
|
|
|
{
|
2014-12-26 22:51:04 +08:00
|
|
|
|
public class SystemPluginQueryDispatcher : IQueryDispatcher
|
2014-01-03 18:16:05 +08:00
|
|
|
|
{
|
2014-12-26 19:36:43 +08:00
|
|
|
|
private IEnumerable<PluginPair> allSytemPlugins = PluginManager.AllPlugins.Where(o => o.Metadata.PluginType == PluginType.System);
|
2014-10-22 22:49:34 +08:00
|
|
|
|
|
2014-12-26 22:51:04 +08:00
|
|
|
|
public void Dispatch(Query query)
|
2014-01-03 18:16:05 +08:00
|
|
|
|
{
|
2014-10-23 18:39:11 +08:00
|
|
|
|
var queryPlugins = allSytemPlugins;
|
2014-07-21 23:18:39 +08:00
|
|
|
|
if (UserSettingStorage.Instance.WebSearches.Exists(o => o.ActionWord == query.ActionName && o.Enabled))
|
2014-01-03 23:52:36 +08:00
|
|
|
|
{
|
2014-07-21 23:18:39 +08:00
|
|
|
|
//websearch mode
|
2014-10-23 18:39:11 +08:00
|
|
|
|
queryPlugins = new List<PluginPair>()
|
2014-07-21 23:18:39 +08:00
|
|
|
|
{
|
2014-12-27 12:34:51 +08:00
|
|
|
|
allSytemPlugins.First(o => o.Metadata.ID == "565B73353DBF4806919830B9202EE3BF")
|
2014-07-21 23:18:39 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
2014-07-01 22:19:46 +08:00
|
|
|
|
|
2014-10-23 18:39:11 +08:00
|
|
|
|
foreach (PluginPair pair in queryPlugins)
|
2014-07-21 23:18:39 +08:00
|
|
|
|
{
|
|
|
|
|
PluginPair pair1 = pair;
|
2014-01-03 23:52:36 +08:00
|
|
|
|
ThreadPool.QueueUserWorkItem(state =>
|
|
|
|
|
{
|
2014-03-27 14:50:42 +08:00
|
|
|
|
List<Result> results = pair1.Plugin.Query(query);
|
2014-07-21 23:18:39 +08:00
|
|
|
|
results.ForEach(o => { o.AutoAjustScore = true; });
|
2014-07-05 23:10:34 +08:00
|
|
|
|
|
2014-12-26 22:51:04 +08:00
|
|
|
|
PluginManager.API.PushResults(query, pair1.Metadata, results);
|
2014-01-03 23:52:36 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
2014-01-03 18:16:05 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|