profilesapplication/Profiles/ProfileApp/SettingsViewSrc/CProfileEngineHandler.cpp
branchRCL_3
changeset 19 cd54903d48da
equal deleted inserted replaced
18:b7fa36b488f8 19:cd54903d48da
       
     1 /*
       
     2 * Copyright (c) 2002 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:  Profile engine handler
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "CProfileEngineHandler.h"
       
    22 
       
    23 #include <MProfileEngineExtended.h>
       
    24 #include <MProfilesNamesArray.h>
       
    25 #include <MProfileName.h>
       
    26 
       
    27 // ============================ MEMBER FUNCTIONS ===============================
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // CProfileEngineHandler::CProfileEngineHandler
       
    31 // C++ default constructor can NOT contain any code, that might leave.
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 CProfileEngineHandler::CProfileEngineHandler()
       
    35     {
       
    36     }
       
    37 
       
    38 // -----------------------------------------------------------------------------
       
    39 // CProfileEngineHandler::ConstructL
       
    40 // Symbian 2nd phase constructor can leave.
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 void CProfileEngineHandler::ConstructL()
       
    44     {
       
    45     // Create the Profile Engine
       
    46     iEngine = CreateProfileEngineExtendedL();
       
    47     // Get a list of profile Id:s
       
    48     ReadIdArrayL();
       
    49     }
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // CProfileEngineHandler::NewL
       
    53 // Two-phased constructor.
       
    54 // -----------------------------------------------------------------------------
       
    55 //
       
    56 EXPORT_C CProfileEngineHandler* CProfileEngineHandler::NewL()
       
    57     {
       
    58     CProfileEngineHandler* self = new( ELeave ) CProfileEngineHandler();
       
    59     CleanupStack::PushL( self );
       
    60     self->ConstructL();
       
    61     CleanupStack::Pop( self );
       
    62     return self;
       
    63     }
       
    64 
       
    65 // Destructor.
       
    66 CProfileEngineHandler::~CProfileEngineHandler()
       
    67     {
       
    68     delete iIdArray;
       
    69     if( iEngine )
       
    70         {
       
    71         iEngine->Release();
       
    72         }
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CProfileEngineHandler::Engine
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 EXPORT_C MProfileEngineExtended* CProfileEngineHandler::Engine() const
       
    80     {
       
    81     return iEngine;
       
    82     }
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // CProfileEngineHandler::ReadIdArrayL
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 EXPORT_C void CProfileEngineHandler::ReadIdArrayL()
       
    89     {
       
    90     MProfilesNamesArray* idArray = iEngine->ProfilesNamesArrayLC();
       
    91     CleanupStack::Pop();
       
    92     delete iIdArray;
       
    93     iIdArray = idArray;
       
    94     }
       
    95 
       
    96 // -----------------------------------------------------------------------------
       
    97 // CProfileEngineHandler::IdArray
       
    98 // -----------------------------------------------------------------------------
       
    99 //
       
   100 EXPORT_C MProfilesNamesArray* CProfileEngineHandler::IdArray() const
       
   101     {
       
   102     return iIdArray;
       
   103     }
       
   104 
       
   105 // -----------------------------------------------------------------------------
       
   106 // CProfileEngineHandler::IdForIndex
       
   107 // -----------------------------------------------------------------------------
       
   108 //
       
   109 EXPORT_C TInt CProfileEngineHandler::IdForIndex( TInt aIndex ) const
       
   110     {
       
   111     return iIdArray->ProfileName( aIndex )->Id();
       
   112     }
       
   113 
       
   114 //  End of File