|
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 TBMNeededAction neededAction( EDoReselection ); |
|
122 TInt error = aError; |
|
123 |
|
124 iSession.ProcessErrorComplete( KErrNone, |
|
125 &error, |
|
126 &neededAction ); |
|
127 } |
|
128 |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // CMPMDisconnectDlg::UserSelectedCancel |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 void CMPMDisconnectDlg::UserSelectedCancel( TInt aError ) |
|
135 { |
|
136 // User has selected Cancel |
|
137 // |
|
138 // Read the Connection Id of the application |
|
139 // |
|
140 TConnectionId connId = iSession.ConnectionId(); |
|
141 |
|
142 TBMNeededAction neededAction( EDoReselection ); |
|
143 |
|
144 TInt error = aError; |
|
145 TInt* errorPtr( NULL ); |
|
146 |
|
147 if ( error == KErrNotFound ) |
|
148 { |
|
149 MPMLOGSTRING2( "CMPMDisconnectDlg::UserSelectedCancelL: \ |
|
150 Use original error code %i", iOrigError ) |
|
151 |
|
152 error = iOrigError; |
|
153 } |
|
154 |
|
155 // Get the state of the connection for this Iap Id. |
|
156 // |
|
157 TConnectionState state; |
|
158 iSession.MyServer().GetConnectionState( connId, state ); |
|
159 |
|
160 if ( state == EStarting ) |
|
161 { |
|
162 MPMLOGSTRING2( "CMPMDisconnectDlg::UserSelectedCancelL: \ |
|
163 Tell BM to end the client connection with error code %i", error ) |
|
164 |
|
165 neededAction = EPropagateError; |
|
166 errorPtr = &error; |
|
167 } |
|
168 else if ( state == ERoaming ) |
|
169 { |
|
170 // New notification will be attempted with latest |
|
171 // available IAPs |
|
172 // |
|
173 iSession.StoredIapInfo().ResetStoredIapInfo(); |
|
174 neededAction = EIgnoreError; |
|
175 |
|
176 // Get the current connection IapId for this connId |
|
177 // |
|
178 TUint32 currentIap = iSession.MyServer().GetBMIap( connId ); |
|
179 |
|
180 TConnMonIapInfo availableIAPs; |
|
181 availableIAPs = iSession.GetAvailableIAPs(); |
|
182 |
|
183 iSession.MyServer().HandleServerBlackListIap( connId, |
|
184 currentIap, |
|
185 ETemporary ); |
|
186 TRAP( error, iSession.PrefIAPNotificationL( availableIAPs, |
|
187 EBearerMan ) ); |
|
188 if ( error == KErrNotFound ) |
|
189 { |
|
190 neededAction = EPropagateError; |
|
191 |
|
192 errorPtr = &error; |
|
193 TRAP_IGNORE( iSession.MobilityErrorNotificationL( KErrNotFound ) ) |
|
194 MPMLOGSTRING2( |
|
195 "CMPMDisconnectDlg::UserSelectedCancelL: \ |
|
196 Tell BM to end the client connection with error code %i", error ) |
|
197 } |
|
198 else |
|
199 { |
|
200 MPMLOGSTRING( |
|
201 "CMPMDisconnectDlg::UserSelectedCancelL: \ |
|
202 Tell BM to ignore error and let MPM notify application about preferred IAP" ) |
|
203 } |
|
204 } |
|
205 else |
|
206 { |
|
207 MPMLOGSTRING2( "CMPMDisconnectDlg::UserSelectedCancelL: \ |
|
208 Unsupported state %d", state ) |
|
209 } |
|
210 |
|
211 iSession.ProcessErrorComplete( KErrNone, |
|
212 errorPtr, |
|
213 &neededAction ); |
|
214 } |
|
215 |
|
216 |
|
217 // ----------------------------------------------------------------------------- |
|
218 // CMPMDisconnectDlg::RunError |
|
219 // ----------------------------------------------------------------------------- |
|
220 // |
|
221 TInt CMPMDisconnectDlg::RunError(TInt aError) |
|
222 { |
|
223 // Handles a leave occurring in the request completion event handler |
|
224 // RunL(). The active scheduler calls this function if this active |
|
225 // object's RunL() function leaves. This gives this active object |
|
226 // the opportunity to perform any necessary cleanup. |
|
227 // |
|
228 MPMLOGSTRING2( |
|
229 "CMPMDisconnectDlg::RunError: RunL made a leave with error = %i", |
|
230 aError ) |
|
231 |
|
232 iSession.ProcessErrorComplete( aError, NULL, NULL ); |
|
233 |
|
234 // Return KErrNone to prevent panic |
|
235 // |
|
236 return KErrNone; |
|
237 } |
|
238 |
|
239 |
|
240 // ----------------------------------------------------------------------------- |
|
241 // CMPMDisconnectDlg::DoCancel |
|
242 // ----------------------------------------------------------------------------- |
|
243 // |
|
244 void CMPMDisconnectDlg::DoCancel() |
|
245 { |
|
246 MPMLOGSTRING( "CMPMDisconnectDlg::DoCancel" ) |
|
247 iDlgServ.CancelDisconnectDlg(); |
|
248 } |
|
249 |
|
250 |
|
251 // ----------------------------------------------------------------------------- |
|
252 // CMPMDisconnectDlg::Start |
|
253 // ----------------------------------------------------------------------------- |
|
254 // |
|
255 void CMPMDisconnectDlg::Start( CMPMDialogBase* aDlg ) |
|
256 { |
|
257 // If there are no outstanding CMPMDisconnectDlg, then |
|
258 // start CMPMDisconnectDlg immediately. |
|
259 // |
|
260 if ( aDlg ) |
|
261 { |
|
262 CMPMDisconnectDlg* dlg = (CMPMDisconnectDlg*) aDlg; |
|
263 iUserStatus = dlg->iUserStatus; |
|
264 iUserIap = dlg->iUserIap; |
|
265 } |
|
266 if ( iUserStatus == KErrNone && iUserIap != 0 ) |
|
267 { |
|
268 UserSelectedOk( iUserStatus ); |
|
269 } |
|
270 else if ( iUserStatus != KErrNone ) |
|
271 { |
|
272 UserSelectedCancel( iUserStatus ); |
|
273 } |
|
274 else |
|
275 { |
|
276 iDlgServ.DisconnectDlg( iStatus, iIapId, ETrue ); |
|
277 SetActive(); |
|
278 } |
|
279 } |
|
280 |
|
281 |
|
282 // End of File |