Added RDS functionality to the QRadioTuner/QDeclarativeRadio
authorSami Nurmenniemi <ext-sami.nurmenniemi@nokia.com>
Tue, 11 Oct 2011 06:06:12 +0000 (09:06 +0300)
committerQt by Nokia <qt-info@nokia.com>
Fri, 21 Oct 2011 01:40:14 +0000 (03:40 +0200)
Change-Id: I865e3caba82977002cf1f01f1d64ee0a42de77c6
Reviewed-by: Jonas Rabbe <jonas.rabbe@nokia.com>
Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
33 files changed:
src/imports/multimedia/multimedia.cpp
src/imports/multimedia/multimedia.pro
src/imports/multimedia/qdeclarativeradio.cpp
src/imports/multimedia/qdeclarativeradio_p.h
src/imports/multimedia/qdeclarativeradiodata.cpp [new file with mode: 0644]
src/imports/multimedia/qdeclarativeradiodata_p.h [new file with mode: 0644]
src/multimedia/multimedia.pro
src/multimedia/qradiodata.cpp [new file with mode: 0644]
src/multimedia/qradiodata.h [new file with mode: 0644]
src/multimedia/qradiodatacontrol.cpp [new file with mode: 0644]
src/multimedia/qradiodatacontrol.h [new file with mode: 0644]
src/multimedia/qradiotuner.cpp
src/multimedia/qradiotuner.h
src/multimedia/qradiotunercontrol.cpp
src/multimedia/qradiotunercontrol.h
src/plugins/fakeradio/fakeradio.pro
src/plugins/fakeradio/fakeradiodatacontrol.cpp [new file with mode: 0644]
src/plugins/fakeradio/fakeradiodatacontrol.h [new file with mode: 0644]
src/plugins/fakeradio/fakeradioservice.cpp
src/plugins/fakeradio/fakeradioservice.h
src/plugins/fakeradio/fakeradioserviceplugin.cpp
src/plugins/fakeradio/fakeradiotunercontrol.cpp
src/plugins/fakeradio/fakeradiotunercontrol.h
tests/auto/multimedia.pro
tests/auto/qmultimedia_common/mockradio.pri
tests/auto/qmultimedia_common/mockradiodatacontrol.h [new file with mode: 0644]
tests/auto/qmultimedia_common/mockradiotunercontrol.h
tests/auto/qradiodata/main.cpp [new file with mode: 0755]
tests/auto/qradiodata/qradiodata.pro [new file with mode: 0644]
tests/auto/qradiodata/tst_qradiodata.cpp [new file with mode: 0644]
tests/auto/qradiodata/tst_qradiodata.h [new file with mode: 0644]
tests/auto/qradiotuner/tst_qradiotuner.cpp
tests/auto/qradiotuner/tst_qradiotuner.h

index cabf8fd246a3f8445215130223c22c0e759e1959..deb47c5d3c6c4b5580ca32fadbe090fedee341aa 100644 (file)
@@ -49,6 +49,7 @@
 #include "qdeclarativeaudio_p.h"
 #include "qdeclarativevideooutput_p.h"
 #include "qdeclarativeradio_p.h"
+#include "qdeclarativeradiodata_p.h"
 #include "qdeclarativebackgroundaudio_p.h"
 #include "qdeclarativecamera_p.h"
 #include "qdeclarativecamerapreviewprovider_p.h"
@@ -76,6 +77,7 @@ public:
         qmlRegisterType<QDeclarativeAudio>(uri, 4, 0, "MediaPlayer");
         qmlRegisterType<QDeclarativeVideoOutput>(uri, 4, 0, "VideoOutput");
         qmlRegisterType<QDeclarativeRadio>(uri, 4, 0, "Radio");
+        qmlRegisterType<QDeclarativeRadioData>(uri, 4, 0, "RadioData");
         qmlRegisterType<QDeclarativeBackgroundAudio>(uri, 4, 0, "BackgroundAudio");
         qmlRegisterType<QDeclarativeCamera>(uri, 4, 0, "Camera");
         qmlRegisterUncreatableType<QDeclarativeCameraCapture>(uri, 4, 0, "CameraCapture",
index 2043130d84aee7e5107e2b89067452718577f6c0..d5b6ae53b53c9b2313aa1f14234109bf60472b63 100644 (file)
@@ -17,6 +17,7 @@ HEADERS += \
         qsgvideonode_i420.h \
         qsgvideonode_rgb.h \
         qdeclarativeradio_p.h \
+        qdeclarativeradiodata_p.h \
         qdeclarativebackgroundaudio_p.h \
         qdeclarativecamera_p.h \
         qdeclarativecameracapture_p.h \
@@ -36,6 +37,7 @@ SOURCES += \
         qsgvideonode_i420.cpp \
         qsgvideonode_rgb.cpp \
         qdeclarativeradio.cpp \
+        qdeclarativeradiodata.cpp \
         qdeclarativebackgroundaudio.cpp \
         qdeclarativecamera.cpp \
         qdeclarativecameracapture.cpp \
index 5cac32e6f0b3acec8f6cae4a5ad0d5ebce26c9a4..e2b495db52e9777c5e601dad21ed4d3c51065346 100644 (file)
@@ -58,6 +58,7 @@ QDeclarativeRadio::QDeclarativeRadio(QObject *parent) :
     connect(m_radioTuner, SIGNAL(signalStrengthChanged(int)), this, SIGNAL(signalStrengthChanged(int)));
     connect(m_radioTuner, SIGNAL(volumeChanged(int)), this, SIGNAL(volumeChanged(int)));
     connect(m_radioTuner, SIGNAL(mutedChanged(bool)), this, SIGNAL(mutedChanged(bool)));
+    connect(m_radioTuner, SIGNAL(stationFound(int, QString)), this, SIGNAL(stationFound(int, QString)));
 
     connect(m_radioTuner, SIGNAL(error(QRadioTuner::Error)), this, SLOT(_q_error(QRadioTuner::Error)));
 }
@@ -171,6 +172,11 @@ void QDeclarativeRadio::scanUp()
     m_radioTuner->searchForward();
 }
 
