Files
coffee_crisis_arcade_edition/source/shutdown.h
2025-08-16 19:48:32 +02:00

38 lines
1.7 KiB
C++

#pragma once
// --- Namespace SystemShutdown: utilidad multiplataforma para apagar el sistema de forma segura ---
namespace SystemShutdown {
// --- Enums ---
enum class ShutdownResult {
SUCCESS = 0, // Éxito
ERROR_PERMISSION, // Error de permisos insuficientes
ERROR_SYSTEM_CALL, // Error en la llamada al sistema
ERROR_FORK_FAILED, // Error al crear proceso hijo (Unix)
ERROR_UNSUPPORTED // Sistema operativo no soportado
};
// --- Estructuras ---
struct ShutdownConfig {
int delay_seconds; // Segundos de retraso antes del apagado
bool force_close_apps; // Forzar cierre de aplicaciones
const char* shutdown_message; // Mensaje mostrado durante el apagado
// Constructor con valores por defecto
ShutdownConfig()
: delay_seconds(5)
, force_close_apps(true)
, shutdown_message("El sistema se apagará...")
{}
};
// --- Funciones ---
ShutdownResult shutdownSystem(); // Apaga el sistema con configuración por defecto
ShutdownResult shutdownSystem(const ShutdownConfig& config); // Apaga el sistema con configuración personalizada
ShutdownResult shutdownSystem(int delay_seconds, bool force_apps = true); // Apaga el sistema con parámetros simples
const char* resultToString(ShutdownResult result); // Convierte un código de resultado a string descriptivo
bool isShutdownSupported(); // Verifica si el sistema actual soporta apagado programático
const char* getRequiredPermissions(); // Obtiene información sobre los permisos necesarios
} // namespace SystemShutdown