55
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-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: Implementation of CWsfAiHelperAppUi
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// EXTERNAL INCLUDES
|
|
20 |
#include <avkon.hrh>
|
|
21 |
#include <apgcli.h>
|
|
22 |
#include <cmmanager.h>
|
|
23 |
#include <cmconnectionmethod.h>
|
|
24 |
#include <StringLoader.h>
|
|
25 |
#include <wsfaihelper.rsg>
|
|
26 |
#include <AknQueryDialog.h>
|
|
27 |
#include <e32property.h>
|
|
28 |
#include <ErrorUI.h>
|
|
29 |
#include <wlanerrorcodes.h>
|
|
30 |
|
|
31 |
// CLASS HEADER
|
|
32 |
#include "wsfaihelperappui.h"
|
|
33 |
|
|
34 |
// INTERNAL INCLUDES
|
|
35 |
#include "wsfaihelperdocument.h"
|
|
36 |
#include "wsfaihelperapplication.h"
|
|
37 |
#include "wsfmodel.h"
|
|
38 |
#include "wsfwlaninfo.h"
|
|
39 |
#include "wsfaihelperview.h"
|
|
40 |
#include "wsfaihelper.hrh"
|
|
41 |
#include "wsflogger.h"
|
|
42 |
|
|
43 |
|
|
44 |
// CONSTANTS
|
|
45 |
|
|
46 |
// property keys for AiHelper return
|
|
47 |
static const TUint KWsfAiHelperExitCodeKey = 0;
|
|
48 |
static const TUint KWsfAiHelperIapIdKey = 1;
|
|
49 |
|
|
50 |
|
|
51 |
// ---------------------------------------------------------------------------
|
|
52 |
// CWsfAiHelperAppUi::ConstructL
|
|
53 |
// ---------------------------------------------------------------------------
|
|
54 |
//
|
|
55 |
void CWsfAiHelperAppUi::ConstructL()
|
|
56 |
{
|
|
57 |
BaseConstructL( EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible );
|
|
58 |
|
|
59 |
iIdle = CIdle::NewL( CActive::EPriorityIdle );
|
|
60 |
|
|
61 |
// Create stub view for Wizard launching
|
|
62 |
CWsfAiHelperView* view = CWsfAiHelperView::NewLC( this );
|
|
63 |
AddViewL( view );
|
|
64 |
CleanupStack::Pop( view );
|
|
65 |
}
|
|
66 |
|
|
67 |
|
|
68 |
// ---------------------------------------------------------------------------
|
|
69 |
// CWsfAiHelperAppUi::CWsfAiHelperAppUi
|
|
70 |
// ---------------------------------------------------------------------------
|
|
71 |
//
|
|
72 |
CWsfAiHelperAppUi::CWsfAiHelperAppUi():
|
|
73 |
iResult( KErrCancel )
|
|
74 |
{
|
|
75 |
// no implementation required
|
|
76 |
}
|
|
77 |
|
|
78 |
|
|
79 |
// ---------------------------------------------------------------------------
|
|
80 |
// CWsfAiHelperAppUi::~CWsfAiHelperAppUi
|
|
81 |
// ---------------------------------------------------------------------------
|
|
82 |
//
|
|
83 |
CWsfAiHelperAppUi::~CWsfAiHelperAppUi()
|
|
84 |
{
|
|
85 |
delete iIdle;
|
|
86 |
}
|
|
87 |
|
|
88 |
|
|
89 |
// ---------------------------------------------------------------------------
|
|
90 |
// CWsfAiHelperAppUi::HandleCommandL
|
|
91 |
// ---------------------------------------------------------------------------
|
|
92 |
//
|
|
93 |
void CWsfAiHelperAppUi::HandleCommandL( TInt aCommand )
|
|
94 |
{
|
|
95 |
LOG_ENTERFN( "CWsfAiHelperAppUi::HandleCommandL" );
|
|
96 |
LOG_WRITEF( "command = %d", aCommand );
|
|
97 |
|
|
98 |
if ( iSuppressingKeyEvents )
|
|
99 |
{
|
|
100 |
return;
|
|
101 |
}
|
|
102 |
|
|
103 |
switch ( aCommand )
|
|
104 |
{
|
|
105 |
case EAknCmdExit:
|
|
106 |
case EEikCmdExit:
|
|
107 |
case EAknSoftkeyBack:
|
|
108 |
case EAknSoftkeyExit:
|
|
109 |
{
|
|
110 |
// set the "exit code" value
|
|
111 |
RProperty::Define( Application()->AppDllUid(),
|
|
112 |
KWsfAiHelperExitCodeKey,
|
|
113 |
RProperty::EInt );
|
|
114 |
|
|
115 |
TInt err = RProperty::Set( Application()->AppDllUid(),
|
|
116 |
KWsfAiHelperExitCodeKey,
|
|
117 |
iResult );
|
|
118 |
|
|
119 |
if ( err == KErrNone )
|
|
120 |
{
|
|
121 |
LOG_WRITEF( "exitcode property set to %d", iResult );
|
|
122 |
}
|
|
123 |
else
|
|
124 |
{
|
|
125 |
LOG_WRITEF( "exitcode property setting failed with code = %d",
|
|
126 |
err );
|
|
127 |
User::LeaveIfError( err );
|
|
128 |
}
|
|
129 |
|
|
130 |
Exit();
|
|
131 |
break;
|
|
132 |
}
|
|
133 |
|
|
134 |
default:;
|
|
135 |
}
|
|
136 |
}
|
|
137 |
|
|
138 |
|
|
139 |
// ---------------------------------------------------------------------------
|
|
140 |
// CWsfAiHelperAppUi::ProcessCommandParametersL
|
|
141 |
// ---------------------------------------------------------------------------
|
|
142 |
//
|
|
143 |
TBool CWsfAiHelperAppUi::ProcessCommandParametersL(
|
|
144 |
TApaCommand /*aCommand*/,
|
|
145 |
TFileName& /*aDocumentName*/,
|
|
146 |
const TDesC8& /*aTail*/ )
|
|
147 |
{
|
|
148 |
return EFalse;
|
|
149 |
}
|
|
150 |
|
|
151 |
|
|
152 |
// ---------------------------------------------------------------------------
|
|
153 |
// CWsfAiHelperAppUi::NotifyFileName
|
|
154 |
// ---------------------------------------------------------------------------
|
|
155 |
//
|
|
156 |
void CWsfAiHelperAppUi::NotifyFileName()
|
|
157 |
{
|
|
158 |
LOG_ENTERFN( "CWsfAiHelperAppUi::NotifyFileName" );
|
|
159 |
if ( !iIdle->IsActive() )
|
|
160 |
{
|
|
161 |
iIdle->Start( TCallBack( LaunchCompletedL, this ) );
|
|
162 |
}
|
|
163 |
}
|
|
164 |
|
|
165 |
|
|
166 |
// ---------------------------------------------------------------------------
|
|
167 |
// CWsfAiHelperAppUi::Doc
|
|
168 |
// ---------------------------------------------------------------------------
|
|
169 |
//
|
|
170 |
CWsfAiHelperDocument* CWsfAiHelperAppUi::Doc()
|
|
171 |
{
|
|
172 |
return static_cast<CWsfAiHelperDocument*>( iDocument );
|
|
173 |
}
|
|
174 |
|
|
175 |
|
|
176 |
// ---------------------------------------------------------------------------
|
|
177 |
// CWsfAiHelperAppUi::BrowserLaunchCompleteL
|
|
178 |
// ---------------------------------------------------------------------------
|
|
179 |
//
|
|
180 |
void CWsfAiHelperAppUi::BrowserLaunchCompleteL()
|
|
181 |
{
|
|
182 |
LOG_ENTERFN( "CWsfAiHelperAppUi::BrowserLaunchCompleteL" );
|
|
183 |
}
|
|
184 |
|
|
185 |
|
|
186 |
// ---------------------------------------------------------------------------
|
|
187 |
// CWsfAiHelperAppUi::BrowserExitL
|
|
188 |
// ---------------------------------------------------------------------------
|
|
189 |
//
|
|
190 |
void CWsfAiHelperAppUi::BrowserExitL()
|
|
191 |
{
|
|
192 |
LOG_ENTERFN( "CWsfAiHelperAppUi::BrowserExitL" );
|
|
193 |
HandleCommandL( EAknCmdExit );
|
|
194 |
}
|
|
195 |
|
|
196 |
|
|
197 |
// ---------------------------------------------------------------------------
|
|
198 |
// CWsfAiHelperAppUi::BrowserLaunchFailed
|
|
199 |
// ---------------------------------------------------------------------------
|
|
200 |
//
|
|
201 |
void CWsfAiHelperAppUi::BrowserLaunchFailed( TInt /*aError*/ )
|
|
202 |
{
|
|
203 |
LOG_ENTERFN( "CWsfAiHelperAppUi::BrowserLaunchFailed" );
|
|
204 |
TRAP_IGNORE( HandleCommandL( EAknCmdExit ) );
|
|
205 |
}
|
|
206 |
|
|
207 |
|
|
208 |
// ---------------------------------------------------------------------------
|
|
209 |
// CWsfAiHelperAppUi::ConnectingL
|
|
210 |
// ---------------------------------------------------------------------------
|
|
211 |
//
|
|
212 |
void CWsfAiHelperAppUi::ConnectingL( TUint32 /*aIapId*/ )
|
|
213 |
{
|
|
214 |
LOG_ENTERFN( "CWsfAiHelperAppUi::ConnectingL" );
|
|
215 |
Doc()->Model().SetConnecting( ETrue );
|
|
216 |
}
|
|
217 |
|
|
218 |
|
|
219 |
// ---------------------------------------------------------------------------
|
|
220 |
// CWsfAiHelperAppUi::ConnectingFinishedL
|
|
221 |
// ---------------------------------------------------------------------------
|
|
222 |
//
|
|
223 |
void CWsfAiHelperAppUi::ConnectingFinishedL( TInt aResult )
|
|
224 |
{
|
|
225 |
LOG_ENTERFN( "CWsfAiHelperAppUi::ConnectingFinishedL" );
|
|
226 |
if ( Doc()->Model().IsConnecting() )
|
|
227 |
{
|
|
228 |
Doc()->Model().SetConnecting( EFalse );
|
|
229 |
}
|
|
230 |
|
|
231 |
if ( aResult )
|
|
232 |
{
|
|
233 |
// show an error note
|
|
234 |
LOG_WRITE( "showing error note" );
|
|
235 |
CErrorUI* errorUi = CErrorUI::NewLC( *iCoeEnv );
|
|
236 |
errorUi->ShowGlobalErrorNoteL( aResult );
|
|
237 |
CleanupStack::PopAndDestroy( errorUi );
|
|
238 |
}
|
|
239 |
}
|
|
240 |
|
|
241 |
|
|
242 |
// ---------------------------------------------------------------------------
|
|
243 |
// CWsfAiHelperAppUi::SendHelperToBackground
|
|
244 |
// ---------------------------------------------------------------------------
|
|
245 |
//
|
|
246 |
void CWsfAiHelperAppUi::SendHelperToBackground()
|
|
247 |
{
|
|
248 |
LOG_ENTERFN( "CWsfAiHelperAppUi::SendHelperToBackground" );
|
|
249 |
TApaTask task( iEikonEnv->WsSession() );
|
|
250 |
task.SetWgId( iEikonEnv->RootWin().Identifier());
|
|
251 |
task.SendToBackground();
|
|
252 |
}
|
|
253 |
|
|
254 |
|
|
255 |
// ---------------------------------------------------------------------------
|
|
256 |
// CWsfAiHelperAppUi::LaunchCompletedL
|
|
257 |
// ---------------------------------------------------------------------------
|
|
258 |
//
|
|
259 |
TInt CWsfAiHelperAppUi::LaunchCompletedL( TAny* aObject )
|
|
260 |
{
|
|
261 |
LOG_ENTERFN( "CWsfAiHelperAppUi::LaunchCompletedL" );
|
|
262 |
User::LeaveIfNull( aObject );
|
|
263 |
CWsfAiHelperAppUi* appUi = static_cast<CWsfAiHelperAppUi*>( aObject );
|
|
264 |
|
|
265 |
MWsfModelObserver* observer = static_cast<MWsfModelObserver*>( appUi );
|
|
266 |
CWsfModel& model( appUi->Doc()->Model() );
|
|
267 |
|
|
268 |
model.SetEngineObserver( observer );
|
|
269 |
|
|
270 |
TWsfWlanInfo* info( &appUi->Doc()->WlanInfo() );
|
|
271 |
|
|
272 |
if ( !info->Connected() )
|
|
273 |
{
|
|
274 |
// make sure we don't suppress our key events forever
|
|
275 |
CleanupStack::PushL( TCleanupItem( ReleaseSuppressingKeyEventsL, appUi ) );
|
|
276 |
// No appUi key input accepted during IAP connecting & connection test.
|
|
277 |
appUi->iSuppressingKeyEvents = ETrue;
|
|
278 |
|
|
279 |
TBool setIapProperty = EFalse;
|
|
280 |
|
|
281 |
if ( !info->Known() )
|
|
282 |
{
|
|
283 |
TBool accessPointCreated = EFalse;
|
|
284 |
|
|
285 |
// If not known yet, create an IAP.
|
|
286 |
TRAPD( accessPointCreatedError,
|
|
287 |
accessPointCreated = model.CreateAccessPointL( *info,
|
|
288 |
EFalse ) );
|
|
289 |
|
|
290 |
// notify user that Disk is full or creation of a WAPI IAP
|
|
291 |
// is not supported on-the-fly and leave
|
|
292 |
if ( accessPointCreatedError == KErrDiskFull ||
|
|
293 |
accessPointCreatedError == KErrWlanProtectedSetupSetupLocked )
|
|
294 |
{
|
|
295 |
appUi->ConnectingFinishedL(accessPointCreatedError);
|
|
296 |
User::Leave(accessPointCreatedError);
|
|
297 |
}
|
|
298 |
// just leave because we failed to create accesspoint
|
|
299 |
else if ( accessPointCreatedError != KErrNone )
|
|
300 |
{
|
|
301 |
User::Leave(accessPointCreatedError);
|
|
302 |
}
|
|
303 |
|
|
304 |
appUi->SendHelperToBackground();
|
|
305 |
|
|
306 |
if ( accessPointCreated )
|
|
307 |
{
|
|
308 |
setIapProperty = ETrue;
|
|
309 |
}
|
|
310 |
}
|
|
311 |
else
|
|
312 |
{
|
|
313 |
setIapProperty = ETrue;
|
|
314 |
appUi->iResult = KErrNone;
|
|
315 |
}
|
|
316 |
|
|
317 |
if ( setIapProperty )
|
|
318 |
{
|
|
319 |
LOG_WRITE( "Set iap Property" );
|
|
320 |
// Connected succesfully set IAP's property.
|
|
321 |
CWsfAiHelperApplication* app =
|
|
322 |
static_cast<CWsfAiHelperApplication*>(
|
|
323 |
appUi->Application() );
|
|
324 |
|
|
325 |
RProperty::Define( app->AppDllUid(),
|
|
326 |
KWsfAiHelperIapIdKey,
|
|
327 |
RProperty::EInt );
|
|
328 |
|
|
329 |
TInt err = RProperty::Set( app->AppDllUid(),
|
|
330 |
KWsfAiHelperIapIdKey,
|
|
331 |
info->iIapId );
|
|
332 |
|
|
333 |
if ( err == KErrNone )
|
|
334 |
{
|
|
335 |
LOG_WRITEF( "IAP id property "
|
|
336 |
L"set to %d", info->iIapId );
|
|
337 |
}
|
|
338 |
else
|
|
339 |
{
|
|
340 |
LOG_WRITEF( "IAP id property setting failed "
|
|
341 |
L"with code = %d", err );
|
|
342 |
User::LeaveIfError( err );
|
|
343 |
}
|
|
344 |
appUi->iResult = KErrNone;
|
|
345 |
}
|
|
346 |
// pop cleanup item ReleaseSuppressingKeyEvents
|
|
347 |
CleanupStack::Pop();
|
|
348 |
appUi->iSuppressingKeyEvents = EFalse;
|
|
349 |
}
|
|
350 |
|
|
351 |
appUi->HandleCommandL( EAknCmdExit );
|
|
352 |
|
|
353 |
return 0; // Return false (zero) value not be called again.
|
|
354 |
}
|
|
355 |
|
|
356 |
|
|
357 |
// ---------------------------------------------------------------------------
|
|
358 |
// CWsfAiHelperAppUi::WlanListChangedL
|
|
359 |
// ---------------------------------------------------------------------------
|
|
360 |
//
|
|
361 |
void CWsfAiHelperAppUi::WlanListChangedL()
|
|
362 |
{
|
|
363 |
// no implementation required
|
|
364 |
}
|
|
365 |
|
|
366 |
|
|
367 |
// ---------------------------------------------------------------------------
|
|
368 |
// CWsfAiHelperAppUi::NotifyEngineError
|
|
369 |
// ---------------------------------------------------------------------------
|
|
370 |
//
|
|
371 |
void CWsfAiHelperAppUi::NotifyEngineError( TInt /*aError*/ )
|
|
372 |
{
|
|
373 |
// no implementation required
|
|
374 |
}
|
|
375 |
|
|
376 |
|
|
377 |
// ---------------------------------------------------------------------------
|
|
378 |
// CWsfAiHelperAppUi::ScanDisabledL
|
|
379 |
// ---------------------------------------------------------------------------
|
|
380 |
//
|
|
381 |
void CWsfAiHelperAppUi::ScanDisabledL()
|
|
382 |
{
|
|
383 |
// no implementation required
|
|
384 |
}
|
|
385 |
|
|
386 |
|
|
387 |
// ---------------------------------------------------------------------------
|
|
388 |
// CWsfAiHelperAppUi::ScanEnabledL
|
|
389 |
// ---------------------------------------------------------------------------
|
|
390 |
//
|
|
391 |
void CWsfAiHelperAppUi::ScanEnabledL()
|
|
392 |
{
|
|
393 |
// no implementation required
|
|
394 |
}
|
|
395 |
|
|
396 |
|
|
397 |
// ---------------------------------------------------------------------------
|
|
398 |
// CWsfAiHelperAppUi::WlanConnectionActivatedL
|
|
399 |
// ---------------------------------------------------------------------------
|
|
400 |
//
|
|
401 |
void CWsfAiHelperAppUi::WlanConnectionActivatedL()
|
|
402 |
{
|
|
403 |
// no implementation required
|
|
404 |
}
|
|
405 |
|
|
406 |
|
|
407 |
// ---------------------------------------------------------------------------
|
|
408 |
// CWsfAiHelperAppUi::WlanConnectionClosedL
|
|
409 |
// ---------------------------------------------------------------------------
|
|
410 |
//
|
|
411 |
void CWsfAiHelperAppUi::WlanConnectionClosedL()
|
|
412 |
{
|
|
413 |
// no implementation required
|
|
414 |
}
|
|
415 |
|
|
416 |
|
|
417 |
// ---------------------------------------------------------------------------
|
|
418 |
// CWsfAiHelperAppUi::ConnectingFinishedL
|
|
419 |
// ---------------------------------------------------------------------------
|
|
420 |
//
|
|
421 |
void CWsfAiHelperAppUi::ConnectionCreationProcessFinishedL( TInt /*aResult*/ )
|
|
422 |
{
|
|
423 |
// no implementation required
|
|
424 |
}
|
|
425 |
|
|
426 |
|
|
427 |
// ---------------------------------------------------------------------------
|
|
428 |
// CWsfAiHelperAppUi::ReleaseSuppressingKeyEventsL
|
|
429 |
// ---------------------------------------------------------------------------
|
|
430 |
//
|
|
431 |
void CWsfAiHelperAppUi::ReleaseSuppressingKeyEventsL( TAny* aPtr )
|
|
432 |
{
|
|
433 |
CWsfAiHelperAppUi* self =
|
|
434 |
static_cast<CWsfAiHelperAppUi*>( aPtr );
|
|
435 |
self->iSuppressingKeyEvents = EFalse;
|
|
436 |
self->HandleCommandL( EAknCmdExit );
|
|
437 |
}
|
|
438 |
|
|
439 |
|