|
Nokia N97 SDK Example Applications Guide |
1. About this Example
2. Architecture
3. Design and Implementation
The build configuration files are placed in the group folder and the packaging files are placed in the sis folder.
Here's an example command for building the project in command line window.
..\group>bldmake bldfiles ..\group>abld build
First the framework creates the CDirectoryLocalizerExUi object by calling its ConstructL method, The fact that the framework calls the CDirectoryLocalizerExUi object's constructor and ConstructL separately allows the framework to complete any necessary initialisation before the construction of CDirectoryLocalizerExUi object is completed.
void CDirectoryLocalizerExAppUi::ConstructL() { BaseConstructL(); iAppContainer = new (ELeave) CDirectoryLocalizerExContainer(); iAppContainer->SetMopParent( this ); iAppContainer->ConstructL( ClientRect()); AddToStackL( iAppContainer ); };
a) When the user selects a menu item in the example application, HandleCommandL method is called by the framework. The input argument for this method, aCommand, indicates which command the user has selected. Then the AppUI can perform corresponding actions to do the localizer initialisation or retrieving localized data.
void CDirectoryLocalizerExAppUi::HandleCommandL( TInt aCommand ) { switch ( aCommand ) { case EDirLocalizerAddFromResId: { iAppContainer->LocalizedFromResIdL(); break; } case EDirLocalizerSetupFromResRd: { iAppContainer->SetupFromResRdL(); break; } case EDirLocalizerSetupFromResId: { iAppContainer->SetupFromResIdL(); break; } case EDirLocalizerGetExtraData: { iAppContainer->GetExtraDataL(); break; } case EDirLocalizerGetIconIndex: { iAppContainer->GetIconIndexL(); break; } case EAknSoftkeyExit: case EEikCmdExit: { Exit(); return; } default: break; } }
b) After a menu item is selected by user, the CDirectoryLocalizerExUi will invoke the different function of the container, the CDirectoryLocalizerExContainer then initializes the CDirectoryLocalizer instance from resource structure with different method.
LocalizedFromResIdL() function constructs from default construction, and load Directory data from resource via ID as the following,
CDirectoryLocalizer* localizer = CDirectoryLocalizer::NewL();
CleanupStack::PushL(localizer); // localizer
localizer->AddFromResourceL( R_EXAMPLE_LOCALIZER_ENTRIES );
Where R_EXAMPLE_LOCALIZER_ENTRIES is defined in the RSS file.
SetupFromResRdL() function will initialize the CDirectoryLocalizer instance via an instance of TResourceReader, The reader will read directory data from resource file, as the following,
TResourceReader reader;
CCoeEnv::Static()->CreateResourceReaderLC( reader, R_EXAMPLE_LOCALIZER_ENTRIES );
CDirectoryLocalizer* localizer = CDirectoryLocalizer::NewL( reader );
CleanupStack::PushL(localizer); // localizer
SetupFromResIdL() function will initialize CDirectoryLocalizer instance by resource ID directly as the following,
CDirectoryLocalizer* localizer = CDirectoryLocalizer::NewL( R_EXAMPLE_LOCALIZER_ENTRIES );
CleanupStack::PushL(localizer); // localizer
c) After the CDirectoryLocalizer instance initialisation, an absolute path will be set to the CDirectoryLocalizer instance. And if the path has been localized, the localized name will be retrieved and showed by AknInformationNote.
localizer->SetFullPath( KDLTestExistsDir ); TBool success = localizer->IsLocalized(); CAknInformationNote *note = new ( ELeave ) CAknInformationNote(); if( success ) { const TPtrC strNote = localizer->LocalizedName(); note->ExecuteLD( strNote ); } else { _LIT( strNote, "Not Localized" ); note->ExecuteLD( strNote ); } CleanupStack::PopAndDestroy(); // localizer
d) The instance of CDirectoryLocalizer can also retrieve the extra data and icon index after the initialisation and localization, for example:
const TPtrC strNote = localizer->ExtraData();
TInt iconIndex = localizer->Icon();
|
© Nokia 2009 |