author | hgs |
Fri, 15 Oct 2010 16:26:27 +0300 | |
changeset 57 | 21be958eb3ce |
parent 54 | a8ba0c289b44 |
permissions | -rw-r--r-- |
24 | 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 |
// System includes |
|
19 |
#include <e32cmn.h> |
|
20 |
||
21 |
// User includes |
|
22 |
#include "cradioaccessoryobserver.h" |
|
23 |
#include "cradiosystemeventcollectorimp.h" |
|
24 |
#include "cradiosystemeventdetector.h" |
|
25 |
#include "radioengineutils.h" |
|
26 |
#include "cradioenginelogger.h" |
|
27 |
||
28 |
const TInt KVRObserverArrayGranularity( 2 ); |
|
29 |
||
30 |
// --------------------------------------------------------------------------- |
|
31 |
// |
|
32 |
// --------------------------------------------------------------------------- |
|
33 |
// |
|
34 |
CRadioSystemEventCollectorImp::CRadioSystemEventCollectorImp() : |
|
35 |
iSystemEventObservers( KVRObserverArrayGranularity ) |
|
36 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
37 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 38 |
} |
39 |
||
40 |
// --------------------------------------------------------------------------- |
|
41 |
// |
|
42 |
// --------------------------------------------------------------------------- |
|
43 |
// |
|
44 |
void CRadioSystemEventCollectorImp::ConstructL() |
|
45 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
46 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 47 |
RadioEngineUtils::InitializeL(); |
48 |
iSystemEventDetector = CRadioSystemEventDetector::NewL( *this ); |
|
49 |
||
50 |
iHeadsetObserver = CRadioAccessoryObserver::NewL(); |
|
51 |
iHeadsetObserver->SetObserver( this ); |
|
52 |
} |
|
53 |
||
54 |
// --------------------------------------------------------------------------- |
|
55 |
// |
|
56 |
// --------------------------------------------------------------------------- |
|
57 |
// |
|
58 |
CRadioSystemEventCollectorImp* CRadioSystemEventCollectorImp::NewL() |
|
59 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
60 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 61 |
CRadioSystemEventCollectorImp* self = new( ELeave ) CRadioSystemEventCollectorImp; |
62 |
CleanupStack::PushL( self ); |
|
63 |
self->ConstructL(); |
|
64 |
CleanupStack::Pop( self ); |
|
65 |
return self; |
|
66 |
} |
|
67 |
||
68 |
// --------------------------------------------------------------------------- |
|
69 |
// |
|
70 |
// --------------------------------------------------------------------------- |
|
71 |
// |
|
72 |
CRadioSystemEventCollectorImp::~CRadioSystemEventCollectorImp() |
|
73 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
74 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 75 |
delete iSystemEventDetector; |
76 |
delete iHeadsetObserver; |
|
77 |
||
78 |
iSystemEventObservers.Close(); |
|
79 |
RadioEngineUtils::Release(); |
|
80 |
} |
|
81 |
||
82 |
// --------------------------------------------------------------------------- |
|
83 |
// Adds a system event observer |
|
84 |
// --------------------------------------------------------------------------- |
|
85 |
// |
|
86 |
void CRadioSystemEventCollectorImp::AddObserverL( MRadioSystemEventObserver* aHeadsetObserver ) |
|
87 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
88 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 89 |
iSystemEventObservers.AppendL( aHeadsetObserver ); |
90 |
} |
|
91 |
||
92 |
// --------------------------------------------------------------------------- |
|
93 |
// Removes a system event observer |
|
94 |
// --------------------------------------------------------------------------- |
|
95 |
// |
|
96 |
void CRadioSystemEventCollectorImp::RemoveObserver( MRadioSystemEventObserver* aSystemObserver ) |
|
97 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
98 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 99 |
TInt objectIndex = iSystemEventObservers.Find( aSystemObserver ); |
100 |
||
101 |
if ( objectIndex != KErrNotFound ) |
|
102 |
{ |
|
103 |
iSystemEventObservers.Remove( objectIndex ); |
|
104 |
} |
|
105 |
} |
|
106 |
||
107 |
// --------------------------------------------------------------------------- |
|
108 |
// Getter for mobile network state |
|
109 |
// --------------------------------------------------------------------------- |
|
110 |
// |
|
111 |
TBool CRadioSystemEventCollectorImp::IsMobileNetworkCoverage() const |
|
112 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
113 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 114 |
return iSystemEventDetector->IsMobileNetworkCoverage(); |
115 |
} |
|
116 |
||
117 |
// --------------------------------------------------------------------------- |
|
118 |
// Getter for network state |
|
119 |
// --------------------------------------------------------------------------- |
|
120 |
// |
|
121 |
TBool CRadioSystemEventCollectorImp::IsNetworkCoverage() const |
|
122 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
123 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 124 |
return iSystemEventDetector->IsNetworkCoverage(); |
125 |
} |
|
126 |
||
127 |
// --------------------------------------------------------------------------- |
|
128 |
// Getter for call state |
|
129 |
// --------------------------------------------------------------------------- |
|
130 |
// |
|
131 |
TBool CRadioSystemEventCollectorImp::IsCallActive() const |
|
132 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
133 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 134 |
return iSystemEventDetector->IsCallActive(); |
135 |
} |
|
136 |
||
137 |
// --------------------------------------------------------------------------- |
|
138 |
// Getter for audio resource state |
|
139 |
// --------------------------------------------------------------------------- |
|
140 |
// |
|
141 |
TBool CRadioSystemEventCollectorImp::IsAudioResourcesAvailable() const |
|
142 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
143 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 144 |
return iSystemEventDetector->IsAudioResourcesAvailable(); |
145 |
} |
|
146 |
||
147 |
// --------------------------------------------------------------------------- |
|
148 |
// Getter for headset connection status |
|
149 |
// --------------------------------------------------------------------------- |
|
150 |
TBool CRadioSystemEventCollectorImp::IsHeadsetConnectedL() const |
|
151 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
152 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 153 |
return iHeadsetObserver->IsHeadsetConnectedL(); |
154 |
} |
|
155 |
||
156 |
// --------------------------------------------------------------------------- |
|
54 | 157 |
// returns this as MRadioAudioRoutingObserver |
158 |
// --------------------------------------------------------------------------- |
|
159 |
void CRadioSystemEventCollectorImp::AsObserver( MRadioAudioRoutingObserver*& obj )const |
|
160 |
{ |
|
57 | 161 |
LEVEL3( LOG_METHOD_AUTO ); |
54 | 162 |
CRadioSystemEventCollectorImp *object = const_cast<CRadioSystemEventCollectorImp*>( this ); |
163 |
obj = object; |
|
164 |
} |
|
165 |
||
166 |
// --------------------------------------------------------------------------- |
|
24 | 167 |
// Notifies the observers of system event |
168 |
// --------------------------------------------------------------------------- |
|
169 |
// |
|
170 |
void CRadioSystemEventCollectorImp::NotifyObserversL( TRadioSystemEventType aEvent ) |
|
171 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
172 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 173 |
for ( TInt i = 0; i < iSystemEventObservers.Count(); ++i ) |
174 |
{ |
|
175 |
iSystemEventObservers[i]->HandleSystemEventL( aEvent ); |
|
176 |
} |
|
177 |
} |
|
178 |
||
179 |
// --------------------------------------------------------------------------- |
|
180 |
// From class MRadioSystemEventDetectorObserver. |
|
181 |
// --------------------------------------------------------------------------- |
|
182 |
// |
|
183 |
void CRadioSystemEventCollectorImp::NetworkUpCallbackL() |
|
184 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
185 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 186 |
NotifyObserversL( ERadioNetworkCoverageUp ); |
187 |
} |
|
188 |
||
189 |
// --------------------------------------------------------------------------- |
|
190 |
// From class MRadioSystemEventDetectorObserver. |
|
191 |
// --------------------------------------------------------------------------- |
|
192 |
// |
|
193 |
void CRadioSystemEventCollectorImp::NetworkDownCallbackL() |
|
194 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
195 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 196 |
NotifyObserversL( ERadioNetworkCoverageDown ); |
197 |
} |
|
198 |
||
199 |
// --------------------------------------------------------------------------- |
|
200 |
// From class MRadioSystemEventDetectorObserver. |
|
201 |
// --------------------------------------------------------------------------- |
|
202 |
// |
|
203 |
void CRadioSystemEventCollectorImp::CallActivatedCallbackL() |
|
204 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
205 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 206 |
NotifyObserversL( ERadioCallActivated ); |
207 |
} |
|
208 |
||
209 |
// --------------------------------------------------------------------------- |
|
210 |
// From class MRadioSystemEventDetectorObserver. |
|
211 |
// --------------------------------------------------------------------------- |
|
212 |
// |
|
213 |
void CRadioSystemEventCollectorImp::CallDeactivatedCallbackL() |
|
214 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
215 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 216 |
NotifyObserversL( ERadioCallDeactivated ); |
217 |
} |
|
218 |
||
219 |
// --------------------------------------------------------------------------- |
|
220 |
// From class MRadioSystemEventDetectorObserver. |
|
221 |
// --------------------------------------------------------------------------- |
|
222 |
// |
|
223 |
void CRadioSystemEventCollectorImp::AudioResourcesAvailableL() |
|
224 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
225 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 226 |
NotifyObserversL( ERadioAudioResourcesAvailable ); |
227 |
} |
|
228 |
||
229 |
// --------------------------------------------------------------------------- |
|
230 |
// From class MRadioSystemEventDetectorObserver. |
|
231 |
// --------------------------------------------------------------------------- |
|
232 |
// |
|
233 |
void CRadioSystemEventCollectorImp::AudioAutoResumeForbiddenL() |
|
234 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
235 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 236 |
NotifyObserversL( ERadioAudioAutoResumeForbidden ); |
237 |
} |
|
238 |
||
239 |
// --------------------------------------------------------------------------- |
|
240 |
// From class MRadioSystemEventDetectorObserver. |
|
241 |
// --------------------------------------------------------------------------- |
|
242 |
// |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
243 |
void CRadioSystemEventCollectorImp::ErrorCallbackL( TInt DEBUGVAR3( aError ) ) |
24 | 244 |
{ |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
245 |
LEVEL3( LOG_METHOD_AUTO ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
246 |
LEVEL3( LOG_FORMAT( "aError = %d", aError ) ); |
24 | 247 |
// P&S get fail not considered as a critical issue. |
248 |
} |
|
249 |
||
250 |
// --------------------------------------------------------------------------- |
|
251 |
// From class MRadioHeadsetEventObserver. |
|
252 |
// --------------------------------------------------------------------------- |
|
253 |
// |
|
254 |
void CRadioSystemEventCollectorImp::HeadsetConnectedCallbackL() |
|
255 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
256 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 257 |
NotifyObserversL( ERadioHeadsetConnected ); |
258 |
} |
|
259 |
||
260 |
// --------------------------------------------------------------------------- |
|
261 |
// From class MRadioHeadsetEventObserver. |
|
262 |
// --------------------------------------------------------------------------- |
|
263 |
// |
|
264 |
void CRadioSystemEventCollectorImp::HeadsetDisconnectedCallbackL() |
|
265 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
266 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 267 |
NotifyObserversL( ERadioHeadsetDisconnected ); |
268 |
} |
|
269 |
||
270 |
// --------------------------------------------------------------------------- |
|
271 |
// From class MRadioAudioRoutingObserver. |
|
272 |
// --------------------------------------------------------------------------- |
|
273 |
// |
|
274 |
void CRadioSystemEventCollectorImp::AudioRouteChangedL( RadioEngine::TRadioAudioRoute aRoute ) |
|
275 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
276 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 277 |
TRadioSystemEventType ev = ERadioAudioRouteHeadset; |
278 |
if ( aRoute != RadioEngine::ERadioHeadset ) |
|
279 |
{ |
|
280 |
ev = ERadioAudioRouteSpeaker; |
|
281 |
} |
|
282 |
||
283 |
NotifyObserversL( ev ); |
|
284 |
} |