+void QDeclarativeRadio::searchAllStations(QDeclarativeRadio::SearchMode searchMode)
+{
+    m_radioTuner->searchAllStations(static_cast<QRadioTuner::SearchMode>(searchMode));
+}
+
 void QDeclarativeRadio::tuneDown()
 {
     int f = frequency();
index eddf93bfc36753c9d92725c11e7e6358f5a5f4ad..d719f6fa3fe08e08f8ec95999f3b88b794b4d028 100644 (file)
@@ -79,6 +79,7 @@ class QDeclarativeRadio : public QObject
     Q_ENUMS(Band)
     Q_ENUMS(Error)
     Q_ENUMS(StereoMode)
+    Q_ENUMS(SearchMode)
 
 public:
     enum State {
@@ -107,6 +108,11 @@ public:
         Auto = QRadioTuner::Auto
     };
 
+    enum SearchMode {
+        SearchFast = QRadioTuner::SearchFast,
+        SearchGetStationId = QRadioTuner::SearchGetStationId
+    };
+
     QDeclarativeRadio(QObject *parent = 0);
     ~QDeclarativeRadio();
 
@@ -139,6 +145,8 @@ public Q_SLOTS:
     void scanUp();
     void tuneUp();
     void tuneDown();
+    void searchAllStations(QDeclarativeRadio::SearchMode searchMode = QDeclarativeRadio::SearchFast );
+
     void start();
     void stop();
 
@@ -151,6 +159,7 @@ Q_SIGNALS:
     void signalStrengthChanged(int signalStrength);
     void volumeChanged(int volume);
     void mutedChanged(bool muted);
+    void stationFound(int frequency, QString stationId);
 
     void errorChanged();
     void error(QDeclarativeRadio::Error errorCode);
diff --git a/src/imports/multimedia/qdeclarativeradiodata.cpp b/src/imports/multimedia/qdeclarativeradiodata.cpp
new file mode 100644 (file)
index 0000000..debea99
--- /dev/null
@@ -0,0 +1,118 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeradiodata_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QDeclarativeRadioData::QDeclarativeRadioData(QObject *parent) :
+    QObject(parent),
+    m_radioData(0)
+{
+    m_radioData = new QRadioData(this);
+
+    connect(m_radioData, SIGNAL(programTypeChanged(QRadioData::ProgramType)), this,
+                                 SLOT(_q_programTypeChanged(QRadioData::ProgramType)));
+
+    connect(m_radioData, SIGNAL(stationIdChanged(QString)), this, SIGNAL(stationIdChanged(QString)));
+    connect(m_radioData, SIGNAL(programTypeNameChanged(QString)), this, SIGNAL(programTypeNameChanged(QString)));
+    connect(m_radioData, SIGNAL(stationNameChanged(QString)), this, SIGNAL(stationNameChanged(QString)));
+    connect(m_radioData, SIGNAL(radioTextChanged(QString)), this, SIGNAL(radioTextChanged(QString)));
+    connect(m_radioData, SIGNAL(alternativeFrequenciesEnabledChanged(bool)), this,
+                         SIGNAL(alternativeFrequenciesEnabledChanged(bool)));
+
+    connect(m_radioData, SIGNAL(error(QRadioData::Error)), this, SLOT(_q_error(QRadioData::Error)));
+}
+
+QDeclarativeRadioData::~QDeclarativeRadioData()
+{
+}
+
+bool QDeclarativeRadioData::isAvailable() const
+{
+    return m_radioData->isAvailable();
+}
+
+QString QDeclarativeRadioData::stationId() const
+{
+    return m_radioData->stationId();
+}
+
+QDeclarativeRadioData::ProgramType QDeclarativeRadioData::programType() const
+{
+    return static_cast<QDeclarativeRadioData::ProgramType>(m_radioData->programType());
+}
+
+QString QDeclarativeRadioData::programTypeName() const
+{
+    return m_radioData->programTypeName();
+}
+
+QString QDeclarativeRadioData::stationName() const
+{
+    return m_radioData->stationName();
+}
+
+QString QDeclarativeRadioData::radioText() const
+{
+    return m_radioData->radioText();
+}
+
+bool QDeclarativeRadioData::alternativeFrequenciesEnabled() const
+{
+    return m_radioData->isAlternativeFrequenciesEnabled();
+}
+
+void QDeclarativeRadioData::setAlternativeFrequenciesEnabled(bool enabled)
+{
+    m_radioData->setAlternativeFrequenciesEnabled(enabled);
+}
+
+void QDeclarativeRadioData::_q_programTypeChanged(QRadioData::ProgramType programType)
+{
+    emit programTypeChanged(static_cast<QDeclarativeRadioData::ProgramType>(programType));
+}
+
+void QDeclarativeRadioData::_q_error(QRadioData::Error errorCode)
+{
+    emit error(static_cast<QDeclarativeRadioData::Error>(errorCode));
+    emit errorChanged();
+}
diff --git a/src/imports/multimedia/qdeclarativeradiodata_p.h b/src/imports/multimedia/qdeclarativeradiodata_p.h
new file mode 100644 (file)
index 0000000..fc43563
--- /dev/null
@@ -0,0 +1,178 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVERADIODATA_P_H
+#define QDECLARATIVERADIODATA_P_H
+
+//
+//  W A R N I N G
+//  -------------
+//
+// This file is not part of the Qt API.  It exists for the convenience
+// of other Qt classes.  This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtDeclarative/qdeclarative.h>
+#include <qradiodata.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeRadioData : public QObject
+{
+    Q_OBJECT
+    Q_PROPERTY(QString stationId READ stationId NOTIFY stationIdChanged)
+    Q_PROPERTY(QDeclarativeRadioData::ProgramType programType READ programType NOTIFY programTypeChanged)
+    Q_PROPERTY(QString programTypeName READ programTypeName NOTIFY programTypeNameChanged)
+    Q_PROPERTY(QString stationName READ stationName NOTIFY stationNameChanged)
+    Q_PROPERTY(QString radioText READ radioText NOTIFY radioTextChanged)
+    Q_PROPERTY(bool alternativeFrequenciesEnabled READ alternativeFrequenciesEnabled
+               WRITE setAlternativeFrequenciesEnabled NOTIFY alternativeFrequenciesEnabledChanged)
+    Q_ENUMS(Error)
+    Q_ENUMS(ProgramType)
+
+public:
+
+    enum Error {
+        NoError = QRadioData::NoError,
+        ResourceError = QRadioData::ResourceError,
+        OpenError = QRadioData::OpenError,
+        OutOfRangeError = QRadioData::OutOfRangeError
+    };
+
+    enum ProgramType {
+        Undefined = QRadioData::Undefined,
+        News = QRadioData::News,
+        CurrentAffairs = QRadioData::CurrentAffairs,
+        Information = QRadioData::Information,
+        Sport = QRadioData::Sport,
+        Education = QRadioData::Education,
+        Drama = QRadioData::Drama,
+        Culture = QRadioData::Culture,
+        Science = QRadioData::Science,
+        Varied = QRadioData::Varied,
+        PopMusic = QRadioData::PopMusic,
+        RockMusic = QRadioData::RockMusic,
+        EasyListening = QRadioData::EasyListening,
+        LightClassical = QRadioData::LightClassical,
+        SeriousClassical = QRadioData::SeriousClassical,
+        OtherMusic = QRadioData::OtherMusic,
+        Weather = QRadioData::Weather,
+        Finance = QRadioData::Finance,
+        ChildrensProgrammes = QRadioData::ChildrensProgrammes,
+        SocialAffairs = QRadioData::SocialAffairs,
+        Religion = QRadioData::Religion,
+        PhoneIn = QRadioData::PhoneIn,
+        Travel = QRadioData::Travel,
+        Leisure = QRadioData::Leisure,
+        JazzMusic = QRadioData::JazzMusic,
+        CountryMusic = QRadioData::CountryMusic,
+        NationalMusic = QRadioData::NationalMusic,
+        OldiesMusic = QRadioData::OldiesMusic,
+        FolkMusic = QRadioData::FolkMusic,
+        Documentary = QRadioData::Documentary,
+        AlarmTest = QRadioData::AlarmTest,
+        Alarm = QRadioData::Alarm,
+        Talk = QRadioData::Talk,
+        ClassicRock = QRadioData::ClassicRock,
+        AdultHits = QRadioData::AdultHits,
+        SoftRock = QRadioData::SoftRock,
+        Top40 = QRadioData::Top40,
+        Soft = QRadioData::Soft,
+        Nostalgia = QRadioData::Nostalgia,
+        Classical = QRadioData::Classical,
+        RhythmAndBlues = QRadioData::RhythmAndBlues,
+        SoftRhythmAndBlues = QRadioData::SoftRhythmAndBlues,
+        Language = QRadioData::Language,
+        ReligiousMusic = QRadioData::ReligiousMusic,
+        ReligiousTalk = QRadioData::ReligiousTalk,
+        Personality = QRadioData::Personality,
+        Public = QRadioData::Public,
+        College = QRadioData::College,
+    };
+
+    QDeclarativeRadioData(QObject *parent = 0);
+    ~QDeclarativeRadioData();
+
+    Q_INVOKABLE bool isAvailable() const;
+
+    QString stationId() const;
+    QDeclarativeRadioData::ProgramType programType() const;
+    QString programTypeName() const;
+    QString stationName() const;
+    QString radioText() const;
+    bool alternativeFrequenciesEnabled() const;
+
+public Q_SLOTS:
+    void setAlternativeFrequenciesEnabled(bool enabled);
+
+Q_SIGNALS:
+    void stationIdChanged(QString stationId);
+    void programTypeChanged(QDeclarativeRadioData::ProgramType programType);
+    void programTypeNameChanged(QString programTypeName);
+    void stationNameChanged(QString stationName);
+    void radioTextChanged(QString radioText);
+    void alternativeFrequenciesEnabledChanged(bool enabled);
+
+    void errorChanged();
+    void error(QDeclarativeRadioData::Error errorCode);
+
+private Q_SLOTS:
+    void _q_programTypeChanged(QRadioData::ProgramType programType);
+    void _q_error(QRadioData::Error errorCode);
+
+private:
+    Q_DISABLE_COPY(QDeclarativeRadioData)
+
+    QRadioData *m_radioData;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeRadioData))
+
+QT_END_HEADER
+
+#endif // QDECLARATIVERADIODATA_P_H
index b955e71a0c61bb619b0aaa13a1085eac280ccd6a..f1c11b998a52fffad5233634c0c0678a2a2d72a8 100644 (file)
@@ -55,7 +55,9 @@ PUBLIC_HEADERS += \
     qmetadatawritercontrol.h \
     qmediastreamscontrol.h \
     qradiotuner.h \
+    qradiodata.h \
     qradiotunercontrol.h \
+    qradiodatacontrol.h \
     qtmedianamespace.h \
     qaudioencodercontrol.h \
     qvideoencodercontrol.h \
@@ -95,7 +97,9 @@ SOURCES += qmediacontrol.cpp \
     qmetadatawritercontrol.cpp \
     qmediastreamscontrol.cpp \
     qradiotuner.cpp \
+    qradiodata.cpp \
     qradiotunercontrol.cpp \
+    qradiodatacontrol.cpp \
     qaudioencodercontrol.cpp \
     qvideoencodercontrol.cpp \
     qimageencodercontrol.cpp \
