|
1 /* |
|
2 * Copyright (c) 2002-2007 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: Observes SIM Access Profile status changes. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <MSatShellController.h> |
|
20 #include <BTSapDomainPSKeys.h> |
|
21 #include "MSatUiSession.h" |
|
22 #include "MSatSUiClientHandler.h" |
|
23 #include "TSatSystemStateFactory.h" |
|
24 #include "MSatSystemStateChangeNotifier.h" |
|
25 #include "CSatSAPChangeObserver.h" |
|
26 #include "SatLog.h" |
|
27 #include "CSatCommandContainer.h" |
|
28 #include "CSatSUiClientHandler.h" |
|
29 |
|
30 |
|
31 // ======== MEMBER FUNCTIONS ======== |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // C++ default constructor can NOT contain any code, that |
|
35 // might leave. |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 CSatSAPChangeObserver::CSatSAPChangeObserver( |
|
39 CSatCommandContainer& aContainer ) : |
|
40 iContainer( aContainer ) |
|
41 { |
|
42 LOG( SIMPLE, "SATENGINE: CSatSAPChangeObserver::CSatSAPChangeObserver\ |
|
43 calling-exiting" ) |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // Two-phased constructor. |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 CSatSAPChangeObserver* CSatSAPChangeObserver::NewL( |
|
51 CSatCommandContainer& aContainer ) |
|
52 { |
|
53 LOG( SIMPLE, "SATENGINE: CSatSAPChangeObserver::NewL calling" ) |
|
54 |
|
55 CSatSAPChangeObserver* self = |
|
56 new ( ELeave ) CSatSAPChangeObserver( aContainer ); |
|
57 CleanupStack::PushL( self ); |
|
58 self->ConstructL(); |
|
59 CleanupStack::Pop( self ); |
|
60 |
|
61 LOG( SIMPLE, "SATENGINE: CSatSAPChangeObserver::NewL exiting" ) |
|
62 return self; |
|
63 } |
|
64 |
|
65 |
|
66 // Destructor |
|
67 CSatSAPChangeObserver::~CSatSAPChangeObserver() |
|
68 { |
|
69 LOG( SIMPLE, |
|
70 "SATENGINE: CSatSAPChangeObserver::~CSatSAPChangeObserver calling" ) |
|
71 |
|
72 if ( iStateNotifier ) |
|
73 { |
|
74 iStateNotifier->CancelNotify(); |
|
75 delete iStateNotifier; |
|
76 iStateNotifier = NULL; |
|
77 } |
|
78 |
|
79 LOG( SIMPLE, |
|
80 "SATENGINE: CSatSAPChangeObserver::~CSatSAPChangeObserver exiting" ) |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // Two-phased constructor. |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 void CSatSAPChangeObserver::ConstructL() |
|
88 { |
|
89 LOG( SIMPLE, "SATENGINE: CSatSAPChangeObserver::ConstructL calling" ) |
|
90 |
|
91 iStateNotifier = |
|
92 TSatSystemStateFactory::CreateSIMAccessProfileChangeNotifierL( *this ); |
|
93 // Start observer immediately |
|
94 iStateNotifier->NotifyChangeL(); |
|
95 |
|
96 LOG( SIMPLE, "SATENGINE: CSatSAPChangeObserver::ConstructL exiting" ) |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // Two-phased constructor. |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 void CSatSAPChangeObserver::StateChanged( const TInt aValue ) |
|
104 { |
|
105 LOG2( SIMPLE, |
|
106 "SATENGINE: CSatSAPChangeObserver::StateChanged calling with value %d", |
|
107 aValue ) |
|
108 |
|
109 TInt error( KErrNone ); |
|
110 |
|
111 // If value is true, stop all command handlers and remove |
|
112 // SAT Icon from Application Shell. |
|
113 if ( EBTSapConnecting == aValue || |
|
114 EBTSapConnected == aValue ) |
|
115 { |
|
116 // SIM Access Profile activated. |
|
117 // Notify listeners about SAT UI icon removing from Application Shell. |
|
118 // This should be notified before command handlers are stopped. |
|
119 iContainer.NotifyEvent( MSatUtils::ERemoveSatUiCalled ); |
|
120 |
|
121 // Then stop command handlers and remove SAT UI from Application Shell. |
|
122 iContainer.StopCommandHandlers(); |
|
123 } |
|
124 else if ( EBTSapNotConnected == aValue ) |
|
125 { |
|
126 LOG( SIMPLE, "SATENGINE: CSatSAPChangeObserver::StateChanged \ |
|
127 EBTSapNotConnected" ) |
|
128 // Start command handlers |
|
129 TRAP( error, |
|
130 iContainer.StartCommandHandlersL(); |
|
131 ); // End of TRAP |
|
132 |
|
133 if ( KErrNone != error ) |
|
134 { |
|
135 LOG2( SIMPLE, "SATENGINE: CSatSAPChangeObserver::StateChanged \ |
|
136 failed to recover from SAP: %i", error ) |
|
137 } |
|
138 |
|
139 // Notify listeners about SAT UI icon adding. |
|
140 iContainer.NotifyEvent( MSatUtils::EAddSatUiCalled ); |
|
141 } |
|
142 else |
|
143 { |
|
144 LOG( SIMPLE, "SATENGINE: Unexpected value" ) |
|
145 } |
|
146 |
|
147 LOG2( SIMPLE, "SATENGINE: CSatSAPChangeObserver::StateChanged exiting, \ |
|
148 error: %d",error ) |
|
149 } |