2019-02-03 00:50:36 +00:00
|
|
|
/**
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-FileCopyrightText: 2018 Jun Bo Bi <jambonmcyeah@gmail.com>
|
2019-02-03 00:50:36 +00:00
|
|
|
*
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
2019-02-03 00:50:36 +00:00
|
|
|
*/
|
|
|
|
|
2023-07-21 19:22:59 +01:00
|
|
|
#pragma once
|
2018-11-20 00:14:17 +00:00
|
|
|
|
|
|
|
#include <QMap>
|
2022-09-10 22:23:52 +01:00
|
|
|
#include <QObject>
|
2018-11-20 00:14:17 +00:00
|
|
|
|
|
|
|
#include <core/kdeconnectplugin.h>
|
|
|
|
|
|
|
|
#include <Windows.h>
|
|
|
|
#include <endpointvolume.h>
|
2022-09-10 22:23:52 +01:00
|
|
|
#include <mmdeviceapi.h>
|
2018-11-20 00:14:17 +00:00
|
|
|
|
2019-04-30 18:09:26 +01:00
|
|
|
#ifdef __MINGW32__
|
|
|
|
#include <initguid.h>
|
|
|
|
#endif
|
|
|
|
|
2018-11-20 00:14:17 +00:00
|
|
|
#define PACKET_TYPE_SYSTEMVOLUME QStringLiteral("kdeconnect.systemvolume")
|
|
|
|
#define PACKET_TYPE_SYSTEMVOLUME_REQUEST QStringLiteral("kdeconnect.systemvolume.request")
|
|
|
|
|
2023-07-22 10:37:35 +01:00
|
|
|
class SystemvolumePlugin : public KdeConnectPlugin
|
2018-11-20 00:14:17 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2022-09-10 22:23:52 +01:00
|
|
|
public:
|
2018-11-20 00:14:17 +00:00
|
|
|
explicit SystemvolumePlugin(QObject *parent, const QVariantList &args);
|
|
|
|
~SystemvolumePlugin();
|
2023-07-31 08:25:45 +01:00
|
|
|
void receivePacket(const NetworkPacket &np) override;
|
2018-11-20 00:14:17 +00:00
|
|
|
void connected() override;
|
|
|
|
|
2022-09-10 22:23:52 +01:00
|
|
|
private:
|
2018-11-20 00:14:17 +00:00
|
|
|
class CMMNotificationClient;
|
|
|
|
class CAudioEndpointVolumeCallback;
|
|
|
|
|
|
|
|
bool valid;
|
2022-09-10 22:23:52 +01:00
|
|
|
IMMDeviceEnumerator *deviceEnumerator;
|
|
|
|
CMMNotificationClient *deviceCallback;
|
2018-11-20 00:14:17 +00:00
|
|
|
QMap<QString, QPair<IAudioEndpointVolume *, CAudioEndpointVolumeCallback *>> sinkList;
|
2020-11-19 19:54:25 +00:00
|
|
|
QMap<QString, QString> idToNameMap;
|
2018-11-20 00:14:17 +00:00
|
|
|
|
|
|
|
bool sendSinkList();
|
2022-09-10 22:23:52 +01:00
|
|
|
HRESULT setDefaultAudioPlaybackDevice(QString &name, bool enabled);
|
2018-11-20 00:14:17 +00:00
|
|
|
};
|