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

/*
 * Implementation of interface class __Power
 */

class __PowerPrivate
{
public:
   __PowerPrivate() = default;

    // begin member variables
    bool AmbientLightAdjustBrightness;
    BatteryPresentInfo BatteryIsPresent;
    int BatteryLidClosedAction;
    int BatteryLockDelay;
    BatteryPercentageInfo BatteryPercentage;
    int BatteryPressPowerBtnAction;
    int BatteryScreenBlackDelay;
    int BatteryScreensaverDelay;
    int BatterySleepDelay;
    BatteryStateInfo BatteryState;
    bool HasAmbientLightSensor;
    bool IsHighPerformanceSupported;
    bool LidClosedSleep;
    bool LidIsPresent;
    int LinePowerLidClosedAction;
    int LinePowerLockDelay;
    int LinePowerPressPowerBtnAction;
    int LinePowerScreenBlackDelay;
    int LinePowerScreensaverDelay;
    int LinePowerSleepDelay;
    int LowPowerAutoSleepThreshold;
    bool LowPowerNotifyEnable;
    int LowPowerNotifyThreshold;
    bool OnBattery;
    bool ScreenBlackLock;
    bool SleepLock;
    uint WarnLevel;

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

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

    if (QMetaType::type("BatteryPercentageInfo") == QMetaType::UnknownType)
        registerBatteryPercentageInfoMetaType();
    if (QMetaType::type("BatteryPresentInfo") == QMetaType::UnknownType)
        registerBatteryPresentInfoMetaType();
    if (QMetaType::type("BatteryStateInfo") == QMetaType::UnknownType)
        registerBatteryStateInfoMetaType();
}

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

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

    if (propName == QStringLiteral("BatteryIsPresent"))
    {
        const BatteryPresentInfo &BatteryIsPresent = qvariant_cast<BatteryPresentInfo>(value);
        if (d_ptr->BatteryIsPresent != BatteryIsPresent)
        {
            d_ptr->BatteryIsPresent = BatteryIsPresent;
            Q_EMIT BatteryIsPresentChanged(d_ptr->BatteryIsPresent);
        }
        return;
    }

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

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

    if (propName == QStringLiteral("BatteryPercentage"))
    {
        const BatteryPercentageInfo &BatteryPercentage = qvariant_cast<BatteryPercentageInfo>(value);
        if (d_ptr->BatteryPercentage != BatteryPercentage)
        {
            d_ptr->BatteryPercentage = BatteryPercentage;
            Q_EMIT BatteryPercentageChanged(d_ptr->BatteryPercentage);
        }
        return;
    }

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

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

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

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

    if (propName == QStringLiteral("BatteryState"))
    {
        const BatteryStateInfo &BatteryState = qvariant_cast<BatteryStateInfo>(value);
        if (d_ptr->BatteryState != BatteryState)
        {
            d_ptr->BatteryState = BatteryState;
            Q_EMIT BatteryStateChanged(d_ptr->BatteryState);
        }
        return;
    }

    if (propName == QStringLiteral("HasAmbientLightSensor"))
    {
        const bool &HasAmbientLightSensor = qvariant_cast<bool>(value);
        if (d_ptr->HasAmbientLightSensor != HasAmbientLightSensor)
        {
            d_ptr->HasAmbientLightSensor = HasAmbientLightSensor;
            Q_EMIT HasAmbientLightSensorChanged(d_ptr->HasAmbientLightSensor);
        }
        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("LidClosedSleep"))
    {
        const bool &LidClosedSleep = qvariant_cast<bool>(value);
        if (d_ptr->LidClosedSleep != LidClosedSleep)
        {
            d_ptr->LidClosedSleep = LidClosedSleep;
            Q_EMIT LidClosedSleepChanged(d_ptr->LidClosedSleep);
        }
        return;
    }

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

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

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

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

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

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

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

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

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

    if (propName == QStringLiteral("LowPowerNotifyThreshold"))
    {
        const int &LowPowerNotifyThreshold = qvariant_cast<int>(value);
        if (d_ptr->LowPowerNotifyThreshold != LowPowerNotifyThreshold)
        {
            d_ptr->LowPowerNotifyThreshold = LowPowerNotifyThreshold;
            Q_EMIT LowPowerNotifyThresholdChanged(d_ptr->LowPowerNotifyThreshold);
        }
        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("ScreenBlackLock"))
    {
        const bool &ScreenBlackLock = qvariant_cast<bool>(value);
        if (d_ptr->ScreenBlackLock != ScreenBlackLock)
        {
            d_ptr->ScreenBlackLock = ScreenBlackLock;
            Q_EMIT ScreenBlackLockChanged(d_ptr->ScreenBlackLock);
        }
        return;
    }

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

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

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

bool __Power::ambientLightAdjustBrightness()
{
    return qvariant_cast<bool>(internalPropGet("AmbientLightAdjustBrightness", &d_ptr->AmbientLightAdjustBrightness));
}

