telephonyserverplugins/common_tsy/phonetsy/src/cmmphonefactorytsy.cpp
changeset 49 f50f4094acd7
parent 42 3adadc800673
child 62 8ef833fbf5aa
equal deleted inserted replaced
48:14460bf2a402 49:f50f4094acd7
    14 // INCLUDE FILES
    14 // INCLUDE FILES
    15 //
    15 //
    16 
    16 
    17 
    17 
    18 
    18 
    19 
       
    20 #include "OstTraceDefinitions.h"
    19 #include "OstTraceDefinitions.h"
    21 #ifdef OST_TRACE_COMPILER_IN_USE
    20 #ifdef OST_TRACE_COMPILER_IN_USE
    22 #include "cmmphonefactorytsyTraces.h"
    21 #include "cmmphonefactorytsyTraces.h"
    23 #endif
    22 #endif
    24 
       
    25 #include <featmgr/featurecontrol.h>
    23 #include <featmgr/featurecontrol.h>
    26 #include <featureuids.h>
    24 #include <featureuids.h>
    27 
    25 
       
    26 #include <ctsy/mmtsy_names.h>
       
    27 #include <ctsy/serviceapi/ctsysatmessagingbase.h>
       
    28 
       
    29 #include "cmmmessagemanagerbase.h"
    28 #include "cmmphonefactorytsy.h"
    30 #include "cmmphonefactorytsy.h"
    29 #include "cmmphonetsy.h"
    31 #include "cmmphonetsy.h"
    30 #include <ctsy/mmtsy_names.h>
       
    31 #include "MmTsy_conf.h"
    32 #include "MmTsy_conf.h"
    32 #include "cmmmessagemanagerbase.h"
    33 
    33 #include <ctsy/serviceapi/ctsysatmessagingbase.h>
    34 _LIT(KLtsyIniFile, "ltsydata.ini");
    34 
    35 
    35 #ifdef USING_CTSY_DISPATCHER
    36 #ifdef USING_CTSY_DISPATCHER
    36 _LIT(KLicenseeTsyDllName, "licenseetsy.dll");
    37 _LIT(KDefaultLicenseeTsyDllName, "ctsydispatcher.dll");
    37 _LIT(KCtsyDispatcherDllName, "ctsydispatcher.dll");
    38 const TInt KDefaultLicenseeTsyUID3 =  0x10285C38;
    38 
    39 #else
    39 const TInt KLicenseeTsyUID3 = 0x2000BEE4;
    40 _LIT(KDefaultLicenseeTsyDllName, "licenseetsy.dll");
    40 const TInt KCtsyDispatcherUID3 =  0x10285C38;
    41 const TInt KDefaultLicenseeTsyUID3 = 0x2000BEE4;
       
    42 #endif //USING_CTSY_DISPATCHER
    41 
    43 
    42 typedef MLtsyFactoryBase*(*TFactoryBaseNewL)();
    44 typedef MLtsyFactoryBase*(*TFactoryBaseNewL)();
    43 
    45 
    44 #endif //USING_CTSY_DISPATCHER
       
    45 // ======== MEMBER FUNCTIONS ========
    46 // ======== MEMBER FUNCTIONS ========
    46 
    47 
    47 CMmPhoneFactoryTsy::CMmPhoneFactoryTsy()
    48 CMmPhoneFactoryTsy::CMmPhoneFactoryTsy()
    48     {
    49     {
    49     // Version numbers defined in ETEL.h
    50     // Version numbers defined in ETEL.h
    66     {
    67     {
    67     }
    68     }
    68 
    69 
    69 CMmPhoneFactoryTsy::~CMmPhoneFactoryTsy()
    70 CMmPhoneFactoryTsy::~CMmPhoneFactoryTsy()
    70     {
    71     {
    71 #ifdef USING_CTSY_DISPATCHER
       
    72     iLoadedLib.Close();
    72     iLoadedLib.Close();
    73 #endif //USING_CTSY_DISPATCHER
    73     }
    74 	}
       
    75 
    74 
    76 // ---------------------------------------------------------------------------
    75 // ---------------------------------------------------------------------------
    77 // CMmPhoneFactoryTsy::NewPhoneL
    76 // CMmPhoneFactoryTsy::NewPhoneL
    78 // Creates a new phone object instance
    77 // Creates a new phone object instance
    79 // (other items were commented in a header).
    78 // (other items were commented in a header).
    86     iPhoneTsy = NULL;
    85     iPhoneTsy = NULL;
    87 
    86 
    88     // In case of debug build, print flag info.
    87     // In case of debug build, print flag info.
    89 #ifdef TF_LOGGING_ENABLED
    88 #ifdef TF_LOGGING_ENABLED
    90     
    89     
    91 	RFeatureControl featureControl;
    90     RFeatureControl featureControl;
    92 	TInt err = featureControl.Open();
    91     TInt err = featureControl.Open();
    93 	if (err != KErrNone)
    92     if (err != KErrNone)
    94 		{
    93         {
    95 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEFACTORYTSY_NEWPHONEL_2, "CMmPhoneFactoryTsy::NewPhoneL - failed to connect to FeatMgr");
    94 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEFACTORYTSY_NEWPHONEL_2, "CMmPhoneFactoryTsy::NewPhoneL - failed to connect to FeatMgr");
    96 		}
    95         }
    97 	else if (featureControl.FeatureSupported(NFeature::KCsVideoTelephony) == KFeatureSupported) 
    96     else if (featureControl.FeatureSupported(NFeature::KCsVideoTelephony) == KFeatureSupported) 
    98         {
    97         {
    99 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEFACTORYTSY_NEWPHONEL_3, "TSY: __CS_VIDEO_TELEPHONY -flag is on");
    98 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEFACTORYTSY_NEWPHONEL_3, "TSY: __CS_VIDEO_TELEPHONY -flag is on");
   100         }
    99         }
   101 	else if (featureControl.FeatureSupported(NFeature::KEmergencyCallsEnabledInOfflineMode) == KFeatureSupported)
   100     else if (featureControl.FeatureSupported(NFeature::KEmergencyCallsEnabledInOfflineMode) == KFeatureSupported)
   102         {
   101         {
   103 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEFACTORYTSY_NEWPHONEL_4, "TSY: __COMMON_TSY__EMERGENCY_CALLS_ENABLED_IN_OFFLINE_MODE -flag is on");
   102 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEFACTORYTSY_NEWPHONEL_4, "TSY: __COMMON_TSY__EMERGENCY_CALLS_ENABLED_IN_OFFLINE_MODE -flag is on");
   104         }
   103         }
   105 
   104 
   106 	featureControl.Close();
   105     featureControl.Close();
   107 #endif
   106 #endif
   108 	
   107     
   109     // Check if the Phone Name is OK
   108     // Check if the Phone Name is OK
   110     if ( KErrNone == aName.CompareF( KMmTsyPhoneName ) )
   109     if ( KErrNone == aName.CompareF( KMmTsyPhoneName ) )
   111         {
   110         {
   112         iMessageRouter = NULL;
   111         iMessageRouter = NULL;
   113 
   112                 
   114         // Create Message Manager (the 'core' of the LTSY Plug-in API)
   113         // Dynamic loading of LTSY
   115         CMmMessageManagerBase* messageManager = CMmMessageManagerBase::NewL();
   114         iLtsyFactory = LoadLibraryL();
   116         if ( messageManager )
       
   117             {
       
   118 	        CleanupStack::PushL( messageManager );
       
   119         
       
   120             // LTSY Plug-in API successfully created
       
   121 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEFACTORYTSY_NEWPHONEL_5, "TSY: CMmPhoneFactoryTsy::NewL - Starting to open LicenceeTSY");
       
   122             
       
   123             // get TSY message manager callback object
       
   124             MmMessageManagerCallback* callBack = 
       
   125                 messageManager->GetMessageManagerCallback();
       
   126             
       
   127 #ifdef USING_CTSY_DISPATCHER
       
   128             iLtsyFactory = LoadLibraryL();
       
   129 #else
       
   130             // library entry for LTSY, get base factory object
       
   131             iLtsyFactory = LTsyFactoryL();
       
   132             
       
   133 #endif //USING_CTSY_DISPATCHER
       
   134 
       
   135             if( iLtsyFactory )
       
   136                 {
       
   137                 // Get message router from LTSY. All current interface versions
       
   138                 // have the same GetMessageRouter defined in version 1.
       
   139                 MLtsyFactoryV1* ptr_v1 = 
       
   140                 	static_cast<MLtsyFactoryV1*>( iLtsyFactory );
       
   141                         
       
   142                 iMessageRouter = ptr_v1->GetMessageRouter( *callBack );
       
   143 		        User::LeaveIfNull( iMessageRouter );
       
   144         
       
   145 		        // Licencee Tsy successfully created
       
   146 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEFACTORYTSY_NEWPHONEL_6, "TSY: CMmPhoneFactoryTsy::NewL -  LicenceeTSY successfully opened");
       
   147 
       
   148 	            // set the pointer to the message router object
       
   149 	            messageManager->SetMessageRouter( iMessageRouter );
       
   150 
       
   151 	            // Ownership of messageManager passed to iPhoneTsy.
       
   152                 CleanupStack::Pop( messageManager );
       
   153 	            // Create Phone Tsy (which creates the whole Common TSY)
       
   154 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEFACTORYTSY_NEWPHONEL_7, "TSY: CMmPhoneFactoryTsy::NewL - Starting to open CommonTSY");
       
   155 	            iPhoneTsy = CMmPhoneTsy::NewL( 
       
   156 	                messageManager, this, iLtsyFactory );
       
   157 
       
   158 	            if ( iPhoneTsy )
       
   159 	                {
       
   160 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEFACTORYTSY_NEWPHONEL_8, "TSY: CMmPhoneFactoryTsy::NewL - CommonTSY successfully opened");
       
   161 	                messageManager->SetPhoneTsy( iPhoneTsy );
       
   162 	                }
       
   163                 }
       
   164             else
       
   165             	{
       
   166     	        CleanupStack::PopAndDestroy( messageManager );
       
   167             	}
       
   168             }
       
   169         }
   115         }
   170 
   116 
   171     return iPhoneTsy;
   117     return iPhoneTsy;
   172     }
   118     }
   173 
   119 
   292     CTsySatMessagingBase* satMessaging = NULL;
   238     CTsySatMessagingBase* satMessaging = NULL;
   293     
   239     
   294     if ( KErrNone == aName.CompareF( KSatToolkit ) )
   240     if ( KErrNone == aName.CompareF( KSatToolkit ) )
   295         {
   241         {
   296 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEFACTORYTSY_NEWSIMATK_1, "TSY: CMmPhoneFactoryTsy::NewSimAtk - Starting to open SimAtkTSY");
   242 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEFACTORYTSY_NEWSIMATK_1, "TSY: CMmPhoneFactoryTsy::NewSimAtk - Starting to open SimAtkTSY");
   297 
   243        
   298         if( iLtsyFactory )
   244         if (iLtsyFactory == NULL)
       
   245             {
       
   246             TRAP_IGNORE(iLtsyFactory = LoadLibraryL());
       
   247             }
       
   248         
       
   249         if (iLtsyFactory != NULL)
   299             {
   250             {
   300             // Get SIM ATK TSY messaging service from LicenseeTsy
   251             // Get SIM ATK TSY messaging service from LicenseeTsy
   301             MLtsyFactoryV1* ptr_v1 = 
   252             MLtsyFactoryV1* ptr_v1 = static_cast<MLtsyFactoryV1*>( iLtsyFactory );
   302             	static_cast<MLtsyFactoryV1*>( iLtsyFactory );
       
   303      
   253      
   304 #ifdef USING_CTSY_DISPATCHER     	
   254 #ifdef USING_CTSY_DISPATCHER        
   305            	satMessaging = ptr_v1->GetSatMessagingService( 
   255             satMessaging = ptr_v1->GetSatMessagingService(iPhoneTsy->SmsService());
   306             	iPhoneTsy->SmsService() );
       
   307 #else
   256 #else
   308            	satMessaging = ptr_v1->GetSatMessagingService( );
   257             satMessaging = ptr_v1->GetSatMessagingService( );
   309 #endif
   258 #endif
   310             }
   259             }        
   311         }
   260         }
   312 
   261 
   313     return satMessaging;
   262     return satMessaging;
   314     }
   263     }
   315 
   264 
   342     return factory; 
   291     return factory; 
   343     }
   292     }
   344 
   293 
   345 #ifdef USING_CTSY_DISPATCHER
   294 #ifdef USING_CTSY_DISPATCHER
   346 TBool CMmPhoneFactoryTsy::UsingCtsyDispatcher()
   295 TBool CMmPhoneFactoryTsy::UsingCtsyDispatcher()
   347 	{
   296 /**
   348 	//function to determine whether the setup is using the CTSY Dispatcher layer.
   297  * Function to determine whether the setup is using the CTSY Dispatcher layer.
       
   298  */
       
   299     {
       
   300     return ETrue; 
       
   301     }
       
   302 #endif //USING_CTSY_DISPATCHER
       
   303 
       
   304 // ---------------------------------------------------------------------------
       
   305 // CMmPhoneFactoryTsy::LoadLibraryL
       
   306 // Dynamically loads a LTSY.
       
   307 // ---------------------------------------------------------------------------
       
   308 //
       
   309 MLtsyFactoryBase* CMmPhoneFactoryTsy::LoadLibraryL()
       
   310     {
       
   311     TPtrC ltsyDllName(0, NULL);
       
   312     TUint ltsyDllUid = 0;
       
   313     
   349 #ifdef USING_CTSY_DISPATCHER 
   314 #ifdef USING_CTSY_DISPATCHER 
   350 	return ETrue; 
   315     ltsyDllName.Set(KDefaultLicenseeTsyDllName);
       
   316     ltsyDllUid = KDefaultLicenseeTsyUID3; 
   351 #else
   317 #else
   352 	return EFalse;
   318     RBuf configData;
       
   319     CleanupClosePushL(configData);
       
   320     
       
   321     TRAPD(ret,
       
   322           {
       
   323           ReadConfigFileL(&configData);
       
   324           ltsyDllName.Set(ReadDllNameFromConfigL(configData));
       
   325           ltsyDllUid = ReadDllUidFromConfigL(configData);
       
   326           });
       
   327     
       
   328     if (ret != KErrNone)
       
   329         {
       
   330         ltsyDllName.Set(KDefaultLicenseeTsyDllName);
       
   331         ltsyDllUid = KDefaultLicenseeTsyUID3;
       
   332 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_ERROR, CMMPHONEFACTORYTSY_LOADLIBRARYL_1A, "TSY: Failed to load LTSY dll details from ini (error: %d), using defaults", ret);
       
   333         }
   353 #endif
   334 #endif
   354 	}
   335     
   355 
   336 OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEFACTORYTSY_LOADLIBRARYL_1, "TSY: CMmPhoneFactoryTsy::LoadLibraryL - Loading Dll=%S, UID3=0x%8X", ltsyDllName, ltsyDllUid);
   356 MLtsyFactoryBase* CMmPhoneFactoryTsy::LoadLibraryL()
   337     User::LeaveIfError(iLoadedLib.Load(ltsyDllName));
   357 	{
   338     
   358 	//load library.  This can either be LicenseeTsy or CtsyDispatcher dlls
   339 #ifndef USING_CTSY_DISPATCHER
   359 	TPtrC dllname;
   340     CleanupStack::PopAndDestroy();  // configData
   360 	TInt uid3_int;
   341 #endif
   361 	if(UsingCtsyDispatcher())
   342     
   362 		{
   343     // Check the Uid3 is as expected
   363 		dllname.Set(KCtsyDispatcherDllName);
   344     if (iLoadedLib.Type()[2] != TUid::Uid(ltsyDllUid))
   364 		uid3_int = KCtsyDispatcherUID3;
   345         {
   365 		}
   346         User::Leave(KErrBadLibraryEntryPoint);
   366 	else
   347         }
   367 		{
   348     
   368 		dllname.Set(KLicenseeTsyDllName);
   349     TFactoryBaseNewL libEntry = reinterpret_cast<TFactoryBaseNewL>(iLoadedLib.Lookup(1));   
   369 		uid3_int = KLicenseeTsyUID3;
   350     MLtsyFactoryBase* factory = (*libEntry)();    // libEntry may leave.
   370 		}
   351     User::LeaveIfNull(factory);
   371 	
   352     
   372 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEFACTORYTSY_LOADLIBRARYL_1, "TSY: CMmPhoneFactoryTsy::LoadLibraryL - Loading Dll=%S, UID3=0x%8X", dllname, (TUint)uid3_int);
   353     InitCtsyL(factory);
   373 	
   354     
   374 	TUidType uid(KNullUid, KNullUid, TUid::Uid(uid3_int));
   355 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEFACTORYTSY_LOADLIBRARYL_2, "TSY: Loaded LTSY");
   375 	
   356     return factory;
   376 	User::LeaveIfError(iLoadedLib.Load(dllname));
   357     }
   377 	
   358 
   378 	// Check the Uid3 is as expected
   359 void CMmPhoneFactoryTsy::InitCtsyL(MLtsyFactoryBase* aLtsyFactory)
   379 	if(iLoadedLib.Type()[2]!=TUid::Uid(uid3_int))
   360 /**
   380 		User::Leave(KErrBadLibraryEntryPoint);
   361  * Initialises iPhoneTsy
   381 	
   362  */
   382 	TFactoryBaseNewL libEntry=(TFactoryBaseNewL)iLoadedLib.Lookup(1);	
   363     {    
   383 	MLtsyFactoryBase* factory=(*libEntry)();	// libEntry may leave.
   364     if (iPhoneTsy != NULL)
   384 	
   365         {
   385 	return factory;
   366         return;
   386 	}
   367         }
   387 #endif //USING_CTSY_DISPATCHER
   368     
   388 
   369     // Create Message Manager (the 'core' of the LTSY Plug-in API)
   389 //  End of File
   370     CMmMessageManagerBase* messageManager = CMmMessageManagerBase::NewL();
   390 
   371     User::LeaveIfNull(messageManager);
   391 
   372     CleanupStack::PushL( messageManager );
       
   373 
       
   374     // get TSY message manager callback object
       
   375     MmMessageManagerCallback* callBack = 
       
   376         messageManager->GetMessageManagerCallback();
       
   377 
       
   378     // Get message router from LTSY. All current interface versions
       
   379     // have the same GetMessageRouter defined in version 1.
       
   380     MLtsyFactoryV1* ptr_v1 = 
       
   381          static_cast<MLtsyFactoryV1*>( aLtsyFactory );
       
   382              
       
   383     iMessageRouter = ptr_v1->GetMessageRouter( *callBack );
       
   384     User::LeaveIfNull( iMessageRouter );
       
   385     
       
   386     // set the pointer to the message router object
       
   387     messageManager->SetMessageRouter( iMessageRouter );
       
   388 
       
   389     // Ownership of messageManager to be passed to iPhoneTsy.
       
   390     CleanupStack::Pop( messageManager );
       
   391     
       
   392     // LTSY Plug-in API successfully created
       
   393 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEFACTORYTSY_INITLTSYL_1, "TSY: CMmPhoneFactoryTsy::NewL - Starting to open CommonTSY");
       
   394     // Create Phone Tsy (which creates the whole Common TSY)
       
   395     iPhoneTsy = CMmPhoneTsy::NewL(messageManager, this, aLtsyFactory);
       
   396 
       
   397     if (iPhoneTsy != NULL)
       
   398         {
       
   399         // Licencee Tsy successfully created
       
   400 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_NORMAL, CMMPHONEFACTORYTSY_INITLTSYL_2, "TSY: CMmPhoneFactoryTsy::NewL -  CommonTSY successfully opened");
       
   401         messageManager->SetPhoneTsy( iPhoneTsy );
       
   402         }
       
   403     else
       
   404         {
       
   405 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_WARNING, CMMPHONEFACTORYTSY_INITLTSYL_3, "TSY: CMmPhoneFactoryTsy::NewL - CommonTSY not opened");
       
   406         }
       
   407     }
       
   408 
       
   409 TPtrC CMmPhoneFactoryTsy::ReadDllNameFromConfigL(const TDesC& aConfigData)
       
   410     {
       
   411     _LIT(KLicenseeTsyDllKeyName, "LicenseeTsyDllName");
       
   412     TPtrC dllName = GetValueForKeyL(aConfigData, KLicenseeTsyDllKeyName);
       
   413 OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEFACTORYTSY_READDLLNAMEFROMCONFIGL_1, "TSY: Config file: LTSY DLL name = %S", dllName);
       
   414     return dllName;
       
   415     }
       
   416 
       
   417 TUint CMmPhoneFactoryTsy::ReadDllUidFromConfigL(const TDesC& aConfigData)
       
   418     {
       
   419     _LIT(KLicenseeTsyUid3, "LicenseeTsyUid3");
       
   420 
       
   421     const TDesC& rawUid = GetValueForKeyL(aConfigData, KLicenseeTsyUid3);
       
   422     // only take the right 8 characters (ie discard the "0x")
       
   423     ASSERT(rawUid.Length() >= 8);
       
   424     TLex lex(rawUid.Right(8));   
       
   425     TUint uid;
       
   426     User::LeaveIfError(lex.Val(uid, EHex));
       
   427 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEFACTORYTSY_READUIDFROMCONFIGL_1, "TSY: Config file: LTSY UID3 = 0x%x", uid);
       
   428     return uid;
       
   429     }
       
   430 
       
   431 /*static*/
       
   432 void CMmPhoneFactoryTsy::ReadConfigFileL(RBuf* aConfigData)
       
   433 /**
       
   434  * Reads config file from system drive or, if not present, from ROM
       
   435  *
       
   436  * @param aConfigData This buffer gets created and has the ini file contents loaded into it
       
   437  */
       
   438     {
       
   439     RFs fs;
       
   440     User::LeaveIfError(fs.Connect());
       
   441     CleanupClosePushL(fs);
       
   442 
       
   443 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEFACTORYTSY_READCONFIGFILE_1, "TSY: Trying to load from %d (C) drive", fs.GetSystemDrive());
       
   444     fs.SetSessionToPrivate(fs.GetSystemDrive());
       
   445 
       
   446     RFile configFile;
       
   447     TInt ret = configFile.Open(fs, KLtsyIniFile, EFileShareExclusive);
       
   448     if (ret == KErrNotFound)
       
   449         {
       
   450 OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEFACTORYTSY_READCONFIGFILE_2, "TSY: Trying to load ini from %d (Z) drive, as read for system drive returned error %d", EDriveZ, ret);
       
   451         User::LeaveIfError(fs.SetSessionToPrivate(EDriveZ));
       
   452         User::LeaveIfError(configFile.Open(fs, KLtsyIniFile, EFileShareExclusive));
       
   453         }
       
   454 
       
   455 OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEFACTORYTSY_READCONFIGFILE_3, "TSY: Reading ini file %S", KLtsyIniFile);
       
   456     
       
   457     CleanupClosePushL(configFile);
       
   458 
       
   459     TInt configFileSize;
       
   460     User::LeaveIfError(configFile.Size(configFileSize));
       
   461 
       
   462     RBuf8 fileBuf;
       
   463     fileBuf.Create(configFileSize);
       
   464     CleanupClosePushL(fileBuf);
       
   465     User::LeaveIfError(configFile.Read(fileBuf));
       
   466 
       
   467     aConfigData->CreateL(configFileSize);
       
   468     aConfigData->Copy(fileBuf);
       
   469 
       
   470     CleanupStack::PopAndDestroy(3, &fs); // fs, configFile, fileBuf
       
   471     }
       
   472 
       
   473 /*static*/
       
   474 TPtrC CMmPhoneFactoryTsy::GetValueForKeyL(const TDesC& aKeysValues, const TDesC& aKey)
       
   475 /**
       
   476  * Gets the value for a specified key. The expected format is
       
   477  * <pre>
       
   478  * key1 value1
       
   479  * key2 value2
       
   480  * </pre>
       
   481  * 
       
   482  * However the parsing is flexible enough to allow "key1 =value1" as it allows an equals separator and extra whitespace
       
   483  * The value cannot include whitespace, even if quoted.
       
   484  */
       
   485     {
       
   486     // this matches the bracket expression in this regexp: \w+\s*=?\s*(\w+)[\s$]
       
   487     TInt startOfKey = aKeysValues.Find(aKey);
       
   488     TLex valueExtractor(aKeysValues);
       
   489     valueExtractor.Inc(startOfKey + aKey.Length());
       
   490     valueExtractor.SkipSpaceAndMark();
       
   491     // allow equals separating key and value
       
   492     if (valueExtractor.Peek() == '=')
       
   493         {
       
   494         valueExtractor.Inc();
       
   495         valueExtractor.SkipSpaceAndMark();
       
   496         }
       
   497     
       
   498     TPtrC value = valueExtractor.NextToken();
       
   499     __ASSERT_ALWAYS(value.Length() > 0, User::Leave(KErrCorrupt));
       
   500     return value;
       
   501     }