|
1 /* |
|
2 * Copyright (c) 2001-2009 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 the License "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: Implementation of CWiFiProtDlgsPlugin. |
|
15 * |
|
16 */ |
|
17 |
|
18 /* |
|
19 * %version: tr1cfwln#10 % |
|
20 */ |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include <e32property.h> // For RProperty |
|
24 #include <wifiprotuiddefs.h> |
|
25 #include <bautils.h> |
|
26 #include <eikenv.h> |
|
27 #include <data_caging_path_literals.hrh> |
|
28 |
|
29 #include "wifiprotdlgsplugin.h" |
|
30 #include "wifiprotplugin.h" |
|
31 #include "wifiprotlogger.h" |
|
32 #include "wifiprotactiverunner.h" |
|
33 |
|
34 |
|
35 |
|
36 using namespace WiFiProt; |
|
37 |
|
38 // CONSTS |
|
39 _LIT( KDriveZ, "z:" ); |
|
40 |
|
41 // ============================ MEMBER FUNCTIONS ============================ |
|
42 |
|
43 // -------------------------------------------------------------------------- |
|
44 // CWiFiProtDlgsPlugin* CWiFiProtDlgsPlugin::NewL() |
|
45 // -------------------------------------------------------------------------- |
|
46 // |
|
47 CWiFiProtDlgsPlugin* CWiFiProtDlgsPlugin::NewL( |
|
48 const TBool aResourceFileResponsible, |
|
49 RCmManagerExt* aCmManagerExt ) |
|
50 |
|
51 { |
|
52 CLOG_ENTERFN( "CWiFiProtDlgsPlugin::NewL" ); |
|
53 |
|
54 CWiFiProtDlgsPlugin* self = new ( ELeave ) CWiFiProtDlgsPlugin(); |
|
55 CleanupStack::PushL( self ); |
|
56 self->ConstructL( KResourceFileName, |
|
57 aResourceFileResponsible, aCmManagerExt ); |
|
58 CleanupStack::Pop( self ); |
|
59 |
|
60 CLOG_LEAVEFN( "CWiFiProtDlgsPlugin::NewL" ); |
|
61 |
|
62 return self; |
|
63 } |
|
64 |
|
65 // -------------------------------------------------------------------------- |
|
66 // CWiFiProtDlgsPlugin* CWiFiProtDlgsPlugin::NewL() |
|
67 // -------------------------------------------------------------------------- |
|
68 // |
|
69 CWiFiProtDlgsPlugin* CWiFiProtDlgsPlugin::NewL( |
|
70 const TBool aResourceFileResponsible ) |
|
71 { |
|
72 CLOG_ENTERFN( "CWiFiProtDlgsPlugin::NewL (without passed CmManager)" ); |
|
73 |
|
74 CWiFiProtDlgsPlugin* ret = NewL( aResourceFileResponsible, NULL ); |
|
75 |
|
76 CLOG_LEAVEFN( "CWiFiProtDlgsPlugin::NewL (without passed CmManager)" ); |
|
77 |
|
78 return ret; |
|
79 } |
|
80 |
|
81 // -------------------------------------------------------------------------- |
|
82 // CWiFiProtDlgsPlugin::~CWiFiProtDlgsPlugin |
|
83 // -------------------------------------------------------------------------- |
|
84 // |
|
85 CWiFiProtDlgsPlugin::~CWiFiProtDlgsPlugin( ) |
|
86 |
|
87 { |
|
88 CLOG_ENTERFN( "CWiFiProtDlgsPlugin::~CWiFiProtDlgsPlugin" ); |
|
89 |
|
90 delete iRunner; |
|
91 |
|
92 //we didn't get a cmManager from the client, so use our own |
|
93 if (iPassedCmManagerExt == NULL) |
|
94 { |
|
95 iCmManagerExt.Close(); |
|
96 } |
|
97 |
|
98 iUids.Close(); |
|
99 |
|
100 if ( iResource ) |
|
101 { |
|
102 CCoeEnv::Static()->DeleteResourceFile( iResource ); |
|
103 } |
|
104 |
|
105 CLOG_LEAVEFN( "CWiFiProtDlgsPlugin::~CWiFiProtDlgsPlugin" ); |
|
106 |
|
107 } |
|
108 |
|
109 // -------------------------------------------------------------------------- |
|
110 // CWiFiProtDlgsPlugin::TNotifierInfo |
|
111 // CWiFiProtDlgsPlugin::Info() const |
|
112 // -------------------------------------------------------------------------- |
|
113 // |
|
114 CWiFiProtDlgsPlugin::TNotifierInfo CWiFiProtDlgsPlugin::Info() const |
|
115 { |
|
116 return iInfo; |
|
117 } |
|
118 |
|
119 // -------------------------------------------------------------------------- |
|
120 // TPtrC8 CWiFiProtDlgsPlugin::StartL() |
|
121 // -------------------------------------------------------------------------- |
|
122 // |
|
123 TPtrC8 CWiFiProtDlgsPlugin::StartL( const TDesC8& /*aBuffer*/ ) |
|
124 { |
|
125 CLOG_WRITE( "CWiFiProtDlgsPlugin::StartL" ); |
|
126 return KNullDesC8().Ptr(); |
|
127 } |
|
128 |
|
129 // -------------------------------------------------------------------------- |
|
130 // void CWiFiProtDlgsPlugin::Cancel() |
|
131 // -------------------------------------------------------------------------- |
|
132 // |
|
133 void CWiFiProtDlgsPlugin::Cancel() |
|
134 { |
|
135 CLOG_ENTERFN( "CWiFiProtDlgsPlugin::Cancel" ); |
|
136 |
|
137 if ( !iCancelled ) |
|
138 { |
|
139 if ( iRunner && !iCancelledFromInside ) |
|
140 { |
|
141 iClientCancelled = ETrue; |
|
142 iRunner->CancelByClient(); |
|
143 } |
|
144 iCancelled = ETrue; |
|
145 if ( !iMessage.IsNull() ) |
|
146 { |
|
147 if ( iConnMode ) |
|
148 { |
|
149 TRAP_IGNORE( iMessage.WriteL( iReplySlot, |
|
150 TPckg<WiFiProt::TWiFiConnOutputParams>( |
|
151 TWlanProtectedSetupCredentialAttribute() ) |
|
152 )); |
|
153 } |
|
154 else |
|
155 { |
|
156 TRAP_IGNORE( iMessage.WriteL( iReplySlot, |
|
157 TPckg<WiFiProt::TWiFiOutputParams>( KNullDesC8() ) |
|
158 )); |
|
159 } |
|
160 iMessage.Complete( KErrCancel ); |
|
161 } |
|
162 } |
|
163 |
|
164 CLOG_LEAVEFN( "CWiFiProtDlgsPlugin::Cancel" ); |
|
165 |
|
166 } |
|
167 |
|
168 // -------------------------------------------------------------------------- |
|
169 // void CWiFiProtDlgsPlugin::Release() |
|
170 // -------------------------------------------------------------------------- |
|
171 // |
|
172 void CWiFiProtDlgsPlugin::Release() |
|
173 { |
|
174 CLOG_ENTERFN( "CWiFiProtDlgsPlugin::Release" ); |
|
175 |
|
176 delete this; |
|
177 |
|
178 CLOG_LEAVEFN( "CWiFiProtDlgsPlugin::Release" ); |
|
179 } |
|
180 |
|
181 // -------------------------------------------------------------------------- |
|
182 // TPtrC8 CWiFiProtDlgsPlugin::UpdateL() |
|
183 // -------------------------------------------------------------------------- |
|
184 // |
|
185 TPtrC8 CWiFiProtDlgsPlugin::UpdateL(const TDesC8& /*aBuffer*/) |
|
186 { |
|
187 return KNullDesC8().Ptr(); |
|
188 } |
|
189 |
|
190 // -------------------------------------------------------------------------- |
|
191 // void CWiFiProtDlgsPlugin::CompleteL() |
|
192 // -------------------------------------------------------------------------- |
|
193 // |
|
194 void CWiFiProtDlgsPlugin::CompleteL( TInt aStatus ) |
|
195 { |
|
196 CLOG_ENTERFN( "CWiFiProtDlgsPlugin::CompleteL" ); |
|
197 |
|
198 CLOG_WRITEF( _L( "aStatus:" ), aStatus ); |
|
199 iCancelled = ETrue; |
|
200 if ( !iMessage.IsNull() ) |
|
201 { |
|
202 if ( iConnMode ) |
|
203 { |
|
204 // return a different kind of message |
|
205 // for connection creation |
|
206 WiFiProt::TWiFiConnOutputParams connOutputParams = |
|
207 WiFiProt::TWiFiConnOutputParams( iNetworkSettings ); |
|
208 connOutputParams.iReturn = iReturn; |
|
209 iMessage.WriteL( iReplySlot, |
|
210 TPckg<WiFiProt::TWiFiConnOutputParams>( connOutputParams ) ); |
|
211 } |
|
212 else |
|
213 { |
|
214 // ... or iap(s) creation |
|
215 const TInt elementSize = sizeof(TUint32); |
|
216 TBuf8<(KMaxNumberOfUids * elementSize)> buf; |
|
217 TInt uidsCount = iUids.Count(); |
|
218 if ( uidsCount > KMaxNumberOfUids ) |
|
219 { |
|
220 uidsCount = KMaxNumberOfUids; |
|
221 } |
|
222 // copy data from the array to iIapIds in TWiFiOutputParams |
|
223 buf.Append((const TUint8 *)(&iUids[0]), uidsCount *elementSize); |
|
224 //append return value |
|
225 WiFiProt::TWiFiOutputParams outputParams = |
|
226 WiFiProt::TWiFiOutputParams(buf); |
|
227 outputParams.iReturn = iReturn; |
|
228 iMessage.WriteL( iReplySlot, |
|
229 TPckg<WiFiProt::TWiFiOutputParams>( outputParams ) ); |
|
230 } |
|
231 iMessage.Complete( aStatus ); |
|
232 } |
|
233 |
|
234 CLOG_LEAVEFN( "CWiFiProtDlgsPlugin::CompleteL" ); |
|
235 |
|
236 } |
|
237 |
|
238 // -------------------------------------------------------------------------- |
|
239 // CWiFiProtDlgsPlugin::SetCancelledFlag |
|
240 // -------------------------------------------------------------------------- |
|
241 // |
|
242 void CWiFiProtDlgsPlugin::SetCancelledFlag( TBool aCancelled ) |
|
243 { |
|
244 iCancelled = aCancelled; |
|
245 } |
|
246 |
|
247 // -------------------------------------------------------------------------- |
|
248 // CWiFiProtDlgsPlugin::TNotifierInfo CWiFiProtDlgsPlugin::RegisterL() |
|
249 // -------------------------------------------------------------------------- |
|
250 // |
|
251 CWiFiProtDlgsPlugin::TNotifierInfo CWiFiProtDlgsPlugin::RegisterL() |
|
252 { |
|
253 CLOG_ENTERFN( "CWiFiProtDlgsPlugin::RegisterL" ); |
|
254 |
|
255 iInfo.iUid = KUidWiFiProtSetup; |
|
256 iInfo.iPriority = ENotifierPriorityHigh; |
|
257 iInfo.iChannel = KUidWiFiProtSetup; |
|
258 |
|
259 CLOG_LEAVEFN( "CWiFiProtDlgsPlugin::RegisterL" ); |
|
260 |
|
261 return iInfo; |
|
262 } |
|
263 |
|
264 // -------------------------------------------------------------------------- |
|
265 // void CWiFiProtDlgsPlugin::StartL |
|
266 // -------------------------------------------------------------------------- |
|
267 // |
|
268 void CWiFiProtDlgsPlugin::StartL( const TDesC8& aBuffer, |
|
269 TInt aReplySlot, |
|
270 const RMessagePtr2& aMessage ) |
|
271 { |
|
272 CLOG_ENTERFN( "CWiFiProtDlgsPlugin::StartL" ); |
|
273 |
|
274 TPckgBuf<TWiFiInputParams> pckgParams( |
|
275 TPckgBuf<TWiFiInputParams>(TWiFiInputParams(KNullDesC8(), |
|
276 EFalse))); |
|
277 pckgParams.Copy( *((TPckgBuf<TWiFiInputParams>*) (&aBuffer))); |
|
278 TWiFiInputParams params((pckgParams)()); |
|
279 iConnMode = params.iConnectionNeeded; |
|
280 TWlanSsid ssid; |
|
281 ssid.Copy( params.iSSid ); |
|
282 |
|
283 iCancelled = EFalse; |
|
284 |
|
285 iReplySlot = aReplySlot; |
|
286 iMessage = aMessage; |
|
287 |
|
288 if ( iConnMode ) |
|
289 { |
|
290 // no need for uid array to return, but we need a single network |
|
291 // settings struct |
|
292 iRunner->StartProtectedSetupConnL( ssid, iNetworkSettings, |
|
293 CmManagerToUse()); |
|
294 } |
|
295 else |
|
296 { |
|
297 iRunner->StartProtectedSetupAsyncL( ssid, iUids, CmManagerToUse() ); |
|
298 } |
|
299 |
|
300 CLOG_LEAVEFN( "CWiFiProtDlgsPlugin::StartL" ); |
|
301 } |
|
302 |
|
303 // -------------------------------------------------------------------------- |
|
304 // WiFiProt::TWiFiReturn CWiFiProtDlgsPlugin::CompleteProcessL |
|
305 // -------------------------------------------------------------------------- |
|
306 // |
|
307 void CWiFiProtDlgsPlugin::CompleteProcessL( WiFiProt::TWiFiReturn aReturnValue ) |
|
308 { |
|
309 CLOG_ENTERFN( "WiFiProtDlgsPlugin::CompleteProcessL" ); |
|
310 iReturn = aReturnValue; |
|
311 switch ( aReturnValue ) |
|
312 { |
|
313 case EWiFiOK: |
|
314 { |
|
315 CLOG_WRITE("StartProtectedSetupL returned EWiFiOK"); |
|
316 CompleteL( KErrNone ); |
|
317 break; |
|
318 } |
|
319 case EWifiNoAuto: |
|
320 { |
|
321 CLOG_WRITE("StartProtectedSetupL returned EWifiNoAuto"); |
|
322 CompleteL( KErrNone ); |
|
323 break; |
|
324 } |
|
325 case EWiFiCancel: |
|
326 { |
|
327 CLOG_WRITE("StartProtectedSetupL returned EWiFiCancel"); |
|
328 iCancelledFromInside = ETrue; |
|
329 Cancel(); |
|
330 break; |
|
331 } |
|
332 default: |
|
333 { |
|
334 //should never happen |
|
335 CLOG_WRITE("Unhandled exit value, leaving..."); |
|
336 User::Leave( KErrGeneral ); |
|
337 break; |
|
338 } |
|
339 } |
|
340 CLOG_WRITEF( _L( "Uids returned:" ), iUids.Count() ); |
|
341 for ( TInt i = 0;i<iUids.Count();i++ ) |
|
342 { |
|
343 CLOG_WRITEF( _L( "Uid:" ), iUids[i] ); |
|
344 } |
|
345 |
|
346 CLOG_LEAVEFN( "CWiFiProtDlgsPlugin::CompleteProcessL" ); |
|
347 } |
|
348 |
|
349 |
|
350 // -------------------------------------------------------------------------- |
|
351 // WiFiProt::TWiFiReturn CWiFiProtDlgsPlugin::StartFromUiL |
|
352 // -------------------------------------------------------------------------- |
|
353 // |
|
354 |
|
355 WiFiProt::TWiFiReturn CWiFiProtDlgsPlugin::StartFromUiL( |
|
356 const TWlanSsid& aSSid, |
|
357 TBool aConnectionNeeded, |
|
358 RArray<TUint32>& aUidsReturned) |
|
359 { |
|
360 CLOG_ENTERFN( "CWiFiProtDlgsPlugin::StartFromUiL" ); |
|
361 |
|
362 CLOG_WRITE("Input params:"); |
|
363 CLOG_WRITE("SSid:"); |
|
364 |
|
365 TBuf<KWlanMaxSsidLength> buf; |
|
366 buf.Copy(aSSid); |
|
367 CLOG_WRITEF( buf ); |
|
368 CLOG_WRITE("Connection needed:"); |
|
369 if ( aConnectionNeeded ) |
|
370 { |
|
371 CLOG_WRITE("ETrue"); |
|
372 } |
|
373 else |
|
374 { |
|
375 CLOG_WRITE("EFalse"); |
|
376 } |
|
377 //use passed CmManager if present |
|
378 WiFiProt::TWiFiReturn ret = iRunner->StartProtectedSetupL( |
|
379 aSSid, aUidsReturned, CmManagerToUse()); |
|
380 |
|
381 CLOG_LEAVEFN( "CWiFiProtDlgsPlugin::StartFromUiL" ); |
|
382 return ret; |
|
383 } |
|
384 |
|
385 // -------------------------------------------------------------------------- |
|
386 // void CWiFiProtDlgsPlugin::CmManagerToUse() |
|
387 // -------------------------------------------------------------------------- |
|
388 // |
|
389 RCmManagerExt& CWiFiProtDlgsPlugin::CmManagerToUse() |
|
390 { |
|
391 CLOG_ENTERFN( "CWiFiProtDlgsPlugin::CmManagerToUse" ); |
|
392 |
|
393 if (iPassedCmManagerExt == NULL ) |
|
394 { |
|
395 CLOG_WRITE("Own CmManagerExt used"); |
|
396 |
|
397 CLOG_LEAVEFN( "CWiFiProtDlgsPlugin::CmManagerToUse" ); |
|
398 |
|
399 return iCmManagerExt; |
|
400 } |
|
401 else |
|
402 { |
|
403 CLOG_WRITE("Passed CmManagerExt used"); |
|
404 |
|
405 CLOG_LEAVEFN( "CWiFiProtDlgsPlugin::CmManagerToUse" ); |
|
406 |
|
407 return *iPassedCmManagerExt; |
|
408 } |
|
409 } |
|
410 |
|
411 // -------------------------------------------------------------------------- |
|
412 // CWiFiProtDlgsPlugin::CWiFiProtDlgsPlugin() |
|
413 // -------------------------------------------------------------------------- |
|
414 // |
|
415 CWiFiProtDlgsPlugin::CWiFiProtDlgsPlugin() |
|
416 : iCancelled( EFalse ), |
|
417 iResource( 0 ), |
|
418 iCancelledFromInside( EFalse ) |
|
419 |
|
420 { |
|
421 CLOG_WRITE("CWiFiProtDlgsPlugin::CWiFiProtDlgsPlugin"); |
|
422 } |
|
423 |
|
424 // -------------------------------------------------------------------------- |
|
425 // void CWiFiProtDlgsPlugin::ConstructL( ) |
|
426 // -------------------------------------------------------------------------- |
|
427 // |
|
428 void CWiFiProtDlgsPlugin::ConstructL(const TDesC& aResourceFileName, |
|
429 const TBool aResourceFileResponsible, |
|
430 RCmManagerExt* aCmManagerExt ) |
|
431 { |
|
432 CLOG_ENTERFN( "CWiFiProtDlgsPlugin::ConstructL" ); |
|
433 |
|
434 if ( aResourceFileResponsible ) |
|
435 { |
|
436 // Since this is a .DLL, resource files that are to be used by the |
|
437 // notifier aren't added automatically so we do that here. |
|
438 TFileName fileName; |
|
439 |
|
440 fileName.Append( KDriveZ ); |
|
441 fileName.Append( KDC_RESOURCE_FILES_DIR ); |
|
442 fileName.Append( aResourceFileName ); |
|
443 |
|
444 BaflUtils::NearestLanguageFile( CCoeEnv::Static()->FsSession(), |
|
445 fileName ); |
|
446 iResource = CCoeEnv::Static()->AddResourceFileL( fileName ); |
|
447 } |
|
448 |
|
449 iPassedCmManagerExt = aCmManagerExt; |
|
450 //we didn't get a cmManager from the client, so use our own |
|
451 if (iPassedCmManagerExt == NULL) |
|
452 { |
|
453 iCmManagerExt.OpenL(); |
|
454 } |
|
455 iRunner = CWiFiProtActiveRunner::NewL( this ); |
|
456 |
|
457 CLOG_LEAVEFN( "CWiFiProtDlgsPlugin::ConstructL" ); |
|
458 |
|
459 } |
|
460 |
|
461 // End of File |