diff --git a/src/multimedia/qradiodata.cpp b/src/multimedia/qradiodata.cpp
new file mode 100644 (file)
index 0000000..1840db2
--- /dev/null
@@ -0,0 +1,341 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qradiodata.h"
+#include "qmediaservice.h"
+#include "qmediaobject_p.h"
+#include "qradiodatacontrol.h"
+
+#include <QPair>
+
+
+QT_BEGIN_NAMESPACE
+
+/*!
+    \class QRadioData
+    \brief The QRadioData class provides interfaces to the RDS functionality of the system radio.
+
+    \inmodule QtMultimedia
+    \ingroup multimedia
+    \since 5.0
+
+    The radio data object will emit signals for any changes in radio data. You can enable or disable
+    alternative frequency with setAlternativeFrequenciesEnabled().
+
+*/
+
+
+class QRadioDataPrivate : public QMediaObjectPrivate
+{
+public:
+    QRadioDataPrivate():provider(0), control(0) {}
+    QMediaServiceProvider *provider;
+    QRadioDataControl* control;
+};
+
+/*!
+    Constructs a radio data based on a media service allocated by a media service \a provider.
+
+    The \a parent is passed to QMediaObject.
+    \since 5.0
+*/
+
+QRadioData::QRadioData(QObject *parent, QMediaServiceProvider* provider):
+    QMediaObject(*new QRadioDataPrivate, parent, provider->requestService(Q_MEDIASERVICE_RADIO))
+{
+    Q_D(QRadioData);
+
+    d->provider = provider;
+
+    if (d->service != 0) {
+        d->control = qobject_cast<QRadioDataControl*>(d->service->requestControl(QRadioDataControl_iid));
+        if (d->control != 0) {
+            connect(d->control, SIGNAL(stationIdChanged(QString)), SIGNAL(stationIdChanged(QString)));
+            connect(d->control, SIGNAL(programTypeChanged(QRadioData::ProgramType)),
+                                SIGNAL(programTypeChanged(QRadioData::ProgramType)));
+            connect(d->control, SIGNAL(programTypeNameChanged(QString)), SIGNAL(programTypeNameChanged(QString)));
+            connect(d->control, SIGNAL(stationNameChanged(QString)), SIGNAL(stationNameChanged(QString)));
+            connect(d->control, SIGNAL(radioTextChanged(QString)), SIGNAL(radioTextChanged(QString)));
+            connect(d->control, SIGNAL(alternativeFrequenciesEnabledChanged(bool)), SIGNAL(alternativeFrequenciesEnabledChanged(bool)));
+            connect(d->control, SIGNAL(error(QRadioData::Error)), SIGNAL(error(QRadioData::Error)));
+        }
+    }
+}
+
+/*!
+    Destroys a radio data.
+*/
+
+QRadioData::~QRadioData()
+{
+    Q_D(QRadioData);
+
+    if (d->service && d->control)
+        d->service->releaseControl(d->control);
+
+    d->provider->releaseService(d->service);
+}
+
+/*!
+    Returns true if the radio data service is ready to use.
+    \since 5.0
+*/
+bool QRadioData::isAvailable() const
+{
+    Q_D(const QRadioData);
+
+    if (d->control != 0)
+        return d_func()->control->isAvailable();
+    else
+        return false;
+}
+
+/*!
+    Returns the availability error state.
+    \since 5.0
+*/
+QtMultimedia::AvailabilityError QRadioData::availabilityError() const
+{
+    Q_D(const QRadioData);
+
+    if (d->control != 0)
+        return d_func()->control->availabilityError();
+    else
+        return QtMultimedia::ServiceMissingError;
+}
+
+/*!
+    \property QRadioData::stationId
+    \brief Current Program Identification
+
+    \since 5.0
+*/
+
+QString QRadioData::stationId() const
+{
+    Q_D(const QRadioData);
+
+    if (d->control != 0)
+        return d->control->stationId();
+    return QString();
+}
+
+/*!
+    \property QRadioData::programType
+    \brief Current Program Type
+
+    \since 5.0
+*/
+
+QRadioData::ProgramType QRadioData::programType() const
+{
+    Q_D(const QRadioData);
+
+    if (d->control != 0)
+        return d->control->programType();
+
+    return QRadioData::Undefined;
+}
+
+/*!
+    \property QRadioData::programTypeName
+    \brief Current Program Type Name
+
+    \since 5.0
+*/
+
+QString QRadioData::programTypeName() const
+{
+    Q_D(const QRadioData);
+
+    if (d->control != 0)
+        return d->control->programTypeName();
+    return QString();
+}
+
+/*!
+    \property QRadioData::stationName
+    \brief Current Program Service
+
+    \since 5.0
+*/
+
+QString QRadioData::stationName() const
+{
+    Q_D(const QRadioData);
+
+    if (d->control != 0)
+        return d->control->stationName();
+    return QString();
+}
+
+/*!
+    \property QRadioData::radioText
+    \brief Current Radio Text
+
+    \since 5.0
+*/
+
+QString QRadioData::radioText() const
+{
+    Q_D(const QRadioData);
+
+    if (d->control != 0)
+        return d->control->radioText();
+    return QString();
+}
+
+/*!
+    \property QRadioData::alternativeFrequenciesEnabled
+    \brief Is Alternative Frequency currently enabled
+
+    \since 5.0
+*/
+
+bool QRadioData::isAlternativeFrequenciesEnabled() const
+{
+    Q_D(const QRadioData);
+
+    if (d->control != 0)
+        return d->control->isAlternativeFrequenciesEnabled();
+    return false;
+}
+
+void QRadioData::setAlternativeFrequenciesEnabled( bool enabled )
+{
+    Q_D(const QRadioData);
+
+    if (d->control != 0)
+        return d->control->setAlternativeFrequenciesEnabled(enabled);
+}
+
+/*!
+    Returns the error state of a radio data.
+
+    \since 5.0
+    \sa errorString()
+*/
+
+QRadioData::Error QRadioData::error() const
+{
+    Q_D(const QRadioData);
+
+    if (d->control != 0)
+        return d->control->error();
+    return QRadioData::ResourceError;
+}
+
+/*!
+    Returns a description of a radio data's error state.
+
+    \since 5.0
+    \sa error()
+*/
+QString QRadioData::errorString() const
+{
+    Q_D(const QRadioData);
+
+    if (d->control != 0)
+        return d->control->errorString();
+    return QString();
+}
+
+/*!
+    \fn void QRadioData::stationIdChanged(QString stationId)
+
+    Signals that the Program Identification code has changed to \a stationId
+    \since 5.0
+*/
+
+/*!
+    \fn void QRadioData::programTypeChanged(QRadioData::ProgramType programType)
+
+    Signals that the Program Type code has changed to \a programType
+    \since 5.0
+*/
+
+/*!
+    \fn void QRadioData::programTypeNameChanged(QString programTypeName)
+
+    Signals that the Program Type Name has changed to \a programTypeName
+    \since 5.0
+*/
+
+/*!
+    \fn void QRadioData::stationNameChanged(int stationName)
+
+    Signals that the Program Service has changed to \a stationName
+    \since 5.0
+*/
+
+/*!
+    \fn void QRadioData::alternativeFrequenciesEnabledChanged(bool enabled)
+
+    Signals that the AF has been enabled or disabled
+    \since 5.0
+*/
+
+/*!
+    \fn void QRadioData::error(QRadioData::Error error)
+
+    Signals that an \a error occurred.
+    \since 5.0
+*/
+
+/*!
+    \enum QRadioData::Error
+
+    Enumerates radio data error conditions.
+
+    \value NoError         No errors have occurred.
+    \value ResourceError   There is no radio service available.
+    \value OpenError       Unable to open radio device.
+    \value OutOfRangeError An attempt to set a frequency or band that is not supported by radio device.
+*/
+
+/*! \fn void QRadioData::stateChanged(QRadioData::State state)
+  This signal is emitted when the state changes to \a state.
+  \since 5.0
+ */
+
+#include "moc_qradiodata.cpp"
+QT_END_NAMESPACE
+
diff --git a/src/multimedia/qradiodata.h b/src/multimedia/qradiodata.h
new file mode 100644 (file)
index 0000000..71ae222
--- /dev/null
@@ -0,0 +1,136 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QRADIODATA_H
+#define QRADIODATA_H
+
+#include <QtCore/qobject.h>
+
+#include "qmediaobject.h"
+#include "qmediaserviceprovider.h"
+#include <qmediaenumdebug.h>
+
+#include <QPair>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Multimedia)
+
+
+class QRadioDataPrivate;
+class Q_MULTIMEDIA_EXPORT QRadioData : public QMediaObject
+{
+    Q_OBJECT
+    Q_PROPERTY(QString stationId READ stationId NOTIFY stationIdChanged)
+    Q_PROPERTY(ProgramType programType READ programType NOTIFY programTypeChanged)
+    Q_PROPERTY(QString programTypeName READ programTypeName NOTIFY programTypeNameChanged)
+    Q_PROPERTY(QString stationName READ stationName NOTIFY stationNameChanged)
+    Q_PROPERTY(QString radioText READ radioText NOTIFY radioTextChanged)
+    Q_PROPERTY(bool alternativeFrequenciesEnabled READ isAlternativeFrequenciesEnabled
+               WRITE setAlternativeFrequenciesEnabled NOTIFY alternativeFrequenciesEnabledChanged)
+    Q_ENUMS(Error)
+    Q_ENUMS(ProgramType)
+
+public:
+    enum Error { NoError, ResourceError, OpenError, OutOfRangeError };
+
+    enum ProgramType { Undefined = 0, News, CurrentAffairs, Information,
+        Sport, Education, Drama, Culture, Science, Varied,
+        PopMusic, RockMusic, EasyListening, LightClassical,
+        SeriousClassical, OtherMusic, Weather, Finance,
+        ChildrensProgrammes, SocialAffairs, Religion,
+        PhoneIn, Travel, Leisure, JazzMusic, CountryMusic,
+        NationalMusic, OldiesMusic, FolkMusic, Documentary,
+        AlarmTest, Alarm, Talk, ClassicRock, AdultHits,
+        SoftRock, Top40, Soft, Nostalgia, Classical,
+        RhythmAndBlues, SoftRhythmAndBlues, Language,
+        ReligiousMusic, ReligiousTalk, Personality, Public,
+        College
+    };
+
+    QRadioData(QObject *parent = 0, QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider());
+    ~QRadioData();
+
+    bool isAvailable() const;
+    QtMultimedia::AvailabilityError availabilityError() const;
+
+    QString stationId() const;
+    ProgramType programType() const;
+    QString programTypeName() const;
+    QString stationName() const;
+    QString radioText() const;
+    bool isAlternativeFrequenciesEnabled() const;
+
+    Error error() const;
+    QString errorString() const;
+
+public Q_SLOTS:
+    void setAlternativeFrequenciesEnabled(bool enabled);
+
+Q_SIGNALS:
+    void stationIdChanged(QString stationId);
+    void programTypeChanged(QRadioData::ProgramType programType);
+    void programTypeNameChanged(QString programTypeName);
+    void stationNameChanged(QString stationName);
+    void radioTextChanged(QString radioText);
+    void alternativeFrequenciesEnabledChanged(bool enabled);
+
+    void error(QRadioData::Error error);
+
+private:
+
+    Q_DISABLE_COPY(QRadioData)
+    Q_DECLARE_PRIVATE(QRadioData)
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QRadioData::Error)
+Q_DECLARE_METATYPE(QRadioData::ProgramType)
+
+Q_MEDIA_ENUM_DEBUG(QRadioData, Error)
+Q_MEDIA_ENUM_DEBUG(QRadioData, ProgramType)
+
+QT_END_HEADER
+
+#endif  // QRADIOPLAYER_H
diff --git a/src/multimedia/qradiodatacontrol.cpp b/src/multimedia/qradiodatacontrol.cpp
new file mode 100644 (file)
index 0000000..28b9a99
--- /dev/null
@@ -0,0 +1,216 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtmultimediadefs.h>
+#include "qradiodatacontrol.h"
+#include "qmediacontrol_p.h"
+
+QT_BEGIN_NAMESPACE
+
+
+/*!
+    \class QRadioDataControl
+    \inmodule QtMultimedia
+    \ingroup multimedia-serv
+    \since 5.0
+
+
+    \brief The QRadioDataControl class provides access to the RDS functionality of the
+    radio in the QMediaService.
+
+    The functionality provided by this control is exposed to application code
+    through the QRadioData class.
+
+    The interface name of QRadioDataControl is \c com.nokia.Qt.QRadioDataControl/5.0 as
+    defined in QRadioDataControl_iid.
+
+    \sa QMediaService::requestControl(), QRadioData
+*/
+
+/*!
+    \macro QRadioDataControl_iid
+
+    \c com.nokia.Qt.QRadioDataControl/5.0
+
+    Defines the interface name of the QRadioDataControl class.
+
+    \relates QRadioDataControl
+*/
+
+/*!
+    Constructs a radio data control with the given \a parent.
+*/
+
+QRadioDataControl::QRadioDataControl(QObject *parent):
+    QMediaControl(*new QMediaControlPrivate, parent)
+{
+}
+
+/*!
+    Destroys a radio data control.
+*/
+
+QRadioDataControl::~QRadioDataControl()
+{
+}
+
+/*!
+    \fn bool QRadioDataControl::isAvailable() const
+
+    Returns true if the radio service is ready to use.
+    \since 5.0
+*/
+
+/*!
+    \fn QtMultimedia::AvailabilityError QRadioDataControl::availabilityError() const
+
+    Returns the error state of the radio service.
+    \since 5.0
+*/
+
+/*!
+    \fn QRadioData::Error QRadioDataControl::error() const
+
+    Returns the error state of a radio data.
+    \since 5.0
+*/
+
+/*!
+    \fn QString QRadioDataControl::errorString() const
+
+    Returns a string describing a radio data's error state.
+    \since 5.0
+*/
+
+/*!
+    \fn void QRadioDataControl::error(QRadioData::Error error)
+
+    Signals that an \a error has occurred.
+    \since 5.0
+*/
+
+/*!
+    \fn int QRadioDataControl::stationId()
+
+    Returns the current Program Identification
+    \since 5.0
+*/
+
+/*!
+    \fn QRadioData::ProgramType QRadioDataControl::programType()
+
+    Returns the current Program Type
+    \since 5.0
+*/
+
+/*!
+    \fn QString QRadioDataControl::programTypeName()
+
+    Returns the current Program Type Name
+    \since 5.0
+*/
+
+/*!
+    \fn QString QRadioDataControl::stationName()
+
+    Returns the current Program Service
+    \since 5.0
+*/
+
+/*!
+    \fn QString QRadioDataControl::radioText()
+
+    Returns the current Radio Text
+    \since 5.0
+*/
+
+/*!
+    \fn void QRadioDataControl::setAlternativeFrequenciesEnabled(bool enabled)
+
+    Sets the Alternative Frequency to \a enabled
+    \since 5.0
+*/
+
+/*!
+    \fn bool QRadioDataControl::isAlternativeFrequenciesEnabled()
+
+    Returns true if Alternative Frequency is currently enabled
+    \since 5.0
+*/
+
+/*!
+    \fn void QRadioDataControl::stationIdChanged(QString stationId)
+
+    Signals that the Program Identification \a stationId has changed
+    \since 5.0
+*/
+
+/*!
+    \fn void QRadioDataControl::programTypeChanged(QRadioData::ProgramType programType)
+
+    Signals that the Program Type \a programType has changed
+    \since 5.0
+*/
+
+/*!
+    \fn void QRadioDataControl::programTypeNameChanged(QString programTypeName)
+
+    Signals that the Program Type Name \a programTypeName has changed
+    \since 5.0
+*/
+
+/*!
+    \fn void QRadioDataControl::stationNameChanged(QString stationName)
+
+    Signals that the Program Service \a stationName has changed
+    \since 5.0
+*/
+
+/*!
+    \fn void QRadioDataControl::radioTextChanged(QString radioText)
+
+    Signals that the Radio Text \a radioText has changed
+    \since 5.0
+*/
+
+#include "moc_qradiodatacontrol.cpp"
+QT_END_NAMESPACE
+
diff --git a/src/multimedia/qradiodatacontrol.h b/src/multimedia/qradiodatacontrol.h
new file mode 100644 (file)
index 0000000..487236c
--- /dev/null
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QRADIODATACONTROL_H
+#define QRADIODATACONTROL_H
+
+#include "qmediacontrol.h"
+#include "qradiodata.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Multimedia)
+
+
+class Q_MULTIMEDIA_EXPORT QRadioDataControl : public QMediaControl
+{
+    Q_OBJECT
+
+public:
+    ~QRadioDataControl();
+
+    virtual bool isAvailable() const = 0;
+    virtual QtMultimedia::AvailabilityError availabilityError() const = 0;
+
+    virtual QString stationId() const = 0;
+    virtual QRadioData::ProgramType programType() const = 0;
+    virtual QString programTypeName() const = 0;
+    virtual QString stationName() const = 0;
+    virtual QString radioText() const = 0;
+    virtual void setAlternativeFrequenciesEnabled(bool enabled) = 0;
+    virtual bool isAlternativeFrequenciesEnabled() const = 0;
+
+    virtual QRadioData::Error error() const = 0;
+    virtual QString errorString() const = 0;
+
+Q_SIGNALS:
+    void stationIdChanged(QString stationId);
+    void programTypeChanged(QRadioData::ProgramType programType);
+    void programTypeNameChanged(QString programTypeName);
+    void stationNameChanged(QString stationName);
+    void radioTextChanged(QString radioText);
+    void alternativeFrequenciesEnabledChanged(bool enabled);
+    void error(QRadioData::Error err);
+
+protected:
+    QRadioDataControl(QObject *parent = 0);
+};
+
+#define QRadioDataControl_iid "com.nokia.Qt.QRadioDataControl/5.0"
+Q_MEDIA_DECLARE_CONTROL(QRadioDataControl, QRadioDataControl_iid)
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+
+#endif  // QRADIODATACONTROL_H
index 25f76b83a592a18d93779d59075f141225fcd75f..3673d34bdb8bbc10f85fb17ef7a52a2e0cb97f2c 100644 (file)
@@ -106,6 +106,7 @@ QRadioTuner::QRadioTuner(QObject *parent, QMediaServiceProvider* provider):
             connect(d->control, SIGNAL(signalStrengthChanged(int)), SIGNAL(signalStrengthChanged(int)));
             connect(d->control, SIGNAL(volumeChanged(int)), SIGNAL(volumeChanged(int)));
             connect(d->control, SIGNAL(mutedChanged(bool)), SIGNAL(mutedChanged(bool)));
