|
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 #if defined(__WINSCW__) |
|
104 //custom ap overriden settings cannot be used in emulator environment |
|
105 iLauncher->LaunchBrowserEmbeddedL( *urlToLaunch, NULL, this ); |
|
106 #else |
|
107 //Get available iap and pass it to browser |
|
108 TUint32 wap = iModel.GetAvailableWapIdL(); |
|
109 if ( wap == 0 ) |
|
110 { |
|
111 User::Leave( KErrCouldNotConnect ); |
|
112 } |
|
113 TBrowserOverriddenSettings overriddenSettings; |
|
114 overriddenSettings.SetBrowserSetting( EBrowserOverSettingsCustomAp, wap ); |
|
115 |
|
116 iLauncher->LaunchBrowserEmbeddedL( *urlToLaunch, NULL, this, &overriddenSettings ); |
|
117 #endif |
|
118 |
|
119 CleanupStack::PopAndDestroy( urlToLaunch ); |
|
120 CleanupStack::PopAndDestroy( parsed ); |
|
121 CleanupStack::PopAndDestroy( parameter ); |
|
122 CleanupStack::PopAndDestroy( inetUri ); |
|
123 } |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // Close browser. |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 void CVcxHgVodListImplBase::CloseEmbeddedBrowser() |
|
131 { |
|
132 //Note: Don't do this unless you know this app has started browser. |
|
133 if ( iLauncher ) |
|
134 { |
|
135 iLauncher->Cancel(); |
|
136 } |
|
137 } |
|
138 |
|
139 // ----------------------------------------------------------------------------- |
|
140 // Set content for model |
|
141 // ----------------------------------------------------------------------------- |
|
142 // |
|
143 void CVcxHgVodListImplBase::HandleServerAppExit( TInt /*aReason*/ ) |
|
144 { |
|
145 //Back is called that we can return from EBrowser state to last state |
|
146 iModel.HandleBack(); |
|
147 TRAP_IGNORE( iView.ChangeListViewL() ); |
|
148 } |
|
149 |
|
150 // ----------------------------------------------------------------------------- |
|
151 // Set text for title pane |
|
152 // ----------------------------------------------------------------------------- |
|
153 // |
|
154 void CVcxHgVodListImplBase::SetTitlePaneTextL( const TDesC& aTitle ) |
|
155 { |
|
156 iView.TitlePaneL()->SetTextL( aTitle ); |
|
157 } |
|
158 |
|
159 // ----------------------------------------------------------------------------- |
|
160 // Set empty list widget text |
|
161 // ----------------------------------------------------------------------------- |
|
162 // |
|
163 void CVcxHgVodListImplBase::SetTitlePaneTextFromResourceL( TInt aResourceId ) |
|
164 { |
|
165 HBufC* title = StringLoader::LoadLC( aResourceId ); |
|
166 SetTitlePaneTextL( *title ); |
|
167 CleanupStack::PopAndDestroy( title ); |
|
168 } |
|
169 |
|
170 // ----------------------------------------------------------------------------- |
|
171 // Set empty list widget text |
|
172 // ----------------------------------------------------------------------------- |
|
173 // |
|
174 void CVcxHgVodListImplBase::SetEmptyListTextL( TInt aResourceId ) |
|
175 { |
|
176 HBufC* emptylistText = |
|
177 CVcxHgVodUtils::LoadStringFromResourceLC( aResourceId ); |
|
178 iScroller.SetEmptyTextL( *emptylistText ); |
|
179 iScroller.DrawDeferred(); |
|
180 CleanupStack::PopAndDestroy( emptylistText ); |
|
181 } |
|
182 |
|
183 // ----------------------------------------------------------------------------- |
|
184 // Set menu |
|
185 // ----------------------------------------------------------------------------- |
|
186 // |
|
187 void CVcxHgVodListImplBase::SetMenuResourceId( TInt aResourceId ) |
|
188 { |
|
189 iView.MenuBar()->SetMenuTitleResourceId( aResourceId ); |
|
190 } |
|
191 |
|
192 // --------------------------------------------------------- |
|
193 // CVcxHgVodListImplBase::ShowInformationPopupL( ) |
|
194 // --------------------------------------------------------- |
|
195 // |
|
196 void CVcxHgVodListImplBase::ShowInformationPopupL( |
|
197 TBool aShow, |
|
198 TInt aDownloadedTbns, |
|
199 TInt aTotalTbns ) |
|
200 { |
|
201 if( aShow && |
|
202 iModel.VcAppState() != EStateServiceView ) |
|
203 { |
|
204 if( aDownloadedTbns == 0 && aTotalTbns == 0 ) |
|
205 { |
|
206 ShowInformationPopupL(); |
|
207 } |
|
208 else if( aDownloadedTbns == 1 && aTotalTbns == 1 ) |
|
209 { |
|
210 HBufC* thumbnailtext = StringLoader::LoadLC( R_VCXHG_UPDATED_THUMBNAILS_ONE ); |
|
211 SetInfoPopupTextL( *thumbnailtext ); |
|
212 CleanupStack::PopAndDestroy( thumbnailtext ); |
|
213 ShowInformationPopupL(); |
|
214 } |
|
215 else |
|
216 { |
|
217 CArrayFix<TInt>* numbers = |
|
218 new (ELeave) CArrayFixFlat<TInt>( KThumbnailDownloadTextNumberCount ); |
|
219 CleanupStack::PushL( numbers ); |
|
220 |
|
221 numbers->AppendL( aTotalTbns ); |
|
222 numbers->AppendL( aDownloadedTbns ); |
|
223 |
|
224 HBufC* thumbnailtext = StringLoader::LoadLC( R_VCXHG_UPDATED_THUMBNAILS, *numbers ); |
|
225 SetInfoPopupTextL( *thumbnailtext ); |
|
226 |
|
227 CleanupStack::PopAndDestroy( thumbnailtext ); |
|
228 CleanupStack::PopAndDestroy( numbers ); |
|
229 |
|
230 ShowInformationPopupL(); |
|
231 } |
|
232 } |
|
233 else |
|
234 { |
|
235 HideInformationPopup(); |
|
236 } |
|
237 } |
|
238 |
|
239 // --------------------------------------------------------- |
|
240 // CVcxHgVodListImplBase::ShowInformationPopupL( ) |
|
241 // --------------------------------------------------------- |
|
242 // |
|
243 void CVcxHgVodListImplBase::ShowInformationPopupL() |
|
244 { |
|
245 if ( iModel.VcAppState() != EStateNoState && iView.IsForeground() ) |
|
246 { |
|
247 if ( !iInformationPopup ) |
|
248 { |
|
249 iInformationPopup = CVcxHgVodInformationPopup::NewL( iView, iModel ); |
|
250 } |
|
251 |
|
252 iInformationPopup->ShowL(); |
|
253 } |
|
254 } |
|
255 |
|
256 // --------------------------------------------------------- |
|
257 // CVcxHgVodListImplBase::SetTextL( ) |
|
258 // --------------------------------------------------------- |
|
259 // |
|
260 void CVcxHgVodListImplBase::SetInfoPopupTextL( const TDesC& aInformationText ) |
|
261 { |
|
262 if ( iInformationPopup ) |
|
263 { |
|
264 iInformationPopup->SetTextL( aInformationText ); |
|
265 } |
|
266 } |
|
267 |
|
268 // --------------------------------------------------------- |
|
269 // CVcxHgVodListImplBase::HideInformationPopup( ) |
|
270 // --------------------------------------------------------- |
|
271 // |
|
272 void CVcxHgVodListImplBase::HideInformationPopup() |
|
273 { |
|
274 if ( iInformationPopup ) |
|
275 { |
|
276 iInformationPopup->Hide(); |
|
277 } |
|
278 } |
|
279 |
|
280 // ----------------------------------------------------------------------------- |
|
281 // |
|
282 // ----------------------------------------------------------------------------- |
|
283 // |
|
284 void CVcxHgVodListImplBase::HandleSizeChange() |
|
285 { |
|
286 if ( iInformationPopup ) |
|
287 { |
|
288 iInformationPopup->HandleSizeChange(); |
|
289 } |
|
290 } |
|
291 |
|
292 // ----------------------------------------------------------------------------- |
|
293 // |
|
294 // ----------------------------------------------------------------------------- |
|
295 // |
|
296 void CVcxHgVodListImplBase::HandleForegroundEventL( TBool aForeground ) |
|
297 { |
|
298 if ( iInformationPopup ) |
|
299 { |
|
300 iInformationPopup->HandleForegroundEventL( aForeground ); |
|
301 } |
|
302 } |
|
303 |
|
304 // --------------------------------------------------------- |
|
305 // CVcxHgVodListImplBase::SearchImplL() |
|
306 // --------------------------------------------------------- |
|
307 // |
|
308 CVcxHgVodSearchImpl* CVcxHgVodListImplBase::SearchImpl() |
|
309 { |
|
310 return iSearchImpl; |
|
311 } |
|
312 |
|
313 |
|
314 // --------------------------------------------------------- |
|
315 // CVcxHgVodListImplBase::InitSearchImplL() |
|
316 // --------------------------------------------------------- |
|
317 // |
|
318 void CVcxHgVodListImplBase::InitSearchImplL() |
|
319 { |
|
320 if ( !iSearchImpl ) |
|
321 { |
|
322 iSearchImpl = CVcxHgVodSearchImpl::NewL( iModel, iView ); |
|
323 } |
|
324 } |
|
325 |
|
326 // --------------------------------------------------------- |
|
327 // CVcxHgVodListImplBase::ShowUpdateErrorNoteL() |
|
328 // --------------------------------------------------------- |
|
329 // |
|
330 void CVcxHgVodListImplBase::ShowUpdateErrorNoteL( TInt aError ) |
|
331 { |
|
332 HBufC* errText = NULL; |
|
333 |
|
334 switch ( aError ) |
|
335 { |
|
336 case KIptvRssParserError: |
|
337 errText = StringLoader::LoadLC( R_VCXHG_INVALID_DATA_RECEIVED ); |
|
338 break; |
|
339 case EIptvDlConnectionFailed: |
|
340 errText = StringLoader::LoadLC( R_VCXHG_INVALID_ACCESS_POINT ); |
|
341 break; |
|
342 case EIptvDlAuthFailed: |
|
343 errText = StringLoader::LoadLC( R_VCXHG_AUTH_FAILED ); |
|
344 break; |
|
345 case EIptvDlBadUrl: |
|
346 case EIptvDlContentNotFound: |
|
347 errText = StringLoader::LoadLC( R_VCXHG_INVALID_ADDRESS ); |
|
348 break; |
|
349 case EIptvDlDiskFull: |
|
350 { |
|
351 errText = StringLoader::LoadLC( R_VCXHG_MEMORY_FULL ); |
|
352 CAknQueryDialog* dlg = CAknQueryDialog::NewL( ); |
|
353 dlg->ExecuteLD( R_VCXHG_CONFIRMATION_QUERY, *errText ); |
|
354 CleanupStack::PopAndDestroy( errText ); |
|
355 errText = NULL; |
|
356 } |
|
357 break; |
|
358 case EIptvDlProxyAuthFailed: |
|
359 case EIptvDlDestFileInUse: |
|
360 default: |
|
361 errText = StringLoader::LoadLC( R_VCXHG_CONTENT_UPDATE_FAILED ); |
|
362 break; |
|
363 } |
|
364 |
|
365 if ( errText ) |
|
366 { |
|
367 // Note: We need to show the note synchronously if we are handling |
|
368 // authentication problem. Otherwise program would crash when this |
|
369 // note and authentication query mix each other. |
|
370 if ( aError == EIptvDlAuthFailed || aError == EIptvDlConnectionFailed ) |
|
371 { |
|
372 ShowErrorNoteL( *errText, ETrue ); |
|
373 } |
|
374 else |
|
375 { |
|
376 ShowErrorNoteL( *errText ); |
|
377 } |
|
378 |
|
379 CleanupStack::PopAndDestroy( errText ); |
|
380 } |
|
381 } |
|
382 |
|
383 // --------------------------------------------------------- |
|
384 // CVcxHgVodListImplBase::HandleAuthenticationL() |
|
385 // --------------------------------------------------------- |
|
386 // |
|
387 void CVcxHgVodListImplBase::HandleAuthenticationL( |
|
388 TBool aEpgUpdateFailed, |
|
389 CVcxNsContent* aContent ) |
|
390 { |
|
391 HBufC* username = HBufC::NewLC( KIptvEpgServiceUserNameMaxLength ); |
|
392 TPtr usernamePtr = username->Des(); |
|
393 HBufC* passwd = HBufC::NewLC( KIptvEpgServicePasswordMaxLength ); |
|
394 TPtr passwdPtr = passwd->Des(); |
|
395 |
|
396 CAknMultiLineDataQueryDialog* dlg = |
|
397 CAknMultiLineDataQueryDialog::NewL( usernamePtr, passwdPtr ); |
|
398 |
|
399 TInt dlgRes = dlg->ExecuteLD( R_VCXHG_AUTHENTICATION_QUERY ); |
|
400 |
|
401 if ( !dlgRes ) |
|
402 { |
|
403 User::Leave( KErrCancel ); |
|
404 } |
|
405 |
|
406 if ( aEpgUpdateFailed ) |
|
407 { |
|
408 MVcxNsServiceProviderIf* serviceProvider = iModel.GetServiceProviderL(); |
|
409 if ( serviceProvider ) |
|
410 { |
|
411 serviceProvider->SetAuthenticationDataL( *username, *passwd ); |
|
412 } |
|
413 } |
|
414 else |
|
415 { |
|
416 if ( aContent ) |
|
417 { |
|
418 aContent->SetUsernameL( *username ); |
|
419 aContent->SetPasswordL( *passwd ); |
|
420 } |
|
421 } |
|
422 |
|
423 CleanupStack::PopAndDestroy( passwd ); |
|
424 CleanupStack::PopAndDestroy( username ); |
|
425 } |
|
426 |
|
427 // --------------------------------------------------------- |
|
428 // CVcxHgVodListImplBase::ShowErrorNoteL |
|
429 // --------------------------------------------------------- |
|
430 // |
|
431 void CVcxHgVodListImplBase::ShowErrorNoteL( |
|
432 const TDesC& aErrorText, |
|
433 TBool aWaiting ) |
|
434 { |
|
435 CAknErrorNote* note = new ( ELeave ) CAknErrorNote( aWaiting ); |
|
436 note->ExecuteLD( aErrorText ); |
|
437 } |
|
438 |
|
439 // --------------------------------------------------------- |
|
440 // CVcxHgVodListImplBase::SetMskL |
|
441 // --------------------------------------------------------- |
|
442 // |
|
443 void CVcxHgVodListImplBase::SetMskL( TInt aResourceId ) |
|
444 { |
|
445 if ( aResourceId != iCurrentMskResource ) |
|
446 { |
|
447 iCurrentMskResource = aResourceId; |
|
448 if ( iView.ViewCba() ) |
|
449 { |
|
450 iView.ViewCba()->SetCommandL( KVcxMskPosition, iCurrentMskResource ); |
|
451 iView.ViewCba()->DrawDeferred(); |
|
452 } |
|
453 } |
|
454 } |
|
455 |
|
456 // --------------------------------------------------------- |
|
457 // CVcxHgVodListImplBase::HandleKeyEventL |
|
458 // --------------------------------------------------------- |
|
459 // |
|
460 TKeyResponse CVcxHgVodListImplBase::HandleKeyEventL( |
|
461 const TKeyEvent& /*aEvent*/, |
|
462 TEventCode /*aType*/ ) |
|
463 { |
|
464 return EKeyWasNotConsumed; |
|
465 } |
|
466 |
|
467 // --------------------------------------------------------- |
|
468 // CVcxHgVodListImplBase::HandleSelectL |
|
469 // --------------------------------------------------------- |
|
470 // |
|
471 void CVcxHgVodListImplBase::HandleSelectL( TInt /*aIndex*/ ) |
|
472 { |
|
473 // empty default impl. |
|
474 } |
|
475 |
|
476 // --------------------------------------------------------- |
|
477 // CVcxHgVodListImplBase::HandleOpenL |
|
478 // --------------------------------------------------------- |
|
479 // |
|
480 void CVcxHgVodListImplBase::HandleOpenL( TInt /*aIndex*/ ) |
|
481 { |
|
482 // empty default impl. |
|
483 } |
|
484 |
|
485 // --------------------------------------------------------- |
|
486 // CVcxHgVodListImplBase::SetFocus |
|
487 // --------------------------------------------------------- |
|
488 // |
|
489 void CVcxHgVodListImplBase::SetFocus( TBool aFocus ) |
|
490 { |
|
491 if ( !iScroller.IsFocused() ) |
|
492 { |
|
493 iScroller.SetFocus( aFocus ); |
|
494 } |
|
495 } |