/*
 * This file was generated by qdbusxml2cpp-fix version 0.8
 * Command line was: qdbusxml2cpp-fix -c DeepinWm -p /build/deepin-session/src/dde-session/dbusinterface/com_deepin_Wm /build/deepin-session/src/dde-session/dbus/interface/com.deepin.wm.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 "/build/deepin-session/src/dde-session/dbusinterface/com_deepin_Wm.h"

DCORE_USE_NAMESPACE
/*
 * Implementation of interface class __DeepinWm
 */

class __DeepinWmPrivate
{
public:
   __DeepinWmPrivate() = default;

    // begin member variables
    bool compositingAllowSwitch;
    bool compositingEnabled;
    bool compositingPossible;
    int cursorSize;
    QString cursorTheme;
    bool zoneEnabled;

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

__DeepinWm::__DeepinWm(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
    : DDBusExtendedAbstractInterface(service, path, staticInterfaceName(), connection, parent)
    , d_ptr(new __DeepinWmPrivate)
{
    connect(this, &__DeepinWm::propertyChanged, this, &__DeepinWm::onPropertyChanged);

    if (QMetaType::fromName("QList<uint>").id() == QMetaType::UnknownType) {
        qRegisterMetaType< QList<uint> >("QList<uint>");
        qDBusRegisterMetaType< QList<uint> >();
    }
}

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

void __DeepinWm::onPropertyChanged(const QString &propName, const QVariant &value)
{
    if (propName == QStringLiteral("compositingAllowSwitch"))
    {
        const bool &compositingAllowSwitch = qvariant_cast<bool>(value);
        if (d_ptr->compositingAllowSwitch != compositingAllowSwitch)
        {
            d_ptr->compositingAllowSwitch = compositingAllowSwitch;
            Q_EMIT CompositingAllowSwitchChanged(d_ptr->compositingAllowSwitch);
        }
        return;
    }

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

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

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

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

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

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

bool __DeepinWm::compositingAllowSwitch()
{
    return qvariant_cast<bool>(internalPropGet("compositingAllowSwitch", &d_ptr->compositingAllowSwitch));
}

bool __DeepinWm::compositingEnabled()
{
    return qvariant_cast<bool>(internalPropGet("compositingEnabled", &d_ptr->compositingEnabled));
}

void __DeepinWm::setCompositingEnabled(bool value)
{

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

bool __DeepinWm::compositingPossible()
{
    return qvariant_cast<bool>(internalPropGet("compositingPossible", &d_ptr->compositingPossible));
}

int __DeepinWm::cursorSize()
{
    return qvariant_cast<int>(internalPropGet("cursorSize", &d_ptr->cursorSize));
}

void __DeepinWm::setCursorSize(int value)
{

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

QString __DeepinWm::cursorTheme()
{
    return qvariant_cast<QString>(internalPropGet("cursorTheme", &d_ptr->cursorTheme));
}

void __DeepinWm::setCursorTheme(const QString &value)
{

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

bool __DeepinWm::zoneEnabled()
{
    return qvariant_cast<bool>(internalPropGet("zoneEnabled", &d_ptr->zoneEnabled));
}

void __DeepinWm::setZoneEnabled(bool value)
{

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

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

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