25
|
1 |
/*
|
|
2 |
* Copyright (c) 2003-2006 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: Implementation of CCoUtlActive.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
#include "CCoUtlActive.h"
|
|
22 |
#include <mmtsy_names.h>
|
|
23 |
#include <nifvar.h>
|
|
24 |
#include <pcktcs.h>
|
|
25 |
#include <AknGlobalConfirmationQuery.h>
|
|
26 |
#include <AknUtils.h>
|
|
27 |
#include <StringLoader.h>
|
|
28 |
#include <connectutilrsc.rsg>
|
|
29 |
#include <avkon.hrh>
|
|
30 |
#include <e32property.h>
|
|
31 |
#include <PSVariables.h>
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
// CONSTANTS
|
|
36 |
|
|
37 |
// Panic category.
|
|
38 |
_LIT( KCoUtlPanicCategory, "CoUtl" );
|
|
39 |
|
|
40 |
// Enumerates panic reasons
|
|
41 |
enum
|
|
42 |
{
|
|
43 |
// Terminate is already called and operation has not been completed yet.
|
|
44 |
// Cancel before calling Terminate.
|
|
45 |
ECoUtlPanicTerminateAlreadyActive = 0
|
|
46 |
};
|
|
47 |
|
|
48 |
// MACROS
|
|
49 |
|
|
50 |
#if defined _DEBUG && !defined __WINS__
|
|
51 |
// Target UDEB environment - debug traces enabled
|
|
52 |
|
|
53 |
#define COUTL_RDEBUG(X) RDebug::Print(X);
|
|
54 |
#define COUTL_RDEBUG_INT(X,Y) RDebug::Print(X,Y);
|
|
55 |
|
|
56 |
#else
|
|
57 |
// Other environments - debug traces disabled
|
|
58 |
|
|
59 |
#define COUTL_RDEBUG(X)
|
|
60 |
#define COUTL_RDEBUG_INT(X,Y)
|
|
61 |
|
|
62 |
#endif
|
|
63 |
|
|
64 |
|
|
65 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
66 |
|
|
67 |
// -----------------------------------------------------------------------------
|
|
68 |
// CCoUtlActive::CCoUtlActive
|
|
69 |
// C++ default constructor can NOT contain any code, that
|
|
70 |
// might leave.
|
|
71 |
// -----------------------------------------------------------------------------
|
|
72 |
//
|
|
73 |
CCoUtlActive::CCoUtlActive()
|
|
74 |
: CActive( CActive::EPriorityStandard )
|
|
75 |
{
|
|
76 |
CActiveScheduler::Add( this );
|
|
77 |
}
|
|
78 |
|
|
79 |
// -----------------------------------------------------------------------------
|
|
80 |
// CCoUtlActive::~CCoUtlActive
|
|
81 |
// Destructor.
|
|
82 |
// -----------------------------------------------------------------------------
|
|
83 |
//
|
|
84 |
/*****************************************************
|
|
85 |
* Series 60 Customer / ETel
|
|
86 |
* Series 60 ETel API
|
|
87 |
*****************************************************/
|
|
88 |
CCoUtlActive::~CCoUtlActive()
|
|
89 |
{
|
|
90 |
Cancel();
|
|
91 |
|
|
92 |
if ( iServer.Handle() )
|
|
93 |
{
|
|
94 |
// Error is ignored - loading might have failed.
|
|
95 |
iServer.UnloadPhoneModule( KMmTsyModuleName );
|
|
96 |
}
|
|
97 |
|
|
98 |
delete iConfirmationQuery;
|
|
99 |
delete iConfirmationText;
|
|
100 |
|
|
101 |
iConnections.Close();
|
|
102 |
iPacketService.Close();
|
|
103 |
iMobilePhone.Close();
|
|
104 |
iServer.Close();
|
|
105 |
iConnectionMonitor.CancelNotifications();
|
|
106 |
iConnectionMonitor.Close();
|
|
107 |
}
|
|
108 |
|
|
109 |
// -----------------------------------------------------------------------------
|
|
110 |
// CCoUtlActive::CurrentState
|
|
111 |
// -----------------------------------------------------------------------------
|
|
112 |
//
|
|
113 |
CCoUtlActive::TState CCoUtlActive::CurrentState() const
|
|
114 |
{
|
|
115 |
return iState;
|
|
116 |
}
|
|
117 |
|
|
118 |
// -----------------------------------------------------------------------------
|
|
119 |
// CCoUtlActive::Start
|
|
120 |
// -----------------------------------------------------------------------------
|
|
121 |
//
|
|
122 |
void CCoUtlActive::Start( TRequestStatus& aStatus )
|
|
123 |
{
|
|
124 |
if ( !IsActive() )
|
|
125 |
{
|
|
126 |
aStatus = KRequestPending;
|
|
127 |
iRequestStatus = &aStatus;
|
|
128 |
GoToStateAndComplete( EStarted );
|
|
129 |
}
|
|
130 |
else
|
|
131 |
{
|
|
132 |
User::Panic( KCoUtlPanicCategory, ECoUtlPanicTerminateAlreadyActive );
|
|
133 |
}
|
|
134 |
}
|
|
135 |
|
|
136 |
// -----------------------------------------------------------------------------
|
|
137 |
// CCoUtlActive::RunL
|
|
138 |
// -----------------------------------------------------------------------------
|
|
139 |
//
|
|
140 |
void CCoUtlActive::RunL()
|
|
141 |
{
|
|
142 |
COUTL_RDEBUG_INT( _L("CCoUtlActive::RunL - State %d: "), iState )
|
|
143 |
COUTL_RDEBUG_INT( _L("CCoUtlActive::RunL - Status %d: "), iStatus.Int() )
|
|
144 |
|
|
145 |
// Clean up parameters that might require uninitialisation.
|
|
146 |
delete iConfirmationQuery;
|
|
147 |
iConfirmationQuery = NULL;
|
|
148 |
|
|
149 |
delete iConfirmationText;
|
|
150 |
iConfirmationText = NULL;
|
|
151 |
|
|
152 |
// Leave in case of error.
|
|
153 |
User::LeaveIfError( iStatus.Int() );
|
|
154 |
|
|
155 |
// Handle state transitions.
|
|
156 |
switch ( iState )
|
|
157 |
{
|
|
158 |
case EStarted:
|
|
159 |
iConnections.Reset();
|
|
160 |
GetAttachStatusL();
|
|
161 |
break;
|
|
162 |
|
|
163 |
case ECheckIfAttached:
|
|
164 |
if ( IsAttached() )
|
|
165 |
{
|
|
166 |
GetConnectionCountL();
|
|
167 |
}
|
|
168 |
break;
|
|
169 |
|
|
170 |
case EGetConnectionCount:
|
|
171 |
iConnectionsIndex = 0;
|
|
172 |
CheckConnectionsL();
|
|
173 |
break;
|
|
174 |
|
|
175 |
case EGoThroughConnections:
|
|
176 |
if ( iConnectionsIndex < iConnections.Count() )
|
|
177 |
{
|
|
178 |
GoThroughConnectionsGetBearerL();
|
|
179 |
}
|
|
180 |
else
|
|
181 |
{
|
|
182 |
GetNetworkModeL();
|
|
183 |
}
|
|
184 |
break;
|
|
185 |
|
|
186 |
case EGoThroughConnectionsGetBearer:
|
|
187 |
if ( AcceptConnectionBearer() )
|
|
188 |
{
|
|
189 |
GoThroughConnectionsGetStatusL();
|
|
190 |
}
|
|
191 |
else
|
|
192 |
{
|
|
193 |
// Not accepted - delete and continue to the next.
|
|
194 |
iConnections.Remove( iConnectionsIndex );
|
|
195 |
GoToStateAndComplete( EGoThroughConnections );
|
|
196 |
}
|
|
197 |
break;
|
|
198 |
|
|
199 |
case EGoThroughConnectionsGetStatus:
|
|
200 |
if ( !IsConnectionActive() )
|
|
201 |
{
|
|
202 |
// Not accepted - delete and continue to the next.
|
|
203 |
iConnections.Remove( iConnectionsIndex );
|
|
204 |
}
|
|
205 |
else
|
|
206 |
{
|
|
207 |
// Accepted, go to next one.
|
|
208 |
iConnectionsIndex++;
|
|
209 |
}
|
|
210 |
|
|
211 |
GoToStateAndComplete( EGoThroughConnections );
|
|
212 |
break;
|
|
213 |
|
|
214 |
case ECheckIfNetworkModeIII:
|
|
215 |
if ( IsNetworkModeIII() )
|
|
216 |
{
|
|
217 |
StopConnectionsAndDetachL();
|
|
218 |
}
|
|
219 |
else
|
|
220 |
{
|
|
221 |
GoToStateAndComplete( ECheckConnectionCount );
|
|
222 |
}
|
|
223 |
break;
|
|
224 |
|
|
225 |
case EStopConnectionsAndDetach:
|
|
226 |
DetachL();
|
|
227 |
break;
|
|
228 |
|
|
229 |
case ECheckConnectionCount:
|
|
230 |
if ( !IsConnections() )
|
|
231 |
{
|
|
232 |
GetAttachModeAndDetachIfRequiredL();
|
|
233 |
}
|
|
234 |
else
|
|
235 |
{
|
|
236 |
ConfirmAllConnectionsTerminationL();
|
|
237 |
}
|
|
238 |
break;
|
|
239 |
|
|
240 |
case EStopConnectionsAndCheckDetachRequired:
|
|
241 |
GetAttachModeAndDetachIfRequiredL();
|
|
242 |
break;
|
|
243 |
|
|
244 |
case ECheckDetachRequired:
|
|
245 |
if ( IsAttachModeOnDemand() )
|
|
246 |
{
|
|
247 |
DetachL();
|
|
248 |
}
|
|
249 |
break;
|
|
250 |
|
|
251 |
case EGetBearerThenNameThenConfirmTermination:
|
|
252 |
GetNameThenConfirmTerminationL();
|
|
253 |
break;
|
|
254 |
|
|
255 |
case EGetNameThenConfirmTermination:
|
|
256 |
ConfirmTerminationL( iConnectionName );
|
|
257 |
break;
|
|
258 |
|
|
259 |
case EConfirmAllConnectionsTermination:
|
|
260 |
if ( IsConfirmed() )
|
|
261 |
{
|
|
262 |
StopAllConnectionsAndDetachIfRequiredL();
|
|
263 |
}
|
|
264 |
break;
|
|
265 |
|
|
266 |
case EDetach:
|
|
267 |
case EIdle:
|
|
268 |
default:
|
|
269 |
break;
|
|
270 |
}
|
|
271 |
|
|
272 |
if ( !IsActive() )
|
|
273 |
{
|
|
274 |
// Operation has been finished.
|
|
275 |
iState = EIdle;
|
|
276 |
CompleteRequest( KErrNone );
|
|
277 |
}
|
|
278 |
|
|
279 |
COUTL_RDEBUG_INT( _L("CCoUtlActive::RunL finished - %d: "), iState )
|
|
280 |
}
|
|
281 |
|
|
282 |
// -----------------------------------------------------------------------------
|
|
283 |
// CCoUtlActive::DoCancel
|
|
284 |
// -----------------------------------------------------------------------------
|
|
285 |
//
|
|
286 |
/*****************************************************
|
|
287 |
* Series 60 Customer / ETel
|
|
288 |
* Series 60 ETel API
|
|
289 |
*****************************************************/
|
|
290 |
void CCoUtlActive::DoCancel()
|
|
291 |
{
|
|
292 |
COUTL_RDEBUG_INT( _L("CCoUtlActive::DoCancel - %d: "), iState )
|
|
293 |
// Operation is canceled - cancel ongoing operation and
|
|
294 |
// complete original request with the KErrCancel error code.
|
|
295 |
|
|
296 |
TInt packetServiceCancel = 0;
|
|
297 |
TInt connectionMonitorCancel = 0;
|
|
298 |
|
|
299 |
switch ( iState )
|
|
300 |
{
|
|
301 |
case ECheckIfNetworkModeIII:
|
|
302 |
packetServiceCancel = EPacketGetMSClass;
|
|
303 |
break;
|
|
304 |
|
|
305 |
case EGetConnectionCount:
|
|
306 |
connectionMonitorCancel = EConnMonGetConnectionCount;
|
|
307 |
break;
|
|
308 |
|
|
309 |
case EGoThroughConnectionsGetStatus:
|
|
310 |
case EGoThroughConnectionsGetBearer:
|
|
311 |
case EGetBearerThenNameThenConfirmTermination:
|
|
312 |
connectionMonitorCancel = EConnMonGetIntAttribute;
|
|
313 |
break;
|
|
314 |
|
|
315 |
case ECheckDetachRequired:
|
|
316 |
packetServiceCancel = EPacketGetAttachMode;
|
|
317 |
break;
|
|
318 |
|
|
319 |
case EGetNameThenConfirmTermination:
|
|
320 |
connectionMonitorCancel = EConnMonGetStringAttribute;
|
|
321 |
break;
|
|
322 |
|
|
323 |
case EConfirmAllConnectionsTermination:
|
|
324 |
if ( iConfirmationQuery )
|
|
325 |
{
|
|
326 |
iConfirmationQuery->CancelConfirmationQuery();
|
|
327 |
delete iConfirmationQuery;
|
|
328 |
iConfirmationQuery = NULL;
|
|
329 |
|
|
330 |
delete iConfirmationText;
|
|
331 |
iConfirmationText = NULL;
|
|
332 |
}
|
|
333 |
break;
|
|
334 |
|
|
335 |
case EDetach:
|
|
336 |
packetServiceCancel = EPacketDetach;
|
|
337 |
break;
|
|
338 |
|
|
339 |
case EIdle:
|
|
340 |
case EStarted:
|
|
341 |
case ECheckIfAttached:
|
|
342 |
case EStopConnectionsAndDetach:
|
|
343 |
case EGoThroughConnections:
|
|
344 |
case ECheckConnectionCount:
|
|
345 |
case EStopConnectionsAndCheckDetachRequired:
|
|
346 |
default:
|
|
347 |
break;
|
|
348 |
}
|
|
349 |
|
|
350 |
if ( packetServiceCancel && iPacketService.SubSessionHandle() )
|
|
351 |
{
|
|
352 |
iPacketService.CancelAsyncRequest( packetServiceCancel );
|
|
353 |
}
|
|
354 |
if ( connectionMonitorCancel && iConnectionMonitor.Handle() )
|
|
355 |
{
|
|
356 |
iConnectionMonitor.CancelAsyncRequest( connectionMonitorCancel );
|
|
357 |
}
|
|
358 |
|
|
359 |
CompleteRequest( KErrCancel );
|
|
360 |
GoToState( EIdle );
|
|
361 |
|
|
362 |
COUTL_RDEBUG( _L("CCoUtlActive::DoCancel finished") )
|
|
363 |
}
|
|
364 |
|
|
365 |
// -----------------------------------------------------------------------------
|
|
366 |
// CCoUtlActive::RunError
|
|
367 |
// -----------------------------------------------------------------------------
|
|
368 |
//
|
|
369 |
TInt CCoUtlActive::RunError( TInt aError )
|
|
370 |
{
|
|
371 |
COUTL_RDEBUG_INT( _L("CCoUtlActive::RunError - %d: "), aError )
|
|
372 |
|
|
373 |
// Handles exceptions. Either operation has completed with aError code,
|
|
374 |
// or then exception has occured while performing RunL when state has
|
|
375 |
// been specified.
|
|
376 |
// However, RunL has been implemented in such a way that once asynchronous
|
|
377 |
// request has been made, then exception is not raised in that RunL.
|
|
378 |
|
|
379 |
switch ( iState )
|
|
380 |
{
|
|
381 |
case EStopConnectionsAndDetach:
|
|
382 |
// Try to move on.
|
|
383 |
GoToStateAndComplete( EDetach );
|
|
384 |
break;
|
|
385 |
|
|
386 |
case EGoThroughConnectionsGetBearer:
|
|
387 |
case EGoThroughConnectionsGetStatus:
|
|
388 |
if ( aError == KErrNotFound &&
|
|
389 |
( iConnectionsIndex < iConnections.Count() ) )
|
|
390 |
{
|
|
391 |
iConnections.Remove( iConnectionsIndex );
|
|
392 |
GoToStateAndComplete( EGoThroughConnections );
|
|
393 |
break;
|
|
394 |
}
|
|
395 |
//lint -fallthrough
|
|
396 |
case EStarted:
|
|
397 |
case ECheckIfAttached:
|
|
398 |
case ECheckIfNetworkModeIII:
|
|
399 |
case EGetConnectionCount:
|
|
400 |
case EGoThroughConnections:
|
|
401 |
case ECheckConnectionCount:
|
|
402 |
case EGetBearerThenNameThenConfirmTermination:
|
|
403 |
case EGetNameThenConfirmTermination:
|
|
404 |
case EConfirmAllConnectionsTermination:
|
|
405 |
case EStopConnectionsAndCheckDetachRequired:
|
|
406 |
case EDetach:
|
|
407 |
case ECheckDetachRequired:
|
|
408 |
case EIdle:
|
|
409 |
default:
|
|
410 |
CompleteRequest( aError );
|
|
411 |
GoToState( EIdle );
|
|
412 |
break;
|
|
413 |
}
|
|
414 |
|
|
415 |
return KErrNone;
|
|
416 |
}
|
|
417 |
|
|
418 |
// -----------------------------------------------------------------------------
|
|
419 |
// CCoUtlActive::GetAttachStatusL
|
|
420 |
// -----------------------------------------------------------------------------
|
|
421 |
//
|
|
422 |
void CCoUtlActive::GetAttachStatusL()
|
|
423 |
{
|
|
424 |
TInt status = KErrNone;
|
|
425 |
TInt statusWcdma = KErrNone;
|
|
426 |
|
|
427 |
//Fetch attach status from RProperty.
|
|
428 |
TInt error = RProperty::Get( KUidSystemCategory, KPSUidGprsStatusValue, status );
|
|
429 |
if ( error != KErrNone )
|
|
430 |
{
|
|
431 |
// On error, assume attached - connection monitor will inform
|
|
432 |
// detailed information.
|
|
433 |
status = EPSGprsAttach;
|
|
434 |
}
|
|
435 |
error = RProperty::Get( KUidSystemCategory, KPSUidWcdmaStatusValue, statusWcdma );
|
|
436 |
if ( error != KErrNone )
|
|
437 |
{
|
|
438 |
// On error, assume attached - connection monitor will inform
|
|
439 |
// detailed information.
|
|
440 |
statusWcdma = EPSWcdmaAttach;
|
|
441 |
}
|
|
442 |
iServiceStatus = status;
|
|
443 |
iWcdmaConnectionStatus = statusWcdma;
|
|
444 |
GoToStateAndComplete( ECheckIfAttached );
|
|
445 |
}
|
|
446 |
|
|
447 |
// -----------------------------------------------------------------------------
|
|
448 |
// CCoUtlActive::GetNetworkModeL
|
|
449 |
// -----------------------------------------------------------------------------
|
|
450 |
//
|
|
451 |
void CCoUtlActive::GetNetworkModeL()
|
|
452 |
{
|
|
453 |
PacketServiceL().GetMSClass( iStatus, iCurrentClass, iMaxClass );
|
|
454 |
SetActive();
|
|
455 |
GoToState( ECheckIfNetworkModeIII );
|
|
456 |
}
|
|
457 |
|
|
458 |
// -----------------------------------------------------------------------------
|
|
459 |
// CCoUtlActive::StopConnectionsAndDetachL
|
|
460 |
// -----------------------------------------------------------------------------
|
|
461 |
//
|
|
462 |
void CCoUtlActive::StopConnectionsAndDetachL()
|
|
463 |
{
|
|
464 |
TInt err = DoStopAllConnectionsL();
|
|
465 |
GoToStateAndComplete(
|
|
466 |
EStopConnectionsAndDetach,
|
|
467 |
err );
|
|
468 |
}
|
|
469 |
|
|
470 |
// -----------------------------------------------------------------------------
|
|
471 |
// CCoUtlActive::GetConnectionCountL
|
|
472 |
// -----------------------------------------------------------------------------
|
|
473 |
//
|
|
474 |
void CCoUtlActive::GetConnectionCountL()
|
|
475 |
{
|
|
476 |
GoToState( EGetConnectionCount );
|
|
477 |
ConnectionMonitorL().GetConnectionCount( iConnectionCount, iStatus );
|
|
478 |
SetActive();
|
|
479 |
}
|
|
480 |
|
|
481 |
// -----------------------------------------------------------------------------
|
|
482 |
// CCoUtlActive::CheckConnectionsL
|
|
483 |
// -----------------------------------------------------------------------------
|
|
484 |
//
|
|
485 |
void CCoUtlActive::CheckConnectionsL()
|
|
486 |
{
|
|
487 |
RConnectionMonitor& monitor = ConnectionMonitorL();
|
|
488 |
iConnections.Reset();
|
|
489 |
|
|
490 |
// Go through all connections
|
|
491 |
// Note indexing from 1, 2, 3, .., iConnectionCount.
|
|
492 |
for ( TUint index = 1; index <= iConnectionCount; index++ )
|
|
493 |
{
|
|
494 |
TConnectionId id;
|
|
495 |
TUint subConnectionCount = 0;
|
|
496 |
|
|
497 |
TInt err =
|
|
498 |
monitor.GetConnectionInfo(
|
|
499 |
index,
|
|
500 |
id.iConnectionId,
|
|
501 |
subConnectionCount );
|
|
502 |
|
|
503 |
// SubConnectionIds are not used.
|
|
504 |
id.iSubConnectionId = 0;
|
|
505 |
|
|
506 |
if ( err != KErrNotFound )
|
|
507 |
{
|
|
508 |
// the KErrNotFound error code indicates that connection has
|
|
509 |
// already been dropped, so those indices are simply ignored.
|
|
510 |
User::LeaveIfError( err );
|
|
511 |
User::LeaveIfError( iConnections.Append( id ) );
|
|
512 |
}
|
|
513 |
}
|
|
514 |
|
|
515 |
GoToStateAndComplete( EGoThroughConnections );
|
|
516 |
}
|
|
517 |
|
|
518 |
// -----------------------------------------------------------------------------
|
|
519 |
// CCoUtlActive::GoThroughConnectionsGetBearerL
|
|
520 |
// -----------------------------------------------------------------------------
|
|
521 |
//
|
|
522 |
void CCoUtlActive::GoThroughConnectionsGetBearerL()
|
|
523 |
{
|
|
524 |
TConnectionId& current = iConnections[ iConnectionsIndex ];
|
|
525 |
ConnectionMonitorL().GetIntAttribute(
|
|
526 |
current.iConnectionId,
|
|
527 |
current.iSubConnectionId,
|
|
528 |
KBearer,
|
|
529 |
iConnectionBearer,
|
|
530 |
iStatus );
|
|
531 |
SetActive();
|
|
532 |
GoToState( EGoThroughConnectionsGetBearer );
|
|
533 |
}
|
|
534 |
|
|
535 |
// -----------------------------------------------------------------------------
|
|
536 |
// CCoUtlActive::GoThroughConnectionsGetStatusL
|
|
537 |
// -----------------------------------------------------------------------------
|
|
538 |
//
|
|
539 |
void CCoUtlActive::GoThroughConnectionsGetStatusL()
|
|
540 |
{
|
|
541 |
TConnectionId& current = iConnections[ iConnectionsIndex ];
|
|
542 |
ConnectionMonitorL().GetIntAttribute(
|
|
543 |
current.iConnectionId,
|
|
544 |
current.iSubConnectionId,
|
|
545 |
KConnectionStatus,
|
|
546 |
iConnectionStatus,
|
|
547 |
iStatus );
|
|
548 |
SetActive();
|
|
549 |
GoToState( EGoThroughConnectionsGetStatus );
|
|
550 |
}
|
|
551 |
|
|
552 |
// -----------------------------------------------------------------------------
|
|
553 |
// CCoUtlActive::GetAttachModeAndDetachIfRequiredL
|
|
554 |
// -----------------------------------------------------------------------------
|
|
555 |
//
|
|
556 |
void CCoUtlActive::GetAttachModeAndDetachIfRequiredL()
|
|
557 |
{
|
|
558 |
PacketServiceL().GetAttachMode( iStatus, iAttachMode );
|
|
559 |
SetActive();
|
|
560 |
GoToState( ECheckDetachRequired );
|
|
561 |
}
|
|
562 |
|
|
563 |
// -----------------------------------------------------------------------------
|
|
564 |
// CCoUtlActive::ConfirmAllConnectionsTerminationL
|
|
565 |
// -----------------------------------------------------------------------------
|
|
566 |
//
|
|
567 |
void CCoUtlActive::ConfirmAllConnectionsTerminationL()
|
|
568 |
{
|
|
569 |
if ( iConnections.Count() == 1 ) // Exactly one connection
|
|
570 |
{
|
|
571 |
GetBearerThenNameThenConfirmTerminationL();
|
|
572 |
}
|
|
573 |
else
|
|
574 |
{
|
|
575 |
ConfirmTerminationL( iConnections.Count() );
|
|
576 |
}
|
|
577 |
}
|
|
578 |
|
|
579 |
// -----------------------------------------------------------------------------
|
|
580 |
// CCoUtlActive::ConfirmTerminationL
|
|
581 |
// -----------------------------------------------------------------------------
|
|
582 |
//
|
|
583 |
void CCoUtlActive::ConfirmTerminationL( TInt aAmount )
|
|
584 |
{
|
|
585 |
HBufC* text =
|
|
586 |
StringLoader::LoadLC(
|
|
587 |
R_COUTL_CONFIRM_CONNECTIONS,
|
|
588 |
aAmount );
|
|
589 |
|
|
590 |
TPtr ptr = text->Des();
|
|
591 |
|
|
592 |
// Convert digits in the string to correct digit type.
|
|
593 |
AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr );
|
|
594 |
|
|
595 |
DoConfirmTerminationL( *text );
|
|
596 |
CleanupStack::Pop( text );
|
|
597 |
iConfirmationText = text;
|
|
598 |
}
|
|
599 |
|
|
600 |
// -----------------------------------------------------------------------------
|
|
601 |
// CCoUtlActive::ConfirmTerminationL
|
|
602 |
// -----------------------------------------------------------------------------
|
|
603 |
//
|
|
604 |
void CCoUtlActive::ConfirmTerminationL( const TDesC& aName )
|
|
605 |
{
|
|
606 |
HBufC* text =
|
|
607 |
StringLoader::LoadLC(
|
|
608 |
R_COUTL_CONFIRM_ONE_CONNECTION,
|
|
609 |
aName );
|
|
610 |
|
|
611 |
DoConfirmTerminationL( *text );
|
|
612 |
CleanupStack::Pop( text );
|
|
613 |
iConfirmationText = text;
|
|
614 |
}
|
|
615 |
|
|
616 |
// -----------------------------------------------------------------------------
|
|
617 |
// CCoUtlActive::DoConfirmTerminationL
|
|
618 |
// -----------------------------------------------------------------------------
|
|
619 |
//
|
|
620 |
void CCoUtlActive::DoConfirmTerminationL( const TDesC& aText )
|
|
621 |
{
|
|
622 |
CAknGlobalConfirmationQuery* confirmationQuery =
|
|
623 |
CAknGlobalConfirmationQuery::NewLC();
|
|
624 |
confirmationQuery->ShowConfirmationQueryL(
|
|
625 |
iStatus,
|
|
626 |
aText );
|
|
627 |
CleanupStack::Pop( confirmationQuery );
|
|
628 |
|
|
629 |
SetActive();
|
|
630 |
iConfirmationQuery = confirmationQuery;
|
|
631 |
GoToState( EConfirmAllConnectionsTermination );
|
|
632 |
}
|
|
633 |
|
|
634 |
// -----------------------------------------------------------------------------
|
|
635 |
// CCoUtlActive::GetBearerThenNameThenConfirmTerminationL
|
|
636 |
// -----------------------------------------------------------------------------
|
|
637 |
//
|
|
638 |
void CCoUtlActive::GetBearerThenNameThenConfirmTerminationL()
|
|
639 |
{
|
|
640 |
TConnectionId& id = iConnections[ 0 ]; // first
|
|
641 |
ConnectionMonitorL().GetIntAttribute(
|
|
642 |
id.iConnectionId,
|
|
643 |
id.iSubConnectionId,
|
|
644 |
KBearer,
|
|
645 |
iConnectionBearer,
|
|
646 |
iStatus );
|
|
647 |
SetActive();
|
|
648 |
GoToState( EGetBearerThenNameThenConfirmTermination );
|
|
649 |
}
|
|
650 |
|
|
651 |
// -----------------------------------------------------------------------------
|
|
652 |
// CCoUtlActive::GetNameThenConfirmTerminationL
|
|
653 |
// -----------------------------------------------------------------------------
|
|
654 |
//
|
|
655 |
void CCoUtlActive::GetNameThenConfirmTerminationL()
|
|
656 |
{
|
|
657 |
TConnectionId& id = iConnections[ 0 ]; // first
|
|
658 |
|
|
659 |
TUint attribute = KIAPName;
|
|
660 |
if ( iConnectionBearer == EBearerExternalGPRS ||
|
|
661 |
iConnectionBearer == EBearerExternalEdgeGPRS ||
|
|
662 |
iConnectionBearer == EBearerExternalWCDMA )
|
|
663 |
{
|
|
664 |
attribute = KAccessPointName;
|
|
665 |
}
|
|
666 |
|
|
667 |
ConnectionMonitorL().GetStringAttribute(
|
|
668 |
id.iConnectionId,
|
|
669 |
id.iSubConnectionId,
|
|
670 |
attribute,
|
|
671 |
iConnectionName,
|
|
672 |
iStatus );
|
|
673 |
SetActive();
|
|
674 |
GoToState( EGetNameThenConfirmTermination );
|
|
675 |
}
|
|
676 |
|
|
677 |
// -----------------------------------------------------------------------------
|
|
678 |
// CCoUtlActive::StopAllConnectionsAndDetachIfRequiredL
|
|
679 |
// -----------------------------------------------------------------------------
|
|
680 |
//
|
|
681 |
void CCoUtlActive::StopAllConnectionsAndDetachIfRequiredL()
|
|
682 |
{
|
|
683 |
TInt err = DoStopAllConnectionsL();
|
|
684 |
GoToStateAndComplete(
|
|
685 |
EStopConnectionsAndCheckDetachRequired,
|
|
686 |
err );
|
|
687 |
}
|
|
688 |
|
|
689 |
// -----------------------------------------------------------------------------
|
|
690 |
// CCoUtlActive::DoStopAllConnectionsL
|
|
691 |
// -----------------------------------------------------------------------------
|
|
692 |
//
|
|
693 |
TInt CCoUtlActive::DoStopAllConnectionsL()
|
|
694 |
{
|
|
695 |
TInt err = KErrNone;
|
|
696 |
|
|
697 |
for ( TInt index = iConnections.Count() - 1; index >= 0; index-- )
|
|
698 |
{
|
|
699 |
const TConnectionId& id = iConnections[ index ];
|
|
700 |
|
|
701 |
TInt result = ConnectionMonitorL().SetBoolAttribute(
|
|
702 |
id.iConnectionId, id.iSubConnectionId, KConnectionStop, ETrue );
|
|
703 |
if ( result == KErrNotFound )
|
|
704 |
{
|
|
705 |
// the KErrNotFound error code is ignored, because connection
|
|
706 |
// may have been ended by another client.
|
|
707 |
result = KErrNone;
|
|
708 |
}
|
|
709 |
|
|
710 |
// Combine error codes.
|
|
711 |
err = Min( err, result );
|
|
712 |
}
|
|
713 |
|
|
714 |
return err;
|
|
715 |
}
|
|
716 |
|
|
717 |
// -----------------------------------------------------------------------------
|
|
718 |
// CCoUtlActive::DetachL
|
|
719 |
// -----------------------------------------------------------------------------
|
|
720 |
//
|
|
721 |
void CCoUtlActive::DetachL()
|
|
722 |
{
|
|
723 |
PacketServiceL().Detach( iStatus );
|
|
724 |
SetActive();
|
|
725 |
GoToState( EDetach );
|
|
726 |
}
|
|
727 |
|
|
728 |
// -----------------------------------------------------------------------------
|
|
729 |
// CCoUtlActive::IsAttached
|
|
730 |
// -----------------------------------------------------------------------------
|
|
731 |
//
|
|
732 |
inline TBool CCoUtlActive::IsAttached() const
|
|
733 |
{
|
|
734 |
return (
|
|
735 |
( iServiceStatus != EPSGprsUnattached ) ||
|
|
736 |
( iWcdmaConnectionStatus != EPSWcdmaUnattached ) );
|
|
737 |
}
|
|
738 |
|
|
739 |
// -----------------------------------------------------------------------------
|
|
740 |
// CCoUtlActive::IsNetworkModeIII
|
|
741 |
// -----------------------------------------------------------------------------
|
|
742 |
//
|
|
743 |
inline TBool CCoUtlActive::IsNetworkModeIII() const
|
|
744 |
{
|
|
745 |
return
|
|
746 |
( iCurrentClass == RPacketService::EMSClassAlternateMode ) ||
|
|
747 |
( iCurrentClass == RPacketService::EMSClassPacketSwitchedOnly ) ||
|
|
748 |
( iCurrentClass == RPacketService::EMSClassCircuitSwitchedOnly );
|
|
749 |
}
|
|
750 |
|
|
751 |
// -----------------------------------------------------------------------------
|
|
752 |
// CCoUtlActive::IsConnections
|
|
753 |
// -----------------------------------------------------------------------------
|
|
754 |
//
|
|
755 |
inline TBool CCoUtlActive::IsConnections() const
|
|
756 |
{
|
|
757 |
return iConnections.Count();
|
|
758 |
}
|
|
759 |
|
|
760 |
// -----------------------------------------------------------------------------
|
|
761 |
// CCoUtlActive::AcceptConnectionBearer
|
|
762 |
// -----------------------------------------------------------------------------
|
|
763 |
//
|
|
764 |
inline TBool CCoUtlActive::AcceptConnectionBearer() const
|
|
765 |
{
|
|
766 |
return ( iConnectionBearer == EBearerGPRS ) ||
|
|
767 |
( iConnectionBearer == EBearerEdgeGPRS ) ||
|
|
768 |
( iConnectionBearer == EBearerWCDMA ) ||
|
|
769 |
( iConnectionBearer == EBearerExternalGPRS ) ||
|
|
770 |
( iConnectionBearer == EBearerExternalEdgeGPRS ) ||
|
|
771 |
( iConnectionBearer == EBearerExternalWCDMA );
|
|
772 |
}
|
|
773 |
|
|
774 |
// -----------------------------------------------------------------------------
|
|
775 |
// CCoUtlActive::IsAttachModeOnDemand
|
|
776 |
// -----------------------------------------------------------------------------
|
|
777 |
//
|
|
778 |
inline TBool CCoUtlActive::IsAttachModeOnDemand() const
|
|
779 |
{
|
|
780 |
return ( iAttachMode == RPacketService::EAttachWhenNeeded );
|
|
781 |
}
|
|
782 |
|
|
783 |
// -----------------------------------------------------------------------------
|
|
784 |
// CCoUtlActive::IsConnectionActive
|
|
785 |
// -----------------------------------------------------------------------------
|
|
786 |
//
|
|
787 |
inline TBool CCoUtlActive::IsConnectionActive() const
|
|
788 |
{
|
|
789 |
return ( iConnectionStatus != KConnectionClosed ) &&
|
|
790 |
( iConnectionStatus != KLinkLayerClosed );
|
|
791 |
}
|
|
792 |
|
|
793 |
// -----------------------------------------------------------------------------
|
|
794 |
// CCoUtlActive::Confirmed
|
|
795 |
// -----------------------------------------------------------------------------
|
|
796 |
//
|
|
797 |
inline TBool CCoUtlActive::IsConfirmed() const
|
|
798 |
{
|
|
799 |
return iStatus.Int() == EAknSoftkeyYes;
|
|
800 |
}
|
|
801 |
|
|
802 |
// -----------------------------------------------------------------------------
|
|
803 |
// CCoUtlActive::TelServerL
|
|
804 |
// -----------------------------------------------------------------------------
|
|
805 |
//
|
|
806 |
/*****************************************************
|
|
807 |
* Series 60 Customer / TSY
|
|
808 |
* Needs customer TSY implementation
|
|
809 |
*****************************************************/
|
|
810 |
inline RTelServer& CCoUtlActive::TelServerL()
|
|
811 |
{
|
|
812 |
if ( !iServer.Handle() )
|
|
813 |
{
|
|
814 |
// ETel server session will be closed if any of the following operations
|
|
815 |
// fail. In this way, the above Handle condition is sufficient; if
|
|
816 |
// session has been opened, then it has been initialised properly as
|
|
817 |
// well.
|
|
818 |
CleanupClosePushL( iServer );
|
|
819 |
User::LeaveIfError( iServer.Connect() );
|
|
820 |
User::LeaveIfError(
|
|
821 |
iServer.SetExtendedErrorGranularity(
|
|
822 |
RTelServer::EErrorExtended ) );
|
|
823 |
User::LeaveIfError( iServer.LoadPhoneModule( KMmTsyModuleName ) );
|
|
824 |
CleanupStack::Pop(); // Success
|
|
825 |
}
|
|
826 |
|
|
827 |
return iServer;
|
|
828 |
}
|
|
829 |
|
|
830 |
// -----------------------------------------------------------------------------
|
|
831 |
// CCoUtlActive::MobilePhoneL
|
|
832 |
// -----------------------------------------------------------------------------
|
|
833 |
//
|
|
834 |
/*****************************************************
|
|
835 |
* Series 60 Customer / ETel
|
|
836 |
* Series 60 ETel API
|
|
837 |
*****************************************************/
|
|
838 |
inline RMobilePhone& CCoUtlActive::MobilePhoneL()
|
|
839 |
{
|
|
840 |
if ( !iMobilePhone.SubSessionHandle() )
|
|
841 |
{
|
|
842 |
User::LeaveIfError( iMobilePhone.Open( TelServerL(), KMmTsyPhoneName ) );
|
|
843 |
}
|
|
844 |
|
|
845 |
return iMobilePhone;
|
|
846 |
}
|
|
847 |
|
|
848 |
// -----------------------------------------------------------------------------
|
|
849 |
// CCoUtlActive::PacketServiceL
|
|
850 |
// -----------------------------------------------------------------------------
|
|
851 |
//
|
|
852 |
/*****************************************************
|
|
853 |
* Series 60 Customer / ETel
|
|
854 |
* Series 60 ETel API
|
|
855 |
*****************************************************/
|
|
856 |
inline RPacketService& CCoUtlActive::PacketServiceL()
|
|
857 |
{
|
|
858 |
if ( !iPacketService.SubSessionHandle() )
|
|
859 |
{
|
|
860 |
User::LeaveIfError( iPacketService.Open( MobilePhoneL() ) );
|
|
861 |
}
|
|
862 |
|
|
863 |
return iPacketService;
|
|
864 |
}
|
|
865 |
|
|
866 |
// -----------------------------------------------------------------------------
|
|
867 |
// CCoUtlActive::ConnectionMonitorL
|
|
868 |
// -----------------------------------------------------------------------------
|
|
869 |
//
|
|
870 |
inline RConnectionMonitor& CCoUtlActive::ConnectionMonitorL()
|
|
871 |
{
|
|
872 |
if ( !iConnectionMonitor.Handle() )
|
|
873 |
{
|
|
874 |
User::LeaveIfError( iConnectionMonitor.ConnectL() );
|
|
875 |
User::LeaveIfError( iConnectionMonitor.NotifyEventL( *this ) );
|
|
876 |
}
|
|
877 |
|
|
878 |
return iConnectionMonitor;
|
|
879 |
}
|
|
880 |
|
|
881 |
// -----------------------------------------------------------------------------
|
|
882 |
// CCoUtlActive::CompleteRequest
|
|
883 |
// -----------------------------------------------------------------------------
|
|
884 |
//
|
|
885 |
void CCoUtlActive::CompleteRequest( TInt aErrorCode )
|
|
886 |
{
|
|
887 |
if ( iRequestStatus )
|
|
888 |
{
|
|
889 |
User::RequestComplete( iRequestStatus, aErrorCode );
|
|
890 |
iRequestStatus = NULL;
|
|
891 |
}
|
|
892 |
}
|
|
893 |
|
|
894 |
// -----------------------------------------------------------------------------
|
|
895 |
// CCoUtlActive::EventL
|
|
896 |
// -----------------------------------------------------------------------------
|
|
897 |
//
|
|
898 |
void CCoUtlActive::EventL( const CConnMonEventBase &aConnMonEvent )
|
|
899 |
{
|
|
900 |
COUTL_RDEBUG_INT( _L("CCoUtlActive::EventL - Event %d: "), aConnMonEvent.EventType() )
|
|
901 |
switch ( aConnMonEvent.EventType() )
|
|
902 |
{
|
|
903 |
case EConnMonDeleteConnection:
|
|
904 |
{
|
|
905 |
if ( IsActive() && iConfirmationQuery )
|
|
906 |
{
|
|
907 |
COUTL_RDEBUG( _L("CCoUtlActive::EventL - Cancel()") )
|
|
908 |
Cancel();
|
|
909 |
}
|
|
910 |
}
|
|
911 |
break;
|
|
912 |
default:
|
|
913 |
break;
|
|
914 |
}
|
|
915 |
}
|
|
916 |
|
|
917 |
// -----------------------------------------------------------------------------
|
|
918 |
// CCoUtlActive::GoToState
|
|
919 |
// -----------------------------------------------------------------------------
|
|
920 |
//
|
|
921 |
inline void CCoUtlActive::GoToState( TState aNewState )
|
|
922 |
{
|
|
923 |
iState = aNewState;
|
|
924 |
}
|
|
925 |
|
|
926 |
// -----------------------------------------------------------------------------
|
|
927 |
// CCoUtlActive::GoToStateAndComplete
|
|
928 |
// -----------------------------------------------------------------------------
|
|
929 |
//
|
|
930 |
inline void CCoUtlActive::GoToStateAndComplete( TState aNewState, TInt aError )
|
|
931 |
{
|
|
932 |
GoToState( aNewState );
|
|
933 |
TRequestStatus* status = &iStatus;
|
|
934 |
User::RequestComplete( status, aError );
|
|
935 |
SetActive();
|
|
936 |
}
|
|
937 |
|
|
938 |
// End of File
|