satengine/SatServer/Engine/src/CSatCommandContainer.cpp
branchRCL_3
changeset 19 7d48bed6ce0c
parent 8 ba42c4bd84dd
child 20 987c9837762f
--- a/satengine/SatServer/Engine/src/CSatCommandContainer.cpp	Thu Aug 19 10:28:14 2010 +0300
+++ b/satengine/SatServer/Engine/src/CSatCommandContainer.cpp	Tue Aug 31 15:45:17 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies). 
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -20,12 +20,12 @@
 #include    <f32file.h>
 #include    <barsc.h>
 #include    <bautils.h>
-#include    <SatServer.rsg>
 #include    <ecom.h>
 #include    <e32property.h>
 #include    <data_caging_path_literals.hrh>
 #include    <startupdomainpskeys.h>
 #include    <satdomainpskeys.h>
+#include    <hbtextresolversymbian.h>
 
 #include    "MSatSystemState.h"
 #include    "TSatSystemStateFactory.h"
@@ -52,21 +52,44 @@
 #include    "csatmultimodeapi.h"
 #include    "csatsactivewrapper.h"
 
-// Drive letter for resource file
-_LIT( KResourceDrive, "Z:" );
-// SatServer's resource file
-_LIT( KSatServerRsc, "SatServer.rsc" );
-
+_LIT( KResourceDrive, "z:\\resource\\qt\\translations" );
+_LIT( KSatServerRsc, "satapp_");
+_LIT( KSatLogTitle, "txt_simatk_title_sim_services");
+_LIT( KSatCmccTitle, "txt_simatk_titlw_cmcc_sim_services");
 
 const TUid KSatInterfaceDefinitionUid = { 0x1000f001 };
 const TInt KSizeOfBuf = 50;
 
-const TInt8 KCreateSatAppNamePop( 2 );
 
 // Important plugins UIDs. These are started on startup
 // Implementation UID is from the <plugin>.rss
 const TUid KSetUpEventListUid = { 0x10202993 };
 
+// ======== LOCAL FUNCTIONS ========
+
+// -----------------------------------------------------------------------------
+// CleanupPointerArray
+// Cleanup RPointerArray objects by using the cleanup stack. Function will be 
+// called when application leaves while a RPointerArray object still alive, 
+// or when CleanupStack::PopAndDestroy is explicitly called to release a 
+// RPointerArray. See CleanupStack::PushL( TCleanupItem ) for more details.
+// -----------------------------------------------------------------------------
+//
+static void CleanupPointerArray( TAny* aArray )
+    {
+    LOG2( NORMAL, "SATENGINE: CSatCommandContainer::CleanupPointerArray \
+        calling array = 0x%08x", aArray )
+    
+    RImplInfoPtrArray* array = reinterpret_cast<RImplInfoPtrArray*>( aArray );
+    if ( array )
+        {
+        array->ResetAndDestroy();
+        }
+    
+    LOG( NORMAL, "SATENGINE: CSatCommandContainer::CleanupPointerArray \
+        exiting" )
+    }
+
 // ======== MEMBER FUNCTIONS ========
 
 // -----------------------------------------------------------------------------
@@ -158,6 +181,8 @@
              in startup phase" )
         // Create command handlers.
         RImplInfoPtrArray satCommandImplementations;
+        CleanupStack::PushL( 
+            TCleanupItem( CleanupPointerArray, &satCommandImplementations ) );
         REComSession::ListImplementationsL( KSatInterfaceDefinitionUid,
             satCommandImplementations );
 
@@ -196,7 +221,7 @@
                     }
                 }
             }
-        satCommandImplementations.ResetAndDestroy();
+        CleanupStack::PopAndDestroy( &satCommandImplementations );
         
         // Notify TSY about readiness i.e. all nofies are sent
         // Done only once in startup phase
@@ -219,6 +244,8 @@
 
         // Create command handlers.
         RImplInfoPtrArray satCommandImplementations;
+        CleanupStack::PushL( 
+            TCleanupItem( CleanupPointerArray, &satCommandImplementations ) );
         REComSession::ListImplementationsL( KSatInterfaceDefinitionUid,
             satCommandImplementations );
 
@@ -253,7 +280,7 @@
             // No commands, remove SAT Icon from shell
             iSatUiHandler.ShellController().RemoveSatUiL();
             }
