46 class CWrtDataPlugin : public CAiContentPublisher, |
45 class CWrtDataPlugin : public CAiContentPublisher, |
47 public MAiPropertyExtension, |
46 public MAiPropertyExtension, |
48 public MAiEventHandlerExtension |
47 public MAiEventHandlerExtension |
49 |
48 |
50 { |
49 { |
51 |
50 |
52 public : |
51 public : |
53 /** |
52 /** |
54 * Plugin's network state. |
53 * Plugin's network state. |
55 */ |
54 */ |
56 enum TPluginNetworkStatus |
55 enum TPluginNetworkStatus |
57 { |
56 { |
58 EUnknown, |
57 EUnknown, |
59 EOffline, |
58 EOffline, |
60 EOnline |
59 EOnline |
61 }; |
60 }; |
62 |
61 |
63 /** |
62 /** |
64 * Plugin's state. |
63 * Plugin's state. |
65 */ |
64 */ |
66 enum TPluginStates |
65 enum TPluginStates |
67 { |
66 { |
68 ENone, |
67 ENone, |
69 EResume, |
68 EResume, |
70 ESuspend, |
69 ESuspend, |
71 EInActive, |
70 EInActive, |
72 }; |
71 }; |
73 public: |
72 |
74 |
73 /** |
75 /** |
74 * Content Items |
76 * Part of the two phased constuction |
75 */ |
77 * |
76 enum TContentItem |
78 * @param none |
77 { |
79 * @return none |
78 EDefaultImage, |
80 */ |
79 EDefaultText, |
81 static CWrtDataPlugin* NewL(); |
80 EImage1 |
82 |
81 }; |
83 /** |
82 |
84 * Destructor |
83 public: |
85 * |
84 |
86 * @param none |
85 /** |
87 * @return none |
86 * Part of the two phased constuction |
88 */ |
87 * |
89 ~CWrtDataPlugin(); |
88 * @param none |
90 |
89 * @return none |
91 private: |
90 */ |
92 |
91 static CWrtDataPlugin* NewL(); |
93 /** |
92 |
94 * Constructor |
93 /** |
95 * |
94 * Destructor |
96 * @param none |
95 * |
97 * @return none |
96 * @param none |
98 */ |
97 * @return none |
99 CWrtDataPlugin(); |
98 */ |
100 |
99 ~CWrtDataPlugin(); |
101 /** |
100 |
102 * Publishes widget's texts and images |
101 public: // from base class CAiContentPublisher |
103 * |
102 |
104 * @param void |
103 /** |
105 * @return void |
104 * From CAiContentPublisher |
106 */ |
105 * The method is called by the framework to request the plug-in free all |
107 void PublishL(); |
106 * memory and CPU resources and close all its open files, e.g. the plug-in |
108 |
107 * should unload its engines due backup operation. The method transits the |
109 /** |
108 * plug-in to "Idle" state. |
110 * Part of the two phased construction |
109 * |
111 * |
110 * @param aReason reason for state change, see TAiTransitionChange. |
112 * @param void |
111 * @return void |
113 * @return void |
112 */ |
114 */ |
113 void Stop( TAiTransitionReason aReason ); |
115 void ConstructL(); |
114 |
116 |
115 /** |
117 /** |
116 * From CAiContentPublisher |
118 * Resume the plug-in. |
117 * The method is called by the framework to instruct plug-in that it is |
119 * |
118 * allowed to consume CPU resources, e.g plug-in is able to run timers, |
120 * @param aReason reason for state change, see TAiTransitionChange. |
119 * perform asynchronous operations, etc. The method transits the plug-in |
121 * @return void |
120 * to "Alive" state. |
122 */ |
121 * |
123 void DoResumeL(TAiTransitionReason aReason); |
122 * @param aReason reason for state change, see TAiTransitionChange. |
124 |
123 * @return void |
125 public: // from base class CAiContentPublisher |
124 */ |
126 |
125 void Resume( TAiTransitionReason aReason ); |
127 /** |
126 |
128 * From CAiContentPublisher |
127 /** |
129 * The method is called by the framework to request the plug-in free all |
128 * From CAiContentPublisher |
130 * memory and CPU resources and close all its open files, e.g. the plug-in |
129 * The method is called by the framework to instruct plug-in that it is |
131 * should unload its engines due backup operation. The method transits the |
130 * not allowed to consume CPU resources, e.g plug-in MUST stop each |
132 * plug-in to "Idle" state. |
131 * timers, cancel outstanding asynchronous operations, etc. The method |
133 * |
132 * transits the plug-in to "Suspendend" state. |
134 * @param aReason reason for state change, see TAiTransitionChange. |
133 * |
135 * @return void |
134 * @param aReason reason for state change, see TAiTransitionChange. |
136 */ |
135 * @return void |
137 void Stop( TAiTransitionReason aReason ); |
136 */ |
138 |
137 void Suspend( TAiTransitionReason aReason ); |
139 /** |
138 |
140 * From CAiContentPublisher |
139 /** |
141 * The method is called by the framework to instruct plug-in that it is |
140 * From CAiContentPublisher |
142 * allowed to consume CPU resources, e.g plug-in is able to run timers, |
141 * Adds the content observer / subscriber to plug-in. The plug-in MUST |
143 * perform asynchronous operations, etc. The method transits the plug-in |
142 * maintain a registry of subscribers and send notification to all them |
144 * to "Alive" state. |
143 * whenever the plug-in changes state or new content available. |
145 * |
144 * |
146 * @param aReason reason for state change, see TAiTransitionChange. |
145 * @param aObserver content observer to register. |
147 * @return void |
146 * @return void |
148 */ |
147 */ |
149 void Resume( TAiTransitionReason aReason ); |
148 void SubscribeL( MAiContentObserver& aObserver ); |
150 |
149 |
151 /** |
150 /** |
152 * From CAiContentPublisher |
151 * From CAiContentPublisher |
153 * The method is called by the framework to instruct plug-in that it is |
152 * Configures the plug-in. |
154 * not allowed to consume CPU resources, e.g plug-in MUST stop each |
153 * Plug-ins take ownership of the settings array, so it must either |
155 * timers, cancel outstanding asynchronous operations, etc. The method |
154 * store it in a member or free it. Framework has put the array in cleanup |
156 * transits the plug-in to "Suspendend" state. |
155 * stack so the plugin shouldn't do that. |
157 * |
156 * If this leaves, the plug-in will be destroyed by AI FW. |
158 * @param aReason reason for state change, see TAiTransitionChange. |
157 * Plug-in must support LaunchByValue-event even if normal shortcuts don't |
159 * @return void |
158 * work. The only allowed serious enough leave is KErrNotFound from CenRep. |
160 */ |
159 * |
161 void Suspend( TAiTransitionReason aReason ); |
160 * @param aSettings setting items defined in the UI definition. |
162 |
161 * @return void |
163 /** |
162 */ |
164 * From CAiContentPublisher |
163 void ConfigureL( RAiSettingsItemArray& aSettings ); |
165 * Adds the content observer / subscriber to plug-in. The plug-in MUST |
164 |
166 * maintain a registry of subscribers and send notification to all them |
165 /** |
167 * whenever the plug-in changes state or new content available. |
166 * From CAiContentPublisher |
168 * |
167 * Returns interface extension. In Series 60 3.1 only event & property |
169 * @param aObserver content observer to register. |
168 * extensions are supported. See MAiEventExtension & MAiPropertyExtension |
170 * @return void |
169 * interfaces. |
171 */ |
170 * |
172 void SubscribeL( MAiContentObserver& aObserver ); |
171 * @param aUid - UID of the extension interface to access. |
173 |
172 * @return the extension interface. Actual type depends on the passed aUid |
174 /** |
173 * argument. |
175 * From CAiContentPublisher |
174 */ |
176 * Configures the plug-in. |
175 TAny* Extension( TUid aUid ); |
177 * Plug-ins take ownership of the settings array, so it must either |
176 |
178 * store it in a member or free it. Framework has put the array in cleanup |
177 // from base class MAiPropertyExtension |
179 * stack so the plugin shouldn't do that. |
178 |
180 * If this leaves, the plug-in will be destroyed by AI FW. |
179 /** |
181 * Plug-in must support LaunchByValue-event even if normal shortcuts don't |
180 * From MAiPropertyExtension. |
182 * work. The only allowed serious enough leave is KErrNotFound from CenRep. |
181 * Read property of publisher plug-in. |
183 * |
182 * |
184 * @param aSettings setting items defined in the UI definition. |
183 * @param aProperty - identification of property. |
185 * @return void |
184 * @return pointer to property value. |
186 */ |
185 */ |
187 void ConfigureL( RAiSettingsItemArray& aSettings ); |
186 TAny* GetPropertyL( TInt aProperty ); |
188 |
187 |
189 /** |
188 /** |
190 * From CAiContentPublisher |
189 * From MAiPropertyExtension. |
191 * Returns interface extension. In Series 60 3.1 only event & property |
190 * Write property value. |
192 * extensions are supported. See MAiEventExtension & MAiPropertyExtension |
191 * |
193 * interfaces. |
192 * @param aProperty - identification of property. |
194 * |
193 * @param aValue - contains pointer to property value. |
195 * @param aUid - UID of the extension interface to access. |
194 */ |
196 * @return the extension interface. Actual type depends on the passed aUid |
195 void SetPropertyL( TInt aProperty, TAny* aValue ); |
197 * argument. |
196 |
198 */ |
197 // from base class MAiEventHandlerExtension |
199 TAny* Extension( TUid aUid ); |
198 |
200 |
199 /** |
201 // from base class MAiPropertyExtension |
200 * From MAiEventHandlerExtension |
202 |
201 * Invoked by the framework when plug-in must handle an event. |
203 /** |
202 * @param aEvent - unique identifier of event from plug-in content model. |
204 * From MAiPropertyExtension. |
203 * @param aParam - parameters associated with event. Each UI Definition |
205 * Read property of publisher plug-in. |
204 * declares events in the format: <event name>(<event params>), |
206 * |
205 * where <event name> is mapped by the framework to unique |
207 * @param aProperty - identification of property. |
206 * identifier supplied in aEvent, <event params> are provided to |
208 * @return pointer to property value. |
207 * plug-in as-is in the descriptor. |
209 */ |
208 * @since S60 3.2 |
210 TAny* GetPropertyL( TInt aProperty ); |
209 */ |
211 |
210 void HandleEvent(TInt aEvent, const TDesC& aParam); |
212 /** |
211 |
213 * From MAiPropertyExtension. |
212 /** |
214 * Write property value. |
213 * From MAiEventHandlerExtension |
215 * |
214 * Invoked by the framework when plug-in must handle an event. |
216 * @param aProperty - identification of property. |
215 * |
217 * @param aValue - contains pointer to property value. |
216 * @param aEventName - name of the event from plug-in content model. |
218 */ |
217 * @param aParam - parameters associated with event. Each UI Definition |
219 void SetPropertyL( TInt aProperty, TAny* aValue ); |
218 * declares events in the format: <event name>(<event params>), |
220 |
219 * where <event name> mapping to unique identifier supplied by event |
221 // from base class MAiEventHandlerExtension |
220 * is failed by the frame work then the <event name> and |
222 |
221 * <event params> are provided to plug-in as-is in the descriptor. |
223 /** |
222 */ |
224 * From MAiEventHandlerExtension |
223 void HandleEvent(const TDesC& aEventName, const TDesC& aParam); |
225 * Invoked by the framework when plug-in must handle an event. |
224 |
226 * @param aEvent - unique identifier of event from plug-in content model. |
225 /** |
227 * @param aParam - parameters associated with event. Each UI Definition |
226 * Invoked by the framework for querying if plugin has menu item |
228 * declares events in the format: <event name>(<event params>), |
227 * |
229 * where <event name> is mapped by the framework to unique |
228 * @param aMenuItem menu item name. |
230 * identifier supplied in aEvent, <event params> are provided to |
229 * @return ETrue if plugin has specific menu item, EFalse otherwise |
231 * plug-in as-is in the descriptor. |
230 */ |
232 * @since S60 3.2 |
231 TBool HasMenuItem(const TDesC16& aMenuItem); |
233 */ |
232 |
234 void HandleEvent(TInt aEvent, const TDesC& aParam); |
233 public : // New functions |
235 |
234 |
236 /** |
235 /** |
237 * From MAiEventHandlerExtension |
236 * Gets the id of a content |
238 * Invoked by the framework when plug-in must handle an event. |
237 * |
239 * |
238 * @param aObjectId image or text id |
240 * @param aEventName - name of the event from plug-in content model. |
239 * @return id of the content |
241 * @param aParam - parameters associated with event. Each UI Definition |
240 */ |
242 * declares events in the format: <event name>(<event params>), |
241 TInt GetIdL(TDesC16& aObjectId); |
243 * where <event name> mapping to unique identifier supplied by event |
242 |
244 * is failed by the frame work then the <event name> and |
243 /** |
245 * <event params> are provided to plug-in as-is in the descriptor. |
244 * Gets the type of a specific content |
246 */ |
245 * |
247 void HandleEvent(const TDesC& aEventName, const TDesC& aParam); |
246 * @param aObjectId image or text id |
248 |
247 * @param aType type |
249 /** |
248 * @return void |
250 * Invoked by the framework for querying if plugin has menu item |
249 */ |
251 * |
250 void GetTypeL( TDesC16& aObjectId, TDes16& aType ); |
252 * @param aMenuItem menu item name. |
251 |
253 * @return ETrue if plugin has specific menu item, EFalse otherwise |
252 /** |
254 */ |
253 * RefereshL a specific image of text in the widget |
255 TBool HasMenuItem(const TDesC16& aMenuItem); |
254 * |
256 |
255 * @param aOperation operation performed |
257 public : |
256 * @param aDataMap data map |
258 |
257 * @return void |
259 /** |
258 */ |
260 * Gets the id of a content |
259 void RefreshL(TDesC16& aOperation, CLiwDefaultMap* aDataMap ); |
261 * |
260 |
262 * @param aObjectId image or text id |
261 /** |
263 * @return id of the content |
262 * Is plugin active to publish the data |
264 */ |
263 * |
265 TInt GetIdL(TDesC16& aObjectId); |
264 * @param void |
266 |
265 * @return boolean (ETrue/EFalse) |
267 /** |
266 */ |
268 * Gets the type of a specific content |
267 TBool IsActive(); |
269 * |
268 |
270 * @param aObjectId image or text id |
269 /** |
271 * @param aType type |
270 * Publish a specific text of the widget |
272 * @return void |
271 * |
273 */ |
272 * @param aObserver observer |
274 void GetTypeL( TDesC16& aObjectId, TDes16& aType ); |
273 * @param aContentId content model id |
275 |
274 * @param aContentValue content value |
276 /** |
275 * @return void |
277 * RefereshL a specific image of text in the widget |
276 */ |
278 * |
277 void PublishTextL(MAiContentObserver* aObserver, |
279 * @param aOperation operation performed |
278 TInt aContentId, const TDesC16& aContentValue); |
280 * @return void |
279 |
281 */ |
280 /** |
282 void RefreshL(TDesC16& aOperation ); |
281 * Publish a specific image of the widget |
283 |
282 * |
284 /** |
283 * @param aObserver observer |
285 * Is plugin active to publish the data |
284 * @param aContentId content model id |
286 * |
285 * @param aHandle image handle |
287 * @param void |
286 * @param aMaskHandle handle of the mask image |
288 * @return boolean (ETrue/EFalse) |
287 * @return void |
289 */ |
288 */ |
290 TBool IsActive(); |
289 void PublishImageL(MAiContentObserver* aObserver, |
291 |
290 TContentItem aContentId, TInt aHandle, TInt aMaskHandle); |
292 /** |
291 |
293 * Publish a specific text of the widget |
292 /** |
294 * |
293 * Publish a specific image of the widget |
295 * @param aObserver observer |
294 * |
296 * @param aContentId content model id |
295 * @param aObserver observer |
297 * @param aContentValue content value |
296 * @param aContentId content model id |
298 * @return void |
297 * @param aPath image path / skin id pattern / mif id Pattern |
299 */ |
298 * @return void |
300 /*void PublishTextL(MAiContentObserver* aObserver, |
299 */ |
301 TInt& aContentId, TDesC16& aContentValue);*/ |
300 void PublishImageL(MAiContentObserver* aObserver, |
302 |
301 TContentItem aContentId, const TDesC16& aPath ); |
303 /** |
302 |
304 * Publish a specific image of the widget |
303 /** |
305 * |
304 * Cleans a data from the widget |
306 * @param aObserver observer |
305 * |
307 * @param aContentId content model id |
306 * @param aObserver observer |
308 * @param aHandle image handle |
307 * @param aContentId content model id |
309 * @param aMaskHandle handle of the mask image |
308 * @return void |
310 * @return void |
309 */ |
311 */ |
310 void Clean(MAiContentObserver* aObserver, |
312 void PublishImageL(MAiContentObserver* aObserver, |
311 TInt aContentId ); |
313 TContentItem aContentId, TInt aHandle, TInt aMaskHandle); |
312 |
314 |
313 /** |
315 /** |
314 * Shows the loading icon animation |
316 * Publish a specific image of the widget |
315 * |
317 * |
316 * @param aObserver observer |
318 * @param aObserver observer |
317 * @return void |
319 * @param aContentId content model id |
318 */ |
320 * @param aPath image path / skin id pattern / mif id Pattern |
319 void ShowLoadingIcon(MAiContentObserver* aObserver); |
321 * @return void |
320 |
322 */ |
321 /** |
323 void PublishImageL(MAiContentObserver* aObserver, |
322 * Hides the loading icon animation |
324 TContentItem aContentId, TDesC16& aPath ); |
323 * |
325 |
324 * @param aObserver observer |
326 /** |
325 * @return void |
327 * Cleans a data from the widget |
326 */ |
328 * |
327 void HideLoadingIcon(MAiContentObserver* aObserver); |
329 * @param aObserver observer |
328 |
330 * @param aContentId content model id |
329 /** |
331 * @return void |
330 * CWrtData getter |
332 */ |
331 * @return Pointer to CWrtData |
333 void Clean(MAiContentObserver* aObserver, |
332 */ |
334 TInt aContentId ); |
333 inline CWrtData* Data() const |
335 |
334 { |
336 /** |
335 return iData; |
337 * CWrtData getter |
336 } |
338 * @return Pointer to CWrtData |
337 |
339 */ |
338 /* |
340 inline CWrtData* Data() const |
339 * Plugin's network status getter |
341 { |
340 * @return Pointer to Harvester status observer |
342 return iData; |
341 */ |
343 } |
342 inline TPluginNetworkStatus NetworkStatus() const |
344 |
343 { |
345 /* |
344 return iNetworkStatus; |
346 * Plugin's network status getter |
345 } |
347 * @return Pointer to Harvester status observer |
346 |
348 */ |
347 private: |
349 inline TPluginNetworkStatus NetworkStatus() const |
348 |
350 { |
349 /** |
351 return iNetworkStatus; |
350 * Constructor |
352 } |
351 * |
353 |
352 * @param none |
354 private: // data |
353 * @return none |
355 |
354 */ |
356 // Iterator for plugin content |
355 CWrtDataPlugin(); |
357 // Own |
356 |
358 MAiContentItemIterator* iContent; |
357 /** |
359 |
358 * Part of the two phased construction |
360 // Array of content observers |
359 * |
361 // Own |
360 * @param void |
362 RPointerArray<MAiContentObserver> iObservers; |
361 * @return void |
363 |
362 */ |
364 // Information about the content publisher (this plug-in) |
363 void ConstructL(); |
365 TAiPublisherInfo iInfo; |
364 |
366 |
365 /** |
367 // Number of data in the content model. |
366 * Publishes widget's texts and images |
368 TInt iDataCount; |
367 * |
369 |
368 * @param void |
370 // Dynamic content model |
369 * @return void |
371 // Own |
370 */ |
372 TAiContentItem* iContentModel; |
371 void PublishL(); |
373 |
372 |
374 // Reference array for Published text |
373 /** |
375 // Own |
374 * Resume the plug-in. |
376 RPointerArray<HBufC> iDataArray; |
375 * |
377 |
376 * @param aReason reason for state change, see TAiTransitionChange. |
378 // Service API Data Subscriber. |
377 * @return void |
379 // Own |
378 */ |
380 CWrtData* iData; |
379 void DoResumeL(TAiTransitionReason aReason); |
381 |
380 |
382 // References array for published images |
381 /** |
383 // Own |
382 * Resolves skin item id and Mif id from pattern |
384 RArray<CGulIcon*> iIconArray; |
383 * skin( <majorId> <minorId> (<colourGroupId>) |
385 |
384 * mif(<MifFileName.mif> <bitmapId> <maskId>) |
386 // File Server |
385 * |
387 // Reference |
386 * @param aPath skin pattern / mif pattern value |
388 RFs iRfs; |
387 * @param aItemId skin item id |
389 |
388 * @param aMifId mif id |
390 // Plugin's network status |
389 * @param aMaskId mask id |
391 TPluginNetworkStatus iNetworkStatus; |
390 * @param aFilename mif file name |
392 |
391 * @return boolean (ETrue/EFalse) |
393 // Is Homescreen foreground. |
392 */ |
394 TBool iHSForeGround; |
393 TBool ResolveSkinIdAndMifId( const TDesC& aPath, TAknsItemID& aItemId, |
395 |
394 TInt& aMifId, TInt& aMaskId, TDes& aFilename ); |
396 // Is KeyLockON. |
395 |
397 TBool iKeyLockOn; |
396 private: // data |
398 |
397 |
399 // Plugin state |
398 // Iterator for plugin content |
400 TPluginStates iPluginState; |
399 // Own |
|
400 MAiContentItemIterator* iContent; |
|
401 |
|
402 // Array of content observers |
|
403 // Own |
|
404 RPointerArray<MAiContentObserver> iObservers; |
|
405 |
|
406 // Information about the content publisher (this plug-in) |
|
407 TAiPublisherInfo iInfo; |
|
408 |
|
409 // Number of data in the content model. |
|
410 TInt iDataCount; |
|
411 |
|
412 // Dynamic content model |
|
413 // Own |
|
414 TAiContentItem* iContentModel; |
|
415 |
|
416 // Reference array for Published text |
|
417 // Own |
|
418 RPointerArray<HBufC> iDataArray; |
|
419 |
|
420 // Service API Data Subscriber. |
|
421 // Own |
|
422 CWrtData* iData; |
|
423 |
|
424 // References array for published images |
|
425 // Own |
|
426 RArray<CGulIcon*> iIconArray; |
|
427 |
|
428 // Plugin's network status |
|
429 TPluginNetworkStatus iNetworkStatus; |
|
430 |
|
431 // Is Homescreen foreground. |
|
432 TBool iHSForeGround; |
|
433 |
|
434 // Is KeyLockON. |
|
435 TBool iKeyLockOn; |
|
436 |
|
437 // Plugin state |
|
438 TPluginStates iPluginState; |
401 }; |
439 }; |
402 |
440 |
403 #endif // WRTDATAPLUGIN_H |
441 #endif // WRTDATAPLUGIN_H |
404 |
442 |
405 |
443 |