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