/*
 * This file was generated by qdbusxml2cpp-fix version 0.8
 * Command line was: qdbusxml2cpp-fix -c Mouse -p generated/com_deepin_daemon_inputdevice_mouse ../xml/com.deepin.daemon.InputDevice.Mouse.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_mouse.h"

/*
 * Implementation of interface class __Mouse
 */

class __MousePrivate
{
public:
   __MousePrivate() = default;

    // begin member variables
    bool AdaptiveAccelProfile;
    QString DeviceList;
    bool DisableTpad;
    int DoubleClick;
    int DragThreshold;
    bool Exist;
    bool LeftHanded;
    bool MiddleButtonEmulation;
    double MotionAcceleration;
    double MotionScaling;
    double MotionThreshold;
    bool NaturalScroll;

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

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

}

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

void __Mouse::onPropertyChanged(const QString &propName, const QVariant &value)
{
    if (propName == QStringLiteral("AdaptiveAccelProfile"))
    {
        const bool &AdaptiveAccelProfile = qvariant_cast<bool>(value);
        if (d_ptr->AdaptiveAccelProfile != AdaptiveAccelProfile)
        {
            d_ptr->AdaptiveAccelProfile = AdaptiveAccelProfile;
            Q_EMIT AdaptiveAccelProfileChanged(d_ptr->AdaptiveAccelProfile);
        }
        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("DisableTpad"))
    {
        const bool &DisableTpad = qvariant_cast<bool>(value);
        if (d_ptr->DisableTpad != DisableTpad)
        {
            d_ptr->DisableTpad = DisableTpad;
            Q_EMIT DisableTpadChanged(d_ptr->DisableTpad);
        }
        return;
    }

    if (propName == QStringLiteral("DoubleClick"))
    {
        const int &DoubleClick = qvariant_cast<int>(value);
        if (d_ptr->DoubleClick != DoubleClick)
        {
            d_ptr->DoubleClick = DoubleClick;
            Q_EMIT DoubleClickChanged(d_ptr->DoubleClick);
        }
        return;
    }

    if (propName == QStringLiteral("DragThreshold"))
    {
        const int &DragThreshold = qvariant_cast<int>(value);
        if (d_ptr->DragThreshold != DragThreshold)
        {
            d_ptr->DragThreshold = DragThreshold;
            Q_EMIT DragThresholdChanged(d_ptr->DragThreshold);
        }
        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("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("MiddleButtonEmulation"))
    {
        const bool &MiddleButtonEmulation = qvariant_cast<bool>(value);
        if (d_ptr->MiddleButtonEmulation != MiddleButtonEmulation)
        {
            d_ptr->MiddleButtonEmulation = MiddleButtonEmulation;
            Q_EMIT MiddleButtonEmulationChanged(d_ptr->MiddleButtonEmulation);
        }
        return;
    }

    if (propName == QStringLiteral("MotionAcceleration"))
    {
        const double &MotionAcceleration = qvariant_cast<double>(value);
        if (d_ptr->MotionAcceleration != MotionAcceleration)
        {
            d_ptr->MotionAcceleration = MotionAcceleration;
            Q_EMIT MotionAccelerationChanged(d_ptr->MotionAcceleration);
        }
        return;
    }

    if (propName == QStringLiteral("MotionScaling"))
    {
        const double &MotionScaling = qvariant_cast<double>(value);
        if (d_ptr->MotionScaling != MotionScaling)
        {
            d_ptr->MotionScaling = MotionScaling;
            Q_EMIT MotionScalingChanged(d_ptr->MotionScaling);
        }
        return;
    }

    if (propName == QStringLiteral("MotionThreshold"))
    {
        const double &MotionThreshold = qvariant_cast<double>(value);
        if (d_ptr->MotionThreshold != MotionThreshold)
        {
            d_ptr->MotionThreshold = MotionThreshold;
            Q_EMIT MotionThresholdChanged(d_ptr->MotionThreshold);
        }
        return;
    }

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

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

bool __Mouse::adaptiveAccelProfile()
{
    return qvariant_cast<bool>(internalPropGet("AdaptiveAccelProfile", &d_ptr->AdaptiveAccelProfile));
}

void __Mouse::setAdaptiveAccelProfile(bool value)
{

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

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

bool __Mouse::disableTpad()
{
    return qvariant_cast<bool>(internalPropGet("DisableTpad", &d_ptr->DisableTpad));
}

void __Mouse::setDisableTpad(bool value)
{

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

int __Mouse::doubleClick()
{
    return qvariant_cast<int>(internalPropGet("DoubleClick", &d_ptr->DoubleClick));
}

void __Mouse::setDoubleClick(int value)
{

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

int __Mouse::dragThreshold()
{
    return qvariant_cast<int>(internalPropGet("DragThreshold", &d_ptr->DragThreshold));
}

void __Mouse::setDragThreshold(int value)
{

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

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

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

void __Mouse::setLeftHanded(bool value)
{

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

bool __Mouse::middleButtonEmulation()
{
    return qvariant_cast<bool>(internalPropGet("MiddleButtonEmulation", &d_ptr->MiddleButtonEmulation));
}

void __Mouse::setMiddleButtonEmulation(bool value)
{

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

double __Mouse::motionAcceleration()
{
    return qvariant_cast<double>(internalPropGet("MotionAcceleration", &d_ptr->MotionAcceleration));
}

void __Mouse::setMotionAcceleration(double value)
{

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

double __Mouse::motionScaling()
{
    return qvariant_cast<double>(internalPropGet("MotionScaling", &d_ptr->MotionScaling));
}

void __Mouse::setMotionScaling(double value)
{

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

double __Mouse::motionThreshold()
{
    return qvariant_cast<double>(internalPropGet("MotionThreshold", &d_ptr->MotionThreshold));
}

void __Mouse::setMotionThreshold(double value)
{

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

bool __Mouse::naturalScroll()
{
    return qvariant_cast<bool>(internalPropGet("NaturalScroll", &d_ptr->NaturalScroll));
}

void __Mouse::setNaturalScroll(bool value)
{

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

void __Mouse::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, &__Mouse::onPendingCallFinished);
        d_ptr->m_processingCalls.insert(callName, watcher);
    }
}

void __Mouse::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);
}
