|
1 /* |
|
2 * Copyright (c) 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: AppUi -part of the CCApplication |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ccappheaders.h" |
|
20 |
|
21 // --------------------------------------------------------------------------- |
|
22 // CCCAAppAppUi::CCCAAppAppUi |
|
23 // --------------------------------------------------------------------------- |
|
24 // |
|
25 CCCAAppAppUi::CCCAAppAppUi() |
|
26 { |
|
27 // The default navigation keys |
|
28 iPrevViewKey = EKeyLeftArrow; |
|
29 iNextViewKey = EKeyRightArrow; |
|
30 } |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // CCCAAppAppUi::ConstructL |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 void CCCAAppAppUi::ConstructL() |
|
37 { |
|
38 CCA_DP( KCCAppLogFile, CCA_L("->CCCAAppAppUi::ConstructL")); |
|
39 |
|
40 FeatureManager::InitializeLibL(); |
|
41 BaseConstructL( EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible ); |
|
42 iCCAppView = CCCAppView::NewL( *this ); |
|
43 |
|
44 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAAppAppUi::ConstructL")); |
|
45 } |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // CCCAAppAppUi::~CCCAAppAppUi |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 CCCAAppAppUi::~CCCAAppAppUi() |
|
52 { |
|
53 CCA_DP( KCCAppLogFile, CCA_L("->CCCAAppAppUi::~CCCAAppAppUi")); |
|
54 |
|
55 FeatureManager::UnInitializeLib(); |
|
56 delete iCCAppView; |
|
57 delete iCCAParameter; |
|
58 iReservedKeys.Reset(); |
|
59 delete iRepository; |
|
60 |
|
61 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAAppAppUi::~CCCAAppAppUi")); |
|
62 } |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // CCCAAppAppUi::HandleCommandL |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 void CCCAAppAppUi::HandleCommandL( TInt aCommand ) |
|
69 { |
|
70 CCA_DP( KCCAppLogFile, CCA_L("->CCCAAppAppUi::HandleCommandL")); |
|
71 CCA_DP( KCCAppLogFile, CCA_L("::HandleCommandL - aCommand: %d"), aCommand ); |
|
72 |
|
73 switch( aCommand ) |
|
74 { |
|
75 // Handle the launching of help in CCApplication side |
|
76 // (plugin needs just to implement GetHelpContext in container) |
|
77 case EAknCmdHelp: |
|
78 if( FeatureManager::FeatureSupported( KFeatureIdHelp )) |
|
79 { |
|
80 HlpLauncher::LaunchHelpApplicationL( |
|
81 iEikonEnv->WsSession(), AppHelpContextL() ); |
|
82 } |
|
83 break; |
|
84 // Handle the exits in CCApplication side |
|
85 case EEikCmdExit:// fallthrough |
|
86 case EAknSoftkeyBack:// fallthrough |
|
87 case EAknSoftkeyExit: |
|
88 Exit(); |
|
89 break; |
|
90 case EAknCmdExit: |
|
91 { |
|
92 // Special case with mycard contact editor, which calls |
|
93 // HandleCommandL directly. This command should be handled in |
|
94 // CAknViewAppUi::ProcessCommandL() |
|
95 ProcessCommandL( EAknCmdExit ); |
|
96 break; |
|
97 } |
|
98 default: |
|
99 break; |
|
100 } |
|
101 |
|
102 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAAppAppUi::HandleCommandL")); |
|
103 } |
|
104 |
|
105 // --------------------------------------------------------------------------- |
|
106 // CCCAAppAppUi::PrepareToExit |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 void CCCAAppAppUi::PrepareToExit() |
|
110 { |
|
111 CAknViewAppUi::PrepareToExit(); |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // CCCAAppAppUi::HandleKeyEventL |
|
116 // --------------------------------------------------------------------------- |
|
117 // |
|
118 TKeyResponse CCCAAppAppUi::HandleKeyEventL( |
|
119 const TKeyEvent& aKeyEvent, |
|
120 TEventCode aType ) |
|
121 { |
|
122 CCA_DP( KCCAppLogFile, CCA_L("->CCCAAppAppUi::HandleKeyEventL")); |
|
123 |
|
124 // if plug-in is busy with something, just ignore key event |
|
125 if ( iCCAppView->CurrentPluginBusy() && !CCoeAppUi::IsDisplayingDialog() ) |
|
126 { |
|
127 return EKeyWasConsumed; |
|
128 } |
|
129 |
|
130 TKeyResponse returnValue = EKeyWasNotConsumed; |
|
131 |
|
132 if ( !iSettingsLoaded ) |
|
133 { |
|
134 // Load the setting to know which navigation key we accept |
|
135 TRAP_IGNORE( LoadSettingsL() ); |
|
136 } |
|
137 |
|
138 if ( EEventKey == aType |
|
139 && ( iNextViewKey == aKeyEvent.iCode || iPrevViewKey == aKeyEvent.iCode )) |
|
140 { |
|
141 // Handle the reserved keys |
|
142 CCA_DP( KCCAppLogFile, CCA_L("::HandleKeyEventL - reserved key")); |
|
143 if ( KErrNone != iCCAppView->ChangeView( iNextViewKey == aKeyEvent.iCode )) |
|
144 { |
|
145 Exit(); |
|
146 } |
|
147 returnValue = EKeyWasConsumed; |
|
148 } |
|
149 |
|
150 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAAppAppUi::HandleKeyEventL")); |
|
151 return returnValue; |
|
152 } |
|
153 |
|
154 // --------------------------------------------------------------------------- |
|
155 // CCCAAppAppUi::HandleWsEventL |
|
156 // --------------------------------------------------------------------------- |
|
157 // |
|
158 void CCCAAppAppUi::HandleWsEventL(const TWsEvent &aEvent, |
|
159 CCoeControl *aDestination) |
|
160 { |
|
161 CCA_DP( KCCAppLogFile, CCA_L("->CCCAAppAppUi::HandleWsEventL")); |
|
162 // handle WS event only if plug-in is not busy with something |
|
163 if ( !iCCAppView->CurrentPluginBusy() || CCoeAppUi::IsDisplayingDialog() ) |
|
164 { |
|
165 CAknViewAppUi::HandleWsEventL( aEvent, aDestination ); |
|
166 } |
|
167 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAAppAppUi::HandleWsEventL - OUT")); |
|
168 } |
|
169 |
|
170 // --------------------------------------------------------------------------- |
|
171 // CCCAAppAppUi::InitializePlugin |
|
172 // --------------------------------------------------------------------------- |
|
173 // |
|
174 void CCCAAppAppUi::InitializePlugin( |
|
175 CCCAParameter& aParameter ) |
|
176 { |
|
177 CCA_DP( KCCAppLogFile, CCA_L("->CCCAAppAppUi::InitializePluginL")); |
|
178 |
|
179 iCCAParameter = &aParameter; |
|
180 if ( KErrNone != |
|
181 iCCAppView->StartView( iCCAParameter->LaunchedViewUid() )) |
|
182 { |
|
183 Exit(); |
|
184 } |
|
185 |
|
186 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAAppAppUi::InitializePluginL")); |
|
187 } |
|
188 |
|
189 // --------------------------------------------------------------------------- |
|
190 // CCCAAppAppUi::Parameter |
|
191 // --------------------------------------------------------------------------- |
|
192 // |
|
193 CCCAParameter& CCCAAppAppUi::Parameter() |
|
194 { |
|
195 CCA_DP( KCCAppLogFile, CCA_L("CCCAAppAppUi::Parameter")); |
|
196 return *iCCAParameter; |
|
197 } |
|
198 |
|
199 // --------------------------------------------------------------------------- |
|
200 // CCCAAppAppUi::LoadSettingsL |
|
201 // --------------------------------------------------------------------------- |
|
202 // |
|
203 void CCCAAppAppUi::LoadSettingsL() |
|
204 { |
|
205 CCA_DP( KCCAppLogFile, CCA_L("->CCCAAppAppUi::LoadSettingsL")); |
|
206 |
|
207 if ( !iRepository ) |
|
208 iRepository = CRepository::NewL( KCRUIDCCAApplication ); |
|
209 |
|
210 TInt error = iRepository->Get( KPrevViewKey, iPrevViewKey ); |
|
211 CCA_DP( KCCAppLogFile, CCA_L("::LoadSettingsL - iPrevViewKey settings loaded, error: %d"), error ); |
|
212 |
|
213 if( KErrNone == error ) |
|
214 { |
|
215 error = iRepository->Get( KNextViewKey, iNextViewKey ); |
|
216 CCA_DP( KCCAppLogFile, CCA_L("::LoadSettingsL - iNextViewKey settings loaded, error: %d"), error ); |
|
217 |
|
218 if( KErrNone == error ) |
|
219 { |
|
220 iSettingsLoaded = ETrue; |
|
221 } |
|
222 } |
|
223 |
|
224 iReservedKeys.Reset(); |
|
225 iReservedKeys.Append( iPrevViewKey ); |
|
226 iReservedKeys.Append( iNextViewKey ); |
|
227 |
|
228 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAAppAppUi::LoadSettingsL")); |
|
229 } |
|
230 |
|
231 // --------------------------------------------------------------------------- |
|
232 // CCCAAppAppUi::EikonEnv |
|
233 // --------------------------------------------------------------------------- |
|
234 // |
|
235 CEikonEnv& CCCAAppAppUi::EikonEnv() |
|
236 { |
|
237 CCA_DP( KCCAppLogFile, CCA_L("CCCAAppAppUi::EikonEnv")); |
|
238 return *iEikonEnv; |
|
239 } |
|
240 |
|
241 // --------------------------------------------------------------------------- |
|
242 // CCCAAppAppUi::ReservedKeys |
|
243 // --------------------------------------------------------------------------- |
|
244 // |
|
245 RArray<TInt>& CCCAAppAppUi::ReservedKeys() |
|
246 { |
|
247 CCA_DP( KCCAppLogFile, CCA_L("->CCCAAppAppUi::ReservedKeysL")); |
|
248 |
|
249 if ( !iSettingsLoaded ) |
|
250 { |
|
251 // Load the setting to know which navigation key we accept |
|
252 TRAP_IGNORE( LoadSettingsL() ); |
|
253 } |
|
254 |
|
255 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAAppAppUi::ReservedKeysL")); |
|
256 return iReservedKeys; |
|
257 } |
|
258 |
|
259 // --------------------------------------------------------------------------- |
|
260 // CCCAAppAppUi::RemoveInvalidPluginL |
|
261 // --------------------------------------------------------------------------- |
|
262 // |
|
263 void CCCAAppAppUi::RecoverFromBadPluginL() |
|
264 { |
|
265 CCA_DP( KCCAppLogFile, CCA_L("CCCAAppAppUi::RecoverFromBadPluginL")); |
|
266 iCCAppView->RecoverFromBadPluginL(); |
|
267 } |
|
268 |
|
269 // --------------------------------------------------------------------------- |
|
270 // CCCAAppAppUi::HandleError |
|
271 // --------------------------------------------------------------------------- |
|
272 // |
|
273 TErrorHandlerResponse CCCAAppAppUi::HandleError( |
|
274 TInt aError, |
|
275 const SExtendedError& aExtErr, |
|
276 TDes& aErrorText, |
|
277 TDes& aContextText ) |
|
278 { |
|
279 CCA_DP( KCCAppLogFile, CCA_L("CCCAAppAppUi::HandleError")); |
|
280 |
|
281 // HandleError seems to be the only way (?) to catch |
|
282 // if DoActivateL leaves during the Avkon fw callbacks. |
|
283 // |
|
284 // Problem is that "normal leaves" like HandleCommandL leave |
|
285 // or DynInitMenuPaneL leave will also come HandleError. This |
|
286 // is now handled with following if the view ids are out of sync. |
|
287 // If they're out of sync, it means that most propably something |
|
288 // went wrong during the last view activation. CCAppUi cannot do much |
|
289 // for that situation -> plugin is unloaded. |
|
290 TBool viewsInSync = |
|
291 iView->Id() == iCCAppView->PluginLoader().PluginInFocus()->Plugin().Id(); |
|
292 if ( !viewsInSync ) |
|
293 TRAP_IGNORE( RecoverFromBadPluginL() ); |
|
294 |
|
295 return CAknAppUi::HandleError( |
|
296 aError, aExtErr, aErrorText, aContextText ); |
|
297 } |
|
298 |
|
299 // --------------------------------------------------------------------------- |
|
300 // CCCAAppAppUi::SetTitleL |
|
301 // --------------------------------------------------------------------------- |
|
302 // |
|
303 void CCCAAppAppUi::SetTitleL( const TDesC& aTitle ) |
|
304 { |
|
305 CEikStatusPane* statuspane = EikonEnv(). |
|
306 AppUiFactory()->StatusPane();//not owned |
|
307 CAknTitlePane* titlepane = (CAknTitlePane*)statuspane-> |
|
308 ControlL(TUid::Uid(EEikStatusPaneUidTitle));//not owned |
|
309 |
|
310 TPtrC oldText = *titlepane->Text(); |
|
311 |
|
312 if ( oldText.Compare( aTitle )) |
|
313 titlepane->SetTextL( aTitle, ETrue ); |
|
314 |
|
315 } |
|
316 |
|
317 // end of file |
|
318 |
|
319 |
|
320 |