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

DCORE_USE_NAMESPACE
/*
 * Implementation of interface class __Audio1
 */

class __Audio1Private
{
public:
   __Audio1Private() = default;

    // begin member variables
    QString BluetoothAudioMode;
    QStringList BluetoothAudioModeOpts;
    QString Cards;
    QString CardsWithoutUnavailable;
    QDBusObjectPath DefaultSink;
    QDBusObjectPath DefaultSource;
    bool IncreaseVolume;
    double MaxUIVolume;
    bool ReduceNoise;
    QList<QDBusObjectPath> SinkInputs;
    QList<QDBusObjectPath> Sinks;
    QList<QDBusObjectPath> Sources;

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

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

}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

QString __Audio1::bluetoothAudioMode()
{
    return qvariant_cast<QString>(internalPropGet("BluetoothAudioMode", &d_ptr->BluetoothAudioMode));
}

QStringList __Audio1::bluetoothAudioModeOpts()
{
    return qvariant_cast<QStringList>(internalPropGet("BluetoothAudioModeOpts", &d_ptr->BluetoothAudioModeOpts));
}

QString __Audio1::cards()
{
    return qvariant_cast<QString>(internalPropGet("Cards", &d_ptr->Cards));
}

QString __Audio1::cardsWithoutUnavailable()
{
    return qvariant_cast<QString>(internalPropGet("CardsWithoutUnavailable", &d_ptr->CardsWithoutUnavailable));
}

QDBusObjectPath __Audio1::defaultSink()
{
    return qvariant_cast<QDBusObjectPath>(internalPropGet("DefaultSink", &d_ptr->DefaultSink));
}

QDBusObjectPath __Audio1::defaultSource()
{
    return qvariant_cast<QDBusObjectPath>(internalPropGet("DefaultSource", &d_ptr->DefaultSource));
}

bool __Audio1::increaseVolume()
{
    return qvariant_cast<bool>(internalPropGet("IncreaseVolume", &d_ptr->IncreaseVolume));
}

void __Audio1::setIncreaseVolume(bool value)
{

   internalPropSet("IncreaseVolume", QVariant::fromValue(value), &d_ptr->IncreaseVolume);
}

double __Audio1::maxUIVolume()
{
    return qvariant_cast<double>(internalPropGet("MaxUIVolume", &d_ptr->MaxUIVolume));
}

bool __Audio1::reduceNoise()
{
    return qvariant_cast<bool>(internalPropGet("ReduceNoise", &d_ptr->ReduceNoise));
}

void __Audio1::setReduceNoise(bool value)
{

   internalPropSet("ReduceNoise", QVariant::fromValue(value), &d_ptr->ReduceNoise);
}

QList<QDBusObjectPath> __Audio1::sinkInputs()
{
    return qvariant_cast<QList<QDBusObjectPath>>(internalPropGet("SinkInputs", &d_ptr->SinkInputs));
}

QList<QDBusObjectPath> __Audio1::sinks()
{
    return qvariant_cast<QList<QDBusObjectPath>>(internalPropGet("Sinks", &d_ptr->Sinks));
}

QList<QDBusObjectPath> __Audio1::sources()
{
    return qvariant_cast<QList<QDBusObjectPath>>(internalPropGet("Sources", &d_ptr->Sources));
}

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

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