/*
 * This file was generated by qdbusxml2cpp-fix version 0.8
 * Command line was: qdbusxml2cpp-fix -m -p display1interface /build/deepin-clipboard/src/dde-clipboard/dbus/org.deepin.dde.Display1.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 "display1interface.h"

DCORE_USE_NAMESPACE
/*
 * Implementation of interface class __OrgDeepinDdeDisplay1Interface
 */

class __OrgDeepinDdeDisplay1InterfacePrivate
{
public:
   __OrgDeepinDdeDisplay1InterfacePrivate() = default;

    // begin member variables
    BrightnessMap Brightness;
    int ColorTemperatureManual;
    int ColorTemperatureMode;
    QString CurrentCustomId;
    QStringList CustomIdList;
    uchar DisplayMode;
    bool HasChanged;
    uint MaxBacklightBrightness;
    QList<QDBusObjectPath> Monitors;
    QString Primary;
    ScreenRect PrimaryRect;
    ushort ScreenHeight;
    ushort ScreenWidth;
    TouchscreenMap TouchMap;
    TouchscreenInfoList Touchscreens;
    TouchscreenInfoList_V2 TouchscreensV2;

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

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

    if (QMetaType::fromName("ResolutionList").id() == QMetaType::UnknownType)
        registerResolutionListMetaType();
    if (QMetaType::fromName("BrightnessMap").id() == QMetaType::UnknownType)
        registerBrightnessMapMetaType();
    if (QMetaType::fromName("ScreenRect").id() == QMetaType::UnknownType)
        registerScreenRectMetaType();
    if (QMetaType::fromName("TouchscreenMap").id() == QMetaType::UnknownType)
        registerTouchscreenMapMetaType();
    if (QMetaType::fromName("TouchscreenInfoList").id() == QMetaType::UnknownType)
        registerTouchscreenInfoListMetaType();
    if (QMetaType::fromName("TouchscreenInfoList_V2").id() == QMetaType::UnknownType)
        registerTouchscreenInfoList_V2MetaType();
}

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

