/*
 * This file was generated by qdbusxml2cpp-fix version 0.8
 * Command line was: qdbusxml2cpp-fix -p /build/deepin-session-shell/src/dde-session-shell-snipe/src/global_util/dbus/session2interface /build/deepin-session-shell/src/dde-session-shell-snipe/xml/snipe/org.deepin.dde.Authenticate1.Session2.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-shell/src/dde-session-shell-snipe/src/global_util/dbus/session2interface.h"

DCORE_USE_NAMESPACE
/*
 * Implementation of interface class __OrgDeepinDdeAuthenticate1SessionInterface
 */

class __OrgDeepinDdeAuthenticate1SessionInterfacePrivate
{
public:
   __OrgDeepinDdeAuthenticate1SessionInterfacePrivate() = default;

    // begin member variables
    MFAInfoList FactorsInfo;
    bool IsFuzzyMFA;
    bool IsMFA;
    int PINLen;
    QString Prompt;
    QString Username;

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

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

    if (QMetaType::fromName("ArrayInt").id() == QMetaType::UnknownType)
        registerArrayIntMetaType();
    if (QMetaType::fromName("MFAInfoList").id() == QMetaType::UnknownType)
        registerMFAInfoListMetaType();
}

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

void __OrgDeepinDdeAuthenticate1SessionInterface::onPropertyChanged(const QString &propName, const QVariant &value)
{
    if (propName == QStringLiteral("FactorsInfo"))
    {
        const MFAInfoList &FactorsInfo = qvariant_cast<MFAInfoList>(value);
        if (d_ptr->FactorsInfo != FactorsInfo)
        {
            d_ptr->FactorsInfo = FactorsInfo;
            Q_EMIT FactorsInfoChanged(d_ptr->FactorsInfo);
        }
        return;
    }

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

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

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

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

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

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

MFAInfoList __OrgDeepinDdeAuthenticate1SessionInterface::factorsInfo()
{
    return qvariant_cast<MFAInfoList>(internalPropGet("FactorsInfo", &d_ptr->FactorsInfo));
}

bool __OrgDeepinDdeAuthenticate1SessionInterface::isFuzzyMFA()
{
    return qvariant_cast<bool>(internalPropGet("IsFuzzyMFA", &d_ptr->IsFuzzyMFA));
}

bool __OrgDeepinDdeAuthenticate1SessionInterface::isMFA()
{
    return qvariant_cast<bool>(internalPropGet("IsMFA", &d_ptr->IsMFA));
}

int __OrgDeepinDdeAuthenticate1SessionInterface::pINLen()
{
    return qvariant_cast<int>(internalPropGet("PINLen", &d_ptr->PINLen));
}

QString __OrgDeepinDdeAuthenticate1SessionInterface::prompt()
{
    return qvariant_cast<QString>(internalPropGet("Prompt", &d_ptr->Prompt));
}

QString __OrgDeepinDdeAuthenticate1SessionInterface::username()
{
    return qvariant_cast<QString>(internalPropGet("Username", &d_ptr->Username));
}

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

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