summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Holland <dominik.holland@pelagicore.com>2016-06-22 16:46:40 +0200
committerJohan Thelin <johan.thelin@pelagicore.com>2016-07-04 06:10:11 +0000
commit0b023831782fbecc819987dbddf5937a5c32c47c (patch)
treef099d9953631557f9c8855b6572c2ac2cd0ac62a
parent11c43c160ce9681acbe300f1e75fecf4ffe52bda (diff)
downloadqtivi-0b023831782fbecc819987dbddf5937a5c32c47c.tar.gz
Added a basic AmFmTuner
Including a basic tuner QML example and a simulation backend Change-Id: I46985d26a5eaa6ab84f19384ef8f08d6206570aa Task-number: QTAUTO-60 Reviewed-by: Johan Thelin <johan.thelin@pelagicore.com>
-rw-r--r--examples/media/media.pro3
-rw-r--r--examples/media/tuner/main.cpp64
-rw-r--r--examples/media/tuner/main.qml153
-rw-r--r--examples/media/tuner/qml.qrc5
-rw-r--r--examples/media/tuner/tuner.pro16
-rw-r--r--src/imports/media/plugin.cpp3
-rw-r--r--src/ivimedia/ivimedia.pro11
-rw-r--r--src/ivimedia/qiviamfmtuner.cpp430
-rw-r--r--src/ivimedia/qiviamfmtuner.h109
-rw-r--r--src/ivimedia/qiviamfmtuner_p.h89
-rw-r--r--src/ivimedia/qiviamfmtunerbackendinterface.cpp144
-rw-r--r--src/ivimedia/qiviamfmtunerbackendinterface.h77
-rw-r--r--src/ivimedia/qivitunerstation.cpp60
-rw-r--r--src/ivimedia/qivitunerstation.h84
-rw-r--r--src/plugins/ivimedia/ivimedia.pro3
-rw-r--r--src/plugins/ivimedia/media_simulator/media_simulator.json7
-rw-r--r--src/plugins/ivimedia/media_simulator/media_simulator.pro4
-rw-r--r--src/plugins/ivimedia/media_simulator/mediaplugin.h2
-rw-r--r--src/plugins/ivimedia/tuner_simulator/amfmtunerbackend.cpp189
-rw-r--r--src/plugins/ivimedia/tuner_simulator/amfmtunerbackend.h105
-rw-r--r--src/plugins/ivimedia/tuner_simulator/searchandbrowsebackend.cpp111
-rw-r--r--src/plugins/ivimedia/tuner_simulator/searchandbrowsebackend.h68
-rw-r--r--src/plugins/ivimedia/tuner_simulator/tuner_simulator.json6
-rw-r--r--src/plugins/ivimedia/tuner_simulator/tuner_simulator.pro21
-rw-r--r--src/plugins/ivimedia/tuner_simulator/tunerplugin.cpp74
-rw-r--r--src/plugins/ivimedia/tuner_simulator/tunerplugin.h67
26 files changed, 1898 insertions, 7 deletions
diff --git a/examples/media/media.pro b/examples/media/media.pro
index bf30a2c..ab7c158 100644
--- a/examples/media/media.pro
+++ b/examples/media/media.pro
@@ -1,2 +1,3 @@
TEMPLATE = subdirs
-SUBDIRS = mediaplayer
+SUBDIRS = mediaplayer \
+ tuner
diff --git a/examples/media/tuner/main.cpp b/examples/media/tuner/main.cpp
new file mode 100644
index 0000000..1b4c909
--- /dev/null
+++ b/examples/media/tuner/main.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Pelagicore AG
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtIvi module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD-QTAS$
+** Commercial License Usage
+** Licensees holding valid commercial Qt Automotive Suite licenses may use
+** this file in accordance with the commercial license agreement provided
+** with the Software or, alternatively, in accordance with the terms
+** contained in a written agreement between you and The Qt Company. For
+** licensing terms and conditions see https://www.qt.io/terms-conditions.
+** For further information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+** SPDX-License-Identifier: BSD-3-Clause
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QQmlApplicationEngine>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ QQmlApplicationEngine engine;
+ engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+
+ return app.exec();
+}
diff --git a/examples/media/tuner/main.qml b/examples/media/tuner/main.qml
new file mode 100644
index 0000000..662173e
--- /dev/null
+++ b/examples/media/tuner/main.qml
@@ -0,0 +1,153 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Pelagicore AG
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtIvi module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD-QTAS$
+** Commercial License Usage
+** Licensees holding valid commercial Qt Automotive Suite licenses may use
+** this file in accordance with the commercial license agreement provided
+** with the Software or, alternatively, in accordance with the terms
+** contained in a written agreement between you and The Qt Company. For
+** licensing terms and conditions see https://www.qt.io/terms-conditions.
+** For further information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+** SPDX-License-Identifier: BSD-3-Clause
+**
+****************************************************************************/
+
+import QtQuick 2.6
+import QtQuick.Controls 1.5
+import QtQuick.Layouts 1.1
+import QtIvi 1.0
+import QtIvi.Media 1.0
+
+ApplicationWindow {
+ visible: true
+ width: 500
+ height: 250
+ title: qsTr("Tuner")
+
+ AmFmTuner {
+ id: tuner
+
+ band: bandGroup.current.text === "AM" ? AmFmTuner.AMBand : AmFmTuner.FMBand
+ }
+
+ SplitView {
+ id: splitView1
+ anchors.fill: parent
+
+ ColumnLayout {
+
+ RowLayout {
+ Label { text: "Station:" }
+ Label { text: tuner.station.stationName }
+ }
+
+ RowLayout {
+ Label { text: "Frequency:" }
+ Label { text: tuner.frequency }
+ }
+
+ RowLayout {
+ Label { text: "Band:" }
+ RadioButton { text: "AM"; exclusiveGroup: bandGroup; checked: tuner.band === AmFmTuner.AMBand }
+ RadioButton { text: "FM"; exclusiveGroup: bandGroup; checked: tuner.band === AmFmTuner.FMBand }
+ }
+
+ ExclusiveGroup {
+ id: bandGroup
+ }
+
+ RowLayout {
+ Button {
+ text: "<-"
+ onClicked: tuner.seekDown()
+ }
+
+ Button {
+ text: "<"
+ onClicked: tuner.stepDown()
+ }
+
+ Button {
+ text: ">"
+ onClicked: tuner.stepUp()
+ }
+
+ Button {
+ text: "->"
+ onClicked: tuner.seekUp()
+ }
+ }
+ }
+
+ ListView {
+ spacing: 8
+ clip: true
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+
+ model: SearchAndBrowseModel {
+ serviceObject: tuner.serviceObject
+ contentType: "station"
+ }
+
+ delegate: Rectangle {
+ width: ListView.view.width
+ height: column.height
+ color: "#efefef"
+
+ Column {
+ id: column
+ width: parent.width
+
+ Text { text: "Name: " + model.item.stationName }
+ Text { text: "Type: " + model.item.frequency }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ tuner.tune(model.item)
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/media/tuner/qml.qrc b/examples/media/tuner/qml.qrc
new file mode 100644
index 0000000..5f6483a
--- /dev/null
+++ b/examples/media/tuner/qml.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/media/tuner/tuner.pro b/examples/media/tuner/tuner.pro
new file mode 100644
index 0000000..f8ac5ed
--- /dev/null
+++ b/examples/media/tuner/tuner.pro
@@ -0,0 +1,16 @@
+TEMPLATE = app
+
+QT += qml quick widgets ivicore
+
+CONFIG += c++11
+
+SOURCES += main.cpp
+
+RESOURCES += qml.qrc
+
+# Additional import path used to resolve QML modules in Qt Creator's code model
+QML_IMPORT_PATH =
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/media/tuner
+INSTALLS += target
diff --git a/src/imports/media/plugin.cpp b/src/imports/media/plugin.cpp
index 3f928e0..021a03c 100644
--- a/src/imports/media/plugin.cpp
+++ b/src/imports/media/plugin.cpp
@@ -46,6 +46,7 @@
#include <QtIviMedia/QIviMediaDeviceDiscoveryModel>
#include <QtIviMedia/QIviMediaIndexerControl>
#include <QtIviMedia/QIviPlayQueue>
+#include <QtIviMedia/QIviAmFmTuner>
#include <QtIviMedia/QIviMediaDevice>
QT_BEGIN_NAMESPACE
@@ -64,6 +65,8 @@ public:
//This should be an singleton, otherwise we might delete a pointer twice ?
qmlRegisterType<QIviMediaDeviceDiscoveryModel>(uri, 1, 0, "MediaDeviceDiscoveryModel");
qmlRegisterType<QIviMediaIndexerControl>(uri, 1, 0, "MediaIndexerControl");
+ qmlRegisterType<QIviAmFmTuner>(uri, 1, 0, "AmFmTuner");
+
qmlRegisterUncreatableType<QIviPlayQueue>(uri, 1, 0, "PlayQueue", "PlayQueue needs to be retrieved from the MediaPlayer");
qmlRegisterUncreatableType<QIviMediaDevice>(uri, 1, 0, "MediaDevice", "MediaDevice can't be instantiated from QML");
diff --git a/src/ivimedia/ivimedia.pro b/src/ivimedia/ivimedia.pro
index 3dfb655..eb3f32f 100644
--- a/src/ivimedia/ivimedia.pro
+++ b/src/ivimedia/ivimedia.pro
@@ -24,7 +24,11 @@ HEADERS += \
qivimediadevice.h \
qivimediaindexercontrol.h \
qivimediaindexercontrol_p.h \
- qivimediaindexercontrolbackendinterface.h
+ qivimediaindexercontrolbackendinterface.h \
+ qiviamfmtuner.h \
+ qiviamfmtuner_p.h \
+ qiviamfmtunerbackendinterface.h \
+ qivitunerstation.h
SOURCES += \
qivimediaplayer.cpp \
@@ -35,6 +39,9 @@ SOURCES += \
qivimediadevicediscoverymodelbackendinterface.cpp \
qivimediadevice.cpp \
qivimediaindexercontrol.cpp \
- qivimediaindexercontrolbackendinterface.cpp
+ qivimediaindexercontrolbackendinterface.cpp \
+ qiviamfmtuner.cpp \
+ qiviamfmtunerbackendinterface.cpp \
+ qivitunerstation.cpp
load(qt_module)
diff --git a/src/ivimedia/qiviamfmtuner.cpp b/src/ivimedia/qiviamfmtuner.cpp
new file mode 100644
index 0000000..f9d77b2
--- /dev/null
+++ b/src/ivimedia/qiviamfmtuner.cpp
@@ -0,0 +1,430 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Pelagicore AG
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtIVI module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL-QTAS$
+** Commercial License Usage
+** Licensees holding valid commercial Qt Automotive Suite licenses may use
+** this file in accordance with the commercial license agreement provided
+** with the Software or, alternatively, in accordance with the terms
+** contained in a written agreement between you and The Qt Company. For
+** licensing terms and conditions see https://www.qt.io/terms-conditions.
+** For further information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+** SPDX-License-Identifier: LGPL-3.0
+**
+****************************************************************************/
+
+#include "qiviamfmtuner.h"
+#include "qiviamfmtuner_p.h"
+#include <QtIviCore/QIviServiceObject>
+#include <QtDebug>
+
+QIviAmFmTunerPrivate::QIviAmFmTunerPrivate(const QString &interface, QIviAmFmTuner *parent)
+ : QIviAbstractFeaturePrivate(interface, parent)
+ , q_ptr(parent)
+ , m_frequency(-1)
+ , m_band(QIviAmFmTuner::FMBand)
+{
+ qRegisterMetaType<QIviTunerStation>();
+ qRegisterMetaType<QIviAmFmTunerStation>();
+}
+
+void QIviAmFmTunerPrivate::init()
+{
+}
+
+void QIviAmFmTunerPrivate::clearToDefaults()
+{
+ m_frequency = -1;
+ m_band = QIviAmFmTuner::FMBand;
+ m_station = QVariant();
+}
+
+void QIviAmFmTunerPrivate::onFrequencyChanged(int frequency)
+{
+ if (m_frequency == frequency)
+ return;
+
+ Q_Q(QIviAmFmTuner);
+ m_frequency = frequency;
+ emit q->frequencyChanged(frequency);
+}
+
+void QIviAmFmTunerPrivate::onBandChanged(QIviAmFmTuner::Band band)
+{
+ if (m_band == band)
+ return;
+
+ Q_Q(QIviAmFmTuner);
+ m_band = band;
+ emit q->bandChanged(band);
+}
+
+void QIviAmFmTunerPrivate::onStationChanged(const QVariant &station)
+{
+ const QIviAmFmTunerStation *st = stationItem(station);
+ if (st && m_station == station)
+ return;
+
+ Q_Q(QIviAmFmTuner);
+ m_station = station;
+ emit q->stationChanged(station);
+}
+
+//TODO replace me by a generic function for all classes
+const QIviAmFmTunerStation *QIviAmFmTunerPrivate::stationItem(const QVariant &item)
+{
+ const void *data = item.constData();
+
+ QMetaType type(item.userType());
+ if (!type.flags().testFlag(QMetaType::IsGadget)) {
+ qCritical() << "The passed QVariant needs to use the Q_GADGET macro";
+ return nullptr;
+ }
+
+ const QMetaObject *mo = type.metaObject();
+ while (mo) {
+ if (mo->className() == QIviAmFmTunerStation::staticMetaObject.className())
+ return reinterpret_cast<const QIviAmFmTunerStation*>(data);
+ mo = mo->superClass();
+ }
+
+ qCritical() << "The passed QVariant is not derived from QIviPlayableItem";
+ return nullptr;
+}
+
+QIviAmFmTunerBackendInterface *QIviAmFmTunerPrivate::tunerBackend() const
+{
+ Q_Q(const QIviAmFmTuner);
+ QIviServiceObject *so = q->serviceObject();
+ if (so)
+ return qobject_cast<QIviAmFmTunerBackendInterface*>(so->interfaceInstance(QIviStringAmFmTunerInterfaceName));
+
+ return nullptr;
+}
+
+/*!
+ \class QIviAmFmTuner
+ \inmodule QtIviMedia
+ \brief Provides a interface to control the am fm tuner
+
+ The QIviAmFmTuner provides the methods to control a am/fm tuner.
+*/
+
+/*!
+ \qmltype AmFmTuner
+ \instantiates QIviAmFmTuner
+ \inqmlmodule QtIvi.Media
+ \inherits AbstractFeature
+ \brief Provides a interface to control the am fm tuner
+
+ The AmFmTuner provides the methods to control a am/fm tuner.
+*/
+
+/*!
+ \enum QIviAmFmTuner::Band
+ \value AMBand
+ The AM Band is based on the Amplitude Modulation technique and can range from 520 to 1610 kHz (1710 kHz).
+ The step size is usually between 9 or 10 kHz.
+ \value FMBand
+ The FM Band is based on the Frequency Modulation technique and can range from 87.5 to 108.0 MHz.
+ The step size is usually 100 kHz.
+*/
+
+/*!
+ Constructs a QIviAmFmTuner.
+
+ The \a parent argument is passed on to the \l QIviAbstractFeature base class.
+*/
+QIviAmFmTuner::QIviAmFmTuner(QObject *parent)
+ : QIviAbstractFeature(*new QIviAmFmTunerPrivate(QIviStringAmFmTunerInterfaceName, this), parent)
+{
+ Q_D(QIviAmFmTuner);
+ d->init();
+}
+
+/*!
+ \qmlproperty int AmFmTuner::frequency
+ \brief The current frequency of the tuner.
+ */
+/*!
+ \property QIviAmFmTuner::frequency
+ \brief The current frequency of the tuner.
+ */
+int QIviAmFmTuner::frequency() const
+{
+ Q_D(const QIviAmFmTuner);
+ return d->m_frequency;
+}
+
+/*!
+ \qmlproperty enumeration AmFmTuner::band
+ \brief The current band of the tuner.
+
+ Available values are:
+ \value AMBand
+ The AM Band is based on the Amplitude Modulation technique and can range from 520 to 1610 kHz (1710 kHz).
+ The step size is usually between 9 or 10 kHz.
+ \value FMBand
+ The FM Band is based on the Frequency Modulation technique and can range from 87.5 to 108.0 MHz.
+ The step size is usually 100 kHz.
+ */
+/*!
+ \property QIviAmFmTuner::band
+ \brief The current band of the tuner.
+ */
+QIviAmFmTuner::Band QIviAmFmTuner::band() const
+{
+ Q_D(const QIviAmFmTuner);
+ return d->m_band;
+}
+
+/*!
+ \qmlproperty AmFmTunerStation AmFmTuner::station
+ \brief The currently tuned station.
+ */
+/*!
+ \property QIviAmFmTuner::station
+ \brief The currently tuned station.
+ */
+QVariant QIviAmFmTuner::station() const
+{
+ Q_D(const QIviAmFmTuner);
+ return d->m_station;
+}
+
+/*!
+ \qmlmethod AmFmTuner::tune(AmFmTunerStation station)
+
+ Tunes to the provided \a station.
+*/
+
+/*!
+ \fn void QIviAmFmTuner::tune(const QVariant &station)
+
+ Tunes to the provided \a station.
+*/
+//TODO Change this to use the real class, but for this we need to refactor the Q_GADGET classes to real classes with copy constructors and propably QSharedData
+void QIviAmFmTuner::tune(const QVariant &station)
+{
+ Q_D(QIviAmFmTuner);
+ const QIviAmFmTunerStation *stationItem = d->stationItem(station);
+ if (!stationItem)
+ return;
+
+ if (stationItem->band() != d->m_band)
+ setBand(stationItem->band());
+ if (stationItem->frequency() != d->m_frequency)
+ setFrequency(stationItem->frequency());
+}
+
+void QIviAmFmTuner::setFrequency(int frequency)
+{
+ Q_D(QIviAmFmTuner);
+ QIviAmFmTunerBackendInterface *backend = d->tunerBackend();
+ if (!backend) {
+ qWarning("Can't set the frequency without a connected backend");
+ return;
+ }
+
+ backend->setFrequency(frequency);
+}
+
+void QIviAmFmTuner::setBand(QIviAmFmTuner::Band band)
+{
+ Q_D(QIviAmFmTuner);
+ QIviAmFmTunerBackendInterface *backend = d->tunerBackend();
+ if (!backend) {
+ qWarning("Can't set the band without a connected backend");
+ return;
+ }
+
+ backend->setBand(band);
+}
+
+/*!
+ \qmlmethod AmFmTuner::stepUp()
+
+ Increases the frequency by the current bands step size.
+*/
+
+/*!
+ \fn void QIviAmFmTuner::stepUp()
+
+ Increases the frequency by the current bands step size.
+*/
+void QIviAmFmTuner::stepUp()
+{
+ Q_D(QIviAmFmTuner);
+ QIviAmFmTunerBackendInterface *backend = d->tunerBackend();
+ if (!backend) {
+ qWarning("Can't step up without a connected backend");
+ return;
+ }
+
+ backend->stepUp();
+}
+
+/*!
+ \qmlmethod AmFmTuner::stepDown()
+
+ Decreases the frequency by the current bands step size.
+*/
+
+/*!
+ \fn void QIviAmFmTuner::stepDown()
+
+ Decreases the frequency by the current bands step size.
+*/
+void QIviAmFmTuner::stepDown()
+{
+ Q_D(QIviAmFmTuner);
+ QIviAmFmTunerBackendInterface *backend = d->tunerBackend();
+ if (!backend) {
+ qWarning("Can't step down without a connected backend");
+ return;
+ }
+
+ backend->stepDown();
+}
+
+/*!
+ \qmlmethod AmFmTuner::seekUp()
+
+ Seeks the next available Station in upwards direction and tunes it.
+
+ If the end of the band where hit without finding a station, the search will be continued from the beginning of the band.
+*/
+
+/*!
+ \fn void QIviAmFmTuner::seekUp()
+
+ Seeks the next available Station in upwards direction and tunes it.
+
+ If the end of the band where hit without finding a station, the search will be continued from the beginning of the band.
+*/
+void QIviAmFmTuner::seekUp()
+{
+ Q_D(QIviAmFmTuner);
+ QIviAmFmTunerBackendInterface *backend = d->tunerBackend();
+ if (!backend) {
+ qWarning("Can't seek up without a connected backend");
+ return;
+ }
+
+ backend->seekUp();
+}
+
+/*!
+ \qmlmethod AmFmTuner::seekDown()
+
+ Seeks the next available Station in downwards direction and tunes it.
+
+ If the beginning of the band where hit without finding a station, the search will be continued from the end of the band.
+*/
+
+/*!
+ \fn void QIviAmFmTuner::seekDown()
+
+ Seeks the next available Station in downwards direction and tunes it.
+
+ If the beginning of the band where hit without finding a station, the search will be continued from the end of the band.
+*/
+void QIviAmFmTuner::seekDown()
+{
+ Q_D(QIviAmFmTuner);
+ QIviAmFmTunerBackendInterface *backend = d->tunerBackend();
+ if (!backend) {
+ qWarning("Can't seek down without a connected backend");
+ return;
+ }
+
+ backend->seekDown();
+}
+
+/*!
+ \internal
+ */
+QIviAmFmTuner::QIviAmFmTuner(QIviAmFmTunerPrivate &dd, QObject *parent)
+ : QIviAbstractFeature(dd, parent)
+{
+ Q_D(QIviAmFmTuner);
+ d->init();
+}
+
+/*!
+ \reimp
+ */
+bool QIviAmFmTuner::acceptServiceObject(QIviServiceObject *serviceObject)
+{
+ return serviceObject->interfaces().contains(QIviStringAmFmTunerInterfaceName);
+}
+
+/*!
+ \reimp
+ */
+void QIviAmFmTuner::connectToServiceObject(QIviServiceObject *serviceObject)
+{
+ Q_UNUSED(serviceObject);
+
+ Q_D(QIviAmFmTuner);
+
+ QIviAmFmTunerBackendInterface *backend = d->tunerBackend();
+ if (!backend)
+ return;
+
+ QObjectPrivate::connect(backend, &QIviAmFmTunerBackendInterface::frequencyChanged,
+ d, &QIviAmFmTunerPrivate::onFrequencyChanged);
+ QObjectPrivate::connect(backend, &QIviAmFmTunerBackendInterface::bandChanged,
+ d, &QIviAmFmTunerPrivate::onBandChanged);
+ QObjectPrivate::connect(backend, &QIviAmFmTunerBackendInterface::stationChanged,
+ d, &QIviAmFmTunerPrivate::onStationChanged);
+ backend->initialize();
+}
+
+/*!
+ \reimp
+ */
+void QIviAmFmTuner::disconnectFromServiceObject(QIviServiceObject *serviceObject)
+{
+ QIviAmFmTunerBackendInterface *backend = qobject_cast<QIviAmFmTunerBackendInterface*>(serviceObject->interfaceInstance(QIviStringAmFmTunerInterfaceName));
+
+ if (backend)
+ disconnect(backend, 0, this, 0);
+}
+
+/*!
+ \reimp
+ */
+void QIviAmFmTuner::clearServiceObject()
+{
+ Q_D(QIviAmFmTuner);
+ d->clearToDefaults();
+}
+
+#include "moc_qiviamfmtuner.cpp"
diff --git a/src/ivimedia/qiviamfmtuner.h b/src/ivimedia/qiviamfmtuner.h
new file mode 100644
index 0000000..ea8a55c
--- /dev/null
+++ b/src/ivimedia/qiviamfmtuner.h
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Pelagicore AG
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtIVI module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL-QTAS$
+** Commercial License Usage
+** Licensees holding valid commercial Qt Automotive Suite licenses may use
+** this file in accordance with the commercial license agreement provided
+** with the Software or, alternatively, in accordance with the terms
+** contained in a written agreement between you and The Qt Company. For
+** licensing terms and conditions see https://www.qt.io/terms-conditions.
+** For further information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+** SPDX-License-Identifier: LGPL-3.0
+**
+****************************************************************************/
+
+#ifndef QIVIAMFMTUNER_H
+#define QIVIAMFMTUNER_H
+
+#include <QtIviCore/QIviAbstractFeature>
+#include <QtIviMedia/qtivimediaglobal.h>
+#include <QVariant>
+
+QT_BEGIN_NAMESPACE
+
+class QIviAmFmTunerPrivate;
+
+static const QLatin1String QIviStringAmFmTunerInterfaceName("com.qt-project.qtivi.AmFmTuner");
+
+class Q_QTIVIMEDIA_EXPORT QIviAmFmTuner : public QIviAbstractFeature
+{
+ Q_OBJECT
+
+ Q_PROPERTY(int frequency READ frequency WRITE setFrequency NOTIFY frequencyChanged)
+ Q_PROPERTY(QIviAmFmTuner::Band band READ band WRITE setBand NOTIFY bandChanged)
+ Q_PROPERTY(QVariant station READ station NOTIFY stationChanged)
+
+public:
+ explicit QIviAmFmTuner(QObject *parent = Q_NULLPTR);
+
+ enum Band {
+ AMBand,
+ FMBand
+ };
+ Q_ENUM(Band)
+
+
+ int frequency() const;
+ Band band() const;
+ QVariant station() const;
+
+ Q_INVOKABLE void tune(const QVariant &station);
+
+public Q_SLOTS:
+ void setFrequency(int frequency);
+ void setBand(QIviAmFmTuner::Band band);
+ void stepUp();
+ void stepDown();
+ void seekUp();
+ void seekDown();
+
+Q_SIGNALS:
+ void frequencyChanged(int frequency);
+ void bandChanged(QIviAmFmTuner::Band band);
+ void stationChanged(const QVariant &station);
+
+protected:
+ QIviAmFmTuner(QIviAmFmTunerPrivate &dd, QObject *parent = Q_NULLPTR);
+
+ virtual bool acceptServiceObject(QIviServiceObject *serviceObject) Q_DECL_OVERRIDE;
+ virtual void connectToServiceObject(QIviServiceObject *serviceObject) Q_DECL_OVERRIDE;
+ virtual void disconnectFromServiceObject(QIviServiceObject *serviceObject) Q_DECL_OVERRIDE;
+ virtual void clearServiceObject() Q_DECL_OVERRIDE;
+
+private:
+ Q_DECLARE_PRIVATE(QIviAmFmTuner)
+ Q_PRIVATE_SLOT(d_func(), void onFrequencyChanged(int frequency))
+ Q_PRIVATE_SLOT(d_func(), void onBandChanged(QIviAmFmTuner::Band band))
+ Q_PRIVATE_SLOT(d_func(), void onStationChanged(const QVariant &station))
+};
+
+QT_END_NAMESPACE
+
+#endif // QIVIAMFMTUNER_H
diff --git a/src/ivimedia/qiviamfmtuner_p.h b/src/ivimedia/qiviamfmtuner_p.h
new file mode 100644
index 0000000..7abbd48
--- /dev/null
+++ b/src/ivimedia/qiviamfmtuner_p.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Pelagicore AG
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtIVI module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL-QTAS$
+** Commercial License Usage
+** Licensees holding valid commercial Qt Automotive Suite licenses may use
+** this file in accordance with the commercial license agreement provided
+** with the Software or, alternatively, in accordance with the terms
+** contained in a written agreement between you and The Qt Company. For
+** licensing terms and conditions see https://www.qt.io/terms-conditions.
+** For further information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+** SPDX-License-Identifier: LGPL-3.0
+**
+****************************************************************************/
+
+#ifndef QIVIAMFMTUNER_P_H
+#define QIVIAMFMTUNER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "private/qiviabstractfeature_p.h"
+
+#include "qiviamfmtuner.h"
+#include "qiviamfmtunerbackendinterface.h"
+
+#include <QtIviMedia/QIviTunerStation>
+
+QT_BEGIN_NAMESPACE
+
+class QIviAmFmTunerPrivate : public QIviAbstractFeaturePrivate
+{
+public:
+ QIviAmFmTunerPrivate(const QString &interface, QIviAmFmTuner *parent);
+
+ void init();
+ void clearToDefaults();
+ void onFrequencyChanged(int frequency);
+ void onBandChanged(QIviAmFmTuner::Band band);
+ void onStationChanged(const QVariant &station);
+
+ const QIviAmFmTunerStation *stationItem(const QVariant &item);
+ QIviAmFmTunerBackendInterface *tunerBackend() const;
+
+ QIviAmFmTuner * const q_ptr;
+ int m_frequency;
+ QIviAmFmTuner::Band m_band;
+ QVariant m_station;
+
+ Q_DECLARE_PUBLIC(QIviAmFmTuner)
+};
+
+QT_END_NAMESPACE
+
+#endif // QIVIAMFMTUNER_P_H
diff --git a/src/ivimedia/qiviamfmtunerbackendinterface.cpp b/src/ivimedia/qiviamfmtunerbackendinterface.cpp
new file mode 100644
index 0000000..cdfc4d6
--- /dev/null
+++ b/src/ivimedia/qiviamfmtunerbackendinterface.cpp
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Pelagicore AG
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtIVI module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL-QTAS$
+** Commercial License Usage
+** Licensees holding valid commercial Qt Automotive Suite licenses may use
+** this file in accordance with the commercial license agreement provided
+** with the Software or, alternatively, in accordance with the terms
+** contained in a written agreement between you and The Qt Company. For
+** licensing terms and conditions see https://www.qt.io/terms-conditions.
+** For further information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+** SPDX-License-Identifier: LGPL-3.0
+**
+****************************************************************************/
+
+#include "qiviamfmtunerbackendinterface.h"
+
+/*!
+ \class QIviAmFmTunerBackendInterface
+ \inmodule QtIviMedia
+ \ingroup backends
+ \inherits QObject
+ \brief The QIviAmFmTunerBackendInterface defines the interface for backends to the
+ QIviAmFmTuner feature class.
+
+ The QIviAmFmTunerBackendInterface is the interface used by \l QIviAmFmTuner
+
+ The interface is discovered by a \l QIviAmFmTuner object, which connects to it and sets it up.
+
+ <example of a fully featured backend>
+*/
+
+/*!
+ Constructs a backend interface.
+
+ The \a parent is sent to the QObject constructor.
+*/
+QIviAmFmTunerBackendInterface::QIviAmFmTunerBackendInterface(QObject *parent)
+ : QObject(parent)
+{
+}
+
+/*!
+ \fn QIviAmFmTunerBackendInterface::initialize()
+
+ Initializes the backend. This function is called, after a feature connected to the backend.
+ It is expected that this function will inform about the current state of the backend by emitting signals with the current status.
+*/
+
+/*!
+ \fn QIviAmFmTunerBackendInterface::setFrequency(int frequency)
+
+ Changes the frequency to the new value passed as \a frequency.
+
+ This method is expected to emit a \l frequencyChanged() signal when the internal state changes due to this function call
+*/
+
+/*!
+ \fn QIviAmFmTunerBackendInterface::setBand(QIviAmFmTuner::Band band)
+
+ Changes the band to the new value passed as \a band.
+
+ This method is expected to emit a \l bandChanged() signal when the internal state changes due to this function call
+*/
+
+/*!
+ \fn QIviAmFmTunerBackendInterface::stepUp()
+
+ Increases the frequency by the current bands step size.
+
+ \sa frequencyChanged stationChanged
+*/
+
+/*!
+ \fn QIviAmFmTunerBackendInterface::stepDown()
+
+ Decreases the frequency by the current bands step size.
+
+ \sa frequencyChanged stationChanged
+*/
+
+/*!
+ \fn QIviAmFmTunerBackendInterface::seekUp()
+
+ Seeks the next available Station in upwards direction and tunes it.
+
+ If the end of the band where hit without finding a station, the search will be continued from the beginning of the band.
+
+ \sa frequencyChanged stationChanged
+*/
+
+/*!
+ \fn QIviAmFmTunerBackendInterface::seekDown()
+
+ Seeks the next available Station in downwards direction and tunes it.
+
+ If the beginning of the band where hit without finding a station, the search will be continued from the end of the band.
+
+ \sa frequencyChanged stationChanged
+*/
+
+/*!
+ \fn QIviAmFmTunerBackendInterface::frequencyChanged(int frequency)
+
+ Emitted when the current frequency changed. The new value is passed as \a frequency.
+*/
+
+/*!
+ \fn QIviAmFmTunerBackendInterface::bandChanged(QIviAmFmTuner::Band band)
+
+ Emitted when the current band changed. The new value is passed as \a band.
+*/
+
+/*!
+ \fn QIviAmFmTunerBackendInterface::stationChanged(QVariant station)
+
+ Emitted when the current station changed. The new station is passed as \a station.
+*/
diff --git a/src/ivimedia/qiviamfmtunerbackendinterface.h b/src/ivimedia/qiviamfmtunerbackendinterface.h
new file mode 100644
index 0000000..9e06798
--- /dev/null
+++ b/src/ivimedia/qiviamfmtunerbackendinterface.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Pelagicore AG
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtIVI module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL-QTAS$
+** Commercial License Usage
+** Licensees holding valid commercial Qt Automotive Suite licenses may use
+** this file in accordance with the commercial license agreement provided
+** with the Software or, alternatively, in accordance with the terms
+** contained in a written agreement between you and The Qt Company. For
+** licensing terms and conditions see https://www.qt.io/terms-conditions.
+** For further information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+** SPDX-License-Identifier: LGPL-3.0
+**
+****************************************************************************/
+
+#ifndef QIVIAMFMTUNERBACKENDINTERFACE_H
+#define QIVIAMFMTUNERBACKENDINTERFACE_H
+
+#include <QtIviMedia/qtivimediaglobal.h>
+#include <QtIviMedia/QIviAmFmTuner>
+#include <QtCore/QObject>
+
+QT_BEGIN_NAMESPACE
+
+class QIviPlayableItem;
+
+class Q_QTIVIMEDIA_EXPORT QIviAmFmTunerBackendInterface : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit QIviAmFmTunerBackendInterface(QObject *parent = Q_NULLPTR);
+
+ virtual void initialize() = 0;
+ virtual void setFrequency(int frequency) = 0;
+ virtual void setBand(QIviAmFmTuner::Band band) = 0;
+ virtual void stepUp() = 0;
+ virtual void stepDown() = 0;
+ virtual void seekUp() = 0;
+ virtual void seekDown() = 0;
+
+Q_SIGNALS:
+ void frequencyChanged(int frequency);
+ void bandChanged(QIviAmFmTuner::Band band);
+ void stationChanged(QVariant station);
+
+};
+
+QT_END_NAMESPACE
+
+#endif // QIVIAMFMTUNERBACKENDINTERFACE_H
diff --git a/src/ivimedia/qivitunerstation.cpp b/src/ivimedia/qivitunerstation.cpp
new file mode 100644
index 0000000..7a5d9d9
--- /dev/null
+++ b/src/ivimedia/qivitunerstation.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Pelagicore AG
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtIVI module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL-QTAS$
+** Commercial License Usage
+** Licensees holding valid commercial Qt Automotive Suite licenses may use
+** this file in accordance with the commercial license agreement provided
+** with the Software or, alternatively, in accordance with the terms
+** contained in a written agreement between you and The Qt Company. For
+** licensing terms and conditions see https://www.qt.io/terms-conditions.
+** For further information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+** SPDX-License-Identifier: LGPL-3.0
+**
+****************************************************************************/
+
+#include "qivitunerstation.h"
+
+QIviTunerStation::QIviTunerStation()
+ : QIviSearchAndBrowseListItem()
+{
+}
+
+QIviTunerStation::~QIviTunerStation()
+{
+}
+
+QIviAmFmTunerStation::QIviAmFmTunerStation()
+ : QIviTunerStation()
+{
+}
+
+QIviAmFmTunerStation::~QIviAmFmTunerStation()
+{
+}
diff --git a/src/ivimedia/qivitunerstation.h b/src/ivimedia/qivitunerstation.h
new file mode 100644
index 0000000..bbdda77
--- /dev/null
+++ b/src/ivimedia/qivitunerstation.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Pelagicore AG
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtIVI module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL-QTAS$
+** Commercial License Usage
+** Licensees holding valid commercial Qt Automotive Suite licenses may use
+** this file in accordance with the commercial license agreement provided
+** with the Software or, alternatively, in accordance with the terms
+** contained in a written agreement between you and The Qt Company. For
+** licensing terms and conditions see https://www.qt.io/terms-conditions.
+** For further information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+** SPDX-License-Identifier: LGPL-3.0
+**
+****************************************************************************/
+
+#ifndef QIVITUNERSTATION_H
+#define QIVITUNERSTATION_H
+
+#include <QtIviMedia/qtivimediaglobal.h>
+#include <QtIviMedia/QIviAmFmTuner>
+#include <QtIviCore/QIviSearchAndBrowseListItem>
+
+QT_BEGIN_NAMESPACE
+
+class Q_QTIVIMEDIA_EXPORT QIviTunerStation : public QIviSearchAndBrowseListItem
+{
+ Q_GADGET
+
+ Q_PROPERTY(QString stationName READ stationName)
+ Q_PROPERTY(int frequency READ frequency)
+
+public:
+ QIviTunerStation();
+ virtual ~QIviTunerStation();
+
+ virtual QString stationName() const { return QString(); }
+ virtual int frequency() const { return -1; }
+};
+
+class Q_QTIVIMEDIA_EXPORT QIviAmFmTunerStation : public QIviTunerStation
+{
+ Q_GADGET
+
+ Q_PROPERTY(QIviAmFmTuner::Band band READ band)
+
+public:
+ QIviAmFmTunerStation();
+ virtual ~QIviAmFmTunerStation();
+
+ virtual QIviAmFmTuner::Band band() const { return QIviAmFmTuner::FMBand; }
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QIviTunerStation)
+Q_DECLARE_METATYPE(QIviAmFmTunerStation)
+
+#endif // QIVITUNERSTATION_H
diff --git a/src/plugins/ivimedia/ivimedia.pro b/src/plugins/ivimedia/ivimedia.pro
index 6dbe254..3afabaa 100644
--- a/src/plugins/ivimedia/ivimedia.pro
+++ b/src/plugins/ivimedia/ivimedia.pro
@@ -1,2 +1,3 @@
TEMPLATE = subdirs
-SUBDIRS = media_simulator
+SUBDIRS = media_simulator \
+ tuner_simulator
diff --git a/src/plugins/ivimedia/media_simulator/media_simulator.json b/src/plugins/ivimedia/media_simulator/media_simulator.json
index 5e15d21..565930d 100644
--- a/src/plugins/ivimedia/media_simulator/media_simulator.json
+++ b/src/plugins/ivimedia/media_simulator/media_simulator.json
@@ -1,3 +1,8 @@
{
- "interfaces" : [ "com.qt-project.qtivi.MediaPlayer", "com.qt-project.qtivi.SearchAndBrowseModel", "com.qt-project.qtivi.MediaDiscovery", "com.qt-project.qtivi.MediaIndexer"]
+ "interfaces" : [
+ "com.qt-project.qtivi.MediaPlayer",
+ "com.qt-project.qtivi.SearchAndBrowseModel",
+ "com.qt-project.qtivi.MediaDiscovery",
+ "com.qt-project.qtivi.MediaIndexer"
+ ]
}
diff --git a/src/plugins/ivimedia/media_simulator/media_simulator.pro b/src/plugins/ivimedia/media_simulator/media_simulator.pro
index fca52ad..3279207 100644
--- a/src/plugins/ivimedia/media_simulator/media_simulator.pro
+++ b/src/plugins/ivimedia/media_simulator/media_simulator.pro
@@ -27,7 +27,7 @@ HEADERS += \
mediadiscoverybackend.h \
usbdevice.h \
usbbrowsebackend.h \
- mediaindexerbackend.h
+ mediaindexerbackend.h \
SOURCES += \
mediaplugin.cpp \
@@ -36,4 +36,4 @@ SOURCES += \
mediadiscoverybackend.cpp \
usbdevice.cpp \
usbbrowsebackend.cpp \
- mediaindexerbackend.cpp
+ mediaindexerbackend.cpp \
diff --git a/src/plugins/ivimedia/media_simulator/mediaplugin.h b/src/plugins/ivimedia/media_simulator/mediaplugin.h
index a391277..8ff2ba5 100644
--- a/src/plugins/ivimedia/media_simulator/mediaplugin.h
+++ b/src/plugins/ivimedia/media_simulator/mediaplugin.h
@@ -50,6 +50,7 @@ class MediaPlayerBackend;
class SearchAndBrowseBackend;
class MediaDiscoveryBackend;
class MediaIndexerBackend;
+class AmFmTunerBackend;
class MediaPlugin : public QObject, QIviServiceInterface
{
@@ -68,6 +69,7 @@ private:
SearchAndBrowseBackend *m_browse;
MediaDiscoveryBackend *m_discovery;
MediaIndexerBackend *m_indexer;
+ AmFmTunerBackend *m_amfmtuner;
QSqlDatabase m_db;
};
diff --git a/src/plugins/ivimedia/tuner_simulator/amfmtunerbackend.cpp b/src/plugins/ivimedia/tuner_simulator/amfmtunerbackend.cpp
new file mode 100644
index 0000000..a7b64f0
--- /dev/null
+++ b/src/plugins/ivimedia/tuner_simulator/amfmtunerbackend.cpp
@@ -0,0 +1,189 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Pelagicore AG
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtIvi module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL-QTAS$
+** Commercial License Usage
+** Licensees holding valid commercial Qt Automotive Suite licenses may use
+** this file in accordance with the commercial license agreement provided
+** with the Software or, alternatively, in accordance with the terms
+** contained in a written agreement between you and The Qt Company. For
+** licensing terms and conditions see https://www.qt.io/terms-conditions.
+** For further information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+** SPDX-License-Identifier: LGPL-3.0
+**
+****************************************************************************/
+
+#include "amfmtunerbackend.h"
+
+#include <QtDebug>
+
+AmFmTunerBackend::AmFmTunerBackend(QObject *parent)
+ : QIviAmFmTunerBackendInterface(parent)
+ , m_band(QIviAmFmTuner::FMBand)
+{
+ qRegisterMetaType<AmFmStation>();
+
+ QVector<AmFmStation> fm_stations;
+ AmFmStation radioQt;
+ radioQt.setId("0");
+ radioQt.setStationName("Radio Qt");
+ radioQt.setFrequency(87500000);
+ radioQt.setBand(QIviAmFmTuner::FMBand);
+ fm_stations.append(radioQt);
+
+ AmFmStation qtRocksNonStop;
+ qtRocksNonStop.setId("1");
+ qtRocksNonStop.setStationName("Qt Rocks non-stop");
+ qtRocksNonStop.setFrequency(102500000);
+ qtRocksNonStop.setBand(QIviAmFmTuner::FMBand);
+ fm_stations.append(qtRocksNonStop);
+ BandData fmdata;
+ fmdata.m_frequency = 87500000;
+ fmdata.m_stepSize = 100000;
+ fmdata.m_stations = fm_stations;
+ m_bandHash.insert(QIviAmFmTuner::FMBand, fmdata);
+
+ BandData amdata;
+ amdata.m_frequency = 520000;
+ amdata.m_stepSize = 10000;
+ m_bandHash.insert(QIviAmFmTuner::AMBand, amdata);
+}
+
+void AmFmTunerBackend::initialize()
+{
+ emit bandChanged(m_band);
+ emit frequencyChanged(m_bandHash[m_band].m_frequency);
+ emit stationChanged(QVariant::fromValue(m_bandHash[m_band].m_stations.at(0)));
+}
+
+void AmFmTunerBackend::setFrequency(int frequency)
+{
+ if (m_bandHash[m_band].m_frequency == frequency)
+ return;
+
+ qWarning() << "SIMULATION Frequency changed to" << frequency;
+
+ m_bandHash[m_band].m_frequency = frequency;
+ emit frequencyChanged(frequency);
+ emit stationChanged(QVariant::fromValue(stationAt(m_bandHash[m_band].m_frequency)));
+}
+
+void AmFmTunerBackend::setBand(QIviAmFmTuner::Band band)
+{
+ if (m_band == band)
+ return;
+
+ qWarning() << "SIMULATION Band changed to" << band;
+
+ m_band = band;
+ emit bandChanged(band);
+ emit frequencyChanged(m_bandHash[m_band].m_frequency);
+ emit stationChanged(QVariant::fromValue(stationAt(m_bandHash[m_band].m_frequency)));
+}
+
+void AmFmTunerBackend::stepUp()
+{
+ qWarning() << "SIMULATION Step Up";
+ setFrequency(m_bandHash[m_band].m_frequency + m_bandHash[m_band].m_stepSize);
+}
+
+void AmFmTunerBackend::stepDown()
+{
+ qWarning() << "SIMULATION Step Down";
+ setFrequency(m_bandHash[m_band].m_frequency - m_bandHash[m_band].m_stepSize);
+}
+
+void AmFmTunerBackend::seekUp()
+{
+ qWarning() << "SIMULATION Seek Up";
+
+ QVector<AmFmStation> stations = m_bandHash[m_band].m_stations;
+ if (stations.count() == 0) {
+ return;
+ } else if (stations.count() == 1) {
+ setCurrentStation(stations.at(0));
+ } else {
+ int index = stationIndexFromFrequency(m_bandHash[m_band].m_frequency);
+ index++;
+ if (index >= stations.count())
+ index = 0;
+
+ setCurrentStation(stations.at(index));
+ }
+}
+
+void AmFmTunerBackend::seekDown()
+{
+ qWarning() << "SIMULATION Seek Down";
+
+ QVector<AmFmStation> stations = m_bandHash[m_band].m_stations;
+ if (stations.count() == 0) {
+ return;
+ } else if (stations.count() == 1) {
+ setCurrentStation(stations.at(0));
+ } else {
+ int index = stationIndexFromFrequency(m_bandHash[m_band].m_frequency);
+ index--;
+ if (index < 0)
+ index = stations.count() - 1;
+
+ setCurrentStation(stations.at(index));
+ }
+}
+
+void AmFmTunerBackend::setCurrentStation(const AmFmStation& station)
+{
+ m_bandHash[m_band].m_frequency = station.frequency();
+
+ qWarning() << "SIMULATION Station changed to" << station.stationName() << station.frequency();
+
+ emit frequencyChanged(station.frequency());
+ emit stationChanged(QVariant::fromValue(station));
+}
+
+int AmFmTunerBackend::stationIndexFromFrequency(int frequency) const
+{
+ QVector<AmFmStation> stations = m_bandHash[m_band].m_stations;
+ for (int i=0; i < stations.count(); i++) {
+ const AmFmStation& station = stations.at(i);
+ if (station.frequency() == frequency)
+ return i;
+ }
+
+ return -1;
+}
+
+AmFmStation AmFmTunerBackend::stationAt(int frequency) const
+{
+ int index = stationIndexFromFrequency(frequency);
+ if (index != -1)
+ return m_bandHash[m_band].m_stations.at(index);
+
+ return AmFmStation();
+}
diff --git a/src/plugins/ivimedia/tuner_simulator/amfmtunerbackend.h b/src/plugins/ivimedia/tuner_simulator/amfmtunerbackend.h
new file mode 100644
index 0000000..20f33b0
--- /dev/null
+++ b/src/plugins/ivimedia/tuner_simulator/amfmtunerbackend.h
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Pelagicore AG
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtIvi module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL-QTAS$
+** Commercial License Usage
+** Licensees holding valid commercial Qt Automotive Suite licenses may use
+** this file in accordance with the commercial license agreement provided
+** with the Software or, alternatively, in accordance with the terms
+** contained in a written agreement between you and The Qt Company. For
+** licensing terms and conditions see https://www.qt.io/terms-conditions.
+** For further information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+** SPDX-License-Identifier: LGPL-3.0
+**
+****************************************************************************/
+
+#ifndef AMFMTUNERBACKEND_H
+#define AMFMTUNERBACKEND_H
+
+#include <QtIviMedia/QIviAmFmTunerBackendInterface>
+#include <QtIviMedia/QIviTunerStation>
+
+class AmFmStation : public QIviAmFmTunerStation
+{
+ Q_GADGET
+
+public:
+ virtual QString id() const { return m_id; }
+ void setId(const QString &id) { m_id = id; }
+ virtual QString name() const { return m_stationName; }
+ virtual QString type() const { return "amfmstation"; }
+
+ virtual QString stationName() const { return m_stationName; }
+ void setStationName(const QString &name) { m_stationName = name; }
+
+ virtual int frequency() const { return m_frequency; }
+ void setFrequency(int frequency) { m_frequency = frequency; }
+
+ virtual QIviAmFmTuner::Band band() const { return m_band; }
+ void setBand(QIviAmFmTuner::Band band) { m_band = band; }
+
+private:
+ QString m_id;
+ QString m_stationName;
+ int m_frequency;
+ QIviAmFmTuner::Band m_band;
+};
+Q_DECLARE_METATYPE(AmFmStation)
+
+class AmFmTunerBackend : public QIviAmFmTunerBackendInterface
+{
+ Q_OBJECT
+public:
+ explicit AmFmTunerBackend(QObject *parent = 0);
+
+ virtual void initialize() Q_DECL_OVERRIDE;
+ virtual void setFrequency(int frequency) Q_DECL_OVERRIDE;
+ virtual void setBand(QIviAmFmTuner::Band band) Q_DECL_OVERRIDE;
+ virtual void stepUp() Q_DECL_OVERRIDE;
+ virtual void stepDown() Q_DECL_OVERRIDE;
+ virtual void seekUp() Q_DECL_OVERRIDE;
+ virtual void seekDown() Q_DECL_OVERRIDE;
+
+private:
+ void setCurrentStation(const AmFmStation &station);
+ int stationIndexFromFrequency(int frequency) const;
+ AmFmStation stationAt(int frequency) const;
+
+ QIviAmFmTuner::Band m_band;
+ struct BandData {
+ QVector<AmFmStation> m_stations;
+ int m_stepSize;
+ int m_frequency;
+ };
+ QHash<QIviAmFmTuner::Band, BandData> m_bandHash;
+
+ friend class SearchAndBrowseBackend;
+};
+
+#endif // AMFMTUNERBACKEND_H
diff --git a/src/plugins/ivimedia/tuner_simulator/searchandbrowsebackend.cpp b/src/plugins/ivimedia/tuner_simulator/searchandbrowsebackend.cpp
new file mode 100644
index 0000000..0159796
--- /dev/null
+++ b/src/plugins/ivimedia/tuner_simulator/searchandbrowsebackend.cpp
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Pelagicore AG
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtIvi module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL-QTAS$
+** Commercial License Usage
+** Licensees holding valid commercial Qt Automotive Suite licenses may use
+** this file in accordance with the commercial license agreement provided
+** with the Software or, alternatively, in accordance with the terms
+** contained in a written agreement between you and The Qt Company. For
+** licensing terms and conditions see https://www.qt.io/terms-conditions.
+** For further information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+** SPDX-License-Identifier: LGPL-3.0
+**
+****************************************************************************/
+
+#include "searchandbrowsebackend.h"
+#include "amfmtunerbackend.h"
+
+#include <QtDebug>
+
+SearchAndBrowseBackend::SearchAndBrowseBackend(AmFmTunerBackend *tunerBackend, QObject *parent)
+ : QIviSearchAndBrowseModelInterface(parent)
+ , m_tunerBackend(tunerBackend)
+{
+ qRegisterMetaType<AmFmStation>();
+ registerContentType<AmFmStation>("station");
+}
+
+
+QIviSearchAndBrowseModelInterface::Flags SearchAndBrowseBackend::supportedFlags() const
+{
+ return QIviSearchAndBrowseModelInterface::Flags(
+ QIviSearchAndBrowseModelInterface::SupportsStatelessNavigation |
+ QIviSearchAndBrowseModelInterface::SupportsGetSize);
+}
+
+void SearchAndBrowseBackend::fetchData(const QUuid &identifier, const QString &type, QIviAbstractQueryTerm *term, const QList<QIviOrderTerm> &orderTerms, int start, int count)
+{
+ Q_UNUSED(term)
+ Q_UNUSED(orderTerms)
+
+ if (type != "station")
+ return;
+
+ QVector<AmFmStation> stations = m_tunerBackend->m_bandHash[QIviAmFmTuner::AMBand].m_stations + m_tunerBackend->m_bandHash[QIviAmFmTuner::FMBand].m_stations;
+
+ emit countChanged(identifier, stations.length());
+ QVariantList requestedStations;
+
+ int size = qMin(count, stations.length());
+ for (int i = start; i < size; i++)
+ requestedStations.append(QVariant::fromValue(stations.at(i)));
+
+ emit dataFetched(identifier, requestedStations, start, start + count < stations.length());
+}
+
+bool SearchAndBrowseBackend::canGoBack(const QUuid &identifier, const QString &type)
+{
+ Q_UNUSED(identifier)
+ Q_UNUSED(type)
+ return false;
+}
+
+QString SearchAndBrowseBackend::goBack(const QUuid &identifier, const QString &type)
+{
+ Q_UNUSED(identifier)
+ Q_UNUSED(type)
+ return QString();
+}
+
+bool SearchAndBrowseBackend::canGoForward(const QUuid &identifier, const QString &type, const QString &itemId)
+{
+ Q_UNUSED(identifier)
+ Q_UNUSED(type)
+ Q_UNUSED(itemId)
+ return false;
+}
+
+QString SearchAndBrowseBackend::goForward(const QUuid &identifier, const QString &type, const QString &itemId)
+{
+ Q_UNUSED(identifier)
+ Q_UNUSED(type)
+ Q_UNUSED(itemId)
+ return QString();
+}
diff --git a/src/plugins/ivimedia/tuner_simulator/searchandbrowsebackend.h b/src/plugins/ivimedia/tuner_simulator/searchandbrowsebackend.h
new file mode 100644
index 0000000..ae19a51
--- /dev/null
+++ b/src/plugins/ivimedia/tuner_simulator/searchandbrowsebackend.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Pelagicore AG
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtIvi module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL-QTAS$
+** Commercial License Usage
+** Licensees holding valid commercial Qt Automotive Suite licenses may use
+** this file in accordance with the commercial license agreement provided
+** with the Software or, alternatively, in accordance with the terms
+** contained in a written agreement between you and The Qt Company. For
+** licensing terms and conditions see https://www.qt.io/terms-conditions.
+** For further information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+** SPDX-License-Identifier: LGPL-3.0
+**
+****************************************************************************/
+
+#ifndef SEARCHBACKEND_H
+#define SEARCHBACKEND_H
+
+#include <QtIviCore/QIviSearchAndBrowseModelInterface>
+#include <QtIviCore/QIviSearchAndBrowseModel>
+
+class AmFmTunerBackend;
+
+class SearchAndBrowseBackend : public QIviSearchAndBrowseModelInterface
+{
+ Q_OBJECT
+public:
+ explicit SearchAndBrowseBackend(AmFmTunerBackend *tunerBackend, QObject *parent = Q_NULLPTR);
+
+ virtual Flags supportedFlags() const Q_DECL_OVERRIDE;
+ virtual void fetchData(const QUuid &identifier, const QString &type, QIviAbstractQueryTerm *term, const QList<QIviOrderTerm> &orderTerms, int start, int count) Q_DECL_OVERRIDE;
+ virtual bool canGoBack(const QUuid &identifier, const QString &type) Q_DECL_OVERRIDE;
+ virtual QString goBack(const QUuid &identifier, const QString &type) Q_DECL_OVERRIDE;
+ virtual bool canGoForward(const QUuid &identifier, const QString &type, const QString &itemId) Q_DECL_OVERRIDE;
+ virtual QString goForward(const QUuid &identifier, const QString &type, const QString &itemId) Q_DECL_OVERRIDE;
+
+private:
+
+ AmFmTunerBackend *m_tunerBackend;
+};
+
+#endif // SEARCHBACKEND_H
diff --git a/src/plugins/ivimedia/tuner_simulator/tuner_simulator.json b/src/plugins/ivimedia/tuner_simulator/tuner_simulator.json
new file mode 100644
index 0000000..742135f
--- /dev/null
+++ b/src/plugins/ivimedia/tuner_simulator/tuner_simulator.json
@@ -0,0 +1,6 @@
+{
+ "interfaces" : [
+ "com.qt-project.qtivi.AmFmTuner",
+ "com.qt-project.qtivi.SearchAndBrowseModel"
+ ]
+}
diff --git a/src/plugins/ivimedia/tuner_simulator/tuner_simulator.pro b/src/plugins/ivimedia/tuner_simulator/tuner_simulator.pro
new file mode 100644
index 0000000..d11e77d
--- /dev/null
+++ b/src/plugins/ivimedia/tuner_simulator/tuner_simulator.pro
@@ -0,0 +1,21 @@
+TARGET = tuner_simulator
+
+PLUGIN_TYPE = qtivi
+PLUGIN_EXTENDS = qtivi
+PLUGIN_CLASS_NAME = QIviServiceInterface
+
+QT += core ivicore ivimedia
+
+load(qt_plugin)
+
+DISTFILES += tuner_simulator.json
+
+HEADERS += \
+ amfmtunerbackend.h \
+ searchandbrowsebackend.h \
+ tunerplugin.h
+
+SOURCES += \
+ amfmtunerbackend.cpp \
+ searchandbrowsebackend.cpp \
+ tunerplugin.cpp
diff --git a/src/plugins/ivimedia/tuner_simulator/tunerplugin.cpp b/src/plugins/ivimedia/tuner_simulator/tunerplugin.cpp
new file mode 100644
index 0000000..d54efe7
--- /dev/null
+++ b/src/plugins/ivimedia/tuner_simulator/tunerplugin.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Pelagicore AG
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtIvi module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL-QTAS$
+** Commercial License Usage
+** Licensees holding valid commercial Qt Automotive Suite licenses may use
+** this file in accordance with the commercial license agreement provided
+** with the Software or, alternatively, in accordance with the terms
+** contained in a written agreement between you and The Qt Company. For
+** licensing terms and conditions see https://www.qt.io/terms-conditions.
+** For further information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+** SPDX-License-Identifier: LGPL-3.0
+**
+****************************************************************************/
+
+#include "tunerplugin.h"
+#include "amfmtunerbackend.h"
+#include "searchandbrowsebackend.h"
+
+#include <QtIviMedia/QIviMediaPlayer>
+#include <QtIviCore/QIviSearchAndBrowseModel>
+#include <QStringList>
+#include <QtDebug>
+
+TunerPlugin::TunerPlugin(QObject *parent)
+ : QObject(parent)
+ , m_amfmtuner(new AmFmTunerBackend(this))
+ , m_searchbackend(new SearchAndBrowseBackend(m_amfmtuner, this))
+{
+}
+
+QStringList TunerPlugin::interfaces() const
+{
+ QStringList list;
+ list << QIviStringSearchAndBrowseModelInterfaceName;
+ list << QIviStringAmFmTunerInterfaceName;
+ return list;
+}
+
+QObject *TunerPlugin::interfaceInstance(const QString &interface) const
+{
+ if (interface == QIviStringAmFmTunerInterfaceName)
+ return m_amfmtuner;
+ else if (interface == QIviStringSearchAndBrowseModelInterfaceName)
+ return m_searchbackend;
+
+ return 0;
+}
diff --git a/src/plugins/ivimedia/tuner_simulator/tunerplugin.h b/src/plugins/ivimedia/tuner_simulator/tunerplugin.h
new file mode 100644
index 0000000..e836653
--- /dev/null
+++ b/src/plugins/ivimedia/tuner_simulator/tunerplugin.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Pelagicore AG
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtIvi module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL-QTAS$
+** Commercial License Usage
+** Licensees holding valid commercial Qt Automotive Suite licenses may use
+** this file in accordance with the commercial license agreement provided
+** with the Software or, alternatively, in accordance with the terms
+** contained in a written agreement between you and The Qt Company. For
+** licensing terms and conditions see https://www.qt.io/terms-conditions.
+** For further information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+** SPDX-License-Identifier: LGPL-3.0
+**
+****************************************************************************/
+
+#ifndef TUNERPLUGIN_H
+#define TUNERPLUGIN_H
+
+#include <QtIviCore/QIviServiceInterface>
+
+class AmFmTunerBackend;
+class SearchAndBrowseBackend;
+
+class TunerPlugin : public QObject, QIviServiceInterface
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "com.pelagicore.QIviServiceInterface" FILE "tuner_simulator.json")
+ Q_INTERFACES(QIviServiceInterface)
+
+public:
+ explicit TunerPlugin(QObject *parent = Q_NULLPTR);
+
+ QStringList interfaces() const;
+ QObject *interfaceInstance(const QString &interface) const;
+
+private:
+ AmFmTunerBackend *m_amfmtuner;
+ SearchAndBrowseBackend *m_searchbackend;
+};
+
+#endif // TUNERPLUGIN_H