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 CMCSPLUGIN_H |
|
20 #define CMCSPLUGIN_H |
|
21 |
|
22 #include <aicontentpublisher.h> |
|
23 #include <aipropertyextension.h> |
|
24 #include <aicontentmodel.h> |
|
25 #include <aieventhandlerextension.h> |
|
26 #include <centralrepository.h> |
|
27 #include "mcspluginwatcher.h" |
|
28 |
|
29 class MAiContentObserver; |
|
30 class MAiContentItemIterator; |
|
31 class CMCSPluginEngine; |
|
32 class TMCSData; |
|
33 //class CMCSPluginData; |
|
34 |
|
35 //class RAiSettingsItemArray; |
|
36 |
|
37 /** |
|
38 * @ingroup group_mcsplugin |
|
39 * |
|
40 * Plug-in main class |
|
41 * |
|
42 * @since S60 v3.2 |
|
43 */ |
|
44 class CMCSPlugin : public CAiContentPublisher, |
|
45 public MAiPropertyExtension, |
|
46 public MAiEventHandlerExtension, |
|
47 public MMCSPluginWatcherObserver |
|
48 |
|
49 |
|
50 { |
|
51 |
|
52 public: |
|
53 |
|
54 /** |
|
55 * Part of the two phased constuction |
|
56 * |
|
57 * @param none |
|
58 * @return none |
|
59 */ |
|
60 static CMCSPlugin* NewL(); |
|
61 |
|
62 /** |
|
63 * CompareItems |
|
64 * |
|
65 * @param aFirst |
|
66 * @param aSecond |
|
67 */ |
|
68 static TInt CompareItems(const MAiPluginSettings& aFirst, |
|
69 const MAiPluginSettings& aSecond ); |
|
70 /** |
|
71 * Constructor |
|
72 * |
|
73 * @param none |
|
74 * @return none |
|
75 */ |
|
76 CMCSPlugin(); |
|
77 |
|
78 /** |
|
79 * Destructor |
|
80 * |
|
81 * @param none |
|
82 * @return none |
|
83 */ |
|
84 ~CMCSPlugin(); |
|
85 |
|
86 /** |
|
87 * Publishes profile names |
|
88 * |
|
89 * @param void |
|
90 * @return void |
|
91 */ |
|
92 void PublishL(); |
|
93 |
|
94 /** |
|
95 * From base class MMCSPluginWatcherObserver |
|
96 * .a method for Skin UID cenrep key change handeling |
|
97 */ |
|
98 void HandleNotifyL(); |
|
99 |
|
100 // from base class CAiContentPublisher |
|
101 |
|
102 /** |
|
103 * From CAiContentPublisher |
|
104 * The method is called by the framework to request the plug-in free all |
|
105 * memory and CPU resources and close all its open files, e.g. the plug-in |
|
106 * should unload its engines due backup operation. The method transits the |
|
107 * plug-in to "Idle" state. |
|
108 * |
|
109 * @param aReason reason for state change, see TAiTransitionChange. |
|
110 * @return void |
|
111 */ |
|
112 void Stop( TAiTransitionReason aReason ); |
|
113 |
|
114 /** |
|
115 * From CAiContentPublisher |
|
116 * The method is called by the framework to instruct plug-in that it is |
|
117 * allowed to consume CPU resources, e.g plug-in is able to run timers, |
|
118 * perform asynchronous operations, etc. The method transits the plug-in |
|
119 * to "Alive" state. |
|
120 * |
|
121 * @param aReason reason for state change, see TAiTransitionChange. |
|
122 * @return void |
|
123 */ |
|
124 void Resume( TAiTransitionReason aReason ); |
|
125 |
|
126 /** |
|
127 * From CAiContentPublisher |
|
128 * The method is called by the framework to instruct plug-in that it is |
|
129 * not allowed to consume CPU resources, e.g plug-in MUST stop each |
|
130 * timers, cancel outstanding asynchronous operations, etc. The method |
|
131 * transits the plug-in to "Suspendend" state. |
|
132 * |
|
133 * @param aReason reason for state change, see TAiTransitionChange. |
|
134 * @return void |
|
135 */ |
|
136 void Suspend( TAiTransitionReason aReason ); |
|
137 |
|
138 /** |
|
139 * From CAiContentPublisher |
|
140 * Adds the content observer / subscriber to plug-in. The plug-in MUST |
|
141 * maintain a registry of subscribers and send notification to all them |
|
142 * whenever the plug-in changes state or new content available. |
|
143 * |
|
144 * @param aObserver content observer to register. |
|
145 * @return void |
|
146 */ |
|
147 void SubscribeL( MAiContentObserver& aObserver ); |
|
148 |
|
149 /** |
|
150 * From CAiContentPublisher |
|
151 * Configures the plug-in. |
|
152 * Plug-ins take ownership of the settings array, so it must either |
|
153 * store it in a member or free it. Framework has put the array in cleanup |
|
154 * stack so the plugin shouldn't do that. |
|
155 * If this leaves, the plug-in will be destroyed by AI FW. |
|
156 * Plug-in must support LaunchByValue-event even if normal shortcuts don't |
|
157 * work. The only allowed serious enough leave is KErrNotFound from CenRep. |
|
158 * |
|
159 * @param aSettings setting items defined in the UI definition. |
|
160 * @return void |
|
161 */ |
|
162 void ConfigureL( RAiSettingsItemArray& aSettings ); |
|
163 |
|
164 /** |
|
165 * From CAiContentPublisher |
|
166 * Returns interface extension. In Series 60 3.1 only event & property |
|
167 * extensions are supported. See MAiEventExtension & MAiPropertyExtension |
|
168 * interfaces. |
|
169 * |
|
170 * @param aUid - UID of the extension interface to access. |
|
171 * @return the extension interface. Actual type depends on the passed aUid |
|
172 * argument. |
|
173 */ |
|
174 TAny* Extension( TUid aUid ); |
|
175 |
|
176 // from base class MAiPropertyExtension |
|
177 |
|
178 /** |
|
179 * From MAiPropertyExtension. |
|
180 * Read property of publisher plug-in. |
|
181 * |
|
182 * @param aProperty - identification of property. |
|
183 * @return pointer to property value. |
|
184 */ |
|
185 TAny* GetPropertyL( TInt aProperty ); |
|
186 |
|
187 /** |
|
188 * From MAiPropertyExtension. |
|
189 * Write property value. |
|
190 * |
|
191 * @param aProperty - identification of property. |
|
192 * @param aValue - contains pointer to property value. |
|
193 */ |
|
194 void SetPropertyL( TInt aProperty, TAny* aValue ); |
|
195 |
|
196 // from base class MAiEventHandlerExtension |
|
197 |
|
198 /** |
|
199 * From MAiEventHandlerExtension |
|
200 * Invoked by the framework when plug-in must handle an event. |
|
201 * |
|
202 * @param aEvent - unique identifier of event from plug-in content model. |
|
203 * @param aParam - parameters associated with event. Each UI Definition |
|
204 * declares events in the format: <event name>(<event params>), |
|
205 * where <event name> is mapped by the framework to unique |
|
206 * identifier supplied in aEvent, <event params> are provided to |
|
207 * plug-in as-is in the descriptor. |
|
208 * @since S60 3.2 |
|
209 */ |
|
210 void HandleEvent(TInt aEvent, const TDesC& aParam); |
|
211 |
|
212 /** |
|
213 * From MAiEventHandlerExtension |
|
214 * Invoked by the framework when plug-in must handle an event. |
|
215 * |
|
216 * @param aEventName - name of the event from plug-in content model. |
|
217 * @param aParam - parameters associated with event. Each UI Definition |
|
218 * declares events in the format: <event name>(<event params>), |
|
219 * where <event name> mapping to unique identifier supplied by event |
|
220 * is failed by the frame work then the <event name> and |
|
221 * <event params> are provided to plug-in as-is in the descriptor. |
|
222 */ |
|
223 void HandleEvent(const TDesC& aEventName, const TDesC& aParam); |
|
224 |
|
225 protected: |
|
226 |
|
227 private: |
|
228 |
|
229 /** |
|
230 * Part of the two phased construction |
|
231 * |
|
232 * @param void |
|
233 * @return void |
|
234 */ |
|
235 void ConstructL(); |
|
236 |
|
237 /** |
|
238 * Resume the plug-in. |
|
239 * |
|
240 * @param aReason reason for state change, see TAiTransitionChange. |
|
241 * @return void |
|
242 */ |
|
243 void DoResumeL(TAiTransitionReason aReason); |
|
244 |
|
245 /** |
|
246 * Publishes content for one menu item |
|
247 */ |
|
248 void PublishLItemL( MAiContentObserver& aObserver, TMCSData& aDataItem, TInt aIndex ); |
|
249 |
|
250 /** |
|
251 * Free the engine |
|
252 * |
|
253 * @param void |
|
254 * @return void |
|
255 */ |
|
256 void FreeEngine(); |
|
257 |
|
258 /** |
|
259 * Delete content model |
|
260 */ |
|
261 void DeleteContentModel(); |
|
262 |
|
263 private: // data |
|
264 |
|
265 // Iterator for plugin content |
|
266 // Own |
|
267 MAiContentItemIterator* iContent; |
|
268 |
|
269 // Number of data in the content model. |
|
270 TInt iDataCount; |
|
271 |
|
272 // Dynamic content model |
|
273 // Own. |
|
274 TAiContentItem* iContentModel; |
|
275 |
|
276 // Plugin engine |
|
277 // Own |
|
278 CMCSPluginEngine* iEngine; |
|
279 |
|
280 // Array of content observers |
|
281 // not own |
|
282 RPointerArray<MAiContentObserver> iObservers; |
|
283 |
|
284 // Information about the content publisher (this plug-in) |
|
285 TAiPublisherInfo iInfo; |
|
286 |
|
287 // For accessing central repository keys |
|
288 CRepository* iRepository; |
|
289 |
|
290 // For observing central repository Skin UID key change |
|
291 CMCSPluginWatcher* iRepositoryWatcher; |
|
292 |
|
293 }; |
|
294 |
|
295 #endif // CMCSPLUGIN_H |
|