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

/*
 * Implementation of interface class __TrackPoint
 */

class __TrackPointPrivate
{
public:
   __TrackPointPrivate() = default;

    // begin member variables
    QString DeviceList;
    bool Exist;
    bool LeftHanded;
    bool MiddleButtonEnabled;
    int MiddleButtonTimeout;
    double MotionAcceleration;
    double MotionScaling;
    double MotionThreshold;
    bool WheelEmulation;
    int WheelEmulationButton;
    int WheelEmulationTimeout;
    bool WheelHorizScroll;

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

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

}

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

void __TrackPoint::onPropertyChanged(const QString &propName, const QVariant &value)
{
    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("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("MiddleButtonEnabled"))
    {
        const bool &MiddleButtonEnabled = qvariant_cast<bool>(value);
        if (d_ptr->MiddleButtonEnabled != MiddleButtonEnabled)
        {
            d_ptr->MiddleButtonEnabled = MiddleButtonEnabled;
            Q_EMIT MiddleButtonEnabledChanged(d_ptr->MiddleButtonEnabled);
        }
        return;
    }

    if (propName == QStringLiteral("MiddleButtonTimeout"))
    {
        const int &MiddleButtonTimeout = qvariant_cast<int>(value);
        if (d_ptr->MiddleButtonTimeout != MiddleButtonTimeout)
        {
            d_ptr->MiddleButtonTimeout = MiddleButtonTimeout;
            Q_EMIT MiddleButtonTimeoutChanged(d_ptr->MiddleButtonTimeout);
        }
        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("WheelEmulation"))
    {
        const bool &WheelEmulation = qvariant_cast<bool>(value);
        if (d_ptr->WheelEmulation != WheelEmulation)
        {
            d_ptr->WheelEmulation = WheelEmulation;
            Q_EMIT WheelEmulationChanged(d_ptr->WheelEmulation);
        }
        return;
    }

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

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

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

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

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

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

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

void __TrackPoint::setLeftHanded(bool value)
{

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

bool __TrackPoint::middleButtonEnabled()
{
    return qvariant_cast<bool>(internalPropGet("MiddleButtonEnabled", &d_ptr->MiddleButtonEnabled));
}

void __TrackPoint::setMiddleButtonEnabled(bool value)
{

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

int __TrackPoint::middleButtonTimeout()
{
    return qvariant_cast<int>(internalPropGet("MiddleButtonTimeout", &d_ptr->MiddleButtonTimeout));
}

void __TrackPoint::setMiddleButtonTimeout(int value)
{

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

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

void __TrackPoint::setMotionAcceleration(double value)
{

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

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

void __TrackPoint::setMotionScaling(double value)
{

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

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

void __TrackPoint::setMotionThreshold(double value)
{

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

bool __TrackPoint::wheelEmulation()
{
    return qvariant_cast<bool>(internalPropGet("WheelEmulation", &d_ptr->WheelEmulation));
}

void __TrackPoint::setWheelEmulation(bool value)
{

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

int __TrackPoint::wheelEmulationButton()
{
    return qvariant_cast<int>(internalPropGet("WheelEmulationButton", &d_ptr->WheelEmulationButton));
}

void __TrackPoint::setWheelEmulationButton(int value)
{

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

int __TrackPoint::wheelEmulationTimeout()
{
    return qvariant_cast<int>(internalPropGet("WheelEmulationTimeout", &d_ptr->WheelEmulationTimeout));
}

void __TrackPoint::setWheelEmulationTimeout(int value)
{

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

bool __TrackPoint::wheelHorizScroll()
{
    return qvariant_cast<bool>(internalPropGet("WheelHorizScroll", &d_ptr->WheelHorizScroll));
}

void __TrackPoint::setWheelHorizScroll(bool value)
{

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

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

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