mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
add sound dbus interface
Change-Id: I2d880a89495225d21ef47672af54345fccea1066
This commit is contained in:
parent
0acfa37a67
commit
4dfbfaad7d
Notes:
Deepin Code Review
2016-08-02 07:19:04 +00:00
Verified+1: Anonymous Coward #1000004 Code-Review+2: 石博文 <sbw@sbw.so> Submitted-by: 石博文 <sbw@sbw.so> Submitted-at: Tue, 02 Aug 2016 07:19:04 +0000 Reviewed-on: https://cr.deepin.io/14854 Project: dde/dde-dock Branch: refs/heads/master
33
plugins/sound/dbus/com.deepin.daemon.Audio.Sink.xml
Normal file
33
plugins/sound/dbus/com.deepin.daemon.Audio.Sink.xml
Normal file
@ -0,0 +1,33 @@
|
||||
<interface name="com.deepin.daemon.Audio.Sink">
|
||||
<method name="GetMeter">
|
||||
<arg type="o" direction="out"></arg>
|
||||
</method>
|
||||
<method name="SetBalance">
|
||||
<arg type="d" direction="in"></arg>
|
||||
<arg type="b" direction="in"></arg>
|
||||
</method>
|
||||
<method name="SetFade">
|
||||
<arg type="d" direction="in"></arg>
|
||||
</method>
|
||||
<method name="SetMute">
|
||||
<arg type="b" direction="in"></arg>
|
||||
</method>
|
||||
<method name="SetPort">
|
||||
<arg type="s" direction="in"></arg>
|
||||
</method>
|
||||
<method name="SetVolume">
|
||||
<arg type="d" direction="in"></arg>
|
||||
<arg type="b" direction="in"></arg>
|
||||
</method>
|
||||
<property name="Name" type="s" access="read"></property>
|
||||
<property name="Description" type="s" access="read"></property>
|
||||
<property name="BaseVolume" type="d" access="read"></property>
|
||||
<property name="Mute" type="b" access="read"></property>
|
||||
<property name="Volume" type="d" access="read"></property>
|
||||
<property name="Balance" type="d" access="read"></property>
|
||||
<property name="SupportBalance" type="b" access="read"></property>
|
||||
<property name="Fade" type="d" access="read"></property>
|
||||
<property name="SupportFade" type="b" access="read"></property>
|
||||
<!--property name="Ports" type="a(ssy)" access="read"></property>
|
||||
<property name="ActivePort" type="(ssy)" access="read"></property-->
|
||||
</interface>
|
26
plugins/sound/dbus/com.deepin.daemon.Audio.xml
Normal file
26
plugins/sound/dbus/com.deepin.daemon.Audio.xml
Normal file
@ -0,0 +1,26 @@
|
||||
<interface name="com.deepin.daemon.Audio">
|
||||
<method name="GetDefaultSink">
|
||||
<arg type="o" direction="out"></arg>
|
||||
</method>
|
||||
<method name="GetDefaultSource">
|
||||
<arg type="o" direction="out"></arg>
|
||||
</method>
|
||||
<method name="Reset"></method>
|
||||
<method name="SetDefaultSink">
|
||||
<arg type="s" direction="in"></arg>
|
||||
</method>
|
||||
<method name="SetDefaultSource">
|
||||
<arg type="s" direction="in"></arg>
|
||||
</method>
|
||||
<method name="SetProfile">
|
||||
<arg type="u" direction="in"></arg>
|
||||
<arg type="s" direction="in"></arg>
|
||||
</method>
|
||||
<property name="Sinks" type="ao" access="read"></property>
|
||||
<property name="Sources" type="ao" access="read"></property>
|
||||
<property name="SinkInputs" type="ao" access="read"></property>
|
||||
<property name="Cards" type="s" access="read"></property>
|
||||
<property name="DefaultSink" type="s" access="read"></property>
|
||||
<property name="DefaultSource" type="s" access="read"></property>
|
||||
<property name="MaxUIVolume" type="d" access="read"></property>
|
||||
</interface>
|
28
plugins/sound/dbus/dbusaudio.cpp
Normal file
28
plugins/sound/dbus/dbusaudio.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* This file was generated by qdbusxml2cpp version 0.8
|
||||
* Command line was: qdbusxml2cpp -c DBusAudio -p dbusaudio com.deepin.daemon.Audio.xml
|
||||
*
|
||||
* qdbusxml2cpp is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
|
||||
*
|
||||
* This is an auto-generated file.
|
||||
* This file may have been hand-edited. Look for HAND-EDIT comments
|
||||
* before re-generating it.
|
||||
*/
|
||||
|
||||
#include "dbusaudio.h"
|
||||
|
||||
/*
|
||||
* Implementation of interface class DBusAudio
|
||||
*/
|
||||
|
||||
DBusAudio::DBusAudio(QObject *parent)
|
||||
: QDBusAbstractInterface("com.deepin.daemon.Audio", "/com/deepin/daemon/Audio", staticInterfaceName(), QDBusConnection::sessionBus(), parent)
|
||||
{
|
||||
QDBusConnection::sessionBus().connect(this->service(), this->path(), "org.freedesktop.DBus.Properties", "PropertiesChanged","sa{sv}as", this, SLOT(__propertyChanged__(QDBusMessage)));
|
||||
}
|
||||
|
||||
DBusAudio::~DBusAudio()
|
||||
{
|
||||
QDBusConnection::sessionBus().disconnect(service(), path(), "org.freedesktop.DBus.Properties", "PropertiesChanged", "sa{sv}as", this, SLOT(propertyChanged(QDBusMessage)));
|
||||
}
|
||||
|
144
plugins/sound/dbus/dbusaudio.h
Normal file
144
plugins/sound/dbus/dbusaudio.h
Normal file
@ -0,0 +1,144 @@
|
||||
/*
|
||||
* This file was generated by qdbusxml2cpp version 0.8
|
||||
* Command line was: qdbusxml2cpp -c DBusAudio -p dbusaudio com.deepin.daemon.Audio.xml
|
||||
*
|
||||
* qdbusxml2cpp is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
|
||||
*
|
||||
* This is an auto-generated file.
|
||||
* Do not edit! All changes made to it will be lost.
|
||||
*/
|
||||
|
||||
#ifndef DBUSAUDIO_H_1470120815
|
||||
#define DBUSAUDIO_H_1470120815
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtDBus/QtDBus>
|
||||
|
||||
/*
|
||||
* Proxy class for interface com.deepin.daemon.Audio
|
||||
*/
|
||||
class DBusAudio: public QDBusAbstractInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_SLOT void __propertyChanged__(const QDBusMessage& msg)
|
||||
{
|
||||
QList<QVariant> arguments = msg.arguments();
|
||||
if (3 != arguments.count())
|
||||
return;
|
||||
QString interfaceName = msg.arguments().at(0).toString();
|
||||
if (interfaceName !="com.deepin.daemon.Audio")
|
||||
return;
|
||||
QVariantMap changedProps = qdbus_cast<QVariantMap>(arguments.at(1).value<QDBusArgument>());
|
||||
foreach(const QString &prop, changedProps.keys()) {
|
||||
const QMetaObject* self = metaObject();
|
||||
for (int i=self->propertyOffset(); i < self->propertyCount(); ++i) {
|
||||
QMetaProperty p = self->property(i);
|
||||
if (p.name() == prop) {
|
||||
Q_EMIT p.notifySignal().invoke(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public:
|
||||
static inline const char *staticInterfaceName()
|
||||
{ return "com.deepin.daemon.Audio"; }
|
||||
|
||||
public:
|
||||
explicit DBusAudio(QObject *parent = 0);
|
||||
|
||||
~DBusAudio();
|
||||
|
||||
Q_PROPERTY(QString Cards READ cards NOTIFY CardsChanged)
|
||||
inline QString cards() const
|
||||
{ return qvariant_cast< QString >(property("Cards")); }
|
||||
|
||||
Q_PROPERTY(QString DefaultSink READ defaultSink NOTIFY DefaultSinkChanged)
|
||||
inline QString defaultSink() const
|
||||
{ return qvariant_cast< QString >(property("DefaultSink")); }
|
||||
|
||||
Q_PROPERTY(QString DefaultSource READ defaultSource NOTIFY DefaultSourceChanged)
|
||||
inline QString defaultSource() const
|
||||
{ return qvariant_cast< QString >(property("DefaultSource")); }
|
||||
|
||||
Q_PROPERTY(double MaxUIVolume READ maxUIVolume NOTIFY MaxUIVolumeChanged)
|
||||
inline double maxUIVolume() const
|
||||
{ return qvariant_cast< double >(property("MaxUIVolume")); }
|
||||
|
||||
Q_PROPERTY(QList<QDBusObjectPath> SinkInputs READ sinkInputs NOTIFY SinkInputsChanged)
|
||||
inline QList<QDBusObjectPath> sinkInputs() const
|
||||
{ return qvariant_cast< QList<QDBusObjectPath> >(property("SinkInputs")); }
|
||||
|
||||
Q_PROPERTY(QList<QDBusObjectPath> Sinks READ sinks NOTIFY SinksChanged)
|
||||
inline QList<QDBusObjectPath> sinks() const
|
||||
{ return qvariant_cast< QList<QDBusObjectPath> >(property("Sinks")); }
|
||||
|
||||
Q_PROPERTY(QList<QDBusObjectPath> Sources READ sources NOTIFY SourcesChanged)
|
||||
inline QList<QDBusObjectPath> sources() const
|
||||
{ return qvariant_cast< QList<QDBusObjectPath> >(property("Sources")); }
|
||||
|
||||
public Q_SLOTS: // METHODS
|
||||
inline QDBusPendingReply<QDBusObjectPath> GetDefaultSink()
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
return asyncCallWithArgumentList(QStringLiteral("GetDefaultSink"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<QDBusObjectPath> GetDefaultSource()
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
return asyncCallWithArgumentList(QStringLiteral("GetDefaultSource"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> Reset()
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
return asyncCallWithArgumentList(QStringLiteral("Reset"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> SetDefaultSink(const QString &in0)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(in0);
|
||||
return asyncCallWithArgumentList(QStringLiteral("SetDefaultSink"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> SetDefaultSource(const QString &in0)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(in0);
|
||||
return asyncCallWithArgumentList(QStringLiteral("SetDefaultSource"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> SetProfile(uint in0, const QString &in1)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1);
|
||||
return asyncCallWithArgumentList(QStringLiteral("SetProfile"), argumentList);
|
||||
}
|
||||
|
||||
Q_SIGNALS: // SIGNALS
|
||||
// begin property changed signals
|
||||
void CardsChanged();
|
||||
void DefaultSinkChanged();
|
||||
void DefaultSourceChanged();
|
||||
void MaxUIVolumeChanged();
|
||||
void SinkInputsChanged();
|
||||
void SinksChanged();
|
||||
void SourcesChanged();
|
||||
};
|
||||
|
||||
namespace com {
|
||||
namespace deepin {
|
||||
namespace daemon {
|
||||
typedef ::DBusAudio DBusAudio;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
28
plugins/sound/dbus/dbussink.cpp
Normal file
28
plugins/sound/dbus/dbussink.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* This file was generated by qdbusxml2cpp version 0.8
|
||||
* Command line was: qdbusxml2cpp -c DBusSink -p dbussink com.deepin.daemon.Audio.Sink.xml
|
||||
*
|
||||
* qdbusxml2cpp is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
|
||||
*
|
||||
* This is an auto-generated file.
|
||||
* This file may have been hand-edited. Look for HAND-EDIT comments
|
||||
* before re-generating it.
|
||||
*/
|
||||
|
||||
#include "dbussink.h"
|
||||
|
||||
/*
|
||||
* Implementation of interface class DBusSink
|
||||
*/
|
||||
|
||||
DBusSink::DBusSink(const QString &path, QObject *parent)
|
||||
: QDBusAbstractInterface("com.deepin.daemon.Audio", path, staticInterfaceName(), QDBusConnection::sessionBus(), parent)
|
||||
{
|
||||
QDBusConnection::sessionBus().connect(this->service(), this->path(), "org.freedesktop.DBus.Properties", "PropertiesChanged","sa{sv}as", this, SLOT(__propertyChanged__(QDBusMessage)));
|
||||
}
|
||||
|
||||
DBusSink::~DBusSink()
|
||||
{
|
||||
QDBusConnection::sessionBus().disconnect(service(), path(), "org.freedesktop.DBus.Properties", "PropertiesChanged", "sa{sv}as", this, SLOT(propertyChanged(QDBusMessage)));
|
||||
}
|
||||
|
158
plugins/sound/dbus/dbussink.h
Normal file
158
plugins/sound/dbus/dbussink.h
Normal file
@ -0,0 +1,158 @@
|
||||
/*
|
||||
* This file was generated by qdbusxml2cpp version 0.8
|
||||
* Command line was: qdbusxml2cpp -c DBusSink -p dbussink com.deepin.daemon.Audio.Sink.xml
|
||||
*
|
||||
* qdbusxml2cpp is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
|
||||
*
|
||||
* This is an auto-generated file.
|
||||
* Do not edit! All changes made to it will be lost.
|
||||
*/
|
||||
|
||||
#ifndef DBUSSINK_H_1470121396
|
||||
#define DBUSSINK_H_1470121396
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtDBus/QtDBus>
|
||||
|
||||
/*
|
||||
* Proxy class for interface com.deepin.daemon.Audio.Sink
|
||||
*/
|
||||
class DBusSink: public QDBusAbstractInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_SLOT void __propertyChanged__(const QDBusMessage& msg)
|
||||
{
|
||||
QList<QVariant> arguments = msg.arguments();
|
||||
if (3 != arguments.count())
|
||||
return;
|
||||
QString interfaceName = msg.arguments().at(0).toString();
|
||||
if (interfaceName !="com.deepin.daemon.Audio.Sink")
|
||||
return;
|
||||
QVariantMap changedProps = qdbus_cast<QVariantMap>(arguments.at(1).value<QDBusArgument>());
|
||||
foreach(const QString &prop, changedProps.keys()) {
|
||||
const QMetaObject* self = metaObject();
|
||||
for (int i=self->propertyOffset(); i < self->propertyCount(); ++i) {
|
||||
QMetaProperty p = self->property(i);
|
||||
if (p.name() == prop) {
|
||||
Q_EMIT p.notifySignal().invoke(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public:
|
||||
static inline const char *staticInterfaceName()
|
||||
{ return "com.deepin.daemon.Audio.Sink"; }
|
||||
|
||||
public:
|
||||
explicit DBusSink(const QString &path, QObject *parent = 0);
|
||||
|
||||
~DBusSink();
|
||||
|
||||
Q_PROPERTY(double Balance READ balance NOTIFY BalanceChanged)
|
||||
inline double balance() const
|
||||
{ return qvariant_cast< double >(property("Balance")); }
|
||||
|
||||
Q_PROPERTY(double BaseVolume READ baseVolume NOTIFY BaseVolumeChanged)
|
||||
inline double baseVolume() const
|
||||
{ return qvariant_cast< double >(property("BaseVolume")); }
|
||||
|
||||
Q_PROPERTY(QString Description READ description NOTIFY DescriptionChanged)
|
||||
inline QString description() const
|
||||
{ return qvariant_cast< QString >(property("Description")); }
|
||||
|
||||
Q_PROPERTY(double Fade READ fade NOTIFY FadeChanged)
|
||||
inline double fade() const
|
||||
{ return qvariant_cast< double >(property("Fade")); }
|
||||
|
||||
Q_PROPERTY(bool Mute READ mute NOTIFY MuteChanged)
|
||||
inline bool mute() const
|
||||
{ return qvariant_cast< bool >(property("Mute")); }
|
||||
|
||||
Q_PROPERTY(QString Name READ name NOTIFY NameChanged)
|
||||
inline QString name() const
|
||||
{ return qvariant_cast< QString >(property("Name")); }
|
||||
|
||||
Q_PROPERTY(bool SupportBalance READ supportBalance NOTIFY SupportBalanceChanged)
|
||||
inline bool supportBalance() const
|
||||
{ return qvariant_cast< bool >(property("SupportBalance")); }
|
||||
|
||||
Q_PROPERTY(bool SupportFade READ supportFade NOTIFY SupportFadeChanged)
|
||||
inline bool supportFade() const
|
||||
{ return qvariant_cast< bool >(property("SupportFade")); }
|
||||
|
||||
Q_PROPERTY(double Volume READ volume NOTIFY VolumeChanged)
|
||||
inline double volume() const
|
||||
{ return qvariant_cast< double >(property("Volume")); }
|
||||
|
||||
public Q_SLOTS: // METHODS
|
||||
inline QDBusPendingReply<QDBusObjectPath> GetMeter()
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
return asyncCallWithArgumentList(QStringLiteral("GetMeter"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> SetBalance(double in0, bool in1)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1);
|
||||
return asyncCallWithArgumentList(QStringLiteral("SetBalance"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> SetFade(double in0)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(in0);
|
||||
return asyncCallWithArgumentList(QStringLiteral("SetFade"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> SetMute(bool in0)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(in0);
|
||||
return asyncCallWithArgumentList(QStringLiteral("SetMute"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> SetPort(const QString &in0)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(in0);
|
||||
return asyncCallWithArgumentList(QStringLiteral("SetPort"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> SetVolume(double in0, bool in1)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1);
|
||||
return asyncCallWithArgumentList(QStringLiteral("SetVolume"), argumentList);
|
||||
}
|
||||
|
||||
Q_SIGNALS: // SIGNALS
|
||||
// begin property changed signals
|
||||
void BalanceChanged();
|
||||
void BaseVolumeChanged();
|
||||
void DescriptionChanged();
|
||||
void FadeChanged();
|
||||
void MuteChanged();
|
||||
void NameChanged();
|
||||
void SupportBalanceChanged();
|
||||
void SupportFadeChanged();
|
||||
void VolumeChanged();
|
||||
};
|
||||
|
||||
namespace com {
|
||||
namespace deepin {
|
||||
namespace daemon {
|
||||
namespace Audio {
|
||||
typedef ::DBusSink Sink;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@ -13,12 +13,16 @@ DISTFILES += sound.json
|
||||
HEADERS += \
|
||||
soundplugin.h \
|
||||
sounditem.h \
|
||||
soundapplet.h
|
||||
soundapplet.h \
|
||||
dbus/dbusaudio.h \
|
||||
dbus/dbussink.h
|
||||
|
||||
SOURCES += \
|
||||
soundplugin.cpp \
|
||||
sounditem.cpp \
|
||||
soundapplet.cpp
|
||||
soundapplet.cpp \
|
||||
dbus/dbusaudio.cpp \
|
||||
dbus/dbussink.cpp
|
||||
|
||||
target.path = $${PREFIX}/lib/dde-dock/plugins/
|
||||
INSTALLS += target
|
||||
|
@ -5,7 +5,9 @@
|
||||
SoundApplet::SoundApplet(QWidget *parent)
|
||||
: QScrollArea(parent),
|
||||
|
||||
m_centeralWidget(new QWidget(this))
|
||||
m_centeralWidget(new QWidget(this)),
|
||||
|
||||
m_audioInter(new DBusAudio(this))
|
||||
{
|
||||
m_centeralLayout = new QVBoxLayout;
|
||||
m_centeralWidget->setLayout(m_centeralLayout);
|
||||
@ -17,4 +19,10 @@ SoundApplet::SoundApplet(QWidget *parent)
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setStyleSheet("background-color:transparent;");
|
||||
|
||||
for (auto sp : m_audioInter->sinks())
|
||||
{
|
||||
DBusSink *sink = new DBusSink(sp.path(), this);
|
||||
qDebug() << sink->name();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
#ifndef SOUNDAPPLET_H
|
||||
#define SOUNDAPPLET_H
|
||||
|
||||
#include "dbus/dbusaudio.h"
|
||||
#include "dbus/dbussink.h"
|
||||
|
||||
#include <QScrollArea>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
@ -14,6 +17,8 @@ public:
|
||||
private:
|
||||
QWidget *m_centeralWidget;
|
||||
QVBoxLayout *m_centeralLayout;
|
||||
|
||||
DBusAudio *m_audioInter;
|
||||
};
|
||||
|
||||
#endif // SOUNDAPPLET_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user