/*
 * This file was generated by qdbusxml2cpp-fix version 0.8
 * Command line was: qdbusxml2cpp-fix -c Login1User -p /build/deepin-session/src/dde-session/dbusinterface/org_freedesktop_login1_User /build/deepin-session/src/dde-session/dbus/interface/org.freedesktop.login1.User.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/src/dde-session/dbusinterface/org_freedesktop_login1_User.h"

DCORE_USE_NAMESPACE
/*
 * Implementation of interface class __Login1User
 */

class __Login1UserPrivate
{
public:
   __Login1UserPrivate() = default;

    // begin member variables
    SessionPath Display;
    uint GID;
    bool IdleHint;
    qulonglong IdleSinceHint;
    qulonglong IdleSinceHintMonotonic;
    bool Linger;
    QString Name;
    QString RuntimePath;
    QString Service;
    SessionPathList Sessions;
    QString Slice;
    QString State;
    qulonglong Timestamp;
    qulonglong TimestampMonotonic;
    uint UID;

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

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

    if (QMetaType::fromName("SessionPath").id() == QMetaType::UnknownType)
        registerSessionPathMetaType();
    if (QMetaType::fromName("SessionPathList").id() == QMetaType::UnknownType)
        registerSessionPathListMetaType();
}

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

void __Login1User::onPropertyChanged(const QString &propName, const QVariant &value)
{
    if (propName == QStringLiteral("Display"))
    {
        const SessionPath &Display = qvariant_cast<SessionPath>(value);
        if (d_ptr->Display != Display)
        {
            d_ptr->Display = Display;
            Q_EMIT DisplayChanged(d_ptr->Display);
        }
        return;
    }

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

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

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

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

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

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

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

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

    if (propName == QStringLiteral("Sessions"))
    {
        const SessionPathList &Sessions = qvariant_cast<SessionPathList>(value);
        if (d_ptr->Sessions != Sessions)
        {
            d_ptr->Sessions = Sessions;
            Q_EMIT SessionsChanged(d_ptr->Sessions);
        }
        return;
    }

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

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

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

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

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

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

SessionPath __Login1User::display()
{
    return qvariant_cast<SessionPath>(internalPropGet("Display", &d_ptr->Display));
}

uint __Login1User::gID()
{
    return qvariant_cast<uint>(internalPropGet("GID", &d_ptr->GID));
}

bool __Login1User::idleHint()
{
    return qvariant_cast<bool>(internalPropGet("IdleHint", &d_ptr->IdleHint));
}

qulonglong __Login1User::idleSinceHint()
{
    return qvariant_cast<qulonglong>(internalPropGet("IdleSinceHint", &d_ptr->IdleSinceHint));
}

qulonglong __Login1User::idleSinceHintMonotonic()
{
    return qvariant_cast<qulonglong>(internalPropGet("IdleSinceHintMonotonic", &d_ptr->IdleSinceHintMonotonic));
}

bool __Login1User::linger()
{
    return qvariant_cast<bool>(internalPropGet("Linger", &d_ptr->Linger));
}

QString __Login1User::name()
{
    return qvariant_cast<QString>(internalPropGet("Name", &d_ptr->Name));
}

QString __Login1User::runtimePath()
{
    return qvariant_cast<QString>(internalPropGet("RuntimePath", &d_ptr->RuntimePath));
}

QString __Login1User::service()
{
    return qvariant_cast<QString>(internalPropGet("Service", &d_ptr->Service));
}

SessionPathList __Login1User::sessions()
{
    return qvariant_cast<SessionPathList>(internalPropGet("Sessions", &d_ptr->Sessions));
}

QString __Login1User::slice()
{
    return qvariant_cast<QString>(internalPropGet("Slice", &d_ptr->Slice));
}

QString __Login1User::state()
{
    return qvariant_cast<QString>(internalPropGet("State", &d_ptr->State));
}

qulonglong __Login1User::timestamp()
{
    return qvariant_cast<qulonglong>(internalPropGet("Timestamp", &d_ptr->Timestamp));
}

qulonglong __Login1User::timestampMonotonic()
{
    return qvariant_cast<qulonglong>(internalPropGet("TimestampMonotonic", &d_ptr->TimestampMonotonic));
}

uint __Login1User::uID()
{
    return qvariant_cast<uint>(internalPropGet("UID", &d_ptr->UID));
}

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

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