+            connect(d->control, SIGNAL(stationFound(int,QString)), SIGNAL(stationFound(int,QString)));
             connect(d->control, SIGNAL(error(QRadioTuner::Error)), SIGNAL(error(QRadioTuner::Error)));
         }
     }
@@ -456,6 +457,26 @@ void QRadioTuner::searchBackward()
         d->control->searchBackward();
 }
 
+/*!
+    Search all stations in current band
+
+    Emits QRadioTuner::stationFound(int, QString) for every found station.
+    After searching is completed, QRadioTuner::searchingChanged(bool) is
+    emitted (false). If \a searchMode is set to SearchGetStationId, searching
+    waits for station id (PI) on each frequency.
+
+    \since 5.0
+    \sa searchForward(), searchBackward(), searching
+*/
+
+void QRadioTuner::searchAllStations(QRadioTuner::SearchMode searchMode)
+{
+    Q_D(const QRadioTuner);
+
+    if (d->control != 0)
+        d->control->searchAllStations(searchMode);
+}
+
 /*!
     Stops scanning for a signal.
 
@@ -554,6 +575,14 @@ QString QRadioTuner::errorString() const
     \since 1.0
 */
 
+/*!
+    \fn void QRadioTuner::stationFound(int frequency, QString stationId)
+
+    Signals that a station was found in \a frequency with \a stationId Program
+    Identification code.
+    \since 5.0
+*/
+
 /*!
     \fn void QRadioTuner::error(QRadioTuner::Error error)
 
index 78852638c504e306f07df8d8151f90decab437f3..21497f45c20f9830abe8135749312d10ecb42e6c 100644 (file)
@@ -74,12 +74,14 @@ class Q_MULTIMEDIA_EXPORT QRadioTuner : public QMediaObject
     Q_ENUMS(Band)
     Q_ENUMS(Error)
     Q_ENUMS(StereoMode)
+    Q_ENUMS(SearchMode)
 
 public:
     enum State { ActiveState, StoppedState };
     enum Band { AM, FM, SW, LW, FM2 };
     enum Error { NoError, ResourceError, OpenError, OutOfRangeError };
     enum StereoMode { ForceStereo, ForceMono, Auto };
+    enum SearchMode { SearchFast, SearchGetStationId };
 
     QRadioTuner(QObject *parent = 0, QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider());
     ~QRadioTuner();
@@ -114,6 +116,7 @@ public:
 public Q_SLOTS:
     void searchForward();
     void searchBackward();
+    void searchAllStations(QRadioTuner::SearchMode searchMode = QRadioTuner::SearchFast);
     void cancelSearch();
 
     void setBand(Band band);
@@ -134,6 +137,8 @@ Q_SIGNALS:
     void signalStrengthChanged(int signalStrength);
     void volumeChanged(int volume);
     void mutedChanged(bool muted);
+    void stationFound(int frequency, QString stationId);
+
     void error(QRadioTuner::Error error);
 
 private:
@@ -147,11 +152,13 @@ Q_DECLARE_METATYPE(QRadioTuner::State)
 Q_DECLARE_METATYPE(QRadioTuner::Band)
 Q_DECLARE_METATYPE(QRadioTuner::Error)
 Q_DECLARE_METATYPE(QRadioTuner::StereoMode)
+Q_DECLARE_METATYPE(QRadioTuner::SearchMode)
 
 Q_MEDIA_ENUM_DEBUG(QRadioTuner, State)
 Q_MEDIA_ENUM_DEBUG(QRadioTuner, Band)
 Q_MEDIA_ENUM_DEBUG(QRadioTuner, Error)
 Q_MEDIA_ENUM_DEBUG(QRadioTuner, StereoMode)
+Q_MEDIA_ENUM_DEBUG(QRadioTuner, SearchMode)
 
 QT_END_HEADER
 
index 97ffd23961eb7751dbda1c305c622500430b2eac..6e2b488a31743687bf5f2551839a120602a69a49 100644 (file)
@@ -267,6 +267,13 @@ QRadioTunerControl::~QRadioTunerControl()
     \since 1.0
 */
 
