using System.Collections.Generic;
using System.Collections.ObjectModel;
using HC_APTBS.Models;
namespace HC_APTBS.Services
{
///
/// Provides read/write access to persisted application configuration.
/// Configuration files live under %UserProfile%\.HC_APTBS\config\.
///
public interface IConfigurationService
{
// ── Settings ──────────────────────────────────────────────────────────────
/// Application-wide settings (temperature limits, PID, refresh rates, etc.).
AppSettings Settings { get; }
/// Persists to config.xml.
void SaveSettings();
// ── Bench configuration ───────────────────────────────────────────────────
///
/// Current bench CAN parameter map and relay definitions.
/// Loaded from bench.xml on first access.
///
BenchConfiguration Bench { get; }
/// Persists to bench.xml.
void SaveBench();
// ── Pump database ─────────────────────────────────────────────────────────
/// Returns all known pump IDs from the pump database.
IReadOnlyList GetPumpIds();
///
/// Loads the full for the pump with the given ID,
/// including its CAN parameter map and test list.
///
PumpDefinition? LoadPump(string pumpId);
/// Persists a pump definition back to the database.
void SavePump(PumpDefinition pump);
// ── Clients ───────────────────────────────────────────────────────────────
/// Sorted client name → contact info dictionary.
SortedDictionary Clients { get; }
/// Persists the client list to clients.xml.
void SaveClients();
// ── Pump status definitions ───────────────────────────────────────────────
///
/// Loads the for the given status ID.
/// Definitions are cached after first load. Returns null if the ID is not found.
///
PumpStatusDefinition? LoadPumpStatus(int statusId);
// ── Alarms ────────────────────────────────────────────────────────────────
/// Persists alarm definitions to alarms.xml.
void SaveAlarms();
// ── Sensors ───────────────────────────────────────────────────────────────
/// Saves updated sensor calibration data to sensors.xml.
void SaveSensors();
// ── Users ─────────────────────────────────────────────────────────────────
/// Validates a username/password pair against stored credentials.
bool ValidateUser(string username, string password);
/// Returns all stored usernames (passwords are never exposed).
IReadOnlyList GetUsers();
/// Replaces all stored user credentials and persists them.
void UpdateUsers(Dictionary users);
///
/// Adds a new user with the given plaintext password.
/// Returns false if the username already exists, if either field is empty/whitespace,
/// or if the username contains the reserved separator characters ':' or ','.
/// Hashes of existing users are preserved.
///
bool AddUser(string username, string password);
///
/// Removes the user with the given username.
/// Returns false if the user does not exist or if this would remove the last remaining user.
/// Hashes of other users are preserved.
///
bool RemoveUser(string username);
///
/// Replaces the stored password for an existing user.
/// Returns false if the user does not exist or the password is empty.
/// Hashes of other users are preserved.
///
bool ChangeUserPassword(string username, string newPassword);
}
}