10
by Tiago Salem Herrmann
add speaker interface |
1 |
/**
|
19
by Tiago Salem Herrmann
fix copyright year |
2 |
* Copyright (C) 2013 Canonical, Ltd.
|
10
by Tiago Salem Herrmann
add speaker interface |
3 |
*
|
24.1.2
by Ricardo Salveti de Araujo
* Packaging cleanup |
4 |
* This program is free software: you can redistribute it and/or modify it under
|
5 |
* the terms of the GNU Lesser General Public License version 3, as published by
|
|
6 |
* the Free Software Foundation.
|
|
7 |
*
|
|
8 |
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
9 |
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
|
|
10 |
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
11 |
* Lesser General Public License for more details.
|
|
12 |
*
|
|
13 |
* You should have received a copy of the GNU Lesser General Public License
|
|
10
by Tiago Salem Herrmann
add speaker interface |
14 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
24.1.2
by Ricardo Salveti de Araujo
* Packaging cleanup |
15 |
*
|
16 |
* Authors: Tiago Salem Herrmann <tiago.herrmann@canonical.com>
|
|
10
by Tiago Salem Herrmann
add speaker interface |
17 |
*/
|
18 |
||
19 |
#include <QDebug> |
|
20 |
||
21 |
#include <TelepathyQt/Constants> |
|
22 |
#include <TelepathyQt/DBusObject> |
|
23 |
||
91.3.2
by Tiago Salem Herrmann
move SpeakerInterface to AudioOutputsInterface |
24 |
#include "audiooutputsiface.h" |
25 |
||
26 |
||
27 |
QDBusArgument &operator<<(QDBusArgument &argument, const AudioOutput &output) |
|
28 |
{
|
|
29 |
argument.beginStructure(); |
|
30 |
argument << output.id << output.type << output.name; |
|
31 |
argument.endStructure(); |
|
32 |
return argument; |
|
33 |
}
|
|
34 |
||
35 |
const QDBusArgument &operator>>(const QDBusArgument &argument, AudioOutput &output) |
|
36 |
{
|
|
37 |
argument.beginStructure(); |
|
38 |
argument >> output.id >> output.type >> output.name; |
|
39 |
argument.endStructure(); |
|
40 |
return argument; |
|
41 |
}
|
|
42 |
||
43 |
// Chan.I.AudioOutputs
|
|
44 |
BaseChannelAudioOutputsInterface::Adaptee::Adaptee(BaseChannelAudioOutputsInterface *interface) |
|
10
by Tiago Salem Herrmann
add speaker interface |
45 |
: QObject(interface), |
46 |
mInterface(interface) |
|
47 |
{
|
|
91.3.2
by Tiago Salem Herrmann
move SpeakerInterface to AudioOutputsInterface |
48 |
qDBusRegisterMetaType<AudioOutput>(); |
49 |
qDBusRegisterMetaType<AudioOutputList>(); |
|
10
by Tiago Salem Herrmann
add speaker interface |
50 |
}
|
51 |
||
91.3.2
by Tiago Salem Herrmann
move SpeakerInterface to AudioOutputsInterface |
52 |
struct TP_QT_NO_EXPORT BaseChannelAudioOutputsInterface::Private { |
53 |
Private(BaseChannelAudioOutputsInterface *parent) |
|
54 |
: adaptee(new BaseChannelAudioOutputsInterface::Adaptee(parent)) { |
|
10
by Tiago Salem Herrmann
add speaker interface |
55 |
}
|
91.3.2
by Tiago Salem Herrmann
move SpeakerInterface to AudioOutputsInterface |
56 |
AudioOutputList audioOutputs; |
57 |
QString activeAudioOutput; |
|
58 |
SetActiveAudioOutputCallback setActiveAudioOutputCB; |
|
59 |
BaseChannelAudioOutputsInterface::Adaptee *adaptee; |
|
10
by Tiago Salem Herrmann
add speaker interface |
60 |
};
|
61 |
||
91.3.2
by Tiago Salem Herrmann
move SpeakerInterface to AudioOutputsInterface |
62 |
BaseChannelAudioOutputsInterface::Adaptee::~Adaptee() |
10
by Tiago Salem Herrmann
add speaker interface |
63 |
{
|
64 |
}
|
|
65 |
||
91.3.2
by Tiago Salem Herrmann
move SpeakerInterface to AudioOutputsInterface |
66 |
void BaseChannelAudioOutputsInterface::Adaptee::setActiveAudioOutput(const QString &id, const ChannelInterfaceAudioOutputsAdaptor::SetActiveAudioOutputContextPtr &context) |
10
by Tiago Salem Herrmann
add speaker interface |
67 |
{
|
91.3.2
by Tiago Salem Herrmann
move SpeakerInterface to AudioOutputsInterface |
68 |
if (!mInterface->mPriv->setActiveAudioOutputCB.isValid()) { |
10
by Tiago Salem Herrmann
add speaker interface |
69 |
context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented")); |
70 |
return; |
|
71 |
}
|
|
72 |
Tp::DBusError error; |
|
91.3.2
by Tiago Salem Herrmann
move SpeakerInterface to AudioOutputsInterface |
73 |
mInterface->mPriv->setActiveAudioOutputCB(id, &error); |
10
by Tiago Salem Herrmann
add speaker interface |
74 |
if (error.isValid()) { |
75 |
context->setFinishedWithError(error.name(), error.message()); |
|
76 |
return; |
|
77 |
}
|
|
78 |
context->setFinished(); |
|
79 |
}
|
|
80 |
||
91.3.2
by Tiago Salem Herrmann
move SpeakerInterface to AudioOutputsInterface |
81 |
BaseChannelAudioOutputsInterface::BaseChannelAudioOutputsInterface() |
82 |
: AbstractChannelInterface(TP_QT_IFACE_CHANNEL_AUDIOOUTPUTS), |
|
10
by Tiago Salem Herrmann
add speaker interface |
83 |
mPriv(new Private(this)) |
84 |
{
|
|
85 |
}
|
|
86 |
||
91.3.2
by Tiago Salem Herrmann
move SpeakerInterface to AudioOutputsInterface |
87 |
BaseChannelAudioOutputsInterface::~BaseChannelAudioOutputsInterface() |
10
by Tiago Salem Herrmann
add speaker interface |
88 |
{
|
89 |
delete mPriv; |
|
90 |
}
|
|
91 |
||
91.3.2
by Tiago Salem Herrmann
move SpeakerInterface to AudioOutputsInterface |
92 |
QString BaseChannelAudioOutputsInterface::activeAudioOutput() const |
93 |
{
|
|
94 |
return mPriv->activeAudioOutput; |
|
95 |
}
|
|
96 |
||
97 |
AudioOutputList BaseChannelAudioOutputsInterface::audioOutputs() const |
|
98 |
{
|
|
99 |
return mPriv->audioOutputs; |
|
100 |
}
|
|
101 |
||
102 |
void BaseChannelAudioOutputsInterface::setSetActiveAudioOutputCallback(const SetActiveAudioOutputCallback &cb) |
|
103 |
{
|
|
104 |
mPriv->setActiveAudioOutputCB = cb; |
|
105 |
}
|
|
106 |
||
107 |
void BaseChannelAudioOutputsInterface::setActiveAudioOutput(const QString &id) |
|
108 |
{
|
|
109 |
mPriv->activeAudioOutput = id; |
|
110 |
Q_EMIT mPriv->adaptee->activeAudioOutputChanged(id); |
|
111 |
}
|
|
112 |
||
113 |
void BaseChannelAudioOutputsInterface::setAudioOutputs(const AudioOutputList &outputs) |
|
114 |
{
|
|
115 |
mPriv->audioOutputs = outputs; |
|
116 |
Q_EMIT mPriv->adaptee->audioOutputsChanged(outputs); |
|
117 |
}
|
|
118 |
||
119 |
QVariantMap BaseChannelAudioOutputsInterface::immutableProperties() const |
|
10
by Tiago Salem Herrmann
add speaker interface |
120 |
{
|
121 |
QVariantMap map; |
|
122 |
return map; |
|
123 |
}
|
|
124 |
||
91.3.2
by Tiago Salem Herrmann
move SpeakerInterface to AudioOutputsInterface |
125 |
void BaseChannelAudioOutputsInterface::createAdaptor() |
10
by Tiago Salem Herrmann
add speaker interface |
126 |
{
|
91.3.2
by Tiago Salem Herrmann
move SpeakerInterface to AudioOutputsInterface |
127 |
(void) new ChannelInterfaceAudioOutputsAdaptor(dbusObject()->dbusConnection(), |
10
by Tiago Salem Herrmann
add speaker interface |
128 |
mPriv->adaptee, dbusObject()); |
129 |
}
|
|
130 |
||
131 |
||
91.3.2
by Tiago Salem Herrmann
move SpeakerInterface to AudioOutputsInterface |
132 |
ChannelInterfaceAudioOutputsAdaptor::ChannelInterfaceAudioOutputsAdaptor(const QDBusConnection& bus, QObject* adaptee, QObject* parent) |
10
by Tiago Salem Herrmann
add speaker interface |
133 |
: Tp::AbstractAdaptor(bus, adaptee, parent) |
134 |
{
|
|
91.3.2
by Tiago Salem Herrmann
move SpeakerInterface to AudioOutputsInterface |
135 |
connect(adaptee, SIGNAL(audioOutputsChanged(AudioOutputList)), SIGNAL(AudioOutputsChanged(AudioOutputList))); |
136 |
connect(adaptee, SIGNAL(activeAudioOutputChanged(QString)), SIGNAL(ActiveAudioOutputChanged(QString))); |
|
137 |
}
|
|
138 |
||
139 |
ChannelInterfaceAudioOutputsAdaptor::~ChannelInterfaceAudioOutputsAdaptor() |
|
140 |
{
|
|
141 |
}
|
|
142 |
||
143 |
void ChannelInterfaceAudioOutputsAdaptor::SetActiveAudioOutput(const QString &id, const QDBusMessage& dbusMessage) |
|
144 |
{
|
|
145 |
if (!adaptee()->metaObject()->indexOfMethod("setActiveAudioOutput(QString,ChannelInterfaceAudioOutputsAdaptor::SetActiveAudioOutputContextPtr)") == -1) { |
|
10
by Tiago Salem Herrmann
add speaker interface |
146 |
dbusConnection().send(dbusMessage.createErrorReply(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"))); |
147 |
return; |
|
148 |
}
|
|
149 |
||
91.3.2
by Tiago Salem Herrmann
move SpeakerInterface to AudioOutputsInterface |
150 |
SetActiveAudioOutputContextPtr ctx = SetActiveAudioOutputContextPtr( |
151 |
new Tp::MethodInvocationContext< >(dbusConnection(), dbusMessage)); |
|
152 |
QMetaObject::invokeMethod(adaptee(), "setActiveAudioOutput", |
|
153 |
Q_ARG(QString, id), |
|
154 |
Q_ARG(ChannelInterfaceAudioOutputsAdaptor::SetActiveAudioOutputContextPtr, ctx)); |
|
10
by Tiago Salem Herrmann
add speaker interface |
155 |
return; |
156 |
}
|
|
157 |
||
91.3.2
by Tiago Salem Herrmann
move SpeakerInterface to AudioOutputsInterface |
158 |
QString ChannelInterfaceAudioOutputsAdaptor::ActiveAudioOutput() const |
159 |
{
|
|
160 |
return qvariant_cast< QString >(adaptee()->property("activeAudioOutput")); |
|
161 |
}
|
|
162 |
||
163 |
AudioOutputList ChannelInterfaceAudioOutputsAdaptor::AudioOutputs() const |
|
164 |
{
|
|
165 |
return qvariant_cast< AudioOutputList >(adaptee()->property("audioOutputs")); |
|
10
by Tiago Salem Herrmann
add speaker interface |
166 |
}
|
167 |