#pragma once

#include <QString>
#include <QDateTime>
#include <QMap>

namespace softbus::device_bus::monitor
{

enum class DeviceEventType {
    Serial,
    Usb,
    Storage,
    NetInterface,
    Unknown,
};

enum class DeviceEventAction {
    Add,
    Remove,
    Change,
    Unknown,
};

struct DeviceEvent
{
    DeviceEventType type{DeviceEventType::Unknown};
    DeviceEventAction action{DeviceEventAction::Unknown};
    QDateTime timestamp{QDateTime::currentDateTimeUtc()};

    // Common identifiers
    QString subsystem;   // e.g. "tty", "usb", "block", "net"
    QString devnode;     // e.g. /dev/ttyUSB0
    QString devicePath;  // platform-native path (Windows device interface path)

    // USB-ish fields
    QString vid;
    QString pid;
    QString serial;
    QString model;
    QString vendor;

    // Network fields
    QString ifname;
    int ifindex{-1};
    bool linkUp{false};

    // Extra properties (best-effort)
    QMap<QString, QString> props;
};

inline QString toString(DeviceEventType t)
{
    switch (t) {
    case DeviceEventType::Serial: return QStringLiteral("Serial");
    case DeviceEventType::Usb: return QStringLiteral("Usb");
    case DeviceEventType::Storage: return QStringLiteral("Storage");
    case DeviceEventType::NetInterface: return QStringLiteral("NetInterface");
    default: return QStringLiteral("Unknown");
    }
}

inline QString toString(DeviceEventAction a)
{
    switch (a) {
    case DeviceEventAction::Add: return QStringLiteral("add");
    case DeviceEventAction::Remove: return QStringLiteral("remove");
    case DeviceEventAction::Change: return QStringLiteral("change");
    default: return QStringLiteral("unknown");
    }
}

} // namespace softbus::device_bus::monitor

