using InnovEnergy.Lib.Protocols.DBus.Protocol;
using InnovEnergy.Lib.Protocols.DBus.Protocol.DataTypes;
using InnovEnergy.Lib.Protocols.DBus.Protocol.Header;

namespace InnovEnergy.Lib.Protocols.DBus.Daemon;

public static class DBusDaemonApi
{
    public const  String     ServiceName = "org.freedesktop.DBus";
    public const  String     Interface   = ServiceName;
    public static ObjectPath ObjectPath => "/org/freedesktop/DBus";

    public static Boolean IsDaemonSignal(Message m)
    {
        return m is
        {
            Type: MessageType.Signal,
            Sender: ServiceName,
            Interface: Interface
        };
    }

    public static Boolean IsBusName(this String? n) => !IsBusId(n);
    public static Boolean IsBusId  (this String? n) => n != null && (n.StartsWith(":") || n == ServiceName);

}