+/*!
+    \fn  void QRadioTunerControl::searchAllStations()
+
+    Starts a scan through the whole frequency band searching all stations
+    \since 5.0
+*/
+
 /*!
     \fn void QRadioTunerControl::cancelSearch()
 
@@ -359,6 +366,13 @@ QRadioTunerControl::~QRadioTunerControl()
     \since 1.0
 */
 
+/*!
+    \fn void QRadioTunerControl::stationFound(int frequency)
+
+    Signals that new station with \a frequency was found when scanning
+    \since 5.0
+*/
+
 #include "moc_qradiotunercontrol.cpp"
 QT_END_NAMESPACE
 
index 04812be48012e0ea9fc9e8c819a7f5d9836ac9a2..b0ea542508c9a74be3046573212b0b3a6616f4ed 100644 (file)
@@ -89,6 +89,7 @@ public:
 
     virtual void searchForward() = 0;
     virtual void searchBackward() = 0;
+    virtual void searchAllStations(QRadioTuner::SearchMode searchMode = QRadioTuner::SearchFast) = 0;
     virtual void cancelSearch() = 0;
 
     virtual void start() = 0;
@@ -107,6 +108,7 @@ Q_SIGNALS:
     void volumeChanged(int volume);
     void mutedChanged(bool muted);
     void error(QRadioTuner::Error err);
+    void stationFound(int frequency, QString stationId);
 
 protected:
     QRadioTunerControl(QObject *parent = 0);
index a91ebb92714c35b782cb9e23b94d5bf4c251496c..137a82ddbfedce26edc2d180fa13f7b1e02c4608 100644 (file)
@@ -10,13 +10,14 @@ DESTDIR = $$QT.multimedia.plugins/$${PLUGIN_TYPE}
 HEADERS += \
   fakeradioserviceplugin.h \
   fakeradioservice.h \
-  fakeradiotunercontrol.h
+  fakeradiotunercontrol.h \
+  fakeradiodatacontrol.h
 
 SOURCES += \
   fakeradioserviceplugin.cpp \
   fakeradioservice.cpp \
-  fakeradiotunercontrol.cpp
-
+  fakeradiotunercontrol.cpp \
+  fakeradiodatacontrol.cpp
 
 target.path += $$[QT_INSTALL_PLUGINS]/$${PLUGIN_TYPE}
 INSTALLS += target