-        satCommandImplementations.ResetAndDestroy();
+        CleanupStack::PopAndDestroy( &satCommandImplementations );
         }
     else
         {
@@ -366,7 +393,7 @@
         iIsCmccSim = ETrue;
 
         // Update default name read in ConstructL.
-        TRAPD( err, CreateSatAppNameL( R_QTN_SAT_CMCC_TITLE ) );
+        TRAPD( err, CreateSatAppNameL( KSatCmccTitle ) );
         LOG2( NORMAL, "SATENGINE:   Error: %i", err )
         if ( KErrNone == err )
             {
@@ -598,7 +625,7 @@
         {
         LOG( NORMAL,
             "SATENGINE: CSatCommandContainer::RestoreSatAppNameL name reset" )
-        CreateSatAppNameL( R_QTN_SAT_LOG_TITLE );
+        CreateSatAppNameL( KSatLogTitle );
         }
     LOG( NORMAL, "SATENGINE: CSatCommandContainer::RestoreSatAppNameL exiting" )
     }
@@ -873,7 +900,7 @@
     LOG( NORMAL, "SATENGINE: CSatCommandContainer::ConstructL calling" )
 
     iIsCmccSim = EFalse;
-    CreateSatAppNameL( R_QTN_SAT_LOG_TITLE );
+    CreateSatAppNameL( KSatLogTitle );
 
     // Register for ui events in order to keep track if user or command
     // has launched the ui.
@@ -962,52 +989,22 @@
 // (other items were commented in a header).
 // -----------------------------------------------------------------------------
 //
-void CSatCommandContainer::CreateSatAppNameL( const TInt aResourceId )
+void CSatCommandContainer::CreateSatAppNameL( const TDesC& aResourceId )
     {
     LOG( NORMAL, "SATENGINE: CSatCommandContainer::CreateSatAppNameL calling" )
-
-    // Open the RFs session.
-    RFs fs;
-
-    User::LeaveIfError( fs.Connect() );
-
-    // Push close operation in tbe cleanup stack
-    CleanupClosePushL( fs );
-
-    RResourceFile resFile;
-    // Backslashes are already defined in resource file, not needed here.
-    TBuf<KSizeOfBuf> buf( KResourceDrive );
-    buf.Append( KDC_RESOURCE_FILES_DIR );
-    buf.Append( KSatServerRsc );
-
-    TFileName fileName( buf );
-
-    BaflUtils::NearestLanguageFile( fs, fileName );
-
-    // Open the resource file
-    resFile.OpenL( fs, fileName );
+    delete iSatAppName;
+    iSatAppName = NULL;
+    const TBool textResolver = HbTextResolverSymbian::Init( 
+        KSatServerRsc, KResourceDrive );
+    LOG2(NORMAL,"SATENGINE: CSatCommandContainer::\
+        CreateSatAppNameL textResolver = %d", textResolver ) 
+    LOG2(NORMAL,"SATENGINE: CSatCommandContainer::\
+        CreateSatAppNameL aResourceId = %S", &aResourceId )
 
-    // Push close operation in the cleanup stack
-    CleanupClosePushL( resFile );
-
-    resFile.ConfirmSignatureL( ESatSResourceSignature );
-
-    // Reads a resource structure with memory allocation.
-    HBufC8* dataBuffer = resFile.AllocReadLC( aResourceId );
-
-    TResourceReader resReader;
-    resReader.SetBuffer( dataBuffer );
-
-    // Reads a string with memory allocation
-    iSatAppName = resReader.ReadHBufCL();
+    iSatAppName = HbTextResolverSymbian::LoadL( aResourceId );
+    LOG2(NORMAL,"SATENGINE: CSatCommandContainer::\
+        CreateSatAppNameL iSatAppName = %S", iSatAppName )
     iSatBipName.Copy( SatAppName() );
-
-    // dataBuffer
-    CleanupStack::PopAndDestroy( dataBuffer );
-    // resFile, Calls resFile.Close()
-    // fs, Calls fs.Close
-    CleanupStack::PopAndDestroy( KCreateSatAppNamePop );
-
     LOG( NORMAL, "SATENGINE: CSatCommandContainer::CreateSatAppNameL exiting" )
     }
 
@@ -1085,9 +1082,11 @@
 
     // Create command handlers.
     RImplInfoPtrArray satCommandImplementations;
+    CleanupStack::PushL( 
+        TCleanupItem( CleanupPointerArray, &satCommandImplementations ) );
     REComSession::ListImplementationsL( KSatInterfaceDefinitionUid,
         satCommandImplementations );
-
+    
     // Container for commands
     const TInt cmdCount( satCommandImplementations.Count() );
     LOG2( NORMAL, "SATENGINE: CSatCommandContainer::\
@@ -1118,8 +1117,8 @@
             CleanupStack::Pop( setUpEventListCmd );
             }
         }
-
-    satCommandImplementations.Close();
+    
+    CleanupStack::PopAndDestroy( &satCommandImplementations );
     LOG( NORMAL, "SATENGINE: CSatCommandContainer::\
         StartImportantCommandHandlersL exiting" )
     }
@@ -1142,3 +1141,5 @@
         }
     LOG( NORMAL, "SATENGINE: CSatCommandContainer::CheckStartupState exiting" )
     }
+
+// End Of File