|
1 /* |
|
2 * Copyright (c) 2004 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: Stations view class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 /* --------------------------------------------------------------------------- |
|
20 * Version history: |
|
21 * Template version: |
|
22 * <ccm_history> |
|
23 * |
|
24 * Version: 8, Thu Aug 18 14:32:00 2008 by Rohit |
|
25 * Ref: |
|
26 * Fixed bug : Tapping StationInfo toolbar-option for last station in Station list is causing crash |
|
27 * Modified GetStationsViewActualIndex() to remove increment of currentIndex. |
|
28 * |
|
29 * Version: 8, Thurs July 18 12:00:00 2008 by Prabina |
|
30 * Ref: |
|
31 * Code Review Comments Fixed |
|
32 * |
|
33 * Version: 7, May 28 wed 16:34:00 2008 by Rohit |
|
34 * Fixed bug to verify network before invoking Song Information view |
|
35 * |
|
36 * Version: 6, Tues March 29 10:30:00 2008 by Prabina |
|
37 * Ref: |
|
38 * Stations View Container Derived from CCoeControl |
|
39 * |
|
40 * Version: 5, Tues March 25 17:30:00 2008 by Prabina |
|
41 * Ref: |
|
42 * Fixing the PCLint errors |
|
43 * |
|
44 * Version: 4, Mon March 24 18:00:00 2008 by Prabina |
|
45 * Ref: |
|
46 * Added WorkAround for adding different stations to favourites list , Added Wait dialog for adding to favourites |
|
47 * |
|
48 * Version: 3, Fri March 21 17:20:00 2008 by Prabina |
|
49 * Ref: |
|
50 * Added WorkAround for supporting different Resolutions , Added Wait Dialog for Loading of stations , |
|
51 * Handled Single/Double tapping on the list itmes |
|
52 * |
|
53 * Version: 2, Thurs March 20 15:50:00 2008 by Prabina |
|
54 * Ref: |
|
55 * Created new views for the Station Directory Views , Enabled the Touch toolbar functionality , |
|
56 * Help Options enabled |
|
57 * |
|
58 * </ccm_history> |
|
59 * ============================================================================ |
|
60 */ |
|
61 |
|
62 |
|
63 #include <akniconarray.h> |
|
64 #include <akntitle.h> |
|
65 #include <eikmenup.h> |
|
66 #include <gulicon.h> |
|
67 #include <stringloader.h> |
|
68 #include <psserv.h> |
|
69 #include <hlplch.h> |
|
70 #include <aknnotewrappers.h> |
|
71 #include <eikenv.h> |
|
72 #include <internetradio.rsg> |
|
73 #include <internetradio.mbg> |
|
74 //For Touch Toolbar |
|
75 #include <akntoolbar.h> |
|
76 #include <akntouchpane.h> |
|
77 #include <aknbutton.h> |
|
78 #include <aknwaitdialog.h> |
|
79 |
|
80 #include "irui.h" |
|
81 #include "ir.hrh" |
|
82 #include "ircommon.h" |
|
83 #include "irdebug.h" |
|
84 #include "irbaseview.h" |
|
85 #include "irstationsview.h" |
|
86 #include "irstationsviewcontainer.h" |
|
87 #include "irapplication.h" |
|
88 #include "irisdswrapper.h" |
|
89 #include "irsettings.h" |
|
90 #include "irmainview.h" |
|
91 #include "irnowplayingwrapper.h" |
|
92 #include "irstationinfoview.h" |
|
93 #include "irimageconverter.h" |
|
94 #include "irlogodownloadengine.h" |
|
95 #include "irdataprovider.h" |
|
96 #include "irhttpdataprovider.h" |
|
97 #include "irnetworkcontroller.h" |
|
98 #include "iractivenetworkobserver.h" |
|
99 #include "irdialoglauncher.h" |
|
100 #include "irfilteredmodel.h" |
|
101 #include "irpubsub.h" |
|
102 |
|
103 const TInt KImagesSize = 59; |
|
104 const TInt KImageReqFrom = 0; |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // CIRStationsView::CIRStationsView() |
|
108 // C++ default constructor can NOT contain any code, that might leave. |
|
109 // --------------------------------------------------------------------------- |
|
110 // |
|
111 CIRStationsView::CIRStationsView():iCallRequestPending(EFalse) |
|
112 { |
|
113 IRLOG_DEBUG( "CIRStationsView::CIRStationsView" ); |
|
114 iResultsReqMade = EFalse; |
|
115 } |
|
116 |
|
117 |
|
118 // --------------------------------------------------------------------------- |
|
119 // void CIRStationsView::ConstructL() |
|
120 // EPOC default constructor can leave. |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 void CIRStationsView::ConstructL() |
|
124 { |
|
125 IRLOG_DEBUG( "CIRStationsView::ConstructL - Entering" ); |
|
126 CIRBaseView::ConstructL( R_IR_STATIONS ); |
|
127 MAknsSkinInstance * skin=AknsUtils::SkinInstance () ; |
|
128 TRgb color; |
|
129 TInt skinColor=AknsUtils::GetCachedColor(skin, color, KAknsIIDQsnTextColors, |
|
130 EAknsCIQsnTextColorsCG6 ); |
|
131 if(color.Gray2()!=0) |
|
132 { |
|
133 CreateAndSetToolbarL(R_IR_STATIONSVIEW_WHITE_TOOLBAR); |
|
134 } |
|
135 else |
|
136 { |
|
137 CreateAndSetToolbarL(R_IR_STATIONSVIEW_BLACK_TOOLBAR); |
|
138 } |
|
139 if( AknLayoutUtils::PenEnabled() && Toolbar() ) |
|
140 { |
|
141 Toolbar()->SetToolbarObserver( this ); |
|
142 } |
|
143 |
|
144 iFilteredIndex = 0; |
|
145 iFirstTimeLaunchFlag= EFalse; |
|
146 iRequestPending = EFalse; |
|
147 iAddToFav= EFalse; |
|
148 iStationDetails = EFalse; |
|
149 IRLOG_DEBUG( "CIRStationsView::ConstructL - Exiting" ); |
|
150 } |
|
151 |
|
152 // ----------------------------------------------------------------------------- |
|
153 // CIRStationsView::NewL() |
|
154 // Two-phased constructor. |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 CIRStationsView* CIRStationsView::NewL() |
|
158 { |
|
159 IRLOG_DEBUG( "CIRStationsView::NewL" ); |
|
160 CIRStationsView* self = CIRStationsView::NewLC(); |
|
161 CleanupStack::Pop( self ); |
|
162 IRLOG_DEBUG( "CIRStationsView::NewL - Exiting" ); |
|
163 return self; |
|
164 } |
|
165 |
|
166 |
|
167 // --------------------------------------------------------------------------- |
|
168 // CIRStationsView::NewLC() |
|
169 // Two-phased constructor. |
|
170 // --------------------------------------------------------------------------- |
|
171 // |
|
172 CIRStationsView* CIRStationsView::NewLC() |
|
173 { |
|
174 IRLOG_DEBUG( "CIRStationsView::NewLC - Entering" ); |
|
175 CIRStationsView* self = new( ELeave ) CIRStationsView; |
|
176 CleanupStack::PushL( self ); |
|
177 self->ConstructL(); |
|
178 IRLOG_DEBUG( "CIRStationsView::NewLC - Exiting" ); |
|
179 return self; |
|
180 } |
|
181 |
|
182 |
|
183 // --------------------------------------------------------------------------- |
|
184 // CIRStationsView::~CIRStationsView() |
|
185 // Destructor |
|
186 // --------------------------------------------------------------------------- |
|
187 // |
|
188 CIRStationsView::~CIRStationsView() |
|
189 { |
|
190 IRLOG_DEBUG( "CIRStationsView::~CIRStationsView - Entering" ); |
|
191 if ( iContainer ) |
|
192 { |
|
193 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
194 delete iContainer; |
|
195 iContainer = NULL; |
|
196 } |
|
197 if ( Toolbar() ) |
|
198 { |
|
199 Toolbar()->SetToolbarVisibility(EFalse, EFalse); |
|
200 Toolbar()->SetToolbarObserver( NULL ); |
|
201 } |
|
202 iFilteredIndex = 0; |
|
203 IRLOG_DEBUG( "CIRStationsView::~CIRStationsView - Exiting" ); |
|
204 } |
|
205 |
|
206 // --------------------------------------------------------------------------- |
|
207 // TUid CIRStationsView::Id() const |
|
208 // From class CAknView. |
|
209 // Returns view id. |
|
210 // --------------------------------------------------------------------------- |
|
211 // |
|
212 TUid CIRStationsView::Id() const |
|
213 { |
|
214 IRLOG_DEBUG( "CIRStationsView::Id" ); |
|
215 return KIRStationsViewId; |
|
216 } |
|
217 |
|
218 // --------------------------------------------------------------------------- |
|
219 // void CIRStationsView::DoActivateL( ) |
|
220 // From class CAknView. |
|
221 // Handles view activation. |
|
222 // --------------------------------------------------------------------------- |
|
223 // |
|
224 void CIRStationsView::DoActivateL( const TVwsViewId& aPrevViewId, |
|
225 TUid aCustomMessageId, const TDesC8& aCustomMessage ) |
|
226 { |
|
227 IRLOG_DEBUG( "CIRStationsView::DoActivateL - Entering" ); |
|
228 |
|
229 TInt customMessageId = aCustomMessageId.iUid; |
|
230 if(customMessageId == 1) |
|
231 { |
|
232 SetCurrentFocus(0); |
|
233 SetCurrentTopItem(0); |
|
234 iFirstTimeLaunchFlag= ETrue; |
|
235 } |
|
236 aCustomMessageId.iUid = 0; |
|
237 iUi->iPresentViewID = KIRStationsViewId; |
|
238 |
|
239 //////////////////////////////////////////////////////////// |
|
240 |
|
241 if(iResultsReqMade) |
|
242 { |
|
243 if(iContainer) |
|
244 { |
|
245 delete iContainer; |
|
246 iContainer = NULL; |
|
247 } |
|
248 iResultsReqMade = EFalse; |
|
249 } |
|
250 |
|
251 //////////////////////////////////////////////////////////// |
|
252 |
|
253 |
|
254 ConstructToolbarL(); |
|
255 if ( !iContainer ) |
|
256 { |
|
257 iContainer = CIRStationsViewContainer::NewL( *this, ClientRect() ); |
|
258 iContainer->CreateListBoxL(); |
|
259 AppUi()->AddToViewStackL( *this, iContainer); |
|
260 } |
|
261 else |
|
262 { |
|
263 // we must notify a resource change in order to update the skin context |
|
264 // This is a flaw of CEikFormattedCellListBox |
|
265 // _LIT(KText,"") |
|
266 // iContainer->iStationsSearchBox->SetSearchTextL (KText) |
|
267 // iContainer->RefreshViewBack() |
|
268 |
|
269 iContainer->SetRect(ClientRect()); |
|
270 iContainer->HandleResourceChange(KEikDynamicLayoutVariantSwitch); |
|
271 AppUi()->AddToViewStackL( *this, iContainer); |
|
272 // iContainer->iItemArray->Reset() |
|
273 // iContainer->UpdateStationsViewL() |
|
274 } |
|
275 |
|
276 |
|
277 iContainer->ActivateL(); |
|
278 iContainer->MakeVisible( ETrue ); |
|
279 SetStatusPaneTextL(); |
|
280 CIRBaseView::DoActivateL( aPrevViewId, aCustomMessageId, aCustomMessage ); |
|
281 EnableObserverL(EIRSystemEventObserver); |
|
282 HandleStatusPaneSizeChange(); |
|
283 iUi->iNetworkController->RegisterActiveNetworkObserverL(*this); |
|
284 IRLOG_DEBUG( "CIRStationsView::DoActivateL - Exiting" ); |
|
285 } |
|
286 |
|
287 // --------------------------------------------------------------------------- |
|
288 // void CIRStationsView::DoDeactivate() |
|
289 // From class CAknView. |
|
290 // Handles view deactivation. |
|
291 // --------------------------------------------------------------------------- |
|
292 // |
|
293 void CIRStationsView::DoDeactivate() |
|
294 { |
|
295 IRLOG_DEBUG( "CIRStationsView::DoDeactivate - Entering" ); |
|
296 if(&(iUi->SystemEventCollector())) |
|
297 { |
|
298 DisableObserver(EIRSystemEventObserver); |
|
299 } |
|
300 if ( iContainer ) |
|
301 { |
|
302 if(iContainer->iStationsListBox && iContainer->GetSearchBoxPointer()) |
|
303 { |
|
304 iContainer->GetSearchBoxPointer()->GetSearchText(iContainer->iFindString); |
|
305 if(iContainer->GetSearchBoxPointer() && iContainer->iFindString.Length()!=0) |
|
306 { |
|
307 if(iIndex) |
|
308 { |
|
309 SetCurrentFocus(iIndex); |
|
310 } |
|
311 else |
|
312 { |
|
313 iContainer->Comparestrings(); |
|
314 SetCurrentFocus(iIndex); |
|
315 } |
|
316 } |
|
317 else |
|
318 { |
|
319 SetCurrentFocus(iContainer->GetCurrentItemIndex()); |
|
320 } |
|
321 SetCurrentTopItem(iContainer->GetListBoxTopIndex()); |
|
322 } |
|
323 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
324 iContainer->MakeVisible( EFalse ); |
|
325 } |
|
326 if ( Toolbar() ) |
|
327 { |
|
328 Toolbar()->SetToolbarVisibility(EFalse, EFalse); |
|
329 Toolbar()->SetToolbarObserver( NULL ); |
|
330 } |
|
331 iFirstTimeLaunchFlag= EFalse; |
|
332 iUi->iNetworkController->DeleteActiveNetworkObserver(*this); |
|
333 IRLOG_DEBUG( "CIRStationsView::DoDeactivate - Exiting" ); |
|
334 } |
|
335 |
|
336 // --------------------------------------------------------------------------- |
|
337 // void CIRStationsView::HandleCommandL( TInt aCommand ) |
|
338 // From class CAknView. |
|
339 // Command handling function. |
|
340 // --------------------------------------------------------------------------- |
|
341 // |
|
342 void CIRStationsView::HandleCommandL( TInt aCommand ) |
|
343 { |
|
344 IRLOG_DEBUG( "CIRStationsView::HandleCommandL - Entering" ); |
|
345 CIRUi* appUi = static_cast<CIRUi*>( AppUi() ); |
|
346 iCommand = aCommand; |
|
347 |
|
348 switch(aCommand) |
|
349 { |
|
350 //Activate NowPlaying view. |
|
351 case EGotoNowPlayingViewCmd: |
|
352 { |
|
353 appUi->SetHistory(EFalse); |
|
354 appUi->SavePrevIDL(KIRStationsViewId, aCommand); |
|
355 } |
|
356 break; |
|
357 case EAddtoFavouritesCmd: |
|
358 { |
|
359 if ( iUi->CheckAndNotifyLowDiskSpaceL() ) |
|
360 { |
|
361 break; |
|
362 } |
|
363 else if( iUi->VerifyNetworkConnectivityL() ) |
|
364 { |
|
365 iRequestPending = ETrue; |
|
366 iAddToFav = ETrue; |
|
367 iListenRequest = EFalse; |
|
368 iStationDetails = EFalse; |
|
369 break; |
|
370 } |
|
371 else |
|
372 { |
|
373 iAddToFav = ETrue; |
|
374 AddToFavouritesL(GetStationsViewActualIndex(),aCommand); |
|
375 } |
|
376 } |
|
377 break; |
|
378 case EListenCmd: |
|
379 { |
|
380 if ( iUi->CheckAndNotifyLowDiskSpaceL() ) |
|
381 { |
|
382 break; |
|
383 } |
|
384 iUi->SetListenFromPls(EFalse); |
|
385 if( iUi->VerifyNetworkConnectivityL() ) |
|
386 { |
|
387 iRequestPending = ETrue; |
|
388 iListenRequest = ETrue; |
|
389 iAddToFav = EFalse; |
|
390 iStationDetails = EFalse; |
|
391 break; |
|
392 } |
|
393 else |
|
394 { |
|
395 //SetCurrentFocus(GetStationsViewActualIndex()) |
|
396 ListenChannelL(GetStationsViewActualIndex()); |
|
397 } |
|
398 } |
|
399 break; |
|
400 //Activate settings view. |
|
401 case ESettingsCmd: |
|
402 { |
|
403 AppUi()->ActivateLocalViewL(KIRSettingsViewId); |
|
404 } |
|
405 break; |
|
406 case EHelpCmd: |
|
407 { |
|
408 if ( !iUi->CheckAndNotifyLowDiskSpaceL() ) |
|
409 { |
|
410 HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), AppUi()->AppHelpContextL() ); |
|
411 } |
|
412 } |
|
413 break; |
|
414 case EStationDetailsCmd: |
|
415 { |
|
416 if ( iUi->CheckAndNotifyLowDiskSpaceL() ) |
|
417 { |
|
418 break; |
|
419 } |
|
420 if( iUi->VerifyNetworkConnectivityL() ) |
|
421 { |
|
422 iRequestPending = ETrue; |
|
423 iStationDetails = ETrue; |
|
424 iAddToFav = EFalse; |
|
425 iListenRequest = EFalse; |
|
426 break; |
|
427 } |
|
428 else |
|
429 { |
|
430 iStationDetails = ETrue; |
|
431 TInt currentIndex = GetStationsViewActualIndex(); |
|
432 SetCurrentFocus(currentIndex); |
|
433 DisplayStationInformationL(currentIndex, aCommand); |
|
434 } |
|
435 } |
|
436 break; |
|
437 case EAdvertisementUrl: |
|
438 { |
|
439 if ( iUi->CheckAndNotifyLowDiskSpaceL() ) |
|
440 { |
|
441 break; |
|
442 } |
|
443 else if( iUi->VerifyNetworkConnectivityL() ) |
|
444 { |
|
445 break; |
|
446 } |
|
447 if(iUi->iIsdsWrapper->iClickThroughUrl) |
|
448 { |
|
449 if((iUi->iIsdsWrapper->iClickThroughUrl->Length())!=0) |
|
450 { |
|
451 iContainer->OpenUrlL(*iUi->iIsdsWrapper->iClickThroughUrl); |
|
452 } |
|
453 } |
|
454 else |
|
455 { |
|
456 iUi->iIsdsWrapper->GetDialogLauncherInstance()->ShowErrorNoteL |
|
457 (R_IRAPP_ERROR_URL_UNAVAILABLE,ETrue); |
|
458 } |
|
459 } |
|
460 break; |
|
461 default: |
|
462 { |
|
463 CIRBaseView::HandleCommandL( aCommand ); |
|
464 } |
|
465 break; |
|
466 } |
|
467 IRLOG_DEBUG( "CIRStationsView::HandleCommandL - Exiting" ); |
|
468 } |
|
469 // --------------------------------------------------------------------------- |
|
470 // void CIRStationsView::SetStatusPaneTextL() |
|
471 // Sets the title pane of the search results view |
|
472 // --------------------------------------------------------------------------- |
|
473 // |
|
474 |
|
475 void CIRStationsView:: SetStatusPaneTextL() const |
|
476 { |
|
477 IRLOG_DEBUG( "CIRStationsView::SetStatusPaneTextL - Entering" ); |
|
478 static_cast<CAknTitlePane*>( StatusPane()->ControlL( |
|
479 TUid::Uid( EEikStatusPaneUidTitle ) ) )->SetTextL( iUi->iStationsViewTitleString ); |
|
480 IRLOG_DEBUG( "CIRStationsView::SetStatusPaneTextL - Exiting" ); |
|
481 } |
|
482 |
|
483 // --------------------------------------------------------------------------- |
|
484 // void CIRStationsView::DynInitMenuPaneL() |
|
485 // Dynamically initialises a menu pane |
|
486 // --------------------------------------------------------------------------- |
|
487 // |
|
488 void CIRStationsView::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane) |
|
489 { |
|
490 IRLOG_DEBUG( "CIRStationsView::DynInitMenuPaneL - Entering" ); |
|
491 CIRUi* appUi = static_cast<CIRUi*>( AppUi() ); |
|
492 |
|
493 if(!aMenuPane) User::Leave(KErrNotFound); |
|
494 { |
|
495 if(aResourceId == R_IR_MENU_STATIONS) |
|
496 { |
|
497 // Now Playing option |
|
498 if(iNowPlayingWrapper->iPlaying) |
|
499 { |
|
500 aMenuPane->SetItemDimmed(EGotoNowPlayingViewCmd,EFalse); |
|
501 } |
|
502 else |
|
503 { |
|
504 aMenuPane->SetItemDimmed(EGotoNowPlayingViewCmd,ETrue); |
|
505 } |
|
506 } |
|
507 } |
|
508 IRLOG_DEBUG( "CIRStationsView::DynInitMenuPaneL - Exiting" ); |
|
509 } |
|
510 |
|
511 // --------------------------------------------------------------------------- |
|
512 // void CIRStationsView::ListenChannelL() |
|
513 // Request for listening to a channel |
|
514 // --------------------------------------------------------------------------- |
|
515 // |
|
516 |
|
517 void CIRStationsView:: ListenChannelL(TInt aCurrentIndex) |
|
518 { |
|
519 IRLOG_DEBUG( "CIRStationsView::ListenChannelL - Entering" ); |
|
520 iNowPlayingWrapper->SetView(EStations); |
|
521 iNowPlayingWrapper->SetWhenUserCancelsBufferingWaitBar(EFalse); |
|
522 iNowPlayingWrapper->SetListenFromIsdsValue(EFalse); |
|
523 iNowPlayingWrapper->SetWhenUserCancelsIsdsBufferingWaitBar(EFalse); |
|
524 iNowPlayingWrapper->CreateWaitDialogL(); |
|
525 iUi->GetPubSubManagerInstance()->PublishBufferingState(EIRStateBufferingStart); |
|
526 |
|
527 iIsdsWrapper->IsdsListenRequestL(this,aCurrentIndex); |
|
528 IRLOG_DEBUG( "CIRStationsView::ListenChannelL - Exiting" ); |
|
529 } |
|
530 // --------------------------------------------------------------------------- |
|
531 // Touch Toolbar |
|
532 // |
|
533 // --------------------------------------------------------------------------- |
|
534 |
|
535 void CIRStationsView::ConstructToolbarL() |
|
536 { |
|
537 IRLOG_DEBUG( "CIRStationsView::ConstructToolbarL - Entering" ); |
|
538 SetToolbarItems(); |
|
539 |
|
540 // Update rect, as changes in toolbar visibility also affect layout. |
|
541 if(iContainer) |
|
542 { |
|
543 iContainer->SetRect( ClientRect() ); |
|
544 iContainer->DrawDeferred(); |
|
545 } |
|
546 |
|
547 IRLOG_DEBUG( "CIRStationsView::ConstructToolbarL - Exiting" ); |
|
548 } |
|
549 |
|
550 |
|
551 |
|
552 // -------------------------------------------------------------------------- |
|
553 // CIRStationsView::OfferToolbarEventL |
|
554 // -------------------------------------------------------------------------- |
|
555 // |
|
556 void CIRStationsView::OfferToolbarEventL ( TInt aCommand ) |
|
557 { |
|
558 IRLOG_DEBUG( "CIRStationsView::OfferToolbarEventL - Entering" ); |
|
559 HandleCommandL(aCommand); |
|
560 IRLOG_DEBUG( "CIRStationsView::OfferToolbarEventL - Exiting" ); |
|
561 } |
|
562 |
|
563 |
|
564 |
|
565 |
|
566 // --------------------------------------------------------------------------- |
|
567 // From class CAknView. |
|
568 // Foreground event handling function. |
|
569 // --------------------------------------------------------------------------- |
|
570 // |
|
571 void CIRStationsView::HandleForegroundEventL( TBool aForeground ) |
|
572 { |
|
573 IRLOG_DEBUG( "CIRStationsView::HandleForegroundEventL - Entering" ); |
|
574 CIRBaseView::HandleForegroundEventL( aForeground ); |
|
575 |
|
576 if ( aForeground ) |
|
577 { |
|
578 if ( iContainer ) |
|
579 { |
|
580 MAknsSkinInstance * skin=AknsUtils::SkinInstance () ; |
|
581 TRgb color; |
|
582 TInt skinColor=AknsUtils::GetCachedColor(skin, color, KAknsIIDQsnTextColors, |
|
583 EAknsCIQsnTextColorsCG6 ); |
|
584 if(color.Gray2()!=0) |
|
585 { |
|
586 CreateAndSetToolbarL(R_IR_STATIONSVIEW_WHITE_TOOLBAR); |
|
587 } |
|
588 else |
|
589 { |
|
590 CreateAndSetToolbarL(R_IR_STATIONSVIEW_BLACK_TOOLBAR); |
|
591 } |
|
592 if( AknLayoutUtils::PenEnabled() && Toolbar() ) |
|
593 { |
|
594 Toolbar()->SetToolbarObserver( this ); |
|
595 } |
|
596 ConstructToolbarL(); |
|
597 iContainer->DrawDeferred(); |
|
598 } |
|
599 } |
|
600 IRLOG_DEBUG( "CIRStationsView::HandleForegroundEventL - Exiting" ); |
|
601 } |
|
602 |
|
603 // --------------------------------------------------------------------------- |
|
604 // From class CAknView. |
|
605 // Event handler for status pane size changes. |
|
606 // --------------------------------------------------------------------------- |
|
607 // |
|
608 void CIRStationsView::HandleStatusPaneSizeChange() |
|
609 { |
|
610 IRLOG_DEBUG( "CIRStationsView::HandleStatusPaneSizeChange - Entering" ); |
|
611 CIRBaseView::HandleStatusPaneSizeChange(); |
|
612 |
|
613 if ( iContainer ) |
|
614 { |
|
615 iContainer->SetRect( ClientRect() ); |
|
616 } |
|
617 IRLOG_DEBUG( "CIRStationsView::HandleStatusPaneSizeChange - Exiting" ); |
|
618 } |
|
619 |
|
620 // --------------------------------------------------------------------------- |
|
621 // CIRStationsView::AddToFavouritesL() |
|
622 // |
|
623 // --------------------------------------------------------------------------- |
|
624 // |
|
625 void CIRStationsView::AddToFavouritesL(TInt aCurrentIndex,TInt aCommand) |
|
626 { |
|
627 IRLOG_DEBUG( "CIRStationsView::AddToFavouritesL - Entering" ); |
|
628 iLoadingCancelled = EFalse; |
|
629 |
|
630 //request isds for preset data to be added to favorites |
|
631 iIsdsWrapper->IsdsPresetRequestL(this,aCurrentIndex,aCommand); |
|
632 |
|
633 //Display a loading Progress Bar |
|
634 IRLOG_DEBUG( "CIRStationsView::AddToFavouritesL - Exiting" ); |
|
635 } |
|
636 |
|
637 // --------------------------------------------------------------------------- |
|
638 // CIRStationsView::DisplayStationInformation() |
|
639 // |
|
640 // --------------------------------------------------------------------------- |
|
641 // |
|
642 void CIRStationsView::DisplayStationInformationL(TInt aCurrentIndex,TInt aCommand) |
|
643 { |
|
644 IRLOG_DEBUG( "CIRStationsView::DisplayStationInformationL - Entering" ); |
|
645 |
|
646 //request isds for preset data to be added to favorites |
|
647 iIsdsWrapper->IsdsPresetRequestL(this, aCurrentIndex, aCommand, EFalse); |
|
648 |
|
649 //Display a loading Progress Bar |
|
650 IRLOG_DEBUG( "CIRStationsView::DisplayStationInformationL - Exiting" ); |
|
651 } |
|
652 |
|
653 |
|
654 // --------------------------------------------------------------------------- |
|
655 // void CIRStationsView::ResponseL() |
|
656 // Activates the Stations view after getting the IsdsResponse |
|
657 // --------------------------------------------------------------------------- |
|
658 // |
|
659 void CIRStationsView::ResponseL( CIRIsdsPreset* /*aPreset*/ ) |
|
660 { |
|
661 IRLOG_DEBUG( "CIRStationsView::ResponseL - Entering" ); |
|
662 //TO DO :: The line can be removed in future written to fix |
|
663 // Code Scanner ERROR |
|
664 ResetPendingRequests(EFalse); |
|
665 IRLOG_DEBUG( "CIRStationsView::ResponseL - Exiting" ); |
|
666 |
|
667 } |
|
668 |
|
669 // --------------------------------------------------------------------------- |
|
670 // void CIRStationsView::PresetResponseL() |
|
671 // Issues Request to listen to a particular channel |
|
672 // --------------------------------------------------------------------------- |
|
673 // |
|
674 void CIRStationsView::PresetResponseL(CIRIsdsPreset* aPreset) |
|
675 { |
|
676 IRLOG_DEBUG( "CIRStationsView::PresetResponseL - Entering" ); |
|
677 if ( iUi->CheckAndNotifyLowDiskSpaceL() ) |
|
678 { |
|
679 return; |
|
680 } |
|
681 |
|
682 if( EStationDetailsCmd == iCommand ) |
|
683 { |
|
684 ResetPendingRequests(EFalse); |
|
685 iUi->iStationInfoView->SetStationPresetL( aPreset ); |
|
686 AppUi()->ActivateLocalViewL(KIRStationInfoViewId); |
|
687 } |
|
688 else |
|
689 { |
|
690 if(!iNowPlayingWrapper->GetWhenUserCancelsIsdsBufferingWaitBar()) |
|
691 { |
|
692 ResetPendingRequests(EFalse); |
|
693 iNowPlayingWrapper->SetListenFromIsdsValue(ETrue); |
|
694 iNowPlayingWrapper->ListenToChannelL(aPreset); |
|
695 } |
|
696 } |
|
697 IRLOG_DEBUG( "CIRStationsView::PresetResponseL - Exiting" ); |
|
698 } |
|
699 |
|
700 // --------------------------------------------------------------------------- |
|
701 // void CIRStationsView::ErrorL() |
|
702 // Handles the errors from Isds |
|
703 // --------------------------------------------------------------------------- |
|
704 // |
|
705 void CIRStationsView::ErrorL() |
|
706 { |
|
707 IRLOG_DEBUG( "CIRStationsView::ErrorL - Entering" ); |
|
708 if(iIsdsWrapper->GetListenRequest()) |
|
709 { |
|
710 IRRDEBUG2("CIRNowPlayingWrapper:: DestroyWaitDialog9", KNullDesC); |
|
711 iUi->GetPubSubManagerInstance()->PublishBufferingState(EIRStateBufferingError); |
|
712 iNowPlayingWrapper->DestroyWaitDialogL(); |
|
713 iIsdsWrapper->SetListenRequest(EFalse); |
|
714 } |
|
715 if(iIsdsWrapper->iConnTimeOut) |
|
716 { |
|
717 iIsdsWrapper->iConnTimeOut = EFalse; |
|
718 } |
|
719 IRLOG_DEBUG( "CIRStationsView::ErrorL - Exiting" ); |
|
720 } |
|
721 |
|
722 |
|
723 |
|
724 // --------------------------------------------------------------------------- |
|
725 // CIRStationsView::LogoRequestL() |
|
726 // called from the container |
|
727 // --------------------------------------------------------------------------- |
|
728 // |
|
729 void CIRStationsView::LogoRequestL() |
|
730 { |
|
731 IRLOG_DEBUG( "CIRStationsView::LogoRequestL - Entering" ); |
|
732 if(iContainer) |
|
733 { |
|
734 iUi->iIsdsWrapper->GetISDSInstance()->GetDataProvider()->GetHttpDataProvider()-> |
|
735 GetLogoDownloadEngine()->SendRequestL(iContainer->iTempPreset,this, |
|
736 KImageReqFrom,KImagesSize,KImagesSize); |
|
737 } |
|
738 IRLOG_DEBUG( "CIRStationsView::LogoRequestL - Exiting" ); |
|
739 } |
|
740 |
|
741 |
|
742 |
|
743 // --------------------------------------------------------------------------- |
|
744 // CIRStationsView::PresetLogoDownloadedL() |
|
745 // from base class MLogoDownloadObserver |
|
746 // --------------------------------------------------------------------------- |
|
747 // |
|
748 void CIRStationsView::PresetLogoDownloadedL(CIRIsdsPreset* aPreset) |
|
749 { |
|
750 IRLOG_DEBUG( "CIRStationsView::PresetLogoDownloadedL - Entering" ); |
|
751 if(iContainer) |
|
752 { |
|
753 iContainer->PresetLogoDownloadL(aPreset); |
|
754 } |
|
755 IRLOG_DEBUG( "CIRStationsView::PresetLogoDownloadedL - Exiting" ); |
|
756 } |
|
757 |
|
758 |
|
759 // --------------------------------------------------------------------------- |
|
760 // CIRStationsView::PresetLogoDownloadError() |
|
761 // from base class MLogoDownloadObserver |
|
762 // --------------------------------------------------------------------------- |
|
763 // |
|
764 void CIRStationsView::PresetLogoDownloadError(CIRIsdsPreset* /*aPreset*/) |
|
765 { |
|
766 IRLOG_DEBUG( "CIRStationsView::PresetLogoDownloadError" ); |
|
767 //call the API of stations view container |
|
768 if(iContainer) |
|
769 { |
|
770 TRAP_IGNORE(iContainer->HandleLogoErrorL()) |
|
771 } |
|
772 IRLOG_DEBUG( "CIRStationsView::PresetLogoDownloadError - Exiting" ); |
|
773 } |
|
774 |
|
775 |
|
776 // --------------------------------------------------------------------------- |
|
777 // CIRStationsView::LogoRequestL() |
|
778 // called from the container |
|
779 // --------------------------------------------------------------------------- |
|
780 // |
|
781 void CIRStationsView::AdRequestL() |
|
782 { |
|
783 IRLOG_DEBUG( "CIRStationsView::LogoRequestL - Entering" ); |
|
784 if(iContainer) |
|
785 { |
|
786 iUi->iIsdsWrapper->GetISDSInstance()->GetDataProvider()->GetHttpDataProvider()-> |
|
787 GetLogoDownloadEngine()->SendRequestL(iContainer->iAdvPreset,this); |
|
788 } |
|
789 IRLOG_DEBUG( "CIRStationsView::LogoRequestL - Exiting" ); |
|
790 } |
|
791 // --------------------------------------------------------------------------- |
|
792 // CIRStationsView::GetFilteredIndex() |
|
793 // Returns the filtered Index |
|
794 // --------------------------------------------------------------------------- |
|
795 // |
|
796 TInt CIRStationsView::GetFilteredIndex() |
|
797 { |
|
798 IRLOG_DEBUG( "CIRStationsView::GetFilteredIndex - Entering" ); |
|
799 return iFilteredIndex; |
|
800 } |
|
801 // --------------------------------------------------------------------------- |
|
802 // CIRStationsView::SetLoadingCancelled() |
|
803 // Sets iLoadingCancelled to aValue |
|
804 // --------------------------------------------------------------------------- |
|
805 // |
|
806 void CIRStationsView::SetLoadingCancelled(TBool aValue) |
|
807 { |
|
808 IRLOG_DEBUG( "CIRStationsView::SetLoadingCancelled - Entering" ); |
|
809 iLoadingCancelled = aValue; |
|
810 IRLOG_DEBUG( "CIRStationsView::SetLoadingCancelled - Exiting" ); |
|
811 } |
|
812 |
|
813 // --------------------------------------------------------- |
|
814 // CIRStationsView::SetActualFilteredItemIndex () |
|
815 // Sets the actual index of the station |
|
816 // --------------------------------------------------------- |
|
817 // |
|
818 void CIRStationsView::SetActualFilteredItemIndex(TInt aIndex) |
|
819 { |
|
820 IRLOG_DEBUG( "CIRStationsView::SetActualFilteredItemIndex - Entering." ); |
|
821 iIndex = aIndex; |
|
822 IRLOG_DEBUG( "CIRStationsView::SetActualFilteredItemIndex - Exiting." ); |
|
823 } |
|
824 // --------------------------------------------------------- |
|
825 // CIRStationsView::GetActualFilteredItemIndex () |
|
826 // Gets the actual index of the station |
|
827 // --------------------------------------------------------- |
|
828 // |
|
829 TInt CIRStationsView::GetActualFilteredItemIndex() |
|
830 { |
|
831 IRLOG_DEBUG( "CIRStationsView::GetActualFilteredItemIndex - Entering." ); |
|
832 IRLOG_DEBUG( "CIRStationsView::GetActualFilteredItemIndex - Exiting." ); |
|
833 return iIndex; |
|
834 } |
|
835 // --------------------------------------------------------------------------- |
|
836 // CIRStationsView::GetStationsViewActualIndex(). |
|
837 // Returns the actual index. |
|
838 // --------------------------------------------------------------------------- |
|
839 // |
|
840 TInt CIRStationsView::GetStationsViewActualIndex() |
|
841 { |
|
842 IRLOG_DEBUG( "CIRStationsViewContainer::GetStationsViewActualIndex - Entering" ); |
|
843 TInt currentIndex = iContainer->GetCurrentItemIndex(); |
|
844 SetCurrentFocus(currentIndex); |
|
845 TBuf<KFindStringLength> findstring ; |
|
846 if(iContainer->GetSearchBoxPointer()) |
|
847 { |
|
848 iContainer->GetSearchBoxPointer()->GetSearchText(findstring); |
|
849 } |
|
850 if(iContainer->GetSearchBoxPointer() && findstring.Length()!=0) |
|
851 { |
|
852 iFilteredIndex = currentIndex; |
|
853 iContainer->Comparestrings(); |
|
854 currentIndex = iIndex; |
|
855 } |
|
856 if(iContainer->GetLogoNotSupported()) |
|
857 { |
|
858 currentIndex = currentIndex +1; |
|
859 } |
|
860 |
|
861 IRLOG_DEBUG( "CIRStationsViewContainer::GetStationsViewActualIndex - Exiting" ); |
|
862 return currentIndex; |
|
863 } |
|
864 // --------------------------------------------------------- |
|
865 // CIRStationsView::GetFirstLaunchFlag () |
|
866 // returns whether is launching for the first time /coming from other view |
|
867 // which is activated from this view. |
|
868 // --------------------------------------------------------- |
|
869 // |
|
870 TBool CIRStationsView::GetFirstLaunchFlag() |
|
871 { |
|
872 IRLOG_DEBUG( "CIRStationsView::GetFirstLaunchFlag - Entering." ); |
|
873 IRLOG_DEBUG( "CIRStationsView::GetFirstLaunchFlag - Exiting." ); |
|
874 return iFirstTimeLaunchFlag; |
|
875 } |
|
876 // --------------------------------------------------------------------------- |
|
877 // void CIRStationsView::SetToolbarItems() |
|
878 // Setting toolbar items when text is entered |
|
879 // --------------------------------------------------------------------------- |
|
880 void CIRStationsView:: SetToolbarItems() |
|
881 { |
|
882 IRLOG_DEBUG( "CIRMainView::SetToolbarItems - Entering" ); |
|
883 if(Toolbar()) |
|
884 { |
|
885 if(iContainer) |
|
886 { |
|
887 Toolbar()->SetToolbarVisibility(ETrue, EFalse); |
|
888 if(iContainer->iStationsListBox) |
|
889 { |
|
890 TInt currentIndex = iContainer->GetCurrentItemIndex(); |
|
891 TBuf<KFindStringLength> findstring ; |
|
892 if(iContainer->GetSearchBoxPointer()) |
|
893 { |
|
894 iContainer->GetSearchBoxPointer()->GetSearchText(findstring); |
|
895 } |
|
896 TInt filterModelCount = iContainer->GetFilterdModelPointer()->NumberOfItems(); |
|
897 if(iContainer->GetSearchBoxPointer() && findstring.Length()!=0 |
|
898 && filterModelCount == 0) |
|
899 { |
|
900 Toolbar()->SetItemDimmed(EAddtoFavouritesCmd,ETrue,ETrue); |
|
901 Toolbar()->SetItemDimmed(EListenCmd,ETrue,ETrue); |
|
902 Toolbar()->SetItemDimmed(EStationDetailsCmd,ETrue,ETrue); |
|
903 } |
|
904 else |
|
905 { |
|
906 if (currentIndex == 0 && !iContainer->GetLogoNotSupported()) |
|
907 { |
|
908 if (iUi->iIsdsWrapper->GetBannerUrl()) |
|
909 { |
|
910 Toolbar()->SetItemDimmed(EAddtoFavouritesCmd,ETrue,ETrue); |
|
911 Toolbar()->SetItemDimmed(EListenCmd,ETrue,ETrue); |
|
912 Toolbar()->SetItemDimmed(EStationDetailsCmd,ETrue,ETrue); |
|
913 } |
|
914 else |
|
915 { |
|
916 Toolbar()->SetItemDimmed(EAddtoFavouritesCmd,EFalse,ETrue); |
|
917 Toolbar()->SetItemDimmed(EListenCmd,EFalse,ETrue); |
|
918 Toolbar()->SetItemDimmed(EStationDetailsCmd,EFalse,ETrue); |
|
919 } |
|
920 } |
|
921 else |
|
922 { |
|
923 Toolbar()->SetItemDimmed(EAddtoFavouritesCmd,EFalse,ETrue); |
|
924 Toolbar()->SetItemDimmed(EListenCmd,EFalse,ETrue); |
|
925 Toolbar()->SetItemDimmed(EStationDetailsCmd,EFalse,ETrue); |
|
926 } |
|
927 } |
|
928 Toolbar()->DrawNow(); |
|
929 } |
|
930 } |
|
931 } |
|
932 IRLOG_DEBUG( "CIRMainView::SetToolbarItems - Exiting" ); |
|
933 } |
|
934 |
|
935 // --------------------------------------------------------- |
|
936 // CIRStationsView::HandleSystemEventL |
|
937 // from base class MIRSystemEventObserver |
|
938 // --------------------------------------------------------- |
|
939 // |
|
940 void CIRStationsView::HandleSystemEventL(TIRSystemEventType aEventType) |
|
941 { |
|
942 IRLOG_DEBUG(" CIRNowPlayingView::::HandleSystemEventL - Entering"); |
|
943 |
|
944 CIRUi* appUi = static_cast<CIRUi*>(AppUi()); |
|
945 switch (aEventType) |
|
946 { |
|
947 case EIRCallActivated: |
|
948 { |
|
949 if( iUi->GetNetworkControllerInstance()->IdentifyConnectionType() != EWiFi ) |
|
950 { |
|
951 if(iUi->iIsdsWrapper->iIsdsWaitDialog) |
|
952 { |
|
953 TRAP_IGNORE( iUi->iIsdsWrapper->DestroyWaitDialogL() ); |
|
954 } |
|
955 if((!iCallRequestPending && iCommand==EStationDetailsCmd) || |
|
956 (!iCallRequestPending && iCommand==EAddtoFavouritesCmd)) |
|
957 { |
|
958 iUi->iIsdsWrapper->IsdsCancelRequest(); |
|
959 iCallRequestPending = ETrue; |
|
960 } |
|
961 if(iUi->iIsdsWrapper->GetListenRequest()) |
|
962 { |
|
963 iNowPlayingWrapper->DestroyWaitDialogL(); |
|
964 iUi->iIsdsWrapper->SetListenRequest(EFalse); |
|
965 iUi->iIsdsWrapper->IsdsCancelRequest(); |
|
966 } |
|
967 } |
|
968 break; |
|
969 } |
|
970 case EIRCallDeactivated: |
|
971 { |
|
972 if((iCallRequestPending && iCommand==EStationDetailsCmd) || |
|
973 (iCallRequestPending && iCommand==EAddtoFavouritesCmd)) |
|
974 { |
|
975 iCallRequestPending = EFalse; |
|
976 HandleCommandL( iCommand ); |
|
977 } |
|
978 break; |
|
979 } |
|
980 default: |
|
981 { |
|
982 break; |
|
983 } |
|
984 } |
|
985 IRLOG_DEBUG( "CIRNowPlayingView::HandleSystemEventL - Exiting." ); |
|
986 } |
|
987 |
|
988 |
|
989 // --------------------------------------------------------------------------- |
|
990 //Notifies all observers whose network request is active |
|
991 // to reissue the request |
|
992 //NotifyActiveNetworkObserversL() |
|
993 // --------------------------------------------------------------------------- |
|
994 |
|
995 void CIRStationsView::NotifyActiveNetworkObserversL(TIRNetworkEvent aEvent) |
|
996 { |
|
997 IRLOG_DEBUG( "CIRStationsView::NotifyActiveNetworkObserversL - Entering." ); |
|
998 IRRDEBUG2("CIRStationsView::NotifyActiveNetworkObserversL entering ", KNullDesC); |
|
999 |
|
1000 switch(aEvent) |
|
1001 { |
|
1002 case ENetworkConnectionDisconnected: |
|
1003 { |
|
1004 iNowPlayingWrapper->HandleNetworkDisconnected(); |
|
1005 } |
|
1006 break; |
|
1007 case ENetworkConnectionEstablished : |
|
1008 { |
|
1009 |
|
1010 if(iContainer) |
|
1011 { |
|
1012 if(iRequestPending || iUi->iNetworkController->IsHandingOverConnection()) |
|
1013 { |
|
1014 if(iAddToFav) |
|
1015 { |
|
1016 iAddToFav = ETrue; |
|
1017 iListenRequest = EFalse; |
|
1018 iStationDetails = EFalse; |
|
1019 AddToFavouritesL(GetStationsViewActualIndex(),EAddtoFavouritesCmd); |
|
1020 } |
|
1021 else if (iStationDetails) |
|
1022 { |
|
1023 iStationDetails = ETrue; |
|
1024 iAddToFav = EFalse; |
|
1025 iListenRequest = EFalse; |
|
1026 TInt currentIndex = GetStationsViewActualIndex(); |
|
1027 SetCurrentFocus(currentIndex); |
|
1028 DisplayStationInformationL(currentIndex, EStationDetailsCmd); |
|
1029 } |
|
1030 else if(iListenRequest) |
|
1031 { |
|
1032 iListenRequest = EFalse; |
|
1033 SetCurrentFocus(GetStationsViewActualIndex()); |
|
1034 ListenChannelL(GetStationsViewActualIndex()); |
|
1035 } |
|
1036 else |
|
1037 { |
|
1038 |
|
1039 } |
|
1040 } |
|
1041 } |
|
1042 if(iUi->iNetworkController->IsHandingOverConnection()) |
|
1043 ResetPendingRequests(EFalse); |
|
1044 } |
|
1045 } |
|
1046 |
|
1047 IRLOG_DEBUG( "CIRStationsView::NotifyActiveNetworkObserversL - Exiting." ); |
|
1048 IRRDEBUG2("CIRStationsView::NotifyActiveNetworkObserversL exiting ", KNullDesC); |
|
1049 |
|
1050 } |
|
1051 |
|
1052 |
|
1053 |
|
1054 // ----------------------------------------------------------------------------- |
|
1055 // Notified by network controller when user cancels network connection, to reset |
|
1056 // the pending requests |
|
1057 // ResetPendingRequests() |
|
1058 // ----------------------------------------------------------------------------- |
|
1059 void CIRStationsView::ResetPendingRequests(TBool aValue) |
|
1060 { |
|
1061 iRequestPending = aValue; |
|
1062 iAddToFav = aValue; |
|
1063 iListenRequest = aValue; |
|
1064 iStationDetails = aValue; |
|
1065 |
|
1066 } |