/*
 * 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/accounts1interface /build/deepin-session-shell/src/dde-session-shell-snipe/xml/org.deepin.dde.Accounts1.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/accounts1interface.h"

DCORE_USE_NAMESPACE
/*
 * Implementation of interface class __OrgDeepinDdeAccounts1Interface
 */

class __OrgDeepinDdeAccounts1InterfacePrivate
{
public:
   __OrgDeepinDdeAccounts1InterfacePrivate() = default;

    // begin member variables
    bool AllowGuest;
    QString GuestIcon;
    QStringList UserList;

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

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

}

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

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

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

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

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

bool __OrgDeepinDdeAccounts1Interface::allowGuest()
{
    return qvariant_cast<bool>(internalPropGet("AllowGuest", &d_ptr->AllowGuest));
}

QString __OrgDeepinDdeAccounts1Interface::guestIcon()
{
    return qvariant_cast<QString>(internalPropGet("GuestIcon", &d_ptr->GuestIcon));
}

QStringList __OrgDeepinDdeAccounts1Interface::userList()
{
    return qvariant_cast<QStringList>(internalPropGet("UserList", &d_ptr->UserList));
}

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

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