profilesservices/ProfileEngine/WrapperSrc/CProEngEngineImpl.cpp
branchRCL_3
changeset 25 7e0eff37aedb
parent 24 8ee96d21d9bf
--- a/profilesservices/ProfileEngine/WrapperSrc/CProEngEngineImpl.cpp	Tue Aug 31 15:29:50 2010 +0300
+++ b/profilesservices/ProfileEngine/WrapperSrc/CProEngEngineImpl.cpp	Wed Sep 01 12:20:44 2010 +0100
@@ -19,15 +19,28 @@
 
 // INCLUDE FILES
 #include    "CProEngEngineImpl.h"
-#include    "CProEngProfileImpl.h"
-#include    "CProEngToneHandler.h"
-#include    "CProEngProfileNameArrayImpl.h"
 #include    <f32file.h>
 #include    <MProEngProfile.h>
 #include    <MProEngProfileNameArray.h>
 #include    <MProfileEngineExtended.h>
 #include    <ProfileEngineConstants.h>
+#include    "CProEngProfileImpl.h"
+#include    "CProEngToneHandler.h"
+#include    "CProEngProfileNameArrayImpl.h"
+#include    <proengwrapper.rsg>
+#include    <ConeResLoader.h>
+#include 	<startupdomainpskeys.h>
+#include    <StringLoader.h>
+#include    <AknQueryDialog.h>
+#include    <aknnotewrappers.h>
+#include    <barsc.h>  // RResourceFile
+#include    <bautils.h> // BaflUtils
 
+namespace
+	{
+	// The filename of the resource file
+	_LIT( KProEngResourceFileName, "Z:ProEngWrapper.RSC" );
+	}
 // ============================ MEMBER FUNCTIONS ===============================
 
 // -----------------------------------------------------------------------------
@@ -154,7 +167,7 @@
     MProEngProfile* profileWrapper = ActiveProfileLC();
 
     CleanupStack::Pop(); // profileWrapper
-    
+
     return profileWrapper;
     }
 
@@ -190,6 +203,50 @@
 //
 void CProEngEngineImpl::SetActiveProfileL( TInt aId )
     {
+    if ( //  active profile is Off-line
+        ( iProfileEngine->ActiveProfileId() == EProfileOffLineId ) &&
+        // and currently focused profile is not Off-line
+        ( aId != EProfileOffLineId ) )
+        {
+
+        TInt simCStatus( ESimNotPresent );
+        RProperty simStatus;
+        CleanupClosePushL( simStatus );
+		
+        User::LeaveIfError( simStatus.Attach( KPSUidStartup, KPSSimStatus ) );
+        User::LeaveIfError( simStatus.Get( simCStatus ) );
+        CleanupStack::PopAndDestroy();//simStatus
+
+        // SIM card does not exist.
+        if ( simCStatus == ESimNotPresent )
+            {				
+            TParse* fp = new ( ELeave ) TParse();
+            fp->Set( KProEngResourceFileName, &KDC_RESOURCE_FILES_DIR, NULL );
+            TFileName localizedFileName( fp->FullName() );
+            delete fp;
+			
+            RFs fs;
+            User::LeaveIfError( fs.Connect() );
+            CleanupClosePushL( fs );	
+			
+            BaflUtils::NearestLanguageFile( fs, localizedFileName );
+			
+            RConeResourceLoader resourceLoader( *CCoeEnv::Static() );
+            CleanupClosePushL( resourceLoader );
+			
+            TRAP_IGNORE( resourceLoader.OpenL( localizedFileName ) );
+			
+            HBufC* infoNoteText = StringLoader::LoadLC(
+					R_PROFILE_TEXT_INSERT_SIM );
+            CAknInformationNote* note = new ( ELeave ) CAknInformationNote( ETrue );
+            note->ExecuteLD( *infoNoteText );
+			
+            CleanupStack::PopAndDestroy( infoNoteText );
+            CleanupStack::PopAndDestroy( 2 ); //resourceLoader&fs
+			
+            return;
+            }	
+        }
     iProfileEngine->SetActiveProfileL( aId );
     }