summaryrefslogtreecommitdiff
path: root/fmrxcontrol.cpp
blob: 8116021c7ac44a240666dd643c141f7994bf9662 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
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);
}