|
1 /* |
|
2 * Copyright (c) 2010 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: This module contains the implementation of CNWRegistrationStatusMonitor |
|
15 * class member functions. |
|
16 * |
|
17 */ |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "nwregistrationstatusmonitor.h" |
|
21 // System |
|
22 #include <exterror.h> |
|
23 #include <mmtsy_names.h> // KMmTsyModuleName |
|
24 #include <etelmmerr.h> |
|
25 |
|
26 // ================= MEMBER FUNCTIONS ======================================= |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CNWRegistrationStatusMonitor::CNWRegistrationStatusMonitor |
|
30 // C++ default constructor can NOT contain any code, that |
|
31 // might leave. |
|
32 // |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 CNWRegistrationStatusMonitor::CNWRegistrationStatusMonitor() : |
|
36 CActive( EPriorityStandard ) |
|
37 { |
|
38 } |
|
39 |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CNWRegistrationStatusMonitor::ConstructL |
|
43 // Symbian 2nd phase constructor can leave. |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 void CNWRegistrationStatusMonitor::ConstructL() |
|
47 { |
|
48 // Add to scheduler. |
|
49 CActiveScheduler::Add( this ); |
|
50 |
|
51 // Open connection to ETel |
|
52 OpenConnectionL(); |
|
53 |
|
54 // Start monitoring |
|
55 IssueRequest(); |
|
56 } |
|
57 |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CNWRegistrationStatusMonitor::NewL |
|
61 // Two-phased constructor. |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 CNWRegistrationStatusMonitor* CNWRegistrationStatusMonitor::NewL() |
|
65 { |
|
66 RDebug::Print( _L("NW: CNWRegistrationStatusMonitor::NewL -START") ); |
|
67 |
|
68 CNWRegistrationStatusMonitor* self = new ( ELeave ) CNWRegistrationStatusMonitor(); |
|
69 CleanupStack::PushL( self ); |
|
70 self->ConstructL(); |
|
71 CleanupStack::Pop( self ); |
|
72 |
|
73 RDebug::Print( _L("NW: CNWRegistrationStatusMonitor::NewL -END") ); |
|
74 return self; |
|
75 } |
|
76 |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // Destructor |
|
80 // |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 CNWRegistrationStatusMonitor::~CNWRegistrationStatusMonitor() |
|
84 { |
|
85 Cancel(); |
|
86 |
|
87 CloseConnection(); |
|
88 |
|
89 delete iNoteWrapper; |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // CNWRegistrationStatusMonitor::OpenConnectionL() |
|
94 // Open connection to ETel |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 void CNWRegistrationStatusMonitor::OpenConnectionL() |
|
98 { |
|
99 // Connect ETel server |
|
100 User::LeaveIfError( iTelServer.Connect() ); |
|
101 |
|
102 // Load ETel TSY module |
|
103 User::LeaveIfError( iTelServer.LoadPhoneModule( KMmTsyModuleName ) ); |
|
104 |
|
105 // Set this session to receive detailed errors |
|
106 User::LeaveIfError( iTelServer.SetExtendedErrorGranularity( |
|
107 RTelServer::EErrorExtended ) ); |
|
108 |
|
109 // Opens a phone subsession by name, |
|
110 User::LeaveIfError( iPhone.Open( iTelServer, KMmTsyPhoneName ) ); |
|
111 } |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CNWRegistrationStatusMonitor::CloseConnection() |
|
115 // Closes the connection to ETel |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 void CNWRegistrationStatusMonitor::CloseConnection() |
|
119 { |
|
120 iPhone.Close(); |
|
121 |
|
122 if ( iTelServer.Handle() ) |
|
123 { |
|
124 iTelServer.UnloadPhoneModule( KMmTsyModuleName ); |
|
125 iTelServer.Close(); |
|
126 } |
|
127 } |
|
128 |
|
129 // ----------------------------------------------------------------------------- |
|
130 // CNWRegistrationStatusMonitor::DoCancel |
|
131 // Cancels the pending async. command. |
|
132 // (other items were commented in a header). |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 void CNWRegistrationStatusMonitor::DoCancel() |
|
136 { |
|
137 RDebug::Print( _L("NW: CNWRegistrationStatusMonitor::DoCancel -START") ); |
|
138 |
|
139 iPhone.CancelAsyncRequest( EMobilePhoneNotifyNetworkRegistrationStatusChange ); |
|
140 |
|
141 RDebug::Print( _L("NW: CNWRegistrationStatusMonitor::DoCancel -END") ); |
|
142 } |
|
143 |
|
144 |
|
145 // ----------------------------------------------------------------------------- |
|
146 // CNWRegistrationStatusMonitor::RunL |
|
147 // Receives the completion of the pending async. command, |
|
148 // saves possible values from async. |
|
149 // |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 void CNWRegistrationStatusMonitor::RunL() |
|
153 { |
|
154 RDebug::Print( _L("NW: CNWRegistrationStatusMonitor::RunL -START") ); |
|
155 |
|
156 if( iStatus.Int() != KErrNone ) // Display only errors |
|
157 { |
|
158 // Parse error code to iResId |
|
159 ParseErrCode(); |
|
160 |
|
161 if( !iNoteWrapper ) |
|
162 { // Instantiate a notewrapper and pass err code to be displayed |
|
163 iNoteWrapper = CNetworkNotifierNoteWrapper::NewL( *this, iResID ); |
|
164 } |
|
165 else // If note wrapper exists already, add error code -stack in wrapper |
|
166 { |
|
167 iNoteWrapper->AppendNote( iResID ); |
|
168 } |
|
169 } |
|
170 else |
|
171 { |
|
172 if( iStatus.Int() == KErrBadHandle || |
|
173 iStatus.Int() == KErrServerBusy ) |
|
174 { |
|
175 // Close the session to ETel |
|
176 CloseConnection(); |
|
177 // Reconnect |
|
178 OpenConnectionL(); |
|
179 } |
|
180 } |
|
181 |
|
182 // Keep monitoring |
|
183 IssueRequest(); |
|
184 |
|
185 RDebug::Print( _L("NW: CNWRegistrationStatusMonitor::RunL -END") ); |
|
186 } |
|
187 |
|
188 |
|
189 // ----------------------------------------------------------------------------- |
|
190 // CNWRegistrationStatusMonitor::ParseErrorCode() |
|
191 // |
|
192 // ----------------------------------------------------------------------------- |
|
193 // |
|
194 void CNWRegistrationStatusMonitor::ParseErrCode() |
|
195 { |
|
196 switch( iStatus.Int() ) |
|
197 { |
|
198 case KErrGsmMMImsiUnknownInHlr: |
|
199 { |
|
200 iResID = R_SIM_NOT_PROV_MM2; |
|
201 RDebug::Print( _L("NW: CNWRegistrationStatusMonitor::ParseErrCode() : R_SIM_NOT_PROV_MM2") ); |
|
202 break; |
|
203 } |
|
204 case KErrGsmMMIllegalMs: |
|
205 { |
|
206 iResID = R_SIM_NOT_ALLOW_MM3; |
|
207 RDebug::Print( _L("NW: CNWRegistrationStatusMonitor::ParseErrCode() : R_SIM_NOT_ALLOW_MM3") ); |
|
208 break; |
|
209 } |
|
210 case KErrGsmMMImsiUnknownInVlr: |
|
211 { |
|
212 iResID = R_CALL_FAILED_MM4; |
|
213 RDebug::Print( _L("NW: CNWRegistrationStatusMonitor::ParseErrCode() : R_CALL_FAILED_MM4") ); |
|
214 break; |
|
215 } |
|
216 case KErrGsmMMImeiNotAccepted: |
|
217 { |
|
218 iResID = R_PHONE_NOT_ALLOW_MM5; |
|
219 RDebug::Print( _L("NW: CNWRegistrationStatusMonitor::ParseErrCode() : R_PHONE_NOT_ALLOW_MM5") ); |
|
220 break; |
|
221 } |
|
222 case KErrGsmMMIllegalMe: |
|
223 { |
|
224 iResID = R_PHONE_NOT_ALLOW_MM6; |
|
225 RDebug::Print( _L("NW: CNWRegistrationStatusMonitor::ParseErrCode() : R_PHONE_NOT_ALLOW_MM6") ); |
|
226 break; |
|
227 } |
|
228 case KErrMMEtelAuthenticateFailed: |
|
229 { |
|
230 RDebug::Print( _L("NW: CNWRegistrationStatusMonitor::ParseErrCode() : R_SIM_NOT_ALLOW") ); |
|
231 iResID = R_SIM_NOT_ALLOW; |
|
232 break; |
|
233 } |
|
234 default: |
|
235 break; |
|
236 } |
|
237 } |
|
238 |
|
239 |
|
240 // ----------------------------------------------------------------------------- |
|
241 // CNWRegistrationStatusMonitor::IssueRequest |
|
242 // Executes the async. NotifyNetworkRegistrationStatusChange function. |
|
243 // |
|
244 // ----------------------------------------------------------------------------- |
|
245 // |
|
246 void CNWRegistrationStatusMonitor::IssueRequest() |
|
247 { |
|
248 RDebug::Print( _L("NW: CNWRegistrationStatusMonitor::IssueRequest -START") ); |
|
249 |
|
250 if ( !IsActive() ) |
|
251 { |
|
252 iPhone.NotifyNetworkRegistrationStatusChange( iStatus, iRegistrationStatus ); |
|
253 SetActive(); |
|
254 RDebug::Print( _L("NW: CNWRegistrationStatusMonitor::IssueRequest : NotifyChange()-request set active - pending !") ); |
|
255 } |
|
256 |
|
257 RDebug::Print( _L("NW: CNWRegistrationStatusMonitor::IssueRequest -END") ); |
|
258 } |
|
259 |
|
260 |
|
261 // ----------------------------------------------------------------------------- |
|
262 // CNWRegistrationStatusMonitor::PopupNoteClosed |
|
263 // |
|
264 // Callback from note wrapper class : all error notes are displayed since this monitor |
|
265 // class can destruct note wrapper |
|
266 // ----------------------------------------------------------------------------- |
|
267 // |
|
268 void CNWRegistrationStatusMonitor::PopupNoteClosed() |
|
269 { |
|
270 RDebug::Print( _L("NW: CNWRegistrationStatusMonitor::PopupNoteClosed -START") ); |
|
271 |
|
272 delete iNoteWrapper; |
|
273 iNoteWrapper = NULL; |
|
274 |
|
275 RDebug::Print( _L("NW: CNWRegistrationStatusMonitor::PopupNoteClosed -END") ); |
|
276 } |
|
277 |
|
278 |
|
279 // ----------------------------------------------------------------------------- |
|
280 // CNWRegistrationStatusMonitor::RunError() |
|
281 // Processes any errors. |
|
282 // ----------------------------------------------------------------------------- |
|
283 // |
|
284 TInt CNWRegistrationStatusMonitor::RunError( TInt /*aError*/ ) |
|
285 { |
|
286 RDebug::Print( _L("NW: CNWRegistrationStatusMonitor::RunError -START") ); |
|
287 |
|
288 // Keep monitoring |
|
289 IssueRequest(); |
|
290 |
|
291 RDebug::Print( _L("NW: CNWRegistrationStatusMonitor::RunError -END") ); |
|
292 return KErrNone; // Handled the error fully |
|
293 } |
|
294 |
|
295 // End of File |