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 CWsfLaunchAiHelperActiveWrapper. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "wsflogger.h" |
|
21 #include "wsfmodel.h" |
|
22 #include "wsfaicontroller.h" |
|
23 #include "wsflaunchaihelperactivewrapper.h" |
|
24 |
|
25 // Category UID of AiHelper property |
|
26 static const TUid KWsfAiHelperCategoryUid = { 0x10281CEB }; |
|
27 |
|
28 // key numbers within the property |
|
29 static const TUint KWsfAiHelperExitCodeKey = 0; |
|
30 static const TUint KWsfAiHelperIapIdKey = 1; |
|
31 |
|
32 /** |
|
33 * Delay that we wait for the aihelper to terminate |
|
34 */ |
|
35 static const TInt KTimerTickInterval = 1 * 1000 * 1000; |
|
36 |
|
37 |
|
38 // ---------------------------------------------------------------------------- |
|
39 // CWsfLaunchAiHelperActiveWrapper::CWsfLaunchAiHelperActiveWrapper |
|
40 // ---------------------------------------------------------------------------- |
|
41 // |
|
42 CWsfLaunchAiHelperActiveWrapper::CWsfLaunchAiHelperActiveWrapper() : |
|
43 CActive( EPriorityStandard ) // Standard priority |
|
44 { |
|
45 } |
|
46 |
|
47 |
|
48 // ---------------------------------------------------------------------------- |
|
49 // CWsfLaunchAiHelperActiveWrapper::NewLC |
|
50 // ---------------------------------------------------------------------------- |
|
51 // |
|
52 CWsfLaunchAiHelperActiveWrapper* CWsfLaunchAiHelperActiveWrapper::NewLC( |
|
53 CWsfModel* aModel, TWsfAiController &aController ) |
|
54 { |
|
55 LOG_ENTERFN( "CWsfLaunchAiHelperActiveWrapper::NewLC" ); |
|
56 CWsfLaunchAiHelperActiveWrapper* self = |
|
57 new (ELeave) CWsfLaunchAiHelperActiveWrapper(); |
|
58 CleanupStack::PushL( self ); |
|
59 self->ConstructL( aModel, aController ); |
|
60 return self; |
|
61 } |
|
62 |
|
63 |
|
64 // ---------------------------------------------------------------------------- |
|
65 // CWsfLaunchAiHelperActiveWrapper::NewL |
|
66 // ---------------------------------------------------------------------------- |
|
67 // |
|
68 CWsfLaunchAiHelperActiveWrapper* CWsfLaunchAiHelperActiveWrapper::NewL( |
|
69 CWsfModel* aModel, TWsfAiController &aController ) |
|
70 { |
|
71 LOG_ENTERFN( "CWsfLaunchAiHelperActiveWrapper::NewL" ); |
|
72 CWsfLaunchAiHelperActiveWrapper* self = |
|
73 CWsfLaunchAiHelperActiveWrapper::NewLC( aModel, aController ); |
|
74 CleanupStack::Pop(); // self; |
|
75 return self; |
|
76 } |
|
77 |
|
78 |
|
79 // ---------------------------------------------------------------------------- |
|
80 // CWsfLaunchAiHelperActiveWrapper::ConstructL |
|
81 // ---------------------------------------------------------------------------- |
|
82 // |
|
83 void CWsfLaunchAiHelperActiveWrapper::ConstructL( CWsfModel* aModel, |
|
84 TWsfAiController &aController ) |
|
85 { |
|
86 LOG_ENTERFN( "CWsfLaunchAiHelperActiveWrapper::ConstructL" ); |
|
87 CActiveScheduler::Add( this ); // Add to scheduler |
|
88 iModel = aModel; |
|
89 iController = &aController; |
|
90 User::LeaveIfError( iTimer.CreateLocal() ); |
|
91 User::LeaveIfError( iAiHelperAppExitCode.Attach( KWsfAiHelperCategoryUid, |
|
92 KWsfAiHelperExitCodeKey ) ); |
|
93 |
|
94 User::LeaveIfError( iAiHelperAppIapId.Attach( KWsfAiHelperCategoryUid, |
|
95 KWsfAiHelperIapIdKey ) ); |
|
96 } |
|
97 |
|
98 // ---------------------------------------------------------------------------- |
|
99 // CWsfLaunchAiHelperActiveWrapper::~CWsfLaunchAiHelperActiveWrapper |
|
100 // ---------------------------------------------------------------------------- |
|
101 // |
|
102 CWsfLaunchAiHelperActiveWrapper::~CWsfLaunchAiHelperActiveWrapper() |
|
103 { |
|
104 LOG_ENTERFN( |
|
105 "CWsfLaunchAiHelperActiveWrapper::~CWsfWLANListActiveWrapper" ); |
|
106 Cancel(); // Cancel any request, if outstanding |
|
107 // Delete instance variables if any |
|
108 iAiHelperAppExitCode.Close(); |
|
109 iAiHelperAppIapId.Close(); |
|
110 iTimer.Close(); |
|
111 } |
|
112 |
|
113 // ---------------------------------------------------------------------------- |
|
114 // CWsfLaunchAiHelperActiveWrapper::DoCancel |
|
115 // ---------------------------------------------------------------------------- |
|
116 // |
|
117 void CWsfLaunchAiHelperActiveWrapper::DoCancel() |
|
118 { |
|
119 iAiHelperAppExitCode.Cancel(); |
|
120 iAiHelperAppIapId.Cancel(); |
|
121 iTimer.Cancel(); |
|
122 iStoppingHelper = iModel->CloseHelperApplication(); |
|
123 } |
|
124 |
|
125 // ---------------------------------------------------------------------------- |
|
126 // CWsfLaunchAiHelperActiveWrapper::Start |
|
127 // ---------------------------------------------------------------------------- |
|
128 // |
|
129 void CWsfLaunchAiHelperActiveWrapper::Start( TWsfWlanInfo& aInfo, |
|
130 TBool aConnectOnly, |
|
131 TBool aTestAccessPoint ) |
|
132 { |
|
133 LOG_ENTERFN( "CWsfLaunchAiHelperActiveWrapper::Start" ); |
|
134 iStoppingHelper = EFalse; |
|
135 Cancel(); // Cancel any request, just to be sure |
|
136 iState = EUninitialized; |
|
137 iUsedInfo = aInfo; |
|
138 iConnectOnly = aConnectOnly; |
|
139 iTestAccessPoint = aTestAccessPoint; |
|
140 |
|
141 if ( iStoppingHelper ) |
|
142 { |
|
143 LOG_WRITE( "Helper was stopped - wait for a while" ); |
|
144 iTimer.Cancel(); |
|
145 iTimer.After( iStatus, KTimerTickInterval ); |
|
146 } |
|
147 else |
|
148 { |
|
149 LOG_WRITE( "Helper was not alive" ); |
|
150 TRequestStatus* status = &iStatus; |
|
151 User::RequestComplete(status, KErrNone); |
|
152 } |
|
153 SetActive(); |
|
154 } |
|
155 |
|
156 // ---------------------------------------------------------------------------- |
|
157 // CWsfLaunchAiHelperActiveWrapper::RunL |
|
158 // ---------------------------------------------------------------------------- |
|
159 // |
|
160 void CWsfLaunchAiHelperActiveWrapper::RunL() |
|
161 { |
|
162 LOG_ENTERFN( "CWsfLaunchAiHelperActiveWrapper::RunL" ); |
|
163 if ( iStatus == KErrNone ) |
|
164 { |
|
165 if ( iState == EUninitialized ) |
|
166 { |
|
167 LOG_WRITE( "Start launching ai helper" ); |
|
168 // register for notification |
|
169 iAiHelperAppExitCode.Subscribe( iStatus ); |
|
170 iModel->LaunchHelperApplicationL( iUsedInfo ); |
|
171 iState = EInitialized; |
|
172 SetActive(); // Tell scheduler a request is active |
|
173 } |
|
174 else if (iState == EInitialized) |
|
175 { |
|
176 TInt exitCode( KErrNone ); |
|
177 iAiHelperAppExitCode.Get( exitCode ); |
|
178 |
|
179 LOG_WRITEF( "AiHelper returned %d", exitCode ); |
|
180 |
|
181 if ( exitCode == KErrNone ) |
|
182 { |
|
183 TInt iapId(0); |
|
184 iAiHelperAppIapId.Get( iapId ); |
|
185 iUsedInfo.iIapId = TUint32( iapId ); |
|
186 LOG_WRITEF( "AiHelper iap id = %d", iapId ); |
|
187 if ( iUsedInfo.iIapId ) |
|
188 { |
|
189 LOG_WRITE( "Iap id exist - connect" ); |
|
190 iController->ConnectL( iUsedInfo, iConnectOnly, |
|
191 iTestAccessPoint ); |
|
192 } |
|
193 else |
|
194 { |
|
195 LOG_WRITE( "No iap id from ai helper" ); |
|
196 } |
|
197 } |
|
198 else |
|
199 { |
|
200 User::Leave(exitCode); |
|
201 } |
|
202 } |
|
203 else |
|
204 { |
|
205 LOG_WRITEF( "iState = %d", iState ); |
|
206 } |
|
207 } |
|
208 else |
|
209 { |
|
210 LOG_WRITEF( "CWsfLaunchAiHelperActiveWrapper iStatus = %d", |
|
211 iStatus.Int() ); |
|
212 } |
|
213 } |
|
214 |
|
215 // ---------------------------------------------------------------------------- |
|
216 // CWsfLaunchAiHelperActiveWrapper::RunError |
|
217 // ---------------------------------------------------------------------------- |
|
218 // |
|
219 #ifdef _DEBUG |
|
220 TInt CWsfLaunchAiHelperActiveWrapper::RunError( TInt aError ) |
|
221 { |
|
222 LOG_ENTERFN( "CWsfLaunchAiHelperActiveWrapper::RunError" ); |
|
223 LOG_WRITEF( "aError = %d", aError ); |
|
224 #else |
|
225 TInt CWsfLaunchAiHelperActiveWrapper::RunError( TInt /*aError*/ ) |
|
226 { |
|
227 #endif |
|
228 return KErrNone; |
|
229 } |
|
230 |
|