diff --git a/src/plugins/fakeradio/fakeradiodatacontrol.cpp b/src/plugins/fakeradio/fakeradiodatacontrol.cpp
new file mode 100644 (file)
index 0000000..c781385
--- /dev/null
@@ -0,0 +1,226 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "fakeradiodatacontrol.h"
+#include "fakeradioservice.h"
+
+#include <QtCore/qdebug.h>
+
+FakeRadioDataControl::FakeRadioDataControl(QObject *parent)
+    :QRadioDataControl(parent)
+{
+    initializeProgramTypeMapping();
+
+    m_rdsTimer = new QTimer(this);
+    connect(m_rdsTimer,SIGNAL(timeout()),this,SLOT(rdsUpdate()));
+    m_rdsTimer->start(5000);
+    rdsUpdate();
+
+    qsrand(QTime::currentTime().msec());
+}
+
+FakeRadioDataControl::~FakeRadioDataControl()
+{
+}
+
+bool FakeRadioDataControl::isAvailable() const
+{
+    return true;
+}
+
+QtMultimedia::AvailabilityError FakeRadioDataControl::availabilityError() const
+{
+    return QtMultimedia::NoError;
+}
+
+QString FakeRadioDataControl::stationId() const
+{
+    return "12345678";
+}
+
+QRadioData::ProgramType FakeRadioDataControl::programType() const
+{
+    return QRadioData::Drama;
+}
+
+QString FakeRadioDataControl::programTypeName() const
+{
+    return "Cycling";
+}
+
+QString FakeRadioDataControl::stationName() const
+{
+    return "Fake FM";
+}
+
+void FakeRadioDataControl::rdsUpdate()
+{
+    static int index = 0;
+    QString rdsStrings[] = {
+        "This is radio Fake FM",
+        "There is nothing to listen to here",
+        "Please remain calm" };
+    setradioText(rdsStrings[index%3]);
+    index++;
+}
+
+void FakeRadioDataControl::setradioText(QString text)
+{
+    m_radioText = text;
+    emit radioTextChanged(m_radioText);
+}
+
+QString FakeRadioDataControl::radioText() const
+{
+    return m_radioText;
+}
+
+void FakeRadioDataControl::setAlternativeFrequenciesEnabled(bool enabled)
+{
+    m_alternativeFrequenciesEnabled = enabled;
+}
+
+bool FakeRadioDataControl::isAlternativeFrequenciesEnabled() const
+{
+    return m_alternativeFrequenciesEnabled;
+}
+
+QRadioData::Error FakeRadioDataControl::error() const
+{
+    return QRadioData::NoError;
+}
+
+QString FakeRadioDataControl::errorString() const
+{
+    return QString();
+}
+
+void FakeRadioDataControl::initializeProgramTypeMapping()
+{
+    m_programTypeMapRDS[0] = QRadioData::Undefined;
+    m_programTypeMapRDS[1] = QRadioData::News;
+    m_programTypeMapRDS[2] = QRadioData::CurrentAffairs;
+    m_programTypeMapRDS[3] = QRadioData::Information;
+    m_programTypeMapRDS[4] = QRadioData::Sport;
+    m_programTypeMapRDS[5] = QRadioData::Education;
+    m_programTypeMapRDS[6] = QRadioData::Drama;
+    m_programTypeMapRDS[7] = QRadioData::Culture;
+    m_programTypeMapRDS[8] = QRadioData::Science;
+    m_programTypeMapRDS[9] = QRadioData::Varied;
+    m_programTypeMapRDS[10] = QRadioData::PopMusic;
+    m_programTypeMapRDS[11] = QRadioData::RockMusic;
+    m_programTypeMapRDS[12] = QRadioData::EasyListening;
+    m_programTypeMapRDS[13] = QRadioData::LightClassical;
+    m_programTypeMapRDS[14] = QRadioData::SeriousClassical;
+    m_programTypeMapRDS[15] = QRadioData::OtherMusic;
+    m_programTypeMapRDS[16] = QRadioData::Weather;
+    m_programTypeMapRDS[17] = QRadioData::Finance;
+    m_programTypeMapRDS[18] = QRadioData::ChildrensProgrammes;
+    m_programTypeMapRDS[19] = QRadioData::SocialAffairs;
+    m_programTypeMapRDS[20] = QRadioData::Religion;
+    m_programTypeMapRDS[21] = QRadioData::PhoneIn;
+    m_programTypeMapRDS[22] = QRadioData::Travel;
+    m_programTypeMapRDS[23] = QRadioData::Leisure;
+    m_programTypeMapRDS[24] = QRadioData::JazzMusic;
+    m_programTypeMapRDS[25] = QRadioData::CountryMusic;
+    m_programTypeMapRDS[26] = QRadioData::NationalMusic;
+    m_programTypeMapRDS[27] = QRadioData::OldiesMusic;
+    m_programTypeMapRDS[28] = QRadioData::FolkMusic;
+    m_programTypeMapRDS[29] = QRadioData::Documentary;
+    m_programTypeMapRDS[30] = QRadioData::AlarmTest;
+    m_programTypeMapRDS[31] = QRadioData::Alarm;
+
+    m_programTypeMapRBDS[0] = QRadioData::Undefined,
+    m_programTypeMapRBDS[1] = QRadioData::News;
+    m_programTypeMapRBDS[2] = QRadioData::Information;
+    m_programTypeMapRBDS[3] = QRadioData::Sport;
+    m_programTypeMapRBDS[4] = QRadioData::Talk;
+    m_programTypeMapRBDS[5] = QRadioData::RockMusic;
+    m_programTypeMapRBDS[6] = QRadioData::ClassicRock;
+    m_programTypeMapRBDS[7] = QRadioData::AdultHits;
+    m_programTypeMapRBDS[8] = QRadioData::SoftRock;
+    m_programTypeMapRBDS[9] = QRadioData::Top40;
+    m_programTypeMapRBDS[10] = QRadioData::CountryMusic;
+    m_programTypeMapRBDS[11] = QRadioData::OldiesMusic;
+    m_programTypeMapRBDS[12] = QRadioData::Soft;
+    m_programTypeMapRBDS[13] = QRadioData::Nostalgia;
+    m_programTypeMapRBDS[14] = QRadioData::JazzMusic;
+    m_programTypeMapRBDS[15] = QRadioData::Classical;
+    m_programTypeMapRBDS[16] = QRadioData::RhythmAndBlues;
+    m_programTypeMapRBDS[17] = QRadioData::SoftRhythmAndBlues;
+    m_programTypeMapRBDS[18] = QRadioData::Language;
+    m_programTypeMapRBDS[19] = QRadioData::ReligiousMusic;
+    m_programTypeMapRBDS[20] = QRadioData::ReligiousTalk;
+    m_programTypeMapRBDS[21] = QRadioData::Personality;
+    m_programTypeMapRBDS[22] = QRadioData::Public;
+    m_programTypeMapRBDS[23] = QRadioData::College;
+    m_programTypeMapRBDS[24] = QRadioData::Undefined;
+    m_programTypeMapRBDS[25] = QRadioData::Undefined;
+    m_programTypeMapRBDS[26] = QRadioData::Undefined;
+    m_programTypeMapRBDS[27] = QRadioData::Undefined;
+    m_programTypeMapRBDS[28] = QRadioData::Undefined;
+    m_programTypeMapRBDS[29] = QRadioData::Weather;
+    m_programTypeMapRBDS[30] = QRadioData::AlarmTest;
+    m_programTypeMapRBDS[31] = QRadioData::Alarm;
+}
+
+bool FakeRadioDataControl::usingRBDS()
+{
+    switch ( QLocale::system().country() )
+    {
+        case QLocale::Canada:
+        case QLocale::Mexico:
+        case QLocale::UnitedStates:
+            return true;
+
+        default:
+            return false;
+    }
+    return false;
+}
+
+QRadioData::ProgramType FakeRadioDataControl::fromRawProgramType(int rawProgramType)
+{
+    if ( usingRBDS() )
+        return m_programTypeMapRBDS.value(rawProgramType, QRadioData::Undefined);
+
+    return m_programTypeMapRDS.value(rawProgramType, QRadioData::Undefined);
+}
diff --git a/src/plugins/fakeradio/fakeradiodatacontrol.h b/src/plugins/fakeradio/fakeradiodatacontrol.h
new file mode 100644 (file)
index 0000000..fc417a8
--- /dev/null
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef FAKERADIODATACONTROL_H
+#define FAKERADIODATACONTROL_H
+
+#include <QtCore/qobject.h>
+#include <QtCore/qtimer.h>
+#include <QtCore/qdatetime.h>
+
+#include <qradiodatacontrol.h>
+
+QT_USE_NAMESPACE
+
+class FakeRadioService;
+
+class FakeRadioDataControl : public QRadioDataControl
+{
+    Q_OBJECT
+
+public:
+    FakeRadioDataControl(QObject *parent = 0);
+    ~FakeRadioDataControl();
+
+    bool isAvailable() const;
+    QtMultimedia::AvailabilityError availabilityError() const;
+
+    QString stationId() const;
+    QRadioData::ProgramType programType() const;
+    QString programTypeName() const;
+    QString stationName() const;
+    QString radioText() const;
+    void setAlternativeFrequenciesEnabled(bool enabled);
+    bool isAlternativeFrequenciesEnabled() const;
+
+    QRadioData::Error error() const;
+    QString errorString() const;
+
+private slots:
+    void rdsUpdate();
+
+private:
+    void setradioText(QString);
+    void initializeProgramTypeMapping();
+    bool usingRBDS();
+    QRadioData::ProgramType fromRawProgramType(int rawProgramType);
+
+private: //data
+    bool m_alternativeFrequenciesEnabled;
+    QString m_radioText;
+    QTimer *m_rdsTimer;
+
+    QMap<int, QRadioData::ProgramType> m_programTypeMapRDS;
+    QMap<int, QRadioData::ProgramType> m_programTypeMapRBDS;
+
+};
+
+#endif // FAKERADIODATACONTROL_H
index 144e3b3c7aaad9fca573a910380db9e5f6723de2..5596c6db9db5a2f6f123837f3248c31ddc1031e6 100644 (file)
 
 #include "fakeradioservice.h"
 #include "fakeradiotunercontrol.h"
+#include "fakeradiodatacontrol.h"
+
+Q_GLOBAL_STATIC( QMutex, fakeRadioServiceMutex );
+FakeRadioService* FakeRadioService::m_instance = 0;
+int FakeRadioService::m_referenceCount = 0;
 
 FakeRadioService::FakeRadioService(QObject *parent):
     QMediaService(parent)
 {
-    m_control = new FakeRadioTunerControl(this);
+    m_tunerControl = new FakeRadioTunerControl(this);
+    m_dataControl = new FakeRadioDataControl(this);
 }
 
 FakeRadioService::~FakeRadioService()
 {
 }
 
+FakeRadioService* FakeRadioService::instance()
+{
+    QMutexLocker lock(fakeRadioServiceMutex());
+    if (!m_instance)
+        m_instance = new FakeRadioService;
+    m_referenceCount++;
+    return m_instance;
+}
+
+void FakeRadioService::release()
+{
+    QMutexLocker lock(fakeRadioServiceMutex());
+    m_referenceCount--;
+    if (m_referenceCount == 0)
+        delete m_instance;
+}
+
 QMediaControl *FakeRadioService::requestControl(const char* name)
 {
     if (qstrcmp(name,QRadioTunerControl_iid) == 0)
-        return m_control;
+        return m_tunerControl;
+    if (qstrcmp(name,QRadioDataControl_iid) == 0)
+        return m_dataControl;
 
     return 0;
 }
index 6b55d538082ba903d5f7316c57fa8aba1baf06f2..01b0f9e4d34b1a1fd25436ff09509cdef18a05cb 100644 (file)
 #define FAKERADIOSERVICE_H
 
 #include <QtCore/qobject.h>
+#include <QMutex>
 
 #include <qmediaservice.h>
 QT_USE_NAMESPACE
 
 class FakeRadioTunerControl;
+class FakeRadioDataControl;
 
 class FakeRadioService : public QMediaService
 {
     Q_OBJECT
 
-public:
+private:
     FakeRadioService(QObject *parent = 0);
     ~FakeRadioService();
 
+public:
+    static FakeRadioService* instance();
+    void release();
+
     QMediaControl *requestControl(const char* name);
     void releaseControl(QMediaControl *);
 
 private:
-    FakeRadioTunerControl *m_control;
+    static FakeRadioService* m_instance;
+    static int m_referenceCount;
+
+    FakeRadioTunerControl *m_tunerControl;
+    FakeRadioDataControl *m_dataControl;
+
 };
 
 #endif // FAKERADIOSERVICE_H
index d4881195ccf9b7680b8168d5455045c543d40c8b..ee8d0c8d7f86eabd4989c6407e2c48d4a8f5df42 100644 (file)
@@ -59,14 +59,16 @@ QStringList FakeRadioServicePlugin::keys() const
 QMediaService* FakeRadioServicePlugin::create(QString const& key)
 {
     if (key == QLatin1String(Q_MEDIASERVICE_RADIO))
-        return new FakeRadioService;
+        return FakeRadioService::instance();
 
     return 0;
 }
 
 void FakeRadioServicePlugin::release(QMediaService *service)
 {
-    delete service;
+    FakeRadioService* fakeRadio = qobject_cast<FakeRadioService*>(service);
+    if (fakeRadio)
+        fakeRadio->release();
 }
 
 QList<QByteArray> FakeRadioServicePlugin::devices(const QByteArray &service) const
