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

DCORE_USE_NAMESPACE
/*
 * Implementation of interface class __OrgDeepinDdeAirplaneMode1Interface
 */

class __OrgDeepinDdeAirplaneMode1InterfacePrivate
{
public:
   __OrgDeepinDdeAirplaneMode1InterfacePrivate() = default;

    // begin member variables
    bool BluetoothEnabled;
    bool Enabled;
    bool WifiEnabled;

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

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

}

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

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

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

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

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

bool __OrgDeepinDdeAirplaneMode1Interface::bluetoothEnabled()
{
    return qvariant_cast<bool>(internalPropGet("BluetoothEnabled", &d_ptr->BluetoothEnabled));
}

bool __OrgDeepinDdeAirplaneMode1Interface::enabled()
{
    return qvariant_cast<bool>(internalPropGet("Enabled", &d_ptr->Enabled));
}

bool __OrgDeepinDdeAirplaneMode1Interface::wifiEnabled()
{
    return qvariant_cast<bool>(internalPropGet("WifiEnabled", &d_ptr->WifiEnabled));
}

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

void __OrgDeepinDdeAirplaneMode1Interface::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_airplanemode1interface.cpp"
