//! apt-ostree daemon module
//! 
//! This module contains the daemon implementation for apt-ostree,
//! providing system management services via DBus.

pub mod dbus;
pub mod transaction;
pub mod ostree;
pub mod apt;
pub mod security;
pub mod sysroot;
pub mod os;

pub use dbus::DaemonDBus;
pub use transaction::{TransactionManager, TransactionType, TransactionState};
pub use ostree::OstreeManager;
pub use apt::AptManager;
pub use security::SecurityManager;
pub use sysroot::SysrootManager;
pub use os::OsManager;

/// Daemon configuration
#[derive(Debug, Clone)]
pub struct DaemonConfig {
    pub dbus_name: String,
    pub dbus_path: String,
    pub dbus_interface: String,
    pub ostree_sysroot: String,
    pub apt_cache_dir: String,
    pub log_level: String,
    pub enable_debug: bool,
}

impl Default for DaemonConfig {
    fn default() -> Self {
        Self {
            dbus_name: "org.projectatomic.aptostree1".to_string(),
            dbus_path: "/org/projectatomic/aptostree1".to_string(),
            dbus_interface: "org.projectatomic.aptostree1".to_string(),
            ostree_sysroot: "/".to_string(),
            apt_cache_dir: "/var/cache/apt".to_string(),
            log_level: "info".to_string(),
            enable_debug: false,
        }
    }
}

/// Daemon error types
#[derive(Debug, thiserror::Error)]
pub enum DaemonError {
    #[error("DBus error: {0}")]
    DBus(#[from] zbus::Error),
    
    #[error("OSTree error: {0}")]
    Ostree(String),
    
    #[error("APT error: {0}")]
    Apt(String),
    
    #[error("Transaction error: {0}")]
    Transaction(String),
    
    #[error("Security error: {0}")]
    Security(String),
    
    #[error("System error: {0}")]
    System(String),
    
    #[error("Configuration error: {0}")]
    Configuration(String),
}

pub type DaemonResult<T> = Result<T, DaemonError>;