index d88d90ce6abe6ec825604c224c6558d438ea07fb..b30cd0bb4a0b1d164416b9ffbdbc4cf94e73d5e2 100644 (file)
@@ -60,10 +60,16 @@ FakeRadioTunerControl::FakeRadioTunerControl(QObject *parent)
 
     m_searching = false;
     m_forward = true;
+    m_searchMode = QRadioTuner::SearchFast;
+    m_piCounter = 0;
     m_searchTimer = new QTimer(this);
     m_searchTimer->setSingleShot(true);
     connect(m_searchTimer, SIGNAL(timeout()), this, SLOT(searchEnded()));
 
+    m_allStationSeekTimer = new QTimer(this);
+    m_allStationSeekTimer->setSingleShot(true);
+    connect(m_allStationSeekTimer,SIGNAL(timeout()),this,SLOT(newStationFound()));
+
     QTimer::singleShot(300, this, SLOT(delayedInit()));
 
     qsrand(QTime::currentTime().msec());
@@ -269,6 +275,42 @@ void FakeRadioTunerControl::searchBackward()
     performSearch();
 }
 
+void FakeRadioTunerControl::searchAllStations(QRadioTuner::SearchMode searchMode)
+{
+    m_searchMode = searchMode;
+    m_seekingStartFreq = m_currentFreq;
+    m_searching = true;
+    m_allStationSeekTimer->start(10);
+    emit searchingChanged(m_searching);
+}
+
+void FakeRadioTunerControl::newStationFound()
+{
+    QPair<int, int> fRange = frequencyRange(m_currentBand);
+    if (m_currentFreq == fRange.second)
+        m_currentFreq = fRange.first;
+    else
+        m_currentFreq += 100000;
+    emit frequencyChanged(m_currentFreq);
+
+    // There are 200 ticks, we want to find average of 5 stations per scan
+    if (qrand() < (RAND_MAX/40)) {
+        QString programmeId;
+
+        if (m_searchMode == QRadioTuner::SearchGetStationId)
+            programmeId = QString("FakeProgrammeID") + QString::number(m_piCounter++);
+
+        emit stationFound(m_currentFreq, programmeId);
+    }
+
+    if (m_currentFreq == m_seekingStartFreq) {
+        m_searching = false;
+        emit searchingChanged(m_searching);
+    }else {
+        m_allStationSeekTimer->start(10);
+    }
+}
+
 void FakeRadioTunerControl::start()
 {
     if (isAvailable() && m_state != QRadioTuner::ActiveState) {
index abb45cf53e604341a8744947561c0ba9bb5dbd4d..d53e947c7b448ed65072de78de05e33f71ac3089 100644 (file)
@@ -90,6 +90,7 @@ public:
 
     void searchForward();
     void searchBackward();
+    void searchAllStations(QRadioTuner::SearchMode searchMode = QRadioTuner::SearchFast);
 
     void start();
     void stop();
@@ -101,6 +102,7 @@ private slots:
     void delayedInit();
     void performSearch();
     void searchEnded();
+    void newStationFound();
 
 private: //data
     QRadioTuner::State  m_state;
@@ -108,6 +110,7 @@ private: //data
     qint64 m_freqMin;
     qint64 m_freqMax;
     qint64 m_currentFreq;
+    qint64 m_seekingStartFreq;
     bool m_stereo;
     QRadioTuner::StereoMode m_stereoMode;
     int m_signalStrength;
@@ -117,7 +120,11 @@ private: //data
     // searching
     bool m_searching;
     bool m_forward;
+    QRadioTuner::SearchMode m_searchMode;
+    int m_piCounter;
     QTimer *m_searchTimer;
+    QTimer *m_allStationSeekTimer;
+
 };
 
 #endif // FAKERADIOTUNERCONTROL_H
index 307a252567accdb7cae89a6b757d5dd19703bbcb..07289e266ee7f4a646c902330296fde4eb146674 100644 (file)
@@ -18,6 +18,7 @@ SUBDIRS += \
     qmediaservice \
     qmediatimerange \
     qradiotuner \
+    qradiodata \
     qvideoframe \
     qvideosurfaceformat \
     qmetadatareadercontrol \
index a56564f9804ffdf1f92917521c7528cab3eed917..0f7f84a2fa018f6b52ede2f20b91cfe22c53b877 100644 (file)
@@ -4,4 +4,5 @@
 INCLUDEPATH += .
 
 HEADERS += \
-    ../qmultimedia_common/mockradiotunercontrol.h
+    ../qmultimedia_common/mockradiotunercontrol.h \
+    ../qmultimedia_common/mockradiodatacontrol.h
diff --git a/tests/auto/qmultimedia_common/mockradiodatacontrol.h b/tests/auto/qmultimedia_common/mockradiodatacontrol.h
new file mode 100644 (file)
index 0000000..ca6eb40
--- /dev/null
@@ -0,0 +1,157 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MOCKRADIODATACONTROL_H
+#define MOCKRADIODATACONTROL_H
+
+#include "qradiodatacontrol.h"
+
+class MockRadioDataControl : public QRadioDataControl
+{
+    Q_OBJECT
+
+public:
+    MockRadioDataControl(QObject *parent):
+        QRadioDataControl(parent), m_err(QRadioData::NoError),
+        m_errstr("")
+    {
+    }
+
+    using QRadioDataControl::error;
+
+    bool isAvailable() const
+    {
+        return true;
+    }
+    QtMultimedia::AvailabilityError availabilityError() const
+    {
+        return QtMultimedia::NoError;
+    }
+
+    QRadioData::Error error() const
+    {
+        return m_err;
+    }
+
+    QString errorString() const
+    {
+        return m_errstr;
+    }
+
+    QString stationId() const
+    {
+        return m_stationId;
+    }
+
+    QRadioData::ProgramType programType() const
+    {
+        return m_programType;
+    }
+
+    QString programTypeName() const
+    {
+        return m_programTypeName;
+    }
+
+    QString stationName() const
+    {
+        return m_stationName;
+    }
+
+    QString radioText() const
+    {
+        return m_radioText;
+    }
+
+    void setAlternativeFrequenciesEnabled(bool enabled)
+    {
+        m_alternativeFrequenciesEnabled = enabled;
+        emit alternativeFrequenciesEnabledChanged(m_alternativeFrequenciesEnabled);
+    }
+
+    bool isAlternativeFrequenciesEnabled() const
+    {
+        return m_alternativeFrequenciesEnabled;
+    }
+
+    void forceRT( QString text )
+    {
+        m_radioText = text;
+        emit radioTextChanged(m_radioText);
+    }
+
+    void forceProgramType( int pty )
+    {
+        m_programType = static_cast<QRadioData::ProgramType>(pty);
+        emit programTypeChanged(m_programType);
+    }
+
+    void forcePTYN( QString ptyn )
+    {
+        m_programTypeName = ptyn;
+        emit programTypeNameChanged(m_programTypeName);
+    }
+
+    void forcePI( QString pi )
+    {
+        m_stationId = pi;
+        emit stationIdChanged(m_stationId);
+    }
+
+    void forcePS( QString ps )
+    {
+        m_stationName = ps;
+        emit stationNameChanged(m_stationName);
+    }
+
+public:
+    QString m_radioText;
+    QRadioData::ProgramType m_programType;
+    QString m_programTypeName;
+    QString m_stationId;
+    QString m_stationName;
+    bool m_alternativeFrequenciesEnabled;
+
+    QRadioData::Error m_err;
+    QString m_errstr;
+};
+
+#endif // MOCKRADIODATACONTROL_H
index 5e2d015f9485e757aa4329923ce6542c2b55cda3..6648253561cf6f7119792d8910c4e4dbc7f87e00 100644 (file)
@@ -216,6 +216,32 @@ public:
         emit searchingChanged(m_searching);
     }
 