void __Power::setAmbientLightAdjustBrightness(bool value)
{

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

BatteryPresentInfo __Power::batteryIsPresent()
{
    return qvariant_cast<BatteryPresentInfo>(internalPropGet("BatteryIsPresent", &d_ptr->BatteryIsPresent));
}

int __Power::batteryLidClosedAction()
{
    return qvariant_cast<int>(internalPropGet("BatteryLidClosedAction", &d_ptr->BatteryLidClosedAction));
}

void __Power::setBatteryLidClosedAction(int value)
{

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

int __Power::batteryLockDelay()
{
    return qvariant_cast<int>(internalPropGet("BatteryLockDelay", &d_ptr->BatteryLockDelay));
}

void __Power::setBatteryLockDelay(int value)
{

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

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

int __Power::batteryPressPowerBtnAction()
{
    return qvariant_cast<int>(internalPropGet("BatteryPressPowerBtnAction", &d_ptr->BatteryPressPowerBtnAction));
}

void __Power::setBatteryPressPowerBtnAction(int value)
{

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

int __Power::batteryScreenBlackDelay()
{
    return qvariant_cast<int>(internalPropGet("BatteryScreenBlackDelay", &d_ptr->BatteryScreenBlackDelay));
}

void __Power::setBatteryScreenBlackDelay(int value)
{

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

int __Power::batteryScreensaverDelay()
{
    return qvariant_cast<int>(internalPropGet("BatteryScreensaverDelay", &d_ptr->BatteryScreensaverDelay));
}

void __Power::setBatteryScreensaverDelay(int value)
{

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

int __Power::batterySleepDelay()
{
    return qvariant_cast<int>(internalPropGet("BatterySleepDelay", &d_ptr->BatterySleepDelay));
}

void __Power::setBatterySleepDelay(int value)
{

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

BatteryStateInfo __Power::batteryState()
{
    return qvariant_cast<BatteryStateInfo>(internalPropGet("BatteryState", &d_ptr->BatteryState));
}

bool __Power::hasAmbientLightSensor()
{
    return qvariant_cast<bool>(internalPropGet("HasAmbientLightSensor", &d_ptr->HasAmbientLightSensor));
}

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

bool __Power::lidClosedSleep()
{
    return qvariant_cast<bool>(internalPropGet("LidClosedSleep", &d_ptr->LidClosedSleep));
}

void __Power::setLidClosedSleep(bool value)
{

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

bool __Power::lidIsPresent()
{
    return qvariant_cast<bool>(internalPropGet("LidIsPresent", &d_ptr->LidIsPresent));
}

int __Power::linePowerLidClosedAction()
{
    return qvariant_cast<int>(internalPropGet("LinePowerLidClosedAction", &d_ptr->LinePowerLidClosedAction));
}

void __Power::setLinePowerLidClosedAction(int value)
{

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

int __Power::linePowerLockDelay()
{
    return qvariant_cast<int>(internalPropGet("LinePowerLockDelay", &d_ptr->LinePowerLockDelay));
}

void __Power::setLinePowerLockDelay(int value)
{

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

int __Power::linePowerPressPowerBtnAction()
{
    return qvariant_cast<int>(internalPropGet("LinePowerPressPowerBtnAction", &d_ptr->LinePowerPressPowerBtnAction));
}

void __Power::setLinePowerPressPowerBtnAction(int value)
{

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

int __Power::linePowerScreenBlackDelay()
{
    return qvariant_cast<int>(internalPropGet("LinePowerScreenBlackDelay", &d_ptr->LinePowerScreenBlackDelay));
}

void __Power::setLinePowerScreenBlackDelay(int value)
{

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

int __Power::linePowerScreensaverDelay()
{
    return qvariant_cast<int>(internalPropGet("LinePowerScreensaverDelay", &d_ptr->LinePowerScreensaverDelay));
}

void __Power::setLinePowerScreensaverDelay(int value)
{

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

int __Power::linePowerSleepDelay()
{
    return qvariant_cast<int>(internalPropGet("LinePowerSleepDelay", &d_ptr->LinePowerSleepDelay));
}

void __Power::setLinePowerSleepDelay(int value)
{

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

int __Power::lowPowerAutoSleepThreshold()
{
    return qvariant_cast<int>(internalPropGet("LowPowerAutoSleepThreshold", &d_ptr->LowPowerAutoSleepThreshold));
}

void __Power::setLowPowerAutoSleepThreshold(int value)
{

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

bool __Power::lowPowerNotifyEnable()
{
    return qvariant_cast<bool>(internalPropGet("LowPowerNotifyEnable", &d_ptr->LowPowerNotifyEnable));
}

void __Power::setLowPowerNotifyEnable(bool value)
{

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

int __Power::lowPowerNotifyThreshold()
{
    return qvariant_cast<int>(internalPropGet("LowPowerNotifyThreshold", &d_ptr->LowPowerNotifyThreshold));
}

void __Power::setLowPowerNotifyThreshold(int value)
{

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

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

bool __Power::screenBlackLock()
{
    return qvariant_cast<bool>(internalPropGet("ScreenBlackLock", &d_ptr->ScreenBlackLock));
}

void __Power::setScreenBlackLock(bool value)
{

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

bool __Power::sleepLock()
{
    return qvariant_cast<bool>(internalPropGet("SleepLock", &d_ptr->SleepLock));
}

void __Power::setSleepLock(bool value)
{

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

uint __Power::warnLevel()
{
    return qvariant_cast<uint>(internalPropGet("WarnLevel", &d_ptr->WarnLevel));
}

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

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