54
|
1 |
/*
|
|
2 |
* Copyright (c) 2005 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: Main View.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include <gsmainview.h>
|
|
21 |
#include "GSMainContainer.h"
|
|
22 |
#include "GsLogger.h"
|
|
23 |
#include "gsplugininterface.h"
|
|
24 |
#include "GSDocument.h"
|
|
25 |
#include "GSUi.h"
|
|
26 |
#include <gsapp.rsg>
|
|
27 |
#include <gsfwviewuids.h>
|
|
28 |
|
|
29 |
#include <aknlists.h>
|
|
30 |
#include <ConeResLoader.h>
|
|
31 |
#include <featmgr.h>
|
|
32 |
#include <akntitle.h>
|
|
33 |
#include <bautils.h> // Localization
|
|
34 |
#include <hlplch.h>
|
|
35 |
#include <gscommon.hrh>
|
|
36 |
#include <gfxtranseffect/gfxtranseffect.h>
|
|
37 |
#include <layoutmetadata.cdl.h>
|
|
38 |
|
|
39 |
// ========================= MEMBER FUNCTIONS ================================
|
|
40 |
|
|
41 |
// ---------------------------------------------------------------------------
|
|
42 |
// CGSMainView::CGSMainView
|
|
43 |
// C++ constructor.
|
|
44 |
//
|
|
45 |
// ---------------------------------------------------------------------------
|
|
46 |
//
|
|
47 |
CGSMainView::CGSMainView()
|
|
48 |
: iResourceLoader( *iCoeEnv )
|
|
49 |
{
|
|
50 |
}
|
|
51 |
|
|
52 |
|
|
53 |
// ---------------------------------------------------------------------------
|
|
54 |
// CGSMainView::NewL()
|
|
55 |
// Symbian OS two-phased constructor.
|
|
56 |
//
|
|
57 |
// ---------------------------------------------------------------------------
|
|
58 |
//
|
|
59 |
CGSMainView* CGSMainView::NewL()
|
|
60 |
{
|
|
61 |
CGSMainView* self = NewLC();
|
|
62 |
CleanupStack::Pop( self );
|
|
63 |
return self;
|
|
64 |
}
|
|
65 |
|
|
66 |
|
|
67 |
// ---------------------------------------------------------------------------
|
|
68 |
// CGSMainView::NewLC()
|
|
69 |
// Symbian OS two-phased constructor.
|
|
70 |
//
|
|
71 |
// ---------------------------------------------------------------------------
|
|
72 |
//
|
|
73 |
CGSMainView* CGSMainView::NewLC()
|
|
74 |
{
|
|
75 |
CGSMainView* self = new( ELeave ) CGSMainView();
|
|
76 |
CleanupStack::PushL( self );
|
|
77 |
self->ConstructL();
|
|
78 |
return self;
|
|
79 |
}
|
|
80 |
|
|
81 |
|
|
82 |
// ---------------------------------------------------------------------------
|
|
83 |
// CGSMainView::ConstructL(const TRect& aRect)
|
|
84 |
// Symbian OS default constuctor.
|
|
85 |
//
|
|
86 |
// ---------------------------------------------------------------------------
|
|
87 |
//
|
|
88 |
void CGSMainView::ConstructL()
|
|
89 |
{
|
|
90 |
__GSLOGSTRING( "[CGSMainView] ConstructL()" );
|
|
91 |
iAppUi = AppUi();
|
|
92 |
|
|
93 |
OpenLocalizedResourceFileL( KGSMainViewResourceFileName );
|
|
94 |
BaseConstructL( R_GS_MAIN_VIEW );
|
|
95 |
|
|
96 |
iPluginArray = new CArrayPtrFlat<CGSPluginInterface>( 10 );
|
|
97 |
|
|
98 |
iPluginLoader = CGSPluginLoader::NewL( iAppUi );
|
|
99 |
iPluginLoader->SetObserver( this );
|
|
100 |
iPluginLoader->LoadAsyncL( KGSPluginInterfaceUid, KGSMainViewUid,
|
|
101 |
iPluginArray );
|
|
102 |
iPosition.Reset();
|
|
103 |
}
|
|
104 |
|
|
105 |
|
|
106 |
// ---------------------------------------------------------------------------
|
|
107 |
// CGSMainView::~CGSMainView()
|
|
108 |
// Destructor
|
|
109 |
//
|
|
110 |
// ---------------------------------------------------------------------------
|
|
111 |
//
|
|
112 |
CGSMainView::~CGSMainView()
|
|
113 |
{
|
|
114 |
__GSLOGSTRING( "[CGSMainView] ~CGSMainView" );
|
|
115 |
if ( iPluginLoader )
|
|
116 |
{
|
|
117 |
delete iPluginLoader;
|
|
118 |
}
|
|
119 |
|
|
120 |
if ( iPluginArray )
|
|
121 |
{
|
|
122 |
// Since the plugins are actually avkon views, avkon is responsible
|
|
123 |
// for owning the plugins. This means we do not reset and destroy
|
|
124 |
// the contents of the array in which the plugins reside. We have to
|
|
125 |
// leave it up to avkon to tidy up.
|
|
126 |
delete iPluginArray;
|
|
127 |
}
|
|
128 |
|
|
129 |
iResourceLoader.Close();
|
|
130 |
|
|
131 |
if( iContainer && iAppUi )
|
|
132 |
{
|
|
133 |
iAppUi->RemoveFromViewStack( *this, iContainer );
|
|
134 |
delete iContainer;
|
|
135 |
}
|
|
136 |
}
|
|
137 |
|
|
138 |
|
|
139 |
// ---------------------------------------------------------------------------
|
|
140 |
// TUid CGSMainView::OpenLocalizedResourceFileL()
|
|
141 |
//
|
|
142 |
//
|
|
143 |
// ---------------------------------------------------------------------------
|
|
144 |
//
|
|
145 |
void CGSMainView::OpenLocalizedResourceFileL( const TDesC& aResourceFileName )
|
|
146 |
{
|
|
147 |
RFs &fsSession = CCoeEnv::Static()->FsSession();
|
|
148 |
|
|
149 |
// Find the resource file
|
|
150 |
TParse parse;
|
|
151 |
parse.Set( aResourceFileName, &KDC_APP_RESOURCE_DIR, NULL );
|
|
152 |
TFileName fileName( parse.FullName() );
|
|
153 |
|
|
154 |
// Get language of resource file
|
|
155 |
BaflUtils::NearestLanguageFile( fsSession, fileName );
|
|
156 |
|
|
157 |
// Open resource file
|
|
158 |
iResourceLoader.OpenL( fileName );
|
|
159 |
}
|
|
160 |
|
|
161 |
|
|
162 |
// ---------------------------------------------------------------------------
|
|
163 |
// TUid CGSMainView::Id()
|
|
164 |
//
|
|
165 |
//
|
|
166 |
// ---------------------------------------------------------------------------
|
|
167 |
//
|
|
168 |
TUid CGSMainView::Id() const
|
|
169 |
{
|
|
170 |
return KGSMainViewUid;
|
|
171 |
}
|
|
172 |
|
|
173 |
|
|
174 |
// ---------------------------------------------------------------------------
|
|
175 |
// CGSMainView::DoActivateL()
|
|
176 |
//
|
|
177 |
//
|
|
178 |
// ---------------------------------------------------------------------------
|
|
179 |
//
|
|
180 |
void CGSMainView::DoActivateL( const TVwsViewId& /*aPrevViewId*/,
|
|
181 |
TUid /*aCustomMessageId*/,
|
|
182 |
const TDesC8& /*aCustomMessage*/ )
|
|
183 |
{
|
|
184 |
__GSLOGSTRING( "[CGSMainView] DoActivateL()" );
|
|
185 |
|
|
186 |
iPluginLoader->RequestPriority( CActive::EPriorityHigh );
|
|
187 |
|
|
188 |
if( iContainer )
|
|
189 |
{
|
|
190 |
iAppUi->RemoveFromViewStack( *this, iContainer );
|
|
191 |
delete iContainer;
|
|
192 |
iContainer = NULL;
|
|
193 |
}
|
|
194 |
NewContainerL();
|
|
195 |
|
|
196 |
// Set the empty text of list box
|
|
197 |
_LIT( KEmptyText, "" );
|
|
198 |
TBuf<1> empty( KEmptyText );
|
|
199 |
iContainer->SetListBoxEmptyTextL( empty );
|
|
200 |
|
|
201 |
// Do this to update listbox from already existing iPluginArray.
|
|
202 |
iContainer->UpdateListBoxL();
|
|
203 |
if ( iPosition.iCurrentItemIndex != -1 )
|
|
204 |
{
|
|
205 |
if ( iIsLandscapeOrientation == Layout_Meta_Data::IsLandscapeOrientation() )
|
|
206 |
{
|
|
207 |
iContainer->RestoreListBoxPositionL( iPosition, EFalse );
|
|
208 |
}
|
|
209 |
else
|
|
210 |
{
|
|
211 |
iContainer->RestoreListBoxPositionL( iPosition, ETrue );
|
|
212 |
}
|
|
213 |
}
|
|
214 |
iAppUi->AddToViewStackL( *this, iContainer );
|
|
215 |
// Navigating to main view will reset all child plugin selected indexes:
|
|
216 |
for( TInt i = 0; i < iPluginArray->Count(); i++ )
|
|
217 |
{
|
|
218 |
CGSPluginInterface* plugin = iPluginArray->operator[]( i );
|
|
219 |
plugin->ResetSelectedItemIndex();
|
|
220 |
}
|
|
221 |
GfxTransEffect::EndFullScreen();
|
|
222 |
}
|
|
223 |
|
|
224 |
|
|
225 |
// ---------------------------------------------------------------------------
|
|
226 |
// CGSMainView::DoDeactivate()
|
|
227 |
//
|
|
228 |
//
|
|
229 |
// ---------------------------------------------------------------------------
|
|
230 |
//
|
|
231 |
void CGSMainView::DoDeactivate()
|
|
232 |
{
|
|
233 |
__GSLOGSTRING( "[CGSMainView] DoDeactivate()" );
|
|
234 |
|
|
235 |
iPluginLoader->RequestPriority( CActive::EPriorityLow );
|
|
236 |
|
|
237 |
if ( iContainer )
|
|
238 |
{
|
|
239 |
|
|
240 |
iPosition.Reset();
|
|
241 |
TRAPD( err, iContainer->StoreListBoxPositionL( iPosition ) );
|
|
242 |
iIsLandscapeOrientation = Layout_Meta_Data::IsLandscapeOrientation();
|
|
243 |
iAppUi->RemoveFromViewStack(*this, iContainer);
|
|
244 |
delete iContainer;
|
|
245 |
iContainer = NULL;
|
|
246 |
}
|
|
247 |
}
|
|
248 |
|
|
249 |
|
|
250 |
// ---------------------------------------------------------------------------
|
|
251 |
// CGSMainView::NewContainerL()
|
|
252 |
//
|
|
253 |
//
|
|
254 |
// ---------------------------------------------------------------------------
|
|
255 |
//
|
|
256 |
void CGSMainView::NewContainerL()
|
|
257 |
{
|
|
258 |
iContainer = new( ELeave ) CGSMainContainer;
|
|
259 |
iContainer->SetMopParent( this );
|
|
260 |
|
|
261 |
TRAPD(
|
|
262 |
error,
|
|
263 |
iContainer->ConstructL( ClientRect() , AppUi(), iPluginArray ) );
|
|
264 |
|
|
265 |
if ( error )
|
|
266 |
{
|
|
267 |
delete iContainer;
|
|
268 |
iContainer = NULL;
|
|
269 |
User::Leave( error );
|
|
270 |
}
|
|
271 |
}
|
|
272 |
|
|
273 |
|
|
274 |
// ---------------------------------------------------------------------------
|
|
275 |
// TUid CGSMainView::HandleCommandL()
|
|
276 |
//
|
|
277 |
//
|
|
278 |
// ---------------------------------------------------------------------------
|
|
279 |
//
|
|
280 |
void CGSMainView::HandleCommandL( TInt aCommand )
|
|
281 |
{
|
|
282 |
__GSLOGSTRING1( "[CGSMainView] HandleCommandL(%d)", aCommand );
|
|
283 |
|
|
284 |
switch ( aCommand )
|
|
285 |
{
|
|
286 |
case EGSCmdAppOpen:
|
|
287 |
case EAknSoftkeyOpen:
|
|
288 |
if( iContainer )
|
|
289 |
{
|
|
290 |
CGSPluginInterface* plugin = iContainer->SelectedPlugin();
|
|
291 |
if ( plugin )
|
|
292 |
{
|
|
293 |
switch (plugin->ItemType())
|
|
294 |
{
|
|
295 |
// In these cases the plugin is a view:
|
|
296 |
case EGSItemTypeSingleLarge:
|
|
297 |
case EGSItemTypeSetting:
|
|
298 |
case EGSItemTypeSettingIcon:
|
|
299 |
iAppUi->ActivateLocalViewL(plugin->Id());
|
|
300 |
break;
|
|
301 |
// In these cases the plugin is a dialog:
|
|
302 |
case EGSItemTypeSettingDialog:
|
|
303 |
case EGSItemTypeSingleLargeDialog:
|
|
304 |
plugin->HandleSelection(EGSSelectionByMenu);
|
|
305 |
break;
|
|
306 |
}
|
|
307 |
}
|
|
308 |
}
|
|
309 |
break;
|
|
310 |
case EAknCmdHelp:
|
|
311 |
{
|
|
312 |
if( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
|
|
313 |
{
|
|
314 |
HlpLauncher::LaunchHelpApplicationL(
|
|
315 |
iEikonEnv->WsSession(), iAppUi->AppHelpContextL() );
|
|
316 |
}
|
|
317 |
break;
|
|
318 |
}
|
|
319 |
default:
|
|
320 |
iAppUi->HandleCommandL( aCommand );
|
|
321 |
break;
|
|
322 |
}
|
|
323 |
}
|
|
324 |
|
|
325 |
|
|
326 |
// ---------------------------------------------------------------------------
|
|
327 |
// TUid CGSMainView::HandlePluginLoaded()
|
|
328 |
//
|
|
329 |
//
|
|
330 |
// ---------------------------------------------------------------------------
|
|
331 |
//
|
|
332 |
void CGSMainView::HandlePluginLoaded( KGSPluginLoaderStatus aStatus )
|
|
333 |
{
|
|
334 |
__GSLOGSTRING1( "[CGSMainView::HandlePluginLoaded] aStatus:%d", aStatus );
|
|
335 |
|
|
336 |
switch( aStatus )
|
|
337 |
{
|
|
338 |
case MGSPluginLoadObserver::EGSSuccess:
|
|
339 |
// Should not update each time when plugin is loaded, only when
|
|
340 |
// finished loading spesific view plugins?
|
|
341 |
break;
|
|
342 |
case MGSPluginLoadObserver::EGSFinished:
|
|
343 |
if( iContainer )
|
|
344 |
{
|
|
345 |
TRAPD( err,
|
|
346 |
iContainer->UpdateListBoxL(); )
|
|
347 |
if( err != KErrNone )
|
|
348 |
{
|
|
349 |
__GSLOGSTRING1(
|
|
350 |
"[CGSMainView] Error updating listbox: %d",
|
|
351 |
err );
|
|
352 |
}
|
|
353 |
}
|
|
354 |
break;
|
|
355 |
default:
|
|
356 |
break;
|
|
357 |
}
|
|
358 |
|
|
359 |
}
|
|
360 |
|
|
361 |
|
|
362 |
// ---------------------------------------------------------------------------
|
|
363 |
// CGSMainView::TransferDynamicPluginL()
|
|
364 |
//
|
|
365 |
//
|
|
366 |
// ---------------------------------------------------------------------------
|
|
367 |
//
|
|
368 |
void CGSMainView::TransferDynamicPluginL( CGSPluginInterface* aPlugin )
|
|
369 |
{
|
|
370 |
__GSLOGSTRING1( "[CGSMainView] CGSMainView::TransferDynamicPluginL() - plugin id: 0x%x added to appUi.", aPlugin->Id() );
|
|
371 |
|
|
372 |
CleanupStack::PushL( aPlugin );
|
|
373 |
iAppUi->AddViewL( aPlugin );
|
|
374 |
CleanupStack::Pop( aPlugin );
|
|
375 |
|
|
376 |
// Add to the overall plugin array for this parent plugin
|
|
377 |
iPluginArray->AppendL( aPlugin );
|
|
378 |
|
|
379 |
// Resort the plugins so that they are in order
|
|
380 |
iPluginLoader->SortPluginsL( iPluginArray );
|
|
381 |
|
|
382 |
// Update the listbox with the new information
|
|
383 |
HandlePluginLoaded( MGSPluginLoadObserver::EGSSuccess );
|
|
384 |
}
|
|
385 |
|
|
386 |
|
|
387 |
// ------------------------------------------------- --------------------------
|
|
388 |
// TUid CGSMainView::TabbedViews()
|
|
389 |
//
|
|
390 |
//
|
|
391 |
// ---------------------------------------------------------------------------
|
|
392 |
//
|
|
393 |
CArrayPtrFlat<CGSPluginInterface>* CGSMainView::TabbedViews()
|
|
394 |
{
|
|
395 |
return iPluginArray;
|
|
396 |
}
|
|
397 |
|
|
398 |
|
|
399 |
// -----------------------------------------------------------------------------
|
|
400 |
// CGSMainView::TabChangedL()
|
|
401 |
//
|
|
402 |
//
|
|
403 |
// -----------------------------------------------------------------------------
|
|
404 |
//
|
|
405 |
void CGSMainView::TabChangedL( TUid selectedTabUid )
|
|
406 |
{
|
|
407 |
// Update selected item because changing tab in main view's children
|
|
408 |
// affects also main view's selected item:
|
|
409 |
iSelectedPluginUid = selectedTabUid;
|
|
410 |
}
|
|
411 |
|
|
412 |
|
|
413 |
// -----------------------------------------------------------------------------
|
|
414 |
// CGSMainView::UpdateView()
|
|
415 |
//
|
|
416 |
//
|
|
417 |
// -----------------------------------------------------------------------------
|
|
418 |
//
|
|
419 |
void CGSMainView::UpdateView()
|
|
420 |
{
|
|
421 |
TRAP_IGNORE( iContainer->UpdateListBoxL() );
|
|
422 |
}
|
|
423 |
|
|
424 |
|
|
425 |
// -----------------------------------------------------------------------------
|
|
426 |
// CGSMainView::DynInitMenuPaneL()
|
|
427 |
//
|
|
428 |
// dynamically handle help item if not supported
|
|
429 |
// -----------------------------------------------------------------------------
|
|
430 |
//
|
|
431 |
void CGSMainView::DynInitMenuPaneL( TInt aResourceId,
|
|
432 |
CEikMenuPane* aMenuPane )
|
|
433 |
{
|
|
434 |
if( aResourceId == R_GS_MENU_ITEM_HELP )
|
|
435 |
{
|
|
436 |
User::LeaveIfNull( aMenuPane );
|
|
437 |
|
|
438 |
if ( FeatureManager::FeatureSupported( KFeatureIdHelp ))
|
|
439 |
{
|
|
440 |
aMenuPane->SetItemDimmed( EAknCmdHelp, EFalse );
|
|
441 |
}
|
|
442 |
else
|
|
443 |
{
|
|
444 |
aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue );
|
|
445 |
}
|
|
446 |
}
|
|
447 |
}
|
|
448 |
|
|
449 |
//End of File
|