1 /* |
|
2 * Copyright (c) 2005-2006 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: Interface for Active Idle content publisher plug-ins. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_AICONTENTPUBLISHER_H |
|
20 #define C_AICONTENTPUBLISHER_H |
|
21 |
|
22 #include <ecom/ecom.h> |
|
23 #include <aicontentpublisheruid.hrh> |
|
24 |
|
25 /** |
|
26 * ECom plugin interface UID |
|
27 */ |
|
28 const TUid KInterfaceUidContentPlugin = { AI_UID_ECOM_INTERFACE_CONTENTPUBLISHER }; |
|
29 |
|
30 /** |
|
31 * API Extension UID for MAiPropertyExtension. |
|
32 * |
|
33 * @see CAiContentPublisher::Extension |
|
34 * @see MAiPropertyExtension |
|
35 */ |
|
36 const TUid KExtensionUidProperty = { 0x1 }; |
|
37 |
|
38 /** |
|
39 * API Extension UID for MAiEventExtension. |
|
40 * |
|
41 * @see CAiContentPublisher::Extension |
|
42 * @see MAiEventExtension |
|
43 */ |
|
44 const TUid KExtensionUidEventHandler = { 0x2 }; |
|
45 |
|
46 /** |
|
47 * Defines set of reasons for plug-in state change. |
|
48 */ |
|
49 enum TAiTransitionReason |
|
50 { |
|
51 |
|
52 /** |
|
53 * Unknown transition reason. |
|
54 */ |
|
55 EAiUnknownTransitionReason = 0, |
|
56 |
|
57 /** |
|
58 * System has started up. |
|
59 */ |
|
60 EAiSystemStartup, |
|
61 |
|
62 /** |
|
63 * System is shutting down. |
|
64 */ |
|
65 EAiSystemShutdown, |
|
66 |
|
67 /** |
|
68 * Backlight on. |
|
69 */ |
|
70 EAiBacklightOn, |
|
71 |
|
72 /** |
|
73 * Backlight off. |
|
74 */ |
|
75 EAiBacklightOff, |
|
76 |
|
77 /** |
|
78 * Backup or restore has been initiated. |
|
79 */ |
|
80 EAiBackupRestoreStarted, |
|
81 |
|
82 /** |
|
83 * Backup or restore has ended. |
|
84 */ |
|
85 EAiBackupRestoreEnded, |
|
86 |
|
87 /** |
|
88 * Call started. |
|
89 */ |
|
90 EAiPhoneCallStarted, |
|
91 |
|
92 /** |
|
93 * Call ended. |
|
94 */ |
|
95 EAiPhoneCallEnded, |
|
96 |
|
97 /** |
|
98 * Active Idle UI Definition change has started. |
|
99 */ |
|
100 EAiUiDefinitionChangeStarted, |
|
101 |
|
102 /** |
|
103 * Active Idle UI Definition change has ended. |
|
104 */ |
|
105 EAiUiDefinitionChangeEnded, |
|
106 |
|
107 /** |
|
108 * Phone general theme has changed. |
|
109 */ |
|
110 EAiGeneralThemeChanged, |
|
111 |
|
112 /** |
|
113 * Screen layout has changed. |
|
114 */ |
|
115 EAiScreenLayoutChanged, |
|
116 |
|
117 /** |
|
118 * System clock crossed midnight. |
|
119 */ |
|
120 EAiMidnightPassed, |
|
121 |
|
122 /** |
|
123 * Language has been changed. |
|
124 */ |
|
125 EAiLanguageChanged, |
|
126 |
|
127 /** |
|
128 * System time has been changed by user. |
|
129 */ |
|
130 EAiTimeChanged, |
|
131 |
|
132 /** |
|
133 * Idle changes to background. |
|
134 */ |
|
135 EAiIdleBackground, |
|
136 |
|
137 /** |
|
138 * Idle changes to foreground. |
|
139 */ |
|
140 EAiIdleForeground, |
|
141 |
|
142 /** |
|
143 * Suspending plugins. |
|
144 */ |
|
145 EAiSuspendPlugins, |
|
146 |
|
147 /** |
|
148 * Keylock enabled. |
|
149 */ |
|
150 EAiKeylockEnabled, |
|
151 |
|
152 /** |
|
153 * Keylock disabled. |
|
154 */ |
|
155 EAiKeylockDisabled, |
|
156 |
|
157 /** |
|
158 * Plugins can go online |
|
159 */ |
|
160 EAiIdleOnLine, |
|
161 |
|
162 /** |
|
163 * Plugins must go offline |
|
164 */ |
|
165 EAiIdleOffLine, |
|
166 |
|
167 /** |
|
168 * Page changed |
|
169 */ |
|
170 EAiIdlePageSwitch |
|
171 }; |
|
172 |
|
173 class MAiContentObserver; |
|
174 class MAiPluginSettings; |
|
175 typedef RPointerArray< MAiPluginSettings > RAiSettingsItemArray; |
|
176 |
|
177 /** |
|
178 * ECom plug-in interface that Active Idle plug-ins must implement. |
|
179 * It is used to control plug-in life cycle: load/destroy plug-ins; |
|
180 * suspend/resume plug-in execution. |
|
181 * |
|
182 * @since S60 3.2 |
|
183 */ |
|
184 class CAiContentPublisher : public CBase |
|
185 { |
|
186 public: // Constructors and destructor |
|
187 |
|
188 /** |
|
189 * Creates a new plug-in instance based on implementation UID. |
|
190 * |
|
191 * @param aImpUid implementation UID of plug-in to instantiate. |
|
192 * @return pointer to the instantiated interface implementation. |
|
193 * @pre Interface implementation exists by uid aImpUid. |
|
194 */ |
|
195 inline static CAiContentPublisher* NewL(TUid aImpUid); |
|
196 |
|
197 /** |
|
198 * Creates a new plug-in instance based on mime type. |
|
199 * |
|
200 * @param aMime MIME type of plug-in to instantiate. |
|
201 * @return pointer to the instantiated interface implementation. |
|
202 */ |
|
203 inline static CAiContentPublisher* NewL(const TDesC8& aMime); |
|
204 |
|
205 /** |
|
206 * Destroys instance of the plug-in. Called by the framework during plug-in |
|
207 * unloading phase. |
|
208 */ |
|
209 inline virtual ~CAiContentPublisher(); |
|
210 |
|
211 public: // New functions |
|
212 /** |
|
213 * This method transit the plugin to "Alive" state. |
|
214 * The method is called by the framework to instruct plug-in that it is |
|
215 * allowed to actively publish its data to its observers. This means the plugin |
|
216 * is allowed to consume memory and CPU resources, e.g plug-in is able load |
|
217 * engines, run timers, perform asynchronous operations, etc. The method |
|
218 * transits the plug-in to "Alive" state. There can be many concurrent |
|
219 * calls to resume, with different or the same reason code, this allows |
|
220 * the plugin to properly respond to enviroment change that raise the |
|
221 * need to re-publish content (changes like date/time change etc). |
|
222 * |
|
223 * @param aReason reason for state change, see TAiTransitionChange. |
|
224 * @pre None |
|
225 * @post Plugin is in resumed state and actively publishes its data. |
|
226 * |
|
227 * Short example what a typical resume implementation does. |
|
228 * @code |
|
229 * if( !MyEngineCreated() ) |
|
230 * { |
|
231 * CreateEngine(); |
|
232 * } |
|
233 * StartEngine(); |
|
234 * @endcode |
|
235 */ |
|
236 virtual void Resume(TAiTransitionReason aReason) = 0; |
|
237 |
|
238 /** |
|
239 * This method transits the plug-in to "Suspendend" state. |
|
240 * The method is called by the framework to instruct plug-in that it is |
|
241 * not allowed to consume CPU resources, e.g plug-in MUST stop each |
|
242 * timer, cancel outstanding asynchronous operations, etc. |
|
243 * |
|
244 * @param aReason reason for state change, see TAiTransitionChange. |
|
245 * @pre None |
|
246 * @post Plugin suspends publishing data and free resources (timers etc). |
|
247 * |
|
248 * Short example what a typical suspend implementation does. |
|
249 * @code |
|
250 * DisableEngine(); |
|
251 * @endcode |
|
252 */ |
|
253 virtual void Suspend(TAiTransitionReason aReason) = 0; |
|
254 |
|
255 /** |
|
256 * This method transits the plug-in to "Idle" state. |
|
257 * The method is called by the framework to request the plug-in free all |
|
258 * memory and CPU resources and close all its open files, the plug-in |
|
259 * should unload its engines during backup operation. |
|
260 * |
|
261 * @param aReason reason for state change, see TAiTransitionChange. |
|
262 * @pre None |
|
263 * @post Plugin stops publishing data and frees all possible resources. |
|
264 * |
|
265 * Short example what a typical stop implementation does. |
|
266 * @code |
|
267 * DestroyEngine(); |
|
268 * @endcode |
|
269 */ |
|
270 virtual void Stop(TAiTransitionReason aReason) = 0; |
|
271 |
|
272 /** |
|
273 * Adds the content observer / subscriber to plug-in. The plug-in MUST |
|
274 * maintain a registry of subscribers and send notification to all them |
|
275 * whenever the plug-in changes state or new content available. |
|
276 * |
|
277 * @param aObserver content observer to register. |
|
278 * @pre None |
|
279 * @post Plugin publishes its data to the subscribed observer. |
|
280 * |
|
281 * Short example what a typical subscribe implementation does and |
|
282 * one alternative how observers are used. |
|
283 * @code |
|
284 * if( !ObserverAlreadyAdded( aObserver ) ) |
|
285 * { |
|
286 * iMyContentObservers.AppendL( aObserver ); |
|
287 * } |
|
288 * |
|
289 * ... |
|
290 * |
|
291 * // Engine reports data changed |
|
292 * |
|
293 * const TDesC& data = iEngine->LatestData(); |
|
294 * for( TInt i = 0; i < iMyContentObservers.Count(); ++i ) |
|
295 * { |
|
296 * iMyContentObservers[i].Publish( data ); |
|
297 * } |
|
298 * @endcode |
|
299 */ |
|
300 virtual void SubscribeL(MAiContentObserver& aObserver) = 0; |
|
301 |
|
302 /** |
|
303 * Configures the plug-in. |
|
304 * |
|
305 * @param aSettings setting items defined in the UI definition. |
|
306 * This plugin takes ownership of the |
|
307 * MAiPluginSettings objects in the array. |
|
308 * If this method leaves the caller will handle the cleanup. |
|
309 * @pre None |
|
310 * @post Plugin has set its state according to relevant settings. |
|
311 * |
|
312 * Short example how to read plugin settings. |
|
313 * @code |
|
314 * for( TInt i = 0; i < aSettings.Count(); ++i ) |
|
315 * { |
|
316 * MAiPluginSettingsItem& item = (aSettings[i])->AiPluginSettingsItem(); |
|
317 * TInt32 value = 0; |
|
318 * if( ParseInt( value, item.Value() ) != KErrNone ) |
|
319 * { |
|
320 * continue; |
|
321 * } |
|
322 * if( value < 0 ) |
|
323 * { |
|
324 * continue; // All our settings are counts, skip bad settings |
|
325 * } |
|
326 * if( item.Key() == EMySettingMaxUsers ) |
|
327 * { |
|
328 * iEngine->SetMaxUsers( value ); |
|
329 * continue; |
|
330 * } |
|
331 * else if( item.Key() == EMySettingNumItems ) |
|
332 * { |
|
333 * iNumItems = value; |
|
334 * continue; |
|
335 * } |
|
336 * } |
|
337 * // We own the array so destroy it |
|
338 * aSettings.ResetAndDestroy(); |
|
339 * @endcode |
|
340 */ |
|
341 virtual void ConfigureL( RAiSettingsItemArray& aSettings) = 0; |
|
342 |
|
343 /** |
|
344 * Returns interface extension. In S60 3.2 only event & property |
|
345 * extensions are supported. See MAiEventHandlerExtension & MAiPropertyExtension |
|
346 * interfaces. |
|
347 * |
|
348 * @param aUid - UID of the extension interface to access. |
|
349 * @see MAiEventExtension |
|
350 * @see MAiPropertyExtension |
|
351 * @return the extension interface. Actual type depends on the passed aUid |
|
352 * argument. |
|
353 * |
|
354 * Example on how to properly return an extension. |
|
355 * @code |
|
356 * if (aUid == KExtensionUidProperty) |
|
357 * { |
|
358 * return static_cast<MAiPropertyExtension*>(this); |
|
359 * } |
|
360 * else if (aUid == KExtensionUidEventHandler) |
|
361 * { |
|
362 * return static_cast<MAiEventHandlerExtension*>(this); |
|
363 * } |
|
364 * return NULL; // Requested extension not supported |
|
365 * @endcode |
|
366 */ |
|
367 virtual TAny* Extension(TUid aUid) = 0; |
|
368 |
|
369 private: // data |
|
370 /** An identifier used during destruction. */ |
|
371 TUid iDestructKey; |
|
372 }; |
|
373 |
|
374 inline CAiContentPublisher* CAiContentPublisher::NewL(TUid aImplUid) |
|
375 { |
|
376 TAny* ptr = REComSession::CreateImplementationL(aImplUid, |
|
377 _FOFF(CAiContentPublisher, iDestructKey)); |
|
378 |
|
379 return reinterpret_cast<CAiContentPublisher*> (ptr); |
|
380 } |
|
381 |
|
382 inline CAiContentPublisher* CAiContentPublisher::NewL(const TDesC8& aMime) |
|
383 { |
|
384 TEComResolverParams params; |
|
385 params.SetDataType(aMime); |
|
386 |
|
387 TAny* ptr = REComSession::CreateImplementationL(KInterfaceUidContentPlugin, |
|
388 _FOFF(CAiContentPublisher, iDestructKey), params); |
|
389 |
|
390 return reinterpret_cast<CAiContentPublisher*> (ptr); |
|
391 } |
|
392 |
|
393 inline CAiContentPublisher::~CAiContentPublisher() |
|
394 { |
|
395 REComSession::DestroyedImplementation(iDestructKey); |
|
396 } |
|
397 |
|
398 #endif // C_AICONTENTPUBLISHER_H |
|