|
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: Implements CAcpQueryView methods |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <eikenv.h> |
|
20 #include <aknlists.h> |
|
21 #include <akntitle.h> |
|
22 #include <aknviewappui.h> |
|
23 #include <stringloader.h> |
|
24 #include <accountcreationplugin.rsg> |
|
25 #include <BrowserUiSDKCRKeys.h> |
|
26 #include <apgcli.h> |
|
27 #include <apgtask.h> |
|
28 #include <centralrepository.h> |
|
29 |
|
30 #include "acpcontroller.h" |
|
31 #include "acpqueryview.h" |
|
32 #include "acpdialog.h" |
|
33 #include "acpquerycontainer.h" |
|
34 #include "acpproviderlistview.h" |
|
35 #include "accountcreationpluginlogger.h" |
|
36 |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // CAcpQueryView::CAcpQueryView |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 CAcpQueryView::CAcpQueryView( CAcpController& aController ) |
|
43 : iController( aController ) |
|
44 { |
|
45 } |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // CAcpQueryView::ConstructL |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 void CAcpQueryView::ConstructL() |
|
52 { |
|
53 ACPLOG( "CAcpQueryView::ConstructL begin" ); |
|
54 |
|
55 iEikEnv = CEikonEnv::Static(); |
|
56 iUi = static_cast<CAknViewAppUi*> ( static_cast<CAknAppUi*> |
|
57 ( iEikEnv->EikAppUi() ) ); |
|
58 |
|
59 BaseConstructL( R_ACP_QUERY_VIEW ); |
|
60 |
|
61 iDialog = CAcpDialog::NewL( *this ); |
|
62 |
|
63 ACPLOG( "CAcpQueryView::ConstructL end" ); |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // CAcpQueryView::NewL |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 CAcpQueryView* CAcpQueryView::NewL( CAcpController& aController ) |
|
71 { |
|
72 CAcpQueryView* self = CAcpQueryView::NewLC( aController ); |
|
73 CleanupStack::Pop( self ); |
|
74 return self; |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // CAcpQueryView::NewLC |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 CAcpQueryView* CAcpQueryView::NewLC( CAcpController& aController ) |
|
82 { |
|
83 CAcpQueryView* self = new ( ELeave ) CAcpQueryView( aController ); |
|
84 CleanupStack::PushL( self ); |
|
85 self->ConstructL(); |
|
86 return self; |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // CAcpQueryView::~CAcpQueryView |
|
91 // --------------------------------------------------------------------------- |
|
92 // |
|
93 CAcpQueryView::~CAcpQueryView() |
|
94 { |
|
95 ACPLOG( "CAcpQueryView::~CAcpQueryView begin" ); |
|
96 |
|
97 // Delete container when view is deactivated. |
|
98 if ( iContainer && iUi ) |
|
99 { |
|
100 iUi->RemoveFromViewStack( *this, iContainer ); |
|
101 delete iContainer; |
|
102 } |
|
103 |
|
104 delete iDialog; |
|
105 |
|
106 iEikEnv = NULL; |
|
107 |
|
108 ACPLOG( "CAcpQueryView::~CAcpQueryView end" ); |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------------------------- |
|
112 // CAcpQueryView::SetTitlePaneTextL |
|
113 // For changing text to the title pane. |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 void CAcpQueryView::SetTitlePaneTextL( const TDesC& aText ) const |
|
117 { |
|
118 // Get handle to title pane. |
|
119 CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane(); |
|
120 if ( statusPane ) |
|
121 { |
|
122 CAknTitlePane* titlePane = |
|
123 static_cast<CAknTitlePane*> ( statusPane->ControlL( |
|
124 TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
125 if ( titlePane ) |
|
126 { |
|
127 titlePane->SetTextL( aText ); // Set text. |
|
128 } |
|
129 } |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 // CAcpQueryView::Id |
|
134 // From CAknView. |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 TUid CAcpQueryView::Id() const |
|
138 { |
|
139 return KQueryViewId; |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // CAcpQueryView::HandleCommandL |
|
144 // From CEikAppUi. |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 void CAcpQueryView::HandleCommandL( TInt aCommand ) |
|
148 { |
|
149 ACPLOG2( "CAcpQueryView::HandleCommandL: cmd=%d", aCommand ); |
|
150 |
|
151 switch ( aCommand ) |
|
152 { |
|
153 case EAknSoftkeyOk: |
|
154 { |
|
155 TInt index; // Indicates which provider to be activated |
|
156 |
|
157 TBuf<KSipUsername> username; // SIP username. |
|
158 TBuf<KSipPassword> password; // SIP password. |
|
159 // URL for activating current provider. |
|
160 TBuf8<KMaxUrlLength> activationUrl; |
|
161 |
|
162 // Get current provider. |
|
163 index = iController.ActiveIndex(); |
|
164 |
|
165 // Get username and password. |
|
166 iContainer->GetContainerDataL( username, password ); |
|
167 |
|
168 // Get activation URL. |
|
169 activationUrl.Copy( |
|
170 iController.ProviderActivationUrlFromIndexL( index ) ); |
|
171 |
|
172 // Set username. |
|
173 activationUrl.Append( KAmperSand ); |
|
174 activationUrl.Append( KUsername ); |
|
175 activationUrl.Append( KPlacing ); |
|
176 activationUrl.Append( username ); |
|
177 |
|
178 // Set password. |
|
179 activationUrl.Append( KAmperSand ); |
|
180 activationUrl.Append( KPassword ); |
|
181 activationUrl.Append( KPlacing ); |
|
182 activationUrl.Append( password ); |
|
183 |
|
184 ACPLOG( "Launching browser"); |
|
185 |
|
186 // Instantiate the repository for disabling |
|
187 // all security warnings and data saving form of the browser. |
|
188 // Remember to restore the settings later on!! |
|
189 CRepository* brRepository = CRepository::NewLC( KCRUidBrowser ); |
|
190 |
|
191 // Get original security warning setting. |
|
192 brRepository->Get( KBrowserNGShowSecurityWarnings, iWarning ); |
|
193 |
|
194 // Get original data saving form setting. |
|
195 brRepository->Get( KBrowserFormDataSaving, iDataSaving ); |
|
196 |
|
197 // Set security warning off. |
|
198 brRepository->Set( KBrowserNGShowSecurityWarnings, 0 ); |
|
199 |
|
200 // Set data saving form off. |
|
201 brRepository->Set( KBrowserFormDataSaving, 0 ); |
|
202 |
|
203 // Creates the application architecture server instance for |
|
204 // getting new browser session. |
|
205 // Remember to close the session before going out of scope. |
|
206 RApaLsSession apaLsSession; |
|
207 CleanupClosePushL( apaLsSession ); |
|
208 |
|
209 // Get current application list. |
|
210 TApaTaskList taskList( iEikEnv->WsSession() ); |
|
211 |
|
212 // Get the browser session. |
|
213 TApaTask browserTask = taskList.FindApp( KCRUidBrowser ); |
|
214 |
|
215 // Checks whether browser session exist or not. |
|
216 if ( browserTask.Exists() ) |
|
217 { |
|
218 // Brings the session to the foreground. |
|
219 browserTask.BringToForeground(); |
|
220 // Get new buffer for sending the |
|
221 // activation request to server. |
|
222 HBufC8* param8 = HBufC8::NewLC( activationUrl.Length() ); |
|
223 // Copy the activation URL. |
|
224 param8->Des().Append( activationUrl ); |
|
225 // Try to activate provider earlier selected |
|
226 // by using the browser session. |
|
227 // UID not used. |
|
228 browserTask.SendMessage( TUid::Uid(0), *param8 ); |
|
229 // Destroy the activation buffer. |
|
230 CleanupStack::PopAndDestroy( param8 ); |
|
231 } |
|
232 else |
|
233 { |
|
234 // Browser instance does not exist but instance is needed |
|
235 // for activating provider via OTA. |
|
236 // Next connecting to the application architecture server |
|
237 // and try to start a new browser instance with the |
|
238 // activation address. |
|
239 |
|
240 TBuf<KMaxUrlLength> activationUrl16; // The activation URL. |
|
241 activationUrl16.Copy( activationUrl ); |
|
242 |
|
243 TThreadId threadId; // Browser instance's thread. |
|
244 |
|
245 // Check whether a handle number exist for the server. |
|
246 if ( !apaLsSession.Handle() ) |
|
247 { |
|
248 // Connect to the server |
|
249 User::LeaveIfError( apaLsSession.Connect() ); |
|
250 } |
|
251 |
|
252 // Launch browser and send the activation request to the server. |
|
253 User::LeaveIfError( |
|
254 apaLsSession.StartDocument( activationUrl16, |
|
255 KCRUidBrowser, threadId )); |
|
256 } |
|
257 |
|
258 CleanupStack::PopAndDestroy( &apaLsSession ); |
|
259 |
|
260 // Activate provider list view. |
|
261 iUi->ActivateLocalViewL( KProviderListViewId ); |
|
262 } |
|
263 break; |
|
264 case EAknSoftkeySelect: |
|
265 { |
|
266 // Provisioning started. |
|
267 HandleListBoxSelectionL(); |
|
268 } |
|
269 break; |
|
270 case EAknSoftkeyCancel: |
|
271 // Going back to the provider list view. |
|
272 iUi->ActivateLocalViewL( KProviderListViewId ); |
|
273 break; |
|
274 case EEikCmdExit: |
|
275 case EAknSoftkeyExit: |
|
276 { |
|
277 // Creates a repository to restore the settings earlier |
|
278 // configured for browser. |
|
279 CRepository* repository = CRepository::NewLC( KCRUidBrowser ); |
|
280 // Restore the security warnings. |
|
281 repository->Set( KBrowserNGShowSecurityWarnings, iWarning ); |
|
282 // Restore the data saving form. |
|
283 repository->Set( KBrowserFormDataSaving, iDataSaving ); |
|
284 // Destroys the repository. |
|
285 CleanupStack::PopAndDestroy( repository ); |
|
286 // Exit the application. |
|
287 iUi->HandleCommandL( aCommand ); |
|
288 } |
|
289 break; |
|
290 default: |
|
291 break; |
|
292 } |
|
293 } |
|
294 |
|
295 // --------------------------------------------------------------------------- |
|
296 // CAcpQueryView::HandleListBoxEventL |
|
297 // From MEikListBoxObserver. |
|
298 // --------------------------------------------------------------------------- |
|
299 // |
|
300 void CAcpQueryView::HandleListBoxEventL( CEikListBox* /*aListBox*/, |
|
301 TListBoxEvent aEventType ) |
|
302 { |
|
303 switch ( aEventType ) |
|
304 { |
|
305 case EEventEnterKeyPressed: |
|
306 case EEventItemDoubleClicked: |
|
307 HandleListBoxSelectionL(); |
|
308 break; |
|
309 default: |
|
310 break; |
|
311 } |
|
312 } |
|
313 |
|
314 // --------------------------------------------------------------------------- |
|
315 // CAcpQueryView::HandleListBoxSelectionL |
|
316 // From MEikListBoxObserver. |
|
317 // --------------------------------------------------------------------------- |
|
318 // |
|
319 void CAcpQueryView::HandleListBoxSelectionL() |
|
320 { |
|
321 ACPLOG2( "CAcpQueryView::HandleListBoxSelectionL: %d", |
|
322 iContainer->CurrentItemIndex() ); |
|
323 |
|
324 switch ( iContainer->CurrentItemIndex() ) |
|
325 { |
|
326 // Setting page item: Server username |
|
327 case EAcpGenericUsername: |
|
328 iContainer->ShowUsernameSettingPageL(); |
|
329 break; |
|
330 // Setting page item: Server password |
|
331 case EAcpGenericPassword: |
|
332 iContainer->ShowPwordSettingPageL(); |
|
333 break; |
|
334 default: |
|
335 break; |
|
336 } |
|
337 } |
|
338 |
|
339 // --------------------------------------------------------------------------- |
|
340 // CAcpProviderSpecificView::DynInitMenuPaneL |
|
341 // From MEikListBoxObserver. |
|
342 // --------------------------------------------------------------------------- |
|
343 // |
|
344 void CAcpQueryView::DynInitMenuPaneL( |
|
345 TInt /*aResourceId*/, CEikMenuPane* /*aMenuPane*/ ) |
|
346 { |
|
347 ACPLOG( "CAcpQueryView::DynInitMenuPaneL begin" ); |
|
348 ACPLOG( "CAcpQueryView::DynInitMenuPaneL end" ); |
|
349 } |
|
350 |
|
351 // --------------------------------------------------------------------------- |
|
352 // CAcpProviderListView::DialogDismissed |
|
353 // From MAcpDialogObserver. |
|
354 // --------------------------------------------------------------------------- |
|
355 // |
|
356 void CAcpQueryView::DialogDismissed( TInt /*aError*/ ) |
|
357 { |
|
358 iDialog->DestroyWaitNote(); |
|
359 } |
|
360 |
|
361 // --------------------------------------------------------------------------- |
|
362 // CAcpQueryView::DoActivateL |
|
363 // From CAknView. |
|
364 // --------------------------------------------------------------------------- |
|
365 // |
|
366 void CAcpQueryView::DoActivateL( |
|
367 const TVwsViewId& /*aPrevViewId*/, |
|
368 TUid /*aCustomMessageId*/, |
|
369 const TDesC8& /*aCustomMessage*/ ) |
|
370 { |
|
371 ACPLOG( "CAcpQueryView::DoActivateL begin" ); |
|
372 |
|
373 // Create container when view is activated. |
|
374 if ( !iContainer ) |
|
375 { |
|
376 iContainer = CAcpQueryContainer::NewL( ClientRect() ); |
|
377 iContainer->SetMopParent( this ); |
|
378 iUi->AddToStackL( *this, iContainer ); |
|
379 iContainer->ListBox()->SetListBoxObserver( this ); |
|
380 } |
|
381 |
|
382 // Set provider specific name to title pane. |
|
383 TInt index = iController.ActiveIndex(); |
|
384 TBuf<KAcpTitlePaneTextLength> name = |
|
385 iController.ProviderNameFromIndexL( index ); |
|
386 |
|
387 HBufC* caption = StringLoader::LoadLC( R_ACP_QUERY_TITLE_PANE_TEXT ); |
|
388 name.Append( caption->Des() ); |
|
389 |
|
390 SetTitlePaneTextL( name ); |
|
391 |
|
392 ACPLOG( "set title pane" ); |
|
393 |
|
394 CleanupStack::PopAndDestroy( caption ); |
|
395 |
|
396 ACPLOG( "CAcpQueryView::DoActivateL end" ); |
|
397 } |
|
398 |
|
399 // --------------------------------------------------------------------------- |
|
400 // CAcpQueryView::DoDeactivate() |
|
401 // From CAknView. |
|
402 // --------------------------------------------------------------------------- |
|
403 // |
|
404 void CAcpQueryView::DoDeactivate() |
|
405 { |
|
406 ACPLOG( "CAcpQueryView::DoDeactivate begin" ); |
|
407 |
|
408 // Delete container when view is deactivated. |
|
409 if ( iContainer ) |
|
410 { |
|
411 iUi->RemoveFromViewStack( *this, iContainer ); |
|
412 delete iContainer; |
|
413 iContainer = NULL; |
|
414 } |
|
415 |
|
416 ACPLOG( "CAcpQueryView::DoDeactivate end" ); |
|
417 } |
|
418 |
|
419 // End of file. |