#include "server.hpp"

#include <fmt/format.h>
#include <linux/ipmi_bmc.h>

#include <sdbusplus/exception.hpp>
#include <sdbusplus/server/interface.hpp>
#include <sdbusplus/vtable.hpp>
#include <stdplus/fd/ops.hpp>

#include <stdexcept>

namespace kcsbridge
{

void setAttention(sdbusplus::message::message& m, stdplus::Fd& kcs)
{
    stdplus::fd::ioctl(kcs, IPMI_BMC_IOCTL_SET_SMS_ATN, nullptr);
    m.new_method_return().method_return();
}

void clearAttention(sdbusplus::message::message& m, stdplus::Fd& kcs)
{
    stdplus::fd::ioctl(kcs, IPMI_BMC_IOCTL_CLEAR_SMS_ATN, nullptr);
    m.new_method_return().method_return();
}

void forceAbort(sdbusplus::message::message& m, stdplus::Fd& kcs)
{
    stdplus::fd::ioctl(kcs, IPMI_BMC_IOCTL_FORCE_ABORT, nullptr);
    m.new_method_return().method_return();
}

template <auto func, typename Data>
int methodRsp(sd_bus_message* mptr, void* dataptr, sd_bus_error* error) noexcept
{
    sdbusplus::message::message m(mptr);
    try
    {
        func(m, *reinterpret_cast<Data*>(dataptr));
    }
    catch (const std::exception& e)
    {
        fmt::print(stderr, "Method response failed: {}\n", e.what());
        sd_bus_error_set(error,
                         "xyz.openbmc_project.Common.Error.InternalFailure",
                         "The operation failed internally.");
    }
    return 1;
}

template <typename Data>
constexpr sdbusplus::vtable::vtable_t dbusMethods[] = {
    sdbusplus::vtable::start(),
    sdbusplus::vtable::method("setAttention", "", "",
                              methodRsp<setAttention, Data>),
    sdbusplus::vtable::method("clearAttention", "", "",
                              methodRsp<clearAttention, Data>),
    sdbusplus::vtable::method("forceAbort", "", "",
                              methodRsp<forceAbort, Data>),
    sdbusplus::vtable::end(),
};

sdbusplus::server::interface::interface createSMSHandler(
    sdbusplus::bus::bus& bus, const char* obj, stdplus::Fd& kcs)
{
    return sdbusplus::server::interface::interface(
        bus, obj, "xyz.openbmc_project.Ipmi.Channel.SMS",
        dbusMethods<stdplus::Fd>, reinterpret_cast<stdplus::Fd*>(&kcs));
}

} // namespace kcsbridge
