profilesservices/ProfileEngine/WrapperSrc/CProEngEngineImpl.cpp
branchRCL_3
changeset 17 3b47783fdf16
parent 12 bdac6c462392
child 20 3b67655da2cc
equal deleted inserted replaced
16:8fcb49b86877 17:3b47783fdf16
    25 #include    <MProfileEngineExtended.h>
    25 #include    <MProfileEngineExtended.h>
    26 #include    <ProfileEngineConstants.h>
    26 #include    <ProfileEngineConstants.h>
    27 #include    "CProEngProfileImpl.h"
    27 #include    "CProEngProfileImpl.h"
    28 #include    "CProEngToneHandler.h"
    28 #include    "CProEngToneHandler.h"
    29 #include    "CProEngProfileNameArrayImpl.h"
    29 #include    "CProEngProfileNameArrayImpl.h"
    30 #include    <ProEngWrapper.rsg>
    30 
    31 #include    <ConeResLoader.h> 
       
    32 #include 	<startupdomainpskeys.h>
       
    33 #include    <StringLoader.h>
       
    34 #include    <AknQueryDialog.h>
       
    35 #include    <aknnotewrappers.h>
       
    36 #include    <barsc.h>  // RResourceFile
       
    37 #include    <bautils.h> // BaflUtils
       
    38 
       
    39 namespace
       
    40 	{
       
    41 	// The filename of the resource file
       
    42 	_LIT( KProEngResourceFileName, "Z:ProEngWrapper.RSC" );
       
    43 	}
       
    44 // ============================ MEMBER FUNCTIONS ===============================
    31 // ============================ MEMBER FUNCTIONS ===============================
    45 
    32 
    46 // -----------------------------------------------------------------------------
    33 // -----------------------------------------------------------------------------
    47 // CProEngEngineImpl::CProEngEngineImpl
    34 // CProEngEngineImpl::CProEngEngineImpl
    48 // -----------------------------------------------------------------------------
    35 // -----------------------------------------------------------------------------
    58 //
    45 //
    59 void CProEngEngineImpl::ConstructL()
    46 void CProEngEngineImpl::ConstructL()
    60     {
    47     {
    61     iProfileEngine = CreateProfileEngineExtendedL();
    48     iProfileEngine = CreateProfileEngineExtendedL();
    62     iToneHandler = CProEngToneHandler::NewL();
    49     iToneHandler = CProEngToneHandler::NewL();
    63 	iFs = new ( ELeave ) RFs;
       
    64     User::LeaveIfError( iFs->Connect() );
       
    65     }
    50     }
    66 
    51 
    67 // -----------------------------------------------------------------------------
    52 // -----------------------------------------------------------------------------
    68 // CProEngEngineImpl::ConstructL
    53 // CProEngEngineImpl::ConstructL
    69 // -----------------------------------------------------------------------------
    54 // -----------------------------------------------------------------------------
   138     if( iProfileEngine )
   123     if( iProfileEngine )
   139         {
   124         {
   140         iProfileEngine->Release();
   125         iProfileEngine->Release();
   141         }
   126         }
   142     delete iToneHandler;
   127     delete iToneHandler;
   143     iFs->Close();
       
   144     delete iFs;
       
   145     }
   128     }
   146 
   129 
   147 // -----------------------------------------------------------------------------
   130 // -----------------------------------------------------------------------------
   148 // CProEngEngineImpl::Release
   131 // CProEngEngineImpl::Release
   149 // -----------------------------------------------------------------------------
   132 // -----------------------------------------------------------------------------
   203 
   186 
   204 // -----------------------------------------------------------------------------
   187 // -----------------------------------------------------------------------------
   205 // CProEngEngineImpl::SetActiveProfileL
   188 // CProEngEngineImpl::SetActiveProfileL
   206 // -----------------------------------------------------------------------------
   189 // -----------------------------------------------------------------------------
   207 //
   190 //
   208 void CProEngEngineImpl::SetActiveProfileL(TInt aId)
   191 void CProEngEngineImpl::SetActiveProfileL( TInt aId )
   209 	{
   192     {
   210 	if ( //  active profile is Off-line
   193     iProfileEngine->SetActiveProfileL( aId );
   211 	( iProfileEngine->ActiveProfileId() == EProfileOffLineId ) &&
   194     }
   212 	// and currently focused profile is not Off-line
       
   213 			( aId != EProfileOffLineId ) )
       
   214 		{
       
   215 
       
   216 		TInt simCStatus( ESimNotPresent );
       
   217 		RProperty simStatus;
       
   218 		User::LeaveIfError( simStatus.Attach(KPSUidStartup, KPSSimStatus ) );
       
   219 		User::LeaveIfError( simStatus.Get( simCStatus ) );
       
   220 		simStatus.Close();
       
   221 
       
   222 		TParse* fp = new ( ELeave ) TParse();
       
   223 		fp->Set( KProEngResourceFileName, &KDC_RESOURCE_FILES_DIR, NULL );
       
   224 		TFileName localizedFileName( fp->FullName() );
       
   225 		delete fp;
       
   226 
       
   227 		BaflUtils::NearestLanguageFile( *iFs, localizedFileName );
       
   228 		RConeResourceLoader resourceLoader( *CCoeEnv::Static() );
       
   229 		TRAP_IGNORE( resourceLoader.OpenL( localizedFileName ) );
       
   230 
       
   231 		if ( simCStatus == ESimNotPresent )
       
   232 			{
       
   233 			// SIM card does not exist.
       
   234 			HBufC* infoNoteText = StringLoader::LoadLC(
       
   235 					R_PROFILE_TEXT_INSERT_SIM );
       
   236 			CAknInformationNote* note = new ( ELeave ) CAknInformationNote( ETrue );
       
   237 			note->ExecuteLD( *infoNoteText );
       
   238 			CleanupStack::PopAndDestroy( infoNoteText );
       
   239 			resourceLoader.Close();	
       
   240 			return;
       
   241 			}
       
   242 		resourceLoader.Close();
       
   243 		}
       
   244 
       
   245 	iProfileEngine->SetActiveProfileL(aId);
       
   246 	}
       
   247 
   195 
   248 // -----------------------------------------------------------------------------
   196 // -----------------------------------------------------------------------------
   249 // CProEngEngineImpl::ProfileLC
   197 // CProEngEngineImpl::ProfileLC
   250 // -----------------------------------------------------------------------------
   198 // -----------------------------------------------------------------------------
   251 //
   199 //