1 /* |
|
2 * Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <s32strm.h> |
|
19 |
|
20 #include "irchannelserverurl.h" |
|
21 #include "irdebug.h" |
|
22 #include "irpresetimpl.h" |
|
23 #include "irisdspreset.h" |
|
24 |
|
25 const TInt KUrlArrayMaxLength = 128; |
|
26 |
|
27 // ======== MEMBER FUNCTIONS ======== |
|
28 |
|
29 // --------------------------------------------------------------------------- |
|
30 // CIRPresetImpl::NewL() |
|
31 // Static function |
|
32 // standard two phased constructor |
|
33 // --------------------------------------------------------------------------- |
|
34 // |
|
35 CIRPresetImpl* CIRPresetImpl::NewL( TAny* aParams ) |
|
36 { |
|
37 IRLOG_DEBUG( "CIRPresetImpl::NewL" ); |
|
38 CIRPresetImpl* self = CIRPresetImpl::NewLC( aParams ); |
|
39 CleanupStack::Pop( self ); |
|
40 IRLOG_DEBUG( "CIRPresetImpl::NewL - Exiting." ); |
|
41 return self; |
|
42 } |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // CIRPresetImpl::NewLC() |
|
46 // Static function |
|
47 // standard two phased constructor |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 CIRPresetImpl* CIRPresetImpl::NewLC( TAny* aParams ) |
|
51 { |
|
52 IRLOG_DEBUG( "CIRPresetImpl::NewLC" ); |
|
53 CIRPresetImpl* self = new (ELeave) CIRPresetImpl; |
|
54 CleanupStack::PushL( self ); |
|
55 self->ConstructL( aParams ); |
|
56 IRLOG_DEBUG( "CIRPresetImpl::NewLC - Exiting." ); |
|
57 return self; |
|
58 } |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // CIRPresetImpl::ConstructL() |
|
62 // standard second phase constructor |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 void CIRPresetImpl::ConstructL(TAny* aParams) |
|
66 { |
|
67 IRLOG_DEBUG( "CIRPresetImpl::ConstructL" ); |
|
68 BaseConstructL(aParams); |
|
69 iUrlArray= |
|
70 new (ELeave) CArrayPtrFlat<CIRChannelServerUrl>( |
|
71 KUrlArrayMaxLength); |
|
72 |
|
73 IRLOG_DEBUG( "CIRPresetImpl::ConstructL - Exiting." ); |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // CIRPresetImpl::~CIRPresetImpl() |
|
78 // standard C++ destructor |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 CIRPresetImpl::~CIRPresetImpl() |
|
82 { |
|
83 IRLOG_DEBUG( "CIRPresetImpl::~CIRPresetImpl" ); |
|
84 iLanguageCode.Close(); |
|
85 iLanguage.Close(); |
|
86 iCountryCode.Close(); |
|
87 iCountry.Close(); |
|
88 iLastModified.Close(); |
|
89 iAdvertisementUrl.Close(); |
|
90 iAdvertisementInUse.Close(); |
|
91 iImgUrl.Close(); |
|
92 iLogoData.Close(); |
|
93 iDescription.Close(); |
|
94 iShortDesc.Close(); |
|
95 iGenereName.Close(); |
|
96 iGenereId.Close(); |
|
97 iMusicStoreStatus.Close(); |
|
98 |
|
99 if (iUrlArray) |
|
100 { |
|
101 iUrlArray->ResetAndDestroy(); |
|
102 } |
|
103 |
|
104 delete iUrlArray; |
|
105 iBitrateArray.Close(); |
|
106 IRLOG_DEBUG( "CIRPresetImpl::~CIRPresetImpl - Exiting." ); |
|
107 } |
|
108 |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // CIRPresetImpl::SetId() |
|
112 // Function to set iPresetId |
|
113 // --------------------------------------------------------------------------- |
|
114 // |
|
115 void CIRPresetImpl::SetId(TInt aId) |
|
116 { |
|
117 iPresetId=aId; |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------------------------- |
|
121 // CIRPresetImpl::SetId() |
|
122 // Function to set iPresetId from a TDesC |
|
123 // --------------------------------------------------------------------------- |
|
124 // |
|
125 void CIRPresetImpl::SetId(const TDesC &aId) |
|
126 { |
|
127 TLex conv(aId); |
|
128 conv.Val(iPresetId); |
|
129 } |
|
130 |
|
131 // --------------------------------------------------------------------------- |
|
132 // CIRPresetImpl::SetLangCode() |
|
133 // Function to set iLanguageCode from a TDesC |
|
134 // --------------------------------------------------------------------------- |
|
135 // |
|
136 void CIRPresetImpl::SetLangCode(const TDesC &aLangId) |
|
137 { |
|
138 iLanguageCode.Close(); |
|
139 iLanguageCode.Create( aLangId ); |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // CIRPresetImpl::SetLang() |
|
144 // Function to set iLanguage from a TDesC |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 void CIRPresetImpl::SetLang(const TDesC& aLangName) |
|
148 { |
|
149 iLanguage.Close(); |
|
150 iLanguage.Create( aLangName ); |
|
151 } |
|
152 |
|
153 // --------------------------------------------------------------------------- |
|
154 // CIRPresetImpl::SetCountryCode() |
|
155 // Function to set iCountryCode from a TDesC |
|
156 // --------------------------------------------------------------------------- |
|
157 void CIRPresetImpl::SetCountryCode(const TDesC &aCountryId) |
|
158 { |
|
159 iCountryCode.Close(); |
|
160 iCountryCode.Create( aCountryId ); |
|
161 } |
|
162 |
|
163 // --------------------------------------------------------------------------- |
|
164 // CIRPresetImpl::SetCountryName() |
|
165 // Function to set iCountry from a TDesC |
|
166 // --------------------------------------------------------------------------- |
|
167 // |
|
168 void CIRPresetImpl::SetCountryName(const TDesC& aCountryName) |
|
169 { |
|
170 iCountry.Close(); |
|
171 iCountry.Create( aCountryName ); |
|
172 } |
|
173 |
|
174 // --------------------------------------------------------------------------- |
|
175 // CIRPresetImpl::SetLangInfo() |
|
176 // Function to set iLanguageCode, iLanguage |
|
177 // --------------------------------------------------------------------------- |
|
178 // |
|
179 void CIRPresetImpl::SetLangInfo(const TDesC &aLangId,const TDesC& aLangName) |
|
180 { |
|
181 SetLangCode( aLangId ); |
|
182 SetLang( aLangName ); |
|
183 } |
|
184 |
|
185 |
|
186 // --------------------------------------------------------------------------- |
|
187 // CIRPresetImpl::SetLangInfo() |
|
188 // Function to set iCountryCode, iCountry |
|
189 // --------------------------------------------------------------------------- |
|
190 // |
|
191 void CIRPresetImpl::SetCountryInfo(const TDesC &aCountryId, |
|
192 const TDesC& aCountryName) |
|
193 { |
|
194 SetCountryCode( aCountryId ); |
|
195 SetCountryName( aCountryName ); |
|
196 } |
|
197 |
|
198 // --------------------------------------------------------------------------- |
|
199 // CIRPresetImpl::SetLastModifiedTime() |
|
200 // Function to set iLastModified |
|
201 // --------------------------------------------------------------------------- |
|
202 // |
|
203 void CIRPresetImpl::SetLastModifiedTime(const TDesC &aLastModified) |
|
204 { |
|
205 iLastModified.Close(); |
|
206 iLastModified.Create( aLastModified ); |
|
207 } |
|
208 |
|
209 // --------------------------------------------------------------------------- |
|
210 // CIRPresetImpl::SetGenreInfo() |
|
211 // Function to set iGenereName, iGenereId |
|
212 // --------------------------------------------------------------------------- |
|
213 // |
|
214 void CIRPresetImpl::SetGenreInfo(const TDesC& aGenreId, |
|
215 const TDesC& aGenreName) |
|
216 { |
|
217 iGenereName.Close(); |
|
218 iGenereName.Create( aGenreName ); |
|
219 iGenereId.Close(); |
|
220 iGenereId.Create( aGenreId ); |
|
221 } |
|
222 |
|
223 // --------------------------------------------------------------------------- |
|
224 // CIRPresetImpl::SetImgUrl() |
|
225 // Function to set iImgUrl |
|
226 // --------------------------------------------------------------------------- |
|
227 // |
|
228 void CIRPresetImpl::SetImgUrl(const TDesC& aImgUrl) |
|
229 { |
|
230 iImgUrl.Close(); |
|
231 iImgUrl.Create( aImgUrl ); |
|
232 } |
|
233 |
|
234 // --------------------------------------------------------------------------- |
|
235 // From class CIRPresetImpl |
|
236 // Sets the raw logo image data. |
|
237 // --------------------------------------------------------------------------- |
|
238 // |
|
239 void CIRPresetImpl::SetLogoData( const TDesC8& aData ) |
|
240 { |
|
241 iLogoData.Close(); |
|
242 iLogoData.Create( aData ); |
|
243 } |
|
244 |
|
245 // --------------------------------------------------------------------------- |
|
246 // From class CIRPresetImpl |
|
247 // Returns the raw logo image data. |
|
248 // --------------------------------------------------------------------------- |
|
249 // |
|
250 const TDesC8& CIRPresetImpl::GetLogoData() const |
|
251 { |
|
252 return iLogoData; |
|
253 } |
|
254 |
|
255 // --------------------------------------------------------------------------- |
|
256 // CIRPresetImpl::SetAdvertisementUrl() |
|
257 // Function to set iAdvertisementUrl |
|
258 // --------------------------------------------------------------------------- |
|
259 // |
|
260 void CIRPresetImpl::SetAdvertisementUrl(const TDesC& aAdvertisementUrl) |
|
261 { |
|
262 iAdvertisementUrl.Close(); |
|
263 iAdvertisementUrl.Create( aAdvertisementUrl ); |
|
264 } |
|
265 |
|
266 // --------------------------------------------------------------------------- |
|
267 // CIRPresetImpl::SetAdvertisementInUse() |
|
268 // Function to set iAdvertisementInUse |
|
269 // --------------------------------------------------------------------------- |
|
270 // |
|
271 void CIRPresetImpl::SetAdvertisementInUse(const TDesC& aAdvertisementInUse) |
|
272 { |
|
273 iAdvertisementInUse.Close(); |
|
274 iAdvertisementInUse.Create( aAdvertisementInUse ); |
|
275 } |
|
276 |
|
277 // --------------------------------------------------------------------------- |
|
278 // CIRPresetImpl::SetDescription() |
|
279 // Function to set iDescription |
|
280 // --------------------------------------------------------------------------- |
|
281 // |
|
282 void CIRPresetImpl:: SetDescription(const TDesC& aDescription) |
|
283 { |
|
284 iDescription.Close(); |
|
285 iDescription.Create( aDescription ); |
|
286 } |
|
287 |
|
288 |
|
289 // --------------------------------------------------------------------------- |
|
290 // CIRPresetImpl::SetShortDesc() |
|
291 // Function to set iShortDesc |
|
292 // --------------------------------------------------------------------------- |
|
293 // |
|
294 void CIRPresetImpl:: SetShortDesc(const TDesC& aShortDesc) |
|
295 { |
|
296 iShortDesc.Close(); |
|
297 iShortDesc.Create( aShortDesc ); |
|
298 } |
|
299 |
|
300 // --------------------------------------------------------------------------- |
|
301 // CIRPresetImpl::SetUrlCount() |
|
302 // Function to set iChannelUrlCount |
|
303 // --------------------------------------------------------------------------- |
|
304 // |
|
305 void CIRPresetImpl::SetUrlCount() |
|
306 { |
|
307 iChannelUrlCount=iUrlArray->Count(); |
|
308 } |
|
309 |
|
310 // --------------------------------------------------------------------------- |
|
311 // CIRPresetImpl::SetUrlCount() |
|
312 // Function to set iChannelUrlCount |
|
313 // --------------------------------------------------------------------------- |
|
314 void CIRPresetImpl::SetUrlCount(TInt aCnt) |
|
315 { |
|
316 iChannelUrlCount=aCnt; |
|
317 } |
|
318 |
|
319 // --------------------------------------------------------------------------- |
|
320 // CIRPresetImpl::SetChannelType() |
|
321 // Function to set iType |
|
322 // --------------------------------------------------------------------------- |
|
323 // |
|
324 void CIRPresetImpl::SetChannelType(TInt aType) |
|
325 { |
|
326 iType = aType; |
|
327 } |
|
328 |
|
329 // --------------------------------------------------------------------------- |
|
330 // CIRPresetImpl::SetUrl() |
|
331 // Function to set Url parameter |
|
332 // --------------------------------------------------------------------------- |
|
333 // |
|
334 void CIRPresetImpl::SetUrlL(const TDesC &aServerName,const TDesC &aUrl, |
|
335 const TDesC &aBitrate) |
|
336 { |
|
337 IRLOG_DEBUG( "CIRPresetImpl::SetUrlL" ); |
|
338 CIRChannelServerUrl* hold=CIRChannelServerUrl::NewL(); |
|
339 hold->SetServerName(aServerName); |
|
340 hold->SetServerUrl(aUrl); |
|
341 TLex conv(aBitrate); |
|
342 TInt conVal = 0; |
|
343 conv.Val(conVal); |
|
344 hold->SetBitRate(conVal); |
|
345 //ownership transferred to the array |
|
346 //no need to delete hold |
|
347 iUrlArray->AppendL(hold); |
|
348 IRLOG_DEBUG( "CIRPresetImpl::SetUrlL - Exiting." ); |
|
349 } |
|
350 |
|
351 |
|
352 |
|
353 // --------------------------------------------------------------------------- |
|
354 // CIRPresetImpl::SetUrl() |
|
355 // Function to set Url parameter |
|
356 // --------------------------------------------------------------------------- |
|
357 // |
|
358 void CIRPresetImpl::SetUrlL(const TDesC &aServerName,const TDesC &aUrl, |
|
359 TInt aBitrate) |
|
360 { |
|
361 IRLOG_DEBUG( "CIRPresetImpl::SetUrlL(const TDesC &aServerName,const TDesC &aUrl,TInt aBitrate)" ); |
|
362 CIRChannelServerUrl* hold=CIRChannelServerUrl::NewL(); |
|
363 hold->SetServerName(aServerName); |
|
364 hold->SetServerUrl(aUrl); |
|
365 hold->SetBitRate(aBitrate); |
|
366 iUrlArray->AppendL(hold); |
|
367 IRLOG_DEBUG( "CIRPresetImpl::SetUrlL(const TDesC &aServerName,const TDesC &aUrl,TInt aBitrate) - Exiting." ); |
|
368 } |
|
369 |
|
370 |
|
371 // --------------------------------------------------------------------------- |
|
372 // CIRPresetImpl::SetMusicStoreStatus() |
|
373 // Function to set iMusicStoreStatus |
|
374 // --------------------------------------------------------------------------- |
|
375 // |
|
376 void CIRPresetImpl::SetMusicStoreStatus(const TDesC& aMusicStoreStatus) |
|
377 { |
|
378 IRLOG_DEBUG( "CIRPresetImpl::SetMusicStoreStatus - Entering" ); |
|
379 iMusicStoreStatus.Close(); |
|
380 iMusicStoreStatus.Create( aMusicStoreStatus ); |
|
381 IRLOG_DEBUG( "CIRPresetImpl::SetMusicStoreStatus - Exiting" ); |
|
382 } |
|
383 |
|
384 |
|
385 |
|
386 // --------------------------------------------------------------------------- |
|
387 // CIRPresetImpl::GetId() |
|
388 // Function to get iPresetId |
|
389 // --------------------------------------------------------------------------- |
|
390 // |
|
391 TInt CIRPresetImpl::GetId()const |
|
392 { |
|
393 return iPresetId; |
|
394 } |
|
395 |
|
396 |
|
397 // --------------------------------------------------------------------------- |
|
398 // CIRPresetImpl::GetLangId() |
|
399 // Function to get iLanguageCode |
|
400 // --------------------------------------------------------------------------- |
|
401 // |
|
402 const TDesC& CIRPresetImpl::GetLangId() const |
|
403 { |
|
404 return iLanguageCode; |
|
405 } |
|
406 |
|
407 |
|
408 // --------------------------------------------------------------------------- |
|
409 // CIRPresetImpl::GetLangName() |
|
410 // Function to get iLanguage |
|
411 // --------------------------------------------------------------------------- |
|
412 // |
|
413 const TDesC& CIRPresetImpl::GetLangName() const |
|
414 { |
|
415 return iLanguage; |
|
416 } |
|
417 |
|
418 |
|
419 // --------------------------------------------------------------------------- |
|
420 // CIRPresetImpl::GetCountryId() |
|
421 // Function to get iCountryCode |
|
422 // --------------------------------------------------------------------------- |
|
423 // |
|
424 const TDesC& CIRPresetImpl::GetCountryId() const |
|
425 { |
|
426 return iCountryCode; |
|
427 } |
|
428 |
|
429 |
|
430 // --------------------------------------------------------------------------- |
|
431 // CIRPresetImpl::GetCountryName() |
|
432 // Function to get iCountry |
|
433 // --------------------------------------------------------------------------- |
|
434 // |
|
435 const TDesC& CIRPresetImpl::GetCountryName() const |
|
436 { |
|
437 return iCountry; |
|
438 } |
|
439 |
|
440 |
|
441 // --------------------------------------------------------------------------- |
|
442 // CIRPresetImpl::GetLastModifiedTime() |
|
443 // Function to get iLastModified |
|
444 // --------------------------------------------------------------------------- |
|
445 // |
|
446 const TDesC& CIRPresetImpl::GetLastModifiedTime() const |
|
447 { |
|
448 return iLastModified; |
|
449 } |
|
450 |
|
451 |
|
452 // --------------------------------------------------------------------------- |
|
453 // CIRPresetImpl::GetGenreId() |
|
454 // Function to get iGenereId |
|
455 // --------------------------------------------------------------------------- |
|
456 // |
|
457 const TDesC& CIRPresetImpl::GetGenreId() const |
|
458 { |
|
459 return iGenereId; |
|
460 } |
|
461 |
|
462 |
|
463 // --------------------------------------------------------------------------- |
|
464 // CIRPresetImpl::GetGenreName() |
|
465 // Function to get iGenereName |
|
466 // --------------------------------------------------------------------------- |
|
467 // |
|
468 const TDesC& CIRPresetImpl::GetGenreName() const |
|
469 { |
|
470 return iGenereName; |
|
471 } |
|
472 |
|
473 |
|
474 // --------------------------------------------------------------------------- |
|
475 // CIRPresetImpl::GetAdvertisementUrl() |
|
476 // Function to get iAdvertisementUrl |
|
477 // --------------------------------------------------------------------------- |
|
478 // |
|
479 const TDesC& CIRPresetImpl::GetAdvertisementUrl() const |
|
480 { |
|
481 return iAdvertisementUrl; |
|
482 } |
|
483 |
|
484 const TDesC& CIRPresetImpl::GetAdvertisementInUse() const |
|
485 { |
|
486 return iAdvertisementInUse; |
|
487 } |
|
488 |
|
489 // --------------------------------------------------------------------------- |
|
490 // CIRPresetImpl::GetImgUrl() |
|
491 // Function to get iImgUrl |
|
492 // --------------------------------------------------------------------------- |
|
493 // |
|
494 const TDesC& CIRPresetImpl::GetImgUrl() const |
|
495 { |
|
496 return iImgUrl; |
|
497 } |
|
498 |
|
499 // --------------------------------------------------------------------------- |
|
500 // CIRPresetImpl::GetUrlCount() |
|
501 // Function to get iChannelUrlCount |
|
502 // --------------------------------------------------------------------------- |
|
503 // |
|
504 TInt CIRPresetImpl::GetUrlCount() const |
|
505 { |
|
506 return iChannelUrlCount; |
|
507 } |
|
508 |
|
509 CIRChannelServerUrl& CIRPresetImpl::GetUrl(TInt aIndex) const |
|
510 { |
|
511 ASSERT( aIndex >= 0 && aIndex < iUrlArray->Count() ); |
|
512 return ((*iUrlArray->At(aIndex))); |
|
513 } |
|
514 |
|
515 /* |
|
516 * get the channel url at specified position |
|
517 * |
|
518 */ |
|
519 const TDesC& CIRPresetImpl::GetChannelUrlAt(TInt aIndex) const |
|
520 { |
|
521 return iUrlArray->At(aIndex)->GetServerUrl(); |
|
522 } |
|
523 |
|
524 // --------------------------------------------------------------------------- |
|
525 // CIRPresetImpl::GetDescription() |
|
526 // Function to get iDescription |
|
527 // --------------------------------------------------------------------------- |
|
528 // |
|
529 const TDesC& CIRPresetImpl::GetDescription() const |
|
530 { |
|
531 return iDescription; |
|
532 } |
|
533 |
|
534 // --------------------------------------------------------------------------- |
|
535 //CIRPresetImpl::GetShortDescription() |
|
536 //Function to get iDescription |
|
537 // --------------------------------------------------------------------------- |
|
538 // |
|
539 const TDesC& CIRPresetImpl::GetShortDescription() const |
|
540 { |
|
541 return iShortDesc; |
|
542 } |
|
543 |
|
544 // --------------------------------------------------------------------------- |
|
545 //CIRPresetImpl::GetMusicStoreStatus() |
|
546 //Function to get iMusicStoreStatus |
|
547 // --------------------------------------------------------------------------- |
|
548 // |
|
549 const TDesC& CIRPresetImpl::GetMusicStoreStatus() const |
|
550 { |
|
551 return iMusicStoreStatus; |
|
552 } |
|
553 |
|
554 |
|
555 |
|
556 |
|
557 // --------------------------------------------------------------------------- |
|
558 // CIRPresetImpl::GetChannelType() |
|
559 // Function to get iType |
|
560 // --------------------------------------------------------------------------- |
|
561 // |
|
562 TInt CIRPresetImpl::GetChannelType()const |
|
563 { |
|
564 return iType; |
|
565 } |
|
566 |
|
567 // --------------------------------------------------------------------------- |
|
568 // CIRPresetImpl& CIRPresetImpl::operator=(const CIRPresetImpl& preset) |
|
569 // assignment operator eg. preset1=preset2 |
|
570 // shallow copy |
|
571 // --------------------------------------------------------------------------- |
|
572 // |
|
573 CIRPresetImpl& CIRPresetImpl::operator=(const CIRPresetImpl& aPreset) |
|
574 { |
|
575 IRLOG_DEBUG( "CIRPresetImpl::operator=" ); |
|
576 if(&aPreset == this) |
|
577 { |
|
578 return *this; |
|
579 } |
|
580 //copy data members |
|
581 iPresetId = aPreset.iPresetId; |
|
582 |
|
583 TRAP_IGNORE(SetNameL(aPreset.Name())) |
|
584 |
|
585 iLanguageCode.Close(); |
|
586 iLanguageCode.Create(aPreset.iLanguageCode); |
|
587 |
|
588 iLanguage.Close(); |
|
589 iLanguage.Create(aPreset.iLanguage); |
|
590 |
|
591 iCountryCode.Close(); |
|
592 iCountryCode.Create(aPreset.iCountryCode); |
|
593 |
|
594 iCountry.Close(); |
|
595 iCountry.Create(aPreset.iCountry); |
|
596 |
|
597 iLastModified.Close(); |
|
598 iLastModified.Create(aPreset.iLastModified); |
|
599 |
|
600 iAdvertisementUrl.Close(); |
|
601 iAdvertisementUrl.Create(aPreset.iAdvertisementUrl); |
|
602 |
|
603 iAdvertisementInUse.Close(); |
|
604 iAdvertisementInUse.Create(aPreset.iAdvertisementInUse); |
|
605 |
|
606 iImgUrl.Close(); |
|
607 iImgUrl.Create(aPreset.iImgUrl); |
|
608 |
|
609 iLogoData.Close(); |
|
610 iLogoData.Create( aPreset.iLogoData ); |
|
611 |
|
612 iDescription.Close(); |
|
613 iDescription.Create(aPreset.iDescription); |
|
614 |
|
615 iShortDesc.Close(); |
|
616 iShortDesc.Create(aPreset.iShortDesc); |
|
617 |
|
618 iMusicStoreStatus.Close(); |
|
619 iMusicStoreStatus.Create(aPreset.iMusicStoreStatus); |
|
620 |
|
621 iGenereName.Close(); |
|
622 iGenereName.Create(aPreset.iGenereName); |
|
623 |
|
624 iGenereId.Close(); |
|
625 iGenereId.Create(aPreset.iGenereId); |
|
626 |
|
627 iChannelUrlCount = aPreset.iChannelUrlCount; |
|
628 iType = aPreset.iType; //0 for user defined 1 for isds type. |
|
629 for(TInt cnt=0;cnt<iChannelUrlCount;cnt++) |
|
630 { |
|
631 ASSERT( cnt >= 0 && cnt < aPreset.iUrlArray->Count() ); |
|
632 TRAPD(errUrl,SetUrlL(aPreset.iUrlArray->At(cnt)->GetServerName(), |
|
633 aPreset.iUrlArray->At(cnt)->GetServerUrl(), |
|
634 aPreset.iUrlArray->At(cnt)->GetBitRate())) |
|
635 if(errUrl!=KErrNone) |
|
636 { |
|
637 return *this ; |
|
638 } |
|
639 } |
|
640 IRLOG_DEBUG( "CIRPresetImpl::operator= - Exiting." ); |
|
641 return *this; |
|
642 } |
|
643 |
|
644 |
|
645 // --------------------------------------------------------------------------- |
|
646 // CIRPresetImpl::CIRPresetImpl() |
|
647 // default C++ constructor |
|
648 // standard two phased constructor |
|
649 // --------------------------------------------------------------------------- |
|
650 CIRPresetImpl::CIRPresetImpl() |
|
651 { |
|
652 // no implementation |
|
653 } |
|
654 |
|
655 |
|
656 // --------------------------------------------------------------------------- |
|
657 // CIRPresetImpl::CIRPresetImpl() |
|
658 // default C++ constructor |
|
659 // standard two phased constructor |
|
660 // --------------------------------------------------------------------------- |
|
661 // |
|
662 void CIRPresetImpl::ExternalizeL(RWriteStream& aWriteStream)const |
|
663 { |
|
664 IRLOG_DEBUG( "CIRPresetImpl::ExternalizeL" ); |
|
665 //! externalize TInts s |
|
666 aWriteStream.WriteInt32L(iPresetId); |
|
667 aWriteStream.WriteInt32L(iType); |
|
668 aWriteStream.WriteInt32L(iChannelUrlCount); |
|
669 |
|
670 //Externalize HBufC s |
|
671 //algo |
|
672 //1.check if data is present for the particular member variable |
|
673 //2.if yes get the length of the data and externalize the length and then the data |
|
674 //3.if no data is present write the length as 0. |
|
675 TInt len = 0; |
|
676 if(!iLanguageCode.Length()) |
|
677 { |
|
678 len=0; |
|
679 aWriteStream.WriteInt32L(len); |
|
680 } |
|
681 else |
|
682 { |
|
683 len=iLanguageCode.Length(); |
|
684 aWriteStream.WriteInt32L(len); |
|
685 aWriteStream<<iLanguageCode; |
|
686 } |
|
687 |
|
688 if(!iLanguage.Length()) |
|
689 { |
|
690 len=0; |
|
691 aWriteStream.WriteInt32L(len); |
|
692 } |
|
693 else |
|
694 { |
|
695 len=iLanguage.Length(); |
|
696 aWriteStream.WriteInt32L(len); |
|
697 aWriteStream<<iLanguage; |
|
698 } |
|
699 |
|
700 if(!iCountryCode.Length()) |
|
701 { |
|
702 len=0; |
|
703 aWriteStream.WriteInt32L(len); |
|
704 } |
|
705 else |
|
706 { |
|
707 len=iCountryCode.Length(); |
|
708 aWriteStream.WriteInt32L(len); |
|
709 aWriteStream<<iCountryCode; |
|
710 } |
|
711 |
|
712 if(!iCountry.Length()) |
|
713 { |
|
714 len=0; |
|
715 aWriteStream.WriteInt32L(len); |
|
716 } |
|
717 else |
|
718 { |
|
719 len=iCountry.Length(); |
|
720 aWriteStream.WriteInt32L(len); |
|
721 aWriteStream<<iCountry; |
|
722 } |
|
723 |
|
724 if(!iGenereName.Length()) |
|
725 { |
|
726 len=0; |
|
727 aWriteStream.WriteInt32L(len); |
|
728 } |
|
729 else |
|
730 { |
|
731 len=iGenereName.Length(); |
|
732 aWriteStream.WriteInt32L(len); |
|
733 aWriteStream<<iGenereName; |
|
734 } |
|
735 |
|
736 if(!iGenereId.Length()) |
|
737 { |
|
738 len=0; |
|
739 aWriteStream.WriteInt32L(len); |
|
740 } |
|
741 else |
|
742 { |
|
743 len=iGenereId.Length(); |
|
744 aWriteStream.WriteInt32L(len); |
|
745 aWriteStream<<iGenereId; |
|
746 } |
|
747 |
|
748 if(!iLastModified.Length()) |
|
749 { |
|
750 len=0; |
|
751 aWriteStream.WriteInt32L(len); |
|
752 } |
|
753 else |
|
754 { |
|
755 len=iLastModified.Length(); |
|
756 aWriteStream.WriteInt32L(len); |
|
757 aWriteStream<<iLastModified; |
|
758 } |
|
759 |
|
760 if(!iAdvertisementUrl.Length()) |
|
761 { |
|
762 len=0; |
|
763 aWriteStream.WriteInt32L(len); |
|
764 } |
|
765 else |
|
766 { |
|
767 len=iAdvertisementUrl.Length(); |
|
768 aWriteStream.WriteInt32L(len); |
|
769 aWriteStream<<iAdvertisementUrl; |
|
770 } |
|
771 |
|
772 if(!iAdvertisementInUse.Length()) |
|
773 { |
|
774 len=0; |
|
775 aWriteStream.WriteInt32L(len); |
|
776 } |
|
777 else |
|
778 { |
|
779 len=iAdvertisementInUse.Length(); |
|
780 aWriteStream.WriteInt32L(len); |
|
781 aWriteStream<<iAdvertisementInUse; |
|
782 } |
|
783 |
|
784 if(!iImgUrl.Length()) |
|
785 { |
|
786 len=0; |
|
787 aWriteStream.WriteInt32L(len); |
|
788 } |
|
789 else |
|
790 { |
|
791 len=iImgUrl.Length(); |
|
792 aWriteStream.WriteInt32L(len); |
|
793 aWriteStream<<iImgUrl; |
|
794 } |
|
795 |
|
796 if(!iDescription.Length()) |
|
797 { |
|
798 len=0; |
|
799 aWriteStream.WriteInt32L(len); |
|
800 } |
|
801 else |
|
802 { |
|
803 len=iDescription.Length(); |
|
804 aWriteStream.WriteInt32L(len); |
|
805 aWriteStream<<iDescription; |
|
806 } |
|
807 |
|
808 if(!iShortDesc.Length()) |
|
809 { |
|
810 len=0; |
|
811 aWriteStream.WriteInt32L(len); |
|
812 } |
|
813 else |
|
814 { |
|
815 len=iShortDesc.Length(); |
|
816 aWriteStream.WriteInt32L(len); |
|
817 aWriteStream<<iShortDesc; |
|
818 } |
|
819 |
|
820 if(!iMusicStoreStatus.Length()) |
|
821 { |
|
822 len=0; |
|
823 aWriteStream.WriteInt32L(len); |
|
824 } |
|
825 else |
|
826 { |
|
827 len=iMusicStoreStatus.Length(); |
|
828 aWriteStream.WriteInt32L(len); |
|
829 aWriteStream<<iMusicStoreStatus; |
|
830 } |
|
831 |
|
832 if(!iLogoData.Length()) |
|
833 { |
|
834 len=0; |
|
835 aWriteStream.WriteInt32L(len); |
|
836 } |
|
837 else |
|
838 { |
|
839 len=iLogoData.Length(); |
|
840 aWriteStream.WriteInt32L(len); |
|
841 aWriteStream<<iLogoData; |
|
842 } |
|
843 |
|
844 //externalizing the preset data |
|
845 for(TInt cnt=0;cnt<iChannelUrlCount;cnt++) |
|
846 { |
|
847 GetUrl(cnt).ExternalizeL(aWriteStream); |
|
848 } |
|
849 |
|
850 //added by Peter on June 23rd, 2009 |
|
851 aWriteStream.WriteInt32L(iPlayedTimes); |
|
852 |
|
853 aWriteStream.WriteInt32L(iRenamed); |
|
854 |
|
855 IRLOG_DEBUG( "CIRPresetImpl::ExternalizeL - Exiting." ); |
|
856 } |
|
857 |
|
858 |
|
859 // --------------------------------------------------------------------------- |
|
860 // CIRPresetImpl::CIRPresetImpl() |
|
861 // Internalizes the preset data |
|
862 // required for being derived from CPSPresetInterface |
|
863 // --------------------------------------------------------------------------- |
|
864 // |
|
865 void CIRPresetImpl::InternalizeL(RReadStream& aReadStream) |
|
866 { |
|
867 IRLOG_DEBUG( "CIRPresetImpl::InternalizeL" ); |
|
868 //! Internalize TInts s |
|
869 iPresetId=aReadStream.ReadInt32L(); |
|
870 iType=aReadStream.ReadInt32L(); |
|
871 iChannelUrlCount=aReadStream.ReadInt32L(); |
|
872 TInt len = 0; |
|
873 |
|
874 //algo |
|
875 //1.get the length of the data |
|
876 //2.read that many bytes |
|
877 //3.if read length is zero. skip. |
|
878 len=aReadStream.ReadInt32L(); |
|
879 iLanguageCode.Close(); |
|
880 if(len!=0) |
|
881 { |
|
882 iLanguageCode.CreateL(aReadStream,len); |
|
883 } |
|
884 |
|
885 len=aReadStream.ReadInt32L(); |
|
886 iLanguage.Close(); |
|
887 if(len!=0) |
|
888 { |
|
889 iLanguage.CreateL(aReadStream,len); |
|
890 } |
|
891 |
|
892 len=aReadStream.ReadInt32L(); |
|
893 iCountryCode.Close(); |
|
894 if(len!=0) |
|
895 { |
|
896 iCountryCode.CreateL(aReadStream,len); |
|
897 } |
|
898 |
|
899 len=aReadStream.ReadInt32L(); |
|
900 iCountry.Close(); |
|
901 if(len!=0) |
|
902 { |
|
903 iCountry.CreateL(aReadStream,len); |
|
904 } |
|
905 |
|
906 len=aReadStream.ReadInt32L(); |
|
907 iGenereName.Close(); |
|
908 if(len!=0) |
|
909 { |
|
910 iGenereName.CreateL(aReadStream,len); |
|
911 } |
|
912 |
|
913 len=aReadStream.ReadInt32L(); |
|
914 iGenereId.Close(); |
|
915 if(len!=0) |
|
916 { |
|
917 iGenereId.CreateL(aReadStream,len); |
|
918 } |
|
919 |
|
920 len=aReadStream.ReadInt32L(); |
|
921 iLastModified.Close(); |
|
922 if(len!=0) |
|
923 { |
|
924 iLastModified.CreateL(aReadStream,len); |
|
925 } |
|
926 |
|
927 len=aReadStream.ReadInt32L(); |
|
928 iAdvertisementUrl.Close(); |
|
929 if(len!=0) |
|
930 { |
|
931 iAdvertisementUrl.CreateL(aReadStream,len); |
|
932 } |
|
933 |
|
934 len=aReadStream.ReadInt32L(); |
|
935 iAdvertisementInUse.Close(); |
|
936 if(len!=0) |
|
937 { |
|
938 iAdvertisementInUse.CreateL(aReadStream,len); |
|
939 } |
|
940 |
|
941 len=aReadStream.ReadInt32L(); |
|
942 iImgUrl.Close(); |
|
943 if(len!=0) |
|
944 { |
|
945 iImgUrl.CreateL(aReadStream,len); |
|
946 } |
|
947 |
|
948 len=aReadStream.ReadInt32L(); |
|
949 iDescription.Close(); |
|
950 if(len!=0) |
|
951 { |
|
952 iDescription.CreateL(aReadStream,len); |
|
953 } |
|
954 |
|
955 len=aReadStream.ReadInt32L(); |
|
956 iShortDesc.Close(); |
|
957 if(len!=0) |
|
958 { |
|
959 iShortDesc.CreateL(aReadStream,len); |
|
960 } |
|
961 |
|
962 len=aReadStream.ReadInt32L(); |
|
963 iMusicStoreStatus.Close(); |
|
964 if(len!=0) |
|
965 { |
|
966 iMusicStoreStatus.CreateL(aReadStream,len); |
|
967 } |
|
968 |
|
969 |
|
970 len=aReadStream.ReadInt32L(); |
|
971 iLogoData.Close(); |
|
972 if(len!=0) |
|
973 { |
|
974 iLogoData.CreateL(aReadStream,len); |
|
975 } |
|
976 |
|
977 //internalizing the preset data |
|
978 CIRChannelServerUrl *url = NULL; |
|
979 for(TInt cnt=0;cnt<iChannelUrlCount;cnt++) |
|
980 { |
|
981 url = CIRChannelServerUrl::NewLC(); |
|
982 url->InternalizeL(aReadStream); |
|
983 iUrlArray->AppendL(url); |
|
984 CleanupStack::Pop(url); |
|
985 } |
|
986 |
|
987 iPlayedTimes = aReadStream.ReadInt32L(); |
|
988 |
|
989 iRenamed = aReadStream.ReadInt32L(); |
|
990 |
|
991 IRLOG_DEBUG( "CIRPresetImpl::InternalizeL - Exiting." ); |
|
992 } |
|
993 |
|
994 |
|
995 // --------------------------------------------------------------------------- |
|
996 // void CIRPresetImpl::CIRIsdsPresetToCIRPresetImpl(const CIRIsdsPreset& aIsdsPreset) |
|
997 // used to convert the isdspresets to plugnized presets. |
|
998 // Does a deep copy for all the member variables |
|
999 // --------------------------------------------------------------------------- |
|
1000 // |
|
1001 void CIRPresetImpl::CIRIsdsPresetToCIRPresetImpl(const CIRIsdsPreset& aIsdsPreset) |
|
1002 { |
|
1003 IRLOG_DEBUG( "CIRPresetImpl::CIRIsdsPresetToCIRPresetImpl" ); |
|
1004 iPresetId = aIsdsPreset.GetId(); |
|
1005 iChannelUrlCount = aIsdsPreset.GetUrlCount(); |
|
1006 iType = aIsdsPreset.GetChannelType(); //0 for user defined 1 for isds type. |
|
1007 |
|
1008 TRAP_IGNORE( SetNameL( aIsdsPreset.GetName() ) ) |
|
1009 SetLangCode( aIsdsPreset.GetLangId() ); |
|
1010 |
|
1011 SetLogoData( aIsdsPreset.GetLogoData() ); |
|
1012 SetLang( aIsdsPreset.GetLangName() ); |
|
1013 SetCountryCode( aIsdsPreset.GetCountryId() ); |
|
1014 SetCountryName( aIsdsPreset.GetCountryName() ); |
|
1015 SetLastModifiedTime( aIsdsPreset.GetLastModifiedTime() ); |
|
1016 SetAdvertisementUrl( aIsdsPreset.GetAdvertisementUrl() ); |
|
1017 SetAdvertisementInUse( aIsdsPreset.GetAdvertisementInUse() ); |
|
1018 SetImgUrl( aIsdsPreset.GetImgUrl() ); |
|
1019 SetDescription( aIsdsPreset.GetDescription() ); |
|
1020 SetShortDesc( aIsdsPreset.GetShortDescription() ); |
|
1021 SetMusicStoreStatus(aIsdsPreset.GetMusicStoreStatus()); |
|
1022 SetGenreInfo( aIsdsPreset.GetGenreId(), aIsdsPreset.GetGenreName() ); |
|
1023 |
|
1024 |
|
1025 iUrlArray->ResetAndDestroy(); |
|
1026 |
|
1027 for(TInt cnt=0;cnt<aIsdsPreset.GetUrlCount();cnt++) |
|
1028 { |
|
1029 ASSERT( cnt >= 0 && cnt < aIsdsPreset.iUrlArray->Count() ); |
|
1030 TRAPD(errUrl,SetUrlL(aIsdsPreset.iUrlArray->At(cnt)->GetServerName(), |
|
1031 aIsdsPreset.iUrlArray->At(cnt)->GetServerUrl(), |
|
1032 aIsdsPreset.iUrlArray->At(cnt)->GetBitRate())) |
|
1033 if(errUrl!=KErrNone) |
|
1034 { |
|
1035 return ; |
|
1036 } |
|
1037 } |
|
1038 IRLOG_DEBUG( "CIRPresetImpl::CIRIsdsPresetToCIRPresetImpl - Exiting." ); |
|
1039 } |
|
1040 /* |
|
1041 // --------------------------------------------------------------------------- |
|
1042 // void CIRPresetImpl::UserDefinedPresetToCIRPresetImpl |
|
1043 // used to convert the userdefined preset to plugnized presets. |
|
1044 // Does a deep copy for all the member variables |
|
1045 // --------------------------------------------------------------------------- |
|
1046 // |
|
1047 void CIRPresetImpl::UserDefinedPresetToCIRPresetImpl(const TDesC& aName, |
|
1048 const TDesC& aURl,TInt aId,TInt aIndex) |
|
1049 { |
|
1050 IRLOG_DEBUG( "CIRPresetImpl::UserDefinedPresetToCIRPresetImpl" ); |
|
1051 iPresetId=aId; |
|
1052 TRAP_IGNORE(SetNameL(aName)) |
|
1053 SetChannelType(0);//type set to user defined |
|
1054 //done to match the API,new API should be exposed by DS to accept only Url |
|
1055 _LIT(KServerName,"NA"); |
|
1056 //copy the url |
|
1057 TRAPD(errUrl,SetUrlL(KServerName,aURl,0)) |
|
1058 if(errUrl!=KErrNone) |
|
1059 { |
|
1060 IRLOG_ERROR2( "CIRPresetImpl::UserDefinedPresetToCIRPresetImpl - SetUrlL left with %d.", errUrl ); |
|
1061 return ; // WHATTHEHECK |
|
1062 } |
|
1063 // manually added channels have only one channel url |
|
1064 SetUrlCount(1); |
|
1065 IRLOG_DEBUG( "CIRPresetImpl::UserDefinedPresetToCIRPresetImpl - Exiting." ); |
|
1066 } |
|
1067 */ |
|
1068 |
|
1069 // --------------------------------------------------------------------------- |
|
1070 //CIRPresetImpl::CopyPresetData() |
|
1071 // copy data to CIRIsdsPreset |
|
1072 // --------------------------------------------------------------------------- |
|
1073 // |
|
1074 void CIRPresetImpl::CopyPresetData(CIRIsdsPreset& aIsdsPreset) const |
|
1075 { |
|
1076 IRLOG_DEBUG( "CIRPresetImpl::CopyPresetData" ); |
|
1077 aIsdsPreset.SetId( iPresetId ); |
|
1078 aIsdsPreset.SetUrlCount( iChannelUrlCount ); |
|
1079 aIsdsPreset.SetChannelType( iType ); //0 for user defined 1 for isds type. |
|
1080 //algo |
|
1081 //1.check if the CIRIsdsPreset,member contains any data |
|
1082 //2.if yes delete it and set it to null |
|
1083 //3.allocate memory and copy data |
|
1084 aIsdsPreset.SetGenreName( iGenereName ); |
|
1085 aIsdsPreset.SetGenreId( iGenereId ); |
|
1086 aIsdsPreset.SetLangCode( iLanguageCode ); |
|
1087 |
|
1088 aIsdsPreset.SetLogoData(iLogoData); |
|
1089 aIsdsPreset.SetLang( iLanguage ); |
|
1090 aIsdsPreset.SetCountryCode( iCountryCode ); |
|
1091 aIsdsPreset.SetCountryName( iCountry ); |
|
1092 aIsdsPreset.SetName( Name() ); |
|
1093 aIsdsPreset.SetLastModifiedTime( iLastModified ); |
|
1094 aIsdsPreset.SetAdvertisementUrl( iAdvertisementUrl ); |
|
1095 aIsdsPreset.SetAdvertisementInUse( iAdvertisementInUse ); |
|
1096 aIsdsPreset.SetImgUrl( iImgUrl ); |
|
1097 aIsdsPreset.SetDescription( iDescription ); |
|
1098 aIsdsPreset.SetShortDesc( iShortDesc ); |
|
1099 aIsdsPreset.SetMusicStoreStatus( iMusicStoreStatus ); |
|
1100 |
|
1101 aIsdsPreset.iUrlArray->ResetAndDestroy(); |
|
1102 |
|
1103 for(TInt cnt=0;cnt<iChannelUrlCount;cnt++) |
|
1104 { |
|
1105 ASSERT( cnt >= 0 && cnt < iUrlArray->Count() ); |
|
1106 TRAPD(errUrl,aIsdsPreset.SetUrlL(iUrlArray->At(cnt)->GetServerName(), |
|
1107 iUrlArray->At(cnt)->GetServerUrl(), |
|
1108 iUrlArray->At(cnt)->GetBitRate())) |
|
1109 if(errUrl!=KErrNone) |
|
1110 { |
|
1111 return ; |
|
1112 } |
|
1113 } |
|
1114 IRLOG_DEBUG( "CIRPresetImpl::CopyPresetData - Exiting." ); |
|
1115 } |
|
1116 |
|
1117 |
|
1118 // --------------------------------------------------------------------------- |
|
1119 // CIRPresetImpl::GetAvailableBitrates() |
|
1120 // Function to get available bitrates |
|
1121 // --------------------------------------------------------------------------- |
|
1122 // |
|
1123 RArray<TInt>& CIRPresetImpl::GetAvailableBitrates() |
|
1124 { |
|
1125 IRLOG_DEBUG( "CIRPresetImpl::GetAvailableBitrates" ); |
|
1126 iBitrateArray.Reset(); |
|
1127 //creates an array of bitrates(int)that are available for a particular preset |
|
1128 for(TInt loop=0;loop<iUrlArray->Count();loop++) |
|
1129 { |
|
1130 iBitrateArray.InsertInOrder(iUrlArray->At(loop)->GetBitRate()); |
|
1131 } |
|
1132 IRLOG_DEBUG( "CIRPresetImpl::GetAvailableBitrates - Exiting." ); |
|
1133 return iBitrateArray; |
|
1134 } |
|
1135 |
|
1136 /* |
|
1137 * Returns the played times of the channel |
|
1138 */ |
|
1139 TInt CIRPresetImpl::GetPlayedTimes() const |
|
1140 { |
|
1141 return iPlayedTimes; |
|
1142 } |
|
1143 |
|
1144 /* |
|
1145 * Set the played times of the channel |
|
1146 */ |
|
1147 void CIRPresetImpl::SetPlayedTimes(TInt aPlayedTimes) |
|
1148 { |
|
1149 iPlayedTimes = aPlayedTimes; |
|
1150 } |
|
1151 |
|
1152 TBool CIRPresetImpl::GetRenamed() const |
|
1153 { |
|
1154 return iRenamed; |
|
1155 } |
|
1156 |
|
1157 void CIRPresetImpl::SetRenamed() |
|
1158 { |
|
1159 iRenamed = ETrue; |
|
1160 } |
|