18 |
18 |
19 |
19 |
20 #include <f32file.h> |
20 #include <f32file.h> |
21 #include <barsc.h> |
21 #include <barsc.h> |
22 #include <bautils.h> |
22 #include <bautils.h> |
|
23 #include <SatServer.rsg> |
23 #include <ecom.h> |
24 #include <ecom.h> |
24 #include <e32property.h> |
25 #include <e32property.h> |
25 #include <data_caging_path_literals.hrh> |
26 #include <data_caging_path_literals.hrh> |
26 #include <startupdomainpskeys.h> |
27 #include <startupdomainpskeys.h> |
27 #include <satdomainpskeys.h> |
28 #include <satdomainpskeys.h> |
28 #include <hbtextresolversymbian.h> |
|
29 |
29 |
30 #include "MSatSystemState.h" |
30 #include "MSatSystemState.h" |
31 #include "TSatSystemStateFactory.h" |
31 #include "TSatSystemStateFactory.h" |
32 #include "MSatSystemStateChangeNotifier.h" |
32 #include "MSatSystemStateChangeNotifier.h" |
33 #include "CSatCommandContainer.h" |
33 #include "CSatCommandContainer.h" |
50 #include "csatprofilechangeobserver.h" |
50 #include "csatprofilechangeobserver.h" |
51 #include "SATInternalPSKeys.h" |
51 #include "SATInternalPSKeys.h" |
52 #include "csatmultimodeapi.h" |
52 #include "csatmultimodeapi.h" |
53 #include "csatsactivewrapper.h" |
53 #include "csatsactivewrapper.h" |
54 |
54 |
55 _LIT( KResourceDrive, "z:\\resource\\qt\\translations" ); |
55 // Drive letter for resource file |
56 _LIT( KSatServerRsc, "satapp_"); |
56 _LIT( KResourceDrive, "Z:" ); |
57 _LIT( KSatLogTitle, "txt_simatk_title_sim_services"); |
57 // SatServer's resource file |
58 _LIT( KSatCmccTitle, "txt_simatk_titlw_cmcc_sim_services"); |
58 _LIT( KSatServerRsc, "SatServer.rsc" ); |
|
59 |
59 |
60 |
60 const TUid KSatInterfaceDefinitionUid = { 0x1000f001 }; |
61 const TUid KSatInterfaceDefinitionUid = { 0x1000f001 }; |
61 const TInt KSizeOfBuf = 50; |
62 const TInt KSizeOfBuf = 50; |
62 |
63 |
|
64 const TInt8 KCreateSatAppNamePop( 2 ); |
63 |
65 |
64 // Important plugins UIDs. These are started on startup |
66 // Important plugins UIDs. These are started on startup |
65 // Implementation UID is from the <plugin>.rss |
67 // Implementation UID is from the <plugin>.rss |
66 const TUid KSetUpEventListUid = { 0x10202993 }; |
68 const TUid KSetUpEventListUid = { 0x10202993 }; |
67 |
|
68 // ======== LOCAL FUNCTIONS ======== |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CleanupPointerArray |
|
72 // Cleanup RPointerArray objects by using the cleanup stack. Function will be |
|
73 // called when application leaves while a RPointerArray object still alive, |
|
74 // or when CleanupStack::PopAndDestroy is explicitly called to release a |
|
75 // RPointerArray. See CleanupStack::PushL( TCleanupItem ) for more details. |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 static void CleanupPointerArray( TAny* aArray ) |
|
79 { |
|
80 LOG2( NORMAL, "SATENGINE: CSatCommandContainer::CleanupPointerArray \ |
|
81 calling array = 0x%08x", aArray ) |
|
82 |
|
83 RImplInfoPtrArray* array = reinterpret_cast<RImplInfoPtrArray*>( aArray ); |
|
84 if ( array ) |
|
85 { |
|
86 array->ResetAndDestroy(); |
|
87 } |
|
88 |
|
89 LOG( NORMAL, "SATENGINE: CSatCommandContainer::CleanupPointerArray \ |
|
90 exiting" ) |
|
91 } |
|
92 |
69 |
93 // ======== MEMBER FUNCTIONS ======== |
70 // ======== MEMBER FUNCTIONS ======== |
94 |
71 |
95 // ----------------------------------------------------------------------------- |
72 // ----------------------------------------------------------------------------- |
96 // CSatCommandContainer::NewL |
73 // CSatCommandContainer::NewL |
179 { |
156 { |
180 LOG( NORMAL, "SATENGINE: CSatCommandContainer::StartCommandHandlersL \ |
157 LOG( NORMAL, "SATENGINE: CSatCommandContainer::StartCommandHandlersL \ |
181 in startup phase" ) |
158 in startup phase" ) |
182 // Create command handlers. |
159 // Create command handlers. |
183 RImplInfoPtrArray satCommandImplementations; |
160 RImplInfoPtrArray satCommandImplementations; |
184 CleanupStack::PushL( |
|
185 TCleanupItem( CleanupPointerArray, &satCommandImplementations ) ); |
|
186 REComSession::ListImplementationsL( KSatInterfaceDefinitionUid, |
161 REComSession::ListImplementationsL( KSatInterfaceDefinitionUid, |
187 satCommandImplementations ); |
162 satCommandImplementations ); |
188 |
163 |
189 // Container for commands |
164 // Container for commands |
190 const TInt cmdCount( satCommandImplementations.Count() ); |
165 const TInt cmdCount( satCommandImplementations.Count() ); |
219 iCmdHandlers->AppendL( cmd ); |
194 iCmdHandlers->AppendL( cmd ); |
220 CleanupStack::Pop( cmd ); |
195 CleanupStack::Pop( cmd ); |
221 } |
196 } |
222 } |
197 } |
223 } |
198 } |
224 CleanupStack::PopAndDestroy( &satCommandImplementations ); |
199 satCommandImplementations.ResetAndDestroy(); |
225 |
200 |
226 // Notify TSY about readiness i.e. all nofies are sent |
201 // Notify TSY about readiness i.e. all nofies are sent |
227 // Done only once in startup phase |
202 // Done only once in startup phase |
228 TInt ret = iUSatAPI->UsatClientReadyIndication(); |
203 TInt ret = iUSatAPI->UsatClientReadyIndication(); |
229 LOG2( NORMAL, "SATENGINE: UsatClientReadyIndication() gives %d", ret ) |
204 LOG2( NORMAL, "SATENGINE: UsatClientReadyIndication() gives %d", ret ) |
242 User::LeaveIfError( iUSatAPI->Connect( *iMultiModeApi ) ); |
217 User::LeaveIfError( iUSatAPI->Connect( *iMultiModeApi ) ); |
243 } |
218 } |
244 |
219 |
245 // Create command handlers. |
220 // Create command handlers. |
246 RImplInfoPtrArray satCommandImplementations; |
221 RImplInfoPtrArray satCommandImplementations; |
247 CleanupStack::PushL( |
|
248 TCleanupItem( CleanupPointerArray, &satCommandImplementations ) ); |
|
249 REComSession::ListImplementationsL( KSatInterfaceDefinitionUid, |
222 REComSession::ListImplementationsL( KSatInterfaceDefinitionUid, |
250 satCommandImplementations ); |
223 satCommandImplementations ); |
251 |
224 |
252 // Container for commands |
225 // Container for commands |
253 const TInt cmdCount( satCommandImplementations.Count() ); |
226 const TInt cmdCount( satCommandImplementations.Count() ); |
278 LOG( NORMAL, "SATENGINE: CSatCommandContainer::\ |
251 LOG( NORMAL, "SATENGINE: CSatCommandContainer::\ |
279 StartCommandHandlersL No commands found" ) |
252 StartCommandHandlersL No commands found" ) |
280 // No commands, remove SAT Icon from shell |
253 // No commands, remove SAT Icon from shell |
281 iSatUiHandler.ShellController().RemoveSatUiL(); |
254 iSatUiHandler.ShellController().RemoveSatUiL(); |
282 } |
255 } |
283 CleanupStack::PopAndDestroy( &satCommandImplementations ); |
256 satCommandImplementations.ResetAndDestroy(); |
284 } |
257 } |
285 else |
258 else |
286 { |
259 { |
287 LOG( NORMAL, " Not starting any command handlers" ) |
260 LOG( NORMAL, " Not starting any command handlers" ) |
288 } |
261 } |
391 { |
364 { |
392 LOG( NORMAL, "SATENGINE: Event: ECmccSimDetected" ) |
365 LOG( NORMAL, "SATENGINE: Event: ECmccSimDetected" ) |
393 iIsCmccSim = ETrue; |
366 iIsCmccSim = ETrue; |
394 |
367 |
395 // Update default name read in ConstructL. |
368 // Update default name read in ConstructL. |
396 TRAPD( err, CreateSatAppNameL( KSatCmccTitle ) ); |
369 TRAPD( err, CreateSatAppNameL( R_QTN_SAT_CMCC_TITLE ) ); |
397 LOG2( NORMAL, "SATENGINE: Error: %i", err ) |
370 LOG2( NORMAL, "SATENGINE: Error: %i", err ) |
398 if ( KErrNone == err ) |
371 if ( KErrNone == err ) |
399 { |
372 { |
400 // Notify application name update. |
373 // Notify application name update. |
401 NotifyEvent( EApplNameUpdated ); |
374 NotifyEvent( EApplNameUpdated ); |
623 LOG( NORMAL, "SATENGINE: CSatCommandContainer::RestoreSatAppNameL calling" ) |
596 LOG( NORMAL, "SATENGINE: CSatCommandContainer::RestoreSatAppNameL calling" ) |
624 if ( !iIsCmccSim ) |
597 if ( !iIsCmccSim ) |
625 { |
598 { |
626 LOG( NORMAL, |
599 LOG( NORMAL, |
627 "SATENGINE: CSatCommandContainer::RestoreSatAppNameL name reset" ) |
600 "SATENGINE: CSatCommandContainer::RestoreSatAppNameL name reset" ) |
628 CreateSatAppNameL( KSatLogTitle ); |
601 CreateSatAppNameL( R_QTN_SAT_LOG_TITLE ); |
629 } |
602 } |
630 LOG( NORMAL, "SATENGINE: CSatCommandContainer::RestoreSatAppNameL exiting" ) |
603 LOG( NORMAL, "SATENGINE: CSatCommandContainer::RestoreSatAppNameL exiting" ) |
631 } |
604 } |
632 |
605 |
633 // ----------------------------------------------------------------------------- |
606 // ----------------------------------------------------------------------------- |
898 void CSatCommandContainer::ConstructL() |
871 void CSatCommandContainer::ConstructL() |
899 { |
872 { |
900 LOG( NORMAL, "SATENGINE: CSatCommandContainer::ConstructL calling" ) |
873 LOG( NORMAL, "SATENGINE: CSatCommandContainer::ConstructL calling" ) |
901 |
874 |
902 iIsCmccSim = EFalse; |
875 iIsCmccSim = EFalse; |
903 CreateSatAppNameL( KSatLogTitle ); |
876 CreateSatAppNameL( R_QTN_SAT_LOG_TITLE ); |
904 |
877 |
905 // Register for ui events in order to keep track if user or command |
878 // Register for ui events in order to keep track if user or command |
906 // has launched the ui. |
879 // has launched the ui. |
907 iEventMediator.RegisterL( this, MSatUtils::ESatUiClosed ); |
880 iEventMediator.RegisterL( this, MSatUtils::ESatUiClosed ); |
908 iEventMediator.RegisterL( this, MSatUtils::ECmccSimDetected ); |
881 iEventMediator.RegisterL( this, MSatUtils::ECmccSimDetected ); |
987 // ----------------------------------------------------------------------------- |
960 // ----------------------------------------------------------------------------- |
988 // CSatCommandContainer::CreateSatAppNameL |
961 // CSatCommandContainer::CreateSatAppNameL |
989 // (other items were commented in a header). |
962 // (other items were commented in a header). |
990 // ----------------------------------------------------------------------------- |
963 // ----------------------------------------------------------------------------- |
991 // |
964 // |
992 void CSatCommandContainer::CreateSatAppNameL( const TDesC& aResourceId ) |
965 void CSatCommandContainer::CreateSatAppNameL( const TInt aResourceId ) |
993 { |
966 { |
994 LOG( NORMAL, "SATENGINE: CSatCommandContainer::CreateSatAppNameL calling" ) |
967 LOG( NORMAL, "SATENGINE: CSatCommandContainer::CreateSatAppNameL calling" ) |
995 delete iSatAppName; |
968 |
996 iSatAppName = NULL; |
969 // Open the RFs session. |
997 const TBool textResolver = HbTextResolverSymbian::Init( |
970 RFs fs; |
998 KSatServerRsc, KResourceDrive ); |
971 |
999 LOG2(NORMAL,"SATENGINE: CSatCommandContainer::\ |
972 User::LeaveIfError( fs.Connect() ); |
1000 CreateSatAppNameL textResolver = %d", textResolver ) |
973 |
1001 LOG2(NORMAL,"SATENGINE: CSatCommandContainer::\ |
974 // Push close operation in tbe cleanup stack |
1002 CreateSatAppNameL aResourceId = %S", &aResourceId ) |
975 CleanupClosePushL( fs ); |
1003 |
976 |
1004 iSatAppName = HbTextResolverSymbian::LoadL( aResourceId ); |
977 RResourceFile resFile; |
1005 LOG2(NORMAL,"SATENGINE: CSatCommandContainer::\ |
978 // Backslashes are already defined in resource file, not needed here. |
1006 CreateSatAppNameL iSatAppName = %S", iSatAppName ) |
979 TBuf<KSizeOfBuf> buf( KResourceDrive ); |
|
980 buf.Append( KDC_RESOURCE_FILES_DIR ); |
|
981 buf.Append( KSatServerRsc ); |
|
982 |
|
983 TFileName fileName( buf ); |
|
984 |
|
985 BaflUtils::NearestLanguageFile( fs, fileName ); |
|
986 |
|
987 // Open the resource file |
|
988 resFile.OpenL( fs, fileName ); |
|
989 |
|
990 // Push close operation in the cleanup stack |
|
991 CleanupClosePushL( resFile ); |
|
992 |
|
993 resFile.ConfirmSignatureL( ESatSResourceSignature ); |
|
994 |
|
995 // Reads a resource structure with memory allocation. |
|
996 HBufC8* dataBuffer = resFile.AllocReadLC( aResourceId ); |
|
997 |
|
998 TResourceReader resReader; |
|
999 resReader.SetBuffer( dataBuffer ); |
|
1000 |
|
1001 // Reads a string with memory allocation |
|
1002 iSatAppName = resReader.ReadHBufCL(); |
1007 iSatBipName.Copy( SatAppName() ); |
1003 iSatBipName.Copy( SatAppName() ); |
|
1004 |
|
1005 // dataBuffer |
|
1006 CleanupStack::PopAndDestroy( dataBuffer ); |
|
1007 // resFile, Calls resFile.Close() |
|
1008 // fs, Calls fs.Close |
|
1009 CleanupStack::PopAndDestroy( KCreateSatAppNamePop ); |
|
1010 |
1008 LOG( NORMAL, "SATENGINE: CSatCommandContainer::CreateSatAppNameL exiting" ) |
1011 LOG( NORMAL, "SATENGINE: CSatCommandContainer::CreateSatAppNameL exiting" ) |
1009 } |
1012 } |
1010 |
1013 |
1011 // ----------------------------------------------------------------------------- |
1014 // ----------------------------------------------------------------------------- |
1012 // CSatCommandContainer::CreateAndGetBIPUtilsL |
1015 // CSatCommandContainer::CreateAndGetBIPUtilsL |
1080 LOG( NORMAL, "SATENGINE: CSatCommandContainer::\ |
1083 LOG( NORMAL, "SATENGINE: CSatCommandContainer::\ |
1081 StartImportantCommandHandlersL calling" ) |
1084 StartImportantCommandHandlersL calling" ) |
1082 |
1085 |
1083 // Create command handlers. |
1086 // Create command handlers. |
1084 RImplInfoPtrArray satCommandImplementations; |
1087 RImplInfoPtrArray satCommandImplementations; |
1085 CleanupStack::PushL( |
|
1086 TCleanupItem( CleanupPointerArray, &satCommandImplementations ) ); |
|
1087 REComSession::ListImplementationsL( KSatInterfaceDefinitionUid, |
1088 REComSession::ListImplementationsL( KSatInterfaceDefinitionUid, |
1088 satCommandImplementations ); |
1089 satCommandImplementations ); |
1089 |
1090 |
1090 // Container for commands |
1091 // Container for commands |
1091 const TInt cmdCount( satCommandImplementations.Count() ); |
1092 const TInt cmdCount( satCommandImplementations.Count() ); |
1092 LOG2( NORMAL, "SATENGINE: CSatCommandContainer::\ |
1093 LOG2( NORMAL, "SATENGINE: CSatCommandContainer::\ |
1093 StartImportantCommandHandlersL Command handler count: %d", cmdCount ) |
1094 StartImportantCommandHandlersL Command handler count: %d", cmdCount ) |
1094 |
1095 |
1115 CleanupStack::PushL( setUpEventListCmd ); |
1116 CleanupStack::PushL( setUpEventListCmd ); |
1116 iCmdHandlers->AppendL( setUpEventListCmd ); |
1117 iCmdHandlers->AppendL( setUpEventListCmd ); |
1117 CleanupStack::Pop( setUpEventListCmd ); |
1118 CleanupStack::Pop( setUpEventListCmd ); |
1118 } |
1119 } |
1119 } |
1120 } |
1120 |
1121 |
1121 CleanupStack::PopAndDestroy( &satCommandImplementations ); |
1122 satCommandImplementations.Close(); |
1122 LOG( NORMAL, "SATENGINE: CSatCommandContainer::\ |
1123 LOG( NORMAL, "SATENGINE: CSatCommandContainer::\ |
1123 StartImportantCommandHandlersL exiting" ) |
1124 StartImportantCommandHandlersL exiting" ) |
1124 } |
1125 } |
1125 |
1126 |
1126 // ----------------------------------------------------------------------------- |
1127 // ----------------------------------------------------------------------------- |