56
|
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: Base view for all plugin views.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include "pslnfwbaseview.h"
|
|
21 |
#include "pslnfwbasecontainer.h"
|
|
22 |
#include "PslnConst.h"
|
|
23 |
#include "PslnDebug.h"
|
|
24 |
|
|
25 |
// For Download and Help command handling
|
|
26 |
#include <psln.hrh>
|
|
27 |
#include <hlplch.h>
|
|
28 |
|
|
29 |
// AVKON utilities
|
|
30 |
#include <aknnavide.h>
|
|
31 |
#include <akntitle.h>
|
|
32 |
#include <aknViewAppUi.h>
|
|
33 |
#include <akntabgrp.h>
|
|
34 |
|
|
35 |
// General Utilities
|
|
36 |
#include <barsread.h>
|
|
37 |
#include <bautils.h>
|
|
38 |
#include <data_caging_path_literals.hrh>
|
|
39 |
#include <StringLoader.h>
|
|
40 |
|
|
41 |
// Static view locations.
|
|
42 |
const TInt KPslnFWGeneralThemeViewLocation = 0;
|
|
43 |
|
|
44 |
// ========================= MEMBER FUNCTIONS ================================
|
|
45 |
// ---------------------------------------------------------------------------
|
|
46 |
// C++ constructor
|
|
47 |
// ---------------------------------------------------------------------------
|
|
48 |
EXPORT_C CPslnFWBaseView::CPslnFWBaseView() : iResourceLoader( *iCoeEnv ),
|
|
49 |
iMyTabIndex ( KErrNotFound )
|
|
50 |
{
|
|
51 |
}
|
|
52 |
|
|
53 |
// ---------------------------------------------------------------------------
|
|
54 |
// Destructor
|
|
55 |
// ---------------------------------------------------------------------------
|
|
56 |
EXPORT_C CPslnFWBaseView::~CPslnFWBaseView()
|
|
57 |
{
|
|
58 |
iResourceLoader.Close();
|
|
59 |
if ( iContainer )
|
|
60 |
{
|
|
61 |
CAknViewAppUi* appUi = AppUi();
|
|
62 |
if ( appUi )
|
|
63 |
{
|
|
64 |
appUi->RemoveFromStack( iContainer );
|
|
65 |
}
|
|
66 |
delete iContainer;
|
|
67 |
}
|
|
68 |
}
|
|
69 |
|
|
70 |
// ---------------------------------------------------------------------------
|
|
71 |
// CPslnFWBaseView::Container
|
|
72 |
// ---------------------------------------------------------------------------
|
|
73 |
EXPORT_C CPslnFWBaseContainer* CPslnFWBaseView::Container()
|
|
74 |
{
|
|
75 |
return iContainer;
|
|
76 |
}
|
|
77 |
|
|
78 |
// ---------------------------------------------------------------------------
|
|
79 |
// CPslnFWBaseView::SetCurrentItem
|
|
80 |
// ---------------------------------------------------------------------------
|
|
81 |
EXPORT_C void CPslnFWBaseView::SetCurrentItem( TInt aIndex )
|
|
82 |
{
|
|
83 |
PSLN_TRACE_DEBUG("CPslnFWBaseView::SetCurrentItem");
|
|
84 |
if ( aIndex > 0 )
|
|
85 |
{
|
|
86 |
iCurrentItem = aIndex;
|
|
87 |
}
|
|
88 |
else
|
|
89 |
{
|
|
90 |
// If invalid index, set to first.
|
|
91 |
iCurrentItem = 0;
|
|
92 |
}
|
|
93 |
}
|
|
94 |
|
|
95 |
// ---------------------------------------------------------------------------
|
|
96 |
// CPslnFWBaseView::HandleListBoxEventL
|
|
97 |
// ---------------------------------------------------------------------------
|
|
98 |
EXPORT_C void CPslnFWBaseView::HandleListBoxEventL( CEikListBox* /*aListBox*/,
|
|
99 |
TListBoxEvent aEventType )
|
|
100 |
{
|
|
101 |
switch ( aEventType )
|
|
102 |
{
|
|
103 |
case EEventItemClicked:
|
|
104 |
if ( iContainer && iContainer->iMSKObserver )
|
|
105 |
{
|
|
106 |
iContainer->iMSKObserver->CheckMiddleSoftkeyLabelL();
|
|
107 |
}
|
|
108 |
break;
|
|
109 |
case EEventEnterKeyPressed:
|
|
110 |
case EEventItemDoubleClicked:
|
|
111 |
case EEventItemSingleClicked:
|
|
112 |
HandleListBoxSelectionL();
|
|
113 |
break;
|
|
114 |
default:
|
|
115 |
break;
|
|
116 |
}
|
|
117 |
}
|
|
118 |
|
|
119 |
// ---------------------------------------------------------------------------
|
|
120 |
// Sets navi_pane.
|
|
121 |
// ---------------------------------------------------------------------------
|
|
122 |
//
|
|
123 |
EXPORT_C void CPslnFWBaseView::SetNaviPaneL()
|
|
124 |
{
|
|
125 |
PSLN_TRACE_DEBUG("CPslnFWBaseView::SetNaviPaneL BEGIN");
|
|
126 |
if ( !iNaviControlContainer )
|
|
127 |
{
|
|
128 |
CAknViewAppUi* appUi = AppUi();
|
|
129 |
if ( appUi )
|
|
130 |
{
|
|
131 |
CEikStatusPane* sp = appUi->StatusPane();
|
|
132 |
if ( sp )
|
|
133 |
{
|
|
134 |
iNaviControlContainer = static_cast<CAknNavigationControlContainer*>
|
|
135 |
( sp->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );
|
|
136 |
}
|
|
137 |
}
|
|
138 |
}
|
|
139 |
|
|
140 |
_LIT( KPanicText, "CPslnFWBaseView" );
|
|
141 |
__ASSERT_DEBUG( iNaviControlContainer, User::Panic( KPanicText, KErrGeneral ) );
|
|
142 |
|
|
143 |
if ( iNaviControlContainer )
|
|
144 |
{
|
|
145 |
if ( iNaviPaneContext )
|
|
146 |
{
|
|
147 |
iNaviControlContainer->PushL( *iNaviPaneContext );
|
|
148 |
}
|
|
149 |
else
|
|
150 |
{
|
|
151 |
iNaviControlContainer->PushDefaultL();
|
|
152 |
}
|
|
153 |
}
|
|
154 |
PSLN_TRACE_DEBUG("CPslnFWBaseView::SetNaviPaneL END");
|
|
155 |
}
|
|
156 |
|
|
157 |
// ---------------------------------------------------------------------------
|
|
158 |
// CPslnFWBaseView::CreateNaviPaneContextL
|
|
159 |
// ---------------------------------------------------------------------------
|
|
160 |
//
|
|
161 |
EXPORT_C void CPslnFWBaseView::CreateNaviPaneContextL( TInt /*aResourceId*/ )
|
|
162 |
{
|
|
163 |
// Deprecated.
|
|
164 |
}
|
|
165 |
|
|
166 |
// ---------------------------------------------------------------------------
|
|
167 |
// Sets navi_pane decorator.
|
|
168 |
// ---------------------------------------------------------------------------
|
|
169 |
//
|
|
170 |
EXPORT_C void CPslnFWBaseView::SetNaviPaneDecorator(
|
|
171 |
CAknNavigationDecorator* aDecorator )
|
|
172 |
{
|
|
173 |
PSLN_TRACE_DEBUG("CPslnFWBaseView::SetNaviPaneDecorator");
|
|
174 |
iNaviPaneContext = aDecorator;
|
|
175 |
}
|
|
176 |
|
|
177 |
// ---------------------------------------------------------------------------
|
|
178 |
// Sets navi_pane and activates a tab.
|
|
179 |
// ---------------------------------------------------------------------------
|
|
180 |
//
|
|
181 |
EXPORT_C void CPslnFWBaseView::SetNaviPaneL( const TInt aTabLocation )
|
|
182 |
{
|
|
183 |
PSLN_TRACE_DEBUG("CPslnFWBaseView::SetNaviPaneL w/ param BEGIN");
|
|
184 |
if ( !iNaviControlContainer )
|
|
185 |
{
|
|
186 |
CAknViewAppUi* appUi = AppUi();
|
|
187 |
if ( appUi )
|
|
188 |
{
|
|
189 |
CEikStatusPane* sp = appUi->StatusPane();
|
|
190 |
if ( sp )
|
|
191 |
{
|
|
192 |
iNaviControlContainer = static_cast<CAknNavigationControlContainer*>
|
|
193 |
( sp->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );
|
|
194 |
}
|
|
195 |
}
|
|
196 |
}
|
|
197 |
|
|
198 |
if ( iNaviControlContainer )
|
|
199 |
{
|
|
200 |
if ( iNaviPaneContext && ( aTabLocation > 0 ) )
|
|
201 |
{
|
|
202 |
CAknTabGroup* tabGrp = static_cast <CAknTabGroup*>
|
|
203 |
( iNaviPaneContext->DecoratedControl() );
|
|
204 |
tabGrp->SetActiveTabByIndex( aTabLocation );
|
|
205 |
iNaviControlContainer->PushL( *iNaviPaneContext );
|
|
206 |
}
|
|
207 |
else
|
|
208 |
{
|
|
209 |
iNaviControlContainer->PushDefaultL();
|
|
210 |
}
|
|
211 |
}
|
|
212 |
PSLN_TRACE_DEBUG("CPslnFWBaseView::SetNaviPaneL w/ param END");
|
|
213 |
}
|
|
214 |
|
|
215 |
// ---------------------------------------------------------------------------
|
|
216 |
// Activates the view.
|
|
217 |
// ---------------------------------------------------------------------------
|
|
218 |
//
|
|
219 |
EXPORT_C void CPslnFWBaseView::DoActivateL( const TVwsViewId& aPrevViewId,
|
|
220 |
TUid /*aCustomMessageId*/,
|
|
221 |
const TDesC8& /*aCustomMessage*/ )
|
|
222 |
{
|
|
223 |
PSLN_TRACE_DEBUG("CPslnFWBaseView::DoActivateL END");
|
|
224 |
iPrevViewId = aPrevViewId;
|
|
225 |
CAknViewAppUi* appUi = AppUi();
|
|
226 |
if ( !iContainer )
|
|
227 |
{
|
|
228 |
CreateContainerL();
|
|
229 |
if ( appUi )
|
|
230 |
{
|
|
231 |
AppUi()->AddToStackL( *this, iContainer );
|
|
232 |
}
|
|
233 |
iContainer->iListBox->SetListBoxObserver( this );
|
|
234 |
}
|
|
235 |
|
|
236 |
#ifdef RD_CONTROL_PANEL
|
|
237 |
TInt titlePaneResID = KErrNotFound;
|
|
238 |
SetTitlePaneL( titlePaneResID );
|
|
239 |
// Retrieve title pane and set it.
|
|
240 |
CEikStatusPane* sp = iAvkonAppUi->StatusPane();
|
|
241 |
if ( sp )
|
|
242 |
{
|
|
243 |
CAknTitlePane* titlePane = static_cast<CAknTitlePane*>(
|
|
244 |
sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
|
|
245 |
if ( ( titlePaneResID > KErrNone ) && titlePane )
|
|
246 |
{
|
|
247 |
HBufC* titlePaneText = NULL;
|
|
248 |
titlePaneText = StringLoader::LoadLC( titlePaneResID );
|
|
249 |
titlePane->SetTextL( titlePaneText->Des() );
|
|
250 |
CleanupStack::PopAndDestroy( titlePaneText );
|
|
251 |
}
|
|
252 |
}
|
|
253 |
#endif //RD_CONTROL_PANEL
|
|
254 |
|
|
255 |
PSLN_TRACE_DEBUG("CPslnFWBaseView::DoActivateL END");
|
|
256 |
}
|
|
257 |
|
|
258 |
// ---------------------------------------------------------------------------
|
|
259 |
// Deactivates view.
|
|
260 |
// ---------------------------------------------------------------------------
|
|
261 |
//
|
|
262 |
EXPORT_C void CPslnFWBaseView::DoDeactivate()
|
|
263 |
{
|
|
264 |
PSLN_TRACE_DEBUG("CPslnFWBaseView::DoDeactivate BEGIN");
|
|
265 |
if ( iContainer )
|
|
266 |
{
|
|
267 |
CAknViewAppUi* appUi = AppUi();
|
|
268 |
if ( appUi )
|
|
269 |
{
|
|
270 |
appUi->RemoveFromStack( iContainer );
|
|
271 |
}
|
|
272 |
delete iContainer;
|
|
273 |
iContainer = NULL;
|
|
274 |
}
|
|
275 |
PSLN_TRACE_DEBUG("CPslnFWBaseView::DoDeactivate END");
|
|
276 |
}
|
|
277 |
|
|
278 |
// ---------------------------------------------------------------------------
|
|
279 |
// Sets the real tab location of the view.
|
|
280 |
// ---------------------------------------------------------------------------
|
|
281 |
//
|
|
282 |
EXPORT_C void CPslnFWBaseView::SetTabIndex( TInt aMyTabIndex )
|
|
283 |
{
|
|
284 |
if ( iNaviPaneContext &&
|
|
285 |
IsValidLocation( aMyTabIndex ) )
|
|
286 |
{
|
|
287 |
CAknTabGroup* tabGrp = static_cast <CAknTabGroup*>
|
|
288 |
( iNaviPaneContext->DecoratedControl() );
|
|
289 |
if ( tabGrp && ( tabGrp->TabCount() > aMyTabIndex ) )
|
|
290 |
{
|
|
291 |
iMyTabIndex = aMyTabIndex;
|
|
292 |
}
|
|
293 |
}
|
|
294 |
}
|
|
295 |
|
|
296 |
// ---------------------------------------------------------------------------
|
|
297 |
// Gets the real tab location of the view.
|
|
298 |
// ---------------------------------------------------------------------------
|
|
299 |
//
|
|
300 |
EXPORT_C TInt CPslnFWBaseView::GetTabIndex() const
|
|
301 |
{
|
|
302 |
return iMyTabIndex;
|
|
303 |
}
|
|
304 |
|
|
305 |
// ---------------------------------------------------------------------------
|
|
306 |
// Creates container.
|
|
307 |
// ---------------------------------------------------------------------------
|
|
308 |
//
|
|
309 |
EXPORT_C void CPslnFWBaseView::CreateContainerL()
|
|
310 |
{
|
|
311 |
PSLN_TRACE_DEBUG("CPslnFWBaseView::CreateContainerL BEGIN");
|
|
312 |
NewContainerL();
|
|
313 |
iContainer->SetMopParent( this );
|
|
314 |
|
|
315 |
CPslnFWBaseContainer* container = iContainer;
|
|
316 |
iContainer = NULL;
|
|
317 |
CleanupStack::PushL( container );
|
|
318 |
container->ConstructL( ClientRect() );
|
|
319 |
CleanupStack::Pop( container );
|
|
320 |
iContainer = container;
|
|
321 |
PSLN_TRACE_DEBUG("CPslnFWBaseView::CreateContainerL END");
|
|
322 |
}
|
|
323 |
|
|
324 |
// ---------------------------------------------------------------------------
|
|
325 |
// Opens localized resource file from static path.
|
|
326 |
// ---------------------------------------------------------------------------
|
|
327 |
//
|
|
328 |
EXPORT_C void CPslnFWBaseView::OpenLocalizedResourceFileL(
|
|
329 |
const TDesC& aResourceFileName,
|
|
330 |
RConeResourceLoader& aResourceLoader )
|
|
331 |
{
|
|
332 |
PSLN_TRACE_DEBUG("CPslnFWBaseView::OpenLocalizedResourceFileL BEGIN");
|
|
333 |
// Find the resource file:
|
|
334 |
OpenLocalizedResourceFileL(
|
|
335 |
aResourceFileName,
|
|
336 |
aResourceLoader,
|
|
337 |
&KDC_RESOURCE_FILES_DIR );
|
|
338 |
PSLN_TRACE_DEBUG("CPslnFWBaseView::OpenLocalizedResourceFileL END");
|
|
339 |
}
|
|
340 |
|
|
341 |
// ---------------------------------------------------------------------------
|
|
342 |
// Same as above, except this takes resource path from user.
|
|
343 |
// ---------------------------------------------------------------------------
|
|
344 |
//
|
|
345 |
EXPORT_C void CPslnFWBaseView::OpenLocalizedResourceFileL(
|
|
346 |
const TDesC& aResourceFileName,
|
|
347 |
RConeResourceLoader& aResourceLoader,
|
|
348 |
const TDesC* aPath )
|
|
349 |
{
|
|
350 |
PSLN_TRACE_DEBUG("CPslnFWBaseView::OpenLocalizedResourceFileL 2 BEGIN");
|
|
351 |
// Find the resource file:
|
|
352 |
TParse* parse = new (ELeave) TParse;
|
|
353 |
CleanupStack::PushL( parse );
|
|
354 |
parse->Set( aResourceFileName, aPath, NULL );
|
|
355 |
TFileName* fileName = new (ELeave) TFileName( parse->FullName() );
|
|
356 |
CleanupStack::PushL( fileName );
|
|
357 |
|
|
358 |
// Open resource file:
|
|
359 |
aResourceLoader.OpenL( *fileName );
|
|
360 |
|
|
361 |
CleanupStack::PopAndDestroy( 2, parse ); // fileName, parse
|
|
362 |
PSLN_TRACE_DEBUG("CPslnFWBaseView::OpenLocalizedResourceFileL 2 END");
|
|
363 |
}
|
|
364 |
|
|
365 |
// ---------------------------------------------------------------------------
|
|
366 |
// Sets middle softkey label.
|
|
367 |
// ---------------------------------------------------------------------------
|
|
368 |
//
|
|
369 |
EXPORT_C void CPslnFWBaseView::SetMiddleSoftKeyLabelL(
|
|
370 |
const TInt aResourceId, const TInt aCommandId )
|
|
371 |
{
|
|
372 |
PSLN_TRACE_DEBUG("CPslnFWBaseView::SetMiddleSoftKeyLabelL BEGIN");
|
|
373 |
CEikButtonGroupContainer* cbaGroup = Cba();
|
|
374 |
if ( cbaGroup )
|
|
375 |
{
|
|
376 |
HBufC* middleSKText = StringLoader::LoadLC( aResourceId );
|
|
377 |
TPtr mskPtr = middleSKText->Des();
|
|
378 |
cbaGroup->AddCommandToStackL(
|
|
379 |
KPslnMSKControlID,
|
|
380 |
aCommandId,
|
|
381 |
mskPtr );
|
|
382 |
CleanupStack::PopAndDestroy( middleSKText );
|
|
383 |
}
|
|
384 |
PSLN_TRACE_DEBUG("CPslnFWBaseView::SetMiddleSoftKeyLabelL END");
|
|
385 |
}
|
|
386 |
|
|
387 |
// ---------------------------------------------------------------------------
|
|
388 |
// Handles Help command.
|
|
389 |
// ---------------------------------------------------------------------------
|
|
390 |
//
|
|
391 |
EXPORT_C void CPslnFWBaseView::HandleCommandL( TInt aCommand )
|
|
392 |
{
|
|
393 |
CAknViewAppUi* appUi = AppUi();
|
|
394 |
if ( !appUi )
|
|
395 |
{
|
|
396 |
User::Leave( KErrNotFound );
|
|
397 |
}
|
|
398 |
switch( aCommand )
|
|
399 |
{
|
|
400 |
case EAknCmdHelp:
|
|
401 |
case EPslnCmdAppHelp:
|
|
402 |
// launch Help
|
|
403 |
HlpLauncher::LaunchHelpApplicationL(
|
|
404 |
iCoeEnv->WsSession(), appUi->AppHelpContextL());
|
|
405 |
break;
|
|
406 |
default:
|
|
407 |
appUi->HandleCommandL( aCommand );
|
|
408 |
break;
|
|
409 |
}
|
|
410 |
}
|
|
411 |
|
|
412 |
// ---------------------------------------------------------------------------
|
|
413 |
// Set title pane to a view.
|
|
414 |
// ---------------------------------------------------------------------------
|
|
415 |
//
|
|
416 |
EXPORT_C void CPslnFWBaseView::SetTitlePaneL( TInt& /*aResourceId*/ )
|
|
417 |
{
|
|
418 |
// Empty implementation to be overloaded.
|
|
419 |
}
|
|
420 |
|
|
421 |
// ----------------------------------------------------------------------------
|
|
422 |
// Checks that the location is valid.
|
|
423 |
// ----------------------------------------------------------------------------
|
|
424 |
//
|
|
425 |
TBool CPslnFWBaseView::IsValidLocation( const TInt& aLoc ) const
|
|
426 |
{
|
|
427 |
TBool retVal = ETrue;
|
|
428 |
// First location is always forbidden.
|
|
429 |
if ( aLoc == KPslnFWGeneralThemeViewLocation )
|
|
430 |
{
|
|
431 |
retVal = EFalse;
|
|
432 |
}
|
|
433 |
return retVal;
|
|
434 |
}
|
|
435 |
|
|
436 |
//End of File
|