[OpenDocString] kdeconnect-kde (cpp)
remotesystemvolumeplugin.cpp
RemoteSystemVolumePlugin::RemoteSystemVolumePlugin(QObject *parent, const QVariantList &args)
    : KdeConnectPlugin(parent, args)
{
}
Constructs a plugin that wraps a QObject and connects it to its parent object.
RemoteSystemVolumePlugin::~RemoteSystemVolumePlugin()
{
}
This removes the volume plugin from the list of plugins.
bool RemoteSystemVolumePlugin::receivePacket(const NetworkPacket &np)
{
    if (np.has(QStringLiteral("sinkList"))) {
        QJsonDocument document(np.get(QStringLiteral("sinkList")));
        m_sinks = document.toJson();
        Q_EMIT sinksChanged();
    } else {
        QString name = np.get(QStringLiteral("name"));

        if (np.has(QStringLiteral("volume"))) {
            Q_EMIT volumeChanged(name, np.get(QStringLiteral("volume")));
        }

        if (np.has(QStringLiteral("muted"))) {
            Q_EMIT mutedChanged(name, np.get(QStringLiteral("muted")));
        }
    }

    return true;
}
It receives a NetworkPacket object np and emits signals for sinksChanged, volumeChanged and mutedChanged.
void RemoteSystemVolumePlugin::sendVolume(const QString &name, int volume)
{
    NetworkPacket np(PACKET_TYPE_SYSTEMVOLUME_REQUEST);
    np.set(QStringLiteral("name"), name);
    np.set(QStringLiteral("volume"), volume);
    sendPacket(np);
}
This sends a system volume request to the controller.
void RemoteSystemVolumePlugin::sendMuted(const QString &name, bool muted)
{
    NetworkPacket np(PACKET_TYPE_SYSTEMVOLUME_REQUEST);
    np.set(QStringLiteral("name"), name);
    np.set(QStringLiteral("muted"), muted);
    sendPacket(np);
}
This sends a system volume request to the controller.
void RemoteSystemVolumePlugin::connected()
{
    NetworkPacket np(PACKET_TYPE_SYSTEMVOLUME_REQUEST);
    np.set(QStringLiteral("requestSinks"), true);
    sendPacket(np);
}
This sends a network packet that requests sinks from the daemon.
QByteArray RemoteSystemVolumePlugin::sinks()
{
    return m_sinks;
}
Returns the sink list storage as a QByteArray.
QString RemoteSystemVolumePlugin::dbusPath() const
{
    return QStringLiteral("/modules/kdeconnect/devices/") + device()->id() + QStringLiteral("/remotesystemvolume");
}
Returns the dbus path as a QString.