1/* This file is part of the KDE project
2 Copyright (C) 2007 Matthias Kretz <kretz@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) version 3, or any
8 later version accepted by the membership of KDE e.V. (or its
9 successor approved by the membership of KDE e.V.), Nokia Corporation
10 (or its successors, if any) and the KDE Free Qt Foundation, which shall
11 act as a proxy defined in Section 6 of version 3 of the license.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library. If not, see <http://www.gnu.org/licenses/>.
20
21*/
22
23#include "platform_p.h"
24#include "platformplugin.h"
25#include "factory_p.h"
26#include <QtCore/QCoreApplication>
27#include <QtCore/QUrl>
28#include <QtGui/QIcon>
29#include <QtGui/QStyle>
30#include <QtGui/QApplication>
31
32QT_BEGIN_NAMESPACE
33
34namespace Phonon
35{
36
37void Platform::saveVolume(const QString &outputName, qreal volume)
38{
39#ifndef QT_NO_PHONON_PLATFORMPLUGIN
40 PlatformPlugin *f = Factory::platformPlugin();
41 if (f) {
42 f->saveVolume(outputName, volume);
43 }
44#else
45 Q_UNUSED(outputName);
46 Q_UNUSED(volume);
47#endif //QT_NO_PHONON_PLATFORMPLUGIN
48}
49
50qreal Platform::loadVolume(const QString &outputName)
51{
52#ifndef QT_NO_PHONON_PLATFORMPLUGIN
53 const PlatformPlugin *f = Factory::platformPlugin();
54 if (f) {
55 return f->loadVolume(outputName);
56 }
57#else
58 Q_UNUSED(outputName);
59#endif //QT_NO_PHONON_PLATFORMPLUGIN
60 return 1.0;
61}
62
63AbstractMediaStream *Platform::createMediaStream(const QUrl &url, QObject *parent)
64{
65#ifndef QT_NO_PHONON_PLATFORMPLUGIN
66 PlatformPlugin *f = Factory::platformPlugin();
67 if (f) {
68 return f->createMediaStream(url, parent);
69 }
70#else
71 Q_UNUSED(url);
72 Q_UNUSED(parent);
73#endif //QT_NO_PHONON_PLATFORMPLUGIN
74 return 0;
75}
76
77QIcon Platform::icon(const QString &name, QStyle *style)
78{
79 QIcon ret;
80#ifndef QT_NO_PHONON_PLATFORMPLUGIN
81 if (const PlatformPlugin *f = Factory::platformPlugin()) {
82 ret = f->icon(name);
83 }
84#endif //QT_NO_PHONON_PLATFORMPLUGIN
85 if (ret.isNull()) {
86 if (!style) {
87 style = QApplication::style();
88 }
89 if (name == QLatin1String("player-volume")) {
90 ret = style->standardPixmap(QStyle::SP_MediaVolume);
91 } else if (name == QLatin1String("player-volume-muted")) {
92 ret = style->standardPixmap(QStyle::SP_MediaVolumeMuted);
93 }
94 }
95
96 return ret;
97}
98
99void Platform::notification(const char *notificationName, const QString &text,
100 const QStringList &actions, QObject *receiver,
101 const char *actionSlot)
102{
103#ifndef QT_NO_PHONON_PLATFORMPLUGIN
104 const PlatformPlugin *f = Factory::platformPlugin();
105 if (f) {
106 f->notification(notificationName, text, actions, receiver, actionSlot);
107 }
108#else
109 Q_UNUSED(notificationName);
110 Q_UNUSED(text);
111 Q_UNUSED(actions);
112 Q_UNUSED(receiver);
113 Q_UNUSED(actionSlot);
114#endif //QT_NO_PHONON_PLATFORMPLUGIN
115}
116
117QString Platform::applicationName()
118{
119#ifndef QT_NO_PHONON_PLATFORMPLUGIN
120 const PlatformPlugin *f = Factory::platformPlugin();
121 if (f) {
122 return f->applicationName();
123 }
124#endif //QT_NO_PHONON_PLATFORMPLUGIN
125 QString ret = QCoreApplication::applicationName();
126 if (ret.isEmpty())
127 ret = QCoreApplication::applicationFilePath();
128 return ret;
129}
130
131QList<QPair<QByteArray, QString> > Platform::deviceAccessListFor(const Phonon::AudioOutputDevice &deviceDesc)
132{
133#ifndef QT_NO_PHONON_PLATFORMPLUGIN
134 const PlatformPlugin *f = Factory::platformPlugin();
135 if (f) {
136 return f->deviceAccessListFor(deviceDesc);
137 }
138#endif //QT_NO_PHONON_PLATFORMPLUGIN
139 return QList<QPair<QByteArray, QString> >();
140}
141
142} // namespace Phonon
143
144QT_END_NAMESPACE
145