/*
 * This file was generated by qdbusxml2cpp-fix version 0.8
 * Command line was: qdbusxml2cpp-fix -c Wacom -p generated/com_deepin_daemon_inputdevice_wacom ../xml/com.deepin.daemon.InputDevice.Wacom.xml
 *
 * qdbusxml2cpp-fix is Copyright (C) 2016 Deepin Technology Co., Ltd.
 *
 * This is an auto-generated file.
 * This file may have been hand-edited. Look for HAND-EDIT comments
 * before re-generating it.
 */

#include "generated/com_deepin_daemon_inputdevice_wacom.h"

/*
 * Implementation of interface class __Wacom
 */

class __WacomPrivate
{
public:
   __WacomPrivate() = default;

    // begin member variables
    WacomDeviceList ActionInfos;
    bool CursorMode;
    QString DeviceList;
    uint EraserPressureSensitive;
    uint EraserRawSample;
    uint EraserThreshold;
    bool Exist;
    QString KeyDownAction;
    QString KeyUpAction;
    bool LeftHanded;
    QString MapOutput;
    uint StylusPressureSensitive;
    uint StylusRawSample;
    uint StylusThreshold;
    uint Suppress;

public:
    QMap<QString, QDBusPendingCallWatcher *> m_processingCalls;
    QMap<QString, QList<QVariant>> m_waittingCalls;
};

