|
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 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: HG VOD list base class implementation* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 #include <ganes/HgScroller.h> |
|
20 #include <aknnotewrappers.h> |
|
21 #include <browserlauncher.h> |
|
22 #include <browseroverriddensettings.h> |
|
23 #include "CIptvUtil.h" |
|
24 #include <uriutils.h> |
|
25 #include <StringLoader.h> |
|
26 #include "vcxnsuiengine.h" |
|
27 #include <vcxhgvodui.rsg> |
|
28 #include <akntitle.h> |
|
29 #include <aknViewAppUi.h> |
|
30 |
|
31 #include "vcxhgvodlistimplbase.h" |
|
32 #include "vcxhgvodmainview.h" |
|
33 #include "vcxhgvodutils.h" |
|
34 #include "vcxhgvodinformationpopup.h" |
|
35 #include "vcxhgvodsearchimpl.h" |
|
36 #include "vcxnsserviceproviderif.h" |
|
37 |
|
38 /* Parameter for embedded browser launch */ |
|
39 _LIT(KUrlLaunchParameter, "4 "); |
|
40 /* comment constant */ |
|
41 const TInt KThumbnailDownloadTextNumberCount( 2 ); |
|
42 |
|
43 const TInt KVcxMskPosition = 3; |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // CVcxHgVodListImplBase::CVcxHgVodListImplBase() |
|
47 // Constructor |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 CVcxHgVodListImplBase::CVcxHgVodListImplBase( |
|
51 CVcxHgVodMainView& aView, |
|
52 CVcxNsUiEngine& aModel, |
|
53 CHgScroller& aScroller ) |
|
54 : iView ( aView ), |
|
55 iModel ( aModel ), |
|
56 iScroller ( aScroller ) |
|
57 { |
|
58 iScroller.SetFlags( CHgScroller::EHgScrollerKeyMarkingDisabled ); |
|
59 iScroller.SetMopParent( &aView ); |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // CVcxHgVodListImplBase::~CVcxHgVodListImplBase() |
|
64 // Destructor |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 CVcxHgVodListImplBase::~CVcxHgVodListImplBase() |
|
68 { |
|
69 delete iInformationPopup; |
|
70 delete iLauncher; |
|
71 delete iSearchImpl; |
|
72 iView.AppUi()->RemoveFromStack( &iScroller ); |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // Open browser in embedded mode with specified uri |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 void CVcxHgVodListImplBase::OpenEmbeddedBrowserL( const TDesC& aUri ) |
|
80 { |
|
81 if ( aUri.Length() > 0 ) |
|
82 { |
|
83 CUri8* inetUri = NULL; |
|
84 inetUri = UriUtils::CreateUriL( aUri ); |
|
85 CleanupStack::PushL( inetUri ); |
|
86 |
|
87 HBufC8* parameter = HBufC8::NewLC( inetUri->Uri().UriDes().Length() ); |
|
88 parameter->Des().Format( _L8( "%S" ), &inetUri->Uri().UriDes() ); |
|
89 |
|
90 HBufC* parsed = HBufC::NewLC( parameter->Length() ); |
|
91 parsed->Des().Copy(*parameter); |
|
92 |
|
93 if ( !iLauncher ) |
|
94 { |
|
95 iLauncher = CBrowserLauncher::NewL(); |
|
96 } |
|
97 |
|
98 HBufC* urlToLaunch = HBufC::NewLC( |
|
99 parsed->Length() + KUrlLaunchParameter.iTypeLength ); |
|
100 urlToLaunch->Des().Append( KUrlLaunchParameter ); |
|
101 urlToLaunch->Des().Append( *parsed ); |
|
102 |
|
103 //Get available iap and pass it to browser |
|
104 TUint32 wap = iModel.GetAvailableWapIdL(); |
|
105 if ( wap == 0 ) |
|
106 { |
|
107 User::Leave( KErrCouldNotConnect ); |
|
108 } |
|
109 TBrowserOverriddenSettings overriddenSettings; |
|
110 overriddenSettings.SetBrowserSetting( EBrowserOverSettingsCustomAp, wap ); |
|
111 |
|
112 // Check, that the state has not been changed while launching |
|
113 if ( iModel.VcAppState() == EStateBrowser ) |
|
114 { |
|
115 iLauncher->LaunchBrowserEmbeddedL( *urlToLaunch, NULL, this, &overriddenSettings ); |
|
116 } |
|
117 |
|
118 CleanupStack::PopAndDestroy( urlToLaunch ); |
|
119 CleanupStack::PopAndDestroy( parsed ); |
|
120 CleanupStack::PopAndDestroy( parameter ); |
|
121 CleanupStack::PopAndDestroy( inetUri ); |
|
122 } |
|
123 } |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // Close browser. |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 void CVcxHgVodListImplBase::CloseEmbeddedBrowser() |
|
130 { |
|
131 //Note: Don't do this unless you know this app has started browser. |
|
132 if ( iLauncher ) |
|
133 { |
|
134 iLauncher->Cancel(); |
|
135 } |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // Set content for model |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 void CVcxHgVodListImplBase::HandleServerAppExit( TInt /*aReason*/ ) |
|
143 { |
|
144 //Back is called that we can return from EBrowser state to last state |
|
145 iModel.HandleBack(); |
|
146 TRAP_IGNORE( iView.ChangeListViewL() ); |
|
147 } |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // Set text for title pane |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 void CVcxHgVodListImplBase::SetTitlePaneTextL( const TDesC& aTitle ) |
|
154 { |
|
155 iView.TitlePaneL()->SetTextL( aTitle ); |
|
156 } |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // Set empty list widget text |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 void CVcxHgVodListImplBase::SetTitlePaneTextFromResourceL( TInt aResourceId ) |
|
163 { |
|
164 HBufC* title = StringLoader::LoadLC( aResourceId ); |
|
165 SetTitlePaneTextL( *title ); |
|
166 CleanupStack::PopAndDestroy( title ); |
|
167 } |
|
168 |
|
169 // ----------------------------------------------------------------------------- |
|
170 // Set empty list widget text |
|
171 // ----------------------------------------------------------------------------- |
|
172 // |
|
173 void CVcxHgVodListImplBase::SetEmptyListTextL( TInt aResourceId ) |
|
174 { |
|
175 HBufC* emptylistText = |
|
176 CVcxHgVodUtils::LoadStringFromResourceLC( aResourceId ); |
|
177 iScroller.SetEmptyTextL( *emptylistText ); |
|
178 iScroller.DrawDeferred(); |
|
179 CleanupStack::PopAndDestroy( emptylistText ); |
|
180 } |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // Set menu |
|
184 // ----------------------------------------------------------------------------- |
|
185 // |
|
186 void CVcxHgVodListImplBase::SetMenuResourceId( TInt aResourceId ) |
|
187 { |
|
188 iView.MenuBar()->SetMenuTitleResourceId( aResourceId ); |
|
189 } |
|
190 |
|
191 // --------------------------------------------------------- |
|
192 // CVcxHgVodListImplBase::ShowInformationPopupL( ) |
|
193 // --------------------------------------------------------- |
|
194 // |
|
195 void CVcxHgVodListImplBase::ShowInformationPopupL( |
|
196 TBool aShow, |
|
197 TInt aDownloadedTbns, |
|
198 TInt aTotalTbns ) |
|
199 { |
|
200 if( aShow && |
|
201 iModel.VcAppState() != EStateServiceView ) |
|
202 { |
|
203 if( aDownloadedTbns == 0 && aTotalTbns == 0 ) |
|
204 { |
|
205 ShowInformationPopupL(); |
|
206 } |
|
207 else if( aDownloadedTbns == 1 && aTotalTbns == 1 ) |
|
208 { |
|
209 HBufC* thumbnailtext = StringLoader::LoadLC( R_VCXHG_UPDATED_THUMBNAILS_ONE ); |
|
210 SetInfoPopupTextL( *thumbnailtext ); |
|
211 CleanupStack::PopAndDestroy( thumbnailtext ); |
|
212 ShowInformationPopupL(); |
|
213 } |
|
214 else |
|
215 { |
|
216 CArrayFix<TInt>* numbers = |
|
217 new (ELeave) CArrayFixFlat<TInt>( KThumbnailDownloadTextNumberCount ); |
|
218 CleanupStack::PushL( numbers ); |
|
219 |
|
220 numbers->AppendL( aTotalTbns ); |
|
221 numbers->AppendL( aDownloadedTbns ); |
|
222 |
|
223 HBufC* thumbnailtext = StringLoader::LoadLC( R_VCXHG_UPDATED_THUMBNAILS, *numbers ); |
|
224 SetInfoPopupTextL( *thumbnailtext ); |
|
225 |
|
226 CleanupStack::PopAndDestroy( thumbnailtext ); |
|
227 CleanupStack::PopAndDestroy( numbers ); |
|
228 |
|
229 ShowInformationPopupL(); |
|
230 } |
|
231 } |
|
232 else |
|
233 { |
|
234 HideInformationPopup(); |
|
235 } |
|
236 } |
|
237 |
|
238 // --------------------------------------------------------- |
|
239 // CVcxHgVodListImplBase::ShowInformationPopupL( ) |
|
240 // --------------------------------------------------------- |
|
241 // |
|
242 void CVcxHgVodListImplBase::ShowInformationPopupL() |
|
243 { |
|
244 if ( iModel.VcAppState() != EStateNoState && iView.IsForeground() ) |
|
245 { |
|
246 if ( !iInformationPopup ) |
|
247 { |
|
248 iInformationPopup = CVcxHgVodInformationPopup::NewL( iView, iModel ); |
|
249 } |
|
250 |
|
251 iInformationPopup->ShowL(); |
|
252 } |
|
253 } |
|
254 |
|
255 // --------------------------------------------------------- |
|
256 // CVcxHgVodListImplBase::SetTextL( ) |
|
257 // --------------------------------------------------------- |
|
258 // |
|
259 void CVcxHgVodListImplBase::SetInfoPopupTextL( const TDesC& aInformationText ) |
|
260 { |
|
261 if ( iInformationPopup ) |
|
262 { |
|
263 iInformationPopup->SetTextL( aInformationText ); |
|
264 } |
|
265 } |
|
266 |
|
267 // --------------------------------------------------------- |
|
268 // CVcxHgVodListImplBase::HideInformationPopup( ) |
|
269 // --------------------------------------------------------- |
|
270 // |
|
271 void CVcxHgVodListImplBase::HideInformationPopup() |
|
272 { |
|
273 if ( iInformationPopup ) |
|
274 { |
|
275 iInformationPopup->Hide(); |
|
276 } |
|
277 } |
|
278 |
|
279 // ----------------------------------------------------------------------------- |
|
280 // |
|
281 // ----------------------------------------------------------------------------- |
|
282 // |
|
283 void CVcxHgVodListImplBase::HandleSizeChange() |
|
284 { |
|
285 if ( iInformationPopup ) |
|
286 { |
|
287 iInformationPopup->HandleSizeChange(); |
|
288 } |
|
289 } |
|
290 |
|
291 // ----------------------------------------------------------------------------- |
|
292 // |
|
293 // ----------------------------------------------------------------------------- |
|
294 // |
|
295 void CVcxHgVodListImplBase::HandleForegroundEventL( TBool aForeground ) |
|
296 { |
|
297 if ( iInformationPopup ) |
|
298 { |
|
299 iInformationPopup->HandleForegroundEventL( aForeground ); |
|
300 } |
|
301 } |
|
302 |
|
303 // --------------------------------------------------------- |
|
304 // CVcxHgVodListImplBase::SearchImplL() |
|
305 // --------------------------------------------------------- |
|
306 // |
|
307 CVcxHgVodSearchImpl* CVcxHgVodListImplBase::SearchImpl() |
|
308 { |
|
309 return iSearchImpl; |
|
310 } |
|
311 |
|
312 |
|
313 // --------------------------------------------------------- |
|
314 // CVcxHgVodListImplBase::InitSearchImplL() |
|
315 // --------------------------------------------------------- |
|
316 // |
|
317 void CVcxHgVodListImplBase::InitSearchImplL() |
|
318 { |
|
319 if ( !iSearchImpl ) |
|
320 { |
|
321 iSearchImpl = CVcxHgVodSearchImpl::NewL( iModel, iView ); |
|
322 } |
|
323 } |
|
324 |
|
325 // --------------------------------------------------------- |
|
326 // CVcxHgVodListImplBase::ShowUpdateErrorNoteL() |
|
327 // --------------------------------------------------------- |
|
328 // |
|
329 void CVcxHgVodListImplBase::ShowUpdateErrorNoteL( TInt aError ) |
|
330 { |
|
331 HBufC* errText = NULL; |
|
332 |
|
333 switch ( aError ) |
|
334 { |
|
335 case KIptvRssParserError: |
|
336 errText = StringLoader::LoadLC( R_VCXHG_INVALID_DATA_RECEIVED ); |
|
337 break; |
|
338 case EIptvDlConnectionFailed: |
|
339 errText = StringLoader::LoadLC( R_VCXHG_INVALID_ACCESS_POINT ); |
|
340 break; |
|
341 case EIptvDlAuthFailed: |
|
342 errText = StringLoader::LoadLC( R_VCXHG_AUTH_FAILED ); |
|
343 break; |
|
344 case EIptvDlBadUrl: |
|
345 case EIptvDlContentNotFound: |
|
346 errText = StringLoader::LoadLC( R_VCXHG_INVALID_ADDRESS ); |
|
347 break; |
|
348 case EIptvDlDiskFull: |
|
349 { |
|
350 errText = StringLoader::LoadLC( R_VCXHG_MEMORY_FULL ); |
|
351 CAknQueryDialog* dlg = CAknQueryDialog::NewL( ); |
|
352 dlg->ExecuteLD( R_VCXHG_CONFIRMATION_QUERY, *errText ); |
|
353 CleanupStack::PopAndDestroy( errText ); |
|
354 errText = NULL; |
|
355 } |
|
356 break; |
|
357 case EIptvDlProxyAuthFailed: |
|
358 case EIptvDlDestFileInUse: |
|
359 default: |
|
360 errText = StringLoader::LoadLC( R_VCXHG_CONTENT_UPDATE_FAILED ); |
|
361 break; |
|
362 } |
|
363 |
|
364 if ( errText ) |
|
365 { |
|
366 // Note: We need to show the note synchronously if we are handling |
|
367 // authentication problem. Otherwise program would crash when this |
|
368 // note and authentication query mix each other. |
|
369 if ( aError == EIptvDlAuthFailed || aError == EIptvDlConnectionFailed ) |
|
370 { |
|
371 ShowErrorNoteL( *errText, ETrue ); |
|
372 } |
|
373 else |
|
374 { |
|
375 ShowErrorNoteL( *errText ); |
|
376 } |
|
377 |
|
378 CleanupStack::PopAndDestroy( errText ); |
|
379 } |
|
380 } |
|
381 |
|
382 // --------------------------------------------------------- |
|
383 // CVcxHgVodListImplBase::HandleAuthenticationL() |
|
384 // --------------------------------------------------------- |
|
385 // |
|
386 void CVcxHgVodListImplBase::HandleAuthenticationL( |
|
387 TBool aEpgUpdateFailed, |
|
388 CVcxNsContent* aContent ) |
|
389 { |
|
390 HBufC* username = HBufC::NewLC( KIptvEpgServiceUserNameMaxLength ); |
|
391 TPtr usernamePtr = username->Des(); |
|
392 HBufC* passwd = HBufC::NewLC( KIptvEpgServicePasswordMaxLength ); |
|
393 TPtr passwdPtr = passwd->Des(); |
|
394 |
|
395 CAknMultiLineDataQueryDialog* dlg = |
|
396 CAknMultiLineDataQueryDialog::NewL( usernamePtr, passwdPtr ); |
|
397 |
|
398 TInt dlgRes = dlg->ExecuteLD( R_VCXHG_AUTHENTICATION_QUERY ); |
|
399 |
|
400 if ( !dlgRes ) |
|
401 { |
|
402 User::Leave( KErrCancel ); |
|
403 } |
|
404 |
|
405 if ( aEpgUpdateFailed ) |
|
406 { |
|
407 MVcxNsServiceProviderIf* serviceProvider = iModel.GetServiceProviderL(); |
|
408 if ( serviceProvider ) |
|
409 { |
|
410 serviceProvider->SetAuthenticationDataL( *username, *passwd ); |
|
411 } |
|
412 } |
|
413 else |
|
414 { |
|
415 if ( aContent ) |
|
416 { |
|
417 aContent->SetUsernameL( *username ); |
|
418 aContent->SetPasswordL( *passwd ); |
|
419 } |
|
420 } |
|
421 |
|
422 CleanupStack::PopAndDestroy( passwd ); |
|
423 CleanupStack::PopAndDestroy( username ); |
|
424 } |
|
425 |
|
426 // --------------------------------------------------------- |
|
427 // CVcxHgVodListImplBase::ShowErrorNoteL |
|
428 // --------------------------------------------------------- |
|
429 // |
|
430 void CVcxHgVodListImplBase::ShowErrorNoteL( |
|
431 const TDesC& aErrorText, |
|
432 TBool aWaiting ) |
|
433 { |
|
434 CAknErrorNote* note = new ( ELeave ) CAknErrorNote( aWaiting ); |
|
435 note->ExecuteLD( aErrorText ); |
|
436 } |
|
437 |
|
438 // --------------------------------------------------------- |
|
439 // CVcxHgVodListImplBase::SetMskL |
|
440 // --------------------------------------------------------- |
|
441 // |
|
442 void CVcxHgVodListImplBase::SetMskL( TInt aResourceId ) |
|
443 { |
|
444 if ( aResourceId != iCurrentMskResource ) |
|
445 { |
|
446 iCurrentMskResource = aResourceId; |
|
447 if ( iView.ViewCba() ) |
|
448 { |
|
449 iView.ViewCba()->SetCommandL( KVcxMskPosition, iCurrentMskResource ); |
|
450 iView.ViewCba()->DrawDeferred(); |
|
451 } |
|
452 } |
|
453 } |
|
454 |
|
455 // --------------------------------------------------------- |
|
456 // CVcxHgVodListImplBase::HandleKeyEventL |
|
457 // --------------------------------------------------------- |
|
458 // |
|
459 TKeyResponse CVcxHgVodListImplBase::HandleKeyEventL( |
|
460 const TKeyEvent& /*aEvent*/, |
|
461 TEventCode /*aType*/ ) |
|
462 { |
|
463 return EKeyWasNotConsumed; |
|
464 } |
|
465 |
|
466 // --------------------------------------------------------- |
|
467 // CVcxHgVodListImplBase::HandleSelectL |
|
468 // --------------------------------------------------------- |
|
469 // |
|
470 void CVcxHgVodListImplBase::HandleSelectL( TInt /*aIndex*/ ) |
|
471 { |
|
472 // empty default impl. |
|
473 } |
|
474 |
|
475 // --------------------------------------------------------- |
|
476 // CVcxHgVodListImplBase::HandleOpenL |
|
477 // --------------------------------------------------------- |
|
478 // |
|
479 void CVcxHgVodListImplBase::HandleOpenL( TInt /*aIndex*/ ) |
|
480 { |
|
481 // empty default impl. |
|
482 } |
|
483 |
|
484 // --------------------------------------------------------- |
|
485 // CVcxHgVodListImplBase::SetFocus |
|
486 // --------------------------------------------------------- |
|
487 // |
|
488 void CVcxHgVodListImplBase::SetFocus( TBool aFocus ) |
|
489 { |
|
490 if ( !iScroller.IsFocused() ) |
|
491 { |
|
492 iScroller.SetFocus( aFocus ); |
|
493 } |
|
494 } |