1 /* |
|
2 * Copyright (c) 2008-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: Data for single station logo |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <alf/alfenv.h> |
|
20 #include <alf/alfevent.h> |
|
21 #include <alf/alfimagevisual.h> |
|
22 #include <alf/alftexture.h> |
|
23 #include "irdebug.h" |
|
24 |
|
25 #include "irstationlogodata.h" |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // Default constructor |
|
29 // --------------------------------------------------------------------------- |
|
30 // |
|
31 CIRStationLogoData::CIRStationLogoData( TInt aId, const TDesC8& aRawData ) : |
|
32 iData( aRawData ), |
|
33 iId( aId ), |
|
34 iTextureId( KErrNotFound ) |
|
35 { |
|
36 } |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // Second phase constructor |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 void CIRStationLogoData::ConstructL() |
|
43 { |
|
44 //TO DO :: The line can be removed in future nad written to fix |
|
45 return; |
|
46 } |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // Two-phased constructor |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 CIRStationLogoData* CIRStationLogoData::NewLC( TInt aId, const TDesC8& aRawData ) |
|
53 { |
|
54 CIRStationLogoData* self = new( ELeave ) CIRStationLogoData( aId, aRawData ); |
|
55 CleanupStack::PushL( self ); |
|
56 self->ConstructL(); |
|
57 return self; |
|
58 } |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // Destructor |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 CIRStationLogoData::~CIRStationLogoData() |
|
65 { |
|
66 DestroyVisual(); |
|
67 DestroyTexture(); |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // Sets the raw data |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 void CIRStationLogoData::SetRawData( const TDesC8& aRawData ) |
|
75 { |
|
76 iData.Set( aRawData ); |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // Provides the raw data |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 const TDesC8& CIRStationLogoData::RawData() const |
|
84 { |
|
85 return iData; |
|
86 } |
|
87 |
|
88 // --------------------------------------------------------------------------- |
|
89 // Updates the texture |
|
90 // --------------------------------------------------------------------------- |
|
91 // |
|
92 void CIRStationLogoData::UpdateTextureL( CFbsBitmap* aBitmap, CFbsBitmap* aMask ) |
|
93 { |
|
94 IRLOG_DEBUG(" *** S60VisualRadio -- CIRStationLogoData::UpdateTextureL()"); |
|
95 DestroyTexture(); |
|
96 iBitmap = aBitmap; |
|
97 iMask = aMask; |
|
98 iTexture = &CAlfEnv::Static()->TextureManager().CreateTextureL( KAlfAutoGeneratedTextureId, |
|
99 this, EAlfTextureFlagRetainResolution ); |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------------------------- |
|
103 // Destroys the texture |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 void CIRStationLogoData::DestroyTexture() |
|
107 { |
|
108 IRLOG_DEBUG(" *** S60VisualRadio -- CIRStationLogoData::DestroyTexture()"); |
|
109 if( iTextureId != KErrNotFound ) |
|
110 { |
|
111 CAlfEnv::Static()->TextureManager().UnloadTexture( iTextureId ); |
|
112 } |
|
113 delete iTexture; |
|
114 iTexture = NULL; |
|
115 |
|
116 delete iBitmap; |
|
117 iBitmap = NULL; |
|
118 delete iMask; |
|
119 iMask = NULL; |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------------------------- |
|
123 // Sets the visual for this logo data |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 void CIRStationLogoData::SetVisual( CAlfImageVisual* aVisual ) |
|
127 { |
|
128 DestroyVisual(); |
|
129 iVisual = aVisual; |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 // Provides the visual |
|
134 // --------------------------------------------------------------------------- |
|
135 // |
|
136 CAlfImageVisual* CIRStationLogoData::Visual() |
|
137 { |
|
138 return iVisual; |
|
139 } |
|
140 |
|
141 // --------------------------------------------------------------------------- |
|
142 // Destroys the visual |
|
143 // --------------------------------------------------------------------------- |
|
144 // |
|
145 void CIRStationLogoData::DestroyVisual() |
|
146 { |
|
147 IRLOG_DEBUG(" *** S60VisualRadio -- CIRStationLogoData::DestroyVisual()"); |
|
148 if( iVisual ) |
|
149 { |
|
150 iVisual->RemoveAndDestroyAllD(); |
|
151 } |
|
152 iVisual = NULL; |
|
153 } |
|
154 |
|
155 // --------------------------------------------------------------------------- |
|
156 // Provides the texture |
|
157 // --------------------------------------------------------------------------- |
|
158 // |
|
159 CAlfTexture* CIRStationLogoData::Texture() |
|
160 { |
|
161 return iTexture; |
|
162 } |
|
163 |
|
164 // --------------------------------------------------------------------------- |
|
165 // Provides the ID |
|
166 // --------------------------------------------------------------------------- |
|
167 // |
|
168 TInt CIRStationLogoData::Id() const |
|
169 { |
|
170 return iId; |
|
171 } |
|
172 |
|
173 // --------------------------------------------------------------------------- |
|
174 // From class MAlfBitmapProvider. |
|
175 // Provides the bitmap for the texture |
|
176 // --------------------------------------------------------------------------- |
|
177 // |
|
178 void CIRStationLogoData::ProvideBitmapL(TInt aId, CFbsBitmap*& aBitmap, CFbsBitmap*& aMaskBitmap) |
|
179 { |
|
180 IRLOG_DEBUG2(" *** S60VisualRadio -- CIRStationLogoData::ProvideBitmapL(aId=%d)", aId); |
|
181 iTextureId = aId; |
|
182 // Ownership is transfered so the members are NULLED |
|
183 aBitmap = iBitmap; |
|
184 iBitmap = NULL; |
|
185 aMaskBitmap = iMask; |
|
186 iMask = NULL; |
|
187 |
|
188 return; |
|
189 } |
|
190 |
|
191 // --------------------------------------------------------------------------- |
|
192 // From class MAlfEventHandler. |
|
193 // Handles the Alf events |
|
194 // --------------------------------------------------------------------------- |
|
195 // |
|
196 TBool CIRStationLogoData::OfferEventL( const TAlfEvent& aEvent ) |
|
197 { |
|
198 TBool eventHandled( EFalse ); |
|
199 if( aEvent.IsCustomEvent() && aEvent.CustomParameter() == EIRCustomEventLogoFadeOutComplete ) |
|
200 { |
|
201 IRLOG_DEBUG(" *** S60VisualRadio -- CIRStationLogoData::OfferEventL() -- deleting visual and texture"); |
|
202 DestroyVisual(); |
|
203 DestroyTexture(); |
|
204 eventHandled = ETrue; |
|
205 } |
|
206 |
|
207 return eventHandled; |
|
208 } |
|