|
1 /* |
|
2 * Copyright (c) 2005-2007 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: Plug-in main class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef WRTDATAPLUGIN_H |
|
20 #define WRTDATAPLUGIN_H |
|
21 |
|
22 // System includes |
|
23 |
|
24 // User includes |
|
25 #include <hscontentpublisher.h> |
|
26 #include <aicontentmodel.h> |
|
27 |
|
28 // Forward declarations |
|
29 class MAiContentObserver; |
|
30 class MAiContentItemIterator; |
|
31 class CWrtData; |
|
32 class CGulIcon; |
|
33 class CLiwDefaultMap; |
|
34 |
|
35 /** |
|
36 * @ingroup group_wrtdataplugin |
|
37 * |
|
38 * Plug-in main class |
|
39 * |
|
40 * @since S60 v3.2 |
|
41 */ |
|
42 NONSHARABLE_CLASS( CWrtDataPlugin ) : public CHsContentPublisher |
|
43 { |
|
44 public: |
|
45 // type definitions |
|
46 |
|
47 /** |
|
48 * Plugin's network state. |
|
49 */ |
|
50 enum TPluginNetworkStatus |
|
51 { |
|
52 EUnknown, |
|
53 EOffline, |
|
54 EOnline |
|
55 }; |
|
56 |
|
57 /** |
|
58 * Plugin's state. |
|
59 */ |
|
60 enum TPluginStates |
|
61 { |
|
62 EStopped, |
|
63 EStarted, |
|
64 EResume, |
|
65 ESuspend |
|
66 }; |
|
67 |
|
68 /** |
|
69 * Content Items |
|
70 */ |
|
71 enum TContentItem |
|
72 { |
|
73 EDefaultImage, |
|
74 EDefaultText, |
|
75 EImage1 |
|
76 }; |
|
77 |
|
78 public: |
|
79 // constructor and destructor |
|
80 |
|
81 static CWrtDataPlugin* NewL(); |
|
82 |
|
83 ~CWrtDataPlugin(); |
|
84 |
|
85 private: |
|
86 // constructors |
|
87 |
|
88 /** |
|
89 * C++ constructor |
|
90 */ |
|
91 CWrtDataPlugin(); |
|
92 |
|
93 /** |
|
94 * 2nd phase constructor |
|
95 */ |
|
96 void ConstructL(); |
|
97 |
|
98 public: |
|
99 // from CHsContentPublisher |
|
100 |
|
101 /** |
|
102 * @see CHsContentPublisher |
|
103 */ |
|
104 void Start( TStartReason aReason ); |
|
105 |
|
106 /** |
|
107 * @see CHsContentPublisher |
|
108 */ |
|
109 void Stop( TStopReason aReason ); |
|
110 |
|
111 /** |
|
112 * @see CHsContentPublisher |
|
113 */ |
|
114 void Resume( TResumeReason aReason ); |
|
115 |
|
116 /** |
|
117 * @see CHsContentPublisher |
|
118 */ |
|
119 void Suspend( TSuspendReason aReason ); |
|
120 |
|
121 /** |
|
122 * @see CHsContentPublisher |
|
123 */ |
|
124 void SetOnline(); |
|
125 |
|
126 /** |
|
127 * @see CHsContentPublisher |
|
128 */ |
|
129 void SetOffline(); |
|
130 |
|
131 /** |
|
132 * @see CHsContentPublisher |
|
133 */ |
|
134 void SubscribeL( MAiContentObserver& aObserver ); |
|
135 |
|
136 /** |
|
137 * @see CHsContentPublisher |
|
138 */ |
|
139 void ConfigureL( RAiSettingsItemArray& aSettings ); |
|
140 |
|
141 /** |
|
142 * @see CHsContentPublisher |
|
143 */ |
|
144 void SetProperty( TProperty aProperty, TAny* aAny ); |
|
145 |
|
146 /** |
|
147 * @see CHsContentPublisher |
|
148 */ |
|
149 TAny* GetProperty( TProperty aProperty ); |
|
150 |
|
151 /** |
|
152 * @see CHsContentPublisher |
|
153 */ |
|
154 void HandleEvent( const TDesC& aEventName, const TDesC& aParam ); |
|
155 |
|
156 public: |
|
157 |
|
158 /** |
|
159 * Gets the id of a content |
|
160 * |
|
161 * @param aObjectId image or text id |
|
162 * @return id of the content |
|
163 */ |
|
164 TInt GetIdL( TDesC16& aObjectId ); |
|
165 |
|
166 /** |
|
167 * Gets the type of a specific content |
|
168 * |
|
169 * @param aObjectId image or text id |
|
170 * @param aType type |
|
171 * @return void |
|
172 */ |
|
173 void GetTypeL( TDesC16& aObjectId, TDes16& aType ); |
|
174 |
|
175 /** |
|
176 * RefereshL a specific image of text in the widget |
|
177 * |
|
178 * @param aOperation operation performed |
|
179 * @param aDataMap data map |
|
180 * @return void |
|
181 */ |
|
182 void RefreshL( TDesC16& aOperation, CLiwDefaultMap* aDataMap ); |
|
183 |
|
184 /** |
|
185 * Is plugin active to publish the data |
|
186 * |
|
187 * @param void |
|
188 * @return boolean (ETrue/EFalse) |
|
189 */ |
|
190 TBool IsActive() const; |
|
191 |
|
192 /** |
|
193 * Is plugin stopped |
|
194 * |
|
195 * @param void |
|
196 * @return boolean (ETrue/EFalse) |
|
197 */ |
|
198 TBool IsStopped() const; |
|
199 |
|
200 /** |
|
201 * Publish a specific text of the widget |
|
202 * |
|
203 * @param aObserver observer |
|
204 * @param aContentId content model id |
|
205 * @param aContentValue content value |
|
206 * @return void |
|
207 */ |
|
208 void PublishTextL( MAiContentObserver* aObserver, |
|
209 TInt aContentId, const TDesC16& aContentValue ); |
|
210 |
|
211 /** |
|
212 * Publish a specific image of the widget |
|
213 * |
|
214 * @param aObserver observer |
|
215 * @param aContentId content model id |
|
216 * @param aHandle image handle |
|
217 * @param aMaskHandle handle of the mask image |
|
218 * @return void |
|
219 */ |
|
220 void PublishImageL( MAiContentObserver* aObserver, |
|
221 TContentItem aContentId, TInt aHandle, TInt aMaskHandle ); |
|
222 |
|
223 /** |
|
224 * Publish a specific image of the widget |
|
225 * |
|
226 * @param aObserver observer |
|
227 * @param aContentId content model id |
|
228 * @param aPath image path / skin id pattern / mif id Pattern |
|
229 * @return void |
|
230 */ |
|
231 void PublishImageL( MAiContentObserver* aObserver, |
|
232 TContentItem aContentId, const TDesC16& aPath ); |
|
233 |
|
234 /** |
|
235 * Cleans a data from the widget |
|
236 * |
|
237 * @param aObserver observer |
|
238 * @param aContentId content model id |
|
239 * @return void |
|
240 */ |
|
241 void Clean( MAiContentObserver* aObserver, |
|
242 TInt aContentId ); |
|
243 |
|
244 /** |
|
245 * Shows the loading icon animation |
|
246 * |
|
247 * @param aObserver observer |
|
248 * @return void |
|
249 */ |
|
250 void ShowLoadingIcon( MAiContentObserver* aObserver ); |
|
251 |
|
252 /** |
|
253 * Hides the loading icon animation |
|
254 * |
|
255 * @param aObserver observer |
|
256 * @return void |
|
257 */ |
|
258 void HideLoadingIcon( MAiContentObserver* aObserver ); |
|
259 |
|
260 /** |
|
261 * CWrtData getter |
|
262 * @return Pointer to CWrtData |
|
263 */ |
|
264 CWrtData* Data() const; |
|
265 |
|
266 /* |
|
267 * Plugin's network status getter |
|
268 * @return Pointer to Harvester status observer |
|
269 */ |
|
270 TPluginNetworkStatus NetworkStatus() const; |
|
271 |
|
272 /** |
|
273 * Creates initial data republishing timer if needed and starts it |
|
274 */ |
|
275 void StartTimer(); |
|
276 |
|
277 private: |
|
278 // new functions |
|
279 |
|
280 /** |
|
281 * Publishes widget's initial texts and images |
|
282 * |
|
283 * @param void |
|
284 * @return void |
|
285 */ |
|
286 void PublishInitialDataL(); |
|
287 |
|
288 /** |
|
289 * Resolves skin item id and Mif id from pattern |
|
290 * skin( <majorId> <minorId> (<colourGroupId>) |
|
291 * mif(<MifFileName.mif> <bitmapId> <maskId>) |
|
292 * |
|
293 * @param aPath skin pattern / mif pattern value |
|
294 * @param aItemId skin item id |
|
295 * @param aMifId mif id |
|
296 * @param aMaskId mask id |
|
297 * @param aFilename mif file name |
|
298 * @return boolean (ETrue/EFalse) |
|
299 */ |
|
300 TBool ResolveSkinIdAndMifId( const TDesC& aPath, TAknsItemID& aItemId, |
|
301 TInt& aMifId, TInt& aMaskId, TDes& aFilename ); |
|
302 |
|
303 /** |
|
304 * Cancels transaction in case of leave |
|
305 * |
|
306 * @param aObserver Transaction target |
|
307 */ |
|
308 static void CancelTransaction( TAny* aObserver ); |
|
309 |
|
310 /** |
|
311 * Cancels initial data republishing timer |
|
312 */ |
|
313 void CancelTimer(); |
|
314 |
|
315 /** |
|
316 * Stops and deletes initial data republishing timer. |
|
317 */ |
|
318 void StopTimer(); |
|
319 |
|
320 /** |
|
321 * Timeout callback from timer. Used if publishing of initial data has failed. |
|
322 * |
|
323 * @param aPtr Contains pointer to instance of this class |
|
324 */ |
|
325 static TInt Timeout( TAny* aPtr ); |
|
326 |
|
327 |
|
328 private: |
|
329 // data |
|
330 |
|
331 /** Iterator for plugin content, owned */ |
|
332 MAiContentItemIterator* iContent; |
|
333 /** Array of content observers, owned */ |
|
334 RPointerArray< MAiContentObserver > iObservers; |
|
335 /** Number of data in the content model */ |
|
336 TInt iDataCount; |
|
337 /** Dynamic content model, owned */ |
|
338 TAiContentItem* iContentModel; |
|
339 /** Reference array for Published text, owned */ |
|
340 RPointerArray< HBufC > iDataArray; |
|
341 /** Service API Data Subscriber, owned */ |
|
342 CWrtData* iData; |
|
343 /* References array for published images, owned */ |
|
344 RArray< CGulIcon* > iIconArray; |
|
345 /** Plugin's network status */ |
|
346 TPluginNetworkStatus iNetworkStatus; |
|
347 /** Plugin state */ |
|
348 TPluginStates iPluginState; |
|
349 /** File server session handle, owned */ |
|
350 RFs iRfs; |
|
351 /** Timer for initial data republishing, owned */ |
|
352 CPeriodic* iTimer; |
|
353 }; |
|
354 |
|
355 #endif // WRTDATAPLUGIN_H |
|
356 |
|
357 |