Example Application Guide

- Main Page
- Classes
- Files

# geoprofileselector.cpp

    00001 /*
    00002 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
    00003 * All rights reserved.
    00004 * This component and the accompanying materials are made available
    00005 * under the terms of the License "Eclipse Public License v1.0"
    00006 * which accompanies this distribution, and is available
    00007 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    00008 *
    00009 * Initial Contributors:
    00010 * Nokia Corporation - initial contribution.
    00011 *
    00012 * Contributors:
    00013 *
    00014 * Description:  Geo Profile selector
    00015 *
    00016 */
    00017
    00018
    00019 // SYSTEM INCLUDES
    00020 #include <BADESCA.H>
    00021 #include <stringloader.h>
    00022 #include <aknlistquerydialog.h>
    00023 #include <aknpopupheadingpane.h>
    00024 #include <geoprofilesui.rsg>
    00025 #include <ProEngFactory.h>
    00026 #include <mproengengine.h>
    00027 #include <mproengprofilenamearray.h>
    00028
    00029
    00030 // USER INCLUDES
    00031 #include "geoprofileselector.h"
    00032
    00033 // CONSTANT DEFINTION
    00034 _LIT( KTab, "\t" );
    00035
    00036 // ---------------------------------------------------------------------------
    00037 // CGeoProfileSelector::CGeoProfileSelector
    00038 // ---------------------------------------------------------------------------
    00039 //
    00040 CGeoProfileSelector::CGeoProfileSelector()
    00041     {
    00042     }
    00043
    00044 // ---------------------------------------------------------------------------
    00045 // CGeoProfileSelector::~CGeoProfileSelector
    00046 // ---------------------------------------------------------------------------
    00047 //
    00048 CGeoProfileSelector::~CGeoProfileSelector()
    00049     {
    00050     delete iProfilePopupTitle;
    00051     }
    00052
    00053 // ---------------------------------------------------------------------------
    00054 // CGeoProfileSelector::NewL
    00055 // ---------------------------------------------------------------------------
    00056 //
    00057 CGeoProfileSelector* CGeoProfileSelector::NewLC()
    00058     {
    00059     CGeoProfileSelector* self = new ( ELeave ) CGeoProfileSelector();
    00060     CleanupStack::PushL( self );
    00061     self->ConstructL();
    00062     return self;
    00063     }
    00064
    00065 // ---------------------------------------------------------------------------
    00066 // CGeoProfileSelector::ConstructL
    00067 // ---------------------------------------------------------------------------
    00068 //
    00069 void CGeoProfileSelector::ConstructL()
    00070     {
    00071     // Allocate the Title text
    00072     iProfilePopupTitle = NULL;
    00073     }
    00074
    00075 // ---------------------------------------------------------------------------
    00076 // void CGeoProfileSelector::SelectGeoProfileL
    00077 // ---------------------------------------------------------------------------
    00078 //
    00079 TInt CGeoProfileSelector::SelectGeoProfileL( TInt&    aProfileId )
    00080     {
    00081     TInt retVal = KErrCancel;
    00082
    00083     // Index for profile selection
    00084     TInt index = 0;
    00085
    00086     // Load the Title text
    00087     HBufC* title = StringLoader::LoadLC( R_LBL_GEOPROFILES_PROFILE );
    00088
    00089     // Obtain the list of profiles
    00090     MProEngEngine* profileEng = ProEngFactory::NewEngineL();
    00091     CleanupReleasePushL( *profileEng );
    00092
    00093     MProEngProfileNameArray* profileNames = profileEng->ProfileNameArrayLC();
    00094
    00095     // Create the list Query Dialog
    00096     CAknListQueryDialog* placeQuery = new( ELeave ) CAknListQueryDialog( &index );
    00097     placeQuery->PrepareLC( R_GEOPROFILES_LIST_QUERY );
    00098
    00099     // Assign Title Text
    00100     CAknPopupHeadingPane *  heading = placeQuery->QueryHeading();
    00101     if( heading )
    00102         {
    00103         heading->SetTextL( *title );
    00104         }
    00105
    00106     // Descriptor array
    00107     CDesCArrayFlat* array = new ( ELeave ) CDesCArrayFlat( 4 );
    00108     CleanupStack::PushL( array );
    00109
    00110     HBufC* profileName = HBufC::NewLC( 256 );
    00111     TPtr profileNamePtr = profileName->Des();
    00112
    00113     for ( TInt i = 0; i < profileNames->MdcaCount(); i++ )
    00114         {
    00115         profileNamePtr.Zero();
    00116         profileNamePtr.Append( KTab );
    00117         profileNamePtr.Append( profileNames->MdcaPoint( i ));
    00118
    00119         array->AppendL( *profileName );
    00120         }
    00121
    00122     // Cleanup the profile Name buffer
    00123     CleanupStack::PopAndDestroy( profileName );
    00124
    00125     // Assign the Item text array
    00126     placeQuery->SetItemTextArray( array );
    00127     placeQuery->SetOwnershipType(  ELbmOwnsItemArray );
    00128     CleanupStack::Pop( array );
    00129
    00130     if ( placeQuery->RunLD())
    00131         {
    00132         retVal = KErrNone;
    00133
    00134         // Obtain the Profile Name and Profile ID at index
    00135         aProfileId = profileNames->ProfileId( index );
    00136         }
    00137
    00138     CleanupStack::PopAndDestroy( 3, title );
    00139     return retVal;
    00140     }

© Nokia 2009 |