|
1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * CWmWidgetData declaration |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef WMWIDGETDATA_H |
|
21 #define WMWIDGETDATA_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32std.h> |
|
25 #include <e32base.h> |
|
26 #include <f32file.h> |
|
27 #include <bamdesca.h> |
|
28 #include <hscontentinfo.h> |
|
29 |
|
30 |
|
31 // FORWARD DECLARATIONS |
|
32 class CDictionaryFileStore; |
|
33 class MWmWidgetDataObserver; |
|
34 class CFbsBitmap; |
|
35 class CHsContentInfo; |
|
36 class CWmPersistentWidgetOrder; |
|
37 class RWidgetRegistryClientSession; |
|
38 class CWmResourceLoader; |
|
39 class CWmImageConverter; |
|
40 |
|
41 // CLASS DECLARATION |
|
42 /** |
|
43 * CWmWidgetData is a representation of a widget in CWmListBox. it |
|
44 * stores all data required for drawing the item in a list box, and |
|
45 * handling the list item. |
|
46 */ |
|
47 NONSHARABLE_CLASS( CWmWidgetData ) |
|
48 : public CBase |
|
49 { |
|
50 |
|
51 public: // types |
|
52 |
|
53 /** widget type */ |
|
54 enum TWidgetType |
|
55 { |
|
56 EUnknown, |
|
57 ENative, |
|
58 ECps // wrt widgets included in this category |
|
59 }; |
|
60 |
|
61 /** wrt widget type */ |
|
62 enum TWrtType |
|
63 { |
|
64 EUnIdentified, |
|
65 EWgz, |
|
66 EWgt |
|
67 }; |
|
68 |
|
69 public: // construction |
|
70 /** |
|
71 * static constructor |
|
72 * @param aLogoSize size of logo image. |
|
73 * @param aHsContentInfo (takes ownership) |
|
74 * @param aRegistryClientSession (does not take ownership) |
|
75 */ |
|
76 static CWmWidgetData* NewL( |
|
77 const TSize& aLogoSize, |
|
78 CWmResourceLoader& aWmResourceLoader, |
|
79 CHsContentInfo* aHsContentInfo, |
|
80 RWidgetRegistryClientSession* aRegistryClientSession ); |
|
81 |
|
82 /** |
|
83 * static constructor, leaves object in cleanup stack |
|
84 * @param aLogoSize size of logo image. |
|
85 * @param aHsContentInfo (takes ownership) |
|
86 * @param aRegistryClientSession (does not take ownership) |
|
87 */ |
|
88 static CWmWidgetData* NewLC( |
|
89 const TSize& aLogoSize, |
|
90 CWmResourceLoader& aWmResourceLoader, |
|
91 CHsContentInfo* aHsContentInfo, |
|
92 RWidgetRegistryClientSession* aRegistryClientSession ); |
|
93 |
|
94 /** Destructor. */ |
|
95 ~CWmWidgetData(); |
|
96 |
|
97 private: // private construction |
|
98 /** Constructor for performing 1st stage construction */ |
|
99 CWmWidgetData( const TSize& aLogoSize, |
|
100 CWmResourceLoader& aWmResourceLoader ); |
|
101 |
|
102 /** 2nd phase constructor */ |
|
103 void ConstructL( |
|
104 CHsContentInfo* aHsContentInfo, |
|
105 RWidgetRegistryClientSession* aRegistryClientSession ); |
|
106 |
|
107 /** |
|
108 * Initialisation routine |
|
109 * called from ConstructL and whenever the content type changes |
|
110 */ |
|
111 void InitL( |
|
112 CHsContentInfo* aHsContentInfo, |
|
113 RWidgetRegistryClientSession* aRegistryClientSession ); |
|
114 |
|
115 public: // external handles |
|
116 |
|
117 /** current uninstall animation bitmap */ |
|
118 const CFbsBitmap* AnimationBitmap( const TSize& aSize ); |
|
119 |
|
120 /** current uninstall animation mask */ |
|
121 const CFbsBitmap* AnimationMask( const TSize& aSize ); |
|
122 |
|
123 /** |
|
124 * @return ETrue if widget is being uninstalled. |
|
125 */ |
|
126 TBool IsUninstalling(); |
|
127 |
|
128 /** |
|
129 * @return ETrue if logo is being created,false otherwise. |
|
130 */ |
|
131 TBool IsPrepairingLogo(); |
|
132 |
|
133 /** |
|
134 * sets an observer for callbacks |
|
135 * |
|
136 * @param aObserver notifications when changes occur in widget data |
|
137 */ |
|
138 void SetObserver( MWmWidgetDataObserver* aObserver ); |
|
139 |
|
140 /** |
|
141 * persistent widget order handle, which is used in comparing |
|
142 */ |
|
143 void SetPersistentWidgetOrder( |
|
144 const CWmPersistentWidgetOrder* aPersistentWidgetOrder ); |
|
145 |
|
146 /** |
|
147 * Init logo re-creation |
|
148 */ |
|
149 void UpdateLogo( const TSize& aSize, TBool aReCreateLogo ); |
|
150 |
|
151 /** |
|
152 * returns widget description |
|
153 */ |
|
154 const TDesC& Description() const; |
|
155 |
|
156 /** |
|
157 * Replaces the content of this widget data. The method is called |
|
158 * during widget update. If widget values change, a change event is |
|
159 * fired for the observer. |
|
160 * |
|
161 * @param aHsContentInfo new content (takes ownership) |
|
162 * @return ETrue if content was changed |
|
163 */ |
|
164 TBool ReplaceContentInfo( |
|
165 CHsContentInfo* aHsContentInfo ); |
|
166 |
|
167 public: // comparing / sorting |
|
168 /** whether this object represents the same widget as aContentInfo */ |
|
169 TBool EqualsTo( CHsContentInfo& aContentInfo ); |
|
170 |
|
171 /** comparator function for sort by name (compare two names)*/ |
|
172 static TInt CompareByName( |
|
173 const CWmWidgetData& aDataOne, |
|
174 const CWmWidgetData& aDataTwo ); |
|
175 |
|
176 /** |
|
177 * comparator function for sorting by stored order |
|
178 **/ |
|
179 static TInt CompareByPersistentWidgetOrder( |
|
180 const CWmWidgetData& aDataOne, |
|
181 const CWmWidgetData& aDataTwo ); |
|
182 |
|
183 public: // methods to read the content |
|
184 |
|
185 /** Mdcapoint for listbox("\t0widget name") */ |
|
186 const TDesC& MdcaPoint() const; |
|
187 |
|
188 /** the HsContent info */ |
|
189 inline CHsContentInfo& HsContentInfo(); |
|
190 |
|
191 /** the HsContent info */ |
|
192 inline const CHsContentInfo& HsContentInfo() const; |
|
193 |
|
194 /** widget name */ |
|
195 const TDesC& Name() const; |
|
196 |
|
197 /** widget uid */ |
|
198 inline TUid Uid() const; |
|
199 |
|
200 /** cps widget publisher id */ |
|
201 inline const TDesC& PublisherId() const; |
|
202 |
|
203 /** cps widget publisher uid */ |
|
204 TUid PublisherUid(); |
|
205 |
|
206 /** widget type */ |
|
207 inline TWidgetType WidgetType() const; |
|
208 |
|
209 /** wrt widget type */ |
|
210 inline TWrtType WrtType() const; |
|
211 |
|
212 /** running install animation index */ |
|
213 inline TInt InstallAnimationIndex() const; |
|
214 |
|
215 /** the logo bitmap */ |
|
216 inline const CFbsBitmap* LogoImage(); |
|
217 |
|
218 /** the logo bitmap */ |
|
219 inline const CFbsBitmap* LogoImageMask(); |
|
220 |
|
221 /** whether the widget data is valid or not */ |
|
222 inline TBool IsValid(); |
|
223 |
|
224 /** sets the widget data validity */ |
|
225 inline void SetValid( TBool aValid ); |
|
226 |
|
227 /** start animation for uninstallation*/ |
|
228 void VisualizeUninstallL(); |
|
229 |
|
230 /** stop uninstallation animation */ |
|
231 void StopUninstallAnimation(); |
|
232 |
|
233 private: // new functions |
|
234 |
|
235 /** uninstall animation related*/ |
|
236 void PrepairAnimL(); |
|
237 void DestroyAnimData(); |
|
238 static TInt AnimationTick( TAny* aPtr ); |
|
239 |
|
240 /** fetches publisher uid from widget registry*/ |
|
241 void FetchPublisherUidL( |
|
242 const TDesC& aPublisherId, |
|
243 RWidgetRegistryClientSession* aRegistryClientSession ); |
|
244 |
|
245 /** Converts uid to TUid from TDesC8 */ |
|
246 TUid UidFromString( const TDesC8& aUidString ) const; |
|
247 |
|
248 /** Logo icon string handling */ |
|
249 void HandleIconString( const TDesC& aIconStr ); |
|
250 void FireDataChanged(); |
|
251 |
|
252 private: // data members |
|
253 |
|
254 /* reference to resource loader */ |
|
255 CWmResourceLoader& iWmResourceLoader; |
|
256 |
|
257 /* observes this widget representation (NOT OWNED) */ |
|
258 MWmWidgetDataObserver* iObserver; |
|
259 |
|
260 /** the widget logo bitmap */ |
|
261 CFbsBitmap* iLogoImage; |
|
262 |
|
263 /** the widget logo mask */ |
|
264 CFbsBitmap* iLogoImageMask; |
|
265 |
|
266 /** The CHsContentInfo that corresponds to this list row */ |
|
267 CHsContentInfo* iHsContentInfo; |
|
268 |
|
269 /** type of the widget */ |
|
270 TWidgetType iWidgetType; |
|
271 |
|
272 /** type of the wrt widget */ |
|
273 TWrtType iWrtType; |
|
274 |
|
275 /** persistent order of widgets (used in sorting) */ |
|
276 const CWmPersistentWidgetOrder* iPersistentWidgetOrder; |
|
277 |
|
278 /** "0\t" + widget name for listbox*/ |
|
279 HBufC* iMdcaPoint; |
|
280 |
|
281 /** wrt widget publisher uid */ |
|
282 TUid iPublisherUid; |
|
283 |
|
284 /** size of logo rect in list item */ |
|
285 TSize iLogoSize; |
|
286 |
|
287 /** validity of the widget - used during list refresh */ |
|
288 TBool iValid; |
|
289 |
|
290 /* Array of uninstall animation bitmaps*/ |
|
291 RArray<CFbsBitmap*> iUninstallAnimIcons; |
|
292 |
|
293 /** timer for updating animation */ |
|
294 CPeriodic* iAnimationTimer; |
|
295 |
|
296 /* uninstall animation index */ |
|
297 TInt iAnimationIndex; |
|
298 |
|
299 /** uninstallation switch */ |
|
300 TBool iAsyncUninstalling; |
|
301 |
|
302 /* the image converter utility */ |
|
303 CWmImageConverter* iImageConverter; |
|
304 }; |
|
305 |
|
306 |
|
307 /** |
|
308 * Pointer array of widget data objects. |
|
309 * Also acts as an adapter to a descriptor array, providing the |
|
310 * widget names as descriptor array elements. |
|
311 */ |
|
312 NONSHARABLE_CLASS( RWidgetDataValues ) : public RPointerArray<CWmWidgetData>, |
|
313 public MDesCArray |
|
314 { |
|
315 protected: // from MDesCArray |
|
316 /** returns number of items in the pointer array */ |
|
317 inline TInt MdcaCount() const; |
|
318 |
|
319 /** returns the pointed widget name */ |
|
320 inline TPtrC16 MdcaPoint(TInt aIndex) const; |
|
321 }; |
|
322 |
|
323 #include "wmwidgetdata.inl" |
|
324 #endif // WMWIDGETDATA_H |