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: Container class for IRHistoryListContainer |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 /* --------------------------------------------------------------------------- |
|
20 * Version history: |
|
21 * Template version: |
|
22 * <ccm_history> |
|
23 * |
|
24 * Version: 2, Thu Apr 10 20:00:00 2008 by Rohit |
|
25 * Ref: |
|
26 * Implemented SongHistory changes for channelwise songs |
|
27 * |
|
28 * </ccm_history> |
|
29 * ============================================================================ |
|
30 */ |
|
31 |
|
32 #include <stringloader.h> |
|
33 #include <internetradio.rsg> |
|
34 #include "iraap.hlp.hrh" |
|
35 #include <aknsinglestyletreelist.h> |
|
36 #include <aknsbasicbackgroundcontrolcontext.h> |
|
37 #include <akntoolbar.h> |
|
38 |
|
39 #include "irsonghistoryengine.h" |
|
40 #include "irui.h" |
|
41 #include "ir.hrh" |
|
42 #include "ircommon.h" |
|
43 #include "irdebug.h" |
|
44 #include "irbaseview.h" |
|
45 #include "irhistorylistview.h" |
|
46 #include "irhistorylistcontainer.h" |
|
47 #include "irapplication.h" |
|
48 #include "irsonghistoryinfo.h" |
|
49 #include "irnowplayingwrapper.h" |
|
50 #include "irfavoritesdb.h" |
|
51 #include "irisdswrapper.h" |
|
52 #include "irisdspreset.h" |
|
53 #include "irpubsub.h" |
|
54 |
|
55 const TInt KMaxSize = 5; |
|
56 const TInt KTwo = 2 ; |
|
57 _LIT(KNo,"No"); |
|
58 |
|
59 //----------------------------------------------------------------------------- |
|
60 // CIRHistoryListContainer::NewL |
|
61 // Creates a new instance of History Container |
|
62 //----------------------------------------------------------------------------- |
|
63 // |
|
64 CIRHistoryListContainer* CIRHistoryListContainer::NewL( |
|
65 const TRect& aRect,CIRHistoryListView& aView, |
|
66 RPointerArray<CIRSongHistoryInfo>& aHistoryDataArr) |
|
67 { |
|
68 IRLOG_DEBUG( "CIRHistoryListContainer::NewL - Entering" ); |
|
69 CIRHistoryListContainer* self = CIRHistoryListContainer::NewLC(aRect,aView,aHistoryDataArr); |
|
70 CleanupStack::Pop(self); |
|
71 IRLOG_DEBUG( "CIRHistoryListContainer::NewL - Exiting." ); |
|
72 return self; |
|
73 } |
|
74 |
|
75 //----------------------------------------------------------------------------- |
|
76 // CIRHistoryListContainer::NewLC |
|
77 // Creates a new instance of History Container and leaves it on the cleanup stack. |
|
78 //----------------------------------------------------------------------------- |
|
79 // |
|
80 CIRHistoryListContainer* CIRHistoryListContainer::NewLC(const TRect& aRect , |
|
81 CIRHistoryListView& aView ,RPointerArray<CIRSongHistoryInfo>& aHistoryDataArr) |
|
82 { |
|
83 IRLOG_DEBUG( "CIRHistoryListContainer::NewLC - Entering" ); |
|
84 CIRHistoryListContainer* self = new (ELeave) CIRHistoryListContainer(aView); |
|
85 CleanupStack::PushL(self); |
|
86 self->ConstructL(aRect,aHistoryDataArr); |
|
87 IRLOG_DEBUG( "CIRHistoryListContainer::NewLC - Exiting." ); |
|
88 return self; |
|
89 } |
|
90 |
|
91 // --------------------------------------------------------------------------- |
|
92 // C++ default constructor can NOT contain any code, that might leave. |
|
93 // --------------------------------------------------------------------------- |
|
94 // |
|
95 CIRHistoryListContainer::CIRHistoryListContainer( CIRHistoryListView& aHistoryListView): |
|
96 iHistoryListView( aHistoryListView ) |
|
97 { |
|
98 IRLOG_DEBUG( "CIRHistoryListContainer::CIRHistoryListContainer" ); |
|
99 iDimmed=ETrue; |
|
100 } |
|
101 |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // CIRHistoryListContainer::ConstructL |
|
105 // --------------------------------------------------------------------------- |
|
106 // |
|
107 void CIRHistoryListContainer::ConstructL( const TRect& aRect, |
|
108 RPointerArray<CIRSongHistoryInfo>& aHistoryDataArr |
|
109 ) |
|
110 { |
|
111 IRLOG_DEBUG( "CIRHistoryListContainer::ConstructL - Entering" ); |
|
112 CreateWindowL(); |
|
113 |
|
114 InitComponentArrayL(); |
|
115 Components().SetControlsOwnedExternally( ETrue ); |
|
116 CAknSingleStyleTreeList* list =CAknSingleStyleTreeList::NewL( *this ); |
|
117 // Use list as a component control of the view. |
|
118 Components().AppendLC( list, KCoeNoControlId ); |
|
119 CleanupStack::Pop( list ); |
|
120 iTreeListBox = list; |
|
121 iTreeListBox->SetContainerWindowL(*this); |
|
122 iTreeListBox->SetFlags( iTreeListBox->Flags() ^ KAknTreeListLooping ^ |
|
123 KAknTreeListNoStructureLines ^ KAknTreeListMarqueeScrolling); |
|
124 iTreeListBox->AddObserverL( this ); |
|
125 iBgContext = CAknsBasicBackgroundControlContext::NewL( |
|
126 KAknsIIDQsnBgAreaMain, iAvkonAppUi->ApplicationRect(), EFalse ); |
|
127 |
|
128 |
|
129 iChannelArray=new ( ELeave ) CDesC16ArrayFlat (KMaxSize); |
|
130 iUrlArray=new ( ELeave ) CDesC16ArrayFlat (KMaxSize); |
|
131 iChannelDescriptionArray=new ( ELeave ) CDesC16ArrayFlat (KMaxSize); |
|
132 iMusicStoreStatus=new ( ELeave ) CDesC16ArrayFlat (KMaxSize); |
|
133 |
|
134 UpdateAllL(aHistoryDataArr); |
|
135 iTreeListBox->SetRect(aRect); |
|
136 iTreeListBox->SetFocus(ETrue); |
|
137 iTreeListBox->MakeVisible(ETrue); |
|
138 SetRect( aRect ); |
|
139 DrawNow(); |
|
140 iTreeListBox->DrawNow(); |
|
141 IRLOG_DEBUG( "CIRHistoryListContainer::ConstructL - Exiting" ); |
|
142 } |
|
143 |
|
144 // --------------------------------------------------------------------------- |
|
145 // Destructor |
|
146 // --------------------------------------------------------------------------- |
|
147 // |
|
148 CIRHistoryListContainer::~CIRHistoryListContainer() |
|
149 { |
|
150 |
|
151 IRLOG_DEBUG( "CIRHistoryListContainer::~CIRHistoryListContainer - Entering" ); |
|
152 if(iTreeListBox) |
|
153 { |
|
154 delete iTreeListBox; |
|
155 iTreeListBox = NULL; |
|
156 } |
|
157 |
|
158 iNodeArray.Close(); |
|
159 |
|
160 iLeafArray.Close(); |
|
161 |
|
162 iChannelTypeArray.Close(); |
|
163 |
|
164 iChannelIdArray.Close(); |
|
165 |
|
166 if(iBgContext) |
|
167 { |
|
168 delete iBgContext; |
|
169 iBgContext = NULL; |
|
170 } |
|
171 |
|
172 if(iUrlArray) |
|
173 { |
|
174 iUrlArray->Reset(); |
|
175 delete iUrlArray; |
|
176 iUrlArray=NULL; |
|
177 } |
|
178 if(iChannelArray) |
|
179 { |
|
180 iChannelArray->Reset(); |
|
181 delete iChannelArray; |
|
182 iChannelArray=NULL; |
|
183 } |
|
184 if(iChannelDescriptionArray) |
|
185 { |
|
186 iChannelDescriptionArray->Reset(); |
|
187 delete iChannelDescriptionArray; |
|
188 iChannelDescriptionArray=NULL; |
|
189 } |
|
190 if(iMusicStoreStatus) |
|
191 { |
|
192 iMusicStoreStatus->Reset(); |
|
193 delete iMusicStoreStatus; |
|
194 iMusicStoreStatus=NULL; |
|
195 } |
|
196 IRLOG_DEBUG( "CIRHistoryListContainer::~CIRHistoryListContainer - Exiting" ); |
|
197 } |
|
198 |
|
199 // --------------------------------------------------------------------------- |
|
200 // From class CCoeControl. |
|
201 // We need to catch the selection key event in order to do a couple of things |
|
202 // in moving state make the movement, and in normal state open channel |
|
203 // specific popup menu. Up and down buttons are forwarded to the list. |
|
204 // --------------------------------------------------------------------------- |
|
205 // |
|
206 TKeyResponse CIRHistoryListContainer::OfferKeyEventL( |
|
207 const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
208 { |
|
209 IRLOG_DEBUG( "CIRHistoryListContainer::OfferKeyEventL -Entering" ); |
|
210 if(iTreeListBox) |
|
211 { |
|
212 IRLOG_DEBUG( "CIRHistoryListContainer::OfferKeyEventL -Exiting" ); |
|
213 return iTreeListBox->OfferKeyEventL(aKeyEvent, aType); |
|
214 } |
|
215 return EKeyWasNotConsumed; |
|
216 } |
|
217 |
|
218 void CIRHistoryListContainer::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
|
219 { |
|
220 IRLOG_DEBUG( "CIRHistoryListContainer::HandlePointerEventL - Entering" ); |
|
221 if(iTreeListBox) |
|
222 { |
|
223 iTreeListBox->HandlePointerEventL( aPointerEvent ); |
|
224 } |
|
225 IRLOG_DEBUG( "CIRHistoryListContainer::HandlePointerEventL - Exiting" ); |
|
226 } |
|
227 |
|
228 // --------------------------------------------------------------------------- |
|
229 // CIRHistoryListContainer::UpdateAllL() |
|
230 // Fills list with data read from data base. |
|
231 // --------------------------------------------------------------------------- |
|
232 // |
|
233 void CIRHistoryListContainer::UpdateAllL(RPointerArray<CIRSongHistoryInfo> & aHistoryDataArr) |
|
234 { |
|
235 IRLOG_DEBUG( "CIRHistoryListContainer::UpdateAllL - Entering" ); |
|
236 if(aHistoryDataArr.Count()==0) |
|
237 { |
|
238 iTreeListBox->DrawNow(); |
|
239 HBufC* headerText = StringLoader::LoadLC(R_IRAPP_CLEAR_HISTORY); |
|
240 iTreeListBox->SetEmptyTextL(*headerText); |
|
241 CleanupStack::PopAndDestroy(headerText); |
|
242 |
|
243 } |
|
244 else |
|
245 { |
|
246 |
|
247 |
|
248 TUint32 flags = CAknSingleStyleTreeList::EPersistent; |
|
249 TBool drawNow = EFalse; |
|
250 |
|
251 for(TInt songCount = 0; songCount < aHistoryDataArr.Count(); songCount++) |
|
252 { |
|
253 if(songCount==0) |
|
254 { |
|
255 iChannelArray->AppendL(aHistoryDataArr[songCount]->GetChannelName()); |
|
256 iUrlArray->AppendL(aHistoryDataArr[songCount]->GetStreamUrl()); |
|
257 iChannelTypeArray.Append(aHistoryDataArr[songCount]->GetChannelType()); |
|
258 iChannelIdArray.Append(aHistoryDataArr[songCount]->GetChannelId()); |
|
259 iChannelDescriptionArray->AppendL(aHistoryDataArr[songCount]->GetChannelDesc()); |
|
260 iMusicStoreStatus->AppendL(aHistoryDataArr[songCount]->GetChannelMusicStatus()); |
|
261 } |
|
262 else |
|
263 { |
|
264 TBool nextChannel=EFalse; |
|
265 for(TInt comp=0;comp<iChannelArray->Count();comp++) |
|
266 { |
|
267 if((aHistoryDataArr[songCount]->GetChannelName()==iChannelArray->MdcaPoint(comp)) && |
|
268 (aHistoryDataArr[songCount]->GetStreamUrl()==iUrlArray->MdcaPoint(comp)) && |
|
269 (aHistoryDataArr[songCount]->GetChannelType()==iChannelTypeArray[comp])) |
|
270 { |
|
271 nextChannel=ETrue; |
|
272 } |
|
273 |
|
274 |
|
275 |
|
276 } |
|
277 if(!nextChannel) |
|
278 { |
|
279 |
|
280 iChannelArray->AppendL(aHistoryDataArr[songCount]->GetChannelName()); |
|
281 iUrlArray->AppendL(aHistoryDataArr[songCount]->GetStreamUrl()); |
|
282 iChannelTypeArray.Append(aHistoryDataArr[songCount]->GetChannelType()); |
|
283 iChannelIdArray.Append(aHistoryDataArr[songCount]->GetChannelId()); |
|
284 iChannelDescriptionArray->AppendL(aHistoryDataArr[songCount]-> |
|
285 GetChannelDesc()); |
|
286 iMusicStoreStatus->AppendL(aHistoryDataArr[songCount]-> |
|
287 GetChannelMusicStatus()); |
|
288 |
|
289 } |
|
290 |
|
291 } |
|
292 |
|
293 } |
|
294 for(TInt index=0;index<iChannelArray->Count();index++) |
|
295 { |
|
296 |
|
297 TAknTreeItemID subtitle = iTreeListBox->AddNodeL( 1, |
|
298 iChannelArray->MdcaPoint(index), |
|
299 flags, |
|
300 drawNow ); |
|
301 iNodeArray.Append(subtitle); |
|
302 } |
|
303 for(TInt songCount = 0; songCount < aHistoryDataArr.Count(); songCount++) |
|
304 { |
|
305 for(TInt index=0;index<iChannelArray->Count();index++) |
|
306 { |
|
307 if((aHistoryDataArr[songCount]->GetChannelName()==iChannelArray->MdcaPoint(index)) && |
|
308 (aHistoryDataArr[songCount]->GetStreamUrl()==iUrlArray->MdcaPoint(index)) && |
|
309 (aHistoryDataArr[songCount]->GetChannelType()==iChannelTypeArray[index])) |
|
310 { |
|
311 HBufC* text ; |
|
312 CDesCArray* strings = new ( ELeave ) CDesCArrayFlat( 2 ); |
|
313 CleanupStack::PushL( strings ); |
|
314 if(aHistoryDataArr[songCount]->GetArtistInfo() != KNullDesC && |
|
315 aHistoryDataArr[songCount]->GetSongInfo() != KNullDesC) |
|
316 { |
|
317 strings->AppendL(aHistoryDataArr[songCount]->GetArtistInfo()); |
|
318 strings->AppendL(aHistoryDataArr[songCount]->GetSongInfo()); |
|
319 text = StringLoader::LoadLC( R_IR_HISTORY_ARTIST_SONG, *strings ); |
|
320 } |
|
321 else if(aHistoryDataArr[songCount]->GetArtistInfo() != KNullDesC) |
|
322 { |
|
323 text = HBufC::NewLC( aHistoryDataArr[songCount]-> |
|
324 GetArtistInfo().Length() + KTwo ); |
|
325 text->Des().Copy(aHistoryDataArr[songCount]->GetArtistInfo()); |
|
326 } |
|
327 else |
|
328 { |
|
329 text = HBufC::NewLC( aHistoryDataArr[songCount]-> |
|
330 GetSongInfo().Length() + KTwo ); |
|
331 text->Des().Copy(aHistoryDataArr[songCount]->GetSongInfo()); |
|
332 } |
|
333 if(index>=0 && index<iNodeArray.Count()) |
|
334 { |
|
335 TAknTreeItemID coreItem = iTreeListBox->AddLeafL( iNodeArray[index], |
|
336 *text, flags, drawNow ); |
|
337 iTreeListBox->SetIcon( coreItem, CAknSingleStyleTreeList::ELeaf, NULL, ETrue ); |
|
338 iLeafArray.AppendL(coreItem); |
|
339 } |
|
340 CleanupStack::PopAndDestroy( text ); |
|
341 CleanupStack::PopAndDestroy( strings ); |
|
342 } |
|
343 |
|
344 |
|
345 } |
|
346 |
|
347 } |
|
348 iTreeListBox->DrawNow(); |
|
349 if(iHistoryListView.Toolbar()) |
|
350 { |
|
351 iHistoryListView.Toolbar()->SetItemDimmed(EListenCmd,EFalse,ETrue); |
|
352 iHistoryListView.Toolbar()->DrawNow(); |
|
353 } |
|
354 } |
|
355 IRLOG_DEBUG( "CIRHistoryListContainer::UpdateAllL - Exiting" ); |
|
356 |
|
357 |
|
358 } |
|
359 // --------------------------------------------------------------------------- |
|
360 // CIRHistoryListContainer::RemoveListItem() |
|
361 // Removes data from the list read from data base. |
|
362 // --------------------------------------------------------------------------- |
|
363 // |
|
364 void CIRHistoryListContainer::RemoveListItem(const TDesC &/*aSongName*/ , const TDesC & /*aArtistName*/, const TDesC & /*aChannelName*/) |
|
365 { |
|
366 IRLOG_DEBUG( "CIRHistoryListContainer::RemoveListItem" ); |
|
367 } |
|
368 |
|
369 |
|
370 // --------------------------------------------------------------------------- |
|
371 // From class CCoeControl. |
|
372 // Draws the control. |
|
373 // --------------------------------------------------------------------------- |
|
374 // |
|
375 void CIRHistoryListContainer::Draw( const TRect& /*aRect*/ ) const |
|
376 { |
|
377 IRLOG_DEBUG( "CIRHistoryListContainer::Draw" ); |
|
378 } |
|
379 |
|
380 |
|
381 // --------------------------------------------------------------------------- |
|
382 // From class CCoeControl. |
|
383 // Opens help by context. |
|
384 // --------------------------------------------------------------------------- |
|
385 // |
|
386 void CIRHistoryListContainer::GetHelpContext( TCoeHelpContext& aContext ) const |
|
387 { |
|
388 IRLOG_DEBUG( "CIRHistoryListContainer::GetHelpContext - Entering" ); |
|
389 aContext = TCoeHelpContext( KIRMCVUid, KIR_HELP_STATIONS ); |
|
390 IRLOG_DEBUG( "CIRHistoryListContainer::GetHelpContext - Exiting" ); |
|
391 } |
|
392 |
|
393 // --------------------------------------------------------------------------- |
|
394 // CIRHistoryListContainer::ClearHistoryListL(). |
|
395 // Clears the List |
|
396 // --------------------------------------------------------------------------- |
|
397 // |
|
398 void CIRHistoryListContainer::ClearHistoryListL() |
|
399 { |
|
400 IRLOG_DEBUG( "CIRHistoryListContainer::ClearHistoryListL - Entering" ); |
|
401 HBufC* headerText = StringLoader::LoadLC(R_IRAPP_CLEAR_HISTORY); |
|
402 iTreeListBox->SetEmptyTextL(* headerText); |
|
403 CleanupStack::PopAndDestroy(headerText); |
|
404 for(TInt index=0;index<iNodeArray.Count();index++) |
|
405 { |
|
406 iTreeListBox->RemoveItem( iNodeArray[index], EFalse ); |
|
407 } |
|
408 |
|
409 iNodeArray.Reset(); |
|
410 iLeafArray.Reset(); |
|
411 iChannelTypeArray.Reset(); |
|
412 iChannelIdArray.Reset(); |
|
413 if(iUrlArray) |
|
414 { |
|
415 iUrlArray->Reset(); |
|
416 } |
|
417 if(iMusicStoreStatus) |
|
418 { |
|
419 iMusicStoreStatus->Reset(); |
|
420 } |
|
421 if(iChannelArray) |
|
422 { |
|
423 iChannelArray->Reset(); |
|
424 } |
|
425 if(iChannelDescriptionArray) |
|
426 { |
|
427 iChannelDescriptionArray->Reset(); |
|
428 } |
|
429 |
|
430 IRLOG_DEBUG( "CIRHistoryListContainer::ClearHistoryListL - Exiting" ); |
|
431 } |
|
432 |
|
433 // --------------------------------------------------------------------------- |
|
434 // CIRHistoryListContainer::ListenUrlL() |
|
435 // Listen a URL and displays Now Playing |
|
436 // --------------------------------------------------------------------------- |
|
437 // |
|
438 void CIRHistoryListContainer::ListenUrlL( TInt aIndex ) |
|
439 { |
|
440 IRLOG_DEBUG( "CIRHistoryListContainer::ListenUrlL - Entering" ); |
|
441 iHistoryListView.iNowPlayingWrapper->SetView(EHistoryView); |
|
442 |
|
443 iListenFrmHistory = ETrue ; |
|
444 iAddFrmHistory = EFalse; |
|
445 // Listen the URL |
|
446 if(aIndex>=0 && aIndex<iChannelTypeArray.Count()) |
|
447 { |
|
448 if(iChannelTypeArray[aIndex]==0) |
|
449 { |
|
450 CIRIsdsPreset* preset = CIRIsdsPreset::NewL(); |
|
451 CleanupStack::PushL( preset ); |
|
452 preset->SetName(iChannelArray->MdcaPoint(aIndex)); |
|
453 if(aIndex>=0 && aIndex<iChannelTypeArray.Count()) |
|
454 { |
|
455 preset->SetChannelType(iChannelTypeArray[aIndex]); |
|
456 } |
|
457 preset->SetShortDesc(iChannelDescriptionArray->MdcaPoint(aIndex )); |
|
458 preset->SetDescription(iChannelDescriptionArray->MdcaPoint(aIndex )); |
|
459 //Set the URL data. |
|
460 _LIT(KNA,"NA"); |
|
461 preset->SetUrlL( KNA, iUrlArray->MdcaPoint(aIndex ), 0 ); |
|
462 preset->SetUrlCount(); |
|
463 // Set the channel as last played and currently playing |
|
464 *iHistoryListView.iNowPlayingWrapper->iNowPlayingPreset = *preset; |
|
465 CleanupStack::PopAndDestroy( preset ); |
|
466 |
|
467 iHistoryListView.iUi->iNPPrevViewId = KIRHistoryListViewId; |
|
468 |
|
469 //connecting to server |
|
470 iHistoryListView.iNowPlayingWrapper->SetCurrentConnectionSource(EIRHistoryAdhoc); |
|
471 iHistoryListView.iNowPlayingWrapper->ConnectToChannelL(*iHistoryListView. |
|
472 iNowPlayingWrapper->iNowPlayingPreset); |
|
473 } |
|
474 else |
|
475 { |
|
476 iHistoryListView.iUi->iNPPrevViewId = KIRHistoryListViewId; |
|
477 if(aIndex>=0 && aIndex<iChannelIdArray.Count()) |
|
478 { |
|
479 iChannelSyncId = iChannelIdArray[aIndex] ; |
|
480 iChangedIndex = aIndex; |
|
481 iHistoryListView.iNowPlayingWrapper->SetWhenUserCancelsBufferingWaitBar(EFalse); |
|
482 iHistoryListView.iNowPlayingWrapper->SetListenFromIsdsValue(EFalse); |
|
483 iHistoryListView.iNowPlayingWrapper->CreateWaitDialogL(); |
|
484 iHistoryListView.iUi->GetPubSubManagerInstance()->PublishBufferingState( |
|
485 EIRStateBufferingStart); |
|
486 iHistoryListView.iIsdsWrapper->IsdsListenRequestL(this,iChannelIdArray[aIndex],ETrue); |
|
487 } |
|
488 } |
|
489 } |
|
490 IRLOG_DEBUG( "CIRHistoryListContainer::ListenUrlL - Exiting" ); |
|
491 } |
|
492 |
|
493 |
|
494 // --------------------------------------------------------------------------- |
|
495 // void CIRHistoryListContainer::SizeChanged(const TRect& aRect) |
|
496 // |
|
497 // --------------------------------------------------------------------------- |
|
498 // |
|
499 |
|
500 void CIRHistoryListContainer::SizeChanged() |
|
501 { |
|
502 IRLOG_DEBUG( "CIRHistoryListContainer::SizeChanged - Entering" ); |
|
503 TRect rect = Rect(); |
|
504 if (iTreeListBox) |
|
505 { |
|
506 iTreeListBox->SetRect( rect ); |
|
507 } |
|
508 if ( iBgContext ) |
|
509 { |
|
510 iBgContext->SetRect( rect ); |
|
511 } |
|
512 IRLOG_DEBUG( "CIRHistoryListContainer::SizeChanged - Exiting" ); |
|
513 } |
|
514 |
|
515 //---------------------------------------------------------------------------- |
|
516 // CIRHistoryListContainer::CountComponentControls() const |
|
517 // returns the number of components in the view. |
|
518 //---------------------------------------------------------------------------- |
|
519 // |
|
520 TInt CIRHistoryListContainer::CountComponentControls() const |
|
521 { |
|
522 IRLOG_DEBUG( "CIRHistoryListContainer::CountComponentControls" ); |
|
523 return 1; |
|
524 } |
|
525 //---------------------------------------------------------------------------- |
|
526 // CIRHistoryListContainer::ComponentControl() const |
|
527 // returns a pointer to the control under this view depending on the index |
|
528 // passed,to the framework. |
|
529 //---------------------------------------------------------------------------- |
|
530 // |
|
531 CCoeControl* CIRHistoryListContainer::ComponentControl(TInt /*aIndex*/) const |
|
532 { |
|
533 IRLOG_DEBUG( "CIRHistoryListContainer::ComponentControl" ); |
|
534 return iTreeListBox; |
|
535 } |
|
536 |
|
537 // ---------------------------------------------------- |
|
538 // CIRHistoryListContainer::HandleTreeListEvent |
|
539 // From MAknTreeListObserver . |
|
540 // Handles the events on the TreeList |
|
541 // ---------------------------------------------------- |
|
542 // |
|
543 TBool CIRHistoryListContainer::HandleTreeListEvent( CAknTreeList& aList, |
|
544 TAknTreeItemID /* aItem */, TEvent aEvent ) |
|
545 { |
|
546 IRLOG_DEBUG( "CIRHistoryListContainer::HandleTreeListEvent - Entering" ); |
|
547 if ( &aList != iTreeListBox ) |
|
548 { |
|
549 return KErrNone; |
|
550 } |
|
551 |
|
552 switch ( aEvent ) |
|
553 { |
|
554 // One of the nodes in the list is being expanded. |
|
555 case ENodeExpanded: |
|
556 // One of the nodes in the list is being collapsed. |
|
557 case ENodeCollapsed: |
|
558 // Simple data row or core data row is selected. |
|
559 case EItemSelected: |
|
560 break; |
|
561 // Focused item changes |
|
562 case EItemFocused: |
|
563 { |
|
564 _LIT(KMusicStoreEnabled, "yes"); |
|
565 if(iHistoryListView.Toolbar()) |
|
566 { |
|
567 if(!ShowFocus()) |
|
568 { |
|
569 iHistoryListView.Toolbar()->SetItemDimmed(EFindInShop,ETrue,ETrue); |
|
570 iDimmed=ETrue; |
|
571 |
|
572 } |
|
573 else |
|
574 { |
|
575 TInt itemIndex =GetCurrentFocussedNode(); |
|
576 if(itemIndex>=0 && itemIndex<iMusicStoreStatus->MdcaCount() ) |
|
577 { |
|
578 TInt comp=(iMusicStoreStatus->MdcaPoint(itemIndex)).Compare(KMusicStoreEnabled); |
|
579 if(comp) |
|
580 { |
|
581 iHistoryListView.Toolbar()->SetItemDimmed(EFindInShop,ETrue,ETrue); |
|
582 iDimmed=ETrue; |
|
583 } |
|
584 else |
|
585 { |
|
586 if(iHistoryListView.GetFindInShopInstance()) |
|
587 { |
|
588 iHistoryListView.Toolbar()->SetItemDimmed(EFindInShop,EFalse,ETrue); |
|
589 iDimmed=EFalse; |
|
590 } |
|
591 else |
|
592 { |
|
593 iHistoryListView.Toolbar()->SetItemDimmed(EFindInShop,ETrue,ETrue); |
|
594 iDimmed=ETrue; |
|
595 } |
|
596 } |
|
597 } |
|
598 } |
|
599 iHistoryListView.Toolbar()->DrawNow(); |
|
600 } |
|
601 |
|
602 } |
|
603 break; |
|
604 // Item is being removed from the list. |
|
605 case EItemRemoved: |
|
606 case EMarkingModeEnabled: |
|
607 case EMarkingModeDisabled: |
|
608 case EItemUnmarked: |
|
609 case EItemMarked: |
|
610 break; |
|
611 |
|
612 default: |
|
613 break; |
|
614 } |
|
615 IRLOG_DEBUG( "CIRHistoryListContainer::HandleTreeListEvent - Exiting" ); |
|
616 return KErrNone; |
|
617 } |
|
618 |
|
619 // ---------------------------------------------------- |
|
620 // CIRHistoryListContainer::MopSupplyObject() |
|
621 // ---------------------------------------------------- |
|
622 // |
|
623 TTypeUid::Ptr CIRHistoryListContainer::MopSupplyObject( TTypeUid aId ) |
|
624 { |
|
625 IRLOG_DEBUG( "CIRHistoryListContainer::MopSupplyObject - Entering" ); |
|
626 if ( aId.iUid == MAknsControlContext::ETypeId && iBgContext ) |
|
627 { |
|
628 IRLOG_DEBUG( "CIRHistoryListContainer::MopSupplyObject - Exiting" ); |
|
629 return MAknsControlContext::SupplyMopObject( aId, iBgContext ); |
|
630 } |
|
631 IRLOG_DEBUG( "CIRHistoryListContainer::MopSupplyObject - Exiting" ); |
|
632 return CCoeControl::MopSupplyObject( aId ); |
|
633 } |
|
634 |
|
635 // ---------------------------------------------------- |
|
636 // CIRHistoryListContainer::HandleResourceChange() |
|
637 // Handles Changes in the resources |
|
638 // ---------------------------------------------------- |
|
639 // |
|
640 void CIRHistoryListContainer::HandleResourceChange( TInt aType ) |
|
641 { |
|
642 IRLOG_DEBUG( "CIRHistoryListContainer::HandleResourceChange - Entering" ); |
|
643 CCoeControl::HandleResourceChange( aType ); |
|
644 CIRUi* ui = reinterpret_cast<CIRUi*>( iCoeEnv->AppUi() ); |
|
645 TRect rect = ui->ApplicationRect(); |
|
646 if( aType == KAknsMessageSkinChange ) |
|
647 { |
|
648 } |
|
649 if( aType == KEikDynamicLayoutVariantSwitch ) |
|
650 { |
|
651 if ( iBgContext ) |
|
652 { |
|
653 iBgContext->SetRect( Rect() ); |
|
654 } |
|
655 iTreeListBox->SetRect(rect); |
|
656 SizeChanged(); |
|
657 DrawNow(); |
|
658 |
|
659 } |
|
660 IRLOG_DEBUG( "CIRHistoryListContainer::HandleResourceChange - Exiting" ); |
|
661 } |
|
662 |
|
663 // ---------------------------------------------------- |
|
664 // CIRHistoryListContainer::GetCurrentFocussed() |
|
665 // To get the focus of Node of the treeList |
|
666 // ---------------------------------------------------- |
|
667 // |
|
668 |
|
669 TInt CIRHistoryListContainer::GetCurrentFocussedNode() |
|
670 { |
|
671 IRLOG_DEBUG( "CIRHistoryListContainer::GetCurrentFocussedNode - Entering" ); |
|
672 TInt focusItem=iTreeListBox->FocusedItem(); |
|
673 TInt isNode=iTreeListBox->IsNode( focusItem ); |
|
674 TInt retValue = -1; |
|
675 if(!isNode) |
|
676 { |
|
677 focusItem=iTreeListBox->Parent(focusItem); |
|
678 } |
|
679 for(TInt index=0;index<iUrlArray->Count();index++) |
|
680 { |
|
681 if(index>=0 && index<iNodeArray.Count()) |
|
682 { |
|
683 if(focusItem==iNodeArray[index]) |
|
684 retValue=index; |
|
685 } |
|
686 } |
|
687 IRLOG_DEBUG( "CIRHistoryListContainer::GetCurrentFocussedNode - Exiting" ); |
|
688 return retValue; |
|
689 } |
|
690 |
|
691 // ---------------------------------------------------- |
|
692 // CIRHistoryListContainer::GetCurrentFocussedLeaf() |
|
693 // To get the focus of Leaf of the treeList |
|
694 // ---------------------------------------------------- |
|
695 // |
|
696 TInt CIRHistoryListContainer::GetCurrentFocussedLeaf() |
|
697 { |
|
698 IRLOG_DEBUG( "CIRHistoryListContainer::GetCurrentFocussedLeaf - Entering" ); |
|
699 TInt focusItem=iTreeListBox->FocusedItem(); |
|
700 TInt isLeaf=iTreeListBox->IsLeaf( focusItem ); |
|
701 TInt retValue = -1; |
|
702 if(isLeaf) |
|
703 { |
|
704 for(TInt index=0;index<iLeafArray.Count();index++) |
|
705 { |
|
706 if(focusItem==iLeafArray[index]) |
|
707 { |
|
708 retValue = index; |
|
709 break; |
|
710 } |
|
711 } |
|
712 } |
|
713 |
|
714 IRLOG_DEBUG( "CIRHistoryListContainer::GetCurrentFocussedLeaf - Exiting" ); |
|
715 return retValue; |
|
716 } |
|
717 |
|
718 // ---------------------------------------------------- |
|
719 // CIRHistoryListContainer::AddStationToFavorites() |
|
720 // For Adding the Station name to the favorites DB. |
|
721 // ---------------------------------------------------- |
|
722 // |
|
723 |
|
724 void CIRHistoryListContainer::AddStationToFavoritesL(TInt aCommand) |
|
725 { |
|
726 IRLOG_DEBUG( "CIRHistoryListContainer::AddStationToFavoritesL - Entering" ); |
|
727 iLoadingCancelled = EFalse; |
|
728 |
|
729 iAddFrmHistory = ETrue; |
|
730 iListenFrmHistory = EFalse ; |
|
731 TInt focusItem=iTreeListBox->FocusedItem(); |
|
732 TInt isNode=iTreeListBox->IsNode( focusItem ); |
|
733 TInt favouriteIndexChannel = -1; |
|
734 if(!isNode) |
|
735 { |
|
736 focusItem=iTreeListBox->Parent(focusItem); |
|
737 } |
|
738 for(TInt index=0;index<iUrlArray->Count();index++) |
|
739 { |
|
740 if(index>=0 && index<iNodeArray.Count()) |
|
741 { |
|
742 if(focusItem==iNodeArray[index]) |
|
743 favouriteIndexChannel=index; |
|
744 } |
|
745 } |
|
746 _LIT(KNA,"NA"); |
|
747 TInt res = KErrNone; |
|
748 if(favouriteIndexChannel>=0 && favouriteIndexChannel<iChannelTypeArray.Count()) |
|
749 { |
|
750 if(iChannelTypeArray[favouriteIndexChannel]==0) |
|
751 { |
|
752 CIRIsdsPreset* preset = CIRIsdsPreset::NewL(); |
|
753 CleanupStack::PushL( preset ); |
|
754 preset->SetName(iChannelArray->MdcaPoint(favouriteIndexChannel)); |
|
755 preset->SetUrlL( KNA, iUrlArray->MdcaPoint(favouriteIndexChannel ), 0 ); |
|
756 preset->SetUrlCount(); |
|
757 if(favouriteIndexChannel >=0 && favouriteIndexChannel<iChannelTypeArray.Count()) |
|
758 { |
|
759 preset->SetChannelType(iChannelTypeArray[favouriteIndexChannel]); |
|
760 } |
|
761 if(favouriteIndexChannel >=0 && favouriteIndexChannel<iChannelIdArray.Count()) |
|
762 { |
|
763 preset->SetId(iChannelIdArray[favouriteIndexChannel]); |
|
764 } |
|
765 preset->SetShortDesc(iChannelDescriptionArray->MdcaPoint(favouriteIndexChannel )); |
|
766 preset->SetDescription(iChannelDescriptionArray->MdcaPoint(favouriteIndexChannel )); |
|
767 iHistoryListView.iUi->iFavPresets->AddPresetL(*preset,res); |
|
768 if( res == KErrNoMemory ) |
|
769 { |
|
770 DisplayErroronDBL(); |
|
771 } |
|
772 else |
|
773 { |
|
774 iHistoryListView.iUi->DisplayInformationL( R_IRAPP_STATIONS_POPUP_SAVED, |
|
775 iChannelArray-> |
|
776 MdcaPoint(favouriteIndexChannel) ); |
|
777 } |
|
778 CleanupStack::PopAndDestroy( preset ); |
|
779 } |
|
780 else |
|
781 { |
|
782 //Display a loading Progress Bar |
|
783 iChannelSyncId = iChannelIdArray[favouriteIndexChannel] ; |
|
784 iChangedIndex = favouriteIndexChannel; |
|
785 iHistoryListView.iIsdsWrapper->IsdsPresetRequestL(this, |
|
786 iChannelIdArray[favouriteIndexChannel], |
|
787 aCommand,EFalse,ETrue); |
|
788 } |
|
789 } |
|
790 IRLOG_DEBUG( "CIRHistoryListContainer::AddStationToFavoritesL - Exiting" ); |
|
791 |
|
792 } |
|
793 |
|
794 // ---------------------------------------------------- |
|
795 // CIRHistoryListContainer::DisplayErroronDBL() |
|
796 // To show error note whenever the Fovorites DB is full |
|
797 // ---------------------------------------------------- |
|
798 // |
|
799 void CIRHistoryListContainer::DisplayErroronDBL() |
|
800 { |
|
801 IRLOG_DEBUG( "CIRHistoryListContainer::DisplayErroronDBL - Entering" ); |
|
802 iHistoryListView.iUi->iDialogNote->ShowErrorNoteL(R_IRAPP_ADDFAVOURITES_ERROR,ETrue); |
|
803 IRLOG_DEBUG( "CIRHistoryListContainer::DisplayErroronDBL - Exiting" ); |
|
804 } |
|
805 |
|
806 // ---------------------------------------------------- |
|
807 // CIRHistoryListContainer::ShowFocus() |
|
808 // To return whether a leaf or node is focused |
|
809 // ---------------------------------------------------- |
|
810 // |
|
811 TInt CIRHistoryListContainer::ShowFocus() |
|
812 { |
|
813 IRLOG_DEBUG( "CIRHistoryListContainer::ShowFocus - Entering" ); |
|
814 TInt focusItem=iTreeListBox->FocusedItem(); |
|
815 TInt isLeaf=0; |
|
816 TInt retValue; |
|
817 if(focusItem) |
|
818 { |
|
819 isLeaf=iTreeListBox->IsLeaf( focusItem ); |
|
820 } |
|
821 if(isLeaf) |
|
822 { |
|
823 retValue = ETrue; |
|
824 } |
|
825 else |
|
826 { |
|
827 retValue = EFalse; |
|
828 } |
|
829 IRLOG_DEBUG( "CIRHistoryListContainer::ShowFocus - Exiting" ); |
|
830 return retValue ; |
|
831 |
|
832 } |
|
833 |
|
834 // --------------------------------------------------------------------------- |
|
835 // void CIRHistoryListContainer::ResponseL() |
|
836 // Activates the Stations view after getting the IsdsResponse |
|
837 // --------------------------------------------------------------------------- |
|
838 // |
|
839 void CIRHistoryListContainer::ResponseL( CIRIsdsPreset* aPreset ) |
|
840 { |
|
841 IRLOG_DEBUG( "CIRHistoryListContainer::ResponseL - Entering" ); |
|
842 iHistoryListView.ResetPendingRequests(EFalse); |
|
843 |
|
844 iHistoryListView.HistoryEngineInstance()->UpdateSongHistoryDb(aPreset->GetId(), |
|
845 aPreset->GetName(), |
|
846 KNo, |
|
847 aPreset->GetMusicStoreStatus()); |
|
848 iHistoryListView.RefreshHistoryL(); |
|
849 IRLOG_DEBUG( "CIRHistoryListContainer::ResponseL - Exiting" ); |
|
850 return; |
|
851 } |
|
852 // --------------------------------------------------------------------------- |
|
853 // void CIRHistoryListContainer::PresetResponseL() |
|
854 // Called when Preset Data is received |
|
855 // Used to Listen to a channel with given preset. |
|
856 // --------------------------------------------------------------------------- |
|
857 // |
|
858 void CIRHistoryListContainer::PresetResponseL(CIRIsdsPreset* aPreset) |
|
859 { |
|
860 IRLOG_DEBUG( "CIRHistoryListContainer::PresetResponseL - Entering" ); |
|
861 if ( !iHistoryListView.iUi->CheckAndNotifyLowDiskSpaceL() ) |
|
862 { |
|
863 iHistoryListView.ResetPendingRequests(EFalse); |
|
864 if(!iHistoryListView.iNowPlayingWrapper->GetWhenUserCancelsIsdsBufferingWaitBar()) |
|
865 { |
|
866 iHistoryListView.iNowPlayingWrapper->SetListenFromIsdsValue(ETrue); |
|
867 iHistoryListView.iNowPlayingWrapper->ListenToChannelL(aPreset); |
|
868 } |
|
869 } |
|
870 IRLOG_DEBUG( "CIRHistoryListContainer::PresetResponseL - Exiting" ); |
|
871 } |
|
872 // --------------------------------------------------------------------------- |
|
873 // void CIRHistoryListContainer::ErrorL() |
|
874 // Handles error Conditions |
|
875 // --------------------------------------------------------------------------- |
|
876 // |
|
877 void CIRHistoryListContainer::ErrorL() |
|
878 { |
|
879 IRLOG_DEBUG( "CIRHistoryListContainer::ErrorL - Entering" ); |
|
880 if(iHistoryListView.iIsdsWrapper->GetListenRequest()) |
|
881 { |
|
882 iHistoryListView.iNowPlayingWrapper->DestroyWaitDialogL(); |
|
883 iHistoryListView.iUi->GetPubSubManagerInstance()->PublishBufferingState(EIRStateBufferingError); |
|
884 |
|
885 iHistoryListView.iIsdsWrapper->SetListenRequest(EFalse); |
|
886 } |
|
887 if(iHistoryListView.iIsdsWrapper->iConnTimeOut) |
|
888 { |
|
889 iHistoryListView.iIsdsWrapper->iConnTimeOut = EFalse; |
|
890 } |
|
891 RemovedIsdsChannelL(); |
|
892 IRLOG_DEBUG( "CIRHistoryListContainer::ErrorL - Exiting" ); |
|
893 return; |
|
894 } |
|
895 |
|
896 // ----------------------------------------------------------------------------- |
|
897 // CIRHistoryListContainer::IsdsOrNot() |
|
898 // Whether ISDS channel or not. |
|
899 // ----------------------------------------------------------------------------- |
|
900 // |
|
901 TBool CIRHistoryListContainer::IsdsOrNot() |
|
902 { |
|
903 IRLOG_DEBUG( "CIRHistoryListContainer::IsdsOrNot - Entering" ); |
|
904 TInt focusItem=iTreeListBox->FocusedItem(); |
|
905 TInt isNode=iTreeListBox->IsNode( focusItem ); |
|
906 TInt itemIndex = -1; |
|
907 TBool retValue = EFalse; |
|
908 if(!isNode) |
|
909 { |
|
910 focusItem=iTreeListBox->Parent(focusItem); |
|
911 } |
|
912 for(TInt index=0;index<iUrlArray->Count();index++) |
|
913 { |
|
914 if(index>=0 && index<iNodeArray.Count()) |
|
915 { |
|
916 if(focusItem==iNodeArray[index]) |
|
917 itemIndex=index; |
|
918 } |
|
919 } |
|
920 if(itemIndex >=0 && itemIndex<iChannelTypeArray.Count()) |
|
921 { |
|
922 if(iChannelTypeArray[itemIndex]==1) |
|
923 { |
|
924 retValue = ETrue; |
|
925 } |
|
926 } |
|
927 IRLOG_DEBUG( "CIRHistoryListContainer::IsdsOrNot - Exiting" ); |
|
928 return retValue; |
|
929 } |
|
930 |
|
931 // ----------------------------------------------------------------------------- |
|
932 // CIRHistoryListContainer::GetButtonDimmed() |
|
933 // Whether Find in Shop Button is dimmed or not. |
|
934 // ----------------------------------------------------------------------------- |
|
935 // |
|
936 TBool CIRHistoryListContainer::GetButtonDimmed() |
|
937 { |
|
938 return iDimmed; |
|
939 } |
|
940 // ----------------------------------------------------------------------------- |
|
941 // CIRHistoryListContainer::RemovedIsdsChannelL() |
|
942 // To add or play a channel which has been removed from ISDS . |
|
943 // ----------------------------------------------------------------------------- |
|
944 // |
|
945 void CIRHistoryListContainer::RemovedIsdsChannelL() |
|
946 { |
|
947 IRLOG_DEBUG( "CIRHistoryListContainer::RemovedIsdsChannelL - Entering" ); |
|
948 if(iHistoryListView.iIsdsWrapper->GetErrorCode()) |
|
949 { |
|
950 iHistoryListView.HistoryEngineInstance()->SyncHistory( iChannelSyncId ); |
|
951 |
|
952 _LIT(KNA,"NA"); |
|
953 CIRIsdsPreset* preset = CIRIsdsPreset::NewL(); |
|
954 CleanupStack::PushL( preset ); |
|
955 preset->SetName(iChannelArray->MdcaPoint(iChangedIndex)); |
|
956 preset->SetUrlL( KNA, iUrlArray->MdcaPoint(iChangedIndex ), 0 ); |
|
957 preset->SetUrlCount(); |
|
958 preset->SetChannelType(0); |
|
959 preset->SetId(0); |
|
960 preset->SetShortDesc(iChannelDescriptionArray->MdcaPoint(iChangedIndex )); |
|
961 preset->SetDescription(iChannelDescriptionArray->MdcaPoint(iChangedIndex )); |
|
962 TInt res = KErrNone; |
|
963 |
|
964 if(iAddFrmHistory) |
|
965 { |
|
966 iHistoryListView.iUi->iFavPresets->AddPresetL(*preset,res); |
|
967 if( res == KErrNoMemory ) |
|
968 { |
|
969 DisplayErroronDBL(); |
|
970 } |
|
971 else |
|
972 { |
|
973 iHistoryListView.iUi->DisplayInformationL( R_IRAPP_STATIONS_POPUP_SAVED, |
|
974 iChannelArray-> |
|
975 MdcaPoint(iChangedIndex) ); |
|
976 } |
|
977 CleanupStack::PopAndDestroy( preset ); |
|
978 iAddFrmHistory = EFalse ; |
|
979 } |
|
980 if(iListenFrmHistory) |
|
981 { |
|
982 |
|
983 // Set the channel as last played and currently playing |
|
984 *iHistoryListView.iNowPlayingWrapper->iNowPlayingPreset = *preset; |
|
985 CleanupStack::PopAndDestroy( preset ); |
|
986 |
|
987 iHistoryListView.iUi->iNPPrevViewId = KIRHistoryListViewId; |
|
988 |
|
989 //connecting to server |
|
990 iHistoryListView.iNowPlayingWrapper->SetCurrentConnectionSource(EIRHistoryAdhoc); |
|
991 iHistoryListView.iNowPlayingWrapper->ConnectToChannelL(*iHistoryListView. |
|
992 iNowPlayingWrapper->iNowPlayingPreset); |
|
993 |
|
994 iListenFrmHistory = EFalse ; |
|
995 } |
|
996 iHistoryListView.RefreshHistoryL(); |
|
997 } |
|
998 IRLOG_DEBUG( "CIRHistoryListContainer::RemovedIsdsChannelL - Exiting" ); |
|
999 } |
|
1000 |
|
1001 |
|
1002 |
|