|
1 /* |
|
2 * Copyright (c) 2003 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: Observer class for System Agent events |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "SwimSysAgentObserver.h" |
|
22 #include "SwimReaderIF.h" |
|
23 #include "WimTrace.h" |
|
24 |
|
25 #ifdef RD_STARTUP_CHANGE |
|
26 #include <startupdomainpskeys.h> // Property values |
|
27 #else |
|
28 #include <PSVariables.h> // Property values |
|
29 #endif |
|
30 |
|
31 |
|
32 // ============================ MEMBER FUNCTIONS =============================== |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CSwimSysAgentObserver::CSwimSysAgentObserver |
|
36 // C++ default constructor can NOT contain any code, that |
|
37 // might leave. |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 CSwimSysAgentObserver::CSwimSysAgentObserver( CSwimReaderIF* aReaderIF ) |
|
41 : CActive( EPriorityNormal ) |
|
42 { |
|
43 _WIMTRACE(_L("WIM|SwimReader|CSwimSysAgentObserver::CSwimSysAgentObserver|Begin")); |
|
44 CActiveScheduler::Add( this ); |
|
45 iReaderIF = aReaderIF; |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CSwimSysAgentObserver::ConstructL |
|
50 // Symbian 2nd phase constructor can leave. |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 void CSwimSysAgentObserver::ConstructL() |
|
54 { |
|
55 _WIMTRACE(_L("WIM|SwimReader|CSwimSysAgentObserver::ConstructL|Begin")); |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CSwimSysAgentObserver::NewL |
|
60 // Two-phased constructor. |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 CSwimSysAgentObserver* CSwimSysAgentObserver::NewL( CSwimReaderIF* aReaderIF ) |
|
64 { |
|
65 _WIMTRACE(_L("WIM|SwimReader|CSwimSysAgentObserver::NewL|Begin")); |
|
66 CSwimSysAgentObserver* self = new( ELeave ) CSwimSysAgentObserver ( aReaderIF ); |
|
67 |
|
68 CleanupStack::PushL( self ); |
|
69 self->ConstructL(); |
|
70 CleanupStack::Pop( self ); |
|
71 |
|
72 return self; |
|
73 } |
|
74 |
|
75 |
|
76 // Destructor |
|
77 CSwimSysAgentObserver::~CSwimSysAgentObserver() |
|
78 { |
|
79 _WIMTRACE(_L("WIM|SwimReader|CSwimSysAgentObserver::~CSwimSysAgentObserver|Begin")); |
|
80 Cancel(); |
|
81 iProperty.Close(); |
|
82 } |
|
83 |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // CSwimSysAgentObserver::Start |
|
87 // Start listening System agent events |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 void CSwimSysAgentObserver::Start() |
|
91 { |
|
92 _WIMTRACE(_L("WIM|SwimReader|CSwimSysAgentObserver::Start|Begin")); |
|
93 StartListening( ); //Start listening |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CSwimSysAgentObserver::StartListening |
|
98 // Start listening card status from System Agent |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 void CSwimSysAgentObserver::StartListening() |
|
102 { |
|
103 _WIMTRACE(_L("WIM|SwimReader|CSwimSysAgentObserver::StartListening|Begin")); |
|
104 iStatus = KRequestPending; |
|
105 #ifdef RD_STARTUP_CHANGE |
|
106 TInt err = iProperty.Attach( KPSUidStartup, KPSSimStatus ); |
|
107 #else |
|
108 TInt err = iProperty.Attach( KUidSystemCategory, KPSUidSIMStatusValue ); |
|
109 #endif |
|
110 if ( err == KErrNone ) |
|
111 { |
|
112 iProperty.Subscribe( iStatus ); |
|
113 } |
|
114 SetActive(); |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CSwimSysAgentObserver::RunL |
|
119 // Got card state event |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 void CSwimSysAgentObserver::RunL() |
|
123 { |
|
124 _WIMTRACE(_L("WIM|SwimReader|CSwimSysAgentObserver::RunL|Begin")); |
|
125 //Notify on card event |
|
126 TInt simState; |
|
127 iProperty.Get( simState ); |
|
128 #ifdef RD_STARTUP_CHANGE |
|
129 switch ( simState ) |
|
130 { |
|
131 case ESimUsable: //Card OK, no actions |
|
132 { |
|
133 StartListening(); |
|
134 break; |
|
135 } |
|
136 |
|
137 // In these states, the SIM card cannot be used by WIM. Notify. |
|
138 // |
|
139 case ESimReadable: |
|
140 case ESimNotReady: |
|
141 case ESimNotPresent: |
|
142 { |
|
143 iReaderIF->Notify( EScardRemoved ); //Notify Scard server |
|
144 StartListening(); //Start listening again |
|
145 break; |
|
146 } |
|
147 |
|
148 // The device does not support any SIM card. WIM cannot be used. |
|
149 // |
|
150 case ESimNotSupported: |
|
151 { |
|
152 break; |
|
153 } |
|
154 |
|
155 // These states are considered as fatal errors. |
|
156 // |
|
157 case ESimStatusUninitialized: |
|
158 default: |
|
159 { |
|
160 // __ASSERT_DEBUG( PANIC ) |
|
161 break; |
|
162 } |
|
163 } |
|
164 #else |
|
165 switch ( simState ) |
|
166 { |
|
167 case EPSSimOk: //Card OK, no actions |
|
168 { |
|
169 StartListening(); |
|
170 break; |
|
171 } |
|
172 case EPSSimNotPresent: //Flow trough |
|
173 case EPSSimRejected: // Card removed |
|
174 { |
|
175 iReaderIF->Notify( EScardRemoved ); //Notify Scard server |
|
176 StartListening(); //Start listening again |
|
177 break; |
|
178 } |
|
179 default: |
|
180 { |
|
181 break; |
|
182 } |
|
183 } |
|
184 #endif // RD_STARTUP_CHANGE |
|
185 } |
|
186 |
|
187 |
|
188 // ----------------------------------------------------------------------------- |
|
189 // CSwimSysAgentObserver::DoCancel |
|
190 // Cancel asynchronous request |
|
191 // ----------------------------------------------------------------------------- |
|
192 // |
|
193 void CSwimSysAgentObserver::DoCancel() |
|
194 { |
|
195 _WIMTRACE(_L("WIM|SwimReader|CSwimSysAgentObserver::DoCancel|Begin")); |
|
196 iProperty.Cancel(); |
|
197 } |
|
198 |
|
199 // End of File |