1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
/*
SPDX-FileCopyrightText: 2007-2008 Matthias Kretz <kretz@kde.org>
SPDX-License-Identifier: LGPL-2.0-only
*/
#include "kdeplatformplugin.h"
#include <QCoreApplication>
#include <QDir>
#include <QFile>
#include <QtPlugin>
#include <KAboutData>
#include <KConfigGroup>
#include <KLocalizedString>
#include <KMessageBox>
#include <KNotification>
#include <KSharedConfig>
#include "debug.h"
#include "kiomediastream.h"
namespace Phonon
{
KdePlatformPlugin::KdePlatformPlugin()
{
}
KdePlatformPlugin::~KdePlatformPlugin()
{
}
AbstractMediaStream *KdePlatformPlugin::createMediaStream(const QUrl &url, QObject *parent)
{
return new KioMediaStream(url, parent);
}
QIcon KdePlatformPlugin::icon(const QString &name) const
{
return QIcon::fromTheme(name);
}
void KdePlatformPlugin::notification(const char *notificationName,
const QString &text,
const QStringList &actions,
QObject *receiver,
const char *actionSlot) const
{
KNotification *notification = new KNotification(notificationName);
notification->setComponentName(QLatin1String("phonon"));
notification->setText(text);
notification->addContext(QLatin1String("Application"), KAboutData::applicationData().componentName());
if (!actions.isEmpty() && receiver && actionSlot) {
notification->setActions(actions);
QObject::connect(notification, SIGNAL(activated(unsigned int)), receiver, actionSlot);
}
notification->sendEvent();
}
QString KdePlatformPlugin::applicationName() const
{
KAboutData aboutData = KAboutData::applicationData();
if (!aboutData.displayName().isEmpty()) {
return aboutData.displayName();
}
if (!aboutData.componentName().isEmpty()) {
return aboutData.componentName();
}
// FIXME: why was this not localized?
return QLatin1String("Qt Application");
}
// Phonon4Qt5 internally implements backend lookup an creation. Driving it
// through KService is not practical because Phonon4Qt5 lacks appropriate
// wiring to frameworks.
QObject *KdePlatformPlugin::createBackend()
{
return nullptr;
}
QObject *KdePlatformPlugin::createBackend(const QString & /*library*/, const QString & /*version*/)
{
return nullptr;
}
bool KdePlatformPlugin::isMimeTypeAvailable(const QString & /*mimeType*/) const
{
// Static mimetype based support reporting is utter nonsense, so always say
// everything is supported.
// In particular there's two problems
// 1. mimetypes do not map well to actual formats because the majority of
// files these days are containers that can contain arbitrary content
// streams, so mimetypes are too generic to properly define supportedness.
// 2. just about every multimedia library in the world draws format support
// from a plugin based architecture which means that technically everything
// can support anything as long as there is a plugin and/or the means to
// install a plugin.
// So, always say every mimetype is supported.
// Phonon5 will do away with all mentionings of mimetypes as well.
return true;
}
// Volume restoration is a capability that will also be removed in Phonon5.
// For proper restoration capabilities the actual platform will be used (e.g.
// PulseAudio on Linux will remember streams and correctly restore the volume).
void KdePlatformPlugin::saveVolume(const QString &outputName, qreal volume)
{
KConfigGroup config(KSharedConfig::openConfig(), "Phonon::AudioOutput");
config.writeEntry(outputName + "_Volume", volume);
}
qreal KdePlatformPlugin::loadVolume(const QString &outputName) const
{
KConfigGroup config(KSharedConfig::openConfig(), "Phonon::AudioOutput");
return config.readEntry<qreal>(outputName + "_Volume", 1.0);
}
QList<int> KdePlatformPlugin::objectDescriptionIndexes(ObjectDescriptionType type) const
{
switch (type) {
case AudioOutputDeviceType:
case AudioCaptureDeviceType:
case VideoCaptureDeviceType:
default:
return QList<int>();
}
}
QHash<QByteArray, QVariant> KdePlatformPlugin::objectDescriptionProperties(ObjectDescriptionType type, int index) const
{
Q_UNUSED(index);
switch (type) {
case AudioOutputDeviceType:
case AudioCaptureDeviceType:
case VideoCaptureDeviceType:
default:
return QHash<QByteArray, QVariant>();
}
}
} // namespace Phonon
|