mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Plugins - Implemented enabling/disabling (doesnt work for devices)
Plugins - Disable plugins that caused a crash Tray icon - Added menu items for quick access
This commit is contained in:
1 parent
16b221d2f8
commit
57d82fafa8
29 files changed
+442
-164
No files matched your search
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
|
||||
namespace Artemis.Storage.Entities.Plugins
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the configuration of a plugin, each plugin has one configuration
|
||||
/// </summary>
|
||||
public class PluginEntity
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid PluginGuid { get; set; }
|
||||
|
||||
public bool IsEnabled { get; set; }
|
||||
public bool LastEnableSuccessful { get; set; }
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -1,7 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace Artemis.Storage.Entities
|
||||
namespace Artemis.Storage.Entities.Plugins
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the setting of a plugin, a plugin can have multiple settings
|
||||
/// </summary>
|
||||
public class PluginSettingEntity
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using Artemis.Storage.Entities.Plugins;
|
||||
|
||||
namespace Artemis.Storage.Repositories.Interfaces
|
||||
{
|
||||
public interface IPluginRepository : IRepository
|
||||
{
|
||||
void AddPlugin(PluginEntity pluginEntity);
|
||||
PluginEntity GetPluginByGuid(Guid pluginGuid);
|
||||
void SavePlugin(PluginEntity pluginEntity);
|
||||
void AddSetting(PluginSettingEntity pluginSettingEntity);
|
||||
PluginSettingEntity GetSettingByGuid(Guid pluginGuid);
|
||||
PluginSettingEntity GetSettingByNameAndGuid(string name, Guid pluginGuid);
|
||||
void SaveSetting(PluginSettingEntity pluginSettingEntity);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Storage.Entities;
|
||||
|
||||
namespace Artemis.Storage.Repositories.Interfaces
|
||||
{
|
||||
public interface IPluginSettingRepository : IRepository
|
||||
{
|
||||
void Add(PluginSettingEntity pluginSettingEntity);
|
||||
List<PluginSettingEntity> GetByPluginGuid(Guid pluginGuid);
|
||||
PluginSettingEntity GetByNameAndPluginGuid(string name, Guid pluginGuid);
|
||||
void Save(PluginSettingEntity pluginSettingEntity);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using Artemis.Storage.Entities.Plugins;
|
||||
using Artemis.Storage.Repositories.Interfaces;
|
||||
using LiteDB;
|
||||
|
||||
namespace Artemis.Storage.Repositories
|
||||
{
|
||||
public class PluginRepository : IPluginRepository
|
||||
{
|
||||
private readonly LiteRepository _repository;
|
||||
|
||||
internal PluginRepository(LiteRepository repository)
|
||||
{
|
||||
_repository = repository;
|
||||
|
||||
_repository.Database.GetCollection<PluginEntity>().EnsureIndex(s => s.PluginGuid);
|
||||
_repository.Database.GetCollection<PluginSettingEntity>().EnsureIndex(s => s.Name);
|
||||
_repository.Database.GetCollection<PluginSettingEntity>().EnsureIndex(s => s.PluginGuid);
|
||||
}
|
||||
|
||||
public void AddPlugin(PluginEntity pluginEntity)
|
||||
{
|
||||
_repository.Insert(pluginEntity);
|
||||
}
|
||||
|
||||
public PluginEntity GetPluginByGuid(Guid pluginGuid)
|
||||
{
|
||||
return _repository.FirstOrDefault<PluginEntity>(p => p.PluginGuid == pluginGuid);
|
||||
}
|
||||
|
||||
public void SavePlugin(PluginEntity pluginEntity)
|
||||
{
|
||||
_repository.Upsert(pluginEntity);
|
||||
}
|
||||
|
||||
public void AddSetting(PluginSettingEntity pluginSettingEntity)
|
||||
{
|
||||
_repository.Insert(pluginSettingEntity);
|
||||
}
|
||||
|
||||
public PluginSettingEntity GetSettingByGuid(Guid pluginGuid)
|
||||
{
|
||||
return _repository.FirstOrDefault<PluginSettingEntity>(p => p.PluginGuid == pluginGuid);
|
||||
}
|
||||
|
||||
public PluginSettingEntity GetSettingByNameAndGuid(string name, Guid pluginGuid)
|
||||
{
|
||||
return _repository.FirstOrDefault<PluginSettingEntity>(p => p.Name == name && p.PluginGuid == pluginGuid);
|
||||
}
|
||||
|
||||
public void SaveSetting(PluginSettingEntity pluginSettingEntity)
|
||||
{
|
||||
_repository.Upsert(pluginSettingEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Storage.Entities;
|
||||
using Artemis.Storage.Repositories.Interfaces;
|
||||
using LiteDB;
|
||||
|
||||
namespace Artemis.Storage.Repositories
|
||||
{
|
||||
public class PluginSettingRepository : IPluginSettingRepository
|
||||
{
|
||||
private readonly LiteRepository _repository;
|
||||
|
||||
internal PluginSettingRepository(LiteRepository repository)
|
||||
{
|
||||
_repository = repository;
|
||||
_repository.Database.GetCollection<PluginSettingEntity>().EnsureIndex(s => s.Name);
|
||||
_repository.Database.GetCollection<PluginSettingEntity>().EnsureIndex(s => s.PluginGuid);
|
||||
}
|
||||
|
||||
public void Add(PluginSettingEntity pluginSettingEntity)
|
||||
{
|
||||
_repository.Insert(pluginSettingEntity);
|
||||
}
|
||||
|
||||
public List<PluginSettingEntity> GetByPluginGuid(Guid pluginGuid)
|
||||
{
|
||||
return _repository.Query<PluginSettingEntity>().Where(p => p.PluginGuid == pluginGuid).ToList();
|
||||
}
|
||||
|
||||
public PluginSettingEntity GetByNameAndPluginGuid(string name, Guid pluginGuid)
|
||||
{
|
||||
return _repository.FirstOrDefault<PluginSettingEntity>(p => p.Name == name && p.PluginGuid == pluginGuid);
|
||||
}
|
||||
|
||||
public void Save(PluginSettingEntity pluginSettingEntity)
|
||||
{
|
||||
_repository.Upsert(pluginSettingEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user