void __OrgDeepinDdeDisplay1Interface::onPropertyChanged(const QString &propName, const QVariant &value)
{
    if (propName == QStringLiteral("Brightness"))
    {
        const BrightnessMap &Brightness = qvariant_cast<BrightnessMap>(value);
        if (d_ptr->Brightness != Brightness)
        {
            d_ptr->Brightness = Brightness;
            Q_EMIT BrightnessChanged(d_ptr->Brightness);
        }
        return;
    }

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

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

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

    if (propName == QStringLiteral("CustomIdList"))
    {
        const QStringList &CustomIdList = qvariant_cast<QStringList>(value);
        if (d_ptr->CustomIdList != CustomIdList)
        {
            d_ptr->CustomIdList = CustomIdList;
            Q_EMIT CustomIdListChanged(d_ptr->CustomIdList);
        }
        return;
    }

    if (propName == QStringLiteral("DisplayMode"))
    {
        const uchar &DisplayMode = qvariant_cast<uchar>(value);
        if (d_ptr->DisplayMode != DisplayMode)
        {
            d_ptr->DisplayMode = DisplayMode;
            Q_EMIT DisplayModeChanged(d_ptr->DisplayMode);
        }
        return;
    }

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

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

    if (propName == QStringLiteral("Monitors"))
    {
        const QList<QDBusObjectPath> &Monitors = qvariant_cast<QList<QDBusObjectPath>>(value);
        if (d_ptr->Monitors != Monitors)
        {
            d_ptr->Monitors = Monitors;
            Q_EMIT MonitorsChanged(d_ptr->Monitors);
        }
        return;
    }

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

    if (propName == QStringLiteral("PrimaryRect"))
    {
        const ScreenRect &PrimaryRect = qvariant_cast<ScreenRect>(value);
        if (d_ptr->PrimaryRect != PrimaryRect)
        {
            d_ptr->PrimaryRect = PrimaryRect;
            Q_EMIT PrimaryRectChanged(d_ptr->PrimaryRect);
        }
        return;
    }

    if (propName == QStringLiteral("ScreenHeight"))
    {
        const ushort &ScreenHeight = qvariant_cast<ushort>(value);
        if (d_ptr->ScreenHeight != ScreenHeight)
        {
            d_ptr->ScreenHeight = ScreenHeight;
            Q_EMIT ScreenHeightChanged(d_ptr->ScreenHeight);
        }
        return;
    }

    if (propName == QStringLiteral("ScreenWidth"))
    {
        const ushort &ScreenWidth = qvariant_cast<ushort>(value);
        if (d_ptr->ScreenWidth != ScreenWidth)
        {
            d_ptr->ScreenWidth = ScreenWidth;
            Q_EMIT ScreenWidthChanged(d_ptr->ScreenWidth);
        }
        return;
    }

    if (propName == QStringLiteral("TouchMap"))
    {
        const TouchscreenMap &TouchMap = qvariant_cast<TouchscreenMap>(value);
        if (d_ptr->TouchMap != TouchMap)
        {
            d_ptr->TouchMap = TouchMap;
            Q_EMIT TouchMapChanged(d_ptr->TouchMap);
        }
        return;
    }

    if (propName == QStringLiteral("Touchscreens"))
    {
        const TouchscreenInfoList &Touchscreens = qvariant_cast<TouchscreenInfoList>(value);
        if (d_ptr->Touchscreens != Touchscreens)
        {
            d_ptr->Touchscreens = Touchscreens;
            Q_EMIT TouchscreensChanged(d_ptr->Touchscreens);
        }
        return;
    }

    if (propName == QStringLiteral("TouchscreensV2"))
    {
        const TouchscreenInfoList_V2 &TouchscreensV2 = qvariant_cast<TouchscreenInfoList_V2>(value);
        if (d_ptr->TouchscreensV2 != TouchscreensV2)
        {
            d_ptr->TouchscreensV2 = TouchscreensV2;
            Q_EMIT TouchscreensV2Changed(d_ptr->TouchscreensV2);
        }
        return;
    }

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

BrightnessMap __OrgDeepinDdeDisplay1Interface::brightness()
{
    return qvariant_cast<BrightnessMap>(internalPropGet("Brightness", &d_ptr->Brightness));
}

int __OrgDeepinDdeDisplay1Interface::colorTemperatureManual()
{
    return qvariant_cast<int>(internalPropGet("ColorTemperatureManual", &d_ptr->ColorTemperatureManual));
}

int __OrgDeepinDdeDisplay1Interface::colorTemperatureMode()
{
    return qvariant_cast<int>(internalPropGet("ColorTemperatureMode", &d_ptr->ColorTemperatureMode));
}

QString __OrgDeepinDdeDisplay1Interface::currentCustomId()
{
    return qvariant_cast<QString>(internalPropGet("CurrentCustomId", &d_ptr->CurrentCustomId));
}

QStringList __OrgDeepinDdeDisplay1Interface::customIdList()
{
    return qvariant_cast<QStringList>(internalPropGet("CustomIdList", &d_ptr->CustomIdList));
}

uchar __OrgDeepinDdeDisplay1Interface::displayMode()
{
    return qvariant_cast<uchar>(internalPropGet("DisplayMode", &d_ptr->DisplayMode));
}

bool __OrgDeepinDdeDisplay1Interface::hasChanged()
{
    return qvariant_cast<bool>(internalPropGet("HasChanged", &d_ptr->HasChanged));
}

uint __OrgDeepinDdeDisplay1Interface::maxBacklightBrightness()
{
    return qvariant_cast<uint>(internalPropGet("MaxBacklightBrightness", &d_ptr->MaxBacklightBrightness));
}

QList<QDBusObjectPath> __OrgDeepinDdeDisplay1Interface::monitors()
{
    return qvariant_cast<QList<QDBusObjectPath>>(internalPropGet("Monitors", &d_ptr->Monitors));
}

QString __OrgDeepinDdeDisplay1Interface::primary()
{
    return qvariant_cast<QString>(internalPropGet("Primary", &d_ptr->Primary));
}

ScreenRect __OrgDeepinDdeDisplay1Interface::primaryRect()
{
    return qvariant_cast<ScreenRect>(internalPropGet("PrimaryRect", &d_ptr->PrimaryRect));
}

ushort __OrgDeepinDdeDisplay1Interface::screenHeight()
{
    return qvariant_cast<ushort>(internalPropGet("ScreenHeight", &d_ptr->ScreenHeight));
}

ushort __OrgDeepinDdeDisplay1Interface::screenWidth()
{
    return qvariant_cast<ushort>(internalPropGet("ScreenWidth", &d_ptr->ScreenWidth));
}

TouchscreenMap __OrgDeepinDdeDisplay1Interface::touchMap()
{
    return qvariant_cast<TouchscreenMap>(internalPropGet("TouchMap", &d_ptr->TouchMap));
}

TouchscreenInfoList __OrgDeepinDdeDisplay1Interface::touchscreens()
{
    return qvariant_cast<TouchscreenInfoList>(internalPropGet("Touchscreens", &d_ptr->Touchscreens));
}

TouchscreenInfoList_V2 __OrgDeepinDdeDisplay1Interface::touchscreensV2()
{
    return qvariant_cast<TouchscreenInfoList_V2>(internalPropGet("TouchscreensV2", &d_ptr->TouchscreensV2));
}

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

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

#include "moc_display1interface.cpp"
