|
1 /* |
|
2 * Copyright (c) 2005-2008 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: MPM disconnect dialog handling |
|
15 * |
|
16 */ |
|
17 |
|
18 /** |
|
19 @file mpmdisconnectdlg.cpp |
|
20 Mobility Policy Manager disconnect dialog initiation. |
|
21 */ |
|
22 |
|
23 // INCLUDE FILES |
|
24 #include "mpmdisconnectdlg.h" |
|
25 #include "mpmconnmonevents.h" |
|
26 #include "mpmlogger.h" |
|
27 |
|
28 // ============================= LOCAL FUNCTIONS =============================== |
|
29 |
|
30 // ============================ MEMBER FUNCTIONS =============================== |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // CMPMDisconnectDlg::NewL |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 CMPMDisconnectDlg* CMPMDisconnectDlg::NewL( |
|
37 CMPMServerSession& aSession, |
|
38 TInt aOrigError, |
|
39 CArrayPtrFlat<CMPMDisconnectDlg>& aDisconnectQueue ) |
|
40 { |
|
41 CMPMDisconnectDlg* self = new (ELeave) CMPMDisconnectDlg( aSession, |
|
42 aOrigError, |
|
43 aDisconnectQueue ); |
|
44 CleanupStack::PushL( self ); |
|
45 self->ConstructL(); |
|
46 CleanupStack::Pop( self ); |
|
47 return self; |
|
48 } |
|
49 |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CMPMDisconnectDlg::CMPMDisconnectDlg |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 CMPMDisconnectDlg::CMPMDisconnectDlg( |
|
56 CMPMServerSession& aSession, |
|
57 TInt aOrigError, |
|
58 CArrayPtrFlat<CMPMDisconnectDlg>& aDisconnectQueue ) |
|
59 : CMPMDialogBase( *(CArrayPtrFlat<CMPMDialogBase>*)&aDisconnectQueue ), |
|
60 iSession( aSession ), |
|
61 iOrigError( aOrigError ) |
|
62 { |
|
63 } |
|
64 |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CMPMDisconnectDlg::~CMPMDisconnectDlg |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 CMPMDisconnectDlg::~CMPMDisconnectDlg() |
|
71 { |
|
72 MPMLOGSTRING( "CMPMDisconnectDlg::~CMPMDisconnectDlg" ) |
|
73 Cancel(); |
|
74 iDlgServ.Close(); |
|
75 } |
|
76 |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CMPMDisconnectDlg::ConstructL |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 void CMPMDisconnectDlg::ConstructL() |
|
83 { |
|
84 User::LeaveIfError( iDlgServ.Connect() ); |
|
85 CMPMDialogBase::ConstructL(); |
|
86 } |
|
87 |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // CMPMDisconnectDlg::RunL |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 void CMPMDisconnectDlg::RunL() |
|
94 { |
|
95 MPMLOGSTRING2( "CMPMDisconnectDlg::RunL status %d", iStatus.Int() ) |
|
96 |
|
97 TInt error = iStatus.Int(); |
|
98 if ( error == KErrNone ) |
|
99 { |
|
100 UserSelectedOk( iStatus.Int() ); |
|
101 } |
|
102 else |
|
103 { |
|
104 UserSelectedCancel( iStatus.Int() ); |
|
105 } |
|
106 // Store selection |
|
107 iUserStatus = iStatus.Int(); |
|
108 iUserIap = iIapId; |
|
109 } |
|
110 |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CMPMDisconnectDlg::UserSelectedOk |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 void CMPMDisconnectDlg::UserSelectedOk( TInt aError ) |
|
117 { |
|
118 MPMLOGSTRING( "CMPMDisconnectDlg::UserSelectedOk: \ |
|
119 Tell BM to ignore error and do reselection" ) |
|
120 |
|
121 TInt error = aError; |
|
122 |
|
123 // Get the current connection IapId for this connId |
|
124 TUint32 iapId = iSession.MyServer().GetBMIap( iSession.ConnectionId() ); |
|
125 |
|
126 TBMNeededAction neededActionForPendingMsgs( EIgnoreError ); |
|
127 iSession.MyServer().HandlePendingMsgs( iapId, |
|
128 KErrNone, |
|
129 &error, |
|
130 &neededActionForPendingMsgs ); |
|
131 |
|
132 TBMNeededAction neededAction( EDoReselection ); |
|
133 iSession.ProcessErrorComplete( KErrNone, |
|
134 &error, |
|
135 &neededAction ); |
|
136 } |
|
137 |
|
138 |
|
139 // ----------------------------------------------------------------------------- |
|
140 // CMPMDisconnectDlg::UserSelectedCancel |
|
141 // ----------------------------------------------------------------------------- |
|
142 // |
|
143 void CMPMDisconnectDlg::UserSelectedCancel( TInt aError ) |
|
144 { |
|
145 // User has selected Cancel |
|
146 // |
|
147 // Read the Connection Id of the application |
|
148 // |
|
149 TConnectionId connId = iSession.ConnectionId(); |
|
150 |
|
151 TBMNeededAction neededAction( EDoReselection ); |
|
152 |
|
153 TInt error = aError; |
|
154 TInt* errorPtr( NULL ); |
|
155 |
|
156 if ( error == KErrNotFound ) |
|
157 { |
|
158 MPMLOGSTRING2( "CMPMDisconnectDlg::UserSelectedCancelL: \ |
|
159 Use original error code %i", iOrigError ) |
|
160 |
|
161 error = iOrigError; |
|
162 } |
|
163 |
|
164 // Get the state of the connection for this Iap Id. |
|
165 // |
|
166 TConnectionState state; |
|
167 iSession.MyServer().GetConnectionState( connId, state ); |
|
168 |
|
169 // Get the current connection IapId for this connId |
|
170 // |
|
171 TUint32 currentIap = iSession.MyServer().GetBMIap( connId ); |
|
172 |
|
173 if ( state == EStarting ) |
|
174 { |
|
175 MPMLOGSTRING2( "CMPMDisconnectDlg::UserSelectedCancelL: \ |
|
176 Tell BM to end the client connection with error code %i", error ) |
|
177 |
|
178 neededAction = EPropagateError; |
|
179 errorPtr = &error; |
|
180 } |
|
181 else if ( state == ERoaming ) |
|
182 { |
|
183 // New notification will be attempted with latest |
|
184 // available IAPs |
|
185 // |
|
186 iSession.StoredIapInfo().ResetStoredIapInfo(); |
|
187 neededAction = EIgnoreError; |
|
188 |
|
189 TConnMonIapInfo availableIAPs; |
|
190 availableIAPs = iSession.GetAvailableIAPs(); |
|
191 |
|
192 iSession.MyServer().HandleServerBlackListIap( connId, |
|
193 currentIap, |
|
194 ETemporary ); |
|
195 TRAP( error, iSession.PrefIAPNotificationL( availableIAPs, |
|
196 EBearerMan ) ); |
|
197 if ( error == KErrNotFound ) |
|
198 { |
|
199 neededAction = EPropagateError; |
|
200 |
|
201 errorPtr = &error; |
|
202 TRAP_IGNORE( iSession.MobilityErrorNotificationL( KErrNotFound ) ) |
|
203 MPMLOGSTRING2( |
|
204 "CMPMDisconnectDlg::UserSelectedCancelL: \ |
|
205 Tell BM to end the client connection with error code %i", error ) |
|
206 } |
|
207 else |
|
208 { |
|
209 MPMLOGSTRING( |
|
210 "CMPMDisconnectDlg::UserSelectedCancelL: \ |
|
211 Tell BM to ignore error and let MPM notify application about preferred IAP" ) |
|
212 } |
|
213 } |
|
214 else |
|
215 { |
|
216 MPMLOGSTRING2( "CMPMDisconnectDlg::UserSelectedCancelL: \ |
|
217 Unsupported state %d", state ) |
|
218 } |
|
219 |
|
220 iSession.MyServer().HandlePendingMsgs( currentIap, |
|
221 KErrNone, |
|
222 errorPtr, |
|
223 &neededAction ); |
|
224 |
|
225 iSession.ProcessErrorComplete( KErrNone, |
|
226 errorPtr, |
|
227 &neededAction ); |
|
228 } |
|
229 |
|
230 |
|
231 // ----------------------------------------------------------------------------- |
|
232 // CMPMDisconnectDlg::RunError |
|
233 // ----------------------------------------------------------------------------- |
|
234 // |
|
235 TInt CMPMDisconnectDlg::RunError(TInt aError) |
|
236 { |
|
237 // Handles a leave occurring in the request completion event handler |
|
238 // RunL(). The active scheduler calls this function if this active |
|
239 // object's RunL() function leaves. This gives this active object |
|
240 // the opportunity to perform any necessary cleanup. |
|
241 // |
|
242 MPMLOGSTRING2( |
|
243 "CMPMDisconnectDlg::RunError: RunL made a leave with error = %i", |
|
244 aError ) |
|
245 |
|
246 // Get the current connection IapId for this connId |
|
247 TUint32 iapId = iSession.MyServer().GetBMIap( iSession.ConnectionId() ); |
|
248 |
|
249 iSession.MyServer().HandlePendingMsgs( iapId, aError, NULL, NULL ); |
|
250 |
|
251 iSession.ProcessErrorComplete( aError, NULL, NULL ); |
|
252 |
|
253 // Return KErrNone to prevent panic |
|
254 // |
|
255 return KErrNone; |
|
256 } |
|
257 |
|
258 |
|
259 // ----------------------------------------------------------------------------- |
|
260 // CMPMDisconnectDlg::DoCancel |
|
261 // ----------------------------------------------------------------------------- |
|
262 // |
|
263 void CMPMDisconnectDlg::DoCancel() |
|
264 { |
|
265 MPMLOGSTRING( "CMPMDisconnectDlg::DoCancel" ) |
|
266 iDlgServ.CancelDisconnectDlg(); |
|
267 } |
|
268 |
|
269 |
|
270 // ----------------------------------------------------------------------------- |
|
271 // CMPMDisconnectDlg::Start |
|
272 // ----------------------------------------------------------------------------- |
|
273 // |
|
274 void CMPMDisconnectDlg::Start( CMPMDialogBase* aDlg ) |
|
275 { |
|
276 // If there are no outstanding CMPMDisconnectDlg, then |
|
277 // start CMPMDisconnectDlg immediately. |
|
278 // |
|
279 if ( aDlg ) |
|
280 { |
|
281 CMPMDisconnectDlg* dlg = (CMPMDisconnectDlg*) aDlg; |
|
282 iUserStatus = dlg->iUserStatus; |
|
283 iUserIap = dlg->iUserIap; |
|
284 } |
|
285 if ( iUserStatus == KErrNone && iUserIap != 0 ) |
|
286 { |
|
287 UserSelectedOk( iUserStatus ); |
|
288 } |
|
289 else if ( iUserStatus != KErrNone ) |
|
290 { |
|
291 UserSelectedCancel( iUserStatus ); |
|
292 } |
|
293 else |
|
294 { |
|
295 iDlgServ.DisconnectDlg( iStatus, iIapId, ETrue ); |
|
296 SetActive(); |
|
297 } |
|
298 } |
|
299 |
|
300 |
|
301 // End of File |