author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:59:48 +0300 | |
branch | RCL_3 |
changeset 69 | cf1b3ddbe9a1 |
parent 58 | 83ca720e2b9a |
permissions | -rw-r--r-- |
58 | 1 |
/* |
2 |
* Copyright (c) 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: Represents a GPRS connection |
|
15 |
* |
|
16 |
* |
|
17 |
*/ |
|
18 |
||
19 |
||
20 |
// INCLUDE FILES |
|
21 |
//#include <nifvar.h> |
|
22 |
#include <StringLoader.h> |
|
23 |
#include <ConnectionMonitorUi.rsg> |
|
24 |
#include <ConnectionMonitorUi.mbg> |
|
25 |
//#include <Avkon.rsg> |
|
26 |
||
27 |
#include "ConnectionMonitorUiLogger.h" |
|
28 |
#include "GprsConnectionInfo.h" |
|
29 |
#include "ActiveWrapper.h" |
|
30 |
||
31 |
// CONSTANTS |
|
32 |
LOCAL_D const TUint KDetailsArrayGranularityInternal = 11; |
|
33 |
LOCAL_D const TUint KDetailsArrayGranularityExternal = 10; |
|
34 |
||
35 |
||
36 |
// ================= MEMBER FUNCTIONS ======================= |
|
37 |
// --------------------------------------------------------- |
|
38 |
// CGprsConnectionInfo::NewL |
|
39 |
// --------------------------------------------------------- |
|
40 |
// |
|
41 |
CGprsConnectionInfo* CGprsConnectionInfo::NewL( TInt aConnectionId, |
|
42 |
RConnectionMonitor* const aConnectionMonitor, |
|
43 |
TConnMonBearerType aConnectionBearerType, |
|
44 |
CActiveWrapper* aActiveWrapper ) |
|
45 |
{ |
|
46 |
CGprsConnectionInfo* self = new ( ELeave ) CGprsConnectionInfo( |
|
47 |
aConnectionId, |
|
48 |
aConnectionMonitor, |
|
49 |
aConnectionBearerType, |
|
50 |
aActiveWrapper ); |
|
51 |
CleanupStack::PushL( self ); |
|
52 |
self->ConstructL(); // Have to call this ConstructL at first, |
|
53 |
CleanupStack::Pop( self ); |
|
54 |
CMUILOGGER_WRITE( "NewL, CGprsConnectionInfo" ); |
|
55 |
return self; |
|
56 |
} |
|
57 |
||
58 |
||
59 |
// --------------------------------------------------------- |
|
60 |
// CGprsConnectionInfo::~CGprsConnectionInfo |
|
61 |
// --------------------------------------------------------- |
|
62 |
// |
|
63 |
CGprsConnectionInfo::~CGprsConnectionInfo() |
|
64 |
{ |
|
65 |
} |
|
66 |
||
67 |
||
68 |
// --------------------------------------------------------- |
|
69 |
// CGprsConnectionInfo::CGprsConnectionInfo |
|
70 |
// --------------------------------------------------------- |
|
71 |
// |
|
72 |
CGprsConnectionInfo::CGprsConnectionInfo( TInt aConnectionId, |
|
73 |
RConnectionMonitor* const aConnectionMonitor, |
|
74 |
TConnMonBearerType aConnectionBearerType, |
|
75 |
CActiveWrapper* aActiveWrapper ) : |
|
76 |
CConnectionInfoBase( aConnectionId, |
|
77 |
aConnectionMonitor, |
|
78 |
aConnectionBearerType, |
|
79 |
aActiveWrapper ) |
|
80 |
{ |
|
81 |
CMUILOGGER_WRITE( "CGprsConnectionInfo constuctor" ); |
|
82 |
} |
|
83 |
||
84 |
||
85 |
// --------------------------------------------------------- |
|
86 |
// CGprsConnectionInfo::ConstructL |
|
87 |
// --------------------------------------------------------- |
|
88 |
// |
|
89 |
void CGprsConnectionInfo::ConstructL() |
|
90 |
{ |
|
91 |
CMUILOGGER_ENTERFN( "CGprsConnectionInfo::ConstructL() start" ); |
|
92 |
||
93 |
iActiveWrapper->StartGetStringAttribute( iConnectionId, |
|
94 |
iConnectionMonitor, |
|
95 |
KAccessPointName, |
|
96 |
iApName ); |
|
97 |
#ifdef __WINS__ |
|
98 |
iApName = _L( "LAN" ); |
|
99 |
#else |
|
100 |
TInt err( iActiveWrapper->iStatus.Int() ); |
|
101 |
CMUILOGGER_WRITE_F( "CGprsConnectionInfo::ConstructL status: %d", err ); |
|
102 |
if ( err != KErrNone ) |
|
103 |
{ |
|
104 |
User::Leave( err ); |
|
105 |
} |
|
106 |
#endif |
|
107 |
CMUILOGGER_WRITE_F( "iApName Connection name: %S", &iApName ); |
|
108 |
||
109 |
CConnectionInfoBase::ConstructL(); // and base class ConstructL next. |
|
110 |
CMUILOGGER_WRITE( "CGprsConnectionInfo::ConstructL() end" ); |
|
111 |
} |
|
112 |
||
113 |
// --------------------------------------------------------- |
|
114 |
// CGprsConnectionInfo::DeepCopyL |
|
115 |
// --------------------------------------------------------- |
|
116 |
// |
|
117 |
CConnectionInfoBase* CGprsConnectionInfo::DeepCopyL() |
|
118 |
{ |
|
119 |
CGprsConnectionInfo* temp = new ( ELeave ) CGprsConnectionInfo( |
|
120 |
iConnectionId, |
|
121 |
iConnectionMonitor, |
|
122 |
iConnectionBearerType, |
|
123 |
iActiveWrapper ); |
|
124 |
||
125 |
temp->iConnectionName = iConnectionName; |
|
126 |
temp->iConnectionStatus = iConnectionStatus; |
|
127 |
temp->iUploaded = iUploaded; |
|
128 |
temp->iDownloaded = iDownloaded; |
|
129 |
temp->iStartTime = iStartTime; |
|
130 |
temp->iDuration = iDuration; |
|
131 |
temp->iLastSpeedUpdate = iLastSpeedUpdate; |
|
132 |
temp->iUpSpeed = iUpSpeed; |
|
133 |
temp->iDownSpeed = iDownSpeed; |
|
134 |
temp->iListBoxItemText = iListBoxItemText; |
|
135 |
||
136 |
temp->iApName = iApName; |
|
137 |
||
138 |
if ( iDetailsArray ) |
|
139 |
{ |
|
140 |
CleanupStack::PushL( temp ); |
|
141 |
temp->ToArrayDetailsL(); |
|
142 |
CleanupStack::Pop( temp ); |
|
143 |
} |
|
144 |
||
145 |
return temp; |
|
146 |
} |
|
147 |
||
148 |
||
149 |
// --------------------------------------------------------- |
|
150 |
// CGprsConnectionInfo::GetIconId |
|
151 |
// --------------------------------------------------------- |
|
152 |
// |
|
153 |
TUint CGprsConnectionInfo::GetIconId() const |
|
154 |
{ |
|
155 |
TUint iconId = EGprs; |
|
156 |
if ( iConnectionStatus == EConnectionSuspended ) |
|
157 |
{ |
|
158 |
iconId = ESuspended; |
|
159 |
} |
|
160 |
return iconId; |
|
161 |
} |
|
162 |
||
163 |
// --------------------------------------------------------- |
|
164 |
// CGprsConnectionInfo::RefreshDetailsL |
|
165 |
// --------------------------------------------------------- |
|
166 |
// |
|
167 |
void CGprsConnectionInfo::RefreshDetailsL() |
|
168 |
{ |
|
169 |
CMUILOGGER_WRITE( "CGprsConnectionInfo::RefreshDetailsL start" ); |
|
170 |
||
171 |
iActiveWrapper->StartGetStringAttribute( iConnectionId, |
|
172 |
iConnectionMonitor, |
|
173 |
KAccessPointName, |
|
174 |
iApName ); |
|
175 |
#ifdef __WINS__ |
|
176 |
iActiveWrapper->Cancel(); |
|
177 |
iApName = _L( "LAN" ); |
|
178 |
#else |
|
179 |
TInt err( iActiveWrapper->iStatus.Int() ); |
|
180 |
CMUILOGGER_WRITE_F( "CGprsConnectionInfo::RefreshDetailsL status: %d", |
|
181 |
err ); |
|
182 |
if ( err != KErrNone ) |
|
183 |
{ |
|
184 |
User::Leave( err ); |
|
185 |
} |
|
186 |
#endif |
|
187 |
CMUILOGGER_WRITE_F( "iApName Connection name: %S", &iApName ); |
|
188 |
||
189 |
RefreshTransferSpeedsL(); |
|
190 |
RefreshDuration(); |
|
191 |
CMUILOGGER_WRITE( "CGprsConnectionInfo::RefreshDetailsL end" ); |
|
192 |
} |
|
193 |
||
194 |
// --------------------------------------------------------- |
|
195 |
// CGprsConnectionInfo::ToStringApNameLC |
|
196 |
// --------------------------------------------------------- |
|
197 |
// |
|
198 |
HBufC* CGprsConnectionInfo::ToStringApNameLC() const |
|
199 |
{ |
|
200 |
HBufC* apName = iApName.AllocLC(); |
|
201 |
return apName; |
|
202 |
} |
|
203 |
||
204 |
||
205 |
// --------------------------------------------------------- |
|
206 |
// CGprsConnectionInfo::RefreshConnectionListBoxItemTextL |
|
207 |
// --------------------------------------------------------- |
|
208 |
// |
|
209 |
void CGprsConnectionInfo::RefreshConnectionListBoxItemTextL() |
|
210 |
{ |
|
211 |
CMUILOGGER_WRITE( |
|
212 |
"CGprsConnectionInfo::RefreshConnectionListBoxItemTextL start" ); |
|
213 |
||
214 |
TUint iconId; |
|
215 |
HBufC* secondRow = NULL; |
|
216 |
||
217 |
iconId = GetIconId(); |
|
218 |
||
219 |
if ( iConnectionStatus == EConnectionCreated ) |
|
220 |
{ |
|
221 |
CDesCArrayFlat* array = new (ELeave) CDesCArrayFlat(2); |
|
222 |
CleanupStack::PushL( array ); |
|
223 |
||
224 |
HBufC* stringReceivedData = ToStringReceivedDataLC( ETrue ); |
|
225 |
HBufC* stringSentData = ToStringSentDataLC( ETrue ); |
|
226 |
||
227 |
StringMarkerRemoval( stringReceivedData ); |
|
228 |
StringMarkerRemoval( stringSentData ); |
|
229 |
||
230 |
array->AppendL( *stringReceivedData ); |
|
231 |
array->AppendL( *stringSentData ); |
|
232 |
||
233 |
secondRow = StringLoader::LoadL( R_QTN_CMON_UL_DL_DATA_AMOUNTS, |
|
234 |
*array ); |
|
235 |
||
236 |
CleanupStack::PopAndDestroy( stringSentData ); |
|
237 |
CleanupStack::PopAndDestroy( stringReceivedData ); |
|
238 |
CleanupStack::PopAndDestroy( array ); |
|
239 |
} |
|
240 |
else // if connection has not created yet gives back the status of its. |
|
241 |
{ |
|
242 |
secondRow = ToStringStatusLC( EFalse ); |
|
243 |
CleanupStack::Pop( secondRow ); |
|
244 |
} |
|
245 |
||
246 |
iListBoxItemText.Format( KConnectonListItemTextFormat, iconId, |
|
247 |
&iConnectionName, secondRow ); |
|
248 |
delete secondRow; |
|
249 |
CMUILOGGER_WRITE( |
|
250 |
"CGprsConnectionInfo::RefreshConnectionListBoxItemTextL end" ); |
|
251 |
} |
|
252 |
||
253 |
// --------------------------------------------------------- |
|
254 |
// CGprsConnectionInfo::RefreshDetailsArrayL |
|
255 |
// --------------------------------------------------------- |
|
256 |
// |
|
257 |
void CGprsConnectionInfo::RefreshDetailsArrayL() |
|
258 |
{ |
|
259 |
CMUILOGGER_WRITE( "CGprsConnectionInfo::RefreshDetailsArrayL start" ); |
|
260 |
if ( iDetailsArray ) |
|
261 |
{ |
|
262 |
TBool internal = iConnectionBearerType < EBearerExternalCSD ; |
|
263 |
HBufC* temp = NULL; |
|
264 |
||
265 |
temp = ToStringStatusLC(); |
|
266 |
ToDetailsListBoxItemTextWithReplaceL( R_QTN_CMON_HEADING_STATUS, |
|
267 |
temp, 2 ); |
|
268 |
||
269 |
ToDetailsListBoxItemTextWithReplaceL( R_QTN_CMON_HEADING_DATA_TOTAL, |
|
270 |
ToStringTotalTransmittedDataLC(), |
|
271 |
3 ); |
|
272 |
ToDetailsListBoxItemTextWithReplaceL |
|
273 |
( |
|
274 |
R_QTN_CMON_HEADING_DATA_RECEIVED, |
|
275 |
ToStringReceivedDataLC(), |
|
276 |
4 |
|
277 |
); |
|
278 |
||
279 |
ToDetailsListBoxItemTextWithReplaceL( R_QTN_CMON_HEADING_DATA_SENT, |
|
280 |
ToStringSentDataLC(), 5 ); |
|
281 |
||
282 |
ToDetailsListBoxItemTextWithReplaceL( R_QTN_CMON_HEADING_DURATION, |
|
283 |
ToStringDurationLC(), 6 ); |
|
284 |
||
285 |
ToDetailsListBoxItemTextWithReplaceL |
|
286 |
( |
|
287 |
R_QTN_CMON_HEADING_SPEED, |
|
288 |
ToStringTransferSpeedDownLC(), |
|
289 |
7 |
|
290 |
); |
|
291 |
||
292 |
ToDetailsListBoxItemTextWithReplaceL |
|
293 |
( |
|
294 |
0, |
|
295 |
ToStringTransferSpeedUpLC(), |
|
296 |
8 |
|
297 |
); |
|
298 |
||
299 |
CleanupStack::PopAndDestroy( 7, temp ); // ToString...LC() |
|
300 |
||
301 |
if ( internal ) |
|
302 |
{ |
|
303 |
TInt sharing = RefreshAppNamesL(); |
|
304 |
||
69
cf1b3ddbe9a1
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
58
diff
changeset
|
305 |
if ( sharing > 1 ) |
58 | 306 |
{ |
307 |
if ( iDetailsArray->Count() > 10 ) |
|
308 |
{ |
|
309 |
iDetailsArray->Delete( 10, |
|
310 |
iDetailsArray->Count() - 10 ); |
|
311 |
iDetailsArray->Compress(); |
|
312 |
} |
|
313 |
||
314 |
for ( TInt i = 0; i < sharing; i++ ) |
|
315 |
{ |
|
316 |
if ( i == 0 ) |
|
317 |
{ |
|
318 |
ToDetailsListBoxItemTextWithAppendL( |
|
319 |
R_QTN_CMON_HEADING_SHARING_INFO, |
|
320 |
ToStringAppNameLC( i ) ); |
|
321 |
} |
|
322 |
else |
|
323 |
{ |
|
324 |
ToDetailsListBoxItemTextWithAppendL( 0, |
|
325 |
ToStringAppNameLC( i ) ); |
|
326 |
} |
|
327 |
} |
|
328 |
CleanupStack::PopAndDestroy( sharing ); |
|
329 |
// ToStringAppNameLC() |
|
330 |
} |
|
331 |
else |
|
332 |
{ |
|
333 |
if ( iDetailsArray->Count() > 10 ) |
|
334 |
{ |
|
335 |
iDetailsArray->Delete( 10, iDetailsArray->Count() - 10 ); |
|
336 |
iDetailsArray->Compress(); |
|
337 |
} |
|
338 |
} |
|
339 |
} |
|
340 |
} |
|
341 |
CMUILOGGER_WRITE( "CGprsConnectionInfo::RefreshDetailsArrayL end" ); |
|
342 |
} |
|
343 |
||
344 |
||
345 |
// --------------------------------------------------------- |
|
346 |
// CGprsConnectionInfo::ToArrayDetailsL |
|
347 |
// --------------------------------------------------------- |
|
348 |
// |
|
349 |
void CGprsConnectionInfo::ToArrayDetailsL() |
|
350 |
{ |
|
351 |
CMUILOGGER_ENTERFN("CGprsConnectionInfo::ToArrayDetailsL"); |
|
352 |
TBool internal = iConnectionBearerType < EBearerExternalCSD ; |
|
353 |
TUint granularity = KDetailsArrayGranularityExternal; |
|
354 |
HBufC* temp = NULL; |
|
355 |
||
356 |
||
357 |
if ( internal ) |
|
358 |
{ |
|
359 |
granularity = KDetailsArrayGranularityInternal; |
|
360 |
} |
|
361 |
delete iDetailsArray; |
|
362 |
iDetailsArray = NULL; |
|
363 |
iDetailsArray = new ( ELeave ) CDesCArrayFlat( granularity ); |
|
364 |
||
365 |
temp = iConnectionName.AllocLC(); |
|
366 |
||
367 |
ToDetailsListBoxItemTextWithAppendL( R_QTN_CMON_HEADING_CONN_NAME, |
|
368 |
temp ); |
|
369 |
||
370 |
ToDetailsListBoxItemTextWithAppendL( R_QTN_CMON_HEADING_BEARER, |
|
371 |
ToStringBearerLC() ); |
|
372 |
||
373 |
ToDetailsListBoxItemTextWithAppendL( R_QTN_CMON_HEADING_STATUS, |
|
374 |
ToStringStatusLC() ); |
|
375 |
||
376 |
ToDetailsListBoxItemTextWithAppendL( R_QTN_CMON_HEADING_DATA_TOTAL, |
|
377 |
ToStringTotalTransmittedDataLC() ); |
|
378 |
||
379 |
ToDetailsListBoxItemTextWithAppendL( R_QTN_CMON_HEADING_DATA_RECEIVED, |
|
380 |
ToStringReceivedDataLC() ); |
|
381 |
||
382 |
ToDetailsListBoxItemTextWithAppendL( R_QTN_CMON_HEADING_DATA_SENT, |
|
383 |
ToStringSentDataLC() ); |
|
384 |
||
385 |
ToDetailsListBoxItemTextWithAppendL( R_QTN_CMON_HEADING_DURATION, |
|
386 |
ToStringDurationLC() ); |
|
387 |
||
388 |
ToDetailsListBoxItemTextWithAppendL( R_QTN_CMON_HEADING_SPEED, |
|
389 |
ToStringTransferSpeedDownLC() ); |
|
390 |
||
391 |
ToDetailsListBoxItemTextWithAppendL( 0, |
|
392 |
ToStringTransferSpeedUpLC() ); |
|
393 |
||
394 |
ToDetailsListBoxItemTextWithAppendL( R_QTN_CMON_HEADING_GPRS_APN, |
|
395 |
ToStringApNameLC() ); |
|
396 |
CleanupStack::PopAndDestroy( 10, temp ); // ToString...LC() |
|
397 |
||
398 |
if ( internal ) |
|
399 |
{ |
|
400 |
TInt sharing = RefreshAppNamesL(); |
|
401 |
||
69
cf1b3ddbe9a1
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
58
diff
changeset
|
402 |
if ( sharing > 1 ) |
58 | 403 |
{ |
404 |
for ( TInt i = 0; i < sharing; i++ ) |
|
405 |
{ |
|
406 |
if ( i == 0 ) |
|
407 |
{ |
|
408 |
ToDetailsListBoxItemTextWithAppendL( |
|
409 |
R_QTN_CMON_HEADING_SHARING_INFO, |
|
410 |
ToStringAppNameLC( i ) ); |
|
411 |
} |
|
412 |
else |
|
413 |
{ |
|
414 |
ToDetailsListBoxItemTextWithAppendL( 0, |
|
415 |
ToStringAppNameLC( i ) ); |
|
416 |
} |
|
417 |
} |
|
418 |
CleanupStack::PopAndDestroy( sharing ); |
|
419 |
// ToStringAppNameLC() |
|
420 |
} |
|
421 |
} |
|
422 |
CMUILOGGER_LEAVEFN("CGprsConnectionInfo::ToArrayDetailsL"); |
|
423 |
} |
|
424 |
||
425 |
||
426 |
// End of File |