/*
* ThreadPilot - Advanced Windows Process and Power Plan Manager
* Copyright (C) 2025 Prime Build
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, version 3 only.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
namespace ThreadPilot.Services
{
using System;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using ThreadPilot.Models;
public interface IPowerPlanService
{
///
/// Occurs when the active power plan changes.
///
event EventHandler? PowerPlanChanged;
///
/// Retrieves all power plans currently available on the system.
///
/// Collection of power plans with active-state metadata.
Task> GetPowerPlansAsync();
///
/// Retrieves custom power plans discovered in the managed plans directory.
///
/// Collection of importable custom power plans.
Task> GetCustomPowerPlansAsync();
///
/// Sets the active plan using a instance.
///
/// Power plan to activate.
/// when activation succeeds; otherwise .
Task SetActivePowerPlan(PowerPlanModel powerPlan);
///
/// Gets the current active power plan.
///
/// The active power plan, or when unavailable.
Task GetActivePowerPlan();
///
/// Imports a custom power plan from a .pow file.
///
/// Absolute path to the source .pow file.
/// when import succeeds; otherwise .
Task ImportCustomPowerPlan(string filePath);
///
/// Adds a custom .pow file to the managed custom plans library.
///
/// Absolute path to the source .pow file.
/// when the file is added successfully; otherwise .
Task AddCustomPowerPlanFileAsync(string filePath);
///
/// Deletes a non-active Windows power plan by GUID when Windows permits removal.
///
/// Power plan GUID to delete.
/// when deletion succeeds; otherwise .
Task DeletePowerPlanAsync(string powerPlanGuid);
///
/// Sets the active power plan by GUID with duplicate change prevention.
///
/// Target power plan GUID.
/// Whether to skip redundant changes when already active.
/// when the operation succeeds; otherwise .
Task SetActivePowerPlanByGuidAsync(string powerPlanGuid, bool preventDuplicateChanges = true);
///
/// Gets the currently active power plan GUID.
///
/// Active plan GUID, or when unavailable.
Task GetActivePowerPlanGuidAsync();
///
/// Checks if a power plan with the given GUID exists.
///
/// Power plan GUID to check.
/// when the plan exists; otherwise .
Task PowerPlanExistsAsync(string powerPlanGuid);
///
/// Gets a power plan by GUID.
///
/// Power plan GUID.
/// Matching plan when found; otherwise .
Task GetPowerPlanByGuidAsync(string powerPlanGuid);
///
/// Validates that a power plan change is necessary.
///
/// Target plan GUID.
/// when a change should be applied; otherwise .
Task IsPowerPlanChangeNeededAsync(string targetPowerPlanGuid);
}
///
/// Event arguments for power plan changes.
///
public class PowerPlanChangedEventArgs : EventArgs
{
///
/// Gets the previously active power plan.
///
public PowerPlanModel? PreviousPowerPlan { get; }
///
/// Gets the newly active power plan.
///
public PowerPlanModel? NewPowerPlan { get; }
///
/// Gets the local timestamp when the change was recorded.
///
public DateTime Timestamp { get; }
///
/// Gets the optional reason for the power plan transition.
///
public string? Reason { get; }
///
/// Initializes a new instance of the class.
///
/// Power plan active before the change.
/// Power plan active after the change.
/// Optional reason describing why the change occurred.
public PowerPlanChangedEventArgs(PowerPlanModel? previousPowerPlan, PowerPlanModel? newPowerPlan, string? reason = null)
{
this.PreviousPowerPlan = previousPowerPlan;
this.NewPowerPlan = newPowerPlan;
this.Timestamp = DateTime.Now;
this.Reason = reason;
}
}
}