+    void findNewStation( int frequency, QString stationId )
+    {
+        setFrequency(frequency);
+        emit stationFound( frequency, stationId );
+    }
+
+    void searchAllStations(QRadioTuner::SearchMode searchMode = QRadioTuner::SearchFast)
+    {
+        QString programmeIdentifiers[3] = { "", "", "" };
+
+        if ( searchMode == QRadioTuner::SearchGetStationId ) {
+            programmeIdentifiers[0] = QString("MockProgramPI1");
+            programmeIdentifiers[1] = QString("MockProgramPI2");
+            programmeIdentifiers[2] = QString("MockProgramPI3");
+        }
+        m_searching = true;
+        emit searchingChanged(m_searching);
+
+        findNewStation(88300000, programmeIdentifiers[0]);
+        findNewStation(95100000, programmeIdentifiers[1]);
+        findNewStation(103100000, programmeIdentifiers[2]);
+
+        m_searching = false;
+        emit searchingChanged(m_searching);
+    }
+
     void start()
     {
         if (!m_active) {
diff --git a/tests/auto/qradiodata/main.cpp b/tests/auto/qradiodata/main.cpp
new file mode 100755 (executable)
index 0000000..1bd2e27
--- /dev/null
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtCore/qcoreapplication.h>
+#include <QtTest/QtTest>
+
+#include "tst_qradiodata.h"
+
+int main(int argc, char**argv)
+{
+    QCoreApplication app(argc,argv);
+    int ret;
+    tst_QRadioData test_api;
+    ret = QTest::qExec(&test_api, argc, argv);
+    return ret;
+}
diff --git a/tests/auto/qradiodata/qradiodata.pro b/tests/auto/qradiodata/qradiodata.pro
new file mode 100644 (file)
index 0000000..0e3c4ed
--- /dev/null
@@ -0,0 +1,11 @@
+CONFIG += testcase
+TARGET = tst_qradiodata
+
+QT += multimedia-private testlib
+CONFIG += no_private_qt_headers_warning
+
+HEADERS += tst_qradiodata.h
+SOURCES += main.cpp tst_qradiodata.cpp
+
+include (../qmultimedia_common/mock.pri)
+include (../qmultimedia_common/mockradio.pri)
diff --git a/tests/auto/qradiodata/tst_qradiodata.cpp b/tests/auto/qradiodata/tst_qradiodata.cpp
new file mode 100644 (file)
index 0000000..157f63d
--- /dev/null
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//TESTED_COMPONENT=src/multimedia
+
+#include "tst_qradiodata.h"
+
+QT_USE_NAMESPACE
+
+void tst_QRadioData::initTestCase()
+{
+    qRegisterMetaType<QRadioData::ProgramType>("QRadioData::ProgramType");
+
+    mock = new MockRadioDataControl(this);
+    service = new MockMediaService(this, mock);
+    provider = new MockMediaServiceProvider(service);
+    radio = new QRadioData(0,provider);
+    QVERIFY(radio->service() != 0);
+    QVERIFY(radio->isAvailable());
+    QVERIFY(radio->availabilityError() == QtMultimedia::NoError);
+}
+
+void tst_QRadioData::cleanupTestCase()
+{
+    QVERIFY(radio->error() == QRadioData::NoError);
+    QVERIFY(radio->errorString().isEmpty());
+
+    delete radio;
+    delete service;
+    delete provider;
+}
+
+void tst_QRadioData::testNullService()
+{
+    const QPair<int, int> nullRange(0, 0);
+
+    MockMediaServiceProvider provider(0);
+    QRadioData radio(0, &provider);
+    QVERIFY(!radio.isAvailable());
+    QCOMPARE(radio.error(), QRadioData::ResourceError);
+    QCOMPARE(radio.errorString(), QString());
+    QCOMPARE(radio.stationId(), QString());
+    QCOMPARE(radio.programType(), QRadioData::Undefined);
+    QCOMPARE(radio.programTypeName(), QString());
+    QCOMPARE(radio.stationName(), QString());
+    QCOMPARE(radio.radioText(), QString());
+    QCOMPARE(radio.isAlternativeFrequenciesEnabled(), false);
+
+}
+
+void tst_QRadioData::testNullControl()
+{
+    const QPair<int, int> nullRange(0, 0);
+
+    MockMediaService service(0, 0);
+    MockMediaServiceProvider provider(&service);
+    QRadioData radio(0, &provider);
+    QVERIFY(!radio.isAvailable());
+    QCOMPARE(radio.error(), QRadioData::ResourceError);
+    QCOMPARE(radio.errorString(), QString());
+
+    QCOMPARE(radio.stationId(), QString());
+    QCOMPARE(radio.programType(), QRadioData::Undefined);
+    QCOMPARE(radio.programTypeName(), QString());
+    QCOMPARE(radio.stationName(), QString());
+    QCOMPARE(radio.radioText(), QString());
+    QCOMPARE(radio.isAlternativeFrequenciesEnabled(), false);
+    {
+        QSignalSpy spy(&radio, SIGNAL(alternativeFrequenciesEnabledChanged(bool)));
+
+        radio.setAlternativeFrequenciesEnabled(true);
+        QCOMPARE(radio.isAlternativeFrequenciesEnabled(), false);
+        QCOMPARE(spy.count(), 0);
+    }
+}
+
+void tst_QRadioData::testAlternativeFrequencies()
+{
+    QSignalSpy readSignal(radio, SIGNAL(alternativeFrequenciesEnabledChanged(bool)));
+    radio->setAlternativeFrequenciesEnabled(true);
+    QTestEventLoop::instance().enterLoop(1);
+    QVERIFY(radio->isAlternativeFrequenciesEnabled() == true);
+    QVERIFY(readSignal.count() == 1);
+}
+
+void tst_QRadioData::testRadioDataUpdates()
+{
+    QSignalSpy rtSpy(radio, SIGNAL(radioTextChanged(QString)));
+    QSignalSpy ptyPTYSpy(radio, SIGNAL(programTypeChanged(QRadioData::ProgramType)));
+    QSignalSpy ptynSpy(radio, SIGNAL(programTypeNameChanged(QString)));
+    QSignalSpy piSpy(radio, SIGNAL(stationIdChanged(QString)));
+    QSignalSpy psSpy(radio, SIGNAL(stationNameChanged(QString)));
+    mock->forceRT("Mock Radio Text");
+    mock->forceProgramType(static_cast<int>(QRadioData::Sport));
+    mock->forcePTYN("Mock Programme Type Name");
+    mock->forcePI("Mock Programme Identification");
+    mock->forcePS("Mock Programme Service");
+    QTestEventLoop::instance().enterLoop(1);
+    QVERIFY(rtSpy.count() == 1);
+    QVERIFY(ptyPTYSpy.count() == 1);
+    QVERIFY(ptynSpy.count() == 1);
+    QVERIFY(piSpy.count() == 1);
+    QVERIFY(psSpy.count() == 1);
+    qDebug()<<radio->radioText();
+    QCOMPARE(radio->radioText(), QString("Mock Radio Text"));
+    QCOMPARE(radio->programType(), QRadioData::Sport);
+    QCOMPARE(radio->programTypeName(), QString("Mock Programme Type Name"));
+    QCOMPARE(radio->stationId(), QString("Mock Programme Identification"));
+    QCOMPARE(radio->stationName(), QString("Mock Programme Service"));
+}
diff --git a/tests/auto/qradiodata/tst_qradiodata.h b/tests/auto/qradiodata/tst_qradiodata.h
new file mode 100644 (file)
index 0000000..9851975
--- /dev/null
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef TST_QRADIODATA_H
+#define TST_QRADIODATA_H
+
+#include <QtTest/QtTest>
+#include <QDebug>
+#include <QTimer>
+
+#include <qmediaobject.h>
+#include <qmediacontrol.h>
+#include <qmediaservice.h>
+#include <qradiodatacontrol.h>
+#include <qradiodata.h>
+
+#include "mockmediaserviceprovider.h"
+#include "mockmediaservice.h"
+#include "mockradiodatacontrol.h"
+
+QT_USE_NAMESPACE
+
+class tst_QRadioData: public QObject
+{
+    Q_OBJECT
+
+public slots:
+    void initTestCase();
+    void cleanupTestCase();
+
+private slots:
+    void testNullService();
+    void testNullControl();
+    void testAlternativeFrequencies();
+    void testRadioDataUpdates();
+
+private:
+    MockRadioDataControl     *mock;
+    MockMediaService     *service;
+    MockMediaServiceProvider    *provider;
+    QRadioData    *radio;
+};
+#endif
index 62db50ce197eb5c2eae44d6cdea584cd0e2092e6..c426422839790bbcafaecd93242bfbfe1012af19 100644 (file)
@@ -186,6 +186,10 @@ void tst_QRadioTuner::testNullControl()
         QCOMPARE(radio.isSearching(), false);
         QCOMPARE(spy.count(), 0);
 
+        radio.searchAllStations();
+        QCOMPARE(radio.isSearching(), false);
+        QCOMPARE(spy.count(), 0);
+
         radio.cancelSearch();
         QCOMPARE(radio.isSearching(), false);
         QCOMPARE(spy.count(), 0);
@@ -281,6 +285,19 @@ void tst_QRadioTuner::testStereo()
     QVERIFY(radio->stereoMode() == QRadioTuner::ForceMono);
 }
 
+void tst_QRadioTuner::testSearchAllStations()
+{
+    QSignalSpy foundSpy(radio, SIGNAL(stationFound(int,QString)));
+    QSignalSpy completeSpy(radio, SIGNAL(searchingChanged(bool)));
+    radio->searchAllStations(QRadioTuner::SearchGetStationId);
+    QTestEventLoop::instance().enterLoop(1);
+    QCOMPARE(radio->frequency(), 103100000 );
+    QCOMPARE(foundSpy.count(), 3);
+    QVERIFY(qvariant_cast<int>(foundSpy.at(2).at(0)) == 103100000 );
+    QVERIFY(qvariant_cast<QString>(foundSpy.at(2).at(1)) == QString("MockProgramPI3") );
+    QCOMPARE(completeSpy.count(), 2);
+}
+
 // QRadioTuner's errorsignal
 void tst_QRadioTuner::errorSignal()
 {
index 34040ce77f53b15b102ec54416d5b8c5083dbf8e..364f5e2d979bfa697d64d18cd265f8ba6151ab32 100644 (file)
@@ -75,6 +75,7 @@ private slots:
     void testVolume();
     void testSignal();
     void testStereo();
+    void testSearchAllStations();
     void errorSignal();
 
 private: