/*
 * This file was generated by qdbusxml2cpp-fix version 0.8
 * Command line was: qdbusxml2cpp-fix -m -p power1interface /build/deepin-tray-loader/src/dde-tray-loader/plugins/dde-dock/dbus/xml/org.deepin.dde.Power1.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 "power1interface.h"

DCORE_USE_NAMESPACE
/*
 * Implementation of interface class __OrgDeepinDdePower1Interface
 */

class __OrgDeepinDdePower1InterfacePrivate
{
public:
   __OrgDeepinDdePower1InterfacePrivate() = default;

    // begin member variables
    double BatteryPercentage;
    uint BatteryStatus;
    qulonglong BatteryTimeToEmpty;
    qulonglong BatteryTimeToFull;
    bool HasBattery;
    bool HasLidSwitch;
    bool IsHighPerformanceSupported;
    QString Mode;
    bool OnBattery;
    bool PowerSavingModeAuto;
    bool PowerSavingModeAutoWhenBatteryLow;
    uint PowerSavingModeBrightnessDropPercent;
    bool PowerSavingModeEnabled;
    bool PowerSystemAutoToSleepWhenFree;

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

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

}

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

void __OrgDeepinDdePower1Interface::onPropertyChanged(const QString &propName, const QVariant &value)
{
    if (propName == QStringLiteral("BatteryPercentage"))
    {
        const double &BatteryPercentage = qvariant_cast<double>(value);
        if (d_ptr->BatteryPercentage != BatteryPercentage)
        {
            d_ptr->BatteryPercentage = BatteryPercentage;
            Q_EMIT BatteryPercentageChanged(d_ptr->BatteryPercentage);
        }
        return;
    }

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

    if (propName == QStringLiteral("BatteryTimeToEmpty"))
    {
        const qulonglong &BatteryTimeToEmpty = qvariant_cast<qulonglong>(value);
        if (d_ptr->BatteryTimeToEmpty != BatteryTimeToEmpty)
        {
            d_ptr->BatteryTimeToEmpty = BatteryTimeToEmpty;
            Q_EMIT BatteryTimeToEmptyChanged(d_ptr->BatteryTimeToEmpty);
        }
        return;
    }

    if (propName == QStringLiteral("BatteryTimeToFull"))
    {
        const qulonglong &BatteryTimeToFull = qvariant_cast<qulonglong>(value);
        if (d_ptr->BatteryTimeToFull != BatteryTimeToFull)
        {
            d_ptr->BatteryTimeToFull = BatteryTimeToFull;
            Q_EMIT BatteryTimeToFullChanged(d_ptr->BatteryTimeToFull);
        }
        return;
    }

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

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

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

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

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

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

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

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

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

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

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

double __OrgDeepinDdePower1Interface::batteryPercentage()
{
    return qvariant_cast<double>(internalPropGet("BatteryPercentage", &d_ptr->BatteryPercentage));
}

uint __OrgDeepinDdePower1Interface::batteryStatus()
{
    return qvariant_cast<uint>(internalPropGet("BatteryStatus", &d_ptr->BatteryStatus));
}

qulonglong __OrgDeepinDdePower1Interface::batteryTimeToEmpty()
{
    return qvariant_cast<qulonglong>(internalPropGet("BatteryTimeToEmpty", &d_ptr->BatteryTimeToEmpty));
}

qulonglong __OrgDeepinDdePower1Interface::batteryTimeToFull()
{
    return qvariant_cast<qulonglong>(internalPropGet("BatteryTimeToFull", &d_ptr->BatteryTimeToFull));
}

bool __OrgDeepinDdePower1Interface::hasBattery()
{
    return qvariant_cast<bool>(internalPropGet("HasBattery", &d_ptr->HasBattery));
}

bool __OrgDeepinDdePower1Interface::hasLidSwitch()
{
    return qvariant_cast<bool>(internalPropGet("HasLidSwitch", &d_ptr->HasLidSwitch));
}

bool __OrgDeepinDdePower1Interface::isHighPerformanceSupported()
{
    return qvariant_cast<bool>(internalPropGet("IsHighPerformanceSupported", &d_ptr->IsHighPerformanceSupported));
}

QString __OrgDeepinDdePower1Interface::mode()
{
    return qvariant_cast<QString>(internalPropGet("Mode", &d_ptr->Mode));
}

bool __OrgDeepinDdePower1Interface::onBattery()
{
    return qvariant_cast<bool>(internalPropGet("OnBattery", &d_ptr->OnBattery));
}

bool __OrgDeepinDdePower1Interface::powerSavingModeAuto()
{
    return qvariant_cast<bool>(internalPropGet("PowerSavingModeAuto", &d_ptr->PowerSavingModeAuto));
}

void __OrgDeepinDdePower1Interface::setPowerSavingModeAuto(bool value)
{

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

bool __OrgDeepinDdePower1Interface::powerSavingModeAutoWhenBatteryLow()
{
    return qvariant_cast<bool>(internalPropGet("PowerSavingModeAutoWhenBatteryLow", &d_ptr->PowerSavingModeAutoWhenBatteryLow));
}

void __OrgDeepinDdePower1Interface::setPowerSavingModeAutoWhenBatteryLow(bool value)
{

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

uint __OrgDeepinDdePower1Interface::powerSavingModeBrightnessDropPercent()
{
    return qvariant_cast<uint>(internalPropGet("PowerSavingModeBrightnessDropPercent", &d_ptr->PowerSavingModeBrightnessDropPercent));
}

void __OrgDeepinDdePower1Interface::setPowerSavingModeBrightnessDropPercent(uint value)
{

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

bool __OrgDeepinDdePower1Interface::powerSavingModeEnabled()
{
    return qvariant_cast<bool>(internalPropGet("PowerSavingModeEnabled", &d_ptr->PowerSavingModeEnabled));
}

void __OrgDeepinDdePower1Interface::setPowerSavingModeEnabled(bool value)
{

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

bool __OrgDeepinDdePower1Interface::powerSystemAutoToSleepWhenFree()
{
    return qvariant_cast<bool>(internalPropGet("PowerSystemAutoToSleepWhenFree", &d_ptr->PowerSystemAutoToSleepWhenFree));
}

void __OrgDeepinDdePower1Interface::setPowerSystemAutoToSleepWhenFree(bool value)
{

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

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

void __OrgDeepinDdePower1Interface::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_power1interface.cpp"
