|
1 /* |
|
2 * Copyright (c) 2008 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 to listen for HSxPA notifications. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <e32base.h> |
|
19 #include <rmmcustomapi.h> |
|
20 |
|
21 #include "ConnMonServ.h" |
|
22 #include "ConnMonSess.h" |
|
23 #include "ConnMonIAP.h" |
|
24 #include "ConnMonNoti.h" |
|
25 |
|
26 #include "ConnMonHsdpaNotifier.h" |
|
27 #include "ConnMonBearerNotifier.h" |
|
28 |
|
29 #include "log.h" |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CConnMonHsdpaNotifier::CConnMonHsdpaNotifier |
|
33 // Notifies when WCDMA bearer activity changes. |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 CConnMonHsdpaNotifier::CConnMonHsdpaNotifier( |
|
37 CConnMonBearerNotifier* aObserver, |
|
38 CConnMonServer* aServer, |
|
39 RMobilePhone& aMobilePhone ) |
|
40 : |
|
41 CActive( EConnMonPriorityNormal ), |
|
42 iObserver( aObserver ), |
|
43 iServer( aServer ), |
|
44 iMobilePhone( aMobilePhone ) |
|
45 { |
|
46 iPreviousHsxpaStatus = EBearerInfoWCDMA; |
|
47 iHsxpaStatus = EBearerInfoWCDMA; |
|
48 iHsupaActive = EFalse; |
|
49 iHsdpaActive = EFalse; |
|
50 iPacketServLoaded = 0; |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CConnMonHsdpaNotifier::ConstructL |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 void CConnMonHsdpaNotifier::Construct() |
|
58 { |
|
59 //LOGENTRFN("CConnMonHsdpaNotifier::ConstructL()") |
|
60 |
|
61 CActiveScheduler::Add( this ); |
|
62 TInt err = iPacketService.Open( iMobilePhone ); |
|
63 if ( KErrNone == err ) |
|
64 { |
|
65 iPacketServLoaded = 1; |
|
66 } |
|
67 LOGIT("Created CConnMonHsdpaNotifier") |
|
68 |
|
69 //LOGEXITFN("CConnMonHsdpaNotifier::ConstructL()") |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CConnMonHsdpaNotifier::NewL |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 CConnMonHsdpaNotifier* CConnMonHsdpaNotifier::NewL( |
|
77 CConnMonBearerNotifier* aObserver, |
|
78 CConnMonServer* aServer, |
|
79 RMobilePhone& aMobilePhone ) |
|
80 { |
|
81 CConnMonHsdpaNotifier* self = new( ELeave ) CConnMonHsdpaNotifier( |
|
82 aObserver, |
|
83 aServer, |
|
84 aMobilePhone ); |
|
85 |
|
86 self->Construct(); |
|
87 return self; |
|
88 } |
|
89 |
|
90 // Destructor |
|
91 CConnMonHsdpaNotifier::~CConnMonHsdpaNotifier() |
|
92 { |
|
93 Cancel(); |
|
94 if ( iPacketServLoaded == 1 ) |
|
95 { |
|
96 iPacketService.Close(); |
|
97 iPacketServLoaded = 0; |
|
98 } |
|
99 } |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CConnMonHsdpaNotifier::Receive |
|
103 // Requests a new event (bearer WCDMA activity changed) from ETel |
|
104 // ----------------------------------------------------------------------------- |
|
105 // |
|
106 void CConnMonHsdpaNotifier::Receive() |
|
107 { |
|
108 if ( IsActive() ) |
|
109 { |
|
110 return; |
|
111 } |
|
112 |
|
113 iPacketService.NotifyDynamicCapsChange( iStatus, iDynCaps ); |
|
114 SetActive(); |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CConnMonHsdpaNotifier::HsdpaActive |
|
119 // Returns the latest state of HSDPA activity |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 TBool CConnMonHsdpaNotifier::HsdpaActive() |
|
123 { |
|
124 return iHsdpaActive; |
|
125 } |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // CConnMonHsdpaNotifier::HsupaActive |
|
129 // Returns the latest state of HSUPA activity |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 TBool CConnMonHsdpaNotifier::HsupaActive() |
|
133 { |
|
134 return iHsupaActive; |
|
135 } |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // CConnMonHsdpaNotifier::HsxpaStatus |
|
139 // Returns the latest state of HSxPA activity |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 TInt CConnMonHsdpaNotifier::HsxpaStatus() |
|
143 { |
|
144 return iHsxpaStatus; |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // CConnMonHsdpaNotifier::DoCancel |
|
149 // Cancels the request from ETel. |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 void CConnMonHsdpaNotifier::DoCancel() |
|
153 { |
|
154 if ( IsActive() ) |
|
155 { |
|
156 LOGIT("SERVER: Cancel NotifyDynamicCapsChange()") |
|
157 iPacketService.CancelAsyncRequest( EPacketNotifyDynamicCapsChange ); |
|
158 } |
|
159 } |
|
160 |
|
161 // ----------------------------------------------------------------------------- |
|
162 // CConnMonHsdpaNotifier::RunL |
|
163 // Handles the event that has arrived from ETel |
|
164 // ----------------------------------------------------------------------------- |
|
165 // |
|
166 void CConnMonHsdpaNotifier::RunL() |
|
167 { |
|
168 //LOGENTRFN("CConnMonHsdpaNotifier::RunL()") |
|
169 |
|
170 // All RunL():s outside CServer-derived main class MUST NOT LEAVE. |
|
171 // Use TRAPD when needed. |
|
172 |
|
173 LOGIT(".") |
|
174 LOGIT1("RunL: CConnMonHsdpaNotifier, status %d", iStatus.Int()) |
|
175 |
|
176 if ( KErrNone != iStatus.Int() ) |
|
177 { |
|
178 LOGIT1("ERROR, NotifyDynamicCapsChange FAILED <%d>", iStatus.Int()) |
|
179 } |
|
180 else |
|
181 { |
|
182 // Let's check the bearer availability first... |
|
183 TBool byPhone( EFalse ); |
|
184 TBool byCell( EFalse ); |
|
185 |
|
186 TInt err = iServer->Iap()->GetBearerSupportInfo( EBearerIdWCDMA, byCell, byPhone ); |
|
187 if ( KErrNone != err ) |
|
188 { |
|
189 LOGIT1("CConnMonHsdpaNotifier: GetBearerSupportInfo returned error <%d>", err) |
|
190 Receive(); |
|
191 return; |
|
192 } |
|
193 |
|
194 LOGIT3("CConnMonHsdpaNotifier: Bearer availability: cell %d, phone %d, dyn.caps 0x%04X", |
|
195 byCell, byPhone, iDynCaps) |
|
196 if ( byCell && byPhone ) // Wcdma bearer is available |
|
197 { |
|
198 if ( iDynCaps & RPacketService::KCapsHSDPA ) |
|
199 { |
|
200 iHsdpaActive = ETrue; |
|
201 if ( iDynCaps & RPacketService::KCapsHSUPA ) |
|
202 { |
|
203 // HSxPA |
|
204 LOGIT("NotifyDynamicCapsChange() --> HSxPA active") |
|
205 iHsxpaStatus = EBearerInfoHSxPA; |
|
206 iHsupaActive = ETrue; |
|
207 } |
|
208 else |
|
209 { |
|
210 // HSDPA |
|
211 LOGIT("NotifyDynamicCapsChange() --> HSDPA active") |
|
212 iHsxpaStatus = EBearerInfoHSDPA; |
|
213 iHsupaActive = EFalse; |
|
214 } |
|
215 } |
|
216 else |
|
217 { |
|
218 iHsdpaActive = EFalse; |
|
219 if ( iDynCaps & RPacketService::KCapsHSUPA ) |
|
220 { |
|
221 // HSUPA |
|
222 LOGIT("NotifyDynamicCapsChange() --> HSUPA active") |
|
223 iHsxpaStatus = EBearerInfoHSUPA; |
|
224 iHsupaActive = ETrue; |
|
225 } |
|
226 else |
|
227 { |
|
228 // WCDMA |
|
229 LOGIT("NotifyDynamicCapsChange() --> WCDMA active") |
|
230 iHsxpaStatus = EBearerInfoWCDMA; |
|
231 iHsupaActive = EFalse; |
|
232 } |
|
233 } |
|
234 |
|
235 if ( iPreviousHsxpaStatus != iHsxpaStatus ) |
|
236 { |
|
237 LOGIT2("CConnMonHsdpaNotifier: prev %d, curr %d (changed)", iPreviousHsxpaStatus, iHsxpaStatus) |
|
238 iPreviousHsxpaStatus = iHsxpaStatus; |
|
239 iObserver->HandleEvent(); |
|
240 } |
|
241 else |
|
242 { |
|
243 LOGIT2("CConnMonHsdpaNotifier: prev %d, curr %d", iPreviousHsxpaStatus, iHsxpaStatus) |
|
244 } |
|
245 } |
|
246 } |
|
247 Receive(); |
|
248 //LOGEXITFN("CConnMonHsdpaNotifier::RunL()") |
|
249 } |
|
250 |
|
251 // End-of-file |