using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using Artemis.Core.DeviceProviders;
using RGB.NET.Core;
namespace Artemis.Core.Services;
///
/// A service providing plugin management
///
public interface IPluginManagementService : IArtemisService, IDisposable
{
///
/// Gets a list containing additional directories in which plugins are located, used while loading plugins.
///
List AdditionalPluginDirectories { get; }
///
/// Indicates whether or not plugins are currently being loaded
///
bool LoadingPlugins { get; }
///
/// Copy built-in plugins from the executable directory to the plugins directory if the version is higher
/// (higher or equal if compiled as debug)
///
void CopyBuiltInPlugins();
///
/// Loads all installed plugins. If plugins already loaded this will reload them all
///
void LoadPlugins(bool isElevated);
///
/// Starts monitoring plugin directories for changes and reloads plugins when changes are detected
///
void StartHotReload();
///
/// Unloads all installed plugins.
///
void UnloadPlugins();
///
/// Loads the plugin located in the provided
///
/// The directory where the plugin is located
Plugin? LoadPlugin(DirectoryInfo directory);
///
/// Enables the provided
///
/// The plugin to enable
/// Whether or not to save the new enabled state
///
/// Whether or not plugin lock files should be ignored. If set to ,
/// plugins with lock files will load successfully
///
void EnablePlugin(Plugin plugin, bool saveState, bool ignorePluginLock = false);
///
/// Unloads the provided
///
/// The plugin to unload
void UnloadPlugin(Plugin plugin);
///
/// Disables the provided
///
/// The plugin to disable
/// Whether or not to save the new enabled state
void DisablePlugin(Plugin plugin, bool saveState);
///
/// Imports the plugin contained in the provided ZIP file
///
/// The full path to the ZIP file that contains the plugin
/// The resulting plugin
Plugin? ImportPlugin(string fileName);
///
/// Unloads and permanently removes the provided plugin
///
/// The plugin to remove
///
void RemovePlugin(Plugin plugin, bool removeSettings);
///
/// Removes the settings of a disabled plugin
///
/// The plugin whose settings to remove
void RemovePluginSettings(Plugin plugin);
///
/// Enables the provided plugin feature
///
/// The feature to enable
/// Whether or not to save the new enabled state
/// If true, fails if there is a lock file present
void EnablePluginFeature(PluginFeature pluginFeature, bool saveState, bool isAutoEnable = false);
///
/// Disables the provided plugin feature
///
/// The feature to enable
/// Whether or not to save the new enabled state
void DisablePluginFeature(PluginFeature pluginFeature, bool saveState);
///
/// Gets the plugin info of all loaded plugins
///
/// A list containing all the plugin info
List GetAllPlugins();
///
/// Finds all enabled instances of
///
///
/// Either or a plugin type implementing
///
///
/// Returns a list of feature instances of
List GetFeaturesOfType() where T : PluginFeature;
///
/// Gets the plugin that provided the specified assembly
///
///
///
Plugin? GetPluginByAssembly(Assembly? assembly);
///
/// Returns the plugin info of the current call stack
///
/// If the current call stack contains a plugin, the plugin. Otherwise null
Plugin? GetCallingPlugin();
///
/// Returns the plugin that threw the provided exception.
///
///
/// If the exception was thrown by a plugin, the plugin. Otherwise null
Plugin? GetPluginFromException(Exception exception);
///
/// Gets the plugin that defined the specified device
///
///
///
DeviceProvider GetDeviceProviderByDevice(IRGBDevice device);
///
/// Occurs when built-in plugins are being loaded
///
event EventHandler CopyingBuildInPlugins;
///
/// Occurs when a plugin has started loading
///
event EventHandler PluginLoading;
///
/// Occurs when a plugin has loaded
///
event EventHandler PluginLoaded;
///
/// Occurs when a plugin has been unloaded
///
event EventHandler PluginUnloaded;
///
/// Occurs when a plugin is being enabled
///
event EventHandler PluginEnabling;
///
/// Occurs when a plugin has been enabled
///
event EventHandler PluginEnabled;
///
/// Occurs when a plugin has been disabled
///
event EventHandler PluginDisabled;
///
/// Occurs when a plugin is removed
///
event EventHandler PluginRemoved;
///
/// Occurs when a plugin feature is being enabled
///
public event EventHandler PluginFeatureEnabling;
///
/// Occurs when a plugin feature has been enabled
///
public event EventHandler PluginFeatureEnabled;
///
/// Occurs when a plugin feature could not be enabled
///
public event EventHandler PluginFeatureEnableFailed;
///
/// Occurs when a plugin feature has been disabled
///
public event EventHandler PluginFeatureDisabled;
}