|
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 #include "wmimageconverter.h" |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class CDictionaryFileStore; |
|
34 class MWmWidgetDataObserver; |
|
35 class CFbsBitmap; |
|
36 class CHsContentInfo; |
|
37 class CWmPersistentWidgetOrder; |
|
38 class RWidgetRegistryClientSession; |
|
39 |
|
40 // CLASS DECLARATION |
|
41 /** |
|
42 * CWmWidgetData is a representation of a widget in CWmListBox. it |
|
43 * stores all data required for drawing the item in a list box, and |
|
44 * handling the list item. |
|
45 */ |
|
46 NONSHARABLE_CLASS( CWmWidgetData ) |
|
47 : public CBase |
|
48 , public MConverterObserver |
|
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 public: // construction |
|
62 /** |
|
63 * static constructor |
|
64 * @param aHsContentInfo (takes ownership) |
|
65 * @param aRegistryClientSession (does not take ownership) |
|
66 */ |
|
67 static CWmWidgetData* NewL( |
|
68 CHsContentInfo* aHsContentInfo, |
|
69 RWidgetRegistryClientSession* aRegistryClientSession ); |
|
70 |
|
71 /** |
|
72 * static constructor, leaves object in cleanup stack |
|
73 * @param aHsContentInfo (takes ownership) |
|
74 * @param aRegistryClientSession (does not take ownership) |
|
75 */ |
|
76 static CWmWidgetData* NewLC( |
|
77 CHsContentInfo* aHsContentInfo, |
|
78 RWidgetRegistryClientSession* aRegistryClientSession ); |
|
79 |
|
80 /** Destructor. */ |
|
81 ~CWmWidgetData(); |
|
82 |
|
83 private: // private construction |
|
84 /** Constructor for performing 1st stage construction */ |
|
85 CWmWidgetData(); |
|
86 |
|
87 /** 2nd phase constructor */ |
|
88 void ConstructL( |
|
89 CHsContentInfo* aHsContentInfo, |
|
90 RWidgetRegistryClientSession* aRegistryClientSession ); |
|
91 |
|
92 /** |
|
93 * Initialisation routine |
|
94 * called from ConstructL and whenever the content type changes |
|
95 */ |
|
96 void InitL( |
|
97 CHsContentInfo* aHsContentInfo, |
|
98 RWidgetRegistryClientSession* aRegistryClientSession ); |
|
99 |
|
100 public: // external handles |
|
101 |
|
102 /** |
|
103 * sets an observer for callbacks |
|
104 * |
|
105 * @param aObserver notifications when changes occur in widget data |
|
106 */ |
|
107 void SetObserver( MWmWidgetDataObserver* aObserver ); |
|
108 |
|
109 /** |
|
110 * persistent widget order handle, which is used in comparing |
|
111 */ |
|
112 void SetPersistentWidgetOrder( |
|
113 const CWmPersistentWidgetOrder* aPersistentWidgetOrder ); |
|
114 |
|
115 /** |
|
116 * set logo rect size |
|
117 */ |
|
118 void SetLogoSize( const TSize& aSize ); |
|
119 |
|
120 /** |
|
121 * Init logo re-creation |
|
122 */ |
|
123 void ReCreateLogo( const TSize& aSize ); |
|
124 |
|
125 /** |
|
126 * Replaces the content of this widget data. The method is called |
|
127 * during widget update. If widget values change, a change event is |
|
128 * fired for the observer. |
|
129 * |
|
130 * @param aHsContentInfo new content (takes ownership) |
|
131 * @return ETrue if content was changed |
|
132 */ |
|
133 TBool ReplaceContentInfoL( |
|
134 CHsContentInfo* aHsContentInfo ); |
|
135 |
|
136 public: // comparing / sorting |
|
137 /** whether this object represents the same widget as aContentInfo */ |
|
138 TBool EqualsTo( CHsContentInfo& aContentInfo ); |
|
139 |
|
140 /** comparator function for sort by name (compare two names)*/ |
|
141 static TInt CompareByName( |
|
142 const CWmWidgetData& aDataOne, |
|
143 const CWmWidgetData& aDataTwo ); |
|
144 |
|
145 /** |
|
146 * comparator function for sorting by stored order |
|
147 **/ |
|
148 static TInt CompareByPersistentWidgetOrder( |
|
149 const CWmWidgetData& aDataOne, |
|
150 const CWmWidgetData& aDataTwo ); |
|
151 |
|
152 public: // methods to read the content |
|
153 |
|
154 /** the HsContent info */ |
|
155 inline CHsContentInfo& HsContentInfo(); |
|
156 |
|
157 /** the HsContent info */ |
|
158 inline const CHsContentInfo& HsContentInfo() const; |
|
159 |
|
160 /** widget name */ |
|
161 inline const TDesC& Name() const; |
|
162 |
|
163 /** widget description */ |
|
164 inline const TDesC& Description() const; |
|
165 |
|
166 /** widget uid */ |
|
167 inline TUid Uid() const; |
|
168 |
|
169 /** cps widget publisher id */ |
|
170 inline const TDesC& PublisherId() const; |
|
171 |
|
172 /** cps widget publisher uid */ |
|
173 TUid PublisherUid(); |
|
174 |
|
175 /** widget type */ |
|
176 inline TWidgetType WidgetType() const; |
|
177 |
|
178 /** running install animation index */ |
|
179 inline TInt InstallAnimationIndex() const; |
|
180 |
|
181 /** the logo bitmap */ |
|
182 inline const CFbsBitmap* LogoImage(); |
|
183 |
|
184 /** the logo bitmap */ |
|
185 inline const CFbsBitmap* LogoImageMask(); |
|
186 |
|
187 /** whether the widget data is valid or not */ |
|
188 inline TBool IsValid(); |
|
189 |
|
190 /** sets the widget data validity */ |
|
191 inline void SetValid( TBool aValid ); |
|
192 |
|
193 protected: // from MConverterObserver |
|
194 |
|
195 /** image conversin completed */ |
|
196 void NotifyCompletion( TInt aError ); |
|
197 |
|
198 private: // new functions |
|
199 |
|
200 /** fetches publisher uid from widget registry*/ |
|
201 void FetchPublisherUidL( |
|
202 RWidgetRegistryClientSession* aRegistryClientSession ); |
|
203 |
|
204 /** Converts uid to TUid from TDesC8 */ |
|
205 TUid UidFromString( const TDesC8& aUidString ) const; |
|
206 |
|
207 /** Logo icon string handling */ |
|
208 static TInt HandleAsyncIconString( TAny* aPtr ); |
|
209 void HandleIconStringL( const TDesC& aIconStr ); |
|
210 void FireDataChanged(); |
|
211 |
|
212 private: // data members |
|
213 |
|
214 /* instance of the CIdle class for async iconStr handling*/ |
|
215 CIdle* iIdle; |
|
216 |
|
217 /* the image converter utility */ |
|
218 CWmImageConverter* iImageConverter; |
|
219 |
|
220 /* observes this widget representation (NOT OWNED) */ |
|
221 MWmWidgetDataObserver* iObserver; |
|
222 |
|
223 /* rotating animation index */ |
|
224 TInt iInstallAnimationIndex; |
|
225 |
|
226 /** the widget logo bitmap */ |
|
227 CFbsBitmap* iLogoImage; |
|
228 |
|
229 /** the widget logo mask */ |
|
230 CFbsBitmap* iLogoImageMask; |
|
231 |
|
232 /** The CHsContentInfo that corresponds to this list row */ |
|
233 CHsContentInfo* iHsContentInfo; |
|
234 |
|
235 /** type oif the widget */ |
|
236 TWidgetType iWidgetType; |
|
237 |
|
238 /** persistent order of widgets (used in sorting) */ |
|
239 const CWmPersistentWidgetOrder* iPersistentWidgetOrder; |
|
240 |
|
241 /** wrt widget publisher uid */ |
|
242 TUid iPublisherUid; |
|
243 |
|
244 /** size of logo rect in list item */ |
|
245 TSize iLogoSize; |
|
246 |
|
247 /** validity of the widget - used during list refresh */ |
|
248 TBool iValid; |
|
249 |
|
250 }; |
|
251 |
|
252 |
|
253 /** |
|
254 * Pointer array of widget data objects. |
|
255 * Also acts as an adapter to a descriptor array, providing the |
|
256 * widget names as descriptor array elements. |
|
257 */ |
|
258 NONSHARABLE_CLASS( RWidgetDataValues ) : public RPointerArray<CWmWidgetData>, |
|
259 public MDesCArray |
|
260 { |
|
261 protected: // from MDesCArray |
|
262 /** returns number of items in the pointer array */ |
|
263 inline TInt MdcaCount() const; |
|
264 |
|
265 /** returns the pointed widget name */ |
|
266 inline TPtrC16 MdcaPoint(TInt aIndex) const; |
|
267 |
|
268 }; |
|
269 |
|
270 #include "wmwidgetdata.inl" |
|
271 #endif // WMWIDGETDATA_H |