__Wacom::__Wacom(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
    : DBusExtendedAbstractInterface(service, path, staticInterfaceName(), connection, parent)
    , d_ptr(new __WacomPrivate)
{
    connect(this, &__Wacom::propertyChanged, this, &__Wacom::onPropertyChanged);

    if (QMetaType::type("WacomDeviceList") == QMetaType::UnknownType)
        registerWacomDeviceListMetaType();
}

__Wacom::~__Wacom()
{
    qDeleteAll(d_ptr->m_processingCalls.values());
    delete d_ptr;
}

void __Wacom::onPropertyChanged(const QString &propName, const QVariant &value)
{
    if (propName == QStringLiteral("ActionInfos"))
    {
        const WacomDeviceList &ActionInfos = qvariant_cast<WacomDeviceList>(value);
        if (d_ptr->ActionInfos != ActionInfos)
        {
            d_ptr->ActionInfos = ActionInfos;
            Q_EMIT ActionInfosChanged(d_ptr->ActionInfos);
        }
        return;
    }

    if (propName == QStringLiteral("CursorMode"))
    {
        const bool &CursorMode = qvariant_cast<bool>(value);
        if (d_ptr->CursorMode != CursorMode)
        {
            d_ptr->CursorMode = CursorMode;
            Q_EMIT CursorModeChanged(d_ptr->CursorMode);
        }
        return;
    }

    if (propName == QStringLiteral("DeviceList"))
    {
        const QString &DeviceList = qvariant_cast<QString>(value);
        if (d_ptr->DeviceList != DeviceList)
        {
            d_ptr->DeviceList = DeviceList;
            Q_EMIT DeviceListChanged(d_ptr->DeviceList);
        }
        return;
    }

    if (propName == QStringLiteral("EraserPressureSensitive"))
    {
        const uint &EraserPressureSensitive = qvariant_cast<uint>(value);
        if (d_ptr->EraserPressureSensitive != EraserPressureSensitive)
        {
            d_ptr->EraserPressureSensitive = EraserPressureSensitive;
            Q_EMIT EraserPressureSensitiveChanged(d_ptr->EraserPressureSensitive);
        }
        return;
    }

    if (propName == QStringLiteral("EraserRawSample"))
    {
        const uint &EraserRawSample = qvariant_cast<uint>(value);
        if (d_ptr->EraserRawSample != EraserRawSample)
        {
            d_ptr->EraserRawSample = EraserRawSample;
            Q_EMIT EraserRawSampleChanged(d_ptr->EraserRawSample);
        }
        return;
    }

    if (propName == QStringLiteral("EraserThreshold"))
    {
        const uint &EraserThreshold = qvariant_cast<uint>(value);
        if (d_ptr->EraserThreshold != EraserThreshold)
        {
            d_ptr->EraserThreshold = EraserThreshold;
            Q_EMIT EraserThresholdChanged(d_ptr->EraserThreshold);
        }
        return;
    }

    if (propName == QStringLiteral("Exist"))
    {
        const bool &Exist = qvariant_cast<bool>(value);
        if (d_ptr->Exist != Exist)
        {
            d_ptr->Exist = Exist;
            Q_EMIT ExistChanged(d_ptr->Exist);
        }
        return;
    }

    if (propName == QStringLiteral("KeyDownAction"))
    {
        const QString &KeyDownAction = qvariant_cast<QString>(value);
        if (d_ptr->KeyDownAction != KeyDownAction)
        {
            d_ptr->KeyDownAction = KeyDownAction;
            Q_EMIT KeyDownActionChanged(d_ptr->KeyDownAction);
        }
        return;
    }

    if (propName == QStringLiteral("KeyUpAction"))
    {
        const QString &KeyUpAction = qvariant_cast<QString>(value);
        if (d_ptr->KeyUpAction != KeyUpAction)
        {
            d_ptr->KeyUpAction = KeyUpAction;
            Q_EMIT KeyUpActionChanged(d_ptr->KeyUpAction);
        }
        return;
    }

    if (propName == QStringLiteral("LeftHanded"))
    {
        const bool &LeftHanded = qvariant_cast<bool>(value);
        if (d_ptr->LeftHanded != LeftHanded)
        {
            d_ptr->LeftHanded = LeftHanded;
            Q_EMIT LeftHandedChanged(d_ptr->LeftHanded);
        }
        return;
    }

    if (propName == QStringLiteral("MapOutput"))
    {
        const QString &MapOutput = qvariant_cast<QString>(value);
        if (d_ptr->MapOutput != MapOutput)
        {
            d_ptr->MapOutput = MapOutput;
            Q_EMIT MapOutputChanged(d_ptr->MapOutput);
        }
        return;
    }

    if (propName == QStringLiteral("StylusPressureSensitive"))
    {
        const uint &StylusPressureSensitive = qvariant_cast<uint>(value);
        if (d_ptr->StylusPressureSensitive != StylusPressureSensitive)
        {
            d_ptr->StylusPressureSensitive = StylusPressureSensitive;
            Q_EMIT StylusPressureSensitiveChanged(d_ptr->StylusPressureSensitive);
        }
        return;
    }

    if (propName == QStringLiteral("StylusRawSample"))
    {
        const uint &StylusRawSample = qvariant_cast<uint>(value);
        if (d_ptr->StylusRawSample != StylusRawSample)
        {
            d_ptr->StylusRawSample = StylusRawSample;
            Q_EMIT StylusRawSampleChanged(d_ptr->StylusRawSample);
        }
        return;
    }

    if (propName == QStringLiteral("StylusThreshold"))
    {
        const uint &StylusThreshold = qvariant_cast<uint>(value);
        if (d_ptr->StylusThreshold != StylusThreshold)
        {
            d_ptr->StylusThreshold = StylusThreshold;
            Q_EMIT StylusThresholdChanged(d_ptr->StylusThreshold);
        }
        return;
    }

    if (propName == QStringLiteral("Suppress"))
    {
        const uint &Suppress = qvariant_cast<uint>(value);
        if (d_ptr->Suppress != Suppress)
        {
            d_ptr->Suppress = Suppress;
            Q_EMIT SuppressChanged(d_ptr->Suppress);
        }
        return;
    }

    qWarning() << "property not handle: " << propName;
    return;
}

WacomDeviceList __Wacom::actionInfos()
{
    return qvariant_cast<WacomDeviceList>(internalPropGet("ActionInfos", &d_ptr->ActionInfos));
}

bool __Wacom::cursorMode()
{
    return qvariant_cast<bool>(internalPropGet("CursorMode", &d_ptr->CursorMode));
}

void __Wacom::setCursorMode(bool value)
{

   internalPropSet("CursorMode", QVariant::fromValue(value), &d_ptr->CursorMode);
}

QString __Wacom::deviceList()
{
    return qvariant_cast<QString>(internalPropGet("DeviceList", &d_ptr->DeviceList));
}

uint __Wacom::eraserPressureSensitive()
{
    return qvariant_cast<uint>(internalPropGet("EraserPressureSensitive", &d_ptr->EraserPressureSensitive));
}

void __Wacom::setEraserPressureSensitive(uint value)
{

   internalPropSet("EraserPressureSensitive", QVariant::fromValue(value), &d_ptr->EraserPressureSensitive);
}

uint __Wacom::eraserRawSample()
{
    return qvariant_cast<uint>(internalPropGet("EraserRawSample", &d_ptr->EraserRawSample));
}

void __Wacom::setEraserRawSample(uint value)
{

   internalPropSet("EraserRawSample", QVariant::fromValue(value), &d_ptr->EraserRawSample);
}

uint __Wacom::eraserThreshold()
{
    return qvariant_cast<uint>(internalPropGet("EraserThreshold", &d_ptr->EraserThreshold));
}

void __Wacom::setEraserThreshold(uint value)
{

   internalPropSet("EraserThreshold", QVariant::fromValue(value), &d_ptr->EraserThreshold);
}

bool __Wacom::exist()
{
    return qvariant_cast<bool>(internalPropGet("Exist", &d_ptr->Exist));
}

QString __Wacom::keyDownAction()
{
    return qvariant_cast<QString>(internalPropGet("KeyDownAction", &d_ptr->KeyDownAction));
}

void __Wacom::setKeyDownAction(const QString &value)
{

   internalPropSet("KeyDownAction", QVariant::fromValue(value), &d_ptr->KeyDownAction);
}

QString __Wacom::keyUpAction()
{
    return qvariant_cast<QString>(internalPropGet("KeyUpAction", &d_ptr->KeyUpAction));
}

void __Wacom::setKeyUpAction(const QString &value)
{

   internalPropSet("KeyUpAction", QVariant::fromValue(value), &d_ptr->KeyUpAction);
}

bool __Wacom::leftHanded()
{
    return qvariant_cast<bool>(internalPropGet("LeftHanded", &d_ptr->LeftHanded));
}

void __Wacom::setLeftHanded(bool value)
{

   internalPropSet("LeftHanded", QVariant::fromValue(value), &d_ptr->LeftHanded);
}

QString __Wacom::mapOutput()
{
    return qvariant_cast<QString>(internalPropGet("MapOutput", &d_ptr->MapOutput));
}

void __Wacom::setMapOutput(const QString &value)
{

   internalPropSet("MapOutput", QVariant::fromValue(value), &d_ptr->MapOutput);
}

uint __Wacom::stylusPressureSensitive()
{
    return qvariant_cast<uint>(internalPropGet("StylusPressureSensitive", &d_ptr->StylusPressureSensitive));
}

void __Wacom::setStylusPressureSensitive(uint value)
{

   internalPropSet("StylusPressureSensitive", QVariant::fromValue(value), &d_ptr->StylusPressureSensitive);
}

uint __Wacom::stylusRawSample()
{
    return qvariant_cast<uint>(internalPropGet("StylusRawSample", &d_ptr->StylusRawSample));
}

void __Wacom::setStylusRawSample(uint value)
{

   internalPropSet("StylusRawSample", QVariant::fromValue(value), &d_ptr->StylusRawSample);
}

uint __Wacom::stylusThreshold()
{
    return qvariant_cast<uint>(internalPropGet("StylusThreshold", &d_ptr->StylusThreshold));
}

void __Wacom::setStylusThreshold(uint value)
{

   internalPropSet("StylusThreshold", QVariant::fromValue(value), &d_ptr->StylusThreshold);
}

uint __Wacom::suppress()
{
    return qvariant_cast<uint>(internalPropGet("Suppress", &d_ptr->Suppress));
}

void __Wacom::setSuppress(uint value)
{

   internalPropSet("Suppress", QVariant::fromValue(value), &d_ptr->Suppress);
}

void __Wacom::CallQueued(const QString &callName, const QList<QVariant> &args)
{
    if (d_ptr->m_waittingCalls.contains(callName))
    {
        d_ptr->m_waittingCalls[callName] = args;
        return;
    }
    if (d_ptr->m_processingCalls.contains(callName))
    {
        d_ptr->m_waittingCalls.insert(callName, args);
    } else {
        QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(asyncCallWithArgumentList(callName, args));
        connect(watcher, &QDBusPendingCallWatcher::finished, this, &__Wacom::onPendingCallFinished);
        d_ptr->m_processingCalls.insert(callName, watcher);
    }
}

void __Wacom::onPendingCallFinished(QDBusPendingCallWatcher *w)
{
    w->deleteLater();
    const auto callName = d_ptr->m_processingCalls.key(w);
    Q_ASSERT(!callName.isEmpty());
    if (callName.isEmpty())
        return;
    d_ptr->m_processingCalls.remove(callName);
    if (!d_ptr->m_waittingCalls.contains(callName))
        return;
    const auto args = d_ptr->m_waittingCalls.take(callName);
    CallQueued(callName, args);
}
