ashboard dans le webapp qui liste dynamiquement toutes les APIs OpenAPI disponibles dans PMOMusic

This commit is contained in:
2025-10-17 13:12:28 +02:00
parent 8b3cb719a9
commit f94a600ff8
18 changed files with 580 additions and 823 deletions

View File

@@ -132,6 +132,10 @@ impl Device {
format!("urn:schemas-upnp-org:device:{}:{}", self.device_type, self.version)
}
pub fn device_category(&self) -> &String {
&self.device_type
}
/// Définit la version du device.
pub fn set_version(&mut self, version: u8) -> Result<(), DeviceError> {
if version == 0 {

View File

@@ -78,8 +78,8 @@ impl UpnpInstance for DeviceInstance {
fn new(model: &Device) -> Self {
// Obtenir ou créer un UDN persistant via la configuration
let device_name = model.get_name();
let udn = if let Ok(config_udn) = pmoconfig::get_config().get_device_udn("mediarenderer", device_name) {
let device_type = model.device_category();
let udn = if let Ok(config_udn) = pmoconfig::get_config().get_device_udn(&device_type, device_name) {
config_udn
} else {
// Fallback : générer un UDN

View File

@@ -20,7 +20,7 @@ use std::{collections::HashMap, sync::Arc};
use std::sync::RwLock;
pub use crate::object_trait::*;
pub use crate::upnp_server::UpnpServer;
pub use crate::upnp_server::UpnpServerExt;
#[derive(Debug, Clone)]
pub struct UpnpObjectType {

View File

@@ -69,7 +69,7 @@ static DEVICE_REGISTRY: Lazy<RwLock<DeviceRegistry>> = Lazy::new(|| {
/// // Introspection via le trait UpnpServer
/// let devices = server.device_registry().list_devices();
/// ```
pub trait UpnpServer {
pub trait UpnpServerExt {
/// Enregistre un device UPnP et toutes ses URLs.
///
/// # Arguments
@@ -92,7 +92,7 @@ pub trait UpnpServer {
}
// Implémentation du trait UpnpServer pour pmoserver::Server
impl UpnpServer for Server {
impl UpnpServerExt for Server {
async fn register_device(&mut self, device: Arc<Device>) -> Result<Arc<DeviceInstance>, DeviceError> {
// Créer l'instance (retourne déjà un Arc<DeviceInstance>)
let di = device.create_instance();