// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#include "mcusupportdevice.h"
#include "mcusupportconstants.h"
#include "mcusupporttr.h"

using namespace ProjectExplorer;
using namespace Utils;

namespace McuSupport::Internal {

McuSupportDevice::McuSupportDevice()
{
    setupId(IDevice::AutoDetected, Constants::DEVICE_ID);
    setType(Constants::DEVICE_TYPE);
    const QString displayNameAndType = Tr::tr("MCU Device");
    setDefaultDisplayName(displayNameAndType);
    setDisplayType(displayNameAndType);
    setMachineType(IDevice::Hardware);
    setOsType(Utils::OsTypeOther);
    setDeviceState(IDevice::DeviceStateUnknown);
}

ProjectExplorer::IDevice::Ptr McuSupportDevice::create()
{
    auto device = new McuSupportDevice;
    return ProjectExplorer::IDevice::Ptr(device);
}

Utils::Result<> McuSupportDevice::handlesFile(const Utils::FilePath &) const
{
    return Utils::ResultError(Tr::tr("File handling is not supported."));
}

McuSupportDeviceFactory::McuSupportDeviceFactory()
    : ProjectExplorer::IDeviceFactory(Constants::DEVICE_TYPE)
{
    setDisplayName(Tr::tr("MCU Device"));
    setCombinedIcon(":/mcusupport/images/mcusupportdevicesmall.png",
                    ":/mcusupport/images/mcusupportdevice.png");
    setConstructionFunction(&McuSupportDevice::create);
    setCreator(&McuSupportDevice::create);
}

} // namespace McuSupport::Internal
