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

/*
 * Implementation of interface class __SystemInfo
 */

class __SystemInfoPrivate
{
public:
   __SystemInfoPrivate() = default;

    // begin member variables
    qulonglong DiskCap;
    QString DistroDesc;
    QString DistroID;
    QString DistroVer;
    qulonglong MemoryCap;
    QString Processor;
    qlonglong SystemType;
    QString Version;

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

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

}

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

void __SystemInfo::onPropertyChanged(const QString &propName, const QVariant &value)
{
    if (propName == QStringLiteral("DiskCap"))
    {
        const qulonglong &DiskCap = qvariant_cast<qulonglong>(value);
        if (d_ptr->DiskCap != DiskCap)
        {
            d_ptr->DiskCap = DiskCap;
            Q_EMIT DiskCapChanged(d_ptr->DiskCap);
        }
        return;
    }

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

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

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

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

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

    if (propName == QStringLiteral("SystemType"))
    {
        const qlonglong &SystemType = qvariant_cast<qlonglong>(value);
        if (d_ptr->SystemType != SystemType)
        {
            d_ptr->SystemType = SystemType;
            Q_EMIT SystemTypeChanged(d_ptr->SystemType);
        }
        return;
    }

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

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

qulonglong __SystemInfo::diskCap()
{
    return qvariant_cast<qulonglong>(internalPropGet("DiskCap", &d_ptr->DiskCap));
}

QString __SystemInfo::distroDesc()
{
    return qvariant_cast<QString>(internalPropGet("DistroDesc", &d_ptr->DistroDesc));
}

QString __SystemInfo::distroID()
{
    return qvariant_cast<QString>(internalPropGet("DistroID", &d_ptr->DistroID));
}

QString __SystemInfo::distroVer()
{
    return qvariant_cast<QString>(internalPropGet("DistroVer", &d_ptr->DistroVer));
}

qulonglong __SystemInfo::memoryCap()
{
    return qvariant_cast<qulonglong>(internalPropGet("MemoryCap", &d_ptr->MemoryCap));
}

QString __SystemInfo::processor()
{
    return qvariant_cast<QString>(internalPropGet("Processor", &d_ptr->Processor));
}

qlonglong __SystemInfo::systemType()
{
    return qvariant_cast<qlonglong>(internalPropGet("SystemType", &d_ptr->SystemType));
}

QString __SystemInfo::version()
{
    return qvariant_cast<QString>(internalPropGet("Version", &d_ptr->Version));
}

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

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