21
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <unistd.h>
|
25
|
19 |
#include "xadebug.h"
|
|
20 |
#include "xaadaptationmmf.h"
|
|
21 |
#include "xaradioitfadaptation.h"
|
|
22 |
#include "xaradioadaptctx.h"
|
21
|
23 |
#include "cmmfradiobackendengine.h"
|
|
24 |
|
|
25 |
/*
|
|
26 |
* XAresult XARadioItfAdapt_SetFreqRange(XAAdaptationMMFCtx *bCtx, XAuint8 range)
|
|
27 |
*/
|
|
28 |
XAresult XARadioItfAdapt_SetFreqRange(XAAdaptationMMFCtx *bCtx, XAuint8 range)
|
|
29 |
{
|
|
30 |
XAresult ret = XA_RESULT_SUCCESS;
|
|
31 |
DEBUG_API("->XARadioItfAdapt_SetFreqRange");
|
|
32 |
mmf_set_radio_adapt_context(cmmfradiobackendengine_init(), bCtx);
|
|
33 |
set_freq_range(cmmfradiobackendengine_init(), range);
|
|
34 |
DEBUG_API("<-XARadioItfAdapt_SetFreqRange");
|
|
35 |
return ret;
|
|
36 |
}
|
|
37 |
|
|
38 |
/*
|
|
39 |
* XAresult XARadioItfAdapt_GetFreqRange(XAuint8 * pFreqRange)
|
|
40 |
*
|
|
41 |
*/
|
|
42 |
XAresult XARadioItfAdapt_GetFreqRange(XAuint8 * pFreqRange)
|
|
43 |
{
|
|
44 |
XAresult res = XA_RESULT_SUCCESS;
|
|
45 |
DEBUG_API("->XARadioItfAdapt_GetFreqRange");
|
|
46 |
res = get_freq_range(cmmfradiobackendengine_init(), pFreqRange);
|
|
47 |
DEBUG_API("<-XARadioItfAdapt_GetFreqRange");
|
|
48 |
return res;
|
|
49 |
}
|
|
50 |
|
|
51 |
/*
|
|
52 |
* XAresult XARadioItfAdapt_IsFreqRangeSupported(XAuint8 range,
|
|
53 |
* XAboolean * pSupported)
|
|
54 |
*/
|
|
55 |
XAresult XARadioItfAdapt_IsFreqRangeSupported(XAuint8 range,
|
|
56 |
XAboolean * pSupported)
|
|
57 |
{
|
|
58 |
XAresult ret = XA_RESULT_SUCCESS;
|
|
59 |
DEBUG_API("->XARadioItfAdapt_IsFreqRangeSupported");
|
28
|
60 |
if ((range == XA_FREQRANGE_FMEUROAMERICA) || (range == XA_FREQRANGE_FMJAPAN))
|
|
61 |
{
|
|
62 |
*pSupported = XA_BOOLEAN_TRUE;
|
|
63 |
}
|
|
64 |
else
|
|
65 |
*pSupported = XA_BOOLEAN_FALSE;
|
|
66 |
|
21
|
67 |
DEBUG_API("<-XARadioItfAdapt_IsFreqRangeSupported");
|
|
68 |
return ret;
|
|
69 |
}
|
|
70 |
|
|
71 |
/*
|
|
72 |
* XAresult XARadioItfAdapt_GetFreqRangeProperties(XAAdaptationMMFCtx *bCtx,
|
38
|
73 |
* XAuint8 range,
|
21
|
74 |
* XAuint32 * pMinFreq,
|
|
75 |
* XAuint32 * pMaxFreq)
|
|
76 |
*/
|
|
77 |
XAresult XARadioItfAdapt_GetFreqRangeProperties(XAAdaptationMMFCtx *bCtx,
|
|
78 |
XAuint8 range,
|
|
79 |
XAuint32 * pMinFreq,
|
|
80 |
XAuint32 * pMaxFreq)
|
|
81 |
{
|
|
82 |
XAresult res = XA_RESULT_SUCCESS;
|
|
83 |
DEBUG_API("->XARadioItfAdapt_GetFreqRangeProperties");
|
|
84 |
mmf_set_radio_adapt_context(cmmfradiobackendengine_init(), bCtx);
|
|
85 |
res = get_freq_range_properties(cmmfradiobackendengine_init(), range, pMinFreq, pMaxFreq);
|
|
86 |
DEBUG_API("<-XARadioItfAdapt_GetFreqRangeProperties");
|
|
87 |
return res;
|
|
88 |
}
|
|
89 |
|
|
90 |
/*
|
|
91 |
* XAresult XARadioItfAdapt_SetFrequency(XAAdaptationMMFCtx *bCtx, XAuint32 freq)
|
|
92 |
*/
|
|
93 |
XAresult XARadioItfAdapt_SetFrequency(XAAdaptationMMFCtx *bCtx, XAuint32 freq)
|
|
94 |
{
|
|
95 |
XAresult ret = XA_RESULT_SUCCESS;
|
|
96 |
DEBUG_API("->XARadioItfAdapt_SetFrequency");
|
|
97 |
mmf_set_radio_adapt_context(cmmfradiobackendengine_init(), bCtx);
|
|
98 |
set_frequency(cmmfradiobackendengine_init(), freq);
|
|
99 |
DEBUG_API("<-XARadioItfAdapt_SetFrequency");
|
|
100 |
return ret;
|
|
101 |
}
|
|
102 |
|
|
103 |
|
|
104 |
/*
|
|
105 |
* XAresult XARadioItfAdapt_GetFrequency(XAAdaptationMMFCtx *bCtx,
|
|
106 |
* XAuint32* pFrequency)
|
|
107 |
*/
|
|
108 |
XAresult XARadioItfAdapt_GetFrequency(XAuint32* pFrequency)
|
|
109 |
{
|
|
110 |
XAresult ret = XA_RESULT_SUCCESS;
|
|
111 |
DEBUG_API("->XARadioItfAdapt_GetFrequency");
|
|
112 |
ret = get_frequency(cmmfradiobackendengine_init(), pFrequency);
|
|
113 |
DEBUG_API("<-XARadioItfAdapt_GetFrequency");
|
|
114 |
return ret;
|
|
115 |
}
|
|
116 |
|
|
117 |
|
|
118 |
/*
|
|
119 |
* XAresult XARadioItfAdapt_CancelSetFrequency()
|
|
120 |
*/
|
|
121 |
XAresult XARadioItfAdapt_CancelSetFrequency()
|
|
122 |
{
|
|
123 |
XAresult ret = XA_RESULT_SUCCESS;
|
|
124 |
DEBUG_API("->XARadioItfAdapt_CancelSetFrequency");
|
|
125 |
cancel_set_frequency(cmmfradiobackendengine_init());
|
|
126 |
DEBUG_API("<-XARadioItfAdapt_CancelSetFrequency");
|
|
127 |
return ret;
|
|
128 |
}
|
|
129 |
|
|
130 |
/*
|
|
131 |
* XAresult XARadioItfAdapt_SetSquelch(XAboolean squelch)
|
|
132 |
*/
|
|
133 |
XAresult XARadioItfAdapt_SetSquelch(XAboolean squelch)
|
|
134 |
{
|
|
135 |
XAresult ret = XA_RESULT_FEATURE_UNSUPPORTED;
|
|
136 |
DEBUG_API("->XARadioItfAdapt_SetSquelch");
|
|
137 |
return ret;
|
|
138 |
}
|
|
139 |
|
|
140 |
/*
|
|
141 |
* XAresult XARadioItfAdapt_GetSquelch(XAboolean *squelch)
|
|
142 |
*/
|
|
143 |
XAresult XARadioItfAdapt_GetSquelch(XAboolean* squelch)
|
|
144 |
{
|
|
145 |
XAresult ret = XA_RESULT_FEATURE_UNSUPPORTED;
|
|
146 |
DEBUG_API("->XARadioItfAdapt_GetSquelch");
|
|
147 |
return ret;
|
|
148 |
}
|
|
149 |
|
|
150 |
/*
|
|
151 |
* XAresult XARadioItfAdapt_SetStereoMode(XAAdaptationMMFCtx *bCtx, XAuint32 mode)
|
|
152 |
*/
|
|
153 |
XAresult XARadioItfAdapt_SetStereoMode(XAAdaptationMMFCtx *bCtx, XAuint32 mode)
|
|
154 |
{
|
|
155 |
XAresult res = XA_RESULT_SUCCESS;
|
|
156 |
DEBUG_API("->XARadioItfAdapt_SetStereoMode");
|
|
157 |
mmf_set_radio_adapt_context(cmmfradiobackendengine_init(), bCtx);
|
|
158 |
res = set_stereo_mode(cmmfradiobackendengine_init(), mode);
|
|
159 |
DEBUG_API("<-XARadioItfAdapt_SetStereoMode");
|
|
160 |
return res;
|
|
161 |
}
|
|
162 |
|
|
163 |
/*
|
|
164 |
* XAresult XARadioItfAdapt_GetSignalStrength(XAuint32 * pStrength)
|
|
165 |
*/
|
|
166 |
XAresult XARadioItfAdapt_GetSignalStrength(XAuint32 * pStrength)
|
|
167 |
{
|
|
168 |
XAresult ret = XA_RESULT_SUCCESS;
|
|
169 |
DEBUG_API("->XARadioItfAdapt_GetSignalStrength");
|
|
170 |
ret = get_signal_strength(cmmfradiobackendengine_init(), pStrength);
|
|
171 |
DEBUG_API("<-XARadioItfAdapt_GetSignalStrength");
|
|
172 |
return ret;
|
|
173 |
}
|
|
174 |
|
|
175 |
/*
|
|
176 |
* XAresult XARadioItfAdapt_Seek(XAAdaptationMMFCtx *bCtx, XAboolean upwards)
|
|
177 |
*/
|
|
178 |
XAresult XARadioItfAdapt_Seek(XAAdaptationMMFCtx *bCtx, XAboolean upwards)
|
|
179 |
{
|
|
180 |
XAresult ret = XA_RESULT_SUCCESS;
|
28
|
181 |
|
21
|
182 |
DEBUG_API("->XARadioItfAdapt_Seek");
|
|
183 |
mmf_set_radio_adapt_context(cmmfradiobackendengine_init(), bCtx);
|
28
|
184 |
station_seek(cmmfradiobackendengine_init(), upwards);
|
21
|
185 |
DEBUG_API("<-XARadioItfAdapt_Seek");
|
|
186 |
return ret;
|
|
187 |
}
|
|
188 |
|
|
189 |
/*
|
|
190 |
* void XARadioItfAdapt_StopSeeking(XAAdaptationMMFCtx *bCtx)
|
|
191 |
*/
|
|
192 |
void XARadioItfAdapt_StopSeeking(XAAdaptationMMFCtx *bCtx)
|
|
193 |
{
|
|
194 |
DEBUG_API("->XARadioItfAdapt_StopSeeking");
|
|
195 |
mmf_set_radio_adapt_context(cmmfradiobackendengine_init(), bCtx);
|
|
196 |
cancel_station_seek(cmmfradiobackendengine_init());
|
|
197 |
DEBUG_API("<-XARadioItfAdapt_StopSeeking");
|
|
198 |
}
|
|
199 |
|
|
200 |
/*
|
|
201 |
* XAresult XARadioItfAdapt_GetStereoMode(XAuint32 * pMode)
|
|
202 |
*/
|
|
203 |
XAresult XARadioItfAdapt_GetStereoMode(XAuint32 * pMode)
|
|
204 |
{
|
|
205 |
XAresult ret = XA_RESULT_SUCCESS;
|
|
206 |
DEBUG_API("->XARadioItfAdapt_GetStereoMode");
|
|
207 |
ret = get_stereo_mode(cmmfradiobackendengine_init(), pMode);
|
|
208 |
DEBUG_API("<-XARadioItfAdapt_GetStereoMode");
|
|
209 |
return ret;
|
|
210 |
}
|
|
211 |
|
|
212 |
/*
|
|
213 |
* void XARadioItfAdapt_Free()
|
|
214 |
*/
|
|
215 |
void XARadioItfAdapt_Free()
|
|
216 |
{
|
|
217 |
DEBUG_API("->XARadioItfAdapt_Free");
|
|
218 |
|
|
219 |
}
|
|
220 |
|
|
221 |
void XARadioItfAdapt_SeekComplete(XAAdaptationBaseCtx *ctx, TInt aError, TInt aFrequency)
|
|
222 |
{
|
|
223 |
XAAdaptEvent event = {XA_RADIOITFEVENTS, XA_ADAPT_RADIO_SEEK_COMPLETE,1,0};
|
|
224 |
if (ctx)
|
|
225 |
{
|
|
226 |
if (aError)
|
|
227 |
{
|
|
228 |
event.data = &aError;
|
|
229 |
}
|
|
230 |
else
|
|
231 |
{
|
|
232 |
event.data = &aFrequency;
|
|
233 |
}
|
|
234 |
|
|
235 |
XAAdaptationBase_SendAdaptEvents(ctx, &event );
|
|
236 |
}
|
|
237 |
}
|
|
238 |
|
|
239 |
void XARadioItfAdapt_FrequencyChange(XAAdaptationBaseCtx *ctx, TInt aFrequency)
|
|
240 |
{
|
|
241 |
// Currently: Bug in FM Radio Utility: SetFrequency calls this callback as well as SetFrequencyComplete
|
|
242 |
// (So client will end up getting 2 events on a SetFrequency call)
|
|
243 |
XAuint32 freq = aFrequency;
|
|
244 |
XAAdaptEvent event = {XA_RADIOITFEVENTS, XA_ADAPT_RADIO_FREQUENCY_CHANGED,1,0};
|
|
245 |
if (ctx)
|
|
246 |
{
|
|
247 |
event.data = &freq;
|
|
248 |
XAAdaptationBase_SendAdaptEvents(ctx, &event );
|
|
249 |
}
|
|
250 |
}
|
|
251 |
|
|
252 |
void XARadioItfAdapt_FrequencyRangeChange(XAAdaptationBaseCtx* ctx, TInt aFreqRangeChange)
|
|
253 |
{
|
|
254 |
// Currently: Bug in FM Radio Utility: SetFrequencyRange triggers this callback as well as SetFrequencyRangeComplete
|
|
255 |
|
|
256 |
/* XAAdaptEvent event = {XA_RADIOITFEVENTS, XA_ADAPT_RADIO_FREQUENCY_RANGE_CHANGED,1,0};
|
|
257 |
if (baseCtx)
|
|
258 |
{
|
|
259 |
event.data = &aFreqRangeChange;
|
|
260 |
XAAdaptationBase_SendAdaptEvents(&baseCtx->baseObj, &event );
|
|
261 |
}
|
|
262 |
*/
|
|
263 |
}
|
|
264 |
|
|
265 |
void XARadioItfAdapt_SetFrequencyComplete(XAAdaptationBaseCtx *ctx, TInt aError, TInt aFrequency)
|
|
266 |
{
|
|
267 |
// Currently: Qt API has no event for SetFrequencyComplete, so must use this one:
|
|
268 |
XAAdaptEvent event = {XA_RADIOITFEVENTS, XA_ADAPT_RADIO_FREQUENCY_CHANGED,1,0};
|
|
269 |
XAuint32 freq = aFrequency;
|
|
270 |
if (ctx)
|
|
271 |
{
|
|
272 |
if (!aError)
|
|
273 |
{
|
|
274 |
event.data = &freq;
|
|
275 |
}
|
|
276 |
else
|
|
277 |
{
|
|
278 |
event.data = &aError;
|
|
279 |
}
|
|
280 |
XAAdaptationBase_SendAdaptEvents(ctx, &event );
|
|
281 |
}
|
|
282 |
}
|
|
283 |
|
|
284 |
void XARadioItfAdapt_SetFrequencyRangeComplete(XAAdaptationBaseCtx *ctx, TInt aError)
|
|
285 |
{
|
|
286 |
XAAdaptEvent event = {XA_RADIOITFEVENTS, XA_ADAPT_RADIO_FREQUENCY_RANGE_CHANGED,1,0};
|
|
287 |
if (ctx)
|
|
288 |
{
|
|
289 |
event.data = &aError;
|
|
290 |
XAAdaptationBase_SendAdaptEvents(ctx, &event );
|
|
291 |
}
|
|
292 |
}
|
|
293 |
|
|
294 |
void XARadioItfAdapt_StereoStatusChange(XAAdaptationBaseCtx *ctx, XAboolean aStereoStatus)
|
|
295 |
{
|
|
296 |
XAAdaptEvent event = {XA_RADIOITFEVENTS, XA_ADAPT_RADIO_STEREO_STATUS_CHANGED,1,0};
|
|
297 |
DEBUG_INFO_A1("XARadioItfAdapt_StereoStatusChange to: %s", aStereoStatus);
|
|
298 |
if (ctx)
|
|
299 |
{
|
|
300 |
event.data = &aStereoStatus;
|
|
301 |
XAAdaptationBase_SendAdaptEvents(ctx, &event );
|
|
302 |
}
|
|
303 |
}
|
|
304 |
|
|
305 |
void XARadioItfAdapt_SignalStrengthChange(XAAdaptationBaseCtx *ctx, TInt aSignalStrength)
|
|
306 |
{
|
|
307 |
XAAdaptEvent event = {XA_RADIOITFEVENTS, XA_ADAPT_RADIO_SIGNAL_STRENGTH_CHANGED,1,0};
|
|
308 |
DEBUG_INFO_A1("XARadioItfAdapt_SignalStrengthChange to: %s", aSignalStrength);
|
|
309 |
if (ctx)
|
|
310 |
{
|
|
311 |
event.data = &aSignalStrength;
|
|
312 |
XAAdaptationBase_SendAdaptEvents(ctx, &event );
|
|
313 |
}
|
|
314 |
}
|