1 /* |
|
2 * Copyright (c) 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: Handles displaying wlan dialogs |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <wlanmgmtcommon.h> |
|
20 #include <e32std.h> |
|
21 #include <utf.h> |
|
22 #include <cmpluginwlandef.h> |
|
23 #include <ctsydomainpskeys.h> |
|
24 |
|
25 #include "mpmwlanquerydialog.h" |
|
26 #include "mpmiapselection.h" |
|
27 #include "mpmconnmonevents.h" |
|
28 #include "mpmlogger.h" |
|
29 |
|
30 // ======== MEMBER FUNCTIONS ======== |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // CMPMWlanQueryDialog::CMPMWlanQueryDialog |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 CMPMWlanQueryDialog::CMPMWlanQueryDialog( CMPMIapSelection& aIapSelection, |
|
37 TUint32 aWlanIapId ) |
|
38 : CActive( CActive::EPriorityStandard ), |
|
39 iIapSelection( aIapSelection ), |
|
40 iWlanQueryState( EOffline ), |
|
41 iWlanIapId( aWlanIapId ), |
|
42 iOverrideStatus( KErrNone ) |
|
43 { |
|
44 CActiveScheduler::Add( this ); |
|
45 } |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // CMPMWlanQueryDialog::ConstructL |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 void CMPMWlanQueryDialog::ConstructL() |
|
52 { |
|
53 User::LeaveIfError(iNotifier.Connect()); |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // CMPMWlanQueryDialog::NewL |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 CMPMWlanQueryDialog* CMPMWlanQueryDialog::NewL( CMPMIapSelection& aSession, |
|
61 TUint32 aWlanIapElementId ) |
|
62 { |
|
63 CMPMWlanQueryDialog* self = new( ELeave ) CMPMWlanQueryDialog( aSession, |
|
64 aWlanIapElementId ); |
|
65 CleanupStack::PushL( self ); |
|
66 self->ConstructL(); |
|
67 CleanupStack::Pop( self ); |
|
68 return self; |
|
69 } |
|
70 |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // CMPMWlanQueryDialog::~CMPMWlanQueryDialog |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 CMPMWlanQueryDialog::~CMPMWlanQueryDialog() |
|
77 { |
|
78 MPMLOGSTRING( "CMPMWlanQueryDialog::~CMPMWlanQueryDialog enters" ) |
|
79 |
|
80 // Check if this dialog instance was not started but only added to the queue |
|
81 if ( iIapSelection.Session()->MyServer().FirstInWlanQueryQueue() != this ) |
|
82 { |
|
83 MPMLOGSTRING( "CMPMWlanQueryDialog::~CMPMWlanQueryDialog, not a active delete" ) |
|
84 |
|
85 // Close notifier |
|
86 iNotifier.Close(); |
|
87 |
|
88 // We're not first in the queue, thus we can just delete. |
|
89 // But remember the pointer in the array. |
|
90 iIapSelection.Session()->MyServer().RemoveFromWlanQueryQueue( this ); |
|
91 MPMLOGSTRING( "CMPMWlanQueryDialog::~CMPMWlanQueryDialog exits (break)" ) |
|
92 return; |
|
93 } |
|
94 |
|
95 // Cancel previous dialogs if any. |
|
96 Cancel(); |
|
97 |
|
98 // Close notifier |
|
99 iNotifier.Close(); |
|
100 |
|
101 // Remove self from the queue |
|
102 iIapSelection.Session()->MyServer().RemoveFromWlanQueryQueue( this ); |
|
103 |
|
104 // Start the next query |
|
105 CMPMWlanQueryDialog* dlg = iIapSelection.Session()->MyServer().FirstInWlanQueryQueue(); |
|
106 if ( dlg ) |
|
107 { |
|
108 MPMLOGSTRING( "CMPMWlanQueryDialog::~CMPMWlanQueryDialog starts new dialog" ) |
|
109 dlg->OfferInformation( iStatus.Int() ); |
|
110 // In destructor we cannot let the query leave |
|
111 TRAPD( err, dlg->StartWlanQueryL(); ) |
|
112 if ( err != KErrNone ) |
|
113 { |
|
114 MPMLOGSTRING2( "CMPMWlanQueryDialog::~CMPMWlanQueryDialog caught Leave %d, executing RunError()", err ) |
|
115 dlg->RunError( err ); |
|
116 } |
|
117 } |
|
118 |
|
119 MPMLOGSTRING( "CMPMWlanQueryDialog::~CMPMWlanQueryDialog exits" ) |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------------------------- |
|
123 // CMPMWlanQueryDialog::DoCancel |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 void CMPMWlanQueryDialog::DoCancel() |
|
127 { |
|
128 MPMLOGSTRING2( "CMPMWlanQueryDialog::DoCancel state %d", iWlanQueryState ) |
|
129 if ( iWlanQueryState == EOffline ) |
|
130 { |
|
131 iNotifier.CancelNotifier( KUidCOfflineWlanNoteDlg ); |
|
132 } |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // CMPMWlanQueryDialog::RunL |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 void CMPMWlanQueryDialog::RunL() |
|
140 { |
|
141 MPMLOGSTRING3( "CMPMWlanQueryDialog::RunL status %d state %d", |
|
142 iStatus.Int(), |
|
143 iWlanQueryState ) |
|
144 |
|
145 if( iWlanQueryState == EOffline ) |
|
146 { |
|
147 if( iStatus.Int() == KErrNone ) |
|
148 { |
|
149 iIapSelection.Session()->MyServer().SetOfflineWlanQueryResponse( |
|
150 EOfflineResponseYes ); |
|
151 } |
|
152 else if ( iStatus.Int() == KErrCancel ) |
|
153 { |
|
154 iIapSelection.Session()->MyServer().SetOfflineWlanQueryResponse( |
|
155 EOfflineResponseNo ); |
|
156 MPMLOGSTRING2( "CMPMWlanQueryDialog::RunL offline query returned %d", |
|
157 iStatus.Int() ) |
|
158 } |
|
159 else |
|
160 { |
|
161 MPMLOGSTRING2( "CMPMWlanQueryDialog::RunL offline query returned %d", |
|
162 iStatus.Int() ) |
|
163 } |
|
164 } |
|
165 // if an error was given through OfferInformation() -call we abort the execution. |
|
166 // |
|
167 else if ( iOverrideStatus != KErrNone ) |
|
168 { |
|
169 MPMLOGSTRING2( "CMPMWlanQueryDialog::StartWlanQuery inherited error %d", iOverrideStatus ) |
|
170 iIapSelection.UserWlanSelectionDoneL( iOverrideStatus, iWlanIapId ); |
|
171 } |
|
172 else |
|
173 { |
|
174 MPMLOGSTRING2( "CMPMWlanQueryDialog::RunL, unknown state: %d", iWlanQueryState ) |
|
175 User::Leave( KErrCancel ); |
|
176 } |
|
177 |
|
178 iIapSelection.UserWlanSelectionDoneL( iStatus.Int(), iWlanIapId ); |
|
179 |
|
180 iWlanIapId = 0; |
|
181 } |
|
182 |
|
183 // --------------------------------------------------------------------------- |
|
184 // CMPMWlanQueryDialog::RunError |
|
185 // --------------------------------------------------------------------------- |
|
186 // |
|
187 TInt CMPMWlanQueryDialog::RunError( TInt aError ) |
|
188 { |
|
189 MPMLOGSTRING2( "CMPMWlanQueryDialog::RunError failed with %d", aError ) |
|
190 iIapSelection.ChooseIapComplete( aError, NULL ); |
|
191 return KErrNone; |
|
192 } |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // CMPMWlanQueryDialog::StartWlanQueryL |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 void CMPMWlanQueryDialog::StartWlanQueryL() |
|
199 { |
|
200 MPMLOGSTRING( "CMPMWlanQueryDialog::StartWlanQuery" ) |
|
201 |
|
202 TUint32 activeWlanIap = iIapSelection.Session()->MyServer().IsWlanConnectionStartedL( |
|
203 iIapSelection.Session()->MyServer().CommsDatAccess() ); |
|
204 |
|
205 // Get EmergencyCallInfo via Publish & Subscribe |
|
206 // |
|
207 TInt emergencyCallEstablished( 0 ); |
|
208 RProperty::Get( KPSUidCtsyEmergencyCallInfo, |
|
209 KCTSYEmergencyCallInfo, |
|
210 emergencyCallEstablished ); |
|
211 MPMLOGSTRING2( "CMPMWlanQueryDialog::StartWlanQuery KCTSYEmergencyCallInfo = %d", |
|
212 emergencyCallEstablished ) |
|
213 |
|
214 // Get note behaviour setting |
|
215 TUint32 noteBehaviour( 0 ); |
|
216 noteBehaviour = iIapSelection.MpmConnPref().NoteBehaviour(); |
|
217 MPMLOGSTRING2( "CMPMWlanQueryDialog::StartWlanQuery noteBehaviour = %d", noteBehaviour ) |
|
218 |
|
219 if( !emergencyCallEstablished && |
|
220 iIapSelection.Session()->MyServer().IsPhoneOffline() && |
|
221 !activeWlanIap && |
|
222 iIapSelection.Session()->MyServer().OfflineWlanQueryResponse() != EOfflineResponseYes && |
|
223 iOverrideStatus == KErrNone ) |
|
224 { |
|
225 if ( noteBehaviour & TExtendedConnPref::ENoteBehaviourConnDisableQueries ) |
|
226 { |
|
227 MPMLOGSTRING( "CMPMWlanQueryDialog::StartWlanQuery offline note query not shown due to disabled queries" ) |
|
228 iIapSelection.UserWlanSelectionDoneL( KErrPermissionDenied, iWlanIapId ); |
|
229 } |
|
230 else |
|
231 { |
|
232 MPMLOGSTRING( "CMPMWlanQueryDialog::StartWlanQuery, starting offline note" ) |
|
233 iWlanQueryState = EOffline; |
|
234 iNotifier.StartNotifierAndGetResponse( iStatus, |
|
235 KUidCOfflineWlanNoteDlg, |
|
236 KNullDesC8(), |
|
237 iOfflineReply ); |
|
238 SetActive(); |
|
239 } |
|
240 } |
|
241 else |
|
242 { |
|
243 MPMLOGSTRING( "CMPMWlanQueryDialog::StartWlanQuery no wlan dialog to show" ) |
|
244 iIapSelection.UserWlanSelectionDoneL( KErrNone, iWlanIapId ); |
|
245 } |
|
246 } |
|
247 |
|
248 // ----------------------------------------------------------------------------- |
|
249 // CMPMWlanQueryDialog::OfferInformation |
|
250 // ----------------------------------------------------------------------------- |
|
251 // |
|
252 void CMPMWlanQueryDialog::OfferInformation( TInt aDialogStatus ) |
|
253 { |
|
254 TOfflineWlanQueryResponse offlineResponse = |
|
255 iIapSelection.Session()->MyServer().OfflineWlanQueryResponse(); |
|
256 if ( offlineResponse != EOfflineResponseUndefined ) |
|
257 { |
|
258 MPMLOGSTRING3( "CMPMWlanQueryDialog<0x%x>::OfferInformation: offline response %d", |
|
259 iIapSelection.Session()->ConnectionId(), |
|
260 offlineResponse ) |
|
261 iOverrideStatus = aDialogStatus; |
|
262 } |
|
263 |
|
264 #ifdef _LOG |
|
265 else |
|
266 { |
|
267 MPMLOGSTRING( "CMPMWlanQueryDialog::OfferInformation, information not taken." ) |
|
268 } |
|
269 #endif |
|
270 } |
|
271 |
|