profilesservices/ProfileEngine/WrapperSrc/CProEngEngineImpl.cpp
changeset 68 13e71d907dc3
parent 32 20bd089f4aaa
--- a/profilesservices/ProfileEngine/WrapperSrc/CProEngEngineImpl.cpp	Fri Jun 25 17:09:30 2010 +0800
+++ b/profilesservices/ProfileEngine/WrapperSrc/CProEngEngineImpl.cpp	Thu Nov 04 13:38:47 2010 +0800
@@ -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 );
     }