/*
 * This file was generated by qdbusxml2cpp-fix version 0.8
 * Command line was: qdbusxml2cpp-fix -m -c StatusNotifierItem -i api/types/dbustooltip.h -p statusnotifieriteminterface /build/deepin-tray-loader/src/dde-tray-loader/plugins/application-tray/api/dbus/org.kde.StatusNotifierItem.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 "statusnotifieriteminterface.h"

DCORE_USE_NAMESPACE
/*
 * Implementation of interface class __StatusNotifierItem
 */

class __StatusNotifierItemPrivate
{
public:
   __StatusNotifierItemPrivate() = default;

    // begin member variables
    QString AttentionIconName;
    DBusImageList AttentionIconPixmap;
    QString AttentionMovieName;
    QString Category;
    QString IconName;
    DBusImageList IconPixmap;
    QString IconThemePath;
    QString Id;
    bool ItemIsMenu;
    QDBusObjectPath Menu;
    QString OverlayIconName;
    DBusImageList OverlayIconPixmap;
    QString Status;
    QString Title;
    DBusToolTip ToolTip;
    int WindowId;

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

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

    if (QMetaType::fromName("DBusImageList").id() == QMetaType::UnknownType)
        registerDBusImageListMetaType();
    if (QMetaType::fromName("DBusToolTip").id() == QMetaType::UnknownType)
        registerDBusToolTipMetaType();
}

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

void __StatusNotifierItem::onPropertyChanged(const QString &propName, const QVariant &value)
{
    if (propName == QStringLiteral("AttentionIconName"))
    {
        const QString &AttentionIconName = qvariant_cast<QString>(value);
        if (d_ptr->AttentionIconName != AttentionIconName)
        {
            d_ptr->AttentionIconName = AttentionIconName;
            Q_EMIT AttentionIconNameChanged(d_ptr->AttentionIconName);
        }
        return;
    }

    if (propName == QStringLiteral("AttentionIconPixmap"))
    {
        const DBusImageList &AttentionIconPixmap = qvariant_cast<DBusImageList>(value);
        if (d_ptr->AttentionIconPixmap != AttentionIconPixmap)
        {
            d_ptr->AttentionIconPixmap = AttentionIconPixmap;
            Q_EMIT AttentionIconPixmapChanged(d_ptr->AttentionIconPixmap);
        }
        return;
    }

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

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

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

    if (propName == QStringLiteral("IconPixmap"))
    {
        const DBusImageList &IconPixmap = qvariant_cast<DBusImageList>(value);
        if (d_ptr->IconPixmap != IconPixmap)
        {
            d_ptr->IconPixmap = IconPixmap;
            Q_EMIT IconPixmapChanged(d_ptr->IconPixmap);
        }
        return;
    }

    if (propName == QStringLiteral("IconThemePath"))
    {
        const QString &IconThemePath = qvariant_cast<QString>(value);
        if (d_ptr->IconThemePath != IconThemePath)
        {
            d_ptr->IconThemePath = IconThemePath;
            Q_EMIT IconThemePathChanged(d_ptr->IconThemePath);
        }
        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("ItemIsMenu"))
    {
        const bool &ItemIsMenu = qvariant_cast<bool>(value);
        if (d_ptr->ItemIsMenu != ItemIsMenu)
        {
            d_ptr->ItemIsMenu = ItemIsMenu;
            Q_EMIT ItemIsMenuChanged(d_ptr->ItemIsMenu);
        }
        return;
    }

    if (propName == QStringLiteral("Menu"))
    {
        const QDBusObjectPath &Menu = qvariant_cast<QDBusObjectPath>(value);
        if (d_ptr->Menu != Menu)
        {
            d_ptr->Menu = Menu;
            Q_EMIT MenuChanged(d_ptr->Menu);
        }
        return;
    }

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

    if (propName == QStringLiteral("OverlayIconPixmap"))
    {
        const DBusImageList &OverlayIconPixmap = qvariant_cast<DBusImageList>(value);
        if (d_ptr->OverlayIconPixmap != OverlayIconPixmap)
        {
            d_ptr->OverlayIconPixmap = OverlayIconPixmap;
            Q_EMIT OverlayIconPixmapChanged(d_ptr->OverlayIconPixmap);
        }
        return;
    }

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

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

    if (propName == QStringLiteral("ToolTip"))
    {
        const DBusToolTip &ToolTip = qvariant_cast<DBusToolTip>(value);
        if (d_ptr->ToolTip != ToolTip)
        {
            d_ptr->ToolTip = ToolTip;
            Q_EMIT ToolTipChanged(d_ptr->ToolTip);
        }
        return;
    }

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

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

QString __StatusNotifierItem::attentionIconName()
{
    return qvariant_cast<QString>(internalPropGet("AttentionIconName", &d_ptr->AttentionIconName));
}

DBusImageList __StatusNotifierItem::attentionIconPixmap()
{
    return qvariant_cast<DBusImageList>(internalPropGet("AttentionIconPixmap", &d_ptr->AttentionIconPixmap));
}

QString __StatusNotifierItem::attentionMovieName()
{
    return qvariant_cast<QString>(internalPropGet("AttentionMovieName", &d_ptr->AttentionMovieName));
}

QString __StatusNotifierItem::category()
{
    return qvariant_cast<QString>(internalPropGet("Category", &d_ptr->Category));
}

QString __StatusNotifierItem::iconName()
{
    return qvariant_cast<QString>(internalPropGet("IconName", &d_ptr->IconName));
}

DBusImageList __StatusNotifierItem::iconPixmap()
{
    return qvariant_cast<DBusImageList>(internalPropGet("IconPixmap", &d_ptr->IconPixmap));
}

QString __StatusNotifierItem::iconThemePath()
{
    return qvariant_cast<QString>(internalPropGet("IconThemePath", &d_ptr->IconThemePath));
}

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

bool __StatusNotifierItem::itemIsMenu()
{
    return qvariant_cast<bool>(internalPropGet("ItemIsMenu", &d_ptr->ItemIsMenu));
}

QDBusObjectPath __StatusNotifierItem::menu()
{
    return qvariant_cast<QDBusObjectPath>(internalPropGet("Menu", &d_ptr->Menu));
}

QString __StatusNotifierItem::overlayIconName()
{
    return qvariant_cast<QString>(internalPropGet("OverlayIconName", &d_ptr->OverlayIconName));
}

DBusImageList __StatusNotifierItem::overlayIconPixmap()
{
    return qvariant_cast<DBusImageList>(internalPropGet("OverlayIconPixmap", &d_ptr->OverlayIconPixmap));
}

QString __StatusNotifierItem::status()
{
    return qvariant_cast<QString>(internalPropGet("Status", &d_ptr->Status));
}

QString __StatusNotifierItem::title()
{
    return qvariant_cast<QString>(internalPropGet("Title", &d_ptr->Title));
}

DBusToolTip __StatusNotifierItem::toolTip()
{
    return qvariant_cast<DBusToolTip>(internalPropGet("ToolTip", &d_ptr->ToolTip));
}

int __StatusNotifierItem::windowId()
{
    return qvariant_cast<int>(internalPropGet("WindowId", &d_ptr->WindowId));
}

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

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

#include "moc_statusnotifieriteminterface.cpp"
