/*
* 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.Generic;
using System.Threading.Tasks;
using ThreadPilot.Models;
///
/// Event arguments for profile application events.
///
public class ProfileApplicationEventArgs : EventArgs
{
public ConditionalProcessProfile Profile { get; set; } = new();
public ProcessModel Process { get; set; } = new();
public SystemState SystemState { get; set; } = new();
public bool WasApplied { get; set; }
public string Reason { get; set; } = string.Empty;
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
}
///
/// Event arguments for profile conflict events.
///
public class ProfileConflictEventArgs : EventArgs
{
public List ConflictingProfiles { get; set; } = new();
public ProcessModel Process { get; set; } = new();
public ConditionalProcessProfile SelectedProfile { get; set; } = new();
public string Resolution { get; set; } = string.Empty;
}
///
/// Service for managing conditional process profiles.
///
public interface IConditionalProfileService
{
///
/// Initialize the conditional profile service.
///
Task InitializeAsync();
///
/// Add a conditional profile.
///
Task AddProfileAsync(ConditionalProcessProfile profile);
///
/// Remove a conditional profile.
///
Task RemoveProfileAsync(string profileId);
///
/// Update an existing conditional profile.
///
Task UpdateProfileAsync(ConditionalProcessProfile profile);
///
/// Get all conditional profiles.
///
Task> GetAllProfilesAsync();
///
/// Get profiles for a specific process.
///
Task> GetProfilesForProcessAsync(string processName);
///
/// Evaluate all profiles for a process and return applicable ones.
///
Task> EvaluateProfilesAsync(ProcessModel process);
///
/// Apply the best matching profile for a process.
///
Task ApplyBestProfileAsync(ProcessModel process);
///
/// Get current system state for condition evaluation.
///
Task GetSystemStateAsync();
///
/// Start automatic profile monitoring and application.
///
Task StartMonitoringAsync();
///
/// Stop automatic profile monitoring.
///
Task StopMonitoringAsync();
///
/// Gets a value indicating whether check if monitoring is active.
///
bool IsMonitoring { get; }
///
/// Resolve conflicts when multiple profiles match.
///
ConditionalProcessProfile ResolveProfileConflict(List conflictingProfiles, ProcessModel process);
///
/// Create a default conditional profile template.
///
ConditionalProcessProfile CreateDefaultProfile(string processName);
///
/// Validate a conditional profile.
///
Task<(bool IsValid, List Errors)> ValidateProfileAsync(ConditionalProcessProfile profile);
///
/// Export profiles to JSON.
///
Task ExportProfilesToJsonAsync();
///
/// Import profiles from JSON.
///
Task ImportProfilesFromJsonAsync(string json);
///
/// Event raised when a profile is automatically applied
///
event EventHandler? ProfileApplied;
///
/// Event raised when profile conflicts are resolved
///
event EventHandler? ProfileConflictResolved;
///
/// Event raised when system state changes significantly
///
event EventHandler? SystemStateChanged;
}
}