|
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: Native UI controller. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_NATIVEUICONTROLLER_H |
|
20 #define C_NATIVEUICONTROLLER_H |
|
21 |
|
22 |
|
23 #include <aisystemuids.hrh> |
|
24 #include "aiuicontroller.h" |
|
25 #include "aiuiframeworkobserver.h" |
|
26 #include "aicontentobserver.h" |
|
27 |
|
28 #include <aiutility.h> |
|
29 |
|
30 class MAiPropertyExtension; |
|
31 class MAiPSPropertyObserver; |
|
32 |
|
33 namespace AiNativeUiController |
|
34 { |
|
35 |
|
36 class CAiNativeRenderer; |
|
37 class CAiStatusPanel; |
|
38 class CAppUi; |
|
39 class CAiToolbarRenderer; |
|
40 |
|
41 const TInt KImplementationUidNativeUiController = AI_UID_ECOM_IMPLEMENTATION_UICONTROLLER_NATIVE; |
|
42 |
|
43 const TUid KUidNativeUiController = { KImplementationUidNativeUiController }; |
|
44 |
|
45 /** |
|
46 * Native UI controller. |
|
47 * This class works as a secondary UI controller. It implements |
|
48 * the MAiContentObserver interface thus handling and forwarding the data coming |
|
49 * from the publishers. |
|
50 * |
|
51 * @since Series 60 3.2 |
|
52 */ |
|
53 class CNativeUiController : public CAiUiController, |
|
54 public MAiSecondaryUiController, |
|
55 public MAiMainUiController, |
|
56 public MAiUiFrameworkObserver, |
|
57 public MAiContentObserver |
|
58 { |
|
59 public: |
|
60 |
|
61 static CNativeUiController* NewL(); |
|
62 |
|
63 virtual ~CNativeUiController(); |
|
64 |
|
65 // from base class CAiUiController |
|
66 |
|
67 void PrepareToExit(); |
|
68 |
|
69 void LoadUIDefinitionL(); |
|
70 |
|
71 void GetPluginsL(RAiPublisherInfoArray& aPlugins); |
|
72 |
|
73 void GetSettingsL(const TAiPublisherInfo& aPubInfo, |
|
74 RAiSettingsItemArray& aSettings); |
|
75 |
|
76 void ActivateUI(); |
|
77 |
|
78 MAiContentObserver& GetContentObserver(); |
|
79 |
|
80 void SetEventHandler(MAiFwEventHandler& aEventHandler); |
|
81 |
|
82 MAiFwEventHandler* FwEventHandler(); |
|
83 |
|
84 void RemovePluginFromUI( MAiPropertyExtension& aPlugin ); |
|
85 |
|
86 MAiMainUiController* MainInterface(); |
|
87 |
|
88 MAiSecondaryUiController* SecondaryInterface(); |
|
89 |
|
90 void HandleLoadedPlugins(const RAiPublisherInfoArray& /*aRequiredPlugins*/ ) {}; |
|
91 |
|
92 // from base class MAiMainUiController |
|
93 |
|
94 void RunApplicationL(); |
|
95 |
|
96 CCoeEnv& CoeEnv(); |
|
97 |
|
98 void SetUiFrameworkObserver( MAiUiFrameworkObserver& aObserver ); |
|
99 |
|
100 TBool IsMenuOpen(); |
|
101 |
|
102 // from base class CAiSecordaryUiController |
|
103 |
|
104 void SetCoeEnv( CCoeEnv& aCoeEnv ); |
|
105 |
|
106 MAiUiFrameworkObserver* UiFrameworkObserver(); |
|
107 |
|
108 // from base class MAiUiFrameworkObserver |
|
109 |
|
110 void HandleResourceChange( TInt aType ); |
|
111 |
|
112 void HandleForegroundEvent( TBool aForeground ); |
|
113 |
|
114 // from base class MAiContentObserver |
|
115 |
|
116 TInt StartTransaction(TInt aTxId); |
|
117 |
|
118 TInt Commit(TInt aTxId); |
|
119 |
|
120 TInt CancelTransaction(TInt aTxId); |
|
121 |
|
122 TBool CanPublish(MAiPropertyExtension& aPlugin, TInt aContent, TInt aIndex); |
|
123 |
|
124 TInt Publish(MAiPropertyExtension& aPlugin, TInt aContent, TInt aResource, TInt aIndex ); |
|
125 |
|
126 TInt Publish(MAiPropertyExtension& aPlugin, TInt aContent, const TDesC16& aText, TInt aIndex ); |
|
127 |
|
128 TInt Publish(MAiPropertyExtension& aPlugin, TInt aContent, const TDesC8& aBuf, TInt aIndex ); |
|
129 |
|
130 TInt Publish(MAiPropertyExtension& aPlugin, TInt aContent, RFile& aFile, TInt aIndex ); |
|
131 |
|
132 TInt Clean(MAiPropertyExtension& aPlugin, TInt aContent, TInt aIndex ); |
|
133 |
|
134 TAny* Extension(TUid aUid); |
|
135 |
|
136 TBool RequiresSubscription( const TAiPublisherInfo& aPublisherInfo ) const; |
|
137 |
|
138 // new methods |
|
139 |
|
140 /** |
|
141 * Set app ui instance to this class. |
|
142 * |
|
143 * @since S60 3.2 |
|
144 * @param aAppUi is pointer to app ui. |
|
145 */ |
|
146 void SetAppUi( CAppUi* aAppUi ) |
|
147 { |
|
148 iAppUi = aAppUi; |
|
149 } |
|
150 |
|
151 void VariateToMainUiController(); |
|
152 |
|
153 void Exit(); |
|
154 |
|
155 private: |
|
156 |
|
157 CNativeUiController(); |
|
158 |
|
159 static CApaApplication* NewApplication(); |
|
160 |
|
161 /** |
|
162 * Add renderer. |
|
163 * |
|
164 * Ownership transferred. |
|
165 * |
|
166 * @since S60 3.2 |
|
167 * @param aRenderer is pointer to renderer. |
|
168 */ |
|
169 void AddRendererL( CAiNativeRenderer* aRenderer ); |
|
170 |
|
171 /** |
|
172 * Remove a renderer. Renderer is only |
|
173 * removed from the array and is deleted ONLY |
|
174 * when aDelete = ETrue |
|
175 * |
|
176 * @since S60 5.0 |
|
177 * @param aRenderer is pointer to the renderer to be removed |
|
178 * @param aDelete is ETrue when the renderer will be deleted |
|
179 * @return ETrue upon successful removing. |
|
180 */ |
|
181 TBool RemoveRenderer( CAiNativeRenderer *aRenderer, TBool aDelete = EFalse ); |
|
182 |
|
183 /** |
|
184 * Recreates the toolbar renderer |
|
185 */ |
|
186 TBool RecreateToolbarRendererL(); |
|
187 |
|
188 /** |
|
189 * Deletes and removes the toolbar renderer from |
|
190 * renderer array. |
|
191 */ |
|
192 void DeleteToolbarRenderer(); |
|
193 |
|
194 /** |
|
195 * Template function for publish. |
|
196 * |
|
197 * @since S60 3.2 |
|
198 * @param aPlugin is publishing plugin. |
|
199 * @param aContent is content id |
|
200 * @param aData is published data |
|
201 * @param aIndex is index in the control, not used by Native UI Controller. |
|
202 * @return KErrNone if publishing was successful. |
|
203 */ |
|
204 template<class T> |
|
205 TInt DoPublish( MAiPropertyExtension& aPlugin, TInt aContent, T& aData, TInt aIndex ); |
|
206 |
|
207 /** |
|
208 * Handles idle state changes. |
|
209 * |
|
210 * @since S60 v3.2 |
|
211 */ |
|
212 static TInt HandleIdleStateEvent( TAny* aPtr ); |
|
213 |
|
214 /** |
|
215 * Handles keylock state changes. |
|
216 * |
|
217 * @since S60 v3.2 |
|
218 */ |
|
219 static TInt HandleKeylockStateEvent( TAny* aPtr ); |
|
220 |
|
221 static TInt HandlePluginConfChange( TAny* aPtr ); |
|
222 |
|
223 static TInt ExitTimerCallBack( TAny* aSelf ); |
|
224 void GetSettingsFromCRL( const TAiPublisherInfo& aPubInfo, |
|
225 RAiSettingsItemArray &aPluginSettings ); |
|
226 |
|
227 private: // Data |
|
228 |
|
229 /** |
|
230 * Array of renderers. |
|
231 * Own. |
|
232 */ |
|
233 RPointerArray<CAiNativeRenderer> iRenderers; |
|
234 |
|
235 /** |
|
236 * Offset of resource file. |
|
237 */ |
|
238 TInt iResourceOffset; |
|
239 |
|
240 /** |
|
241 * Status panel |
|
242 * Own. |
|
243 */ |
|
244 CAiStatusPanel* iStatusPanel; |
|
245 |
|
246 /** |
|
247 * Reference to available CONE environment object. Not own. |
|
248 */ |
|
249 CCoeEnv* iCoeEnv; |
|
250 |
|
251 /** |
|
252 * Idle state PS observer. |
|
253 * Own. |
|
254 */ |
|
255 MAiPSPropertyObserver* iIdleStatusObserver; |
|
256 |
|
257 /** |
|
258 * Keylock state PS observer. |
|
259 * Own. |
|
260 */ |
|
261 MAiPSPropertyObserver* iKeylockStatusObserver; |
|
262 |
|
263 |
|
264 /** |
|
265 * ExtHS plugin configuration PS observer. |
|
266 * Own. |
|
267 */ |
|
268 MAiPSPropertyObserver* iExtHsPluginConfChange; |
|
269 |
|
270 /** |
|
271 * Native UI controller plug-ins |
|
272 */ |
|
273 RAiPublisherInfoArray iPlugins; |
|
274 |
|
275 /** |
|
276 * Plug-in event handler. |
|
277 * Doesn't own. |
|
278 */ |
|
279 MAiFwEventHandler* iFwEventHandler; |
|
280 |
|
281 /** |
|
282 * Pointer to this, when role is main ui controller. |
|
283 */ |
|
284 MAiMainUiController* iMain; |
|
285 |
|
286 /** |
|
287 * Ui framework observer. Not own. |
|
288 */ |
|
289 MAiUiFrameworkObserver* iUiFrameworkObserver; |
|
290 |
|
291 /** |
|
292 * Pointer to app ui. |
|
293 * Not own. |
|
294 */ |
|
295 CAppUi* iAppUi; |
|
296 |
|
297 /** |
|
298 * Indicates if Native UI Controller takes responsibilities of |
|
299 * Main UI Controller. |
|
300 */ |
|
301 TBool iRunningAsMain; |
|
302 |
|
303 /** |
|
304 * Timer to call AppUi's exit |
|
305 **/ |
|
306 CPeriodic *iExitTimer; |
|
307 |
|
308 /** |
|
309 * To prevent double loading of the UI |
|
310 **/ |
|
311 TBool iUiLoaded; |
|
312 |
|
313 /** |
|
314 * Pointer to our toolbar renderer. Do not delete |
|
315 * renderer through this pointer |
|
316 */ |
|
317 CAiToolbarRenderer *iToolbarRenderer; |
|
318 |
|
319 }; |
|
320 |
|
321 #include "nativeuicontroller.inl" |
|
322 |
|
323 } // namespace AiNativeUiController |
|
324 |
|
325 #endif |
|
326 |
|
327 // End of File. |