20
|
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::InitializePluginL()
|
|
175 |
{
|
|
176 |
CCA_DP( KCCAppLogFile, CCA_L("->CCCAAppAppUi::InitializePluginL"));
|
|
177 |
|
|
178 |
|
|
179 |
|
|
180 |
TInt error = iCCAppView->StartView( iCCAParameter->LaunchedViewUid() );
|
|
181 |
if ( KErrNone != error )
|
|
182 |
{
|
|
183 |
User::Leave( error );
|
|
184 |
}
|
|
185 |
|
|
186 |
CCA_DP( KCCAppLogFile, CCA_L("<-CCCAAppAppUi::InitializePluginL"));
|
|
187 |
}
|
|
188 |
|
|
189 |
// ---------------------------------------------------------------------------
|
|
190 |
// CCCAAppAppUi::SetParameter
|
|
191 |
// ---------------------------------------------------------------------------
|
|
192 |
//
|
|
193 |
void CCCAAppAppUi::SetParameter( CCCAParameter& aParameter )
|
|
194 |
{
|
|
195 |
iCCAParameter = &aParameter;
|
|
196 |
}
|
|
197 |
|
|
198 |
// ---------------------------------------------------------------------------
|
|
199 |
// CCCAAppAppUi::Parameter
|
|
200 |
// ---------------------------------------------------------------------------
|
|
201 |
//
|
|
202 |
CCCAParameter& CCCAAppAppUi::Parameter()
|
|
203 |
{
|
|
204 |
CCA_DP( KCCAppLogFile, CCA_L("CCCAAppAppUi::Parameter"));
|
|
205 |
return *iCCAParameter;
|
|
206 |
}
|
|
207 |
|
|
208 |
// ---------------------------------------------------------------------------
|
|
209 |
// CCCAAppAppUi::LoadSettingsL
|
|
210 |
// ---------------------------------------------------------------------------
|
|
211 |
//
|
|
212 |
void CCCAAppAppUi::LoadSettingsL()
|
|
213 |
{
|
|
214 |
CCA_DP( KCCAppLogFile, CCA_L("->CCCAAppAppUi::LoadSettingsL"));
|
|
215 |
|
|
216 |
if ( !iRepository )
|
|
217 |
iRepository = CRepository::NewL( KCRUIDCCAApplication );
|
|
218 |
|
|
219 |
TInt error = iRepository->Get( KPrevViewKey, iPrevViewKey );
|
|
220 |
CCA_DP( KCCAppLogFile, CCA_L("::LoadSettingsL - iPrevViewKey settings loaded, error: %d"), error );
|
|
221 |
|
|
222 |
if( KErrNone == error )
|
|
223 |
{
|
|
224 |
error = iRepository->Get( KNextViewKey, iNextViewKey );
|
|
225 |
CCA_DP( KCCAppLogFile, CCA_L("::LoadSettingsL - iNextViewKey settings loaded, error: %d"), error );
|
|
226 |
|
|
227 |
if( KErrNone == error )
|
|
228 |
{
|
|
229 |
iSettingsLoaded = ETrue;
|
|
230 |
}
|
|
231 |
}
|
|
232 |
|
|
233 |
iReservedKeys.Reset();
|
|
234 |
iReservedKeys.Append( iPrevViewKey );
|
|
235 |
iReservedKeys.Append( iNextViewKey );
|
|
236 |
|
|
237 |
CCA_DP( KCCAppLogFile, CCA_L("<-CCCAAppAppUi::LoadSettingsL"));
|
|
238 |
}
|
|
239 |
|
|
240 |
// ---------------------------------------------------------------------------
|
|
241 |
// CCCAAppAppUi::EikonEnv
|
|
242 |
// ---------------------------------------------------------------------------
|
|
243 |
//
|
|
244 |
CEikonEnv& CCCAAppAppUi::EikonEnv()
|
|
245 |
{
|
|
246 |
CCA_DP( KCCAppLogFile, CCA_L("CCCAAppAppUi::EikonEnv"));
|
|
247 |
return *iEikonEnv;
|
|
248 |
}
|
|
249 |
|
|
250 |
// ---------------------------------------------------------------------------
|
|
251 |
// CCCAAppAppUi::ReservedKeys
|
|
252 |
// ---------------------------------------------------------------------------
|
|
253 |
//
|
|
254 |
RArray<TInt>& CCCAAppAppUi::ReservedKeys()
|
|
255 |
{
|
|
256 |
CCA_DP( KCCAppLogFile, CCA_L("->CCCAAppAppUi::ReservedKeysL"));
|
|
257 |
|
|
258 |
if ( !iSettingsLoaded )
|
|
259 |
{
|
|
260 |
// Load the setting to know which navigation key we accept
|
|
261 |
TRAP_IGNORE( LoadSettingsL() );
|
|
262 |
}
|
|
263 |
|
|
264 |
CCA_DP( KCCAppLogFile, CCA_L("<-CCCAAppAppUi::ReservedKeysL"));
|
|
265 |
return iReservedKeys;
|
|
266 |
}
|
|
267 |
|
|
268 |
// ---------------------------------------------------------------------------
|
|
269 |
// CCCAAppAppUi::RemoveInvalidPluginL
|
|
270 |
// ---------------------------------------------------------------------------
|
|
271 |
//
|
|
272 |
void CCCAAppAppUi::RecoverFromBadPluginL()
|
|
273 |
{
|
|
274 |
CCA_DP( KCCAppLogFile, CCA_L("CCCAAppAppUi::RecoverFromBadPluginL"));
|
|
275 |
iCCAppView->RecoverFromBadPluginL();
|
|
276 |
}
|
|
277 |
|
|
278 |
// ---------------------------------------------------------------------------
|
|
279 |
// CCCAAppAppUi::HandleError
|
|
280 |
// ---------------------------------------------------------------------------
|
|
281 |
//
|
|
282 |
TErrorHandlerResponse CCCAAppAppUi::HandleError(
|
|
283 |
TInt aError,
|
|
284 |
const SExtendedError& aExtErr,
|
|
285 |
TDes& aErrorText,
|
|
286 |
TDes& aContextText )
|
|
287 |
{
|
|
288 |
CCA_DP( KCCAppLogFile, CCA_L("CCCAAppAppUi::HandleError"));
|
|
289 |
|
|
290 |
// HandleError seems to be the only way (?) to catch
|
|
291 |
// if DoActivateL leaves during the Avkon fw callbacks.
|
|
292 |
//
|
|
293 |
// Problem is that "normal leaves" like HandleCommandL leave
|
|
294 |
// or DynInitMenuPaneL leave will also come HandleError. This
|
|
295 |
// is now handled with following if the view ids are out of sync.
|
|
296 |
// If they're out of sync, it means that most propably something
|
|
297 |
// went wrong during the last view activation. CCAppUi cannot do much
|
|
298 |
// for that situation -> plugin is unloaded.
|
|
299 |
TBool viewsInSync =
|
|
300 |
iView->Id() == iCCAppView->PluginLoader().PluginInFocus()->Plugin().Id();
|
|
301 |
if ( !viewsInSync )
|
|
302 |
TRAP_IGNORE( RecoverFromBadPluginL() );
|
|
303 |
|
|
304 |
return CAknAppUi::HandleError(
|
|
305 |
aError, aExtErr, aErrorText, aContextText );
|
|
306 |
}
|
|
307 |
|
|
308 |
// ---------------------------------------------------------------------------
|
|
309 |
// CCCAAppAppUi::SetTitleL
|
|
310 |
// ---------------------------------------------------------------------------
|
|
311 |
//
|
|
312 |
void CCCAAppAppUi::SetTitleL( const TDesC& aTitle )
|
|
313 |
{
|
|
314 |
CEikStatusPane* statuspane = EikonEnv().
|
|
315 |
AppUiFactory()->StatusPane();//not owned
|
|
316 |
CAknTitlePane* titlepane = (CAknTitlePane*)statuspane->
|
|
317 |
ControlL(TUid::Uid(EEikStatusPaneUidTitle));//not owned
|
|
318 |
|
|
319 |
TPtrC oldText = *titlepane->Text();
|
|
320 |
|
|
321 |
if ( oldText.Compare( aTitle ))
|
|
322 |
titlepane->SetTextL( aTitle, ETrue );
|
|
323 |
|
|
324 |
}
|
|
325 |
|
|
326 |
// end of file
|
|
327 |
|
|
328 |
|
|
329 |
|