/*
 * This file was generated by qdbusxml2cpp-fix version 0.8
 * Command line was: qdbusxml2cpp-fix -m -p audio1sinkinterface /build/deepin-tray-loader/src/dde-tray-loader/plugins/dde-dock/dbus/xml/org.deepin.dde.Audio1.Sink.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 "audio1sinkinterface.h"

DCORE_USE_NAMESPACE
/*
 * Implementation of interface class __OrgDeepinDdeAudio1SinkInterface
 */

class __OrgDeepinDdeAudio1SinkInterfacePrivate
{
public:
   __OrgDeepinDdeAudio1SinkInterfacePrivate() = default;

    // begin member variables
    AudioPort ActivePort;
    double Balance;
    double BaseVolume;
    uint Card;
    QString Description;
    double Fade;
    bool Mute;
    QString Name;
    AudioPortList Ports;
    bool SupportBalance;
    bool SupportFade;
    double Volume;

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

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

    if (QMetaType::fromName("AudioPort").id() == QMetaType::UnknownType)
        registerAudioPortMetaType();
    if (QMetaType::fromName("AudioPortList").id() == QMetaType::UnknownType)
        registerAudioPortListMetaType();
}

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

void __OrgDeepinDdeAudio1SinkInterface::onPropertyChanged(const QString &propName, const QVariant &value)
{
    if (propName == QStringLiteral("ActivePort"))
    {
        const AudioPort &ActivePort = qvariant_cast<AudioPort>(value);
        if (d_ptr->ActivePort != ActivePort)
        {
            d_ptr->ActivePort = ActivePort;
            Q_EMIT ActivePortChanged(d_ptr->ActivePort);
        }
        return;
    }

    if (propName == QStringLiteral("Balance"))
    {
        const double &Balance = qvariant_cast<double>(value);
        if (d_ptr->Balance != Balance)
        {
            d_ptr->Balance = Balance;
            Q_EMIT BalanceChanged(d_ptr->Balance);
        }
        return;
    }

    if (propName == QStringLiteral("BaseVolume"))
    {
        const double &BaseVolume = qvariant_cast<double>(value);
        if (d_ptr->BaseVolume != BaseVolume)
        {
            d_ptr->BaseVolume = BaseVolume;
            Q_EMIT BaseVolumeChanged(d_ptr->BaseVolume);
        }
        return;
    }

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

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

    if (propName == QStringLiteral("Fade"))
    {
        const double &Fade = qvariant_cast<double>(value);
        if (d_ptr->Fade != Fade)
        {
            d_ptr->Fade = Fade;
            Q_EMIT FadeChanged(d_ptr->Fade);
        }
        return;
    }

    if (propName == QStringLiteral("Mute"))
    {
        const bool &Mute = qvariant_cast<bool>(value);
        if (d_ptr->Mute != Mute)
        {
            d_ptr->Mute = Mute;
            Q_EMIT MuteChanged(d_ptr->Mute);
        }
        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("Ports"))
    {
        const AudioPortList &Ports = qvariant_cast<AudioPortList>(value);
        if (d_ptr->Ports != Ports)
        {
            d_ptr->Ports = Ports;
            Q_EMIT PortsChanged(d_ptr->Ports);
        }
        return;
    }

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

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

    if (propName == QStringLiteral("Volume"))
    {
        const double &Volume = qvariant_cast<double>(value);
        if (d_ptr->Volume != Volume)
        {
            d_ptr->Volume = Volume;
            Q_EMIT VolumeChanged(d_ptr->Volume);
        }
        return;
    }

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

AudioPort __OrgDeepinDdeAudio1SinkInterface::activePort()
{
    return qvariant_cast<AudioPort>(internalPropGet("ActivePort", &d_ptr->ActivePort));
}

double __OrgDeepinDdeAudio1SinkInterface::balance()
{
    return qvariant_cast<double>(internalPropGet("Balance", &d_ptr->Balance));
}

double __OrgDeepinDdeAudio1SinkInterface::baseVolume()
{
    return qvariant_cast<double>(internalPropGet("BaseVolume", &d_ptr->BaseVolume));
}

uint __OrgDeepinDdeAudio1SinkInterface::card()
{
    return qvariant_cast<uint>(internalPropGet("Card", &d_ptr->Card));
}

QString __OrgDeepinDdeAudio1SinkInterface::description()
{
    return qvariant_cast<QString>(internalPropGet("Description", &d_ptr->Description));
}

double __OrgDeepinDdeAudio1SinkInterface::fade()
{
    return qvariant_cast<double>(internalPropGet("Fade", &d_ptr->Fade));
}

bool __OrgDeepinDdeAudio1SinkInterface::mute()
{
    return qvariant_cast<bool>(internalPropGet("Mute", &d_ptr->Mute));
}

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

AudioPortList __OrgDeepinDdeAudio1SinkInterface::ports()
{
    return qvariant_cast<AudioPortList>(internalPropGet("Ports", &d_ptr->Ports));
}

bool __OrgDeepinDdeAudio1SinkInterface::supportBalance()
{
    return qvariant_cast<bool>(internalPropGet("SupportBalance", &d_ptr->SupportBalance));
}

bool __OrgDeepinDdeAudio1SinkInterface::supportFade()
{
    return qvariant_cast<bool>(internalPropGet("SupportFade", &d_ptr->SupportFade));
}

double __OrgDeepinDdeAudio1SinkInterface::volume()
{
    return qvariant_cast<double>(internalPropGet("Volume", &d_ptr->Volume));
}

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

void __OrgDeepinDdeAudio1SinkInterface::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_audio1sinkinterface.cpp"
