|
1 /* |
|
2 * Copyright (c) 2002-2004 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: Active object for each spontaneous event from Radio Server. |
|
15 * Notifies MRadioEventObserver upon receiving a new event. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include "RadioEventHandler.h" |
|
23 #include "RadioClientServer.h" |
|
24 #include "RadioDebug.h" |
|
25 |
|
26 // ============================ MEMBER FUNCTIONS =============================== |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CRadioEventHandler::CRadioEventHandler |
|
30 // C++ default constructor can NOT contain any code, that |
|
31 // might leave. |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 CRadioEventHandler::CRadioEventHandler( |
|
35 MRadioObserver& aObserver, |
|
36 RRadioSession& aSession, |
|
37 TUint aKey ) |
|
38 : CActive(EPriorityStandard), |
|
39 iSession(aSession), |
|
40 iKey(aKey), |
|
41 iObserver(aObserver) |
|
42 { |
|
43 if ( iKey == ERadioServPsAfSearchEnd ) |
|
44 { |
|
45 // This is necessary to make sure AfSearchEnd comes in before FrequencyChanged event. |
|
46 // Because the AO for FrequencyChanged is added to the scheduler first, AfSearchEnd |
|
47 // must have slightly higer priority to come in first. |
|
48 SetPriority(EPriorityUserInput); |
|
49 } |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CRadioEventHandler::ConstructL |
|
54 // Symbian 2nd phase constructor can leave. |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 void CRadioEventHandler::ConstructL() |
|
58 { |
|
59 RADIO_RDEBUG(_L("[RADIO-SESS] CRadioEventHandler::ConstructL()")); |
|
60 CActiveScheduler::Add(this); |
|
61 User::LeaveIfError( iProperty.Attach(KRadioServerPropertyCategory, iKey) ); |
|
62 iProperty.Subscribe(iStatus); |
|
63 SetActive(); |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CRadioEventHandler::NewL |
|
68 // Two-phased constructor. |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 CRadioEventHandler* CRadioEventHandler::NewLC( |
|
72 MRadioObserver& aObserver, |
|
73 RRadioSession& aSession, |
|
74 TUint aKey ) |
|
75 { |
|
76 CRadioEventHandler* self = new( ELeave ) CRadioEventHandler(aObserver,aSession, aKey); |
|
77 CleanupStack::PushL( self ); |
|
78 self->ConstructL(); |
|
79 return self; |
|
80 } |
|
81 |
|
82 // Destructor |
|
83 CRadioEventHandler::~CRadioEventHandler() |
|
84 { |
|
85 if ( IsActive() ) |
|
86 { |
|
87 Cancel(); |
|
88 } |
|
89 iProperty.Close(); |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // CRadioEventHandler::DoCancel |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 void CRadioEventHandler::DoCancel() |
|
97 { |
|
98 iProperty.Cancel(); |
|
99 } |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CRadioEventHandler::RunL |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 void CRadioEventHandler::RunL() |
|
106 { |
|
107 // Subscribe immediately before analyzing the notification to ensure that we |
|
108 // don't miss further updates. |
|
109 iProperty.Subscribe(iStatus); |
|
110 SetActive(); |
|
111 |
|
112 switch ( iKey ) |
|
113 { |
|
114 case ERadioServPsPlayerState: |
|
115 { |
|
116 TPckgBuf<TRsSettingsData> playerState; |
|
117 iProperty.Get(playerState); |
|
118 iObserver.RadioEventStateChange(playerState().iData1, // Player state |
|
119 playerState().iError); |
|
120 } |
|
121 break; |
|
122 case ERadioServPsAntennaStatus: |
|
123 { |
|
124 TBool attached; |
|
125 iProperty.Get(attached); |
|
126 iObserver.RadioEventAntennaStatusChange(attached); |
|
127 } |
|
128 break; |
|
129 case ERadioServPsOfflineMode: |
|
130 { |
|
131 TBool offline; |
|
132 iProperty.Get(offline); |
|
133 iObserver.RadioEventOfflineModeChange(offline); |
|
134 } |
|
135 break; |
|
136 case ERadioServPsTransmitterStatus: |
|
137 { |
|
138 TBool transmitter; |
|
139 iProperty.Get(transmitter); |
|
140 iObserver.RadioEventTransmitterStatusChange(transmitter); |
|
141 } |
|
142 break; |
|
143 case ERadioServPsFrequency: |
|
144 { |
|
145 TInt frequency; |
|
146 iProperty.Get(frequency); |
|
147 iObserver.RadioEventFrequencyChange(frequency); |
|
148 } |
|
149 break; |
|
150 case ERadioServPsFrequencyRange: |
|
151 { |
|
152 TInt freqRange; |
|
153 iProperty.Get(freqRange); |
|
154 iObserver.RadioEventFrequencyRangeChanged((TRsFrequencyRange) freqRange); |
|
155 } |
|
156 break; |
|
157 case ERadioServPsForceMonoReception: |
|
158 { |
|
159 TBool forcedMono; |
|
160 iProperty.Get(forcedMono); |
|
161 iObserver.RadioEventForcedMonoChanged(forcedMono); |
|
162 } |
|
163 break; |
|
164 case ERadioServPsSquelch: |
|
165 { |
|
166 TBool squelch; |
|
167 iProperty.Get(squelch); |
|
168 iObserver.RadioEventSquelchChanged(squelch); |
|
169 } |
|
170 break; |
|
171 case ERadioServPsVolume: |
|
172 { |
|
173 TInt volume; |
|
174 iProperty.Get(volume); |
|
175 iObserver.RadioEventVolumeChange(volume); |
|
176 } |
|
177 break; |
|
178 case ERadioServPsMuteStatus: |
|
179 { |
|
180 TBool muted; |
|
181 iProperty.Get(muted); |
|
182 iObserver.RadioEventMuteChange(muted); |
|
183 } |
|
184 break; |
|
185 case ERadioServPsBalance: |
|
186 { |
|
187 TPckgBuf<TRsSettingsData> balance; |
|
188 iProperty.Get(balance); |
|
189 iObserver.RadioEventBalanceChange(balance().iData1, // Left |
|
190 balance().iData2); // Right |
|
191 } |
|
192 break; |
|
193 case ERadioServPsRdsSignalStatus: |
|
194 { |
|
195 TBool signal; |
|
196 iProperty.Get(signal); |
|
197 iObserver.RadioEventRdsSignalChange(signal); |
|
198 } |
|
199 break; |
|
200 case ERadioServPsAutoSwitchStatus: |
|
201 { |
|
202 TBool autoSwitch; |
|
203 iProperty.Get(autoSwitch); |
|
204 iObserver.RadioEventRdsAutomaticSwitchingChange(autoSwitch); |
|
205 } |
|
206 break; |
|
207 case ERadioServPsProgrammeIdentification: |
|
208 { |
|
209 TInt pi; |
|
210 iProperty.Get(pi); |
|
211 iObserver.RadioEventRdsDataPI(pi); |
|
212 } |
|
213 break; |
|
214 case ERadioServPsProgrammeType: |
|
215 { |
|
216 TRsRdsProgrammeType pty; |
|
217 iProperty.Get(pty); |
|
218 iObserver.RadioEventRdsDataPTY(pty); |
|
219 } |
|
220 break; |
|
221 case ERadioServPsProgrammeService: |
|
222 { |
|
223 TRsRdsPSName ps; |
|
224 iProperty.Get(ps); |
|
225 iObserver.RadioEventRdsDataPS(ps); |
|
226 } |
|
227 break; |
|
228 case ERadioServPsRadioText: |
|
229 { |
|
230 TRsRdsRadioText rt; |
|
231 iProperty.Get(rt); |
|
232 iObserver.RadioEventRdsDataRT(rt); |
|
233 } |
|
234 break; |
|
235 case ERadioServPsRadioTextPlusObjects: |
|
236 { |
|
237 TPckgBuf<TRsRdsRTPlusObjectData> objData; |
|
238 TUint32 iClassType1; |
|
239 TUint32 iClassType2; |
|
240 TRsRdsRadioText aRTobject1; |
|
241 TRsRdsRadioText aRTobject2; |
|
242 |
|
243 iProperty.Get(objData); |
|
244 |
|
245 aRTobject1 = objData().aRtObj1; |
|
246 iClassType1 = objData().iContentType1; |
|
247 aRTobject2 = objData().aRtObj2; |
|
248 iClassType2 = objData().iContentType2; |
|
249 |
|
250 iObserver.RadioEventRdsDataRTplus( (TRsRdsRTplusClass)iClassType1, aRTobject1 ); |
|
251 iObserver.RadioEventRdsDataRTplus( (TRsRdsRTplusClass)iClassType2, aRTobject2 ); |
|
252 } |
|
253 break; |
|
254 case ERadioServPsClockTime: |
|
255 { |
|
256 TPckgBuf<TDateTime> rdsCt; |
|
257 iProperty.Get(rdsCt); |
|
258 iObserver.RadioEventRdsDataCT(rdsCt()); |
|
259 } |
|
260 break; |
|
261 case ERadioServPsTrafficAnnouncementStatus: |
|
262 { |
|
263 TBool taOn; |
|
264 iProperty.Get(taOn); |
|
265 iObserver.RadioEventRdsDataTA(taOn); |
|
266 } |
|
267 break; |
|
268 case ERadioServPsAfSearchBegin: |
|
269 { |
|
270 iObserver.RadioEventRdsSearchBeginAF(); |
|
271 } |
|
272 break; |
|
273 case ERadioServPsAfSearchEnd: |
|
274 { |
|
275 TPckgBuf<TRsSettingsData> afData; |
|
276 iProperty.Get(afData); |
|
277 iObserver.RadioEventRdsSearchEndAF(afData().iError, |
|
278 afData().iData1); // Frequency |
|
279 } |
|
280 break; |
|
281 default: |
|
282 { |
|
283 RADIO_RDEBUG(_L("[RADIO-SESS] CRadioEventHandler::RunL(): ERROR case default !!!")); |
|
284 User::Panic(_L("RadioServer"), KErrGeneral ); |
|
285 } |
|
286 break; |
|
287 } |
|
288 } |
|
289 |
|
290 // End of File |
|
291 |