summaryrefslogtreecommitdiff
path: root/fmrxcontrol.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fmrxcontrol.cpp')
-rw-r--r--fmrxcontrol.cpp159
1 files changed, 159 insertions, 0 deletions
diff --git a/fmrxcontrol.cpp b/fmrxcontrol.cpp
new file mode 100644
index 0000000..8116021
--- /dev/null
+++ b/fmrxcontrol.cpp
@@ -0,0 +1,159 @@
+#include "fmrxcontrol.h"
+#include "fmrxservice.h"
+
+FmRxControl::FmRxControl(FmRxService *parent) :
+ QRadioTunerControl(parent), m_service(parent)
+{
+ connect(m_service, SIGNAL(started()), this, SLOT(handleStarted()));
+ connect(m_service, SIGNAL(stopped()), this, SLOT(handleStopped()));
+ connect(m_service, SIGNAL(tuned(double)), this, SLOT(handleTuned(double)));
+}
+
+bool FmRxControl::isAvailable() const
+{
+ return m_service->isAvailable();
+}
+
+QtMultimediaKit::AvailabilityError FmRxControl::availabilityError() const
+{
+ return m_service->availabilityError();
+}
+
+QRadioTuner::State FmRxControl::state() const
+{
+ return m_service->isActive() ?
+ QRadioTuner::ActiveState : QRadioTuner::StoppedState;
+}
+
+QRadioTuner::Band FmRxControl::band() const
+{
+ return QRadioTuner::FM;
+}
+
+void FmRxControl::setBand(QRadioTuner::Band b)
+{
+ // Only one band!
+ Q_UNUSED(b);
+}
+
+bool FmRxControl::isBandSupported(QRadioTuner::Band b) const
+{
+ return b == QRadioTuner::FM;
+}
+
+int FmRxControl::frequency() const
+{
+ return m_service->frequency() * 1000000.0;
+}
+
+int FmRxControl::frequencyStep(QRadioTuner::Band b) const
+{
+ return 100 * 1000;
+}
+
+QPair<int, int> FmRxControl::frequencyRange(QRadioTuner::Band b) const
+{
+ if (b == QRadioTuner::FM)
+ return qMakePair<int,int>(87500000, 108000000);
+
+ return qMakePair<int,int>(0, 0);
+}
+
+void FmRxControl::setFrequency(int frequency)
+{
+ m_service->setFrequency(frequency / 1000000.0);
+}
+
+bool FmRxControl::isStereo() const
+{
+ return true; // TODO
+}
+
+QRadioTuner::StereoMode FmRxControl::stereoMode() const
+{
+ return QRadioTuner::Auto;
+}
+
+void FmRxControl::setStereoMode(QRadioTuner::StereoMode mode)
+{
+ // TODO
+}
+
+int FmRxControl::signalStrength() const
+{
+ return 0; // TODO
+}
+
+int FmRxControl::volume() const
+{
+ return 100; // Best not to have volume control in Harmattan.
+}
+void FmRxControl::setVolume(int volume)
+{
+ // Best not to have volume control in Harmattan.
+}
+
+bool FmRxControl::isMuted() const
+{
+ return false;
+}
+
+void FmRxControl::setMuted(bool muted)
+{
+ // Best not to have volume control in Harmattan.
+}
+
+bool FmRxControl::isSearching() const
+{
+ return false;
+}
+
+void FmRxControl::cancelSearch()
+{
+ // TODO
+}
+
+void FmRxControl::searchForward()
+{
+ m_service->searchForward();
+}
+
+void FmRxControl::searchBackward()
+{
+ m_service->searchBackward();
+}
+
+void FmRxControl::start()
+{
+ m_service->start();
+}
+
+void FmRxControl::stop()
+{
+ m_service->stop();
+}
+
+QRadioTuner::Error FmRxControl::error() const
+{
+ return QRadioTuner::NoError;
+}
+
+QString FmRxControl::errorString() const
+{
+ return QString();
+}
+
+void FmRxControl::handleStarted()
+{
+ emit stateChanged(QRadioTuner::ActiveState);
+}
+
+void FmRxControl::handleStopped()
+{
+ emit stateChanged(QRadioTuner::StoppedState);
+}
+
+void FmRxControl::handleTuned(double frequency)
+{
+ emit frequencyChanged(frequency * 1000000.0);
+}