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

DCORE_USE_NAMESPACE
/*
 * Implementation of interface class __Login1Session
 */

class __Login1SessionPrivate
{
public:
   __Login1SessionPrivate() = default;

    // begin member variables
    bool Active;
    uint Audit;
    QString Desktop;
    QString Display;
    QString Id;
    bool IdleHint;
    qulonglong IdleSinceHint;
    qulonglong IdleSinceHintMonotonic;
    uint Leader;
    bool LockedHint;
    QString Name;
    bool Remote;
    QString RemoteHost;
    QString RemoteUser;
    QString Scope;
    QString Service;
    QString State;
    QString TTY;
    qulonglong Timestamp;
    qulonglong TimestampMonotonic;
    QString Type;
    uint VTNr;

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

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

}

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

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

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

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

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

    if (propName == QStringLiteral("Id"))
    {
        const QString &Id = qvariant_cast<QString>(value);
        if (d_ptr->Id != Id)
        {
            d_ptr->Id = Id;
            Q_EMIT IdChanged(d_ptr->Id);
        }
        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("Leader"))
    {
        const uint &Leader = qvariant_cast<uint>(value);
        if (d_ptr->Leader != Leader)
        {
            d_ptr->Leader = Leader;
            Q_EMIT LeaderChanged(d_ptr->Leader);
        }
        return;
    }

    if (propName == QStringLiteral("LockedHint"))
    {
        const bool &LockedHint = qvariant_cast<bool>(value);
        if (d_ptr->LockedHint != LockedHint)
        {
            d_ptr->LockedHint = LockedHint;
            Q_EMIT LockedHintChanged(d_ptr->LockedHint);
        }
        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("Remote"))
    {
        const bool &Remote = qvariant_cast<bool>(value);
        if (d_ptr->Remote != Remote)
        {
            d_ptr->Remote = Remote;
            Q_EMIT RemoteChanged(d_ptr->Remote);
        }
        return;
    }

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

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

    if (propName == QStringLiteral("Scope"))
    {
        const QString &Scope = qvariant_cast<QString>(value);
        if (d_ptr->Scope != Scope)
        {
            d_ptr->Scope = Scope;
            Q_EMIT ScopeChanged(d_ptr->Scope);
        }
        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("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("TTY"))
    {
        const QString &TTY = qvariant_cast<QString>(value);
        if (d_ptr->TTY != TTY)
        {
            d_ptr->TTY = TTY;
            Q_EMIT TTYChanged(d_ptr->TTY);
        }
        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("Type"))
    {
        const QString &Type = qvariant_cast<QString>(value);
        if (d_ptr->Type != Type)
        {
            d_ptr->Type = Type;
            Q_EMIT TypeChanged(d_ptr->Type);
        }
        return;
    }

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

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

bool __Login1Session::active()
{
    return qvariant_cast<bool>(internalPropGet("Active", &d_ptr->Active));
}

uint __Login1Session::audit()
{
    return qvariant_cast<uint>(internalPropGet("Audit", &d_ptr->Audit));
}

QString __Login1Session::desktop()
{
    return qvariant_cast<QString>(internalPropGet("Desktop", &d_ptr->Desktop));
}

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

QString __Login1Session::id()
{
    return qvariant_cast<QString>(internalPropGet("Id", &d_ptr->Id));
}

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

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

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

uint __Login1Session::leader()
{
    return qvariant_cast<uint>(internalPropGet("Leader", &d_ptr->Leader));
}

bool __Login1Session::lockedHint()
{
    return qvariant_cast<bool>(internalPropGet("LockedHint", &d_ptr->LockedHint));
}

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

bool __Login1Session::remote()
{
    return qvariant_cast<bool>(internalPropGet("Remote", &d_ptr->Remote));
}

QString __Login1Session::remoteHost()
{
    return qvariant_cast<QString>(internalPropGet("RemoteHost", &d_ptr->RemoteHost));
}

QString __Login1Session::remoteUser()
{
    return qvariant_cast<QString>(internalPropGet("RemoteUser", &d_ptr->RemoteUser));
}

QString __Login1Session::scope()
{
    return qvariant_cast<QString>(internalPropGet("Scope", &d_ptr->Scope));
}

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

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

QString __Login1Session::tTY()
{
    return qvariant_cast<QString>(internalPropGet("TTY", &d_ptr->TTY));
}

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

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

QString __Login1Session::type()
{
    return qvariant_cast<QString>(internalPropGet("Type", &d_ptr->Type));
}

uint __Login1Session::vTNr()
{
    return qvariant_cast<uint>(internalPropGet("VTNr", &d_ptr->VTNr));
}

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

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