|
1 /* |
|
2 * Copyright (c) 2005-2008 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: UI controller manager class |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 #include <centralrepository.h> |
|
20 |
|
21 // User includes |
|
22 #include <aisystemuids.hrh> |
|
23 #include "aiuicontroller.h" |
|
24 #include "aicontentobserver.h" |
|
25 #include "activeidle2domaincrkeys.h" |
|
26 #include "aifw.h" |
|
27 |
|
28 #include "aiuicontrollermanager.h" |
|
29 |
|
30 #include "aifwpanic.h" |
|
31 |
|
32 #include "debug.h" |
|
33 |
|
34 // ======== MEMBER FUNCTIONS ======== |
|
35 |
|
36 // ---------------------------------------------------------------------------- |
|
37 // CAiUiControllerManager::CAiUiControllerManager() |
|
38 // |
|
39 // ---------------------------------------------------------------------------- |
|
40 // |
|
41 CAiUiControllerManager::CAiUiControllerManager() |
|
42 { |
|
43 } |
|
44 |
|
45 // ---------------------------------------------------------------------------- |
|
46 // CAiUiControllerManager::LoadMainControllerL() |
|
47 // |
|
48 // ---------------------------------------------------------------------------- |
|
49 // |
|
50 void CAiUiControllerManager::LoadMainControllerL( CRepository& aRepository ) |
|
51 { |
|
52 TInt value( 0 ); |
|
53 |
|
54 // Main UI Controller must be configured correctly |
|
55 User::LeaveIfError( aRepository.Get( KAiMainUIController, value ) ); |
|
56 |
|
57 CAiUiController* controller = CAiUiController::NewL( TUid::Uid( value ) ); |
|
58 |
|
59 iCreatedUICList.Append( value ); |
|
60 CleanupStack::PushL( controller ); |
|
61 |
|
62 iMainUiController = controller->MainInterface(); |
|
63 |
|
64 // Main UI controller must be configured correctly |
|
65 if( !iMainUiController ) |
|
66 { |
|
67 __PRINT( __DBG_FORMAT("Main UI controller interface not found from controller 0x%x"), value ); |
|
68 User::Leave( KErrNotFound ); |
|
69 } |
|
70 |
|
71 iUiControllerArray.AppendL( controller ); |
|
72 CleanupStack::Pop( controller ); |
|
73 } |
|
74 |
|
75 // ---------------------------------------------------------------------------- |
|
76 // CAiUiControllerManager::LoadSecondaryControllersL() |
|
77 // |
|
78 // ---------------------------------------------------------------------------- |
|
79 // |
|
80 void CAiUiControllerManager::LoadSecondaryControllersL( |
|
81 CRepository& aRepository ) |
|
82 { |
|
83 TInt value( 0 ); |
|
84 |
|
85 // Instantiate rest of the UI controllers. |
|
86 for( TInt key = KAiFirstUIController; |
|
87 key <= KAiLastUIController && aRepository.Get( key, value ) == KErrNone; |
|
88 ++key ) |
|
89 { |
|
90 // skip empty entries |
|
91 if( value == 0 ) |
|
92 { |
|
93 continue; |
|
94 } |
|
95 |
|
96 if( iCreatedUICList.Find( value ) != KErrNotFound ) |
|
97 { |
|
98 continue; |
|
99 } |
|
100 |
|
101 iCreatedUICList.Append( value ); |
|
102 |
|
103 CAiUiController* controller = |
|
104 CAiUiController::NewL( TUid::Uid( value ) ); |
|
105 |
|
106 CleanupStack::PushL( controller ); |
|
107 |
|
108 iUiControllerArray.AppendL( controller ); |
|
109 CleanupStack::Pop( controller ); |
|
110 } |
|
111 } |
|
112 |
|
113 // ---------------------------------------------------------------------------- |
|
114 // CAiUiControllerManager::ConstructL() |
|
115 // |
|
116 // ---------------------------------------------------------------------------- |
|
117 // |
|
118 void CAiUiControllerManager::ConstructL( CAiFw* aAiFw ) |
|
119 { |
|
120 __HEAP("FW: Init - Create UI Ctrls"); |
|
121 __TIME_MARK(t); |
|
122 |
|
123 CRepository& repository( aAiFw->Repository() ); |
|
124 |
|
125 LoadMainControllerL( repository ); |
|
126 |
|
127 // Failing on secondary is not fatal. Ignore leaves. |
|
128 TRAP_IGNORE( LoadSecondaryControllersL( repository ) ); |
|
129 |
|
130 for ( TInt i = 0; i < iUiControllerArray.Count(); i++ ) |
|
131 { |
|
132 iUiControllerArray[i]->SetEventHandler( *aAiFw ); |
|
133 } |
|
134 |
|
135 __TIME_ENDMARK("FW: Create UI Ctrls", t); |
|
136 __HEAP("FW: Done - Create UI Ctrls"); |
|
137 } |
|
138 |
|
139 // ---------------------------------------------------------------------------- |
|
140 // CAiUiControllerManager::NewL() |
|
141 // |
|
142 // ---------------------------------------------------------------------------- |
|
143 // |
|
144 CAiUiControllerManager* CAiUiControllerManager::NewL( CAiFw* aAiFw ) |
|
145 { |
|
146 CAiUiControllerManager* self = |
|
147 new ( ELeave ) CAiUiControllerManager; |
|
148 |
|
149 CleanupStack::PushL( self ); |
|
150 self->ConstructL( aAiFw ); |
|
151 CleanupStack::Pop( self ); // self |
|
152 |
|
153 return self; |
|
154 } |
|
155 |
|
156 // ---------------------------------------------------------------------------- |
|
157 // CAiUiControllerManager::~CAiUiControllerManager() |
|
158 // |
|
159 // ---------------------------------------------------------------------------- |
|
160 // |
|
161 CAiUiControllerManager::~CAiUiControllerManager() |
|
162 { |
|
163 iUiControllerArray.ResetAndDestroy(); |
|
164 |
|
165 iCreatedUICList.Reset(); |
|
166 } |
|
167 |
|
168 // ---------------------------------------------------------------------------- |
|
169 // CAiUiControllerManager::UiControllers() |
|
170 // |
|
171 // ---------------------------------------------------------------------------- |
|
172 // |
|
173 RPointerArray< CAiUiController >& CAiUiControllerManager::UiControllers() const |
|
174 { |
|
175 return iUiControllerArray; |
|
176 } |
|
177 |
|
178 // ---------------------------------------------------------------------------- |
|
179 // CAiUiControllerManager::IsMainUiController() |
|
180 // |
|
181 // ---------------------------------------------------------------------------- |
|
182 // |
|
183 TBool CAiUiControllerManager::IsMainUiController( |
|
184 CAiUiController& aUiController ) const |
|
185 { |
|
186 return ( aUiController.MainInterface() == iMainUiController ); |
|
187 } |
|
188 |
|
189 // ---------------------------------------------------------------------------- |
|
190 // CAiUiControllerManager::RunApplicationL() |
|
191 // |
|
192 // ---------------------------------------------------------------------------- |
|
193 // |
|
194 void CAiUiControllerManager::RunApplicationL() |
|
195 { |
|
196 iMainUiController->RunApplicationL(); |
|
197 } |
|
198 |
|
199 // ---------------------------------------------------------------------------- |
|
200 // CAiUiControllerManager::ActivateUI() |
|
201 // |
|
202 // ---------------------------------------------------------------------------- |
|
203 // |
|
204 void CAiUiControllerManager::ActivateUI() |
|
205 { |
|
206 for( TInt i = 0; i < iUiControllerArray.Count(); i++ ) |
|
207 { |
|
208 iUiControllerArray[i]->ActivateUI(); |
|
209 } |
|
210 } |
|
211 |
|
212 // ---------------------------------------------------------------------------- |
|
213 // CAiUiControllerManager::LoadUIDefinition() |
|
214 // |
|
215 // ---------------------------------------------------------------------------- |
|
216 // |
|
217 void CAiUiControllerManager::LoadUIDefinition() |
|
218 { |
|
219 for( TInt i = 0; i < iUiControllerArray.Count(); i++ ) |
|
220 { |
|
221 CAiUiController* uiCtl( iUiControllerArray[i] ); |
|
222 |
|
223 MAiSecondaryUiController* secIntr( uiCtl->SecondaryInterface() ); |
|
224 |
|
225 if( secIntr ) |
|
226 { |
|
227 secIntr->SetCoeEnv( CoeEnv() ); |
|
228 } |
|
229 |
|
230 TRAPD( err, uiCtl->LoadUIDefinitionL() ); |
|
231 |
|
232 if( err != KErrNone ) |
|
233 { |
|
234 if( IsMainUiController( *uiCtl ) ) |
|
235 { |
|
236 // Main ui controller failing is fatal |
|
237 _LIT(KAIFWStartupFailed, "FW startup failed."); |
|
238 |
|
239 User::Panic( KAIFWStartupFailed, 0 ); |
|
240 } |
|
241 else |
|
242 { |
|
243 // Secondary UI controller failed, delete it |
|
244 delete uiCtl; |
|
245 uiCtl = NULL; |
|
246 |
|
247 iUiControllerArray.Remove( i ); |
|
248 } |
|
249 } |
|
250 } |
|
251 } |
|
252 |
|
253 // ---------------------------------------------------------------------------- |
|
254 // CAiUiControllerManager::CoeEnv() |
|
255 // |
|
256 // ---------------------------------------------------------------------------- |
|
257 // |
|
258 CCoeEnv& CAiUiControllerManager::CoeEnv() const |
|
259 { |
|
260 return iMainUiController->CoeEnv(); |
|
261 } |
|
262 |
|
263 // ---------------------------------------------------------------------------- |
|
264 // CAiUiControllerManager::MainUiController() |
|
265 // |
|
266 // ---------------------------------------------------------------------------- |
|
267 // |
|
268 MAiMainUiController& CAiUiControllerManager::MainUiController() const |
|
269 { |
|
270 return *iMainUiController; |
|
271 } |
|
272 |
|
273 // ---------------------------------------------------------------------------- |
|
274 // CAiUiControllerManager::DestroySecondaryUiControllers() |
|
275 // |
|
276 // ---------------------------------------------------------------------------- |
|
277 // |
|
278 void CAiUiControllerManager::DestroySecondaryUiControllers() |
|
279 { |
|
280 for( TInt i = iUiControllerArray.Count() - 1; i >= 0; --i ) |
|
281 { |
|
282 CAiUiController* uiController = iUiControllerArray[i]; |
|
283 |
|
284 if( !IsMainUiController( *uiController ) ) |
|
285 { |
|
286 delete uiController; |
|
287 uiController = NULL; |
|
288 |
|
289 iUiControllerArray.Remove(i); |
|
290 } |
|
291 } |
|
292 } |
|
293 |
|
294 // ---------------------------------------------------------------------------- |
|
295 // CAiUiControllerManager::ExitMainController() |
|
296 // |
|
297 // ---------------------------------------------------------------------------- |
|
298 // |
|
299 void CAiUiControllerManager::ExitMainController() |
|
300 { |
|
301 iMainUiController->Exit(); |
|
302 } |
|
303 |
|
304 // ---------------------------------------------------------------------------- |
|
305 // CAiUiControllerManager::SetStateHandler() |
|
306 // |
|
307 // ---------------------------------------------------------------------------- |
|
308 // |
|
309 void CAiUiControllerManager::SetStateHandler( MAiFwStateHandler& aHandler ) |
|
310 { |
|
311 for ( TInt i = 0; i < iUiControllerArray.Count(); i++ ) |
|
312 { |
|
313 iUiControllerArray[i]->SetStateHandler( aHandler ); |
|
314 } |
|
315 } |
|
316 |
|
317 // End of file |