profilesservices/ProfileEngine/WrapperSrc/CProEngEngineImpl.cpp
changeset 0 8c5d936e5675
child 8 f62c3a3d66b8
equal deleted inserted replaced
-1:000000000000 0:8c5d936e5675
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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:  Implementation of CProEngEngineImpl.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    "CProEngEngineImpl.h"
       
    22 #include    <f32file.h>
       
    23 #include    <MProEngProfile.h>
       
    24 #include    <MProEngProfileNameArray.h>
       
    25 #include    "MProfileEngineExtended.h"
       
    26 #include    "ProfileEngineConstants.h"
       
    27 #include    "CProEngProfileImpl.h"
       
    28 #include    "CProEngToneHandler.h"
       
    29 #include    "CProEngProfileNameArrayImpl.h"
       
    30 
       
    31 // ============================ MEMBER FUNCTIONS ===============================
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // CProEngEngineImpl::CProEngEngineImpl
       
    35 // -----------------------------------------------------------------------------
       
    36 //
       
    37 CProEngEngineImpl::CProEngEngineImpl()
       
    38     {
       
    39     }
       
    40 
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // CProEngEngineImpl::ConstructL
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 void CProEngEngineImpl::ConstructL()
       
    47     {
       
    48     iProfileEngine = CreateProfileEngineExtendedL();
       
    49     iToneHandler = CProEngToneHandler::NewL();
       
    50     }
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // CProEngEngineImpl::ConstructL
       
    54 // -----------------------------------------------------------------------------
       
    55 //
       
    56 void CProEngEngineImpl::ConstructL( RFs& aFs )
       
    57     {
       
    58     iProfileEngine = CreateProfileEngineExtendedL( &aFs );
       
    59     iToneHandler = CProEngToneHandler::NewL();
       
    60     }
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // CProEngEngineImpl::NewL
       
    64 // Two-phased constructor.
       
    65 // -----------------------------------------------------------------------------
       
    66 //
       
    67 CProEngEngineImpl* CProEngEngineImpl::NewL()
       
    68     {
       
    69     CProEngEngineImpl* self = CProEngEngineImpl::NewLC();
       
    70 
       
    71     CleanupStack::Pop( self );
       
    72 
       
    73     return self;
       
    74     }
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // CProEngEngineImpl::NewLC
       
    78 // Two-phased constructor.
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 CProEngEngineImpl* CProEngEngineImpl::NewLC()
       
    82     {
       
    83     CProEngEngineImpl* self = new ( ELeave ) CProEngEngineImpl;
       
    84 
       
    85     CleanupStack::PushL( self );
       
    86     self->ConstructL();
       
    87 
       
    88     return self;
       
    89     }
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // CProEngEngineImpl::NewL
       
    93 // Two-phased constructor.
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 CProEngEngineImpl* CProEngEngineImpl::NewL( RFs& aFs )
       
    97     {
       
    98     CProEngEngineImpl* self = CProEngEngineImpl::NewLC( aFs );
       
    99 
       
   100     CleanupStack::Pop( self );
       
   101 
       
   102     return self;
       
   103     }
       
   104 
       
   105 // -----------------------------------------------------------------------------
       
   106 // CProEngEngineImpl::NewLC
       
   107 // Two-phased constructor.
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 CProEngEngineImpl* CProEngEngineImpl::NewLC( RFs& aFs )
       
   111     {
       
   112     CProEngEngineImpl* self = new ( ELeave ) CProEngEngineImpl;
       
   113 
       
   114     CleanupStack::PushL( self );
       
   115     self->ConstructL( aFs );
       
   116 
       
   117     return self;
       
   118     }
       
   119 
       
   120 // Destructor
       
   121 CProEngEngineImpl::~CProEngEngineImpl()
       
   122     {
       
   123     if( iProfileEngine )
       
   124         {
       
   125         iProfileEngine->Release();
       
   126         }
       
   127     delete iToneHandler;
       
   128     }
       
   129 
       
   130 // -----------------------------------------------------------------------------
       
   131 // CProEngEngineImpl::Release
       
   132 // -----------------------------------------------------------------------------
       
   133 //
       
   134 void CProEngEngineImpl::Release()
       
   135     {
       
   136     delete this;
       
   137     }
       
   138 
       
   139 // -----------------------------------------------------------------------------
       
   140 // CProEngEngineImpl::ActiveProfileLC
       
   141 // -----------------------------------------------------------------------------
       
   142 //
       
   143 MProEngProfile* CProEngEngineImpl::ActiveProfileLC()
       
   144     {
       
   145     return ProfileLC( ActiveProfileId() );
       
   146     }
       
   147 
       
   148 // -----------------------------------------------------------------------------
       
   149 // CProEngEngineImpl::ActiveProfileL
       
   150 // -----------------------------------------------------------------------------
       
   151 //
       
   152 MProEngProfile* CProEngEngineImpl::ActiveProfileL()
       
   153     {
       
   154     MProEngProfile* profileWrapper = ActiveProfileLC();
       
   155 
       
   156     CleanupStack::Pop(); // profileWrapper
       
   157     
       
   158     return profileWrapper;
       
   159     }
       
   160 
       
   161 // -----------------------------------------------------------------------------
       
   162 // CProEngEngineImpl::ActiveProfileId
       
   163 // -----------------------------------------------------------------------------
       
   164 //
       
   165 TInt CProEngEngineImpl::ActiveProfileId()
       
   166     {
       
   167     return iProfileEngine->ActiveProfileId();
       
   168     }
       
   169 
       
   170 // -----------------------------------------------------------------------------
       
   171 // CProEngEngineImpl::ProfileNameArrayLC
       
   172 // -----------------------------------------------------------------------------
       
   173 //
       
   174 MProEngProfileNameArray* CProEngEngineImpl::ProfileNameArrayLC()
       
   175     {
       
   176     MProfilesNamesArray* nameArray = iProfileEngine->ProfilesNamesArrayLC();
       
   177 
       
   178     CProEngProfileNameArrayImpl* nameArrayWrapper =
       
   179         CProEngProfileNameArrayImpl::NewL( nameArray ); // takes ownership
       
   180 
       
   181     CleanupStack::Pop();  // namearray
       
   182     CleanupStack::PushL( nameArrayWrapper );
       
   183 
       
   184     return nameArrayWrapper;
       
   185     }
       
   186 
       
   187 // -----------------------------------------------------------------------------
       
   188 // CProEngEngineImpl::SetActiveProfileL
       
   189 // -----------------------------------------------------------------------------
       
   190 //
       
   191 void CProEngEngineImpl::SetActiveProfileL( TInt aId )
       
   192     {
       
   193     iProfileEngine->SetActiveProfileL( aId );
       
   194     }
       
   195 
       
   196 // -----------------------------------------------------------------------------
       
   197 // CProEngEngineImpl::ProfileLC
       
   198 // -----------------------------------------------------------------------------
       
   199 //
       
   200 MProEngProfile* CProEngEngineImpl::ProfileLC( TInt aId )
       
   201     {
       
   202     return ProfilePrivateLC( aId );
       
   203     }
       
   204 
       
   205 // -----------------------------------------------------------------------------
       
   206 // CProEngEngineImpl::ProfileL
       
   207 // -----------------------------------------------------------------------------
       
   208 //
       
   209 MProEngProfile* CProEngEngineImpl::ProfileL( TInt aId )
       
   210     {
       
   211     MProEngProfile* profileWrapper = ProfileLC( aId );
       
   212 
       
   213     CleanupStack::Pop();  // profileWrapper
       
   214 
       
   215     return profileWrapper;
       
   216     }
       
   217 
       
   218 // -----------------------------------------------------------------------------
       
   219 // CProEngEngineImpl::ProfilePrivateLC
       
   220 // -----------------------------------------------------------------------------
       
   221 //
       
   222 CProEngProfileImpl* CProEngEngineImpl::ProfilePrivateLC( TInt aId )
       
   223     {
       
   224     // This check is needed if the given id belongs to a variated profile which
       
   225     // is not supported by the platform (unfortunately the settings for this
       
   226     // kind of profile always exist in Central Repository):
       
   227     if( !IsDynamicProfileId( aId ) && !iProfileEngine->IsDefaultProfile( aId ) )
       
   228         {
       
   229         User::Leave( KErrNotFound );
       
   230         }
       
   231 
       
   232     MProfileExtended* profile = iProfileEngine->ProfileLC( aId );
       
   233 
       
   234     CProEngProfileImpl* profileWrapper =
       
   235         CProEngProfileImpl::NewL( *this, profile );
       
   236 
       
   237     CleanupStack::Pop(); // profile
       
   238     CleanupStack::PushL( profileWrapper );
       
   239 
       
   240     return profileWrapper;
       
   241     }
       
   242 
       
   243 // -----------------------------------------------------------------------------
       
   244 // CProEngEngineImpl::ProfileEngineExtended
       
   245 // -----------------------------------------------------------------------------
       
   246 //
       
   247 MProfileEngineExtended& CProEngEngineImpl::ProfileEngineExtended()
       
   248     {
       
   249     return *iProfileEngine;
       
   250     }
       
   251 
       
   252 // -----------------------------------------------------------------------------
       
   253 // CProEngEngineImpl::ToneHandler
       
   254 // -----------------------------------------------------------------------------
       
   255 //
       
   256 CProEngToneHandler& CProEngEngineImpl::ToneHandler()
       
   257     {
       
   258     return *iToneHandler;
       
   259     }
       
   260 
       
   261 // -----------------------------------------------------------------------------
       
   262 // CProEngEngineImpl::IsDynamicProfileId
       
   263 // -----------------------------------------------------------------------------
       
   264 //
       
   265 TBool CProEngEngineImpl::IsDynamicProfileId( TInt aId )
       
   266     {
       
   267     return ( ( aId >= KProfileBaseDynamicProfileId ) &&
       
   268              ( aId < ( KProfileBaseDynamicProfileId +
       
   269                        KProfilesMaxNumberOfDynamicProfiles ) ) );
       
   270     }
       
   271 
       
   272 //  End of File
       
   273 
       
   274